You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update optimising.md
* Update questions.md
* Update angermob.md
* Update angermob.md
* Update angermob.md
* Update amountitems.md
* Update angermob.md
* Update angermob.md
* Update areas.md
* Update blockinvert.md
* Update angermob.md
* Update fakeplayer.md
* Update blockdelay.md
* Update blockdelay.md
* Update blockdelay.md
* Update randomnumber.md
* Update randomnumber.md
* Update randomnumber.md
* Update randomnumber.md
* Update areas.md
* Update blockdelay.md
* Update blockdelay.md
* Update highestscore.md
* Update linkentity.md
* Update lookat.md
* Update amountitems.md
* Update fakeplayer.md
* Update fakeplayer.md
* Update debugging.md
* Update debugging.md
* Update debugging.md
* Update optimising.md
* Update optimising.md
* Update debugging.md
* Update numplayers.md
* Update numplayers.md
* Update playerdeaths.md
* Update questions.md
* Update angermob.md
* Update blockdelay.md
* Update functionconditions.md
* Update changeofscore.md
Remove bedrock edition method as it is the same as Java, review in the wiki https://minecraft.wiki/w/Commands/execute#ifunlessscore but it should work in bedrock
* Update playerjoin.md
* Update debugging.md
#2 (comment)
* Update findsamescoreentity.md
* Update runonce.md
* Update lookat.md
* Update lookat.md
* Update debugging.md
* Create shop.md
Has missing information about behavior packs (if there is another way of doing it with them not showed in this tutorial) in bedrock edition as I am not experienced with them.
* Update shop.md
Fixed a typo
* Update blockdelay.md
* Update blockinvert.md
* Update commandcontext.md
* Update blockdelay.md
* Update debugging.md
* Update questions.md
* Update questions.md
“Detect when a mob died” not starting in a new line and continuing in the last one
* Update questions.md
* Update customcrafting.md
Updated to bedrock edition
* Update customcrafting.md
* Update customcrafting.md
* Create hostilefriendly.md
Not sure about bedrock syntax, https://minecraft.wiki/w/Commands/replaceitem
* Update debugging.md
#2 (comment)
* Update optimising.md
#2 (comment)
* Update debugging.md
#2 (comment)
* Update debugging.md
#2 (comment)
* Update debugging.md
* Update lookat.md
#2 (comment)
* Update debugging.md
* Update changeofscore.md
#2 (comment)
* Update angermob.md
#2 (comment)
* Update questions.md
#2 (comment)
* Update questions.md
#2 (comment)
* Update blockdelay.md
* Update shop.md
#2 (comment)
* Update shop.md
#2 (comment)
* Update shop.md
* Update questions.md
* Update blockdelay.md
#2 (comment)
* Update shop.md
Typo
* Update shop.md
#2 (comment)
* Update shop.md
* Update hostilefriendly.md
* Update shop.md
#2 (comment)
* Update shop.md
#2 (comment)
* Update shop.md
* Update debugging.md
* Update debugging.md
* Update resources.md
Why misode was not in advancements generators?
* Update playerjoin.md
#2 (comment)
* Update linkentity.md
* Update numplayers.md
* Update randomnumber.md
* Update numplayers.md
* Update storeinventory.md
* Update itemclick.md
* Update debugging.md
Common problems, such as not adding limit or /data selecting more than one targets
* Update debugging.md
More to debug…
* Update optimising.md
A update for @n
* Update storeinventory.md
Curse of vanishing warning
* Update shop.md
* Update debugging.md
Edition world gen requires to leave the world
* Update debugging.md
* Update questions.md
Added link to submit GitHub pull request
* Update bcresources.md
Each line was not starting in a new one
* Update compasstoplayer.md
Note about players spawning in world spawn
* Update debugging.md
Scores are not saved in playerdata
* Update modifyinventory.md
Just added a link, why not
* Update randomnumber.md
* Update playerjoin.md
Added a simple explanation
* Update shop.md
Information and notez
* Update debugging.md
CommandBlockModificationLimit
* Update debugging.md
#2 (comment)
* Update hostilefriendly.md
#2 (comment)
* Update storeinventory.md
#2 (comment)
* Update playerjoin.md
#2 (comment)
* Update randomnumber.md
#2 (comment)
* Update storeinventory.md
#2 (comment)
* Update shop.md
#2 (comment)
* Update playerjoin.md
#2 (comment)
* Update findsamescoreentity.md
* Update debugging.md
Updated image of how to enable game log
* Update hostilefriendly.md
I just tested, it does not work in bedrock
* Create npc.md
After experimenting with NPCs, I wrote information about creating chained dialogues and add commands... as @GalSergey said in #2 (comment)
* Update amountitems.md
Fixed bedrock command
* Update changeofscore.md
It is the same in bedrock
* Update compasstoplayer.md
Missing dot at the end of a sentence
* Update customitemtag.md
Bedrock
* Update detectitem.md
Using color codes with a tag to identify it
* Update findsamescoreentity.md
The java version is the same as the bedrock one (without predicates)
* Update hostilefriendly.md
Typo
* Update itemclick.md
* Update linkentity.md
It works for bedrock too
* Update movetoscore.md
It works in bedrock binary tp
* Update shop.md
Added related article
* Update blockinvert.md
* Update heighttest.md
Added explanation that negative numbers are supported using `dy ` to detect any player below
* Update heighttest.md
* Update debugging.md
https://www.minecraft.net/en-us/article/minecraft-snapshot-24w21a Changes in directory names
* Update debugging.md
I am not sure if it should be in this category…
* Update shop.md
Missing “?”
* Update questions.md
Added NPC
* Update optimising.md
* Update storeinventory.md
#2 (comment)
* Update storeinventory.md
It could be done in multiplayer, but it will require multiple chests
* Update storeinventory.md
Bedrock /replaceitem does not allow using “from”, so it’s not possible to do this directly
* Update playerkills.md
Added the advancement
* Update raycast.md
user Reddit link
* Update raycast.md
It’s better to have the title at the top, in my opinion
* Update playerkills.md
Removed extra line
* Update shop.md
Added how to use multiple items as a price
* Update runonce.md
Added bedrock support
* Update runonce.md
* Update randomnumber.md
Added example to bedrock edition
* Update customitemtag.md
Source https://www.reddit.com/r/MinecraftCommands/comments/1d241x6/comment/l5y5cms/?utm_source=share&utm_medium=web2x&context=3
* Update customitemtag.md
* Update detectitem.md
Source: https://www.reddit.com/r/MinecraftCommands/comments/1d241x6/comment/l5y5cms/?utm_source=share&utm_medium=web2x&context=3
* Update commandcontext.md
Added NPC command context
* Update compasstoplayer.md
* Update customitemtag.md
Im not expecting bedrock people scroll trought a lot of text only to find their solution
* Update storeinventory.md
/replaceitem does not accept “with”
* Update randomnumber.md
Addedca note, saying the information is outdated
* Update optimising.md
Falling blocks or entities does not show how to do it, just added the example
* Update optimising.md
* Update questions.md
Summarized
* Update blockinvert.md
Remove extra *
* Update npc.md
Added link to the minecraft.wiki NPC
* Update numplayers.md
Im not sure if they changed that,
* Update areas.md
* Update giveitembedrock.md
Added an exaplanation that tells that you can use wprld editors to get illegal enchantemtents
* Update giveitembedrock.md
/structure did not was `/structure `
* Update commandcontext.md
Added a missing soace between npc and the text that says bedrock edition only
* Update debugging.md
* Update debugging.md
Even more to debug
* Update lookat.md
Missing `) `
* Update movetoscore.md
Typo
* Update playerdeaths.md
Typo
* Update playerjoin.md
* Update movetoscore.md
@s wasn’t in inline code
* Update movetoscore.md
If you are in a slab and store in the scoreboard Pos[1] and then tp to that score, you will be inside the slab, and if there is no block below, you will clip
* Update movetoscore.md
* Update shop.md
Missing tellraw
* Update shop.md
Adde related
* Update optimising.md
#2 (comment)
* Update blockdelay.md
#2 (comment)
* Update blockdelay.md
#2 (comment)
* Update blockdelay.md
#2 (comment)
* Update changeofscore.md
#2 (comment)
* Update commandcontext.md
#2 (comment)
* Update commandcontext.md
#2 (comment), and did the same for the NPC
* Update compasstoplayer.md
#2 (comment)
* Update customitemtag.md
#2 (comment)
* Update customitemtag.md
#2 (comment)
* Update detectitem.md
#2 (comment)
* Update detectitem.md
#2 (comment)
* Update findsamescoreentity.md
#2 (comment)
* Update functionconditions.md
#2 (comment)
* Update heighttest.md
#2 (comment)
* Update hostilefriendly.md
#2 (comment)
* Update hostilefriendly.md
#2 (comment)
* Update hostilefriendly.md
#2 (comment)
* Update hostilefriendly.md
#2 (comment)
* Update hostilefriendly.md
#2 (comment)
And
#2 (comment)
* Update hostilefriendly.md
#2 (comment)
* Update hostilefriendly.md
#2 (comment)
* Update hostilefriendly.md
#2 (comment)
* Update lookat.md
#2 (comment)
* Update lookat.md
#2 (comment)
* Update npc.md
#2 (comment)
* Update playerjoin.md
#2 (comment)
* Update playerjoin.md
#2 (comment)
* Update randomnumber.md
#2 (comment)
* Update functionconditions.md
#2 (comment)
* Update npc.md
#2 (comment)
* Update npc.md
#2 (comment), I think it’s better inline code
* Update lookat.md
#2 (comment)
* Update npc.md
#2 (comment)
* Update questions.md
#2 (comment)#2 (comment)
* Update functionconditions.md
#2 (comment)
* Update playerkills.md
#2 (comment)
* Update randomnumber.md
#2 (comment)
* Update runonce.md
#2 (comment)
* Update shop.md
#2 (comment)
* Update debugging.md
#2 (comment)
* Update commandcontext.md
#2 (comment)
* Update shop.md
#2 (comment)
* Update shop.md
#2 (comment)
* Update questions/shop.md
#2 (comment)
Co-authored-by: Lukas Scheuerle <[email protected]>
* Update shop.md
#2 (comment)
* Update shop.md
#2 (comment)
* Update shop.md
#2 (comment)
* Update runonce.md
#2 (comment)
* Update playerkills.md
#2 (comment)
* Update blockdelay.md
#2 (comment)
* Update optimising.md
#2 (comment)
* Update optimising.md
#2 (comment)
* Update blockdelay.md
#2 (comment)
* Update optimising.md
#2 (comment)
* Update blockdelay.md
By global, I mean optimizing a command and make it run half the speed for example
* Update shop.md
* Update shop.md
#2 (comment)
* Update shop.md
#2 (comment)#2 (comment)
* Update runonce.md
33ad867#r142661214
* Update shop.md
* Update runonce.md
https://github.com/MinecraftCommands/wiki/pull/2/files#r1624255977@GalSergey it is ok now?
and @Plagiatus review this (as I just added it)
* Update debugging.md
Missing inline code
* Update questions/customitemtag.md
Co-authored-by: Lukas Scheuerle <[email protected]>
* Update questions/detectitem.md
Co-authored-by: Lukas Scheuerle <[email protected]>
* Update questions/functionconditions.md
Co-authored-by: Lukas Scheuerle <[email protected]>
---------
Co-authored-by: Lukas Scheuerle <[email protected]>
Copy file name to clipboardExpand all lines: optimising.md
+15-35Lines changed: 15 additions & 35 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@
6
6
7
7
For example, if you have a function or chain of command blocks that control an arena, you probably only need those running when someone is actually in the arena.
8
8
9
-
Consider a "branching" structure of checks. You could start with just `/testfor @a`. If and only if that succeeds you'd run checks to do with players, such as whether a player is holding *any* special item. If a player is holding any special item, run checks to see what kind of special item it is. Only then off of these last checks would you run the commands that make that item work.
9
+
Consider a "branching" structure of checks. You could start with just `/execute if entity @a` (Or `/testfor @a` in pre-1.13). If and only if that succeeds you'd run checks to do with players, such as whether a player is holding *any* special item. If a player is holding any special item, run checks to see what kind of special item it is. Only then off of these last checks would you run the commands that make that item work.
10
10
11
11
**Don't** achieve this by repeatedly using `/execute` as a condition (e.g: `/execute as @a[tag=holdItem] ...`) while still having all the blocks/commands running, as this will still need to repeatedly evaluate the selector for each command. Instead, you want the commands to not be running at all if the previous check failed.
12
12
@@ -23,46 +23,26 @@ You can alternatively use the following commands to activate an impulse command
23
23
24
24
These commands should be conditional blocks on the chain that performs the condition test. Your setup might look [something like this](http://i.imgur.com/vyhnmTH.png).
25
25
26
-
**Functions** make this even easier and more efficient. You can run a different function only if a selector succeeds/fails, for example:
26
+
**Functions** make this even easier and more efficient. You can run a different function only if a condition (for example, if a specified selector exist) succeeds/fails, for example:
27
27
28
28
# pre-1.13 syntax
29
29
function code:arena_events if @a[tag=in_arena]
30
30
function code:check_winner unless @a[tag=winner]
31
31
# 1.13+ syntax
32
32
execute if entity @a[tag=in_arena] run function code:arena_events
33
33
execute unless entity @a[tag=winner] run function code:check_winner
34
+
# 1.13+ syntax (block condition)
35
+
execute if block 0 60 0 air run function code:missing_block
36
+
execute unless block 0 90 0 grass_block run function code:place_block
34
37
35
-
## Slow down your commands
36
-
37
-
Not everything needs to be running at 20Hz. If you can run some commands at 10Hz instead, you've halved the impact those commands were having. In Bedrock you can just add a delay to a repeating commandblock into the block directly, in Java you need some workaround.
38
-
39
-
An easy trick with command blocks to make a clock run at half its speed is the following command:
execute if block ~ ~ ~ repeating_command_block{SuccessCount:0}
45
-
46
-
Set up [like this](http://i.imgur.com/OULTCZx.png), the command will alternate between succeeding (as it failed last time so has `SuccessCount:0`) and failing (as it succeeded last time so has `SuccessCount:1`), and the conditional repeating block coming off of it will thus activate every other tick.
38
+
In 1.13+ you can check more things apart from selectors with [`execute if/unless`](https://minecraft.wiki/w/Commands/execute#Condition_subcommands)
47
39
48
-
These cause no block updates and require no entities or scoreboard objectives, but are limited to halving the speed of the first block.
49
-
50
-
More flexible and commonly used are scoreboard timers. One command continually increments a value, another tests when this value reaches a certain number, then the value is reset and a chain of commands is activated.
51
-
52
-
[Here's an example setup image.](http://i.imgur.com/fGyA294.png)
53
-
54
-
These cause no block updates and require no entities, but will require an objective, and a new fake player for each timer. Scoreboard timers can also be used in functions.
55
-
56
-
Other methods such as a falling block clock exist and can be convenient, but cause block updates, lighting updates, and requires an entity.
57
-
58
-
**Functions** can be even easier to run on slower speeds, as the `schedule` command allows you to run functions after a certain amount of time has passed. You can use this for functions to schedule themselves to essentially create a slower clock.
59
-
60
-
`code/slow_function.mcfunction`
40
+
## Slow down your commands
41
+
Not everything needs to be running at 20Hz. If you can run some commands at 10Hz instead, you've halved the impact those commands were having.
61
42
62
-
schedule function slow_function 10t
63
-
say this will run twice per second
43
+
In Bedrock you can just add a delay to a repeating commandblock into the block directly, in Java you need some workaround that you can find in the questions ["How to add delay to a command"](/wiki/questions/blockdelay)
64
44
65
-
you just need to start the function at some point (e.g. in the `#minecraft:load` function tag) and it will run at a slower speed.
45
+
If you are using command blocks it is recomended to use the `SuccessCount` method to make them at half speed but if you are using datapacks, use schedule functions.
66
46
67
47
## Avoid chunk updates
68
48
@@ -106,7 +86,7 @@ Selectors are used a lot in commands. To make sure you're not causing extra work
106
86
107
87
Your main aim here is to narrow down the list as much as possible before getting to the expensive distance-sorting/shuffling and especially the super expensive NBT checks. You shouldn't however unnecessarily check arguments that won't narrow down the list before distance-sorting/shuffling. For example, don't check `@e[type=zombie,tag=IsUndeadMob]` if all zombies will have that tag. You shouldn't make your selector imprecise so that it applies to more entities than it needs to, either.
108
88
109
-
`nbt` is the least efficient target selector, as it has to do a lot of converting and comparing, and as such should be avoided at (almost) all costs, or at least limited to the absolute minimum required.
89
+
`nbt` is the least efficient target selector, as it has to do a lot of converting and comparing, and as such should be avoided at (almost) all costs, or at least limited to the absolute minimum required.[Predicates](https://minecraft.wiki/w/Predicate), in the other hand, can archive the same causing less performance impact only when not using NBT checks but built-in checks. If using NBT checks it actually performs worse.
110
90
111
91
`@s` is the most efficient selector, directly grabbing the command sender. See the section on **function-specific optimisations** for how you can make use of it to cut down on use of other selectors.
112
92
@@ -122,9 +102,9 @@ Using armor stands as markers? Strongly consider switching to area effect clouds
These won't show up to spectators, which is a bonus if you don't want spectators to see your markers. If you want to see them for debugging purposes, turn on hitboxes (`F3 + B`). Armor stands should only be used where necessary, such as displaying an item or using `Motion`.
105
+
These won't show up to spectators, which is a bonus if you don't want spectators to see your markers. If you want to see them for debugging purposes, turn on hitboxes (`F3 + B`). Armor stands should only be used where necessary, such as displaying an item (In pre-1.19.4, as you can use item displays in newer versions) or using `Motion`.
126
106
127
-
[Marker entities](https://minecraft.wiki/wiki/Marker) on the other hand are impossible to see, as they aren't even sent to the client, so you'd need to resort to other options to debug them. This however means that they have a competitive advantage when it comes to performance and should be used as a marker over the other options wherever possible.
107
+
[Marker entities](https://minecraft.wiki/wiki/Marker) on the other hand are impossible to see, as they aren't even sent to the client (unless using [a mod](https://modrinth.com/mod/visiblebarriers), that needs to be on the server as well), so you'd need to resort to other options to debug them. This however means that they have a competitive advantage when it comes to performance and should be used as a marker over the other options wherever possible.
128
108
Additionally they can store any kind of NBT data in their `data` NBT component (though storing abritrary data is probably better stored in the `storage` anyways).
129
109
130
110
Remember from the previous section that selectors work by getting a list of all loaded entities, then narrowing that down. This means that extra entities increase the workload of every selector in your commands. In some cases, you could be able to use static coordinates rather than executing off of a marker entity.
@@ -157,6 +137,6 @@ This means that instead of evaluating `@e[tag=blah]` many times, it is only eval
157
137
158
138
## More in-depth optimization
159
139
160
-
/u/Wooden_chest created an in-depth analysis of a lot of small things that can improve your performance, like what order to put your execute subcommands into or that depending on the circumstance it might actually be faster to copy NBT you want to test to the storage first before testing it instead of testing it on the entity/player directly.
140
+
[/u/Wooden_chest](https://www.reddit.com/user/Wooden_chest/) created an in-depth analysis of a lot of small things that can improve your performance, like what order to put your execute subcommands into or that depending on the circumstance it might actually be faster to copy NBT you want to test to the storage first before testing it instead of testing it on the entity/player directly.
161
141
162
-
Read their full post here: https://www.reddit.com/r/MinecraftCommands/comments/w4vjs3/whenever_i_create_datapacks_i_sometimes_do/
142
+
Read their full post here: https://www.reddit.com/r/MinecraftCommands/comments/w4vjs3/whenever_i_create_datapacks_i_sometimes_do/
Copy file name to clipboardExpand all lines: questions.md
+15-5Lines changed: 15 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,13 @@
4
4
5
5
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).
6
6
7
+
## Why is my give command broken (java)?
8
+
In 1.20.5 a new system for storing item data has been introduced to Java Edition in [Snapshot 24w09a](https://www.minecraft.net/en-us/article/minecraft-snapshot-24w09a).
9
+
Anything relating to items (such as /give, /item or loot tables) have a different format now.
10
+
The gist of it is this: Unstructured NBT data attached to stacks of items (tag field) has been replaced with structured 'components' that go in [] and are comma separated.
11
+
For example: /give @p diamond_pickaxe[damage=10,custom_model_data=7]
12
+
For a list of how item components are structured, see [this article on the minecraft.wiki](https://minecraft.wiki/w/Item_format/1.20.5).
13
+
7
14
## How do I...
8
15
9
16
### Items
@@ -14,7 +21,8 @@ Because in 1.19.50, the [new execute syntax](https://learn.microsoft.com/en-us/m
14
21
[Detect rightclick or leftclick (on an item)?](/wiki/questions/itemclick)
15
22
[Give a special item (Bedrock)?](/wiki/questions/giveitembedrock)
16
23
[Change an item while it's in the players inventory?](/wiki/questions/modifyinventory)
[Setup, configure and add multiple dialogues to NPCs?](/wiki/questions/npc)
55
65
56
66
## What is...
57
67
@@ -67,4 +77,4 @@ Because in 1.19.50, the [new execute syntax](https://learn.microsoft.com/en-us/m
67
77
68
78
## Still needed articles
69
79
70
-
*Found something that should be added? Maybe even want to contribute an article? Submit a pull request or create a GitHub issue.*
80
+
*Found something that should be added? Maybe even want to contribute an article? Submit a pull request or create a GitHub issue[here](https://github.com/MinecraftCommands/wiki).*
Copy file name to clipboardExpand all lines: questions/amountitems.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,6 @@ Here are some examples for this:
52
52
53
53
## Bedrock
54
54
55
-
In the **1.18.20 beta** they added the [`hasitem`](https://minecraft.wiki/wiki/Target_selectors#Selecting_targets_by_items) target selector, which allows you to check for specific amounts (as [ranges](/wiki/questions/range)) of items in entities inventories. Below is an example, check the link above for more information.
55
+
In the **1.18.20 beta** they added the [`hasitem`](https://minecraft.wiki/wiki/Target_selectors#Selecting_targets_by_items) target selector, which allows you to check for specific amounts (as [ranges](/wiki/questions/range)) of items in entities inventories. Below is an example (using 1.19.50 execute), check the link above for more information.
56
56
57
-
execute @a[hasitem={item:apple,quantity=5..}] ~~~ run say I have 5 or more apples in my inventory
57
+
execute as @a[hasitem={item=apple,quantity=5..}] run say I have 5 or more apples in my inventory
0 commit comments