GenuineSounds

Changes to EntityItem Concept

Jul 7th, 2012
243
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.84 KB | None | 0 0
  1. public void onUpdate() {
  2.     ticksExisted = ++age;
  3.     if (age >= 6000)
  4.         setDead();
  5.     prevPosX = posX;
  6.     prevPosY = posY;
  7.     prevPosZ = posZ;
  8.     if (delayBeforeCanPickup > 0)
  9.         delayBeforeCanPickup--;
  10.     if (motionX != 0 || motionY != 0 || motionZ != 0 || motionX != -0 || motionY != -0 || motionZ != -0) {
  11.         ticksExisted--;
  12.         super.onUpdate();
  13.         if ((Math.abs(motionX) + Math.abs(motionY) + Math.abs(motionZ)) <= 0.001)
  14.             motionX = motionY = motionZ = 0;
  15.         if (onGround)
  16.             motionY = 0;
  17.         if (handleWaterMovement()) {
  18.             if (!inWater) {
  19.                 float f = MathHelper.sqrt_double(motionX * motionX * 0.2 + motionY * motionY + motionZ * motionZ * 0.2) * 0.2F;
  20.                 if (f > 1.0F)
  21.                     f = 1.0F;
  22.                 worldObj.playSoundAtEntity(this, "random.splash", f, 1.0F + (rand.nextFloat() - rand.nextFloat()) * 0.4F);
  23.                 float f1 = MathHelper.floor_double(boundingBox.minY);
  24.                 for (int l = 0; (float) l < 1.0F + width * 20F; l++) {
  25.                     float f2 = (rand.nextFloat() * 2.0F - 1.0F) * width;
  26.                     float f4 = (rand.nextFloat() * 2.0F - 1.0F) * width;
  27.                     worldObj.spawnParticle("bubble", posX + (double) f2, f1 + 1.0F, posZ + (double) f4, motionX, motionY - (double) (rand.nextFloat() * 0.2F), motionZ);
  28.                 }
  29.                 for (int i1 = 0; (float) i1 < 1.0F + width * 20F; i1++) {
  30.                     float f3 = (rand.nextFloat() * 2.0F - 1.0F) * width;
  31.                     float f5 = (rand.nextFloat() * 2.0F - 1.0F) * width;
  32.                     worldObj.spawnParticle("splash", posX + (double) f3, f1 + 1.0F, posZ + (double) f5, motionX, motionY, motionZ);
  33.                 }
  34.             }
  35.             fallDistance = 0.0F;
  36.             inWater = true;
  37.         } else
  38.             inWater = false;
  39.         motionY -= 0.04;
  40.         if (worldObj.getBlockMaterial(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)) == Material.lava) {
  41.             motionY = 0.2;
  42.             motionX = (rand.nextFloat() - rand.nextFloat()) * 0.2F;
  43.             motionZ = (rand.nextFloat() - rand.nextFloat()) * 0.2F;
  44.             worldObj.playSoundAtEntity(this, "random.fizz", 0.4F, 2.0F + rand.nextFloat() * 0.4F);
  45.         }
  46.         pushOutOfBlocks(posX, (boundingBox.minY + boundingBox.maxY) / 2D, posZ);
  47.         moveEntity(motionX, motionY, motionZ);
  48.         float f = 0.98F;
  49.         if (onGround) {
  50.             f = 0.588F;
  51.             int i = worldObj.getBlockId(MathHelper.floor_double(posX), MathHelper.floor_double(boundingBox.minY) - 1, MathHelper.floor_double(posZ));
  52.             if (i > 0)
  53.                 f = Block.blocksList[i].slipperiness * 0.98F;
  54.         }
  55.         motionX *= f;
  56.         motionY *= 0.98D;
  57.         motionZ *= f;
  58.     } else if (worldObj.getBlockId(MathHelper.floor_double(posX), MathHelper.floor_double((boundingBox.minY + boundingBox.maxY) / 2D) - 1, MathHelper.floor_double(posZ)) == 0
  59.             || worldObj.getBlockId(MathHelper.floor_double(posX), MathHelper.floor_double((boundingBox.minY + boundingBox.maxY) / 2D), MathHelper.floor_double(posZ)) != 0)
  60.         motionY = -0.01; // Wake dormant entity up. Use actual calculations if block underneath is removed or entity is covered with a block.
  61. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment