Spawning a mob with an item in its hand

Started by willk55 on

Topic category: Help with MCreator software

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Spawning a mob with an item in its hand

I'm trying to make a block where you can put an item into it and then it will spawn an armor stand that is holding that item. I know how to spawn an entity and how to place an item into an entity's hand, but I can't figure out how to target the armor stand specifically. Any ideas?

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I figured out that you can…
Tue, 08/11/2020 - 20:12

I figured out that you can use the "execute command" block to summon an armor stand with an item in its hand, but you need the id of the item for it to work.

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I solved my problem. Using…
Wed, 08/12/2020 - 12:16

I solved my problem. Using the "execute command" block I summoned an armor stand holding a special item that marks it as needing an item put in its hand. I then made a new procedure and set it to trigger when an entity spawns. If the entity is holding the special item then it will replace the item with the item that was in the block, which it knows from a global itemstack variable that was set before the armor stand was summoned. 

This seems more complicated than it should be; maybe there could be a block added in a later version that allows you to spawn a mob with an item/armor. If you want to do this yourself, this is the basic command used to spawn the armor stand with the item:

/summon armor_stand ~ ~ ~ {HandItems:[{id:"(name of mod):(name of item)",Count:1b}]}

Joined Jan 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
There are Command Generators…
Wed, 08/12/2020 - 13:44

There are Command Generators like mcstacker.net please delete this pls.

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
No, I think you're…
Wed, 08/12/2020 - 17:12

No, I think you're misunderstanding the problem. It's easy to spawn an entity with an item in its hand if you already know its item id, but to spawn in an entity with the same item that is in a block's inventory is harder. The summon command that I put is there so that someone with a similar problem doesn't need to go and figure it out themselves and can have all the information they need right here.

Joined Sep 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
how you make en mcreator to…
Thu, 09/24/2020 - 15:19

how you make en mcreator to spawn a custom entity in its main hand for example a gold_sword?

 

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The best way I found to…
Thu, 09/24/2020 - 19:28

The best way I found to spawn en entity with an item in its hand within a procedure (which is what this forum is talking about) is by using the block from the world procedures tab, 'Execute command /"clear" at xyz', and replacing "clear" with the command:

/summon armor_stand ~ ~ ~ {HandItems:[{id:"mod_name:item_id",Count:1b}]}

To do what you want to do, use this command:

/summon name_of_mod:name_of_mob ~ ~ ~ {HandItems:[{id:"minecraft:gold_sword",Count:1b}]}

Of course, this requires knowing the mod name and item id of the item beforhand, which dosen't seem to currently be possible :/.

If you want the mob to always be holding a gold sword whenever it spawns (not what this forum is talking about) you need to go the behaviors tab of the mob and modify the equipment. The first box should be the main hand.

Joined Sep 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
but the behaviors is only…
Sat, 09/26/2020 - 09:40

but the behaviors is only worked for biped and zombie models no custom

i want the mob always be holding a sword whenever it spawns

the youtuber NorthWestTrees Gaming say me this for the same question

You should be able to do this by creating a right-click on block event for a item, then test if there is air blocks where the entity will spawn so anywhere Y+1 and around that area, if true then under world management the the should be a option to spawn entities just remember to offset the spawn location +1 or it will spawn in the block, next simulate a main-hand arm swing and then lastly test if the player is NOT in creative if true remove item from main-hand.

but i dont know witch procedures are

any idea?

thanks for your time man


 

 

 
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It looks like that is…
Sat, 09/26/2020 - 14:31

It looks like that is describing how to use an item to spawn a mob. I don't think that is what you want to do. As far as I know, there isn't currently a way to let custom mob models hold any item. I've heard that you could attach a model of the item to the model of the mob, but that would only work for one item :/.

While this might not be what you want, I have put what I think you're describing below. If you could post a link to the video I could probably explain it better, but here it is:

https://drive.google.com/file/d/1Pcf083rQjReFIq9tR9M1jE7pGqIsedDm/view?usp=sharing

This is the code for the procedure.

https://drive.google.com/file/d/1EtdH3vCN065SRdRBLvbi3jXYyHl43rZN/view?usp=sharing

Now if you attatch it to the when clicked on block trigger...

https://drive.google.com/file/d/11ouKDcKVIzDvTJ2W5CcHveR_btTgy5F9/view?usp=sharing

it will spawn a pig when the item is right-click on a block.