Posted May 6, 20196 yr Hi, I want to write a simple autowalk/run mod but I have problems understanding how the Playercontroller works. I had two approaches: 1. simulating keypresses I thought this would be an easy idea using something like this: KeyBinding.onTick(minecraft.gameSettings.keyBindUseItem.getKeyCode()); I gues this method executes this keypress for the time of a single tick? So if I want to move consistently i would need to call this method on every tick using PlayerTickEvent and checking a boolean every time if autowalk is on or off? I think this idea is not so good as you could not use the chat while autowalking. 2. So my next idea was to to access the playercontroller and find some kind of move method. But I could find out how it exactly works and what I need to do to make sure that the player walks like i would just press the W key. I found some code online but I could not find the methods in my libs: player.func_70031_b(true); the player if from type EntityPlayerSP Edited May 6, 20196 yr by HenryFoster
May 7, 20196 yr Entity#move should work About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
May 7, 20196 yr Author 16 hours ago, Cadiboo said: Entity#move should work I'm making advancements. I found a way to move the player using the MovementInput class and : import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; . It worked perfectly however only if I call the method via an event like LeftClickBlock event. When I want to call the method using a keybind: @SubscribeEvent public static void keyPress(KeyInputEvent event) { if(KeyBindings.myKey.isPressed()) { if(!pressed) { pressed = true; }else { pressed = false; } if(pressed) { pmc.moveStraightTo(0,0,4); }else { pmc.resetPlayerInput(); } } } I get a NullPointer Exception: Edit: Im an idiot I did not registered the keybind properly Edited May 7, 20196 yr by HenryFoster
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.