mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 13:06:02 +01:00
44 lines
1.9 KiB
Diff
44 lines
1.9 KiB
Diff
--- /home/matt/mc-dev-private//net/minecraft/server/BlockPressurePlateWeighted.java 2015-02-26 22:40:22.219608143 +0000
|
|
+++ src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java 2015-02-26 22:40:22.219608143 +0000
|
|
@@ -1,5 +1,7 @@
|
|
package net.minecraft.server;
|
|
|
|
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
|
|
+
|
|
public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
|
|
|
|
public static final BlockStateInteger POWER = BlockStateInteger.of("power", 0, 15);
|
|
@@ -16,7 +18,31 @@
|
|
}
|
|
|
|
protected int f(World world, BlockPosition blockposition) {
|
|
- int i = Math.min(world.a(Entity.class, this.a(blockposition)).size(), this.b);
|
|
+ // CraftBukkit start
|
|
+ //int i = Math.min(world.a(Entity.class, this.a(blockposition)).size(), this.b);
|
|
+ int i = 0;
|
|
+ java.util.Iterator iterator = world.a(Entity.class, this.a(blockposition)).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, blockposition, null, null);
|
|
+ } else {
|
|
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
|
+ world.getServer().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.b);
|
|
+ // CraftBukkit end
|
|
|
|
if (i > 0) {
|
|
float f = (float) Math.min(this.b, i) / (float) this.b;
|