mirror of
https://github.com/PaperMC/Paper.git
synced 2025-04-13 07:26:01 +02:00
Prevent desync for poi and pistons (#9270)
This commit is contained in:
parent
f78ebb6629
commit
6667ae5ce2
@ -3,6 +3,10 @@ From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
|
|||||||
Date: Mon, 3 Apr 2023 18:46:49 +0200
|
Date: Mon, 3 Apr 2023 18:46:49 +0200
|
||||||
Subject: [PATCH] Fix block place logic
|
Subject: [PATCH] Fix block place logic
|
||||||
|
|
||||||
|
Fix several issues when a player interact with a block:
|
||||||
|
* the place sound isn't played for the dispensed shulker block
|
||||||
|
* desync of the jukebox blocks between bukkit handler and the vanilla interaction
|
||||||
|
* poi can desync when the BlockPhysicsEvent is cancelled
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java
|
diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
@ -36,3 +40,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(entityhuman, world.getBlockState(blockposition)));
|
world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(entityhuman, world.getBlockState(blockposition)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||||
|
// CraftBukkit start
|
||||||
|
iblockdata1.updateIndirectNeighbourShapes(this, blockposition, k, j - 1); // Don't call an event for the old block to limit event spam
|
||||||
|
CraftWorld world = ((ServerLevel) this).getWorld();
|
||||||
|
+ boolean cancelledUpdates = false; // Paper
|
||||||
|
if (world != null && ((ServerLevel)this).hasPhysicsEvent) { // Paper
|
||||||
|
BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata));
|
||||||
|
this.getCraftServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
- if (event.isCancelled()) {
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
+ cancelledUpdates = event.isCancelled(); // Paper
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
+ if (!cancelledUpdates) { // Paper
|
||||||
|
iblockdata.updateNeighbourShapes(this, blockposition, k, j - 1);
|
||||||
|
iblockdata.updateIndirectNeighbourShapes(this, blockposition, k, j - 1);
|
||||||
|
+ } // Paper
|
||||||
|
}
|
||||||
|
|
||||||
|
// CraftBukkit start - SPIGOT-5710
|
||||||
|
@ -59,7 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ }
|
+ }
|
||||||
+ world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockposition3, iblockdata2, allowDesync ? list1.get(k) : iblockdata1, dir, retract, false));
|
+ world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockposition3, iblockdata2, allowDesync ? list1.get(k) : iblockdata1, dir, retract, false));
|
||||||
+ if (!allowDesync) {
|
+ if (!allowDesync) {
|
||||||
+ world.setBlock(oldPos, Blocks.AIR.defaultBlockState(), 2 | 4 | 16 | 1024); // set air to prevent later physics updates from seeing this block
|
+ world.setBlock(oldPos, Blocks.AIR.defaultBlockState(), Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_MOVE_BY_PISTON | 1024); // set air to prevent later physics updates from seeing this block
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - fix a variety of piston desync dupes
|
+ // Paper end - fix a variety of piston desync dupes
|
||||||
aiblockdata[j++] = iblockdata1;
|
aiblockdata[j++] = iblockdata1;
|
||||||
@ -74,7 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
BlockState blockState = Block.updateFromNeighbourShapes(blockEntity.movedState, world, pos);
|
BlockState blockState = Block.updateFromNeighbourShapes(blockEntity.movedState, world, pos);
|
||||||
if (blockState.isAir()) {
|
if (blockState.isAir()) {
|
||||||
- world.setBlock(pos, blockEntity.movedState, 84);
|
- world.setBlock(pos, blockEntity.movedState, 84);
|
||||||
+ world.setBlock(pos, blockEntity.movedState, io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPistonDuplication ? 84 : (84 | 2)); // Paper - force notify (flag 2), it's possible the set type by the piston block (which doesn't notify) set this block to air
|
+ world.setBlock(pos, blockEntity.movedState, io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPistonDuplication ? 84 : (84 | Block.UPDATE_CLIENTS)); // Paper - force notify (flag 2), it's possible the set type by the piston block (which doesn't notify) set this block to air
|
||||||
Block.updateOrDestroy(blockEntity.movedState, blockState, world, pos, 3);
|
Block.updateOrDestroy(blockEntity.movedState, blockState, world, pos, 3);
|
||||||
} else {
|
} else {
|
||||||
if (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED)) {
|
if (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user