Skip to content

Commit

Permalink
4.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
AV306 committed Oct 10, 2023
1 parent c0ac4af commit a3f3ebd
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 58 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
# check these on https://fabricmc.net/versions.html
minecraft_version = 1.20.2
yarn_mappings = 1.20.2+build.1
loader_version = 0.14.22
loader_version = 0.14.23

# Fabric api
fabric_version = 0.89.2+1.20.2

# Mod Properties
mod_version = 4.2.0+1.20.2
mod_version = 4.2.1+1.20.2
maven_group = me.av306
archives_base_name = xenon

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,37 @@
@ConfigEntries( includeAll = true )
public class ProximityRadarGroup implements XenonConfigGroup
{
@ConfigEntry.BoundedInteger( min = 1, max = 100 )
public static int range = 3;

/*@ConfigEntry.BoundedInteger( min = 1, max = 10 )
@ConfigEntry.Slider
public static int lineThickness = 2;*/
@ConfigEntry.BoundedInteger( min = 1, max = 1000 )
public static int playerRange = 64;

@ConfigEntry.BoundedInteger( min = 1, max = 1000 )
public static int hostileRange = 20;

@ConfigEntry.BoundedInteger( min = 1, max = 1000 )
public static int itemRange = 5;


@ConfigEntry.Boolean
public static boolean showBox = true;
public static boolean showPlayerBox = true;

@ConfigEntry.Boolean
public static boolean showTracer = true;
public static boolean showPlayerTracer = true;


@ConfigEntry.Boolean
public static boolean detectItems = true;
public static boolean showHostileBox = true;

@ConfigEntry.Boolean
public static boolean detectPlayers = true;
public static boolean showHostileTracer = true;


@ConfigEntry.Boolean
public static boolean showItemBox = true;

@ConfigEntry.Boolean
public static boolean showItemTracer = true;


@ConfigEntry.Color( alphaMode = false )
public static Color playerBoxColor = Color.ofRGB( 255, 255, 255 );
Expand All @@ -35,5 +48,4 @@ public class ProximityRadarGroup implements XenonConfigGroup

@ConfigEntry.Color( alphaMode = false )
public static Color itemBoxColor = Color.ofRGB( 116, 190, 207 );

}
6 changes: 3 additions & 3 deletions src/main/java/me/av306/xenon/feature/IToggleableFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected IToggleableFeature( String name )

this.enabledText = TextFactory.createTranslatable( "text.xenon.itoggleablefeature.enabled", name )
.formatted( Xenon.INSTANCE.SUCCESS_FORMAT );
this.disabledText = TextFactory.createLiteral( "text.xenon.itoggleablefeature.disabled", name )
this.disabledText = TextFactory.createTranslatable( "text.xenon.itoggleablefeature.disabled", name )
.formatted( Xenon.INSTANCE.SUCCESS_FORMAT );
}

Expand All @@ -48,7 +48,7 @@ protected IToggleableFeature( String name, String... aliases )

this.enabledText = TextFactory.createTranslatable( "text.xenon.itoggleablefeature.enabled", name )
.formatted( Xenon.INSTANCE.SUCCESS_FORMAT );
this.disabledText = TextFactory.createLiteral( "text.xenon.itoggleablefeature.disabled", name )
this.disabledText = TextFactory.createTranslatable( "text.xenon.itoggleablefeature.disabled", name )
.formatted( Xenon.INSTANCE.SUCCESS_FORMAT );
}

Expand All @@ -58,7 +58,7 @@ protected IToggleableFeature( String name, int key )

this.enabledText = TextFactory.createTranslatable( "text.xenon.itoggleablefeature.enabled", name )
.formatted( Xenon.INSTANCE.SUCCESS_FORMAT );
this.disabledText = TextFactory.createLiteral( "text.xenon.itoggleablefeature.disabled", name )
this.disabledText = TextFactory.createTranslatable( "text.xenon.itoggleablefeature.disabled", name )
.formatted( Xenon.INSTANCE.SUCCESS_FORMAT );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

public class ProximityRadarFeature extends IToggleableFeature
{
private double closestDistance = ProximityRadarGroup.range;
private static final double MAX_POSSIBLE_DISTANCE = Math.max( Math.max( ProximityRadarGroup.playerRange, ProximityRadarGroup.hostileRange ), ProximityRadarGroup.itemRange );
private double closestDistance = MAX_POSSIBLE_DISTANCE;
private EntityScanResult type = EntityScanResult.NONE;

public ProximityRadarFeature()
Expand Down Expand Up @@ -51,19 +52,22 @@ private ActionResult scanEntities( MatrixStack matrices )
{
// FIXME: figure out how to optimise this

// Only run the scan if the feature is enabled and essential stuff isn't null
if (
this.isEnabled
&& Xenon.INSTANCE.client.world != null && Xenon.INSTANCE.client.player != null
)
{
// GL stuff
// Makes the lines appear on top of everything
GL11.glEnable( GL11.GL_BLEND );
GL11.glBlendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA );
GL11.glEnable( GL11.GL_LINE_SMOOTH );
GL11.glClear( GL11.GL_DEPTH_BUFFER_BIT );

matrices.push();

// Idk what this does
RenderUtil.applyRenderOffset( matrices );

// Scan each entity
Expand Down Expand Up @@ -97,10 +101,11 @@ private ActionResult scanEntities( MatrixStack matrices )

// Reset the closest detected distance and type
this.type = EntityScanResult.NONE;
this.closestDistance = ProximityRadarGroup.range;
this.closestDistance = MAX_POSSIBLE_DISTANCE;

matrices.pop();

// Reset GL stuff
GL11.glDisable( GL11.GL_BLEND );
GL11.glDisable( GL11.GL_LINE_SMOOTH );

Expand All @@ -119,60 +124,46 @@ private ActionResult scanEntities( MatrixStack matrices )
*/
private void scanEntityAndRenderHighlight( MatrixStack matrices, Entity entity )
{
final int range = ProximityRadarGroup.range;

// Grab entity data
Vec3d entityPos = entity.getPos();
Vec3d clientPos = Xenon.INSTANCE.client.player.getPos();
double distance = entityPos.distanceTo( clientPos );

if ( distance < range )
if ( entity instanceof PlayerEntity && distance < ProximityRadarGroup.playerRange )
{
if ( entity instanceof HostileEntity )
if ( distance < closestDistance )
{
if ( distance < closestDistance )
{
closestDistance = distance;
type = EntityScanResult.HOSTILE;
}


if ( ProximityRadarGroup.showBox )
drawEntityBox( entity, matrices, ProximityRadarGroup.hostileBoxColor );

if ( ProximityRadarGroup.showTracer )
drawEntityTracer( entity, matrices, ProximityRadarGroup.hostileBoxColor );
type = EntityScanResult.PLAYER;
closestDistance = distance;
}
else if ( entity instanceof PlayerEntity && ProximityRadarGroup.detectPlayers && entity != Xenon.INSTANCE.client.player )
{
if ( distance < closestDistance )
{
closestDistance = distance;
type = EntityScanResult.PLAYER;
}

if ( ProximityRadarGroup.showPlayerBox )
this.drawEntityBox( entity, matrices, ProximityRadarGroup.playerBoxColor );

if ( ProximityRadarGroup.showBox )
this.drawEntityBox( entity, matrices, ProximityRadarGroup.playerBoxColor );

if ( ProximityRadarGroup.showTracer )
drawEntityTracer( entity, matrices, ProximityRadarGroup.playerBoxColor );
}
else if ( entity instanceof ItemEntity && ProximityRadarGroup.detectItems )
if ( ProximityRadarGroup.showPlayerTracer )
this.drawEntityTracer( entity, matrices, ProximityRadarGroup.playerBoxColor );
}
else if ( entity instanceof HostileEntity && distance < ProximityRadarGroup.hostileRange )
{
if ( distance < closestDistance )
{
//type = EntityScanResult.ITEM;
/*Text text = TextFactory.createTranslatable(
"text.xenon.proximityradar.item",
Double.toString( distance ).substring( 0, 3 )
).formatted( Formatting.RED, Formatting.BOLD );*/
type = EntityScanResult.HOSTILE;
closestDistance = distance;
}

//Xenon.INSTANCE.client.player.sendMessage( text, true );
if ( ProximityRadarGroup.showHostileBox )
this.drawEntityBox( entity, matrices, ProximityRadarGroup.hostileBoxColor );

if ( ProximityRadarGroup.showBox )
this.drawEntityBox( entity, matrices, ProximityRadarGroup.itemBoxColor );
if ( ProximityRadarGroup.showHostileTracer )
this.drawEntityTracer( entity, matrices, ProximityRadarGroup.hostileBoxColor );
}
else if ( entity instanceof ItemEntity && distance < ProximityRadarGroup.itemRange )
{
if ( ProximityRadarGroup.showItemBox )
this.drawEntityBox( entity, matrices, ProximityRadarGroup.itemBoxColor );

if ( ProximityRadarGroup.showTracer )
drawEntityTracer( entity, matrices, ProximityRadarGroup.itemBoxColor );
}
if ( ProximityRadarGroup.showItemTracer )
this.drawEntityTracer( entity, matrices, ProximityRadarGroup.itemBoxColor );
}
}

Expand Down

0 comments on commit a3f3ebd

Please sign in to comment.