Filter invalid bounding boxes for entities

This should prevent issues caused by broken horses
This commit is contained in:
Thinkofdeath 2014-12-02 17:53:34 +00:00
parent 0429c76df6
commit 3c4a02ed33
2 changed files with 39 additions and 24 deletions

View File

@ -1,5 +1,5 @@
--- ../work/decompile-8eb82bde//net/minecraft/server/Entity.java 2014-11-28 17:43:43.117707435 +0000 --- ../work/decompile-8eb82bde//net/minecraft/server/Entity.java 2014-12-02 17:53:23.077821724 +0000
+++ src/main/java/net/minecraft/server/Entity.java 2014-11-28 17:38:18.000000000 +0000 +++ src/main/java/net/minecraft/server/Entity.java 2014-12-02 17:52:52.025822413 +0000
@@ -6,8 +6,40 @@ @@ -6,8 +6,40 @@
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -576,3 +576,33 @@
} }
this.dead = true; this.dead = true;
@@ -1680,8 +2042,27 @@
return this.boundingBox;
}
- public void a(AxisAlignedBB axisalignedbb) {
- this.boundingBox = axisalignedbb;
+ public void a(AxisAlignedBB axisalignedbb) {
+ // CraftBukkit start - block invalid bounding boxes
+ double a = axisalignedbb.a,
+ b = axisalignedbb.b,
+ c = axisalignedbb.c,
+ d = axisalignedbb.d,
+ e = axisalignedbb.e,
+ f = axisalignedbb.f;
+ double len = axisalignedbb.d - axisalignedbb.a;
+ if (len < 0) d = a;
+ if (len > 64) d = a + 64.0;
+
+ len = axisalignedbb.e - axisalignedbb.b;
+ if (len < 0) e = b;
+ if (len > 64) e = b + 64.0;
+
+ len = axisalignedbb.f - axisalignedbb.c;
+ if (len < 0) f = c;
+ if (len > 64) f = c + 64.0;
+ this.boundingBox = new AxisAlignedBB(a, b, c, d, e, f);
+ // CraftBukkit end
}
public float getHeadHeight() {

View File

@ -1,5 +1,5 @@
--- ../work/decompile-8eb82bde//net/minecraft/server/EntityHorse.java Sun Nov 30 18:01:41 2014 --- ../work/decompile-8eb82bde//net/minecraft/server/EntityHorse.java 2014-12-02 17:52:23.625823043 +0000
+++ src/main/java/net/minecraft/server/EntityHorse.java Sun Nov 30 18:00:23 2014 +++ src/main/java/net/minecraft/server/EntityHorse.java 2014-12-02 17:51:30.837824215 +0000
@@ -4,6 +4,8 @@ @@ -4,6 +4,8 @@
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -61,12 +61,12 @@
} }
+ // CraftBukkit end */ + // CraftBukkit end */
+ } + }
+
+ // CraftBukkit start - Add method + // CraftBukkit start - Add method
+ @Override + @Override
+ protected void dropDeathLoot(boolean flag, int i) { + protected void dropDeathLoot(boolean flag, int i) {
+ super.dropDeathLoot(flag, i); + super.dropDeathLoot(flag, i);
+
+ // Moved from die method above + // Moved from die method above
+ if (!this.world.isStatic) { + if (!this.world.isStatic) {
+ this.dropChest(); + this.dropChest();
@ -85,22 +85,7 @@
} }
if (!this.cw() && this.passenger == null && this.random.nextInt(300) == 0 && this.world.getType(new BlockPosition(MathHelper.floor(this.locX), MathHelper.floor(this.locY) - 1, MathHelper.floor(this.locZ))).getBlock() == Blocks.GRASS) { if (!this.cw() && this.passenger == null && this.random.nextInt(300) == 0 && this.world.getType(new BlockPosition(MathHelper.floor(this.locX), MathHelper.floor(this.locY) - 1, MathHelper.floor(this.locZ))).getBlock() == Blocks.GRASS) {
@@ -730,6 +746,14 @@ @@ -949,6 +965,7 @@
}
public void s_() {
+ // CraftBukkit start - Remove out of bounds horses, fixes an vanilla bug
+ if ( this.locY < -600 ) {
+ world.removeEntity(this);
+ MinecraftServer.getLogger().warn("Removed oob horse. Prevented a crash for Horse @ " + this.locX + ", " + this.locY + ", " + this.locZ);
+ return;
+ }
+ // CraftBukkit end
+
super.s_();
if (this.world.isStatic && this.datawatcher.a()) {
this.datawatcher.e();
@@ -949,6 +973,7 @@
nbttagcompound.setInt("Temper", this.getTemper()); nbttagcompound.setInt("Temper", this.getTemper());
nbttagcompound.setBoolean("Tame", this.isTame()); nbttagcompound.setBoolean("Tame", this.isTame());
nbttagcompound.setString("OwnerUUID", this.getOwnerUUID()); nbttagcompound.setString("OwnerUUID", this.getOwnerUUID());
@ -108,7 +93,7 @@
if (this.hasChest()) { if (this.hasChest()) {
NBTTagList nbttaglist = new NBTTagList(); NBTTagList nbttaglist = new NBTTagList();
@@ -1001,6 +1026,12 @@ @@ -1001,6 +1018,12 @@
this.setOwnerUUID(s); this.setOwnerUUID(s);
} }
@ -121,7 +106,7 @@
AttributeInstance attributeinstance = this.getAttributeMap().a("Speed"); AttributeInstance attributeinstance = this.getAttributeMap().a("Speed");
if (attributeinstance != null) { if (attributeinstance != null) {
@@ -1166,18 +1197,25 @@ @@ -1166,18 +1189,25 @@
public void v(int i) { public void v(int i) {
if (this.cE()) { if (this.cE()) {