PaperMC/nms-patches/BehaviorInteractDoor.patch

34 lines
1.7 KiB
Diff
Raw Normal View History

2019-04-23 04:00:00 +02:00
--- a/net/minecraft/server/BehaviorInteractDoor.java
+++ b/net/minecraft/server/BehaviorInteractDoor.java
2019-05-14 02:00:00 +02:00
@@ -23,7 +23,7 @@
2019-04-23 04:00:00 +02:00
Set<BlockPosition> set = this.a(worldserver, list, list1);
int j = pathentity.f() - 1;
- this.a(worldserver, list1, set, j);
+ this.a(worldserver, list1, set, j, entityliving); // CraftBukkit - add entity
}
private Set<BlockPosition> a(WorldServer worldserver, List<GlobalPos> list, List<BlockPosition> list1) {
2019-05-14 02:00:00 +02:00
@@ -35,13 +35,20 @@
2019-04-23 04:00:00 +02:00
return (Set) stream.filter(list1::contains).collect(Collectors.toSet());
}
- private void a(WorldServer worldserver, List<BlockPosition> list, Set<BlockPosition> set, int i) {
+ private void a(WorldServer worldserver, List<BlockPosition> list, Set<BlockPosition> set, int i, EntityLiving entityliving) { // CraftBukkit - add entity
set.forEach((blockposition) -> {
int j = list.indexOf(blockposition);
IBlockData iblockdata = worldserver.getType(blockposition);
Block block = iblockdata.getBlock();
if (TagsBlock.WOODEN_DOORS.isTagged(block) && block instanceof BlockDoor) {
+ // CraftBukkit start - entities opening doors
+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.world, blockposition));
+ entityliving.world.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ // CaftBukkit end
((BlockDoor) block).setDoor(worldserver, blockposition, j >= i);
}