2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/level/block/BlockConcretePowder.java
|
|
|
|
+++ b/net/minecraft/world/level/block/BlockConcretePowder.java
|
2023-12-05 17:40:00 +01:00
|
|
|
@@ -14,6 +14,12 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.level.block.state.BlockBase;
|
|
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
2018-07-15 02:00:00 +02:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
2021-09-29 10:56:16 +02:00
|
|
|
+import org.bukkit.craftbukkit.block.CraftBlockStates;
|
2018-07-15 02:00:00 +02:00
|
|
|
+import org.bukkit.event.block.BlockFormEvent;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public class BlockConcretePowder extends BlockFalling {
|
|
|
|
|
2023-12-05 17:40:00 +01:00
|
|
|
public static final MapCodec<BlockConcretePowder> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
|
|
|
@@ -36,7 +42,7 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2021-11-21 23:00:00 +01:00
|
|
|
public void onLand(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1, EntityFallingBlock entityfallingblock) {
|
|
|
|
if (shouldSolidify(world, blockposition, iblockdata1)) {
|
2023-12-05 17:40:00 +01:00
|
|
|
- world.setBlock(blockposition, this.concrete.defaultBlockState(), 3);
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.concrete.defaultBlockState(), 3); // CraftBukkit
|
2017-06-03 09:39:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2023-12-05 17:40:00 +01:00
|
|
|
@@ -47,7 +53,24 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
BlockPosition blockposition = blockactioncontext.getClickedPos();
|
|
|
|
IBlockData iblockdata = world.getBlockState(blockposition);
|
2018-07-21 02:03:08 +02:00
|
|
|
|
2023-12-05 17:40:00 +01:00
|
|
|
- return shouldSolidify(world, blockposition, iblockdata) ? this.concrete.defaultBlockState() : super.getStateForPlacement(blockactioncontext);
|
2018-07-21 02:03:08 +02:00
|
|
|
+ // CraftBukkit start
|
2021-11-21 23:00:00 +01:00
|
|
|
+ if (!shouldSolidify(world, blockposition, iblockdata)) {
|
|
|
|
+ return super.getStateForPlacement(blockactioncontext);
|
2018-07-21 02:03:08 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // TODO: An event factory call for methods like this
|
2021-09-29 10:56:16 +02:00
|
|
|
+ CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockposition);
|
2023-12-05 17:40:00 +01:00
|
|
|
+ blockState.setData(this.concrete.defaultBlockState());
|
2018-07-21 02:03:08 +02:00
|
|
|
+
|
|
|
|
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
|
2021-11-21 23:00:00 +01:00
|
|
|
+ world.getServer().server.getPluginManager().callEvent(event);
|
2018-07-21 02:03:08 +02:00
|
|
|
+
|
|
|
|
+ if (!event.isCancelled()) {
|
|
|
|
+ return blockState.getHandle();
|
|
|
|
+ }
|
|
|
|
+
|
2021-11-21 23:00:00 +01:00
|
|
|
+ return super.getStateForPlacement(blockactioncontext);
|
2018-07-21 02:03:08 +02:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
private static boolean shouldSolidify(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) {
|
2023-12-05 17:40:00 +01:00
|
|
|
@@ -83,7 +106,25 @@
|
2017-06-03 09:39:03 +02:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2024-04-23 17:15:00 +02:00
|
|
|
protected IBlockData updateShape(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
|
2023-12-05 17:40:00 +01:00
|
|
|
- return touchesLiquid(generatoraccess, blockposition) ? this.concrete.defaultBlockState() : super.updateShape(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
|
2018-07-15 02:00:00 +02:00
|
|
|
+ // CraftBukkit start
|
2021-11-21 23:00:00 +01:00
|
|
|
+ if (touchesLiquid(generatoraccess, blockposition)) {
|
2020-08-11 23:00:00 +02:00
|
|
|
+ // Suppress during worldgen
|
|
|
|
+ if (!(generatoraccess instanceof World)) {
|
2023-12-05 17:40:00 +01:00
|
|
|
+ return this.concrete.defaultBlockState();
|
2020-08-11 23:00:00 +02:00
|
|
|
+ }
|
2021-09-29 10:56:16 +02:00
|
|
|
+ CraftBlockState blockState = CraftBlockStates.getBlockState(generatoraccess, blockposition);
|
2023-12-05 17:40:00 +01:00
|
|
|
+ blockState.setData(this.concrete.defaultBlockState());
|
2018-07-15 02:00:00 +02:00
|
|
|
+
|
|
|
|
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
|
2021-06-11 13:33:49 +02:00
|
|
|
+ ((World) generatoraccess).getCraftServer().getPluginManager().callEvent(event);
|
2018-07-15 02:00:00 +02:00
|
|
|
+
|
|
|
|
+ if (!event.isCancelled()) {
|
|
|
|
+ return blockState.getHandle();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2021-11-21 23:00:00 +01:00
|
|
|
+ return super.updateShape(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
|
2018-07-15 02:00:00 +02:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2021-06-11 07:00:00 +02:00
|
|
|
|
|
|
|
@Override
|