From 43f615850c171fb805b6b337f6d576a7619fcc25 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Wed, 24 Dec 2025 23:28:09 +0000 Subject: [PATCH] add stationary ghast datapack --- .../data/minecraft/tags/function/load.json | 5 +++ .../data/minecraft/tags/function/tick.json | 5 +++ .../advancement/stationary_happy_ghast.json | 32 +++++++++++++++++++ .../function/load.mcfunction | 2 ++ .../function/park.mcfunction | 1 + .../function/parkedghast.mcfunction | 3 ++ .../function/tick.mcfunction | 5 +++ .../function/trigger.mcfunction | 17 ++++++++++ .../function/unpark.mcfunction | 3 ++ src/stationary_happy_ghast/pack.mcmeta | 9 ++++++ 10 files changed, 82 insertions(+) create mode 100644 src/stationary_happy_ghast/data/minecraft/tags/function/load.json create mode 100644 src/stationary_happy_ghast/data/minecraft/tags/function/tick.json create mode 100644 src/stationary_happy_ghast/data/stationary_happy_ghast/advancement/stationary_happy_ghast.json create mode 100644 src/stationary_happy_ghast/data/stationary_happy_ghast/function/load.mcfunction create mode 100644 src/stationary_happy_ghast/data/stationary_happy_ghast/function/park.mcfunction create mode 100644 src/stationary_happy_ghast/data/stationary_happy_ghast/function/parkedghast.mcfunction create mode 100644 src/stationary_happy_ghast/data/stationary_happy_ghast/function/tick.mcfunction create mode 100644 src/stationary_happy_ghast/data/stationary_happy_ghast/function/trigger.mcfunction create mode 100644 src/stationary_happy_ghast/data/stationary_happy_ghast/function/unpark.mcfunction create mode 100644 src/stationary_happy_ghast/pack.mcmeta diff --git a/src/stationary_happy_ghast/data/minecraft/tags/function/load.json b/src/stationary_happy_ghast/data/minecraft/tags/function/load.json new file mode 100644 index 0000000..f4bed86 --- /dev/null +++ b/src/stationary_happy_ghast/data/minecraft/tags/function/load.json @@ -0,0 +1,5 @@ +{ + "values": [ + "stationary_happy_ghast:load" + ] +} \ No newline at end of file diff --git a/src/stationary_happy_ghast/data/minecraft/tags/function/tick.json b/src/stationary_happy_ghast/data/minecraft/tags/function/tick.json new file mode 100644 index 0000000..79ace2b --- /dev/null +++ b/src/stationary_happy_ghast/data/minecraft/tags/function/tick.json @@ -0,0 +1,5 @@ +{ + "values": [ + "stationary_happy_ghast:tick" + ] +} \ No newline at end of file diff --git a/src/stationary_happy_ghast/data/stationary_happy_ghast/advancement/stationary_happy_ghast.json b/src/stationary_happy_ghast/data/stationary_happy_ghast/advancement/stationary_happy_ghast.json new file mode 100644 index 0000000..99eb435 --- /dev/null +++ b/src/stationary_happy_ghast/data/stationary_happy_ghast/advancement/stationary_happy_ghast.json @@ -0,0 +1,32 @@ +{ + "display": { + "icon": { + "id": "minecraft:dried_ghast" + }, + "title": "Stationary Happy Ghasts", + "description": [ + "", + { + "text": "Makes happy ghasts not wander when dismounted. Also disables their ability to follow snowballs.\n", + "color": "gold" + }, + { + "text": "/trigger stationary_happy_ghast while near a happy ghast to toggle this behavior.\n", + "color": "yellow" + } + ], + "show_toast": false, + "announce_to_chat": false + }, + "parent": "minecraft:root", + "criteria": { + "tick": { + "trigger": "minecraft:tick" + } + }, + "requirements": [ + [ + "tick" + ] + ] +} \ No newline at end of file diff --git a/src/stationary_happy_ghast/data/stationary_happy_ghast/function/load.mcfunction b/src/stationary_happy_ghast/data/stationary_happy_ghast/function/load.mcfunction new file mode 100644 index 0000000..421152f --- /dev/null +++ b/src/stationary_happy_ghast/data/stationary_happy_ghast/function/load.mcfunction @@ -0,0 +1,2 @@ +scoreboard objectives add ghastflymode trigger +scoreboard objectives add ghast_parking_state dummy \ No newline at end of file diff --git a/src/stationary_happy_ghast/data/stationary_happy_ghast/function/park.mcfunction b/src/stationary_happy_ghast/data/stationary_happy_ghast/function/park.mcfunction new file mode 100644 index 0000000..fabaf4b --- /dev/null +++ b/src/stationary_happy_ghast/data/stationary_happy_ghast/function/park.mcfunction @@ -0,0 +1 @@ +scoreboard players set @s ghast_parking_state 1 \ No newline at end of file diff --git a/src/stationary_happy_ghast/data/stationary_happy_ghast/function/parkedghast.mcfunction b/src/stationary_happy_ghast/data/stationary_happy_ghast/function/parkedghast.mcfunction new file mode 100644 index 0000000..b4859bc --- /dev/null +++ b/src/stationary_happy_ghast/data/stationary_happy_ghast/function/parkedghast.mcfunction @@ -0,0 +1,3 @@ +execute as @s[nbt={still_timeout:10}] as @s[nbt={NoAI:1b}] run data modify entity @s NoAI set value 0b + +execute unless entity @s[nbt={still_timeout:10}] unless entity @s[nbt={NoAI:1b}] run data modify entity @s NoAI set value 1b \ No newline at end of file diff --git a/src/stationary_happy_ghast/data/stationary_happy_ghast/function/tick.mcfunction b/src/stationary_happy_ghast/data/stationary_happy_ghast/function/tick.mcfunction new file mode 100644 index 0000000..1230a7b --- /dev/null +++ b/src/stationary_happy_ghast/data/stationary_happy_ghast/function/tick.mcfunction @@ -0,0 +1,5 @@ +execute as @a[scores={ghastflymode=1..}] at @s run function stationary_happy_ghast:trigger +scoreboard players enable @a ghastflymode + +#parked +execute as @e[type=happy_ghast,scores={ghast_parking_state=1}] at @s run function stationary_happy_ghast:parkedghast \ No newline at end of file diff --git a/src/stationary_happy_ghast/data/stationary_happy_ghast/function/trigger.mcfunction b/src/stationary_happy_ghast/data/stationary_happy_ghast/function/trigger.mcfunction new file mode 100644 index 0000000..77d7d24 --- /dev/null +++ b/src/stationary_happy_ghast/data/stationary_happy_ghast/function/trigger.mcfunction @@ -0,0 +1,17 @@ +execute as @e[type=happy_ghast,distance=..10,sort=nearest,limit=1] if score @s ghast_parking_state matches 1 run tag @s add _was1 +execute as @e[type=happy_ghast,distance=..10,sort=nearest,limit=1] unless score @s ghast_parking_state matches 1 run tag @s add _was0 + +execute as @e[type=happy_ghast,tag=_was1,limit=1,sort=nearest] run function stationary_happy_ghast:unpark +execute as @e[type=happy_ghast,tag=_was0,limit=1,sort=nearest] run function stationary_happy_ghast:park + +execute if entity @e[type=happy_ghast,distance=..10,sort=nearest,limit=1,tag=_was1] run tellraw @a[scores={ghastflymode=1..}] {"text":"Your ghast is now wandering. It will move freely when you dismount.","color":"yellow"} +execute if entity @e[type=happy_ghast,distance=..10,sort=nearest,limit=1,tag=_was0] run tellraw @a[scores={ghastflymode=1..}] {"text":"Your ghast is now stationary. It will no longer wander when you dismount.","color":"yellow"} + +tag @e[type=happy_ghast,tag=_was1] remove _was1 +tag @e[type=happy_ghast,tag=_was0] remove _was0 + +execute unless entity @e[type=happy_ghast,distance=..10] run tellraw @s {"text":"You need to be close with your ghast to use this command.","color":"red"} + +scoreboard players reset @s ghastflymode + + diff --git a/src/stationary_happy_ghast/data/stationary_happy_ghast/function/unpark.mcfunction b/src/stationary_happy_ghast/data/stationary_happy_ghast/function/unpark.mcfunction new file mode 100644 index 0000000..e3d134e --- /dev/null +++ b/src/stationary_happy_ghast/data/stationary_happy_ghast/function/unpark.mcfunction @@ -0,0 +1,3 @@ +scoreboard players reset @s ghast_parking_state + +data modify entity @s NoAI set value 0b \ No newline at end of file diff --git a/src/stationary_happy_ghast/pack.mcmeta b/src/stationary_happy_ghast/pack.mcmeta new file mode 100644 index 0000000..896342b --- /dev/null +++ b/src/stationary_happy_ghast/pack.mcmeta @@ -0,0 +1,9 @@ +{ + "pack": { + "pack_format": 48, + "supported_formats": {"min_inclusive": 48, "max_inclusive": 88}, + "min_format": 48, + "max_format": 88, + "description": [{"text":"Prevents your happy ghast from flying away from you!","color":"gold"}] + } +} \ No newline at end of file