@Override public boolean update() { EntityHuman passenger = (EntityHuman) this.getEntityHandle().passenger; EntityLiving entity = this.getEntityHandle(); float f = MathHelper.g(passenger.yaw - entity.yaw) * 0.5f; if (f > 5) f = 5; if (f < -5) f = -5; entity.yaw = MathHelper.g(entity.yaw + f); if (this.m_currentSpeed < this.m_maxSpeed) this.m_currentSpeed += (this.m_maxSpeed - this.m_currentSpeed) * 0.01; if (this.m_currentSpeed > this.m_maxSpeed) this.m_currentSpeed = this.m_maxSpeed; int x = MathHelper.floor(entity.locX); int y = MathHelper.floor(entity.locY); int z = MathHelper.floor(entity.locZ); float speed = this.m_currentSpeed; if (this.m_speedBoosted) { if (this.m_speedBoostTime++ > this.m_maxSpeedBoostTime) this.m_speedBoosted = false; speed += speed * 1.15 * MathHelper.sin( (float) (this.m_speedBoostTime / this.m_maxSpeedBoostTime * Math.PI)); } float f2 = 0.91f; if (entity.onGround) { f2 = 0.54600006F; Block block = entity.world.getType(MathHelper.d(x), MathHelper.d(y) - 1, MathHelper.d(z)); if (block.getMaterial() != Material.AIR) f2 = block.frictionFactor * 0.91f; } float f3 = 0.16277136F / (f2 * f2 * f2); float f4 = MathHelper.sin(entity.yaw * 3.1415927F / 180.0F); float f5 = MathHelper.cos(entity.yaw * 3.1415927F / 180.0F); float f6 = entity.bl() * f3; float f7 = Math.max(speed, 1.0F); f7 = f6 / f7; float f8 = speed * f7; float f9 = -(f8 * f4); float f10 = f8 * f5; if (MathHelper.abs(f9) > MathHelper.abs(f10)) { if (f9 < 0.0F) { f9 -= entity.width / 2.0F; } if (f9 > 0.0F) { f9 += entity.width / 2.0F; } f10 = 0.0F; } else { f9 = 0.0F; if (f10 < 0.0F) { f10 -= entity.width / 2.0F; } if (f10 > 0.0F) { f10 += entity.width / 2.0F; } } int nextX = MathHelper.floor(entity.locX + f9); int nextZ = MathHelper.floor(entity.locZ + f10); PathPoint point = new PathPoint( MathHelper.d(entity.width + 1), MathHelper.d(entity.length + passenger.length + 1), MathHelper.d(entity.width + 1)); if (x != nextX || z != nextZ) { Block type1 = entity.world.getType(x, y, z); Block type2 = entity.world.getType(x, y - 1, z); boolean isStep = this.isStep(type1) || type1 == null && this.isStep(type2); if (!isStep && Pathfinder.a(entity, nextX, y, nextZ, point, false, false, true) == 0 && Pathfinder.a(entity, x, y + 1, z, point, false, false, true) == 1 && Pathfinder.a(entity, nextX, y + 1, nextZ, point, false, false, true) == 1) NMSUtil.getControllerLook(entity).a(); } if (!passenger.abilities.canInstantlyBuild && this.m_currentSpeed >= this.m_maxSpeed * 0.5 && entity.aI().nextFloat() < 0.006f && !this.m_speedBoosted) { ItemStack item = passenger.be(); if (item != null && item.getItem() == Items.CARROT_STICK) { item.damage(1, passenger); if (item.count == 0) { ItemStack newItem = new ItemStack(Items.FISHING_ROD); newItem.setTag(item.tag); passenger.inventory.items[passenger.inventory.itemInHandIndex] = newItem; } } } entity.e(0, speed); return true; }
/** Updates the task */ public void updateTask() { EntityPlayer var1 = (EntityPlayer) this.thisEntity.riddenByEntity; EntityCreature var2 = (EntityCreature) this.thisEntity; float var3 = MathHelper.wrapAngleTo180_float(var1.rotationYaw - this.thisEntity.rotationYaw) * 0.5F; if (var3 > 5.0F) { var3 = 5.0F; } if (var3 < -5.0F) { var3 = -5.0F; } this.thisEntity.rotationYaw = MathHelper.wrapAngleTo180_float(this.thisEntity.rotationYaw + var3); if (this.currentSpeed < this.maxSpeed) { this.currentSpeed += (this.maxSpeed - this.currentSpeed) * 0.01F; } if (this.currentSpeed > this.maxSpeed) { this.currentSpeed = this.maxSpeed; } int var4 = MathHelper.floor_double(this.thisEntity.posX); int var5 = MathHelper.floor_double(this.thisEntity.posY); int var6 = MathHelper.floor_double(this.thisEntity.posZ); float var7 = this.currentSpeed; if (this.speedBoosted) { if (this.speedBoostTime++ > this.maxSpeedBoostTime) { this.speedBoosted = false; } var7 += var7 * 1.15F * MathHelper.sin( (float) this.speedBoostTime / (float) this.maxSpeedBoostTime * (float) Math.PI); } float var8 = 0.91F; if (this.thisEntity.onGround) { var8 = 0.54600006F; int var9 = this.thisEntity.worldObj.getBlockId( MathHelper.floor_float((float) var4), MathHelper.floor_float((float) var5) - 1, MathHelper.floor_float((float) var6)); if (var9 > 0) { var8 = Block.blocksList[var9].slipperiness * 0.91F; } } float var23 = 0.16277136F / (var8 * var8 * var8); float var10 = MathHelper.sin(var2.rotationYaw * (float) Math.PI / 180.0F); float var11 = MathHelper.cos(var2.rotationYaw * (float) Math.PI / 180.0F); float var12 = var2.getAIMoveSpeed() * var23; float var13 = Math.max(var7, 1.0F); var13 = var12 / var13; float var14 = var7 * var13; float var15 = -(var14 * var10); float var16 = var14 * var11; if (MathHelper.abs(var15) > MathHelper.abs(var16)) { if (var15 < 0.0F) { var15 -= this.thisEntity.width / 2.0F; } if (var15 > 0.0F) { var15 += this.thisEntity.width / 2.0F; } var16 = 0.0F; } else { var15 = 0.0F; if (var16 < 0.0F) { var16 -= this.thisEntity.width / 2.0F; } if (var16 > 0.0F) { var16 += this.thisEntity.width / 2.0F; } } int var17 = MathHelper.floor_double(this.thisEntity.posX + (double) var15); int var18 = MathHelper.floor_double(this.thisEntity.posZ + (double) var16); PathPoint var19 = new PathPoint( MathHelper.floor_float(this.thisEntity.width + 1.0F), MathHelper.floor_float(this.thisEntity.height + var1.height + 1.0F), MathHelper.floor_float(this.thisEntity.width + 1.0F)); if (var4 != var17 || var6 != var18) { int var20 = this.thisEntity.worldObj.getBlockId(var4, var5, var6); int var21 = this.thisEntity.worldObj.getBlockId(var4, var5 - 1, var6); boolean var22 = this.func_98216_b(var20) || Block.blocksList[var20] == null && this.func_98216_b(var21); if (!var22 && PathFinder.func_82565_a(this.thisEntity, var17, var5, var18, var19, false, false, true) == 0 && PathFinder.func_82565_a( this.thisEntity, var4, var5 + 1, var6, var19, false, false, true) == 1 && PathFinder.func_82565_a( this.thisEntity, var17, var5 + 1, var18, var19, false, false, true) == 1) { var2.getJumpHelper().setJumping(); } } if (!var1.capabilities.isCreativeMode && this.currentSpeed >= this.maxSpeed * 0.5F && this.thisEntity.getRNG().nextFloat() < 0.006F && !this.speedBoosted) { ItemStack var24 = var1.getHeldItem(); if (var24 != null && var24.itemID == Item.carrotOnAStick.itemID) { var24.damageItem(1, var1); if (var24.stackSize == 0) { ItemStack var25 = new ItemStack(Item.fishingRod); var25.setTagCompound(var24.stackTagCompound); var1.inventory.mainInventory[var1.inventory.currentItem] = var25; } } } this.thisEntity.moveEntityWithHeading(0.0F, var7); }