Skip to content

Commit

Permalink
book
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsKestrel committed Dec 20, 2024
1 parent 0352475 commit 317bb34
Show file tree
Hide file tree
Showing 17 changed files with 266 additions and 6 deletions.
30 changes: 30 additions & 0 deletions data/chaotic_crafting/advancement/book_crafting.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
12 changes: 12 additions & 0 deletions data/chaotic_crafting/advancement/root.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"criteria": {
"impossible": {
"trigger": "minecraft:impossible"
}
},
"requirements": [
[
"impossible"
]
]
}
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions data/chaotic_crafting/function/book_commands/reset.mcfunction
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions data/chaotic_crafting/function/craft_book.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tag @s add cc_craft_book
advancement revoke @s only chaotic_crafting:book_crafting
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ scoreboard players set $day_timer cc_timer 0

function chaotic_crafting:util/kill_all_customers

function chaotic_crafting:reset
#function chaotic_crafting:reset
1 change: 1 addition & 0 deletions data/chaotic_crafting/function/give_book.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loot give @s loot chaotic_crafting:book
3 changes: 3 additions & 0 deletions data/chaotic_crafting/function/load.mcfunction
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions data/chaotic_crafting/function/replace_book.mcfunction
Original file line number Diff line number Diff line change
@@ -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
16 changes: 15 additions & 1 deletion data/chaotic_crafting/function/reset.mcfunction
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
tellraw @a {"text": "Resetting..."}

scoreboard objectives remove cc_item
scoreboard objectives remove cc_timer
scoreboard objectives remove cc_customers
Expand All @@ -19,11 +21,23 @@ 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

kill @e[tag=cc_trade_data]
function chaotic_crafting:setup/set_trade_data_marker


function chaotic_crafting:setup/setup_scoreboards
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
place template chaotic_crafting:stage1_v1 ~-48 ~-39 ~ none none
place template chaotic_crafting:stage1_v2 ~-47 ~-39 ~-1 none none
9 changes: 8 additions & 1 deletion data/chaotic_crafting/function/tick.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@ function chaotic_crafting:util/debug/debug_tick

function chaotic_crafting:util/block_tracker

#function chaotic_crafting:tick/spawn_crafter
#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
Original file line number Diff line number Diff line change
@@ -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}
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
31 changes: 31 additions & 0 deletions data/chaotic_crafting/function/util/kill_all_markers.mcfunction
Original file line number Diff line number Diff line change
@@ -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]
139 changes: 139 additions & 0 deletions data/chaotic_crafting/loot_table/book.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}
]
}

0 comments on commit 317bb34

Please sign in to comment.