diff --git a/gm4_balloon_animals/beet.yaml b/gm4_balloon_animals/beet.yaml index c07d1b2c67..1d80d4e7c0 100644 --- a/gm4_balloon_animals/beet.yaml +++ b/gm4_balloon_animals/beet.yaml @@ -14,7 +14,6 @@ require: meta: gm4: - minecraft: [] versioning: schedule_loops: [main] website: diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/advancement/interacted.json b/gm4_balloon_animals/data/gm4_balloon_animals/advancement/interacted.json new file mode 100644 index 0000000000..86faec18ee --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/advancement/interacted.json @@ -0,0 +1,28 @@ +{ + "criteria": { + "interacted": { + "trigger": "minecraft:player_interacted_with_entity", + "conditions": { + "entity": { + "type": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "minecraft:entity_type": "minecraft:wandering_trader", + "minecraft:entity_tags": { + "all_of": [ + "gm4_balloon_animal_trader" + ], + "none_of": [ + "gm4_balloon_animal_offers_initialized", + "smithed.entity" + ] + } + } + } + } + } + }, + "rewards": { + "function": "gm4_balloon_animals:wandering_trader/interacted" + } +} diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/function/wandering_trader/init_trader.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/function/wandering_trader/init_trader.mcfunction index bcd32b8ad6..85b9f84b30 100644 --- a/gm4_balloon_animals/data/gm4_balloon_animals/function/wandering_trader/init_trader.mcfunction +++ b/gm4_balloon_animals/data/gm4_balloon_animals/function/wandering_trader/init_trader.mcfunction @@ -11,4 +11,9 @@ execute as @e[type=trader_llama,tag=!smithed.entity,distance=..6] run function g tag @s remove gm4_balloon_animal_trader_new # pick two animals and set up trades +data modify storage gm4_balloon_animals:temp trades set value [] function gm4_balloon_animals:wandering_trader/pick_two_animals + +# copy trades list to entity custom data +data modify entity @s data.gm4_balloon_animals.trades set from storage gm4_balloon_animals:temp trades +data remove storage gm4_balloon_animals:temp trades diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/function/wandering_trader/initialize_offers.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/function/wandering_trader/initialize_offers.mcfunction new file mode 100644 index 0000000000..7e58394ab4 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/function/wandering_trader/initialize_offers.mcfunction @@ -0,0 +1,10 @@ +# @s = wandering trader +# at @s +# run from wandering_trader/interacted + +data modify entity @s Offers.Recipes append from entity @s data.gm4_balloon_animals.trades[] +data remove entity @s data.gm4_balloon_animals.trades + +tag @s add gm4_balloon_animal_offers_initialized + +particle minecraft:happy_villager ~ ~2 ~ 0.5 0.5 0.5 0 5 diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/function/wandering_trader/interacted.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/function/wandering_trader/interacted.mcfunction new file mode 100644 index 0000000000..f19f9f17b4 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/function/wandering_trader/interacted.mcfunction @@ -0,0 +1,6 @@ +# @s = player that just interacted with a non-processed wandering trader +# run from advancement gm4_balloon_animals:interacted + +advancement revoke @s only gm4_balloon_animals:interacted + +execute as @e[type=minecraft:wandering_trader,tag=gm4_balloon_animal_trader,tag=!gm4_balloon_animal_offers_initialized,tag=!smithed.entity] if data entity @s Offers.Recipes[0] if data entity @s data.gm4_balloon_animals.trades[0] at @s run function gm4_balloon_animals:wandering_trader/initialize_offers diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/function/wandering_trader/trade/pick_animal.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/function/wandering_trader/trade/pick_animal.mcfunction index 840097af94..e988b249a5 100644 --- a/gm4_balloon_animals/data/gm4_balloon_animals/function/wandering_trader/trade/pick_animal.mcfunction +++ b/gm4_balloon_animals/data/gm4_balloon_animals/function/wandering_trader/trade/pick_animal.mcfunction @@ -11,5 +11,5 @@ for animal in ctx.meta['animals']: execute if score $animal_id gm4_balloon_animals_data matches ctx.meta['enumeration'].index(animal['id']) summon animal['id'] run function f"gm4_balloon_animals:wandering_trader/trade/{animal['function']}" -data modify entity @s Offers.Recipes append from storage gm4_balloon_animals:temp trade +data modify storage gm4_balloon_animals:temp trades append from storage gm4_balloon_animals:temp trade data remove storage gm4_balloon_animals:temp trade diff --git a/gm4_balloon_animals/mod.mcdoc b/gm4_balloon_animals/mod.mcdoc index df58769cbe..c2fe6d2a94 100644 --- a/gm4_balloon_animals/mod.mcdoc +++ b/gm4_balloon_animals/mod.mcdoc @@ -16,4 +16,6 @@ dispatch minecraft:storage[gm4_balloon_animals:temp] to struct { dispatch mcdoc:custom_data[gm4_balloon_animals] to struct BalloonAnimalsData { trade?: byte, id?: int, + /// Recipe list stored on the wandering trader + trades?: [Recipe], }