SPIGOT-5657: BlockPlaceEvent not cancelling for tripwire hooks

This commit is contained in:
md_5 2020-04-05 17:19:03 +10:00
parent f325b9beac
commit 5838285d60

View file

@ -117,31 +117,33 @@
if (isOutsideWorld(blockposition)) { if (isOutsideWorld(blockposition)) {
return false; return false;
} else if (!this.isClientSide && this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) { } else if (!this.isClientSide && this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) {
@@ -112,9 +199,22 @@ @@ -112,9 +199,24 @@
} else { } else {
Chunk chunk = this.getChunkAtWorldCoords(blockposition); Chunk chunk = this.getChunkAtWorldCoords(blockposition);
Block block = iblockdata.getBlock(); Block block = iblockdata.getBlock();
- IBlockData iblockdata1 = chunk.setType(blockposition, iblockdata, (i & 64) != 0); - IBlockData iblockdata1 = chunk.setType(blockposition, iblockdata, (i & 64) != 0);
+ +
+ // CraftBukkit start - capture blockstates + // CraftBukkit start - capture blockstates
+ 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);
+ this.capturedBlockStates.put(blockposition.immutableCopy(), blockstate); + this.capturedBlockStates.put(blockposition.immutableCopy(), blockstate);
+ captured = true;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
+ IBlockData iblockdata1 = chunk.setType(blockposition, iblockdata, (i & 64) != 0, (i & 1024) == 0); // CraftBukkit custom NO_PLACE flag + IBlockData iblockdata1 = chunk.setType(blockposition, iblockdata, (i & 64) != 0, (i & 1024) == 0); // CraftBukkit custom NO_PLACE flag
if (iblockdata1 == null) { if (iblockdata1 == null) {
+ // CraftBukkit start - remove blockstate if failed + // CraftBukkit start - remove blockstate if failed (or the same)
+ if (this.captureBlockStates) { + if (this.captureBlockStates && captured) {
+ this.capturedBlockStates.remove(blockposition); + this.capturedBlockStates.remove(blockposition);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
return false; return false;
} else { } else {
IBlockData iblockdata2 = this.getType(blockposition); IBlockData iblockdata2 = this.getType(blockposition);
@@ -125,6 +225,7 @@ @@ -125,6 +227,7 @@
this.methodProfiler.exit(); this.methodProfiler.exit();
} }
@ -149,7 +151,7 @@
if (iblockdata2 == iblockdata) { if (iblockdata2 == iblockdata) {
if (iblockdata1 != iblockdata2) { if (iblockdata1 != iblockdata2) {
this.b(blockposition, iblockdata1, iblockdata2); this.b(blockposition, iblockdata1, iblockdata2);
@@ -151,12 +252,65 @@ @@ -151,12 +254,65 @@
this.a(blockposition, iblockdata1, iblockdata2); this.a(blockposition, iblockdata1, iblockdata2);
} }
@ -215,7 +217,7 @@
public void a(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} public void a(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {}
@Override @Override
@@ -195,6 +349,11 @@ @@ -195,6 +351,11 @@
@Override @Override
public void update(BlockPosition blockposition, Block block) { public void update(BlockPosition blockposition, Block block) {
if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) { if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
@ -227,7 +229,7 @@
this.applyPhysics(blockposition, block); this.applyPhysics(blockposition, block);
} }
@@ -243,6 +402,17 @@ @@ -243,6 +404,17 @@
IBlockData iblockdata = this.getType(blockposition); IBlockData iblockdata = this.getType(blockposition);
try { try {
@ -245,7 +247,7 @@
iblockdata.doPhysics(this, blockposition, block, blockposition1, false); iblockdata.doPhysics(this, blockposition, block, blockposition1, false);
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours"); CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours");
@@ -285,6 +455,14 @@ @@ -285,6 +457,14 @@
@Override @Override
public IBlockData getType(BlockPosition blockposition) { public IBlockData getType(BlockPosition blockposition) {
@ -260,7 +262,7 @@
if (isOutsideWorld(blockposition)) { if (isOutsideWorld(blockposition)) {
return Blocks.VOID_AIR.getBlockData(); return Blocks.VOID_AIR.getBlockData();
} else { } else {
@@ -306,11 +484,11 @@ @@ -306,11 +486,11 @@
} }
public boolean isDay() { public boolean isDay() {
@ -274,7 +276,7 @@
} }
@Override @Override
@@ -432,9 +610,11 @@ @@ -432,9 +612,11 @@
TileEntity tileentity1 = (TileEntity) this.tileEntityListPending.get(i); TileEntity tileentity1 = (TileEntity) this.tileEntityListPending.get(i);
if (!tileentity1.isRemoved()) { if (!tileentity1.isRemoved()) {
@ -286,7 +288,7 @@
if (this.isLoaded(tileentity1.getPosition())) { if (this.isLoaded(tileentity1.getPosition())) {
Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition()); Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition());
@@ -442,6 +622,12 @@ @@ -442,6 +624,12 @@
chunk.setTileEntity(tileentity1.getPosition(), tileentity1); chunk.setTileEntity(tileentity1.getPosition(), tileentity1);
this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3); this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3);
@ -299,7 +301,7 @@
} }
} }
} }
@@ -606,12 +792,25 @@ @@ -606,12 +794,25 @@
@Nullable @Nullable
@Override @Override
@ -325,7 +327,7 @@
TileEntity tileentity = null; TileEntity tileentity = null;
if (this.tickingTileEntities) { if (this.tickingTileEntities) {
@@ -646,6 +845,13 @@ @@ -646,6 +847,13 @@
public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) { public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) {
if (!isOutsideWorld(blockposition)) { if (!isOutsideWorld(blockposition)) {
if (tileentity != null && !tileentity.isRemoved()) { if (tileentity != null && !tileentity.isRemoved()) {
@ -339,7 +341,7 @@
if (this.tickingTileEntities) { if (this.tickingTileEntities) {
tileentity.setLocation(this, blockposition); tileentity.setLocation(this, blockposition);
Iterator iterator = this.tileEntityListPending.iterator(); Iterator iterator = this.tileEntityListPending.iterator();
@@ -670,7 +876,7 @@ @@ -670,7 +878,7 @@
} }
public void removeTileEntity(BlockPosition blockposition) { public void removeTileEntity(BlockPosition blockposition) {