Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Seayay committed Nov 14, 2024
1 parent 7f0c2af commit 736011f
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 0 deletions.
13 changes: 13 additions & 0 deletions data/gmbmiwir/function/load.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Create a new objective to detect player rejoin the game.
scoreboard objectives add gmbmiwir.leave minecraft.custom:minecraft.leave_game

# Create a new objective to record the player's remaining invincibility time.
scoreboard objectives add gmbmiwir.timer dummy

# Create new objectives to keep track of how long the player has had the effect.
scoreboard objectives add gmbmiwir.potion.level dummy
scoreboard objectives add gmbmiwir.potion.time dummy
# scoreboard objectives add gmbmiwir.potion.hideParticles dummy
scoreboard players set $-1 gmbmiwir.potion.time -1
scoreboard players set $20 gmbmiwir.potion.time 20
scoreboard players set $0 gmbmiwir.potion.level 0
3 changes: 3 additions & 0 deletions data/gmbmiwir/function/resistance_give.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
scoreboard players set @s gmbmiwir.timer 60
effect clear @s resistance
effect give @s resistance 3 255 true
9 changes: 9 additions & 0 deletions data/gmbmiwir/function/resistance_regive.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
effect clear @s resistance
scoreboard players operation @s gmbmiwir.potion.time /= $20 gmbmiwir.potion.time
data remove storage gmbmiwir:resistance_store duration
data remove storage gmbmiwir:resistance_store level
execute store result storage gmbmiwir:resistance_store duration int 1 run scoreboard players get @s gmbmiwir.potion.time
execute store result storage gmbmiwir:resistance_store level int 1 if score @s gmbmiwir.potion.level matches 0..127 run scoreboard players get @s gmbmiwir.potion.level
# 懒得修
# execute store result storage gmbmiwir:resistance_store hideParticles int 1 run scoreboard players get @s gmbmiwir.potion.hideParticles
execute as @s run function gmbmiwir:resistance_regive_true with storage gmbmiwir:resistance_store
3 changes: 3 additions & 0 deletions data/gmbmiwir/function/resistance_regive_true.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$effect give @s resistance $(duration) $(level)
# 懒得修
# $(hideParticles)
4 changes: 4 additions & 0 deletions data/gmbmiwir/function/resistance_store.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
execute store result score @s gmbmiwir.potion.time run data get entity @s active_effects[{id:"minecraft:resistance"}].duration
execute store result score @s gmbmiwir.potion.level run data get entity @s active_effects[{id:"minecraft:resistance"}].amplifier
# execute store result score @s gmbmiwir.potion.hideParticles run data get entity @s active_effects[{id:"minecraft:resistance"}].show_particles
# scoreboard players set @s[scores={gmbmiwir.potion.hideParticles=0}] gmbmiwir.potion.hideParticles 1
10 changes: 10 additions & 0 deletions data/gmbmiwir/function/tick.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Prevents the value from being null
scoreboard players add @a gmbmiwir.leave 0
scoreboard players add @a gmbmiwir.timer 0
# If rejoin
execute as @a[scores={gmbmiwir.leave=0,gmbmiwir.timer=-2}] run function gmbmiwir:resistance_store
execute as @a[scores={gmbmiwir.leave=1}] run function gmbmiwir:resistance_give
# Regive resistance
scoreboard players remove @a[scores={gmbmiwir.timer=-1..}] gmbmiwir.timer 1
execute as @a[scores={gmbmiwir.timer=-1,gmbmiwir.potion.level=0..127,gmbmiwir.potion.time=1..}] run function gmbmiwir:resistance_regive
scoreboard players set @a gmbmiwir.leave 0
4 changes: 4 additions & 0 deletions data/minecraft/tags/function/load.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"values": ["gmbmiwir:load"],
"replace": false
}
4 changes: 4 additions & 0 deletions data/minecraft/tags/function/tick.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"values": ["gmbmiwir:tick"],
"replace": false
}
11 changes: 11 additions & 0 deletions pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"pack": {
"pack_format": 59,
"supported_formats": {
"min_inclusive": 59,
"max_inclusive": 100
},
"description": "Give me back my InvulnerableTime when I rejoin"
}
}

0 comments on commit 736011f

Please sign in to comment.