diff --git a/404.html b/404.html new file mode 100644 index 000000000..129af5b6b --- /dev/null +++ b/404.html @@ -0,0 +1,50 @@ + + + + + + 404: Page Not Found + + + +
+

404: Page Not Found

+
+

If you encounter any issues, you can create a GitHub issue.

+
+ + \ No newline at end of file diff --git a/_config.yml b/_config.yml index 671640e82..d28cda254 100644 --- a/_config.yml +++ b/_config.yml @@ -11,4 +11,4 @@ include: - CODE_OF_CONDUCT.md - CONTRIBUTING.md - ISSUE_TEMPLATE.md - - PULL_REQUEST_TEMPLATE.md + - PULL_REQUEST_TEMPLATE.md \ No newline at end of file diff --git a/bcresources.md b/bcresources.md index bacdda332..2abc8ac76 100644 --- a/bcresources.md +++ b/bcresources.md @@ -1,12 +1,13 @@ # Bedrock Codebase Resources -This page contains a list of links to utilities and references for **Pocket Edition/Windows 10** ("Minecraft Unified") map making that you may find useful. +This page contains a list of links to utilities and references for **Minecraft Bedrock Edition** map making that you may find useful. Looking for resources for the normal Java PC edition? [Click here for Java/PC resources.](/wiki/resources) -Submit a pull request or create a GitHub issue if you've found a useful tool or reference that you think would fit here. +Submit a [pull request](https://github.com/MinecraftCommands/wiki/pulls) or create a [GitHub issue](https://github.com/MinecraftCommands/wiki/issues) if you've found a useful tool or reference that you think would fit here. -[Online documentation](https://bedrock.dev) (TheDestruc7i0n) +* [Online documentation](https://bedrock.dev) (TheDestruc7i0n) +* [Online documentation](https://wiki.bedrock.dev) ## NBT diff --git a/debugging.md b/debugging.md index 412d5918e..d191c5570 100644 --- a/debugging.md +++ b/debugging.md @@ -20,26 +20,24 @@ This page details information on common problems you might have with a command, * 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) * Narrow down your problem as much as possible. Remove parts slowly (or build up your command slowly in the first place) until you have just the part that's causing the issue * Macs add weird characters that are invisible in-game when the arrow keys are pressed. These will stop the command from working -* Mods/plugins (especially Essentials) may overwrite vanilla commands. To avoid this you can use one of the two following methods: - * `/minecraft:command` instead of `/command` for the vanilla implementation (e.g: `/minecraft:give`) - * `/execute run command` instead of `/command`, this is better because it works in vanilla servers too +* Mods/plugins (especially Essentials) may overwrite vanilla commands. To avoid this you can use`/minecraft:command` instead of `/command` for the vanilla implementation (e.g: `/minecraft:give`) + * `/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.propieties -* 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) +* Make sure command blocks are enabled in `server.properties` +* 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 * The command block must be `always active` or have redstone powering in order for it to run the command * Make sure to capitalize the correct leters in the command, for example `/Say` will not work but `/say` will do (in bedrock edition works different, as you can capitalize commands) * Same goes for scoreboard values, if you capitalized it when creating it, it should be capitalized when you use it -* The `commandModificationBlockLimit` gamerule (defaults to 32768) specifies the limit of blocks that can be selected with the `/fill`, `/fillbiome` and `/clone` commands +* The `commandModificationBlockLimit` gamerule (defaults to `32768`) specifies the limit of blocks that can be selected with the `/fill`, `/fillbiome` and `/clone` commands * Make sure you are **not** using per-1.13 execute in newer versions * 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 * Make sure you are **not** using item components in pre-1.20.5 or item `nbt` in 1.20.5+ -* execute does not allow the use of commands for plugins, so the command `/execute as @a run tpa ...` will **not** work ## Functions @@ -51,8 +49,8 @@ This page details information on common problems you might have with a command, * Inserting from a list/array or NBT path is not allowed * Use a plain plain text editor (Notepad, Notepad++, Sublime, Code), **not** a word processor or rich text editor (Microsoft Word, Wordpad, Textedit) * Make sure your file's encoding is UTF-8 (without BOM) - this is not the default in many programs! ([Notepad](http://i.imgur.com/R4yFjAQ.png), [Notepad++](http://i.imgur.com/8AsDJ3F.png), [Sublime](http://i.imgur.com/63rsYOB.png), [Code](http://i.imgur.com/dmOqy0y.png)) -* The namespace folder is not optional, functions should **not** be directly inside `data/functions/`, they must be in `data//functions/` -* Don't forget to save changes if editing directly the datapack (with programs like VScode), normaly `ctrl+s` (Windows/Lunix) or `cmd+s` (Mac) +* The namespace folder is not optional, functions should **not** be directly inside `data/functions/`, they must be in `data//functions/` (or in `data//function/` in 1.21+) +* 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). @@ -60,8 +58,8 @@ This page details information on common problems you might have with a command, * 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. * Make sure the tick/load function tag is specifing the correct function -* Functions can run any command that requires a higher level permission than 2. - * You can override this if you set `function-level-permission` in `server.propieties` to a higher number +* Functions can not run any command that requires a higher level permission than 2. + * You can override this if you set `function-level-permission` in `server.properties` to a higher number * If a function has a syntax error, it will **not** show up in the autocomplete and it will flail, if you try to run it * All commands must have a correct syntax in order to run the function * You can start the function with a `/say` command, so you will know if the function has been executed diff --git a/oldresources.md b/oldresources.md new file mode 100644 index 000000000..846e00b99 --- /dev/null +++ b/oldresources.md @@ -0,0 +1,274 @@ +# Resources + +| ⚠️ Important | +|--------------| +|This page is outdated: some links won't work and the majority of sites are for older versions of minecraft (1.14 and older). To see rousources for newer versions see the [resources page](wiki/resources)| + +This page contains a list of links to utilities and references relating to commands and map making that you may find useful. + +Submit a [pull request](https://github.com/MinecraftCommands/wiki/pulls) or create a [GitHub issue](https://github.com/MinecraftCommands/wiki/issues) if you've found a useful tool or reference that you think would fit here. + +## NBT + +### Utilities + +- [NBT Studio](https://github.com/tryashtar/nbt-studio) (tryashtar) +- [NBTExplorer](http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-tools/1262665-nbtexplorer-nbt-editor-for-windows-and-mac) (jaquadro) +- [Web NBT Editor](https://irath96.github.io/webNBT/) (irath96) +- [NBT Workbench](https://rttv.ca) ([On GitHub](https://github.com/RealRTTV/nbtworkbench)) (RealRTTV) +- [Tag checker](http://www.mediafire.com/file/n38fgnjnr0q113d/PCN+1.4.zip) (pca006132) +- [Web NBT Validator](https://www.soltoder.com/NBTLint/#{Hello:%22reddit%22,Test:{Int:267,Short:345s,TooLarge:9999999999,%221.12%20Compatible%22:[I;1,2,3]}}) (AjaxGb) +- [1.16 UUID Converter](https://www.soltoder.com/mc-uuid-converter/) (AjaxGb) +- [UUID <--> UUIDMost/Least converter](https://minecraft.repertor.space/uuid.html) (Repertor) +- [UUID <--> UUIDMost/Least converter](http://skylinerw.com/uuid/index.php?convert=dechex&uuidleast=1&uuidmost=1) (Skylinerw) + +### References + +- [Chunk format](http://minecraft.wiki/Chunk_format) (Wiki) +- [Player.dat format](http://minecraft.wiki/Player.dat_format) (Wiki) +- [Structure file format](http://minecraft.wiki/Structure_block_file_format) (Wiki) + +## Commands + +### Utilities + +- [Command language](http://zipkrowd.com/tools.htm#cbp) (CBP) +- [Command language](http://commandstudio.github.io/commandstudio/) (CommandStudio) +- [Command language](http://smelt.gnasp.com/) (Smelt) +- [Command language](http://energyxxer.com/cpm/) (CPM) +- [Commands from C/assembly](https://github.com/simon816/Command-Block-Assembly) (simon816) +- [One command generator](https://mrgarretto.com/commanddump) (MrGarretto) +- [Command editor/one command generator](https://blockbench.net/tools/clg/) (JannisX11) +- [Selector generator](https://blockbench.net/tools/selector/) (JannisX11) +- [Command generator](https://mcstacker.net/mcstacker1.13.php) (MCStacker) +- [Command generator](http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-tools/2142815-1-11-1-12-minecraft-command-generator-v2) (Cubiccl) + +### References + +- [Commands list](http://minecraft.wiki/Commands) (Wiki) +- [Statistics list](http://minecraft.wiki/Statistics) (Wiki) +- [Full syntax tree (as JSON, useful for tools)](https://gist.github.com/Dinnerbone/7370a2846953eee2d8fc64514fb76de8) (Dinnerbone) + +## Loot tables (& predicates) + +### Utilities + +- [Generator](https://misode.github.io/loot-table/) (Misode) +- [Predicate generator](https://misode.github.io/predicate) (Misode) +- [Generator](https://jsfiddle.net/MrPingouin/125mx5r5/embedded/result/) (MrPingouin) +- [Generator](https://amaury.carrade.eu/minecraft/loot_tables) (Amaury, based on MrPingouin's) +- [Generator](http://minecraft.tools/en/loots.php) (Minecraft Tools) ^[Missing features] +- [Evaluator](https://sourceblock.net/beta/tools/loot-table-evaluator) (Skylinerw) +- [VSCode Schema](https://marketplace.visualstudio.com/items?itemName=Levertion.mcjson) (Levertion) + +### References + +- [Guide](http://minecraft.wiki/Loot_table) (Wiki) +- [Guide](https://github.com/skylinerw/guides/blob/master/java/loot%20tables.md) (Skylinerw) +- [New 1.14 features guide](https://gist.github.com/misode/66456e57372ce62cd9b65d1052521069) (Misode) + +## Functions + +### Utilities + +- [VSCode syntax highlighter](https://marketplace.visualstudio.com/items?itemName=arcensoth.language-mcfunction) (Arcensoth) +- [VSCode language server & more](https://marketplace.visualstudio.com/items?itemName=SPGoding.datapack-language-server) (SPGoding) +- [Sublime syntax highlighter](https://github.com/AjaxGb/Sublime-MCFunction) (AjaxGb) +- [Sublime syntax highlighter](https://github.com/42iscool42/MCC) (42iscool42) +- [Atom syntax highlighter](https://atom.io/packages/mcfunction) (MrYurihi) + +### References + +- [Info](http://minecraft.wiki/Function) (Wiki) + +## Advancements + +### Utilities + +- [Generator](http://commandcreator.com/advancements/) (Command Creator) +- [Generator](https://advancements.thedestruc7i0n.ca/) (destruc7i0n) +- [Generator](https://misode.github.io/advancement/) (Misode) +- [Evaluator](https://sourceblock.net/beta/tools/advancement-evaluator) (Skylinerw) +- [Empty vanilla advancements, for overwriting default ones](http://www.mediafire.com/file/oku6p2tje0vv9lc/Impossible%20Advancements.zip) (18w22c) +- [VSCode Schema](https://marketplace.visualstudio.com/items?itemName=Levertion.mcjson) (Levertion) + + +### References + +- [Guide](https://github.com/skylinerw/guides/blob/master/java/advancements.md) (Skylinerw) +- [Format](http://minecraft.wiki/Advancements#JSON_Format) (Wiki) +- [Biome list](https://pastebin.com/MK61Xuzf) (Skylinerw) +- [Order of trigger activations in a tick](http://i.imgur.com/pz5mU0G.png) (Skylinerw) + +## Recipes + +### Utilities + +- [Generator](http://minecraft.tools/en/custom-crafting.php#) (Minecraft Tools) +- [Generator](https://crafting.thedestruc7i0n.ca/) (destruc7i0n) +- [Generator](http://commandcreator.com/Craft/) (Command Creator) +- [Evaluator](https://sourceblock.net/beta/tools/recipe-evaluator) (Skylinerw) + +### References + +- [Guide](https://github.com/skylinerw/guides/blob/master/java/recipes.md) (Skylinerw) + +## Text formatting + +### Utilities + +- [Title](http://minecraft.tools/en/title.php) (Minecraft Tools) +- [Title](https://minecraftcommand.science/title-generator) (Command Science) +- [Sign](http://minecraft.tools/en/sign.php) (Minecraft Tools) +- [Sign](https://minecraftcommand.science/command-sign-generator) (Command Science) ^[Escapes incorrectly] +- [Sign](https://mctoolbox.cmd.science/sign/) (MCToolBox) +- [Book](http://minecraft.tools/en/book.php) (Minecraft Tools) +- [Tellraw](http://minecraft.tools/en/tellraw.php) (Minecraft Tools) +- [Tellraw](https://blockbench.net/tools/tellraw/) (JannisX11) +- [Evaluator](https://sourceblock.net/beta/tools/text-component-evaluator) (Skylinerw) +- [§ code Texteditor](https://plagiatus.net/tools/colortext/) (Plagiatus) + +### References + +- [Guide](https://github.com/skylinerw/guides/blob/master/java/text%20component.md) (Skylinerw) +- [§ codes](http://minecraft.wiki/Formatting_codes) (Wiki) +- [§ codes](http://minecraft.tools/en/color-code.php) (Minecraft Tools) + +## Give + +### Utilities + +- [Give generator](https://mcstacker.net/mcstacker1.13.php) (MCStacker) +- [Item](https://minecraftcommand.science/custom-item-generator) (Command Science) +- [Tools/weapons](https://minecraftcommand.science/tool-generator) (Command Science) +- [Potions](https://minecraftcommand.science/potion-generator) (Command Science) +- [Armor](https://minecraftcommand.science/armor-generator) (Command Science) +- [Firework generator](http://minecraft.tools/en/firework.php) (Minecraft Tools) + +### References + +## Entities + +### Utilities + +- [Summon generator](http://minecraft.tools/en/spawn.php) (Minecraft Tools) +- [Summon generator](https://mcstacker.net/mcstacker1.13.php) (MCStacker) +- [Summon generator](http://www.summon-helper.net/entitySelection.html) (Summon Helper) +- [Spawner generator](https://mcstacker.net/mcstacker1.13.php) (MCStacker, select mob spawner in `/setblock`) +- [Villager shop](https://minecraftcommand.science/shop-generator) (Command Science) +- [Hologram text](https://minecraftcommand.science/hologram-generator) (Command Science) +- [Hologram text](https://mctoolbox.cmd.science/holograms/) (MCToolBox) +- [Mob click detection](http://mctoolbox.cmd.science/click-mobs/) (MCToolBox) + +### References + +- [Chunk format](http://minecraft.wiki/Chunk_format) (Wiki) + +## World editing + +### Utilities + +- [Amulet Editor](https://www.amulet-editor.com/) +- [MCEdit Unified](http://www.mcedit-unified.net) +- [MCEdit 2.0 beta](http://www.mcedit.net/downloads.html) ^[Beta, missing features] +- [MCEdit filter collection](http://www.brightmoore.net/mcedit-filters-1) (Adrian Brightmoore) +- [MCEdit filter collection](http://web.archive.org/web/20161229045538/http://elemanser.com/filters.html) (Texelelf) +- [WorldPainter](http://worldpainter.net/) (Captain Chaos) +- [WorldSynth](https://www.worldsynth.net) (booleanbyte) +- [MCA Selector](https://github.com/Querz/mcaselector) (Querz) +- [Shape planner](http://www.plotz.co.uk/) (Plotz) +- [Template manager](https://www.youtube.com/watch?v=LjixFRcqxSs) (bananenbroek4) + +### References + +- [Data values](http://minecraft.wiki/Data_values) (Wiki) +- [Building guides](https://www.reddit.com/r/Minecraft/comments/6eua5z/a_reminder_of_some_excellent_build_guidesbuilders/) (Adrian Brightmoore) +- [Biome colour-map](http://i.imgur.com/05QGuPX.png) (Word_Wizzard) + +## World generation + +### Utilities + +- [Custom world setting generator](https://misode.github.io/worldgen/) (Misode) +- [Superflat preset generator](http://minecraft.tools/en/flat.php) (Minecraft Tools) + +### References + +- [Custom world type format](https://minecraft.wiki/Custom) +- [Noise settings examples](https://gist.github.com/misode/b83bfe4964e6bf53b2dd31b22ee94157) (Misode) +- [Vanilla worldgen reference files](https://t.co/cm3pJcAHcy) (Mojang) + +## Resource packs + +### Utilities + +- [Model creator](https://blockbench.net/) (BlockBench) +- [Model creator](http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-tools/2146545-opls-model-creator-free-3d-model-editor) (opl) +- [Model creator](https://mrcrayfish.com/tools?id=mc) (MrCrayfish) +- [Model creator](http://thejonwithnoh.github.io/SetblockWebModeler/) (thejonwithnoh) +- [Model creator](https://cubik.studio/) (Cubik) ^[Paid] +- [Damage predicate generator](http://accidentalgames.com/media/durabilityModels.php) (Accidental games) +- [Upgraded damage predicate generator](https://geenium.github.io/damage-value-generator/) (Upgraded by geenium) +- [Resource pack creator](https://minecraft.novaskin.me/resourcepacks) (Novaskin) +- [Resource pack creator](https://mcrpw.github.io/) (MightyPork) +- [Block designer](https://codecrafted.net/blockdesigner) (CodeCrafted, concept by Simplysarc) + +### References + +- [Model format](http://minecraft.wiki/Model) (Wiki) +- [Sounds list](https://minecraft.wiki/Sounds.json/Java_Edition_values) (Wik) +- [Font json format](https://discordapp.com/channels/154777837382008833/154777837382008833/468913675017912320) (AmberW) +- [Shader `post` json format](https://discordapp.com/channels/154777837382008833/154777837382008833/490651571261014036) (Mrpingouin) +- [Shader `program` special variables](https://discordapp.com/channels/154777837382008833/306175724942000128/491380153960628231) (Mrpingouin) +- [Shader guide](https://docs.google.com/document/d/15TOAOVLgSNEoHGzpNlkez5cryH3hFF3awXL5Py81EMk/edit?usp=sharing) (SirBenet) + +## Map publishing + +### Utilities + +- [Map auto-install creator](https://github.com/mrjvs/mpm/releases) (mrjvs) +- [Minecraft Maps](http://www.minecraftmaps.com) (Site for maps) +- [Minecraft Forum](https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/maps) (Site for maps) +- [Planet Minecraft](https://www.planetminecraft.com) (Site for maps) + +### References + +## Miscellaneous + +### Heads + +- [Head generator](https://minecraftcommand.science/head-generator) (Command Science) +- [Custom heads](http://heads.freshcoal.com/maincollection.php) (Freshcoal) +- [Mob head display sizes](https://twitter.com/samasaurus6/status/787010091094540288) (samasaurus6) + +### Banners/shields + +- [Banner designer](http://www.needcoolshoes.com/banner) (Miners Need Cool Shoes) +- [Banner designer](http://www.planetminecraft.com/banner/) (Planet Minecraft) +- [Banner designer](http://minecraft.tools/en/banner.php) (Minecraft Tools) +- [Shield designer](http://minecraft.tools/en/shield.php) (Minecraft Tools) + +### Color + +- [Beacon color](http://minecraft.tools/en/beacon-color.php) (Minecraft Tools) +- [Armor color](http://minecraft.tools/en/armor.php) (Minecraft Tools) +- [Armor color](https://minecraftcommand.science/armor-color) (Command Science) +- [Color picker](http://skylinerw.com/color/) (Skylinerw) +- [Block colors](http://mrgarretto.com/blockcolors) (MrGarretto) +- [Particle color](http://mctoolbox.cmd.science/particles/) (MCToolBox) +- [Biome water colors](https://pastebin.com/2zYzzymu) (extracted by MrPingouin using [Fabric](https://fabricmc.net/)) + +### Map items + +- [Image to map](https://mc-map.djfun.de/) (MC Map Item Tool) +- [Image to map](http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-tools/1261738-linux-windows-imagetomap-in-game-text-and-images) (ImageToMap) +- [Image to map](https://github.com/tryashtar/image-map/raw/master/Image%20Map/bin/Debug/Image%20Map.exe) (tryashtar) +- [NBT reference](http://minecraft.wiki/Player.dat_format#Maps) (Wiki) + + +### Animation + +- [Animator](https://github.com/JannisX11/animator/releases/tag/v1.1.1) (Jannis) +- [Cutscene generator](https://www.youtube.com/watch?v=ukR7126RkU4) (The Redstone Scientist) +- [Armorstand animator](https://mrgarretto.com/armorstand/) (MrGarretto) +- [Block model animator](http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-tools/2715476-block-models-json-model-animator) (fizzy81) diff --git a/optimising.md b/optimising.md index 31e0cfde1..73e929448 100644 --- a/optimising.md +++ b/optimising.md @@ -86,7 +86,9 @@ Selectors are used a lot in commands. To make sure you're not causing extra work 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. -`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. +`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. + +Use `execute if/unless items` instead of `nbt` to detect items in the player inventory. For more details see [Detect a specific item?](/wiki/questions/detectitem) `@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. @@ -98,10 +100,17 @@ Consider also whether you actually need a selector. If you're selecting the same ## Optimize entities -Using armor stands as markers? Strongly consider switching to area effect clouds or, even better, the marker entity instead. [Here's a good video showing just how much difference this makes.](https://www.youtube.com/watch?v=RKXzWGQfIcg) You can summon an area effect cloud that acts as a marker with: +Using armor stands as markers? Strongly consider switching to area effect clouds or, even better, the `marker` entity instead. [Here's a good video showing just how much difference this makes.](https://www.youtube.com/watch?v=RKXzWGQfIcg) You can summon an area effect cloud that acts as a marker with: + # 1.20.5+ + summon area_effect_cloud ~ ~ ~ {Duration:-1} + # Pre-1.20.5 summon area_effect_cloud ~ ~ ~ {Duration:2147483647} +| 📝 Note | +|---------| +|Starting [in 1.21.5](https://www.minecraft.net/de-de/article/minecraft-java-edition-1-21-5), setting the `Duration` to `-1` causes the area effect cloud to never expire (this is now the default, so the `Duration` field can be omitted). Before that you'd set it to `2147483647` which made the cloud expire after over 3 years of ingame time.| + 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`. [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. @@ -140,3 +149,5 @@ This means that instead of evaluating `@e[tag=blah]` many times, it is only eval [/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. Read their full post here: https://www.reddit.com/r/MinecraftCommands/comments/w4vjs3/whenever_i_create_datapacks_i_sometimes_do/ + +You can use [Misode's Report Inspector](https://misode.github.io/report/) to see what commands are causing lag. \ No newline at end of file diff --git a/questions.md b/questions.md index 7c30e33cf..9f180a41b 100644 --- a/questions.md +++ b/questions.md @@ -5,11 +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 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). -Anything relating to items (such as /give, /item or loot tables) have a different format now. -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. -For example: /give @p diamond_pickaxe[damage=10,custom_model_data=7] -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). +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... @@ -44,31 +40,37 @@ For a list of how item components are structured, see [this article on the minec [Detect when a player kills an entity/other player?](/wiki/questions/playerkills) [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 a player looking at something (entity / position)?](/wiki/questions/lookat) -### Misc +### Conditions +[Do conditions with functions?](/wiki/questions/functionconditions) [Do something if a command block *wasn't* successful?](/wiki/questions/blockinvert) +[Check if there are exactly X players (or entities) matching a selector?](/wiki/questions/numplayers) + +### Entities + [Do something (e.g: kill) to the entity I just found with /execute if entity (testfor)?](/wiki/questions/tagentity) -[Add a delay to a command block?](/wiki/questions/blockdelay) -[Check if there are exactly X players matching a selector?](/wiki/questions/numplayers) -[Do conditions with functions?](/wiki/questions/functionconditions) -[Point a compass towards a player?](/wiki/questions/compasstoplayer) -[Summon an entity/projectile flying in the direction the player is looking?](/wiki/questions/shootfacing) -[Make a scoreboard ID system?](/wiki/questions/linkentity) [Make one mob attack another mob/player?](/wiki/questions/angermob) -[Do raycasting?](/wiki/questions/raycast) -[Make a circle (of blocks / entities)?](/wiki/questions/makecircle) +[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 / dissable PvP](/wiki/questions/hostilefriendly) +[Make hostile mobs friendly / disable PvP?](/wiki/questions/hostilefriendly) [Setup, configure and add multiple dialogues to NPCs?](/wiki/questions/npc) +### Misc + +[Add a delay to a command block?](/wiki/questions/blockdelay) +[Point a compass towards a player/location?](/wiki/questions/compasstoplayer) +[Make a scoreboard ID system?](/wiki/questions/linkentity) +[Do raycasting?](/wiki/questions/raycast) +[Make a circle (of blocks / entities)?](/wiki/questions/makecircle) + ## What is... [a fake player?](/wiki/questions/fakeplayer) [a range? / those two dots `..`?](/wiki/questions/range) [command context?](/wiki/questions/commandcontext) - +[escaping?](/wiki/questions/escaping) ## How do I... (1.12 and below only) @@ -77,4 +79,4 @@ For a list of how item components are structured, see [this article on the minec ## Still needed articles -*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).* +*Found something that should be added? Maybe even want to contribute an article? Submit a [pull request](https://github.com/MinecraftCommands/wiki/pulls) or create a [GitHub issue](https://github.com/MinecraftCommands/wiki/issues)* diff --git a/questions/amountitems.md b/questions/amountitems.md index 3d6a4fd74..03030f530 100644 --- a/questions/amountitems.md +++ b/questions/amountitems.md @@ -1,5 +1,8 @@ # Select players with exactly X amount of items? +* [Java](#java) +* [Bedrock](#bedrock) + ## Java ### Clear @@ -7,51 +10,61 @@ Using the [`clear`](https://minecraft.wiki/Commands/clear) command with a `[]` of 0 will return the amount of items a player has, without actually clearing any of them. That means we can use [`execute store`](https://minecraft.wiki/w/Commands/execute#Store_subcommand) to save that number somewhere and then execute depending on that: - # Setup - scoreboard objectives add diamonds dummy +```mcfunction +# Setup +scoreboard objectives add diamonds dummy - # Commands - execute store result score @s diamonds run clear @s diamond 0 - execute if score @s diamonds matches 5 run say I have exactly 5 diamonds in my inventory. - execute if score @s diamonds matches 1..4 run say I have somewhere between 1 and 4 diamonds in my inventory. - execute if score @s diamonds matches 10.. run say I have 10 or more diamonds in my inventory. - execute if score @s diamonds matches ..20 run say I have 20 or less diamonds in my inventory. +# Commands +execute store result score @s diamonds run clear @s diamond 0 +execute if score @s diamonds matches 5 run say I have exactly 5 diamonds in my inventory. +execute if score @s diamonds matches 1..4 run say I have somewhere between 1 and 4 diamonds in my inventory. +execute if score @s diamonds matches 10.. run say I have 10 or more diamonds in my inventory. +execute if score @s diamonds matches ..20 run say I have 20 or less diamonds in my inventory. +``` ### Execute if items -Since version 1.20.5 you can also use [`execute if items`](https://minecraft.wiki/w/Commands/execute#(if|unless)_items) to count the number of items. +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): - # In chat - execute if items entity @s container.* * +```mcfunction +# In chat +execute if items entity @s container.* * +``` You can find out more details on how to detect specific items here: [Detect a specific item](/wiki/questions/detectitem) Below is an example for getting the amount of a custom item and executing some command depending on the result: - # Example item - give @s diamond[minecraft:custom_data={diamond:true},minecraft:item_name="'Custom Diamond'"] - - # Command blocks - execute as @a store result score @s diamonds if items entity @s container.* *[custom_data~{diamond:true}] - execute as @a[scores={diamonds=5}] run say I have exactly 5 coins. - execute as @a[scores={diamonds=1..4}] run say I have somewhere between 1 and 4 coins. - execute as @a[scores={diamonds=10..}] run say I have 10 or more coins. - execute as @a[scores={diamonds=..20}] run say I have 20 or less coins. +```mcfunction +# Example item +give @s diamond[minecraft:custom_data={diamond:true},minecraft:item_name="'Custom Diamond'"] + +# Command blocks +execute as @a store result score @s diamonds if items entity @s container.* *[custom_data~{diamond:true}] +execute as @a[scores={diamonds=5}] run say I have exactly 5 coins. +execute as @a[scores={diamonds=1..4}] run say I have somewhere between 1 and 4 coins. +execute as @a[scores={diamonds=10..}] run say I have 10 or more coins. +execute as @a[scores={diamonds=..20}] run say I have 20 or less coins. +``` Although you can use `/clear` on a player, `if items` can also count the number of items in a chest, shulker_box and other containers, can also count the number of items in a players ender_chest. Here are some examples for this: - # Counting items in chest or any container - execute store result score #container diamonds if items block container.* *[custom_data~{diamond:true}] - - # Counting items in ender_chest - execute as @a store result score @s diamonds if items entity @s enderchest.* *[custom_data~{diamond:true}] +```mcfunction +# Counting items in chest or any container +execute store result score #container diamonds if items block container.* *[custom_data~{diamond:true}] + +# Counting items in ender_chest +execute as @a store result score @s diamonds if items entity @s enderchest.* *[custom_data~{diamond:true}] +``` ## Bedrock 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. - execute as @a[hasitem={item=apple,quantity=5..}] run say I have 5 or more apples in my inventory +```mcfunction +execute as @a[hasitem={item=apple,quantity=5..}] run say I have 5 or more apples in my inventory +``` \ No newline at end of file diff --git a/questions/angermob.md b/questions/angermob.md index 2dcd7f177..ea985e217 100644 --- a/questions/angermob.md +++ b/questions/angermob.md @@ -1,4 +1,4 @@ -# Make a mob attack another specfic entity / player +# Make a mob attack another specific entity / player The basic principle for this method is that a mob that can attack will get angry at whoever attacks them. _(some exceptions apply)_ @@ -6,29 +6,35 @@ The basic principle for this method is that a mob that can attack will get angry ### Using /damage -> [!IMPORTANT] -> In bedrock a lot of entities have a very defined set of other entities they can attack, as defined in their behavior pack. So if the below method doesn't work to anger them, make sure they're actually able to attack the target entity and change the behavior files accordingly! +| ⚠️ Important | +|--------------| +|In bedrock a lot of entities have a very defined set of other entities they can attack, as defined in their behavior pack. So if the below method doesn't work to anger them, make sure they're actually able to attack the target entity and change the behavior files accordingly!| Thanks to the introduction of the [`/damage` command](https://minecraft.wiki/wiki/Commands/damage) (in 1.18.10 Bedrock and 1.19.4 Java) we can use this command to inflict fake damage from one entity onto another with relative ease: - # bedrock - /damage entity_attack entity - # java - /damage by +```mcfunction +# bedrock +/damage entity_attack entity +# java +/damage by +``` so for example, to make a single wolf attack a player, you can run this command - # bedrock - /damage @e[type=wolf,c=1] 0 entity_attack entity @p - # java - /damage @e[type=wolf,limit=1,sort=nearest] 0 player_attack by @p - +```mcfunction +# bedrock +/damage @e[type=wolf,c=1] 0 entity_attack entity @p +# java +/damage @e[type=wolf,limit=1,sort=nearest] 0 player_attack by @p +``` or to make all skeleton skeleton attack a zombie - # bedrock - /damage @e[type=skeleton] 0 entity_attack entity @e[type=zombie] - # java - /execute as @e[type=skeleton] run damage @s 0 player_attack by @e[type=zombie,limit=1] +```mcfunction +# bedrock +/damage @e[type=skeleton] 0 entity_attack entity @e[type=zombie] +# java +/execute as @e[type=skeleton] run damage @s 0 player_attack by @e[type=zombie,limit=1] +``` In this example we're using `0` as the amount of damage, as we just want to pretend to deal damage to the entity, not actually deal any damage. @@ -39,16 +45,19 @@ In this example we're using `0` as the amount of damage, as we just want to pret The way the game knows who got attacked by whom is by tracking the owner of a projectile through the projectiles `Owner` tag, which represents the owners UUID. We can use this to make a projectile that pretends to be from a specific entity by modifying this NBT tag. For example you can use a snowball, as this projectile only deal damage to blazes. The snowball is summoned 2.3 blocks above the target so their hitboxes don't overlap (which would cause the snowball to ignore the target). -> [!IMPORTANT] -> If the player is crawnling or it has a block above them, it wont work. -In the following example a skeleton tagged `attacker` is tricked into attacking a zombie tagged `target`. +| ⚠️ Important | +|--------------| +|If the player is crawling or it has a block above them, it won't work| - # summon the snowball - execute at @e[type=skeleton,tag=attacker] run summon minecraft: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 +In the following example a skeleton tagged `attacker` is tricked into attacking a zombie tagged `target`. +```mcfunction +# summon the snowball +execute at @e[type=skeleton,tag=attacker] run summon minecraft: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 +``` ## Bedrock ### Using behaviors @@ -57,44 +66,50 @@ As mentioned above, what entities can and cannot be attacked by another entity i Here is the relevant component in the vanilla skeleton behavior file (1.17): - "minecraft:behavior.nearest_attackable_target": { - "priority": 2, - "must_see": true, - "reselect_targets": true, - "entity_types": [ - { - "filters": { +
+ See skeleton behavior + +```json + "minecraft:behavior.nearest_attackable_target": { + "priority": 2, + "must_see": true, + "reselect_targets": true, + "entity_types": [ + { + "filters": { + "test": "is_family", + "subject": "other", + "value": "player" + }, + "max_dist": 16 + }, + { + "filters": { + "test": "is_family", + "subject": "other", + "value": "irongolem" + }, + "max_dist": 16 + }, + { + "filters": { + "all_of": [ + { "test": "is_family", "subject": "other", - "value": "player" + "value": "baby_turtle" }, - "max_dist": 16 - }, - { - "filters": { - "test": "is_family", + { + "test": "in_water", "subject": "other", - "value": "irongolem" - }, - "max_dist": 16 - }, - { - "filters": { - "all_of": [ - { - "test": "is_family", - "subject": "other", - "value": "baby_turtle" - }, - { - "test": "in_water", - "subject": "other", - "operator": "!=", - "value": true - } - ] - }, - "max_dist": 16 - } - ] - }, + "operator": "!=", + "value": true + } + ] + }, + "max_dist": 16 + } + ] + }, +``` +
\ No newline at end of file diff --git a/questions/areas.md b/questions/areas.md index f5732f1e2..95e1a4958 100644 --- a/questions/areas.md +++ b/questions/areas.md @@ -1,14 +1,17 @@ # Do something if a player is in certain areas -> [!NOTE] -> Java Syntax, but this can be applied to Bedrock just as well by changing the selector arguments to Bedrock Syntax. Instead of `distance=..X` use `r=X`, instead of `distance=X..Y` use `r=Y,rm=X` and instead of `distance=X..` use `rm=X`. +| 📝 Note | +|---------| +|Java Syntax, but this can be applied to Bedrock just as well by changing the selector arguments to Bedrock Syntax. Instead of `distance=..X` use `r=X`, instead of `distance=X..Y` use `r=Y,rm=X` and instead of `distance=X..` use `rm=X`.| -This mostly comes up as a question to change the gamemode in a certain area (e.g. spawn, safe zones, etc.), so we will focus on that, but this can be applied to any use case. For questions to do something once a player enters a single area, [look here](/wiki/questions/runonce). +This mostly comes up as a question to change the gamemode in a certain area (e.g., spawn, safe zones, etc.), so we will focus on that, but this can be applied to any use case. For questions to do something once a player enters a single area, [look here](/wiki/questions/runonce). The naive approach would be to put everyone in a radius X around the worldspawn (e.g. at 0 0 0) to adventure mode and everyone outside of it to survival mode. - gamemode adventure @a[x=0,y=0,z=0,distance=..X] - gamemode survival @a[x=0,y=0,z=0,distance=X..] +```mcfunction +gamemode adventure @a[x=0,y=0,z=0,distance=..X] +gamemode survival @a[x=0,y=0,z=0,distance=X..] +``` This method quickly falls apart if you have a non-spherical or non-box shaped area or you want this to apply to more than one area, because a player will always be outside of the other areas, even if they are inside one, so will always end up in survival. @@ -16,18 +19,22 @@ This method quickly falls apart if you have a non-spherical or non-box shaped ar The best way to make sure players are in one of multiple areas without overwriting each other, is to use a tag: So instead of applying the desired effect to each area individually, you tag all players that are in one of the areas and apply the effect once to all of them (or everyone else). But this method requires a separate command block for each location. For a large number of locations, use the anchor entity method. - # Command blocks / tick function - tag @a remove inArea - tag @a[x=0,y=0,z=0,distance=..X] add inArea - tag @a[x=100,y=64,z=100,dx=70,dy=16,dz=28] add in Area - .... - gamemode adventure @a[tag=inArea] - gamemode survival @a[tag=!inArea] +```mcfunction +# Command blocks / tick function +tag @a remove inArea +tag @a[x=0,y=0,z=0,distance=..X] add inArea +tag @a[x=100,y=64,z=100,dx=70,dy=16,dz=28] add inArea +.... +gamemode adventure @a[tag=inArea] +gamemode survival @a[tag=!inArea] +``` -To prevent chatspam for the players and unnecessary gamemode changes, we suggest using the gamemode selector argument on the last two commands: +To prevent chat spam for the players and unnecessary gamemode changes, we suggest using the gamemode selector argument on the last two commands: - gamemode adventure @a[tag=inArea,gamemode=!adventure] - gamemode survival @a[tag=!inArea,gamemode=!survival] +```mcfunction +gamemode adventure @a[tag=inArea,gamemode=!adventure] +gamemode survival @a[tag=!inArea,gamemode=!survival] +``` If for some reason you want to keep commandBlockOutput on and don't want your output to be spammed by this system, check out [this post](https://www.reddit.com/r/MinecraftCommands/comments/mw11xm/do_something_to_players_in_multiple_specific) by [u/Afanofall23](https://www.reddit.com/u/Afanofall23). @@ -37,24 +44,28 @@ If you need to check if the player is in one of several spherical areas, for exa For versions before 1.17 you can use armor_stand or area_effect_cloud, but since version 1.17 it is strongly recommended to use an [marker entity](https://minecraft.wiki/w/Marker) to mark a place. - # Summon marker - summon marker {Tags:["adventure_area"]} - - # Command blocks / tick function - execute as @a[gamemode=survival] at @s if entity @e[type=marker,tag=adventure_area,distance=..X,limit=1] run gamemode adventure - execute as @a[gamemode=adventure] at @s unless entity @e[type=marker,tag=adventure_area,distance=..X,limit=1] run gamemode survival - +```mcfunction +# Summon marker +summon marker {Tags:["adventure_area"]} + +# Command blocks / tick function +execute as @a[gamemode=survival] at @s if entity @e[type=marker,tag=adventure_area,distance=..X,limit=1] run gamemode adventure +execute as @a[gamemode=adventure] at @s unless entity @e[type=marker,tag=adventure_area,distance=..X,limit=1] run gamemode survival +``` + `X - distance at which players should be switched into adventure mode.` To make placing markers more convenient, you can give a spawn_egg containing a marker with the tag: - # 1.17 - 1.20.4 - give @s bat_spawn_egg{EntityTag:{id:"minecraft:marker",Tags:["adventure_area"]},display:{Name:'{"text":"Adventure Area Marker","italic":false}'}} - - # 1.20.5+ - give @s minecraft:bat_spawn_egg[entity_data={id:"minecraft:marker",Tags:["adventure_area"]},item_name='"Adventure Area Marker"'] +```mcfunction +# 1.17 - 1.20.4 +give @s bat_spawn_egg{EntityTag:{id:"minecraft:marker",Tags:["adventure_area"]},display:{Name:'{"text":"Adventure Area Marker","italic":false}'}} + +# 1.20.5+ +give @s minecraft:bat_spawn_egg[entity_data={id:"minecraft:marker",Tags:["adventure_area"]},item_name='"Adventure Area Marker"'] +``` -Because in bedrock edition we can't give a custom spawn egg (some exceptions apply, see [give custom item in Bedrock](wiki/questions/giveitembedrock)), you will need to manualy tag the entity with the `/tag` command and use `armor_stand` instead of `marker`. +Because in bedrock edition we can't give a custom spawn egg (some exceptions apply, see [give custom item in Bedrock](wiki/questions/giveitembedrock)), you will need to manually tag the entity with the `/tag` command and use `armor_stand` instead of `marker`. ## Block layer @@ -62,8 +73,10 @@ If you need to execute a command when a player enters a very randomly shaped are For example, you want to create an area on your map where the player will be detected if the player is not sneaking. This example will check the red_concrete block at Y=-63 for this area: - # 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! +```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! +``` ## Predicates @@ -73,65 +86,71 @@ In a predicate, you can use the `minecraft:alternative` (1.14-1.19.4) or `minecr Below is an example of a predicate for checking three cubic areas: +
+ Example predicate + +```json +{ + "condition": "minecraft:any_of", + "terms": [ { - "condition": "minecraft:any_of", - "terms": [ - { - "condition": "minecraft:location_check", - "predicate": { - "position": { - "x": { - "min": 10, - "max": 20 - }, - "y": { - "min": 64, - "max": 70 - }, - "z": { - "min": 30, - "max": 40 - } - } + "condition": "minecraft:location_check", + "predicate": { + "position": { + "x": { + "min": 10, + "max": 20 + }, + "y": { + "min": 64, + "max": 70 + }, + "z": { + "min": 30, + "max": 40 } - }, - { - "condition": "minecraft:location_check", - "predicate": { - "position": { - "x": { - "min": 60, - "max": 85 - }, - "y": { - "min": -20, - "max": 10 - }, - "z": { - "min": 10, - "max": 80 - } - } + } + } + }, + { + "condition": "minecraft:location_check", + "predicate": { + "position": { + "x": { + "min": 60, + "max": 85 + }, + "y": { + "min": -20, + "max": 10 + }, + "z": { + "min": 10, + "max": 80 } - }, - { - "condition": "minecraft:location_check", - "predicate": { - "position": { - "x": { - "min": -80, - "max": -20 - }, - "y": { - "min": 125, - "max": 155 - }, - "z": { - "min": 55, - "max": 78 - } - } + } + } + }, + { + "condition": "minecraft:location_check", + "predicate": { + "position": { + "x": { + "min": -80, + "max": -20 + }, + "y": { + "min": 125, + "max": 155 + }, + "z": { + "min": 55, + "max": 78 } } - ] + } } + ] +} +``` +
\ No newline at end of file diff --git a/questions/blockdelay.md b/questions/blockdelay.md index 68a8a8255..5f3ff0659 100644 --- a/questions/blockdelay.md +++ b/questions/blockdelay.md @@ -1,9 +1,12 @@ # Add a delay to a command block +* [Java](#java) +* [Bedrock](#bedrock) + ## Bedrock -In the Bedrock edition of the game, you can just give a commandblock a delay direcly through its interface, no need for any workarounds, unless you want to make a timer for every player, see the method using a [scoreboard](#scoreboard) +In the Bedrock edition of the game, you can just give a commandblock a delay directly through its interface, no need for any workarounds, unless you want to make a timer for every player, see the method using a [scoreboard](#scoreboard) ## Java @@ -15,44 +18,56 @@ Area effect clouds (AECs) have a `Duration` tag and an `Age` tag. Their `Age` wi For example, the following creates an AEC that will disappear in 100 ticks (5 seconds), as their `Age` defaults to 0: - summon area_effect_cloud ~ ~ ~ {Duration:100} +```mcfunction +summon area_effect_cloud ~ ~ ~ {Duration:100} +``` -> [!NOTE] -> To see area_effect_cloud press `F3 + B` to show hitboxes. +| 📝 Note | +|---------| +|To see area_effect_cloud press `F3 + B` to show hitboxes| You can set the `Duration` tag as a positive value or the `Age` tag as a negative value, but then you need to set the `Particle` tag to `"block air"` (1.20.4 and below) or `{type:"block",block_state:"minecraft:air"}` (1.20.5 and above) to prevent it from creating particles. We can also summon it with a tag to select it with later: +```mcfunction +# 1.20.4 and below +summon area_effect_cloud ~ ~ ~ {Tags:["delay"],Age:-100,Particle:"block air"} - # 1.20.4 and below - summon area_effect_cloud ~ ~ ~ {Tags:["delay"],Age:-100,Particle:"block air"} - - # 1.20.5 and above - summon area_effect_cloud ~ ~ ~ {Tags:["delay"],Age:-100,Particle:{type:"block",block_state:"minecraft:air"}} +# 1.20.5 and above +summon area_effect_cloud ~ ~ ~ {Tags:["delay"],Age:-100,Particle:{type:"block",block_state:"minecraft:air"}} +``` The following 3 commands, in this order on a repeating-chain clock, will tag any AEC that's reached `Age:-1` with `delayActivating`, then make them activate (by turning on/off) an impulse command block at their position: - tag @e[type=area_effect_cloud,tag=delay,nbt={Age:-1}] add delayActivating - execute at @e[type=area_effect_cloud,tag=delayActivating] run data merge block ~ ~ ~ {auto:true} - execute at @e[type=area_effect_cloud,tag=delayActivating] run data merge block ~ ~ ~ {auto:false} +```mcfunction +tag @e[type=area_effect_cloud,tag=delay,nbt={Age:-1}] add delayActivating +execute at @e[type=area_effect_cloud,tag=delayActivating] run data merge block ~ ~ ~ {auto:true} +execute at @e[type=area_effect_cloud,tag=delayActivating] run data merge block ~ ~ ~ {auto:false} +``` That means that if you have those 3 commands repeating somewhere in your world, the command `/summon area_effect_cloud X Y Z {Tags:[delay],Age:-##,Particle:{type:"block",block_state:"minecraft:air"}}` can be used to activate the command block at (X, Y, Z) in ## ticks. An example, that'll activate the block at (10, 64, 30) in 70 ticks: - summon area_effect_cloud 10 64 30 {Tags:["delay"],Age:-70,Particle:{type:"block",block_state:"minecraft:air"}} +```mcfunction +summon area_effect_cloud 10 64 30 {Tags:["delay"],Age:-70,Particle:{type:"block",block_state:"minecraft:air"}} +``` However, if you want to use spawn_egg to simply create an AEC's for delay, then you need to add Radius and WaitTime: - # 1.13 - 1.20.4 - give @s bat_spawn_egg{EntityTag:{id:"minecraft:area_effect_cloud",Tags:["delay"],Duration:100,Radius:0f,WaitTime:0}} - - # 1.20.5+ - give @s bat_spawn_egg[entity_data={id:"minecraft:area_effect_cloud",Tags:["delay"],Duration:100,Radius:0f,WaitTime:0}] +```mcfunction +# 1.13 - 1.20.4 +give @s bat_spawn_egg{EntityTag:{id:"minecraft:area_effect_cloud",Tags:["delay"],Duration:100,Radius:0f,WaitTime:0}} -> [!NOTE] -> You can use any `spawn_egg`, but not just `bat_spawn_egg` +# 1.20.5+ +give @s bat_spawn_egg[entity_data={id:"minecraft:area_effect_cloud",Tags:["delay"],Duration:100,Radius:0f,WaitTime:0}] +``` - # Command block / tick function - execute at @e[type=area_effect_cloud,tag=delay,nbt={Age:99}] run summon zombie +| 📝 Note | +|---------| +|You can use any `spawn_egg`, but not just `bat_spawn_egg`| +```mcfunction +# Command block / tick function +execute at @e[type=area_effect_cloud,tag=delay,nbt={Age:99}] run summon zombie +``` This is a simple way to execute any command at a specified position once with a specified delay. @@ -60,67 +75,78 @@ This is a simple way to execute any command at a specified position once with a If you need to execute a command not only once, but every 5 seconds, for example, at specific location, then you can use the [marker entity](https://minecraft.wiki/w/Marker) (1.17+) for this. If you are on an earlier version use an [`area_effect_cloud`](https://minecraft.wiki/w/Lingering_Potion#Area_effect_cloud) that will not despawn or an invisible [`armor_stand`](https://minecraft.wiki/w/Armor_Stand). - # Summon - summon marker ~ ~ ~ {Tags:["delay"]} - - # Spawn egg - ## 1.17 - 1.20.4 - give @s bat_spawn_egg{EntityTag:{id:"minecraft:marker",Tags:["delay"]}} - - ## 1.20.5+ - give @s bat_spawn_egg[entity_data={id:"minecraft:marker",Tags:["delay"]}] +```mcfunction +# Summon +summon marker ~ ~ ~ {Tags:["delay"]} -In addition to the marker, you need to use a scoreboard timer, which each tick will add 1 to the score marker. +# Spawn egg +## 1.17 - 1.20.4 +give @s bat_spawn_egg{EntityTag:{id:"minecraft:marker",Tags:["delay"]}} - # Command blocks / tick function - scoreboard players add @e[type=marker,tag=delay] timer 1 - execute as @e[type=marker,tag=delay,scores={delay=100..}] at @s store success score @s delay run summon zombie +## 1.20.5+ +give @s bat_spawn_egg[entity_data={id:"minecraft:marker",Tags:["delay"]}] +``` + +In addition to the marker, you need to use a scoreboard timer, which each tick will add 1 to the score marker. +```mcfunction +# Command blocks / tick function +scoreboard players add @e[type=marker,tag=delay] timer 1 +execute as @e[type=marker,tag=delay,scores={delay=100..}] at @s store success score @s delay run summon zombie +``` ### Scoreboard #### Java 1.13+ and Bedrock -For a scoreboard timer you can have a repeating commandblock somewhere that's counting up/down in a particular scoreboard objective and then use `execute if score` in the commandblock that should have the delay. You can either use individual player scores (recommended for player dependant events/delays) or "[fake player](/wiki/questions/fakeplayer)" scores (set "fake" values for player names, recommended for player independant delays). +For a scoreboard timer you can have a repeating commandblock somewhere that's counting up/down in a particular scoreboard objective and then use `execute if score` in the commandblock that should have the delay. You can either use individual player scores (recommended for player dependent events/delays) or "[fake player](/wiki/questions/fakeplayer)" scores (set "fake" values for player names, recommended for player independent delays). + +```mcfunction +# Setup +scoreboard objectives add timer dummy - # Setup - scoreboard objectives add timer dummy - - # The repeating command_block - scoreboard players add @a timer 1 +# The repeating command_block +scoreboard players add @a timer 1 - # The command_block that should run for every player with a timer score of 100 - execute as @a[scores={timer=100}] run say This command has 5 seconds delay. - scoreboard players reset @a[scores={timer=100..}] timer +# The command_block that should run for every player with a timer score of 100 +execute as @a[scores={timer=100}] run say This command has 5 seconds delay. +scoreboard players reset @a[scores={timer=100..}] timer - # Alternatively for a fake player timer - scoreboard players add $FakePlayer timer 1 - execute if score $FakePlayer timer matches 120 run say This command has 6 seconds delay. - execute if score $FakePlayer timer matches 120.. run scoreboard players reset $FakePlayer timer +# Alternatively for a fake player timer +scoreboard players add $FakePlayer timer 1 +execute if score $FakePlayer timer matches 120 run say This command has 6 seconds delay. +execute if score $FakePlayer timer matches 120.. run scoreboard players reset $FakePlayer timer +``` Or, if you do not create additional conditions, you can immediately reset the score in one command using `store success score` (only java edition): - # Command blocks - execute as @a[scores={timer=101..}] store success score @s timer run say This command has 5 seconds delay. - execute if score $FakePlayer timer matches 121.. store success score $FakePlayer timer run say This command has 6 seconds delay. +```mcfunction +# Command blocks +execute as @a[scores={timer=101..}] store success score @s timer run say This command has 5 seconds delay. +execute if score $FakePlayer timer matches 121.. store success score $FakePlayer timer run say This command has 6 seconds delay. +``` This command will not only execute the command, it also works as a timer reset command, however this implementation may not have the exact delay in some cases where your command is executed in some conditions and not in another. You can also make the delay more dynamic by setting a score of a fake player and comparing it to the players score: - # Set delay - scoreboard players set #delay timer 300 - - # Command block / tick function - execute as @a if score @s timer >= #delay timer store success score @s timer run say Custom delay command. +```mcfunction +# Set delay +scoreboard players set #delay timer 300 + +# Command block / tick function +execute as @a if score @s timer >= #delay timer store success score @s timer run say Custom delay command. +``` #### Java pre-1.13 Before 1.13 we didn't have `execute if score` so we will need to use `scoreboard players test` for that. - # command block - scoreboard players add FakePlayerA TimerScore 1 - scoreboard players test FakePlayerA TimerScore 60 - # Chain conditional - scoreboard players set FakePlayerA TimerScore 0 - # Conditional repeating command - +```mcfunction +# command block +scoreboard players add FakePlayerA TimerScore 1 +scoreboard players test FakePlayerA TimerScore 60 +# Chain conditional +scoreboard players set FakePlayerA TimerScore 0 +# Conditional repeating command + +``` [Here's an example setup image](http://i.imgur.com/fGyA294.png) @@ -128,19 +154,24 @@ Before 1.13 we didn't have `execute if score` so we will need to use `scoreboard Using functions the [schedule command](https://minecraft.wiki/Commands/schedule) can be used to make a function run in ## amount of ticks. - schedule function