PaperMC/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch

39 lines
1.9 KiB
Diff
Raw Normal View History

2021-03-15 23:00:00 +01:00
--- a/net/minecraft/world/level/block/BlockPressurePlateBinary.java
+++ b/net/minecraft/world/level/block/BlockPressurePlateBinary.java
@@ -17,6 +17,8 @@
import net.minecraft.world.level.block.state.properties.BlockStateBoolean;
2021-03-15 23:00:00 +01:00
import net.minecraft.world.phys.AxisAlignedBB;
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
+
public class BlockPressurePlateBinary extends BlockPressurePlateAbstract {
public static final BlockStateBoolean POWERED = BlockProperties.POWERED;
@@ -74,6 +76,26 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
+ // CraftBukkit start - Call interact event when turning on a pressure plate
+ if (this.getSignalForState(world.getBlockState(blockposition)) == 0) {
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.plugin.PluginManager manager = world.getCraftServer().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.isIgnoringBlockTriggers()) {
return 15;
}