Posted February 20, 20223 yr Basically the title. For my mob class, I have the following 2 methods overridden: @Override protected void populateDefaultEquipmentSlots(DifficultyInstance difficultyInstance) { this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(ModItems.COMICALLY_LARGE_SPOON.get())); } @Nullable @Override public SpawnGroupData finalizeSpawn(ServerLevelAccessor serverLevelAccessor, DifficultyInstance difficultyInstance, MobSpawnType mobSpawnType, @Nullable SpawnGroupData spawnGroupData, @Nullable CompoundTag compoundTag) { SpawnGroupData spawnGroupDataToReturn = super.finalizeSpawn(serverLevelAccessor, difficultyInstance, mobSpawnType, spawnGroupData, compoundTag); this.populateDefaultEquipmentSlots(difficultyInstance); return spawnGroupDataToReturn; } I've already tested the item separately, so I know it works fine. However, I still can't get my mob to spawn with the item equipped. Is there anything else I have to do for this?
February 20, 20223 yr Author The method is called. I debugged the code when I used a spawn egg for my mob and stepped through the code, and it did call setItemSlot. I would hit the breakpoint in the debugger both using the spawn egg and using SpawnPlacements.register.
February 20, 20223 yr Author That might be it. My Renderer currently extends MobRenderer. It looks like the following: public class MyMobRenderer<Type extends MyMob> extends MobRenderer<Type, MyMobModel<Type>> { private static final ResourceLocation TEXTURE = new ResourceLocation(Main.MOD_ID, "textures/entities/my_mob.png"); public MyMobRenderer(EntityRendererProvider.Context context) { super(context, new MyMobModel<>(context.bakeLayer(MyMobModel.LAYER_LOCATION)), 0.5f); } @Override public ResourceLocation getTextureLocation(MyMob entity) { return TEXTURE; } } I'll try extending HumanoidMobRenderer to see if that works.
February 20, 20223 yr Author Thanks for mentioning the renderer. Extending HumanoidMobRenderer worked since it has logic for rendering items in hands.
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.