13
0
geforkt von Mirrors/Paper
Paper/nms-patches/BlockConcretePowder.patch

75 Zeilen
3.1 KiB
Diff

--- a/net/minecraft/server/BlockConcretePowder.java
+++ b/net/minecraft/server/BlockConcretePowder.java
2018-07-15 02:00:00 +02:00
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlockState;
+import org.bukkit.event.block.BlockFormEvent;
+// CraftBukkit end
+
public class BlockConcretePowder extends BlockFalling {
private final IBlockData a;
2019-04-23 04:00:00 +02:00
@@ -12,7 +17,7 @@
@Override
2020-06-25 02:00:00 +02:00
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1, EntityFallingBlock entityfallingblock) {
2020-01-21 22:00:00 +01:00
if (canHarden(world, blockposition, iblockdata1)) {
2018-07-15 02:00:00 +02:00
- world.setTypeAndData(blockposition, this.a, 3);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.a, 3); // CraftBukkit
}
}
2020-01-21 22:00:00 +01:00
@@ -23,7 +28,24 @@
BlockPosition blockposition = blockactioncontext.getClickPosition();
2020-01-21 22:00:00 +01:00
IBlockData iblockdata = world.getType(blockposition);
2020-01-21 22:00:00 +01:00
- return canHarden(world, blockposition, iblockdata) ? this.a : super.getPlacedState(blockactioncontext);
+ // CraftBukkit start
2020-01-21 22:00:00 +01:00
+ if (!canHarden(world, blockposition, iblockdata)) {
+ return super.getPlacedState(blockactioncontext);
+ }
+
+ // TODO: An event factory call for methods like this
+ CraftBlockState blockState = CraftBlockState.getBlockState(world, blockposition);
+ blockState.setData(this.a);
+
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
+ world.getMinecraftServer().server.getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ return blockState.getHandle();
+ }
+
+ return super.getPlacedState(blockactioncontext);
+ // CraftBukkit end
}
2020-01-21 22:00:00 +01:00
private static boolean canHarden(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) {
2020-08-11 23:00:00 +02:00
@@ -59,6 +81,24 @@
2019-04-23 04:00:00 +02:00
@Override
2018-07-15 02:00:00 +02:00
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
- return a((IBlockAccess) generatoraccess, blockposition) ? this.a : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
+ // CraftBukkit start
+ if (a((IBlockAccess) generatoraccess, blockposition)) {
2020-08-11 23:00:00 +02:00
+ // Suppress during worldgen
+ if (!(generatoraccess instanceof World)) {
+ return this.a;
+ }
2018-07-15 02:00:00 +02:00
+ CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition);
+ blockState.setData(this.a);
+
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
2020-08-11 23:00:00 +02:00
+ ((World) generatoraccess).getServer().getPluginManager().callEvent(event);
2018-07-15 02:00:00 +02:00
+
+ if (!event.isCancelled()) {
+ return blockState.getHandle();
+ }
+ }
+
+ return super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
+ // CraftBukkit end
}
}