Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventTarget
- public void onMove(EventMove event)
- {
- if (!mc.thePlayer.onGround) {
- this.timer.reset();
- }
- if (roundToPlace(mc.thePlayer.posY - (int)mc.thePlayer.posY, 3) == roundToPlace(0.481D, 3))
- {
- mc.thePlayer.motionY -= 0.075D;
- event.setMotionY(-0.075D);
- }
- else if (roundToPlace(mc.thePlayer.posY - (int)mc.thePlayer.posY, 3) == roundToPlace(0.406D, 3))
- {
- mc.thePlayer.motionY = -0.1D;
- event.setMotionY(-0.1D);
- }
- else if (roundToPlace(mc.thePlayer.posY - (int)mc.thePlayer.posY, 3) == roundToPlace(0.306D, 3))
- {
- mc.thePlayer.motionY = -9.E-006D;
- event.setMotionY(-9.E-006D);
- }
- else if (roundToPlace(mc.thePlayer.posY - (int)mc.thePlayer.posY, 3) == roundToPlace(0.305D, 3))
- {
- this.stage = 0;
- }
- if ((this.stage == 1) && ((mc.thePlayer.moveForward != 0.0F) || (mc.thePlayer.moveStrafing != 0.0F)))
- {
- this.stage = 2;
- this.moveSpeed = (!mc.thePlayer.isPotionActive(1) ? 4.48D * getBaseMoveSpeed() - 0.01D : 3.5D * getBaseMoveSpeed() - 0.01D);
- }
- else if (this.stage == 2)
- {
- this.stage = 3;
- mc.thePlayer.motionY = 0.42D;
- event.setMotionY(0.42D);
- this.moveSpeed *= 1.987D;
- }
- else if (this.stage == 3)
- {
- this.stage = 4;
- double difference = 0.67D * (this.lastDist - getBaseMoveSpeed());
- this.moveSpeed = (this.lastDist - difference);
- }
- else
- {
- if ((mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, mc.thePlayer.boundingBox.offset(0.0D, mc.thePlayer.motionY, 0.0D)).size() > 0) || (mc.thePlayer.isCollidedVertically)) {
- if (this.timer.delay(275.0F)) {
- this.stage = 1;
- } else {
- this.stage = 0;
- }
- }
- this.moveSpeed = (this.lastDist - this.lastDist / 159.0D);
- }
- if ((this.stage == 0) &&
- (mc.thePlayer.isSprinting())) {
- mc.thePlayer.setSprinting(false);
- }
- setMoveSpeed(event, this.stage != 0 ? (this.moveSpeed = Math.max(this.moveSpeed, getBaseMoveSpeed())) : 0.15D);
- }
- public double getBaseMoveSpeed()
- {
- double baseSpeed = 0.287D;
- if (mc.thePlayer.isPotionActive(Potion.moveSpeed))
- {
- int amplifier = mc.thePlayer.getActivePotionEffect(Potion.moveSpeed).getAmplifier();
- baseSpeed *= (1.0D + 0.2D * (amplifier + 1));
- }
- return baseSpeed;
- }
- @EventTarget
- public void onUpdate(EventPreTick event)
- {
- double xDist = mc.thePlayer.posX - mc.thePlayer.prevPosX;
- double zDist = mc.thePlayer.posZ - mc.thePlayer.prevPosZ;
- this.lastDist = Math.sqrt(xDist * xDist + zDist * zDist);
- }
- public static double roundToPlace(double value, int places)
- {
- if (places < 0) {
- throw new IllegalArgumentException();
- }
- BigDecimal bd = new BigDecimal(value);
- bd = bd.setScale(places, RoundingMode.HALF_UP);
- return bd.doubleValue();
- }
- public void setMoveSpeed(EventMove event, double speed)
- {
- double forward = mc.thePlayer.movementInput.moveForward;
- double strafe = mc.thePlayer.movementInput.moveStrafe;
- float yaw = mc.thePlayer.rotationYaw;
- if ((forward == 0.0D) && (strafe == 0.0D))
- {
- event.setMotionX(0.0D);
- event.setMotionZ(0.0D);
- }
- else
- {
- if (forward != 0.0D)
- {
- if (strafe > 0.0D) {
- yaw += (forward > 0.0D ? -50 : 50);
- } else if (strafe < 0.0D) {
- yaw += (forward > 0.0D ? 50 : -50);
- }
- strafe = 0.0D;
- if (forward > 0.0D) {
- forward = 1.0D;
- } else if (forward < 0.0D) {
- forward = -1.0D;
- }
- }
- event.setMotionX(forward * speed * Math.cos(Math.toRadians(yaw + 90.0F)) + strafe * speed * Math.sin(Math.toRadians(yaw + 90.0F)));
- event.setMotionZ(forward * speed * Math.sin(Math.toRadians(yaw + 90.0F)) - strafe * speed * Math.cos(Math.toRadians(yaw + 90.0F)));
- }
- }
- public class Timer
- {
- private long prevMS;
- public Timer()
- {
- this.prevMS = 0L;
- }
- public boolean delay(float milliSec)
- {
- return (float)(getTime() - this.prevMS) >= milliSec;
- }
- public void reset()
- {
- this.prevMS = getTime();
- }
- public long getTime()
- {
- return System.nanoTime() / 1000000L;
- }
- public long getDifference()
- {
- return getTime() - this.prevMS;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement