3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 12:30:06 +01:00

Fixed chunk corruption with mobspawners

Dieser Commit ist enthalten in:
Dinner Bone 2011-01-25 10:14:06 -08:00
Ursprung 02a1c24746
Commit 0ba870434e

Datei anzeigen

@ -1,108 +1,108 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
public class TileEntityMobSpawner extends TileEntity { public class TileEntityMobSpawner extends TileEntity {
public int e; public int e;
public String h; // CraftBukkit -> public public String h; // CraftBukkit -> public
public double f; public double f;
public double g; public double g;
public TileEntityMobSpawner() { public TileEntityMobSpawner() {
e = -1; e = -1;
g = 0.0D; g = 0.0D;
h = "Pig"; h = "Pig";
e = 20; e = 20;
} }
public void a(String s) { public void a(String s) {
h = s; h = s;
} }
public boolean a() { public boolean a() {
return a.a((double) b + 0.5D, (double) c + 0.5D, (double) d + 0.5D, 16D) != null; return a.a((double) b + 0.5D, (double) c + 0.5D, (double) d + 0.5D, 16D) != null;
} }
public void f() { public void f() {
g = f; g = f;
if (!a()) { if (!a()) {
return; return;
} }
double d = (float) b + a.l.nextFloat(); double d = (float) b + a.l.nextFloat();
double d2 = (float) c + a.l.nextFloat(); double d2 = (float) c + a.l.nextFloat();
double d4 = (float) this.d + a.l.nextFloat(); double d4 = (float) this.d + a.l.nextFloat();
a.a("smoke", d, d2, d4, 0.0D, 0.0D, 0.0D); a.a("smoke", d, d2, d4, 0.0D, 0.0D, 0.0D);
a.a("flame", d, d2, d4, 0.0D, 0.0D, 0.0D); a.a("flame", d, d2, d4, 0.0D, 0.0D, 0.0D);
for (f += 1000F / ((float) e + 200F); f > 360D;) { for (f += 1000F / ((float) e + 200F); f > 360D;) {
f -= 360D; f -= 360D;
g -= 360D; g -= 360D;
} }
if (e == -1) { if (e == -1) {
b(); b();
} }
if (e > 0) { if (e > 0) {
e--; e--;
return; return;
} }
byte byte0 = 4; byte byte0 = 4;
for (int i = 0; i < byte0; i++) { for (int i = 0; i < byte0; i++) {
EntityLiving entityliving = (EntityLiving) EntityList.a(h, a); EntityLiving entityliving = (EntityLiving) EntityList.a(h, a);
if (entityliving == null) { if (entityliving == null) {
return; return;
} }
int j = a.a(((entityliving)).getClass(), AxisAlignedBB.b(b, c, this.d, b + 1, c + 1, this.d + 1).b(8D, 4D, 8D)).size(); int j = a.a(((entityliving)).getClass(), AxisAlignedBB.b(b, c, this.d, b + 1, c + 1, this.d + 1).b(8D, 4D, 8D)).size();
if (j >= 6) { if (j >= 6) {
b(); b();
return; return;
} }
if (entityliving == null) { if (entityliving == null) {
continue; continue;
} }
double d6 = (double) b + (a.l.nextDouble() - a.l.nextDouble()) * 4D; double d6 = (double) b + (a.l.nextDouble() - a.l.nextDouble()) * 4D;
double d7 = (c + a.l.nextInt(3)) - 1; double d7 = (c + a.l.nextInt(3)) - 1;
double d8 = (double) this.d + (a.l.nextDouble() - a.l.nextDouble()) * 4D; double d8 = (double) this.d + (a.l.nextDouble() - a.l.nextDouble()) * 4D;
entityliving.c(d6, d7, d8, a.l.nextFloat() * 360F, 0.0F); entityliving.c(d6, d7, d8, a.l.nextFloat() * 360F, 0.0F);
if (!entityliving.b()) { if (!entityliving.b()) {
continue; continue;
} }
a.a(((Entity) (entityliving))); a.a(((Entity) (entityliving)));
for (int k = 0; k < 20; k++) { for (int k = 0; k < 20; k++) {
double d1 = (double) b + 0.5D + ((double) a.l.nextFloat() - 0.5D) * 2D; double d1 = (double) b + 0.5D + ((double) a.l.nextFloat() - 0.5D) * 2D;
double d3 = (double) c + 0.5D + ((double) a.l.nextFloat() - 0.5D) * 2D; double d3 = (double) c + 0.5D + ((double) a.l.nextFloat() - 0.5D) * 2D;
double d5 = (double) this.d + 0.5D + ((double) a.l.nextFloat() - 0.5D) * 2D; double d5 = (double) this.d + 0.5D + ((double) a.l.nextFloat() - 0.5D) * 2D;
a.a("smoke", d1, d3, d5, 0.0D, 0.0D, 0.0D); a.a("smoke", d1, d3, d5, 0.0D, 0.0D, 0.0D);
a.a("flame", d1, d3, d5, 0.0D, 0.0D, 0.0D); a.a("flame", d1, d3, d5, 0.0D, 0.0D, 0.0D);
} }
entityliving.R(); entityliving.R();
b(); b();
} }
super.f(); super.f();
} }
private void b() { private void b() {
e = 200 + a.l.nextInt(600); e = 200 + a.l.nextInt(600);
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound); super.a(nbttagcompound);
h = nbttagcompound.h("EntityId"); h = nbttagcompound.h("EntityId");
e = ((int) (nbttagcompound.c("Delay"))); e = ((short) (nbttagcompound.c("Delay")));
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound); super.b(nbttagcompound);
nbttagcompound.a("EntityId", h); nbttagcompound.a("EntityId", h);
nbttagcompound.a("Delay", (short) e); nbttagcompound.a("Delay", (short) e);
} }
} }