Difference between revisions of "Trash Item Removal Tutorial"
From Zedwiki
m (Dax23333 moved page Trash item removal to Trash Item Removal Tutorial) |
|||
Line 34: | Line 34: | ||
#Chain: /scoreboard players tag @e[type=item] add Trash {Item:{id:"minecraft:bone"}} | #Chain: /scoreboard players tag @e[type=item] add Trash {Item:{id:"minecraft:bone"}} | ||
#Chain /kill @e[type=item,tag=Trash] | #Chain /kill @e[type=item,tag=Trash] | ||
+ | |||
+ | [[Category:Tutorial]] |
Revision as of 16:58, 14 July 2017
This tutorial covers a system to remove specific items from the world, as used in the ZestyGames Crypt Wars and Dungeon Dash
Often it will be wanted to have only some items removed from the world. For example a skeleton dropping arrows might be wanted, as they provide arrows but bones are not useful and simply clutter player inventories. In another situation, in Crypt Wars killing an enemy player drops thier gear so the victor can take it. However default equipment is not wanted and needs to be removed to prevent clutter.
Contents
Commands
This tutorial involves two commands.
- scoreboard
- kill
The Tutorial
To remove items we can use the /kill command. This will instantly remove the targeted item (or other) entity, however item type cannot be targeted using selectors. In order to get around this we have to use tags.
/scoreboard players tag @e[type=item] add Trash {Item:{id:"minecraft:rotten_flesh"}}
This command adds the Trash tag to rotten flesh item entities. It uses the capability of the scoreboard command to check the nbt data of an entity. The nbt data of an item entity determines what kind of item it is, and we can use this to identify it. The selector @e[type=item] specifies that we want to target item entities only. The data tag {Item:{id:"minecraft:rotten_flesh"}} specifies the type of item to be tagged, in this case rotten flesh.
More items can be tagged by adding extra command blocks checking for different items. Here we add bones, chain helmets and blaze rods to the items to be removed.
/scoreboard players tag @e[type=item] add Trash {Item:{id:"minecraft:bone"}}
/scoreboard players tag @e[type=item] add Trash {Item:{id:"minecraft:chainmail_helmet"}}
/scoreboard players tag @e[type=item] add Trash {Item:{id:"minecraft:blaze_rod"}}
/kill @e[type=item,tag=Trash]
Once the item is tagged the /kill commands selector can target them so they can be removed. Checking the entity is an item prevents accidents if a player gets the Trash tag, as they would be constantly killed in a difficult to escape loop.
Putting it together
We want to tag items, then remove them, and do so constantly. Therefore we use a repeating command block, and chain command blocks.
- Repeat: /scoreboard players tag @e[type=item] add Trash {Item:{id:"minecraft:bone"}}
- Chain: /scoreboard players tag @e[type=item] add Trash {Item:{id:"minecraft:chainmail_helmet"}}
- Chain: /scoreboard players tag @e[type=item] add Trash {Item:{id:"minecraft:blaze_rod"}}
- Chain: /scoreboard players tag @e[type=item] add Trash {Item:{id:"minecraft:bone"}}
- Chain /kill @e[type=item,tag=Trash]