Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/src/main/java/net/minecraft/server/TileEntityMobSpawner.java

110 Zeilen
3.9 KiB
Java

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