Skip to content

Commit

Permalink
add attack to fullkeyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
AV306 committed Mar 6, 2024
1 parent 2af57f6 commit 7390a55
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions plinstall
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/me/av306/xenon/commands/DebugCrashCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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" ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() );

Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 7390a55

Please sign in to comment.