craftbukkit/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch

78 lines
3.4 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/level/block/BlockConcretePowder.java
+++ b/net/minecraft/world/level/block/BlockConcretePowder.java
2022-03-01 02:00:00 +11:00
@@ -11,6 +11,12 @@
2021-03-16 09:00:00 +11:00
import net.minecraft.world.level.block.state.BlockBase;
import net.minecraft.world.level.block.state.IBlockData;
2018-07-15 10:00:00 +10:00
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlockState;
+import org.bukkit.craftbukkit.block.CraftBlockStates;
2018-07-15 10:00:00 +10:00
+import org.bukkit.event.block.BlockFormEvent;
+// CraftBukkit end
+
public class BlockConcretePowder extends BlockFalling {
2021-06-11 15:00:00 +10:00
private final IBlockData concrete;
2022-03-01 02:00:00 +11:00
@@ -23,7 +29,7 @@
2019-04-23 12:00:00 +10:00
@Override
2021-11-22 09:00:00 +11:00
public void onLand(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1, EntityFallingBlock entityfallingblock) {
if (shouldSolidify(world, blockposition, iblockdata1)) {
- world.setBlock(blockposition, this.concrete, 3);
2021-06-11 15:00:00 +10:00
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.concrete, 3); // CraftBukkit
}
}
2022-03-01 02:00:00 +11:00
@@ -34,7 +40,24 @@
2021-11-22 09:00:00 +11:00
BlockPosition blockposition = blockactioncontext.getClickedPos();
IBlockData iblockdata = world.getBlockState(blockposition);
2021-11-22 09:00:00 +11:00
- return shouldSolidify(world, blockposition, iblockdata) ? this.concrete : super.getStateForPlacement(blockactioncontext);
+ // CraftBukkit start
2021-11-22 09:00:00 +11:00
+ if (!shouldSolidify(world, blockposition, iblockdata)) {
+ return super.getStateForPlacement(blockactioncontext);
+ }
+
+ // TODO: An event factory call for methods like this
+ CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockposition);
2021-06-11 15:00:00 +10:00
+ blockState.setData(this.concrete);
+
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
2021-11-22 09:00:00 +11:00
+ world.getServer().server.getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ return blockState.getHandle();
+ }
+
2021-11-22 09:00:00 +11:00
+ return super.getStateForPlacement(blockactioncontext);
+ // CraftBukkit end
}
2021-11-22 09:00:00 +11:00
private static boolean shouldSolidify(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) {
2022-03-01 02:00:00 +11:00
@@ -70,7 +93,25 @@
2019-04-23 12:00:00 +10:00
@Override
2021-11-22 09:00:00 +11:00
public IBlockData updateShape(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
- return touchesLiquid(generatoraccess, blockposition) ? this.concrete : super.updateShape(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
2018-07-15 10:00:00 +10:00
+ // CraftBukkit start
2021-11-22 09:00:00 +11:00
+ if (touchesLiquid(generatoraccess, blockposition)) {
2020-08-12 07:00:00 +10:00
+ // Suppress during worldgen
+ if (!(generatoraccess instanceof World)) {
2021-06-11 15:00:00 +10:00
+ return this.concrete;
2020-08-12 07:00:00 +10:00
+ }
+ CraftBlockState blockState = CraftBlockStates.getBlockState(generatoraccess, blockposition);
2021-06-11 15:00:00 +10:00
+ blockState.setData(this.concrete);
2018-07-15 10:00:00 +10:00
+
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
+ ((World) generatoraccess).getCraftServer().getPluginManager().callEvent(event);
2018-07-15 10:00:00 +10:00
+
+ if (!event.isCancelled()) {
+ return blockState.getHandle();
+ }
+ }
+
2021-11-22 09:00:00 +11:00
+ return super.updateShape(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
2018-07-15 10:00:00 +10:00
+ // CraftBukkit end
}
2021-06-11 15:00:00 +10:00
@Override