Hi, I'm having trouble adding a potion effect to a zombie. After an hour of searching on Google, I still can't figure it out. Here's what I have Code: public void event(CreatureSpawnEvent event) { if (event.getEntityType() == EntityType.ZOMBIE) { LivingEntity zombie = event.getEntity(); zombie.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); zombie.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 1, true)); } } All the zombies spawn with a diamond helmet, but I can't get the potion effect to apply.
That is because the event code gets handled before the mob actually spawns. Schedule a task 1 tick in the future to add the effect to the mob, once it has spawned.
I just tried for an hour to get a runnable to work for this, do you have any examples I can work off of?