- 14
- 16
- 3
94
This tutorial will be updated over time with more command tutorials, tips and tricks, examples and more!
So make sure to subscribe to get notified about future updates!
In this blog I will share everything I learned about minecraft commands and datapacks from the past couple of years that I've been posting on this page. I will begin with basic minecraft commands first and then move along to more complicated commands and then how a datapack is better than pure command blocks. I will also mostly mention how you can use these for minigames as it is what I mostly create.
Day 1
Today I will focus on small simple commands that are very useful while also showing some other basic commands that are not so useful.
/clear
Really simple use and syntax, this command is used to remove items from the player's inventory, while also tracking how many items it removed.
Syntax: /clear <user> <item> <amount of items>
By just typing /clear on a user it will remove their whole inventory. If you specify the item it will only remove that item and by specifying the amount it will only remove that amount
Example:
/clear : removes all items from the inventory of the person who ran the command
/clear geosivridis : removes all items from the inventory of player geosivridis
/clear geosivridis iron_ingot : removes every iron ingot from the inventory of player geosivridis
/clear geosivridis diamond 3 : removes only 3 diamonds from the inventory of player geosivridis
Tip: you do not have to specify one specific player, you may use @a and target all players online.
I mentioned you can use this to track how many items you removed from the player, but I will show how to when we get to /execute store.
/effect
This command is used to clear and add effects on a player or entity.
Syntax: /effect clear <user> <effect> OR /effect give <user> <effect> <time in seconds> <amplifier> <hide particles>
hide particles is optional with it being false by default
Examples: /effect clear : clears all effects of the person who ran the command
/effect clear geosivridis : clears all effects of the player geosivridis
/effect clear geosivridis speed : only clears the speed effect from the player geosivridis
/effect give geosivridis speed 10 1 : gives speed 1 for 10 seconds to the player
/effect give geosivridis regeneration infinite 3 true : gives regeneration 3 forever to the player while also hiding particles
Same here too, you can target multiple players and entities
Which brings me to the next thing that is somewhat related
Target selectors (part 1)
Very important, they are not exactly commands but any command that targets an entity or player uses target selectors. They include:
@a : All players
@p : Nearest player
@r : Random player
@n : Nearest alive entity
@s : Current entity
@e : All entities
Target selectors also include extra arguments that make them target more specific entities or players, this is why this is split into multiple parts. You can add them by adding square brackets [] after the selector
Some arguments include distance=, type=, scores=, tag= and more but for now we only focus on type=.
type= is only used in @e, it targets specific entities
So for example: /kill is a command that kills entities
If you type /kill @e : it will be chaos because it will kill every single entity and player
But if you type /kill @e[type=chicken] : it will only kill every chicken
You can also use type= and other argument to NOT target something by including a ! in the beginning
So if we had /kill @e[type=!chicken] : this would now kill every entity EXCEPT chickens
You can use type=! multiple times to exclude different mobs, but you can not use type= multiple times, if you have one type= you can not add another type= or type=!
/enchant
Now this is NOT useful since it is way to limited. You can understand that this command enchants your item but it is limited to what you can do in survival, and also fails if you hold the wrong item so I do not recommend it.
Syntax: /enchant <user> <enchantment> <level>
Example: /enchant geosivridis sharpness 5 : enchants your sword with sharpness 5, you can not go over 5 in sharpness as it follows the normal enchantments
If you are lazy and want to enchant your item in a creative world you can use this, but otherwise it is simply more efficient to /give the item instead
Day 2
What I think I'm going to do is one day I will show simple stuff and the next show something a little more complex, do a pattern like that
/execute (part 1, at, as, run, summon)
Easily the MOST USEFUL command ever. If you do anything complex just use execute it has way too many uses which is why it is also split into parts.
/execute run <command> : very simple, runs a command, on its own its not so special but the beauty of /execute is that you can use them all together
/execute as <user>: now this is simple, you simply run a command as an entity.
Example: /execute as @e[type=zombie] run say hi : this is how you combine different subcommands, so /say basically sends a chat message from a user, so since we has 'as zombie' then we will see '[zombie] hi'
/execute as targets MULTIPLE entities and runs the command for as many entities there are, so for the example if we had 10 zombies then the same message would be sent 10 times!
Pro tip: if you use /execute as and want to refer to the same target again, you can use @s, this can make a command with a long selector look shorter
/execute at <user>: also very simple, you run a command at an entity's location.
Example: /execute at @e[type=zombie] run summon sheep : this summons a sheep at a zombie's location
/execute at also targets MULTIPLE entities so if we ran the example, at every zombie location a sheep would be summoned
If you wanted to combine everything and use the pro tip you would have /execute as @e[type=zombie] at @s run summon sheep : it would do the same thing
/execute summon <entity>: I'm not gonna lie, I did not know this existed, its pretty new, and I do not see it useful at all
Example: /execute summon sheep run say hi : from the little testing I did, it summons and entity and also by default runs it as that entity, so the sheep you summoned would say hi. This could have a use but the cherry on top is that you can only summon default mobs, you can not add attributes, tags etc. like /summon
~ ~ ~ :
I don't know how they are called haha, the symbol is tilde and we use it for current coordinates based on x y z. There are also carets ^ which do something similar but I will mention them another time.
So instead of actual coordinates you can put ~ ~ ~ which is set to them by default, what you can also do is set them as a starting point and build from there, by adding a number next to them it changes, so ~1 ~ ~ would be 1 block next to them, and ~ ~ ~-0.5 would be half a block in another direction
So combining this with /execute at: /execute at @a run summon sheep ~ ~10 ~ : this spawns a sheep 10 blocks above every player
If you want to be more specific about where you want the coordinates to be, you can press F3 and check your crosshair, the blue red and green things, shows the positive directions of x y and z
Day 3
Back to basics
/give and /item:
/give is probably the first command someone learns but /item is underrated too! Why are they different? /give just gives an item, while /item gives an item in a specific player slot.
I saw that /item is getting more subcommands for 26.3 but I will skip it for now and maybe update it when it comes out, /item has replace and modify as subcommands, replace replaces an item in a container, and modify modifies it with an item modifier? I never used this, it uses datapacks
You can use /item to modify entity inventories, ender chests, and also chests and other storage blocks
With /item replace you can also copy items from other storages or entity inventories
Example: these should be simple /give @p diamonds 64 : /item replace entity @p weapon.mainhand with diamond 64 : these do the same thing except /give just drops the items on you, so if you have a full inventory you won't pick it up, and /item replaces your main hand no matter if you are holding an item
You can also target multiple entities with both /give and /item thank god
Pro tip: you can give items with different components and stuff like use cooldowns or custom names, and because syntax can get complicated with them I recommend using mcstacker.net as it saves a lot of time
/summon:
Also simple command, summons an entity at a location, the reason this is better than execute summon like I said before is that you can actually modify the entity with /summon
Example: /summon husk ~ ~ ~ {Health:50f,equipment:{feet:{id:"minecraft:iron_boots",count:1}},attributes:[{id:"minecraft:max_health",base:50}]} : I took this straight from mcstacker, this summons a husk wearing iron boots with 50 health and 50 max health
Yet again I recommend using mcstacker for this one again, one side note for both /give and /summon you should know is that attributes change health, damage and all the stats, you should experiment with what you can do in mcstacker and if you have any questions let me know
How about a lightning round to finish off the day:
/experience or /xp:
Adds and removes experience points from the player, you could use this as an actual experience bar in an RPG if you turn off any other way of getting experience, or you could use a bossbar (more of that when we get to /execute store)
Example: /xp add geosivrids 7 : adds 7 xp points /xp add geosivridis 7 levels : adds enough xp for 7 level ups. You can set the level to 0 to reset them and also use /xp query geosivridis levels : to see how many levels the player has
You can't directly remove xp, but you can set it any number instead of add
/tp or /teleport
Teleports entities to coordinates or to other entities
Example: /tp geosivridis 0 50 0 : this will send the player to those specific coordinates, you may use ~ ~ ~ too /tp geosivridis steve : teleports the player to the other player, geosivridis teleports to steve
You can teleport multiple entities but you can only one one entity as a teleport location
Which brings me to
Target selectors (part 2)
We have a few more arguments today, limit=, sort=, and xyz= and dxdydz=
Might as well put them together
limit= adds a limit to the targets selected, you can only add numbers
So if you want to use tp, you can use @e[limit=1], we will keep using this for commands that need to target only one entity
sort= goes hand in hand with limit=, it sorts the entities it selects, theres sort=nearest, furthest, random, and arbitrary which the last one is so useless not even the wiki knows how it works it just does not sort lmao
So to target only one pig next to you, you can do @e[limit=1,sort=nearest,type=pig], if we did not have type=, the closest entity would be yourself, or you could just exclude the player with type=!player
And another example if you have many different mobs you could use @e[sort=random,limit=2] to pick 2 random mobs
The last part are all together, its for selecting entities within a certain space, to start you choose coordinates with x= y= and z=, this is your starting point, the d in dx stands for delta so dx dy and dz say how big your space is
So if I want to target someone within a room you can type @a[x=5,y=50,z=10,dx=10,dy=5,dz=10], xyz are just coordinates dx dy dz is how much the box stretches, so in the example it goes 5 blocks up, 10 blocks right and 10 blocks foward. Make sure to use f3 again to get the correct direction of the delta
You can use xyz in a repeating command block or tick.mcfunction in datapacks to detect when someone enters a room and trigger an event
Combining all these, if you spawn 10 mobs inside a small box you can select a number of random mobs in there, this is a form of random mob generation, I used to use this in mob battles
Day 4
I think its time for one of my favourites
/scoreboard
Now listen, scoreboard sounds very goofy compared to actual numbers in programming but we gotta take what we can get. /scoreboard is a command that counts stuff, stores it in a namespace or entity, and you can do math with, I know scary but not really
The command has a bunch of subcommands and uses. To start we need to create a scoreboard objective
Example: /scoreboard objectives add <name> <criteria> <displayname> : name is obviously its name, criteria is interesting, the criteria shows what kind of objective it would be and there are 4 categories pretty much. 1. is dummy, which is just one criteria on its own, its job is to do nothing, it can only change when we change it. 2. is trigger, more of that later but its pretty much the closest thing we have to custom commands. 3. are objectives that track a stat that can go up, such as how much of a block you mined, your playtime, your death count etc. 4. is tracking stable stats like health and hunger, you cannot modify those. Display name is optional but you can put a json there and add colours and stuff, we always refer to the objective using the normal name.
You created the objective now it exists in the world, why is it useful? I will leave trigger at the end, but what you can do is check for who scored in an objective and then do something to them and then reset them.
To do this, we will use a new target selector, scores=, be careful cause it has different syntax, we type @e[scores={<name>=1}], now 1 can be actually a range of numbers using 2 dots .. so if we want just 1 type =1, if you want 1 and above type 1.., 1 or less we type ..1 and between 1 and 5 its 1..5
For scores= we cannot use scores=!
So using all this we can for example detect if a player dies! First create an objective /scoreboard objectives add death deathCount : we only have to do this once, and inside a command block that is on repeat always active (or a tick.mcfunction file in a datapack, these things basically run 20 times a second) /execute as @a[scores={death=1..}] run say i died, rest in peace :
How a tracking scoreboard works is it adds 1 to the counter of a player every time it meets its criteria, so a death count scoreboard goes up by 1 if a player dies
IMPORTANT: these scoreboards save their scores so the following command would spam the chat, after the command runs we need to make sure we set their death scoreboard to 0, we do that with /scoreboard players
/scoreboard players set @a[scores={death=1..}] death 0 : this basically targets every player with a score of 1 and above in deaths and sets their score back to 0. Make sure this command runs at the end to reset everything.
For scoreboards that track stable stats like health or hunger, you can not edit them, but you can still run a command depending on what their stats are
Finally let's cover trigger, trigger has its own command /trigger, you need to first give permission to people to type this command, after that if they type it their score goes up by one, or they can add or set it to as much as they want.
Example: we create a new scoreboard objective /scoreboard objectives add Heal trigger : its added, now we need to constantly allow people to use it using /scoreboard players enable @a Heal : Now they can use it. enable is only used for trigger scoreboard. Also remember that scoreboard objective names are very character specific, so heal would be different from Heal, their difference is a capital letter. So now we do the exact same thing, /execute as @a[scores={Heal=1..}] run effect give @a[scores={Heal=1..}] instant_health 1 100 true : and after that we need to reset it /scoreboard players set @a[scores={Heal=1..}] Heal 0 : This basically adds a command that when you type it it heals you.
All these commands need to be running every tick, and also in order, you can use chain commands blocks and a repeat command block to do so, or in a datapack put them in order in tick.mcfunction (or make it run a new function, but we will get there)
/scoreboard players also can add and remove scores, and can also do math with /scoreboard players operation : you basically get 2 player numbers and do math, you can add them together (+=) or multiply (*=) etc. It will always be saved on the first player.
Pro tip: if you are counting something that has nothing to do with the player, such as a 'round' number or time, you can save it on a random name. Make sure to use characters that cannot be use in a player's name in case a player with that name exists, for example I use ?t to save any number unrelated to the player
One last thing you can do is display different objectives, this is how we can use <displayname>. You just need to type it once and say /scoreboard objectives setdisplay <display> <objective> : there are multiple places you can set the objective on, it can be on the tab, in the sidebar (which also acts as a leaderboard) and under the player's name (you can use this for health counters).
This command can be combined with execute and tellraw, so that is what I'm going to mention next time.
Day 5
/tellraw
Very important command for map making, datapacks, everything. It simply sends a message in chat using something called a json.
Its different from /say cause /say shows who is broadcasting it and also uses colour, /say ignores jsons
Example: /tellraw <user> <json> : json has a lot of arguments you can use to type, you can do it like me where I learned some basic ones and use mcstacker for everything else, or just use mcstacker from the start its fine.
To start a json is always in between curly or square brackets { }, [ ], square brackets are for more arguments.
There are a bunch of arguments you can add, with the most basic being "text"
/tellraw @a {"text":"Hello"} : this is a hello message without colour. If we wanted colour then we add the "color" argument next to it /tellraw @a {"text":"Hello", "color":"red"} : from there you can also add if you want a bold or italic font and a couple others, you simply add , "bold":true
true and false are boolean so they usually don't need to be within quotes
I recommend using mcstacker if you are not sure what you are doing, the other useful stuff you can add to a tellraw are selectors, meaning a player name, score from a scoreboard, and a few more that I don't use much. You can also make interactable chat but I will show that another time.
/title
This is another place we can use json for text.
Simply type /title <user> title <json> and it will display, you can display it in the subtitle and the action bar too. Quick side note, these are a little different as there's also a time argument, you specify how long they stay on the screen you type /title <user> times <fade in> <stay> <fade out> : these arguments need numbers, you specify how long it takes for each part keep in mind the default value are ticks (1/20th of a second) you can add s at the end for seconds and d for days
/execute (part 2 if, unless)
Back to the best command with the best argument, if and unless, obviously opposites. These are conditionals meaning the command will run only if or unless the test passes, and they have a lot of arguments. You can also check how many times the test passes and store that too.
/execute if biome
I never used this... Checks a block if its in a specific biome, or apparently with structures? I actually don't exactly know /execute if biome ~ ~ ~ minecraft:basault_deltas run say hi : so it will only run if the block is in that specific biome, if it was unless it would run unless it was in that specific biome
/execute if block
This is more useful, checks what a block is /execute if block ~ ~ ~ pink_wool run say pink! : I used this for my battle box map to check what colour the blocks were
/execute if blocks
Its not what it looks like, I got confused too. From what I understand it compares 2 boxes in the world and sees how many blocks are the same? I did some testing and I have no clue. The condition was true whenever the two areas were similar /execute if blocks <pos1> <pos2> <pos3> all run say blocks! : the first 2 positions make a box and the last one marks a box of the same size somewhere else, you can put all it includes air blocks, masked doesn't
/execute if data
We haven't mentioned data too much, every entity and a few blocks have different data that can be modified, this one however just checks if that entity or block with that data exists, more of that when we get to /data
/execute if data entity geosivridis SelectedItem run say hi : this says hi if a player is holding an item
/execute if dimension
Pretty self explanatory, checks the dimension of where the command is run, doesn't check specific block /execute if dimension overworld run say overworld!
/execute if entity
My favourite of all, this checks if an entity exists /execute if entity @e[type=pig] run say pig! : if there's at least one pig it will run, we can also use this to target more specific entities
/execute if function
This is datapack related and lowkey don't understand it so we skip it
/execute if items
Now this is good, pretty new just like /items, it checks for items on specific slots of entities and chests and stuff
/execute if items entity geosivridis armor.head iron_helmet run say Helmet! : runs if the player is wearing an iron helmet
In /item and /execute if items you can use * which means all items, so instead of iron helmet if we had * the command would run if the player had any item on their head
/execute if loaded
Never seen this either, checks if a block is loaded /execute if loaded ~ ~ ~ run say loaded : if we did the same thing for ~ ~ ~10000 which is 10.000 blocks away it wouldn't run
/execute if predicate
This is really good but you need datapacks to use it, we need to add some big json files. Predicates are basically true or false conditions that run very well, you can check for example if player is standing on a block, more of that later.
/execute if score
We are so back, score means scoreboards of course and this can compare 2 players scores or just check if a score is within a range of numbers
/execute if score geosivridis <objective1> > geosivridis <objective2> run say 1 is bigger! : you take a name and an objective, and it compares them using < > <= >= and =, to check for one score we use matches /execute if score geosivrids <objective> matches 1.. run say bigger than 1! : we use the same number range I mentioned before in scores=
Note we can only compare one name's score, so we cannot put @a or @e without limit=1
Apparently there also /execute if stopwatch, but its not written in the wiki and I have no clue what it is
Day 6
Lets do some quality of life
/setblock and /fill
Simple commands, they modify blocks in the world, one only modifies one and the other can do a box of blocks, but has a limit of about 32 thousand which I think its a 16 bit limit.
/setblock ~ ~ ~ <block> [setting] /fill <pos1> <pos2> <block> [setting] : the settings can be pretty useful. First for setblock we have destroy which replaces the block and breaks and drops the previous one, next is keep which only changes air blocks, the default is replace which just replaces it and nothing else, and last is strict which replaces the block without block updates, this means that stuff like falling sand floating won't fall and so on. For fill we have destroy which does the same as it replaces all blocks, hollow which only fills the outside layer and the inside is untouched, keep replaces only air blocks, outline is like hollow but it doesn't drop any items, replace is the default and just replace BUT you can add a specific block you want to only be replaced, and strict again which doesn't cause block updates
/clone
Somewhat similar to fill, you select an area and you can copy paste it
/clone <pos1> <pos2> <pos3> [setting] : this is a little weirder, pos3 is the destination and acts like the first corner selected, apparently you can also set this to clone blocks from one dimension to another. The settings include replace which is the default, masked which is like replace but doesn't replace blocks with air, again strict with no block update, and the a different setting has normal which is default, force does the clone even if something overlaps, and move which replaces the previous region with air
/execute part 3 (align, anchored, facing, in, on, positioned, rotated)
/execute align, honestly learn its use 3 minutes ago... it literally aligns your coordinates to the closest smaller whole number, what this means, if I am located at 9.3 56 103.8 and I type /execute align xyz run spawnpoint @p ~ ~ ~ : /spawnpoint sets the player's spawnpoint, the coordinates will act as 9 56 103. You can modify one or two axis at a time so you can have just x or just yz, but you cannot repeat them
/execute anchored is also simple, it changes between eyes and feet, basically where its executing from Simply /execute anchored eyes run ...
/execute facing goes hand in hand with anchored, it changes the executors rotation you can make it face a block /execute facing ~ ~ ~ : or an entity's eyes or feet /execute facing entity @p feet : I personally haven't used these but I think they are pretty useful for some more complex stuff
/execute in changes the executors dimension /execute in the_nether
/execute on targets entities who are riders or riding mobs or even leashing other mobs or owners of tameable animals /execute on <relation> : we have attacker which is last entity who damage the executor the last 5 seconds, controller the entity rider that is in control, leasher the entity who has a leash on another, origin is the person who summoned another entity like an arrow or tnt, passengers the riders who are not in control, target is the target that the executor wants to attack (apparently this works differently with interaction entities), and vehicle which is the entity ridden
/execute positioned changed the execution's position, it can be coordinates or from an entity, or a specific heightmap too I guess? /execute positioned ~ ~ ~ /execute positioned as <user> : Why is it different from execute at, I don't know, but it does extra stuff
/execute rotated does the same as positioned for rotation, without a heightmap /execute rotated ~ ~ : /execute rotated as <user> : rotation has yaw and pitch, yaw being which direction you look, and pitch being how you look up and down
Day 7
/execute part 4 (store)
Store is a very important subcommand, you use it to store different things you find and also multiply them, you can store a result or a success, what does success mean? If the command you run is successful, it stores 1 and if it does not it stores 0.
/execute store result <destination> : we have different places to store data. We have block I don't really use this, bossbar, entity, score, and storage. Block, entity and storage are also common to the /data command, its where we can get data from.
We can do a lot of things with these 2 commands, but first lets start on /data
/data part 1 (get)
/data is only complicated because there is so much data stored in one place. /data get is a way to get data and for the player to see, but we can also store this data
I will create a scoreboard called y_level, its a dummy scoreboard /scoreboard objectives add y_level dummy : This scoreboard will track the player's y level, meaning their height in the world.
/data get and /data in general can only target one thing at a time, it can be a block like a sign, an entity, or storage. Storage is unrelated to chest, its like data that exists in the world just floating in the void. We can bypass this one at a time limitation by using /execute as
In a repeating command block we can have /execute as @a store result score @s y_level run data get entity @s Pos[1] : Now if we display the scoreboard we will see the player's y level
You can store score in multiple users without execute as. At the end of /data get, if you are trying to get a number, you can multiply it at the end before you store it, this is useful because scoreboards only store whole numbers, so if you want to see half blocks you will have to add 10 to the scale and so on
Pos[] is the data that has the position of an entity, pos[0] is the x number, 1 is y and 2 is z.
/bossbar
Now we can actually use the bossbar command
To begin its like /scoreboard we create a bossbar /bossbar add <id> <name> : id is how we refer to it, while name is what shows on the bossbar. We can change different settings with it such as colour, using /bossbar set <id> <setting> : color changes its colour, max changes how much it can hold (default is 100), players sets who can see the bossbar, and we can change its name, style, value, and visibility. So we set up the bossbar, now we need to make it store something, it can be used for timers and stuff, but its a bossbar, we gotta use it for a boss. So we will use it to store the health of an entity. Have at a repeating command block /execute store result bossbar <id> value run data get entity <boss> Health : Make sure the max of the bossbar is set to as much max health the entity has.
Pro tip: in a repeating command block we should make sure to make the bossbar not visible once the entity is killed
Finally I want to show an example of store success. /spreadplayers is a weird command that can teleport players and spread players, but the good part about it is that we can use it to teleport someone to the surface. This command however has a change to fail, if there is a dangerous block like lava, I use this for the random teleport I made. /execute store success score <user> <success_scoreboard> run spreadplayers <position only x and z> <spread distance> <max range> <respect teams> <user> : It sounds weird but not really, since we want to use this to just teleport one entity, we can set everything to a minimum so 0 distance, 1 range and false respect teams. We can also set the max height we want. The point is, that now we have that scoreboard to check if the command failed or passed, so if it passed its 1 and if it failed its 0
Day 8
Command blocks
Command blocks have a few settings that some people don't understand that are very useful, but datapacks are just better. Keep in mind that when running a command from a command block or a function in a datapack it is not run by a player or entity, so something like @s will do nothing, unless we use /execute as
Block types
There are 3 types of command blocks, there is impulse (orange) for one time use every time its activated (usually by redstone), chain (green) which do the same but connect to other command blocks using their point direction, and repeat (purple) which run every tick (20 times a second) when activated
Needs redstone and always active
Pretty self explanatory, having a command is useful for repeat and conditional command blocks, impulse just runs once
Conditional and unconditional
This is useful for a chain of command blocks, the way a chain command block works is if a command is activated it will pass a signal and run command of the next block in line, all in the same tick but in order, but if we have a conditional command in there, to continue the chain the current command must pass, if it fails it stops the chain
Datapacks, how files work
I won't yet mention how to create a datapack but first we gotta understand how they run commands
Datapacks have their own type of files ending in .mcfunction , in these functions you can write any command you want and they would run like a chain of command blocks, all run in order and in the same tick. Note that if only one command isn't correct, the whole function cannot be run.
There are 2 special mcfunction files that are important. tick.mcfunction and load.mcfunction, they don't really have to be called that way but its fine, these are functions but different. tick run itself every tick, while load runs every time the world is loaded or if we manually type /reload
There is also a command for functions called /function, we use this to run a function and we can also run it with linking it with data which we can use for macros, but that's for future me to explain
Why are datapacks better than command blocks someone might ask. They are better in pretty much every way. If something goes wrong and the player gets softlocked, you can undo something from a datapack while if it was in a command you couldn't. Datapacks are way smaller files, and I'm not 100% sure about this but I think I've noticed the minecraft maps I made to have a smaller file size when I started using datapacks. And also most importantly with datapacks you have more power, you can use predicates, custom advancements, add custom recipes and even remove old ones. I'm currently still learning about those 3, because no one actually explains how the misode generator works bro, but I'll make sure to mention them sometime
Day 9
/attribute
Really fun command, this changes attributes of entities, being part of the new components system. Any time in /summon we want to summon a mob with for example custom health we add an attribute
/attribute <target> <attribute> get <scale> : this gives you the number an entity has in an attribute, if it was health a player would have 20, scale is optional and what it does is it multiplies the number we get to do m a t h. Keep in mind we can only target one entity with this command but it can still be bypassed with /execute as. If we typed 'base get' it would do the same idk why it exists. To change an attribute we type 'base set <number>' and this is where the fun begins. Some fun attributes to change are air drag (the force that slowly stops you from flying infinitely), scale (turn huge or tiny), block interaction range, bounciness, fall damage and a lot more.
/playsound
Now in my opinion this is very important for datapacks and maps. It adds life to your creation and gives feedback to the player.
/playsound <sound> | <source> <targets> <position> <volume> <pitch> <minvolume> : anything past the | is optional, sound is basically every sound that exists in game, I will recommend a few I use later, source is what type of sound it is, I don't think it makes too much of a difference but for pure sound I use 'master', targets is who hears this sound, position is where the sound is, volume is volume default is 1, pitch is how high it sound default is 1 and must be between 0.0 and 2.0, and min volume I never used but its something about people who are away from the sound.
Whenever you want a player to hear the sound effect but don't want it to be on a specific block you can use /execute at.
Some sound effects I use are: block.fire.extinguish, entity.experience_orb.pickup, entity.iron_golem.repair, entity.enderman.teleport, entity.player.levelup, I'm sure there are countless more good ones so try experimenting
/tag
Very important but simple command, this adds an invisible tag to an entity so that way we can target a very specific entity using target selectors
/tag <target> add <tag> : this tag can be any word you want, we can also remove tags with 'remove' and also list them
Keep in mind you can tag multiple entities and also add as many tags as you want. I also use /tag list to debug something and check if it works properly.
To target an entity with specific tags we use tag=, so for example @a[tag=test]
We can use tag=! to target players without a tag, and we can add as many tag= and tag=! as we want to target an entity.
/team
Similar to tag we have /team, this is very different though.
We first add a new team /team add <team> <displayname> : displayname is optional, we can use 'join' and 'leave' to add players and entities to a team, there's also 'empty' to empty an intire team. After that we can 'modify' a team, we can modify friendly fire, color (this also changes the player's name color), prefix and suffix and a couple more.
For the testing I have done /team is good for team pvp minigames, I also tested friendly fire with monsters and it turns out they can still attack each other but won't get angry at each other.
There is also a target selector for people in teams, using team=, team=! also exists but note that an entity can only be in 1 team
Timer
Using scoreboards we can make timed events. If we have a scoreboard called timer we can put it on a repeating command block or tick.mcfunction to add 1 to a selector. Note that I suggest you do the timer in a random name with a special character. The number we have on a scoreboard will be in ticks so we will have to multiply our time by 20, and it will be the number we want the scoreboard to reach, so if I wanted something to happen in 30 seconds, the scoreboard has to reach a score of 600. Once it reaches that number we can run some commands, and we want to make sure we disable the timer if we don't want to use it again. You can do the same by doing the opposite, you can start at 600 score and remove 1 until you reach 0.
Since we are talking about time a good way to make sure a timer doesn't mess with anything after you disabled it is by setting it to -1, we don't want to use negative numbers for timers as time isn't negative.
Day 10
How to make a datapack
The time has come, you are ready... probably.
Step 1: VS Code
Now in theory, you can just code using notepad, but who wants to do that to themselves? The program I recommend for datapack coding, which is also good for other languages, is Visual Studio Code. I recommend you download and setup that, and also download an extension called 'datapack helper plus by spyglass', choose the most downloaded option. The extension button is on the far left with the icon of 4 squares
Step 2: Find your world folder
The easiest way to find your world folder is by going to minecraft before you enter your world, clicking on 'edit' and then selecting 'open world folder' and it will open the folder. Now that its open we gotta go to the folder 'datapacks' which is also where you can add new datapacks. You can do this part using VS Code or just manually with file explorer, you just have to copy paste some stuff using notepad and create files
Step 3: Folders and pack.mcmeta
Now this is where we begin, inside the datapacks folder create a new folder, you can name it whatever you want in won't matter, now lets go inside, in there we create another folder called 'data' and a new file called 'pack.mcmeta'. Now pack is basically telling the game the datapack version its in, this is why some datapacks are not compatible with different versions. Open pack and then copy paste a pack format from the minecraft wiki, I recommend using pack format 88, as its very recent and covers versions from about 1.21.9 to 26.2
Keep in mind when I tell you to create a folder its usually character sensitive, meaning the datapack won't if you capitalize the D in 'data', it has to be the exact same way as I have it here
Step 4: Main file and minecraft folder
Now lets head inside our data folder, in there we will create a folder called 'minecraft' and one more folder where you can name it whatever you want. Make sure you remember the name you give, whenever we refer to functions or other files we have to mention the folder its in, I'll call mine 'test'. Now lets head inside our minecraft folder, in there we will create a folder called 'tags', inside tags we will create another folder called 'function', and inside function we will create 2 new files, 'tick.json' and 'load.json'. You will copy paste what I have from the imgur images inside those files, but where ever you see the word 'code' you have to add the name of that folder I told you to remember, so I will put "test:tick" and "test:load".
Step 5: Functions and beginning
Were almost there, lets go back to our special named folder and inside it we will create a new folder called 'function', in this folder we can also make folders for predicates and advancements and stuff but we won't just yet. Inside functions we can create our 2 special function files, 'tick.mcfunction' and 'load.mcfunction'. And that should be it, you can test the files if they work, you can put a command in tick and it will run 20 times a second, and load will run every time you /reload or reboot a world. You can also create new files ending with .mcfunction, just make sure they don't have any capital letters in their names or weird characters, underscore _ is fine.
/function
Now I gotta explain how this command works, this runs a function we have inside our function folder. To run one of our functions type /function test:name : remember our special folder name, we gotta use it again to refer to functions like I said. Again remember that mcfunctions must not have any syntax errors or they will not run any command inside them.
And that's it, you can now make function datapacks
Pro tip: whenever creating new things with commands like a new scoreboard objective or a new team, you know the commands that you have to type one time and they exist, write them in your load function. This makes sure to add them into a new world if you get a datapack in a different world, and also makes sure VS Code knows what objectives you are talking about.
Remember, commands in chat need / to begin, commands in datapacks don't work with / but command blocks work with both
Day 11
/data part 2 (modify, merge, remove)
Here we are, the data command at its full glory. /data is a very complicated command, just from how many target paths and nbt data exists, I mean you saw what /data get showed. There are 3 types of places where data can be stored I don't remember if I mentioned them. We have entities, blocks (like chests or signs) and storage. Storage is not chest related, storage is saved somewhere in the world and we can save different things. I personally prefer to use /data modify, as merge is about the same but limited, and I don't exactly know why remove exists.
One cool example we can do for modifying entity data is Motion, this can send an entity flying. /data modify entity <target> Motion set value [0d,1d,0d] : Motion is a number that contains 3 doubles, which are like floats but better, just decimal numbers. Each number represents XYZ, so the 1d I only have sends the target flying up.
Remember you can't modify multiple entities without /execute as, and also unfortunately we cannot use /data to modify or merge any data of the player's.
Data types
I think its about time I explained programming basics, its not that complicated don't worry. In minecraft and in a computer in general, information is saved in variables of different categories. These categories in minecraft include strings: which are words, any character even numbers are included ("hello world"), integers: whole numbers including negatives(10, -4382), floats: like integers but with decimals (3.14, -10.0), doubles: larger floats (3.9087063), booleans: just true or false, in game written like 1b, and also arrays: lists of different info that you can add stuff and remove stuff from.
Whenever the game refers to a datatype they usually have a letter after the products, 20f, 10.4d, 1b etc
Now a very important thing you can do with data modify, is modify data, using other saved data. /data modify entity <target> <targetpath> set from entity <target> <targetpath> : this is actually so useful, let me make an example I used recently.
TNT Bow
We will make a custom bow that will show TNT instead of arrows. How this will work is 1. we will detect arrows that come from a specific bow, 2. we will summon a tnt block in its place, 3. we will copy the Motion data from the arrow to the tnt, 4. we kill the previous arrow
To start lets create a bow using mcstacker: /give @p bow[custom_data={tnt_bow:1b}] 1 : you can add stuff like use cooldowns, custom names and stuff but what makes it special is the custom data, we added a boolean tag to it
next I will prefer we use a datapack for this, because a command block has to be loaded all the time to run all this, so in our tick.mcfunction file we put: execute as @e[type=arrow] at @s if data entity @s weapon.components."minecraft:custom_data".tnt_bow run function code:tnt_bow : so this checks if an arrow has that data and if it does it runs a function called 'tnt_bow'
If we run a function with /execute as or at or any execute modifying command, it will use it as a default so we can use @s in that function again.
So after that in that function we can just type: summon tnt ~ ~ ~ {fuse:60,explosion_power:5,Tags:["tnt_bow"]} : use mcstacker for this too to modify fuse, explosion power, but most importantly have the tnt have a tag on it. So after that we will modify its data : data modify entity @e[tag=tnt_bow,limit=1] Motion set from entity @s Motion : now one extra step we need to add is to remove the tag from the tnt : tag @e[tag=tnt_bow] remove tnt_bow : we need this so we don't accidentally target the same tnt again. And finally kill @e[type=arrow,nbt={weapon:{components:{"minecraft:custom_data":{tnt_bow:1b}}}}] : And that's it, that bow can shoot tnt now and only that bow. In the future when we learn how to add custom recipes we will add it to the game.
Day 12
Structure block
I literally learned how to use this a couple days ago. I don't know if I learned every single use but its pretty useful. So my problem was I just had a building made, and the issue was what if I wanted it to face a different direction? That is were this block comes in. Similar to a command block it has different modes and a lot more buttons.
1. Saving
So you just made a house, nice! We can use the structure block to save it as a structure in minecraft's files. First place the structure block in the corner of your build, make sure to place it on the positive corner, the one where in f3 all points meet like this:
Then in the structure block we will change the block into save mode by clicking 'save' in the bottom left. Next you want to name your structure. Name it something unique you can remember and make sure its not the same as another minecraft file. After you name it you need to select a size, so you fill out how big the build is with the second line of numbers, included in picture, since were in that corner you only need to put in positive numbers. Remember to select your whole build. Also another type of structure block is called corner mode which is just for selecting the area but in my opinion this is easier for smaller builds. Now that its selected click 'SAVE' on the bottom right and it will be saved.
2. Load
We saved our structure now we can load it, place a new structure block in a clear area, and type in the name of your structure and simply select 'LOAD' in the bottom right to see its outline and then click it again to confirm.
There is also an option to select entities when saving and loading, and also placing them in strict mode meaning no block updates. But most importantly in loading, you can change the direction with the 0, 90, 180 and 270 buttons, meaning degrees
Target selectors part 3
I think its time to show some of the remaining target selectors, they are not too complicated.
Distance=
This is pretty neat, it targets entities that are within a distance, we can use the 2 dots again to target, so if I wanted to target every entity with a 10 block radius we have @e[distance=..10]
If you want to use this for entity touching detection you can, but keep in mind that if the distance is less that the entity hitbox it will probably not work. To do it you can use dx=0 on its own
Level=
Very simple, targets entities based on experience level, you can use 2 dots here as well
Gamemode=
Selects players based off of their gamemode, can only put stuff like 'creative', you and also use gamemode=!
Name=
Targets players with specific names, you can also use name=!
I use this to make sure no one cheats on my maps, since they are supposed to be on adventure mode, I pretty much put in tick.mcfunction : gamemode adventure @a[name=!geosivridis] : I can also add more name=! if im working with other people
X_rotation= and y_rotation=
Targets entities depending on where they look, can use 2 dots for this. X targets where we look up or down, Y targets if we look east, west etc
Nbt=
This targets entities with specific nbt data, so for example to target arrows that are on the ground we have @e[type=arrow, nbt={inGround:1b}]
Advancements=
Targets players with an advancement @a[advancements={story/smelt_iron=true}]
Predicate=
Targets players with a specific predicate (true or false statement), can use predicate=! ,more on predicates another time
Day 13
/gamerule
Simple command, but I thought I would mention some gamerules that are nice for map making.
command_block_output: This can stop the chat message you get every time a command runs in a command block (which by the way only operators can see it)
show_advancement_messages: Useful for not wanting advancements in chat, and also for death messages show_death_messages
block_drops: If items drop off of broken blocks
entity_drops and mob_drops: one for entities and other for mobs if they drop items
command_blocks_work: Can disable and enable command blocks
max_block_modifications: oh my god, I didn't know this existed, this removes the limit for the /fill and /clone command which use to be 32 thousand YES
tnt_explodes: disables and enables tnt
forgive_dead_players: this makes mobs around the player who died not angry anymore
max_entity_cramming: can extend the limit of how many mobs can fit in one block without suffocating
raids: disables and enables raids
universal_anger: angered netural mobs attack every player and not just their attacker
allow_entering_nether_using_portals: disables nether
drowning_damage, fall_damage, freeze_damage, fire_damage: disables damage for players
ender_pearls_vanish_on_death: enderpearls dissapearing if you die, this can kind of disable teleport chambers
fire_spread_radius_around_player: how far fire can spread, 0 to disable, -1 for unlimited range
immediate_respawn: respawns without the screen
keep_inventory: keeps inventory after dying
limited_crafting: allows player to craft only what they unlocked in recipe book
locator_bar: disables the locator bar
natural_health_regeneration: stops healing from food
pvp: enables players fighting or not
spawn_mobs, spawn_monsters, spawn_phantoms, spawn_wandering_traders, spawn_patrols, spawn_wardens: disables mobs spawning
spawner_block_works: disables spawners
advance_time, advance_weather: stops time and weather cycle
random_tick_speed: how fast the game progresses (such as plants growing)
showtags: shows tags such is "can place on" or "can destroy", useful for adventure maps with adventure mode items
When making minecraft maps
Originally, I was confused as to how /setworldspawn work, and some of my older maps might be broken from that, so instead of doing that you can do one simple fix. What we are going to do is basically have 2 commands in tick.mcfuction or repeating command block. The first one teleports any player who does not have the tag 'inside' to the place where they are supposed to spawn /tp @a[tag=!inside] ~ ~ ~ : and the second one adds a tag of 'inside' to any player who is in that room /tag @a[x=, y=, z= etc] add inside : so now we don't have to worry about players being outside of bounds
Remember that the most lag is made by commands who check nbt data, so if you are using them try not to over use them, like in a repeating way
Day 14
By the way thank you so much for all the support, I did not expect this blog to be trending
Anyways, today I thought I would show some useful scoreboard tips
Scoreboard criteria
I didn't fully cover them all so lets do that
dummy: old reliable, just a normal scoreboard objective
trigger: objective that goes up with command, you can type it once to add 1 or add and set it to whatever number you want, you can use /trigger set : to make commands that the player can input numbers
deathCount: counts deaths, totalKillCount: counts mob and player kills, playerKillCount: counts only player kills
health*: counts health the player has including extra health and absorption, xp*: counts experience points, level*: counts experience levels, food*: counts food level 0-20, air*: how much time a player has when about to drown 300 max, armor*: how much armor player has. The ones with a star * mean they cannot be modified, and also players may show up as 0 in a scoreboard unless their number changes
minecraft.mined:minecraft.<block>: Counts how many times a player broke a block
minecraft.broken:minecraft.<item>: Counts how many times a player broke an item, only applies to items with durability
minecraft.crafted:minecraft.<item>: Counts how many times a player crafted an item, only applies to craftable items
minecraft.used:minecraft.<item>: Counts how many times a player used an item
minecraft.picked_up:minecraft.<item>: Counts how many times a player picked up an item
minecraft.dropped:minecraft.<item>: Counts how many times a player dropped an item
minecraft.killed:minecraft.<entity>: Counts how many times player killed an entity
minecraft.killed_by:minecraft.<entity>: Counts how many times player died from an entity
These are made for specific items only, so if you wanted to count how many times you break every wool, you would need 16 objectives for each color
And the best for last, minecraft.custom:minecraft.<criteria>: now here is a list of all custom criteria
animals_bred, clean_armor-banner-shulker_box (for when you undye leather armor), open_barrel-chest-enderchest-shulker_box, bell_ring, eat_cake_slice, fill_cauldron, damage_absorbed (damage is counted in 1/10ths of one health), damage_blocked_by_shield, damage_dealt, damage_dealt_absorbed, damage_dealth_resisted, damage_taken, inspect_dispenser-dropper-hopper
anything with _one_cm is counting distance in centimeters including: climb, crouch, fall, fly, walk, swim, sprint, walk on water, walk under water, boat, horse, happy ghast, aviate (elytra), pig, nautilus, minecart
leave_game
Day 15
/random
This is a pretty recent command as it was added right before I left PMC, you can use it to generate random numbers from a range of numbers, and apparently control random sequences in the world, though I don't really know how to use the sequence part, its related to loot tables which I haven't really researched much yet
To generate a random number type /random <value or roll> <range> : the range is again using the 2 dots so 1..10 would be 1 to 10, value or roll do about the same thing, except roll broadcasts the result to every player, so I recommend using value. On its own we can't use it so we have to store it with /execute store, I will store it on a scoreboard /execute store result score <name> <objective> run random value 1..10
There is also /random reset but that is used for sequences
/return
This is a good one, I got so excited when I heard about this recently. This command is used in datapack functions, what it does is if it runs it stops the function, its a game changer
You simply have 'return run' and 'return fail'. Run works like /execute run and runs a command, fail however does not do anything, and also returns 0 if we /execute store our function command
Its an actual game changer, things can be done a lot simpler. For example, one issue I had was using a button to toggle something on and off. The point was if you press it once you get a message, a sound, and a scoreboard change, and twice would change those slightly, but when you run the same function it runs everything, but with return it stops at that point and does not run any other command under it
Day 16
[style b size=18px color=#3598db]Datapack tags
[style size=16px color=#3598db]Here is one thing that is pretty simple and very useful in datapack, tags. Tags are pretty much used to categorize different things in one command. Let me give you my example. For one of my projects I needed to /clear every same type of item from a players inventory, for example every dyed glass, for other blo
So make sure to subscribe to get notified about future updates!
In this blog I will share everything I learned about minecraft commands and datapacks from the past couple of years that I've been posting on this page. I will begin with basic minecraft commands first and then move along to more complicated commands and then how a datapack is better than pure command blocks. I will also mostly mention how you can use these for minigames as it is what I mostly create.
Day 1
Today I will focus on small simple commands that are very useful while also showing some other basic commands that are not so useful.
/clear
Really simple use and syntax, this command is used to remove items from the player's inventory, while also tracking how many items it removed.
Syntax: /clear <user> <item> <amount of items>
By just typing /clear on a user it will remove their whole inventory. If you specify the item it will only remove that item and by specifying the amount it will only remove that amount
Example:
/clear : removes all items from the inventory of the person who ran the command
/clear geosivridis : removes all items from the inventory of player geosivridis
/clear geosivridis iron_ingot : removes every iron ingot from the inventory of player geosivridis
/clear geosivridis diamond 3 : removes only 3 diamonds from the inventory of player geosivridis
Tip: you do not have to specify one specific player, you may use @a and target all players online.
I mentioned you can use this to track how many items you removed from the player, but I will show how to when we get to /execute store.
/effect
This command is used to clear and add effects on a player or entity.
Syntax: /effect clear <user> <effect> OR /effect give <user> <effect> <time in seconds> <amplifier> <hide particles>
hide particles is optional with it being false by default
Examples: /effect clear : clears all effects of the person who ran the command
/effect clear geosivridis : clears all effects of the player geosivridis
/effect clear geosivridis speed : only clears the speed effect from the player geosivridis
/effect give geosivridis speed 10 1 : gives speed 1 for 10 seconds to the player
/effect give geosivridis regeneration infinite 3 true : gives regeneration 3 forever to the player while also hiding particles
Same here too, you can target multiple players and entities
Which brings me to the next thing that is somewhat related
Target selectors (part 1)
Very important, they are not exactly commands but any command that targets an entity or player uses target selectors. They include:
@a : All players
@p : Nearest player
@r : Random player
@n : Nearest alive entity
@s : Current entity
@e : All entities
Target selectors also include extra arguments that make them target more specific entities or players, this is why this is split into multiple parts. You can add them by adding square brackets [] after the selector
Some arguments include distance=, type=, scores=, tag= and more but for now we only focus on type=.
type= is only used in @e, it targets specific entities
So for example: /kill is a command that kills entities
If you type /kill @e : it will be chaos because it will kill every single entity and player
But if you type /kill @e[type=chicken] : it will only kill every chicken
You can also use type= and other argument to NOT target something by including a ! in the beginning
So if we had /kill @e[type=!chicken] : this would now kill every entity EXCEPT chickens
You can use type=! multiple times to exclude different mobs, but you can not use type= multiple times, if you have one type= you can not add another type= or type=!
/enchant
Now this is NOT useful since it is way to limited. You can understand that this command enchants your item but it is limited to what you can do in survival, and also fails if you hold the wrong item so I do not recommend it.
Syntax: /enchant <user> <enchantment> <level>
Example: /enchant geosivridis sharpness 5 : enchants your sword with sharpness 5, you can not go over 5 in sharpness as it follows the normal enchantments
If you are lazy and want to enchant your item in a creative world you can use this, but otherwise it is simply more efficient to /give the item instead
Day 2
What I think I'm going to do is one day I will show simple stuff and the next show something a little more complex, do a pattern like that
/execute (part 1, at, as, run, summon)
Easily the MOST USEFUL command ever. If you do anything complex just use execute it has way too many uses which is why it is also split into parts.
/execute run <command> : very simple, runs a command, on its own its not so special but the beauty of /execute is that you can use them all together
/execute as <user>: now this is simple, you simply run a command as an entity.
Example: /execute as @e[type=zombie] run say hi : this is how you combine different subcommands, so /say basically sends a chat message from a user, so since we has 'as zombie' then we will see '[zombie] hi'
/execute as targets MULTIPLE entities and runs the command for as many entities there are, so for the example if we had 10 zombies then the same message would be sent 10 times!
Pro tip: if you use /execute as and want to refer to the same target again, you can use @s, this can make a command with a long selector look shorter
/execute at <user>: also very simple, you run a command at an entity's location.
Example: /execute at @e[type=zombie] run summon sheep : this summons a sheep at a zombie's location
/execute at also targets MULTIPLE entities so if we ran the example, at every zombie location a sheep would be summoned
If you wanted to combine everything and use the pro tip you would have /execute as @e[type=zombie] at @s run summon sheep : it would do the same thing
/execute summon <entity>: I'm not gonna lie, I did not know this existed, its pretty new, and I do not see it useful at all
Example: /execute summon sheep run say hi : from the little testing I did, it summons and entity and also by default runs it as that entity, so the sheep you summoned would say hi. This could have a use but the cherry on top is that you can only summon default mobs, you can not add attributes, tags etc. like /summon
~ ~ ~ :
I don't know how they are called haha, the symbol is tilde and we use it for current coordinates based on x y z. There are also carets ^ which do something similar but I will mention them another time.
So instead of actual coordinates you can put ~ ~ ~ which is set to them by default, what you can also do is set them as a starting point and build from there, by adding a number next to them it changes, so ~1 ~ ~ would be 1 block next to them, and ~ ~ ~-0.5 would be half a block in another direction
So combining this with /execute at: /execute at @a run summon sheep ~ ~10 ~ : this spawns a sheep 10 blocks above every player
If you want to be more specific about where you want the coordinates to be, you can press F3 and check your crosshair, the blue red and green things, shows the positive directions of x y and z
Day 3
Back to basics
/give and /item:
/give is probably the first command someone learns but /item is underrated too! Why are they different? /give just gives an item, while /item gives an item in a specific player slot.
I saw that /item is getting more subcommands for 26.3 but I will skip it for now and maybe update it when it comes out, /item has replace and modify as subcommands, replace replaces an item in a container, and modify modifies it with an item modifier? I never used this, it uses datapacks
You can use /item to modify entity inventories, ender chests, and also chests and other storage blocks
With /item replace you can also copy items from other storages or entity inventories
Example: these should be simple /give @p diamonds 64 : /item replace entity @p weapon.mainhand with diamond 64 : these do the same thing except /give just drops the items on you, so if you have a full inventory you won't pick it up, and /item replaces your main hand no matter if you are holding an item
You can also target multiple entities with both /give and /item thank god
Pro tip: you can give items with different components and stuff like use cooldowns or custom names, and because syntax can get complicated with them I recommend using mcstacker.net as it saves a lot of time
/summon:
Also simple command, summons an entity at a location, the reason this is better than execute summon like I said before is that you can actually modify the entity with /summon
Example: /summon husk ~ ~ ~ {Health:50f,equipment:{feet:{id:"minecraft:iron_boots",count:1}},attributes:[{id:"minecraft:max_health",base:50}]} : I took this straight from mcstacker, this summons a husk wearing iron boots with 50 health and 50 max health
Yet again I recommend using mcstacker for this one again, one side note for both /give and /summon you should know is that attributes change health, damage and all the stats, you should experiment with what you can do in mcstacker and if you have any questions let me know
How about a lightning round to finish off the day:
/experience or /xp:
Adds and removes experience points from the player, you could use this as an actual experience bar in an RPG if you turn off any other way of getting experience, or you could use a bossbar (more of that when we get to /execute store)
Example: /xp add geosivrids 7 : adds 7 xp points /xp add geosivridis 7 levels : adds enough xp for 7 level ups. You can set the level to 0 to reset them and also use /xp query geosivridis levels : to see how many levels the player has
You can't directly remove xp, but you can set it any number instead of add
/tp or /teleport
Teleports entities to coordinates or to other entities
Example: /tp geosivridis 0 50 0 : this will send the player to those specific coordinates, you may use ~ ~ ~ too /tp geosivridis steve : teleports the player to the other player, geosivridis teleports to steve
You can teleport multiple entities but you can only one one entity as a teleport location
Which brings me to
Target selectors (part 2)
We have a few more arguments today, limit=, sort=, and xyz= and dxdydz=
Might as well put them together
limit= adds a limit to the targets selected, you can only add numbers
So if you want to use tp, you can use @e[limit=1], we will keep using this for commands that need to target only one entity
sort= goes hand in hand with limit=, it sorts the entities it selects, theres sort=nearest, furthest, random, and arbitrary which the last one is so useless not even the wiki knows how it works it just does not sort lmao
So to target only one pig next to you, you can do @e[limit=1,sort=nearest,type=pig], if we did not have type=, the closest entity would be yourself, or you could just exclude the player with type=!player
And another example if you have many different mobs you could use @e[sort=random,limit=2] to pick 2 random mobs
The last part are all together, its for selecting entities within a certain space, to start you choose coordinates with x= y= and z=, this is your starting point, the d in dx stands for delta so dx dy and dz say how big your space is
So if I want to target someone within a room you can type @a[x=5,y=50,z=10,dx=10,dy=5,dz=10], xyz are just coordinates dx dy dz is how much the box stretches, so in the example it goes 5 blocks up, 10 blocks right and 10 blocks foward. Make sure to use f3 again to get the correct direction of the delta
You can use xyz in a repeating command block or tick.mcfunction in datapacks to detect when someone enters a room and trigger an event
Combining all these, if you spawn 10 mobs inside a small box you can select a number of random mobs in there, this is a form of random mob generation, I used to use this in mob battles
Day 4
I think its time for one of my favourites
/scoreboard
Now listen, scoreboard sounds very goofy compared to actual numbers in programming but we gotta take what we can get. /scoreboard is a command that counts stuff, stores it in a namespace or entity, and you can do math with, I know scary but not really
The command has a bunch of subcommands and uses. To start we need to create a scoreboard objective
Example: /scoreboard objectives add <name> <criteria> <displayname> : name is obviously its name, criteria is interesting, the criteria shows what kind of objective it would be and there are 4 categories pretty much. 1. is dummy, which is just one criteria on its own, its job is to do nothing, it can only change when we change it. 2. is trigger, more of that later but its pretty much the closest thing we have to custom commands. 3. are objectives that track a stat that can go up, such as how much of a block you mined, your playtime, your death count etc. 4. is tracking stable stats like health and hunger, you cannot modify those. Display name is optional but you can put a json there and add colours and stuff, we always refer to the objective using the normal name.
You created the objective now it exists in the world, why is it useful? I will leave trigger at the end, but what you can do is check for who scored in an objective and then do something to them and then reset them.
To do this, we will use a new target selector, scores=, be careful cause it has different syntax, we type @e[scores={<name>=1}], now 1 can be actually a range of numbers using 2 dots .. so if we want just 1 type =1, if you want 1 and above type 1.., 1 or less we type ..1 and between 1 and 5 its 1..5
For scores= we cannot use scores=!
So using all this we can for example detect if a player dies! First create an objective /scoreboard objectives add death deathCount : we only have to do this once, and inside a command block that is on repeat always active (or a tick.mcfunction file in a datapack, these things basically run 20 times a second) /execute as @a[scores={death=1..}] run say i died, rest in peace :
How a tracking scoreboard works is it adds 1 to the counter of a player every time it meets its criteria, so a death count scoreboard goes up by 1 if a player dies
IMPORTANT: these scoreboards save their scores so the following command would spam the chat, after the command runs we need to make sure we set their death scoreboard to 0, we do that with /scoreboard players
/scoreboard players set @a[scores={death=1..}] death 0 : this basically targets every player with a score of 1 and above in deaths and sets their score back to 0. Make sure this command runs at the end to reset everything.
For scoreboards that track stable stats like health or hunger, you can not edit them, but you can still run a command depending on what their stats are
Finally let's cover trigger, trigger has its own command /trigger, you need to first give permission to people to type this command, after that if they type it their score goes up by one, or they can add or set it to as much as they want.
Example: we create a new scoreboard objective /scoreboard objectives add Heal trigger : its added, now we need to constantly allow people to use it using /scoreboard players enable @a Heal : Now they can use it. enable is only used for trigger scoreboard. Also remember that scoreboard objective names are very character specific, so heal would be different from Heal, their difference is a capital letter. So now we do the exact same thing, /execute as @a[scores={Heal=1..}] run effect give @a[scores={Heal=1..}] instant_health 1 100 true : and after that we need to reset it /scoreboard players set @a[scores={Heal=1..}] Heal 0 : This basically adds a command that when you type it it heals you.
All these commands need to be running every tick, and also in order, you can use chain commands blocks and a repeat command block to do so, or in a datapack put them in order in tick.mcfunction (or make it run a new function, but we will get there)
/scoreboard players also can add and remove scores, and can also do math with /scoreboard players operation : you basically get 2 player numbers and do math, you can add them together (+=) or multiply (*=) etc. It will always be saved on the first player.
Pro tip: if you are counting something that has nothing to do with the player, such as a 'round' number or time, you can save it on a random name. Make sure to use characters that cannot be use in a player's name in case a player with that name exists, for example I use ?t to save any number unrelated to the player
One last thing you can do is display different objectives, this is how we can use <displayname>. You just need to type it once and say /scoreboard objectives setdisplay <display> <objective> : there are multiple places you can set the objective on, it can be on the tab, in the sidebar (which also acts as a leaderboard) and under the player's name (you can use this for health counters).
This command can be combined with execute and tellraw, so that is what I'm going to mention next time.
Day 5
/tellraw
Very important command for map making, datapacks, everything. It simply sends a message in chat using something called a json.
Its different from /say cause /say shows who is broadcasting it and also uses colour, /say ignores jsons
Example: /tellraw <user> <json> : json has a lot of arguments you can use to type, you can do it like me where I learned some basic ones and use mcstacker for everything else, or just use mcstacker from the start its fine.
To start a json is always in between curly or square brackets { }, [ ], square brackets are for more arguments.
There are a bunch of arguments you can add, with the most basic being "text"
/tellraw @a {"text":"Hello"} : this is a hello message without colour. If we wanted colour then we add the "color" argument next to it /tellraw @a {"text":"Hello", "color":"red"} : from there you can also add if you want a bold or italic font and a couple others, you simply add , "bold":true
true and false are boolean so they usually don't need to be within quotes
I recommend using mcstacker if you are not sure what you are doing, the other useful stuff you can add to a tellraw are selectors, meaning a player name, score from a scoreboard, and a few more that I don't use much. You can also make interactable chat but I will show that another time.
/title
This is another place we can use json for text.
Simply type /title <user> title <json> and it will display, you can display it in the subtitle and the action bar too. Quick side note, these are a little different as there's also a time argument, you specify how long they stay on the screen you type /title <user> times <fade in> <stay> <fade out> : these arguments need numbers, you specify how long it takes for each part keep in mind the default value are ticks (1/20th of a second) you can add s at the end for seconds and d for days
/execute (part 2 if, unless)
Back to the best command with the best argument, if and unless, obviously opposites. These are conditionals meaning the command will run only if or unless the test passes, and they have a lot of arguments. You can also check how many times the test passes and store that too.
/execute if biome
I never used this... Checks a block if its in a specific biome, or apparently with structures? I actually don't exactly know /execute if biome ~ ~ ~ minecraft:basault_deltas run say hi : so it will only run if the block is in that specific biome, if it was unless it would run unless it was in that specific biome
/execute if block
This is more useful, checks what a block is /execute if block ~ ~ ~ pink_wool run say pink! : I used this for my battle box map to check what colour the blocks were
/execute if blocks
Its not what it looks like, I got confused too. From what I understand it compares 2 boxes in the world and sees how many blocks are the same? I did some testing and I have no clue. The condition was true whenever the two areas were similar /execute if blocks <pos1> <pos2> <pos3> all run say blocks! : the first 2 positions make a box and the last one marks a box of the same size somewhere else, you can put all it includes air blocks, masked doesn't
/execute if data
We haven't mentioned data too much, every entity and a few blocks have different data that can be modified, this one however just checks if that entity or block with that data exists, more of that when we get to /data
/execute if data entity geosivridis SelectedItem run say hi : this says hi if a player is holding an item
/execute if dimension
Pretty self explanatory, checks the dimension of where the command is run, doesn't check specific block /execute if dimension overworld run say overworld!
/execute if entity
My favourite of all, this checks if an entity exists /execute if entity @e[type=pig] run say pig! : if there's at least one pig it will run, we can also use this to target more specific entities
/execute if function
This is datapack related and lowkey don't understand it so we skip it
/execute if items
Now this is good, pretty new just like /items, it checks for items on specific slots of entities and chests and stuff
/execute if items entity geosivridis armor.head iron_helmet run say Helmet! : runs if the player is wearing an iron helmet
In /item and /execute if items you can use * which means all items, so instead of iron helmet if we had * the command would run if the player had any item on their head
/execute if loaded
Never seen this either, checks if a block is loaded /execute if loaded ~ ~ ~ run say loaded : if we did the same thing for ~ ~ ~10000 which is 10.000 blocks away it wouldn't run
/execute if predicate
This is really good but you need datapacks to use it, we need to add some big json files. Predicates are basically true or false conditions that run very well, you can check for example if player is standing on a block, more of that later.
/execute if score
We are so back, score means scoreboards of course and this can compare 2 players scores or just check if a score is within a range of numbers
/execute if score geosivridis <objective1> > geosivridis <objective2> run say 1 is bigger! : you take a name and an objective, and it compares them using < > <= >= and =, to check for one score we use matches /execute if score geosivrids <objective> matches 1.. run say bigger than 1! : we use the same number range I mentioned before in scores=
Note we can only compare one name's score, so we cannot put @a or @e without limit=1
Apparently there also /execute if stopwatch, but its not written in the wiki and I have no clue what it is
Day 6
Lets do some quality of life
/setblock and /fill
Simple commands, they modify blocks in the world, one only modifies one and the other can do a box of blocks, but has a limit of about 32 thousand which I think its a 16 bit limit.
/setblock ~ ~ ~ <block> [setting] /fill <pos1> <pos2> <block> [setting] : the settings can be pretty useful. First for setblock we have destroy which replaces the block and breaks and drops the previous one, next is keep which only changes air blocks, the default is replace which just replaces it and nothing else, and last is strict which replaces the block without block updates, this means that stuff like falling sand floating won't fall and so on. For fill we have destroy which does the same as it replaces all blocks, hollow which only fills the outside layer and the inside is untouched, keep replaces only air blocks, outline is like hollow but it doesn't drop any items, replace is the default and just replace BUT you can add a specific block you want to only be replaced, and strict again which doesn't cause block updates
/clone
Somewhat similar to fill, you select an area and you can copy paste it
/clone <pos1> <pos2> <pos3> [setting] : this is a little weirder, pos3 is the destination and acts like the first corner selected, apparently you can also set this to clone blocks from one dimension to another. The settings include replace which is the default, masked which is like replace but doesn't replace blocks with air, again strict with no block update, and the a different setting has normal which is default, force does the clone even if something overlaps, and move which replaces the previous region with air
/execute part 3 (align, anchored, facing, in, on, positioned, rotated)
/execute align, honestly learn its use 3 minutes ago... it literally aligns your coordinates to the closest smaller whole number, what this means, if I am located at 9.3 56 103.8 and I type /execute align xyz run spawnpoint @p ~ ~ ~ : /spawnpoint sets the player's spawnpoint, the coordinates will act as 9 56 103. You can modify one or two axis at a time so you can have just x or just yz, but you cannot repeat them
/execute anchored is also simple, it changes between eyes and feet, basically where its executing from Simply /execute anchored eyes run ...
/execute facing goes hand in hand with anchored, it changes the executors rotation you can make it face a block /execute facing ~ ~ ~ : or an entity's eyes or feet /execute facing entity @p feet : I personally haven't used these but I think they are pretty useful for some more complex stuff
/execute in changes the executors dimension /execute in the_nether
/execute on targets entities who are riders or riding mobs or even leashing other mobs or owners of tameable animals /execute on <relation> : we have attacker which is last entity who damage the executor the last 5 seconds, controller the entity rider that is in control, leasher the entity who has a leash on another, origin is the person who summoned another entity like an arrow or tnt, passengers the riders who are not in control, target is the target that the executor wants to attack (apparently this works differently with interaction entities), and vehicle which is the entity ridden
/execute positioned changed the execution's position, it can be coordinates or from an entity, or a specific heightmap too I guess? /execute positioned ~ ~ ~ /execute positioned as <user> : Why is it different from execute at, I don't know, but it does extra stuff
/execute rotated does the same as positioned for rotation, without a heightmap /execute rotated ~ ~ : /execute rotated as <user> : rotation has yaw and pitch, yaw being which direction you look, and pitch being how you look up and down
Day 7
/execute part 4 (store)
Store is a very important subcommand, you use it to store different things you find and also multiply them, you can store a result or a success, what does success mean? If the command you run is successful, it stores 1 and if it does not it stores 0.
/execute store result <destination> : we have different places to store data. We have block I don't really use this, bossbar, entity, score, and storage. Block, entity and storage are also common to the /data command, its where we can get data from.
We can do a lot of things with these 2 commands, but first lets start on /data
/data part 1 (get)
/data is only complicated because there is so much data stored in one place. /data get is a way to get data and for the player to see, but we can also store this data
I will create a scoreboard called y_level, its a dummy scoreboard /scoreboard objectives add y_level dummy : This scoreboard will track the player's y level, meaning their height in the world.
/data get and /data in general can only target one thing at a time, it can be a block like a sign, an entity, or storage. Storage is unrelated to chest, its like data that exists in the world just floating in the void. We can bypass this one at a time limitation by using /execute as
In a repeating command block we can have /execute as @a store result score @s y_level run data get entity @s Pos[1] : Now if we display the scoreboard we will see the player's y level
You can store score in multiple users without execute as. At the end of /data get, if you are trying to get a number, you can multiply it at the end before you store it, this is useful because scoreboards only store whole numbers, so if you want to see half blocks you will have to add 10 to the scale and so on
Pos[] is the data that has the position of an entity, pos[0] is the x number, 1 is y and 2 is z.
/bossbar
Now we can actually use the bossbar command
To begin its like /scoreboard we create a bossbar /bossbar add <id> <name> : id is how we refer to it, while name is what shows on the bossbar. We can change different settings with it such as colour, using /bossbar set <id> <setting> : color changes its colour, max changes how much it can hold (default is 100), players sets who can see the bossbar, and we can change its name, style, value, and visibility. So we set up the bossbar, now we need to make it store something, it can be used for timers and stuff, but its a bossbar, we gotta use it for a boss. So we will use it to store the health of an entity. Have at a repeating command block /execute store result bossbar <id> value run data get entity <boss> Health : Make sure the max of the bossbar is set to as much max health the entity has.
Pro tip: in a repeating command block we should make sure to make the bossbar not visible once the entity is killed
Finally I want to show an example of store success. /spreadplayers is a weird command that can teleport players and spread players, but the good part about it is that we can use it to teleport someone to the surface. This command however has a change to fail, if there is a dangerous block like lava, I use this for the random teleport I made. /execute store success score <user> <success_scoreboard> run spreadplayers <position only x and z> <spread distance> <max range> <respect teams> <user> : It sounds weird but not really, since we want to use this to just teleport one entity, we can set everything to a minimum so 0 distance, 1 range and false respect teams. We can also set the max height we want. The point is, that now we have that scoreboard to check if the command failed or passed, so if it passed its 1 and if it failed its 0
Day 8
Command blocks
Command blocks have a few settings that some people don't understand that are very useful, but datapacks are just better. Keep in mind that when running a command from a command block or a function in a datapack it is not run by a player or entity, so something like @s will do nothing, unless we use /execute as
Block types
There are 3 types of command blocks, there is impulse (orange) for one time use every time its activated (usually by redstone), chain (green) which do the same but connect to other command blocks using their point direction, and repeat (purple) which run every tick (20 times a second) when activated
Needs redstone and always active
Pretty self explanatory, having a command is useful for repeat and conditional command blocks, impulse just runs once
Conditional and unconditional
This is useful for a chain of command blocks, the way a chain command block works is if a command is activated it will pass a signal and run command of the next block in line, all in the same tick but in order, but if we have a conditional command in there, to continue the chain the current command must pass, if it fails it stops the chain
Datapacks, how files work
I won't yet mention how to create a datapack but first we gotta understand how they run commands
Datapacks have their own type of files ending in .mcfunction , in these functions you can write any command you want and they would run like a chain of command blocks, all run in order and in the same tick. Note that if only one command isn't correct, the whole function cannot be run.
There are 2 special mcfunction files that are important. tick.mcfunction and load.mcfunction, they don't really have to be called that way but its fine, these are functions but different. tick run itself every tick, while load runs every time the world is loaded or if we manually type /reload
There is also a command for functions called /function, we use this to run a function and we can also run it with linking it with data which we can use for macros, but that's for future me to explain
Why are datapacks better than command blocks someone might ask. They are better in pretty much every way. If something goes wrong and the player gets softlocked, you can undo something from a datapack while if it was in a command you couldn't. Datapacks are way smaller files, and I'm not 100% sure about this but I think I've noticed the minecraft maps I made to have a smaller file size when I started using datapacks. And also most importantly with datapacks you have more power, you can use predicates, custom advancements, add custom recipes and even remove old ones. I'm currently still learning about those 3, because no one actually explains how the misode generator works bro, but I'll make sure to mention them sometime
Day 9
/attribute
Really fun command, this changes attributes of entities, being part of the new components system. Any time in /summon we want to summon a mob with for example custom health we add an attribute
/attribute <target> <attribute> get <scale> : this gives you the number an entity has in an attribute, if it was health a player would have 20, scale is optional and what it does is it multiplies the number we get to do m a t h. Keep in mind we can only target one entity with this command but it can still be bypassed with /execute as. If we typed 'base get' it would do the same idk why it exists. To change an attribute we type 'base set <number>' and this is where the fun begins. Some fun attributes to change are air drag (the force that slowly stops you from flying infinitely), scale (turn huge or tiny), block interaction range, bounciness, fall damage and a lot more.
/playsound
Now in my opinion this is very important for datapacks and maps. It adds life to your creation and gives feedback to the player.
/playsound <sound> | <source> <targets> <position> <volume> <pitch> <minvolume> : anything past the | is optional, sound is basically every sound that exists in game, I will recommend a few I use later, source is what type of sound it is, I don't think it makes too much of a difference but for pure sound I use 'master', targets is who hears this sound, position is where the sound is, volume is volume default is 1, pitch is how high it sound default is 1 and must be between 0.0 and 2.0, and min volume I never used but its something about people who are away from the sound.
Whenever you want a player to hear the sound effect but don't want it to be on a specific block you can use /execute at.
Some sound effects I use are: block.fire.extinguish, entity.experience_orb.pickup, entity.iron_golem.repair, entity.enderman.teleport, entity.player.levelup, I'm sure there are countless more good ones so try experimenting
/tag
Very important but simple command, this adds an invisible tag to an entity so that way we can target a very specific entity using target selectors
/tag <target> add <tag> : this tag can be any word you want, we can also remove tags with 'remove' and also list them
Keep in mind you can tag multiple entities and also add as many tags as you want. I also use /tag list to debug something and check if it works properly.
To target an entity with specific tags we use tag=, so for example @a[tag=test]
We can use tag=! to target players without a tag, and we can add as many tag= and tag=! as we want to target an entity.
/team
Similar to tag we have /team, this is very different though.
We first add a new team /team add <team> <displayname> : displayname is optional, we can use 'join' and 'leave' to add players and entities to a team, there's also 'empty' to empty an intire team. After that we can 'modify' a team, we can modify friendly fire, color (this also changes the player's name color), prefix and suffix and a couple more.
For the testing I have done /team is good for team pvp minigames, I also tested friendly fire with monsters and it turns out they can still attack each other but won't get angry at each other.
There is also a target selector for people in teams, using team=, team=! also exists but note that an entity can only be in 1 team
Timer
Using scoreboards we can make timed events. If we have a scoreboard called timer we can put it on a repeating command block or tick.mcfunction to add 1 to a selector. Note that I suggest you do the timer in a random name with a special character. The number we have on a scoreboard will be in ticks so we will have to multiply our time by 20, and it will be the number we want the scoreboard to reach, so if I wanted something to happen in 30 seconds, the scoreboard has to reach a score of 600. Once it reaches that number we can run some commands, and we want to make sure we disable the timer if we don't want to use it again. You can do the same by doing the opposite, you can start at 600 score and remove 1 until you reach 0.
Since we are talking about time a good way to make sure a timer doesn't mess with anything after you disabled it is by setting it to -1, we don't want to use negative numbers for timers as time isn't negative.
Day 10
How to make a datapack
The time has come, you are ready... probably.
Step 1: VS Code
Now in theory, you can just code using notepad, but who wants to do that to themselves? The program I recommend for datapack coding, which is also good for other languages, is Visual Studio Code. I recommend you download and setup that, and also download an extension called 'datapack helper plus by spyglass', choose the most downloaded option. The extension button is on the far left with the icon of 4 squares
Step 2: Find your world folder
The easiest way to find your world folder is by going to minecraft before you enter your world, clicking on 'edit' and then selecting 'open world folder' and it will open the folder. Now that its open we gotta go to the folder 'datapacks' which is also where you can add new datapacks. You can do this part using VS Code or just manually with file explorer, you just have to copy paste some stuff using notepad and create files
Step 3: Folders and pack.mcmeta
Now this is where we begin, inside the datapacks folder create a new folder, you can name it whatever you want in won't matter, now lets go inside, in there we create another folder called 'data' and a new file called 'pack.mcmeta'. Now pack is basically telling the game the datapack version its in, this is why some datapacks are not compatible with different versions. Open pack and then copy paste a pack format from the minecraft wiki, I recommend using pack format 88, as its very recent and covers versions from about 1.21.9 to 26.2
Keep in mind when I tell you to create a folder its usually character sensitive, meaning the datapack won't if you capitalize the D in 'data', it has to be the exact same way as I have it here
Step 4: Main file and minecraft folder
Now lets head inside our data folder, in there we will create a folder called 'minecraft' and one more folder where you can name it whatever you want. Make sure you remember the name you give, whenever we refer to functions or other files we have to mention the folder its in, I'll call mine 'test'. Now lets head inside our minecraft folder, in there we will create a folder called 'tags', inside tags we will create another folder called 'function', and inside function we will create 2 new files, 'tick.json' and 'load.json'. You will copy paste what I have from the imgur images inside those files, but where ever you see the word 'code' you have to add the name of that folder I told you to remember, so I will put "test:tick" and "test:load".
Step 5: Functions and beginning
Were almost there, lets go back to our special named folder and inside it we will create a new folder called 'function', in this folder we can also make folders for predicates and advancements and stuff but we won't just yet. Inside functions we can create our 2 special function files, 'tick.mcfunction' and 'load.mcfunction'. And that should be it, you can test the files if they work, you can put a command in tick and it will run 20 times a second, and load will run every time you /reload or reboot a world. You can also create new files ending with .mcfunction, just make sure they don't have any capital letters in their names or weird characters, underscore _ is fine.
/function
Now I gotta explain how this command works, this runs a function we have inside our function folder. To run one of our functions type /function test:name : remember our special folder name, we gotta use it again to refer to functions like I said. Again remember that mcfunctions must not have any syntax errors or they will not run any command inside them.
And that's it, you can now make function datapacks
Pro tip: whenever creating new things with commands like a new scoreboard objective or a new team, you know the commands that you have to type one time and they exist, write them in your load function. This makes sure to add them into a new world if you get a datapack in a different world, and also makes sure VS Code knows what objectives you are talking about.
Remember, commands in chat need / to begin, commands in datapacks don't work with / but command blocks work with both
Day 11
/data part 2 (modify, merge, remove)
Here we are, the data command at its full glory. /data is a very complicated command, just from how many target paths and nbt data exists, I mean you saw what /data get showed. There are 3 types of places where data can be stored I don't remember if I mentioned them. We have entities, blocks (like chests or signs) and storage. Storage is not chest related, storage is saved somewhere in the world and we can save different things. I personally prefer to use /data modify, as merge is about the same but limited, and I don't exactly know why remove exists.
One cool example we can do for modifying entity data is Motion, this can send an entity flying. /data modify entity <target> Motion set value [0d,1d,0d] : Motion is a number that contains 3 doubles, which are like floats but better, just decimal numbers. Each number represents XYZ, so the 1d I only have sends the target flying up.
Remember you can't modify multiple entities without /execute as, and also unfortunately we cannot use /data to modify or merge any data of the player's.
Data types
I think its about time I explained programming basics, its not that complicated don't worry. In minecraft and in a computer in general, information is saved in variables of different categories. These categories in minecraft include strings: which are words, any character even numbers are included ("hello world"), integers: whole numbers including negatives(10, -4382), floats: like integers but with decimals (3.14, -10.0), doubles: larger floats (3.9087063), booleans: just true or false, in game written like 1b, and also arrays: lists of different info that you can add stuff and remove stuff from.
Whenever the game refers to a datatype they usually have a letter after the products, 20f, 10.4d, 1b etc
Now a very important thing you can do with data modify, is modify data, using other saved data. /data modify entity <target> <targetpath> set from entity <target> <targetpath> : this is actually so useful, let me make an example I used recently.
TNT Bow
We will make a custom bow that will show TNT instead of arrows. How this will work is 1. we will detect arrows that come from a specific bow, 2. we will summon a tnt block in its place, 3. we will copy the Motion data from the arrow to the tnt, 4. we kill the previous arrow
To start lets create a bow using mcstacker: /give @p bow[custom_data={tnt_bow:1b}] 1 : you can add stuff like use cooldowns, custom names and stuff but what makes it special is the custom data, we added a boolean tag to it
next I will prefer we use a datapack for this, because a command block has to be loaded all the time to run all this, so in our tick.mcfunction file we put: execute as @e[type=arrow] at @s if data entity @s weapon.components."minecraft:custom_data".tnt_bow run function code:tnt_bow : so this checks if an arrow has that data and if it does it runs a function called 'tnt_bow'
If we run a function with /execute as or at or any execute modifying command, it will use it as a default so we can use @s in that function again.
So after that in that function we can just type: summon tnt ~ ~ ~ {fuse:60,explosion_power:5,Tags:["tnt_bow"]} : use mcstacker for this too to modify fuse, explosion power, but most importantly have the tnt have a tag on it. So after that we will modify its data : data modify entity @e[tag=tnt_bow,limit=1] Motion set from entity @s Motion : now one extra step we need to add is to remove the tag from the tnt : tag @e[tag=tnt_bow] remove tnt_bow : we need this so we don't accidentally target the same tnt again. And finally kill @e[type=arrow,nbt={weapon:{components:{"minecraft:custom_data":{tnt_bow:1b}}}}] : And that's it, that bow can shoot tnt now and only that bow. In the future when we learn how to add custom recipes we will add it to the game.
Day 12
Structure block
I literally learned how to use this a couple days ago. I don't know if I learned every single use but its pretty useful. So my problem was I just had a building made, and the issue was what if I wanted it to face a different direction? That is were this block comes in. Similar to a command block it has different modes and a lot more buttons.
1. Saving
So you just made a house, nice! We can use the structure block to save it as a structure in minecraft's files. First place the structure block in the corner of your build, make sure to place it on the positive corner, the one where in f3 all points meet like this:
Then in the structure block we will change the block into save mode by clicking 'save' in the bottom left. Next you want to name your structure. Name it something unique you can remember and make sure its not the same as another minecraft file. After you name it you need to select a size, so you fill out how big the build is with the second line of numbers, included in picture, since were in that corner you only need to put in positive numbers. Remember to select your whole build. Also another type of structure block is called corner mode which is just for selecting the area but in my opinion this is easier for smaller builds. Now that its selected click 'SAVE' on the bottom right and it will be saved.
2. Load
We saved our structure now we can load it, place a new structure block in a clear area, and type in the name of your structure and simply select 'LOAD' in the bottom right to see its outline and then click it again to confirm.
There is also an option to select entities when saving and loading, and also placing them in strict mode meaning no block updates. But most importantly in loading, you can change the direction with the 0, 90, 180 and 270 buttons, meaning degrees
Target selectors part 3
I think its time to show some of the remaining target selectors, they are not too complicated.
Distance=
This is pretty neat, it targets entities that are within a distance, we can use the 2 dots again to target, so if I wanted to target every entity with a 10 block radius we have @e[distance=..10]
If you want to use this for entity touching detection you can, but keep in mind that if the distance is less that the entity hitbox it will probably not work. To do it you can use dx=0 on its own
Level=
Very simple, targets entities based on experience level, you can use 2 dots here as well
Gamemode=
Selects players based off of their gamemode, can only put stuff like 'creative', you and also use gamemode=!
Name=
Targets players with specific names, you can also use name=!
I use this to make sure no one cheats on my maps, since they are supposed to be on adventure mode, I pretty much put in tick.mcfunction : gamemode adventure @a[name=!geosivridis] : I can also add more name=! if im working with other people
X_rotation= and y_rotation=
Targets entities depending on where they look, can use 2 dots for this. X targets where we look up or down, Y targets if we look east, west etc
Nbt=
This targets entities with specific nbt data, so for example to target arrows that are on the ground we have @e[type=arrow, nbt={inGround:1b}]
Advancements=
Targets players with an advancement @a[advancements={story/smelt_iron=true}]
Predicate=
Targets players with a specific predicate (true or false statement), can use predicate=! ,more on predicates another time
Day 13
/gamerule
Simple command, but I thought I would mention some gamerules that are nice for map making.
command_block_output: This can stop the chat message you get every time a command runs in a command block (which by the way only operators can see it)
show_advancement_messages: Useful for not wanting advancements in chat, and also for death messages show_death_messages
block_drops: If items drop off of broken blocks
entity_drops and mob_drops: one for entities and other for mobs if they drop items
command_blocks_work: Can disable and enable command blocks
max_block_modifications: oh my god, I didn't know this existed, this removes the limit for the /fill and /clone command which use to be 32 thousand YES
tnt_explodes: disables and enables tnt
forgive_dead_players: this makes mobs around the player who died not angry anymore
max_entity_cramming: can extend the limit of how many mobs can fit in one block without suffocating
raids: disables and enables raids
universal_anger: angered netural mobs attack every player and not just their attacker
allow_entering_nether_using_portals: disables nether
drowning_damage, fall_damage, freeze_damage, fire_damage: disables damage for players
ender_pearls_vanish_on_death: enderpearls dissapearing if you die, this can kind of disable teleport chambers
fire_spread_radius_around_player: how far fire can spread, 0 to disable, -1 for unlimited range
immediate_respawn: respawns without the screen
keep_inventory: keeps inventory after dying
limited_crafting: allows player to craft only what they unlocked in recipe book
locator_bar: disables the locator bar
natural_health_regeneration: stops healing from food
pvp: enables players fighting or not
spawn_mobs, spawn_monsters, spawn_phantoms, spawn_wandering_traders, spawn_patrols, spawn_wardens: disables mobs spawning
spawner_block_works: disables spawners
advance_time, advance_weather: stops time and weather cycle
random_tick_speed: how fast the game progresses (such as plants growing)
showtags: shows tags such is "can place on" or "can destroy", useful for adventure maps with adventure mode items
When making minecraft maps
Originally, I was confused as to how /setworldspawn work, and some of my older maps might be broken from that, so instead of doing that you can do one simple fix. What we are going to do is basically have 2 commands in tick.mcfuction or repeating command block. The first one teleports any player who does not have the tag 'inside' to the place where they are supposed to spawn /tp @a[tag=!inside] ~ ~ ~ : and the second one adds a tag of 'inside' to any player who is in that room /tag @a[x=, y=, z= etc] add inside : so now we don't have to worry about players being outside of bounds
Remember that the most lag is made by commands who check nbt data, so if you are using them try not to over use them, like in a repeating way
Day 14
By the way thank you so much for all the support, I did not expect this blog to be trending
Anyways, today I thought I would show some useful scoreboard tips
Scoreboard criteria
I didn't fully cover them all so lets do that
dummy: old reliable, just a normal scoreboard objective
trigger: objective that goes up with command, you can type it once to add 1 or add and set it to whatever number you want, you can use /trigger set : to make commands that the player can input numbers
deathCount: counts deaths, totalKillCount: counts mob and player kills, playerKillCount: counts only player kills
health*: counts health the player has including extra health and absorption, xp*: counts experience points, level*: counts experience levels, food*: counts food level 0-20, air*: how much time a player has when about to drown 300 max, armor*: how much armor player has. The ones with a star * mean they cannot be modified, and also players may show up as 0 in a scoreboard unless their number changes
minecraft.mined:minecraft.<block>: Counts how many times a player broke a block
minecraft.broken:minecraft.<item>: Counts how many times a player broke an item, only applies to items with durability
minecraft.crafted:minecraft.<item>: Counts how many times a player crafted an item, only applies to craftable items
minecraft.used:minecraft.<item>: Counts how many times a player used an item
minecraft.picked_up:minecraft.<item>: Counts how many times a player picked up an item
minecraft.dropped:minecraft.<item>: Counts how many times a player dropped an item
minecraft.killed:minecraft.<entity>: Counts how many times player killed an entity
minecraft.killed_by:minecraft.<entity>: Counts how many times player died from an entity
These are made for specific items only, so if you wanted to count how many times you break every wool, you would need 16 objectives for each color
And the best for last, minecraft.custom:minecraft.<criteria>: now here is a list of all custom criteria
animals_bred, clean_armor-banner-shulker_box (for when you undye leather armor), open_barrel-chest-enderchest-shulker_box, bell_ring, eat_cake_slice, fill_cauldron, damage_absorbed (damage is counted in 1/10ths of one health), damage_blocked_by_shield, damage_dealt, damage_dealt_absorbed, damage_dealth_resisted, damage_taken, inspect_dispenser-dropper-hopper
anything with _one_cm is counting distance in centimeters including: climb, crouch, fall, fly, walk, swim, sprint, walk on water, walk under water, boat, horse, happy ghast, aviate (elytra), pig, nautilus, minecart
leave_game
Day 15
/random
This is a pretty recent command as it was added right before I left PMC, you can use it to generate random numbers from a range of numbers, and apparently control random sequences in the world, though I don't really know how to use the sequence part, its related to loot tables which I haven't really researched much yet
To generate a random number type /random <value or roll> <range> : the range is again using the 2 dots so 1..10 would be 1 to 10, value or roll do about the same thing, except roll broadcasts the result to every player, so I recommend using value. On its own we can't use it so we have to store it with /execute store, I will store it on a scoreboard /execute store result score <name> <objective> run random value 1..10
There is also /random reset but that is used for sequences
/return
This is a good one, I got so excited when I heard about this recently. This command is used in datapack functions, what it does is if it runs it stops the function, its a game changer
You simply have 'return run' and 'return fail'. Run works like /execute run and runs a command, fail however does not do anything, and also returns 0 if we /execute store our function command
Its an actual game changer, things can be done a lot simpler. For example, one issue I had was using a button to toggle something on and off. The point was if you press it once you get a message, a sound, and a scoreboard change, and twice would change those slightly, but when you run the same function it runs everything, but with return it stops at that point and does not run any other command under it
Day 16
[style b size=18px color=#3598db]Datapack tags
[style size=16px color=#3598db]Here is one thing that is pretty simple and very useful in datapack, tags. Tags are pretty much used to categorize different things in one command. Let me give you my example. For one of my projects I needed to /clear every same type of item from a players inventory, for example every dyed glass, for other blo
15 Update Logs
Update #15 : by orp888 09/09/2026 7:18:14 amSeptember 9 @ 11:18 am UTC
Added datapack tags
LOAD MORE LOGS
More like this
7022138
6



Have something to say?
Thanks for the information.