Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 149 lines 4.6 kB view raw
1package net.minecraft.server; 2 3public class EntitySlime extends EntityLiving implements IMonster { 4 5 public float a; 6 public float b; 7 private int size = 0; 8 9 public EntitySlime(World world) { 10 super(world); 11 this.texture = "/mob/slime.png"; 12 int i = 1 << this.random.nextInt(3); 13 14 this.height = 0.0F; 15 this.size = this.random.nextInt(20) + 10; 16 this.setSize(i); 17 } 18 19 protected void b() { 20 super.b(); 21 this.datawatcher.a(16, new Byte((byte) 1)); 22 } 23 24 public void setSize(int i) { 25 this.datawatcher.watch(16, new Byte((byte) i)); 26 this.b(0.6F * (float) i, 0.6F * (float) i); 27 this.health = i * i; 28 this.setPosition(this.locX, this.locY, this.locZ); 29 } 30 31 public int getSize() { 32 return this.datawatcher.a(16); 33 } 34 35 public void b(NBTTagCompound nbttagcompound) { 36 super.b(nbttagcompound); 37 nbttagcompound.a("Size", this.getSize() - 1); 38 } 39 40 public void a(NBTTagCompound nbttagcompound) { 41 super.a(nbttagcompound); 42 this.setSize(nbttagcompound.e("Size") + 1); 43 } 44 45 public void m_() { 46 this.b = this.a; 47 boolean flag = this.onGround; 48 49 super.m_(); 50 if (this.onGround && !flag) { 51 int i = this.getSize(); 52 53 for (int j = 0; j < i * 8; ++j) { 54 float f = this.random.nextFloat() * 3.1415927F * 2.0F; 55 float f1 = this.random.nextFloat() * 0.5F + 0.5F; 56 float f2 = MathHelper.sin(f) * (float) i * 0.5F * f1; 57 float f3 = MathHelper.cos(f) * (float) i * 0.5F * f1; 58 59 this.world.a("slime", this.locX + (double) f2, this.boundingBox.b, this.locZ + (double) f3, 0.0D, 0.0D, 0.0D); 60 } 61 62 if (i > 2) { 63 this.world.makeSound(this, "mob.slime", this.k(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F); 64 } 65 66 this.a = -0.5F; 67 } 68 69 this.a *= 0.6F; 70 } 71 72 protected void c_() { 73 this.U(); 74 EntityHuman entityhuman = this.world.findNearbyPlayer(this, 16.0D); 75 76 if (entityhuman != null) { 77 this.a(entityhuman, 10.0F, 20.0F); 78 } 79 80 if (this.onGround && this.size-- <= 0) { 81 this.size = this.random.nextInt(20) + 10; 82 if (entityhuman != null) { 83 this.size /= 3; 84 } 85 86 this.aC = true; 87 if (this.getSize() > 1) { 88 this.world.makeSound(this, "mob.slime", this.k(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F); 89 } 90 91 this.a = 1.0F; 92 this.az = 1.0F - this.random.nextFloat() * 2.0F; 93 this.aA = (float) (1 * this.getSize()); 94 } else { 95 this.aC = false; 96 if (this.onGround) { 97 this.az = this.aA = 0.0F; 98 } 99 } 100 } 101 102 public void die() { 103 int i = this.getSize(); 104 105 if (!this.world.isStatic && i > 1 && this.health <= 0) { 106 for (int j = 0; j < 4; ++j) { 107 float f = ((float) (j % 2) - 0.5F) * (float) i / 4.0F; 108 float f1 = ((float) (j / 2) - 0.5F) * (float) i / 4.0F; 109 EntitySlime entityslime = new EntitySlime(this.world); 110 111 entityslime.setSize(i / 2); 112 entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F); 113 this.world.addEntity(entityslime); 114 } 115 } 116 117 super.die(); 118 } 119 120 public void b(EntityHuman entityhuman) { 121 int i = this.getSize(); 122 123 if (i > 1 && this.e(entityhuman) && (double) this.f(entityhuman) < 0.6D * (double) i && entityhuman.damageEntity(this, i)) { 124 this.world.makeSound(this, "mob.slimeattack", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); 125 } 126 } 127 128 protected String h() { 129 return "mob.slime"; 130 } 131 132 protected String i() { 133 return "mob.slime"; 134 } 135 136 protected int j() { 137 return this.getSize() == 1 ? Item.SLIME_BALL.id : 0; 138 } 139 140 public boolean d() { 141 Chunk chunk = this.world.getChunkAtWorldCoords(MathHelper.floor(this.locX), MathHelper.floor(this.locZ)); 142 143 return (this.getSize() == 1 || this.world.spawnMonsters > 0) && this.random.nextInt(10) == 0 && chunk.a(987234911L).nextInt(10) == 0 && this.locY < 16.0D; 144 } 145 146 protected float k() { 147 return 0.6F; 148 } 149}