3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 21:10:17 +01:00

Possibly fixed crashes caused by tile entities under certain circumstances again.

Dieser Commit ist enthalten in:
EvilSeph 2011-07-13 19:49:20 -04:00
Ursprung 185d590146
Commit c9979169b9
2 geänderte Dateien mit 139 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,130 @@
package net.minecraft.server;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class TileEntityPiston extends TileEntity {
private int a;
private int b;
private int c;
private boolean i;
private boolean j;
private float k;
private float l;
private static List m = new ArrayList();
public TileEntityPiston() {}
public TileEntityPiston(int i, int j, int k, boolean flag, boolean flag1) {
this.a = i;
this.b = j;
this.c = k;
this.i = flag;
this.j = flag1;
}
public int a() {
return this.a;
}
public int e() {
return this.b;
}
public boolean c() {
return this.i;
}
public int d() {
return this.c;
}
public float a(float f) {
if (f > 1.0F) {
f = 1.0F;
}
return this.l + (this.k - this.l) * f;
}
private void a(float f, float f1) {
if (!this.i) {
--f;
} else {
f = 1.0F - f;
}
AxisAlignedBB axisalignedbb = Block.PISTON_MOVING.a(this.world, this.x, this.y, this.z, this.a, f, this.c);
if (axisalignedbb != null) {
List list = this.world.b((Entity) null, axisalignedbb);
if (!list.isEmpty()) {
m.addAll(list);
Iterator iterator = m.iterator();
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
entity.move((double) (f1 * (float) PistonBlockTextures.b[this.c]), (double) (f1 * (float) PistonBlockTextures.c[this.c]), (double) (f1 * (float) PistonBlockTextures.d[this.c]));
}
m.clear();
}
}
}
public void k() {
if (this.l < 1.0F) {
this.l = this.k = 1.0F;
this.world.o(this.x, this.y, this.z);
this.h();
if (this.world.getTypeId(this.x, this.y, this.z) == Block.PISTON_MOVING.id) {
this.world.setTypeIdAndData(this.x, this.y, this.z, this.a, this.b);
}
}
}
public void g_() {
// CraftBukkit
if (this.world == null) return;
this.l = this.k;
if (this.l >= 1.0F) {
this.a(1.0F, 0.25F);
this.world.o(this.x, this.y, this.z);
this.h();
if (this.world.getTypeId(this.x, this.y, this.z) == Block.PISTON_MOVING.id) {
this.world.setTypeIdAndData(this.x, this.y, this.z, this.a, this.b);
}
} else {
this.k += 0.5F;
if (this.k >= 1.0F) {
this.k = 1.0F;
}
if (this.i) {
this.a(this.k, this.k - this.l + 0.0625F);
}
}
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
this.a = nbttagcompound.e("blockId");
this.b = nbttagcompound.e("blockData");
this.c = nbttagcompound.e("facing");
this.l = this.k = nbttagcompound.g("progress");
this.i = nbttagcompound.m("extending");
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
nbttagcompound.a("blockId", this.a);
nbttagcompound.a("blockData", this.b);
nbttagcompound.a("facing", this.c);
nbttagcompound.a("progress", this.l);
nbttagcompound.a("extending", this.i);
}
}

Datei anzeigen

@ -1144,14 +1144,20 @@ public class World implements IBlockAccess {
TileEntity tileentity1 = (TileEntity) iterator1.next();
if (!tileentity1.g()) {
if (!this.c.contains(tileentity1)) {
// CraftBukkit - order matters, moved down
/* if (!this.c.contains(tileentity1)) {
this.c.add(tileentity1);
}
} */
Chunk chunk1 = this.getChunkAt(tileentity1.x >> 4, tileentity1.z >> 4);
if (chunk1 != null) {
chunk1.a(tileentity1.x & 15, tileentity1.y, tileentity1.z & 15, tileentity1);
// CraftBukkit start - moved in from above
if (!this.c.contains(tileentity1)) {
this.c.add(tileentity1);
}
// CraftBukkit end
}
this.notify(tileentity1.x, tileentity1.y, tileentity1.z);
@ -1539,8 +1545,8 @@ public class World implements IBlockAccess {
if (chunk != null) {
chunk.a(i & 15, j, k & 15, tileentity);
this.c.add(tileentity); // CraftBukkit - moved in from above
}
this.c.add(tileentity);
}
}
}