3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-20 21:40:06 +01:00
Paper/nms-patches/BlockConcretePowder.patch

71 Zeilen
3.0 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
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {
2019-04-23 04:00:00 +02:00
if (canHarden(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
}
}
2019-04-23 04:00:00 +02:00
@@ -22,7 +27,24 @@
World world = blockactioncontext.getWorld();
BlockPosition blockposition = blockactioncontext.getClickPosition();
2019-04-23 04:00:00 +02:00
- return !canHarden(world.getType(blockposition)) && !a((IBlockAccess) world, blockposition) ? super.getPlacedState(blockactioncontext) : this.a;
+ // CraftBukkit start
2019-04-23 04:00:00 +02:00
+ if (!canHarden(world.getType(blockposition)) && !a((IBlockAccess) world, blockposition)) {
+ 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
}
private static boolean a(IBlockAccess iblockaccess, BlockPosition blockposition) {
2019-04-23 04:00:00 +02:00
@@ -54,6 +76,20 @@
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)) {
+ CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition);
+ blockState.setData(this.a);
+
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
+ generatoraccess.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ return blockState.getHandle();
+ }
+ }
+
+ return super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
+ // CraftBukkit end
}
}