From 5c55940e2ca3c5d2b04d3594b4ee55eed4e8ea22 Mon Sep 17 00:00:00 2001 From: Peter Svensson Date: Fri, 14 Jun 2024 22:57:40 +0200 Subject: [PATCH] rev 1.5 - 1.20.5 - 1.21 compatibility: new datapack format - all versions: fixed bug where multiple dragons spawned simultaneously for creative users when the admin menu allowed non-book spawning - all versions: the fireball cooldown is now configurable in the admin menu --- 1_20_5/data/minecraft/tags/function/load.json | 5 ++ 1_20_5/data/minecraft/tags/function/tick.json | 5 ++ .../ridedragon/functions/admin.mcfunction | 14 +++++ .../ridedragon/functions/give_book.mcfunction | 1 + .../functions/silence_dragon.mcfunction | 2 + .../functions/summon_dragon.mcfunction | 20 +++++++ .../functions/vanish_dragon.mcfunction | 4 ++ .../z_admin/book_from_help_toggle.mcfunction | 12 ++++ .../z_admin/can_fire_toggle.mcfunction | 12 ++++ .../z_admin/can_summon_toggle.mcfunction | 12 ++++ .../z_admin/dragon_health_decrease.mcfunction | 11 ++++ .../z_admin/dragon_health_increase.mcfunction | 11 ++++ .../fireball_cooldown_decrease.mcfunction | 11 ++++ .../fireball_cooldown_increase.mcfunction | 11 ++++ .../summon_without_book_toggle.mcfunction | 12 ++++ .../functions/z_admin/vanish_all.mcfunction | 3 + .../functions/z_dragon_cleanup.mcfunction | 6 ++ .../z_dragon_cleanup_visible.mcfunction | 3 + .../functions/z_dragon_motion.mcfunction | 26 +++++++++ .../ridedragon/functions/z_enable.mcfunction | 10 ++++ .../z_fireball_get_motion.mcfunction | 22 +++++++ .../functions/z_help/credits.mcfunction | 10 ++++ .../functions/z_help/get_book.mcfunction | 7 +++ .../functions/z_help/main.mcfunction | 10 ++++ .../functions/z_help_trigger.mcfunction | 14 +++++ .../ridedragon/functions/z_init.mcfunction | 40 +++++++++++++ .../functions/z_launch_fireball.mcfunction | 30 ++++++++++ .../ridedragon/functions/z_main.mcfunction | 8 +++ .../functions/z_no_player_motion.mcfunction | 8 +++ .../functions/z_player_motion.mcfunction | 26 +++++++++ .../functions/z_silence_toggle.mcfunction | 6 ++ .../functions/z_silence_trigger.mcfunction | 7 +++ .../functions/z_summon_trigger.mcfunction | 20 +++++++ .../functions/z_vanish_trigger.mcfunction | 8 +++ 1_20_5/data/ridedragon/loot_tables/book.json | 57 +++++++++++++++++++ .../predicates/book_holder_mainhand.json | 18 ++++++ .../predicates/book_holder_offhand.json | 19 +++++++ .../predicates/is_holding_trigger_item.json | 15 +++++ 1_21_0/data/minecraft/tags/function/load.json | 5 ++ 1_21_0/data/minecraft/tags/function/tick.json | 5 ++ .../data/ridedragon/function/admin.mcfunction | 14 +++++ .../ridedragon/function/give_book.mcfunction | 1 + .../function/silence_dragon.mcfunction | 2 + .../function/summon_dragon.mcfunction | 20 +++++++ .../function/vanish_dragon.mcfunction | 4 ++ .../z_admin/book_from_help_toggle.mcfunction | 12 ++++ .../z_admin/can_fire_toggle.mcfunction | 12 ++++ .../z_admin/can_summon_toggle.mcfunction | 12 ++++ .../z_admin/dragon_health_decrease.mcfunction | 11 ++++ .../z_admin/dragon_health_increase.mcfunction | 11 ++++ .../fireball_cooldown_decrease.mcfunction | 11 ++++ .../fireball_cooldown_increase.mcfunction | 11 ++++ .../summon_without_book_toggle.mcfunction | 12 ++++ .../function/z_admin/vanish_all.mcfunction | 3 + .../function/z_dragon_cleanup.mcfunction | 6 ++ .../z_dragon_cleanup_visible.mcfunction | 3 + .../function/z_dragon_motion.mcfunction | 26 +++++++++ .../ridedragon/function/z_enable.mcfunction | 10 ++++ .../function/z_fireball_get_motion.mcfunction | 22 +++++++ .../function/z_help/credits.mcfunction | 10 ++++ .../function/z_help/get_book.mcfunction | 7 +++ .../function/z_help/main.mcfunction | 10 ++++ .../function/z_help_trigger.mcfunction | 14 +++++ .../ridedragon/function/z_init.mcfunction | 40 +++++++++++++ .../function/z_launch_fireball.mcfunction | 30 ++++++++++ .../ridedragon/function/z_main.mcfunction | 8 +++ .../function/z_no_player_motion.mcfunction | 8 +++ .../function/z_player_motion.mcfunction | 26 +++++++++ .../function/z_silence_toggle.mcfunction | 6 ++ .../function/z_silence_trigger.mcfunction | 7 +++ .../function/z_summon_trigger.mcfunction | 20 +++++++ .../function/z_vanish_trigger.mcfunction | 8 +++ 1_21_0/data/ridedragon/loot_table/book.json | 57 +++++++++++++++++++ .../predicate/book_holder_mainhand.json | 18 ++++++ .../predicate/book_holder_offhand.json | 19 +++++++ .../predicate/is_holding_trigger_item.json | 15 +++++ Changes.txt | 8 +++ README.md | 3 +- data/ridedragon/functions/admin.mcfunction | 1 + .../functions/summon_dragon.mcfunction | 2 + .../z_admin/dragon_health_increase.mcfunction | 2 +- .../fireball_cooldown_decrease.mcfunction | 11 ++++ .../fireball_cooldown_increase.mcfunction | 11 ++++ data/ridedragon/functions/z_init.mcfunction | 1 + .../functions/z_launch_fireball.mcfunction | 5 +- pack.mcmeta | 41 +++++++++++-- 86 files changed, 1107 insertions(+), 10 deletions(-) create mode 100644 1_20_5/data/minecraft/tags/function/load.json create mode 100644 1_20_5/data/minecraft/tags/function/tick.json create mode 100644 1_20_5/data/ridedragon/functions/admin.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/give_book.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/silence_dragon.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/summon_dragon.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/vanish_dragon.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_admin/book_from_help_toggle.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_admin/can_fire_toggle.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_admin/can_summon_toggle.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_admin/dragon_health_decrease.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_admin/dragon_health_increase.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_admin/fireball_cooldown_decrease.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_admin/fireball_cooldown_increase.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_admin/summon_without_book_toggle.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_admin/vanish_all.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_dragon_cleanup.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_dragon_cleanup_visible.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_dragon_motion.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_enable.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_fireball_get_motion.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_help/credits.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_help/get_book.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_help/main.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_help_trigger.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_init.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_launch_fireball.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_main.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_no_player_motion.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_player_motion.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_silence_toggle.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_silence_trigger.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_summon_trigger.mcfunction create mode 100644 1_20_5/data/ridedragon/functions/z_vanish_trigger.mcfunction create mode 100644 1_20_5/data/ridedragon/loot_tables/book.json create mode 100644 1_20_5/data/ridedragon/predicates/book_holder_mainhand.json create mode 100644 1_20_5/data/ridedragon/predicates/book_holder_offhand.json create mode 100644 1_20_5/data/ridedragon/predicates/is_holding_trigger_item.json create mode 100644 1_21_0/data/minecraft/tags/function/load.json create mode 100644 1_21_0/data/minecraft/tags/function/tick.json create mode 100644 1_21_0/data/ridedragon/function/admin.mcfunction create mode 100644 1_21_0/data/ridedragon/function/give_book.mcfunction create mode 100644 1_21_0/data/ridedragon/function/silence_dragon.mcfunction create mode 100644 1_21_0/data/ridedragon/function/summon_dragon.mcfunction create mode 100644 1_21_0/data/ridedragon/function/vanish_dragon.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_admin/book_from_help_toggle.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_admin/can_fire_toggle.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_admin/can_summon_toggle.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_admin/dragon_health_decrease.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_admin/dragon_health_increase.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_admin/fireball_cooldown_decrease.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_admin/fireball_cooldown_increase.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_admin/summon_without_book_toggle.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_admin/vanish_all.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_dragon_cleanup.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_dragon_cleanup_visible.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_dragon_motion.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_enable.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_fireball_get_motion.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_help/credits.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_help/get_book.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_help/main.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_help_trigger.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_init.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_launch_fireball.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_main.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_no_player_motion.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_player_motion.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_silence_toggle.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_silence_trigger.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_summon_trigger.mcfunction create mode 100644 1_21_0/data/ridedragon/function/z_vanish_trigger.mcfunction create mode 100644 1_21_0/data/ridedragon/loot_table/book.json create mode 100644 1_21_0/data/ridedragon/predicate/book_holder_mainhand.json create mode 100644 1_21_0/data/ridedragon/predicate/book_holder_offhand.json create mode 100644 1_21_0/data/ridedragon/predicate/is_holding_trigger_item.json create mode 100644 data/ridedragon/functions/z_admin/fireball_cooldown_decrease.mcfunction create mode 100644 data/ridedragon/functions/z_admin/fireball_cooldown_increase.mcfunction diff --git a/1_20_5/data/minecraft/tags/function/load.json b/1_20_5/data/minecraft/tags/function/load.json new file mode 100644 index 0000000..79a50ff --- /dev/null +++ b/1_20_5/data/minecraft/tags/function/load.json @@ -0,0 +1,5 @@ +{ + "values":[ + "ridedragon:z_init" + ] +} diff --git a/1_20_5/data/minecraft/tags/function/tick.json b/1_20_5/data/minecraft/tags/function/tick.json new file mode 100644 index 0000000..ded7e67 --- /dev/null +++ b/1_20_5/data/minecraft/tags/function/tick.json @@ -0,0 +1,5 @@ +{ + "values":[ + "ridedragon:z_main" + ] +} diff --git a/1_20_5/data/ridedragon/functions/admin.mcfunction b/1_20_5/data/ridedragon/functions/admin.mcfunction new file mode 100644 index 0000000..a6c694d --- /dev/null +++ b/1_20_5/data/ridedragon/functions/admin.mcfunction @@ -0,0 +1,14 @@ +# +# Description: Display admin options in chat +# Called by: Player +# Entity @s: Player +# +tellraw @s [{"text":"Rideable Dragons - Admin Options","color":"yellow","bold":true}] +tellraw @s [{"text":"Get book from help: ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.book_help", "color":"green", "clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/book_from_help_toggle"}, "hoverEvent":{"action":"show_text", "contents":{"text":"Click to toggle", "color":"yellow"}}}] +tellraw @s [{"text":"Survival players can summon dragons: ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.can_summon", "color":"green", "clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/can_summon_toggle"}, "hoverEvent":{"action":"show_text", "contents":{"text":"Click to toggle", "color":"yellow"}}}] +tellraw @s [{"text":"Summon without the ","color":"aqua"},{"text":"Book of Dragons","color":"light_purple"},{"text":": ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.summon_without_book", "color":"green", "clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/summon_without_book_toggle"}, "hoverEvent":{"action":"show_text", "contents":{"text":"Click to toggle", "color":"yellow"}}}] +tellraw @s [{"text":"Players can fire dragon fireballs: ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.can_fire", "color":"green", "clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/can_fire_toggle"}, "hoverEvent":{"action":"show_text", "contents":{"text":"Click to toggle", "color":"yellow"}}}] +tellraw @s [{"text":"Fireball cooldown (1/20s): ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.fire_cooldown"},{"text":" (","color":"aqua"},{"text":" + ", "color":"green","clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/fireball_cooldown_increase"},"hoverEvent":{"action":"show_text", "contents":{"text":"Click to increase", "color":"yellow"}}},{"text":"/","color":"aqua"},{"text":" - ", "color":"green","clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/fireball_cooldown_decrease"},"hoverEvent":{"action":"show_text", "contents":{"text":"Click to decrease", "color":"yellow"}}},{"text":")","color":"aqua"}] +tellraw @s [{"text":"Initial dragon health : ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.dragon_health"},{"text":" (","color":"aqua"},{"text":" + ", "color":"green","clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/dragon_health_increase"},"hoverEvent":{"action":"show_text", "contents":{"text":"Click to increase", "color":"yellow"}}},{"text":"/","color":"aqua"},{"text":" - ", "color":"green","clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/dragon_health_decrease"},"hoverEvent":{"action":"show_text", "contents":{"text":"Click to decrease", "color":"yellow"}}},{"text":")","color":"aqua"}] +tellraw @s [{"text":"Vanish all tame tragons", "color":"red", "clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/vanish_all"}, "hoverEvent":{"action":"show_text", "contents":{"text":"Click to vanish all loaded tame dragons", "color":"red"}}}] +tellraw @s [{"text":"--------------------------","color":"yellow","bold":true}] diff --git a/1_20_5/data/ridedragon/functions/give_book.mcfunction b/1_20_5/data/ridedragon/functions/give_book.mcfunction new file mode 100644 index 0000000..b22d06c --- /dev/null +++ b/1_20_5/data/ridedragon/functions/give_book.mcfunction @@ -0,0 +1 @@ +loot give @p loot ridedragon:book diff --git a/1_20_5/data/ridedragon/functions/silence_dragon.mcfunction b/1_20_5/data/ridedragon/functions/silence_dragon.mcfunction new file mode 100644 index 0000000..4023192 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/silence_dragon.mcfunction @@ -0,0 +1,2 @@ + +execute as @e[type=ender_dragon,tag=dragonvisible,distance=..10,sort=nearest,limit=1] at @s run function ridedragon:z_silence_toggle diff --git a/1_20_5/data/ridedragon/functions/summon_dragon.mcfunction b/1_20_5/data/ridedragon/functions/summon_dragon.mcfunction new file mode 100644 index 0000000..bc57dd7 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/summon_dragon.mcfunction @@ -0,0 +1,20 @@ +# Step the global counter. It is used as a pseudo-uuid that can be stored in the entity data. +scoreboard players add #rd_global_cnt rd_id 1 + +summon minecraft:horse ~ ~1 ~ {NoAI:1b,Invulnerable:1b,Tags:["dragonseat","dragon_temp"],DeathLootTable:"minecraft:empty",Attributes:[{Name:"generic.knockback_resistance",Base:10000f}],active_effects:[{id:invisibility,amplifier:0,duration:2147483647,show_particles:0b}],Silent:1b} +scoreboard players operation @e[type=minecraft:horse,tag=dragon_temp,distance=..2,limit=1] rd_id = #rd_global_cnt rd_id +tag @e[type=minecraft:horse,tag=dragon_temp,distance=..2,limit=1] remove dragon_temp + +#summon minecraft:armor_stand ~ ~1 ~ {Tags:["dragonhelper","dragon_temp"],NoGravity:1b,Invisible:0b,Invulnerable:1b,Attributes:[{Name:"generic.knockback_resistance",Base:10000f}],CustomName:'["",{"text":"Ender Dragon","color":"dark_purple"}]',ShowParticles:0b} +summon minecraft:marker ~ ~1 ~ {Tags:["dragonhelper","dragon_temp"]} +scoreboard players operation @e[type=minecraft:marker,tag=dragon_temp,distance=..2,limit=1] rd_id = #rd_global_cnt rd_id +tag @e[type=minecraft:marker,tag=dragon_temp,distance=..2,limit=1] remove dragon_temp + +# Set HurtTime to -1 to keep the knockback effect of the dragon disabled. +summon minecraft:ender_dragon ~ ~0.15 ~ {Tags:["dragonvisible","dragon_temp"],Health:5,HurtTime:-1} +data modify entity @e[tag=dragon_temp,limit=1] Health set from storage ridedragon:settings rd_admin.dragon_health +scoreboard players operation @e[type=minecraft:ender_dragon,tag=dragon_temp,distance=..2,limit=1] rd_id = #rd_global_cnt rd_id +scoreboard players set @e[tag=dragon_temp,limit=1] rd_fire_cooldown 0 +tag @e[type=minecraft:ender_dragon,tag=dragon_temp,distance=..2,limit=1] remove dragon_temp + +return 1 diff --git a/1_20_5/data/ridedragon/functions/vanish_dragon.mcfunction b/1_20_5/data/ridedragon/functions/vanish_dragon.mcfunction new file mode 100644 index 0000000..0373406 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/vanish_dragon.mcfunction @@ -0,0 +1,4 @@ +scoreboard players operation #rd_selected_id rd_id = @e[type=minecraft:ender_dragon,tag=dragonvisible,distance=..10,sort=nearest,limit=1] rd_id +execute as @e[type=minecraft:ender_dragon,tag=dragonvisible,distance=..10] if score @s rd_id = #rd_selected_id rd_id run kill @s +execute as @e[type=minecraft:horse,tag=dragonseat,distance=..17] if score @s rd_id = #rd_selected_id rd_id run kill @s +execute as @e[type=minecraft:marker,tag=dragonhelper,distance=..17] if score @s rd_id = #rd_selected_id rd_id run kill @s diff --git a/1_20_5/data/ridedragon/functions/z_admin/book_from_help_toggle.mcfunction b/1_20_5/data/ridedragon/functions/z_admin/book_from_help_toggle.mcfunction new file mode 100644 index 0000000..c4403e1 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_admin/book_from_help_toggle.mcfunction @@ -0,0 +1,12 @@ +# +# Description: Disable option to get the book directly from the help menu +# Called by: ridedragon:admin via chat link +# Entity @s: player +# +execute store success score #rd_success rd_help run data modify storage ridedragon:settings rd_admin.book_help set value "Disabled" +execute unless score #rd_success rd_help matches 1 run data modify storage ridedragon:settings rd_admin.book_help set value "Enabled" +# +tellraw @s [{"text":"Getting the book from the help menu has been ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.book_help"}] +# +function ridedragon:admin + diff --git a/1_20_5/data/ridedragon/functions/z_admin/can_fire_toggle.mcfunction b/1_20_5/data/ridedragon/functions/z_admin/can_fire_toggle.mcfunction new file mode 100644 index 0000000..d4e397f --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_admin/can_fire_toggle.mcfunction @@ -0,0 +1,12 @@ +# +# Description: Disable fireing of dragon fireballs +# Called by: ridedragon:admin via chat link +# Entity @s: player +# +execute store success score #rd_success rd_help run data modify storage ridedragon:settings rd_admin.can_fire set value "Disabled" +execute unless score #rd_success rd_help matches 1 run data modify storage ridedragon:settings rd_admin.can_fire set value "Enabled" +# +tellraw @s [{"text":"Player fireing of dragon fireballs has been ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.can_fire"}] +# +function ridedragon:admin + diff --git a/1_20_5/data/ridedragon/functions/z_admin/can_summon_toggle.mcfunction b/1_20_5/data/ridedragon/functions/z_admin/can_summon_toggle.mcfunction new file mode 100644 index 0000000..c0f096c --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_admin/can_summon_toggle.mcfunction @@ -0,0 +1,12 @@ +# +# Description: Enable/disable summoning of tame dragons by survival players +# Called by: ridedragon:admin via chat link +# Entity @s: player +# +execute store success score #rd_success rd_help run data modify storage ridedragon:settings rd_admin.can_summon set value "Disabled" +execute unless score #rd_success rd_help matches 1 run data modify storage ridedragon:settings rd_admin.can_summon set value "Enabled" +# +tellraw @s [{"text":"Summoning dragons for survival players has been ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.can_summon"}] +# +function ridedragon:admin + diff --git a/1_20_5/data/ridedragon/functions/z_admin/dragon_health_decrease.mcfunction b/1_20_5/data/ridedragon/functions/z_admin/dragon_health_decrease.mcfunction new file mode 100644 index 0000000..94ed9a8 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_admin/dragon_health_decrease.mcfunction @@ -0,0 +1,11 @@ +# +# Description: Disable fireing of dragon fireballs +# Called by: ridedragon:admin via chat link +# Entity @s: player +# + +execute store result score #rd_math rd_help run data get storage ridedragon:settings rd_admin.dragon_health +execute if score #rd_math rd_help matches 11.. store result storage ridedragon:settings rd_admin.dragon_health int 1.0 run scoreboard players remove #rd_math rd_help 10 + +function ridedragon:admin + diff --git a/1_20_5/data/ridedragon/functions/z_admin/dragon_health_increase.mcfunction b/1_20_5/data/ridedragon/functions/z_admin/dragon_health_increase.mcfunction new file mode 100644 index 0000000..87a8499 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_admin/dragon_health_increase.mcfunction @@ -0,0 +1,11 @@ +# +# Description: Increase the dragon health when spawned +# Called by: ridedragon:admin via chat link +# Entity @s: player +# + +execute store result score #rd_math rd_help run data get storage ridedragon:settings rd_admin.dragon_health +execute if score #rd_math rd_help matches ..600 store result storage ridedragon:settings rd_admin.dragon_health int 1.0 run scoreboard players add #rd_math rd_help 10 + +function ridedragon:admin + diff --git a/1_20_5/data/ridedragon/functions/z_admin/fireball_cooldown_decrease.mcfunction b/1_20_5/data/ridedragon/functions/z_admin/fireball_cooldown_decrease.mcfunction new file mode 100644 index 0000000..a6334d1 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_admin/fireball_cooldown_decrease.mcfunction @@ -0,0 +1,11 @@ +# +# Description: Decrease the cooldown time for dragon fireballs +# Called by: ridedragon:admin via chat link +# Entity @s: player +# + +execute store result score #rd_math rd_help run data get storage ridedragon:settings rd_admin.fire_cooldown +execute if score #rd_math rd_help matches 11.. store result storage ridedragon:settings rd_admin.fire_cooldown int 1.0 run scoreboard players remove #rd_math rd_help 10 + +function ridedragon:admin + diff --git a/1_20_5/data/ridedragon/functions/z_admin/fireball_cooldown_increase.mcfunction b/1_20_5/data/ridedragon/functions/z_admin/fireball_cooldown_increase.mcfunction new file mode 100644 index 0000000..1b9ea11 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_admin/fireball_cooldown_increase.mcfunction @@ -0,0 +1,11 @@ +# +# Description: Increase the cooldown time for firing dragon fireballs +# Called by: ridedragon:admin via chat link +# Entity @s: player +# + +execute store result score #rd_math rd_help run data get storage ridedragon:settings rd_admin.fire_cooldown +execute if score #rd_math rd_help matches ..600 store result storage ridedragon:settings rd_admin.fire_cooldown int 1.0 run scoreboard players add #rd_math rd_help 10 + +function ridedragon:admin + diff --git a/1_20_5/data/ridedragon/functions/z_admin/summon_without_book_toggle.mcfunction b/1_20_5/data/ridedragon/functions/z_admin/summon_without_book_toggle.mcfunction new file mode 100644 index 0000000..2b12df6 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_admin/summon_without_book_toggle.mcfunction @@ -0,0 +1,12 @@ +# +# Description: Enable/disable summoning of tame dragons without holding the Book of Dragons +# Called by: ridedragon:admin via chat link +# Entity @s: player +# +execute store success score #rd_success rd_help run data modify storage ridedragon:settings rd_admin.summon_without_book set value "Disabled" +execute unless score #rd_success rd_help matches 1 run data modify storage ridedragon:settings rd_admin.summon_without_book set value "Enabled" +# +tellraw @s [{"text":"Summoning dragons without the Book of Dragons has been ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.summon_without_book"}] +# +function ridedragon:admin + diff --git a/1_20_5/data/ridedragon/functions/z_admin/vanish_all.mcfunction b/1_20_5/data/ridedragon/functions/z_admin/vanish_all.mcfunction new file mode 100644 index 0000000..7fb5eb7 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_admin/vanish_all.mcfunction @@ -0,0 +1,3 @@ +kill @e[type=ender_dragon,tag=dragonvisible] +kill @e[type=marker,tag=dragonhelper] +kill @e[type=horse,tag=dragonseat] diff --git a/1_20_5/data/ridedragon/functions/z_dragon_cleanup.mcfunction b/1_20_5/data/ridedragon/functions/z_dragon_cleanup.mcfunction new file mode 100644 index 0000000..9640b0d --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_dragon_cleanup.mcfunction @@ -0,0 +1,6 @@ +execute as @e[type=ender_dragon,tag=dragonvisible] at @s run function ridedragon:z_dragon_cleanup_visible + +execute as @e[type=horse,tag=dragonseat] at @s unless entity @e[tag=dragonvisible,distance=..7,limit=1] run kill @s +execute as @e[type=marker,tag=dragonhelper] at @s unless entity @e[tag=dragonvisible,distance=..7,limit=1] run kill @s + +schedule function ridedragon:z_dragon_cleanup 23t diff --git a/1_20_5/data/ridedragon/functions/z_dragon_cleanup_visible.mcfunction b/1_20_5/data/ridedragon/functions/z_dragon_cleanup_visible.mcfunction new file mode 100644 index 0000000..2ed13ec --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_dragon_cleanup_visible.mcfunction @@ -0,0 +1,3 @@ +execute unless entity @e[type=minecraft:horse,tag=dragonseat,distance=..7,limit=1] run kill @s +execute unless entity @e[type=minecraft:marker,tag=dragonhelper,distance=..7,limit=1] run kill @s + diff --git a/1_20_5/data/ridedragon/functions/z_dragon_motion.mcfunction b/1_20_5/data/ridedragon/functions/z_dragon_motion.mcfunction new file mode 100644 index 0000000..eccc094 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_dragon_motion.mcfunction @@ -0,0 +1,26 @@ +# called as dragon_visible, at same + +# Fireball cooldown handling +scoreboard players remove @s[scores={rd_fire_cooldown=1..}] rd_fire_cooldown 1 + +# Find all the parts of the flying stack and tag them as +# dragonvisible_selected, dragonhelper_selected, dragonseat_selected, dragonrider_selected + +scoreboard players operation #rd_selected_id rd_id = @s rd_id +tag @s add dragonvisible_selected +execute as @e[type=marker,tag=dragonhelper,distance=..7] if score @s rd_id = #rd_selected_id rd_id run tag @s add dragonhelper_selected +execute as @e[type=horse,tag=dragonseat,distance=..7] if score @s rd_id = #rd_selected_id rd_id run tag @s add dragonseat_selected +tag @a[nbt={RootVehicle:{Entity:{Tags:["dragonseat_selected"]}}},distance=..7,limit=1] add dragonrider_selected + +# Reset HurtTime to keep the knockback effect of the dragon disabled. It seems to be reset +# by actual harming of the dragon, so set it back to -1. +data modify entity @s HurtTime set value -1 + +execute as @a[tag=dragonrider_selected,distance=..7,limit=1] run function ridedragon:z_player_motion +execute as @e[type=marker,tag=dragonhelper_selected,distance=..7,limit=1] unless entity @a[distance=..7,limit=1,tag=dragonrider_selected] run function ridedragon:z_no_player_motion + +tag @s remove dragonvisible_selected +tag @a[distance=..7,tag=dragonrider_selected,limit=1] remove dragonrider_selected +tag @e[type=marker,distance=..7,tag=dragonhelper_selected,limit=1] remove dragonhelper_selected +tag @e[type=horse,distance=..7,tag=dragonseat_selected,limit=1] remove dragonseat_selected + diff --git a/1_20_5/data/ridedragon/functions/z_enable.mcfunction b/1_20_5/data/ridedragon/functions/z_enable.mcfunction new file mode 100644 index 0000000..9763d6f --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_enable.mcfunction @@ -0,0 +1,10 @@ +# +# Periodic reset of triggers on reload +# +scoreboard players enable @p rd_help +scoreboard players enable @p rd_summon +scoreboard players enable @p rd_vanish +scoreboard players enable @p rd_silence + +# Repeat every 4 seconds +schedule function ridedragon:z_enable 83t diff --git a/1_20_5/data/ridedragon/functions/z_fireball_get_motion.mcfunction b/1_20_5/data/ridedragon/functions/z_fireball_get_motion.mcfunction new file mode 100644 index 0000000..8931905 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_fireball_get_motion.mcfunction @@ -0,0 +1,22 @@ +# Extraction looking direction to compute motion for the fireball. Inspired by +# https://www.reddit.com/r/MinecraftCommands/wiki/questions/shootfacing/ + +# this function is executed as the marker entity, positioned at 0 0 0 and still rotated as the player +# (as that wasn't changed with the function call) + +# teleport the entity forward by 0.2 block (based on the player rotation and the position 0 0 0). +# this will form the "acceleration_power" of the dragon fireball +tp @s ^ ^ ^0.1 + +# store the current position in the worlds NBT storage so we don't loose it +data modify storage ridedragon:tmp Motion set from entity @s Pos + +# teleport the entity forward by another 0.6 block +# this will form the "direction" of the dragon fireball +tp @s ^ ^ ^0.6 + +# store the current position in the worlds NBT storage so we don't loose it +data modify storage ridedragon:tmp Motion2 set from entity @s Pos + +# we don't need this entity anymore +kill @s diff --git a/1_20_5/data/ridedragon/functions/z_help/credits.mcfunction b/1_20_5/data/ridedragon/functions/z_help/credits.mcfunction new file mode 100644 index 0000000..775d270 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_help/credits.mcfunction @@ -0,0 +1,10 @@ +# +# Description: Display credits in chat +# Called by: ridedragon:z_help_trigger +# Entity @s: Player +# +tellraw @s [{"text":"Rideable Dragons - Credits","color":"yellow","bold":true}] +tellraw @s [{"text":"Created by: ","color":"aqua"},{"text":"ptefar","color":"#87325d","bold":true,"clickEvent":{"action":"open_url","value":"https://www.youtube.com/channel/UC3ro2x7YnyNt8V1t1bUYfXA"}}] +tellraw @s [{"text":"Based on an idea from: ","color":"aqua"},{"text":"John Paul Inso","color":"#0072e5","bold":true,"clickEvent":{"action":"open_url","value":"https://youtu.be/vBUknTYjylc"}}] +tellraw @s [{"text":"Some frameworks from: ","color":"aqua"},{"text":"Armor Statues datapack","color":"#0072e5","bold":true,"clickEvent":{"action":"open_url","value":"https://www.curseforge.com/minecraft/customization/armor-statues-datapack"}}] +tellraw @s [{"text":"--------------------------","color":"yellow","bold":true}] diff --git a/1_20_5/data/ridedragon/functions/z_help/get_book.mcfunction b/1_20_5/data/ridedragon/functions/z_help/get_book.mcfunction new file mode 100644 index 0000000..1b92fb0 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_help/get_book.mcfunction @@ -0,0 +1,7 @@ +# +# Description: Get book via chat link +# Called by: ridedragon:z_help +# Entity @s: Player +# +function ridedragon:give_book + diff --git a/1_20_5/data/ridedragon/functions/z_help/main.mcfunction b/1_20_5/data/ridedragon/functions/z_help/main.mcfunction new file mode 100644 index 0000000..cd1becb --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_help/main.mcfunction @@ -0,0 +1,10 @@ +# +# Description: Display main help options +# Called by: ridedragon:z_help_trigger +# Entity @s: Player +# +tellraw @s [{"text":"Rideable Dragons - Help","color":"yellow","bold":true},{"text":"\nDragons can be summoned via the ","color":"aqua","bold":false},{"text":"Book of Dragons","color":"light_purple","bold":false},{"text":"\nSummoned dragons are mounted by clicking on their necks\nGet the book by:","color":"aqua","bold":false}] +execute if data storage ridedragon:settings rd_admin{book_help:"Enabled"} run tellraw @s [{"text":" - Clicking ","color":"aqua"},{"text":"here","color":"green","clickEvent":{"action":"run_command","value":"/trigger rd_help set 10"}}] +execute if data storage ridedragon:settings rd_admin{can_fire:"Enabled"} run tellraw @s [{"text":"Hold an End Crystal and look below the horizon while mounted to launch dragon fireballs","color":"aqua"}] +tellraw @s [{"text":"Credits","color":"green","clickEvent":{"action":"run_command","value":"/trigger rd_help set 11"}}] +tellraw @s [{"text":"--------------------------","color":"yellow","bold":true}] diff --git a/1_20_5/data/ridedragon/functions/z_help_trigger.mcfunction b/1_20_5/data/ridedragon/functions/z_help_trigger.mcfunction new file mode 100644 index 0000000..ad42aac --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_help_trigger.mcfunction @@ -0,0 +1,14 @@ +# +# Description: Display help in chat +# Called by: ridedragon:z_main +# Entity @s: player +# +execute if score @s rd_help matches 10 if data storage ridedragon:settings rd_admin{book_help:"Enabled"} run function ridedragon:z_help/get_book +execute if score @s rd_help matches 11 run function ridedragon:z_help/credits +execute if score @s rd_help matches 1..9 run function ridedragon:z_help/main + +# +# Reset trigger score +# +scoreboard players set @s rd_help 0 +scoreboard players enable @s rd_help diff --git a/1_20_5/data/ridedragon/functions/z_init.mcfunction b/1_20_5/data/ridedragon/functions/z_init.mcfunction new file mode 100644 index 0000000..bd92c25 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_init.mcfunction @@ -0,0 +1,40 @@ +# +# Description: Create scoreboards +# Called by: #main:init +# Entity @s: None +# +# Create scoreboards +# +scoreboard objectives add rd_help trigger +scoreboard objectives add rd_summon trigger +scoreboard objectives add rd_vanish trigger +scoreboard objectives add rd_silence trigger +scoreboard objectives add rd_id dummy +# Cooldown timer per dragon, not player +scoreboard objectives add rd_fire_cooldown dummy + +# +# Resets triggers on reload +# Also rerun in the z_enable repeating function +# +scoreboard players enable * rd_help +scoreboard players enable * rd_summon +scoreboard players enable * rd_vanish +scoreboard players enable * rd_silence +# + +# +# Sets storage settings +# +execute unless data storage ridedragon:settings rd_admin.book_help run data modify storage ridedragon:settings rd_admin.book_help set value "Disabled" +execute unless data storage ridedragon:settings rd_admin.can_summon run data modify storage ridedragon:settings rd_admin.can_summon set value "Disabled" +execute unless data storage ridedragon:settings rd_admin.summon_without_book run data modify storage ridedragon:settings rd_admin.summon_without_book set value "Disabled" +execute unless data storage ridedragon:settings rd_admin.can_fire run data modify storage ridedragon:settings rd_admin.can_fire set value "Disabled" +execute unless data storage ridedragon:settings rd_admin.dragon_health run data modify storage ridedragon:settings rd_admin.dragon_health set value 5 +execute unless data storage ridedragon:settings rd_admin.fire_cooldown run data modify storage ridedragon:settings rd_admin.fire_cooldown set value 200 + +# Schedule function to remove orphaned dragon components every 1 seconds (use a prime number of ticks) +schedule function ridedragon:z_dragon_cleanup 23t + +# Schedule function to enable the scoreboard objectives for all players every 4 seconds (use a prime number of ticks) +schedule function ridedragon:z_enable 83t diff --git a/1_20_5/data/ridedragon/functions/z_launch_fireball.mcfunction b/1_20_5/data/ridedragon/functions/z_launch_fireball.mcfunction new file mode 100644 index 0000000..ffaea6f --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_launch_fireball.mcfunction @@ -0,0 +1,30 @@ +# Summon a new dragon fireball +#summon minecraft:dragon_fireball ~ ~4 ~ {Tags:["dragon_fireball_selected","dragon_fireball"],direction:[0.5,0.0,0.0],acceleration_power:[0.1,-0.1,0.0],Owner:[I;1,1,1,1]} +summon minecraft:dragon_fireball ^ ^ ^8 {Tags:["dragon_fireball_selected","dragon_fireball"]} + +# Mark the dragon as the owner so that the dragon's breath can be collected from the +# area_effect_cloud after the dragon fireball lands +data modify entity @e[tag=dragon_fireball_selected,distance=..10,limit=1] Owner set from entity @e[tag=dragonvisible_selected,distance=..10,limit=1] UUID + +# Start the cooldown for the dragon to fire as configured in the admin menu +execute store result score @e[tag=dragonvisible_selected,limit=1] rd_fire_cooldown run data get storage ridedragon:settings rd_admin.fire_cooldown + + +# Set up motion. Inspired by +# https://www.reddit.com/r/MinecraftCommands/wiki/questions/shootfacing/ +# summon the temporary entity at the players position +summon marker ~ ~ ~ {Tags:["direction_marker"]} + +# execute the below function as the marker entity, so it doesn't get lost from being unloaded +# run positioned at the world zero point. this will remove the marker +execute as @e[tag=direction_marker,distance=..10,limit=1] positioned 0.0 0.0 0.0 run function ridedragon:z_fireball_get_motion + +# store the previously stored Motion into the projectile entity +# Note that dragon fireballs use "direction" for the initial direction and +# "power" for the constant acceleration countering drag. +data modify entity @e[tag=dragon_fireball_selected,limit=1] power set from storage ridedragon:tmp Motion +data modify entity @e[tag=dragon_fireball_selected,limit=1] direction set from storage ridedragon:tmp Motion2 +# clean up the tag +tag @e[tag=dragon_fireball_selected] remove dragon_fireball_selected + + diff --git a/1_20_5/data/ridedragon/functions/z_main.mcfunction b/1_20_5/data/ridedragon/functions/z_main.mcfunction new file mode 100644 index 0000000..1b0c5d3 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_main.mcfunction @@ -0,0 +1,8 @@ +execute as @a[scores={rd_summon=1..}] at @s run function ridedragon:z_summon_trigger +execute as @a[scores={rd_vanish=1..}] at @s run function ridedragon:z_vanish_trigger +execute as @a[scores={rd_silence=1..}] at @s run function ridedragon:z_silence_trigger +execute as @a[scores={rd_help=1..}] at @s run function ridedragon:z_help_trigger + +execute as @e[type=ender_dragon,tag=dragonvisible] at @s run function ridedragon:z_dragon_motion + + diff --git a/1_20_5/data/ridedragon/functions/z_no_player_motion.mcfunction b/1_20_5/data/ridedragon/functions/z_no_player_motion.mcfunction new file mode 100644 index 0000000..69e89bf --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_no_player_motion.mcfunction @@ -0,0 +1,8 @@ +# Executed as dragonhelper, no position + +execute as @s at @s if block ~ ~-1.2 ~ air run tp @s ~ ~-0.1 ~ +execute as @s at @s unless block ~ ~-1.2 ~ air run tp @s ~ ~0.1 ~ + +execute as @s at @s run tp @e[type=horse,distance=..7,tag=dragonseat_selected,limit=1] ~ ~ ~ ~ ~ + +execute as @e[distance=..7,tag=dragonseat_selected,limit=1] at @s rotated ~ 0 positioned ^ ^ ^-3.5 rotated as @s run tp @e[tag=dragonvisible_selected,limit=1,distance=..7] ~ ~-1.0 ~ ~-180 ~ diff --git a/1_20_5/data/ridedragon/functions/z_player_motion.mcfunction b/1_20_5/data/ridedragon/functions/z_player_motion.mcfunction new file mode 100644 index 0000000..e534c20 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_player_motion.mcfunction @@ -0,0 +1,26 @@ +# Executed as dragonrider, no position + +# Low speed default +execute as @s at @s positioned ^ ^ ^0.2 positioned ~ ~-0.85 ~ if block ~ ~-1.3 ~ air run tp @e[type=marker,distance=..7,tag=dragonhelper_selected,limit=1] ~ ~ ~ ~ ~ + +# High speed when holding the book +execute if entity @s[predicate=ridedragon:book_holder_mainhand] at @s positioned ^ ^ ^1.0 positioned ~ ~-0.85 ~ if block ~ ~-1.3 ~ air run tp @e[type=marker,distance=..7,tag=dragonhelper_selected,limit=1] ~ ~ ~ ~ ~ +execute if entity @s[predicate=ridedragon:book_holder_offhand] at @s positioned ^ ^ ^1.0 positioned ~ ~-0.85 ~ if block ~ ~-1.3 ~ air run tp @e[type=marker,distance=..7,tag=dragonhelper_selected,limit=1] ~ ~ ~ ~ ~ + +#Move the dragonseat (horse) to the helper marker +execute as @e[type=marker,distance=..7,tag=dragonhelper_selected,limit=1] at @s run tp @e[type=horse,distance=..7,tag=dragonseat_selected,limit=1] ~ ~ ~ ~ ~ + + +# Move the dragon to the correct offset relative to the player/dragonseat depending on the low/high speed +# Low speed +execute as @e[type=horse,distance=..7,tag=dragonseat_selected,limit=1] at @s rotated ~ 0 positioned ^ ^ ^-2.6 rotated as @s run tp @e[type=ender_dragon,tag=dragonvisible_selected,limit=1,sort=nearest,distance=..7] ~ ~-0.7 ~ ~-180 ~ +# High speed looking up or forward +execute if entity @s[predicate=ridedragon:book_holder_mainhand] as @e[type=horse,distance=..7,tag=dragonseat_selected,limit=1] at @s positioned ^ ^ ^-2.7 rotated as @s run tp @e[type=ender_dragon,tag=dragonvisible_selected,limit=1,sort=nearest,distance=..7] ~ ~-0.7 ~ ~-180 ~ +execute if entity @s[predicate=ridedragon:book_holder_offhand] as @e[type=horse,distance=..7,tag=dragonseat_selected,limit=1] at @s positioned ^ ^ ^-2.7 rotated as @s run tp @e[type=ender_dragon,tag=dragonvisible_selected,limit=1,sort=nearest,distance=..7] ~ ~-0.7 ~ ~-180 ~ +# High speed looking down +execute if entity @s[x_rotation=10..90,predicate=ridedragon:book_holder_mainhand] as @e[type=horse,distance=..7,tag=dragonseat_selected,limit=1] at @s rotated ~ 0 positioned ^ ^ ^-2.7 rotated as @s positioned ^ ^ ^-2.2 rotated as @s run tp @e[type=ender_dragon,tag=dragonvisible_selected,limit=1,sort=nearest,distance=..7] ~ ~-0.7 ~ ~-180 ~ +execute if entity @s[x_rotation=10..90,predicate=ridedragon:book_holder_offhand] as @e[type=horse,distance=..7,tag=dragonseat_selected,limit=1] at @s rotated ~ 0 positioned ^ ^ ^-2.7 rotated as @s positioned ^ ^ ^-2.2 rotated as @s run tp @e[type=ender_dragon,tag=dragonvisible_selected,limit=1,sort=nearest,distance=..7] ~ ~-0.7 ~ ~-180 ~ + + +# Check if dragon fireballs are enabled the trigger held and looking sufficiently below the horizon (10 degrees or more) +execute if data storage ridedragon:settings rd_admin{can_fire:"Enabled"} run execute if entity @s[x_rotation=10..90,predicate=ridedragon:is_holding_trigger_item] at @s run execute if entity @e[tag=dragonvisible_selected,limit=1,scores={rd_fire_cooldown=0}] run function ridedragon:z_launch_fireball diff --git a/1_20_5/data/ridedragon/functions/z_silence_toggle.mcfunction b/1_20_5/data/ridedragon/functions/z_silence_toggle.mcfunction new file mode 100644 index 0000000..f63c0ce --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_silence_toggle.mcfunction @@ -0,0 +1,6 @@ + +execute store success score #rd_success rd_help run data modify entity @s Silent set value 1b +execute unless score #rd_success rd_help matches 1 run data modify entity @s Silent set value 0b + +execute if score #rd_success rd_help matches 1 run tellraw @p [{"text":"The dragon has been ","color":"aqua"},{"text":"silenced","color":"yellow"}] +execute unless score #rd_success rd_help matches 1 run tellraw @p [{"text":"The dragon has been ","color":"aqua"},{"text":"granted its voice back","color":"yellow"}] diff --git a/1_20_5/data/ridedragon/functions/z_silence_trigger.mcfunction b/1_20_5/data/ridedragon/functions/z_silence_trigger.mcfunction new file mode 100644 index 0000000..b33c19f --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_silence_trigger.mcfunction @@ -0,0 +1,7 @@ + +function ridedragon:silence_dragon +# +# Reset player's trigger score and re-enable +# +scoreboard players set @s rd_silence 0 +scoreboard players enable @s rd_silence diff --git a/1_20_5/data/ridedragon/functions/z_summon_trigger.mcfunction b/1_20_5/data/ridedragon/functions/z_summon_trigger.mcfunction new file mode 100644 index 0000000..04982ee --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_summon_trigger.mcfunction @@ -0,0 +1,20 @@ +# Need to clear the rd_help scoreboard first as no-match in an execute statement is +# not considered a failure (see https://bugs.mojang.com/browse/MC-125058) +scoreboard players set #rd_success rd_help 0 + +# Test for the conditions allowing summoning: +# - creative player, +# - non-creative player summoning and allowing bare triggers +# - non-creative player holding the Book of Dragons +execute store success score #rd_success rd_help if entity @s[gamemode=creative] run function ridedragon:summon_dragon +execute store success score #rd_success rd_help unless score #rd_success rd_help matches 1 if data storage ridedragon:settings rd_admin{can_summon:"Enabled"} if data storage ridedragon:settings rd_admin{summon_without_book:"Enabled"} run function ridedragon:summon_dragon +execute unless score #rd_success rd_help matches 1 if data storage ridedragon:settings rd_admin{can_summon:"Enabled"} if items entity @s container.* minecraft:written_book[minecraft:custom_data~{DragonBook:"1"}] run function ridedragon:summon_dragon + +execute unless entity @s[gamemode=creative] unless data storage ridedragon:settings rd_admin{can_summon:"Enabled"} run tellraw @s [{"text":"Dragon","color":"light_purple"},{"text":" summoning is globally disabled","color":"aqua"}] + +# +# Reset player's trigger score and re-enable +# +scoreboard players set @s rd_summon 0 +scoreboard players enable @s rd_summon + diff --git a/1_20_5/data/ridedragon/functions/z_vanish_trigger.mcfunction b/1_20_5/data/ridedragon/functions/z_vanish_trigger.mcfunction new file mode 100644 index 0000000..2fd68a0 --- /dev/null +++ b/1_20_5/data/ridedragon/functions/z_vanish_trigger.mcfunction @@ -0,0 +1,8 @@ +function ridedragon:vanish_dragon + +# +# Reset player's trigger score and re-enable +# +scoreboard players set @s rd_vanish 0 +scoreboard players enable @s rd_vanish + diff --git a/1_20_5/data/ridedragon/loot_tables/book.json b/1_20_5/data/ridedragon/loot_tables/book.json new file mode 100644 index 0000000..b3f34b2 --- /dev/null +++ b/1_20_5/data/ridedragon/loot_tables/book.json @@ -0,0 +1,57 @@ +{ + "type": "minecraft:loot", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:written_book", + "functions": [ + { + "function": "minecraft:set_custom_data", + "tag": { + "DragonBook": "1" + } + }, + { + "function": "minecraft:set_custom_model_data", + "value": 10 + }, + { + "function": "minecraft:set_book_cover", + "title": "Book of Dragons", + "author": "ptefar", + "generation": 0 + }, + { + "function": "minecraft:set_written_book_pages", + "mode": "replace_all", + "pages":[ + [ + {"text":"Book of Dragons","bold":true,"color":"dark_purple"}, + {"text":"\n\nRiding a dragon in three easy steps:\n\n1. ","bold":false,"color":"black"}, + {"text":"Summon the Dragon","underlined":true,"bold":false,"clickEvent":{"action":"run_command","value":"/trigger rd_summon"},"hoverEvent":{"action":"show_text","contents":"... or type \"/trigger rd_summon\" in chat"}}, + {"text":"\n2. Click the dragon\\'s\n neck w. empty hand\n3. ","color":"black","bold":false}, + {"text":"Vanish the dragon","underlined":true,"bold":false,"clickEvent":{"action":"run_command","value":"/trigger rd_vanish"},"hoverEvent":{"action":"show_text","contents":"... or type \"/trigger rd_vanish\" in chat"}}, + {"text":"\n\nThe dragon flies faster when you hold this book.","bold":false,"color":"black"} + ], + [ + {"text":"\n\nYou unmount your dragon by sneaking.\n\nIf you think your new pet is too noisy you can ","bold":false}, + {"text":"toggle its voice","underlined":true,"bold":false,"clickEvent":{"action":"run_command","value":"/trigger rd_silence"},"hoverEvent":{"action":"show_text","contents":"... or type \"/trigger rd_silence\" in chat"}}, + {"text":".","color":"black","bold":false,"clickEvent":{"action":"run_command","value":"/trigger rd_silence"},"hoverEvent":{"action":"show_text","contents":"... or type \"/trigger rd_silence\" in chat"}} + ], + [ + {"text":"\n\nPlease see the ","bold":false}, + {"text":"help","bold":true,"underlined":true,"clickEvent":{"action":"run_command","value":"/trigger rd_help"}}, + {"text":" for further information.\n\n\nDatapack by ","bold":false,"color":"black"}, + {"text":"Ptefar","underlined":true,"bold":false,"clickEvent":{"action":"open_url","value":"https://www.youtube.com/channel/UC3ro2x7YnyNt8V1t1bUYfXA"}} + ] + ] + } + ] + } + ] + } + ] +} diff --git a/1_20_5/data/ridedragon/predicates/book_holder_mainhand.json b/1_20_5/data/ridedragon/predicates/book_holder_mainhand.json new file mode 100644 index 0000000..4660c1a --- /dev/null +++ b/1_20_5/data/ridedragon/predicates/book_holder_mainhand.json @@ -0,0 +1,18 @@ +{ + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "type": "minecraft:player", + "equipment": { + "mainhand": { + "items": "minecraft:written_book", + "count": { + "min": 1 + }, + "predicates": { + "minecraft:custom_data": {"DragonBook":"1"} + } + } + } + } +} diff --git a/1_20_5/data/ridedragon/predicates/book_holder_offhand.json b/1_20_5/data/ridedragon/predicates/book_holder_offhand.json new file mode 100644 index 0000000..6651fd9 --- /dev/null +++ b/1_20_5/data/ridedragon/predicates/book_holder_offhand.json @@ -0,0 +1,19 @@ +{ + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "type": "minecraft:player", + "equipment": { + "offhand": { + "items": "minecraft:written_book", + "count": { + "min": 1 + }, + "predicates": { + "minecraft:custom_data": {"DragonBook":"1"} + } + } + } + } +} + diff --git a/1_20_5/data/ridedragon/predicates/is_holding_trigger_item.json b/1_20_5/data/ridedragon/predicates/is_holding_trigger_item.json new file mode 100644 index 0000000..01c701f --- /dev/null +++ b/1_20_5/data/ridedragon/predicates/is_holding_trigger_item.json @@ -0,0 +1,15 @@ +{ + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "type": "minecraft:player", + "equipment": { + "mainhand": { + "items": "minecraft:end_crystal", + "count": { + "min": 1 + } + } + } + } +} diff --git a/1_21_0/data/minecraft/tags/function/load.json b/1_21_0/data/minecraft/tags/function/load.json new file mode 100644 index 0000000..79a50ff --- /dev/null +++ b/1_21_0/data/minecraft/tags/function/load.json @@ -0,0 +1,5 @@ +{ + "values":[ + "ridedragon:z_init" + ] +} diff --git a/1_21_0/data/minecraft/tags/function/tick.json b/1_21_0/data/minecraft/tags/function/tick.json new file mode 100644 index 0000000..ded7e67 --- /dev/null +++ b/1_21_0/data/minecraft/tags/function/tick.json @@ -0,0 +1,5 @@ +{ + "values":[ + "ridedragon:z_main" + ] +} diff --git a/1_21_0/data/ridedragon/function/admin.mcfunction b/1_21_0/data/ridedragon/function/admin.mcfunction new file mode 100644 index 0000000..a6c694d --- /dev/null +++ b/1_21_0/data/ridedragon/function/admin.mcfunction @@ -0,0 +1,14 @@ +# +# Description: Display admin options in chat +# Called by: Player +# Entity @s: Player +# +tellraw @s [{"text":"Rideable Dragons - Admin Options","color":"yellow","bold":true}] +tellraw @s [{"text":"Get book from help: ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.book_help", "color":"green", "clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/book_from_help_toggle"}, "hoverEvent":{"action":"show_text", "contents":{"text":"Click to toggle", "color":"yellow"}}}] +tellraw @s [{"text":"Survival players can summon dragons: ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.can_summon", "color":"green", "clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/can_summon_toggle"}, "hoverEvent":{"action":"show_text", "contents":{"text":"Click to toggle", "color":"yellow"}}}] +tellraw @s [{"text":"Summon without the ","color":"aqua"},{"text":"Book of Dragons","color":"light_purple"},{"text":": ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.summon_without_book", "color":"green", "clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/summon_without_book_toggle"}, "hoverEvent":{"action":"show_text", "contents":{"text":"Click to toggle", "color":"yellow"}}}] +tellraw @s [{"text":"Players can fire dragon fireballs: ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.can_fire", "color":"green", "clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/can_fire_toggle"}, "hoverEvent":{"action":"show_text", "contents":{"text":"Click to toggle", "color":"yellow"}}}] +tellraw @s [{"text":"Fireball cooldown (1/20s): ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.fire_cooldown"},{"text":" (","color":"aqua"},{"text":" + ", "color":"green","clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/fireball_cooldown_increase"},"hoverEvent":{"action":"show_text", "contents":{"text":"Click to increase", "color":"yellow"}}},{"text":"/","color":"aqua"},{"text":" - ", "color":"green","clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/fireball_cooldown_decrease"},"hoverEvent":{"action":"show_text", "contents":{"text":"Click to decrease", "color":"yellow"}}},{"text":")","color":"aqua"}] +tellraw @s [{"text":"Initial dragon health : ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.dragon_health"},{"text":" (","color":"aqua"},{"text":" + ", "color":"green","clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/dragon_health_increase"},"hoverEvent":{"action":"show_text", "contents":{"text":"Click to increase", "color":"yellow"}}},{"text":"/","color":"aqua"},{"text":" - ", "color":"green","clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/dragon_health_decrease"},"hoverEvent":{"action":"show_text", "contents":{"text":"Click to decrease", "color":"yellow"}}},{"text":")","color":"aqua"}] +tellraw @s [{"text":"Vanish all tame tragons", "color":"red", "clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/vanish_all"}, "hoverEvent":{"action":"show_text", "contents":{"text":"Click to vanish all loaded tame dragons", "color":"red"}}}] +tellraw @s [{"text":"--------------------------","color":"yellow","bold":true}] diff --git a/1_21_0/data/ridedragon/function/give_book.mcfunction b/1_21_0/data/ridedragon/function/give_book.mcfunction new file mode 100644 index 0000000..b22d06c --- /dev/null +++ b/1_21_0/data/ridedragon/function/give_book.mcfunction @@ -0,0 +1 @@ +loot give @p loot ridedragon:book diff --git a/1_21_0/data/ridedragon/function/silence_dragon.mcfunction b/1_21_0/data/ridedragon/function/silence_dragon.mcfunction new file mode 100644 index 0000000..4023192 --- /dev/null +++ b/1_21_0/data/ridedragon/function/silence_dragon.mcfunction @@ -0,0 +1,2 @@ + +execute as @e[type=ender_dragon,tag=dragonvisible,distance=..10,sort=nearest,limit=1] at @s run function ridedragon:z_silence_toggle diff --git a/1_21_0/data/ridedragon/function/summon_dragon.mcfunction b/1_21_0/data/ridedragon/function/summon_dragon.mcfunction new file mode 100644 index 0000000..bc57dd7 --- /dev/null +++ b/1_21_0/data/ridedragon/function/summon_dragon.mcfunction @@ -0,0 +1,20 @@ +# Step the global counter. It is used as a pseudo-uuid that can be stored in the entity data. +scoreboard players add #rd_global_cnt rd_id 1 + +summon minecraft:horse ~ ~1 ~ {NoAI:1b,Invulnerable:1b,Tags:["dragonseat","dragon_temp"],DeathLootTable:"minecraft:empty",Attributes:[{Name:"generic.knockback_resistance",Base:10000f}],active_effects:[{id:invisibility,amplifier:0,duration:2147483647,show_particles:0b}],Silent:1b} +scoreboard players operation @e[type=minecraft:horse,tag=dragon_temp,distance=..2,limit=1] rd_id = #rd_global_cnt rd_id +tag @e[type=minecraft:horse,tag=dragon_temp,distance=..2,limit=1] remove dragon_temp + +#summon minecraft:armor_stand ~ ~1 ~ {Tags:["dragonhelper","dragon_temp"],NoGravity:1b,Invisible:0b,Invulnerable:1b,Attributes:[{Name:"generic.knockback_resistance",Base:10000f}],CustomName:'["",{"text":"Ender Dragon","color":"dark_purple"}]',ShowParticles:0b} +summon minecraft:marker ~ ~1 ~ {Tags:["dragonhelper","dragon_temp"]} +scoreboard players operation @e[type=minecraft:marker,tag=dragon_temp,distance=..2,limit=1] rd_id = #rd_global_cnt rd_id +tag @e[type=minecraft:marker,tag=dragon_temp,distance=..2,limit=1] remove dragon_temp + +# Set HurtTime to -1 to keep the knockback effect of the dragon disabled. +summon minecraft:ender_dragon ~ ~0.15 ~ {Tags:["dragonvisible","dragon_temp"],Health:5,HurtTime:-1} +data modify entity @e[tag=dragon_temp,limit=1] Health set from storage ridedragon:settings rd_admin.dragon_health +scoreboard players operation @e[type=minecraft:ender_dragon,tag=dragon_temp,distance=..2,limit=1] rd_id = #rd_global_cnt rd_id +scoreboard players set @e[tag=dragon_temp,limit=1] rd_fire_cooldown 0 +tag @e[type=minecraft:ender_dragon,tag=dragon_temp,distance=..2,limit=1] remove dragon_temp + +return 1 diff --git a/1_21_0/data/ridedragon/function/vanish_dragon.mcfunction b/1_21_0/data/ridedragon/function/vanish_dragon.mcfunction new file mode 100644 index 0000000..0373406 --- /dev/null +++ b/1_21_0/data/ridedragon/function/vanish_dragon.mcfunction @@ -0,0 +1,4 @@ +scoreboard players operation #rd_selected_id rd_id = @e[type=minecraft:ender_dragon,tag=dragonvisible,distance=..10,sort=nearest,limit=1] rd_id +execute as @e[type=minecraft:ender_dragon,tag=dragonvisible,distance=..10] if score @s rd_id = #rd_selected_id rd_id run kill @s +execute as @e[type=minecraft:horse,tag=dragonseat,distance=..17] if score @s rd_id = #rd_selected_id rd_id run kill @s +execute as @e[type=minecraft:marker,tag=dragonhelper,distance=..17] if score @s rd_id = #rd_selected_id rd_id run kill @s diff --git a/1_21_0/data/ridedragon/function/z_admin/book_from_help_toggle.mcfunction b/1_21_0/data/ridedragon/function/z_admin/book_from_help_toggle.mcfunction new file mode 100644 index 0000000..c4403e1 --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_admin/book_from_help_toggle.mcfunction @@ -0,0 +1,12 @@ +# +# Description: Disable option to get the book directly from the help menu +# Called by: ridedragon:admin via chat link +# Entity @s: player +# +execute store success score #rd_success rd_help run data modify storage ridedragon:settings rd_admin.book_help set value "Disabled" +execute unless score #rd_success rd_help matches 1 run data modify storage ridedragon:settings rd_admin.book_help set value "Enabled" +# +tellraw @s [{"text":"Getting the book from the help menu has been ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.book_help"}] +# +function ridedragon:admin + diff --git a/1_21_0/data/ridedragon/function/z_admin/can_fire_toggle.mcfunction b/1_21_0/data/ridedragon/function/z_admin/can_fire_toggle.mcfunction new file mode 100644 index 0000000..d4e397f --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_admin/can_fire_toggle.mcfunction @@ -0,0 +1,12 @@ +# +# Description: Disable fireing of dragon fireballs +# Called by: ridedragon:admin via chat link +# Entity @s: player +# +execute store success score #rd_success rd_help run data modify storage ridedragon:settings rd_admin.can_fire set value "Disabled" +execute unless score #rd_success rd_help matches 1 run data modify storage ridedragon:settings rd_admin.can_fire set value "Enabled" +# +tellraw @s [{"text":"Player fireing of dragon fireballs has been ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.can_fire"}] +# +function ridedragon:admin + diff --git a/1_21_0/data/ridedragon/function/z_admin/can_summon_toggle.mcfunction b/1_21_0/data/ridedragon/function/z_admin/can_summon_toggle.mcfunction new file mode 100644 index 0000000..c0f096c --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_admin/can_summon_toggle.mcfunction @@ -0,0 +1,12 @@ +# +# Description: Enable/disable summoning of tame dragons by survival players +# Called by: ridedragon:admin via chat link +# Entity @s: player +# +execute store success score #rd_success rd_help run data modify storage ridedragon:settings rd_admin.can_summon set value "Disabled" +execute unless score #rd_success rd_help matches 1 run data modify storage ridedragon:settings rd_admin.can_summon set value "Enabled" +# +tellraw @s [{"text":"Summoning dragons for survival players has been ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.can_summon"}] +# +function ridedragon:admin + diff --git a/1_21_0/data/ridedragon/function/z_admin/dragon_health_decrease.mcfunction b/1_21_0/data/ridedragon/function/z_admin/dragon_health_decrease.mcfunction new file mode 100644 index 0000000..94ed9a8 --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_admin/dragon_health_decrease.mcfunction @@ -0,0 +1,11 @@ +# +# Description: Disable fireing of dragon fireballs +# Called by: ridedragon:admin via chat link +# Entity @s: player +# + +execute store result score #rd_math rd_help run data get storage ridedragon:settings rd_admin.dragon_health +execute if score #rd_math rd_help matches 11.. store result storage ridedragon:settings rd_admin.dragon_health int 1.0 run scoreboard players remove #rd_math rd_help 10 + +function ridedragon:admin + diff --git a/1_21_0/data/ridedragon/function/z_admin/dragon_health_increase.mcfunction b/1_21_0/data/ridedragon/function/z_admin/dragon_health_increase.mcfunction new file mode 100644 index 0000000..87a8499 --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_admin/dragon_health_increase.mcfunction @@ -0,0 +1,11 @@ +# +# Description: Increase the dragon health when spawned +# Called by: ridedragon:admin via chat link +# Entity @s: player +# + +execute store result score #rd_math rd_help run data get storage ridedragon:settings rd_admin.dragon_health +execute if score #rd_math rd_help matches ..600 store result storage ridedragon:settings rd_admin.dragon_health int 1.0 run scoreboard players add #rd_math rd_help 10 + +function ridedragon:admin + diff --git a/1_21_0/data/ridedragon/function/z_admin/fireball_cooldown_decrease.mcfunction b/1_21_0/data/ridedragon/function/z_admin/fireball_cooldown_decrease.mcfunction new file mode 100644 index 0000000..a6334d1 --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_admin/fireball_cooldown_decrease.mcfunction @@ -0,0 +1,11 @@ +# +# Description: Decrease the cooldown time for dragon fireballs +# Called by: ridedragon:admin via chat link +# Entity @s: player +# + +execute store result score #rd_math rd_help run data get storage ridedragon:settings rd_admin.fire_cooldown +execute if score #rd_math rd_help matches 11.. store result storage ridedragon:settings rd_admin.fire_cooldown int 1.0 run scoreboard players remove #rd_math rd_help 10 + +function ridedragon:admin + diff --git a/1_21_0/data/ridedragon/function/z_admin/fireball_cooldown_increase.mcfunction b/1_21_0/data/ridedragon/function/z_admin/fireball_cooldown_increase.mcfunction new file mode 100644 index 0000000..1b9ea11 --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_admin/fireball_cooldown_increase.mcfunction @@ -0,0 +1,11 @@ +# +# Description: Increase the cooldown time for firing dragon fireballs +# Called by: ridedragon:admin via chat link +# Entity @s: player +# + +execute store result score #rd_math rd_help run data get storage ridedragon:settings rd_admin.fire_cooldown +execute if score #rd_math rd_help matches ..600 store result storage ridedragon:settings rd_admin.fire_cooldown int 1.0 run scoreboard players add #rd_math rd_help 10 + +function ridedragon:admin + diff --git a/1_21_0/data/ridedragon/function/z_admin/summon_without_book_toggle.mcfunction b/1_21_0/data/ridedragon/function/z_admin/summon_without_book_toggle.mcfunction new file mode 100644 index 0000000..2b12df6 --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_admin/summon_without_book_toggle.mcfunction @@ -0,0 +1,12 @@ +# +# Description: Enable/disable summoning of tame dragons without holding the Book of Dragons +# Called by: ridedragon:admin via chat link +# Entity @s: player +# +execute store success score #rd_success rd_help run data modify storage ridedragon:settings rd_admin.summon_without_book set value "Disabled" +execute unless score #rd_success rd_help matches 1 run data modify storage ridedragon:settings rd_admin.summon_without_book set value "Enabled" +# +tellraw @s [{"text":"Summoning dragons without the Book of Dragons has been ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.summon_without_book"}] +# +function ridedragon:admin + diff --git a/1_21_0/data/ridedragon/function/z_admin/vanish_all.mcfunction b/1_21_0/data/ridedragon/function/z_admin/vanish_all.mcfunction new file mode 100644 index 0000000..7fb5eb7 --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_admin/vanish_all.mcfunction @@ -0,0 +1,3 @@ +kill @e[type=ender_dragon,tag=dragonvisible] +kill @e[type=marker,tag=dragonhelper] +kill @e[type=horse,tag=dragonseat] diff --git a/1_21_0/data/ridedragon/function/z_dragon_cleanup.mcfunction b/1_21_0/data/ridedragon/function/z_dragon_cleanup.mcfunction new file mode 100644 index 0000000..9640b0d --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_dragon_cleanup.mcfunction @@ -0,0 +1,6 @@ +execute as @e[type=ender_dragon,tag=dragonvisible] at @s run function ridedragon:z_dragon_cleanup_visible + +execute as @e[type=horse,tag=dragonseat] at @s unless entity @e[tag=dragonvisible,distance=..7,limit=1] run kill @s +execute as @e[type=marker,tag=dragonhelper] at @s unless entity @e[tag=dragonvisible,distance=..7,limit=1] run kill @s + +schedule function ridedragon:z_dragon_cleanup 23t diff --git a/1_21_0/data/ridedragon/function/z_dragon_cleanup_visible.mcfunction b/1_21_0/data/ridedragon/function/z_dragon_cleanup_visible.mcfunction new file mode 100644 index 0000000..2ed13ec --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_dragon_cleanup_visible.mcfunction @@ -0,0 +1,3 @@ +execute unless entity @e[type=minecraft:horse,tag=dragonseat,distance=..7,limit=1] run kill @s +execute unless entity @e[type=minecraft:marker,tag=dragonhelper,distance=..7,limit=1] run kill @s + diff --git a/1_21_0/data/ridedragon/function/z_dragon_motion.mcfunction b/1_21_0/data/ridedragon/function/z_dragon_motion.mcfunction new file mode 100644 index 0000000..eccc094 --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_dragon_motion.mcfunction @@ -0,0 +1,26 @@ +# called as dragon_visible, at same + +# Fireball cooldown handling +scoreboard players remove @s[scores={rd_fire_cooldown=1..}] rd_fire_cooldown 1 + +# Find all the parts of the flying stack and tag them as +# dragonvisible_selected, dragonhelper_selected, dragonseat_selected, dragonrider_selected + +scoreboard players operation #rd_selected_id rd_id = @s rd_id +tag @s add dragonvisible_selected +execute as @e[type=marker,tag=dragonhelper,distance=..7] if score @s rd_id = #rd_selected_id rd_id run tag @s add dragonhelper_selected +execute as @e[type=horse,tag=dragonseat,distance=..7] if score @s rd_id = #rd_selected_id rd_id run tag @s add dragonseat_selected +tag @a[nbt={RootVehicle:{Entity:{Tags:["dragonseat_selected"]}}},distance=..7,limit=1] add dragonrider_selected + +# Reset HurtTime to keep the knockback effect of the dragon disabled. It seems to be reset +# by actual harming of the dragon, so set it back to -1. +data modify entity @s HurtTime set value -1 + +execute as @a[tag=dragonrider_selected,distance=..7,limit=1] run function ridedragon:z_player_motion +execute as @e[type=marker,tag=dragonhelper_selected,distance=..7,limit=1] unless entity @a[distance=..7,limit=1,tag=dragonrider_selected] run function ridedragon:z_no_player_motion + +tag @s remove dragonvisible_selected +tag @a[distance=..7,tag=dragonrider_selected,limit=1] remove dragonrider_selected +tag @e[type=marker,distance=..7,tag=dragonhelper_selected,limit=1] remove dragonhelper_selected +tag @e[type=horse,distance=..7,tag=dragonseat_selected,limit=1] remove dragonseat_selected + diff --git a/1_21_0/data/ridedragon/function/z_enable.mcfunction b/1_21_0/data/ridedragon/function/z_enable.mcfunction new file mode 100644 index 0000000..9763d6f --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_enable.mcfunction @@ -0,0 +1,10 @@ +# +# Periodic reset of triggers on reload +# +scoreboard players enable @p rd_help +scoreboard players enable @p rd_summon +scoreboard players enable @p rd_vanish +scoreboard players enable @p rd_silence + +# Repeat every 4 seconds +schedule function ridedragon:z_enable 83t diff --git a/1_21_0/data/ridedragon/function/z_fireball_get_motion.mcfunction b/1_21_0/data/ridedragon/function/z_fireball_get_motion.mcfunction new file mode 100644 index 0000000..8931905 --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_fireball_get_motion.mcfunction @@ -0,0 +1,22 @@ +# Extraction looking direction to compute motion for the fireball. Inspired by +# https://www.reddit.com/r/MinecraftCommands/wiki/questions/shootfacing/ + +# this function is executed as the marker entity, positioned at 0 0 0 and still rotated as the player +# (as that wasn't changed with the function call) + +# teleport the entity forward by 0.2 block (based on the player rotation and the position 0 0 0). +# this will form the "acceleration_power" of the dragon fireball +tp @s ^ ^ ^0.1 + +# store the current position in the worlds NBT storage so we don't loose it +data modify storage ridedragon:tmp Motion set from entity @s Pos + +# teleport the entity forward by another 0.6 block +# this will form the "direction" of the dragon fireball +tp @s ^ ^ ^0.6 + +# store the current position in the worlds NBT storage so we don't loose it +data modify storage ridedragon:tmp Motion2 set from entity @s Pos + +# we don't need this entity anymore +kill @s diff --git a/1_21_0/data/ridedragon/function/z_help/credits.mcfunction b/1_21_0/data/ridedragon/function/z_help/credits.mcfunction new file mode 100644 index 0000000..775d270 --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_help/credits.mcfunction @@ -0,0 +1,10 @@ +# +# Description: Display credits in chat +# Called by: ridedragon:z_help_trigger +# Entity @s: Player +# +tellraw @s [{"text":"Rideable Dragons - Credits","color":"yellow","bold":true}] +tellraw @s [{"text":"Created by: ","color":"aqua"},{"text":"ptefar","color":"#87325d","bold":true,"clickEvent":{"action":"open_url","value":"https://www.youtube.com/channel/UC3ro2x7YnyNt8V1t1bUYfXA"}}] +tellraw @s [{"text":"Based on an idea from: ","color":"aqua"},{"text":"John Paul Inso","color":"#0072e5","bold":true,"clickEvent":{"action":"open_url","value":"https://youtu.be/vBUknTYjylc"}}] +tellraw @s [{"text":"Some frameworks from: ","color":"aqua"},{"text":"Armor Statues datapack","color":"#0072e5","bold":true,"clickEvent":{"action":"open_url","value":"https://www.curseforge.com/minecraft/customization/armor-statues-datapack"}}] +tellraw @s [{"text":"--------------------------","color":"yellow","bold":true}] diff --git a/1_21_0/data/ridedragon/function/z_help/get_book.mcfunction b/1_21_0/data/ridedragon/function/z_help/get_book.mcfunction new file mode 100644 index 0000000..1b92fb0 --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_help/get_book.mcfunction @@ -0,0 +1,7 @@ +# +# Description: Get book via chat link +# Called by: ridedragon:z_help +# Entity @s: Player +# +function ridedragon:give_book + diff --git a/1_21_0/data/ridedragon/function/z_help/main.mcfunction b/1_21_0/data/ridedragon/function/z_help/main.mcfunction new file mode 100644 index 0000000..cd1becb --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_help/main.mcfunction @@ -0,0 +1,10 @@ +# +# Description: Display main help options +# Called by: ridedragon:z_help_trigger +# Entity @s: Player +# +tellraw @s [{"text":"Rideable Dragons - Help","color":"yellow","bold":true},{"text":"\nDragons can be summoned via the ","color":"aqua","bold":false},{"text":"Book of Dragons","color":"light_purple","bold":false},{"text":"\nSummoned dragons are mounted by clicking on their necks\nGet the book by:","color":"aqua","bold":false}] +execute if data storage ridedragon:settings rd_admin{book_help:"Enabled"} run tellraw @s [{"text":" - Clicking ","color":"aqua"},{"text":"here","color":"green","clickEvent":{"action":"run_command","value":"/trigger rd_help set 10"}}] +execute if data storage ridedragon:settings rd_admin{can_fire:"Enabled"} run tellraw @s [{"text":"Hold an End Crystal and look below the horizon while mounted to launch dragon fireballs","color":"aqua"}] +tellraw @s [{"text":"Credits","color":"green","clickEvent":{"action":"run_command","value":"/trigger rd_help set 11"}}] +tellraw @s [{"text":"--------------------------","color":"yellow","bold":true}] diff --git a/1_21_0/data/ridedragon/function/z_help_trigger.mcfunction b/1_21_0/data/ridedragon/function/z_help_trigger.mcfunction new file mode 100644 index 0000000..ad42aac --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_help_trigger.mcfunction @@ -0,0 +1,14 @@ +# +# Description: Display help in chat +# Called by: ridedragon:z_main +# Entity @s: player +# +execute if score @s rd_help matches 10 if data storage ridedragon:settings rd_admin{book_help:"Enabled"} run function ridedragon:z_help/get_book +execute if score @s rd_help matches 11 run function ridedragon:z_help/credits +execute if score @s rd_help matches 1..9 run function ridedragon:z_help/main + +# +# Reset trigger score +# +scoreboard players set @s rd_help 0 +scoreboard players enable @s rd_help diff --git a/1_21_0/data/ridedragon/function/z_init.mcfunction b/1_21_0/data/ridedragon/function/z_init.mcfunction new file mode 100644 index 0000000..bd92c25 --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_init.mcfunction @@ -0,0 +1,40 @@ +# +# Description: Create scoreboards +# Called by: #main:init +# Entity @s: None +# +# Create scoreboards +# +scoreboard objectives add rd_help trigger +scoreboard objectives add rd_summon trigger +scoreboard objectives add rd_vanish trigger +scoreboard objectives add rd_silence trigger +scoreboard objectives add rd_id dummy +# Cooldown timer per dragon, not player +scoreboard objectives add rd_fire_cooldown dummy + +# +# Resets triggers on reload +# Also rerun in the z_enable repeating function +# +scoreboard players enable * rd_help +scoreboard players enable * rd_summon +scoreboard players enable * rd_vanish +scoreboard players enable * rd_silence +# + +# +# Sets storage settings +# +execute unless data storage ridedragon:settings rd_admin.book_help run data modify storage ridedragon:settings rd_admin.book_help set value "Disabled" +execute unless data storage ridedragon:settings rd_admin.can_summon run data modify storage ridedragon:settings rd_admin.can_summon set value "Disabled" +execute unless data storage ridedragon:settings rd_admin.summon_without_book run data modify storage ridedragon:settings rd_admin.summon_without_book set value "Disabled" +execute unless data storage ridedragon:settings rd_admin.can_fire run data modify storage ridedragon:settings rd_admin.can_fire set value "Disabled" +execute unless data storage ridedragon:settings rd_admin.dragon_health run data modify storage ridedragon:settings rd_admin.dragon_health set value 5 +execute unless data storage ridedragon:settings rd_admin.fire_cooldown run data modify storage ridedragon:settings rd_admin.fire_cooldown set value 200 + +# Schedule function to remove orphaned dragon components every 1 seconds (use a prime number of ticks) +schedule function ridedragon:z_dragon_cleanup 23t + +# Schedule function to enable the scoreboard objectives for all players every 4 seconds (use a prime number of ticks) +schedule function ridedragon:z_enable 83t diff --git a/1_21_0/data/ridedragon/function/z_launch_fireball.mcfunction b/1_21_0/data/ridedragon/function/z_launch_fireball.mcfunction new file mode 100644 index 0000000..ffaea6f --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_launch_fireball.mcfunction @@ -0,0 +1,30 @@ +# Summon a new dragon fireball +#summon minecraft:dragon_fireball ~ ~4 ~ {Tags:["dragon_fireball_selected","dragon_fireball"],direction:[0.5,0.0,0.0],acceleration_power:[0.1,-0.1,0.0],Owner:[I;1,1,1,1]} +summon minecraft:dragon_fireball ^ ^ ^8 {Tags:["dragon_fireball_selected","dragon_fireball"]} + +# Mark the dragon as the owner so that the dragon's breath can be collected from the +# area_effect_cloud after the dragon fireball lands +data modify entity @e[tag=dragon_fireball_selected,distance=..10,limit=1] Owner set from entity @e[tag=dragonvisible_selected,distance=..10,limit=1] UUID + +# Start the cooldown for the dragon to fire as configured in the admin menu +execute store result score @e[tag=dragonvisible_selected,limit=1] rd_fire_cooldown run data get storage ridedragon:settings rd_admin.fire_cooldown + + +# Set up motion. Inspired by +# https://www.reddit.com/r/MinecraftCommands/wiki/questions/shootfacing/ +# summon the temporary entity at the players position +summon marker ~ ~ ~ {Tags:["direction_marker"]} + +# execute the below function as the marker entity, so it doesn't get lost from being unloaded +# run positioned at the world zero point. this will remove the marker +execute as @e[tag=direction_marker,distance=..10,limit=1] positioned 0.0 0.0 0.0 run function ridedragon:z_fireball_get_motion + +# store the previously stored Motion into the projectile entity +# Note that dragon fireballs use "direction" for the initial direction and +# "power" for the constant acceleration countering drag. +data modify entity @e[tag=dragon_fireball_selected,limit=1] power set from storage ridedragon:tmp Motion +data modify entity @e[tag=dragon_fireball_selected,limit=1] direction set from storage ridedragon:tmp Motion2 +# clean up the tag +tag @e[tag=dragon_fireball_selected] remove dragon_fireball_selected + + diff --git a/1_21_0/data/ridedragon/function/z_main.mcfunction b/1_21_0/data/ridedragon/function/z_main.mcfunction new file mode 100644 index 0000000..1b0c5d3 --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_main.mcfunction @@ -0,0 +1,8 @@ +execute as @a[scores={rd_summon=1..}] at @s run function ridedragon:z_summon_trigger +execute as @a[scores={rd_vanish=1..}] at @s run function ridedragon:z_vanish_trigger +execute as @a[scores={rd_silence=1..}] at @s run function ridedragon:z_silence_trigger +execute as @a[scores={rd_help=1..}] at @s run function ridedragon:z_help_trigger + +execute as @e[type=ender_dragon,tag=dragonvisible] at @s run function ridedragon:z_dragon_motion + + diff --git a/1_21_0/data/ridedragon/function/z_no_player_motion.mcfunction b/1_21_0/data/ridedragon/function/z_no_player_motion.mcfunction new file mode 100644 index 0000000..69e89bf --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_no_player_motion.mcfunction @@ -0,0 +1,8 @@ +# Executed as dragonhelper, no position + +execute as @s at @s if block ~ ~-1.2 ~ air run tp @s ~ ~-0.1 ~ +execute as @s at @s unless block ~ ~-1.2 ~ air run tp @s ~ ~0.1 ~ + +execute as @s at @s run tp @e[type=horse,distance=..7,tag=dragonseat_selected,limit=1] ~ ~ ~ ~ ~ + +execute as @e[distance=..7,tag=dragonseat_selected,limit=1] at @s rotated ~ 0 positioned ^ ^ ^-3.5 rotated as @s run tp @e[tag=dragonvisible_selected,limit=1,distance=..7] ~ ~-1.0 ~ ~-180 ~ diff --git a/1_21_0/data/ridedragon/function/z_player_motion.mcfunction b/1_21_0/data/ridedragon/function/z_player_motion.mcfunction new file mode 100644 index 0000000..e534c20 --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_player_motion.mcfunction @@ -0,0 +1,26 @@ +# Executed as dragonrider, no position + +# Low speed default +execute as @s at @s positioned ^ ^ ^0.2 positioned ~ ~-0.85 ~ if block ~ ~-1.3 ~ air run tp @e[type=marker,distance=..7,tag=dragonhelper_selected,limit=1] ~ ~ ~ ~ ~ + +# High speed when holding the book +execute if entity @s[predicate=ridedragon:book_holder_mainhand] at @s positioned ^ ^ ^1.0 positioned ~ ~-0.85 ~ if block ~ ~-1.3 ~ air run tp @e[type=marker,distance=..7,tag=dragonhelper_selected,limit=1] ~ ~ ~ ~ ~ +execute if entity @s[predicate=ridedragon:book_holder_offhand] at @s positioned ^ ^ ^1.0 positioned ~ ~-0.85 ~ if block ~ ~-1.3 ~ air run tp @e[type=marker,distance=..7,tag=dragonhelper_selected,limit=1] ~ ~ ~ ~ ~ + +#Move the dragonseat (horse) to the helper marker +execute as @e[type=marker,distance=..7,tag=dragonhelper_selected,limit=1] at @s run tp @e[type=horse,distance=..7,tag=dragonseat_selected,limit=1] ~ ~ ~ ~ ~ + + +# Move the dragon to the correct offset relative to the player/dragonseat depending on the low/high speed +# Low speed +execute as @e[type=horse,distance=..7,tag=dragonseat_selected,limit=1] at @s rotated ~ 0 positioned ^ ^ ^-2.6 rotated as @s run tp @e[type=ender_dragon,tag=dragonvisible_selected,limit=1,sort=nearest,distance=..7] ~ ~-0.7 ~ ~-180 ~ +# High speed looking up or forward +execute if entity @s[predicate=ridedragon:book_holder_mainhand] as @e[type=horse,distance=..7,tag=dragonseat_selected,limit=1] at @s positioned ^ ^ ^-2.7 rotated as @s run tp @e[type=ender_dragon,tag=dragonvisible_selected,limit=1,sort=nearest,distance=..7] ~ ~-0.7 ~ ~-180 ~ +execute if entity @s[predicate=ridedragon:book_holder_offhand] as @e[type=horse,distance=..7,tag=dragonseat_selected,limit=1] at @s positioned ^ ^ ^-2.7 rotated as @s run tp @e[type=ender_dragon,tag=dragonvisible_selected,limit=1,sort=nearest,distance=..7] ~ ~-0.7 ~ ~-180 ~ +# High speed looking down +execute if entity @s[x_rotation=10..90,predicate=ridedragon:book_holder_mainhand] as @e[type=horse,distance=..7,tag=dragonseat_selected,limit=1] at @s rotated ~ 0 positioned ^ ^ ^-2.7 rotated as @s positioned ^ ^ ^-2.2 rotated as @s run tp @e[type=ender_dragon,tag=dragonvisible_selected,limit=1,sort=nearest,distance=..7] ~ ~-0.7 ~ ~-180 ~ +execute if entity @s[x_rotation=10..90,predicate=ridedragon:book_holder_offhand] as @e[type=horse,distance=..7,tag=dragonseat_selected,limit=1] at @s rotated ~ 0 positioned ^ ^ ^-2.7 rotated as @s positioned ^ ^ ^-2.2 rotated as @s run tp @e[type=ender_dragon,tag=dragonvisible_selected,limit=1,sort=nearest,distance=..7] ~ ~-0.7 ~ ~-180 ~ + + +# Check if dragon fireballs are enabled the trigger held and looking sufficiently below the horizon (10 degrees or more) +execute if data storage ridedragon:settings rd_admin{can_fire:"Enabled"} run execute if entity @s[x_rotation=10..90,predicate=ridedragon:is_holding_trigger_item] at @s run execute if entity @e[tag=dragonvisible_selected,limit=1,scores={rd_fire_cooldown=0}] run function ridedragon:z_launch_fireball diff --git a/1_21_0/data/ridedragon/function/z_silence_toggle.mcfunction b/1_21_0/data/ridedragon/function/z_silence_toggle.mcfunction new file mode 100644 index 0000000..f63c0ce --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_silence_toggle.mcfunction @@ -0,0 +1,6 @@ + +execute store success score #rd_success rd_help run data modify entity @s Silent set value 1b +execute unless score #rd_success rd_help matches 1 run data modify entity @s Silent set value 0b + +execute if score #rd_success rd_help matches 1 run tellraw @p [{"text":"The dragon has been ","color":"aqua"},{"text":"silenced","color":"yellow"}] +execute unless score #rd_success rd_help matches 1 run tellraw @p [{"text":"The dragon has been ","color":"aqua"},{"text":"granted its voice back","color":"yellow"}] diff --git a/1_21_0/data/ridedragon/function/z_silence_trigger.mcfunction b/1_21_0/data/ridedragon/function/z_silence_trigger.mcfunction new file mode 100644 index 0000000..b33c19f --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_silence_trigger.mcfunction @@ -0,0 +1,7 @@ + +function ridedragon:silence_dragon +# +# Reset player's trigger score and re-enable +# +scoreboard players set @s rd_silence 0 +scoreboard players enable @s rd_silence diff --git a/1_21_0/data/ridedragon/function/z_summon_trigger.mcfunction b/1_21_0/data/ridedragon/function/z_summon_trigger.mcfunction new file mode 100644 index 0000000..04982ee --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_summon_trigger.mcfunction @@ -0,0 +1,20 @@ +# Need to clear the rd_help scoreboard first as no-match in an execute statement is +# not considered a failure (see https://bugs.mojang.com/browse/MC-125058) +scoreboard players set #rd_success rd_help 0 + +# Test for the conditions allowing summoning: +# - creative player, +# - non-creative player summoning and allowing bare triggers +# - non-creative player holding the Book of Dragons +execute store success score #rd_success rd_help if entity @s[gamemode=creative] run function ridedragon:summon_dragon +execute store success score #rd_success rd_help unless score #rd_success rd_help matches 1 if data storage ridedragon:settings rd_admin{can_summon:"Enabled"} if data storage ridedragon:settings rd_admin{summon_without_book:"Enabled"} run function ridedragon:summon_dragon +execute unless score #rd_success rd_help matches 1 if data storage ridedragon:settings rd_admin{can_summon:"Enabled"} if items entity @s container.* minecraft:written_book[minecraft:custom_data~{DragonBook:"1"}] run function ridedragon:summon_dragon + +execute unless entity @s[gamemode=creative] unless data storage ridedragon:settings rd_admin{can_summon:"Enabled"} run tellraw @s [{"text":"Dragon","color":"light_purple"},{"text":" summoning is globally disabled","color":"aqua"}] + +# +# Reset player's trigger score and re-enable +# +scoreboard players set @s rd_summon 0 +scoreboard players enable @s rd_summon + diff --git a/1_21_0/data/ridedragon/function/z_vanish_trigger.mcfunction b/1_21_0/data/ridedragon/function/z_vanish_trigger.mcfunction new file mode 100644 index 0000000..2fd68a0 --- /dev/null +++ b/1_21_0/data/ridedragon/function/z_vanish_trigger.mcfunction @@ -0,0 +1,8 @@ +function ridedragon:vanish_dragon + +# +# Reset player's trigger score and re-enable +# +scoreboard players set @s rd_vanish 0 +scoreboard players enable @s rd_vanish + diff --git a/1_21_0/data/ridedragon/loot_table/book.json b/1_21_0/data/ridedragon/loot_table/book.json new file mode 100644 index 0000000..b3f34b2 --- /dev/null +++ b/1_21_0/data/ridedragon/loot_table/book.json @@ -0,0 +1,57 @@ +{ + "type": "minecraft:loot", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:written_book", + "functions": [ + { + "function": "minecraft:set_custom_data", + "tag": { + "DragonBook": "1" + } + }, + { + "function": "minecraft:set_custom_model_data", + "value": 10 + }, + { + "function": "minecraft:set_book_cover", + "title": "Book of Dragons", + "author": "ptefar", + "generation": 0 + }, + { + "function": "minecraft:set_written_book_pages", + "mode": "replace_all", + "pages":[ + [ + {"text":"Book of Dragons","bold":true,"color":"dark_purple"}, + {"text":"\n\nRiding a dragon in three easy steps:\n\n1. ","bold":false,"color":"black"}, + {"text":"Summon the Dragon","underlined":true,"bold":false,"clickEvent":{"action":"run_command","value":"/trigger rd_summon"},"hoverEvent":{"action":"show_text","contents":"... or type \"/trigger rd_summon\" in chat"}}, + {"text":"\n2. Click the dragon\\'s\n neck w. empty hand\n3. ","color":"black","bold":false}, + {"text":"Vanish the dragon","underlined":true,"bold":false,"clickEvent":{"action":"run_command","value":"/trigger rd_vanish"},"hoverEvent":{"action":"show_text","contents":"... or type \"/trigger rd_vanish\" in chat"}}, + {"text":"\n\nThe dragon flies faster when you hold this book.","bold":false,"color":"black"} + ], + [ + {"text":"\n\nYou unmount your dragon by sneaking.\n\nIf you think your new pet is too noisy you can ","bold":false}, + {"text":"toggle its voice","underlined":true,"bold":false,"clickEvent":{"action":"run_command","value":"/trigger rd_silence"},"hoverEvent":{"action":"show_text","contents":"... or type \"/trigger rd_silence\" in chat"}}, + {"text":".","color":"black","bold":false,"clickEvent":{"action":"run_command","value":"/trigger rd_silence"},"hoverEvent":{"action":"show_text","contents":"... or type \"/trigger rd_silence\" in chat"}} + ], + [ + {"text":"\n\nPlease see the ","bold":false}, + {"text":"help","bold":true,"underlined":true,"clickEvent":{"action":"run_command","value":"/trigger rd_help"}}, + {"text":" for further information.\n\n\nDatapack by ","bold":false,"color":"black"}, + {"text":"Ptefar","underlined":true,"bold":false,"clickEvent":{"action":"open_url","value":"https://www.youtube.com/channel/UC3ro2x7YnyNt8V1t1bUYfXA"}} + ] + ] + } + ] + } + ] + } + ] +} diff --git a/1_21_0/data/ridedragon/predicate/book_holder_mainhand.json b/1_21_0/data/ridedragon/predicate/book_holder_mainhand.json new file mode 100644 index 0000000..4660c1a --- /dev/null +++ b/1_21_0/data/ridedragon/predicate/book_holder_mainhand.json @@ -0,0 +1,18 @@ +{ + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "type": "minecraft:player", + "equipment": { + "mainhand": { + "items": "minecraft:written_book", + "count": { + "min": 1 + }, + "predicates": { + "minecraft:custom_data": {"DragonBook":"1"} + } + } + } + } +} diff --git a/1_21_0/data/ridedragon/predicate/book_holder_offhand.json b/1_21_0/data/ridedragon/predicate/book_holder_offhand.json new file mode 100644 index 0000000..6651fd9 --- /dev/null +++ b/1_21_0/data/ridedragon/predicate/book_holder_offhand.json @@ -0,0 +1,19 @@ +{ + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "type": "minecraft:player", + "equipment": { + "offhand": { + "items": "minecraft:written_book", + "count": { + "min": 1 + }, + "predicates": { + "minecraft:custom_data": {"DragonBook":"1"} + } + } + } + } +} + diff --git a/1_21_0/data/ridedragon/predicate/is_holding_trigger_item.json b/1_21_0/data/ridedragon/predicate/is_holding_trigger_item.json new file mode 100644 index 0000000..01c701f --- /dev/null +++ b/1_21_0/data/ridedragon/predicate/is_holding_trigger_item.json @@ -0,0 +1,15 @@ +{ + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "type": "minecraft:player", + "equipment": { + "mainhand": { + "items": "minecraft:end_crystal", + "count": { + "min": 1 + } + } + } + } +} diff --git a/Changes.txt b/Changes.txt index 6da2cd9..6624aa3 100644 --- a/Changes.txt +++ b/Changes.txt @@ -1,3 +1,11 @@ +rev 1.5 +--------- + +- 1.20.5 - 1.21 compatibility: new datapack format +- all versions: fixed bug where multiple dragons spawned simultaneously for creative users when + the admin menu allowed non-book spawning +- all versions: the fireball cooldown is now configurable in the admin menu + rev 1.4 --------- diff --git a/README.md b/README.md index d8c049f..a71c513 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,8 @@ the admin interface. ----- Important ----- It is recommended to use the "Anti Ender Dragon Grief" data pack (https://modrinth.com/datapack/anti-ender-dragon-grief) by Dragon3025 to prevent the dragons from -erasing parts of the world as they are flown around. +erasing parts of the world as they are flown around. Make sure to get the version suitable for +your Minecraft version. --------------------- This datapack was inspired by the video https://www.youtube.com/watch?v=vBUknTYjylc&t=284s by John diff --git a/data/ridedragon/functions/admin.mcfunction b/data/ridedragon/functions/admin.mcfunction index a3bfe10..a6c694d 100644 --- a/data/ridedragon/functions/admin.mcfunction +++ b/data/ridedragon/functions/admin.mcfunction @@ -8,6 +8,7 @@ tellraw @s [{"text":"Get book from help: ","color":"aqua"},{"storage":"ridedrago tellraw @s [{"text":"Survival players can summon dragons: ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.can_summon", "color":"green", "clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/can_summon_toggle"}, "hoverEvent":{"action":"show_text", "contents":{"text":"Click to toggle", "color":"yellow"}}}] tellraw @s [{"text":"Summon without the ","color":"aqua"},{"text":"Book of Dragons","color":"light_purple"},{"text":": ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.summon_without_book", "color":"green", "clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/summon_without_book_toggle"}, "hoverEvent":{"action":"show_text", "contents":{"text":"Click to toggle", "color":"yellow"}}}] tellraw @s [{"text":"Players can fire dragon fireballs: ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.can_fire", "color":"green", "clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/can_fire_toggle"}, "hoverEvent":{"action":"show_text", "contents":{"text":"Click to toggle", "color":"yellow"}}}] +tellraw @s [{"text":"Fireball cooldown (1/20s): ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.fire_cooldown"},{"text":" (","color":"aqua"},{"text":" + ", "color":"green","clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/fireball_cooldown_increase"},"hoverEvent":{"action":"show_text", "contents":{"text":"Click to increase", "color":"yellow"}}},{"text":"/","color":"aqua"},{"text":" - ", "color":"green","clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/fireball_cooldown_decrease"},"hoverEvent":{"action":"show_text", "contents":{"text":"Click to decrease", "color":"yellow"}}},{"text":")","color":"aqua"}] tellraw @s [{"text":"Initial dragon health : ","color":"aqua"},{"storage":"ridedragon:settings", "nbt":"rd_admin.dragon_health"},{"text":" (","color":"aqua"},{"text":" + ", "color":"green","clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/dragon_health_increase"},"hoverEvent":{"action":"show_text", "contents":{"text":"Click to increase", "color":"yellow"}}},{"text":"/","color":"aqua"},{"text":" - ", "color":"green","clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/dragon_health_decrease"},"hoverEvent":{"action":"show_text", "contents":{"text":"Click to decrease", "color":"yellow"}}},{"text":")","color":"aqua"}] tellraw @s [{"text":"Vanish all tame tragons", "color":"red", "clickEvent":{"action":"run_command", "value":"/function ridedragon:z_admin/vanish_all"}, "hoverEvent":{"action":"show_text", "contents":{"text":"Click to vanish all loaded tame dragons", "color":"red"}}}] tellraw @s [{"text":"--------------------------","color":"yellow","bold":true}] diff --git a/data/ridedragon/functions/summon_dragon.mcfunction b/data/ridedragon/functions/summon_dragon.mcfunction index 8dbf808..bc57dd7 100644 --- a/data/ridedragon/functions/summon_dragon.mcfunction +++ b/data/ridedragon/functions/summon_dragon.mcfunction @@ -16,3 +16,5 @@ data modify entity @e[tag=dragon_temp,limit=1] Health set from storage ridedrago scoreboard players operation @e[type=minecraft:ender_dragon,tag=dragon_temp,distance=..2,limit=1] rd_id = #rd_global_cnt rd_id scoreboard players set @e[tag=dragon_temp,limit=1] rd_fire_cooldown 0 tag @e[type=minecraft:ender_dragon,tag=dragon_temp,distance=..2,limit=1] remove dragon_temp + +return 1 diff --git a/data/ridedragon/functions/z_admin/dragon_health_increase.mcfunction b/data/ridedragon/functions/z_admin/dragon_health_increase.mcfunction index bff5a3a..87a8499 100644 --- a/data/ridedragon/functions/z_admin/dragon_health_increase.mcfunction +++ b/data/ridedragon/functions/z_admin/dragon_health_increase.mcfunction @@ -1,5 +1,5 @@ # -# Description: Disable fireing of dragon fireballs +# Description: Increase the dragon health when spawned # Called by: ridedragon:admin via chat link # Entity @s: player # diff --git a/data/ridedragon/functions/z_admin/fireball_cooldown_decrease.mcfunction b/data/ridedragon/functions/z_admin/fireball_cooldown_decrease.mcfunction new file mode 100644 index 0000000..a6334d1 --- /dev/null +++ b/data/ridedragon/functions/z_admin/fireball_cooldown_decrease.mcfunction @@ -0,0 +1,11 @@ +# +# Description: Decrease the cooldown time for dragon fireballs +# Called by: ridedragon:admin via chat link +# Entity @s: player +# + +execute store result score #rd_math rd_help run data get storage ridedragon:settings rd_admin.fire_cooldown +execute if score #rd_math rd_help matches 11.. store result storage ridedragon:settings rd_admin.fire_cooldown int 1.0 run scoreboard players remove #rd_math rd_help 10 + +function ridedragon:admin + diff --git a/data/ridedragon/functions/z_admin/fireball_cooldown_increase.mcfunction b/data/ridedragon/functions/z_admin/fireball_cooldown_increase.mcfunction new file mode 100644 index 0000000..1b9ea11 --- /dev/null +++ b/data/ridedragon/functions/z_admin/fireball_cooldown_increase.mcfunction @@ -0,0 +1,11 @@ +# +# Description: Increase the cooldown time for firing dragon fireballs +# Called by: ridedragon:admin via chat link +# Entity @s: player +# + +execute store result score #rd_math rd_help run data get storage ridedragon:settings rd_admin.fire_cooldown +execute if score #rd_math rd_help matches ..600 store result storage ridedragon:settings rd_admin.fire_cooldown int 1.0 run scoreboard players add #rd_math rd_help 10 + +function ridedragon:admin + diff --git a/data/ridedragon/functions/z_init.mcfunction b/data/ridedragon/functions/z_init.mcfunction index 8d1a088..bd92c25 100644 --- a/data/ridedragon/functions/z_init.mcfunction +++ b/data/ridedragon/functions/z_init.mcfunction @@ -31,6 +31,7 @@ execute unless data storage ridedragon:settings rd_admin.can_summon run data mod execute unless data storage ridedragon:settings rd_admin.summon_without_book run data modify storage ridedragon:settings rd_admin.summon_without_book set value "Disabled" execute unless data storage ridedragon:settings rd_admin.can_fire run data modify storage ridedragon:settings rd_admin.can_fire set value "Disabled" execute unless data storage ridedragon:settings rd_admin.dragon_health run data modify storage ridedragon:settings rd_admin.dragon_health set value 5 +execute unless data storage ridedragon:settings rd_admin.fire_cooldown run data modify storage ridedragon:settings rd_admin.fire_cooldown set value 200 # Schedule function to remove orphaned dragon components every 1 seconds (use a prime number of ticks) schedule function ridedragon:z_dragon_cleanup 23t diff --git a/data/ridedragon/functions/z_launch_fireball.mcfunction b/data/ridedragon/functions/z_launch_fireball.mcfunction index 2ba7ead..1d628e1 100644 --- a/data/ridedragon/functions/z_launch_fireball.mcfunction +++ b/data/ridedragon/functions/z_launch_fireball.mcfunction @@ -6,8 +6,9 @@ summon minecraft:dragon_fireball ^ ^ ^8 {Tags:["dragon_fireball_selected","drago # area_effect_cloud after the dragon fireball lands data modify entity @e[tag=dragon_fireball_selected,distance=..10,limit=1] Owner set from entity @e[tag=dragonvisible_selected,distance=..10,limit=1] UUID -# Start the cooldown to 10 seconds = 200 ticks for the dragon -scoreboard players set @e[tag=dragonvisible_selected,limit=1] rd_fire_cooldown 200 +# Start the cooldown for the dragon to fire as configured in the admin menu +execute store result score @e[tag=dragonvisible_selected,limit=1] rd_fire_cooldown run data get storage ridedragon:settings rd_admin.fire_cooldown + # Set up motion. Inspired by # https://www.reddit.com/r/MinecraftCommands/wiki/questions/shootfacing/ diff --git a/pack.mcmeta b/pack.mcmeta index 51591f3..fb067e9 100644 --- a/pack.mcmeta +++ b/pack.mcmeta @@ -1,6 +1,35 @@ - { - "pack": { - "pack_format": 17, - "description": "Ridable dragons by ptefar" - } - } +{ + "pack": { + "pack_format": 18, + "supported_formats": { + "min_inclusive": 18, + "max_inclusive": 48 + }, + "description": "Ridable dragons by ptefar" + }, + "overlays": { + "entries": [ + { + "directory": "1_20_3", + "formats": { + "min_inclusive": 19, + "max_inclusive": 9999999 + } + }, + { + "directory": "1_20_5", + "formats": { + "min_inclusive": 41, + "max_inclusive": 9999999 + } + }, + { + "directory": "1_21_0", + "formats": { + "min_inclusive": 48, + "max_inclusive": 9999999 + } + } + ] + } +}