| 1 | package net.minecraft.entity.item;
|
| 2 |
|
| 3 | import java.util.List;
|
| 4 | import net.minecraft.block.Block;
|
| 5 | import net.minecraft.block.material.Material;
|
| 6 | import net.minecraft.entity.Entity;
|
| 7 | import net.minecraft.entity.EntityLivingBase;
|
| 8 | import net.minecraft.entity.player.EntityPlayer;
|
| 9 | import net.minecraft.init.Blocks;
|
| 10 | import net.minecraft.init.Items;
|
| 11 | import net.minecraft.item.Item;
|
| 12 | import net.minecraft.nbt.NBTTagCompound;
|
| 13 | import net.minecraft.util.AxisAlignedBB;
|
| 14 | import net.minecraft.util.BlockPos;
|
| 15 | import net.minecraft.util.DamageSource;
|
| 16 | import net.minecraft.util.EntityDamageSourceIndirect;
|
| 17 | import net.minecraft.util.EnumParticleTypes;
|
| 18 | import net.minecraft.util.MathHelper;
|
| 19 | import net.minecraft.world.World;
|
| 20 |
|
| 21 | public class EntityBoat extends Entity
|
| 22 | {
|
| 23 | /** true if no player in boat */
|
| 24 | private boolean isBoatEmpty;
|
| 25 | private double speedMultiplier;
|
| 26 | private int boatPosRotationIncrements;
|
| 27 | private double boatX;
|
| 28 | private double boatY;
|
| 29 | private double boatZ;
|
| 30 | private double boatYaw;
|
| 31 | private double boatPitch;
|
| 32 | private double velocityX;
|
| 33 | private double velocityY;
|
| 34 | private double velocityZ;
|
| 35 |
|
| 36 | public EntityBoat(World worldIn)
|
| 37 | {
|
| 38 | super(worldIn);
|
| 39 | this.isBoatEmpty = true;
|
| 40 | this.speedMultiplier = 0.07D;
|
| 41 | this.preventEntitySpawning = true;
|
| 42 | this.setSize(1.5F, 0.6F);
|
| 43 | }
|
| 44 |
|
| 45 | /**
|
| 46 | * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
|
| 47 | * prevent them from trampling crops
|
| 48 | */
|
| 49 | protected boolean canTriggerWalking()
|
| 50 | {
|
| 51 | return false;
|
| 52 | }
|
| 53 |
|
| 54 | protected void entityInit()
|
| 55 | {
|
| 56 | this.dataWatcher.addObject(17, new Integer(0));
|
| 57 | this.dataWatcher.addObject(18, new Integer(1));
|
| 58 | this.dataWatcher.addObject(19, new Float(0.0F));
|
| 59 | }
|
| 60 |
|
| 61 | /**
|
| 62 | * Returns a boundingBox used to collide the entity with other entities and blocks. This enables the entity to be
|
| 63 | * pushable on contact, like boats or minecarts.
|
| 64 | */
|
| 65 | public AxisAlignedBB getCollisionBox(Entity entityIn)
|
| 66 | {
|
| 67 | return entityIn.getEntityBoundingBox();
|
| 68 | }
|
| 69 |
|
| 70 | /**
|
| 71 | * Returns the collision bounding box for this entity
|
| 72 | */
|
| 73 | public AxisAlignedBB getCollisionBoundingBox()
|
| 74 | {
|
| 75 | return this.getEntityBoundingBox();
|
| 76 | }
|
| 77 |
|
| 78 | /**
|
| 79 | * Returns true if this entity should push and be pushed by other entities when colliding.
|
| 80 | */
|
| 81 | public boolean canBePushed()
|
| 82 | {
|
| 83 | return true;
|
| 84 | }
|
| 85 |
|
| 86 | public EntityBoat(World worldIn, double p_i1705_2_, double p_i1705_4_, double p_i1705_6_)
|
| 87 | {
|
| 88 | this(worldIn);
|
| 89 | this.setPosition(p_i1705_2_, p_i1705_4_, p_i1705_6_);
|
| 90 | this.motionX = 0.0D;
|
| 91 | this.motionY = 0.0D;
|
| 92 | this.motionZ = 0.0D;
|
| 93 | this.prevPosX = p_i1705_2_;
|
| 94 | this.prevPosY = p_i1705_4_;
|
| 95 | this.prevPosZ = p_i1705_6_;
|
| 96 | }
|
| 97 |
|
| 98 | /**
|
| 99 | * Returns the Y offset from the entity's position for any entity riding this one.
|
| 100 | */
|
| 101 | public double getMountedYOffset()
|
| 102 | {
|
| 103 | return -0.3D;
|
| 104 | }
|
| 105 |
|
| 106 | /**
|
| 107 | * Called when the entity is attacked.
|
| 108 | */
|
| 109 | public boolean attackEntityFrom(DamageSource source, float amount)
|
| 110 | {
|
| 111 | if (this.isEntityInvulnerable(source))
|
| 112 | {
|
| 113 | return false;
|
| 114 | }
|
| 115 | else if (!this.worldObj.isRemote && !this.isDead)
|
| 116 | {
|
| 117 | if (this.riddenByEntity != null && this.riddenByEntity == source.getEntity() && source instanceof EntityDamageSourceIndirect)
|
| 118 | {
|
| 119 | return false;
|
| 120 | }
|
| 121 | else
|
| 122 | {
|
| 123 | this.setForwardDirection(-this.getForwardDirection());
|
| 124 | this.setTimeSinceHit(10);
|
| 125 | this.setDamageTaken(this.getDamageTaken() + amount * 10.0F);
|
| 126 | this.setBeenAttacked();
|
| 127 | boolean flag = source.getEntity() instanceof EntityPlayer && ((EntityPlayer)source.getEntity()).capabilities.isCreativeMode;
|
| 128 |
|
| 129 | if (flag || this.getDamageTaken() > 40.0F)
|
| 130 | {
|
| 131 | if (this.riddenByEntity != null)
|
| 132 | {
|
| 133 | this.riddenByEntity.mountEntity(this);
|
| 134 | }
|
| 135 |
|
| 136 | if (!flag && this.worldObj.getGameRules().getBoolean("doEntityDrops"))
|
| 137 | {
|
| 138 | this.dropItemWithOffset(Items.boat, 1, 0.0F);
|
| 139 | }
|
| 140 |
|
| 141 | this.setDead();
|
| 142 | }
|
| 143 |
|
| 144 | return true;
|
| 145 | }
|
| 146 | }
|
| 147 | else
|
| 148 | {
|
| 149 | return true;
|
| 150 | }
|
| 151 | }
|
| 152 |
|
| 153 | /**
|
| 154 | * Setups the entity to do the hurt animation. Only used by packets in multiplayer.
|
| 155 | */
|
| 156 | public void performHurtAnimation()
|
| 157 | {
|
| 158 | this.setForwardDirection(-this.getForwardDirection());
|
| 159 | this.setTimeSinceHit(10);
|
| 160 | this.setDamageTaken(this.getDamageTaken() * 11.0F);
|
| 161 | }
|
| 162 |
|
| 163 | /**
|
| 164 | * Returns true if other Entities should be prevented from moving through this Entity.
|
| 165 | */
|
| 166 | public boolean canBeCollidedWith()
|
| 167 | {
|
| 168 | return !this.isDead;
|
| 169 | }
|
| 170 |
|
| 171 | public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean p_180426_10_)
|
| 172 | {
|
| 173 | if (p_180426_10_ && this.riddenByEntity != null)
|
| 174 | {
|
| 175 | this.prevPosX = this.posX = x;
|
| 176 | this.prevPosY = this.posY = y;
|
| 177 | this.prevPosZ = this.posZ = z;
|
| 178 | this.rotationYaw = yaw;
|
| 179 | this.rotationPitch = pitch;
|
| 180 | this.boatPosRotationIncrements = 0;
|
| 181 | this.setPosition(x, y, z);
|
| 182 | this.motionX = this.velocityX = 0.0D;
|
| 183 | this.motionY = this.velocityY = 0.0D;
|
| 184 | this.motionZ = this.velocityZ = 0.0D;
|
| 185 | }
|
| 186 | else
|
| 187 | {
|
| 188 | if (this.isBoatEmpty)
|
| 189 | {
|
| 190 | this.boatPosRotationIncrements = posRotationIncrements + 5;
|
| 191 | }
|
| 192 | else
|
| 193 | {
|
| 194 | double d0 = x - this.posX;
|
| 195 | double d1 = y - this.posY;
|
| 196 | double d2 = z - this.posZ;
|
| 197 | double d3 = d0 * d0 + d1 * d1 + d2 * d2;
|
| 198 |
|
| 199 | if (d3 <= 1.0D)
|
| 200 | {
|
| 201 | return;
|
| 202 | }
|
| 203 |
|
| 204 | this.boatPosRotationIncrements = 3;
|
| 205 | }
|
| 206 |
|
| 207 | this.boatX = x;
|
| 208 | this.boatY = y;
|
| 209 | this.boatZ = z;
|
| 210 | this.boatYaw = (double)yaw;
|
| 211 | this.boatPitch = (double)pitch;
|
| 212 | this.motionX = this.velocityX;
|
| 213 | this.motionY = this.velocityY;
|
| 214 | this.motionZ = this.velocityZ;
|
| 215 | }
|
| 216 | }
|
| 217 |
|
| 218 | /**
|
| 219 | * Sets the velocity to the args. Args: x, y, z
|
| 220 | */
|
| 221 | public void setVelocity(double x, double y, double z)
|
| 222 | {
|
| 223 | this.velocityX = this.motionX = x;
|
| 224 | this.velocityY = this.motionY = y;
|
| 225 | this.velocityZ = this.motionZ = z;
|
| 226 | }
|
| 227 |
|
| 228 | /**
|
| 229 | * Called to update the entity's position/logic.
|
| 230 | */
|
| 231 | public void onUpdate()
|
| 232 | {
|
| 233 | super.onUpdate();
|
| 234 |
|
| 235 | if (this.getTimeSinceHit() > 0)
|
| 236 | {
|
| 237 | this.setTimeSinceHit(this.getTimeSinceHit() - 1);
|
| 238 | }
|
| 239 |
|
| 240 | if (this.getDamageTaken() > 0.0F)
|
| 241 | {
|
| 242 | this.setDamageTaken(this.getDamageTaken() - 1.0F);
|
| 243 | }
|
| 244 |
|
| 245 | this.prevPosX = this.posX;
|
| 246 | this.prevPosY = this.posY;
|
| 247 | this.prevPosZ = this.posZ;
|
| 248 | int i = 5;
|
| 249 | double d0 = 0.0D;
|
| 250 |
|
| 251 | for (int j = 0; j < i; ++j)
|
| 252 | {
|
| 253 | double d1 = this.getEntityBoundingBox().minY + (this.getEntityBoundingBox().maxY - this.getEntityBoundingBox().minY) * (double)(j + 0) / (double)i - 0.125D;
|
| 254 | double d3 = this.getEntityBoundingBox().minY + (this.getEntityBoundingBox().maxY - this.getEntityBoundingBox().minY) * (double)(j + 1) / (double)i - 0.125D;
|
| 255 | AxisAlignedBB axisalignedbb = new AxisAlignedBB(this.getEntityBoundingBox().minX, d1, this.getEntityBoundingBox().minZ, this.getEntityBoundingBox().maxX, d3, this.getEntityBoundingBox().maxZ);
|
| 256 |
|
| 257 | if (this.worldObj.isAABBInMaterial(axisalignedbb, Material.water))
|
| 258 | {
|
| 259 | d0 += 1.0D / (double)i;
|
| 260 | }
|
| 261 | }
|
| 262 |
|
| 263 | double d9 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
| 264 |
|
| 265 | if (d9 > 0.2975D)
|
| 266 | {
|
| 267 | double d2 = Math.cos((double)this.rotationYaw * Math.PI / 180.0D);
|
| 268 | double d4 = Math.sin((double)this.rotationYaw * Math.PI / 180.0D);
|
| 269 |
|
| 270 | for (int k = 0; (double)k < 1.0D + d9 * 60.0D; ++k)
|
| 271 | {
|
| 272 | double d5 = (double)(this.rand.nextFloat() * 2.0F - 1.0F);
|
| 273 | double d6 = (double)(this.rand.nextInt(2) * 2 - 1) * 0.7D;
|
| 274 |
|
| 275 | if (this.rand.nextBoolean())
|
| 276 | {
|
| 277 | double d7 = this.posX - d2 * d5 * 0.8D + d4 * d6;
|
| 278 | double d8 = this.posZ - d4 * d5 * 0.8D - d2 * d6;
|
| 279 | this.worldObj.spawnParticle(EnumParticleTypes.WATER_SPLASH, d7, this.posY - 0.125D, d8, this.motionX, this.motionY, this.motionZ, new int[0]);
|
| 280 | }
|
| 281 | else
|
| 282 | {
|
| 283 | double d24 = this.posX + d2 + d4 * d5 * 0.7D;
|
| 284 | double d25 = this.posZ + d4 - d2 * d5 * 0.7D;
|
| 285 | this.worldObj.spawnParticle(EnumParticleTypes.WATER_SPLASH, d24, this.posY - 0.125D, d25, this.motionX, this.motionY, this.motionZ, new int[0]);
|
| 286 | }
|
| 287 | }
|
| 288 | }
|
| 289 |
|
| 290 | if (this.worldObj.isRemote && this.isBoatEmpty)
|
| 291 | {
|
| 292 | if (this.boatPosRotationIncrements > 0)
|
| 293 | {
|
| 294 | double d12 = this.posX + (this.boatX - this.posX) / (double)this.boatPosRotationIncrements;
|
| 295 | double d16 = this.posY + (this.boatY - this.posY) / (double)this.boatPosRotationIncrements;
|
| 296 | double d19 = this.posZ + (this.boatZ - this.posZ) / (double)this.boatPosRotationIncrements;
|
| 297 | double d22 = MathHelper.wrapAngleTo180_double(this.boatYaw - (double)this.rotationYaw);
|
| 298 | this.rotationYaw = (float)((double)this.rotationYaw + d22 / (double)this.boatPosRotationIncrements);
|
| 299 | this.rotationPitch = (float)((double)this.rotationPitch + (this.boatPitch - (double)this.rotationPitch) / (double)this.boatPosRotationIncrements);
|
| 300 | --this.boatPosRotationIncrements;
|
| 301 | this.setPosition(d12, d16, d19);
|
| 302 | this.setRotation(this.rotationYaw, this.rotationPitch);
|
| 303 | }
|
| 304 | else
|
| 305 | {
|
| 306 | double d13 = this.posX + this.motionX;
|
| 307 | double d17 = this.posY + this.motionY;
|
| 308 | double d20 = this.posZ + this.motionZ;
|
| 309 | this.setPosition(d13, d17, d20);
|
| 310 |
|
| 311 | if (this.onGround)
|
| 312 | {
|
| 313 | this.motionX *= 0.5D;
|
| 314 | this.motionY *= 0.5D;
|
| 315 | this.motionZ *= 0.5D;
|
| 316 | }
|
| 317 |
|
| 318 | this.motionX *= 0.9900000095367432D;
|
| 319 | this.motionY *= 0.949999988079071D;
|
| 320 | this.motionZ *= 0.9900000095367432D;
|
| 321 | }
|
| 322 | }
|
| 323 | else
|
| 324 | {
|
| 325 | if (d0 < 1.0D)
|
| 326 | {
|
| 327 | double d10 = d0 * 2.0D - 1.0D;
|
| 328 | this.motionY += 0.03999999910593033D * d10;
|
| 329 | }
|
| 330 | else
|
| 331 | {
|
| 332 | if (this.motionY < 0.0D)
|
| 333 | {
|
| 334 | this.motionY /= 2.0D;
|
| 335 | }
|
| 336 |
|
| 337 | this.motionY += 0.007000000216066837D;
|
| 338 | }
|
| 339 |
|
| 340 | if (this.riddenByEntity instanceof EntityLivingBase)
|
| 341 | {
|
| 342 | EntityLivingBase entitylivingbase = (EntityLivingBase)this.riddenByEntity;
|
| 343 | float f = this.riddenByEntity.rotationYaw + -entitylivingbase.moveStrafing * 90.0F;
|
| 344 | this.motionX += -Math.sin((double)(f * (float)Math.PI / 180.0F)) * this.speedMultiplier * (double)entitylivingbase.moveForward * 0.05000000074505806D;
|
| 345 | this.motionZ += Math.cos((double)(f * (float)Math.PI / 180.0F)) * this.speedMultiplier * (double)entitylivingbase.moveForward * 0.05000000074505806D;
|
| 346 | }
|
| 347 |
|
| 348 | double d11 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
| 349 |
|
| 350 | if (d11 > 0.35D)
|
| 351 | {
|
| 352 | double d14 = 0.35D / d11;
|
| 353 | this.motionX *= d14;
|
| 354 | this.motionZ *= d14;
|
| 355 | d11 = 0.35D;
|
| 356 | }
|
| 357 |
|
| 358 | if (d11 > d9 && this.speedMultiplier < 0.35D)
|
| 359 | {
|
| 360 | this.speedMultiplier += (0.35D - this.speedMultiplier) / 35.0D;
|
| 361 |
|
| 362 | if (this.speedMultiplier > 0.35D)
|
| 363 | {
|
| 364 | this.speedMultiplier = 0.35D;
|
| 365 | }
|
| 366 | }
|
| 367 | else
|
| 368 | {
|
| 369 | this.speedMultiplier -= (this.speedMultiplier - 0.07D) / 35.0D;
|
| 370 |
|
| 371 | if (this.speedMultiplier < 0.07D)
|
| 372 | {
|
| 373 | this.speedMultiplier = 0.07D;
|
| 374 | }
|
| 375 | }
|
| 376 |
|
| 377 | for (int i1 = 0; i1 < 4; ++i1)
|
| 378 | {
|
| 379 | int l1 = MathHelper.floor_double(this.posX + ((double)(i1 % 2) - 0.5D) * 0.8D);
|
| 380 | int i2 = MathHelper.floor_double(this.posZ + ((double)(i1 / 2) - 0.5D) * 0.8D);
|
| 381 |
|
| 382 | for (int j2 = 0; j2 < 2; ++j2)
|
| 383 | {
|
| 384 | int l = MathHelper.floor_double(this.posY) + j2;
|
| 385 | BlockPos blockpos = new BlockPos(l1, l, i2);
|
| 386 | Block block = this.worldObj.getBlockState(blockpos).getBlock();
|
| 387 |
|
| 388 | if (block == Blocks.snow_layer)
|
| 389 | {
|
| 390 | this.worldObj.setBlockToAir(blockpos);
|
| 391 | this.isCollidedHorizontally = false;
|
| 392 | }
|
| 393 | else if (block == Blocks.waterlily)
|
| 394 | {
|
| 395 | this.worldObj.destroyBlock(blockpos, true);
|
| 396 | this.isCollidedHorizontally = false;
|
| 397 | }
|
| 398 | }
|
| 399 | }
|
| 400 |
|
| 401 | if (this.onGround)
|
| 402 | {
|
| 403 | this.motionX *= 0.5D;
|
| 404 | this.motionY *= 0.5D;
|
| 405 | this.motionZ *= 0.5D;
|
| 406 | }
|
| 407 |
|
| 408 | this.moveEntity(this.motionX, this.motionY, this.motionZ);
|
| 409 |
|
| 410 | if (this.isCollidedHorizontally && d9 > 0.2975D)
|
| 411 | {
|
| 412 | if (!this.worldObj.isRemote && !this.isDead)
|
| 413 | {
|
| 414 | this.setDead();
|
| 415 |
|
| 416 | if (this.worldObj.getGameRules().getBoolean("doEntityDrops"))
|
| 417 | {
|
| 418 | for (int j1 = 0; j1 < 3; ++j1)
|
| 419 | {
|
| 420 | this.dropItemWithOffset(Item.getItemFromBlock(Blocks.planks), 1, 0.0F);
|
| 421 | }
|
| 422 |
|
| 423 | for (int k1 = 0; k1 < 2; ++k1)
|
| 424 | {
|
| 425 | this.dropItemWithOffset(Items.stick, 1, 0.0F);
|
| 426 | }
|
| 427 | }
|
| 428 | }
|
| 429 | }
|
| 430 | else
|
| 431 | {
|
| 432 | this.motionX *= 0.9900000095367432D;
|
| 433 | this.motionY *= 0.949999988079071D;
|
| 434 | this.motionZ *= 0.9900000095367432D;
|
| 435 | }
|
| 436 |
|
| 437 | this.rotationPitch = 0.0F;
|
| 438 | double d15 = (double)this.rotationYaw;
|
| 439 | double d18 = this.prevPosX - this.posX;
|
| 440 | double d21 = this.prevPosZ - this.posZ;
|
| 441 |
|
| 442 | if (d18 * d18 + d21 * d21 > 0.001D)
|
| 443 | {
|
| 444 | d15 = (double)((float)(MathHelper.atan2(d21, d18) * 180.0D / Math.PI));
|
| 445 | }
|
| 446 |
|
| 447 | double d23 = MathHelper.wrapAngleTo180_double(d15 - (double)this.rotationYaw);
|
| 448 |
|
| 449 | if (d23 > 20.0D)
|
| 450 | {
|
| 451 | d23 = 20.0D;
|
| 452 | }
|
| 453 |
|
| 454 | if (d23 < -20.0D)
|
| 455 | {
|
| 456 | d23 = -20.0D;
|
| 457 | }
|
| 458 |
|
| 459 | this.rotationYaw = (float)((double)this.rotationYaw + d23);
|
| 460 | this.setRotation(this.rotationYaw, this.rotationPitch);
|
| 461 |
|
| 462 | if (!this.worldObj.isRemote)
|
| 463 | {
|
| 464 | List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));
|
| 465 |
|
| 466 | if (list != null && !list.isEmpty())
|
| 467 | {
|
| 468 | for (int k2 = 0; k2 < list.size(); ++k2)
|
| 469 | {
|
| 470 | Entity entity = (Entity)list.get(k2);
|
| 471 |
|
| 472 | if (entity != this.riddenByEntity && entity.canBePushed() && entity instanceof EntityBoat)
|
| 473 | {
|
| 474 | entity.applyEntityCollision(this);
|
| 475 | }
|
| 476 | }
|
| 477 | }
|
| 478 |
|
| 479 | if (this.riddenByEntity != null && this.riddenByEntity.isDead)
|
| 480 | {
|
| 481 | this.riddenByEntity = null;
|
| 482 | }
|
| 483 | }
|
| 484 | }
|
| 485 | }
|
| 486 |
|
| 487 | public void updateRiderPosition()
|
| 488 | {
|
| 489 | if (this.riddenByEntity != null)
|
| 490 | {
|
| 491 | double d0 = Math.cos((double)this.rotationYaw * Math.PI / 180.0D) * 0.4D;
|
| 492 | double d1 = Math.sin((double)this.rotationYaw * Math.PI / 180.0D) * 0.4D;
|
| 493 | this.riddenByEntity.setPosition(this.posX + d0, this.posY + this.getMountedYOffset() + this.riddenByEntity.getYOffset(), this.posZ + d1);
|
| 494 | }
|
| 495 | }
|
| 496 |
|
| 497 | /**
|
| 498 | * (abstract) Protected helper method to write subclass entity data to NBT.
|
| 499 | */
|
| 500 | protected void writeEntityToNBT(NBTTagCompound tagCompound)
|
| 501 | {
|
| 502 | }
|
| 503 |
|
| 504 | /**
|
| 505 | * (abstract) Protected helper method to read subclass entity data from NBT.
|
| 506 | */
|
| 507 | protected void readEntityFromNBT(NBTTagCompound tagCompund)
|
| 508 | {
|
| 509 | }
|
| 510 |
|
| 511 | /**
|
| 512 | * First layer of player interaction
|
| 513 | */
|
| 514 | public boolean interactFirst(EntityPlayer playerIn)
|
| 515 | {
|
| 516 | if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != playerIn)
|
| 517 | {
|
| 518 | return true;
|
| 519 | }
|
| 520 | else
|
| 521 | {
|
| 522 | if (!this.worldObj.isRemote)
|
| 523 | {
|
| 524 | playerIn.mountEntity(this);
|
| 525 | }
|
| 526 |
|
| 527 | return true;
|
| 528 | }
|
| 529 | }
|
| 530 |
|
| 531 | protected void updateFallState(double y, boolean onGroundIn, Block blockIn, BlockPos pos)
|
| 532 | {
|
| 533 | if (onGroundIn)
|
| 534 | {
|
| 535 | if (this.fallDistance > 3.0F)
|
| 536 | {
|
| 537 | this.fall(this.fallDistance, 1.0F);
|
| 538 |
|
| 539 | if (!this.worldObj.isRemote && !this.isDead)
|
| 540 | {
|
| 541 | this.setDead();
|
| 542 |
|
| 543 | if (this.worldObj.getGameRules().getBoolean("doEntityDrops"))
|
| 544 | {
|
| 545 | for (int i = 0; i < 3; ++i)
|
| 546 | {
|
| 547 | this.dropItemWithOffset(Item.getItemFromBlock(Blocks.planks), 1, 0.0F);
|
| 548 | }
|
| 549 |
|
| 550 | for (int j = 0; j < 2; ++j)
|
| 551 | {
|
| 552 | this.dropItemWithOffset(Items.stick, 1, 0.0F);
|
| 553 | }
|
| 554 | }
|
| 555 | }
|
| 556 |
|
| 557 | this.fallDistance = 0.0F;
|
| 558 | }
|
| 559 | }
|
| 560 | else if (this.worldObj.getBlockState((new BlockPos(this)).down()).getBlock().getMaterial() != Material.water && y < 0.0D)
|
| 561 | {
|
| 562 | this.fallDistance = (float)((double)this.fallDistance - y);
|
| 563 | }
|
| 564 | }
|
| 565 |
|
| 566 | /**
|
| 567 | * Sets the damage taken from the last hit.
|
| 568 | */
|
| 569 | public void setDamageTaken(float p_70266_1_)
|
| 570 | {
|
| 571 | this.dataWatcher.updateObject(19, Float.valueOf(p_70266_1_));
|
| 572 | }
|
| 573 |
|
| 574 | /**
|
| 575 | * Gets the damage taken from the last hit.
|
| 576 | */
|
| 577 | public float getDamageTaken()
|
| 578 | {
|
| 579 | return this.dataWatcher.getWatchableObjectFloat(19);
|
| 580 | }
|
| 581 |
|
| 582 | /**
|
| 583 | * Sets the time to count down from since the last time entity was hit.
|
| 584 | */
|
| 585 | public void setTimeSinceHit(int p_70265_1_)
|
| 586 | {
|
| 587 | this.dataWatcher.updateObject(17, Integer.valueOf(p_70265_1_));
|
| 588 | }
|
| 589 |
|
| 590 | /**
|
| 591 | * Gets the time since the last hit.
|
| 592 | */
|
| 593 | public int getTimeSinceHit()
|
| 594 | {
|
| 595 | return this.dataWatcher.getWatchableObjectInt(17);
|
| 596 | }
|
| 597 |
|
| 598 | /**
|
| 599 | * Sets the forward direction of the entity.
|
| 600 | */
|
| 601 | public void setForwardDirection(int p_70269_1_)
|
| 602 | {
|
| 603 | this.dataWatcher.updateObject(18, Integer.valueOf(p_70269_1_));
|
| 604 | }
|
| 605 |
|
| 606 | /**
|
| 607 | * Gets the forward direction of the entity.
|
| 608 | */
|
| 609 | public int getForwardDirection()
|
| 610 | {
|
| 611 | return this.dataWatcher.getWatchableObjectInt(18);
|
| 612 | }
|
| 613 |
|
| 614 | /**
|
| 615 | * true if no player in boat
|
| 616 | */
|
| 617 | public void setIsBoatEmpty(boolean p_70270_1_)
|
| 618 | {
|
| 619 | this.isBoatEmpty = p_70270_1_;
|
| 620 | }
|
| 621 | }
|
| 622 |
|