Posted October 24, 20204 yr 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.
October 24, 20204 yr 5 hours ago, redtub345 said: It isn't working, and the log doesn't show "Zombie Equipped (almost)". Please help First of all, remove value = Dist.CLIENT The client should not be the one giving items to mobs, that is the job of the server. You can get more details about that at the official forge documentation. Second, you should not use reference equality (==) to check if two strings are equal. In this case, you should not compare strings at all, you probably want to use event.getEntity().getType() to compare entity types. 5 hours ago, redtub345 said: Is this the wrong topic? I'm new here sorry. Yes, you should have posted this in the 'Modder Support' forum and not here, but don't worry about it, a moderator can always move it.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.