35 lines
924 B
Java
35 lines
924 B
Java
package eu.oskar3123.fabric.test.mixin;
|
|
|
|
import eu.oskar3123.fabric.test.TapemouseCommand;
|
|
import net.minecraft.client.options.KeyBinding;
|
|
import org.spongepowered.asm.mixin.Final;
|
|
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.CallbackInfoReturnable;
|
|
|
|
@Mixin(KeyBinding.class)
|
|
public class MixinKeyBinding
|
|
{
|
|
|
|
@Shadow
|
|
@Final
|
|
private String id;
|
|
|
|
@Inject(at = @At("HEAD"), method = "isPressed()Z", cancellable = true)
|
|
public void onIsPressed(CallbackInfoReturnable<Boolean> info)
|
|
{
|
|
if (this.id == null || !this.id.equals("key.use"))
|
|
{
|
|
return;
|
|
}
|
|
if (!TapemouseCommand.isEnabled())
|
|
{
|
|
return;
|
|
}
|
|
info.setReturnValue(true);
|
|
}
|
|
|
|
}
|