[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.
Dieser Commit ist enthalten in:
GJ 2013-12-16 23:16:16 -05:00 committet von Nate Mortensen
Ursprung 6a00959980
Commit 19521b7f1c

Datei anzeigen

@ -2,6 +2,8 @@ package net.minecraft.server;
import java.util.List; import java.util.List;
import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract { public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
private final int a; private final int a;
@ -11,7 +13,30 @@ public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
} }
protected int e(World world, int i, int j, int k) { 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) { if (l <= 0) {
return 0; return 0;