Unknown or incomplete url. See below for error at <--[HERE]
+
+
+
If you encounter any issues or think this is an error, you can create a GitHub issue.
+
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 00000000..03dc024f
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,48 @@
+# Contributing
+
+ - [Codeblocks and Details](#codeblocks-and-details)
+ - [Table of contents](#table-of-contents)
+ - [Article names](#article-names)
+
+## Codeblocks and Details
+
+When typing code longer than several lines and in order to prevent cluttering the article with commands/json wrap your code into an HTML `details` tag, that will result into previewing it like this:
+
+
+ See commands
+
+```mcfunction
+# Command blocks
+say this is a command
+```
+
+
+This is acomplished by typing this
+
+````html
+
+ See commands
+
+```mcfunction
+# Command blocks
+say this is a command
+```
+
+````
+
+## Table of contents
+
+Below the title of each new article add a table of contents, like how it's done in every article for better navigation. For example:
+
+```markdown
+ - [Java](#java)
+ - [Target selector](#target-selector)
+ - [Predicate](#predicate)
+ - [Bedrock](#bedrock)
+ - [Commands](#commands)
+ - [Behavior Packs](#behavior-packs)
+```
+
+## Article names
+
+Keep the article names all lowercase without any separator between worlds, like how it's done in all existing articles.
\ No newline at end of file
diff --git a/_config.yml b/_config.yml
index d28cda25..f8edbbcf 100644
--- a/_config.yml
+++ b/_config.yml
@@ -9,6 +9,5 @@ include:
- LICENSE.md
- COPYING.md
- CODE_OF_CONDUCT.md
- - CONTRIBUTING.md
- ISSUE_TEMPLATE.md
- PULL_REQUEST_TEMPLATE.md
\ No newline at end of file
diff --git a/_includes/head-custom.html b/_includes/head-custom.html
new file mode 100644
index 00000000..138ecceb
--- /dev/null
+++ b/_includes/head-custom.html
@@ -0,0 +1,126 @@
+
+
+
+
\ No newline at end of file
diff --git a/debugging.md b/debugging.md
index a73ca1fc..286dacba 100644
--- a/debugging.md
+++ b/debugging.md
@@ -22,7 +22,7 @@ This page details information on common problems you might have with a command,
* Check for a space at the end of the command, command should **not** end with a space
* Don't miss out arguments. Common ones to forget are:
* The coordinates before the NBT data in `/summon`
- * The coordinates before the command in `/execute`
+ * The coordinates before the command in old `/execute`
* The old block handling mode (replace, keep, etc.) before NBT data in `/setblock` or `/fill`
* The block state/datavalue in `/setblock`, `/execute if block` (or in pre-1.13 `/execute ~ ~ ~ detect`) or `/fill`
* Watch out for `โsmart quotesโ` that word processors might auto-add, only `"normal quotes"` will work. You should use a plain plain text editor (Notepad, Notepad++, Sublime, Code), **not** a word processor or rich text editor (Microsoft Word, Wordpad, Textedit)
@@ -32,7 +32,7 @@ This page details information on common problems you might have with a command,
* `/execute run command` instead of `/command`, no longer works, as `execute` can run plugin commands
* If you have any mods, try vanilla to see if the mod is causing the problem. Even mods like Optifine can cause issues
* Make sure you don't have a mod that dissables command blocks or functions
-* Make sure command blocks are enabled in `server.properties`
+* Make sure command blocks are enabled in `server.properties` for pre-1.21.11 or the gamerule for bedrock and 1.21.11+ java
* When using tutorials or [online generators](/wiki/resources) make sure that are for the correct edition (java or bedrock) and version (1.12, 1.17, 1.20...)
* Check if the command block is in a loaded chunk, you can use the [`/forceload`](https://minecraft.wiki/w/Commands/forceload) command in Java or the [`/tickingarea`](https://minecraft.wiki/w/Commands/tickingarea) command in Bedrock to force a chunk to be always loaded
* Maybe you set the command to conditional accidentaly and it should be uncoditional, double check that
@@ -44,7 +44,7 @@ This page details information on common problems you might have with a command,
* Or viceversa, using 1.13+ execute in pre-1.13
* The same goes for bedrock new execute
* Command blocks can only run commands of level permission of 1 or 2
- * The can **not** ban, kick or deop, for example
+ * They can **not** ban, kick, deop or use `tick`, for example
* Make sure you are **not** using item components in pre-1.20.5 or item `nbt` in 1.20.5+
## Functions
@@ -61,7 +61,7 @@ This page details information on common problems you might have with a command,
* Don't forget to save changes if editing directly the datapack (with programs like VScode), normally `ctrl+s` (Windows/Lunix) or `cmd+s` (Mac)
* Don't forget to use `/reload` to reload the functions after making changes
* Make sure you have the datapack enabled. You can enable the datapack by typing `/datapack enable ""`
- * When edition world generation you need to leave and rejoin the world in order to save changes (or restart the server).
+ * When edition world generation and other experimental features you need to leave and rejoin the world in order to save changes (or restart the server).
* Check that you're saving to the place you think you're saving to (right world, right namespace), and running the function you intend to
* Recursive/looping functions will run `maxCommandChainLength` commands in one tick, then stop, the default value of this gamerule is `65536`
* To check if a function did **not** end (so it has been cut off by this gamerule) you can set a scoreboard value of a [fakeplayer](wiki/questions/fakeplayer) to 1, run all commands and set it to 0 after that (that command should be the last one in the whole tick). In the next tick you can check if the value is 1 or 0, if its 1, the function has been cutted.
@@ -104,7 +104,7 @@ This page details information on common problems you might have with a command,
* Be careful with commands like: `/execute at @a[tag=x] run kill @p`
* If any player has the tag, they'll kill themself, then kill the next nearest player (as `@p` no longer select them), then the next nearest, etc., despite only one player having the tag
* `@s` can be used instead to select themself even if they're dead: `/execute as @a[tag=x] run kill @s`
-* `as` and `at` have a diference in [command context](/wiki/questions/commandcontext). `as` change the executor entity and `at` changes the position.
+* `as` and `at` have a diference in [command context](/wiki/questions/commandcontext). `as` changes the executor entity and `at` changes the position.
* Scheduled functions will lose the context
* Some commands like `/data` or `/damage` in Java edition can only select one target
* The command `/data merge entity @e[type=armor_stand] {Invisible:1b}` will **not** work
@@ -126,7 +126,7 @@ This page details information on common problems you might have with a command,
* Item data from `/item` or `/give` is put in [the item's `tag` tag](http://minecraft.wiki/Player.dat_format#Item_structure), not directly in the item's root compound tag
* Minecraft generally won't "fix" data inside an item's `tag` tag; if you give an item with `{ench:[{id:10,lvl:1}]}`, `id` and `lvl` will stay (and need to be tested) as integers, even though they're normally shorts
* A dropped item entity stores its item data [in an `Item` compound tag](http://minecraft.wiki/Chunk_format#Items_and_XPOrbs), not directly in the entity's root compound tag
-* If you need to include quotes in a string, you'll need to "escape" them by putting \ in front of them. E.G: `{Command:"/say My name is \"\"!"}`
+* If you need to include quotes in a string, you'll need to ["escape"](/wiki/escaping) them by putting \ in front of them. E.G: `{Command:"/say My name is \"\"!"}`
* If you need to escape a second level, you need to escape both the quotes and the previous backslash E.G: `{Command:"/setblock ~ ~ ~ wall_sign 0 replace {Text1:\"{\\\"text\\\":\\\"hello!\\\"}\"}"}`
* [Generators are handy](https://mcstacker.com) you can find some in the [Java resources page](/wiki/resources) or in the [Bedrock resources page](/wiki/bcresources)
* Text editors like [Notepad++](http://i.imgur.com/7XnrEJP.png) can highlight pairs of brackets, helping you put tags in the right place and keep brackets balanced
diff --git a/oldresources.md b/oldresources.md
index 6c74cffb..9d71124e 100644
--- a/oldresources.md
+++ b/oldresources.md
@@ -10,7 +10,7 @@
- [Commands](#commands)
- [Utilities](#utilities)
- [References](#references)
- - [Loot tables (& predicates)](#loot-tables-predicates)
+ - [Loot tables (& predicates)](#loot-tables--predicates)
- [Utilities](#utilities)
- [References](#references)
- [Functions](#functions)
diff --git a/questions.md b/questions.md
index 9f180a41..b771de1e 100644
--- a/questions.md
+++ b/questions.md
@@ -5,7 +5,7 @@
Because in 1.19.50, the [new execute syntax](https://learn.microsoft.com/en-us/minecraft/creator/documents/commandsnewexecute) became mandatory, so you'll need to switch to that. See also [this information on bedrock.dev](https://wiki.bedrock.dev/commands/new-execute.html).
## Why is my give command broken (java)?
-In 1.20.5, unstructured NBT for item stacks (tag field) was replaced with structured "components." Learn more in [this article](https://minecraft.wiki/w/Item_format/1.20.5).
+In 1.20.5, unstructured NBT for item stacks (tag field) was replaced with structured "components". Learn more in [this article](https://minecraft.wiki/w/Item_format/1.20.5).
## How do I...
@@ -18,7 +18,7 @@ In 1.20.5, unstructured NBT for item stacks (tag field) was replaced with struct
[Give a special item (Bedrock)?](/wiki/questions/giveitembedrock)
[Change an item while it's in the players inventory?](/wiki/questions/modifyinventory)
[Do custom crafting?](/wiki/questions/customcrafting)
-[Make a shop? / Buy items?](/wiki/questions/shop)
+[Make a shop? / Buy items?](/wiki/questions/shop)
### Scores
@@ -41,6 +41,7 @@ In 1.20.5, unstructured NBT for item stacks (tag field) was replaced with struct
[Detect a player joining (for the first time)?](/wiki/questions/playerjoin)
[Store a players inventory (and give it back later)?](/wiki/questions/storeinventory)
[Detect a player looking at something (entity / position)?](/wiki/questions/lookat)
+[Detect the player moving?](/wiki/questions/moving)
### Conditions
@@ -55,7 +56,7 @@ In 1.20.5, unstructured NBT for item stacks (tag field) was replaced with struct
[Summon an entity/projectile flying in the direction the player is looking?](/wiki/questions/shootfacing)
[Detect when a mob has died](/wiki/questions/mobdeaths)
[Make hostile mobs friendly / disable PvP?](/wiki/questions/hostilefriendly)
-[Setup, configure and add multiple dialogues to NPCs?](/wiki/questions/npc)
+[Setup, configure and add multiple dialogues to NPCs?](/wiki/questions/npc)
### Misc
@@ -64,6 +65,7 @@ In 1.20.5, unstructured NBT for item stacks (tag field) was replaced with struct
[Make a scoreboard ID system?](/wiki/questions/linkentity)
[Do raycasting?](/wiki/questions/raycast)
[Make a circle (of blocks / entities)?](/wiki/questions/makecircle)
+[Add custom commands](/wik/questions/customcommands)
## What is...
diff --git a/questions/amountitems.md b/questions/amountitems.md
index b9b3bf7e..0b3e76a9 100644
--- a/questions/amountitems.md
+++ b/questions/amountitems.md
@@ -28,7 +28,7 @@ execute if score @s diamonds matches ..20 run say I have 20 or less diamonds in
Since version 1.20.5, you can also use [`execute if items`](https://minecraft.wiki/w/Commands/execute#(if%7Cunless)_items) to count the number of items.
-The `if items` subcommand, when executed, returns the number of items that meet the specified conditions. For a quick example, running this command will show the count of all items in the player's inventory (except for armor and left hand slots):
+The `if items` subcommand, when executed, returns the number of items that meet the specified conditions. For a quick example, running this command will show the count of all items in the player's inventory (except for armor and offhand slots):
```mcfunction
# In chat
@@ -41,7 +41,7 @@ Below is an example for getting the amount of a custom item and executing some c
```mcfunction
# Example item
-give @s diamond[minecraft:custom_data={diamond:true},minecraft:item_name="'Custom Diamond'"]
+give @s diamond[custom_data={diamond:true},item_name="'Custom Diamond'"]
# Command blocks
execute as @a store result score @s diamonds if items entity @s container.* *[custom_data~{diamond:true}]
diff --git a/questions/angermob.md b/questions/angermob.md
index dc554316..c8a2976f 100644
--- a/questions/angermob.md
+++ b/questions/angermob.md
@@ -62,9 +62,9 @@ In the following example a skeleton tagged `attacker` is tricked into attacking
```mcfunction
# summon the snowball
-execute at @e[type=skeleton,tag=attacker] run summon minecraft:snowball ~ ~2.3 ~ {Tags:["atk_target"]}
+execute at @e[type=skeleton,tag=attacker] run summon snowball ~ ~2.3 ~ {Tags:["atk_target"]}
# make the snowball owner the zombie
-execute as @e[type=minecraft:snowball,tag=atk_target] run data modify entity @s Owner set from entity @e[type=zombie,limit=1,tag=target] UUID
+execute as @e[type=snowball,tag=atk_target] run data modify entity @s Owner set from entity @e[type=zombie,limit=1,tag=target] UUID
```
## Bedrock
diff --git a/questions/areas.md b/questions/areas.md
index 30a51a0c..19c13c9a 100644
--- a/questions/areas.md
+++ b/questions/areas.md
@@ -1,11 +1,44 @@
# Do something if a player is in certain areas
- [Do something if a player is in certain areas](#do-something-if-a-player-is-in-certain-areas)
+ - [Singe area](#singe-area)
+ - [Sphere selection](#sphere-selection)
+ - [Cubic selection](#cubic-selection)
+ - [Predicates](#predicates)
- [Hardcoded locations](#hardcoded-locations)
- [Anchor entities](#anchor-entities)
- [Block layer](#block-layer)
- [Predicates](#predicates)
+## Singe area
+### Sphere selection
+Selects players in a radius. x y z define the center, `distance` the radius.
+Java: `@a[x=0,y=90,z=0,distance=..6]` selects players up to 6 blocks away.
+`..a` = a or less, `a..` = a or more, `a..b` = between a and b.
+Bedrock uses `r` (max) and `rm` (min) instead of distance.d
+Uses the entity position (center of feet).
+
+### Cubic selection
+Selects players in a box. `x y z` define the origin, `dx dy dz` define the size.
+`dx dy dz` add `+1` on each axis (e.g. `x=37,dx=10` โ `37 to 48`).
+Checks any part of the hitbox, so heads can count
+
+### Predicates
+You can select entities using a `location_check` predicate.
+```
+{
+ "condition": "minecraft:location_check",
+ "predicate": {
+ "position": {
+ "x": {
+ "min": 38.2,
+ "max": 41.7
+ }
+ }
+ }
+}
+```
+Unlike the `dx dy dz` arguments, this does not check for an entity's hitbox but for its position.
| ๐ Note |
|---------|
@@ -82,7 +115,7 @@ For example, you want to create an area on your map where the player will be det
```mcfunction
# Command block / tick function (1.20.5+)
-execute as @a at @s if predicate {condition:"entity_properties",entity:"this",predicate:{flags:{is_sneaking:false}}} if block ~ -63 ~ minecraft:red_concrete run say You have been found!
+execute as @a at @s if predicate {condition:"entity_properties",entity:"this",predicate:{flags:{is_sneaking:false}}} if block ~ -63 ~ red_concrete run say You have been found!
```
## Predicates
diff --git a/questions/blockdelay.md b/questions/blockdelay.md
index 1c44b19f..c5dd0066 100644
--- a/questions/blockdelay.md
+++ b/questions/blockdelay.md
@@ -10,6 +10,7 @@
- [Schedule](#schedule)
- [Success Count](#success-count)
- [Command block minecart](#command-block-minecart)
+ - [`time_check` predicate](#time_check-predicate)
- [Falling blocks or entities](#falling-blocks-or-entities)
## Bedrock
@@ -233,7 +234,18 @@ These cause no block updates and require no entities or scoreboard objectives, b
### Command block minecart
-The entity [`command_block_minecart`](https://minecraft.wiki/w/Minecart_with_Command_Block) execute the written command every 4 ticks. Keep in mind that people can break the minecart (but it will **not** drop the command block).
+The entity [`command_block_minecart`](https://minecraft.wiki/w/Minecart_with_Command_Block) executes the written command every 4 ticks. Keep in mind that people can break the minecart (but it will **not** drop the command block).
+
+### `time_check` predicate
+If the gamerule `advance_time`/`doDayLightCycle` is set to `true` you can check for a value in a specific period. In the below example, the predicate suceeds every 5 seconds.
+
+```json
+{
+ "condition": "minecraft:time_check",
+ "value": 1,
+ "period": 100
+}
+```
### Falling blocks or entities
Other methods such as a falling block clock exist and can be convenient, but cause block updates, lighting updates, and requires an entity.
diff --git a/questions/blockinvert.md b/questions/blockinvert.md
index fa40ab81..5aa17f72 100644
--- a/questions/blockinvert.md
+++ b/questions/blockinvert.md
@@ -40,4 +40,8 @@ The third command is conditional, and is whatever you want to happen when the fi
## Bedrock
-Because we can't access the `SuccessCount` in bedrock we will need to use a comparator pointing into a block that has a wall redstone torch to invert the output. Keep in mind that redstone is not run every tick.
\ No newline at end of file
+Because we can't access the `SuccessCount` in bedrock we will need to use a comparator pointing into a block that has a wall redstone torch to invert the output. Keep in mind that redstone is not run every tick. For `if` conditions we can use `unless` instead. For example
+
+```mcfunction
+execute unless entity @e[r=5] run say Nobody is within 5 blocks!
+```
\ No newline at end of file
diff --git a/questions/changeofscore.md b/questions/changeofscore.md
index 1745f464..8a39d44c 100644
--- a/questions/changeofscore.md
+++ b/questions/changeofscore.md
@@ -15,13 +15,13 @@ If you are changing the score yourself, it is generally advised to also do the e
This is the more commonly used method, because in many use cases it's not important to know the total score, just that the score changed. It is generally used for [item click detection](/wiki/questions/itemclick), [player deaths](/wiki/questions/playerdeaths) in minigames and more and involves resetting the score back to 0 once it has been changed.
_Some objective types are read-only, such as Health or Hunger. Those won't work for this method._
-So lets assume you have a score that detects a player's death and want to do something with that player every time they die once.
+So let's assume you have a score that detects a player's death and want to do something with that player every time they die once.
```mcfunction
execute as @a[scores={deaths=1..}] run say I died :(
scoreboard players reset @a[scores={dead=1..}] deaths
```
-You can either `set` the score back to 0, or `reset` the score, whichever one fits your system better. In most cases either one will work fine.
+You can either `set` the score back to 0, or `reset` the score, whichever one fits your system better. In most cases, either one will work fine.
## The non-destructive method
@@ -42,4 +42,4 @@ execute as @a if score @s health > @s health.tmp run say My health has increased
execute as @a run scoreboard players operation @s health.tmp = @s health
```
-The first command detects if the health is not the same as the value in the last tick and the second and third command detects if the value incremented or decreased. The last command updates the `health.tpm` scoreboard to be the same as the current health.
+The first command detects if the health is not the same as the value in the last tick, and the second and third command detects if the value incremented or decreased. The last command updates the `health.tpm` scoreboard to be the same as the current health.
diff --git a/questions/commandcontext.md b/questions/commandcontext.md
index 63b63fa9..3e3143d0 100644
--- a/questions/commandcontext.md
+++ b/questions/commandcontext.md
@@ -14,7 +14,11 @@ This context is first set when the command is run and consists of multiple parts
All of which can be modified individually with the 1.13+ Java as well as 1.19.1+ Bedrock execute command.
-See [the Minecraft wiki on the execute command](https://minecraft.wiki/wiki/Commands/execute) for which subcommands modify which context.
+See [the Minecraft wiki on the `execute` command](https://minecraft.wiki/wiki/Commands/execute) for which subcommands modify which context. The most used are:
+- `at`: changes the execution position to be the one of an entity.
+- `as`: changes the executing entity, this is useful to run a function afterward so we don't need to retarget the same entity.
+- `in`: changes dimension.
+- `positioned`: changes the execution position, allows global, relative (`~ ~ ~`) or directional (`^ ^ ^`) coordinates.
## Defaults
diff --git a/questions/compasstoplayer.md b/questions/compasstoplayer.md
index 48f5da0a..4581cf59 100644
--- a/questions/compasstoplayer.md
+++ b/questions/compasstoplayer.md
@@ -6,7 +6,7 @@
## Java and Bedrock
-Since the compass will always point to the worldspawnpoint, your only option is to move the worldspawn to the player you want to point the compass towards. **This means it can only point to one player at a time and the pointing is global, meaning everyone sees the same compass pointing.**
+Since the compass will always point to the world spawnpoint, your only option is to move the worldspawn to the player you want to point the compass towards. **This means it can only point to one player at a time and the pointing is global, meaning everyone sees the same compass pointing.**
**Java & Bedrock syntax:**
@@ -17,7 +17,69 @@ execute at @p[] run setworldspawn ~ ~ ~
| ๐ Note |
|---------|
|If a player dies, they will respawn at the world spawn (unless they have an individual spawn set), which this method is moving around|
-|To avoid this issue, you need to detect when the players respawns to then teleport them to the intended respawn point. In Java edition you can use the scoreboard criteria `custom:time_since_last_death` but in bedrock you will need [a more complex way](https://wiki.bedrock.dev/commands/on-player-death)|
+|To avoid this issue, you need to detect when the players respawn to then teleport them to the intended respawn point. In Java edition you can use the scoreboard criteria `custom:time_since_last_death` but in bedrock you will need [a more complex way](https://wiki.bedrock.dev/commands/on-player-death)|
+
+## 1.17+ (Java only)
+
+In 1.17 we got [item modifiers](https://minecraft.wiki/wiki/Item_modifier), which allow us to modify an item live while it's in the player's inventory, no need to drop it on the floor anymore (if you know which slot it is in).
+
+In this case you follow the process of the 1.16 section below, but instead of storing it into an item entity, you for example store it into the [command storage](https://minecraft.wiki/wiki/Commands/data#Storage) and then use the `copy_nbt` function in the item modifier to copy that data to the item or `set_components` with a macro for 1.20.5+.
+
+In order to do this, we have an advancement of `location` trigger (for performance reasons, to not update the compass each tick) and with the condition of the player having in either weapon hand the custom compass.
+This rewards a function that will revoke the advancement and copy the data of the nearest player with the `target` tag (which is not the one holding the compass) to a storage for future use. Then from this storage we store in a separate one (the macro one) the values we care, `Pos[0]` (x), `Pos[2]` (y), `Dimension` and the hand we are holding the compass with (either `mainhand` or `offhand`).
+We store the data of the player in a separate storage first instead of storing only the data we care directly into the storage because of performance reasons, `data get storage` is better than `data get entity` so we try to minimize the use of the last one.
+Lastly, we run a macro function that is an item modifier that will modify the weapon hand we stored in a macro and will insert the correct values for `x`, `z` and dimension.
+
+
+ See datapack (1.20.5+)
+
+```json
+# advancement example:compasstoplayer/location
+{
+ "criteria": {
+ "criteria": {
+ "trigger": "minecraft:location",
+ "conditions": {
+ "player": {
+ "slots": {
+ "weapon.*": {
+ "predicates": {
+ "minecraft:custom_data": "{compasstoplayer:true}"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "rewards": {
+ "function": "example:compasstoplayer/update_position"
+ }
+}
+```
+```mcfunction
+# function example:compasstoplayer/get_otem
+give @s compass[custom_data={compasstoplayer:true}]
+
+## Use this function to get the compass tracker
+## Note: add the tag "target" to the player that you want to point with the compass
+
+# function example:compasstoplayer/update_position
+advancement revoke @s only example:compasstoplayer/location
+data modify storage example:data compasstoplayer set from entity @p[distance=0.1..,tag=target]
+execute store result storage example:macro compasstoplayer.x int 1 run data get storage example:data player.Pos[0]
+execute store result storage example:macro compasstoplayer.z int 1 run data get storage example:data player.Pos[2]
+data modify storage example:macro compasstoplayer.dimension set from storage example:data player.Dimension
+execute if items entity @s weapon.offhand *[custom_data~{compasstoplayer:true}] run data modify storage example:macro compasstoplayer.weapon set value "offhand"
+execute if items entity @s weapon.offhand *[custom_data~{compasstoplayer:true}] run data modify storage example:macro compasstoplayer.weapon set value "mainhand"
+function example:compasstoplayer/lodestone_update with storage example:macro lodestone
+
+# function example:compasstoplayer/lodestone_update
+$item modify entity @s weapon.$(weapon) {function:"minecraft:set_components",components:{"minecraft:lodestone_tracker":{target:{dimension:"$(dimension)",pos:[$(x),0,$(z)]},tracked:0b}}}
+```
+
+
+_Related: [Modify an item inside the player's inventory](/wiki/questions/modifyinventory)_
## 1.16+ (Java only)
@@ -29,7 +91,7 @@ The give command for such a compass which doesn't need a lodestone to work looks
/give @s compass{LodestoneTracked:0b,LodestonePos:{X:-460,Y:64,Z:-701},LodestoneDimension:"minecraft:overworld"}
```
-Now, using data merge we can modify those numbers dynamically. For example, lets say you want to drop the compass to make it point to the second-nearest player, assuming the nearest player is you. The commands for something like that could look like this (using the [custom item tag](/wiki/questions/customitemtag) `playertracker:1b` to identify such a compass):
+Now, using data merge, we can modify those numbers dynamically. For example, let's say you want to drop the compass to make it point to the second-nearest player, assuming the nearest player is you. The commands for something like that could look like this (using the [custom item tag](/wiki/questions/customitemtag) `playertracker:1b` to identify such a compass):
```mcfunction
# Command block / tick function
@@ -46,12 +108,4 @@ tag @a remove target
data modify entity @s PickupDelay set value 0s
```
-(this assumes that the original given compass has the relevant tags (`LodestoneDimension`, `LodestoneTracked`, `LodestonePos`) already set to initial/correct values, as well as the aforementioned custom tag.)
-
-## 1.17+ (Java only)
-
-In 1.17 we got [item modifiers](https://minecraft.wiki/wiki/Item_modifier), which allow us to modify an item live while it's in the players inventory, no need to drop it on the floor anymore (if you know which slot it is in).
-
-In this case you follow the process of the 1.16 section above, but instead of storing it into an item entity you for example store it into the [command storage](https://minecraft.wiki/wiki/Commands/data#Storage) and then use the `copy_nbt` function in the item modifier to copy that data to the item.
-
-_Related: [Modify an item inside the players inventory](/wiki/questions/modifyinventory)_
+(this assumes that the original given compass has the relevant tags (`LodestoneDimension`, `LodestoneTracked`, `LodestonePos`) already set to initial/correct values, as well as the aforementioned custom tag.)
\ No newline at end of file
diff --git a/questions/customcommands.md b/questions/customcommands.md
new file mode 100644
index 00000000..269fb43a
--- /dev/null
+++ b/questions/customcommands.md
@@ -0,0 +1,39 @@
+# How to make custom commands
+
+ - [Java](#java)
+ - [Trigger](#trigger)
+ - [Functions](#functions)
+ - [Bedrock](#bedrock)
+
+## Java
+### Trigger
+
+In the Java edition of the game, you can create scoreboard objectives with the `trigger` criteria, this scorebaord objective can be changed by non-operator players.
+
+```mcfunction
+scorebaord objectives add example_trigger trigger
+```
+
+This command changes a score, so we can run a command as any player with a score of 1 or above. After that, we reset the score so it does not trigger each tick. Last, we need to enable the objective, if the score is not enabled, players can not run the command.
+
+```mcfunction
+# Command blocks
+execute as @a[scores={example_trigger=1..}] run say I triggered the command
+scoreboard players reset @a example_trigger
+scoreboard players enable @a example_trigger
+```
+
+Any player that wants to run the command must type the `trigger` command in chat:
+
+```mcfunction
+/trigger example_trigger
+```
+
+It is possible to add multiple options to one command (like arguments) but it's limited to only 32 bit integers (without the 0, since it is the "default" state). You could perform one acation if the score is 1 and another action if it is 2 and so on.
+
+## Functions
+
+Functions could be considered custom commands, but only works for operator players. The adventage of them is that they can take macro arguments as inputs.
+
+## Bedrock
+For bedrock, check this detailed article for behavior packs https://wiki.bedrock.dev/scripting/custom-commands.
\ No newline at end of file
diff --git a/questions/customcrafting.md b/questions/customcrafting.md
index da6e5816..039eb2eb 100644
--- a/questions/customcrafting.md
+++ b/questions/customcrafting.md
@@ -301,7 +301,7 @@ Below is an example of how to implement this approach:
```mcfunction
# function example:recipe_reset
advancement revoke @s from example:recipe/root
-clear @s minecraft:knowledge_book
+clear @s knowledge_book
recipe take @s example:some_custom_result
recipe take @s example:another_custom_result
recipe take @s example:more_custom_result
@@ -396,7 +396,7 @@ Below is an example for creating an advancement for a custom craft, which must h
```mcfunction
# function example:recipe_reset
advancement revoke @s from example:recipe/root
-clear @s minecraft:knowledge_book
+clear @s knowledge_book
```
diff --git a/questions/customitemtag.md b/questions/customitemtag.md
index 124d22b0..6426671f 100644
--- a/questions/customitemtag.md
+++ b/questions/customitemtag.md
@@ -34,10 +34,10 @@ So, if you were to `give` an item like this:
```mcfunction
# 1.20.5 and above
-give @s minecraft:stick[minecraft:custom_data={my_custom_tag:true}]
+give @s stick[minecraft:custom_data={my_custom_tag:true}]
# 1.20.4 and below
-give @s minecraft:stick{my_custom_tag:true}
+give @s stick{my_custom_tag:true}
```
Or like this if you want to `summon` item:
diff --git a/questions/detectitem.md b/questions/detectitem.md
index 38848a04..00e3f686 100644
--- a/questions/detectitem.md
+++ b/questions/detectitem.md
@@ -36,10 +36,10 @@ Let's give a simple example of an item with a custom name and [custom tag](/wiki
```mcfunction
# 1.13 - 1.20.4
-give @s minecraft:stick{awesome_stick:true,display:{Name:'{"text":"Awesome Stick"}'}}
+give @s stick{awesome_stick:true,display:{Name:'{"text":"Awesome Stick"}'}}
# 1.20.5+
-give @s minecraft:stick[minecraft:custom_data={awesome_stick:true},minecraft:custom_name='"Awesome Stick"']
+give @s stick[custom_data={awesome_stick:true},custom_name='"Awesome Stick"']
```
**Important!** When you create any custom item that the player should not be able to obtain by renaming it at an anvil, always add a [custom tag](/wiki/questions/customitemtag) to your item. When checking the item, only check for the tag, not the item name, because checking the item name can cause problems with proper formatting and makes the command longer. All examples of check items below will be duplicated with checking the item name and checking the custom tag, if applicable.
@@ -129,7 +129,7 @@ if/unless items entity
An example for checking an item in almost any player slot:
```mcfunction
-execute as @a if items entity @s container.* minecraft:stick[minecraft:custom_data~{awesome_stick:true}]
+execute as @a if items entity @s container.* stick[custom_data~{awesome_stick:true}]
```
This will not include the offhand slot, armor slots and ender_chest slots, so it will require an additional command to check these slots or use a predicate in the datapack.
@@ -195,7 +195,7 @@ This will check every slot in a chest or any container and find all item stacks
To check for an item inside an item_frame, projectile or an item on the ground, use `container.0` or `contents` slot:
```mcfunction
-execute as @e[type=item] if items entity @s contents minecraft:stick[minecraft:custom_data~{awesome_stick:true}]
+execute as @e[type=item] if items entity @s contents stick[custom_data~{awesome_stick:true}]
```
### Predicate
@@ -390,7 +390,7 @@ Detecting a specific item on the ground involves using its name.
| ๐ Note |
|---------|
-|You can use a [special item tag](/wiki/questions/customitemtag#Bedrock) to differentiate it from other `Dirt` items, this method consists of changing the name with color codes, which can not be differentiate from the normal name|
+|You can use a [special item tag](/wiki/questions/customitemtag#bedrock) to differentiate it from other `Dirt` items, this method consists of changing the name with color codes, which can not be differentiate from the normal name|
```mcfunction
kill @e[type=item, name="ยงrยงDirt"]
diff --git a/questions/escaping.md b/questions/escaping.md
index deb86a63..99f1195e 100644
--- a/questions/escaping.md
+++ b/questions/escaping.md
@@ -8,7 +8,7 @@
- [Common errors](#common-errors)
## Introduction to Escaping
-Escaping is the process of marking special characters in a string to be interpreted literally rather than as part of a special syntax. Commands and JSON rely on precise syntax where unescaped characters can break the structure.
+Escaping is the process of marking special characters in a string to be interpreted literally rather than as part of a special syntax. Commands and JSON rely on precise syntax, where unescaped characters can break the structure.
Escaping prevents errors and ensures that commands or JSON structures function as intended. It is essential for handling characters like quotes (`"`) or backslashes (`\`) that are part of the syntax.
@@ -35,9 +35,9 @@ give @p command_block[block_entity_data={id:"command_block",Command:"setblock ~
The Command field is enclosed in quotes (Command:"..."), so the inner quotes within this string must be escaped.
-Inside the Command, the tellraw command also contains a string (tellraw @a "Hi"). To ensure "Hi" is treated literally, the quotes around it are escaped with a backslash (\").
+Inside the Command, the tellraw command also contains a string (tellraw @a "Hi"). To ensure "Hi" is treated literally, the quotes around it are escaped with a backslash (`\"`).
-Since this entire tellraw string is itself nested within another string, the escape characters (\") also need escaping. This is done by adding another layer of backslashes (\\\").
+Since this entire tellraw string is itself nested within another string, the escape characters (`\"`) also need escaping. This is done by adding another layer of backslashes (`\\\"`).
## Escaping in JSON Files
Escaping is also required in JSON files, such as for resource packs, advancements, or custom loot tables:
@@ -94,7 +94,7 @@ Mismatched Quotes:
/tellraw @a "Hi\"
```
-This quote must not be escaped as it defines the end of the string. The backslash must be removed to be interpreted correctly.
+This quote must not be escaped, as it defines the end of the string. The backslash must be removed to be interpreted correctly.
Not nesting strings:
diff --git a/questions/fakeplayer.md b/questions/fakeplayer.md
index d5ed5f47..99ea1f61 100644
--- a/questions/fakeplayer.md
+++ b/questions/fakeplayer.md
@@ -9,7 +9,7 @@ scoreboard players set 2 constant 2
It's generally used for storing constants (e.g., when you need to divide a number by 20, you need to store that somewhere), global variables (e.g., for settings in a datapack or map), or temporary variables, but can be used whenever it seems helpful.
-They can be used like any other selector, but only make sense when dealing with scoreboards, as those don't require the selected player to be online (which is impossible with a fake player). It is highly favored over storing values on a persistent entity, as for that entity you need an `@e` selector which is significantly more performance hungry than using a fake player. Additionally a single objective can hold an near infinite number of fake player scores, while only one score per real entity can be stored.
+They can be used like any other selector, but only make sense when dealing with scoreboards, as those don't require the selected player to be online (which is impossible with a fake player). It is highly favored over storing values on a persistent entity, as for that entity you need an `@e` selector, which is significantly more performance hungry than using a fake player. Additionally, a single objective can hold a near infinite number of fake player scores, while only one score per real entity can be stored.
## Special characters
@@ -21,4 +21,4 @@ It is recommended to use special characters inside the fake player names to prev
## Things to look out for
-When you use this method, if you're using something that could reasonably be an actual player name (like [`Max`](https://namemc.com/profile/Max.1)), and that player happens to be online at that time, you might run into conflicts. As such it is recommended to use those special characters to make sure no conflicts are possible or use separate scoreboard objectives for fake player scores and real player scores.
+When you use this method, if you're using something that could reasonably be an actual player name (like [`Max`](https://namemc.com/profile/Max.1)), and that player happens to be online at that time, you might run into conflicts. As such, it is recommended to use those special characters to make sure no conflicts are possible or use separate scoreboard objectives for fake player scores and real player scores.
diff --git a/questions/findsamescoreentity.md b/questions/findsamescoreentity.md
index 6df22926..a90bab42 100644
--- a/questions/findsamescoreentity.md
+++ b/questions/findsamescoreentity.md
@@ -27,7 +27,7 @@ This method works by changing the executor to all entities that need to be check
### Method 2: Store the score in a fake player first
-This method has the advantage over the first one that it only need to evaluate the selector for the special entity once, but it has the disadvantage that it needs 2 commands. ([what is a fake player?](/wiki/questions/fakeplayer))
+This method has the advantage over the first one that it only needs to evaluate the selector for the special entity once, but it has the disadvantage that it needs 2 commands. ([what is a fake player?](/wiki/questions/fakeplayer))
```mcfunction
scoreboard players operation #fakeplayer points = @e[tag=compare,limit=1] points
@@ -35,7 +35,7 @@ execute as @a if score @s points = #fakeplayer points run I have the same points
```
When using a datapack, you can use this method for your [Scoreboard ID system](/wiki/questions/linkentity).
-One command copies the `ID` score from the selected player to [fake player](/wiki/questions/fakeplayer) `#this ID` and the second adds the `this` tag to the selected entity, so that in the following commands you can simply select all entities except `this` entity. And after that you can easily select any entity that has the same `ID` score in any target selector. At the end of the function you need to remove `this` tag.
+One command copies the `ID` score from the selected player to [fake player](/wiki/questions/fakeplayer) `#this ID` and the second adds the `this` tag to the selected entity, so that in the following commands you can simply select all entities except `this` entity. And after that, you can easily select any entity that has the same `ID` score in any target selector. At the end of the function, you need to remove `this` tag.
Below is an example of a function and predicate that selects an entity with the same `ID` score as the selected player:
@@ -85,7 +85,7 @@ tag @s remove this
### Method 3: Keeping the context through location
-In this method we change the execution _location_ to be the player(s) and the execution _entity_ to be the entities to be compared to. That way `@p` is all the players respectively and `@s` is the entity to compare to. We can then get the player back into the execution chain using `@p`.
+In this method, we change the execution _location_ to be the player(s) and the execution _entity_ to be the entities to be compared to. That way, `@p` is all the players respectively and `@s` is the entity to compare to. We can then get the player back into the execution chain using `@p`.
```mcfunction
execute at @a as @e if score @s id = @p id run ...
@@ -97,7 +97,7 @@ execute at @a as @e if score @s id = @p id run ...
|---------|
|This method also works in bedrock before new execute|
-In bedrock this whole endeavor requires a few more commands, as execute doesn't have any subcommands like that and `/scoreboard players test` only allows for hardcoded ranges. Instead the way to go here is to remove the score from all the entities that need to be checked and then checking whether their score is 0.
+In bedrock before new `execute`, this whole endeavor requires a few more commands, as execute doesn't have any subcommands like that and `/scoreboard players test` only allows for hardcoded ranges. Instead the way to go here is to remove the score from all the entities that need to be checked and then checking whether their score is 0.
Again, we're assuming that the scoreboard objective you want to compare is called `points`, that we want to find any player with the same score, and that the entity to compare to is the only entity tagged with `compare`.
diff --git a/questions/functionconditions.md b/questions/functionconditions.md
index b552c8a2..f9d7e498 100644
--- a/questions/functionconditions.md
+++ b/questions/functionconditions.md
@@ -13,7 +13,7 @@
For example, you want to execute a command when `@a[tag=TeamChange]` finds something.
-Easiest way to do this is by prefixing the command with an `execute if entity`:
+The easiest way to do this is by prefixing the command with an `execute if entity`:
```mcfunction
execute if entity @a[tag=TeamChange,limit=1] run say test
diff --git a/questions/giveitembedrock.md b/questions/giveitembedrock.md
index 4da59499..e9a5fc66 100644
--- a/questions/giveitembedrock.md
+++ b/questions/giveitembedrock.md
@@ -9,12 +9,12 @@ This article is for **Bedrock only**, as Java can just use NBT or item component
Using `/give` on bedrock only works for "basic" items, without any alterations like change of names or enchantments.
+Thus, a different method needs to be followed, of which there are multiple common ones.
+
| ๐ Note |
|---------|
|You can use external programs (such as world editors or "hacks") to get custom items, that are impossible to get, such as items with impossible enchantments|
-Thus, a different method needs to be followed, of which there are multiple common ones.
-
## Loot Table
**_The best method currently available, but doesn't work for all kinds of custom entity data._**
@@ -28,9 +28,11 @@ Thanks to [loot table functions](https://wiki.bedrock.dev/loot/item-functions.ht
**_The best method currently available if you cannot use loot tables_**
+Throw the item(s) on top of a structure block, save the structure with entities (probably as a 1x1x1 sized structure) and disable saving blocks.
+
Same as the structure block method below, but instead of loading it with a structureblock and teleporting the item, you load it using the [`/structure`](https://minecraft.wiki/Commands/structure) command. It has the advantage over the block method that you don't need to worry about the whole redstone block setting and the issues that come with that, you can just load the structure directly at the player in question and be done with it. It also is easy to use with add-ons as no blocks are needed and the structure can be distributed with the add-on by putting it into the `bp/structures/` folder.
-**Make sure to save the structure with a structure void block inside, or the air might override whatever block the player is currently standing on.**
+**Make sure to save the structure with a structure void block inside or disable save blocks, or the air might override whatever block the player is currently standing on.**
## Physical chest
diff --git a/questions/heighttest.md b/questions/heighttest.md
index cd2a0408..5b30318d 100644
--- a/questions/heighttest.md
+++ b/questions/heighttest.md
@@ -18,7 +18,7 @@ The problem with this is that, as they are not specified but `y` is, `x` and `z`
say @a[x=1,y=200,z=3,dx=0,dy=500,dz=0]
```
-Instead, we'll need to `execute at` the player, so that the `x` and `z` will default to the players own `x` and `z`, which they will always match:
+Instead, we'll need to `execute at` the player, so that the `x` and `z` will default to the player's own `x` and `z`, which they will always match:
```mcfunction
execute as @a at @s run say @s[y=200,dy=500]
@@ -31,11 +31,11 @@ To detect below a certain height, you can make the `dy` negative.
```mcfunction
/execute as @a at @s run say @s[y=-30,dy=-500]
```
-this will detect any players below `-30`
+This will detect any players below `-30`
## Predicate
-Predicates have a built in check for the `y` values (alongside with the other axis). Keep in mind that this is Java exclusive and will need a datapack if you are in pre-1.20.5.
+Predicates have a built-in check for the `y` values (alongside with the other axis). Keep in mind that this is Java exclusive and will need a datapack if you are in pre-1.20.5.
```json
{
diff --git a/questions/highestscore.md b/questions/highestscore.md
index 2c60cac5..670943e6 100644
--- a/questions/highestscore.md
+++ b/questions/highestscore.md
@@ -14,7 +14,7 @@ First, you set up a [fake player](/wiki/questions/fakeplayer) with the smallest
scoreboard players set #max score -2147483648
```
-then you execute as all the entities you want to compare, running the scoreboard operation as all of them. Here we'll use all players in the example.
+Then you execute as all the entities you want to compare, running the scoreboard operation as all of them. Here we'll use all players in the example.
```mcfunction
execute as @a run scoreboard players operation #max score > @s score
diff --git a/questions/hostilefriendly.md b/questions/hostilefriendly.md
index 5fc8f176..f51404d6 100644
--- a/questions/hostilefriendly.md
+++ b/questions/hostilefriendly.md
@@ -9,13 +9,13 @@
- [Only disable PvP](#only-disable-pvp)
- [Interactions (Java only)](#interactions-java-only)
- [Distance attribute (Java only)](#distance-attribute-java-only)
- - [Game Rule (Bedrock only)](#game-rule-bedrock-only)
+ - [Game Rule](#game-rule)
## Disable both hostile and PvP
-This method can be used to make both, disable PvP and make hostile mobs passive.
+This method can be used to make, both, disable PvP and make hostile mobs passive.
### Teams (Java only)
-In java, we can create teams, and we can configure friendly fire to make people of that team unable to attack each other. This also works for mobs. In this example we are going to make zombies passive to players.
+In java, we can create teams, and we can configure friendly fire to make people of that team unable to attack each other. This also works for mobs. In this example, we are going to make zombies passive to players.
```mcfunction
# in chat / load function
@@ -27,13 +27,13 @@ team join @e[team=!friendly,type=zombie] friendly
```
### Weakness and resistance (Java and Bedrock)
-If you canโt use the `/team` command (because you are using it for another thing or you are in bedrock) you can use effects. If we give resistance level 5 or higher the entity will be invulnerable to all damages except the `/kill` command. Weakness is recommended to avoid the player or mob to cause knockback.
+If you canโt use the `/team` command (because you are using it for another thing, or you are in bedrock) you can use effects. If we give resistance level 5 or higher, the entity will be invulnerable to all damages except the `/kill` command. Weakness is recommended to avoid the player or mob to cause knockback.
| ๐ Note |
|---------|
|The entity will be invulnerable even to other damage sources, such as fall damage, entity cramming or attacks that arenโt caused by the player.|
-In this example we are going to make all zombies unable to attack the player for one minute
+In this example, we are going to make all zombies unable to attack the player for one minute
```mcfunction
/effect give @e[type=zombie] weakness 60 127 true
@@ -50,10 +50,10 @@ And if we want the player to be unable to attack the zombie
|You can still attack the player/entity if you have the sharpness enchantment, that's why we use resistance|
## Only disable hostile
-This method wont work to disable PvP, it will only prevent the entity attacking the player.
+This method won't work to disable PvP, it will only prevent the entity attacking the player.
### Helmet
-It is unclear whether this is a bug, but it is shown [in this Reddit post](https://new.reddit.com/r/MinecraftCommands/comments/1cuibxp/comment/l4ya7gx/) that constantly using /item on the mob will mess up the AI and will thus prevent it from attacking the player.
+It is unclear whether this is a bug, but it is shown [in this Reddit post](https://new.reddit.com/r/MinecraftCommands/comments/1cuibxp/comment/l4ya7gx/) that constantly using `/item` on the mob will mess up the AI and will thus prevent it from attacking the player.
| ๐ Note |
|---------|
@@ -65,10 +65,10 @@ It is unclear whether this is a bug, but it is shown [in this Reddit post](https
```
### Follow range
-You can modify the follow range attribute of some mobs so they can't find you. In bedrock you can use the invisibility effect to reduce this range, use mob heads or you change a mobs behavior file to change their follow range that way.
+You can modify the follow range attribute of some mobs so they can't find you. In bedrock, you can use the invisibility effect to reduce this range, use mob heads, or you change a mobs' behavior file to change their follow range that way.
## Only disable PvP
-This method will not make hostile mobs passive but it will prevent players from attacking other entities or players.
+This method will not make hostile mobs passive, but it will prevent players from attacking other entities or players.
### Interactions (Java only)
If it is for only one mob you can add an `interaction` entity that constantly teleports to the mob or rides it and the player will attack the interaction instead of the mob, this will make the mob unkillable with attacks
@@ -76,12 +76,12 @@ If it is for only one mob you can add an `interaction` entity that constantly te
Important things to keep in mind when using this method:
* The players will **not** be able to interact with the mob, if itโs a villager you will not be able to trade with them.
-* The interaction can โlagโ behind if the mob moves too quickly such as when it falls if teleporting it into the mob.
+* The interaction can โlagโ behind if the mob moves too quickly, such as when it falls if teleporting it into the mob.
* Hacked clients can override this method, and attack directly the entity with hacks such as killaura.
* Arrows and other projectiles will be able to attack the entity
### Distance attribute (Java only)
-In java edition, there is an attribute related to the range that players can interact with other entities. we can reduce this range to make them unable to interact with other entities.
+In java edition, there is an attribute related to the range that players can interact with other entities. We can reduce this range to make them unable to interact with other entities.
```mcfunction
attribute entity_interaction_range base set 0
@@ -91,9 +91,9 @@ attribute entity_interaction_range base set 0
|---------|
|This will affect right click too so they won't be able to trade with villagers, for example.|
-### Game Rule (Bedrock only)
+### Game Rule
-You can use the gamerule `pvp` but you can specify which players so it will take effect on everybody
+You can use the gamerule `pvp` but you can not specify which players to take effect in, so it will take effect on everybody
```mcfunction
gamerule pvp false
diff --git a/questions/itemclick.md b/questions/itemclick.md
index ec9bdaa3..62527974 100644
--- a/questions/itemclick.md
+++ b/questions/itemclick.md
@@ -21,7 +21,7 @@
## Java
-For item clicks we have to differentiate between leftclick and rightclick detection in the hotbar / offhand as well as clicking on the item while it is in the inventory. Clicking on the item while it is in the inventory works since version 1.20.5 with the addition of a player cursor slot (`player.cursor`) for checking.
+For item clicks, we have to differentiate between leftclick and rightclick detection in the hotbar / offhand as well as clicking on the item while it is in the inventory. Clicking on the item while it is in the inventory works since version 1.20.5 with the addition of a player cursor slot (`player.cursor`) for checking.
### Left / right clicks in / on specific areas
@@ -33,7 +33,7 @@ Here's a simple example for command blocks:
```mcfunction
# Setup
-summon minecraft:interaction ~ ~ ~ {Tags:["click_scan"],width:0.5f,height:0.5f}
+summon interaction ~ ~ ~ {Tags:["click_scan"],width:0.5f,height:0.5f}
# Command blocks
execute as @e[type=interaction,tag=click_scan] store success entity @s attack.player[] int 0 on attacker run say Left Click!
@@ -44,7 +44,7 @@ execute as @e[type=interaction,tag=click_scan] store success entity @s interacti
| ๐ก Tip |
|--------|
-|To see interaction entity press `F3 + B` to show hitboxes|
+|To see interaction entity, press `F3 + B` to show hitboxes|
If you need to check left/right clicks in a large area (or anywhere), then use multiple interaction entities or create a separate interaction entity for each player and teleport to the player every tick, and use the [scoreboard ID system](/wiki/questions/linkentity) for linking.
@@ -104,7 +104,7 @@ execute as @e[type=interaction,tag=click_scan] run data remove entity @s interac
#### Hurt entity
-This one is as easily explained as it is flawed: You can only detect left clicks, if you put something in front of the player to hit. Teleport some form of entity or mob that can take damage and has a hitbox directly in the players face or even over their head, so they have no other chance but to hit that entity. You can then "detect" the clicks either using an advancement with the `player_hurt_entity` trigger ([see here](https://minecraft.wiki/Advancements/JSON_format#minecraft:player_hurt_entity)) or with a scoreboard objective of type `minecraft.custom:minecraft.damage_dealt` ([see here](https://minecraft.wiki/Scoreboard#Criteria)). This method however has many obvious flaws:
+This one is as easily explained as it is flawed: You can only detect left clicks, if you put something in front of the player to hit. Teleport some form of entity or mob that can take damage and has a hitbox directly in the player's face or even over their head, so they have no other chance but to hit that entity. You can then "detect" the clicks either using an advancement with the `player_hurt_entity` trigger ([see here](https://minecraft.wiki/Advancements/JSON_format#minecraft:player_hurt_entity)) or with a scoreboard objective of type `minecraft.custom:minecraft.damage_dealt` ([see here](https://minecraft.wiki/Scoreboard#Criteria)). This method however has many obvious flaws:
- you're blocking the player from hitting anything else but the entity in their face
- you're also blocking the player from building and breaking blocks
@@ -124,7 +124,7 @@ Mapmakers have for many years now exploited what is technically [a bug](https://
This is the generally preferred method of doing this if it fits your situation, as its pros outweigh the cons.
-It should be noted that the debug_stick has the same property in which clicking with it can be tested using scoreboards but it also changes block properties and that tends to remove it from the list of reasonable methods. Since 1.16 there is also the warped fungus on a stick, which has the same properties as the carrot on a stick.
+It should be noted that the debug_stick has the same property in which clicking with it can be tested using scoreboards, but it also changes block properties and that tends to remove it from the list of reasonable methods. Since 1.16 there is also the warped fungus on a stick, which has the same properties as the carrot on a stick.
Pros:
- Multiplayer friendly.
@@ -139,7 +139,7 @@ Cons:
###### 1.13+
-People tend to use a carrot on a stick and then use a resource pack to remodel them for various CustomModelData tags. This way the CoaS looks like your desired item while still providing the same rightclick functionality.
+People tend to use a carrot on a stick and then use a resource pack to remodel them for various `CustomModelData` tags (pre-1.20.5) or `custom_model_data` components (1.20.5+). This way, the CoaS looks like your desired item while still providing the same rightclick functionality.
The `models/item/carrot_on_a_stick.json` file within the resource pack might end up looking like this:
@@ -165,14 +165,14 @@ The `models/item/carrot_on_a_stick.json` file within the resource pack might end
| ๐ก Tip |
|---------|
-|You can make the item completly invisible if using the custom model data of a chest|
+|You can make the item completely invisible if using the custom model data of a chest|
###### 1.21.2+
The new `item_model` component allows you to make any item look like any other item without a resource pack. See this example command of a carrot on a stick that looks like a nether star
```mcfunction
-give @p carrot[item_model="nether_star"] 1
+give @p carrot_on_a_stick[item_model="nether_star"]
```
#### Make item food method
@@ -181,13 +181,13 @@ give @p carrot[item_model="nether_star"] 1
From version 1.20.5 you can add a right click check for any item that does not already use a right click event.
-This method involves adding the [`minecraft:food component`](https://minecraft.wiki/w/Data_component_format#food) to the item.
+This method involves adding the [`minecraft:food` component](https://minecraft.wiki/w/Data_component_format#food) to the item.
When using only command blocks, you need to actually consume this item in order for the usage statistics of your item to change. So it might make sense to set the `eat_seconds` tag to a small value, such as 0.05 seconds (1 tick). Here is a small example for command blocks:
```mcfunction
# Setup
-give @s minecraft:stick[minecraft:food={nutrition:0,saturation:0f,eat_seconds:0.05f,can_always_eat:true}]
+give @s stick[minecraft:food={nutrition:0,saturation:0f,eat_seconds:0.05f,can_always_eat:true}]
scoreboard objectives add click.stick used:stick
# Command blocks
@@ -197,7 +197,7 @@ scoreboard players reset @a click.stick
This method has obvious disadvantages, such as particles appearing when used, sounds and the fact that the item is actually used.
-But when using a datapack, there are none of these disadvantages. Then you want to change `eat_seconds` to something very large so that the eating animation can't start and use the advancement trigger [`minecraft:using_item`](https://minecraft.wiki/w/Custom_advancement#minecraft:using_item) to check the item's usage. Since this advancement trigger is triggered every tick while the player is using the item, you can execute the command up to 20 times per second. However, often you don't want to do this as often and want to add a delay between command runs.
+But when using a datapack, there are none of these disadvantages. Then you want to change `eat_seconds` to something very large so that the eating animation can't start, and use the advancement trigger [`minecraft:using_item`](https://minecraft.wiki/w/Custom_advancement#minecraft:using_item) to check the item's usage. Since this advancement trigger is triggered every tick while the player is using the item, you can execute the command up to 20 times per second. However, often you don't want to do this as often and want to add a delay between command runs.
Below is an example for this with a delay that is easy to configure:
@@ -205,7 +205,7 @@ Below is an example for this with a delay that is easy to configure:
```mcfunction
# Example item
-give @s minecraft:stick[minecraft:custom_data={right_click:true},minecraft:food={nutrition:0,saturation:0f,eat_seconds:2147483648f,can_always_eat:true}]
+give @s stick[minecraft:custom_data={right_click:true},minecraft:food={nutrition:0,saturation:0f,eat_seconds:2147483648f,can_always_eat:true}]
scoreboard objectives add stick.cooldown dummy
```
```json
@@ -242,7 +242,7 @@ execute as @a if score @s stick.cooldown = #reset stick.cooldown run advancement
-This method allows you to check a right click for almost any item and you do not need to use a resourcepack to change the texture as for the CoaS / FoaS method.
+This method allows you to check a right click for almost any item, and you do not need to use a resourcepack to change the texture as for the CoaS / FoaS method.
##### 1.21.2+
@@ -250,10 +250,10 @@ In 1.21.2 some part of the `food` component has been separated into the `consuma
```mcfunction
# get item
-give @p stick[food={nutrition:0,saturation:0,can_always_eat:true},consumable={consume_seconds:2147483647}] 1
+give @p stick[custom_data={right_click:true},consumable={consume_seconds:2147483647}]
```
-We can also add a cooldown (with the `use_cooldown` component) and use another animation instead of eating (it can be `none`, `eat`, `drink`, `block`, `bow`, `spear`, `crossbow`, `spyglass`, `toot_horn` or `brush`). Keep in mind that the item will be gone when using it. Here is a small example, detecting it using an advancement, of a nether star with the bow animation and a 5 second cooldown.
+We can also add a cooldown (with the `use_cooldown` component) and use another animation instead of eating (it can be `none`, `eat`, `drink`, `block`, `bow`, `spear`, `crossbow`, `spyglass`, `toot_horn` or `brush`). Keep in mind that the item will be gone when using it. Here is a small example, detecting it using an advancement, of a nether star with the bow animation and a 5-second cooldown.
See example
@@ -291,14 +291,14 @@ say used nether star
#### Villager method
-Spawn an invisible, NoAI, Silent dummy villager in front of the player and test if the player's "talked to villager" score increases (`minecraft.custom:minecraft.talked_to_villager`, see [here](https://minecraft.wiki/Scoreboard#Criteria)).
+Spawn an invisible, `NoAI`, `Silent` dummy villager in front of the player and test if the player's "talked to villager" score increases (`minecraft.custom:minecraft.talked_to_villager`, see [here](https://minecraft.wiki/Scoreboard#Criteria)).
Pros:
- Works for any item.
Cons:
- Stops players from hitting entities as well as placing and breaking blocks whilst the villager is present.
-- Zombies will path-find to the fake villager often and not the player.
+- Zombies will path-find to the fake villager often, and not the player.
- Creates unexpected behaviour in multiplayer, as other players can also interfere with one player's fake villager; possible to abuse.
_Parts of this post are taken and modified from [here](https://www.reddit.com/r/MinecraftCommands/comments/elnygk/item_abilities), which have been written by [u/Lemon_Lord1](https://www.reddit.com/u/Lemon_Lord1)_
@@ -330,7 +330,7 @@ execute as @a store success score @s hold.in_cursor if items entity @s player.cu
|---------|
|In Java, it is recommended to use the other methods listed above|
-Right-clicking a bundle will take the first item that has. Because it will spawn an enitity, we can target it. In bedrock edition you will need [a complex method](wiki/questions/giveitembedrock) to be able to give a bundle with a renamed item inside, in this example the item is called `right_click` (so we can distinguish it from other items) and we are going to use the structure method to give the item. In Java, you can use custom data for better performance instead, but itโs recommended to use the other methods listed above.
+Right-clicking a bundle will take the first item that has. Because it will spawn an entity, we can target it. In bedrock edition you will need [a complex method](wiki/questions/giveitembedrock) to be able to give a bundle with a renamed item inside, in this example the item is called `right_click` (so we can distinguish it from other items) and we are going to use the structure method to give the item. In Java, you can use custom data for better performance instead, but itโs recommended to use the other methods listed above.
```mcfunction
# bedrock
diff --git a/questions/linkentity.md b/questions/linkentity.md
index c463a080..cf841b36 100644
--- a/questions/linkentity.md
+++ b/questions/linkentity.md
@@ -7,7 +7,7 @@ _Also known as a **scoreboard ID system**_.
## Java
-Sometimes there is a need to link two entities together in a logical fashion. In Minecraft, we can achieve this by giving both entities the same scoreboard score. In this article we'll be linking an entity to a player.
+Sometimes there is a need to link two entities together in a logical fashion. In Minecraft, we can achieve this by giving both entities the same scoreboard score. In this article, we'll be linking an entity to a player.
For example, let's create a dummy scoreboard for player/entity IDs.
@@ -61,7 +61,7 @@ First we need to set up a dummy scoreboard objective
scoreboard objectives add id dummy
```
-Next, to make sure that every player gets a unique id, we need a system that assigns every player a unique score. This can be achieved by simply counting up with every subsequent player that needs a score. For this, we'll set a [fake player](/wiki/questions/fakeplayer) score of this objective to 1 to start with.
+Next, to make sure that every player gets a unique ID, we need a system that assigns every player a unique score. This can be achieved by simply counting up with every subsequent player that needs a score. For this, we'll set a [fake player](/wiki/questions/fakeplayer) score of this objective to 1 to start with.
```mcfunction
scoreboard players set $total id 1
diff --git a/questions/lookat.md b/questions/lookat.md
index 9a3e3e4d..99c5da70 100644
--- a/questions/lookat.md
+++ b/questions/lookat.md
@@ -13,16 +13,16 @@ _This method describes how to check whether the player / an entity is **looking
## Java & Bedrock after 1.19.50
-in Java and later Bedrock versions this can actually be achieved in a single command, thanks to the versatility of the `execute` command. We'll use the following subcommands to achieve our goal:
+in Java and later Bedrock versions, this can actually be achieved in a single command, thanks to the versatility of the `execute` command. We'll use the following subcommands to achieve our goal:
- `as @a at @s` to modify the execution entity and position.
-- `anchored eyes` to move the execution position up to the players eyes. For it to take effect, you'll need a positioned ^ ^ ^ subcommand at some point after this subcommand (which we have 2 subcommands later). See this related bug [MC-169665](https://bugs.mojang.com/browse/MC-169665).
+- `anchored eyes` to move the execution position up to the player's eyes. For it to take effect, you'll need a positioned ^ ^ ^ subcommand at some point after this subcommand (which we have 2 subcommands later). See this related bug [MC-169665](https://bugs.mojang.com/browse/MC-169665).
- `facing ` to change the execution rotation to be facing our object / entity of desire
- `positioned ^ ^ ^1` to move 1 block in the direction of the object
-- `anchored feet` to move the anchor back down to the players feet (due to a bug in the game which would otherwise apply the eye height modification with each position change, which we don't want, as well as to be able to check for the players existence in the last subcommand, this is not the case in the current version of the game so it can be omitted, see [MC-124140](https://bugs.mojang.com/browse/MC-124140))
+- `anchored feet` to move the anchor back down to the players feet (due to a bug in the game which would otherwise apply the eye height modification with each position change, which we don't want, as well as to be able to check for the player's existence in the last subcommand, this is not the case in the current version of the game so it can be omitted, see [MC-124140](https://bugs.mojang.com/browse/MC-124140))
- `rotated as @s` to change the execution rotation back to be the same as the executing player
- `positioned ^ ^ ^-1` to move 1 block in the opposite direction of where the player is facing
-- `if entity @s[distance=..0.1]` to check whether after this back and forth we've arrived roughly back at the player's position. To increase / decrease the tolerance for what is considered "close enough", change the distance parameter (it needs to be between 0 and 2, because 2 basically means "you can look in the opposite direction and it's still close enough". So realistically you want to most likely stay well below 1). To calculate the exact viewing cone angle, see below.
+- `if entity @s[distance=..0.1]` to check whether after this back and forth we've arrived roughly back at the player's position. To increase / decrease the tolerance for what is considered "close enough", change the distance parameter (it needs to be between 0 and 2, because 2 basically means "you can look in the opposite direction and, it's still close enough". So realistically you want to most likely stay well below 1). To calculate the exact viewing cone angle, see below.
So, to bring it all together, the full command is as follows:
@@ -42,7 +42,7 @@ Example 2: looking at the position 10 20 30
execute as @a at @s anchored eyes facing 10 20 30 anchored feet positioned ^ ^ ^1 rotated as @s positioned ^ ^ ^-1 if entity @s[distance=..0.1] run say hello block
```
-To execute commands `as` or `at` the entity add `at` and include the original target selecor used after `facing entity`
+To execute commands `as` or `at` the entity, add `at` and include the original target selector used after `facing entity`
## Java
@@ -75,7 +75,7 @@ execute as @a[predicate=example:looking_cow] run say Hi, cow!
### Advancement
This example is the same advancement as the vanilla ones but without any display.
-You can find (and edit) the preset in [misode's advancement generator](https://misode.github.io/advancement/?version=1.20.5&preset=adventure/spyglass_at_ghast))
+You can find (and edit) the preset in [misode's advancement generator](https://misode.github.io/advancement/?version=1.20.5&preset=adventure/spyglass_at_ghast)
See example
@@ -127,7 +127,7 @@ In bedrock the process is the same as in Java, but due to a lack of advanced exe
Also, due to how rotations work in bedrock, this tends to be somewhat inaccurate when the target is on a different y level than the player. Hopefully this will be resolved when the new execute arrives in 1.19.
-This setup can only happen to one player at a time, so either use functions to make this better scalable or experiment with executing from the players and their closest armorstands (which will still lead to some issues, but less so). Hence this will use `@p` to signify this restriction.
+This setup can only happen to one player at a time, so either use functions to make this better scalable or experiment with executing from the players and their closest armorstands (which will still lead to some issues, but less so). Hence, this will use `@p` to signify this restriction.
See commands
@@ -154,7 +154,7 @@ kill @e[name=checker]
-To increase / decrease the tolerance for what is considered "close enough", change the radius (`r`) selector (it needs to be between 0 and 2, because 2 basically means "you can look in the opposite direction and it's still close enough". So realistically you want to most likely stay well below 1). To calculate the exact viewing cone angle, see below.
+To increase / decrease the tolerance for what is considered "close enough", change the radius (`r`) selector (it needs to be between 0 and 2, because 2 basically means "you can look in the opposite direction and it's still close enough". So realistically, you want to most likely stay well below 1). To calculate the exact viewing cone angle, see below.
### Using Add-Ons
@@ -162,9 +162,9 @@ To check whether the player is looking at an entity, we can use the endermans `l
Also see [`minecraft:lookat` documentation on bedrock.dev](https://bedrock.dev/docs/stable/Entities#minecraft%3Alookat).
-The lookat component then lets us fire an event which could then cause whatever we want to happen to the entity.
+The lookat component then lets us fire an event, which could then cause whatever we want to happen to the entity.
-In this example the entity will (without cooldown) fire the `custom:ive_been_looked_at` event when a player (even in creative mode) within a radius of 20 blocks. It will not set the looker as its attack target.
+In this example, the entity will (without cooldown) fire the `custom:ive_been_looked_at` event when a player (even in creative mode) within a radius of 20 blocks. It will not set the looker as its attack target.
See example
@@ -197,6 +197,6 @@ or, the inverse to calculate what viewing angle a certain radius / distance (`r`
α = sin-1(r⁄2) × 2
-_(remember that depending on your calculator you need to convert from radians to degrees)_.
+_(remember that depending on your calculator, you need to convert from radians to degrees)_.
-With the above calculation the example value of `r=0.1` / `distance=..0.1` leaves us with roughly a 6ยฐ angle by which we can miss the exact target in either direction and still have it considered "close enough".
\ No newline at end of file
+With the above calculation, the example value of `r=0.1` / `distance=..0.1` leaves us with roughly a 6ยฐ angle by which we can miss the exact target in either direction and still have it considered "close enough".
\ No newline at end of file
diff --git a/questions/makecircle.md b/questions/makecircle.md
index deac23e0..c0a48737 100644
--- a/questions/makecircle.md
+++ b/questions/makecircle.md
@@ -12,24 +12,24 @@ The idea of how to achieve this is pretty simple: Have an entity in the center t
## Implementation
-For the example we're assuming that we want to make a block outline. You can easily adjust this to summon entities or make a filled circle by swapping the `/setblock` command for something else (e.g., `/summon`, `/ fill`).
+For the example, we're assuming that we want to make a block outline. You can easily adjust this to summon entities or make a filled circle by swapping the `/setblock` command for something else (e.g., `/summon`, `/ fill`).
1. Summon your center entity. We're using an armorstand for parity, but in Java you can use other things like a [`marker`](https://minecraft.wiki/w/Marker) (for better performance) or any NoAI entity.
-```mcfunction
-/summon armor_stand ~ ~ ~
-```
+ ```mcfunction
+ /summon armor_stand ~ ~ ~
+ ```
2. tag the armorstand so we can reference it easily.
-```mcfunction
-# Bedrock
-/tag @e[type=armor_stand,c=1] add center
-# Java 1.13+
-/tag @e[type=armor_stand,sort=nearest,limit=1] add center
-# Java 1.21+
-/tag @n[type=armor_stand] add center
-```
+ ```mcfunction
+ # Bedrock
+ /tag @e[type=armor_stand,c=1] add center
+ # Java 1.13+
+ /tag @e[type=armor_stand,sort=nearest,limit=1] add center
+ # Java 1.21+
+ /tag @n[type=armor_stand] add center
+ ```
3. now, to automatically place the blocks, we'll want to put the following command into a repeating commandblock and the ones after that into chain commandblocks attached to the repeating one. Starting off with placing the block in front of the armorstand.
```mcfunction
diff --git a/questions/mobdeaths.md b/questions/mobdeaths.md
index a91d8f7b..bfba2d18 100644
--- a/questions/mobdeaths.md
+++ b/questions/mobdeaths.md
@@ -5,9 +5,9 @@
- [Passenger entity](#passenger-entity)
- [Reading data by UUID (1.20.2+)](#reading-data-by-uuid-1202)
-This article applies to Java Edition only. For Bedrock Edition the method is described in this wiki article: [Detect the player killing entities and players](/wiki/questions/playerkills#bedrock)
+This article applies to Java Edition only. For Bedrock Edition, the method is described in this wiki article: [Detect the player killing entities and players](/wiki/questions/playerkills#bedrock)
-When a mob begins to play the death animation, then this mob cannot be selected using the target selector, this is the main difficulty in detecting the death of a mob, but there are still several ways to do this, but each has its own limitations. Each of the methods listed below is completely resistant to unloading mobs from loaded chunks and there will be no false positives.
+When a mob begins to play the death animation, then this mob cannot be selected using the target selector, this is the main difficulty in detecting the death of a mob, but there are still several ways to do this, but each has its own limitations. Each of the methods listed below is completely resistant to unloading mobs from loaded chunks, and there will be no false positives.
----
@@ -47,7 +47,7 @@ Key points:
* can detect mob death only if the killer is a player
* requires using a datapack
-Here's a quick example to detect if a any skeleton type with the tag some\_tag was killed by a player:
+Here's a quick example to detect if any skeleton type with the tag some\_tag was killed by a player:
See example
@@ -90,7 +90,7 @@ say Skeleton with tag some_tag has died.
This method is a direct way to check the death of a specific mob with any cause of death, not just due to the player.
-This method is based on using a [marker entity](https://minecraft.wiki/w/Marker) as a passenger on a mob that needs to be checked for death. The passenger entity will ride the entity until the end of the death animation, so using this you can check the `DeathTime` tag of a mob with a death animation. This way also has a unique opportunity to check not only the death of a mob, but also when and where the mob despawned.
+This method is based on using a [marker entity](https://minecraft.wiki/w/Marker) as a passenger on a mob that needs to be checked for death. The passenger entity will ride the entity until the end of the death animation, so using this, you can check the `DeathTime` tag of a mob with a death animation. This way also has a unique opportunity to check not only the death of a mob, but also when and where the mob despawned.
Key points:
* average load on the server
@@ -161,7 +161,7 @@ kill @s
-As of version 1.19.4, you can use the [execute](https://minecraft.wiki/w/Commands/execute#on) `on vehicle` subcommand to select a dying mob:
+As of version 1.19.4, you can use the [execute on vehicle](https://minecraft.wiki/w/Commands/execute#on) subcommand to select a dying mob:
```mcfunction
# Command blocks
@@ -212,7 +212,7 @@ Key points:
The difficulty with this method is that you need to get the mob's UUID in Hexadecimal format (`ba7916ab-abc0-4ef6-8a43-391dbffdefcd`), but `/data get` can only get the UUID as a list of int values (`[I;-1166469461,-1413460234,-1975305955,-1073877043]`). Therefore, you need to use a UUID converter. In this article will we use this [UUID converter library](https://github.com/gibbsly/gu) by [@gibbsly](https://github.com/gibbsly).
-To convert UUID using this library you need to run the `function gu:convert` as a macro function with the data of the selected mob, and then read the `storage gu:main out` tag.
+To convert UUID using this library, you need to run the `function gu:convert` as a macro function with the data of the selected mob, and then read the `storage gu:main out` tag.
In addition, you need to save the converted UUIDs of mobs in storage and use a macro to insert these UUIDs into your check command.
diff --git a/questions/modifyinventory.md b/questions/modifyinventory.md
index e52f7b1b..5cb0a160 100644
--- a/questions/modifyinventory.md
+++ b/questions/modifyinventory.md
@@ -1,4 +1,4 @@
-# Modify an item inside a players inventory
+# Modify an item inside a player's inventory
- [1.20.5 and above](#1205-and-above)
- [1.17 and above](#117-and-above)
@@ -9,11 +9,11 @@
- [The loot table](#the-loot-table)
- [The commands:](#the-commands)
-_Java only, as NBT data is inaccessible in bedrock this article is irrelevant for BE._
+_Java only, as NBT data is inaccessible in bedrock, this article is irrelevant for BE._
## 1.20.5 and above
-In this version, the functionality of [item_modifier](https://minecraft.wiki/w/Item_modifier) has been expanded with the ability to filter selected items for modification and the ability to change item ID. And the /item command now has the ability to use item_modifier / [predicates](https://minecraft.wiki/w/Predicate) directly in the game without using a datapack. Values have same structure as matching JSON files, though they are encoded as SNBT.
+In this version, the functionality of [item_modifier](https://minecraft.wiki/w/Item_modifier) has been expanded with the ability to filter selected items for modification and the ability to change item ID. And the /item command now has the ability to use item_modifier / [predicates](https://minecraft.wiki/w/Predicate) directly in the game without using a datapack. Values have the same structure as matching JSON files, though they are encoded as SNBT.
Quick example:
@@ -33,7 +33,7 @@ You can also change the item ID without changing any components:
execute as @a run item modify entity @s weapon {function:"minecraft:filtered", item_filter: {items:"minecraft:iron_sword"}, modifier: {function:"minecraft:set_item", item:"minecraft:golden_sword"}}
```
-This example uses the [`minecraft:filtered`](https://minecraft.wiki/w/Item_modifier#:~:text=or%20killer_player.-,filtered,-%E2%80%94Applies%20another%20function) loot function to check that the selected item is `minecraft:iron_sword` and not just any item and then uses the [`minecraft:set_item`](https://minecraft.wiki/w/Item_modifier#:~:text=is%20selected%20randomly.-,set_item,-%E2%80%94Replaces%20item%20type) function to replace iron_sword with golden_sword. In this case, any custom_data, damage, enchantments and other components that this item contains will not be changed, with the exception of inaccessible data, for example, if the original item had a [max_stack_size](https://minecraft.wiki/w/Data_component_format#max_stack_size) component greater than 1 and after modification you change to an item with a [max_damage](https://minecraft.wiki/w/Data_component_format#max_damage) component, then max_stack_size will be changed by 1.
+This example uses the [`minecraft:filtered`](https://minecraft.wiki/w/Item_modifier#:~:text=or%20killer_player.-,filtered,-%E2%80%94Applies%20another%20function) loot function to check that the selected item is `minecraft:iron_sword` and not just any item, and then uses the [`minecraft:set_item`](https://minecraft.wiki/w/Item_modifier#:~:text=is%20selected%20randomly.-,set_item,-%E2%80%94Replaces%20item%20type) function to replace iron_sword with golden_sword. In this case, any custom_data, damage, enchantments and other components that this item contains will not be changed, with the exception of inaccessible data, for example, if the original item had a [max_stack_size](https://minecraft.wiki/w/Data_component_format#max_stack_size) component greater than 1 and after modification you change to an item with a [max_damage](https://minecraft.wiki/w/Data_component_format#max_damage) component, then max_stack_size will be changed by 1.
## 1.17 and above
@@ -41,7 +41,7 @@ In snapshot [20w46a](https://www.minecraft.net/article/minecraft-snapshot-20w46a
### item replace
-With this command you can copy an item to a specified entity/block slot from an entity/block slot. To do this, you also need to use any entity/block that will be used as a buffer slot in which you can change the item data.
+With this command, you can copy an item to a specified entity/block slot from an entity/block slot. To do this, you also need to use any entity/block that will be used as a buffer slot in which you can change the item data.
Here's a quick example of adding an enchantment to an item in a player's hand:
```mcfunction
@@ -83,7 +83,7 @@ item modify entity weapon.mainhand example:add_knockback
## 1.16 and below
-_As of 1.15, [MC-123307](https://bugs.mojang.com/browse/MC-123307), which allowed execute store and data modify commands to edit a player's inventory or ender chest items, has been fixed. The offical replacement was introduced in early 1.17 snapshots. However, there is still a trick dating back to 1.14 that makes use of the loot command with a modified shulker box loot table._
+_As of 1.15, [MC-123307](https://bugs.mojang.com/browse/MC-123307), which allowed `execute store` and data modify commands to edit a player's inventory or ender chest items, has been fixed. The official replacement was introduced in early 1.17 snapshots. However, there is still a trick dating back to 1.14 that makes use of the loot command with a modified shulker box loot table._
### The method:
@@ -91,7 +91,7 @@ In vanilla without data packs, shulker boxes drop themselves with their contents
Of course, that would change normal behavior of loot tables. The actual loot table consists of two entries, one which keeps the normal shulker box drop, and one that drops its contents when mined with a specific item: minecraft:air{drop_contents: 1b}. Because air cannot have NBT data, a player cannot notice any difference, whatever they are holding. The only case where this is useful is in the loot command.
-A shulker box is placed somewhere out of sight of the player. Sometimes far away, usually in a forceloaded chunk, like some libraries (Phi, AESTD, Lantern) do. Alternatively you can place it e.g. at ~ 0 ~ and replace it back with bedrock at the end of the thing. _It is desireable to not constantly setblock and replace a block though, so if you can place it somewhere permanently, do that._ An item is placed inside the shulker box, and is injected to the player's inventory.
+A shulker box is placed somewhere out of sight of the player. Sometimes far away, usually in a forceloaded chunk, like some libraries (Phi, AESTD, Lantern) do. Alternatively, you can place it e.g. at ~ 0 ~ and replace it back with bedrock at the end of the thing. _It is desirable to not constantly setblock and replace a block, though, so if you can place it somewhere permanently, do that._ An item is placed inside the shulker box, and is injected to the player's inventory.
### The loot table
diff --git a/questions/movetoscore.md b/questions/movetoscore.md
index 0e6f6fb3..2aa95f02 100644
--- a/questions/movetoscore.md
+++ b/questions/movetoscore.md
@@ -13,9 +13,15 @@
| โ ๏ธ Important |
|--------------|
-|If the coordinate is inside a block and below it there isn't a solid block, the entity will clip trought and fall, this is common if you are storing the scoreboard value by storing the `Pos` value, when the player is not in a full block (for example a slab)|
+|If the coordinate is inside a block and below it there isn't a solid block, the entity will clip through and fall, this is common if you are storing the scoreboard value by storing the `Pos` value, when the player is not in a full block (for example a slab)|
-If you want to store the position of the player see this [transfer nbt to score](wiki/questions/nbttransfer)
+If you want to store the position of the player, see this [transfer nbt to score](wiki/questions/nbttransfer), but in short, you use `execute store` to retrieve data and store it in a score
+
+```mcfunction
+execute as store result score @s posX run data get entity @s Pos[0]
+execute as store result score @s posY run data get entity @s Pos[1]
+execute as store result score @s posZ run data get entity @s Pos[2]
+```
Since version 1.20.2 you can summon the entity directly at the position of the score using a [macro](https://minecraft.wiki/w/Function_(Java_Edition)#Macros) in the datapack. If you are using an earlier version, or do not use a datapack, then you cannot summon the entity directly at the position of the score, instead you have to summon the entity and then teleport it to your desired position.
@@ -45,7 +51,9 @@ $tellraw @a "Pig summoning at $(x) $(y) $(z)"
```
-**Note: You cannot use macro data in the same function in which you set data for the macro command. You should always run a separate function to execute the macro command.**
+| ๐ Note |
+|---------|
+|You cannot use macro data in the same function in which you set data for the macro command. You should always run a separate function to execute the macro command.|
The macro allows you to insert any numeric or text data into any part of the command; however, before using these values in the command you need to set this data in storage, read the data from the entity / block, or you can manually set the values when running the function. Below is an example:
@@ -59,7 +67,7 @@ $summon $(id) $(x) $(y) $(z)
## Teleport an entity to the position set in a score
-Assuming your desired position is stored in the entity's posX, posY and posZ value, you can just run `execute store` to save the score into the Position like this:
+Assuming your desired position is stored in the entity's `posX`, `posY` and `posZ` value, you can just run `execute store` to save the score into the Position like this:
```mcfunction
execute store result entity @s Pos[0] double 1 run scoreboard players get @s posX
@@ -67,7 +75,7 @@ execute store result entity @s Pos[1] double 1 run scoreboard players get @s pos
execute store result entity @s Pos[2] double 1 run scoreboard players get @s posZ
```
-**Be aware that if the entity enters unloaded chunks at any point during this operation, it might not continue to work, especially if you're not using a function to do this**. So if your X moves the entity out of the loaded chunks, the Y and Z won't be applied anymore. If you're running the commands from above in a function you'll be fine, as we don't need to re-find the entity because we're using the `@s` selector.
+**Be aware that if the entity enters unloaded chunks at any point during this operation, it might not continue to work, especially if you're not using a function to do this**. So if your X moves the entity out of the loaded chunks, the Y and Z won't be applied anymore. If you're running the commands from above in a function, you'll be fine, as we don't need to re-find the entity because we're using the `@s` selector.
But you can easily avoid unloading the entity if you do not change each axis separately, but first do it in storage and then copy the ready `Pos` tag from storage to the entity data:
@@ -81,7 +89,7 @@ data modify entity @s Pos set from storage example:data Pos
## Teleport the player to the position set in a score
-The problem with the player is that the player NBT data cannot be modified and thus we can't just set their position like we can with entities. There are four decent ways to go about this:
+The problem with the player is that the player NBT data cannot be modified, and thus we can't just set their position like we can with entities. There are four decent ways to go about this:
### 1: Macro function
@@ -117,14 +125,14 @@ function example:tp/macro with storage example:macro pos
You can use end gateways to teleport the players to an exact location, see [this for more info](https://minecraft.wiki/End_Gateway_(block)#Data_values).
-Basically you can set its block NBT Data to `ExactTeleport:1b,ExitPortal:{X:1,Y:2,X:3}` using `data merge block` or `execute store` and then teleport the player into said portal. Thanks to `execute store` you can set the Exit Portal NBT dynamically:
+Basically, you can set its block NBT Data to `ExactTeleport:1b,ExitPortal:{X:1,Y:2,X:3}` using `data merge block` or `execute store` and then teleport the player into said portal. Thanks to `execute store` you can set the Exit Portal NBT dynamically:
```mcfunction
# 1.13 - 1.20.4
setblock 0 5 0 minecraft:end_gateway{ExactTeleport:1b,ExitPortal:{X:0,Y:0,Z:0},Age:-9223372036854775808L}
-execute store result block 0 5 0 ExitPortal.X int 1 run scoreboard players get @s MapX
-execute store result block 0 5 0 ExitPortal.Y int 1 run scoreboard players get @s MapY
-execute store result block 0 5 0 ExitPortal.Z int 1 run scoreboard players get @s MapZ
+execute store result block 0 5 0 ExitPortal.X int 1 run scoreboard players get @s PosX
+execute store result block 0 5 0 ExitPortal.Y int 1 run scoreboard players get @s PosY
+execute store result block 0 5 0 ExitPortal.Z int 1 run scoreboard players get @s PosZ
tp @s 0 5 0
```
@@ -135,17 +143,31 @@ Since version 1.20.5, the `ExitPortal` Compound tag has been replaced by the [In
```mcfunction
# 1.20.5+
setblock 0 5 0 minecraft:end_gateway{ExactTeleport:1b,exit_portal:[I;0,0,0],Age:-9223372036854775808L}
-execute store result block 0 5 0 exit_portal[0] int 1 run scoreboard players get @s MapX
-execute store result block 0 5 0 exit_portal[1] int 1 run scoreboard players get @s MapY
-execute store result block 0 5 0 exit_portal[2] int 1 run scoreboard players get @s MapZ
+execute store result block 0 5 0 exit_portal[0] int 1 run scoreboard players get @s PosX
+execute store result block 0 5 0 exit_portal[1] int 1 run scoreboard players get @s PosY
+execute store result block 0 5 0 exit_portal[2] int 1 run scoreboard players get @s PosZ
tp @s 0 5 0
```
### 3: Use an entity
-Summon an entity, use the above method to teleport the entity to the position and then teleport the player to the entity. Here it is also important that the entity is `@s` from the moment you move it, in case it goes into unloaded chunks.
+Summon an entity, use the above method to teleport the entity to the position, and then teleport the player to the entity. Here it is also important that the entity is `@s` from the moment you move it, in case it goes into unloaded chunks.
See [u/SanianCreations](https://www.reddit.com/u/SanianCreations) post about this [here](https://www.reddit.com/r/MinecraftCommands/comments/fd1lds/new_method_to_tp_to_scoreboard_values).
+```mcfunction
+# function example:teleport (run as the player)
+tag @s add this
+execute summon area_effect_cloud run function example:teleport_target
+tag @s remove this
+
+# function example:teleport_target
+execute store result entity @s Pos[0] double 1 run scoreboard players get @a[limit=1,tag=this] PosX
+execute store result entity @s Pos[1] double 1 run scoreboard players get @a[limit=1,tag=this] PosY
+execute store result entity @s Pos[2] double 1 run scoreboard players get @a[limit=1,tag=this] PosZ
+tp @a[limit=1,tag=this] @s
+kill @s
+```
+
### 4: Binary Teleportation
| ๐ Note |
@@ -174,4 +196,4 @@ all the way down to 1, repeat for all 3 coordinates
```
-This does use a lot of commands but using a function it's fairly easy to do and you can go as high as you want. Always start with the highest power of 2.
+This does use a lot of commands but using a function it's fairly easy to do, and you can go as high as you want. Always start with the highest power of 2.
diff --git a/questions/moving.md b/questions/moving.md
new file mode 100644
index 00000000..36af9563
--- /dev/null
+++ b/questions/moving.md
@@ -0,0 +1,62 @@
+# Detect the player moving
+
+ - [Java](#java)
+ - [Predicate](#predicate)
+ - [Commands](#commands)
+ - [Bedrock](#bedrock)
+
+## Java
+### Predicate
+To detect the player moving, you can use the following predicate
+
+```json
+{
+ "condition": "minecraft:entity_properties",
+ "entity": "this",
+ "predicate": {
+ "movement": {
+ "horizontal_speed": {
+ "min": 0.01
+ }
+ }
+ }
+}
+```
+This can be used as a target selector `@e[predicate=...]` or with `execute if predicate`, but then it must be `as` an entity
+
+### Commands
+In older versions, where this predicate didn't exist, you can store the position values and compare to the previous tick
+
+```mcfunction
+# In chat
+scoreboard objectives add Pos.x dummy
+scoreboard objectives add Pos.x.copy dummy
+scoreboard objectives add Pos.z dummy
+scoreboard objectives add Pos.z.copy dummy
+
+# Command blocks
+execute as @a run scoreboard players operation @s Pos.x.copy = @s Pos.x
+execute as @a run scoreboard players operation @s Pos.z.copy = @s Pos.z
+execute as @a store result score Pos.x run data get entity @s Pos[0] 100
+execute as @a store result score Pos.z run data get entity @s Pos[2] 100
+execute as @a unless score @s Pos.x = @s Pos.x.copy run say I'm moving on the x axis
+execute as @a unless score @s Pos.z = @s Pos.z.copy run say I'm moving on the z axis
+```
+
+We have 4 scoreboards. `Pos.x` and `Pos.z` will be where the position will be stored and the `.copy` scoreboards contains the value of the previous tick.
+
+First, we copy the values from the previous tick into the copy scoreboards (multiplied by 100 to retain decimal places), then, we update the current values from the data of the player `Pos[0]` and `Pos[2]`.
+
+Last, we compare if the values aren't the same, if they aren't, we know The player moved.
+
+If you want to run a command when the player moves with this method but don't care if it's the X or Z axis then you can change the last 2 commands to add a tag, the run any command as the player with the tag and lastly remove the tag.
+
+```mcfunction
+execute as @a unless score @s Pos.x = @s Pos.x.copy run tag @s add moving
+execute as @a unless score @s Pos.z = @s Pos.z.copy run tag @s add moving
+execute as @a[tag=moving] run say I'm moving
+tag @a remove moving
+```
+
+## Bedrock
+For bedrock, check this detailed article https://wiki.bedrock.dev/commands/movement-detections#is-moving.
\ No newline at end of file
diff --git a/questions/multipletags.md b/questions/multipletags.md
index a6e08440..7e0040ed 100644
--- a/questions/multipletags.md
+++ b/questions/multipletags.md
@@ -31,4 +31,4 @@ To optimize how this performs, you can specify the least common tag in the `@e`
scoreboard players tag @e[tag=A] add HasAllTags {Tags:["B","C"]}
```
-This means that less entities will need to have their NBT checked.
\ No newline at end of file
+This means that fewer entities will need to have their NBT checked.
\ No newline at end of file
diff --git a/questions/nbttransfer.md b/questions/nbttransfer.md
index 54e4dcf8..ca5e870f 100644
--- a/questions/nbttransfer.md
+++ b/questions/nbttransfer.md
@@ -35,7 +35,7 @@ Next we need to store the value of `/data get`'s result into a scoreboard object
execute store result score run
```
-This will run ``, and store the result into the the ``'s `` score. So, putting it together, you could do something like this:
+This will run ``, and store the result into the ``'s `` score. So, putting it together, you could do something like this:
```mcfunction
execute store result score @s y_pos run data get entity @s Pos[1] 100
@@ -54,7 +54,7 @@ execute store result block (byte|double|float|int|long|short) ` you'll want to run is `/scoreboard players get `, which returns a specified score as its result.
-`` is similar to how it was for `/data get`; the result will be multiplied by this then written to the NBT path. If you scaled up a position 100* when getting it into a score to preserve accuracy, now is the point you'll want to scale it back down (with a scale of 0.01).
+`` is similar to how it was for `/data get`; the result will be multiplied by this, then written to the NBT path. If you scaled up a position 100* when getting it into a score to preserve accuracy, now is the point you'll want to scale it back down (with a scale of 0.01).
`(byte|double|float|int|long|short)` is the **data type** to cast this value to, as NBT has multiple ways to represent a number (whereas scores are always `int`s). You'll need this to match the data type of the tag you're storing the value into.
diff --git a/questions/npc.md b/questions/npc.md
index 199cb160..7a1d38a6 100644
--- a/questions/npc.md
+++ b/questions/npc.md
@@ -18,7 +18,7 @@ For spawning an NPC, you will need to use the `/summmon` or `/give` command:
/give @s spawn_egg 1 51
```
-For removing the NPC just left-click it while you are in creative, or use the `/kill` command.
+For removing the NPC, just left-click it while you are in creative, or use the `/kill` command.
A NPC is invulnerable if you try to kill it with other methods (unless when falling into the void), but it can be moved with water, lava, breeze's wind charges, explosions or pistons.
To edit an NPC right click it in creative, you will open a GUI that allows you to edit the display name and the skin.
@@ -39,14 +39,14 @@ You can use a target selector variable to target the player that is โtalking
For that command there are 3 options: โOn Enterโ to run the command when the player right clicks it, โOn Exitโ to run the command when the player leaves the NPC screen and โButton Modeโ.
This option will show a button in the dialog screen when the player interacts with it. You can change the buttonโs text by typing it in the text box below the options.
-You can add another command at the same button (or action, if you choosed it to be `On Enter`, for example) by pressing `enter` to create a new line.
+You can add another command at the same button (or action, if you chose it to be `On Enter`, for example) by pressing `enter` to create a new line.
The command is run `as` the NPC and `at` the NPC, see [command context](wiki/questions/commandcontext) for more information.
Below the options, you can choose to add another command, to remove a command press the trash button in the top right corner of that command.
## Add another dialog
-If you want you can add another dialog when the player presses a button.
+If you want, you can add another dialog when the player presses a button.
Example: the NPC asks if the player wants a challenge and there are 2 options, yes and no. If the player selects no, no action is initiated. However, if the player selects yes, a dialog will appear inquiring if they are certain about this with 2 options again: yes and no. If they select yes, a zombie will spawn.
diff --git a/questions/playerdeaths.md b/questions/playerdeaths.md
index 05879985..5ba795a7 100644
--- a/questions/playerdeaths.md
+++ b/questions/playerdeaths.md
@@ -109,16 +109,16 @@ execute as @a[scores={respawn=1}] run say I just respawned!
## Bedrock
-In Bedrock the same question is more difficult to answer, since at the time of writing only the `dummy` objective type exists.
+In Bedrock, the same question is more difficult to answer, since only the `dummy` objective type exists.
The best way to do this in bedrock is with the following commands, in this order:
```mcfunction
-/tag @a add dead
-/tag @e[type=player] remove dead
-/scoreboard players add @a[tag=dead,tag=!still_dead] deathCount 1
-/tag @a add still_dead
-/tag @e[type=player] remove still_dead
+tag @a add dead
+tag @e[type=player] remove dead
+scoreboard players add @a[tag=dead,tag=!still_dead] deathCount 1
+tag @a add still_dead
+tag @e[type=player] remove still_dead
```
Set up a dummy scoreboard called `deathCount` and it will count up every time a player dies.
diff --git a/questions/playerjoin.md b/questions/playerjoin.md
index 8bbfc2e0..b0a6a4a0 100644
--- a/questions/playerjoin.md
+++ b/questions/playerjoin.md
@@ -25,7 +25,7 @@ execute as @a[tag=!init] run tellraw @a ["",{"selector":"@s"},{"text":" just log
tag @a[tag=!init] add init
### Advancements
-Another way to do this is using an advancement in a datapack, this advancement will we granted every tick, so new players (that don't have this advancement) will receive it and will run the function specified in the reward.
+Another way to do this is using an advancement in a datapack, this advancement will be granted every tick, so new players (that don't have this advancement) will receive it and will run the function specified in the reward.
```json
# advancement example:first_join
@@ -49,7 +49,7 @@ tellraw @a [{"selector":"@s"}," just logged in for the first time!"]
### Java
-You can set up an objective of type `minecraft.custom:minecraft.leave_game`, which will count up the moment a player leaves the server, which you can then detect the moment they come back, because, even if the score has been updated, the player is not online and we can't target it with `@a[scores={leave=1}]`.
+You can set up an objective of type `minecraft.custom:minecraft.leave_game`, which will count up the moment a player leaves the server, which you can then detect the moment they come back, because, even if the score has been updated, the player is not online, and we can't target it with `@a[scores={leave=1}]`.
Assuming you called the objective `leave`, it could look like this:
```mcfunction
@@ -63,7 +63,7 @@ scoreboard players reset @a[scores={leave=1..}] leave
### Bedrock
-In Bedrock we don't have the luxury of the `leave_game` objective, so we'll need to find a workaround. One such workaround could be to have a fake player count up a score every tick/second, then check whether the player has the same score, if not run whatever you want on them, then set the score to the same score as the fake player. Example with a dummy scoreboard objective called "online":
+In Bedrock, we don't have the luxury of the `leave_game` objective, so we'll need to find a workaround. One such workaround could be to have a fake player count up a score every tick/second, then check whether the player has the same score, if not run whatever you want on them, then set the score to the same score as the fake player. Example with a dummy scoreboard objective called "online":
```mcfunction
scoreboard players add @a online 1
@@ -90,7 +90,7 @@ scoreboard players set @a[scores={leave=1..}] leave 0
But it can be simplified to only 2 commands (and one for creating the scoreboard).
First we detect if the player has no set score (so they are a new player) and we store the success of the tellraw. The score is now set to 1 (from no score at all), because the tellraw always succeeds.
-Then if the value is not 1 (so it is 2, so they leaved the game) we will store the succes of another tellraw command in the scoreboard, because it is the success it will set it to 1.
+Then if the value is not 1 (so it is 2, so they left the game) we will store the success of another tellraw command in the scoreboard, because it is the success it will set it to 1.
```mcfunction
# In chat
@@ -103,7 +103,7 @@ execute as @a unless score @s leave matches 1 store success score @s leave run t
### Bedrock
-In bedrock we don't have `execute store` so we will need to split the command in 2.
+In bedrock, we don't have `execute store` so we will need to split the command in 2.
| ๐ Note |
|---------|
|This method is the same as the 2 others merged, nothing else changed|
diff --git a/questions/playerkills.md b/questions/playerkills.md
index ddaca552..7266deb8 100644
--- a/questions/playerkills.md
+++ b/questions/playerkills.md
@@ -57,7 +57,7 @@ When the player kills a pig, they will run the function `example:kill_entity` as
## Bedrock
-In Bedrock this is much more tricky, as there is only the dummy objective type.
+In Bedrock, this is much more tricky, as there is only the dummy objective type.
The best way this Subreddit has come up with so far is to use a modified loot table, making the entity drop a certain item on death that they otherwise wouldn't drop. _This also works for players, but only if the `keepInventory` gamerule is false._ To change an entities loot table, you will have to modify their behavior file and change the loot table to be your custom one or replace their default loot table if they have one. Find the `minecraft:loot` component (or add it if it doesn't exist) and give it your custom loot table.
@@ -110,4 +110,4 @@ _Credit to [u/DanRileyCG](https://www.reddit.com/user/DanRileyCG/), for the orig
**If you don't have access to the files and are thus unable to create a behavior pack for this, there is a toned down version for player kills only that you can do.**
-It involves giving the player the special item into their inventory and making sure they drop it on death. To make it fool-proof / non-abuseable, there are a few more systems required (don't repeatedly replace it, or they could farm kills, only replace it if it's empty, don't award a kill if the player does have a bee nest in their inventory, etc.). Too much to go into in this wiki article, but here is a video where they show off one such system: [https://www.youtube.com/watch?v=zuhd3qEOJ1I](https://www.youtube.com/watch?v=zuhd3qEOJ1I). Keep in mind that this video uses the old `execute` syntax and it will need to be updated, see [this information](https://wiki.bedrock.dev/commands/new-execute.html) about the changes
\ No newline at end of file
+It involves giving the player the special item into their inventory and making sure they drop it on death. To make it fool-proof / non-abusable, there are a few more systems required (don't repeatedly replace it, or they could farm kills, only replace it if it's empty, don't award a kill if the player does have a bee nest in their inventory, etc.). Too much to go into in this wiki article, but here is a video where they show off one such system: [https://www.youtube.com/watch?v=zuhd3qEOJ1I](https://www.youtube.com/watch?v=zuhd3qEOJ1I). Keep in mind that this video uses the old `execute` syntax, and it will need to be updated, see [this information](https://wiki.bedrock.dev/commands/new-execute.html) about the changes
\ No newline at end of file
diff --git a/questions/randomnumber.md b/questions/randomnumber.md
index 615b8a3f..9b1706b7 100644
--- a/questions/randomnumber.md
+++ b/questions/randomnumber.md
@@ -15,7 +15,7 @@
| ๐ Note |
|---------|
-|**None of these numbers are truly random**. They are all only "pseudo" random (which means they only feel like they are random to a human, but are using some form of deterministic algorithm behind the scenes) because that's how computers work. They will be refered to "random" generator for simplicity. This likely won't affect your contraption, but it's important to point out|
+|**None of these numbers are truly random**. They are all only "pseudo" random (which means they only feel like they are random to a human, but are using some form of deterministic algorithm behind the scenes) because that's how computers work. They will be referred to "random" generator for simplicity. This likely won't affect your contraption, but it's important to point out|
## Bedrock
@@ -25,7 +25,7 @@ In Bedrock, you can use `scoreboard players random` to get a random number into
scoreboard players random
```
-So for example, from 1 to 10 in a score called `some_score`
+So, for example, from 1 to 10 in a score called `some_score`
```mcfunction
scoreboard players random @p some_score 1 10
@@ -90,16 +90,16 @@ For this special case, you don't need any of the random number methods, thanks t
---
| ๐ Note |
|---------|
-|The following information is outdated and should **not** be used in the current version of the game as there are better methods of randomess descrived above|
+|The following information is outdated and should **not** be used in the current version of the game, as there are better methods of randomness described above|
|The following methods should only be used in pre-1.20.2|
### 1: PRNG/LCG
Effective Range: Depends on the implementation, one of the ones on the discord server has [0, 130000]
-You can create a PRNG (pseudo random number generator, pseudo because it's not really random, but to a human it looks random enough) using just a few commands that do some math. Check out the [wikipedia about PRNGs](https://en.wikipedia.org/wiki/Pseudorandom_number_generator). The most common one and easiest to implement is probably the [linear congruential generator](https://en.wikipedia.org/wiki/Linear_congruential_generator).
+You can create a PRNG (pseudo random number generator, pseudo because it's not really random, but to a human it looks random enough) using just a few commands that do some math. Check out the [Wikipedia about PRNGs](https://en.wikipedia.org/wiki/Pseudorandom_number_generator). The most common one and easiest to implement is probably the [linear congruential generator](https://en.wikipedia.org/wiki/Linear_congruential_generator).
-If you don't want to do it yourself, you can go on the [discord](https://discord.gg/9wNcfsH) and check the #resources channel, there are a few PRNGs you can download and use in there. Alternatively you can [check out this post](https://www.reddit.com/r/MinecraftCommands/comments/vv68n6/tutorial_random_number_generator_by_scoreboard) by /u/mingshi3_uiuc for an implementation to copy.
+If you don't want to do it yourself, you can go on the [discord](https://discord.gg/9wNcfsH) and check the #resources channel, there are a few PRNGs you can download and use in there. Alternatively, you can [check out this post](https://www.reddit.com/r/MinecraftCommands/comments/vv68n6/tutorial_random_number_generator_by_scoreboard) by /u/mingshi3_uiuc for an implementation to copy.
_Probably the best listed method if the range is enough for you, as it creates the least amount of server strain while having a very high range that should be enough for most purposes._
@@ -107,17 +107,19 @@ _Probably the best listed method if the range is enough for you, as it creates t
Effective Range: [-2147483648, 2147483647]
-Minecraft already does a bunch of randomization. One of them is generating the UUIDs of entities. This means that you can summon a new entity, `execute store ... data get` to get the UUID and then use scoreboard operations to shrink it into your desired range. ***Note that even though the UUID value being returned is within the full integer range, the `%=` scoreboard operation changes it into a value that's `0` or greater. In versions before 1.13.1, this would also give you negative values.***
+Minecraft already does a bunch of randomization. One of them is generating the UUIDs of entities. This means that you can summon a new entity, `execute store ... data get` to get the UUID, and then use scoreboard operations to shrink it into your desired range. ***Note that even though the UUID value being returned is within the full integer range, the `%=` scoreboard operation changes it into a value that's `0` or greater. In versions before 1.13.1, this would also give you negative values.***
Let's assume there are two dummy scoreboards called `random` and `range` and we want a random score on the executing entity's `random` scoreboard, in the range of the entity's `range` scoreboard.
-Using the UUID method it could look like this:
+Using the UUID method, it could look like this:
- summon area_effect_cloud ~ ~ ~ {Tags:["random_uuid"]}
- execute store result score @s random run data get entity @e[type=area_effect_cloud,tag=random_uuid,limit=1] UUID[0] 1
- scoreboard players operation @s random %= @s range
- kill @e[type=area_effect_cloud,tag=random_uuid]
+```mcfunction
+summon area_effect_cloud ~ ~ ~ {Tags:["random_uuid"]}
+execute store result score @s random run data get entity @e[type=area_effect_cloud,tag=random_uuid,limit=1] UUID[0] 1
+scoreboard players operation @s random %= @s range
+kill @e[type=area_effect_cloud,tag=random_uuid]
+```
-_The second best option listed here. More taxing on the server due to it's creation and removal of entities as well as NBT access, so better limit its use as much as possible. Use only if Method 1 doesn't work for you or if you need a specifc player to always get the same random number (their uuid doesn't change)._
+_The second-best option listed here. More taxing on the server due to its creation and removal of entities as well as NBT access, so better limit its use as much as possible. Use only if Method 1 doesn't work for you or if you need a specific player to always get the same random number (their UUID doesn't change)._
***<1.16*** In versions before 1.16, UUIDs were split into two separate NBT tags called `UUIDLeast` and `UUIDMost`. To make the example above compatible, you'll need to replace the second command with this:
@@ -131,7 +133,7 @@ The NBT tags `UUIDLeast` and `UUIDMost` are both the size of a `long` (64 bits),
Effective Range: [0, 10000] (in theory all the way up to 2^(31)-1, but since you're summoning an entity which gets deleted instantly again for this to work, anything above a few thousand will likely lag your game).
-This method takes advantage of the fact that using `execute store` with the `loot spawn` command will return the amount of rolls the loot table did, because it summons that many item entities. So if we use a loot table that creates a 0 amount item, we can safely use it to get our random number without creating any items in the world. _The item entity is still created but immediately removed again! This is what limits the range of this method._
+This method takes advantage of the fact that using `execute store` with the `loot spawn` command will return the amount of rolls the loot table did, because it summons that many item entities. So if we use a loot table that creates a 0 amount item, we can safely use it to get our random number without creating any items in the world. _The item entity is still created, but immediately removed again! This is what limits the range of this method._
Example loot table:
@@ -166,7 +168,7 @@ Example loot table:
-Change the rolls to fit your desired range (not negative, 0 is allowed), and/or use the method described below to fit it into a range using modulo, so you don't need a different loottable for every different range.
+Change the rolls to fit your desired range (not negative, 0 is allowed), and/or use the method described below to fit it into a range using modulo, so you don't need a different loot table for every different range.
Command to get the value from the table:
@@ -174,7 +176,7 @@ Command to get the value from the table:
execute store result score @s run loot spawn ~ ~ ~ loot example:random_loot_table
```
-_The third best option, with a small effective range. Use only for smaller amounts of values and if methods 1 and 2 don't work for you._
+_The third-best option, with a small effective range. Use only for smaller amounts of values and if methods 1 and 2 don't work for you._
_Taken from [this](https://www.reddit.com/r/MinecraftCommands/comments/evoghb/another_rng_method/) post on the subreddit_.
@@ -184,13 +186,13 @@ _Taken from [this](https://www.reddit.com/r/MinecraftCommands/comments/evoghb/an
Effective Range: [0, 360]
-A way to get a random number before 1.13 in the range of up to 360 numbers was to summon an entity like a squid, kill it and check the rotation of the inksac item entity it just dropped, since that rotation is always random. It's very much deprecated now though, thanks to Number 2 in this list.
+A way to get a random number before 1.13 in the range of up to 360 numbers was to summon an entity like a squid, kill it and check the rotation of the ink sac item entity it just dropped, since that rotation is always random. It's very much deprecated now, though, thanks to Number 2 in this list.
### 5: @r / @e[sort=random]
Effective Range: [0, 10] (theoretically infinite, but practically anything above 10 is not worth it)
-Before we got the (arguably much better) solutions above, we could use `@e[limit=1,sort=random,tag=randomizer]` to select a random entity, which we would've each given their respective scoreboard score (or put the commandblock to be triggered below them or something similar). This has the obvious disadvantage, that you'll need one entity per possible score. as long as it's below 10 this is still doable, anything above does get tedious. To avoid performance issues, use a [marker entity](https://minecraft.wiki/w/Marker).
+Before we got the (arguably much better) solutions above, we could use `@e[limit=1,sort=random,tag=randomizer]` to select a random entity, which we would've each given their respective scoreboard score (or put the commandblock to be triggered below them or something similar). This has the obvious disadvantage, that you'll need one entity per possible score. As long as it's below 10 this is still doable, anything above does get tedious. To avoid performance issues, use a [marker entity](https://minecraft.wiki/w/Marker).
### 6: spreadplayers
@@ -198,24 +200,24 @@ Before we got the (arguably much better) solutions above, we could use `@e[limit
Effective Range: [0, 100] (theoretically 900000000000000 if you're using every single block in a minecraft world as a position, practically even 100 is a stretch)
-Another Minecraft-included way for randomisation is `/spreadplayers`, which will position an entity randomly over a predefined area. Depending on where it lands you could have a commandblock below triggered for it to then run the desired commands. Seems to have a bias agains the edges of the area, so make the spreadplayers area in the command bigger than the actual possible spawning spaces.
+Another Minecraft-included way for randomisation is `/spreadplayers`, which will position an entity randomly over a predefined area. Depending on where it lands, you could have a commandblock below triggered for it to then run the desired commands. Seems to have a bias against the edges of the area, so make the spreadplayers area in the command bigger than the actual possible spawning spaces.
-A different way to use the spreadplayers randomisation is to `data get` the position the entity ends up on. This only works reliably in loaded chunks. Since spreadplayers does load the chunk the entity is placed in briefly, it _may_ work when using a function or chained commands, but this method of chunkloading has been quite unreliable in the past.
+A different way to use the spreadplayers randomisation is to `data get` the position the entity ends up on. This only works reliably in loaded chunks. Since spreadplayers does load the chunk the entity is placed in briefly, it _may_ work when using a function or chained commands, but this method of chunk loading has been quite unreliable in the past.
### 7: running score
-A very primitive way to get somewhat random numbers but probably the easiest one. It relies on time to get a random number, so this is not applicable for when random numbers are needed in predefined time lengths (X amount of ticks, maybe even the same tick) and **it is advised not to use this**, as there are much better alternatives. How it works is you basically count up a scoreboard from the minimum to the maximum random number, incrementing by one per tick and resetting it to the minimum once you reached the maximum. Then to get a "random" number you just take whatever number this running score happens to be on at that moment.
+A very primitive way to get somewhat random numbers but probably the easiest one. It relies on time to get a random number, so this is not applicable for when random numbers are needed in predefined time lengths (X amount of ticks, maybe even the same tick) and **it is advised not to use this**, as there are much better alternatives. How it works is you basically count up a scoreboard from the minimum to the maximum random number, incrementing by one per tick and resetting it to the minimum once you reached the maximum. Then to get a "random" number, you just take whatever number this running score happens to be on at that moment.
### Get the number into the desired range
-Many of the generators above have a range that only covers positive numbers, reaching from 0 up to X. But what if you need a random number between 5 and 15? what about -10 and 10?
+Many of the generators above have a range that only covers positive numbers, reaching from 0 up to X. But what if you need a random number between 5 and 15? What about -10 and 10?
-The answer is very simple: you just shift the result up or down by applying an addition or substraction.
+The answer is very simple: you just shift the result up or down by applying an addition or subtraction.
-`max-min = needed range`, so to get from the result to the desired range we can simply do `result + min = needed range`.
+`max-min = needed range`, so to get from the result to the desired range, we can simply do `result + min = needed range`.
Let's suppose for an example that we're trying to get a score between min=-10 and max=10. That means we have a needed range of `10 - (-10) = [0,20]`. So we set up our RNG to create a number between 0 and 20.
-Then we shift the result down by 10 by adding the -10 (or substracting the 10): `[0,20] + (-10) = [-10,10]`.
+Then we shift the result down by 10 by adding the -10 (or subtracting the 10): `[0,20] + (-10) = [-10,10]`.
Another example on how to get numbers between 5 and 15:
needed: `15-5=[0,10]`
diff --git a/questions/raycast.md b/questions/raycast.md
index 79d42d97..6dc4a15d 100644
--- a/questions/raycast.md
+++ b/questions/raycast.md
@@ -35,7 +35,7 @@ You can generate a raycasting datapack using this generator: https://sourceblock
### Without an entity
-This is the preferred method of raycasting, as this entityless approach causes less strain on the server and you don't need to clean up the used entity afterwards. Of course you can still summon an entity to mark the position you've found for later usage, but it is often encouraged to do it all in a single tick.
+This is the preferred method of raycasting, as this entityless approach causes less strain on the server, and you don't need to clean up the used entity afterwards. Of course, you can still summon an entity to mark the position you've found for later usage, but it is often encouraged to do it all in a single tick.
This method only works in a single tick, so if you need the raycast to be over a period of time instead of instantaneous, use the entity based method instead. It also requires functions to work, so if you're unable to use a datapack, you also need to use the other method.
@@ -45,7 +45,7 @@ First, the command that will initiate a raycast. We're anchoring the execution p
execute as at @s anchored eyes positioned ^ ^ ^ anchored feet run function namespace:start_ray
```
-Next up, the ray setup. We need to set a maximum amount of steps that we can go before we abort our search. This means we can just set a score to the maximum amount of steps. Here, a `dummy` scoreboard named `ray_steps` is used. It's set to 50 steps, so a maximum distance of 5 blocks considering our step distance is 0.1 blocks per step (which is also the reach distance of a player). We also want to store whether our ray successfully hit something, so we know whether to continue or to stop. In this case another `dummy` objective is used, called `ray_success`. Instead of two scoreboards you can also use a single scoreboard and use [fake players](/wiki/questions/fakeplayer) to store the scores.
+Next up, the ray setup. We need to set a maximum amount of steps that we can go before we abort our search. This means we can just set a score to the maximum amount of steps. Here, a `dummy` scoreboard named `ray_steps` is used. It's set to 50 steps, so a maximum distance of 5 blocks considering our step distance is 0.1 blocks per step (which is also the reach distance of a player). We also want to store whether our ray successfully hit something, so we know whether to continue or to stop. In this case, another `dummy` objective is used, called `ray_success`. Instead of two scoreboards, you can also use a single scoreboard and use [fake players](/wiki/questions/fakeplayer) to store the scores.
```mcfunction
# function example:start_ray
@@ -54,7 +54,7 @@ scoreboard players set @s ray_success 0
function example:ray
```
-Next, the actual ray is being cast. For that, we first check whether our stopping condition has been achieved and run a success function if we did. Next, we count up the steps we can still take by 1. And lastly, we run the function again, moved forward by our step size, if we neither hit the stopping condition nor the maximum step size. In this example the stopping condition is hitting a block that is not air.
+Next, the actual ray is being cast. For that, we first check whether our stopping condition has been achieved and run a success function if we did. Next, we count up the steps we can still take by 1. And lastly, we run the function again, moved forward by our step size, if we neither hit the stopping condition nor the maximum step size. In this example, the stopping condition is hitting a block that is not air.
```mcfunction
# function example:ray
@@ -63,7 +63,7 @@ scoreboard players remove @s ray_steps 1
execute if score @s ray_steps matches 1.. if score @s ray_success matches 0 positioned ^ ^ ^0.1 run function example:ray
```
-Lastly, we can use the success function to run whatever we intend to do at the found place. In this case we'll just set a stone block. _Make sure to set the `ray_success` score to 1 at some point in the function though!_
+Lastly, we can use the success function to run whatever we intend to do at the found place. In this case, we'll just set a stone block. _Make sure to set the `ray_success` score to 1 at some point in the function, though!_
```mcfunction
# function example:hit_block
@@ -190,9 +190,9 @@ kill @e[type=xp_orb,tag=!ignore]
-The 4th command is where the magic happens: Due to us splitting the execution path into 2, every time `as @e[c=2]` is called, we're essentially doubling the executions over and over. So because we're calling it 9 times, the rest of the command will be run 2^9 = 512 times. You can adjust this accordingly to your needs. In this case we're moving the ray forwards by 0.1 blocks (thus, to a maximum of 51.2 blocks), only if we can move into the block there (as denoted by the `true` at the end of the tp command). Thus, this command would cause us to find the next solid block the player is looking at (in a 51 block radius).
+The 4th command is where the magic happens: Due to us splitting the execution path into 2, every time `as @e[c=2]` is called, we're essentially doubling the executions over and over. So because we're calling it 9 times, the rest of the command will be run 2^9 = 512 times. You can adjust this accordingly to your needs. In this case we're moving the ray forwards by 0.1 blocks (thus, to a maximum of 51.2 blocks), only if we can move into the block there (as denoted by the `true` at the end of the `tp` command). Thus, this command would cause us to find the next solid block the player is looking at (in a 51 block radius).
-So, for different applications you'd modify the 4th command to find different things. For example, to stop moving if there is a creeper (feet) close by, going through blocks, the command could look like this:
+So, for different applications, you'd modify the 4th command to find different things. For example, to stop moving if there is a creeper (feet) close by, going through blocks, the command could look like this:
```mcfunction
execute as @e[c=2] ... as @e[c=2] as @e[type=xp_orb,tag=!ignore] at @s positioned ^^^0.1 unless entity @e[type=creeper,r=1] at @s run tp @s ^^^0.1
diff --git a/questions/scorecompare.md b/questions/scorecompare.md
index a34f5a50..a5bc9b27 100644
--- a/questions/scorecompare.md
+++ b/questions/scorecompare.md
@@ -104,13 +104,13 @@ This now allows to compare values more accurately because it supports non-intege
### 1.15 and above
-Since version 1.15 you can also use [predicates](https://minecraft.wiki/w/Predicate) in a datapack to compare scores. Unlike using the `if score` subcommand, you cannot, in most cases, compare the score values between two entities. Basically this is only available in mob loot tables and you can only compare the score between the killed mob (`this`) and the entity that killed the mob (`killer` / `killer_player`), or the projectile that killed the mob (`direct_killer`). In other cases, you can only check the score of the selected entity (`this`) and score [fakename](/wiki/questions/fakeplayer).
+Since version 1.15 you can also use [predicates](https://minecraft.wiki/w/Predicate) in a datapack to compare scores. Unlike using the `if score` subcommand, you cannot, in most cases, compare the score values between two entities. Basically this is only available in mob loot tables, and you can only compare the score between the killed mob (`this`) and the entity that killed the mob (`killer` / `killer_player`), or the projectile that killed the mob (`direct_killer`). In other cases, you can only check the score of the selected entity (`this`) and score [fakename](/wiki/questions/fakeplayer).
You can compare scores in a predicate using the `minecraft:entity_scores` condition to compare the score of the selected entity with a specific value or a specified range of values, as well as using the `minecraft:value_check` condition, which does the same thing, but without using the entity.
But you can't just use comparison operators (=, >, <, >=, <=), but only compare whether the value is in the specified range.
-For `entity_score` condition, you can compare the value of the selected entity with an exact value specified manually or a range (`min` and `max`). When using range can use for each min and max:
+For `entity_score` condition, you can compare the value of the selected entity with an exact value specified manually or a range (`min` and `max`). When using range, can use for each min and max:
- exact value (supports non-integer values)
- [binomial distribution](https://en.wikipedia.org/wiki/Binomial_distribution)
diff --git a/questions/shootfacing.md b/questions/shootfacing.md
index d23960b2..1241e233 100644
--- a/questions/shootfacing.md
+++ b/questions/shootfacing.md
@@ -6,7 +6,7 @@
- [Method 2: Storing all values (for easier manipulation)](#method-2-storing-all-values-for-easier-manipulation)
- [Visual bug fix](#visual-bug-fix)
-*Java only. This doesn't work in bedrock and there are currently no known workarounds.*
+*Java only. This doesn't work in bedrock, and there are currently no known workarounds.*
***Advanced**. It is highly recommended that you use functions for this and already know how `execute at` and `execute as` works!*
@@ -20,17 +20,17 @@ Shooting a projectile/entity in the direction a player is facing is not trivial,
### Explanation
-Sounds complicated, but is actually pretty easy. The end goal is to find the correct Motion values to apply to the entity for it to fly into the correct direction. Motion is a three dimensional vector, where each axis corresponds to one of the ingame directions: `Motion:[xMotion,yMotion,zMotion]`. Each value is limited to [-10..10] and will be clamped to these values if you go above or below this limit. A value of 1 means a motion of 1 block per tick in that axis positive direction. Motion will also automatically be changed by the games physics engine, so we only need to set the initial motion and the rest will happen by itself.
+Sounds complicated, but is actually pretty easy. The end goal is to find the correct Motion values to apply to the entity for it to fly into the correct direction. Motion is a three-dimensional vector, where each axis corresponds to one of the in game directions: `Motion:[xMotion,yMotion,zMotion]`. Each value is limited to [-10..10] and will be clamped to these values if you go above or below this limit. A value of 1 means a motion of 1 block per tick in that axis positive direction. Motion will also automatically be changed by the game's physics engine, so we only need to set the initial motion and the rest will happen by itself.
-To find the correct Motion to apply, we need to find the difference between the position the entity starts in and the position the entity should be in the next tick after that (because that's how far it's supposed to move in this one tick). Luckily, we can get both of these positions from the local coordinates (`^ ^ ^`) of the shooting player. For the following examples we'll assume the entity should be shot out with a speed of 1 block per tick in the direction the player is facing (`^ ^ ^1`), but this can be altered to your liking (but remember the limit of 10 in the motion tag!).
+To find the correct Motion to apply, we need to find the difference between the position the entity starts in and the position the entity should be in the next tick after that (because that's how far it's supposed to move in this one tick). Luckily, we can get both of these positions from the local coordinates (`^ ^ ^`) of the shooting player. For the following examples, we'll assume the entity should be shot out with a speed of 1 block per tick in the direction the player is facing (`^ ^ ^1`), but this can be altered to your liking (but remember the limit of 10 in the motion tag!).
-So, we can get the players location using its `Pos` NBT values and we can summon an entity `^ ^ ^1` blocks in front of the player, using its `Pos` attribute to get the second position and thus we know starting position P and target position T. From here vector calculations tell us that to get the movement vector V between those two points, all we need to do is T - P = V for each value individually (T.x - P.x = V.x etc.). Then we have V and can store it into the Motion values of our entity.
+So, we can get the players' location using its `Pos` NBT values, and we can summon an entity `^ ^ ^1` blocks in front of the player, using its `Pos` attribute to get the second position, and thus we know starting position P and target position T. From here vector calculations tell us that to get the movement vector V between those two points, all we need to do is T - P = V for each value individually (T.x - P.x = V.x etc.). Then we have V and can store it into the Motion values of our entity.
-----
## Method 1: Let the game do the math for us by using the zero point (simplified)
-Or rather, make use of the fact that we can use the worlds zero position and pretend the player is there. And because X - 0 = X, we don't need to do the math ourselves but can directly store the result into the entity. Here is how it works (running `as` and `at` the player):
+Or rather, make use of the fact that we can use the world's zero position and pretend the player is there. And because X - 0 = X, we don't need to do the math ourselves but can directly store the result into the entity. Here is how it works (running `as` and `at` the player):
See example
@@ -54,7 +54,7 @@ kill @e[tag=direction]
-**This method requires the worlds `0 0 0` point to be loaded to work. If that is not the case or cannot be guaranteed, use the following modification instead (still `as` and `at` the player).** It ensures that the marker entity doesn't get lost along the way by being teleported to unloaded chunks. Luckily the `@s` selector is able to still select the entity even if it was unloaded, which means we can do it as follows.
+**This method requires the worlds `0 0 0` point to be loaded to work. If that is not the case or cannot be guaranteed, use the following modification instead (still `as` and `at` the player).** It ensures that the marker entity doesn't get lost along the way by being teleported to unloaded chunks. Luckily, the `@s` selector is able to still select the entity even if it was unloaded, which means we can do it as follows.
See example
@@ -95,14 +95,15 @@ kill @s
Since version 1.19.4 you can use `summon` inside the `/execute` command, which allows you to simplify shootfacing and combine the command of calling the direction of an entity and modifying the `Motion` tag of the projectile.
-Now, instead of a marker that must be manually killed, you can use area_effect_cloud, which will disappear on its own on the next tick. Also, force loaded coordinates 0 0 0 are no longer required to work, since we are creating and using direction entities within one command, but it is still strongly recommended to load chunks [-1, -1] to [0, 0], since area_effect_cloud will not be deleted in unloaded chunks automatically.
+Now, instead of a marker that must be manually killed, you can use area_effect_cloud, which will disappear on its own on the next tick. In recent versions, this is no longer the case, but we can still set the `Duration` data to 0 after spawning with `execute store`. In older versions, you can remove `store sucess entity @s Duration int 0` from this tutorial.
+Also, force loaded coordinates 0 0 0 are no longer required to work, since we are creating and using direction entities within one command, but it is still strongly recommended to load chunks [-1, -1] to [0, 0], since `area_effect_cloud` will not be deleted in unloaded chunks automatically.
```mcfunction
# Summon the projectile entity
summon sheep ~ ~ ~ {Tags:["projectile"]}
# Use player rotation to create an area_effect_cloud of about 0 0 and immediately copy the position of this entity into the projectile motion tag.
-execute rotated as positioned 0.0 0.0 0.0 positioned ^ ^ ^1 summon area_effect_cloud run data modify entity @e[tag=projectile,limit=1] Motion set from entity @s Pos
+execute rotated as positioned 0.0 0.0 0.0 positioned ^ ^ ^1 summon area_effect_cloud store sucess entity @s Duration int 0 run data modify entity @e[tag=projectile,limit=1] Motion set from entity @s Pos
# Remove projectile tag
tag @e[tag=projectile] remove projectile
@@ -110,12 +111,12 @@ tag @e[tag=projectile] remove projectile
`^ ^ ^1` is used as the throw strength.
-You can go ahead and do this using almost just one command block. You can perform all settings using `store success entity`. For example, for a fireball, you can immediately set ExplosionPower and power[1] so that the projectile does not fly in a straight line, but in an arc:
+You can go ahead and do this using almost just one command block. You can perform all settings using `store success entity`. For example, for a fireball, you can immediately set `ExplosionPower` and `power[1]` so that the projectile does not fly in a straight line, but in an arc:
```mcfunction
# Command blocks
tag @e[type=fireball,tag=!exist] add exist
-execute as at @s anchored eyes positioned ^ ^ ^3 summon fireball store success entity @s ExplosionPower byte 4 store success entity @s power[1] double -0.08 positioned 0.0 0.0 0.0 positioned ^ ^ ^1 summon area_effect_cloud run data modify entity @e[type=fireball,tag=!exist,limit=1] Motion set from entity @s Pos
+execute as at @s anchored eyes positioned ^ ^ ^3 summon fireball store success entity @s ExplosionPower byte 4 store success entity @s power[1] double -0.08 positioned 0.0 0.0 0.0 positioned ^ ^ ^1 summon area_effect_cloud store sucess entity @s Duration int 0 run data modify entity @e[type=fireball,tag=!exist,limit=1] Motion set from entity @s Pos
```
However, you may notice that this projectile lags in flight. Read about how to fix this in the [\[Visual bug fix\]](#visual-bug-fix) section.
@@ -124,9 +125,9 @@ However, you may notice that this projectile lags in flight. Read about how to f
## Method 2: Storing all values (for easier manipulation)
-*Please note that you probably shouldn't be using this method if method 1 covers your usecase.*
+*Please note that you probably shouldn't be using this method if method 1 covers your use case.*
-This example will assume you have a dummy scoreboard objective set up that is named `pos` and that you're running these commands `as` and `at` the player (in a function). Whenever you see `#` this is a [fake player](/wiki/questions/fakeplayer) that we use for convenient value storage. Because scoreboards can only hold integer values (whole numbers), we scale up the values by 1000 when storing them and down by 0.001 when putting them back into the Motion tag so we don't lose too much accuracy. We need to use scoreboards however, because we need to do some subtractions which is only conveniently possible with scoreboard operations. (This means that the system will stop working once you go above a position of 2'000'000 on either axis, if that is a concern, change it to 100/0.01, that way you can reach 2/3 to the worldborder without issues.)
+This example will assume you have a dummy scoreboard objective set up that is named `pos` and that you're running these commands `as` and `at` the player (in a function). Whenever you see `#` this is a [fake player](/wiki/questions/fakeplayer) that we use for convenient value storage. Because scoreboards, can only hold integer values (whole numbers), we scale up the values by 1000 when storing them and down by 0.001 when putting them back into the Motion tag so we don't lose too much accuracy. We need to use scoreboards however, because we need to do some subtractions which is only conveniently possible with scoreboard operations. (This means that the system will stop working once you go above a position of 2'000'000 on either axis, if that is a concern, change it to 100/0.01, that way you can reach 2/3 to the worldborder without issues.)
See example
@@ -189,7 +190,7 @@ forceload add -1 -1 0 0
execute as @e[tag=projectile] store result entity @s Air short 1 run time query gametime
tag @e[tag=projectile] remove projectile
execute as @a[scores={click=1..}] at @s anchored eyes run summon snowball ^ ^ ^ {Tags:["projectile"]}
-execute rotated as @a[scores={click=1..}] positioned 0.0 0.0 0.0 positioned ^ ^ ^1 summon minecraft:area_effect_cloud run data modify entity @e[tag=projectile,limit=1] Motion set from entity @s Pos
+execute rotated as @a[scores={click=1..}] positioned 0.0 0.0 0.0 positioned ^ ^ ^1 summon area_effect_cloud store sucess entity @s Duration int 0 run data modify entity @e[tag=projectile,limit=1] Motion set from entity @s Pos
scoreboard players reset @a click
```
@@ -208,7 +209,7 @@ execute anchored eyes positioned ^ ^ ^ summon snowball run function example:shoo
# function example:shootfacing
tag @s add this
-execute positioned 0.0 0.0 0.0 positioned ^ ^ ^1 summon minecraft:area_effect_cloud run data modify entity @e[tag=this,limit=1] Motion set from entity @s Pos
+execute positioned 0.0 0.0 0.0 positioned ^ ^ ^1 summon area_effect_cloud store sucess entity @s Duration int 0 run data modify entity @e[tag=this,limit=1] Motion set from entity @s Pos
tag @s remove this
tag @s add fix
schedule function example:fix 2t replace
diff --git a/questions/shop.md b/questions/shop.md
index 1be5f9d0..3248979e 100644
--- a/questions/shop.md
+++ b/questions/shop.md
@@ -26,12 +26,12 @@ _Related:_ [Count how much of X item the player has](/wiki/questions/amountitems
### Java
#### Using commands
-First we figure out how many diamonds the player has and store the value in a scoreboard. If the player has the required number of diamonds we give the netherite ingot and clear the diamonds from them.
+First, we figure out how many diamonds the player has and store the value in a scoreboard. If the player has the required number of diamonds, we give the netherite ingot and clear the diamonds from them.
-Using command blocks we need to make sure we select the correct player every time, so with the first command we tag the relevant player to later limit our selector to that player.
+Using command blocks, we need to make sure we select the correct player every time, so with the first command we tag the relevant player to later limit our selector to that player.
-To avoid the player getting unintentionally re-selected we remove the tag at the end.
-Using functions we can rely on `@s` instead, assuming the function is executed `as` the relevant player.
+To avoid the player getting unintentionally re-selected, we remove the tag at the end.
+Using functions, we can rely on `@s` instead, assuming the function is executed `as` the relevant player.
```mcfunction
# Command blocks
@@ -65,8 +65,8 @@ tellraw @s {"text":"You bought a netherite ingot for 5 diamonds","color":"green"
|--------------|
|The function `example:buy/netherite` must be run `as` the player|
-In 1.20.5 `execute if items` was added, which allows to count items in a diferent way.
-To use this method, all command remains the same, as the previus example except the one for counting items that is this one:
+In 1.20.5 `execute if items` was added, which allows to count items in a different way.
+To use this method, all command remains the same, as the previous example except the one for counting items that is this one:
```mcfunction
execute as @a[tag=buyer.netherite] store result score @s diamonds run clear @s diamond 0
@@ -85,27 +85,27 @@ execute store result score @s diamonds if items entity @s container.* diamond
| ๐ Note |
|--------------|
-|The method that uses the `/clear` command will work in 1.20.5+ but it is recomended to use the one specific for that versions (using `execute if items`, that will not work below 1.20.5)|
+|The method that uses the `/clear` command will work in 1.20.5+ but it is recommended to use the one specific for that versions (using `execute if items`, that will not work below 1.20.5)|
#### Using a villager
Villagers are a passive mob that can be interacted with, and will open the trading GUI.
We can use this vanilla functionality to add our custom trades.
-This can be done by manually typing the command, but it is recomeneded to use an [online generator](https://mcstacker.net) to generate the command with ease.
+This can be done by manually typing the command, but it is recommeneded to use an [online generator](https://mcstacker.net) to generate the command with ease.
This method has some advantages and disadvantages.
**Advantages:**
-* Easy to set up, it only require a summon command.
+* Easy to set up, it only requires a summon command.
* It does not cause performance issues, as we don't run any commands.
**Disadvantages:**
* Need to be interacted. You can't force the player to buy that item.
-* Limited to give 2 items to get one (workarrounds are possible, like giving a shulker box with items in it).
-* You can't show a succes message (workarrounds are possible).
+* Limited to give 2 items to get one (workarounds are possible, like giving a shulker box with items in it).
+* You can't show a success message (workarounds are possible).
* It is linked to a place, unless you teleport the villager to the player.
-* 2 players can't acces the trading screen at the same time.
+* 2 players can't access the trading screen at the same time.
Here is an example command:
```mcfunction
@@ -132,9 +132,9 @@ Here is the same command but for pre-1.20.5, using nbt data instead:
```
### Bedrock
-In bedrock we have the `hasitem` argument, so it uses less commands than in Java.
+In bedrock, we have the `hasitem` argument, so it uses fewer commands than in Java.
-If you don't want to use an NPC can use this method, it is very similar to Java but it uses the `hasitem` argument instead.
+If you don't want to use an NPC can use this method, it is very similar to Java, but it uses the `hasitem` argument instead.
```mcfunction
# Command blocks
@@ -142,24 +142,24 @@ tag @p add buyer.netherite
give @a[tag=buyer.netherite,hasitem={item=diamond,quantity=5..}] netherite_ingot
tellraw @a[tag=buyer.netherite,hasitem={item=diamond,quantity=5..}] {"rawtext":[{"text":"ยง2You bought a netherite ingot"}]}
tellraw @a[tag=buyer.netherite,hasitem={item=diamond,quantity=..5}] {"rawtext":[{"text":"ยง3You don't have 5 diamonds"}]}
-clear @a[tag=buyer.netherite,hasitem={item=diamond,quantity=5..}] diamond 5
+clear @a[tag=buyer.netherite,hasitem={item=diamond,quantity=5..}] diamond -1 5
tag @a remove buyer.netherite
```
| ๐ Note |
|--------------|
-|in order for it to work with npc, change `@p` and `@a` to `@initiator`|
-|_Related: [How to setup a NPC?](/wiki/questions/npc)_|
+|in order for it to work with NPC, change `@p` and `@a` to `@initiator`|
+|_Related: [How to set up a NPC?](/wiki/questions/npc)_|
| ๐ Note |
|--------------|
|It is super important to clear the diamonds in the last step before removing the tag|
### Add more than one items
-In this gide we will use just one item, but you can have multiples but it will require a second tag, that must be added if the player has both items.
-Then when we clear the items we are going to clear them for the player with that tag.
+In this guide we will use just one item, but you can have multiples, but it will require a second tag, that must be added if the player has both items.
+Then when we clear the items, we are going to clear them for the player with that tag.
-In this example we will buy a gold block with 2 emeralds and 5 diamonds. If you are in Java you will need one scoreboard for each item, assuming you already store the items result in each one.
+In this example, we will buy a gold block with 2 emeralds and 5 diamonds. If you are in java, you will need one scoreboard for each item, assuming you already store the items result in each one.
```mcfunction
# Command blocks
@@ -170,12 +170,12 @@ clear @a[tag=buy.example] diamond 5
clear @a[tag=buy.example] emerald 2
give @a[tag=buy.example] gold_block 1
-# And then we remove all the previus used tags
+# And then we remove all the previous used tags
tag @a remove buy.example
tag @a remove buyer.example
```
-In bedrock use the `hasitem` argument instead of `scores`
+In bedrock, use the `hasitem` argument instead of `scores` and add `-1` after the item ID to clear (this is the data value).
## Score shop
This method uses a scoreboard as a currency (such as `coins` for this example) and you can buy items with that currency. In this example, you can buy a `diamond` with 10 `coins`.
@@ -183,7 +183,7 @@ You can adjust the items and the prices by editing the command item and quantity
### Java and Bedrock
When the player wants to buy the item, run this commands in order. It can be achieved with a button, an impulse command block and a chain of command blocks behind as an example.
-In this example the currency is a `dummy` scoreboard called `coins`.
+In this example, the currency is a `dummy` scoreboard called `coins`.
#### With command blocks
@@ -217,4 +217,4 @@ tellraw @s {"text":"You bought a diamond","color":"green"}
| ๐ Note |
|--------------|
-|The function `example:buy/diamond` must be run `as` the player|
\ No newline at end of file
+|The function `example:buy/diamond` must be run `as` the player|
diff --git a/questions/storeinventory.md b/questions/storeinventory.md
index f64c12e6..373d14e9 100644
--- a/questions/storeinventory.md
+++ b/questions/storeinventory.md
@@ -1,4 +1,4 @@
-# Store a players inventory and return it to them at some point
+# Store a player's inventory and return it to them at some point
- [Bedrock](#bedrock)
- [Custom Hopper Entity](#custom-hopper-entity)
@@ -21,7 +21,7 @@ Thus, in your case **it might be easier to just give every player a double chest
## Bedrock
-To get the items from the player, you need to kill them with the `keepinventory` gamerule switched off. Now the question is how you can store the items and give them back at a later point. (Turning on `immediateRespawn` and `showDeathMessages` off helps with making this more seemless for the player.)
+To get the items from the player, you need to kill them with the `keepinventory` gamerule switched off. Now the question is how you can store the items and give them back at a later point. (Turning on `immediateRespawn` and `showDeathMessages` off helps with making this more seamless for the player.)
For this, you need to put them somewhere in a confined space, so the items don't spill everywhere, and you also need to make sure only one player gets put into that area at a time, so the items don't get mixed up.
@@ -72,13 +72,13 @@ For convenience, we can create a single event that deals with both of these comp
}
```
-For a better performance however I recommend to remove the item_hopper component once you're done picking up the items through a dedicated event.
+For a better performance however, it is recommend removing the item_hopper component once you're done picking up the items through a dedicated event.
You are now ready to get the items out of the player, let them be picked up by your custom entity, link them through a [scoreboard ID system](/wiki/questions/linkentity) (aka giving the entity and the player the same id score) and after the game is over, teleport the entity and the player into the same room and kill the entity (through the `/event` described above).
### `/structure`
-One option that allows for an ingame solution (commands only, so without the need to make an add-on) would be to save the item entities in a structure using the `/structure save` command, and giving them back using `/structure load`.
+One option that allows for an in game solution (commands only, so without the need to make an add-on) would be to save the item entities in a structure using the `/structure save` command, and giving them back using `/structure load`.
This has the **disadvantage** that structure names cannot be dynamic, so you have to hardcode all structure names that you intend to use at some point. This also means that you're very much limited in the amount of concurrently stored player inventories to the amount of structures you hardcoded.
@@ -88,9 +88,9 @@ Please note that while an add-on isn't necessarily required for this solution, u
## Java
-Luckily in Java we don't have to go through what is essentially a custom hopper minecart, killing the player to get their items. Instead we can use `NBT` to solve this issue for us. _Usage of functions is highly recommended and is expected for this explanation._
+Luckily, in Java we don't have to go through what is essentially a custom hopper minecart, killing the player to get their items. Instead, we can use `NBT` to solve this issue for us. _Usage of functions is highly recommended and is expected for this explanation._
-There are community made datapacks that do the heavy lifting for you like [PlayerDB](https://rx-modules.github.io/PlayerDB).
+There are community made datapacks that do the heavy lifting for you, like [PlayerDB](https://rx-modules.github.io/PlayerDB).
### Storing
@@ -99,9 +99,9 @@ There are community made datapacks that do the heavy lifting for you like [Playe
#### In storage
-Since version 1.20.2, [macro](https://minecraft.wiki/w/Function_(Java_Edition)#Macros) have been added that allow you to insert any data into any part of the command, making storing/returning easier.
+Since version 1.20.2, [macros](https://minecraft.wiki/w/Function_(Java_Edition)#Macros) have been added that allow you to insert any data into any part of the command, making storing/returning easier.
-Below is an example of storing a player's inventory in storage using the [scoreboard ID system](/wiki/questions/linkentity), or you can store the UUID / nickname instead of using the scoreboard ID system. To do this you need to run the function `example:storing` as a player.
+Below is an example of storing a player's inventory in storage using the [scoreboard ID system](/wiki/questions/linkentity), or you can store the UUID / nickname instead of using the scoreboard ID system. To do this, you need to run the function `example:storing` as a player.
See example
@@ -128,11 +128,57 @@ This player data storage system will create an in storage `example:inv` object f
However, this implementation can support any data other than player `ID` and `Inventory` and you can easily add saving any other data.
+In 1.21.5, all of the NBT paths for equipment slots (except for mainhand in players) were moved to the equipment map.
+e.g.
+`Inventory[{Slot:-106b}]` moved to `equipment.offhand`
+`Inventory[{Slot:100b}]` moved to `equipment.feet`
+etc.
+In order to account for this, some small tweaks are needed in order for proper storing and loading of items in offhand and armor slots to occur. One implementation of that is shown below.
+
+
+ See datapack
+
+```mcfunction
+# function example:storing
+data remove storage example:inv this
+
+execute store result storage example:inv this.ID int 1 run scoreboard players get @s ID
+
+data modify storage example:inv this.Inventory set from entity @s Inventory
+
+data modify storage example:inv this.Equipment[{equipment:"weapon.offhand"}] merge from entity @s equipment.offhand
+data modify storage example:inv this.Equipment[{equipment:"weapon.offhand"}] merge value {Slot:0b}
+execute unless data entity @s equipment.offhand run data modify storage example:inv this.Equipment[{equipment:"weapon.offhand"}] set value {Slot:0b,count:1,equipment:"weapon.offhand",id:"minecraft:air"}
+
+data modify storage example:inv this.Equipment[{equipment:"armor.feet"}] merge from entity @s equipment.feet
+data modify storage example:inv this.Equipment[{equipment:"armor.feet"}] merge value {Slot:1b}
+execute unless data entity @s equipment.feet run data modify storage example:inv this.Equipment[{equipment:"armor.feet"}] set value {Slot:1b,count:1,equipment:"armor.feet",id:"minecraft:air"}
+
+data modify storage example:inv this.Equipment[{equipment:"armor.legs"}] merge from entity @s equipment.legs
+data modify storage example:inv this.Equipment[{equipment:"armor.legs"}] merge value {Slot:2b}
+execute unless data entity @s equipment.legs run data modify storage example:inv this.Equipment[{equipment:"armor.legs"}] set value {Slot:2b,count:1,equipment:"armor.legs",id:"minecraft:air"}
+
+data modify storage example:inv this.Equipment[{equipment:"armor.chest"}] merge from entity @s equipment.chest
+data modify storage example:inv this.Equipment[{equipment:"armor.chest"}] merge value {Slot:3b}
+execute unless data entity @s equipment.chest run data modify storage example:inv this.Equipment[{equipment:"armor.chest"}] set value {Slot:3b,count:1,equipment:"armor.chest",id:"minecraft:air"}
+
+data modify storage example:inv this.Equipment[{equipment:"armor.head"}] merge from entity @s equipment.head
+data modify storage example:inv this.Equipment[{equipment:"armor.head"}] merge value {Slot:4b}
+execute unless data entity @s equipment.head run data modify storage example:inv this.Equipment[{equipment:"armor.head"}] set value {Slot:4b,count:1,equipment:"armor.head",id:"minecraft:air"}
+
+function example:storing/update with storage example:inv this
+
+# function example:storing/update
+$execute unless data storage example:inv players[{ID:$(ID)}] run data modify storage example:inv players append value {ID:$(ID)}
+$data modify storage example:inv players[{ID:$(ID)}] merge from storage example:inv this
+```
+
+
#### In marker entity
-The way to do this is to store the players `Inventory` NBT somewhere safe. There are many things in the game that can store arbitrary NBT data (storage, item tag nbt, etc), and they sure are all good solutions in their own right. In this case, since we're assuming that one player is supposed to be connected to one Inventory save, without any further knowledge of the environment, we'll be using the `marker` entities ability to store arbitrary data for us. *(In case a player is bound to a certain area in a map for example, an item in a jukebox might be a better choice. In any situation, using the `storage` might be a better choice for various reasons, if you know how to properly link data in there with players.)*
+The way to do this is to store the players `Inventory` NBT somewhere safe. There are many things in the game that can store arbitrary NBT data (storage, item tag nbt, etc), and they sure are all good solutions in their own right. In this case, since we're assuming that one player is supposed to be connected to one Inventory save, without any further knowledge of the environment, we'll be using the `marker` entities ability to store arbitrary data for us. *(In case a player is bound to a certain area in a map, for example, an item in a jukebox might be a better choice. In any situation, using the `storage` might be a better choice for various reasons, if you know how to properly link data in there with players.)*
-So, assume we want to **store** a players inventory then. This part is the easy part, as it just takes a few commands (assuming it's executed in a function `as` the player but **not** `at` the player. Instead if possible, make sure this is executed in the spawnchunks or an otherwise ensured to be loaded chunk so the marker entities stay loaded). This also assumes you have a [scoreboard ID system](/wiki/questions/linkentity) set up to link the entity to the player.
+So, assume we want to **store** a player's inventory, then. This part is the easy part, as it just takes a few commands (assuming it's executed in a function `as` the player, but **not** `at` the player. Instead, if possible, make sure this is executed in the spawnchunks (that were removed in 1.21.9) or an otherwise ensured to be loaded chunk, so the marker entities stay loaded). This also assumes you have a [scoreboard ID system](/wiki/questions/linkentity) set up to link the entity to the player.
See example
@@ -169,13 +215,13 @@ But now, we **want to give it back**. This is where it becomes tricky. Choose th
Using macros makes it very easy to return items to the player, since you can simply read the `Slot`, `id`, `Count` and `tag` tags and paste this data into the /item replace command. But there are two small difficulties:
- some slots (offhand and armor slots) cannot be directly inserted by slot number, so a separate function is needed to handle these slots.
-- items may not contain a tag tag, but macros always require all the data to be inserted.
+- items may not contain a tag, but macros always require all the data to be inserted.
Therefore, need to create a scoreboard in which the current slot will be stored in order to run one of two functions: `example:returning/inventory` - for inventory slots (0 - 35) and `example:returning/equipment` - for offhand (-106) and armor slots (100 - 103).
For items without tags, you need to create an empty tag before running the macro for that slot.
-Below is an example for versions 1.20.2 - 1.20.4. To do this need to run function `example:returning` as a player:
+Below is an example for versions 1.20.2 - 1.20.4. To do this, you need to run function `example:returning` as a player:
See example
@@ -221,7 +267,7 @@ $execute if score #this Slot matches 102 run item replace entity @s armor.chest
$execute if score #this Slot matches 103 run item replace entity @s armor.head $(id)$(tag) $(Count)
```
-However, as of version 1.20.5, item tags have now been replaced with components that cannot simply be inserted into the /item command, so for this need use a loot table written inline.
+However, as of version 1.20.5, item tags have now been replaced with components that cannot simply be inserted into the /item command, so for this need to use a loot table written inline.
Below is an example of a loot table in which you need to put the item data using a macro:
@@ -283,7 +329,7 @@ data remove storage example:inv this.Inventory[-1]
execute unless data storage example:inv this.Inventory[-1].components run data modify storage example:inv this.Inventory[-1].components set value {}
function example:returning/item with storage example:inv this.Inventory[-1]
-# function example:returning/inventory with storage example:inv this.Inventory[-1]
+# function example:returning/inventory
$loot replace entity @s container.$(Slot) loot {pools:[{rolls:1,entries:[{type:"minecraft:item",name:"$(id)",functions:[{function:"minecraft:set_count",count:$(count)},{function:"minecraft:set_components",components:$(components)}]}]}]}
# function example:returning/equipment
@@ -295,11 +341,55 @@ $execute if score #this Slot matches 103 run loot replace entity @s armor.head l
```
+In 1.21.5, all of the NBT paths for equipment slots (except for mainhand in players) were moved to the equipment map.
+e.g.
+`Inventory[{Slot:-106b}]` moved to `equipment.offhand`
+`Inventory[{Slot:100b}]` moved to `equipment.feet`
+etc.
+In order to account for this, some small tweaks are needed in order for proper storing and loading of items in offhand and armor slots to occur. One implementation of that is shown below.
+
+
+ See datapack
+
+```mcfunction
+# function example:returning
+scoreboard objectives add Slot dummy
+execute store result storage example:inv this.ID int 1 run scoreboard players get @s ID
+function example:returning/read with storage example:inv this
+execute unless data storage example:inv this.Inventory[-1].components run data modify storage example:inv this.Inventory[-1].components set value {}
+function example:returning/item with storage example:inv this.Inventory[-1]
+function example:returning/equipment with storage example:inv this.Equipment[-1]
+
+# function example:returning/read
+$data modify storage example:inv this set from storage example:inv players[{ID:$(ID)}]
+
+# function example:returning/item
+$scoreboard players set #this Slot $(Slot)
+execute if score #this Slot matches 0..35 run function example:returning/inventory with storage example:inv this.Inventory[-1]
+data remove storage example:inv this.Inventory[-1]
+execute unless data storage example:inv this.Inventory[-1].components run data modify storage example:inv this.Inventory[-1].components set value {}
+function example:returning/item with storage example:inv this.Inventory[-1]
+
+# function example:returning/inventory
+$loot replace entity @s container.$(Slot) loot {pools:[{rolls:1,entries:[{type:"minecraft:item",name:"$(id)",functions:[{function:"minecraft:set_count",count:$(count)},{function:"minecraft:set_components",components:$(components)}]}]}]}
+
+# function example:returning/equipment
+$scoreboard players set #thisEquipmentVersion Slot $(Slot)
+execute unless data storage example:inv this.Equipment[-1].components run data modify storage example:inv this.Equipment[-1].components set value {}
+execute if score #thisEquipmentVersion Slot matches 0..4 run function example:returning/equipment_return with storage example:inv this.Equipment[-1]
+data remove storage example:inv this.Equipment[-1]
+function example:returning/equipment with storage example:inv this.Equipment[-1]
+
+# function example:returning/equipment_return
+$loot replace entity @s $(equipment) loot {pools:[{rolls:1,entries:[{type:"minecraft:item",name:"$(id)",functions:[{function:"minecraft:set_count",count:$(count)},{function:"minecraft:set_components",components:$(components)}]}]}]}
+```
+
+
#### Putting things in the original slot (from marker)
-This one is a little command intensive, but probably the easiest to understand. All we do is use `item replace` to return all the items back to the player, for every slot. But because we can't get the item data directly from the data storage, we first need to put it into a different container or entity inventory. So lets assume we have a chest placed at `` that we can store these items into (you can instead use an entity that has an inventory and summon it as needed).
+This one is a little command intensive, but probably the easiest to understand. All we do is use `item replace` to return all the items back to the player, for every slot. But because we can't get the item data directly from the data storage, we first need to put it into a different container or entity inventory. So let's assume we have a chest placed at `` that we can store these items into (you can instead use an entity that has an inventory and summon it as needed).
-**This replaces all items that might still be in the players inventory.**
+**This replaces all items that might still be in the player's inventory.**
Running this function `as` the marker entity and having the target player marked with the `target` tag. This assumes you have a `temp` dummy scoreboard you can use.
@@ -375,7 +465,7 @@ execute if score #slot temp matches 103 run item replace entity @s armor.head fr
This means that we can just go through all the items in the array and give them back by summoning the item entity at the players feet for them to pick them up.
-Thankfully we can just recursively run through all the entries/items in the array and thus summon them all in the same tick. This is assuming you're executing this `as` the linked marker entity, but `at` the player and that you have a dummy objective you can use, this example uses `temp`.
+Thankfully, we can just recursively run through all the entries/items in the array and thus summon them all in the same tick. This is assuming you're executing this `as` the linked marker entity, but `at` the player and that you have a dummy objective you can use, this example uses `temp`.
See example
@@ -412,13 +502,13 @@ execute if score #items temp matches 1.. run function namespace:return_items
And we should be getting all our items back in a single tick. Items that do not fit in our inventory stay on the floor as item entities instead.
-**However, if the player is moving or close to other players while this is supposed to happen, or if you're worried about spawning lots of item entites, use the following method instead**. It does NOT fix the issue of too many items, as the player isn't able to pick up more than 36 items, but there could be a total of up to 41 items in their inventory at the time of storing (armor and offhand). The first method will drop the item on the floor if that is the case. **The second method will not give the player anything once they reached limit due to how `/loot give` works!**
+**However, if the player is moving or close to other players while this is supposed to happen, or if you're worried about spawning lots of item entities, use the following method instead**. It does NOT fix the issue of too many items, as the player isn't able to pick up more than 36 items, but there could be a total of up to 41 items in their inventory at the time of storing (armor and offhand). The first method will drop the item on the floor if that is the case. **The second method will not give the player anything once they reached limit due to how `/loot give` works!**
-This method uses the [yellow shulkerbox loottable trick as outlined here](/wiki/questions/modifyinventory).
+This method uses the [yellow shulkerbox loot table trick as outlined here](/wiki/questions/modifyinventory).
For this to work, we first need to get rid of the `Slot` data that is in the Inventory data (see under [explanations](#wiki_some_explanations_on_why_we_do_it_this_way) below as to why we need to do this). Then we copy the entire list of items to the shulkerbox, where it will promptly throw out all the ones that didn't fit, we use `/loot` to give its contents to the player. Then we remove the first 27 entries of the inventory (1 full shulkerbox worth) and repeat the same process with the remaining items.
-So first, make sure you have the loottable from the link above added to your datapack. Also make sure you have a yellow shulkerbox placed somewhere in the world. Put the yellow shulkerboxes position into ``.
+So first, make sure you have the loot table from the link above added to your datapack. Also make sure you have a yellow shulkerbox placed somewhere in the world. Put the yellow shulkerboxes position into ``.
Next, run this function `as` the marker, where the target player is `@a[tag=target]`.
@@ -466,11 +556,11 @@ To ensure that all items that fit into a player inventory (a total of 41 items a
1. Either we can hardcode all the slots again, making sure they get placed in an according slot in the chest (see the first method above) or
2. we use a method similar to the `yellow shulker box` method (the second option of the second method), but instead of using `/loot give` we use `/loot insert`.
-The first option is very similar to the option described above, with the change being that the first intermediate storage should be an entity so you can exeute positioned at the chest(s), and that you need to modify `give_correct_slot` to place the items into the slots of the chest instead of the player.
+The first option is very similar to the option described above, with the change being that the first intermediate storage should be an entity so you can exceute positioned at the chest(s), and that you need to modify `give_correct_slot` to place the items into the slots of the chest instead of the player.
The second option is described here in more detail. See the explanation for the yellow shulker box method above.
-For this we assume the two chests of the double chest are located at `~ ~ ~` and `~1 ~ ~`. Execute positioned and adjust the relative coordinates accordingly. Replace `` with the yellow shulkerbox position. Have a dummy `temp` scoreboard objective.
+For this, we assume the two chests of the double chest are located at `~ ~ ~` and `~1 ~ ~`. Execute positioned and adjust the relative coordinates accordingly. Replace `` with the yellow shulkerbox position. Have a dummy `temp` scoreboard objective.
See example
@@ -519,24 +609,25 @@ There are various problems that we need to work around by using the above method
If it wasn't for this, we could just store the inventory in some NBT storage and copy it back to the player at a later date. But sadly Minecraft isn't built to be able to directly manipulate the player entity so we have to do a workaround in the first place.
**Slot numbers are important**
-When merging items into a chest (or other container) `Items` array, the game checks the data for some validity points, like whether it's even a proper item, whether it has a count, etc. One of the things the game checks is the `Slot` number. If this number is outside of a specific range (starting at 0, counting up however many slots a container has, so chest: 0-26, dispenser: 0-8, hopper: 0-4), this item will be discarded as well. This means, since a [player inventory](https://minecraft.wiki/images/Items_slot_number.png) has the slots 0 - 35 (inventory), plus 100 - 103 (armor) and -106 (offhand), we need to do some editing beforehand to modify / remove the `Slot` data so the items aren't discarded by the game.
+When merging items into a chest (or other container) `Items` array, the game checks the data for some validity points, like whether it's even a proper item, whether it has a count, etc. One of the things the game checks is the `Slot` number. If this number is outside of a specific range (starting at 0, counting up however many slots a container has, so chest: 0-26, dispenser: 0-8, hopper: 0-4), this item will be discarded as well. This means, since a [player inventory](https://minecraft.wiki/images/Items_slot_number.png) has the slots 0 - 35 (inventory), plus 100 - 103 (armor) and -106 (offhand), we need to do some editing beforehand to modify / remove the `Slot` data, so the items aren't discarded by the game.
**One by one**
Another trend you can see in the above solutions is that we're doing one item after another, instead of doing multiple at once. Especially with the yellow shulker box method, this might seem strange because on first thought one might think that it should be possible to just dump an entire array into the Items of the chest / box, and just letting it discard whatever doesn't fit anymore. If the items have slot numbers, that works as intended, but if the slot numbers are removed, instead of adding a new item, the slot 0 will be overwritten with each and every item, thus leading to only one item remaining.
-So yes, a part of the solution could be to keep the slots around for the first 27 items, and then use the second method for the remaining items. However, the concious choice has been made in this tutorial to not mix up these two options, as it would increase the command count in this already long enough article and might lead to more confusion over the inner workings of the system.
+So yes, a part of the solution could be to keep the slots around for the first 27 items, and then use the second method for the remaining items. However, the conscious choice has been made in this tutorial to not mix up these two options, as it would increase the command count in this already long enough article and might lead to more confusion over the inner workings of the system.
**Slots != Index**
-We often see something like `Inventory[0]` in this article. This is an array selector notation, and means that we're selecting the first item out of the array called `Inventory`. Note that any item can be in this position in the array, and it's not guaranteed to be the one that was `Slot:0b`. Only items that are actually in your inventory are saved in this list, so anything that is empty (or air I guess) will not be in this list. So if the only item in your inventory is in the last hotbar slot, it will be the only item in the list, eventhough it has `Slot:8b`.
+We often see something like `Inventory[0]` in this article. This is an array selector notation, and means that we're selecting the first item out of the array called `Inventory`. Note that any item can be in this position in the array, and it's not guaranteed to be the one that was `Slot:0b`. Only items that are actually in your inventory are saved in this list, so anything that is empty (or air I guess) will not be in this list. So if the only item in your inventory is in the last hotbar slot, it will be the only item in the list, even though it has `Slot:8b`.
+
+It is possible to select an item from the array based on its Slot like this: `Inventory[{Slot:10b}]`. We could use this for the "correct slot" method, if it weren't for the fact that we can't use `/item replace` with arbitrary data, but we need to use something that is guaranteed to be an item. So we can't skip the step of first putting it into a container / entity inventory first.
-It is possible to select an item from the array based on its Slot like this: `Inventory[{Slot:10b}]`. We could use this for the "correct slot" method, if it weren't for the fact that we can't use `/item replace` with arbitrary data but we need to use something that is guaranteed to be an item. So we can't skip the step of first putting it into a container / entity inventory first.
+### Storing in a chest
-### storing in a chest
| ๐ Note |
|---------|
-|This method is not effective (unless you don't want to use functions) and it is **not** multiplyer compatible (unless using 2 chests for every player)|
+|This method is not effective (unless you don't want to use functions) and it is **not** multipalyer compatible (unless using 2 chests for every player)|
-This method consist on using `/item` (on Java) or to replace all slots in 2 containers (for example 2 chest) with the items in the player inventory. You can use command blocks, but you will need to run every command `as` the player and change `~ ~ ~` to the positon of the chest
+This method consist on using `/item` (on Java) or to replace all slots in 2 containers (for example 2 chests) with the items in the player inventory. You can use command blocks, but you will need to run every command `as` the player and change `~ ~ ~` to the position of the chest
| ๐ Note |
|---------|
@@ -611,4 +702,4 @@ item replace entity @s weapon.offhand with block ~ ~ ~ container.13
-As you can see it takes 40 commands for storing and 40 for returning, so it is a very ineficient way to store the inventory.
\ No newline at end of file
+As you can see, it takes 40 commands for storing and 40 for returning, so it is a very inefficient way to store the inventory.
diff --git a/questions/tagentity.md b/questions/tagentity.md
index 194d84a2..3704c8dc 100644
--- a/questions/tagentity.md
+++ b/questions/tagentity.md
@@ -17,7 +17,7 @@ kill @a[team=red]
## Relies on NBT, 1.12 and below
-If your testfor **relies on NBT data**, you will need to use either `scoreboard players set` or `scoreboard players tag` to give them a scoreboard score/tag, then select them based off of that. For example if you have:
+If your testfor **relies on NBT data**, you will need to use either `scoreboard players set` or `scoreboard players tag` to give them a scoreboard score/tag, then select them based off of that. For example, if you have:
```mcfunction
testfor @a {OnGround:1b}