Files
CatServer/patches/net/minecraft/block/BlockPressurePlate.java.patch
2019-02-24 22:29:41 +08:00

45 lines
2.2 KiB
Diff

--- ../src-base/minecraft/net/minecraft/block/BlockPressurePlate.java
+++ ../src-work/minecraft/net/minecraft/block/BlockPressurePlate.java
@@ -14,13 +14,14 @@
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
+import org.bukkit.event.entity.EntityInteractEvent;
public class BlockPressurePlate extends BlockBasePressurePlate
{
public static final PropertyBool POWERED = PropertyBool.create("powered");
- private final BlockPressurePlate.Sensitivity sensitivity;
+ private final Sensitivity sensitivity;
- protected BlockPressurePlate(Material materialIn, BlockPressurePlate.Sensitivity sensitivityIn)
+ protected BlockPressurePlate(Material materialIn, Sensitivity sensitivityIn)
{
super(materialIn);
this.setDefaultState(this.blockState.getBaseState().withProperty(POWERED, Boolean.valueOf(false)));
@@ -82,6 +83,24 @@
{
for (Entity entity : list)
{
+ 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;
+ }
+ }
+
if (!entity.doesEntityNotTriggerPressurePlate())
{
return 15;