Minecraft – How to change what a zombie is holding

minecraft-commandsminecraft-java-editionminecraft-java-edition-server

Problem

I am setting up a disguising system on Minecraft meant for a server that my friends and I are recording on. What I have right now is this:

tp @e[type=Zombie,name=Rocket] jackmaster110

The idea is that these stay in a repeating command block and the mob seems to be you. The problem is that the items you hold still appear and the mob doesn't hold it. I though, "No problem, I can just use some testfor commands." I set up commands to check which hotbar slot the player is on, and since the series is a roleplay, the hotbar will be preset. Anyway, after setting this up, I realized I had no idea how to make the mob switch items. I did some digging online and found nothing useful. The testfor command is here if you're wondering:

testfor jackmaster110 {SelectedItemSlot:0}

I am aware there is a plugin for this, but it isn't compatible with the replay mod which is what I'm using to record most of the shots.

Background

The series is a Guardians of the Galaxy 1.5 roleplay and we need a Baby Groot (retextured baby zombie pigman), a Rocket (retextured baby zombie), and a Drax (retextured iron golem). That's why we need the disguising.

Other Help

If this isn't possible, does anyone know a disguise plugin that will work with the mod, want to be our camera, or know of a different mod that can work with iDisguise. The last thing I wanted to ask is if anyone knows a way to stop the weird head movement the mob has.

Best Answer

This will probably work:

/replaceitem entity <selector> <slot> <item> [amount]
(entity is not a placeholder)

In the above command:
<selector> must be a player name or entity selector.
<slot> is the inventory slot where the item must be placed (see below).
<item> is the item ID (e.g. minecraft:golden_sword).
[amount] is the how many of the items to stack (must be between 0 and 65, but is optional).

Slots for mobs include:

slot.armor.chest
slot.armor.feet
slot.armor.head
slot.armor.legs
slot.weapon.mainhand
slot.weapon.offhand

Remember, not all mobs will show or make use of the added item. A spider might have a sword, but what is it supposed to do with it?

Oh, and how are you supposed to know which zombie/Rocket you want to mess with? Selectors in Minecraft are a bother, but they work. You'll probably have to give it a custom attribute, such as a name. Give a Summoned mob a name like so:

/summon Zombie x y z {CustomName:"Rocket",IsBaby:1b}
(I don't think you can use spaces for the selecting in the replaceitem command, so best just to use one word names for now. Even underscores can work.)

Now, to give it a sapling!

/replaceitem entity @e[name="Rocket"] slot.weapon.mainhand minecraft:sapling 4 1

There are more things you can do with this command, but I think that this is all you need for what you want to accomplish. I got this information from the Minecraft Gamepedia site for commands, and the more complicated stuff can also be found there.