2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/BlockButtonAbstract.java
|
|
|
|
+++ b/net/minecraft/server/BlockButtonAbstract.java
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -4,6 +4,11 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
import java.util.Random;
|
2016-05-10 13:47:39 +02:00
|
|
|
import javax.annotation.Nullable;
|
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
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
public static final BlockStateBoolean POWERED = BlockProperties.w;
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -70,6 +75,19 @@
|
2018-12-06 00:00:00 +01:00
|
|
|
if ((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)) {
|
2019-12-10 23:00:00 +01:00
|
|
|
return EnumInteractionResult.CONSUME;
|
2014-11-25 22:32:16 +01:00
|
|
|
} else {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ boolean powered = ((Boolean) iblockdata.get(POWERED));
|
|
|
|
+ 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);
|
|
|
|
+ world.getServer().getPluginManager().callEvent(eventRedstone);
|
|
|
|
+
|
|
|
|
+ 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
|
2019-12-10 23:00:00 +01:00
|
|
|
this.d(iblockdata, world, blockposition);
|
2018-07-15 02:00:00 +02:00
|
|
|
this.a(entityhuman, world, blockposition, true);
|
2020-06-25 02:00:00 +02:00
|
|
|
return EnumInteractionResult.a(world.isClientSide);
|
|
|
|
@@ -120,6 +138,16 @@
|
|
|
|
if (this.v) {
|
2019-12-10 23:00:00 +01:00
|
|
|
this.e(iblockdata, (World) 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);
|
2019-12-10 23:00:00 +01:00
|
|
|
+ worldserver.getServer().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
|
2019-12-10 23:00:00 +01:00
|
|
|
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, false), 3);
|
2020-06-25 02:00:00 +02:00
|
|
|
this.f(iblockdata, (World) worldserver, blockposition);
|
2019-12-10 23:00:00 +01:00
|
|
|
this.a((EntityHuman) null, worldserver, blockposition, false);
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -140,7 +168,44 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
boolean flag = !list.isEmpty();
|
2018-12-06 00:00:00 +01:00
|
|
|
boolean flag1 = (Boolean) iblockdata.get(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);
|
|
|
|
+ world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ 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);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ world.getServer().getPluginManager().callEvent(eventRedstone);
|
|
|
|
+
|
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
|
2018-12-06 00:00:00 +01:00
|
|
|
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, flag), 3);
|
2019-12-10 23:00:00 +01:00
|
|
|
this.f(iblockdata, world, blockposition);
|
2018-07-15 02:00:00 +02:00
|
|
|
this.a((EntityHuman) null, world, blockposition, flag);
|