Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. import java.util.List;
  2. import java.util.Random;
  3.  
  4. import net.minecraft.client.Minecraft;
  5. import net.minecraft.entity.Entity;
  6. import net.minecraft.entity.player.EntityPlayer;
  7. import net.minecraft.util.AxisAlignedBB;
  8. import net.minecraft.util.EnumParticleTypes;
  9. import net.minecraft.world.World;
  10. import net.minecraftforge.fml.common.eventhandler.EventPriority;
  11. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  12. import net.minecraftforge.fml.common.gameevent.InputEvent;
  13. import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
  14.  
  15. public class KeyEventHandler
  16. {
  17. private Minecraft mc = Minecraft.getMinecraft();
  18.  
  19.  
  20. //30 ticks per second?
  21. private int Z_TICKS = 80; //4 seconds (more complex)
  22.  
  23. private static final int Z_MOVE_DISTANCE = 2; //In blocks
  24.  
  25. private float rotationTicks = 0;
  26.  
  27. private boolean zPressed = false;
  28.  
  29. @SubscribeEvent
  30. public void onKeyInput(InputEvent.KeyInputEvent event) {
  31. EntityPlayer player = mc.thePlayer;
  32.  
  33. if(KeyHandler.Z.isPressed()) {
  34. if(zPressed) return;
  35. else {
  36. zPressed = true;
  37. player.moveEntity(-Z_MOVE_DISTANCE*Math.sin(Math.toRadians(player.rotationYawHead))*Math.cos(Math.toRadians(player.rotationPitch)),-Z_MOVE_DISTANCE*Math.sin(Math.toRadians(player.rotationPitch)), Z_MOVE_DISTANCE*Math.cos(Math.toRadians(player.rotationYawHead))*Math.cos(Math.toRadians(player.rotationPitch)));
  38. float x = player.rotationYaw;
  39. }
  40. }
  41. }
  42.  
  43. @SubscribeEvent(priority = EventPriority.HIGHEST)
  44. public void clientTickEvent(ClientTickEvent event) {
  45. if(zPressed) {
  46. float yaw = mc.thePlayer.rotationYaw;
  47. while(mc.thePlayer.rotationYaw != yaw) {
  48. if(mc.thePlayer.rotationYaw == yaw) {
  49. zPressed = false;
  50. rotationTicks = 0;
  51. break;
  52. }
  53. rotationTicks += 2F;
  54. mc.thePlayer.rotationYaw += rotationTicks;
  55. }
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement