CustomThings

CustomThings

4M Downloads

Suggestion: Command Items

Pinaz993 opened this issue ยท 2 comments

commented

As a future modded map maker, I would like to have items that would run a command when used (right clicked). However, I don't want to have to define a new itemstack for each command I want to run, especially if I want to run the same command with different parameters. The solution: NBT tagging.

Here is the scheme: when I use a JSON file to make a new item, maybe I would use a tag (or whatever you call the things) named 'command', that would tell the itemstack code to run a command on right click of that item. there would also be other tags to use, such as:

  • 'chargesUp' (like a bow)
  • 'oneUse' (decrements the stack size, so that each item can only be used once. Usually though, such items would not stack, so that you could not spam them and cause lag.)
  • and anything else that might be useful.

On an item instance of one of these items, there would be an NBT tag called "runsCommand" that would specify the command to be run when the item is used. I would also have other tags, like:

  • 'runAsPlayer' (runs the command as the player that is holding ther item)
  • 'pullTime' (this one is for the 'chargesUp' tag mentioned above, and would specify the time it takes to charge the item before it would work)
  • and again anything else that might be useful
    This way, I could have, say a "Beacon Flare" item that shoots off fireworks in a different color based on the item itself, instead of shooting off the same fireworks no matter what.

Why are command-executing items necessary? Well, if you are using command blocks, you either have to have the player do something that activates the command mechanism (which will now be referred to as a CM), such as the /trigger command, which is cumbersome and immersion breaking. If you don't, the CM has to scan for the success conditions constantly. Minecraft does not do so well with that many command clocks running at a time. (Who would have thought?) So, it would be best if you could eliminate the command blocks altogether and run the command when the items is used. Combining the two methods make many more things possible, such as:

  • Giving the player multiple status effects
  • Refilling all mana pools in the area
  • Causing an explosion that kills everything in the area except the player

All of this is possible while simultaniously reducing the amount of CMs that have to be continuously running. Plus, using these CMs, you can make them delete themselves when they are not needed anymore, thus freeing up system resources.

This item would be amazingly useful for not only my upcoming map, but to any other custom maps in the future.

commented

One thing you might want to watch out for, is that commands can only be so long if they are not being used in a command blocks. So, if you don't program with this in mind, a lot of players will be kicked from servers and crashing SP because they have an 'illegally long chat string' or something like that.

commented

If I executed the command directly I don't think this would be an issue. I'll keep it in consideration if I decide to do this, though.