[unsovled]How Do Zombies Target Doors in a village? {code}

Hello can someone explain the code for how a zombie is able to sense an entity inside of a bunch of blocks and breaks down the wooden door? thank you :slight_smile:

Well, let me guess:

  1. All Entities around a Zombie are tested, if the Zombie can see them (via ray tracing or such).
  2. Then the Pathfinder finds a path (who’d have known?) but ignores wooden doors.
  3. The Zombie walks along that path and when he hits a door, he starts breaking it.

I don’t know if this is 100% correct, but is that what you want to know? If you want a full explanation on the Pathfinder, i think we’d need way more text^^

yup look for some example code of this in action :slight_smile: lol

I think zombies arbitrarily look for doors to break if they can’t find a player, but i may be wrong on that…

I think they only break doors if they’re in the way.

…yes but how? lol that’s what i['m asking for can anyone show the coding that does this in minecraft?

I’m pretty sure zombies just go after doors if there might be something behind them.

I have seen zombies attack random village doors and then stop when they’re open because there isn’t anything inside.

ok but how do they attack doors? :slight_smile:

The best thing you could do is to search through the code yourself. That’s what I do when I want to know how something in vanilla works.
Obviously a good start would be to look at EntityZombie
You can see various AI configuration in the constructor e.g. ((PathNavigateGround)this.getNavigator()).setBreakDoors(true);

Entity AI is built on a lot of things so there’s not just one piece of code responsible, it’s built on a fair amount of abstraction. So yeah best thing to do is to dive in and see what you find.

@gravityfox Maybe the wander-around-pathfinder does ignore doors too? And when a Zombie wants to wander in a house, he knocks on the door! This might look random ^^

@simon816 ok … i think lol so pathnavigateground…is that what allows the monsters to walk around?

and where would i find this code? at that uses entity ai?

oooh and can someone explain the entity keys a bit more? Obviously some of them are explanatory but how bout target or anger etc?

ok…so i placecd oak doors down in a whiteserver with controlled variables…then i had this code running…

    public void onBreak(ChangeBlockEvent.Break event){

However the console doesn’t see anything being broken…doors or sand blocks when i break them…help? trying to log and see what they break…but still not working

You can set up a forge project, or just set up the spongeforge project in your workspace, then you can browse the minecraft code in the dependency.

I’m not going to tell you every entity key, but I will say that TARGET relates to TargetLivingData and it’s basically if an entity is ‘targeting’ another entity in AI. e.g. a zombie targeting a villager (I think).
ANGER relates to AngerableData and is an integer representing how ‘angry’ the entity currently is.

It may be useful for you to explore the org.spongepowered.api.data.manipulator.mutable.entity package for more entity related data.

I’m guessing this is the same problem as this thread:

so apparently there is still no zombie’s breaking down my doors lol any help?

Oh so you have an issue with them not breaking doors? Make sure the difficulty level is set to HARD (difficulty=3)

BTW you can see in EntityAIBreakDoor where this happens,

        if (this.breakingTime == 240 && this.theEntity.worldObj.getDifficulty() == EnumDifficulty.HARD)
1 Like

…k so i changed it to hard and they still won’t break down the wooden door to get to me :frowning:

Do you have any plugins/mods? Did you leave the zombie long enough?

yes i’ve got some mods and plugins…but none of them effect the mobs. :confused: what do you mean leave the zombie long enough? yea i sat at my door and when he couldn’t get to me he left