Skip to content

Commit

Permalink
Added movement in casting screen
Browse files Browse the repository at this point in the history
  • Loading branch information
miyucomics committed Mar 1, 2024
1 parent 8c26c80 commit 7ba6ed6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package miyucomics.hexical.mixin;

import at.petrak.hexcasting.client.gui.GuiSpellcasting;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.input.Input;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.option.GameOptions;
import net.minecraft.client.option.KeyBinding;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ClientPlayerEntity.class)
public class ClientPlayerEntityMixin {
@Shadow public Input input;

@Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/tutorial/TutorialManager;onMovement(Lnet/minecraft/client/input/Input;)V"))
private void onInputUpdate(CallbackInfo info) {
MinecraftClient client = MinecraftClient.getInstance();
if (!(client.currentScreen instanceof GuiSpellcasting))
return;
KeyBinding.updatePressedStates();
GameOptions keys = client.options;
keys.dropKey.setPressed(false);
input.pressingForward = keys.forwardKey.isPressed();
input.pressingBack = keys.backKey.isPressed();
input.pressingLeft = keys.leftKey.isPressed();
input.pressingRight = keys.rightKey.isPressed();
input.jumping = keys.jumpKey.isPressed();
input.sneaking = keys.sneakKey.isPressed();
if (!client.player.isSprinting())
client.player.setSprinting(keys.sprintKey.isPressed());
}
}
1 change: 1 addition & 0 deletions common/src/main/resources/hexical-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"client": [
"ClientPlayerEntityMixin",
"MinecraftClientMixin"
],
"mixins": [
Expand Down

0 comments on commit 7ba6ed6

Please sign in to comment.