From 7390a55853299a4b9534b442fc9e90cdd3e04a49 Mon Sep 17 00:00:00 2001 From: AV3_08 Date: Wed, 6 Mar 2024 06:13:30 +0000 Subject: [PATCH] add attack to fullkeyboard --- gradle.properties | 2 +- plinstall | 4 +-- .../xenon/commands/DebugCrashCommand.java | 5 ++++ .../movement/FullKeyboardFeature.java | 25 ++++++++++++++++--- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index b12a7f41..e4bf3a50 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ fabric_version = 0.95.1+1.20.4 # Mod Properties - mod_version = 4.5.0+1.20.4 + mod_version = 4.5.1+1.20.4 maven_group = me.av306 archives_base_name = xenon diff --git a/plinstall b/plinstall index b6783c77..53c5316c 100755 --- a/plinstall +++ b/plinstall @@ -17,8 +17,8 @@ then sudo apt install libqt6core5compat6 -y mkdir PrismLauncher && cd PrismLauncher - wget https://github.com/PrismLauncher/PrismLauncher/releases/download/7.1/PrismLauncher-Linux-Qt6-portable-7.1.tar.gz - tar -xvf PrismLauncher-Linux-Qt6-portable-7.1.tar.gz + wget https://github.com/PrismLauncher/PrismLauncher/releases/download/8.0/PrismLauncher-Linux-Qt6-portable-8.0.tar.gz + tar -xvf PrismLauncher-Linux-Qt6-portable-8.0.tar.gz chmod +x ./PrismLauncher elif [ "$DISTRIB_CODENAME" = "focal" ] then diff --git a/src/main/java/me/av306/xenon/commands/DebugCrashCommand.java b/src/main/java/me/av306/xenon/commands/DebugCrashCommand.java index 56c74a5b..805f0618 100644 --- a/src/main/java/me/av306/xenon/commands/DebugCrashCommand.java +++ b/src/main/java/me/av306/xenon/commands/DebugCrashCommand.java @@ -3,6 +3,7 @@ import me.av306.xenon.Xenon; import me.av306.xenon.command.Command; import net.minecraft.client.Keyboard; +import net.minecraft.client.util.GlfwUtil; public class DebugCrashCommand extends Command { @@ -15,6 +16,10 @@ public void execute( String[] args ) // MC catches the OOBE :( args[args.length] = ""; + + if ( args[0].equals( "force" ) ) GlfwUtil.makeJvmCrash(); + //System.exit( -1 ); + //Xenon.INSTANCE.client.keyboard.pollDebugCrash(); //if ( args[0].equals( "confirm" ) ) diff --git a/src/main/java/me/av306/xenon/features/movement/FullKeyboardFeature.java b/src/main/java/me/av306/xenon/features/movement/FullKeyboardFeature.java index 43ac319f..e9d1c0e7 100644 --- a/src/main/java/me/av306/xenon/features/movement/FullKeyboardFeature.java +++ b/src/main/java/me/av306/xenon/features/movement/FullKeyboardFeature.java @@ -8,6 +8,10 @@ import me.av306.xenon.util.KeybindUtil; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.minecraft.client.option.KeyBinding; +import net.minecraft.entity.Entity; +import net.minecraft.util.Hand; +import net.minecraft.util.hit.EntityHitResult; +import net.minecraft.util.hit.HitResult; import org.lwjgl.glfw.GLFW; public final class FullKeyboardFeature extends IToggleableFeature @@ -68,8 +72,23 @@ private void onEndTick() { if ( !this.isEnabled ) return; - // FIXME: virtual attack key only works for block breaking, not attacking - // Best guess is attack is a wasPressed() call, but block breaking is an isPressed() + // Left mouse stuff + boolean leftMousePressed = this.virtualLeftMouseKey.isPressed(); + // Arm swing + + // Attack + if ( leftMousePressed ) + { + if ( Xenon.INSTANCE.client.crosshairTarget.getType() == HitResult.Type.ENTITY ) + { + Entity e = ((EntityHitResult) Xenon.INSTANCE.client.crosshairTarget).getEntity(); + //Xenon.INSTANCE.client.player.attack( entityHitResult.getEntity() ); + Xenon.INSTANCE.client.interactionManager.attackEntity( Xenon.INSTANCE.client.player, e ); + } + + Xenon.INSTANCE.client.player.swingHand( Hand.MAIN_HAND ); + } + Xenon.INSTANCE.client.options.attackKey.setPressed( this.virtualLeftMouseKey.isPressed() ); Xenon.INSTANCE.client.options.useKey.setPressed( this.virtualRightMouseKey.isPressed() ); @@ -98,7 +117,7 @@ private void modifyMouseDelta( double f, boolean accelerate ) { // View flick assert Xenon.INSTANCE.client.player != null; - // TODO: Do we need packets or something? + if ( this.upKey.wasPressed() ) Xenon.INSTANCE.client.player.setPitch( Xenon.INSTANCE.client.player.getPitch() - 90 ); if ( this.downKey.wasPressed() ) Xenon.INSTANCE.client.player.setPitch( Xenon.INSTANCE.client.player.getPitch() + 90 ); if ( this.leftKey.wasPressed() ) Xenon.INSTANCE.client.player.setYaw( Xenon.INSTANCE.client.player.getYaw() - 90 );