public Vec3 func_70489_a(double p_70489_1_, double p_70489_3_, double p_70489_5_) { int i = MathHelper.floor_double(p_70489_1_); int j = MathHelper.floor_double(p_70489_3_); int k = MathHelper.floor_double(p_70489_5_); if (BlockRailBase.isRailBlock(this.worldObj, new BlockPos(i, j - 1, k))) { --j; } IBlockState iblockstate = this.worldObj.getBlockState(new BlockPos(i, j, k)); if (BlockRailBase.isRailBlock(iblockstate)) { BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection) iblockstate.getValue(((BlockRailBase) iblockstate.getBlock()).getShapeProperty()); int[][] aint = matrix[blockrailbase$enumraildirection.getMetadata()]; double d0 = 0.0D; double d1 = (double) i + 0.5D + (double) aint[0][0] * 0.5D; double d2 = (double) j + 0.0625D + (double) aint[0][1] * 0.5D; double d3 = (double) k + 0.5D + (double) aint[0][2] * 0.5D; double d4 = (double) i + 0.5D + (double) aint[1][0] * 0.5D; double d5 = (double) j + 0.0625D + (double) aint[1][1] * 0.5D; double d6 = (double) k + 0.5D + (double) aint[1][2] * 0.5D; double d7 = d4 - d1; double d8 = (d5 - d2) * 2.0D; double d9 = d6 - d3; if (d7 == 0.0D) { p_70489_1_ = (double) i + 0.5D; d0 = p_70489_5_ - (double) k; } else if (d9 == 0.0D) { p_70489_5_ = (double) k + 0.5D; d0 = p_70489_1_ - (double) i; } else { double d10 = p_70489_1_ - d1; double d11 = p_70489_5_ - d3; d0 = (d10 * d7 + d11 * d9) * 2.0D; } p_70489_1_ = d1 + d7 * d0; p_70489_3_ = d2 + d8 * d0; p_70489_5_ = d3 + d9 * d0; if (d8 < 0.0D) { ++p_70489_3_; } if (d8 > 0.0D) { p_70489_3_ += 0.5D; } return new Vec3(p_70489_1_, p_70489_3_, p_70489_5_); } else { return null; } }
public Vec3 func_70495_a( double p_70495_1_, double p_70495_3_, double p_70495_5_, double p_70495_7_) { int i = MathHelper.floor_double(p_70495_1_); int j = MathHelper.floor_double(p_70495_3_); int k = MathHelper.floor_double(p_70495_5_); if (BlockRailBase.isRailBlock(this.worldObj, new BlockPos(i, j - 1, k))) { --j; } IBlockState iblockstate = this.worldObj.getBlockState(new BlockPos(i, j, k)); if (BlockRailBase.isRailBlock(iblockstate)) { BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection) iblockstate.getValue(((BlockRailBase) iblockstate.getBlock()).getShapeProperty()); p_70495_3_ = (double) j; if (blockrailbase$enumraildirection.isAscending()) { p_70495_3_ = (double) (j + 1); } int[][] aint = matrix[blockrailbase$enumraildirection.getMetadata()]; double d0 = (double) (aint[1][0] - aint[0][0]); double d1 = (double) (aint[1][2] - aint[0][2]); double d2 = Math.sqrt(d0 * d0 + d1 * d1); d0 = d0 / d2; d1 = d1 / d2; p_70495_1_ = p_70495_1_ + d0 * p_70495_7_; p_70495_5_ = p_70495_5_ + d1 * p_70495_7_; if (aint[0][1] != 0 && MathHelper.floor_double(p_70495_1_) - i == aint[0][0] && MathHelper.floor_double(p_70495_5_) - k == aint[0][2]) { p_70495_3_ += (double) aint[0][1]; } else if (aint[1][1] != 0 && MathHelper.floor_double(p_70495_1_) - i == aint[1][0] && MathHelper.floor_double(p_70495_5_) - k == aint[1][2]) { p_70495_3_ += (double) aint[1][1]; } return this.func_70489_a(p_70495_1_, p_70495_3_, p_70495_5_); } else { return null; } }
/** Called to update the entity's position/logic. */ public void onUpdate() { if (this.getRollingAmplitude() > 0) { this.setRollingAmplitude(this.getRollingAmplitude() - 1); } if (this.getDamage() > 0.0F) { this.setDamage(this.getDamage() - 1.0F); } if (this.posY < -64.0D) { this.kill(); } if (!this.worldObj.isRemote && this.worldObj instanceof WorldServer) { this.worldObj.theProfiler.startSection("portal"); MinecraftServer minecraftserver = ((WorldServer) this.worldObj).getMinecraftServer(); int i = this.getMaxInPortalTime(); if (this.inPortal) { if (minecraftserver.getAllowNether()) { if (this.ridingEntity == null && this.portalCounter++ >= i) { this.portalCounter = i; this.timeUntilPortal = this.getPortalCooldown(); int j; if (this.worldObj.provider.getDimensionId() == -1) { j = 0; } else { j = -1; } this.travelToDimension(j); } this.inPortal = false; } } else { if (this.portalCounter > 0) { this.portalCounter -= 4; } if (this.portalCounter < 0) { this.portalCounter = 0; } } if (this.timeUntilPortal > 0) { --this.timeUntilPortal; } this.worldObj.theProfiler.endSection(); } if (this.worldObj.isRemote) { if (this.turnProgress > 0) { double d4 = this.posX + (this.minecartX - this.posX) / (double) this.turnProgress; double d5 = this.posY + (this.minecartY - this.posY) / (double) this.turnProgress; double d6 = this.posZ + (this.minecartZ - this.posZ) / (double) this.turnProgress; double d1 = MathHelper.wrapAngleTo180_double(this.minecartYaw - (double) this.rotationYaw); this.rotationYaw = (float) ((double) this.rotationYaw + d1 / (double) this.turnProgress); this.rotationPitch = (float) ((double) this.rotationPitch + (this.minecartPitch - (double) this.rotationPitch) / (double) this.turnProgress); --this.turnProgress; this.setPosition(d4, d5, d6); this.setRotation(this.rotationYaw, this.rotationPitch); } else { this.setPosition(this.posX, this.posY, this.posZ); this.setRotation(this.rotationYaw, this.rotationPitch); } } else { this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; this.motionY -= 0.03999999910593033D; int k = MathHelper.floor_double(this.posX); int l = MathHelper.floor_double(this.posY); int i1 = MathHelper.floor_double(this.posZ); if (BlockRailBase.isRailBlock(this.worldObj, new BlockPos(k, l - 1, i1))) { --l; } BlockPos blockpos = new BlockPos(k, l, i1); IBlockState iblockstate = this.worldObj.getBlockState(blockpos); if (BlockRailBase.isRailBlock(iblockstate)) { this.func_180460_a(blockpos, iblockstate); if (iblockstate.getBlock() == Blocks.activator_rail) { this.onActivatorRailPass( k, l, i1, ((Boolean) iblockstate.getValue(BlockRailPowered.POWERED)).booleanValue()); } } else { this.moveDerailedMinecart(); } this.doBlockCollisions(); this.rotationPitch = 0.0F; double d0 = this.prevPosX - this.posX; double d2 = this.prevPosZ - this.posZ; if (d0 * d0 + d2 * d2 > 0.001D) { this.rotationYaw = (float) (MathHelper.func_181159_b(d2, d0) * 180.0D / Math.PI); if (this.isInReverse) { this.rotationYaw += 180.0F; } } double d3 = (double) MathHelper.wrapAngleTo180_float(this.rotationYaw - this.prevRotationYaw); if (d3 < -170.0D || d3 >= 170.0D) { this.rotationYaw += 180.0F; this.isInReverse = !this.isInReverse; } this.setRotation(this.rotationYaw, this.rotationPitch); for (Entity entity : this.worldObj.getEntitiesWithinAABBExcludingEntity( this, this.getEntityBoundingBox() .expand(0.20000000298023224D, 0.0D, 0.20000000298023224D))) { if (entity != this.riddenByEntity && entity.canBePushed() && entity instanceof EntityMinecart) { entity.applyEntityCollision(this); } } if (this.riddenByEntity != null && this.riddenByEntity.isDead) { if (this.riddenByEntity.ridingEntity == this) { this.riddenByEntity.ridingEntity = null; } this.riddenByEntity = null; } this.handleWaterMovement(); } }