3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 04:50:05 +01:00
Paper/nms-patches/BlockPressurePlateWeighted.patch

44 Zeilen
1.9 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/BlockPressurePlateWeighted.java
+++ b/net/minecraft/server/BlockPressurePlateWeighted.java
@@ -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);
2015-02-26 23:41:06 +01:00
@@ -16,7 +18,31 @@
}
2016-02-29 22:32:46 +01:00
protected int e(World world, BlockPosition blockposition) {
- int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight);
+ // CraftBukkit start
2016-02-29 22:32:46 +01:00
+ // int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight);
+ int i = 0;
2016-02-29 22:32:46 +01:00
+ java.util.Iterator iterator = world.a(Entity.class, BlockPressurePlateWeighted.c.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, 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++;
+ }
+ }
+
2015-07-30 08:56:52 +02:00
+ i = Math.min(i, this.weight);
+ // CraftBukkit end
if (i > 0) {
2015-07-30 08:56:52 +02:00
float f = (float) Math.min(this.weight, i) / (float) this.weight;