tterrag1098 / CustomThings

Adding basic custom items to minecraft via JSON files
Mozilla Public License 2.0
18 stars 8 forks source link

Suggestion: Command Items #16

Open Pinaz993 opened 8 years ago

Pinaz993 commented 8 years ago

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:

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:

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:

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.

Pinaz993 commented 8 years ago

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.

tterrag1098 commented 8 years ago

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.