Skip to content

Commit

Permalink
Prevent zombies and vindicators from getting through steel doors
Browse files Browse the repository at this point in the history
  • Loading branch information
BluSunrize committed Jun 20, 2024
1 parent 2715d0d commit d0ebd39
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.goal.BreakDoorGoal;
import net.minecraft.world.entity.ai.goal.WrappedGoal;
import net.minecraft.world.entity.monster.Zombie;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.DoorBlock;
Expand All @@ -28,6 +34,7 @@
import net.minecraft.world.phys.BlockHitResult;

import javax.annotation.Nullable;
import java.util.function.Predicate;

public class IEDoorBlock extends DoorBlock
{
Expand Down Expand Up @@ -98,4 +105,13 @@ public void neighborChanged(BlockState blockState, Level level, BlockPos pos, Bl
else
super.neighborChanged(blockState, level, pos, block, fromPos, isMoving);
}

@Override
public boolean canEntityDestroy(BlockState state, BlockGetter level, BlockPos pos, Entity entity)
{
// prevent mobs with door breaking goals from getting through steel doors
if(entity instanceof Mob mob&&mob.goalSelector.getRunningGoals().anyMatch(wrappedGoal -> wrappedGoal.getGoal() instanceof BreakDoorGoal))
return this.type()!=STEEL;
return super.canEntityDestroy(state, level, pos, entity);
}
}

0 comments on commit d0ebd39

Please sign in to comment.