Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.List;
- import java.util.Random;
- import net.minecraft.client.Minecraft;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.util.AxisAlignedBB;
- import net.minecraft.util.EnumParticleTypes;
- import net.minecraft.world.World;
- import net.minecraftforge.fml.common.eventhandler.EventPriority;
- import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
- import net.minecraftforge.fml.common.gameevent.InputEvent;
- import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
- public class KeyEventHandler
- {
- private Minecraft mc = Minecraft.getMinecraft();
- //30 ticks per second?
- private int Z_TICKS = 80; //4 seconds (more complex)
- private static final int Z_MOVE_DISTANCE = 2; //In blocks
- private float rotationTicks = 0;
- private boolean zPressed = false;
- @SubscribeEvent
- public void onKeyInput(InputEvent.KeyInputEvent event) {
- EntityPlayer player = mc.thePlayer;
- if(KeyHandler.Z.isPressed()) {
- if(zPressed) return;
- else {
- zPressed = true;
- 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)));
- float x = player.rotationYaw;
- }
- }
- }
- @SubscribeEvent(priority = EventPriority.HIGHEST)
- public void clientTickEvent(ClientTickEvent event) {
- if(zPressed) {
- float yaw = mc.thePlayer.rotationYaw;
- while(mc.thePlayer.rotationYaw != yaw) {
- if(mc.thePlayer.rotationYaw == yaw) {
- zPressed = false;
- rotationTicks = 0;
- break;
- }
- rotationTicks += 2F;
- mc.thePlayer.rotationYaw += rotationTicks;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement