#how to replace an item with another specific item?
1 messages · Page 1 of 1 (latest)
You can clear it and /give
I found this /replaceitem command and I should now only select the mainhand slot to improve performance so it should only be replaced when equipped on the mainhand slot and run it in a function file every tick but I don't know the syntax nor the item data for all the saplings
It should only replace that specific item and only when equipped on the mainhand
Try something like this:
[main.mcfunction]
execute as @a[hasitem={item=minecraft:stick}] run function replace_stick
[replace_stick.mcfunction]
replaceitem entity @s[hasitem={item=stick,location=slot.inventory,slot=0}] slot.inventory 0 apple
replaceitem entity @s[hasitem={item=stick,location=slot.inventory,slot=1}] slot.inventory 1 apple
This would only work with non-stackable items though, I would recommend using scripting instead of commands.
Clear would work better i think but depends on your use case
I'll give it a try
Yeah, probably. It depends how much the slot that its placed in matters. But clear would be more accurate. You could also use a binary based system to speed it up
Would this replace the corresponding item in the inventory? How about the item count>
Yes but doesnt work with stacks
How about the item data though? Saplings to be exact
wdym?
I meant this, how do I put the item with only with that item data with another item
I managed to make it work using this
I ran this on the tick.json
execute as @a[hasitem={item=minecraft:emerald, location=slot.weapon.mainhand}] run function replace_item
and then run this everytime that command returns true:
replaceitem entity @a slot.weapon.mainhand 0 destroy diamond 1 0
Huh whats destroy
It removes the item that is to be replaced from the inventory
I don't know about scripting yet, but I discovered a workaround, I just basically had to make this and run this on every tick:
what about stacks though
oh wait nvm
whats this for?
Replacing an item with another item base on count
i mean like as a whole since i feel like theres a better solution
Oh, I want to replace the oak sapling item with a custom oak sapling item since the sapling block is hardcoded and the tree that grows from the original block doesn't have leaves because I have modified the feature file for it for my apocalyptic landscape. I also can't make a custom oak tree feature because /placefeature doesn't work and I want that custom feature to grow with my custom oak sapling block
So when a player finds an oak sapling item, it will be replaced with the custom oak tree item the moment they equip it on their main hand
But I ran into a problem, it replaces every sapling even though I only want the oak tree sapling item to be replaced using the data argument using this
I think this is the more efficient way rather than using server animation and animation controllers
Oh i see. Im not sure on the id thing but you could try replacing the tree leaves with a custom one
Yeah but they won't decay