mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 13:07:06 +01:00
b68b282439
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 Warning: this commit contains more mapping changes from upstream, As always, ensure that you have working backups and test this build before deployment; Developers working on paper will, yet again, need to delete their work/Minecraft/1.13.2 folder Bukkit Changes: 7fca5fd4 SPIGOT-4558: Preserve user order in the face of copied defaults in configurations 15c9b1eb Ignore spurious slot IDs sent by client, e.g. in enchanting tables 5d2a10c5 SPIGOT-3747: Add API for force loaded chunks d6dd2bb3 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent 771db4aa SPIGOT-794: Call EntityPlaceEvent for Minecart placement 55462509 Add InventoryView#getSlotType 2f3ce5b6 Remove EntityTransformEvent and CustomItemTagContainer from draft API f04ad7b6 Make ProjectileLaunchEvent extend EntitySpawnEvent ccb85808 Define EntitySpawnEvent b8cc3ebe Add PlayerItemDamageEvent 184a495d Ease ClassLoader Deadlocks Where Possible 11ac4728 Expand Boolean Prompt Values in Conversation API aae62d51 Added getAllSessionData() to the Conversation API. 9290ff91 Add InventoryView#getInventory API 995e530f Add API to get / set base arrow damage CraftBukkit Changes:c4a67eed
SPIGOT-4556: Fix plugins closing inventory during drop events5be2ddcb
Replace version constants with methods to prevent compiler inlininga5b9c7b3
Use API method to create offset command completions2bc7d1df
SPIGOT-3747: Add API for force loaded chunksa408f375
SPIGOT-3538: Add getHitBlockFace for ProjectileHitEventb54b9409
SPIGOT-2864: Make Arrow / Item setTicksLived behave like FallingBlock79ded7a8
SPIGOT-1811: Death message not shown on respawn screenb4a4f15d
SPIGOT-943: InventoryCloseEvent called on death regardless of open inventory0afed592
SPIGOT-794: Call EntityPlaceEvent for Minecart placement2b2d084a
Add InventoryView#getSlotType01a9959a
Do not use deprecated ItemSpawnEvent constructor9642498d
SPIGOT-4547: Call EntitySpawnEvent as general spawn fallback event963f4a5f
Add PlayerItemDamageEvent63db0445
Add API to get / set base arrow damage531c25d7
Add CraftMagicNumbers.MAPPINGS_VERSION for use by NMS pluginsd05c8b14
Mappings Updatebd36e200
SPIGOT-4551: Ignore invalid attribute modifier slots Spigot Changes: 518206a1 Remove redundant trove depend 1959ad21 MC-11211,SPIGOT-4552: Fix placing double slabs at y = 255 29ab5e43 SPIGOT-3661: Allow arguments in restart-script 7cc46316 SPIGOT-852: Growth modifiers for beetroots, potatoes, carrots 82e117e1 Squelch "fatal: Resolve operation not in progress" message 0a1a68e7 Mappings Update & Patch Rebuild
92 lines
5.5 KiB
Diff
92 lines
5.5 KiB
Diff
From 12e96fa13e82f5b001e6e3ee87ad4a4c347f022e 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 1c0b783e8..c5e541985 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 3311e2b24..2e2d14d93 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -1657,6 +1657,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) {
|
|
@@ -1746,6 +1752,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) {
|
|
@@ -2814,6 +2830,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
|
|
|