From f443158faa2095f69ff0e05c747451d6b6df4596 Mon Sep 17 00:00:00 2001 From: EricristianBros Date: Sat, 2 Nov 2024 15:16:00 +0100 Subject: [PATCH 1/7] [Wiki Update]: 1.21.2, resources, callouts * New resources page (old resources are kept) * Callouts have been changed to tables and emojis * 1.21.2 item click food method fix * Organize misc category --- .github/issue_template/bug.yaml | 71 ++++++++ .github/issue_template/request.yaml | 30 +++ bcresources.md | 2 +- debugging.md | 14 +- oldresources.md | 272 ++++++++++++++++++++++++++++ optimising.md | 8 +- questions.md | 33 ++-- questions/angermob.md | 11 +- questions/areas.md | 5 +- questions/blockdelay.md | 25 ++- questions/blockinvert.md | 16 +- questions/changeofscore.md | 2 +- questions/compasstoplayer.md | 12 +- questions/customcrafting.md | 16 +- questions/detectitem.md | 12 +- questions/findsamescoreentity.md | 13 +- questions/giveitembedrock.md | 5 +- questions/heighttest.md | 2 +- questions/highestscore.md | 5 +- questions/hostilefriendly.md | 21 ++- questions/itemclick.md | 117 ++++++++++-- questions/linkentity.md | 5 +- questions/makecircle.md | 10 +- questions/movetoscore.md | 21 ++- questions/npc.md | 13 +- questions/numplayers.md | 35 ++-- questions/playerjoin.md | 10 +- questions/randomnumber.md | 10 +- questions/range.md | 5 +- questions/raycast.md | 5 +- questions/runonce.md | 20 +- questions/shop.md | 37 ++-- questions/storeinventory.md | 15 +- resources.md | 262 ++++----------------------- 34 files changed, 741 insertions(+), 399 deletions(-) create mode 100644 .github/issue_template/bug.yaml create mode 100644 .github/issue_template/request.yaml create mode 100644 oldresources.md diff --git a/.github/issue_template/bug.yaml b/.github/issue_template/bug.yaml new file mode 100644 index 000000000..7b8cffcab --- /dev/null +++ b/.github/issue_template/bug.yaml @@ -0,0 +1,71 @@ +name: "Bug Report" +description: Create a new ticket for a bug. +title: "[BUG]:" +labels: ["bug"] +body: + - type: textarea + id: description + attributes: + label: "Description" + description: Write a summary of the bug here. + validations: + required: true + - type: textarea + id: recreate + attributes: + label: "How to reproduce?" + description: Write, step by step, how to reproduce + value: | + 1. + 2. + 3. + 4. + render: bash + validations: + required: true + - type: textarea + id: result + attributes: + label: Result observed + description: Describe the result observed + placeholder: "The result observed…" + validations: + required: true + - type: textarea + id: expected_result + attributes: + label: Expected result + description: What did you expect as a result? + placeholder: "I expected…" + validations: + required: true + - type: textarea + id: other + attributes: + label: Other + description: Do you want to explain something more? + placeholder: " " + validations: + required: false + - type: textarea + id: files + attributes: + label: Screenshots / Files + description: You can copy and paste or drag and drop to add files. + placeholder: "files" + validations: + required: false + - type: dropdown + id: priority + attributes: + label: "Priority" + description: What is the priority of this bug? 1 means low priority and 5 means high priority. + multiple: false + options: + - 1 (Low priority) + - 2 + - 3 + - 4 + - 5 (High priority) + validations: + required: true \ No newline at end of file diff --git a/.github/issue_template/request.yaml b/.github/issue_template/request.yaml new file mode 100644 index 000000000..3d544f6d3 --- /dev/null +++ b/.github/issue_template/request.yaml @@ -0,0 +1,30 @@ +name: Request +description: Make a request. +title: "[REQUEST]: " +labels: ["request"] +projects: [""] +body: + - type: textarea + id: request + attributes: + label: What would you like to request? + description: Write your suggestion here. + placeholder: "I would like to request…" + validations: + required: true + - type: textarea + id: files + attributes: + label: Screenshots / Files + description: You can copy and paste or drag and drop to add files. + placeholder: "files" + validations: + required: false + - type: textarea + id: issues + attributes: + label: What issues will be solved with this request? + description: You can skip this question if none are solved. + placeholder: "#Issues ID" + validations: + required: false \ No newline at end of file diff --git a/bcresources.md b/bcresources.md index bacdda332..426fe3afb 100644 --- a/bcresources.md +++ b/bcresources.md @@ -4,7 +4,7 @@ This page contains a list of links to utilities and references for **Pocket Edit 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) diff --git a/debugging.md b/debugging.md index 412d5918e..86c19f5a9 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.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...) * 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 @@ -60,7 +58,7 @@ 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. +* 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.propieties` 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 diff --git a/oldresources.md b/oldresources.md new file mode 100644 index 000000000..4388400f5 --- /dev/null +++ b/oldresources.md @@ -0,0 +1,272 @@ +# 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 moder 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..8ae45e8b7 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,7 +100,7 @@ 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: summon area_effect_cloud ~ ~ ~ {Duration:2147483647} @@ -140,3 +142,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..6653428bb 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 data attached to stacks of items (tag field) has been replaced with structured 'components'. Anything related to items have a diferent format. 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). ## How do I... @@ -46,30 +42,35 @@ For a list of how item components are structured, see [this article on the minec [Store a players inventory (and give it back later)?](/wiki/questions/storeinventory) [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) +[Make one mob attack another mob/player?](/wiki/questions/angermob) [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) [Detect when a mob has died](/wiki/questions/mobdeaths) [Make hostile mobs friendly / dissable 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) - ## How do I... (1.12 and below only) [Select an entity with *multiple* scoreboard tags?](/wiki/questions/multipletags) @@ -77,4 +78,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/angermob.md b/questions/angermob.md index 2dcd7f177..e273f948e 100644 --- a/questions/angermob.md +++ b/questions/angermob.md @@ -6,8 +6,9 @@ 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: @@ -39,8 +40,10 @@ 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. + +| ⚠️ Important | +|--------------| +|If the player is crawnling or it has a block above them, it won't work| In the following example a skeleton tagged `attacker` is tricked into attacking a zombie tagged `target`. diff --git a/questions/areas.md b/questions/areas.md index f5732f1e2..b9e610ec6 100644 --- a/questions/areas.md +++ b/questions/areas.md @@ -1,7 +1,8 @@ # 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). diff --git a/questions/blockdelay.md b/questions/blockdelay.md index 68a8a8255..8ec131846 100644 --- a/questions/blockdelay.md +++ b/questions/blockdelay.md @@ -17,8 +17,9 @@ For example, the following creates an AEC that will disappear in 100 ticks (5 se 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. @@ -48,8 +49,9 @@ However, if you want to use spawn_egg to simply create an AEC's for delay, then # 1.20.5+ give @s bat_spawn_egg[entity_data={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` +| 📝 Note | +|---------| +|You can use any `spawn_egg`, but not just `bat_spawn_egg`| # Command block / tick function execute at @e[type=area_effect_cloud,tag=delay,nbt={Age:99}] run summon zombie @@ -139,8 +141,9 @@ So you can create a simple way to run your commands not every tick, but, for exa schedule function example:loops/10s 10s say This will run every 10 second. -> [!NOTE] -> Do not run the schedule function in a tick function, without any conditions. This will overwrite the schedule every tick and the schedule function will never run. +| 📝 Note | +|---------| +|Do not run the schedule function in a tick function, without any conditions. This will overwrite the schedule every tick and the schedule function will never run| This has several limitations: @@ -170,8 +173,9 @@ Read the current gametime and store it in the score of the selected entity and a execute store result score #this timer run time query gametime execute as @e if score @s timer = #this timer run say Example Command. -> [!NOTE] -> If you frequently run the schedule function to delay, then use `append` mode to run the schedule function so that each run does not overwrite the previous one. +| 📝 Note | +|---------| +|If you frequently run the schedule function to delay, then use `append` mode to run the schedule function so that each run does not overwrite the previous one| ### Success Count An easy trick with command blocks to make a clock run at half its speed is the following command: @@ -200,6 +204,7 @@ execute as @e[tag=loop,distance=..3,type=armor_stand] at @s run tp @s ~ ~5 ~ ``` To add more commands, just add a chain one to the previus impulse. -> [!IMPORTANT] -> It is not recomended to use this method +| ⚠️ Important | +|--------------| +|It is not recomended to use this method| diff --git a/questions/blockinvert.md b/questions/blockinvert.md index aa7758469..dbeede30e 100644 --- a/questions/blockinvert.md +++ b/questions/blockinvert.md @@ -1,12 +1,16 @@ # Do something if a command block *wasn't* successful -> [!NOTE] -> in 1.13+ we can use `execute unless ...` instead +## Java + +| 📝 Note | +|---------| +|in 1.13+ we can use `execute unless ...` instead| (This is for command blocks only. For functions, [see here](/wiki/questions/functionconditions)) -> [!NOTE] -> You could use a redstone torch and a comparator, but it is **not** recomended as it causes more lag than the other methods described below. +| 📝 Note | +|---------| +|You could use a redstone torch and a comparator, but it is **not** recomended as it causes more lag than the other methods described below| When a command block runs, its `SuccessCount` tag is updated. This is the value used by comparators to decide how strong a signal to output from that command block. If the command block does not succeed, its `SuccessCount` will be `0`. @@ -28,3 +32,7 @@ The first command is whatever you want to check wasn't successful. In the second command you must adjust `~ ~ ~1 command_block` to match the location and type of the first block. For example, it may be `~-1 ~ ~ chain_command_block`. The third command is conditional, and is whatever you want to happen when the first command fails. + +## Bedrock + +Because we can't access the `SuccessCount` in bedrock we will need to use a comparator poiting 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 diff --git a/questions/changeofscore.md b/questions/changeofscore.md index 2657fead7..7b29e39ff 100644 --- a/questions/changeofscore.md +++ b/questions/changeofscore.md @@ -14,7 +14,7 @@ _Some objective types are read-only, such as Health or Hunger. Those won't work So lets assume you have a score that detects a players death and want to do something with that player everytime they die once. execute as @a[scores={deaths=1..}] run say I died :( - scoreboard players set @a[scores={dead=1..}] deaths 0 + 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. diff --git a/questions/compasstoplayer.md b/questions/compasstoplayer.md index 1c491c68c..733e524ea 100644 --- a/questions/compasstoplayer.md +++ b/questions/compasstoplayer.md @@ -1,4 +1,6 @@ -# Make compass point towards player +# Make compass point towards player/location + +## 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.** @@ -6,10 +8,10 @@ Since the compass will always point to the worldspawnpoint, your only option is 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). +| 📝 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)| ## 1.16+ (Java only) diff --git a/questions/customcrafting.md b/questions/customcrafting.md index 11571a9a2..8f828b03a 100644 --- a/questions/customcrafting.md +++ b/questions/customcrafting.md @@ -1,10 +1,14 @@ # Do custom crafting (with NBT) +* [Java](#bedrock-edition-addon) +* [Bedorck](#bedrock-edition-addon) + +## Java The vanilla crafting system does not support NBT data. Although 1.20.5 added the ability to create recipes with custom crafting data, it still does not support custom data for ingredients. This article provides several ways to create custom crafts that support custom items for both the result and the ingredients. ---- -## Floor Crafting +### Floor Crafting The easiest way to create a custom craft is to use floor crafting. You can create crafting recipes with any ingredients and for each recipe you only need 1 command block, which makes it easy to create many recipes without creating an excessive load on the server. @@ -81,7 +85,7 @@ Since version 1.20.5 NBT tags have been replaced with [components](https://minec ---- -## Custom Dropper Crafting +### Custom Dropper Crafting Another popular way to create custom crafts that support NBT data is to use custom dropper crafting. This method uses a dropper / dispenser interface to simulate the crafting grid as the crafting\_table. This method is more difficult to implement, but looks much better than floor crafting. @@ -140,9 +144,9 @@ Now you can create a ready-made command for the recipe. Below is an example of c ---- -## Custom Knowledge Book Crafting +### Custom Knowledge Book Crafting -### Before 1.20 +#### Before 1.20 Before version 1.20 you could create custom crafts using the Knowledge Book method, however **this method does not support creating custom crafts with NBT data for ingredients, only for the result**. @@ -251,7 +255,7 @@ Below is an example of how to implement this approach: The obvious disadvantages of this method are the inability to create a craft with custom ingredients, and if you give yourself all the recipes, it will give you all the custom items, but you still won’t be able to have your custom crafts in the recipe book. -### After 1.20 +#### After 1.20 Starting with version 1.20, a new advancement trigger was added - `recipe_crafted`. This one triggers when you have crafted the specified craft, but not just unlocked it. Therefore you don't need to take recipes and you can have your crafts in the craft book, although these crafts will appear as knowledge\_book. @@ -334,7 +338,7 @@ Below is an example for creating an advancement for a custom craft, which must h **Important!** The player can still use regular items in crafting, but then the advancement will not work and the player will only craft the knowledge\_book. To avoid this, you need to create a more complex crafting system. -### 1.20.5 and above +#### 1.20.5 and above Version 1.20.5 also added the ability to create crafts with custom data, but only for the craft result - NOT for ingredients. Therefore, if you want to use custom items in crafting, then in this version it will be the same as described for the previous version. diff --git a/questions/detectitem.md b/questions/detectitem.md index 67e6ace7a..4b52bcee9 100644 --- a/questions/detectitem.md +++ b/questions/detectitem.md @@ -252,7 +252,7 @@ In the 1.18.20 beta they added the [`hasitem`](https://minecraft.wiki/wiki/Targe A player with 5 or more apples in their inventory - @a[hasitem={item:apple,quantity=5..}] + @a[hasitem={item=apple,quantity=5..}] A player with an iron pickaxe in their mainhand @@ -277,8 +277,9 @@ effect @a[hasitem={item=stick,data=5}] speed #### before 1.18.20 -> [!NOTE] -> This information is outaded and it is not useful for the current version of the game. +| 📝 Note | +|---------| +|This information is outaded and it is not useful for the current version of the game| Using the `clear` command with a max count of 0 will return a successful result if the item is in the players inventory, without actually removing the item, which can be picked up by either a conditional commandblock or a comparator. **You can only do this for 1 player at a time though, as if you use `@a` you have no way of knowing which one of the players has the item in their inventory.** @@ -301,7 +302,8 @@ Detecting a specific item on the ground involves using its name. **This method is language specific and won't work if your hosting player is not playing in english!** A way to circumvent that problem would be to either rename the item if possible, or to change every language file the game has to make the name of the item the same across all languages, which will require you to include a resourcepack. -> [!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. +| 📝 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| kill @e[type=item, name="§r§Dirt"] diff --git a/questions/findsamescoreentity.md b/questions/findsamescoreentity.md index 171a64e9b..2e3f98c1a 100644 --- a/questions/findsamescoreentity.md +++ b/questions/findsamescoreentity.md @@ -4,9 +4,10 @@ Related: [Check if a score is equal to, greater than, or less than another score ## Java 1.13+ and Bedrock -> [!NOTE] -> In bedrock edition use `c=` instead of `limit=`. -> The method that involves using predicates can **not** be replicated in bedrock +| 📝 Note | +|---------| +|In bedrock edition use `c=` instead of `limit=`| +|The method that involves using predicates can **not** be replicated in bedrock| ### Method 1: Compare directly @@ -70,8 +71,10 @@ In this method we change the execution _location_ to be the player(s) and the ex execute at @a as @e if score @s id = @p id run ... ## Java Pre-1.12 -> [!NOTE] -> This method also works in bedrock before new execute. + +| 📝 Note | +|---------| +|This method also works in bedrock before new execute| In bedrock this whole endeavour 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. diff --git a/questions/giveitembedrock.md b/questions/giveitembedrock.md index 9cd4d7d90..511292f9a 100644 --- a/questions/giveitembedrock.md +++ b/questions/giveitembedrock.md @@ -4,8 +4,9 @@ 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. -> [!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. +| 📝 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. diff --git a/questions/heighttest.md b/questions/heighttest.md index 1ac6c6527..a5a5c3562 100644 --- a/questions/heighttest.md +++ b/questions/heighttest.md @@ -18,5 +18,5 @@ The same technique can be used to find players above/below any `x`/`y`/`z` coord To detect below a certain height, you can make the `dy` negative. - /execute at @a at @s run say @s[y=-30,dz=-500] + /execute at @a at @s run say @s[y=-30,dy=-500] this will detect any players below `-30` diff --git a/questions/highestscore.md b/questions/highestscore.md index d8abb4f93..d16d3d048 100644 --- a/questions/highestscore.md +++ b/questions/highestscore.md @@ -1,7 +1,8 @@ # Find player / entity with the highest score -> [!NOTE] -> This only works with online players / loaded entities. If you want to accomodate offline players / unloaded entities, you'll need a much more complicated system! +| 📝 Note | +|---------| +|This only works with online players / loaded entities. If you want to accomodate offline players / unloaded entities, you'll need a much more complicated system!| Thanks to `scoreboard player operations` this is a fairly easy question to answer, as the `>` operator will ensure the left score is at least as high as the right score. diff --git a/questions/hostilefriendly.md b/questions/hostilefriendly.md index 0cea7676a..70c9f17d6 100644 --- a/questions/hostilefriendly.md +++ b/questions/hostilefriendly.md @@ -17,8 +17,9 @@ In java, we can create teams, and we can configure friendly fire to make people ### 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 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. +| 📝 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 @@ -28,8 +29,9 @@ And if we want the player to be unable to attack the zombie /effect give @a weakness 60 127 -> [!NOTE] -> You can still attack the player/entity if you have the sharpness enchantment, that's why we use resistance. +| 📝 Note | +|---------| +|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 dissable PvP, it will only prevent the entity attacking the player. @@ -37,8 +39,9 @@ This method wont work to dissable PvP, it will only prevent the entity attacking ### 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. -> [!NOTE] -> This does **not** work in Bedrock +| 📝 Note | +|---------| +|This does **not** work in Bedrock| # Java syntax /item replace entity @e[type=skeleton] armor.head with iron_helmet @@ -60,7 +63,9 @@ Important things to keep in mind when using this method: * Arrows and other projectiles will be able to attack the entity ### Distance attribute (Java only) -In java edition there are 2 attributes related to the range that players can interact with the world. we can reduce this range and set it to `-4.5` 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. + + attribute entity_interaction_range base set 0 > [!NOTE] -> This will affect right click too so they won't be able to trade with villagers for example. +> This will affect right click too so they won't be able to trade with villagers, for example. diff --git a/questions/itemclick.md b/questions/itemclick.md index 439832e00..1ea75a027 100644 --- a/questions/itemclick.md +++ b/questions/itemclick.md @@ -1,10 +1,15 @@ # Item Click Detection +* [Java](#java) +* [Java and Bedorck](#java-and-bedrock) + +## 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. -## Left / right clicks in / on specific areas +### Left / right clicks in / on specific areas -### Interaction entity +#### Interaction entity Added in 1.19.4, the [interaction entity](https://minecraft.wiki/w/Interaction) now makes it easier to detect left/right clicks as it uses fewer commands and the hitbox size can be adjusted, making it less likely to miss a click, but otherwise has the same disadvantages as the [Hurt entity method](#hurt-entity). @@ -19,15 +24,16 @@ Here's a simple example for command blocks: **Note:** Do not create an interaction entity that is too large, otherwise click detection will be inconsistent. -> [!TIP] -> To see interaction entity press `F3 + B` to show hitboxes. +| 💡 Tip | +|--------| +|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. You can also check what the player is holding in his hand, but then removing the `interaction` / `attack` tag must be done in a separate command: # Command blocks - ## 1.19.4 - 1.20.4 + ### 1.19.4 - 1.20.4 execute as @e[type=interaction,tag=click_scan] on target if entity @s[nbt={SelectedItem:{tag:{right_click:true}}}] run say Right Click! # 1.20.5+ execute as @e[type=interaction,tag=click_scan] on target if items entity @s weapon *[custom_data~{right_click:true}] run say Right Click! @@ -68,9 +74,9 @@ say Right Click! execute as @e[type=interaction,tag=click_scan] run data remove entity @s interaction ``` -## Left-click +### Left-click -### Hurt entity +#### 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: @@ -80,11 +86,11 @@ This one is as easily explained as it is flawed: You can only detect left clicks While you can use this method more reliably if this is about hitting some special mobs with a special item or something (the advancement method is really good at that), **general leftclick detection is discouraged unless you have a very controlled environment**. -## Right-click +### Right-click -For rightclick detection we have [a lot of different ways](https://i.imgur.com/8gKEdp1.png) (image by [u/Dieuwt](https://www.reddit.com/u/Dieuwt)), and different situations might call for different solutions. Since we cannot write a detailed guide on all these methods, we'll only describe the two most common solutions here. A rundown of the knowledge book method can be found [here](https://www.reddit.com/r/MinecraftCommands/comments/g4jxzy/simple_rightclick_detection_without_sacrificing) (by [u/U2106_Later](https://www.reddit.com/u/U2106_Later). +For rightclick detection we have [a lot of different ways](https://i.imgur.com/8gKEdp1.png) (image by [u/Dieuwt](https://www.reddit.com/u/Dieuwt)), and different situations might call for different solutions. Since we cannot write a detailed guide on all these methods, we'll only describe the two most common solutions here. A rundown of the knowledge book method can be found [here](https://www.reddit.com/r/MinecraftCommands/comments/g4jxzy/simple_rightclick_detection_without_sacrificing) (by [u/U2106_Later](https://www.reddit.com/u/U2106_Later)). -### Carrot on a stick method +#### Carrot on a stick method _Note: This works the same with the warped fungus on a stick._ @@ -103,7 +109,9 @@ Cons: - Looks like a carrot on a stick (fix see below). - Has unremovable Damage NBT tag. This can be somewhat negated by making the CoaS unbreakable. -#### Make the CoaS look like any item +##### Make the CoaS look like any item + +###### 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. @@ -123,10 +131,19 @@ The models/item/carrot_on_a_stick.json file within the resource pack might end u ] } -> [!NOTE] -> You can make the item completly invisible if using the custom model data of a chest. +| 💡 Tip | +|---------| +|You can make the item completly 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 -### Make item food method + give @p carrot[item_model="nether_star"] 1 + +#### Make item food method + +##### 1.20.5+ From version 1.20.5 you can add a right click check for any item that does not already use a right click event. @@ -182,7 +199,45 @@ Below is an example for this with a delay that is easy to configure: 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. -### Villager method +##### 1.21.2+ + +In 1.21.2 some part of the `food` component has been separated into the `consumable` component. So we will need to change the `give` command, depending on what of the two methods you are using the `consume_seconds` will be set to `0`, that is now possible in 1.21.2+ (if using the scoreboard method) or to `2147483647` (if using an advancement) + +``` +# get item +give @p stick[food={nutrition:0,saturation:0,can_always_eat:true},consumable={consume_seconds:2147483647}] 1 +``` + +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. + +``` +# function example:get_star +give @p nether_star[use_cooldown={seconds:5},food={nutrition:0,saturation:0,can_always_eat:true},consumable={consume_seconds:1,animation:"bow"},custom_data={right_click:true}] 1 + +# advancement example:use_nether_star +{ + "criteria": { + "requirement": { + "trigger": "minecraft:consume_item", + "conditions": { + "item": { + "predicates": { + "minecraft:custom_data": "{right_click:true}" + } + } + } + } + }, + "rewards": { + "function": "example:right_click" + } +} + +# function example:right_click +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)). @@ -196,7 +251,7 @@ Cons: _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)_ -## Inventory click +### Inventory click *Note:* This method works since version 1.20.5 @@ -211,3 +266,33 @@ This method is based on checking the player's cursor slot. To do this, need to c # Command blocks execute as @a[scores={hold.in_cursor=0}] if items entity @s player.cursor *[minecraft:custom_data~{in_cursor:true}] run say Cursor Command. execute as @a store success score @s hold.in_cursor if items entity @s player.cursor *[minecraft:custom_data~{in_cursor:true}] + +## Java and Bedrock + +### Bundles + +Right-clicking a bundle will take the first item that has. Because this item is 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. + + # bedrock + execute at @e[type=item,name="right_click"] run tag @p add right_click + replaceitem entity @a[tag=right_click] slot.weapon 0 air + execute at @e[tag=right_click] run structure load right_click_bundle ~ ~ ~ + execute as @e[tag=rigth_click] at @s run say Right click + kill @e[type=item,name="right_click"] + tag @a[tag=right_click] remove right_click + +Java + +Example item: + + give @s bundle[custom_data:{bundle_click:true},bundle_contents=[{id:"minecraft:music_disc_11",count:1,components:{"minecraft:custom_data":{right_click_bundle:true}}}]] + +Command blocks: + + execute as @e[type=item] if contents entity @s *[custom_data:{right_click_bundle:true}] on owner run tag @s run add right_click_bundle + execute as @e[type=item] if contents entity @s *[custom_data:{right_click_bundle:true}] run kill @s + clear @a *[custom_data:{right_click_bundle:true}] + execute as @a[tag=right_click_bundle] run say example + execute as @a[tag=right_click_bundle] if items entity @s weapon.mainhand bundle[custom_data:{bundle_click:true}] run item replace entity @s weapon.mainhand with bundle[custom_data:{bundle_click:true},bundle_contents=[{id:"minecraft:music_disc_11",count:1,components:{"minecraft:custom_data":{right_click_bundle:true}}}]] + execute as @a[tag=right_click_bundle] unless items entity @s weapon.mainhand bundle[custom_data:{bundle_click:true}] run item replace entity @s weapon.mainhand with bundle[custom_data:{bundle_click:true},bundle_contents=[{id:"minecraft:music_disc_11",count:1,components:{"minecraft:custom_data":{right_click_bundle:true}}}]] + tag @a[tag=right_click_bundle] remove right_click_bundle diff --git a/questions/linkentity.md b/questions/linkentity.md index 16d004ba4..f4ca3c143 100644 --- a/questions/linkentity.md +++ b/questions/linkentity.md @@ -41,8 +41,9 @@ If you are using a datapack, then you can use the command above in the tick func ## Java and Bedrock -> [!NOTE] -> The information below is outdated / inefficient for java. Use this only to better understand how the Scoreboard ID system works. +| 📝 Note | +|---------| +|The information below is outdated / inefficient for java. Use this only to better understand how the Scoreboard ID system works| First we need to set up a dummy scoreboard objective diff --git a/questions/makecircle.md b/questions/makecircle.md index 1e4070706..3c2d102c8 100644 --- a/questions/makecircle.md +++ b/questions/makecircle.md @@ -4,13 +4,13 @@ Creating perfect (or as perfect as they can be with minecrafts blocky nature) ci ## The idea -The idea of how to achieve this is pretty simple: Have an entity in the center that slowly rotates, then place what you want X blocks in front of it using the local coordinates (`^ ^ ^X)`. +The idea of how to achieve this is pretty simple: Have an entity in the center that slowly rotates, then place what you want X blocks in front of it using the local coordinates (`^ ^ ^X`). ## 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 or any NoAI entity. +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. /summon armor_stand ~ ~ ~ @@ -18,8 +18,10 @@ For the example we're assuming that we want to make a block outline. You can eas # Bedrock /tag @e[type=armor_stand,c=1] add center - # Java + # 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. diff --git a/questions/movetoscore.md b/questions/movetoscore.md index c60529e0d..5702eb09d 100644 --- a/questions/movetoscore.md +++ b/questions/movetoscore.md @@ -1,10 +1,14 @@ ## Summon an entity at the position set in a score -> [!NOTE] -> This article is about Java Edition, except for binary teleport, found at the end of the article. +| 📝 Note | +|---------| +|This article is about Java Edition, except for binary teleport, found at the end of the article, that will work in bedrock too| -> [!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) +| ⚠️ 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 you want to store the position of the player see this [transfer nbt to score](wiki/questions/nbttransfer) 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. @@ -72,7 +76,9 @@ Since version 1.20.2 you can also use the [macro](https://minecraft.wiki/w/Funct # function example:tp/macro $tp @s $(x) $(y) $(z) -**Note:** A macro cannot be read from a List/Array, but only from an object. Therefore, if you received a list (like Pos tag) as a tag for teleportation, you must convert this into objects: +| 📝 Note | +|---------| +|A macro cannot be read from a List/Array, but only from an object. Therefore, if you received a list (like `Pos` tag) as a tag for teleportation, you must convert this into objects| # Example input pos as List data merge storage example:data {Pos:[25d,100d,65d]} @@ -115,8 +121,9 @@ See [u/SanianCreations](https://www.reddit.com/u/SanianCreations) post about thi ### 4: Binary Teleportation -> [!NOTE] -> This method works with bedrock too +| 📝 Note | +|---------| +|This method works in bedrock too| You basically copy their score to some temporary score so you don't loose it when you modify it, and then you go through the different powers of 2 (hence the name), check if their score is above that and then teleport them relatively that far. diff --git a/questions/npc.md b/questions/npc.md index 69167fedc..d41f0370d 100644 --- a/questions/npc.md +++ b/questions/npc.md @@ -1,8 +1,9 @@ # How to create / customize an NPC? This article will explain how to create NPCs and add commands to it. -> [!NOTE] -> This is for the entity in Bedrock edition called [`NPC`](https://minecraft.wiki/w/NPC) +| 📝 Note | +|---------| +|This is for the entity in Bedrock edition called [`NPC`](https://minecraft.wiki/w/NPC)| ## Basics of an NPC @@ -19,10 +20,10 @@ To edit an NPC right click it in creative, you will open a GUI that allows you t The NPC will be staring at the nearest player that is not in spectator, if it’s in a 6 block radius. ## Dialogues and commands -> [!NOTE] -> You can find useful information in [Wiki Bedrock Dev](https://wiki.bedrock.dev/entities/npc-dialogs.html). -> -> You can use [this tool](https://jannisx11.github.io/dialogue-designer/) by [jannisx11](https://github.com/jannisx11) to add dialogue and commands easily. +| 📝 Note | +|---------| +|You can find useful information in [Wiki Bedrock Dev](https://wiki.bedrock.dev/entities/npc-dialogs.html)| +|You can use [this tool](https://jannisx11.github.io/dialogue-designer/) by [jannisx11](https://github.com/jannisx11) to add dialogue and commands easily| When you interact with the NPC in creative, you will find a button called `Edit Dialog`. When you click it, you will be able to edit the dialogue. The maximum of characters you can have is 307. You can **not** use target selectors in the dialog, for example, if the dialog is `@p`, the dialog will be `@p`, not the nearest player. diff --git a/questions/numplayers.md b/questions/numplayers.md index a131714b5..a35f5aaea 100644 --- a/questions/numplayers.md +++ b/questions/numplayers.md @@ -1,15 +1,17 @@ -# Check if there are exactly X players matching a selector +# Check if there are exactly X players (or entities) matching a selector? For example, you want to check if a team has exactly 2 players. -> [!NOTE] -> if a selector such as `@a[team=red]` selects `Alice, Bob, Carol, Dave`, then `@a[team=red,limit=2]` will select `Alice, Bob` and run the command on those players. `limit=2` does not mean *"only run if there are 2 players"*, but rather *"limit the players selected to at most 2"*. (Same for `c` in bedrock). +| 📝 Note | +|---------| +|if a selector such as `@a[team=red]` selects `Alice, Bob, Carol, Dave`, then `@a[team=red,limit=2]` will select `Alice, Bob` and run the command on those players. `limit=2` does not mean *"only run if there are 2 players"*, but rather *"limit the players selected to at most 2"*. (Same for `c` in bedrock).| A command will still run (and potentially succeed once) even if `@a[team=red,limit=2]` only finds one player, and succeeding once is all that is needed for conditional blocks coming off of the command block to run. ## Java and Bedrock -> [!NOTE] -> This method will work in Java too, but its recomended to use the Java exclusive method +| 📝 Note | +|---------| +|This method will work in Java too, but its recomended to use the Java exclusive method| The easiest way to do this in bedrock is to have the found entities count up the score of another entity or a [fake player](/wiki/questions/fakeplayer) (the later is currently a little harder to check for their score, so it is not used in this tutorial). @@ -26,8 +28,9 @@ You can also use [ranges](wiki/questions/ranges) execute as @e[tag=counter,scores={result=2..9}] run say there are between 2 and 9 people on the red team ## Bedrock -> [!NOTE] -> It is not recomended to use this method +| 📝 Note | +|---------| +|It is not recomended to use this method| You can use a comparator with the `/testfor` command, the output, in signal strengh, is the same as the number of online players. @@ -41,7 +44,7 @@ Using a dummy scoreboard objective name `result` and the [fake player](/wiki/que execute store result score #count result if entity @a[team=red] execute if score #count result matches 2 run say there are exactly 2 players on team red. -The fake player can be replaced by an entity, which then changes the second command to +The fake player can be replaced by an entity, although it is not recommended, which then changes the second command to execute if entity @e[,scores={result=2}] run say there are exactly 2 players on team red. @@ -52,25 +55,27 @@ It also works with [ranges](wiki/questions/ranges) ### Method 2: Checking the command block's `SuccessCount` -> [!NOTE] -> This method is outdated and should not be used in current versions of the game. -> For the sake of allowing users of 1.12 and below to access this for them still useful information, it is kept around. +| 📝 Note | +|---------| +|This method is outdated and should not be used in current versions of the game| +|For the sake of allowing users of 1.12 and below to access this for them still useful information, it is kept around| When a `/testfor` command is run, the command block's `SuccessCount` NBT tag will be set equal to the number of entities that the selector found. You can then use a `/testforblock` command in another block to check whether the first command block's `SuccessCount` is a certain number. For example, this will test for *exactly* 2 players on the red team (no more, no less): testfor @a[team=red] - testforblock X Y Z command_block -1 {SuccessCount:2} + testforblock command_block -1 {SuccessCount:2} -Change `X Y Z` in the second command block to the coordinates of the first command block. You may also need to change `command_block` to `chain_command_block` or `repeating_command_block`. +Change ` ` in the second command block to the coordinates of the first command block. You may also need to change `command_block` to `chain_command_block` or `repeating_command_block`. The second command will only succeed if the first command has a SuccessCount of 1 (it found exactly 1 player). You can then run a conditional chain block off of that second command to activate whatever you want to happen when there are exactly 1 player: ### Method 3: With `/stats` (1.8-1.12) -> [!NOTE] -> This method is outdated and can not be used in current versions of the game. +| 📝 Note | +|---------| +|This method is outdated and can not be used in current versions of the game| Stats are harder to understand and set up, but gives you more flexibility (works in functions, can test a range rather than exact values, can test things other than SuccessCount). If you have not used `/stats` in the past, you will need to watch/read a tutorial (or multiple) and play around with them until you are confident in its usage. Then: diff --git a/questions/playerjoin.md b/questions/playerjoin.md index 50fa4bd1c..0c6de1784 100644 --- a/questions/playerjoin.md +++ b/questions/playerjoin.md @@ -38,8 +38,9 @@ Assuming you called the objective `leave`, it could look like this: execute as @a[scores={leave=1..}] run tellraw @a ["",{"selector":"@s"},{"text":" just came back to us!"}] scoreboard players reset @a[scores={leave=1..}] leave -> [!NOTE] -> This method counts exits from the game, but not joins to the server, because the score increases when the player leaves, but since you cannot target an offline player using the target selector, we cannot check that the score has been changed and this can only be done when the player joins to the server again. +| 📝 Note | +|---------| +|This method counts exits from the game, but not joins to the server, because the score increases when the player leaves, but since you cannot target an offline player using the target selector, we cannot check that the score has been changed and this can only be done when the player joins the server again| ### Bedrock @@ -78,8 +79,9 @@ Then if the value is not 1 (so it is 2, so they leaved the game) we will store t ### Bedrock 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. +| 📝 Note | +|---------| +|This method is the same as the 2 others merged, nothing else changed| # in chat /scoreboard objectives add online dummy diff --git a/questions/randomnumber.md b/questions/randomnumber.md index 2f9b06b61..bfb352aa9 100644 --- a/questions/randomnumber.md +++ b/questions/randomnumber.md @@ -8,8 +8,9 @@ So for example, from 1 to 10 in a score called `some_score` scoreboard players random @p some_score 1 10 -> [!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. +| 📝 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| ## /random command **This method is, currently, the best, there is no reason to use the others** @@ -43,8 +44,9 @@ Or we can use [ranges](wiki/questions/ranges) to detect more of one number. execute if score #command random matches 4..5 run say 4 or 5 ## without /random command (Pre-1.20.2) -> [!NOTE] -> This information is outdated and should **not** be used in the current version of the game. +| 📝 Note | +|---------| +|This information is outdated and should **not** be used in the current version of the game| There are many ways to get a random number in minecraft. the first two are arguably the best as they have the least limitations and require the least work to set up. diff --git a/questions/range.md b/questions/range.md index 4b7625932..610b3bb85 100644 --- a/questions/range.md +++ b/questions/range.md @@ -10,5 +10,6 @@ Either one can be left out to signify an open-ended range. Leaving writing a sin Some selectors (like `distance`) also allow for decimal numbers. `0.5..0.9` works fine in those instances. -> [!IMPORTANT] -> Ranges are not useable when checking for NBT! +| ⚠️ Important | +|--------------| +|Ranges are not useable when checking for NBT!| diff --git a/questions/raycast.md b/questions/raycast.md index 0dabd52e8..0a5ce38da 100644 --- a/questions/raycast.md +++ b/questions/raycast.md @@ -1,7 +1,8 @@ # Raycast -> [!NOTE] -> If you're trying to check whether an entity / player is looking at a specific entity / position, you might be able to use a more streamlined method [described here](/wiki/questions/lookat). +| 📝 Note | +|--------------| +|If you're trying to check whether an entity / player is looking at a specific entity / position, you might be able to use a more streamlined method [described here](/wiki/questions/lookat)| ## What is a raycast? diff --git a/questions/runonce.md b/questions/runonce.md index bf1501bf7..609e42a77 100644 --- a/questions/runonce.md +++ b/questions/runonce.md @@ -1,7 +1,8 @@ # Activate a command *once* when a player does something (e.g: enters an area) -> [!NOTE] -> In bedrock `distance` does not exist so instead of `distance=..X` use `r=X` and instead of `distance=X..` use `rm=X` and instead of `distance=X..Y` use `rm=X,r=Y`, all methods only work in Java unless stated otherwise. +| 📝 Note | +|--------------| +|In bedrock `distance` does not exist so instead of `distance=..X` use `r=X` and instead of `distance=X..` use `rm=X` and instead of `distance=X..Y` use `rm=X,r=Y`, all methods only work in Java unless stated otherwise| This makes a command act as if it was on a comparator, without the lag and multiplayer incompatibility that comes from using a comparator. The general idea here is to select players that match a selector, but did **not** match that same selector in the previous tick. For example, players who have just entered an area (with `@a[x=73,y=10,z=3,distance=..1]`), just gained level 5 (with `@a[level=5]`), just entered creative (with `@a[gamemode=creative]`), etc. @@ -16,8 +17,9 @@ For this method our first command checks two things: Your condition for running execute as @a[scores={matched=0},x=73,y=10,z=3,distance=..1] run say I just entered the area! execute as @a store success score @s matched if entity @s[x=73,y=10,z=3,distance=..1] -> [!NOTE] -> The order in which the commands are executed is important here. In the first command you check your condition and execute the command, and the second command store the success of executing your condition. +| 📝 Note | +|--------------| +|The order in which the commands are executed is important here. In the first command you check your condition and execute the command, and the second command store the success of executing your condition| The previous example doesn't work in Bedrock Edition. Here is a setup that works in both Java and Bedrock Edition (if you change `distance=..X` to `rm=X`): @@ -106,15 +108,17 @@ This method involves creating a [predicate](https://minecraft.wiki/w/Predicate) advancement revoke @s only example:spawn/enter tellraw @s "You leave spawn!" -> [!NOTE] -> In the predicate `example:at_spawn` omits the Y position check, so a player at any height in the specified area will match the conditions of the predicate. +| 📝 Note | +|--------------| +|In the predicate `example:at_spawn` omits the Y position check, so a player at any height in the specified area will match the conditions of the predicate| Such a check may seem very large, but this method allows you not to check the same condition 2 times per tick, but only 1 time per second (because the `minecraft:location` advancement trigger only runs once per second), which can be important with a large online number of players. ## Add/remove tag -> [!NOTE] -> This method will work in Bedrock too +| 📝 Note | +|--------------| +|This method will work in Bedrock too| The following commands, running in this order, will keep track of whether a player matched the selector `@a[x=73,y=10,z=3,distance=..1]`: diff --git a/questions/shop.md b/questions/shop.md index 6a10ef612..89a924339 100644 --- a/questions/shop.md +++ b/questions/shop.md @@ -6,8 +6,9 @@ This method consists of buying items with other items, in this example, you will _Related:_ [Count how much of X item the player has](wiki/questions/amountitems) -> [!NOTE] -> You can add any command you want to run (for example a playsound) before the last command, but the selector must be the same as the command before. +| 📝 Note | +|--------------| +|You can add any command you want to run (for example a playsound) before the last command, but the selector must be the same as the command before| ### Java @@ -44,8 +45,9 @@ Or if you prefer a function: clear @s diamond 5 tellraw @s {"text":"You bought a netherite ingot for 5 diamonds","color":"green"} -> [!NOTE] -> The function `example:buy/netherite` must be run `as` the player +| 📝 Note | +|--------------| +|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: @@ -64,8 +66,9 @@ With this command: 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). +| 📝 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)| #### Using a villager Villagers are a passive mob that can be interacted with, and will open the trading GUI. @@ -121,12 +124,14 @@ If you don't want to use an NPC can use this method, it is very similar to Java clear @a[tag=buyer.netherite,hasitem={item=diamond,quantity=5..}] diamond 5 tag @a remove buyer.netherite -> [!NOTE] -> in order for it to work with npc, change `@p` to `@initiator` -> _Related: [How to setup a NPC?](wiki/questions/npc)_ +| 📝 Note | +|--------------| +|in order for it to work with npc, change `@p` and `@a` to `@initiator`| +|_Related: [How to setup a NPC?](wiki/questions/npc)_| -> [!NOTE] -> It is super important to clear the diamonds in the last step before removing the tag +| 📝 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. @@ -158,8 +163,9 @@ In this example the currency is a `dummy` scoreboard called `coins`. #### With command blocks -> [!NOTE] -> This example uses Java syntax for the message that appears when the player buys the item +| 📝 Note | +|--------------| +|This example uses Java syntax for the message that appears when the player buys the item| /tag @p add buyer.diamond /execute as @p[tag=buyer.diamond] run tag @s[scores={coins=10..}] add buy.diamond @@ -181,5 +187,6 @@ This is more optimized compared to using command blocks as functions keep the co scoreboard players remove @s coins 10 tellraw @s {"text":"You bought a diamond","color":"green"} -> [!NOTE] -> The function `example:buy/diamond` must be run `as` the player +| 📝 Note | +|--------------| +|The function `example:buy/diamond` must be run `as` the player| \ No newline at end of file diff --git a/questions/storeinventory.md b/questions/storeinventory.md index eeb9c4160..c3d4a3e7f 100644 --- a/questions/storeinventory.md +++ b/questions/storeinventory.md @@ -12,8 +12,9 @@ For this, you need to put them somewhere in a confined space, so the items don't Same for the return part, as you only want to give the player who owns the items those items back. You also need to consider that a completely full inventory (including armor) will not be able to be picked up instantly by the player without them manually equipping their armor. -> [!CAUTION] -> You will lose any item with the curse of vanishing enchantment +| ⚠️ Caution | +|------------| +|You will lose any item with the curse of vanishing enchantment| ### Custom Hopper Entity @@ -449,13 +450,15 @@ We often see something like `Inventory[0]` in this article. This is an array sel 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 -> [!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) +| 📝 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 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 -> [!NOTE] -> You must run this function `as` the player +| 📝 Note | +|---------| +|You must run this function `as` the player| # function example:storing execute positioned run function example:storing/container_1 diff --git a/resources.md b/resources.md index 08eff33bb..911fc4583 100644 --- a/resources.md +++ b/resources.md @@ -2,269 +2,79 @@ 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 or create a GitHub issue 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) +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. ## 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) +- [MCStacker](https://mcstacker.net): All commands generators +- [Minecraft Tools](https://minecraft.tools): Mainly for books and titles +- [Colorize Fun](https://colorize.fun/en/minecraft): for text gradients +- [Gamergeeks](https://www.gamergeeks.net): Almost all commands generators, it's better if MCStacker looks confusing for you ### 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 +- [Commands list](http://minecraft.wiki/Commands), The Minecraft Wiki +- [Statistics list](http://minecraft.wiki/Statistics), The Minecraft Wiki +- [Attributes list](https://minecraft.wiki/w/Attribute#Attributes), The Minecraft Wiki -- [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 +## NBT ### 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) +- [irath96](http://irath96.github.io/webNBT/): web nbt editor, no need to download any program +- [NBT Workbench](https://rttv.ca/main): web nbt editor, no need to download any program ### 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) +- [Chunk format](http://minecraft.wiki/Chunk_format), The Minecraft Wiki +- [Player.dat format](http://minecraft.wiki/Player.dat_format), The Minecraft Wiki +- [Structure file format](http://minecraft.wiki/Structure_block_file_format), The Minecraft Wiki -### References - -- [Chunk format](http://minecraft.wiki/Chunk_format) (Wiki) -## World editing +## Datapacks ### 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) +- [Datapack Helper+](https://marketplace.visualstudio.com/items?itemName=SPGoding.datapack-language-server): syntax hightlighter. +- [Misode’s Generator](https://misode.github.io/advancement): loot table, predicate, item modifier, advancement, recipe, dimension, structure and tag generator, between others. +- [Datapack Assembler](https://far.ddns.me): generate data pack from commands ### 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) +- [Functions](http://minecraft.wiki/Function), The Minecraft Wiki +- [Loot Tables](http://minecraft.wiki/Loot_table), The Minecraft Wiki +- [Predicates](http://minecraft.wiki/Predicate), The Minecraft Wiki +- [Advancements](http://minecraft.wiki/Advancements#JSON_Format), The Minecraft Wiki +- [Dimension](), The Minecraft Wiki +- [Vanilla Data Pack](https://mcasset.cloud/) -### References +## Misc -- [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) +- [Order of trigger activations in a tick](https://gist.github.com/misode/77ee37217a69a3c74032679d8084d6c6#file-tick_order-md) -## Resource packs +## 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) +- [BlockBench](https://www.blockbench.net): model editor. +- [Misode’s Generators](https://misode.github.io): blockstate, model, font and atlas. ### References -- [Model format](http://minecraft.wiki/Model) (Wiki) -- [Sounds list](https://minecraft.wiki/Sounds.json/Java_Edition_values) (Wik) +- [Model format](http://minecraft.wiki/Model), The Minecraft Wiki +- [Sounds list](https://minecraft.wiki/Sounds.json/Java_Edition_values), The Minecraft Wiki - [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) +- [Vanilla Resource Pack Assets](https://mcasset.cloud/) -## 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) +## Ask for help -### Animation +- [/r/MinecraftCommands](https://www.reddit.com/r/MinecraftCommands/) +- [Discord server](https://discord.com/invite/9wNcfsH) -- [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) +For older versions of minecraft (1.14 and before) check the [pre-1.15 resources page](wiki/oldresources) \ No newline at end of file From c0e430ce0da12176b23542135ad3daefa48a437d Mon Sep 17 00:00:00 2001 From: EricristianBros Date: Sun, 1 Dec 2024 21:57:07 +0100 Subject: [PATCH 2/7] Fix customitemtag section --- questions/customitemtag.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/questions/customitemtag.md b/questions/customitemtag.md index 53fc41f24..cadf77dc2 100644 --- a/questions/customitemtag.md +++ b/questions/customitemtag.md @@ -1,7 +1,7 @@ # Give an item a custom tag to identify it by -* [Java](#Java) -* [Bedrock](#Bedrock) +* [Java](#java) +* [Bedrock](#bedrock) ## Java From 358b2d97cce677a74ea8ed037374c495e277fcd1 Mon Sep 17 00:00:00 2001 From: EricristianBros Date: Sun, 1 Dec 2024 21:59:37 +0100 Subject: [PATCH 3/7] Update raycast.md https://github.com/MinecraftCommands/wiki/issues/5 --- questions/raycast.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/questions/raycast.md b/questions/raycast.md index 0a5ce38da..8565b3b61 100644 --- a/questions/raycast.md +++ b/questions/raycast.md @@ -24,7 +24,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 useage, 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. From ad7657f8c5c641e5d229e2d75f3e18f4ad610e9e Mon Sep 17 00:00:00 2001 From: EricristianBros Date: Sun, 19 Jan 2025 16:57:05 +0100 Subject: [PATCH 4/7] Grammar fixes, escaping and 404 Grammar fixes added escaping to the FAQ, small fixes and consistency in `itemclick` and added a 404 page with a button to go back to the table of contents. Explanation in `questions` about changes to text components. --- .github/issue_template/bug.yaml | 71 ------------------------ .github/issue_template/request.yaml | 30 ----------- 404.html | 50 +++++++++++++++++ bcresources.md | 5 +- oldresources.md | 2 +- questions.md | 12 +++-- questions/amountitems.md | 2 +- questions/angermob.md | 4 +- questions/areas.md | 6 +-- questions/blockdelay.md | 8 +-- questions/blockinvert.md | 4 +- questions/changeofscore.md | 4 +- questions/commandcontext.md | 4 +- questions/customitemtag.md | 4 +- questions/escaping.md | 84 +++++++++++++++++++++++++++++ questions/fakeplayer.md | 12 ++--- questions/findsamescoreentity.md | 2 +- questions/functionconditions.md | 6 +-- questions/giveitembedrock.md | 6 +-- questions/highestscore.md | 6 +-- questions/hostilefriendly.md | 11 ++-- questions/itemclick.md | 21 +++++--- questions/linkentity.md | 2 +- questions/lookat.md | 8 +-- questions/makecircle.md | 10 ++-- questions/movetoscore.md | 4 +- questions/multipletags.md | 2 +- questions/nbttransfer.md | 4 +- questions/npc.md | 6 +-- questions/numplayers.md | 10 ++-- questions/playerdeaths.md | 6 +-- questions/playerjoin.md | 10 ++-- questions/playerkills.md | 18 +++---- questions/range.md | 4 +- questions/raycast.md | 32 ++++++----- questions/runonce.md | 4 +- questions/scorecompare.md | 8 +-- questions/shop.md | 2 +- questions/tagentity.md | 2 +- 39 files changed, 270 insertions(+), 216 deletions(-) delete mode 100644 .github/issue_template/bug.yaml delete mode 100644 .github/issue_template/request.yaml create mode 100644 404.html create mode 100644 questions/escaping.md diff --git a/.github/issue_template/bug.yaml b/.github/issue_template/bug.yaml deleted file mode 100644 index 7b8cffcab..000000000 --- a/.github/issue_template/bug.yaml +++ /dev/null @@ -1,71 +0,0 @@ -name: "Bug Report" -description: Create a new ticket for a bug. -title: "[BUG]:" -labels: ["bug"] -body: - - type: textarea - id: description - attributes: - label: "Description" - description: Write a summary of the bug here. - validations: - required: true - - type: textarea - id: recreate - attributes: - label: "How to reproduce?" - description: Write, step by step, how to reproduce - value: | - 1. - 2. - 3. - 4. - render: bash - validations: - required: true - - type: textarea - id: result - attributes: - label: Result observed - description: Describe the result observed - placeholder: "The result observed…" - validations: - required: true - - type: textarea - id: expected_result - attributes: - label: Expected result - description: What did you expect as a result? - placeholder: "I expected…" - validations: - required: true - - type: textarea - id: other - attributes: - label: Other - description: Do you want to explain something more? - placeholder: " " - validations: - required: false - - type: textarea - id: files - attributes: - label: Screenshots / Files - description: You can copy and paste or drag and drop to add files. - placeholder: "files" - validations: - required: false - - type: dropdown - id: priority - attributes: - label: "Priority" - description: What is the priority of this bug? 1 means low priority and 5 means high priority. - multiple: false - options: - - 1 (Low priority) - - 2 - - 3 - - 4 - - 5 (High priority) - validations: - required: true \ No newline at end of file diff --git a/.github/issue_template/request.yaml b/.github/issue_template/request.yaml deleted file mode 100644 index 3d544f6d3..000000000 --- a/.github/issue_template/request.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: Request -description: Make a request. -title: "[REQUEST]: " -labels: ["request"] -projects: [""] -body: - - type: textarea - id: request - attributes: - label: What would you like to request? - description: Write your suggestion here. - placeholder: "I would like to request…" - validations: - required: true - - type: textarea - id: files - attributes: - label: Screenshots / Files - description: You can copy and paste or drag and drop to add files. - placeholder: "files" - validations: - required: false - - type: textarea - id: issues - attributes: - label: What issues will be solved with this request? - description: You can skip this question if none are solved. - placeholder: "#Issues ID" - validations: - required: false \ No newline at end of file diff --git a/404.html b/404.html new file mode 100644 index 000000000..7fd3ab8d7 --- /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/bcresources.md b/bcresources.md index 426fe3afb..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](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/oldresources.md b/oldresources.md index 4388400f5..e36811f45 100644 --- a/oldresources.md +++ b/oldresources.md @@ -1,6 +1,6 @@ # 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 moder versions see the [resources page](wiki/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. diff --git a/questions.md b/questions.md index 6653428bb..74173fec3 100644 --- a/questions.md +++ b/questions.md @@ -5,7 +5,10 @@ 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 data attached to stacks of items (tag field) has been replaced with structured 'components'. Anything related to items have a diferent format. 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). + +## Why is my `tellraw` or `/title` command broken (java)? +In 1.21.5, Text Components now use SNBT instead of JSON. Learn more in [this article](https://minecraft.wiki/w/Text_component_format). ## How do I... @@ -40,7 +43,7 @@ In 1.20.5 unstructured NBT data attached to stacks of items (tag field) has been [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) ### Conditions @@ -51,10 +54,10 @@ In 1.20.5 unstructured NBT data attached to stacks of items (tag field) has been ### Entities [Do something (e.g: kill) to the entity I just found with /execute if entity (testfor)?](/wiki/questions/tagentity) -[Make one mob attack another mob/player?](/wiki/questions/angermob) +[Make one mob attack another mob/player?](/wiki/questions/angermob) [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 / dissable PvP?](/wiki/questions/hostilefriendly) [Setup, configure and add multiple dialogues to NPCs?](/wiki/questions/npc) ### Misc @@ -70,6 +73,7 @@ In 1.20.5 unstructured NBT data attached to stacks of items (tag field) has been [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) diff --git a/questions/amountitems.md b/questions/amountitems.md index 3d6a4fd74..39fb5fa89 100644 --- a/questions/amountitems.md +++ b/questions/amountitems.md @@ -19,7 +19,7 @@ That means we can use [`execute store`](https://minecraft.wiki/w/Commands/execut ### 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|unless)_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): diff --git a/questions/angermob.md b/questions/angermob.md index e273f948e..ad67ab7d6 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)_ @@ -43,7 +43,7 @@ For example you can use a snowball, as this projectile only deal damage to blaze | ⚠️ Important | |--------------| -|If the player is crawnling or it has a block above them, it won't work| +|If the player is crawling or it has a block above them, it won't work| In the following example a skeleton tagged `attacker` is tricked into attacking a zombie tagged `target`. diff --git a/questions/areas.md b/questions/areas.md index b9e610ec6..2e650c95a 100644 --- a/questions/areas.md +++ b/questions/areas.md @@ -4,7 +4,7 @@ |---------| |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. @@ -25,7 +25,7 @@ The best way to make sure players are in one of multiple areas without overwriti 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] @@ -55,7 +55,7 @@ To make placing markers more convenient, you can give a spawn_egg containing a m # 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 diff --git a/questions/blockdelay.md b/questions/blockdelay.md index 8ec131846..3a490685c 100644 --- a/questions/blockdelay.md +++ b/questions/blockdelay.md @@ -3,7 +3,7 @@ ## 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 @@ -80,7 +80,7 @@ In addition to the marker, you need to use a scoreboard timer, which each tick w ### 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). # Setup scoreboard objectives add timer dummy @@ -202,9 +202,9 @@ In this example we use an armor stand with the tag `loop`, we will place a press ``` execute as @e[tag=loop,distance=..3,type=armor_stand] at @s run tp @s ~ ~5 ~ ``` -To add more commands, just add a chain one to the previus impulse. +To add more commands, just add a chain one to the previous impulse. | ⚠️ Important | |--------------| -|It is not recomended to use this method| +|It is not recommended to use this method| diff --git a/questions/blockinvert.md b/questions/blockinvert.md index dbeede30e..7ad1f9932 100644 --- a/questions/blockinvert.md +++ b/questions/blockinvert.md @@ -10,7 +10,7 @@ | 📝 Note | |---------| -|You could use a redstone torch and a comparator, but it is **not** recomended as it causes more lag than the other methods described below| +|You could use a redstone torch and a comparator, but it is **not** recommended as it causes more lag than the other methods described below| When a command block runs, its `SuccessCount` tag is updated. This is the value used by comparators to decide how strong a signal to output from that command block. If the command block does not succeed, its `SuccessCount` will be `0`. @@ -35,4 +35,4 @@ 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 poiting 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. \ No newline at end of file diff --git a/questions/changeofscore.md b/questions/changeofscore.md index 7b29e39ff..b74fa5cf1 100644 --- a/questions/changeofscore.md +++ b/questions/changeofscore.md @@ -2,7 +2,7 @@ _Both Java and Bedrock_ -If you need to detect when and if a score of a player has changed, there are two ways to go about this. This is generally most useful if you're using a scoreboard objective that changes because of something the player is doing (e.g. clicking, attacking, sneaking) or the game is doing to the player (e.g. taking damage, change of health and hunger). +If you need to detect when and if a score of a player has changed, there are two ways to go about this. This is generally most useful if you're using a scoreboard objective that changes because of something the player is doing (e.g., clicking, attacking, sneaking) or the game is doing to the player (e.g., taking damage, change of health and hunger). If you are changing the score yourself, it is generally advised to also do the effects to the player yourself, as you're changing the score anyways (which is currently the case in 100% of the time in Bedrock), but in some edge cases this can still be useful to do anyways. @@ -11,7 +11,7 @@ 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 players death and want to do something with that player everytime they die once. +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. execute as @a[scores={deaths=1..}] run say I died :( scoreboard players reset @a[scores={dead=1..}] deaths diff --git a/questions/commandcontext.md b/questions/commandcontext.md index 7d7c97e8a..7bddc7c4c 100644 --- a/questions/commandcontext.md +++ b/questions/commandcontext.md @@ -18,7 +18,7 @@ See [the Minecraft wiki on the execute command](https://minecraft.wiki/wiki/Comm When a command is run, it will get some default values depending on how it is run. - A command **run from chat** is executed `as` and `at` (so positioned and rotated as) the player who runs it. -- A command **run from a commandblock** is executed with the position set to the center of the commandblock in all three axis. It is always rotated `0 0`, so facing straight forward in south (positive z) direction. _There is no executing entity_. +- A command **run from a commandblock** is executed with the position set to the center of the commandblock in all three axes. It is always rotated `0 0`, so facing straight forward in south (positive z) direction. _There is no executing entity_. - A command **run from a function** can have various values, as functions themselves keep context. See below. - A scheduled command does not keep context - Tick and load functions run at world spawn @@ -33,4 +33,4 @@ So a function run in chat will have the same defaults as any other command run f A command run from either the `#minecraft:load` or `#minecraft:tick` [function tags](https://minecraft.wiki/wiki/Tag#Function_tags) will run positioned at world spawn (at the lowest end of the block, unlike the commandblock), rotated `0 0` and without an executing entity. -This allows a lot of [optimization](/wiki/optimising) since you can use a selector once, running the function as that entity and then refer to that entity as `@s` for the rest of the function. It also allows for [entityless raycasting](/wiki/questions/raycast#wiki_without_an_entity) as the position and rotation is preserved between function calls. +This allows a lot of [optimization](/wiki/optimising) since you can use a selector once, running the function as that entity and then refer to that entity as `@s` for the rest of the function. It also allows for [entityless raycasting](/wiki/questions/raycast#wiki_without_an_entity) as the position and rotation are preserved between function calls. diff --git a/questions/customitemtag.md b/questions/customitemtag.md index cadf77dc2..c36c9e5b9 100644 --- a/questions/customitemtag.md +++ b/questions/customitemtag.md @@ -160,7 +160,7 @@ For example, the crafting recipe below (1.20.5+), which will give an item with t ``` ## Bedrock -In bedrock we will need use a workarround, because we can't use custom tags. +In bedrock we will need use a workaround, because we can't use custom tags. ### Item data To get an item with specific data, you can use a number between `2,147,483,647` and `-2,147,483,648`. @@ -175,7 +175,7 @@ This stick will have a data of 5, that we can detect with the `hasitem` argument /effect @a[hasitem={item=stick,data=5}] speed ### Name with color codes -As proposed by [u/V1beRater](https://www.reddit.com/user/V1beRater/) in [this reddit post](https://www.reddit.com/r/MinecraftCommands/comments/xzbj5t/comment/irlhawd/). We can use color codes to change the name of an item of an apple to, for example, `§r§fApple`, wich is indistinguishable from a normal apple name, but you can detect if it's dropped with this command: +As proposed by [u/V1beRater](https://www.reddit.com/user/V1beRater/) in [this Reddit post](https://www.reddit.com/r/MinecraftCommands/comments/xzbj5t/comment/irlhawd/). We can use color codes to change the name of an item of an apple to, for example, `§r§fApple`, which is indistinguishable from a normal apple name, but you can detect if it's dropped with this command: kill @e[type=item, name="§r§fApple"] diff --git a/questions/escaping.md b/questions/escaping.md new file mode 100644 index 000000000..4e09734fa --- /dev/null +++ b/questions/escaping.md @@ -0,0 +1,84 @@ +# What is escaping? +## 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 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. + +Pre-1.21.5 Syntax: Using JSON text components required escaping quotes with a backslash (`\`): + + /tellraw @a "I said \"Hi\" " + +In 1.21.5+, Minecraft switched to SNBT (Stringified NBT) for commands like /tellraw. Here, single quotes (') are used for strings, and escaping is done with backslashes for single quotes: + + /tellraw @a 'I said \'Hi\' ' + +If the backslash (`\`) is removed, the quotes would be misinterpreted as the end of the string, causing a syntax error. Escaping ensures special characters like quotes or backslashes are treated as part of the message rather than command syntax. + +## Combining Quotes to Avoid Escaping +When writing NBT, both types of quotes can be combined to avoid the need to escape (this is not valid for JSON): `'I said "Hi"'` = `I said "Hi"` + +## Escaping backslashes +Note that this means a single backslash \ cannot be used on its own as it will attempt to escape the succeeding character, and therefore will need to be escaped itself + +## Nested Strings +Escaping becomes more complex when dealing with nested strings, where one string contains another string. In such cases, you must escape both the inner and outer layers of quotes to ensure the entire structure is parsed correctly. + + give @p command_block[block_entity_data={id:"command_block",Command:"setblock ~ ~1 ~ command_block{Command:\"tellraw @a \\\\"Hi\\\\"\"}"}] 1 + +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 (\"). + +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: +``` +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:diamond", + "functions": [ + { + "function": "minecraft:set_name", + "name": { + "text": "The \"Shiny\" Diamond", + } + } + ] + } + ] + } + ] +} + +The "text" field contains The "Shiny" Diamond. The inner quotes around Shiny are escaped as \" to be treated as part of the string. Without escaping, the parser would misinterpret the quotes and throw an error. +``` + +## Common errors + +Unescaped quotes: + + "text": "This is a "broken" string" + +The quotes must be escaped. + + "text": "This is a \"broken\" string" + +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. + +Not nesting strings: + + give @p command_block[block_entity_data={id:"command_block",Command:"setblock ~ ~1 ~ command_block{Command:\"tellraw @a \"Hi\"\"}"}] 1 + +The string must be [nested](#nested-strings) + diff --git a/questions/fakeplayer.md b/questions/fakeplayer.md index e3a6b0991..fcf3372ea 100644 --- a/questions/fakeplayer.md +++ b/questions/fakeplayer.md @@ -1,22 +1,22 @@ # What is a fake player -When people talk about "using a fake player" on the scoreboard, they're talking about just writing down a name of a fictional playername instead of using a selector. This has the advantage that it is very fast and convenient to store and use scoreboard values. +When people talk about "using a fake player" on the scoreboard, they're talking about just writing down a name of a fictional player name instead of using a selector. This has the advantage that it is very fast and convenient to store and use scoreboard values. scoreboard players set total points 100 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. +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. ## Special characters -It is recommended to use special characters inside the fake player names to prevent conflicts with real players (see [things to look out for](#things_to_look_out_for)). While you cannot use spaces, you can use a lot more characters that normally wouldn't be possible to be used in normal playernames like `.#$%/*!`. The three most common ones are +It is recommended to use special characters inside the fake player names to prevent conflicts with real players (see [things to look out for](#things_to_look_out_for)). While you cannot use spaces, you can use a lot more characters that normally wouldn't be possible to be used in normal player names like `.#$%/*!`. The three most common ones are -- `.` generally used to create a sort of namespace (e.g. `homes.x`, `homes.y`) -- `$` tends to be used at the start of the fake name. This likely stems from other programming languages where this character symbolises a variable. Not to be confused with macros. +- `.` generally used to create a sort of namespace (e.g., `homes.x`, `homes.y`) +- `$` tends to be used at the start of the fake name. This likely stems from other programming languages where this character symbolizes a variable. Not to be confused with macros. - `#` also used at the start, as it has a **special feature**: If it's the first character in the name, it is not displayed on the sidebar when the objective is displayed there. ## 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 seperate 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 2e3f98c1a..9e5b858d9 100644 --- a/questions/findsamescoreentity.md +++ b/questions/findsamescoreentity.md @@ -76,7 +76,7 @@ In this method we change the execution _location_ to be the player(s) and the ex |---------| |This method also works in bedrock before new execute| -In bedrock this whole endeavour 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 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 4af1f06eb..d3fdca7f4 100644 --- a/questions/functionconditions.md +++ b/questions/functionconditions.md @@ -24,12 +24,12 @@ First, set up a dummy scoreboard objective: scoreboard objectives add success_score dummy -We're going to use a [fake player](/wiki/questions/fakeplayer) (because it's about checking a block, independently of an entity, it's recomended to use it) to store the result. This can of course be substituted for the executing entity or a different entity as well. +We're going to use a [fake player](/wiki/questions/fakeplayer) (because it's about checking a block, independently of an entity, it's recommended to use it) to store the result. This can of course be substituted for the executing entity or a different entity as well. Then, whenever you want to perform a conditional command: execute store success #success success_score if block 73 10 31 stone - execute if score #success success_score matches 1 run say Succes!! + execute if score #success success_score matches 1 run say Success!! execute unless score #success success_score matches 1 run say Not success!! ## 1.12 @@ -44,7 +44,7 @@ Easiest way to do this is by prefixing the command with an `execute`: ---- -If you want to run commands without changing the executer, or run a command if the selector **fails**, you can use `/function`'s `if` or `unless` arguments. For example: +If you want to run commands without changing the executor, or run a command if the selector **fails**, you can use `/function`'s `if` or `unless` arguments. For example: function code:team_change if @a[tag=TeamChange] function code:ready unless @a[tag=!Ready] diff --git a/questions/giveitembedrock.md b/questions/giveitembedrock.md index 511292f9a..660ec15ef 100644 --- a/questions/giveitembedrock.md +++ b/questions/giveitembedrock.md @@ -39,12 +39,12 @@ Either use step 4 or step 6, reasons and problems see below 5. tp the dropped items to the player 6. **or** if you didn't do #4, you can /clear the container from the players inventory instead -Step 4: requires you to either rename the container or hope the player is playing in english, because @e[type=item,name="Chest"] only works in english. Alternatively you can change the language files for every language so all and every chest is called "Chest" in every language. -Step 6: Has the advantage that you don't need to fiddle with the language files or renamed containers, but has the problem that the item may not be picked up instantly thus making it harder to set up properly. +Step 4: requires you to either rename the container or hope the player is playing in English, because @e[type=item,name="Chest"] only works in English. Alternatively, you can change the language files for every language so all and every chest is called "Chest" in every language. +Step 6: Has the advantage that you don't need to fiddle with the language files or renamed containers, but has the problem that the item may not be picked up instantly, thus making it harder to set up properly. ### Structure block -Instead of storing the item in a chest, you store it in a structure block by saving a 1x1 structure that consists of just air and the item entities. So the step by step guide is: +Instead of storing the item in a chest, you store it in a structure block by saving a 1x1 structure that consists of just air and the item entities. So the step-by-step guide is: 1. throw the item(s) on top of a structure block, save the structure with entities (probably as a 1x1x1 sized structure). 2. change the structure block to load mode diff --git a/questions/highestscore.md b/questions/highestscore.md index d16d3d048..7bfdf9488 100644 --- a/questions/highestscore.md +++ b/questions/highestscore.md @@ -2,13 +2,13 @@ | 📝 Note | |---------| -|This only works with online players / loaded entities. If you want to accomodate offline players / unloaded entities, you'll need a much more complicated system!| +|This only works with online players / loaded entities. If you want to accommodate offline players / unloaded entities, you'll need a much more complicated system!| Thanks to `scoreboard player operations` this is a fairly easy question to answer, as the `>` operator will ensure the left score is at least as high as the right score. -Thus the way to do this is as follows (assuming you're trying to find the highest score in an objective named `score`). +Thus, the way to do this is as follows (assuming you're trying to find the highest score in an objective named `score`). -First you set up a [fake player](/wiki/questions/fakeplayer) with the smallest possible score you can reasonably have, or alternatively you can use the smallest possible number (`-2147483648`). +First, you set up a [fake player](/wiki/questions/fakeplayer) with the smallest possible score you can reasonably have, or alternatively you can use the smallest possible number (`-2147483648`). scoreboard players set #max score -2147483648 diff --git a/questions/hostilefriendly.md b/questions/hostilefriendly.md index 70c9f17d6..00fbe2e5e 100644 --- a/questions/hostilefriendly.md +++ b/questions/hostilefriendly.md @@ -15,7 +15,7 @@ In java, we can create teams, and we can configure friendly fire to make people ### 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 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 | |---------| @@ -34,7 +34,7 @@ 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 dissable PvP, it will only prevent the entity attacking the player. +This method wont 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. @@ -63,9 +63,10 @@ Important things to keep in mind when using this method: * 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. attribute entity_interaction_range base set 0 -> [!NOTE] -> This will affect right click too so they won't be able to trade with villagers, for example. +| 📝 Note | +|---------| +|This will affect right click too so they won't be able to trade with villagers, for example.| diff --git a/questions/itemclick.md b/questions/itemclick.md index 1ea75a027..cf24297f5 100644 --- a/questions/itemclick.md +++ b/questions/itemclick.md @@ -107,7 +107,7 @@ Pros: Cons: - Will attract pigs/boost pigs speed when riding a pig. _(or striders if using the wfoas instead)_ - Looks like a carrot on a stick (fix see below). -- Has unremovable Damage NBT tag. This can be somewhat negated by making the CoaS unbreakable. +- Only in pre-1.20.5: Has unremovable Damage NBT tag. This can be somewhat negated by making the CoaS unbreakable. ##### Make the CoaS look like any item @@ -201,7 +201,7 @@ This method allows you to check a right click for almost any item and you do not ##### 1.21.2+ -In 1.21.2 some part of the `food` component has been separated into the `consumable` component. So we will need to change the `give` command, depending on what of the two methods you are using the `consume_seconds` will be set to `0`, that is now possible in 1.21.2+ (if using the scoreboard method) or to `2147483647` (if using an advancement) +In 1.21.2 some part of the `food` component has been separated into the `consumable` component. So we will need to change the `give` command, depending on what of the two methods you are using. The `consume_seconds` will be set to `0`, that is now possible in 1.21.2+ (if using the scoreboard method) or to `2147483647` (if using an advancement) ``` # get item @@ -211,10 +211,10 @@ give @p stick[food={nutrition:0,saturation:0,can_always_eat:true},consumable={co 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. ``` -# function example:get_star +# Setup give @p nether_star[use_cooldown={seconds:5},food={nutrition:0,saturation:0,can_always_eat:true},consumable={consume_seconds:1,animation:"bow"},custom_data={right_click:true}] 1 -# advancement example:use_nether_star +# advancement example:right_click/nether_star { "criteria": { "requirement": { @@ -253,9 +253,10 @@ _Parts of this post are taken and modified from [here](https://www.reddit.com/r/ ### Inventory click -*Note:* This method works since version 1.20.5 - -_Note: This will not work for creative players._ +| 📝 Note | +|---------| +|This method works since version 1.20.5| +|This will not work for creative players.| This method is based on checking the player's cursor slot. To do this, need to check slot `player.cursor` using the `if items` subcommand or predicates. Below is an example for running a command when holding a custom item in the cursor. @@ -271,7 +272,11 @@ This method is based on checking the player's cursor slot. To do this, need to c ### Bundles -Right-clicking a bundle will take the first item that has. Because this item is 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. +| 📝 Note | +|---------| +|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 enitty, 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. # bedrock execute at @e[type=item,name="right_click"] run tag @p add right_click diff --git a/questions/linkentity.md b/questions/linkentity.md index f4ca3c143..19aa7f58d 100644 --- a/questions/linkentity.md +++ b/questions/linkentity.md @@ -4,7 +4,7 @@ _Also known as a **scoreboard ID system**_. ## Java -Sometimes there is a need to link two entites 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. diff --git a/questions/lookat.md b/questions/lookat.md index 07908c9e6..545d295a7 100644 --- a/questions/lookat.md +++ b/questions/lookat.md @@ -10,10 +10,10 @@ in Java and later Bedrock versions this can actually be achieved in a single com - `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). - `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 omited, 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 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)) - `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 players 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: @@ -97,7 +97,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 scaleable 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. # summon armorstand so we can do our check @@ -118,7 +118,7 @@ This setup can only happen to one player at a time, so either use functions to m # remove entity 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 diff --git a/questions/makecircle.md b/questions/makecircle.md index 3c2d102c8..3ebff5603 100644 --- a/questions/makecircle.md +++ b/questions/makecircle.md @@ -8,7 +8,7 @@ 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. @@ -27,9 +27,9 @@ For the example we're assuming that we want to make a block outline. You can eas execute as @e[tag=center] at @s run setblock ^ ^ ^10 stone -4. Next, we rotate by what seems a good rotation to cover the entire circle. You can do some maths to figure out a good stepsize, or you can just decrease the size if you end up with holes in your circle. +4. Next, we rotate by what seems a good rotation to cover the entire circle. You can do some math to figure out a good stepsize, or you can just decrease the size if you end up with holes in your circle. - The math works like this: You calculate the radian distance as follows: `d = (deg / 360) * 2 * π * radius`. Or, if we solve for the degrees needed from a distance between blocks: `deg = (180 * d) / (π * radius)`. So if your radius is 10 blocks as in the example above, and you want to place a block every one block of distance, you should rotate by (180 * 1) / (π * 10) = 5.7°. But with minecrafts blocky nature, if we want to place continous blocks, we might just want to aim for half of that. + The math works like this: You calculate the radian distance as follows: `d = (deg / 360) * 2 * π * radius`. Or, if we solve for the degrees needed from a distance between blocks: `deg = (180 * d) / (π * radius)`. So if your radius is 10 blocks as in the example above, and you want to place a block every one block of distance, you should rotate by (180 * 1) / (π * 10) = 5.7°. But with minecrafts blocky nature, if we want to place continuous blocks, we might just want to aim for half of that. execute as @e[tag=center] at @s run tp @s ~ ~ ~ ~ ~2.35 @@ -39,6 +39,6 @@ You can of course expand on this basic system to make it more modular, run it ex ## Potential issues -If you are trying to use this to make really big circles (hundreds of blocks in diameter), you might find that this won't work as you intend it to, seemingly skipping many steps inbetween. +If you are trying to use this to make really big circles (hundreds of blocks in diameter), you might find that this won't work as you intend it to, seemingly skipping many steps in between. -We're unsure as to why exactly this happens, but our best guess is that minecrafts internal calculations are limited to a certain rotational precision (e.g. angles get rounded to 0.01° for calculations). This doesn't have any noticeable effect on 99.99% of gameplay, but becomes visible in these situations. \ No newline at end of file +We're unsure as to why exactly this happens, but our best guess is that minecrafts internal calculations are limited to a certain rotational precision (e.g., angles get rounded to 0.01° for calculations). This doesn't have any noticeable effect on 99.99% of gameplay, but becomes visible in these situations. \ No newline at end of file diff --git a/questions/movetoscore.md b/questions/movetoscore.md index 5702eb09d..7043582f9 100644 --- a/questions/movetoscore.md +++ b/questions/movetoscore.md @@ -34,7 +34,7 @@ Below is an example of summoning a pig according to the set value in the scorebo **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: +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: # In chat function example:macro_summon {id:"minecraft:pig",x:25.5d, y:65.5d, z:-15.5d} @@ -125,7 +125,7 @@ See [u/SanianCreations](https://www.reddit.com/u/SanianCreations) post about thi |---------| |This method works in bedrock too| -You basically copy their score to some temporary score so you don't loose it when you modify it, and then you go through the different powers of 2 (hence the name), check if their score is above that and then teleport them relatively that far. +You basically copy their score to some temporary score so you don't lose it when you modify it, and then you go through the different powers of 2 (hence the name), check if their score is above that and then teleport them relatively that far. execute as @a unless score @s xTmp matches 0 if score @s xTmp = @s xTmp run teleport @s 0 0 0 diff --git a/questions/multipletags.md b/questions/multipletags.md index 3e028a69d..9fbc987c3 100644 --- a/questions/multipletags.md +++ b/questions/multipletags.md @@ -2,7 +2,7 @@ In 1.12 and below, you're unable to specify multiple selector arguments of the same key directly in a single selector. For example, `@e[tag=A,tag=B,tag=C]` ignores the first two arguments and acts the same as `@e[tag=c]`, regardless of whether the entity has tags `a` or `b`. -**In 1.13, you are able to specify multiple specify multiple tags in a selector** making this tutorial irrelevant. +**In 1.13, you are able to specify multiple tags in a selector**, making this tutorial irrelevant. ## Method 1: Nested `@s` execute (1.12 and above) diff --git a/questions/nbttransfer.md b/questions/nbttransfer.md index e1f115f89..a8ff8b526 100644 --- a/questions/nbttransfer.md +++ b/questions/nbttransfer.md @@ -12,9 +12,9 @@ Rather than printing out all data, you can specify a "path" to get one specific data get entity @s Pos[0] -Pos[0] means the first (indexes counting from 0) element of the `Pos` list, so the x coordinate (you can access tags inside of compounds as `compound.tag`). +Pos[0] means the first (indexes counting from 0) element of the `Pos` list, so the x coordinate (you can access tags inside of compounds as `compound.tag`). -This is cast into an integer, meaining if you are at `x=73.1031`, the command's result will be just `73`. +This is cast into an integer, meaning if you are at `x=73.1031`, the command's result will be just `73`. The optional `[]` factor lets you multiply the number by something before it's read to an integer, for more accuracy. For example, the following would have the result `7310` (100*x): data get entity @s Pos[0] 100 diff --git a/questions/npc.md b/questions/npc.md index d41f0370d..461aa038c 100644 --- a/questions/npc.md +++ b/questions/npc.md @@ -12,7 +12,7 @@ For spawning an NPC, you will need to use the `/summmon` or `/give` command: /summon npc /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. @@ -52,7 +52,7 @@ First NPC (The one player will interact with), with the dialog “Do you want a dialogue open @e[tag=npc.confirm,type=npc] @initiator # Button mode with the text “No” - # This is empty as when pressing any button, the NPC dialogue will close. + # This is empty, as when pressing any button, the NPC dialogue will close. Now we will hide a second NPC underground (so player will **not** see it) with the tag `npc.confirm`, With the dialogue “Are you sure?” @@ -61,6 +61,6 @@ Now we will hide a second NPC underground (so player will **not** see it) with say here is your challenge # Button mode with the text “No” - # This is empty as when pressing any button, the NPC dialogue will close. + # This is empty, as when pressing any button, the NPC dialogue will close. And now you have a dialog that will pop up when you press a button. You can add more dialogues with more NPCs, but each one needs a different tag to identify it. diff --git a/questions/numplayers.md b/questions/numplayers.md index a35f5aaea..6cbd39de6 100644 --- a/questions/numplayers.md +++ b/questions/numplayers.md @@ -11,9 +11,9 @@ A command will still run (and potentially succeed once) even if `@a[team=red,lim ## Java and Bedrock | 📝 Note | |---------| -|This method will work in Java too, but its recomended to use the Java exclusive method| +|This method will work in Java too, but it's recommended to use the Java exclusive method| -The easiest way to do this in bedrock is to have the found entities count up the score of another entity or a [fake player](/wiki/questions/fakeplayer) (the later is currently a little harder to check for their score, so it is not used in this tutorial). +The easiest way to do this in bedrock is to have the found entities count up the score of another entity or a [fake player](/wiki/questions/fakeplayer) (the latter is currently a little harder to check for their score, so it is not used in this tutorial). Using a dummy scoreboard objective named `result` and an entity with the `counter` tag, we can count how many players there are in team red: @@ -30,9 +30,9 @@ You can also use [ranges](wiki/questions/ranges) ## Bedrock | 📝 Note | |---------| -|It is not recomended to use this method| +|It is not recommended to use this method| -You can use a comparator with the `/testfor` command, the output, in signal strengh, is the same as the number of online players. +You can use a comparator with the `/testfor` command, the output, in signal strength, is the same as the number of online players. ## Java @@ -69,7 +69,7 @@ For example, this will test for *exactly* 2 players on the red team (no more, no Change ` ` in the second command block to the coordinates of the first command block. You may also need to change `command_block` to `chain_command_block` or `repeating_command_block`. -The second command will only succeed if the first command has a SuccessCount of 1 (it found exactly 1 player). You can then run a conditional chain block off of that second command to activate whatever you want to happen when there are exactly 1 player: +The second command will only succeed if the first command has a SuccessCount of 1 (it found exactly 1 player). You can then run a conditional chain block off of that second command to activate whatever you want to happen when there is exactly 1 player: ### Method 3: With `/stats` (1.8-1.12) diff --git a/questions/playerdeaths.md b/questions/playerdeaths.md index e3759425b..8784464a4 100644 --- a/questions/playerdeaths.md +++ b/questions/playerdeaths.md @@ -17,7 +17,7 @@ In Java, detecting a dead player is relatively easy. For simple death detection ### Run command at death position -To do this you can use the method described above, but if gamerule `doImmediateRespawn` is true, then the commands from the example above will actually be executed after respawn, which can be a problem if you want to do something at the player's death position. +To do this, you can use the method described above, but if gamerule `doImmediateRespawn` is true, then the commands from the example above will actually be executed after respawn, which can be a problem if you want to do something at the player's death position. If you are limited to using command blocks, then you can read the [player data](https://minecraft.wiki/w/Player.dat_format) `LastDeathLocation` tag (1.19+) to get dimension (`dimension`) and position (`pos`). But since the `LastDeathLocation.pos` tag is an Int Array, but the Pos tag entity is a list, you need to first convert the Int Array to a Double list. Then check the `LastDeathLocation.dimension` in which dimension the player died and set this dimension [`execute in `](https://minecraft.wiki/w/Commands/execute#in), summon area_effect_cloud and move to the death position and in the same tick execute the command on the position of this area_effect_cloud entity. @@ -91,6 +91,6 @@ Set up a dummy scoreboard called `deathCount` and it will count up every time a This works because the `@a` selector selects all players, but the `@e` selector can only select living entities. You can find more information on [the Bedrock wiki](https://wiki.bedrock.dev/commands/on-player-death.html#top). -_This system was first suggested on the subreddit by /u/Sprunkles137 [here](https://old.reddit.com/r/MinecraftCommands/comments/g5b4n8/challenge_1/fo3p5p0/)._ +_This system was first suggested on the Subreddit by /u/Sprunkles137 [here](https://old.reddit.com/r/MinecraftCommands/comments/g5b4n8/challenge_1/fo3p5p0/)._ -There is a different way as well, which can only be used in a very controlled environment where players cannot set their own spawnpoints with beds but all spawning is controlled by the mapmaker. This way you can set everyone's spawnpoint to an otherwise inaccessible position in the world, then detect players respawning there, count up their death score and teleport them to the "actual" spawnpoint. **It is not advised to use this system anymore, as the first system is easier to do, requires less setup and has a wider range of applicable possibilities!** +There is a different way as well, which can only be used in a very controlled environment where players cannot set their own spawnpoints with beds, but all spawning is controlled by the mapmaker. This way you can set everyone's spawnpoint to an otherwise inaccessible position in the world, then detect players respawning there, count up their death score, and teleport them to the "actual" spawnpoint. **It is not advised to use this system anymore, as the first system is easier to do, requires less setup and has a wider range of applicable possibilities!** diff --git a/questions/playerjoin.md b/questions/playerjoin.md index 0c6de1784..c59bc0245 100644 --- a/questions/playerjoin.md +++ b/questions/playerjoin.md @@ -2,8 +2,12 @@ For this, we'll have to differentiate between players joining for the first time and players *re*joining the world for the Nth time, as the approaches are slightly different. +| 📝 Note | +|---------| +|In this example we are using a tellraw command, but in 1.21.5+ the tellraw syntax has changed, so you will need to update it accordingly.| + ## First time -A player that joins a world for the first time is a blank slate, they have no scores, no tags, no advancements, no nothing on them. We can use this to detect the lack of an initialisation tag on the player, apply all our actions to them, then give them the tag. +A player that joins a world for the first time is a blank slate, they have no scores, no tags, no advancements, no nothing on them. We can use this to detect the lack of an initialization tag on the player, apply all our actions to them, then give them the tag. ### Tags @@ -11,7 +15,7 @@ A player that joins a world for the first time is a blank slate, they have no sc tag @a[tag=!init] add init ### Advancements -Another way to do this is using an advancement in a datapack, this advancement will we garanted 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 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. # advancement example:first_join { @@ -92,6 +96,6 @@ In bedrock we don't have `execute store` so we will need to split the command in scoreboard players operation @a online -= .total online execute as @a[scores={online=..-1}] run say I rejoined scoreboard players operation @a online = .total online - execute as @a[tag=!init] run say I joined for first time + execute as @a[tag=!init] run say I joined for the first time tag @a[tag=!init] add init diff --git a/questions/playerkills.md b/questions/playerkills.md index 6b481e158..ae84aae5d 100644 --- a/questions/playerkills.md +++ b/questions/playerkills.md @@ -4,7 +4,7 @@ _Related: [Detect Player Deaths](/wiki/questions/playerdeaths)_ ## Java -In Java this is easy, as there is a whole lot of [scoreboard objectives criteria](https://minecraft.wiki/Scoreboard#Criteria) for every entity you can kill in the game, using the format `minecraft.killed:minecraft.`, where `` is a valid type of entity. +In Java this is easy, as there is a whole lot of [scoreboard objective criteria](https://minecraft.wiki/Scoreboard#Criteria) for every entity you can kill in the game, using the format `minecraft.killed:minecraft.`, where `` is a valid type of entity. This method for command blocks cannot check any NBT data, including the tag of the killed mob. But this can be done using advancement using the [`player_killed_entity`](https://minecraft.wiki/wiki/Advancement/JSON_format#minecraft:player_killed_entity) advancement trigger, if you're using a datapack that looks like this: @@ -27,7 +27,7 @@ But this can be done using advancement using the [`player_killed_entity`](https: } ``` -The advancement from above will check if the entity that the player killed has that NBT (so it has the tag `example` in this case) if you don't want to check NBT you can just use: +The advancement from above will check if the entity that the player killed has that NBT (so it has the tag `example` in this case); if you don't want to check NBT you can just use: ``` { "criteria": { @@ -46,19 +46,19 @@ The advancement from above will check if the entity that the player killed has t } ``` -When the player kills a pig, they will run the funcion `example:kill_entity` as it is set as a reward. +When the player kills a pig, they will run the function `example:kill_entity` as it is set as a reward. ## Bedrock 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 loottable. +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. "minecraft:loot": { "table": "loot_tables/.json" }, -Now, you of course need to create said loot table as well, here is an example of a loot table that will always drop 1 dragon egg if the entity was killed by a player: +Now, you of course need to create said loot table as well. Here is an example of a loot table that will always drop 1 dragon egg if the entity is killed by a player: { "pools": [ @@ -80,18 +80,18 @@ Now, you of course need to create said loot table as well, here is an example of ] } -_This will overwrite the normal loottable for the entity. If you want the item to be dropped in addition to the normal loot, you will have to modify the entities standard loot table._ +_This will overwrite the normal loot table for the entity. If you want the item to be dropped in addition to the normal loot, you will have to modify the entity's standard loot table._ From here you can go two ways: -1. Either you give the player closest to the dropped item the credit for the kill by counting their score up by one, then killing the item. Be aware that this can easily create false results if the combat is ranged or in a chaotic environment, where the closest player to the killed player isn't necessarily the killer. +1. Either you give the player closest to the dropped item the credit for the kill by counting their score up by one, then kill the item. Be aware that this can easily create false results if the combat is ranged or in a chaotic environment, where the closest player to the killed player isn't necessarily the killer. 2. Or you require the players to pick up the item for their kill to be counted, check for the item in their inventory, count up by 1 if you find it and clear 1 from their inventory. Read [here](/wiki/questions/detectitem) how you can detect a certain item. -_Credit to /u/DanRileyCG, for the original [thread here](https://www.reddit.com/r/MinecraftCommands/comments/f7jd9f/help_with_server/)_ +_Credit to [u/DanRileyCG](https://www.reddit.com/user/DanRileyCG/), for the original [thread here](https://www.reddit.com/r/MinecraftCommands/comments/f7jd9f/help_with_server/)_ ### Without behavior packs **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 bees 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 +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. 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/range.md b/questions/range.md index 610b3bb85..50e913168 100644 --- a/questions/range.md +++ b/questions/range.md @@ -1,6 +1,6 @@ # Ranges -Multiple selectors (e.g. `scores` or `distance`) allow for you to specify a **range** of values to test for, instead of just a single value. They are denoted by two dots which seperate the min and max value (including): `min..max` +Multiple selectors (e.g., `scores` or `distance`) allow for you to specify a **range** of values to test for, instead of just a single value. They are denoted by two dots that separate the min and max value (including): `min..max` Either one can be left out to signify an open-ended range. Leaving writing a single number signifies an exact check for this value alone. `1` means "exactly 1" @@ -12,4 +12,4 @@ Some selectors (like `distance`) also allow for decimal numbers. `0.5..0.9` work | ⚠️ Important | |--------------| -|Ranges are not useable when checking for NBT!| +|Ranges are not usable when checking for NBT!| diff --git a/questions/raycast.md b/questions/raycast.md index 8565b3b61..41a975f84 100644 --- a/questions/raycast.md +++ b/questions/raycast.md @@ -6,13 +6,13 @@ ## What is a raycast? -Raycasting (or more accurately in this context: ray marching) in minecraft commands describes a process of moving forward in small increments (basically "drawing" a line) until a certain condition is met. It has many possible usecases, most often it is used to check what a player/entity is looking at by following the looking direction. +Raycasting (or more accurately in this context: ray marching) in minecraft commands describes a process of moving forward in small increments (basically "drawing" a line) until a certain condition is met. It has many possible use cases, most often it is used to check what a player/entity is looking at by following the looking direction. -A raycast is possible due to the introduction of [local coordinates](https://minecraft.wiki/wiki/Coordinates#Local_coordinates) (`^ ^ ^`) which allows a commands origin to be moved relative to the entities local coordinates instead of absolute or world based relative coordinates. +A raycast is possible due to the introduction of [local coordinates](https://minecraft.wiki/wiki/Coordinates#Local_coordinates) (`^ ^ ^`) which allows a command's origin to be moved relative to the entities local coordinates instead of absolute or world based relative coordinates. -In all of the below examples we'll use a step-size of 0.1 blocks at a time. This is a reasonable compromise between error margin and performance hit, but depending on the usecase a smaller or larger step size is absolutely thinkable. +In all of the below examples, we'll use a step-size of 0.1 blocks at a time. This is a reasonable compromise between error margin and performance hit, but depending on the use case, a smaller or larger step size is absolutely thinkable. -Due to the way these raycasts tend to be implemented, they move forward until they hit the desired target (e.g. a block that is not air, but you may also want to not detect other non-solid blocks as water). However, this way it is possible that a ray will never find its terminating condition, so a second ending condition is added: The maximum step amount. This generally consists of a scoreboard value that is increased/decreased with every step, counting the number of steps thus stopping the ray after a certain distance. +Due to the way these raycasts tend to be implemented, they move forward until they hit the desired target (e.g., a block that is not air, but you may also want to not detect other non-solid blocks as water). However, this way it is possible that a ray will never find its terminating condition, so a second ending condition is added: The maximum step amount. This generally consists of a scoreboard value that is increased/decreased with every step, counting the number of steps, thus, stopping the ray after a certain distance. Please remember that a raycast _can_ (depending on the exact implementation) be a somewhat performance intensive procedure, so you need to try to find a balance between accuracy, distance and frequency of your raycast to avoid lag. @@ -28,11 +28,11 @@ This is the preferred method of raycasting, as this entityless approach causes l 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. -First, the command that will initiate a raycast. We're anchoring the execution point at the entities eyes (moving up from their feet), changing the execution position to the eye level and then, due to a quirk in minecrafts keeping of context, move the anchor back to the feet to avoid the game reapplying the hight of the eyes to every step. +First, the command that will initiate a raycast. We're anchoring the execution point at the entities eyes (moving up from their feet), changing the execution position to the eye level, and then, due to a quirk in minecraft's keeping of context, move the anchor back to the feet to avoid the game reapplying the height of the eyes to every step. The subcommand `anchored feet` should not be used in recent versions of the game. execute as at @s anchored eyes positioned ^ ^ ^ anchored feet run function namespace:start_ray -Next up, the ray setup. We need to set a maxium 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. `namespace:start_ray` @@ -40,7 +40,7 @@ Next up, the ray setup. We need to set a maxium amount of steps that we can go b scoreboard players set @s ray_success 0 function namespace: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. `namespace:ray` @@ -48,14 +48,20 @@ Next, the actual ray is being cast. For that, we first check whether our stoppin 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 namespace: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!_ `namespace:hit_block` scoreboard players set @s ray_success 1 setblock ~ ~ ~ stone -And that's the basic skeleton of a raycast, which can now be extended to your hearts content. +And that's the basic skeleton of a raycast, which can now be extended to your heart's content. + +Since 1.20.2, we can use `return` to stop a function early. So the `namespace:ray` function does not need to check the value of the `ray_success` since we don't need this scoreboard anymore. + + execute unless block ~ ~ ~ minecraft:air run return run function namespace:hit_block + scoreboard players remove @s ray_steps 1 + execute if score @s ray_steps matches 1.. positioned ^ ^ ^0.1 run function namespace:ray ### With an entity @@ -83,7 +89,7 @@ We are now executing the ray function as the marker entity instead of the execut tp @s ^ ^ ^0.1 execute if score @s ray_steps matches 1.. if score @s ray_success matches 0 at @s run function namespace:ray -Make sure you kill the entity once it's done it's job, for example by putting the kill command into the success function or at the end of the `start_ray` function. +Make sure you kill the entity once it's done its job, for example, by putting the kill command into the success function or at the end of the `start_ray` function. If you're doing this **without a datapack**, just using commands, then you just need to make sure all the commands that are in the `ray` function are executed as and at the ray_marker entity, that the commands in the `start_ray` function are executed as the ray shooter entity and that you're only affecting the one ray_marker that was summoned on that entity. @@ -116,7 +122,7 @@ As mentioned, this works with just commandblocks, so for the following commands # Kill ray orbs 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: @@ -126,11 +132,11 @@ So, for different applications you'd modify the 4th command to find different th This is the same method as described in the "[with an entity](#wiki_with_an_entity)" section above, just using bedrock syntax. Please see above for an explanation on what is going on. -> **Please note that there seems to be a limitation in bedrock at the time of writing (1.18) that limits the entities up/down movement to 45° angles or just straight up 0°!** Thus a different method might need to be found, possibly using custom projectiles. +> **Please note that there seems to be a limitation in bedrock at the time of writing (1.18) that limits the entities up/down movement to 45° angles or just straight up 0°!** , a different method might need to be found, possibly using custom projectiles. It is _highly_ recommended to use a custom entity for the raycast, as you not only want it to be invisible, without any AI but also unaffected by gravity. -Command to start the raycast (the execution point is moved up manually towards player standing eye level. This means that if the player is not standing up normally (e.g. crouching or swimming) this will produce unexpected results): +Command to start the raycast (the execution point is moved up manually towards player standing eye level. This means that if the player is not standing up normally (e.g., crouching or swimming), this will produce unexpected results): execute ~ ~1.62 ~ function namespace:start_ray diff --git a/questions/runonce.md b/questions/runonce.md index 609e42a77..046c68a93 100644 --- a/questions/runonce.md +++ b/questions/runonce.md @@ -8,7 +8,7 @@ This makes a command act as if it was on a comparator, without the lag and multi ## Scoreboard -For this method our first command checks two things: Your condition for running the command (e.g. `@a[x=73,y=10,z=3,distance=..1]`) and the condition that it didn't already match in the last tick (e.g. `[scores={matched=0}]`). We're storing the success of your condition in a scoreboard in the second command through a success check: +For this method, our first command checks two things: Your condition for running the command (e.g. `@a[x=73,y=10,z=3,distance=..1]`) and the condition that it didn't already match in the last tick (e.g. `[scores={matched=0}]`). We're storing the success of your condition in a scoreboard in the second command through a success check: # In chat / load function scoreboard objectives add matched dummy @@ -38,7 +38,7 @@ Besides the player, this could be some kind of global event, for example, it sta If you are using a datapack and need to do a lot of similar checks, then you can use [advancements](https://minecraft.wiki/w/Advancement/JSON_format) in the datapack for this. -This method involves creating a [predicate](https://minecraft.wiki/w/Predicate) that you check against the player, in this example we want to know whether the player is at the server spawn area (`predicate example:at_spawn`). Then we create two advancements - the first one checks the predicate (player is at spawn) and the second one inverts this check (player isn't at spawn). Then inside the run function you execute the desired command when the player enters / leaves spawn and revoke the opposite advancement. +This method involves creating a [predicate](https://minecraft.wiki/w/Predicate) that you check against the player, in this example, we want to know whether the player is at the server spawn area (`predicate example:at_spawn`). Then we create two advancements - the first one checks the predicate (player is at spawn), and the second one inverts this check (player isn't at spawn). Then, inside the run function, you execute the desired command when the player enters / leaves spawn and revoke the opposite advancement. # predicate example:at_spawn { diff --git a/questions/scorecompare.md b/questions/scorecompare.md index 12400354b..3bfc75723 100644 --- a/questions/scorecompare.md +++ b/questions/scorecompare.md @@ -24,7 +24,7 @@ You can also use `matches` to check for a [range](/wiki/questions/range) if you ### 1.12 and below -To do this we must take one score from another, check if the score is now equal to/greater than/less than 0, then add the score back (to restore the first score's original value). +To do this, we must take one score from another, check if the score is now equal to/greater than/less than 0, then add the score back (to restore the first score's original value). For example, select all players whose `kills` score is greater than their `deaths` score: @@ -46,7 +46,7 @@ For example, select all players whose `kills` score is greater than their `death ### 1.20.5 and above -Since version 1.20.5 can also compare values in storage directly, without copying values to scoreboard. Below is an example of using the `minecraft:value_check` condition to compare values in storage. +Since version 1.20.5 can also compare values in storage directly, without copying values to the scoreboard. Below is an example of using the `minecraft:value_check` condition to compare values in storage. # Example storage data merge storage example:data {value:7.5f,min:0,max:10} @@ -77,9 +77,9 @@ 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 score 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. +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. diff --git a/questions/shop.md b/questions/shop.md index 89a924339..5ffdd2480 100644 --- a/questions/shop.md +++ b/questions/shop.md @@ -94,7 +94,7 @@ Here is an example command: ``` /summon villager ~ ~ ~ {Offers:{Recipes:[{rewardExp:0b,maxUses:2147483647,buy:{id:"minecraft:diamond",count:1},buyB:{id:"minecraft:emerald",count:1},sell:{id:"minecraft:netherite_ingot",count:1}}]}} ``` -Let's break it donw: +Let's break it down: * Inside `Offers` we have `Recipes`, there will be all listed trades. * This trade has `rewardExp:0b` so the player will not get any experience when buying it (you can enable it if you want). * `maxUses:2147483647` is the maximum times it can be traded, this is the maximum value we can set. diff --git a/questions/tagentity.md b/questions/tagentity.md index 9e9eafea3..af17ff9f9 100644 --- a/questions/tagentity.md +++ b/questions/tagentity.md @@ -1,6 +1,6 @@ # Do something (e.g: kill) to the entity I just found with /execute if entity (testfor) -If your execute if entity **does not rely on NBT data**, you can simply move the selector into the command you want to use. For example, if you have: +If your `execute if entity` **does not rely on NBT data**, you can simply move the selector into the command you want to use. For example, if you have: execute if entity @a[team=red] From 6f33989af6df16dd2b47d0b92637bd513dd09715 Mon Sep 17 00:00:00 2001 From: EricristianBros Date: Wed, 19 Mar 2025 13:07:16 +0100 Subject: [PATCH 5/7] Code Block Style --- _config.yml | 3 + debugging.md | 4 +- questions.md | 5 +- questions/amountitems.md | 65 +-- questions/angermob.md | 122 +++--- questions/areas.md | 180 ++++---- questions/blockdelay.md | 195 +++++---- questions/blockinvert.md | 23 +- questions/changeofscore.md | 26 +- questions/commandcontext.md | 2 + questions/compasstoplayer.md | 36 +- questions/customcrafting.md | 28 ++ questions/customitemtag.md | 4 + questions/detectitem.md | 26 +- questions/escaping.md | 21 +- questions/fakeplayer.md | 6 +- questions/findsamescoreentity.md | 95 +++-- questions/functionconditions.md | 68 ++- questions/hostilefriendly.md | 27 +- questions/itemclick.md | 146 ++++--- questions/linkentity.md | 81 ++-- questions/lookat.md | 190 +++++---- questions/makecircle.md | 18 +- questions/mobdeaths.md | 257 ++++++----- questions/modifyinventory.md | 34 +- questions/movetoscore.md | 166 +++++--- questions/multipletags.md | 12 +- questions/nbttransfer.md | 34 +- questions/npc.md | 32 +- questions/numplayers.md | 40 +- questions/playerdeaths.md | 127 +++--- questions/playerjoin.md | 104 +++-- questions/playerkills.md | 62 +-- questions/randomnumber.md | 135 +++--- questions/raycast.md | 207 ++++++--- questions/runonce.md | 170 ++++---- questions/scorecompare.md | 177 ++++---- questions/shootfacing.md | 249 ++++++----- questions/shop.md | 125 +++--- questions/storeinventory.md | 704 +++++++++++++++++-------------- questions/tagentity.md | 24 +- resources.md | 6 +- 42 files changed, 2362 insertions(+), 1674 deletions(-) diff --git a/_config.yml b/_config.yml index 671640e82..d42f485eb 100644 --- a/_config.yml +++ b/_config.yml @@ -12,3 +12,6 @@ include: - CONTRIBUTING.md - ISSUE_TEMPLATE.md - PULL_REQUEST_TEMPLATE.md +kramdown: + parse_block_html: true + parse_span_html: true \ No newline at end of file diff --git a/debugging.md b/debugging.md index 86c19f5a9..8ac762a7b 100644 --- a/debugging.md +++ b/debugging.md @@ -49,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). diff --git a/questions.md b/questions.md index 74173fec3..9f180a41b 100644 --- a/questions.md +++ b/questions.md @@ -7,9 +7,6 @@ Because in 1.19.50, the [new execute syntax](https://learn.microsoft.com/en-us/m ## 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). -## Why is my `tellraw` or `/title` command broken (java)? -In 1.21.5, Text Components now use SNBT instead of JSON. Learn more in [this article](https://minecraft.wiki/w/Text_component_format). - ## How do I... ### Items @@ -57,7 +54,7 @@ In 1.21.5, Text Components now use SNBT instead of JSON. Learn more in [this art [Make one mob attack another mob/player?](/wiki/questions/angermob) [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 diff --git a/questions/amountitems.md b/questions/amountitems.md index 39fb5fa89..cf00802bf 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 +```py +# 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.* * +```py +# 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. +```py +# 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}] +```py +# 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 +```py +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 ad67ab7d6..306c20f5a 100644 --- a/questions/angermob.md +++ b/questions/angermob.md @@ -12,24 +12,29 @@ The basic principle for this method is that a mob that can attack will get angry 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 +```py +# 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 - +```py +# 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] +```py +# 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. @@ -47,11 +52,12 @@ For example you can use a snowball, as this projectile only deal damage to blaze In the following example a skeleton tagged `attacker` is tricked into attacking a zombie tagged `target`. - # 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 - +```py +# 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 @@ -60,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 2e650c95a..5df26b583 100644 --- a/questions/areas.md +++ b/questions/areas.md @@ -8,8 +8,10 @@ This mostly comes up as a question to change the gamemode in a certain area (e.g 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..] +```py +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. @@ -17,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] +```py +# 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 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] +```py +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). @@ -38,22 +44,26 @@ 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 - +```py +# 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"'] +```py +# 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 manually tag the entity with the `/tag` command and use `armor_stand` instead of `marker`. @@ -63,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! +```py +# 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 @@ -74,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 3a490685c..3c649909e 100644 --- a/questions/blockdelay.md +++ b/questions/blockdelay.md @@ -1,6 +1,9 @@ # 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 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) @@ -15,7 +18,9 @@ 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} +```py +summon area_effect_cloud ~ ~ ~ {Duration:100} +``` | 📝 Note | |---------| @@ -24,37 +29,45 @@ For example, the following creates an AEC that will disappear in 100 ticks (5 se 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: +```py +# 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} +```py +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"}} +```py +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}] +```py +# 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}] +``` | 📝 Note | |---------| |You can use any `spawn_egg`, but not just `bat_spawn_egg`| - - # Command block / tick function - execute at @e[type=area_effect_cloud,tag=delay,nbt={Age:99}] run summon zombie +```py +# 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. @@ -62,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"]}] +```py +# 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. +```py +# 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 dependent events/delays) or "[fake player](/wiki/questions/fakeplayer)" scores (set "fake" values for player names, recommended for player independent delays). - # Setup - scoreboard objectives add timer dummy - - # The repeating command_block - scoreboard players add @a timer 1 +```py +# Setup +scoreboard objectives add timer dummy - # 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 repeating command_block +scoreboard players add @a timer 1 - # 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 +# 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 +``` 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. +```py +# 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. +```py +# 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 - +```py +# 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) @@ -130,16 +154,20 @@ 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