Skip to content

Commit

Permalink
???
Browse files Browse the repository at this point in the history
  • Loading branch information
AV306 committed Aug 1, 2023
1 parent 5a411f5 commit 418cdab
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/main/java/me/av306/xenon/Xenon.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private void initCommands()
{
new DebugCrashCommand();
new HelpCommand();
new BindCommand();
}

private void initFeatures()
Expand Down Expand Up @@ -249,14 +250,13 @@ public void sendErrorMessage( String key )
);
try
{
this.client.player.sendMessage(finalText, false);
this.client.player.sendMessage( finalText, false );
}
catch ( NullPointerException ignored ) {}
}

public void sendErrorMessage( String key, Object... args )
{
// TODO: impl parameter packs?
Text finalText = namePrefix.copy()
.append(
TextFactory.createTranslatable( key, args )
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/me/av306/xenon/commands/BindCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package me.av306.xenon.commands;

import me.av306.xenon.Xenon;
import me.av306.xenon.command.Command;
import me.av306.xenon.feature.IFeature;
import net.minecraft.client.input.Input;
import net.minecraft.client.util.InputUtil;

public class BindCommand extends Command
{
public BindCommand()
{
super( "bind", "b") ;
}

@Override
public void execute( String[] args )
{
// args[0] is feature name, args[1][0] is key
try
{
IFeature feature = Xenon.INSTANCE.featureRegistry.get( args[0] );
char key = args[1].charAt( 0 );

// Idk what the scancodes are :(
feature.getKeyBinding().setBoundKey( InputUtil.fromKeyCode( key, -1 ) );

Xenon.INSTANCE.sendInfoMessage( "text.xenon.command.bind.success", args[0], key );
}
catch ( NullPointerException npe )
{
Xenon.INSTANCE.sendErrorMessage( "text.xenon.command.bind.unresolvable", args[0] );
}
catch ( ArrayIndexOutOfBoundsException oobe )
{
Xenon.INSTANCE.sendErrorMessage( "text.xenon.command.bind.notenoughargs", args.length );
}
}
}
3 changes: 2 additions & 1 deletion src/main/java/me/av306/xenon/feature/IFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public abstract class IFeature
* It is advised not to set this directly; use one of the constructors instead.
*/
protected KeyBinding keyBinding;
public KeyBinding getKeyBinding() { return this.keyBinding; }

/**
* Sets whether this Feature should be hidden in FeatureList.
Expand Down Expand Up @@ -109,7 +110,7 @@ protected IFeature( String name, int key )
this.keyBinding = new KeyBinding(
"key.xenon." + name.toLowerCase().replaceAll( " ", "" ),
InputUtil.Type.KEYSYM,
this.key,
key,
"category.xenon." + this.category
);

Expand Down
1 change: 1 addition & 0 deletions src/main/java/me/av306/xenon/features/BlackBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.time.LocalTime;
import java.util.concurrent.*;

// TODO: Finish other data sources after exams
public class BlackBox extends IToggleableFeature
{
private File logFile = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private ActionResult onChatHudAddMessage( String text )
String[] args = Arrays.copyOfRange( cmd, 1, cmd.length );

if ( !this.handleStandaloneCommand( name, args ) && !this.handleFeatureCommand( name, args ) )
Xenon.INSTANCE.sendErrorMessage( "text.xenon.commandprocesor.unresolvable" );
Xenon.INSTANCE.sendErrorMessage( "text.xenon.commandprocesor.unresolvable", name );

return ActionResult.FAIL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Text modifyEntityLabelText( Entity entity, Text text )
{
LivingEntity livingEntity = (LivingEntity) entity;

text = text.copy().append( String.format( " §c(%f❤)§r", livingEntity.getHealth() ) );
text = text.copy().append( String.format( " §c(%.2f❤)§r", livingEntity.getHealth() ) );
}
catch ( ClassCastException ignored ) {}

Expand Down
36 changes: 20 additions & 16 deletions src/main/java/me/av306/xenon/features/render/RedReticleFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.hit.HitResult;

public class RedReticleFeature extends IToggleableFeature
{
public class RedReticleFeature extends IToggleableFeature {

public RedReticleFeature()
{
super( "Red Reticle", "aimassist", "rr" );
RenderCrosshairEvent.START_RENDER.register( this::onStartRenderCrosshair );
RenderCrosshairEvent.END_RENDER.register( this::onEndRenderCrosshair );
public RedReticleFeature() {
super("Red Reticle", "aimassist", "rr");
RenderCrosshairEvent.START_RENDER.register(this::onStartRenderCrosshair);
RenderCrosshairEvent.END_RENDER.register(this::onEndRenderCrosshair);
}

private ActionResult onStartRenderCrosshair( DrawContext drawContext )
{
private ActionResult onStartRenderCrosshair( DrawContext drawContext ) {
if ( this.isEnabled )
{
if ( RedReticleGroup.disableBlend ) RenderSystem.disableBlend();
if ( RedReticleGroup.disableBlend )
RenderSystem.disableBlend();

HitResult hitResult = Xenon.INSTANCE.client.crosshairTarget;

Expand All @@ -40,30 +38,36 @@ private ActionResult onStartRenderCrosshair( DrawContext drawContext )
{
// Friendly!
// Green crosshair
drawContext.setShaderColor( 0f, 1f, 0f, 1f );
} else if ( entity instanceof HostileEntity )
drawContext.setShaderColor( 0f, 1f, 0f, 1f);
}
else if ( entity instanceof HostileEntity )
{
// Hostile and enemy!
// Red crosshair
drawContext.setShaderColor( 1f, 0f, 0f, 1f );
}
}

drawContext.setShaderColor( 1f, 1f, 1f, 1f );
//drawContext.setShaderColor(1f, 1f, 1f, 1f);
}

return ActionResult.PASS;
}

private ActionResult onEndRenderCrosshair( DrawContext drawContext )
{
if ( this.isEnabled ) RenderSystem.enableBlend();
if ( this.isEnabled )
RenderSystem.enableBlend();

drawContext.setShaderColor( 1f, 1f, 1f, 1f );
return ActionResult.PASS;
}

@Override
protected void onEnable() {}
protected void onEnable() {
}

@Override
protected void onDisable() {}
protected void onDisable() {
}
}
5 changes: 4 additions & 1 deletion src/main/resources/assets/xenon/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@
"text.xenon.blackbox.ioexception.write": "An exception occurred while writing to the log file",
"text.xenon.blackbox.ioexception.disposal": "An exception occurred while cleaning up, you might want to restart your PC to clean up potential memory leaks",
"text.xenon.command.debugcrash.warning": "WARNING: This action will not save the world and may corrupt it. Pass the argument \"confirm\" to continue.",
"text.xenon.command.bind.success": "[Bind] Successfully bound %s to %c",
"text.xenon.command.bind.unresolvable": "[Bind] Could not resolve feature: %s",
"text.xenon.command.bind.notenoughargs": "[Bind] Not enough arguments! %d provided, 2 expected",
"text.xenon.commandprocessor.report": "> %s",
"text.xenon.commandprocessor.disabled": "CommandProcessor is disabled! Please enable it to use commands.",
"text.xenon.commandprocessor.exception": "[CommandProcessor] Oh no! An unexpected exception ocurred and this is very bad!!!",
Expand All @@ -120,7 +123,7 @@
"text.xenon.commandprocessor.invalid.command.notenoughargs": "[CommandProcessor] Invalid command: Not enough arguments!",
"text.xenon.commandprocessor.invalid.prefix": "[CommandProcessor] Invalid prefix in registry! Setting prefix to '!'.",
"text.xenon.commandprocessor.possiblekeywords": "[CommandProcessor] Possible command keywords:\n[enable, e, on, disable, d, off, toggle, t\nexecute, exec, ex, run, do, set, s, help, h, ?",
"text.xenon.commandprocesor.unresolvable": "[CommandProcessor] Could not resolve target feature or command",
"text.xenon.commandprocesor.unresolvable": "[CommandProcessor] Could not resolve target feature or command %s",
"text.xenon.commandprocesor.unresolvable.feature": "[CommandProcessor] Could not resolve target feature",
"text.xenon.commandprocesor.unresolvable.standalone": "[CommandProcessor] Could not resolve target command",
"text.xenon.commandprocessor.missing.args": "[CommandProcessor] Insufficient arguments provided: %d expected, %d provided",
Expand Down

0 comments on commit 418cdab

Please sign in to comment.