aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/ButtonBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/ButtonBlock.java.patch')
-rw-r--r--patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/ButtonBlock.java.patch80
1 files changed, 80 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/ButtonBlock.java.patch b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/ButtonBlock.java.patch
new file mode 100644
index 0000000000..8fe77b2e7d
--- /dev/null
+++ b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/ButtonBlock.java.patch
@@ -0,0 +1,80 @@
+--- a/net/minecraft/world/level/block/ButtonBlock.java
++++ b/net/minecraft/world/level/block/ButtonBlock.java
+@@ -32,6 +32,10 @@
+ import net.minecraft.world.phys.BlockHitResult;
+ import net.minecraft.world.phys.shapes.CollisionContext;
+ import net.minecraft.world.phys.shapes.VoxelShape;
++// CraftBukkit start
++import org.bukkit.event.block.BlockRedstoneEvent;
++import org.bukkit.event.entity.EntityInteractEvent;
++// CraftBukkit end
+
+ public class ButtonBlock extends FaceAttachedHorizontalDirectionalBlock {
+
+@@ -127,9 +128,22 @@
+ if ((Boolean) blockstate.getValue(ButtonBlock.POWERED)) {
+ return InteractionResult.CONSUME;
+ } else {
+- this.press(blockstate, level, blockpos);
+- this.playSound(player, level, blockpos, true);
+- level.gameEvent((Entity) player, GameEvent.BLOCK_ACTIVATE, blockpos);
++ // CraftBukkit start
++ boolean powered = ((Boolean) state.getValue(POWERED));
++ org.bukkit.block.Block block = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
++ int old = (powered) ? 15 : 0;
++ int current = (!powered) ? 15 : 0;
++
++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
++ level.getCraftServer().getPluginManager().callEvent(eventRedstone);
++
++ if ((eventRedstone.getNewCurrent() > 0) != (!powered)) {
++ return InteractionResult.SUCCESS;
++ }
++ // CraftBukkit end
++ this.press(state, level, pos);
++ this.playSound(player, level, pos, true);
++ level.gameEvent((Entity) player, GameEvent.BLOCK_ACTIVATE, pos);
+ return InteractionResult.sidedSuccess(level.isClientSide);
+ }
+ }
+@@ -209,11 +216,36 @@
+ boolean flag = abstractarrow != null;
+ boolean flag1 = (Boolean) blockstate.getValue(ButtonBlock.POWERED);
+
++ // CraftBukkit start - Call interact event when arrows turn on wooden buttons
++ if (flag1 != flag && flag) {
++ org.bukkit.block.Block block = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
++ EntityInteractEvent event = new EntityInteractEvent(entityarrow.getBukkitEntity(), block);
++ level.getCraftServer().getPluginManager().callEvent(event);
++
++ if (event.isCancelled()) {
++ return;
++ }
++ }
++ // CraftBukkit end
++
+ if (flag != flag1) {
+- level.setBlock(blockpos, (BlockState) blockstate.setValue(ButtonBlock.POWERED, flag), 3);
+- this.updateNeighbours(blockstate, level, blockpos);
+- this.playSound((Player) null, level, blockpos, flag);
+- level.gameEvent((Entity) abstractarrow, flag ? GameEvent.BLOCK_ACTIVATE : GameEvent.BLOCK_DEACTIVATE, blockpos);
++ // CraftBukkit start
++ boolean powered = flag1;
++ org.bukkit.block.Block block = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
++ int old = (powered) ? 15 : 0;
++ int current = (!powered) ? 15 : 0;
++
++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
++ level.getCraftServer().getPluginManager().callEvent(eventRedstone);
++
++ if ((flag && eventRedstone.getNewCurrent() <= 0) || (!flag && eventRedstone.getNewCurrent() > 0)) {
++ return;
++ }
++ // CraftBukkit end
++ level.setBlock(pos, (IBlockData) state.setValue(ButtonBlock.POWERED, flag), 3);
++ this.updateNeighbours(state, level, pos);
++ this.playSound((Player) null, level, pos, flag);
++ level.gameEvent((Entity) entityarrow, flag ? GameEvent.BLOCK_ACTIVATE : GameEvent.BLOCK_DEACTIVATE, pos);
+ }
+
+ if (flag) {