net.minecraft.util.MovementInput Java Examples

The following examples show how to use net.minecraft.util.MovementInput. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HelperActions.java    From burlapcraft with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static boolean moveForward(boolean jump) {
	MovementInput movement = new MovementInput();
	movement.moveForward = (float) 0.55D;
	movement.jump = jump;

	snapToGrid();

	overrideMovement(movement);

	final Timer timer = new Timer();
	timer.schedule(new TimerTask() {
		@Override
		public void run() {
			resetAllInputs();
			timer.cancel();
		}
	}, 440, 10);

	return true;
}
 
Example #2
Source File: EntityFakePlayer.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
public void setMovementInput(MovementInput movementInput) {
    EntityFakePlayer.movementInput = movementInput;
    if (movementInput.jump && this.onGround) {
        super.jump();
    }
    super.moveEntityWithHeading(movementInput.moveStrafe, movementInput.moveForward);
}
 
Example #3
Source File: BoatFly.java    From ForgeHax with MIT License 5 votes vote down vote up
public static void setMoveSpeedEntity(double speed) {
  if (MC.player != null && MC.player.getRidingEntity() != null) {
    MovementInput movementInput = MC.player.movementInput;
    double forward = movementInput.moveForward;
    double strafe = movementInput.moveStrafe;
    float yaw = MC.player.rotationYaw;
    
    if ((forward == 0.0D) && (strafe == 0.0D)) {
      MC.player.getRidingEntity().motionX = (0.0D);
      MC.player.getRidingEntity().motionZ = (0.0D);
    } else {
      if (forward != 0.0D) {
        if (strafe > 0.0D) {
          yaw += (forward > 0.0D ? -45 : 45);
        } else if (strafe < 0.0D) {
          yaw += (forward > 0.0D ? 45 : -45);
        }
        
        strafe = 0.0D;
        
        if (forward > 0.0D) {
          forward = 1.0D;
        } else if (forward < 0.0D) {
          forward = -1.0D;
        }
      }
      MC.player.getRidingEntity().motionX =
          (forward * speed * Math.cos(Math.toRadians(yaw + 90.0F))
              + strafe * speed * Math.sin(Math.toRadians(yaw + 90.0F)));
      MC.player.getRidingEntity().motionZ =
          (forward * speed * Math.sin(Math.toRadians(yaw + 90.0F))
              - strafe * speed * Math.cos(Math.toRadians(yaw + 90.0F)));
    }
  }
}
 
Example #4
Source File: PlayerMovementManager.java    From OpenModsLib with MIT License 5 votes vote down vote up
@SubscribeEvent
public static void updateMovementState(InputUpdateEvent evt) {
	final MovementInput input = evt.getMovementInput();
	final EntityPlayer owner = evt.getEntityPlayer();
	if (input.jump && !wasJumping) input.jump = postMovementEvent(owner, PlayerMovementEvent.Type.JUMP);
	if (input.sneak && !wasSneaking) input.sneak = postMovementEvent(owner, PlayerMovementEvent.Type.SNEAK);

	wasJumping = input.jump;
	wasSneaking = input.sneak;
}
 
Example #5
Source File: EntitySpeed.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public void onUpdate() {
	if (this.isToggled()) {
		if (mc.player.getRidingEntity() == null) return;
		
		Entity e = mc.player.getRidingEntity();
		double speed = getSettings().get(0).toSlider().getValue();
		
		if (e instanceof LlamaEntity) {
			e.rotationYaw = mc.player.rotationYaw;
			((LlamaEntity) e).rotationYawHead = mc.player.rotationYawHead;
		}
		MovementInput movementInput = mc.player.movementInput;
		double forward = movementInput.moveForward;
		double strafe = movementInput.moveStrafe;
		float yaw = mc.player.rotationYaw;
		if ((forward == 0.0D) && (strafe == 0.0D)) {
			e.setMotion(0, e.getMotion().y, 0);
		} else {
			if (forward != 0.0D) {
				if (strafe > 0.0D) { yaw += (forward > 0.0D ? -45 : 45);
				} else if (strafe < 0.0D) yaw += (forward > 0.0D ? 45 : -45);
				strafe = 0.0D;
				if (forward > 0.0D) { forward = 1.0D;
				} else if (forward < 0.0D) forward = -1.0D;
			}
			e.setMotion((forward * speed * Math.cos(Math.toRadians(yaw + 90.0F)) + strafe * speed * Math.sin(Math.toRadians(yaw + 90.0F))), e.getMotion().y,
					forward * speed * Math.sin(Math.toRadians(yaw + 90.0F)) - strafe * speed * Math.cos(Math.toRadians(yaw + 90.0F)));
			if (e instanceof MinecartEntity) {
				MinecartEntity em = (MinecartEntity) e;
				em.setVelocity((forward * speed * Math.cos(Math.toRadians(yaw + 90.0F)) + strafe * speed * Math.sin(Math.toRadians(yaw + 90.0F))), em.getMotion().y, (forward * speed * Math.sin(Math.toRadians(yaw + 90.0F)) - strafe * speed * Math.cos(Math.toRadians(yaw + 90.0F))));
			}
			
			if (getSettings().get(1).toToggle().state) if (mc.gameSettings.keyBindJump.isKeyDown()) e.setMotion(e.getMotion().x, 0.3, e.getMotion().z);
			
			if (getSettings().get(2).toToggle().state) {
				BlockPos p = e.getPosition().add(0, 0.5, 0);
				if (mc.world.getBlockState(p.down()).getBlock() == Blocks.AIR &&
					mc.world.getBlockState(p.down(2)).getBlock() != Blocks.AIR &&
					!(mc.world.getBlockState(p.down(2)).getMaterial() == Material.WATER) &&
					e.fallDistance > 0.01) e.setMotion(e.getMotion().x, -1, e.getMotion().z);
			}
		}
	}
}
 
Example #6
Source File: SNCPBHop.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onMove(MoveEvent event) {
    ++timerDelay;
    timerDelay %= 5;
    if(timerDelay != 0) {
        mc.timer.timerSpeed = 1F;
    }else{
        if(MovementUtils.isMoving())
            mc.timer.timerSpeed = 32767F;

        if(MovementUtils.isMoving()) {
            mc.timer.timerSpeed = 1.3F;
            mc.thePlayer.motionX *= 1.0199999809265137;
            mc.thePlayer.motionZ *= 1.0199999809265137;
        }
    }

    if(mc.thePlayer.onGround && MovementUtils.isMoving())
        level = 2;

    if(round(mc.thePlayer.posY - (double) ((int) mc.thePlayer.posY)) == round(0.138)) {
        mc.thePlayer.motionY -= 0.08;
        event.setY(event.getY() - 0.09316090325960147);
        mc.thePlayer.posY -= 0.09316090325960147;
    }

    if(level == 1 && (mc.thePlayer.moveForward != 0.0f || mc.thePlayer.moveStrafing != 0.0f)) {
        level = 2;
        moveSpeed = 1.35 * getBaseMoveSpeed() - 0.01;
    }else if(level == 2) {
        level = 3;
        mc.thePlayer.motionY = 0.399399995803833;
        event.setY(0.399399995803833);
        moveSpeed *= 2.149;
    }else if(level == 3) {
        level = 4;
        double difference = 0.66 * (lastDist - getBaseMoveSpeed());
        moveSpeed = lastDist - difference;
    }else if(level == 88) {
        moveSpeed = getBaseMoveSpeed();
        lastDist = 0;
        level = 89;
    }else if(level == 89) {
        if(mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, mc.thePlayer.getEntityBoundingBox().offset(0.0, mc.thePlayer.motionY, 0.0)).size() > 0 || mc.thePlayer.isCollidedVertically)
            level = 1;
        lastDist = 0;
        moveSpeed = getBaseMoveSpeed();
        return;
    }else{
        if(mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, mc.thePlayer.getEntityBoundingBox().offset(0.0, mc.thePlayer.motionY, 0.0)).size() > 0 || mc.thePlayer.isCollidedVertically) {
            moveSpeed = getBaseMoveSpeed();
            lastDist = 0;
            level = 88;
            return;
        }

        moveSpeed = lastDist - lastDist / 159.0;
    }

    moveSpeed = Math.max(moveSpeed, getBaseMoveSpeed());

    final MovementInput movementInput = mc.thePlayer.movementInput;
    float forward = movementInput.moveForward;
    float strafe = movementInput.moveStrafe;
    float yaw = mc.thePlayer.rotationYaw;
    if(forward == 0.0f && strafe == 0.0f) {
        event.setX(0.0);
        event.setZ(0.0);
    }else if(forward != 0.0f) {
        if(strafe >= 1.0f) {
            yaw += (float) (forward > 0.0f ? -45 : 45);
            strafe = 0.0f;
        }else if(strafe <= -1.0f) {
            yaw += (float) (forward > 0.0f ? 45 : -45);
            strafe = 0.0f;
        }
        if(forward > 0.0f) {
            forward = 1.0f;
        }else if(forward < 0.0f) {
            forward = -1.0f;
        }
    }

    final double mx2 = Math.cos(Math.toRadians(yaw + 90.0f));
    final double mz2 = Math.sin(Math.toRadians(yaw + 90.0f));
    event.setX((double) forward * moveSpeed * mx2 + (double) strafe * moveSpeed * mz2);
    event.setZ((double) forward * moveSpeed * mz2 - (double) strafe * moveSpeed * mx2);

    mc.thePlayer.stepHeight = 0.6F;
    if(forward == 0.0F && strafe == 0.0F) {
        event.setX(0.0);
        event.setZ(0.0);
    }
}
 
Example #7
Source File: NullMovementInput.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
public NullMovementInput(MovementInput original) {
	this.original = original;
}
 
Example #8
Source File: CommandForWheeledRobotNavigationImplementation.java    From malmo with MIT License 4 votes vote down vote up
/** Provide access to the MovementInput object we are using to control the player.<br>
 * This is required by the unit tests.
 * @return our MovementInput object.
 */
public MovementInput getMover()
{
    return this.overrideMovement;
}
 
Example #9
Source File: MovementController.java    From Better-Sprinting with Mozilla Public License 2.0 4 votes vote down vote up
public MovementController(MovementInput movementInput){
	this.movementInput = movementInput;
	this.sprintToggle = new ToggleTracker(ClientModManager.keyBindSprintToggle, ClientModManager.keyBindSprintHold);
	this.sneakToggle = new ToggleTracker(ClientModManager.keyBindSneakToggle, mc.gameSettings.keyBindSneak);
}
 
Example #10
Source File: HelperActions.java    From burlapcraft with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void overrideMovement(MovementInput i) {
	if (resetMovementInput == null) {
		resetMovementInput = mc.thePlayer.movementInput;
	}
	mc.thePlayer.movementInput = i;
}