geforkt von Mirrors/Paper
54dd19b818
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 18cda936 Fix variant of unloadChunkRequest that was incorrectly never deprecated 00763e1b Deprecate some methods 35a83d54 SPIGOT-4572: Make default no permission message clearer 6163343d Fix some misplaced material enum entries 8736469c Fix typo in TechnicalPiston documentation CraftBukkit Changes:0c715b32
SPIGOT-4579: Shulker boxes not dropping in creative50fbc3f1
SPIGOT-4576: Fix attributes in itemstack internal data being lost8059a937
SPIGOT-4577: Fix loss of int/double custom tags when serialized to yaml07e504c3
Clarify exception thrown when setting drop chance for player inventory98b862ad
Fix duplicate iron golem add843cee65
Fix a bunch of duplicate EntityCombustEvent calls43855624
SPIGOT-4571: EntityCombustEvent not firing for phantoms
93 Zeilen
5.5 KiB
Diff
93 Zeilen
5.5 KiB
Diff
From df43f5561ed43c61c0631fd2b3fd38677ff38936 Mon Sep 17 00:00:00 2001
|
|
From: Zach Brown <zach.brown@destroystokyo.com>
|
|
Date: Tue, 4 Sep 2018 19:07:57 -0400
|
|
Subject: [PATCH] MC-2025: Save and load entity AABB to prevent wobble
|
|
|
|
What follows is a summarized analysis provided on the Mojira and associated subreddit by various MC community members
|
|
who have investigated this issue and found a solution. This work is largely a result of their efforts.
|
|
|
|
The underlying cause of MC-2025 is that sometimes an AABB ends up slightly smaller than the desired width. If this
|
|
happens before the entity is pushed up against a boundary (i.e. blocks or walls), then upon chunk save and reload, the
|
|
AABB size will be recomputed such that it is intersecting the wall, allowing the entity to be pushed into the wall,
|
|
suffocate, and die. Although the rounding artifacts get larger at larger world coordinates, the drift we see is
|
|
miniscule. Closer to the world origin, we have seen error on the order of 2-46. Compare this to the fact that
|
|
(due to MC-4), entity coordinates send to clients are quantized to multiples of 1/4096 (2-12).
|
|
|
|
But, OMG, do the rounding errors mean that AABB's accumulate shrinkage over time? Actually, no. The statistics on IEEE
|
|
rounding do not have that kind of bias. What has not been stated is that the AABB is just as likely to end up larger
|
|
than the expected width; on save and reload, the entity ends up slightly away from the wall, and we don't notice any
|
|
problem. In reality, the AABB size ends up undergoing random wobble around the expected value all the time, and that
|
|
wobble isn't functionally any different from the kind we'd get even if we tried to force the AABB size to be stable!
|
|
|
|
This reasoning leads us to one clear conclusion: The simplest, least invasive, and most correct solution is to just
|
|
store the AABB in NBT data on chunk save and restore the AABB exactly as it was saved upon reload.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/AxisAlignedBB.java b/src/main/java/net/minecraft/server/AxisAlignedBB.java
|
|
index 1c0b783e8e..c5e541985f 100644
|
|
--- a/src/main/java/net/minecraft/server/AxisAlignedBB.java
|
|
+++ b/src/main/java/net/minecraft/server/AxisAlignedBB.java
|
|
@@ -5,12 +5,12 @@ import javax.annotation.Nullable;
|
|
|
|
public class AxisAlignedBB {
|
|
|
|
- public final double minX;
|
|
- public final double minY;
|
|
- public final double minZ;
|
|
- public final double maxX;
|
|
- public final double maxY;
|
|
- public final double maxZ;
|
|
+ public final double minX; public double getMinX() { return this.minX; } // Paper - OBFHELPER
|
|
+ public final double minY; public double getMinY() { return this.minY; } // Paper - OBFHELPER
|
|
+ public final double minZ; public double getMinZ() { return this.minZ; } // Paper - OBFHELPER
|
|
+ public final double maxX; public double getMaxX() { return this.maxX; } // Paper - OBFHELPER
|
|
+ public final double maxY; public double getMaxY() { return this.maxY; } // Paper - OBFHELPER
|
|
+ public final double maxZ; public double getMaxZ() { return this.maxZ; } // Paper - OBFHELPER
|
|
|
|
public AxisAlignedBB(double d0, double d1, double d2, double d3, double d4, double d5) {
|
|
this.minX = Math.min(d0, d3);
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index c29d7eeb0a..6b65c69423 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -1673,6 +1673,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
if (spawnedViaMobSpawner) {
|
|
nbttagcompound.setBoolean("Paper.FromMobSpawner", true);
|
|
}
|
|
+ // Paper start - MC-2025 fix - Save entity AABB and load it, floating point issues recalculating AABB can result in wobble
|
|
+ AxisAlignedBB boundingBox = this.getBoundingBox();
|
|
+ nbttagcompound.set("Paper.AAAB", this.createList(
|
|
+ boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(),
|
|
+ boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ()
|
|
+ ));
|
|
// Paper end
|
|
return nbttagcompound;
|
|
} catch (Throwable throwable) {
|
|
@@ -1762,6 +1768,16 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
if (this.aD()) {
|
|
this.setPosition(this.locX, this.locY, this.locZ);
|
|
}
|
|
+ // Paper start - MC-2025 fix - Save entity AABB and load it, floating point issues recalculating AABB can result in wobble
|
|
+ // Placement is important, always after the setPosition call above
|
|
+ if (nbttagcompound.hasKey("Paper.AABB")) {
|
|
+ NBTTagList savedBB = nbttagcompound.getList("Paper.AABB", 6);
|
|
+ this.setBoundingBox(new AxisAlignedBB(
|
|
+ savedBB.getDoubleAt(0), savedBB.getDoubleAt(1), savedBB.getDoubleAt(2),
|
|
+ savedBB.getDoubleAt(3), savedBB.getDoubleAt(4), savedBB.getDoubleAt(5)
|
|
+ ));
|
|
+ }
|
|
+ // Paper end
|
|
|
|
// CraftBukkit start
|
|
if (this instanceof EntityLiving) {
|
|
@@ -2830,6 +2846,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
return this.boundingBox;
|
|
}
|
|
|
|
+ public void setBoundingBox(AxisAlignedBB axisAlignedBB) { this.a(axisAlignedBB); } // Paper - OBFHELPER
|
|
public void a(AxisAlignedBB axisalignedbb) {
|
|
// CraftBukkit start - block invalid bounding boxes
|
|
double minX = axisalignedbb.minX,
|
|
--
|
|
2.20.1
|
|
|