Files
CatServer/patches/net/minecraft/block/BlockPressurePlate.java.patch

39 lines
1.8 KiB
Diff

--- ../src-base/minecraft/net/minecraft/block/BlockPressurePlate.java
+++ ../src-work/minecraft/net/minecraft/block/BlockPressurePlate.java
@@ -1,6 +1,9 @@
package net.minecraft.block;
import java.util.List;
+
+import org.bukkit.event.entity.EntityInteractEvent;
+
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
@@ -82,6 +85,25 @@
{
for (Entity entity : list)
{
+ // CraftBukkit start - Call interact event when turning on a pressure plate
+ if (this.getRedstoneStrength(worldIn.getBlockState(pos)) == 0) {
+ org.bukkit.World bworld = worldIn.getWorld();
+ org.bukkit.plugin.PluginManager manager = worldIn.getServer().getPluginManager();
+ org.bukkit.event.Cancellable cancellable;
+
+ if (entity instanceof EntityPlayer) {
+ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityPlayer) entity, org.bukkit.event.block.Action.PHYSICAL, pos, null, null, null);
+ } else {
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), bworld.getBlockAt(pos.getX(), pos.getY(), pos.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.doesEntityNotTriggerPressurePlate())
{
return 15;