I was wondering if there is a way to make a chain of command blocks for an idea me and friends thought of.
Since me and friends are playing on a realm where we can't input a plugin here if you kill a player, they will drop their head
So, we thought that there would be a way to make command blocks have commands where, "if (any player) kills (player A), then at (player A's death location), summon (player A's head)"
However, the problem is, we don't really know much about command blocks and how the commands work because they changed the way the syntax is and what not.... Is there a way to make it for 1.19.3, the latest version?
I'm also wondering if there's a way for, instead of making a command block for every single player in the server/realm, there's a way to make it where we can group those players in a category to where the command would go to something like:
"
team1 = playerA, playerB, playerC, playerD
if playerA(team1) get killed by (anyone in team1) = playerA(team1) drops playerA(head)
This is possible using loot tables, as we can ask those to insert a player's name into a player head's NBT. We first add a datapack to our world and in it add a folder called 'loot_tables', just like the folder 'functions'. In it we add a new loot_table file. You can give it any name you want, I went with drop_player_head.json. The file looks like this:
What this will do is it will set the loot to a player head and then fill the player head's SkullOwner NBT with the name of the entity who ran the loot function. We can then use this command to drop the head of any player at their position:
/execute as JohnDoe54 at @s run loot spawn ~ ~ ~ loot MyEpicDatapack:drop_player_head
Now for the part about doing this when a player is killed. It's quite difficult (without plugins or mods) to run a function accurately when a player is killed specifically by another player, but it is easy to do this when they die to anything, which could include another player. You could simply toggle this function on or off when the player is in or out of PVP to make it work properly.
We first add a scoreboard that tracks the deathCount for every player:
/scoreboard objectives add Deaths deathcount
Then we detect if this value goes up for a player, in which case we run the loot command to drop the head and reset the counter. This following code has to be ran every tick, so use the datapack's built-in tick function to do this.
execute as @a at @s if score @s Deaths matches 1.. run loot spawn ~ ~ ~ loot MyEpicDatapack:drop_player_head
scoreboard players reset @a Deaths
This should make a player drop their own head when they die.
I was wondering if there is a way to make a chain of command blocks for an idea me and friends thought of.
Since me and friends are playing on a realm where we can't input a plugin here if you kill a player, they will drop their head
So, we thought that there would be a way to make command blocks have commands where, "if (any player) kills (player A), then at (player A's death location), summon (player A's head)"
However, the problem is, we don't really know much about command blocks and how the commands work because they changed the way the syntax is and what not.... Is there a way to make it for 1.19.3, the latest version?
I'm also wondering if there's a way for, instead of making a command block for every single player in the server/realm, there's a way to make it where we can group those players in a category to where the command would go to something like:
"
team1 = playerA, playerB, playerC, playerD
if playerA(team1) get killed by (anyone in team1) = playerA(team1) drops playerA(head)
"
This is possible using loot tables, as we can ask those to insert a player's name into a player head's NBT. We first add a datapack to our world and in it add a folder called 'loot_tables', just like the folder 'functions'. In it we add a new loot_table file. You can give it any name you want, I went with drop_player_head.json. The file looks like this:
What this will do is it will set the loot to a player head and then fill the player head's SkullOwner NBT with the name of the entity who ran the loot function. We can then use this command to drop the head of any player at their position:
Now for the part about doing this when a player is killed. It's quite difficult (without plugins or mods) to run a function accurately when a player is killed specifically by another player, but it is easy to do this when they die to anything, which could include another player. You could simply toggle this function on or off when the player is in or out of PVP to make it work properly.
We first add a scoreboard that tracks the deathCount for every player:
Then we detect if this value goes up for a player, in which case we run the loot command to drop the head and reset the counter. This following code has to be ran every tick, so use the datapack's built-in tick function to do this.
This should make a player drop their own head when they die.
Command FAQ
Minecraft Randomizer DataPack (by Me)