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");
Nametags
If you put a name tag around them, they shouldn't despawn
I mean in the code I spawn E.b. Zombies with displayname
To what extent display name
Public static void levelOneZombie (int amount) {
for (int x = 0; x
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));
}
}
Now you've lost me Personally, I would simply change a nametag then they would not despawn
He means by code… Otherwise he would not have given a code example…
Give every hstmob a name tag
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: