Skip to content

Commit

Permalink
SsSsss
Browse files Browse the repository at this point in the history
  • Loading branch information
skylinerw committed Jun 16, 2023
1 parent c24bc29 commit f4cc898
Show file tree
Hide file tree
Showing 20 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion questions/amountitems.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ That means we can use `execute store` to save that number somewhere and then exe

## Bedrock

In the **1.18.20 beta** they added the [`hasitem`](https://minecraft.fandom.com/wiki/Target_selectors#Selecting_targets_by_items) target selector, which allows you to check for specific amounts (as [ranges](/wiki/questionss/range)) of items in entities inventories. Below is an example, check the link above for more information.
In the **1.18.20 beta** they added the [`hasitem`](https://minecraft.fandom.com/wiki/Target_selectors#Selecting_targets_by_items) target selector, which allows you to check for specific amounts (as [ranges](/wiki/questions/range)) of items in entities inventories. Below is an example, check the link above for more information.

execute @a[hasitem={item:apple,quantity=5..}] ~~~ run say I have 5 or more apples in my inventory
2 changes: 1 addition & 1 deletion questions/areas.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

_Java Syntax, but this can be applied to Bedrock just as well by changing the selector arguments to Bedrock Syntax._

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/questionss/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.

Expand Down
2 changes: 1 addition & 1 deletion questions/blockdelay.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ That means that if you have those 3 commands repeating somewhere in your world,

### Scoreboard

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/questionss/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 dependant events/delays) or "[fake player](/wiki/questions/fakeplayer)" scores (set "fake" values for player names, recommended for player independant delays).

# the repeating commandblock
scoreboard players add @a timer 1
Expand Down
2 changes: 1 addition & 1 deletion questions/blockinvert.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Do something if a command block *wasn't* successful

(This is for command blocks only. For functions, [see here](/wiki/questionss/functionconditions))
(This is for command blocks only. For functions, [see here](/wiki/questions/functionconditions))

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`.

Expand Down
2 changes: 1 addition & 1 deletion questions/changeofscore.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ If you are changing the score yourself, it is generally advised to also do the e

## The destructive method

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/questionss/itemclick), [player deaths](/wiki/questionss/playerdeaths) in minigames and more and involves resetting the score back to 0 once it has been changed.
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.
Expand Down
4 changes: 2 additions & 2 deletions questions/compasstoplayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The give command for such a compass which doesn't need a lodestone to work looks

/give @s compass{LodestoneTracked:0b,LodestonePos:{X:-460,Y:64,Z:-701},LodestoneDimension:"minecraft:overworld"}

Now, using data merge we can modify those numbers dynamically. For example, lets say you want to drop the compass to make it point to the second-nearest player, assuming the nearest player is you. The commands for something like that could look like this (using the [custom item tag](/wiki/questionss/customitemtag) `playertracker:1b` to identify such a compass):
Now, using data merge we can modify those numbers dynamically. For example, lets say you want to drop the compass to make it point to the second-nearest player, assuming the nearest player is you. The commands for something like that could look like this (using the [custom item tag](/wiki/questions/customitemtag) `playertracker:1b` to identify such a compass):

tick.mcfunction

Expand All @@ -39,4 +39,4 @@ In 1.17 we got [item modifiers](https://minecraft.fandom.com/wiki/Item_modifier)

In this case you follow the process of the 1.16 section above, but instead of storing it into an item entity you for example store it into the [command storage](https://minecraft.fandom.com/wiki/Commands/data#Storage) and then use the `copy_nbt` function in the item modifier to copy that data to the item.

_Related: [Modify an item inside the players inventory](/wiki/questionss/modifyinventory)_
_Related: [Modify an item inside the players inventory](/wiki/questions/modifyinventory)_
4 changes: 2 additions & 2 deletions questions/customitemtag.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ The key can be any string and the value of this tag can be any NBT, so long as y

/give @p stick{BlahBlahBlah:"string value!"} 1

[How to detect a specific item in more detail](/wiki/questionss/detectitem).
[How to detect a specific item in more detail](/wiki/questions/detectitem).

([Want to then select the player/dropped item/whatever you found with testfor (1.5-1.12)?](/wiki/questionss/tagentity))
([Want to then select the player/dropped item/whatever you found with testfor (1.5-1.12)?](/wiki/questions/tagentity))
4 changes: 2 additions & 2 deletions questions/detectitem.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Java

Detecting an item by some property is a relatively easy task if you know your way around NBT. If you have control over how and when the item is given, [consider using a special item tag to detect it](/wiki/questionss/customitemtag) (that post also contains useful information about how to nest the NBT, so read it before reading on).
Detecting an item by some property is a relatively easy task if you know your way around NBT. If you have control over how and when the item is given, [consider using a special item tag to detect it](/wiki/questions/customitemtag) (that post also contains useful information about how to nest the NBT, so read it before reading on).

Since not all NBT tags can be covered, this post will focus on the `id` and `Name` part of an item, assuming you're testing for a `minecraft:stick` with the name `Awesome Stick`.

Expand Down Expand Up @@ -51,7 +51,7 @@ _Only detecting the item in a players inventory is currently possible with comma

#### since 1.18.20

In the 1.18.20 beta they added the [`hasitem`](https://minecraft.fandom.com/wiki/Target_selectors#Selecting_targets_by_items) target selector, which allows you to check for specific amounts (as [ranges](/wiki/questionss/range)) of specific items in specific amounts in entities inventories. Below are some examples, check the link above for more information.
In the 1.18.20 beta they added the [`hasitem`](https://minecraft.fandom.com/wiki/Target_selectors#Selecting_targets_by_items) target selector, which allows you to check for specific amounts (as [ranges](/wiki/questions/range)) of specific items in specific amounts in entities inventories. Below are some examples, check the link above for more information.

A player with 5 or more apples in their inventory

Expand Down
4 changes: 2 additions & 2 deletions questions/findsamescoreentity.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Find an entity with the same score as another entity or player

related: [Check if a score is equal to, greater than, or less than another score](/wiki/questionss/scorecompare)
related: [Check if a score is equal to, greater than, or less than another score](/wiki/questions/scorecompare)

## Java

Expand All @@ -16,7 +16,7 @@ This method works by changing the executor to all entities that need to be check

### Method 2: Store the score in a fake player first.

This method has the advantage over the first one that it only need to evaluate the selector for the special entity once, but it has the disadvantage that it needs 2 commands. ([what is a fake player?](/wiki/questionss/fakeplayer))
This method has the advantage over the first one that it only need to evaluate the selector for the special entity once, but it has the disadvantage that it needs 2 commands. ([what is a fake player?](/wiki/questions/fakeplayer))

scoreboard players operation #fakeplayer points = @e[tag=compare,limit=1] points
execute as @a if score @s points = #fakeplayer points run I have the same points
Expand Down
2 changes: 1 addition & 1 deletion questions/functionconditions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Easiest way to do this is by prefixing the command with an `execute if entity`:

execute if entity @a[tag=TeamChange,limit=1] run say test

Notice the `limit=1` in the above command, this is purely for performance reasons so the game stops after the first matching entity it found. [If you want to check whether there are an exact amount of entities found with a selector, click here](/wiki/questionss/numplayers).
Notice the `limit=1` in the above command, this is purely for performance reasons so the game stops after the first matching entity it found. [If you want to check whether there are an exact amount of entities found with a selector, click here](/wiki/questions/numplayers).

### My condition is whether or not another command succeeds

Expand Down
4 changes: 2 additions & 2 deletions questions/highestscore.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Thanks to `scoreboard player operations` this is a fairly easy question to answe

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/questionss/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

then you execute as all the entities you want to compare, running the scoreboard operation as all of them. Here we'll use all players in the example.

execute as @a run scoreboard players operation #max score > @s score

And now you can find whoever has the same score as the fake player ([using Method #2 from here](/wiki/questionss/findsamescoreentity/)) to name your winner.
And now you can find whoever has the same score as the fake player ([using Method #2 from here](/wiki/questions/findsamescoreentity/)) to name your winner.

execute as @a if score @s score = #max score run I have the highest score!
2 changes: 1 addition & 1 deletion questions/itemclick.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ For rightclick detection we have [a lot of different ways](https://i.imgur.com/8

_Note: This works the same with the warped fungus on a stick._

Mapmakers have for many years now exploited what is technically [a bug](https://bugs.mojang.com/browse/MC-112991): Carrots on sticks have the property that when you click with one in your main hand or nothing clickable in your main hand with the CoaS in your offhand, it increases a player's "used carrot_on_a_stick" score (`minecraft.used:minecraft.carrot_on_a_stick` see [here](https://minecraft.gamepedia.com/Scoreboard#Criteria)). Testing if a player is holding a carrot on a stick with a specific tag like `{shoot_fireball:1b}` and also has `[scores={used_CoaS=1..}]` will test if a player clicks with a custom carrot on a stick. (related: [detect what item a player is holding](/wiki/questionss/detectitem))
Mapmakers have for many years now exploited what is technically [a bug](https://bugs.mojang.com/browse/MC-112991): Carrots on sticks have the property that when you click with one in your main hand or nothing clickable in your main hand with the CoaS in your offhand, it increases a player's "used carrot_on_a_stick" score (`minecraft.used:minecraft.carrot_on_a_stick` see [here](https://minecraft.gamepedia.com/Scoreboard#Criteria)). Testing if a player is holding a carrot on a stick with a specific tag like `{shoot_fireball:1b}` and also has `[scores={used_CoaS=1..}]` will test if a player clicks with a custom carrot on a stick. (related: [detect what item a player is holding](/wiki/questions/detectitem))

This is the generally preferred method of doing this if it fits your situation, as its pros outweigh the cons.

Expand Down
4 changes: 2 additions & 2 deletions questions/linkentity.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ First we need to set up a dummy scoreboard objective

scoreboard objectives add id dummy

Next, to make sure that every player gets a unique id, we need a system that assigns every player a unique score. This can be achieved by simply counting up with every subsequent player that needs a score. For this, we'll set a [fake player](/wiki/questionss/fakeplayer) score of this objective to 1 to start with.
Next, to make sure that every player gets a unique id, we need a system that assigns every player a unique score. This can be achieved by simply counting up with every subsequent player that needs a score. For this, we'll set a [fake player](/wiki/questions/fakeplayer) score of this objective to 1 to start with.

scoreboard players set $total id 1

Expand Down Expand Up @@ -45,4 +45,4 @@ If for some reason you cannot use a function, use this code for your commandbloc

_If you're on bedrock, replace `execute as @a[tag=addId] run` with `execute @a[tag=addId] ~~~`._

**And we're done, every player has a unique ID**. Now we can just copy the id score to whatever entity we want to link up using `scoreboard players operation`, and use [this method](/wiki/questionss/findsamescoreentity) to find the entity with the same score (aka the linked entity).
**And we're done, every player has a unique ID**. Now we can just copy the id score to whatever entity we want to link up using `scoreboard players operation`, and use [this method](/wiki/questions/findsamescoreentity) to find the entity with the same score (aka the linked entity).
2 changes: 1 addition & 1 deletion questions/lookat.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Check whether the player / an entity is looking at something

_This method describes how to check whether the player / an entity is **looking at something specific / predetermined**, like a specific entity or a specific position! If you're looking for a more general approach, [you'll need to use a raycast](/wiki/questionss/raycast)._
_This method describes how to check whether the player / an entity is **looking at something specific / predetermined**, like a specific entity or a specific position! If you're looking for a more general approach, [you'll need to use a raycast](/wiki/questions/raycast)._

## Java & Bedrock after 1.19.50

Expand Down
4 changes: 2 additions & 2 deletions questions/numplayers.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A command will still run (and potentially succeed once) even if `@a[team=red,lim

## Bedrock

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/questionss/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 later 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:

Expand All @@ -21,7 +21,7 @@ Using a dummy scoreboard objective named `result` and an entity with the `counte
### Method 1: Storing the found entities using `execute store`

Introduced in 1.13 and replacing the `/stats` command, the `store` subcommand of `execute` is able to store the result of the command after it in multiple ways, including into a scoreboard.
Using a dummy scoreboard objective name `result` and the [fake player](/wiki/questionss/fakeplayer) `#count`, we can count the amount of entities a command finds and then execute off of that.
Using a dummy scoreboard objective name `result` and the [fake player](/wiki/questions/fakeplayer) `#count`, we can count the amount of entities a command finds and then execute off of that.

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.
Expand Down
2 changes: 1 addition & 1 deletion questions/playerdeaths.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Detect Player Death

_Related: [Detect Player Kills](/wiki/questionss/playerkills)_
_Related: [Detect Player Kills](/wiki/questions/playerkills)_

## Java

Expand Down
4 changes: 2 additions & 2 deletions questions/playerkills.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Detect the player killing entities and players

_Related: [Detect Player Deaths](/wiki/questionss/playerdeaths)_
_Related: [Detect Player Deaths](/wiki/questions/playerdeaths)_

## Java

Expand Down Expand Up @@ -46,7 +46,7 @@ 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.
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/questionss/detectitem) how you can detect a certain item.
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/)_

Expand Down
Loading

0 comments on commit f4cc898

Please sign in to comment.