mirror of
https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git
synced 2024-11-25 13:56:14 +00:00
78 lines
3.7 KiB
Diff
78 lines
3.7 KiB
Diff
--- a/net/minecraft/world/level/block/BlockConcretePowder.java
|
|
+++ b/net/minecraft/world/level/block/BlockConcretePowder.java
|
|
@@ -16,6 +16,12 @@
|
|
import net.minecraft.world.level.block.state.BlockBase;
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
|
+import org.bukkit.craftbukkit.block.CraftBlockStates;
|
|
+import org.bukkit.event.block.BlockFormEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class BlockConcretePowder extends BlockFalling {
|
|
|
|
public static final MapCodec<BlockConcretePowder> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
|
@@ -38,7 +44,7 @@
|
|
@Override
|
|
public void onLand(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1, EntityFallingBlock entityfallingblock) {
|
|
if (shouldSolidify(world, blockposition, iblockdata1)) {
|
|
- world.setBlock(blockposition, this.concrete.defaultBlockState(), 3);
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.concrete.defaultBlockState(), 3); // CraftBukkit
|
|
}
|
|
|
|
}
|
|
@@ -49,7 +55,24 @@
|
|
BlockPosition blockposition = blockactioncontext.getClickedPos();
|
|
IBlockData iblockdata = world.getBlockState(blockposition);
|
|
|
|
- return shouldSolidify(world, blockposition, iblockdata) ? this.concrete.defaultBlockState() : super.getStateForPlacement(blockactioncontext);
|
|
+ // CraftBukkit start
|
|
+ if (!shouldSolidify(world, blockposition, iblockdata)) {
|
|
+ return super.getStateForPlacement(blockactioncontext);
|
|
+ }
|
|
+
|
|
+ // TODO: An event factory call for methods like this
|
|
+ CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockposition);
|
|
+ blockState.setData(this.concrete.defaultBlockState());
|
|
+
|
|
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
|
|
+ world.getServer().server.getPluginManager().callEvent(event);
|
|
+
|
|
+ if (!event.isCancelled()) {
|
|
+ return blockState.getHandle();
|
|
+ }
|
|
+
|
|
+ return super.getStateForPlacement(blockactioncontext);
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
private static boolean shouldSolidify(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) {
|
|
@@ -85,7 +108,25 @@
|
|
|
|
@Override
|
|
protected IBlockData updateShape(IBlockData iblockdata, IWorldReader iworldreader, ScheduledTickAccess scheduledtickaccess, BlockPosition blockposition, EnumDirection enumdirection, BlockPosition blockposition1, IBlockData iblockdata1, RandomSource randomsource) {
|
|
- return touchesLiquid(iworldreader, blockposition) ? this.concrete.defaultBlockState() : super.updateShape(iblockdata, iworldreader, scheduledtickaccess, blockposition, enumdirection, blockposition1, iblockdata1, randomsource);
|
|
+ // CraftBukkit start
|
|
+ if (touchesLiquid(iworldreader, blockposition)) {
|
|
+ // Suppress during worldgen
|
|
+ if (!(iworldreader instanceof World world)) {
|
|
+ return this.concrete.defaultBlockState();
|
|
+ }
|
|
+ CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockposition);
|
|
+ blockState.setData(this.concrete.defaultBlockState());
|
|
+
|
|
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
|
|
+ world.getCraftServer().getPluginManager().callEvent(event);
|
|
+
|
|
+ if (!event.isCancelled()) {
|
|
+ return blockState.getHandle();
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return super.updateShape(iblockdata, iworldreader, scheduledtickaccess, blockposition, enumdirection, blockposition1, iblockdata1, randomsource);
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
@Override
|