Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.12.1]How would one spawn a custom mob with custom armor and a custom weapon?

Featured Replies

Use Entity#setItemStackToSlot to set the item in an entity's equipment slot.

 

If the mob should always spawn with this equipment or always has a chance to spawn with it, override EntityLiving#setEquipmentBasedOnDifficulty to set the equipment and then override EntityLiving#onInitialSpawn to call it.

 

If the equipment is specific to the way it's being spawned, set the equipment manually before spawning it.

 

Edit: Forgot to mention that EntityLiving#setEquipmentBasedOnDifficulty needs to be called from EntityLiving#onInitialSpawn.

Edited by Choonster

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • Author

I'm doing this, but I don't know what to put in new ItemStack(), when it comes to my custom items

    @SubscribeEvent
    public static void onJacketSpawn(EntityJoinWorldEvent event)
    {
        if (!(event.getEntity() instanceof EntityMasterJacket)) 
        {
            return;
        }      
        
        EntityMasterJacket mj = (EntityMasterJacket) event.getEntity();
        
        mj.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack());
        
    }

Edited by Plgue

  • Author

Seems to be that the code stops here: 

 

 if (!(event.getEntity() instanceof EntityMasterJacket)) 
        {
            return;
        }      

You probably need to do it in the entity's class. Choonster's Entity#setItemStackToSlot method is probably the best way to go.

23 minutes ago, Plgue said:

I'm doing this, but I don't know what to put in new ItemStack(), when it comes to my custom items

 

Why are you using EntityJoinWorldEvent for your own entity?

 

Look at the constructors of the ItemStack class to what parameters they require. You should have your Item and Block instances stored in static fields of a class (usually called something like ModItems/ModBlocks), you can get the instances from these fields to pass to the ItemStack constructor.

 

Do you actually know Java? You need to have a solid understanding of both Java and OO programming in general to a make a mod. This forum isn't for helping people with basic Java issues.

 

13 minutes ago, Plgue said:

Seems to be that the code stops here: 

 

Do you ever spawn an EntityMasterJacket?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

2 minutes ago, Plgue said:

What method would I put it in?

 

I explained that in my first reply.

 

I've also just edited it to include a detail that I forgot (EntityLiving#setEquipmentBasedOnDifficulty needs to be called from EntityLiving#onInitialSpawn).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • Author

I'm sorry about not knowing too much about Minecraft coding, I know basic Java though.

 

  • Author

This whole time the armor and items have been equipped, It's just not rendering for some reason :/

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.