diff --git a/src/main/java/net/moonleay/mods/gimble/mixin/NormalModeMixin.java b/src/main/java/net/moonleay/mods/gimble/mixin/NormalModeMixin.java index 1c9425a..2d1c19e 100644 --- a/src/main/java/net/moonleay/mods/gimble/mixin/NormalModeMixin.java +++ b/src/main/java/net/moonleay/mods/gimble/mixin/NormalModeMixin.java @@ -1,9 +1,13 @@ package net.moonleay.mods.gimble.mixin; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.client.option.GameOptions; import net.moonleay.mods.gimble.client.editor.Editor; import net.moonleay.mods.gimble.client.editor.modes.Mode; +import org.jetbrains.annotations.Nullable; 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; @@ -11,6 +15,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(MinecraftClient.class) public class NormalModeMixin { + @Shadow + @Nullable + public GameOptions options; + @Inject(method = "openPauseMenu", at = @At("HEAD"), cancellable = true) private void setNormalMode(boolean pause, CallbackInfo ci) { if (Editor.INSTANCE.getCURRENT_MODE() != Mode.NORMAL){ @@ -20,4 +28,19 @@ public class NormalModeMixin { ci.cancel(); } } + + @Inject(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z"), cancellable = true) + private void blockWorldManipulation(CallbackInfo ci) { + if (Editor.INSTANCE.getCURRENT_MODE() == Mode.NORMAL || Editor.INSTANCE.getCURRENT_MODE() == Mode.VISUAL) { + while(this.options.attackKey.wasPressed()) { + } + + while(this.options.useKey.wasPressed()) { + } + + while(this.options.pickItemKey.wasPressed()) { + } + ci.cancel(); + } + } }