From 6842b3a1b62e9354741f327903828d36df3ee594 Mon Sep 17 00:00:00 2001 From: Vincent Foriel Date: Fri, 29 Sep 2023 11:48:55 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Added=20lobby=20compass=20+=20tweak?= =?UTF-8?q?=20lobby=20horse=20behaviors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/lobby/functions/__join__.mcfunction | 3 +- .../data/lobby/functions/__load__.mcfunction | 9 +++++ .../data/lobby/functions/__tick__.mcfunction | 3 +- .../lobby/functions/compass/main.mcfunction | 36 +++++++++++++++++++ .../lobby/functions/horse/cooldown.mcfunction | 2 +- .../lobby/functions/horse/main.mcfunction | 4 +-- .../data/lobby/tags/functions/compass.json | 5 +++ 7 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 __global__/data/lobby/functions/compass/main.mcfunction create mode 100644 __global__/data/lobby/tags/functions/compass.json diff --git a/__global__/data/lobby/functions/__join__.mcfunction b/__global__/data/lobby/functions/__join__.mcfunction index 9f2e62f..8a08888 100644 --- a/__global__/data/lobby/functions/__join__.mcfunction +++ b/__global__/data/lobby/functions/__join__.mcfunction @@ -1,2 +1,3 @@ -scoreboard players add @s lobby.horse.cooldown 0 \ No newline at end of file +scoreboard players add @s lobby.horse.cooldown 0 +scoreboard players add @s lobby.compass.select 0 \ No newline at end of file diff --git a/__global__/data/lobby/functions/__load__.mcfunction b/__global__/data/lobby/functions/__load__.mcfunction index 1e6ae3c..a1b3fe8 100644 --- a/__global__/data/lobby/functions/__load__.mcfunction +++ b/__global__/data/lobby/functions/__load__.mcfunction @@ -1,4 +1,13 @@ +# Horse ----------------------------------------------------------------------- + scoreboard objectives add lobby.horse.cooldown dummy +# Compass --------------------------------------------------------------------- + +scoreboard objectives add lobby.compass.select dummy +scoreboard objectives add lobby.compass.drop_trigger minecraft.custom:minecraft.drop + +# Others ---------------------------------------------------------------------- + scoreboard players set 20 const 20 \ No newline at end of file diff --git a/__global__/data/lobby/functions/__tick__.mcfunction b/__global__/data/lobby/functions/__tick__.mcfunction index 4413ef3..f26e9df 100644 --- a/__global__/data/lobby/functions/__tick__.mcfunction +++ b/__global__/data/lobby/functions/__tick__.mcfunction @@ -1,2 +1,3 @@ -function #lobby:horse \ No newline at end of file +function #lobby:horse +function #lobby:compass \ No newline at end of file diff --git a/__global__/data/lobby/functions/compass/main.mcfunction b/__global__/data/lobby/functions/compass/main.mcfunction new file mode 100644 index 0000000..129f68a --- /dev/null +++ b/__global__/data/lobby/functions/compass/main.mcfunction @@ -0,0 +1,36 @@ + +# Count number of compass +execute as @a[team=lobby] store result score @s tmp run clear @s compass 0 + +# If player dropped his compass -> cycle forward +scoreboard players add @a[team=lobby,scores={lobby.compass.drop_trigger=1..,tmp=0}] lobby.compass.select 1 +execute as @a[team=lobby,scores={lobby.compass.drop_trigger=1..,tmp=0}] at @s run playsound minecraft:block.stone_button.click_on master @s ~ ~ ~ 1 2 0 +scoreboard players reset * lobby.compass.drop_trigger +# If the player swapped it from hands -> cycle backward +scoreboard players remove @a[team=lobby,scores={tmp=1},nbt={Inventory:[{Slot:-106b,id:"minecraft:compass"}]}] lobby.compass.select 1 +execute as @a[team=lobby,scores={tmp=1},nbt={Inventory:[{Slot:-106b,id:"minecraft:compass"}]}] at @s run playsound minecraft:block.stone_button.click_off master @s ~ ~ ~ 1 2 0 +clear @a[team=lobby,scores={tmp=1},nbt={Inventory:[{Slot:-106b,id:"minecraft:compass"}]}] compass + +# Remove compass if duplicated +execute as @a[team=lobby,scores={tmp=2..}] run clear @s compass + +# Recompute number of compass +execute as @a[team=lobby] store result score @s tmp run clear @s compass 0 + +# Cycle limits +scoreboard players set @a[team=lobby,scores={lobby.compass.select=4..}] lobby.compass.select 0 +scoreboard players set @a[team=lobby,scores={lobby.compass.select=..-1}] lobby.compass.select 3 + +# Give compass ---------------------------------------------------------------- + +# Jump +item replace entity @a[team=lobby,scores={tmp=0,lobby.compass.select=0}] hotbar.8 with compass{display:{Name:'{"text":"JUMP","color":"dark_purple","bold":true,"italic":true}',Lore:['{"text":"This compass indicate the minigame location"}','{"text":"Drop item to select the next minigame"}','{"text":"Swap it from hands to select the previous one"}']},LodestoneDimension:"minecraft:overworld",LodestoneTracked:0b,LodestonePos:{X:-311,Y:97,Z:19}} + +# Magma run +item replace entity @a[team=lobby,scores={tmp=0,lobby.compass.select=1}] hotbar.8 with compass{display:{Name:'{"text":"MAGMA RUN","color":"gold","bold":true,"italic":true}',Lore:['{"text":"This compass indicate the minigame location"}','{"text":"Drop item to select the next minigame"}','{"text":"Swap it from hands to select the previous one"}']},LodestoneDimension:"minecraft:overworld",LodestoneTracked:0b,LodestonePos:{X:-216,Y:100,Z:17}} + +# One in the chamber +item replace entity @a[team=lobby,scores={tmp=0,lobby.compass.select=2}] hotbar.8 with compass{display:{Name:'{"text":"ONE IN THE CHAMBER","color":"red","bold":true,"italic":true}',Lore:['{"text":"This compass indicate the minigame location"}','{"text":"Drop item to select the next minigame"}','{"text":"Swap it from hands to select the previous one"}']},LodestoneDimension:"minecraft:overworld",LodestoneTracked:0b,LodestonePos:{X:-184,Y:97,Z:-97}} + +# Prophunt +item replace entity @a[team=lobby,scores={tmp=0,lobby.compass.select=3}] hotbar.8 with compass{display:{Name:'{"text":"PROPHUNT","color":"blue","bold":true,"italic":true}',Lore:['{"text":"This compass indicate the minigame location"}','{"text":"Drop item to select the next minigame"}','{"text":"Swap it from hands to select the previous one"}']},LodestoneDimension:"minecraft:overworld",LodestoneTracked:0b,LodestonePos:{X:112,Y:82,Z:66}} diff --git a/__global__/data/lobby/functions/horse/cooldown.mcfunction b/__global__/data/lobby/functions/horse/cooldown.mcfunction index 377c957..229064f 100644 --- a/__global__/data/lobby/functions/horse/cooldown.mcfunction +++ b/__global__/data/lobby/functions/horse/cooldown.mcfunction @@ -3,7 +3,7 @@ scoreboard players operation #lobby.horse.cooldown.seconds data = @s lobby.horse scoreboard players operation #lobby.horse.cooldown.seconds data /= 20 const scoreboard players add #lobby.horse.cooldown.seconds data 1 -item modify entity @s container.8 lobby:horse/cooldown +item modify entity @s container.7 lobby:horse/cooldown execute store result score @s tmp run clear @s ghast_tear{display:{Name:'{"text":"Spawn horse (cooldown)","color":"red","bold":true,"italic":true}'}} 0 execute if score @s tmp > #lobby.horse.cooldown.seconds data run clear @s ghast_tear{display:{Name:'{"text":"Spawn horse (cooldown)","color":"red","bold":true,"italic":true}'}} diff --git a/__global__/data/lobby/functions/horse/main.mcfunction b/__global__/data/lobby/functions/horse/main.mcfunction index 471c47f..afe51cb 100644 --- a/__global__/data/lobby/functions/horse/main.mcfunction +++ b/__global__/data/lobby/functions/horse/main.mcfunction @@ -1,7 +1,7 @@ -item replace entity @a[team=lobby,scores={lobby.horse.cooldown=0}] hotbar.8 with minecraft:horse_spawn_egg{CanPlaceOn:["#lib:all"],display:{Name:'{"text":"Spawn horse","color":"white","bold":true,"italic":true}'},EntityTag:{id:"minecraft:horse",Variant:0,Tags:["lobby.horse","lobby.horse.new"],Tame:1,SaddleItem:{id:"minecraft:saddle",Count:1}}} +item replace entity @a[team=lobby,scores={lobby.horse.cooldown=0}] hotbar.7 with minecraft:horse_spawn_egg{CanPlaceOn:["#lib:all"],display:{Name:'{"text":"Spawn horse","color":"white","bold":true,"italic":true}'},EntityTag:{id:"minecraft:horse",Variant:0,Tags:["lobby.horse","lobby.horse.new"],Tame:1,SaddleItem:{id:"minecraft:saddle",Count:1}}} -item replace entity @a[team=lobby,scores={lobby.horse.cooldown=1..}] hotbar.8 with minecraft:ghast_tear{display:{Name:'{"text":"Spawn horse (cooldown)","color":"red","bold":true,"italic":true}'},CustomModelData:1} +item replace entity @a[team=lobby,scores={lobby.horse.cooldown=1..}] hotbar.7 with minecraft:ghast_tear{display:{Name:'{"text":"Spawn horse (cooldown)","color":"red","bold":true,"italic":true}'},CustomModelData:1} execute as @a[team=lobby] store result score @s tmp run clear @s horse_spawn_egg 0 execute as @a[team=lobby] if score @s tmp matches 2.. run clear @s diff --git a/__global__/data/lobby/tags/functions/compass.json b/__global__/data/lobby/tags/functions/compass.json new file mode 100644 index 0000000..6859859 --- /dev/null +++ b/__global__/data/lobby/tags/functions/compass.json @@ -0,0 +1,5 @@ +{ + "values": [ + "lobby:compass/main" + ] +}