diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch new file mode 100644 index 0000000000..d5bbe02130 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch @@ -0,0 +1,46 @@ +--- a/net/minecraft/world/level/block/WeightedPressurePlateBlock.java ++++ b/net/minecraft/world/level/block/WeightedPressurePlateBlock.java +@@ -14,6 +14,8 @@ + import net.minecraft.world.level.block.state.properties.BlockSetType; + import net.minecraft.world.level.block.state.properties.BlockStateProperties; + import net.minecraft.world.level.block.state.properties.IntegerProperty; ++import org.bukkit.event.entity.EntityInteractEvent; ++// CraftBukkit end + + public class WeightedPressurePlateBlock extends BasePressurePlateBlock { + public static final MapCodec<WeightedPressurePlateBlock> CODEC = RecordCodecBuilder.mapCodec( +@@ -40,9 +42,31 @@ + + @Override + protected int getSignalStrength(Level level, BlockPos pos) { +- int min = Math.min(getEntityCount(level, TOUCH_AABB.move(pos), Entity.class), this.maxWeight); +- if (min > 0) { +- float f = (float)Math.min(this.maxWeight, min) / (float)this.maxWeight; ++ // CraftBukkit start ++ // int i = Math.min(getEntityCount(world, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition), Entity.class), this.maxWeight); ++ int i = 0; ++ for (Entity entity : getEntities(level, WeightedPressurePlateBlock.TOUCH_AABB.move(pos), Entity.class)) { ++ org.bukkit.event.Cancellable cancellable; ++ ++ if (entity instanceof Player) { ++ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((Player) entity, org.bukkit.event.block.Action.PHYSICAL, pos, null, null, null); ++ } else { ++ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ())); ++ level.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; ++ + return Mth.ceil(f * 15.0F); + } else { + return 0; |