Posted July 25, 201411 yr I'm trying to figure out how to disable the player movement keys when the left and right mouse buttons are being held down at the same time. When the player releases the mouse keys the movement keys will work again. I have been reading the tutorials provided on the website explaining how mouse and keyboard input works. http://greyminecraftcoder.blogspot.com.au/2013/10/user-input.html I am looking for tips on how to apply this information to a mod. I'm not entirely sure where to start. Thanks in advance to anyone who is able to help me out.
July 25, 201411 yr Not sure but it is possible that in KeyInputEvent handler you could check for mouse buttons and cancel the event. Not sure that canceling will cancel built-in keybindings but I suspect is might. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
July 25, 201411 yr Hi THis post might be useful http://www.minecraftforge.net/forum/index.php/topic,13727.msg70723.html#msg70723 It was for 1.6.4, not sure if it still works, but is worth a try. Basic idea is - intercept the movement keys by replace this.thePlayer.movementInput (class = MovementInputFromOptions) with your own class -TGG
July 25, 201411 yr Author Hey thanks for the reply guys. TheGreyGhost, I have read the thread you linked me and I figured I will get confused keys working first and then I will use that as a base to get my mod to work. I am however having a few problems. (In 1.7.10) I have re-created your three classes ConfusedMovementInput, ClientTickHandler, (my main modding class) - ConfusedMovementInput doesn't seem to have any errors - ClientTickHandler has the following errors: -> It's telling me I need to create the interface "ITickHandler" -> It's telling me I need to create an interface or Class called "TickType" - (main modding class called Shinobi) doesn't seem to have any errors Here is the code: package net.shinobi.mod; import net.shinobi.mod.keyboard.ConfusedMovementInput; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; @Mod(modid = Shinobi.MODID, version = Shinobi.VERSION) public class Shinobi { public static final String MODID = "Shinobi"; public static final String VERSION = "Alpha 1.0"; public static net.shinobi.mod.Shinobi instance; public static ConfusedMovementInput confusedMovementInput; } package net.shinobi.mod.keyboard; import net.minecraft.util.MovementInput; public class ConfusedMovementInput extends MovementInput { public ConfusedMovementInput(MovementInput interceptedMovementInput) { underlyingMovementInput = interceptedMovementInput; } @Override public void updatePlayerMoveState() { underlyingMovementInput.updatePlayerMoveState(); this.jump = underlyingMovementInput.jump; this.sneak = underlyingMovementInput.sneak; if (!confused) { this.moveStrafe = underlyingMovementInput.moveStrafe; this.moveForward = underlyingMovementInput.moveForward; } else { this.moveStrafe = -underlyingMovementInput.moveStrafe; //swap left and right this.moveForward = underlyingMovementInput.moveForward; } } public void setConfusion(boolean newConfused) { confused = newConfused; } protected MovementInput underlyingMovementInput; private boolean confused = false; } package net.shinobi.mod.keyboard; import java.util.EnumSet; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.item.ItemStack; import net.shinobi.mod.Shinobi; public class ClientTickHandler implements ITickHandler { public EnumSet<TickType> ticks() { return EnumSet.of(TickType.CLIENT); } public void tickStart(EnumSet<TickType> type, Object... tickData) { if (!type.contains(TickType.CLIENT)) return; EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; if (player != null) { if (player.movementInput instanceof ConfusedMovementInput) { } else { Shinobi.confusedMovementInput = new ConfusedMovementInput(player.movementInput); player.movementInput = Shinobi.confusedMovementInput; } ItemStack heldItem = player.getHeldItem(); if (heldItem != null) { Shinobi.confusedMovementInput.setConfusion(true); } else { Shinobi.confusedMovementInput.setConfusion(false); } } } public void tickEnd(EnumSet<TickType> type, Object... tickData) { } public String getLabel() { return "ClientTickHandler"; } }
July 25, 201411 yr Hi Yeah ITickHandler is gone; replaced by Forge Events See here and http://www.wuppy29.com/minecraft/modding-tutorials/wuppys-minecraft-forge-modding-tutorials-for-1-7-events/#sthash.0vnz61rP.dpbs You want ClientTickEvent, which needs to be registered using FMLCommonHandler.instance().bus().register(); -TGG
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.