Skip to content

Commit

Permalink
inventories and upgrades
Browse files Browse the repository at this point in the history
generalized block tracking
emerald tagging
inventory clearing
wood pile spawning
  • Loading branch information
ItsKestrel committed Dec 19, 2024
1 parent b30301d commit 0352475
Show file tree
Hide file tree
Showing 42 changed files with 869 additions and 18 deletions.
15 changes: 15 additions & 0 deletions data/chaotic_crafting/advancement/has_emerald.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"criteria": {
"requirement": {
"trigger": "inventory_changed",
"conditions": {
"items": [{
"items": ["emerald"]
}]
}
}
},
"rewards": {
"function": "chaotic_crafting:util/replace_emerald"
}
}
22 changes: 22 additions & 0 deletions data/chaotic_crafting/advancement/place_barrel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"criteria": {
"example": {
"trigger": "minecraft:placed_block",
"conditions": {
"location": [
{
"condition": "location_check",
"predicate": {
"block": {
"blocks": "barrel"
}
}
}
]
}
}
},
"rewards": {
"function": "chaotic_crafting:block_tracker/barrel/place_barrel"
}
}
22 changes: 22 additions & 0 deletions data/chaotic_crafting/advancement/place_chest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"criteria": {
"example": {
"trigger": "minecraft:placed_block",
"conditions": {
"location": [
{
"condition": "location_check",
"predicate": {
"block": {
"blocks": "chest"
}
}
}
]
}
}
},
"rewards": {
"function": "chaotic_crafting:block_tracker/chest/place_chest"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#tellraw @s {"text": "Placed Barrel."}
advancement revoke @s only chaotic_crafting:place_barrel

function chaotic_crafting:util/block_ray/start_block_ray

execute as @e[type=marker,tag=new_barrel] run function chaotic_crafting:util/center_entity
execute as @e[type=marker,tag=new_barrel] run tag @s remove new_barrel

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#tellraw @s {"text": "Barrel Broken."}
scoreboard players set @s cc_barrel_broken 0

execute as @e[type=marker,tag=cc_barrel_marker] run execute at @s run execute unless block ~ ~ ~ barrel run kill @s
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#tellraw @s {"text": "Placed Chest."}
advancement revoke @s only chaotic_crafting:place_chest

function chaotic_crafting:util/block_ray/start_block_ray

execute as @e[type=marker,tag=new_chest] run function chaotic_crafting:util/center_entity
execute as @e[type=marker,tag=new_chest] run tag @s remove new_chest
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#tellraw @s {"text": "Chest Broken."}
scoreboard players set @s cc_chest_broken 0

execute as @e[type=marker,tag=cc_chest_marker] run execute at @s run execute unless block ~ ~ ~ chest run kill @s
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
function chaotic_crafting:util/gui/close_gui
function chaotic_crafting:planning_phase/merchant/despawn_merchant

gamemode survival @a[tag=cc_player]
execute if score $keep_inventory cc_upgrades matches 0 run function chaotic_crafting:util/clear_inventories

scoreboard players set $day_active cc_settings 1
scoreboard players set $planning_phase_active cc_planning_phase 0

#function chaotic_crafting:loop/start_customer_spawning

execute if score $oak_wood_pile_spawn cc_settings matches 1 run function chaotic_crafting:loop/oak_pile_spawn
execute if score $oak_wood_pile_spawn cc_settings matches 1 run function chaotic_crafting:loop/wood_spawn
execute if score $stone_pile_spawn cc_settings matches 1 run function chaotic_crafting:loop/stone_pile_spawn


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tellraw @a {"text": "Triggering Crafters"}
#tellraw @a {"text": "Triggering Crafters"}
clone ~ ~-1 ~ ~ ~-1 ~ ~ -64 ~ replace
setblock ~ ~-1 ~ redstone_block
clone ~ -64 ~ ~ -64 ~ ~ ~-1 ~ replace
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tellraw @s {"text": "Placed Crafter."}
#tellraw @s {"text": "Placed Crafter."}
function chaotic_crafting:util/find_crafter/start_crafter_ray

#Marker
Expand Down
2 changes: 1 addition & 1 deletion data/chaotic_crafting/function/loop/iron_spread.mcfunction
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
execute if score $day_active cc_settings matches 1 run execute if score $iron_ore_spread cc_settings matches 1 run execute as @e[type=marker,tag=iron_ore_spreader] run function chaotic_crafting:ore_spread/iron_spread
schedule function chaotic_crafting:loop/iron_spread 5s
schedule function chaotic_crafting:loop/iron_spread 10s
3 changes: 0 additions & 3 deletions data/chaotic_crafting/function/loop/oak_pile_spawn.mcfunction

This file was deleted.

9 changes: 9 additions & 0 deletions data/chaotic_crafting/function/loop/wood_spawn.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
execute if score $day_active cc_settings matches 1 run execute if score $oak_wood_pile_spawn cc_settings matches 1 run execute as @e[type=marker,tag=cc_oak_log_pile] at @s run place template chaotic_crafting:oak_log_pile_alt ~ ~ ~

execute if score $day_active cc_settings matches 1 run execute if score $all_wood_spawn cc_settings matches 1 run execute as @e[type=marker,tag=cc_birch_log_pile] at @s run place template chaotic_crafting:birch_log_pile ~ ~ ~
execute if score $day_active cc_settings matches 1 run execute if score $all_wood_spawn cc_settings matches 1 run execute as @e[type=marker,tag=cc_acacia_log_pile] at @s run place template chaotic_crafting:acacia_log_pile ~ ~ ~
execute if score $day_active cc_settings matches 1 run execute if score $all_wood_spawn cc_settings matches 1 run execute as @e[type=marker,tag=cc_cherry_log_pile] at @s run place template chaotic_crafting:cherry_log_pile ~ ~ ~
execute if score $day_active cc_settings matches 1 run execute if score $all_wood_spawn cc_settings matches 1 run execute as @e[type=marker,tag=cc_mangrove_log_pile] at @s run place template chaotic_crafting:mangrove_log_pile ~ ~ ~

execute if score $day_active cc_settings matches 1 run tellraw @a {"text": "A log delivery has arrived.", "color": "white"}
execute if score $day_active cc_settings matches 1 run execute if score $oak_wood_pile_spawn cc_settings matches 1 run schedule function chaotic_crafting:loop/wood_spawn 120s
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ execute if score $merchant_spawned cc_planning_phase matches 0 \
}\
}

#/summon wandering_trader ~ ~ ~ {wander_target:[I;0,0,0],HandItems:[{},{}],Invulnerable:1b,NoAI:1b,Tags:["cc_merchant"],Offers:{Recipes:[{buy: {id: "minecraft:emerald",count: 1},sell: {id: "minecraft:stone_bricks",count: 64},priceMultiplier: 0.05f,maxUses: 2}]}}

execute as @e[type=marker,tag=cc_merchant_spawn] at @s run loot spawn ~ ~ ~ loot chaotic_crafting:merchant_day_1

#execute as @e[type=marker,tag=cc_merchant_spawn] at @s run function chaotic_crafting:planning_phase/merchant/add_trade with entity @e[type=item,distance=..2,limit=1] Item.components."minecraft:custom_data"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
scoreboard players set $planning_phase_active cc_planning_phase 1

execute if score $gui_open cc_gui matches 0 run function chaotic_crafting:util/gui/open_day_gui
schedule function chaotic_crafting:planning_phase/merchant/spawn_merchant 2s
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
scoreboard players operation #day3 cc_temp = $day cc_settings
scoreboard players operation #day3 cc_temp %= #3 cc_consts

gamemode adventure @a[tag=cc_player]

#non-3rd day
execute unless score #day3 cc_temp matches 0 run execute if score $planning_phase_active cc_planning_phase matches 0 run function chaotic_crafting:planning_phase/planning_phase

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ scoreboard players set $diamond_ore_spread cc_settings 0
scoreboard players set $oak_wood_pile_spawn cc_settings 1
scoreboard players set $stone_pile_spawn cc_settings 1
scoreboard players set $coal_deposit_spawn cc_settings 0
scoreboard players set $all_wood_spawn cc_settings 0

#Upgrades
scoreboard objectives add cc_upgrades dummy
Expand Down Expand Up @@ -149,7 +150,12 @@ scoreboard objectives add cc_crafter_broken minecraft.mined:minecraft.crafter
scoreboard objectives add cc_iron_ore_mined minecraft.mined:minecraft.iron_ore
scoreboard objectives add cc_gold_ore_mined minecraft.mined:minecraft.gold_ore
scoreboard objectives add cc_diamond_ore_mined minecraft.mined:minecraft.diamond_ore
scoreboard objectives add cc_barrel_broken minecraft.mined:minecraft.barrel
scoreboard objectives add cc_chest_broken minecraft.mined:minecraft.chest

#Find Crafter Ray
scoreboard objectives add cc_crafter_ray dummy
scoreboard objectives add rm_marker_ray dummy
scoreboard objectives add rm_marker_ray dummy

#Find Blocks
scoreboard objectives add cc_block_ray dummy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
scoreboard players set $diamond_menu cc_upgrades 1
scoreboard players add $cc_menus_unlocked cc_settings 1
scoreboard players set $diamond_ore_spread cc_settings 1
scoreboard players set $coal_deposit_spawn cc_settings 1

data modify entity @e[type=marker,tag=cc_trade_data,limit=1] data.custom_data.menus append value {menu:"chaotic_crafting:menu_diamond_items"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
scoreboard players set $gold_menu cc_upgrades 1
scoreboard players add $cc_menus_unlocked cc_settings 1
scoreboard players set $gold_ore_spread cc_settings 1
scoreboard players set $coal_deposit_spawn cc_settings 1

data modify entity @e[type=marker,tag=cc_trade_data,limit=1] data.custom_data.menus append value {menu:"chaotic_crafting:menu_gold_items"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scoreboard players set $wood_menu cc_upgrades 1
scoreboard players add $cc_menus_unlocked cc_settings 1
scoreboard players set $all_wood_spawn cc_settings 1

data modify entity @e[type=marker,tag=cc_trade_data,limit=1] data.custom_data.menus append value {menu:"chaotic_crafting:menu_wood_items"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
execute if block ~ ~ ~ #chaotic_crafting:crafter run function chaotic_crafting:util/find_crafter/hit_crafter
execute if block ~ ~ ~ #chaotic_crafting:barrel run function chaotic_crafting:util/block_ray/find_blocks/hit_barrel
execute if block ~ ~ ~ #chaotic_crafting:chest run function chaotic_crafting:util/block_ray/find_blocks/hit_chest

scoreboard players add #distance cc_block_ray 1

execute if score #hit cc_block_ray matches 0 if score #distance cc_block_ray matches ..50 positioned ^ ^ ^0.1 run function chaotic_crafting:util/block_ray/block_ray
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#tellraw @s {"text": "Hit Barrel."}
scoreboard players set #hit cc_block_ray 1

summon marker ~ ~ ~ {Tags:[cc_barrel_marker,new_barrel],data:{name:"Barrel"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
scoreboard players set #hit cc_block_ray 1

summon marker ~ ~ ~ {Tags:[cc_chest_marker,new_chest],data:{name:"Chest"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tag @s add find_block
scoreboard players set #hit cc_block_ray 0
scoreboard players set #distance cc_block_ray 0

execute as @s at @s anchored eyes positioned ^ ^ ^ anchored feet run function chaotic_crafting:util/block_ray/block_ray

tag @s remove find_crafter
7 changes: 5 additions & 2 deletions data/chaotic_crafting/function/util/block_tracker.mcfunction
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
execute as @a[scores={cc_crafter_broken=1}] run function chaotic_crafting:functional_blocks/break_crafter
execute as @a[scores={cc_iron_ore_mined=1}] run function chaotic_crafting:ore_spread/mined_iron_ore
execute as @a[scores={cc_gold_ore_mined=1}] run function chaotic_crafting:ore_spread/mined_gold_ore
execute as @a[scores={cc_diamond_ore_mined=1}] run function chaotic_crafting:ore_spread/mined_diamond_ore
execute as @a[scores={cc_diamond_ore_mined=1}] run function chaotic_crafting:ore_spread/mined_diamond_ore

execute as @a[scores={cc_crafter_broken=1}] run function chaotic_crafting:functional_blocks/break_crafter
execute as @a[scores={cc_barrel_broken=1}] run function chaotic_crafting:block_tracker/barrel/remove_barrel
execute as @a[scores={cc_chest_broken=1}] run function chaotic_crafting:block_tracker/chest/remove_chest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tellraw @a {"text": "Centering Entity"}
#tellraw @a {"text": "Centering Entity"}
# Center an entity on its current block (x and z coordinates)
execute store result score $x cc_temp run data get entity @s Pos[0] 1
execute store result score $y cc_temp run data get entity @s Pos[1] 1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

clear @a[tag=cc_player] *[!minecraft:custom_data={keep:true}]
execute as @e[type=marker,tag=cc_barrel_marker] at @s run data modify block ~ ~ ~ Items set value []
execute as @e[type=marker,tag=cc_chest_marker] at @s run data modify block ~ ~ ~ Items set value []
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#execute if score $show_seats cc_settings matches 1 run particle dust{color:[1.000,0.000,0.000],scale:1} 0 62 10 0 1 0 1 10 normal
#execute if score $timer cc_timer matches 100 run execute as @e[type=marker,tag=crafter_lvl1] at @s run function chaotic_crafting:functional_blocks/crafter_lvl_1

execute at @e[type=marker,tag=debug_marker] run particle dust{color:[1.000,0.000,0.000],scale:1} ~ ~ ~ 0 1 0 1 10 normal
#execute at @e[type=marker,tag=debug_marker] run particle dust{color:[1.000,0.000,0.000],scale:1} ~ ~ ~ 0 1 0 1 10 normal

#execute at @e[type=marker,tag=iron_ore_spreader] run particle dust{color:[0.000,1.000,0.000],scale:1} ~ ~ ~ 0 1 0 1 10 normal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
scoreboard players set #hit cc_crafter_ray 1

tellraw @a {"text": "Crafter Found"}
#tellraw @a {"text": "Crafter Found"}
summon armor_stand ~ ~ ~ {Tags:[crafter_marker,new_crafter],attributes:[{id:"generic.scale",base:0.8}],Invisible:1b,Invulnerable:1b,NoGravity:1b,Small:1b}
#execute as @e[type=armor_stand,limit=1,sort=nearest] at @s facing entity @p eyes run tp @s ~ ~ ~ ~ ~
summon marker ~ ~ ~ {Tags:[debug_marker,crafter_marker,new_crafter]}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tellraw @a {"text": "Searching for Crafter."}
#tellraw @a {"text": "Searching for Crafter."}
tag @s add find_crafter
scoreboard players set #hit cc_crafter_ray 0
scoreboard players set #distance cc_crafter_ray 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tellraw @a {"text": "Giving Progress Bar"}
#tellraw @a {"text": "Giving Progress Bar"}
summon item_display ~ ~ ~ {item:{id:"minecraft:emerald",Count:1b,components:{"minecraft:custom_model_data":8000}},billboard:"vertical",brightness:{block:15,sky:0},transformation:{translation:[0f,0f,.6f],left_rotation:[0f,0f,1f,1f],right_rotation:[0f,0f,1f,1f],scale:[1f,1f,0f]},Tags:["progressBar","newProgressBar"]}
ride @e[tag=progressBar,tag=newProgressBar,limit=1] mount @s

Expand Down
11 changes: 11 additions & 0 deletions data/chaotic_crafting/function/util/replace_emerald.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

#give @s minecraft:emerald[custom_data={keep:true}]
summon item ~ ~ ~ {Item:{id:"emerald",components:{"minecraft:custom_data":{keep:true}}},Tags:[keep_emerald]}

execute store result score @s cc_temp run clear @s emerald[!minecraft:custom_data={keep:true}]
execute store result entity @e[distance=..1,type=item,tag=keep_emerald,limit=1] Item.count byte 1 run scoreboard players get @s cc_temp

tag @e[distance=..1,type=item,tag=keep_emerald,limit=1] remove keep_emerald
scoreboard players reset @s cc_temp

execute as @s run schedule function chaotic_crafting:util/revoke_has_emerald 5t
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
advancement revoke @a only chaotic_crafting:has_emerald
Loading

0 comments on commit 0352475

Please sign in to comment.