1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
--- a/net/minecraft/world/level/block/PressurePlateBlock.java
+++ b/net/minecraft/world/level/block/PressurePlateBlock.java
@@ -12,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 {
@@ -46,9 +46,8 @@
}
@Override
- @Override
- protected int getSignalStrength(Level level, BlockPos blockpos) {
- Class oclass;
+ protected int getSignalStrength(Level level, BlockPos pos) {
+ Class<? extends Entity> oclass; // CraftBukkit
switch (this.type.pressurePlateSensitivity()) {
case EVERYTHING:
@@ -63,7 +62,31 @@
Class<? extends Entity> oclass1 = oclass;
- return getEntityCount(level, PressurePlateBlock.TOUCH_AABB.move(blockpos), oclass1) > 0 ? 15 : 0;
+ // 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
|