--- a/net/minecraft/world/level/block/BlockPressurePlateWeighted.java +++ b/net/minecraft/world/level/block/BlockPressurePlateWeighted.java @@ -14,6 +14,11 @@ import net.minecraft.world.level.block.state.properties.BlockSetType; import net.minecraft.world.level.block.state.properties.BlockStateInteger; +// CraftBukkit start +import net.minecraft.world.entity.player.EntityHuman; +import org.bukkit.event.entity.EntityInteractEvent; +// CraftBukkit end + public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { @@ -39,7 +44,27 @@ @Override protected int getSignalStrength(World world, BlockPosition blockposition) { - int i = Math.min(getEntityCount(world, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition), Entity.class), this.maxWeight); + // CraftBukkit start + // int i = Math.min(getEntityCount(world, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition), Entity.class), this.maxWeight); + int i = 0; + for (Entity entity : getEntities(world, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition), Entity.class)) { + 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(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getCraftServer().getPluginManager().callEvent((EntityInteractEvent) cancellable); + } + + // We only want to block turning the plate on if all events are cancelled + if (!cancellable.isCancelled()) { + i++; + } + } + + i = Math.min(i, this.maxWeight); + // CraftBukkit end if (i > 0) { float f = (float) Math.min(this.maxWeight, i) / (float) this.maxWeight;