SPIGOT-4316: Do even less processing when block placement without physics requested

This commit is contained in:
md_5 2018-08-27 18:27:59 +10:00
parent f598574711
commit c2cbdc5ab4
3 changed files with 28 additions and 11 deletions

View file

@ -80,17 +80,33 @@
} }
public Set<BlockPosition> t() { public Set<BlockPosition> t() {
@@ -473,7 +513,8 @@ @@ -412,8 +452,15 @@
}
}
+ // CraftBukkit start
@Nullable
public IBlockData a(BlockPosition blockposition, IBlockData iblockdata, boolean flag) {
+ return this.a(blockposition, iblockdata, flag, true);
+ }
+
+ @Nullable
+ public IBlockData a(BlockPosition blockposition, IBlockData iblockdata, boolean flag, boolean doPlace) {
+ // CraftBukkit end
int i = blockposition.getX() & 15;
int j = blockposition.getY();
int k = blockposition.getZ() & 15;
@@ -473,7 +520,8 @@
} }
} }
- if (!this.world.isClientSide) { - if (!this.world.isClientSide) {
+ // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled. + // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled.
+ if (!this.world.isClientSide && (!this.world.captureBlockStates || block instanceof BlockTileEntity)) { + if (!this.world.isClientSide && doPlace && (!this.world.captureBlockStates || block instanceof BlockTileEntity)) {
iblockdata.onPlace(this.world, blockposition, iblockdata1); iblockdata.onPlace(this.world, blockposition, iblockdata1);
} }
@@ -653,7 +694,12 @@ @@ -653,7 +701,12 @@
@Nullable @Nullable
public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) { public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) {
@ -104,7 +120,7 @@
if (tileentity == null) { if (tileentity == null) {
if (chunk_enumtileentitystate == Chunk.EnumTileEntityState.IMMEDIATE) { if (chunk_enumtileentitystate == Chunk.EnumTileEntityState.IMMEDIATE) {
@@ -688,6 +734,13 @@ @@ -688,6 +741,13 @@
tileentity.z(); tileentity.z();
this.tileEntities.put(blockposition, tileentity); this.tileEntities.put(blockposition, tileentity);
@ -118,7 +134,7 @@
} }
} }
@@ -720,6 +773,17 @@ @@ -720,6 +780,17 @@
})); }));
} }
@ -136,7 +152,7 @@
} }
public void removeEntities() { public void removeEntities() {
@@ -736,9 +800,21 @@ @@ -736,9 +807,21 @@
int i = aentityslice.length; int i = aentityslice.length;
for (int j = 0; j < i; ++j) { for (int j = 0; j < i; ++j) {
@ -160,7 +176,7 @@
} }
} }
@@ -800,8 +876,8 @@ @@ -800,8 +883,8 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next(); Entity entity = (Entity) iterator.next();
@ -171,7 +187,7 @@
} }
} }
} }
@@ -1007,13 +1083,13 @@ @@ -1007,13 +1090,13 @@
@Nullable @Nullable
public LongSet b(String s) { public LongSet b(String s) {
@ -187,7 +203,7 @@
return new LongOpenHashSet(); return new LongOpenHashSet();
})).add(i); })).add(i);
} }
@@ -1061,14 +1137,14 @@ @@ -1061,14 +1144,14 @@
} }
if (this.s instanceof ProtoChunkTickList) { if (this.s instanceof ProtoChunkTickList) {

View file

@ -146,6 +146,7 @@
} else { } else {
Chunk chunk = this.getChunkAtWorldCoords(blockposition); Chunk chunk = this.getChunkAtWorldCoords(blockposition);
Block block = iblockdata.getBlock(); Block block = iblockdata.getBlock();
- IBlockData iblockdata1 = chunk.a(blockposition, iblockdata, (i & 64) != 0);
+ +
+ // CraftBukkit start - capture blockstates + // CraftBukkit start - capture blockstates
+ CraftBlockState blockstate = null; + CraftBlockState blockstate = null;
@ -155,7 +156,7 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
IBlockData iblockdata1 = chunk.a(blockposition, iblockdata, (i & 64) != 0); + IBlockData iblockdata1 = chunk.a(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

View file

@ -157,7 +157,7 @@ public class CraftBlock implements Block {
return world.setTypeAndData(position, blockData, 3); return world.setTypeAndData(position, blockData, 3);
} else { } else {
IBlockData old = world.getType(position); IBlockData old = world.getType(position);
boolean success = world.setTypeAndData(position, blockData, 18); // NOTIFY | NO_OBSERVER boolean success = world.setTypeAndData(position, blockData, 2 | 16 | 1024); // NOTIFY | NO_OBSERVER | NO_PLACE (custom)
if (success) { if (success) {
world.getMinecraftWorld().notify( world.getMinecraftWorld().notify(
position, position,