/** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ public void onLivingUpdate() { if (this.sprintingTicksLeft > 0) { --this.sprintingTicksLeft; if (this.sprintingTicksLeft == 0) { this.setSprinting(false); } } if (this.sprintToggleTimer > 0) { --this.sprintToggleTimer; } this.prevTimeInPortal = this.timeInPortal; if (this.inPortal) { if (this.mc.currentScreen != null && !this.mc.currentScreen.doesGuiPauseGame()) { this.mc.displayGuiScreen((GuiScreen)null); } if (this.timeInPortal == 0.0F) { this.mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("portal.trigger"), this.rand.nextFloat() * 0.4F + 0.8F)); } this.timeInPortal += 0.0125F; if (this.timeInPortal >= 1.0F) { this.timeInPortal = 1.0F; } this.inPortal = false; } else if (this.isPotionActive(Potion.confusion) && this.getActivePotionEffect(Potion.confusion).getDuration() > 60) { this.timeInPortal += 0.006666667F; if (this.timeInPortal > 1.0F) { this.timeInPortal = 1.0F; } } else { if (this.timeInPortal > 0.0F) { this.timeInPortal -= 0.05F; } if (this.timeInPortal < 0.0F) { this.timeInPortal = 0.0F; } } if (this.timeUntilPortal > 0) { --this.timeUntilPortal; } boolean flag = this.movementInput.jump; boolean flag1 = this.movementInput.sneak; float f = 0.8F; boolean flag2 = this.movementInput.moveForward >= f; final boolean flag3 = this.movementInput.moveForward >= f; final float forward = this.movementInput.moveForward; final float strafe = this.movementInput.moveStrafe; this.movementInput.updatePlayerMoveState(); new SilentMoveEvent().publishItself(); if (PlayerHandler.moveFix && PlayerHandler.currentMode == PlayerHandler.MoveFixMode.SILENT) { final float[] floats = this.mySilentStrafe(this.movementInput.moveStrafe, this.movementInput.moveForward, this.rotationYaw, true); final float diffForward = forward - floats[1]; final float diffStrafe = strafe - floats[0]; if (this.movementInput.sneak) { this.movementInput.moveStrafe = MathHelper.clamp_float(floats[0], -0.3f, 0.3f); this.movementInput.moveForward = MathHelper.clamp_float(floats[1], -0.3f, 0.3f); } else { if (diffForward >= 2.0f) { floats[1] = 0.0f; } if (diffForward <= -2.0f) { floats[1] = 0.0f; } if (diffStrafe >= 2.0f) { floats[0] = 0.0f; } if (diffStrafe <= -2.0f) { floats[0] = 0.0f; } this.movementInput.moveStrafe = MathHelper.clamp_float(floats[0], -1.0f, 1.0f); this.movementInput.moveForward = MathHelper.clamp_float(floats[1], -1.0f, 1.0f); } } NoSlowEvent noSlowEvent = new NoSlowEvent(0.2f, 0.2f); noSlowEvent.publishItself(); if (this.isUsingItem() && !this.isRiding()) { MovementInput moveInput1 = this.movementInput; moveInput1.moveStrafe *= noSlowEvent.getStrafe(); MovementInput moveInput2 = this.movementInput; moveInput2.moveForward *= noSlowEvent.getForward(); this.sprintToggleTimer = 0; } this.pushOutOfBlocks(this.posX - (double)this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D, this.posZ + (double)this.width * 0.35D); this.pushOutOfBlocks(this.posX - (double)this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D, this.posZ - (double)this.width * 0.35D); this.pushOutOfBlocks(this.posX + (double)this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D, this.posZ - (double)this.width * 0.35D); this.pushOutOfBlocks(this.posX + (double)this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D, this.posZ + (double)this.width * 0.35D); boolean flag69 = (float) this.getFoodStats().getFoodLevel() > 6.0F || this.capabilities.allowFlying; float movef = this.movementInput.moveForward; if (PlayerHandler.shouldSprintReset) { movef = this.movementInput.moveForward; this.movementInput.moveForward = 0; } if (this.onGround && !flag1 && !flag2 && this.movementInput.moveForward >= f && !this.isSprinting() && flag69 && (!this.isUsingItem() || noSlowEvent.isSprint()) && !this.isPotionActive(Potion.blindness)) { if (this.sprintToggleTimer <= 0 && !this.mc.gameSettings.keyBindSprint.isKeyDown()) { this.sprintToggleTimer = 7; } else { this.setSprinting(true); } } if (!this.isSprinting() && this.movementInput.moveForward >= f && flag69 && (!this.isUsingItem() || noSlowEvent.isSprint()) && !this.isPotionActive(Potion.blindness) && this.mc.gameSettings.keyBindSprint.isKeyDown()) { this.setSprinting(true); } final DirectionSprintCheckEvent sprintCheckEvent = new DirectionSprintCheckEvent(this.movementInput.moveForward < f).publishItself(); if (this.isSprinting() && (sprintCheckEvent.isSprintCheck() || this.isCollidedHorizontally || !flag69)) { this.setSprinting(false); } if (!noSlowEvent.isSprint() && this.isUsingItem() && !this.isRiding()) { this.setSprinting(false); } if (PlayerHandler.shouldSprintReset) { this.movementInput.moveForward = movef; PlayerHandler.shouldSprintReset = false; } if (this.capabilities.allowFlying) { if (this.mc.playerController.isSpectatorMode()) { if (!this.capabilities.isFlying) { this.capabilities.isFlying = true; this.sendPlayerAbilities(); } } else if (!flag && this.movementInput.jump) { if (this.flyToggleTimer == 0) { this.flyToggleTimer = 7; } else { this.capabilities.isFlying = !this.capabilities.isFlying; this.sendPlayerAbilities(); this.flyToggleTimer = 0; } } } if (this.capabilities.isFlying && this.isCurrentViewEntity()) { if (this.movementInput.sneak) { this.motionY -= (double)(this.capabilities.getFlySpeed() * 3.0F); } if (this.movementInput.jump) { this.motionY += (double)(this.capabilities.getFlySpeed() * 3.0F); } } if (this.isRidingHorse()) { if (this.horseJumpPowerCounter < 0) { ++this.horseJumpPowerCounter; if (this.horseJumpPowerCounter == 0) { this.horseJumpPower = 0.0F; } } if (flag && !this.movementInput.jump) { this.horseJumpPowerCounter = -10; this.sendHorseJump(); } else if (!flag && this.movementInput.jump) { this.horseJumpPowerCounter = 0; this.horseJumpPower = 0.0F; } else if (flag) { ++this.horseJumpPowerCounter; if (this.horseJumpPowerCounter < 10) { this.horseJumpPower = (float)this.horseJumpPowerCounter * 0.1F; } else { this.horseJumpPower = 0.8F + 2.0F / (float)(this.horseJumpPowerCounter - 9) * 0.1F; } } } else { this.horseJumpPower = 0.0F; } super.onLivingUpdate(); if (this.onGround && this.capabilities.isFlying && !this.mc.playerController.isSpectatorMode()) { this.capabilities.isFlying = false; this.sendPlayerAbilities(); } }