3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 13:00:06 +01:00
Paper/nms-patches/BlockPressurePlateBinary.patch
2018-12-06 10:00:00 +11:00

39 Zeilen
1.8 KiB
Diff

--- a/net/minecraft/server/BlockPressurePlateBinary.java
+++ b/net/minecraft/server/BlockPressurePlateBinary.java
@@ -3,6 +3,8 @@
import java.util.Iterator;
import java.util.List;
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
+
public class BlockPressurePlateBinary extends BlockPressurePlateAbstract {
public static final BlockStateBoolean POWERED = BlockProperties.t;
@@ -61,6 +63,26 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
+ // CraftBukkit start - Call interact event when turning on a pressure plate
+ if (this.getPower(world.getType(blockposition)) == 0) {
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
+ org.bukkit.event.Cancellable cancellable;
+
+ if (entity instanceof EntityHuman) {
+ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
+ } else {
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ manager.callEvent((EntityInteractEvent) cancellable);
+ }
+
+ // We only want to block turning the plate on if all events are cancelled
+ if (cancellable.isCancelled()) {
+ continue;
+ }
+ }
+ // CraftBukkit end
+
if (!entity.isIgnoreBlockTrigger()) {
return 15;
}