Fix cancelling BlockPlaceEvent calling onRemove
This commit is contained in:
@ -69,7 +69,7 @@
|
||||
protected final NeighborUpdater neighborUpdater;
|
||||
private final List<TickingBlockEntity> pendingBlockEntityTickers = Lists.newArrayList();
|
||||
private boolean tickingBlockEntities;
|
||||
@@ -121,23 +145,90 @@
|
||||
@@ -121,23 +145,91 @@
|
||||
private final DamageSources damageSources;
|
||||
private long subTickCount;
|
||||
|
||||
@ -87,6 +87,7 @@
|
||||
+ public boolean preventPoiUpdated = false; // CraftBukkit - SPIGOT-5710
|
||||
+ public boolean captureBlockStates = false;
|
||||
+ public boolean captureTreeGeneration = false;
|
||||
+ public boolean isBlockPlaceCancelled = false; // Paper - prevent calling cleanup logic when undoing a block place upon a cancelled BlockPlaceEvent
|
||||
+ public Map<BlockPos, org.bukkit.craftbukkit.block.CraftBlockState> capturedBlockStates = new java.util.LinkedHashMap<>(); // Paper
|
||||
+ public Map<BlockPos, BlockEntity> capturedTileEntities = new java.util.LinkedHashMap<>(); // Paper - Retain block place order when capturing blockstates
|
||||
+ public List<ItemEntity> captureDrops;
|
||||
@ -169,7 +170,7 @@
|
||||
}
|
||||
};
|
||||
} else {
|
||||
@@ -145,13 +236,90 @@
|
||||
@@ -145,13 +237,90 @@
|
||||
}
|
||||
|
||||
this.thread = Thread.currentThread();
|
||||
@ -265,7 +266,7 @@
|
||||
@Override
|
||||
public boolean isClientSide() {
|
||||
return this.isClientSide;
|
||||
@@ -163,6 +331,13 @@
|
||||
@@ -163,6 +332,13 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -279,7 +280,7 @@
|
||||
public boolean isInWorldBounds(BlockPos pos) {
|
||||
return !this.isOutsideBuildHeight(pos) && Level.isInWorldBoundsHorizontal(pos);
|
||||
}
|
||||
@@ -172,25 +347,87 @@
|
||||
@@ -172,25 +348,87 @@
|
||||
}
|
||||
|
||||
private static boolean isInWorldBoundsHorizontal(BlockPos pos) {
|
||||
@ -312,7 +313,7 @@
|
||||
|
||||
+ // Paper start - if loaded
|
||||
@Nullable
|
||||
+ @Override
|
||||
@Override
|
||||
+ public final ChunkAccess getChunkIfLoadedImmediately(int x, int z) {
|
||||
+ return ((ServerLevel)this).chunkSource.getChunkAtIfLoadedImmediately(x, z);
|
||||
+ }
|
||||
@ -365,13 +366,13 @@
|
||||
+ return getWorldBorder().isWithinBounds(blockposition) ? getBlockStateIfLoaded(blockposition) : null;
|
||||
+ }
|
||||
+
|
||||
@Override
|
||||
+ @Override
|
||||
public ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) {
|
||||
+ // Paper end
|
||||
ChunkAccess ichunkaccess = this.getChunkSource().getChunk(chunkX, chunkZ, leastStatus, create);
|
||||
|
||||
if (ichunkaccess == null && create) {
|
||||
@@ -207,6 +444,22 @@
|
||||
@@ -207,6 +445,22 @@
|
||||
|
||||
@Override
|
||||
public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) {
|
||||
@ -394,7 +395,7 @@
|
||||
if (this.isOutsideBuildHeight(pos)) {
|
||||
return false;
|
||||
} else if (!this.isClientSide && this.isDebug()) {
|
||||
@@ -214,45 +467,126 @@
|
||||
@@ -214,44 +468,125 @@
|
||||
} else {
|
||||
LevelChunk chunk = this.getChunkAt(pos);
|
||||
Block block = state.getBlock();
|
||||
@ -479,10 +480,10 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start - Split off from above in order to directly send client and physic updates
|
||||
+ public void notifyAndUpdatePhysics(BlockPos blockposition, LevelChunk chunk, BlockState oldBlock, BlockState newBlock, BlockState actualBlock, int i, int j) {
|
||||
+ BlockState iblockdata = newBlock;
|
||||
@ -522,21 +523,20 @@
|
||||
+ iblockdata.updateNeighbourShapes(this, blockposition, k, j - 1);
|
||||
+ iblockdata.updateIndirectNeighbourShapes(this, blockposition, k, j - 1);
|
||||
+ } // Paper - Fix block place logic
|
||||
+ }
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start - SPIGOT-5710
|
||||
+ if (!this.preventPoiUpdated) {
|
||||
+ this.onBlockStateChange(blockposition, iblockdata1, iblockdata2);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
public void onBlockStateChange(BlockPos pos, BlockState oldBlock, BlockState newBlock) {}
|
||||
|
||||
@Override
|
||||
@@ -270,15 +604,33 @@
|
||||
@@ -270,15 +605,33 @@
|
||||
return false;
|
||||
} else {
|
||||
FluidState fluid = this.getFluidState(pos);
|
||||
@ -573,7 +573,7 @@
|
||||
}
|
||||
|
||||
boolean flag1 = this.setBlock(pos, fluid.createLegacyBlock(), 3, maxUpdateDepth);
|
||||
@@ -340,10 +692,18 @@
|
||||
@@ -340,10 +693,18 @@
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState(BlockPos pos) {
|
||||
@ -593,7 +593,7 @@
|
||||
|
||||
return chunk.getBlockState(pos);
|
||||
}
|
||||
@@ -446,34 +806,53 @@
|
||||
@@ -446,34 +807,53 @@
|
||||
this.pendingBlockEntityTickers.clear();
|
||||
}
|
||||
|
||||
@ -656,7 +656,7 @@
|
||||
|
||||
public boolean shouldTickDeath(Entity entity) {
|
||||
return true;
|
||||
@@ -510,13 +889,32 @@
|
||||
@@ -510,13 +890,32 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity getBlockEntity(BlockPos pos) {
|
||||
@ -690,7 +690,7 @@
|
||||
this.getChunkAt(blockposition).addAndRegisterBlockEntity(blockEntity);
|
||||
}
|
||||
}
|
||||
@@ -643,7 +1041,7 @@
|
||||
@@ -643,7 +1042,7 @@
|
||||
|
||||
for (int k = 0; k < j; ++k) {
|
||||
EnderDragonPart entitycomplexpart = aentitycomplexpart[k];
|
||||
@ -699,7 +699,7 @@
|
||||
|
||||
if (t0 != null && predicate.test(t0)) {
|
||||
result.add(t0);
|
||||
@@ -912,7 +1310,7 @@
|
||||
@@ -912,7 +1311,7 @@
|
||||
|
||||
public static enum ExplosionInteraction implements StringRepresentable {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user