2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/level/block/BlockPressurePlateWeighted.java
|
|
|
|
+++ b/net/minecraft/world/level/block/BlockPressurePlateWeighted.java
|
2023-12-05 17:40:00 +01:00
|
|
|
@@ -14,6 +14,11 @@
|
2023-03-14 17:30:00 +01:00
|
|
|
import net.minecraft.world.level.block.state.properties.BlockSetType;
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.level.block.state.properties.BlockStateInteger;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2023-03-14 17:30:00 +01:00
|
|
|
+// CraftBukkit start
|
|
|
|
+import net.minecraft.world.entity.player.EntityHuman;
|
|
|
|
+import org.bukkit.event.entity.EntityInteractEvent;
|
|
|
|
+// CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
|
|
|
|
|
2023-12-05 17:40:00 +01:00
|
|
|
public static final MapCodec<BlockPressurePlateWeighted> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
|
|
|
@@ -39,7 +44,27 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2021-11-21 23:00:00 +01:00
|
|
|
protected int getSignalStrength(World world, BlockPosition blockposition) {
|
2023-06-07 17:30:00 +02:00
|
|
|
- int i = Math.min(getEntityCount(world, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition), Entity.class), this.maxWeight);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2023-06-07 17:30:00 +02:00
|
|
|
+ // int i = Math.min(getEntityCount(world, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition), Entity.class), this.maxWeight);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ int i = 0;
|
2023-06-07 17:30:00 +02:00
|
|
|
+ for (Entity entity : getEntities(world, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition), Entity.class)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ org.bukkit.event.Cancellable cancellable;
|
|
|
|
+
|
|
|
|
+ if (entity instanceof EntityHuman) {
|
2016-03-04 05:24:51 +01:00
|
|
|
+ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ } else {
|
|
|
|
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
2021-06-11 13:33:49 +02:00
|
|
|
+ world.getCraftServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // We only want to block turning the plate on if all events are cancelled
|
|
|
|
+ if (!cancellable.isCancelled()) {
|
|
|
|
+ i++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2021-06-11 07:00:00 +02:00
|
|
|
+ i = Math.min(i, this.maxWeight);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
|
|
|
|
if (i > 0) {
|
2021-06-11 07:00:00 +02:00
|
|
|
float f = (float) Math.min(this.maxWeight, i) / (float) this.maxWeight;
|