Properly track block update flags (actually fixes #5038)

This commit is contained in:
Shane Freeder 2021-01-11 19:08:03 +00:00
parent ace3146df2
commit 880a910a9b
2 changed files with 4 additions and 50 deletions

View File

@ -18,7 +18,7 @@ the blockstate that will be valid for restoration, as opposed to dropping
information on restoration when the event is cancelled. information on restoration when the event is cancelled.
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 327a668f1306f1ec90e63598da925fce576e6ed5..54d7d0da6ee998319db2454372ca283a9d571cdb 100644 index f3ac45a5936c2fbf3b013bfbb904effed5241e15..33444cd8aec8ce39fb4fef232909cd42ef036d54 100644
--- a/src/main/java/net/minecraft/server/World.java --- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java
@@ -71,7 +71,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable { @@ -71,7 +71,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@ -39,16 +39,17 @@ index 327a668f1306f1ec90e63598da925fce576e6ed5..54d7d0da6ee998319db2454372ca283a
if (blockstate == null) { if (blockstate == null) {
blockstate = CapturedBlockState.getTreeBlockState(this, blockposition, i); blockstate = CapturedBlockState.getTreeBlockState(this, blockposition, i);
this.capturedBlockStates.put(blockposition.immutableCopy(), blockstate); this.capturedBlockStates.put(blockposition.immutableCopy(), blockstate);
@@ -313,7 +313,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable { @@ -313,7 +313,8 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
// CraftBukkit start - capture blockstates // CraftBukkit start - capture blockstates
boolean captured = false; boolean captured = false;
if (this.captureBlockStates && !this.capturedBlockStates.containsKey(blockposition)) { if (this.captureBlockStates && !this.capturedBlockStates.containsKey(blockposition)) {
- CapturedBlockState blockstate = CapturedBlockState.getBlockState(this, blockposition, i); - CapturedBlockState blockstate = CapturedBlockState.getBlockState(this, blockposition, i);
+ CraftBlockState blockstate = (CraftBlockState) world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()).getState(); // Paper - use CB getState to get a suitable snapshot + CraftBlockState blockstate = (CraftBlockState) world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()).getState(); // Paper - use CB getState to get a suitable snapshot
+ blockstate.setFlag(i); // Paper - set flag
this.capturedBlockStates.put(blockposition.immutableCopy(), blockstate); this.capturedBlockStates.put(blockposition.immutableCopy(), blockstate);
captured = true; captured = true;
} }
@@ -571,7 +571,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable { @@ -571,7 +572,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
public IBlockData getType(BlockPosition blockposition) { public IBlockData getType(BlockPosition blockposition) {
// CraftBukkit start - tree generation // CraftBukkit start - tree generation
if (captureTreeGeneration) { if (captureTreeGeneration) {

View File

@ -1,47 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Tue, 22 Dec 2020 22:41:12 +0000
Subject: [PATCH] Do not perform neighbour updates when using debug stick
CB blindly drops any update flags when recording block modifications,
this causes the debug stick to blindly update neighbouring blocks on usage
in order to control this, we will special case this item, however, this
ideally should be fixed by recording the actual update flags used,
but will induce ABI breaks...
This patch also maintains the behavior of the BlockPlaceEvent, this
behavior will NOT be guaranteed in the future, however.
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
index 3adb29f004d2fee36f3ee9b21ee5417e84b64837..c84a062d38dcf8c46781b0e30bf3e0821e34dd58 100644
--- a/src/main/java/net/minecraft/server/ItemStack.java
+++ b/src/main/java/net/minecraft/server/ItemStack.java
@@ -211,6 +211,7 @@ public final class ItemStack {
}
public EnumInteractionResult placeItem(ItemActionContext itemactioncontext, EnumHand enumhand) { // CraftBukkit - add hand
+ boolean doPhysicsUpdate = true; // Paper
EntityHuman entityhuman = itemactioncontext.getEntity();
BlockPosition blockposition = itemactioncontext.getClickPosition();
ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getWorld(), blockposition, false);
@@ -228,7 +229,11 @@ public final class ItemStack {
// special case bonemeal
if (this.getItem() == Items.BONE_MEAL) {
world.captureTreeGeneration = true;
+ // Paper start
+ } else if (this.getItem() instanceof ItemDebugStick) {
+ doPhysicsUpdate = false;
}
+ // Paper end
}
Item item = this.getItem();
EnumInteractionResult enuminteractionresult = item.a(itemactioncontext);
@@ -316,7 +321,7 @@ public final class ItemStack {
block.getBlock().onPlace(block, world, newblockposition, oldBlock, true, itemactioncontext); // Paper - pass itemactioncontext
}
- world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getType(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point
+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getType(newblockposition), updateFlag | (doPhysicsUpdate ? 0 : 16), 512); // send null chunk as chunk.k() returns false by this point // Paper
}
// Special case juke boxes as they update their tile entity. Copied from ItemRecord.