aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/ButtonBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/ButtonBlock.java.patch')
-rw-r--r--patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/ButtonBlock.java.patch79
1 files changed, 79 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/ButtonBlock.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/ButtonBlock.java.patch
new file mode 100644
index 0000000000..1c6b231b61
--- /dev/null
+++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/ButtonBlock.java.patch
@@ -0,0 +1,79 @@
+--- a/net/minecraft/world/level/block/ButtonBlock.java
++++ b/net/minecraft/world/level/block/ButtonBlock.java
+@@ -33,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 {
+ public static final MapCodec<ButtonBlock> CODEC = RecordCodecBuilder.mapCodec(
+@@ -114,6 +128,19 @@
+ if (state.getValue(POWERED)) {
+ return InteractionResult.CONSUME;
+ } else {
++ // 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(player, GameEvent.BLOCK_ACTIVATE, pos);
+@@ -184,14 +211,38 @@
+ }
+ }
+
+- protected void checkPressed(BlockState state, Level level, BlockPos pos) {
+- AbstractArrow abstractArrow = this.type.canButtonBeActivatedByArrows()
+- ? level.getEntitiesOfClass(AbstractArrow.class, state.getShape(level, pos).bounds().move(pos)).stream().findFirst().orElse(null)
+- : null;
+- boolean flag = abstractArrow != null;
+- boolean flag1 = state.getValue(POWERED);
++ protected void checkPressed(IBlockData state, Level level, BlockPos pos) {
++ AbstractArrow entityarrow = this.type.canButtonBeActivatedByArrows() ? (AbstractArrow) level.getEntitiesOfClass(AbstractArrow.class, state.getShape(level, pos).bounds().move(pos)).stream().findFirst().orElse(null) : null; // CraftBukkit - decompile error
++ boolean flag = entityarrow != null;
++ boolean flag1 = (Boolean) state.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(pos, state.setValue(POWERED, Boolean.valueOf(flag)), 3);
++ // 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(null, level, pos, flag);
+ level.gameEvent(abstractArrow, flag ? GameEvent.BLOCK_ACTIVATE : GameEvent.BLOCK_DEACTIVATE, pos);