SPIGOT-5847: BlockFadeEvent cannot be triggered asynchronously from another thread

This commit is contained in:
md_5 2020-06-27 08:41:54 +10:00
parent 4ff609e60c
commit 14053c708b
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -14,13 +14,17 @@
public class BlockFire extends BlockFireAbstract {
public static final BlockStateInteger AGE = BlockProperties.aj;
@@ -26,7 +33,20 @@
@@ -26,7 +33,24 @@
@Override
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
- return this.canPlace(iblockdata, generatoraccess, blockposition) ? this.a(generatoraccess, blockposition, (Integer) iblockdata.get(BlockFire.AGE)) : Blocks.AIR.getBlockData();
+ // CraftBukkit start
+ if (!this.canPlace(iblockdata, generatoraccess, blockposition)) {
+ // Suppress during worldgen
+ if (!(generatoraccess instanceof World)) {
+ return Blocks.AIR.getBlockData();
+ }
+ CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition);
+ blockState.setData(Blocks.AIR.getBlockData());
+
@ -36,7 +40,7 @@
}
@Override
@@ -97,7 +117,7 @@
@@ -97,7 +121,7 @@
worldserver.getBlockTickList().a(blockposition, this, a(worldserver.random));
if (worldserver.getGameRules().getBoolean(GameRules.DO_FIRE_TICK)) {
if (!iblockdata.canPlace(worldserver, blockposition)) {
@ -45,7 +49,7 @@
}
IBlockData iblockdata1 = worldserver.getType(blockposition.down());
@@ -105,7 +125,7 @@
@@ -105,7 +129,7 @@
int i = (Integer) iblockdata.get(BlockFire.AGE);
if (!flag && worldserver.isRaining() && this.a((World) worldserver, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) {
@ -54,7 +58,7 @@
} else {
int j = Math.min(15, i + random.nextInt(3) / 2);
@@ -119,14 +139,14 @@
@@ -119,14 +143,14 @@
BlockPosition blockposition1 = blockposition.down();
if (!worldserver.getType(blockposition1).d(worldserver, blockposition1, EnumDirection.UP) || i > 3) {
@ -71,7 +75,7 @@
return;
}
}
@@ -134,12 +154,14 @@
@@ -134,12 +158,14 @@
boolean flag1 = worldserver.u(blockposition);
int k = flag1 ? -50 : 0;
@ -92,7 +96,7 @@
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
for (int l = -1; l <= 1; ++l) {
@@ -165,7 +187,15 @@
@@ -165,7 +191,15 @@
if (i2 > 0 && random.nextInt(k1) <= i2 && (!worldserver.isRaining() || !this.a((World) worldserver, (BlockPosition) blockposition_mutableblockposition))) {
int j2 = Math.min(15, i + random.nextInt(5) / 4);
@ -109,7 +113,7 @@
}
}
}
@@ -189,12 +219,24 @@
@@ -189,12 +223,24 @@
return iblockdata.b(BlockProperties.C) && (Boolean) iblockdata.get(BlockProperties.C) ? 0 : this.flameChances.getInt(iblockdata.getBlock());
}