So I want my mobs to always spawn with armour using an event, so I used:
package com.example.examplemod.events;
import com.example.examplemod.DirtMod;
import com.example.examplemod.util.RegistryHandling;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.event.entity.*;
@Mod.EventBusSubscriber(modid = DirtMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public class ModClientEvents {
@SubscribeEvent
public static void onMobSpawn(EntityJoinWorldEvent event) {
DirtMod.LOGGER.info(event.getEntity().getName().getString().toLowerCase());
if (event.getEntity().getName().getString().toLowerCase() == "zombie") {
DirtMod.LOGGER.info("Zombie equipped (almost)");
event.getEntity().setItemStackToSlot(EquipmentSlotType.MAINHAND, new ItemStack(() -> RegistryHandling.CDIRT_AXE.get(), 1));
event.getEntity().setItemStackToSlot(EquipmentSlotType.HEAD, new ItemStack(() -> RegistryHandling.CDIRT_HELMET.get(), 1));
DirtMod.LOGGER.info("Zombie equipped!");
}
}
}
It isn't working, and the log doesn't show "Zombie Equipped (almost)". Please help
P.S. CDIRT_HELMET and CDIRT_AXE are both custom armour, one of an armour type and one of a axe type.