I realized that when you use a lot of command blocks, it could be a bit time-consuming to do all these coordinates and numbers everywhere so I thought maybe I could introduce variables into Minecraft. Here is how it works.
/variable <add | list | set> //Root command for variable
/variable add <name> <type> [value] [preferences...] //Adds a variable into Minecraft. The types are number, word, coordinate, field, item, entity, and block
/variable list //Lists all the variables, their value, and their type
/variable set <variable> <value> //Sets a value to a variable
To get a variable's value, do this
Here are the explanations of each type of variable
number - A number. Could be used to store an X Position of an entity or the cost of an item at a shop.
word - Stores a word or letter. Could be used for predefined messages a command block would say repeatedly.
coordinate - Stores a coordinate. Could be used for easier teleportation methods.
field - Stores a field between 2 coordinates. Could be used for easier /fill methods. To set in a variable command, use 2 coordinates or 6 numbers (which basically represents 2 coordinates)
item - Stores the name of an item.
entity - Stores a specific entity or a generic one
block - Stores the name of a block
Here are some methods you could use to set variables
/variable add creeperX num @e[type=Creeper,c=1].getX
/variable add nearName word @p.name
Here's the list of all these methods
((1 + 5) * 24) //number
@e.scoreboardValue.(scoreboard name) //word
You could also add a certain list of preferences to these commands
final - Sets this variable to be unchanging
Here are examples of how you could use these
Method 1 - get distance between you and the block you are looking at
/variable add distanceNum num @p.getCoordinate - @p.getViewCoordinate //gets the distance between where you are and the coordinate of where you are looking at. Notice how you could subtract two coordinates to get a distance
/say @v[distanceNum] //says the distance
Method 2 - Stealing a persons armor when you are 1 block away from someone
/variable add distance num //adds a variable called distance
/variable add thief entitiy @p.getSpecificEntity //gets the nearest player and makes them a thief
/variable set distance thief.getCoordinate - @p[[email protected][thief]].getCoordinate //sets the distance variable to the distance between the thief and the nearest player who is not a thief
/testfor @v[distance]<1 //tests if distance is less than 1. You are allowed to do <, >, =,<=,>=, and != to test number variables
/variable add victim entity @p[[email protected][thief]] //adds the victim as the nearest player who isn't the thief
/replaceitem entity @e[@v[thief]] slot.armor.head @e[@v[victim]].slot.armor.head //replaces the helmet
/replaceitem entity @e[@v[thief]] slot.armor.chest @e[@v[victim]].slot.armor.chest //replaces the chestplate
/replaceitem entity @e[@v[thief]] slot.armor.legs @e[@v[victim]].slot.armor.legs //replaces the leggings
/replaceitem entity @e[@v[thief]] slot.armor.feet @e[@v[victim]].slot.armor.feet //replaces the boots
/clear @e[@v[victim]] @e[@v[victim]].slot.armor.head //deletes the victims helmet
/clear @e[@v[victim]] @e[@v[victim]].slot.armor.chest //deletes the victims chestplate
/clear @e[@v[victim]] @e[@v[victim]].slot.armor.legs //deletes the victims leggings
/clear @e[@v[victim]] @e[@v[victim]].slot.armor.feet //deletes the victims boots
Would variables be global (could be used by any command block)? If so, there could be an issue with accidentally using an existing
Also, I would like to suggest a few methods which would be useful:
@e.nameUUID - This gets a players name, but as that player's UUID rather than the in game name. //word
@e.getMobType - if given a mob's UUID, it will tell you the ID of that mob. //word
@e.getnbt.[nbt tag] - This would get the value of a specified NBT tag. //varies
Note that almost anything is possible if you can look at an entity's NBT tags. You could check health, the equipped item, what's in it's inventory, if it is hostile, if a creeper if charged or if a dog is tamed.
I would love to see editing the NBT values of existing mobs, but that is an idea for a different topic (i'm sure they're out there). I don't want to see this become a wishlist.
Support, there's no reason not to add this. For a puzzle/adventure mapmaker, this could be handy!
Rollback Post to RevisionRollBack
My Avatar is a Dalek, therefor your argument is... EXTERMINATED!!!
You know who can tell me something I already know? Me. All the time. I'm really good at telling me stuff I already know. I don't need help in that department. I don't know about others, but I can't imagine I'm alone here.