You need to add @EventBusSubscriber(<modid>) above the class, and make sure it is registered in your main class, or change the method to static. Also it might be better to fire it from LivingSpawnEvent (this is what it is called in 1.15, might be something different in 1.12), since that is only called when an entity spawns, rather than any time one gets loaded (also only applies to living entities).
Thanks, It worked perfectly. I replicated the same code for the skeleton, so that the skeleton spawn with diamond armor and a bow enchanted with punch 2. When I tested it diamond armor was perfect but the bow wasn't enchanted.
Here's my class:
public class SkeletonArchers
public static void giveArmor(LivingSpawnEvent event)
if (!(event.getEntity() instanceof EntitySkeleton))
EntitySkeleton skeleton = (EntitySkeleton) event.getEntity();
ItemStack bow = new ItemStack(Items.BOW);
skeleton.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(Items.DIAMOND_HELMET));
skeleton.setItemStackToSlot(EntityEquipmentSlot.CHEST, new ItemStack(Items.DIAMOND_CHESTPLATE));
skeleton.setItemStackToSlot(EntityEquipmentSlot.LEGS, new ItemStack(Items.DIAMOND_LEGGINGS));
skeleton.setItemStackToSlot(EntityEquipmentSlot.FEET, new ItemStack(Items.DIAMOND_BOOTS));
I thought it was a problem with the bow ItemStack, I tested by changing EntityEquipmentSlot.MAINHAND with EntityEquipmentSlot.OFFHAND and it worked!
I searched through the EntityCreeper class but could not find anything related to creeper Charging can you at least tell me the name of the method in 1.15 so I can find something related to it in 1.12.2 EntityCreeper class