Minecraft Blogs / Tutorial

How to replace item?

  • 24,591 views, 1 today
  • 5
  • 2
  • 14
Mr0-Redmen's Avatar Mr0-Redmen
Level 34 : Artisan Engineer
4
Having problems with /replaceitem?
Then read this tutorial!
/replaceitem has /replaceitem entity OR /replaceitem block.
So you can do
/replaceitem block <x,y,z> <slot> <item> [amount] [data] [dataTag]
OR
/replaceitem entity <selector> <slot> <item> [amount] [data] [dataTag]
1.Explaining the /replaceitem entity.
The "entity" keyword sets it so you replaceitems in a entities inventory(villagers,players,zombies etc.)!
1.1 What is a <selector>?
Selectors can be @p,@e,@a,@r.
@p - closest player to the command block.
@e - entities.
@a - all players.
@r - random player.
Instead of the selector you can put the targets name, example:
/replaceitem entity Mr0Redmen ...
1.2 What are slots?
Slots are inventory areas where you put item,
like in your hotbar you have 9 slots.
Now here we don't use numbers to select slots, we use names.Example:
slot.armor.head
is the helmet slot.
To see all slots you can after typing the selector press tab or look it up on google(can't list theme here, maybe in another blog because there is a lot of them)!
1.3 What to type in item?
Basicly the name of the item, if you are new to 1.8 you can now use names only like: minecraft:grass or just grass.
1.4 Amount?
How much items you want to be placed in a entities inventory, this is optional, hence the [] brackets.
1.5 What is data?
Data or damage is a value that was first used to define the durability of tools, now many items use data/damage values to define stuff(like what color is a wool is defined by its data).
1.6 Whats a dataTag?
Data tag also know as the NBTtag is data that basicly has some more info on what the item is(What is written in book pages,what enchantments does a tool have,the name of the item and many many many more...)!
To see all NBTtags check out:
Minecraft Gamepedia NBT Tags
1.7 So how to replaceitem on entity?
For example:
/replaceitem entity Mr0Redmen slot.hotbar.4 diamond_sword 1 60 {ench:[{id:16,lvl:1}]}
This would put 1 enchanted diamond sword with sharpness 16 into my 5 hotbar slot that is a bit damaged.
2.Explaining /replaceitem block.
This basicly sets it so we manipulate the inventory of a block like a chest or dispenser.
1.1.What are x y z?
They are coordinates, you can check coordinates with the debug button(F3).
They basicly say at what coordinates the block is and then it manipulates the inventory of that block!
1.2.Slots?
I talked about theme in entity they are the exact same thing.
1.3 Items?
Also in entity.
1.4 Amount?
Check Entity.
1.5 Data?
Check Entity...
1.6 DataTag?
I talked about theme in Entity.
1.7 So i want to put in the second slot of a chest 3 diamond swords that are a bit damaged with the name "Mega Sword".
/replaceitem block ~ ~-1 ~ slot.container.1 diamond_sword 3 30 {display:{Name:"Mega Sword"}}
--------------------------------------------------------------
So that's about it if you still have a problem or need help with another command you can ask me in the comments!
I will be doing tutorials on more 1.8 commands!
~Mr0
Tags

Create an account or sign in to comment.

1
05/06/2017 3:16 pm
Level 1 : New Miner
BeepBeepAmSheep
BeepBeepAmSheep's Avatar
i need some help, maybe i'm waaay too late, but i'm trying to make a sort of clone machine, i have a disguise plugin on my server, so if i spawn a skeleton i can just disguise it into a player, thats not a problem,but the problem is i want the skeleton to have the same stuff as the player, weapons, shield, enchants, uses, and even health and effects if its possible, i'm very newbie to commands, and i'm looking forward to a helpful guide, (ps : i'm bad at scoreboards).
1
06/26/2016 7:54 am
Level 4 : Apprentice Network
CactusTato
CactusTato's Avatar
how to make it where if they click it it goes and makes it a suffix?
1
12/13/2014 11:35 am
Level 11 : Journeyman Miner
meltroxgeolix
meltroxgeolix's Avatar
I have a question? I am trying to summon an ArmorStand with a slab on it's head. I have already got that to work, but my problem is how do I change the Damage value of the slab, so the slab on it's head will be an upper stone brick slab? (The damage value for that is 15, I just don't know how to put it in the equipment.)
1
08/28/2015 8:01 am
Level 4 : Apprentice Network
Moderocky
Moderocky's Avatar
The thing after the Amount is the damage value. You could also use Entitydata.

Hope that helped!
1
11/14/2014 4:43 pm
Level 1 : New Miner
cronostasis
cronostasis's Avatar
how do i change the item names color?
1
11/16/2014 3:03 pm
Level 34 : Artisan Engineer
Mr0-Redmen
Mr0-Redmen's Avatar
There isn't a way to do that without using MCEdit.
1
08/28/2015 8:02 am
Level 4 : Apprentice Network
Moderocky
Moderocky's Avatar
That's weird, I've seen people do it before.
1
07/21/2014 12:07 pm
Level 1 : New Miner
Dowapa
Dowapa's Avatar
I need help...
Im trying to create a attack combo damage system using replace item. I want to replace the item using inventory detection (checking the damage value on the sword to see when it has been used). I cant get replace item work only when the inventory is specified. Either it dosent work or it does it when its not suposed to.
I also want this to work in multiplayer
1
07/21/2014 6:31 pm
Level 34 : Artisan Engineer
Mr0-Redmen
Mr0-Redmen's Avatar
1.Make a clock any type of clock.The faster the clock the better the it will work.
2.Put a command block that says: /testfor @p {Inventory:[{id:minecraft:iron_sword,Count:1b,Damage:5b,Slot:0b}],SelectedItemSlot:0b}
3.Put a comperator going out of the command block, when the comperator is on that means that there is a player that has used his sword.



Explanation:
1.Constantly runs the command.
2.Looks for a player that has selected and has damaged a iron sword, Damage:5b is the damage value.
3.Is to easy to explain.



This is a bit buggy in multiplayer.
If you are making a map and this still hasen't help you I could help you on my server or send you a scamatic of the build.
1
07/21/2014 9:13 pm
Level 1 : New Miner
Dowapa
Dowapa's Avatar
I understand this consept. however... it would not work in mutiplayer the way i want it to. I was hoping that there was going to be a way to directaly put the players inventory into the command. for example
/replaceitem entity @a slot.hotbar.4 diamond_sword 1 60 {ench:[{id:16,lvl:1}]} {Inventory:[{id:minecraft:iron_sword,Count:1b,Damage:5b,Slot:0b}],SelectedItemSlot:0b} (i copyed commands from the post for convience)
but that does give me an idea... so i might be able to do this.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome