Paper/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch
CraftBukkit/Spigot 536256d6ff SPIGOT-6508: Rename conflicted getServer
By: md_5 <git@md-5.net>
2021-06-11 21:33:49 +10:00

45 lines
2.1 KiB
Diff

--- a/net/minecraft/world/level/block/BlockPressurePlateWeighted.java
+++ b/net/minecraft/world/level/block/BlockPressurePlateWeighted.java
@@ -14,6 +14,8 @@
import net.minecraft.world.level.block.state.properties.BlockProperties;
import net.minecraft.world.level.block.state.properties.BlockStateInteger;
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
+
public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
public static final BlockStateInteger POWER = BlockProperties.POWER;
@@ -27,7 +29,31 @@
@Override
protected int b(World world, BlockPosition blockposition) {
- int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.TOUCH_AABB.a(blockposition)).size(), this.maxWeight);
+ // CraftBukkit start
+ // int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight);
+ int i = 0;
+ java.util.Iterator iterator = world.a(Entity.class, BlockPressurePlateWeighted.TOUCH_AABB.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.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;