Prevent Minecraft monster despawn?

ga
- in Worlds
9

Hello there's an event or a method to cancel the despawning of the minecraft mobs

They are spawned like this

Zombie zombie = (Zombie) Bukkit.getWorld (getRandomZombieLocation (). GetWorld (). GetName ()). SpawnEntity (location, EntityType.ZOMBIE);

zombie.setCustomName ("§cLevel 1 Zombie");

Al

Nametags

Fa

If you put a name tag around them, they shouldn't despawn

ga

I mean in the code I spawn E.b. Zombies with displayname

Fa

To what extent display name

ga

Public static void levelOneZombie (int amount) {
for (int x = 0; x addMonster (1);
Location location = getRandomZombieLocation ();
Zombie zombie = (Zombie) Bukkit.getWorld (getRandomZombieLocation (). GetWorld (). GetName ()). SpawnEntity (location, EntityType.ZOMBIE);
zombie.setCustomName ("§cLevel 1 Zombie");
zombie.setCanPickupItems (false);
zombie.setCustomNameVisible (true);
zombie.setNoDamageTicks (60);
zombie.setMaxHealth (0.5);
zombie.setFireTicks (0);

EntityEquipment equip = zombie.getEquipment ();
equip.setLeggings (new ItemStack (Material.LEATHER_LEGGINGS));
}

}

Fa

Now you've lost me Personally, I would simply change a nametag then they would not despawn

an

He means by code… Otherwise he would not have given a code example…

Al

Give every hstmob a name tag

an

To keep your mob from despawning, simply do this:

zombie.setRemoveWhenFarAway (false);

Of course, it works with any LivingEntity, not just with zombies. Here is the documentation:

https://hub.spigotmc.org/...y(boolean)