--- a/net/minecraft/world/entity/ai/behavior/InteractWithDoor.java
+++ b/net/minecraft/world/entity/ai/behavior/InteractWithDoor.java
@@ -3,7 +3,9 @@
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Sets;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Objects;
+import java.util.Set;
 import javax.annotation.Nullable;
 import net.minecraft.core.BlockPos;
 import net.minecraft.core.GlobalPos;
@@ -19,6 +21,7 @@
 import net.minecraft.world.level.pathfinder.Path;
 
 public class InteractWithDoor extends Behavior<LivingEntity> {
+
     private static final int COOLDOWN_BEFORE_RERUNNING_IN_SAME_NODE = 20;
     private static final double SKIP_CLOSING_DOOR_IF_FURTHER_AWAY_THAN = 2.0D;
     private static final double MAX_DISTANCE_TO_HOLD_DOOR_OPEN_FOR_OTHER_MOBS = 2.0D;
@@ -32,9 +35,10 @@
 
     @Override
     protected boolean checkExtraStartConditions(ServerLevel world, LivingEntity entity) {
-        Path path = entity.getBrain().getMemory(MemoryModuleType.PATH).get();
-        if (!path.notStarted() && !path.isDone()) {
-            if (!Objects.equals(this.lastCheckedNode, path.getNextNode())) {
+        Path pathentity = (Path) entity.getBrain().getMemory(MemoryModuleType.PATH).get();
+
+        if (!pathentity.notStarted() && !pathentity.isDone()) {
+            if (!Objects.equals(this.lastCheckedNode, pathentity.getNextNode())) {
                 this.remainingCooldown = 20;
                 return true;
             } else {
@@ -51,63 +55,86 @@
 
     @Override
     protected void start(ServerLevel world, LivingEntity entity, long time) {
-        Path path = entity.getBrain().getMemory(MemoryModuleType.PATH).get();
-        this.lastCheckedNode = path.getNextNode();
-        Node node = path.getPreviousNode();
-        Node node2 = path.getNextNode();
-        BlockPos blockPos = node.asBlockPos();
-        BlockState blockState = world.getBlockState(blockPos);
-        if (blockState.is(BlockTags.WOODEN_DOORS, (state) -> {
-            return state.getBlock() instanceof DoorBlock;
+        Path pathentity = (Path) entity.getBrain().getMemory(MemoryModuleType.PATH).get();
+
+        this.lastCheckedNode = pathentity.getNextNode();
+        Node pathpoint = pathentity.getPreviousNode();
+        Node pathpoint1 = pathentity.getNextNode();
+        BlockPos blockposition = pathpoint.asBlockPos();
+        BlockState iblockdata = world.getBlockState(blockposition);
+
+        if (iblockdata.is(BlockTags.WOODEN_DOORS, (blockbase_blockdata) -> {
+            return blockbase_blockdata.getBlock() instanceof DoorBlock;
         })) {
-            DoorBlock doorBlock = (DoorBlock)blockState.getBlock();
-            if (!doorBlock.isOpen(blockState)) {
-                doorBlock.setOpen(entity, world, blockState, blockPos, true);
+            DoorBlock blockdoor = (DoorBlock) iblockdata.getBlock();
+
+            if (!blockdoor.isOpen(iblockdata)) {
+                // CraftBukkit start - entities opening doors
+                org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock.at(entity.level, blockposition));
+                entity.level.getCraftServer().getPluginManager().callEvent(event);
+                if (event.isCancelled()) {
+                    return;
+                }
+                // CraftBukkit end
+                blockdoor.setOpen(entity, world, iblockdata, blockposition, true);
             }
 
-            this.rememberDoorToClose(world, entity, blockPos);
+            this.rememberDoorToClose(world, entity, blockposition);
         }
 
-        BlockPos blockPos2 = node2.asBlockPos();
-        BlockState blockState2 = world.getBlockState(blockPos2);
-        if (blockState2.is(BlockTags.WOODEN_DOORS, (state) -> {
-            return state.getBlock() instanceof DoorBlock;
+        BlockPos blockposition1 = pathpoint1.asBlockPos();
+        BlockState iblockdata1 = world.getBlockState(blockposition1);
+
+        if (iblockdata1.is(BlockTags.WOODEN_DOORS, (blockbase_blockdata) -> {
+            return blockbase_blockdata.getBlock() instanceof DoorBlock;
         })) {
-            DoorBlock doorBlock2 = (DoorBlock)blockState2.getBlock();
-            if (!doorBlock2.isOpen(blockState2)) {
-                doorBlock2.setOpen(entity, world, blockState2, blockPos2, true);
-                this.rememberDoorToClose(world, entity, blockPos2);
+            DoorBlock blockdoor1 = (DoorBlock) iblockdata1.getBlock();
+
+            if (!blockdoor1.isOpen(iblockdata1)) {
+                // CraftBukkit start - entities opening doors
+                org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock.at(entity.level, blockposition1));
+                entity.level.getCraftServer().getPluginManager().callEvent(event);
+                if (event.isCancelled()) {
+                    return;
+                }
+                // CraftBukkit end
+                blockdoor1.setOpen(entity, world, iblockdata1, blockposition1, true);
+                this.rememberDoorToClose(world, entity, blockposition1);
             }
         }
 
-        closeDoorsThatIHaveOpenedOrPassedThrough(world, entity, node, node2);
+        InteractWithDoor.closeDoorsThatIHaveOpenedOrPassedThrough(world, entity, pathpoint, pathpoint1);
     }
 
     public static void closeDoorsThatIHaveOpenedOrPassedThrough(ServerLevel world, LivingEntity entity, @Nullable Node lastNode, @Nullable Node currentNode) {
-        Brain<?> brain = entity.getBrain();
-        if (brain.hasMemoryValue(MemoryModuleType.DOORS_TO_CLOSE)) {
-            Iterator<GlobalPos> iterator = brain.getMemory(MemoryModuleType.DOORS_TO_CLOSE).get().iterator();
+        Brain<?> behaviorcontroller = entity.getBrain();
 
-            while(iterator.hasNext()) {
-                GlobalPos globalPos = iterator.next();
-                BlockPos blockPos = globalPos.pos();
-                if ((lastNode == null || !lastNode.asBlockPos().equals(blockPos)) && (currentNode == null || !currentNode.asBlockPos().equals(blockPos))) {
-                    if (isDoorTooFarAway(world, entity, globalPos)) {
+        if (behaviorcontroller.hasMemoryValue(MemoryModuleType.DOORS_TO_CLOSE)) {
+            Iterator iterator = ((Set) behaviorcontroller.getMemory(MemoryModuleType.DOORS_TO_CLOSE).get()).iterator();
+
+            while (iterator.hasNext()) {
+                GlobalPos globalpos = (GlobalPos) iterator.next();
+                BlockPos blockposition = globalpos.pos();
+
+                if ((lastNode == null || !lastNode.asBlockPos().equals(blockposition)) && (currentNode == null || !currentNode.asBlockPos().equals(blockposition))) {
+                    if (InteractWithDoor.isDoorTooFarAway(world, entity, globalpos)) {
                         iterator.remove();
                     } else {
-                        BlockState blockState = world.getBlockState(blockPos);
-                        if (!blockState.is(BlockTags.WOODEN_DOORS, (state) -> {
-                            return state.getBlock() instanceof DoorBlock;
+                        BlockState iblockdata = world.getBlockState(blockposition);
+
+                        if (!iblockdata.is(BlockTags.WOODEN_DOORS, (blockbase_blockdata) -> {
+                            return blockbase_blockdata.getBlock() instanceof DoorBlock;
                         })) {
                             iterator.remove();
                         } else {
-                            DoorBlock doorBlock = (DoorBlock)blockState.getBlock();
-                            if (!doorBlock.isOpen(blockState)) {
+                            DoorBlock blockdoor = (DoorBlock) iblockdata.getBlock();
+
+                            if (!blockdoor.isOpen(iblockdata)) {
                                 iterator.remove();
-                            } else if (areOtherMobsComingThroughDoor(world, entity, blockPos)) {
+                            } else if (InteractWithDoor.areOtherMobsComingThroughDoor(world, entity, blockposition)) {
                                 iterator.remove();
                             } else {
-                                doorBlock.setOpen(entity, world, blockState, blockPos, false);
+                                blockdoor.setOpen(entity, world, iblockdata, blockposition, false);
                                 iterator.remove();
                             }
                         }
@@ -119,13 +146,14 @@
     }
 
     private static boolean areOtherMobsComingThroughDoor(ServerLevel world, LivingEntity entity, BlockPos pos) {
-        Brain<?> brain = entity.getBrain();
-        return !brain.hasMemoryValue(MemoryModuleType.NEAREST_LIVING_ENTITIES) ? false : brain.getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES).get().stream().filter((livingEntity2) -> {
-            return livingEntity2.getType() == entity.getType();
-        }).filter((livingEntity) -> {
-            return pos.closerToCenterThan(livingEntity.position(), 2.0D);
-        }).anyMatch((livingEntity) -> {
-            return isMobComingThroughDoor(world, livingEntity, pos);
+        Brain<?> behaviorcontroller = entity.getBrain();
+
+        return !behaviorcontroller.hasMemoryValue(MemoryModuleType.NEAREST_LIVING_ENTITIES) ? false : (behaviorcontroller.getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES).get()).stream().filter((entityliving1) -> { // CraftBukkit - decompile error
+            return entityliving1.getType() == entity.getType();
+        }).filter((entityliving1) -> {
+            return pos.closerToCenterThan(entityliving1.position(), 2.0D);
+        }).anyMatch((entityliving1) -> {
+            return InteractWithDoor.isMobComingThroughDoor(world, entityliving1, pos);
         });
     }
 
@@ -133,16 +161,19 @@
         if (!entity.getBrain().hasMemoryValue(MemoryModuleType.PATH)) {
             return false;
         } else {
-            Path path = entity.getBrain().getMemory(MemoryModuleType.PATH).get();
-            if (path.isDone()) {
+            Path pathentity = (Path) entity.getBrain().getMemory(MemoryModuleType.PATH).get();
+
+            if (pathentity.isDone()) {
                 return false;
             } else {
-                Node node = path.getPreviousNode();
-                if (node == null) {
+                Node pathpoint = pathentity.getPreviousNode();
+
+                if (pathpoint == null) {
                     return false;
                 } else {
-                    Node node2 = path.getNextNode();
-                    return pos.equals(node.asBlockPos()) || pos.equals(node2.asBlockPos());
+                    Node pathpoint1 = pathentity.getNextNode();
+
+                    return pos.equals(pathpoint.asBlockPos()) || pos.equals(pathpoint1.asBlockPos());
                 }
             }
         }
@@ -153,12 +184,13 @@
     }
 
     private void rememberDoorToClose(ServerLevel world, LivingEntity entity, BlockPos pos) {
-        Brain<?> brain = entity.getBrain();
-        GlobalPos globalPos = GlobalPos.of(world.dimension(), pos);
-        if (brain.getMemory(MemoryModuleType.DOORS_TO_CLOSE).isPresent()) {
-            brain.getMemory(MemoryModuleType.DOORS_TO_CLOSE).get().add(globalPos);
+        Brain<?> behaviorcontroller = entity.getBrain();
+        GlobalPos globalpos = GlobalPos.of(world.dimension(), pos);
+
+        if (behaviorcontroller.getMemory(MemoryModuleType.DOORS_TO_CLOSE).isPresent()) {
+            ((Set) behaviorcontroller.getMemory(MemoryModuleType.DOORS_TO_CLOSE).get()).add(globalpos);
         } else {
-            brain.setMemory(MemoryModuleType.DOORS_TO_CLOSE, Sets.newHashSet(globalPos));
+            behaviorcontroller.setMemory(MemoryModuleType.DOORS_TO_CLOSE, Sets.newHashSet(new GlobalPos[]{globalpos})); // CraftBukkit - decompile error
         }
 
     }
