mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 04:56:50 +01:00
[Bleeding] Fire interact events for Weighted Pressure Plates. Fixes BUKKIT-5053
In 1.7, Minecraft changed Weighted Pressure Plates to allow players and entities to interact with them, rather than simply changing redstone signal based on the number of items on the pressure plate. This commit adds calls to PlayerInteractEvent or EntityInteractEvent for every entity that steps on the plate.
This commit is contained in:
parent
6a00959980
commit
19521b7f1c
1 changed files with 26 additions and 1 deletions
|
@ -2,6 +2,8 @@ package net.minecraft.server;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
|
||||
|
||||
public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
|
||||
private final int a;
|
||||
|
||||
|
@ -11,7 +13,30 @@ public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
|
|||
}
|
||||
|
||||
protected int e(World world, int i, int j, int k) {
|
||||
int l = Math.min(world.a(Entity.class, this.a(i, j, k)).size(), this.a);
|
||||
// CraftBukkit start
|
||||
int l = 0;
|
||||
java.util.Iterator iterator = world.a(Entity.class, this.a(i, j, k)).iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
org.bukkit.event.Cancellable cancellable;
|
||||
|
||||
if (entity instanceof EntityHuman) {
|
||||
cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, i, j, k, -1, null);
|
||||
} else {
|
||||
cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(i, j, k));
|
||||
world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
|
||||
}
|
||||
|
||||
// We only want to block turning the plate on if all events are cancelled
|
||||
if (!cancellable.isCancelled()) {
|
||||
l++;
|
||||
}
|
||||
}
|
||||
|
||||
l = Math.min(l, this.a);
|
||||
// CraftBukkit end
|
||||
|
||||
if (l <= 0) {
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue