-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add functions for scoreboards / part 3
- Loading branch information
Showing
8 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
3-scoreboards/data/fennifith/functions/animals/load.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
say Hello, world! | ||
|
||
# create a new scoreboard to track the number of animals a player has spawned | ||
scoreboard objectives add fennifith.animals_spawned dummy | ||
|
||
# create a new scoreboard tracking the "carrot_on_a_stick" statistic | ||
scoreboard objectives add fennifith.animals_carrot_stick minecraft.used:minecraft.carrot_on_a_stick |
13 changes: 13 additions & 0 deletions
13
3-scoreboards/data/fennifith/functions/animals/set_max_value.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# initially, set the max value to 0 | ||
scoreboard players set $max fennifith.animals_id 0 | ||
|
||
# for every pig entity in the game... | ||
# | run a scoreboard operation... | ||
# | | set $max in fennifith.animals_id... | ||
# | | | if the following value is larger... | ||
# | | | | to @s in fennifith.animals_id. | ||
# | | | | | | ||
execute as @e[type=pig] run scoreboard players operation $max fennifith.animals_id > @s fennifith.animals_id | ||
|
||
# Tell the player what the max value is | ||
tellraw @s ["The maximum value in the animals_id scoreboard is: ",{"score":{"name":"$max","objective":"fennifith.animals_id"}}] |
11 changes: 11 additions & 0 deletions
11
3-scoreboards/data/fennifith/functions/animals/set_unique_values.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# set a $counter variable to 0 | ||
scoreboard players set $counter fennifith.animals_id 0 | ||
|
||
# for every entity in @e[type=pig]... | ||
# | store the result as the entity's "fennifith.animals_id" score | ||
# | | add "1" to the $counter variable | ||
# | | | | ||
execute as @e[type=pig] store result score @s fennifith.animals_id run scoreboard players add $counter fennifith.animals_id 1 | ||
|
||
# Tell the player what the current counter value is | ||
tellraw @s ["Unique ids have been given to ",{"score":{"name":"$counter","objective":"fennifith.animals_id"}}," entities!"] |
11 changes: 11 additions & 0 deletions
11
3-scoreboards/data/fennifith/functions/animals/spawn.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
summon cow | ||
summon sheep | ||
summon pig | ||
summon goat | ||
summon llama | ||
|
||
# Add 5 animals to the player's summoned animals score | ||
scoreboard players add @s fennifith.animals_spawned 5 | ||
|
||
# Tell the player how many animals they have summoned | ||
tellraw @s ["You have summoned ",{"score":{"name":"@s","objective":"fennifith.animals_spawned"}}," animals!"] |
11 changes: 11 additions & 0 deletions
11
3-scoreboards/data/fennifith/functions/animals/tick.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# for every player in the game... | ||
# | if their score for "carrot_stick" is >= 1 | ||
# | | spawn some animals | ||
# | | | | ||
execute as @a if score @s fennifith.animals_carrot_stick matches 1.. run function fennifith:animals/spawn | ||
|
||
# set the "carrot_stick" score for all players to 0 | ||
scoreboard players set @a fennifith.animals_carrot_stick 0 | ||
|
||
# create a dummy objective to store unique pig entity ids | ||
scoreboard objectives add fennifith.animals_id dummy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"values": ["fennifith:animals/load"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"values": ["fennifith:animals/tick"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"pack": { | ||
"pack_format": 10, | ||
"description": "Spawns a bunch of animals around the player" | ||
} | ||
} |