0

I wanted to make all torches (Crafted and found) have fire aspect using commands. I tried some different things but they didn't work out. Does anyone else have any ideas?

  • Your idea is good and I will "steal" it for my modpack. xD Because with it I exactly know how to do it, however it is not easily possible (maybe some workarounds) in vanilla MC. If you are interested in modded answer, just write me and will post it here. (It involves MineTweaker) – Antoine Hejlík Nov 18 '15 at 9:42
2

Default items have no data of which to detect in order to separate them from custom items. Unfortunately this greatly restricts methods of replacing default items since, for example, /clear would not be able to differentiate your custom torches with default ones.

One work-around is to detect each individual slot in the player's inventory and use /replaceitem, but that requires 64 command blocks for each of the 36 slots just for detection alone.

As a quick run-down:

  1. Find 1 torch in slot 0.

    /scoreboard players set @a TorchSlot0 1 {Inventory:[{id:"minecraft:torch",Count:1b,Slot:0b}]}
    
  2. Replace that torch with 1 custom torch.

    /replaceitem entity @a[score_TorchSlot0_min=1,score_TorchSlot0=1] slot.container.0 minecraft:torch 1 0 {ench:[{id:20s,lvl:1s}]}
    

Which would need to be repeated for every number of torches possible in every slot possible.


If using 1.9, you can customize the loot tables so that the torches that are at least found in chests will have the desired enchantment.

For example, the chests/abandoned_mineshaft.json loot table has the following entry:

{
    "type": "item",
    "name": "minecraft:torch",
    "functions": [
        {
            "function": "set_count",
            "count": {
                "min": 1,
                "max": 16
            }
        }
    ],
    "weight": 15
}

If you want it to be enchanted with fire aspect, you'd add the enchant_randomly function while only specifying minecraft:fire_aspect:

{
    "type": "item",
    "name": "minecraft:torch",
    "functions": [
        {
            "function": "set_count",
            "count": {
                "min": 1,
                "max": 16
            }
        },
        {
            "function": "enchant_randomly",
            "enchantments":[
                "minecraft:fire_aspect"
            ]
        }
    ],
    "weight": 15
}
  • You are aware that clear takes a data tag, right? You can easily count the total as well as the custom torches, and the difference gives you the default number of torches. Mind you, this doesn't do you much good since you can't clear just the default ones, unless you also set another tag to a non-default value for the custom torches. – MBraedley Nov 17 '15 at 1:42
  • @MBraedley /clear takes dataTags, but you cannot cause it to remove non-custom items because they don't have any extra NBT data to detect. You'd just as well be clearing the custom items provided since you cannot use a NOT operator within dataTags. Counting custom and default items is easy, the replacement part (as OP requested) is just not feasible due to that limitation, which is why I stated /clear is not helpful for the end result. – Skylinerw Nov 17 '15 at 2:43
  • "unless you also set another tag to a non-default value for the custom torches" Change the damage value and then check for the default (0). I don't know for sure if that'll work, and currently have no way to test it, but I have a feeling it'll do exactly what's desired. Stick a stats command on it to say how many torches were cleared. Then it's just a matter of giving that many torches back, which admittedly isn't easy, but is certainly doable. – MBraedley Nov 17 '15 at 22:11
  • @MBraedley Unfortunately any invalid Damage values will be given the "not found" texture (black & purple boxes), which is the case with torches. I'm not sure if that can be remedied with resource packs; at the time the invalid textures were implemented for invalid Damage values, it wasn't possible to use resource packs to fix that. I haven't kept up with resource packs, though. – Skylinerw Nov 17 '15 at 23:31
1

Are you currently playing Minecraft without mods, or with mods? Without mods, you are unable to add an enchant to items such as torches, even with commands or command blocks. There are ways however, to use command blocks to set your target that you hit with a torch on fire but it involves some more complicated programming.

An easier method of setting mobs on fire when you hit them with a torch is to download a mod. One example of a mod that works for you is this one: http://dev.bukkit.org/bukkit-plugins/fire_aspect-torches/

  • 1
    It should be clarified that enchantments can be applied to any item in the game (for example, fire aspect will work just fine on a torch: /give @p torch 1 0 {ench:[{id:20s,lvl:1s}]}). – Skylinerw Nov 16 '15 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.