From 317bb347bb31a91475372f6c5e56a9503e1ade45 Mon Sep 17 00:00:00 2001 From: ItsKestrel <36137577+ItsKestrel@users.noreply.github.com> Date: Fri, 20 Dec 2024 01:16:20 -0600 Subject: [PATCH] book --- .../advancement/book_crafting.json | 30 ++++ data/chaotic_crafting/advancement/root.json | 12 ++ .../book_commands/gen_workshop.mcfunction | 4 + .../function/book_commands/reset.mcfunction | 4 + .../book_commands/start_game.mcfunction | 4 + .../function/craft_book.mcfunction | 2 + .../day_manager/failed_day.mcfunction | 2 +- .../function/give_book.mcfunction | 1 + .../chaotic_crafting/function/load.mcfunction | 3 + .../function/replace_book.mcfunction | 4 + .../function/reset.mcfunction | 16 +- .../setup/setup_scoreboards.mcfunction | 7 +- .../setup/spawn_workshop_stage1.mcfunction | 2 +- .../chaotic_crafting/function/tick.mcfunction | 9 +- .../function/util/give_config_book.mcfunction | 2 +- .../function/util/kill_all_markers.mcfunction | 31 ++++ data/chaotic_crafting/loot_table/book.json | 139 ++++++++++++++++++ 17 files changed, 266 insertions(+), 6 deletions(-) create mode 100644 data/chaotic_crafting/advancement/book_crafting.json create mode 100644 data/chaotic_crafting/advancement/root.json create mode 100644 data/chaotic_crafting/function/book_commands/gen_workshop.mcfunction create mode 100644 data/chaotic_crafting/function/book_commands/reset.mcfunction create mode 100644 data/chaotic_crafting/function/book_commands/start_game.mcfunction create mode 100644 data/chaotic_crafting/function/craft_book.mcfunction create mode 100644 data/chaotic_crafting/function/give_book.mcfunction create mode 100644 data/chaotic_crafting/function/replace_book.mcfunction create mode 100644 data/chaotic_crafting/function/util/kill_all_markers.mcfunction create mode 100644 data/chaotic_crafting/loot_table/book.json diff --git a/data/chaotic_crafting/advancement/book_crafting.json b/data/chaotic_crafting/advancement/book_crafting.json new file mode 100644 index 0000000..7da72ea --- /dev/null +++ b/data/chaotic_crafting/advancement/book_crafting.json @@ -0,0 +1,30 @@ +{ + "parent": "chaotic_crafting:root", + "criteria": { + "craft_book": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "items": [ + "minecraft:written_book" + ], + "predicates": { + "minecraft:written_book_content": { + "title": "Chaos" + } + } + } + ] + } + } + }, + "requirements": [ + [ + "craft_book" + ] + ], + "rewards": { + "function": "chaotic_crafting:craft_book" + } +} \ No newline at end of file diff --git a/data/chaotic_crafting/advancement/root.json b/data/chaotic_crafting/advancement/root.json new file mode 100644 index 0000000..78142c5 --- /dev/null +++ b/data/chaotic_crafting/advancement/root.json @@ -0,0 +1,12 @@ +{ + "criteria": { + "impossible": { + "trigger": "minecraft:impossible" + } + }, + "requirements": [ + [ + "impossible" + ] + ] +} \ No newline at end of file diff --git a/data/chaotic_crafting/function/book_commands/gen_workshop.mcfunction b/data/chaotic_crafting/function/book_commands/gen_workshop.mcfunction new file mode 100644 index 0000000..6b4e61e --- /dev/null +++ b/data/chaotic_crafting/function/book_commands/gen_workshop.mcfunction @@ -0,0 +1,4 @@ +execute as @p[scores={cc_gen_workshop=1}] at @s run function chaotic_crafting:setup/spawn_workshop_stage1 + +scoreboard players set @s cc_gen_workshop 0 +scoreboard players enable @s cc_gen_workshop \ No newline at end of file diff --git a/data/chaotic_crafting/function/book_commands/reset.mcfunction b/data/chaotic_crafting/function/book_commands/reset.mcfunction new file mode 100644 index 0000000..904945d --- /dev/null +++ b/data/chaotic_crafting/function/book_commands/reset.mcfunction @@ -0,0 +1,4 @@ +execute as @p[scores={cc_reset=1}] at @s run function chaotic_crafting:reset + +scoreboard players set @s cc_reset 0 +scoreboard players enable @s cc_reset \ No newline at end of file diff --git a/data/chaotic_crafting/function/book_commands/start_game.mcfunction b/data/chaotic_crafting/function/book_commands/start_game.mcfunction new file mode 100644 index 0000000..f466b72 --- /dev/null +++ b/data/chaotic_crafting/function/book_commands/start_game.mcfunction @@ -0,0 +1,4 @@ +execute as @p[scores={cc_start_game=1}] at @s run function chaotic_crafting:start_game + +scoreboard players set @s cc_start_game 0 +scoreboard players enable @s cc_start_game \ No newline at end of file diff --git a/data/chaotic_crafting/function/craft_book.mcfunction b/data/chaotic_crafting/function/craft_book.mcfunction new file mode 100644 index 0000000..ac0cf9d --- /dev/null +++ b/data/chaotic_crafting/function/craft_book.mcfunction @@ -0,0 +1,2 @@ +tag @s add cc_craft_book +advancement revoke @s only chaotic_crafting:book_crafting \ No newline at end of file diff --git a/data/chaotic_crafting/function/day_manager/failed_day.mcfunction b/data/chaotic_crafting/function/day_manager/failed_day.mcfunction index 70061b6..0626286 100644 --- a/data/chaotic_crafting/function/day_manager/failed_day.mcfunction +++ b/data/chaotic_crafting/function/day_manager/failed_day.mcfunction @@ -5,4 +5,4 @@ scoreboard players set $day_timer cc_timer 0 function chaotic_crafting:util/kill_all_customers -function chaotic_crafting:reset \ No newline at end of file +#function chaotic_crafting:reset \ No newline at end of file diff --git a/data/chaotic_crafting/function/give_book.mcfunction b/data/chaotic_crafting/function/give_book.mcfunction new file mode 100644 index 0000000..0ea6fe2 --- /dev/null +++ b/data/chaotic_crafting/function/give_book.mcfunction @@ -0,0 +1 @@ +loot give @s loot chaotic_crafting:book \ No newline at end of file diff --git a/data/chaotic_crafting/function/load.mcfunction b/data/chaotic_crafting/function/load.mcfunction index b5c5c87..9a2835a 100644 --- a/data/chaotic_crafting/function/load.mcfunction +++ b/data/chaotic_crafting/function/load.mcfunction @@ -1,3 +1,6 @@ function chaotic_crafting:setup/setup_scoreboards function chaotic_crafting:setup/set_anchor +scoreboard players enable * cc_gen_workshop +scoreboard players enable * cc_start_game +scoreboard players enable * cc_reset \ No newline at end of file diff --git a/data/chaotic_crafting/function/replace_book.mcfunction b/data/chaotic_crafting/function/replace_book.mcfunction new file mode 100644 index 0000000..36ed288 --- /dev/null +++ b/data/chaotic_crafting/function/replace_book.mcfunction @@ -0,0 +1,4 @@ +execute store result score #cc_success cc_temp run clear @s minecraft:written_book[minecraft:written_book_content~{title:"Chaos"}] 1 +execute if score #cc_success cc_temp matches 1.. run function chaotic_crafting:give_book + +tag @s remove cc_craft_book \ No newline at end of file diff --git a/data/chaotic_crafting/function/reset.mcfunction b/data/chaotic_crafting/function/reset.mcfunction index 8958006..49203d9 100644 --- a/data/chaotic_crafting/function/reset.mcfunction +++ b/data/chaotic_crafting/function/reset.mcfunction @@ -1,3 +1,5 @@ +tellraw @a {"text": "Resetting..."} + scoreboard objectives remove cc_item scoreboard objectives remove cc_timer scoreboard objectives remove cc_customers @@ -19,6 +21,12 @@ scoreboard objectives remove cc_diamond_ore_mined scoreboard objectives remove cc_crafter_ray scoreboard objectives remove rm_marker_ray +scoreboard objectives remove cc_block_ray + +scoreboard objectives remove cc_gen_workshop +scoreboard objectives remove cc_start_game +scoreboard objectives remove cc_reset + kill @e[tag=cc_upgrade_data] function chaotic_crafting:setup/set_upgrade_data_marker @@ -26,4 +34,10 @@ kill @e[tag=cc_trade_data] function chaotic_crafting:setup/set_trade_data_marker -function chaotic_crafting:setup/setup_scoreboards \ No newline at end of file +function chaotic_crafting:setup/setup_scoreboards + + +###Kill all markers? + + +#execute as @e[type=marker,tag=cc_anchor] at @s run function chaotic_crafting:setup/spawn_workshop_stage1 \ No newline at end of file diff --git a/data/chaotic_crafting/function/setup/setup_scoreboards.mcfunction b/data/chaotic_crafting/function/setup/setup_scoreboards.mcfunction index 63eeb01..917dd71 100644 --- a/data/chaotic_crafting/function/setup/setup_scoreboards.mcfunction +++ b/data/chaotic_crafting/function/setup/setup_scoreboards.mcfunction @@ -158,4 +158,9 @@ scoreboard objectives add cc_crafter_ray dummy scoreboard objectives add rm_marker_ray dummy #Find Blocks -scoreboard objectives add cc_block_ray dummy \ No newline at end of file +scoreboard objectives add cc_block_ray dummy + +#Book Commands +scoreboard objectives add cc_gen_workshop trigger +scoreboard objectives add cc_start_game trigger +scoreboard objectives add cc_reset trigger \ No newline at end of file diff --git a/data/chaotic_crafting/function/setup/spawn_workshop_stage1.mcfunction b/data/chaotic_crafting/function/setup/spawn_workshop_stage1.mcfunction index 44cee22..b8fdc8b 100644 --- a/data/chaotic_crafting/function/setup/spawn_workshop_stage1.mcfunction +++ b/data/chaotic_crafting/function/setup/spawn_workshop_stage1.mcfunction @@ -1 +1 @@ -place template chaotic_crafting:stage1_v1 ~-48 ~-39 ~ none none \ No newline at end of file +place template chaotic_crafting:stage1_v2 ~-47 ~-39 ~-1 none none \ No newline at end of file diff --git a/data/chaotic_crafting/function/tick.mcfunction b/data/chaotic_crafting/function/tick.mcfunction index 5a11e0e..f411ebf 100644 --- a/data/chaotic_crafting/function/tick.mcfunction +++ b/data/chaotic_crafting/function/tick.mcfunction @@ -25,4 +25,11 @@ function chaotic_crafting:util/debug/debug_tick function chaotic_crafting:util/block_tracker -#function chaotic_crafting:tick/spawn_crafter \ No newline at end of file +#function chaotic_crafting:tick/spawn_crafter + + +execute as @a[tag=cc_craft_book] run function chaotic_crafting:replace_book + +function chaotic_crafting:book_commands/gen_workshop +function chaotic_crafting:book_commands/start_game +function chaotic_crafting:book_commands/reset \ No newline at end of file diff --git a/data/chaotic_crafting/function/util/give_config_book.mcfunction b/data/chaotic_crafting/function/util/give_config_book.mcfunction index 65c266b..cbad6fa 100644 --- a/data/chaotic_crafting/function/util/give_config_book.mcfunction +++ b/data/chaotic_crafting/function/util/give_config_book.mcfunction @@ -1 +1 @@ -give @p written_book{pages:['["",{"text":"Config\\n\\n"},{"text":"Start Game","bold":true,"color":"dark_green","clickEvent":{"action":"run_command","value":"/scoreboard players set $game_active cc_settings 1"}},{"text":"\\n\\n\\n","color":"reset"},{"text":"Reset","bold":true,"color":"dark_red","clickEvent":{"action":"run_command","value":"/scoreboard players set $game_active cc_settings 0"}}]'],title:"Config Book",author:Kestrel} \ No newline at end of file +give @p written_book[written_book_content={title:"Chaotic Crafting v0.2.0",author:"ItsKestrel",pages:['[{"text":"Chaotic Crafting\\n\\n"},{"text":"NOTE:","color":"red"},{"text":"Please read following pages before using these commands.\\n\\n"},{"text":"Generate Workshop","color":"dark_gray","clickEvent":{"action":"run_command","value":"/trigger cc_gen_workshop"}},{"text":"\\n\\n"},{"text":"Start Game","color":"dark_green","clickEvent":{"action":"run_command","value":"/trigger cc_start_game"}},{"text":"\\n\\n"},{"text":"Reset Game","color":"dark_red","clickEvent":{"action":"run_command","value":"/trigger cc_reset"}}]','[{"text":"Description","bold":true},{"text":"\\n\\nChaotic Crafting is a chaotic crafting mini-game. You must fulfil customer orders by harvesting the required resources and crafting the desired items.","bold":false}]','[{"text":"The Days","bold":true},{"text":"\\n\\nEach day, a set number of customers will arrive at the workshop and request an item. As you fulfil orders, the customers will pay you in emeralds. In between days, a merchant will appear to sell you items that may help you.","bold":false}]','[{"text":"Crafting","bold":true},{"text":"\\nCrafting tables are a bit different in Chaotic Crafting. The crafting tables are \\"interactive\\" and only produce 1 item at a time. To use them, place the resources in the grid on top of the table with right-click, and then hit (left-click) the table outside the grid to craft.","bold":false}]','[{"text":"Patience","bold":true},{"text":"\\n\\nWhenever a customer arrives to the workshop, they will begin to lose patience. After taking their order, the will receive a new set of patience. If any customer loses patience, your run will be over.","bold":false}]','[{"text":"The \\"Upgrades\\"","bold":true},{"text":"\\n\\nEvery 3 days, you will have to choose between 2 different upgrades. These can affect anything from customer behavior, to what kinds of items can be crafted.","bold":false}]','[{"text":"Setup","bold":true},{"text":"\\nUsing the commands at the start of this book, generate the starting workshop. This is a 48x48x48 structure, so make sure you have room for it.\\nSelect \\"Start Game\\" to initiate the game, then use the game UI to add each player.","bold":false},{"text":"\\n\\n -->"}]','"The number of players will affect the difficulty somewhat, but it is important that each player interacts with the UI. Then select \\"Start Day\\" to begin your first day!"']}] 1 \ No newline at end of file diff --git a/data/chaotic_crafting/function/util/kill_all_markers.mcfunction b/data/chaotic_crafting/function/util/kill_all_markers.mcfunction new file mode 100644 index 0000000..2673b1c --- /dev/null +++ b/data/chaotic_crafting/function/util/kill_all_markers.mcfunction @@ -0,0 +1,31 @@ +kill @e[tag=cc_barrel_marker] +kill @e[tag=cc_chest_marker] + +kill @e[tag=cc_acacia_log_pile] +kill @e[tag=cc_birch_log_pile] +kill @e[tag=cc_cherry_log_pile] +kill @e[tag=cc_oak_log_pile] +kill @e[tag=cc_mangrove_log_pile] + +kill @e[tag=cc_coal_deposit] +kill @e[tag=cc_stone_pile] +kill @e[tag=iron_node] +kill @e[tag=gold_node] +kill @e[tag=diamond_node] + +kill @e[tag=cc_customer_rally] +kill @e[tag=cc_customer_spawn] + +kill @e[tag=cc_menu_item_1_marker] +kill @e[tag=cc_menu_item_2_marker] +kill @e[tag=cc_menu_item_3_marker] +kill @e[tag=cc_menu_item] + +kill @e[tag=cc_merchant] +kill @e[tag=cc_merchant_spawn] +kill @e[tag=cc_seat_1] + +kill @e[tag=cc_trade_data] +kill @e[tag=cc_upgrade_data] + +kill @e[tag=slot_marker] \ No newline at end of file diff --git a/data/chaotic_crafting/loot_table/book.json b/data/chaotic_crafting/loot_table/book.json new file mode 100644 index 0000000..59ef11f --- /dev/null +++ b/data/chaotic_crafting/loot_table/book.json @@ -0,0 +1,139 @@ +{ + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:written_book", + "functions": [ + { + "function": "minecraft:set_components", + "components": { + "minecraft:written_book_content": { + "title": "Chaotic Crafting V0.2.0", + "author": "ItsKestrel" + }, + "minecraft:custom_data": { + "datapack": "chaotic_crafting" + } + } + }, + { + "function": "minecraft:set_written_book_pages", + "pages": [ + [ + { + "text":"Chaotic Crafting\n\n" + }, + { + "text":"NOTE: ","color":"red" + }, + { + "text":"Please read following pages before using these commands.\n\n" + }, + { + "text":"[Generate Workshop]", + "color":"dark_gray", + "clickEvent": { + "action":"run_command", + "value":"/trigger cc_gen_workshop set 1" + }, + "hoverEvent": { + "action": "show_text", + "contents": [ + { + "text": "Generates a 48x48x48 structure! Make sure you have room!", + "color": "yellow" + } + ] + } + }, + { + "text":"\n\n" + }, + { + "text":"[Start Game]", + "color":"dark_green", + "clickEvent": { + "action":"run_command","value":"/trigger cc_start_game set 1" + } + }, + { + "text":"\n\n" + }, + { + "text":"[Reset Game]", + "color":"dark_red", + "clickEvent": { + "action":"run_command","value":"/trigger cc_reset set 1" + }, + "hoverEvent": { + "action": "show_text", + "contents": [ + { + "text": "Resets the entire game. Your workshop will be overwritten! Use after failing a run.", + "color": "yellow" + } + ] + } + } + ], + [ + { + "text":"Description", + "bold":true + }, + { + "text":"\n\nChaotic Crafting is a chaotic mini-game where you must fulfill customer orders by harvesting the required resources and crafting the desired items.", + "bold":false + } + ], + [ + { + "text":"Crafting", + "bold":true + }, + { + "text":"\n\nThe crafting tables in this game are \"interactive\" and only produce 1 item at a time. To use them, place items in the grid on top of the table with right-click, then hit (left-click) the table outside the grid to craft.", + "bold":false + } + ], + [ + { + "text":"The \"Upgrades\"", + "bold":true + }, + { + "text":"\n\nEvery 3 days, you will have a choice between 2 upgrades. These can affect anything from customer behavior, to what kinds of items can be crafted. They usually make the game more difficult, but come with some positive effects as well.", + "bold":false + } + ], + [ + { + "text":"Setup", + "bold":true + }, + { + "text":"\n\nUsing the commands at the start of this book, generate the starting workshop. This is a 48x48x48 structure, so make sure you have room for it.\nSelect \"Start Game\" to initiate the game, then use the game UI to add each player.", + "bold":false + }, + { + "text":"\n (cont. ->)", + "bold":false + } + ], + [ + { + "text": "The number of players will affect the difficulty somewhat, but it is important that each player interacts with the UI. Then select \"Start Day\" to begin your first day!" + } + ] + ], + "mode": "replace_all" + } + ] + } + ] + } + ] +} \ No newline at end of file