Skip to content

Commit

Permalink
✨ Added lobby compass + tweak lobby horse behaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
VForiel committed Sep 29, 2023
1 parent 6cc7670 commit 6842b3a
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 5 deletions.
3 changes: 2 additions & 1 deletion __global__/data/lobby/functions/__join__.mcfunction
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

scoreboard players add @s lobby.horse.cooldown 0
scoreboard players add @s lobby.horse.cooldown 0
scoreboard players add @s lobby.compass.select 0
9 changes: 9 additions & 0 deletions __global__/data/lobby/functions/__load__.mcfunction
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion __global__/data/lobby/functions/__tick__.mcfunction
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

function #lobby:horse
function #lobby:horse
function #lobby:compass
36 changes: 36 additions & 0 deletions __global__/data/lobby/functions/compass/main.mcfunction
Original file line number Diff line number Diff line change
@@ -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}}
2 changes: 1 addition & 1 deletion __global__/data/lobby/functions/horse/cooldown.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -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}'}}
Expand Down
4 changes: 2 additions & 2 deletions __global__/data/lobby/functions/horse/main.mcfunction
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions __global__/data/lobby/tags/functions/compass.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"lobby:compass/main"
]
}

0 comments on commit 6842b3a

Please sign in to comment.