2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/level/block/BlockButtonAbstract.java
|
|
|
|
+++ b/net/minecraft/world/level/block/BlockButtonAbstract.java
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -27,6 +27,11 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
|
|
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.event.block.BlockRedstoneEvent;
|
|
|
|
+import org.bukkit.event.entity.EntityInteractEvent;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
public abstract class BlockButtonAbstract extends BlockAttachable {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
public static final BlockStateBoolean POWERED = BlockProperties.POWERED;
|
|
|
|
@@ -97,6 +102,19 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
if ((Boolean) iblockdata.getValue(BlockButtonAbstract.POWERED)) {
|
2019-12-10 23:00:00 +01:00
|
|
|
return EnumInteractionResult.CONSUME;
|
2014-11-25 22:32:16 +01:00
|
|
|
} else {
|
|
|
|
+ // CraftBukkit start
|
2021-11-21 23:00:00 +01:00
|
|
|
+ boolean powered = ((Boolean) iblockdata.getValue(POWERED));
|
2014-11-25 22:32:16 +01:00
|
|
|
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
|
|
+ int old = (powered) ? 15 : 0;
|
|
|
|
+ int current = (!powered) ? 15 : 0;
|
|
|
|
+
|
|
|
|
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
|
2021-06-11 13:33:49 +02:00
|
|
|
+ world.getCraftServer().getPluginManager().callEvent(eventRedstone);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ if ((eventRedstone.getNewCurrent() > 0) != (!powered)) {
|
2019-12-10 23:00:00 +01:00
|
|
|
+ return EnumInteractionResult.SUCCESS;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2021-11-21 23:00:00 +01:00
|
|
|
this.press(iblockdata, world, blockposition);
|
|
|
|
this.playSound(entityhuman, world, blockposition, true);
|
|
|
|
world.gameEvent(entityhuman, GameEvent.BLOCK_PRESS, blockposition);
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -148,6 +166,16 @@
|
|
|
|
if (this.sensitive) {
|
2021-11-21 23:00:00 +01:00
|
|
|
this.checkPressed(iblockdata, worldserver, blockposition);
|
2018-07-15 02:00:00 +02:00
|
|
|
} else {
|
|
|
|
+ // CraftBukkit start
|
2019-12-10 23:00:00 +01:00
|
|
|
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0);
|
2021-06-11 13:33:49 +02:00
|
|
|
+ worldserver.getCraftServer().getPluginManager().callEvent(eventRedstone);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
+ if (eventRedstone.getNewCurrent() > 0) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2021-11-21 23:00:00 +01:00
|
|
|
worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockButtonAbstract.POWERED, false), 3);
|
|
|
|
this.updateNeighbours(iblockdata, worldserver, blockposition);
|
|
|
|
this.playSound((EntityHuman) null, worldserver, blockposition, false);
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -169,11 +197,48 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
boolean flag = !list.isEmpty();
|
2021-11-21 23:00:00 +01:00
|
|
|
boolean flag1 = (Boolean) iblockdata.getValue(BlockButtonAbstract.POWERED);
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Call interact event when arrows turn on wooden buttons
|
|
|
|
+ if (flag1 != flag && flag) {
|
|
|
|
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
|
|
+ boolean allowed = false;
|
|
|
|
+
|
|
|
|
+ // If all of the events are cancelled block the button press, else allow
|
|
|
|
+ for (Object object : list) {
|
|
|
|
+ if (object != null) {
|
|
|
|
+ EntityInteractEvent event = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block);
|
2021-06-11 13:33:49 +02:00
|
|
|
+ world.getCraftServer().getPluginManager().callEvent(event);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ if (!event.isCancelled()) {
|
|
|
|
+ allowed = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!allowed) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
if (flag != flag1) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2018-07-15 02:00:00 +02:00
|
|
|
+ boolean powered = flag1;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
2018-07-15 02:00:00 +02:00
|
|
|
+ int old = (powered) ? 15 : 0;
|
|
|
|
+ int current = (!powered) ? 15 : 0;
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
|
2021-06-11 13:33:49 +02:00
|
|
|
+ world.getCraftServer().getPluginManager().callEvent(eventRedstone);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
+ if ((flag && eventRedstone.getNewCurrent() <= 0) || (!flag && eventRedstone.getNewCurrent() > 0)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2021-11-21 23:00:00 +01:00
|
|
|
world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockButtonAbstract.POWERED, flag), 3);
|
|
|
|
this.updateNeighbours(iblockdata, world, blockposition);
|
|
|
|
this.playSound((EntityHuman) null, world, blockposition, flag);
|
|
|
|
- world.gameEvent((Entity) list.stream().findFirst().orElse((Object) null), flag ? GameEvent.BLOCK_PRESS : GameEvent.BLOCK_UNPRESS, blockposition);
|
|
|
|
+ world.gameEvent((Entity) list.stream().findFirst().orElse(null), flag ? GameEvent.BLOCK_PRESS : GameEvent.BLOCK_UNPRESS, blockposition); // CraftBukkit - decompile error
|
2021-06-11 07:00:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flag) {
|