aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/PressurePlateBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/PressurePlateBlock.java.patch')
-rw-r--r--patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/PressurePlateBlock.java.patch63
1 files changed, 63 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/PressurePlateBlock.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/PressurePlateBlock.java.patch
new file mode 100644
index 0000000000..776a9aaf3d
--- /dev/null
+++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/PressurePlateBlock.java.patch
@@ -0,0 +1,63 @@
+--- a/net/minecraft/world/level/block/PressurePlateBlock.java
++++ b/net/minecraft/world/level/block/PressurePlateBlock.java
+@@ -13,6 +13,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.BooleanProperty;
++import org.bukkit.event.entity.EntityInteractEvent;
++// CraftBukkit end
+
+ public class PressurePlateBlock extends BasePressurePlateBlock {
+ public static final MapCodec<PressurePlateBlock> CODEC = RecordCodecBuilder.mapCodec(
+@@ -43,11 +47,46 @@
+
+ @Override
+ protected int getSignalStrength(Level level, BlockPos pos) {
+- Class<? extends Entity> clazz = switch (this.type.pressurePlateSensitivity()) {
+- case EVERYTHING -> Entity.class;
+- case MOBS -> LivingEntity.class;
+- };
+- return getEntityCount(level, TOUCH_AABB.move(pos), clazz) > 0 ? 15 : 0;
++ Class<? extends Entity> oclass; // CraftBukkit
++
++ switch (this.type.pressurePlateSensitivity()) {
++ case EVERYTHING:
++ oclass = Entity.class;
++ break;
++ case MOBS:
++ oclass = LivingEntity.class;
++ break;
++ default:
++ throw new IncompatibleClassChangeError();
++ }
++
++ Class<? extends Entity> oclass1 = oclass;
++
++ // CraftBukkit start - Call interact event when turning on a pressure plate
++ for (Entity entity : getEntities(level, PressurePlateBlock.TOUCH_AABB.move(pos), oclass)) {
++ if (this.getSignalForState(level.getBlockState(pos)) == 0) {
++ org.bukkit.World bworld = level.getWorld();
++ org.bukkit.plugin.PluginManager manager = level.getCraftServer().getPluginManager();
++ 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(), bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
++ manager.callEvent((EntityInteractEvent) cancellable);
++ }
++
++ // We only want to block turning the plate on if all events are cancelled
++ if (cancellable.isCancelled()) {
++ continue;
++ }
++ }
++
++ return 15;
++ }
++
++ return 0;
++ // CraftBukkit end
+ }
+
+ @Override