2011-01-25 19:14:06 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
public class TileEntityMobSpawner extends TileEntity {
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public int a = -1;
|
2011-01-29 22:50:29 +01:00
|
|
|
public String h = "Pig"; // CraftBukkit private -> public
|
2011-02-23 03:37:56 +01:00
|
|
|
public double b;
|
|
|
|
public double c = 0.0D;
|
2011-01-25 19:14:06 +01:00
|
|
|
|
|
|
|
public TileEntityMobSpawner() {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.a = 20;
|
2011-01-25 19:14:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(String s) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.h = s;
|
2011-01-25 19:14:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a() {
|
2011-02-23 03:37:56 +01:00
|
|
|
return this.d.a((double) this.e + 0.5D, (double) this.f + 0.5D, (double) this.g + 0.5D, 16.0D) != null;
|
2011-01-25 19:14:06 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public void i_() {
|
|
|
|
this.c = this.b;
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.a()) {
|
2011-02-23 03:37:56 +01:00
|
|
|
double d0 = (double) ((float) this.e + this.d.k.nextFloat());
|
|
|
|
double d1 = (double) ((float) this.f + this.d.k.nextFloat());
|
|
|
|
double d2 = (double) ((float) this.g + this.d.k.nextFloat());
|
2011-01-25 19:14:06 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
this.d.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
|
|
|
this.d.a("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
2011-01-25 19:14:06 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
for (this.b += (double) (1000.0F / ((float) this.a + 200.0F)); this.b > 360.0D; this.c -= 360.0D) {
|
|
|
|
this.b -= 360.0D;
|
2011-01-25 19:14:06 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (this.a == -1) {
|
|
|
|
this.c();
|
2011-01-25 19:14:06 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (this.a > 0) {
|
|
|
|
--this.a;
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
|
|
|
byte b0 = 4;
|
|
|
|
|
|
|
|
for (int i = 0; i < b0; ++i) {
|
2011-02-23 03:37:56 +01:00
|
|
|
EntityLiving entityliving = (EntityLiving) ((EntityLiving) EntityTypes.a(this.h, this.d));
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (entityliving == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-13 01:21:50 +01:00
|
|
|
// CraftBukkit start - The world we're spawning in accepts this creature
|
|
|
|
boolean isAnimal = entityliving instanceof EntityAnimal || entityliving instanceof EntityWaterAnimal;
|
2011-02-23 03:37:56 +01:00
|
|
|
if ((isAnimal && !this.d.E) || (!isAnimal && !this.d.D)) {
|
2011-02-13 01:21:50 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
int j = this.d.a(entityliving.getClass(), AxisAlignedBB.b((double) this.e, (double) this.f, (double) this.g, (double) (this.e + 1), (double) (this.f + 1), (double) (this.g + 1)).b(8.0D, 4.0D, 8.0D)).size();
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (j >= 6) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.c();
|
2011-01-29 22:50:29 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entityliving != null) {
|
2011-02-23 03:37:56 +01:00
|
|
|
double d3 = (double) this.e + (this.d.k.nextDouble() - this.d.k.nextDouble()) * 4.0D;
|
|
|
|
double d4 = (double) (this.f + this.d.k.nextInt(3) - 1);
|
|
|
|
double d5 = (double) this.g + (this.d.k.nextDouble() - this.d.k.nextDouble()) * 4.0D;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
entityliving.c(d3, d4, d5, this.d.k.nextFloat() * 360.0F, 0.0F);
|
2011-01-29 22:50:29 +01:00
|
|
|
if (entityliving.b()) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.d.a((Entity) entityliving);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
for (int k = 0; k < 20; ++k) {
|
2011-02-23 03:37:56 +01:00
|
|
|
d0 = (double) this.e + 0.5D + ((double) this.d.k.nextFloat() - 0.5D) * 2.0D;
|
|
|
|
d1 = (double) this.f + 0.5D + ((double) this.d.k.nextFloat() - 0.5D) * 2.0D;
|
|
|
|
d2 = (double) this.g + 0.5D + ((double) this.d.k.nextFloat() - 0.5D) * 2.0D;
|
|
|
|
this.d.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
|
|
|
this.d.a("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
entityliving.M();
|
2011-02-23 03:37:56 +01:00
|
|
|
this.c();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
super.i_();
|
2011-01-25 19:14:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
private void c() {
|
|
|
|
this.a = 200 + this.d.k.nextInt(600);
|
2011-01-25 19:14:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
2011-02-23 03:37:56 +01:00
|
|
|
this.h = nbttagcompound.i("EntityId");
|
|
|
|
this.a = nbttagcompound.d("Delay");
|
2011-01-25 19:14:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
2011-01-29 22:50:29 +01:00
|
|
|
nbttagcompound.a("EntityId", this.h);
|
2011-02-23 03:37:56 +01:00
|
|
|
nbttagcompound.a("Delay", (short) this.a);
|
2011-01-25 19:14:06 +01:00
|
|
|
}
|
|
|
|
}
|