diff --git a/gm4/modeldata_registry.json b/gm4/modeldata_registry.json index d41d3bd0d4..4f8370ea3e 100644 --- a/gm4/modeldata_registry.json +++ b/gm4/modeldata_registry.json @@ -941,6 +941,10 @@ "gm4_liquid_tanks:guidebook_icon/standard_liquids": 2, "gm4_metallurgy:shamir/infinitas": 100 }, + "lead": { + "gm4_balloon_animals:gui/advancement/balloon_animals": 1, + "gm4_balloon_animals:guidebook_icon/balloon_animals": 2 + }, "leather_boots": { "gm4_boots_of_ostara:item/boots_of_ostara": 1, "gm4_scuba_gear:item/flippers": 2, diff --git a/gm4_balloon_animals/animals.csv b/gm4_balloon_animals/animals.csv new file mode 100644 index 0000000000..e9faaf8cd4 --- /dev/null +++ b/gm4_balloon_animals/animals.csv @@ -0,0 +1,19 @@ +type,id,rare,function,names +Cow,minecraft:cow,FALSE,init_animal,"Abigail,Beef,Belle,Bessie,Clarabell,Delilah,Duchess,Maggie,Moo,Wellington,Wendy" +Pig,minecraft:pig,FALSE,init_animal,"Bacon,Betty,Hamm,Hoagie,Piglet,Pua,Pumbaa,Sharla,Swinton" +Sheep,minecraft:sheep,FALSE,init_animal,"Baabra,Bellwether,Blackie,Doug,Gruff,Lamb,Lambie,Sheera,Woolensworth,Woolter" +Horse,minecraft:horse,FALSE,init_animal,"Achilles,Buck,Bullseye,Galahad,Khan,Lancelot,Major,Maximus,Pearl,Shadow" +Rabbit,minecraft:rabbit,FALSE,init_animal,"Berry,Bouncy,Bushy,Clover,Houdini,Jack,Judy,March,Nibbles,Oswald,Roger,Squirt,Thumper" +Wolf,minecraft:wolf,FALSE,init_animal,"Beast,Bolt,Briar,Bruno,Buddy,Duke,Fenrir,Maugrim,Wolfie,Wolfsbane" +Llama,minecraft:llama,FALSE,init_animal,"Andes,Carl,Carlos,Flower,Kuzco,Paul,Roxy,Ruby,Wendy" +Frog,minecraft:frog,FALSE,init_animal,"Carlos,Croaker,Croaky,Flizard,Frankie,Frogini,Garko,Kermit,Naveen,Ribbiton,Sylvia,Stumpy,Tiana,Toadie" +Bee,minecraft:bee,FALSE,add_bee_nest, +Chicken,minecraft:chicken,FALSE,add_chicken_egg, +Fox,minecraft:fox,TRUE,init_animal,"Astuto,Bhati,Fergus,Foxy,Frida,Marian,Nick,Vixen,Vixey,Robin,Sproingo,Tod,Whiskers,Zuzo" +Parrot,minecraft:parrot,TRUE,init_animal,"Barker,Beaks,Duncan,Fritz,Iago,Jose,Michael,Pedro,Pierre,Peghook,Polly,Skully,Talon" +Donkey,minecraft:donkey,TRUE,init_animal,"Alexander,Dapple,Duchess,Eeyore,Jack,Lampwick" +Panda,minecraft:panda,TRUE,init_animal,"Chen,Dopey,Dumpling,Helen,Kai,Lily,Mei,Ping,Po,Thunder" +Camel,minecraft:camel,TRUE,init_animal,"Camelot,Camille,Cammy,Caramel,Eden,Jacchus,Kennedy,Mirage,Sarah" +Goat,minecraft:goat,TRUE,init_animal,"Bill,Billy,Djali,Gertrude,Gideon,Joe,Joey,Kid,Phil,Philoctetes,Valentino" +Ocelot,minecraft:ocelot,TRUE,init_animal,"Catnip,Clawhauser,Dinah,Felicia,Figaro,Hissy,Jagular,Lucifer,Tallulah" +Turtle,minecraft:turtle,TRUE,add_turtle_egg, diff --git a/gm4_balloon_animals/beet.yaml b/gm4_balloon_animals/beet.yaml new file mode 100644 index 0000000000..0c22652bd2 --- /dev/null +++ b/gm4_balloon_animals/beet.yaml @@ -0,0 +1,34 @@ +id: gm4_balloon_animals +name: Balloon Animals +version: 1.0.X + +data_pack: + load: . + +pipeline: + - gm4_balloon_animals.generate + - gm4.plugins.extend.module + - gm4.plugins.include.lib_trades + +require: + - bolt + +meta: + gm4: + versioning: + required: + lib_trades: 1.3.0 + schedule_loops: [main] + website: + description: Looking for exotic animals? This module makes some Wandering Traders sell cute baby animals! + video: null + wiki: https://wiki.gm4.co/wiki/Balloon_Animals + credits: + Creator: + - TheEpyonProject + model_data: + - item: lead + reference: gui/advancement/balloon_animals + template: + name: advancement + forward: minecraft:item/lead diff --git a/gm4_balloon_animals/data/gm4/advancements/balloon_animals.json b/gm4_balloon_animals/data/gm4/advancements/balloon_animals.json new file mode 100644 index 0000000000..e409d3042e --- /dev/null +++ b/gm4_balloon_animals/data/gm4/advancements/balloon_animals.json @@ -0,0 +1,23 @@ +{ + "display": { + "icon": { + "item": "lead", + "nbt": "{CustomModelData:'gui/advancement/balloon_animals'}" + }, + "title": { + "translate": "advancement.gm4.balloon_animals.title", + "fallback": "Party Animals" + }, + "description": { + "translate": "advancement.gm4.balloon_animals.description", + "fallback": "Buy a Balloon Animal from a Wandering Trader", + "color": "gray" + } + }, + "parent": "gm4:root", + "criteria": { + "balloon_animals": { + "trigger": "minecraft:impossible" + } + } + } diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/advancements/purchased_animal.json b/gm4_balloon_animals/data/gm4_balloon_animals/advancements/purchased_animal.json new file mode 100644 index 0000000000..74ecec4efe --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/advancements/purchased_animal.json @@ -0,0 +1,29 @@ +{ + "criteria": { + "primary_animal": { + "trigger": "minecraft:villager_trade", + "conditions": { + "item": { + "nbt": "{gm4_balloon_animals:{animal:1b,trade:1b}}" + } + } + }, + "secondary_animal": { + "trigger": "minecraft:villager_trade", + "conditions": { + "item": { + "nbt": "{gm4_balloon_animals:{animal:2b,trade:2b}}" + } + } + } + }, + "requirements": [ + [ + "primary_animal", + "secondary_animal" + ] + ], + "rewards": { + "function": "gm4_balloon_animals:purchased_animal" + } + } diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/balloon/check_leashed.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/balloon/check_leashed.mcfunction new file mode 100755 index 0000000000..2a9ada1407 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/balloon/check_leashed.mcfunction @@ -0,0 +1,13 @@ +# @s = animal, tag=gm4_balloon_animal,tag=!gm4_balloon_animal_purchased +# at world spawn +# run from main + +execute store success score $leashed gm4_balloon_animals_data if data entity @s Leash +execute if score $leashed gm4_balloon_animals_data matches 1 store success score $leashed gm4_balloon_animals_data on leasher if entity @s[type=wandering_trader] +execute if score $leashed gm4_balloon_animals_data matches 0 run function gm4_balloon_animals:balloon/fly_away/start_animation + +# prevent aging +data modify entity @s Age set value -2147483648 + +# clean up +scoreboard players reset $leashed gm4_balloon_animals_data diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/balloon/fly_away/animate.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/balloon/fly_away/animate.mcfunction new file mode 100644 index 0000000000..3ed4bc1961 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/balloon/fly_away/animate.mcfunction @@ -0,0 +1,11 @@ +# @s = orphaned animal, tag=gm4_balloon_animal,tag=gm4_balloon_animal_purchased +# run from balloon/fly_away/loop + +scoreboard players add @s gm4_balloon_animals_data 1 + +effect give @s[scores={gm4_balloon_animals_data=1}] levitation infinite 3 +effect give @s[scores={gm4_balloon_animals_data=2}] levitation infinite 7 +effect give @s[scores={gm4_balloon_animals_data=3}] levitation infinite 15 +effect give @s[scores={gm4_balloon_animals_data=4..}] levitation infinite 31 + +execute if entity @s[scores={gm4_balloon_animals_data=4..}] at @s run function gm4_balloon_animals:balloon/kill_orphan diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/balloon/fly_away/loop.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/balloon/fly_away/loop.mcfunction new file mode 100755 index 0000000000..a1e41634b8 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/balloon/fly_away/loop.mcfunction @@ -0,0 +1,6 @@ +# @s = orphaned animal, tag=gm4_balloon_animal,tag=gm4_balloon_animal_purchased +# run from balloon/fly_away/start_animation + +execute as @e[type=#gm4_balloon_animals:balloon_animal,tag=gm4_balloon_animal_fly_away] run function gm4_balloon_animals:balloon/fly_away/animate + +execute if entity @e[type=#gm4_balloon_animals:balloon_animal,tag=gm4_balloon_animal_fly_away,limit=1] run schedule function gm4_balloon_animals:balloon/fly_away/loop 16t diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/balloon/fly_away/start_animation.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/balloon/fly_away/start_animation.mcfunction new file mode 100755 index 0000000000..bd6ebf211f --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/balloon/fly_away/start_animation.mcfunction @@ -0,0 +1,8 @@ +# @s = orphaned animal, tag=gm4_balloon_animal,tag=gm4_balloon_animal_purchased +# run from balloon/check_leashed + +scoreboard players set @s gm4_balloon_animals_data 0 + +tag @s add gm4_balloon_animal_fly_away + +schedule function gm4_balloon_animals:balloon/fly_away/loop 16t diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/balloon/kill_orphan.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/balloon/kill_orphan.mcfunction new file mode 100755 index 0000000000..4530dee85a --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/balloon/kill_orphan.mcfunction @@ -0,0 +1,7 @@ +# @s = orphaned animal, tag=gm4_balloon_animal,tag=!gm4_balloon_animal_purchased +# at @s +# run from balloon/fly_away/animate + +particle poof ~ ~ ~ 0 0 0 0.1 10 +tp @s ~ ~-4096 ~ +kill @s diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/debug/init_trader.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/debug/init_trader.mcfunction new file mode 100755 index 0000000000..e1643cbd66 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/debug/init_trader.mcfunction @@ -0,0 +1,5 @@ +# Initializes and saves trader data +# run from debug/summon_trader_with_llamas + +data modify entity @s DespawnDelay set value 48000 +data modify storage gm4_balloon_animals:temp trader_uuid set from entity @s UUID diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/debug/summon_trader_with_llamas.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/debug/summon_trader_with_llamas.mcfunction new file mode 100755 index 0000000000..56948604c8 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/debug/summon_trader_with_llamas.mcfunction @@ -0,0 +1,6 @@ +# summons wandering trader with 2 llamas, as if it were a natural trader +# run manually + +execute summon wandering_trader run function gm4_balloon_animals:debug/init_trader +execute summon trader_llama run data modify entity @s Leash.UUID set from storage gm4_balloon_animals:temp trader_uuid +execute summon trader_llama run data modify entity @s Leash.UUID set from storage gm4_balloon_animals:temp trader_uuid diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/init.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/init.mcfunction new file mode 100755 index 0000000000..62f257029e --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/init.mcfunction @@ -0,0 +1,9 @@ + +scoreboard objectives add gm4_balloon_animals_data dummy +scoreboard objectives add gm4_balloon_animals_id dummy + +execute unless score balloon_animals gm4_modules matches 1 run data modify storage gm4:log queue append value {type:"install",module:"Balloon Animals"} +execute unless score balloon_animals gm4_earliest_version < balloon_animals gm4_modules run scoreboard players operation balloon_animals gm4_earliest_version = balloon_animals gm4_modules +scoreboard players set balloon_animals gm4_modules 1 + +schedule function gm4_balloon_animals:main 1t diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/main.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/main.mcfunction new file mode 100755 index 0000000000..2053108f9d --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/main.mcfunction @@ -0,0 +1,4 @@ + +execute as @e[type=#gm4_balloon_animals:balloon_animal,tag=gm4_balloon_animal,tag=!gm4_balloon_animal_purchased] run function gm4_balloon_animals:balloon/check_leashed + +schedule function gm4_balloon_animals:main 4s diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/animal/cleanse.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/animal/cleanse.mcfunction new file mode 100644 index 0000000000..b566dac37e --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/animal/cleanse.mcfunction @@ -0,0 +1,18 @@ +# Removes effects that protected and kept afloat the balloon animal +# @s = newly purchased balloon animal, tag=gm4_balloon_animal_purchased,tag=gm4_balloon_animal_newly_purchased +# at world spawn +# run from purchase/animal/locate_cleanse + +tag @s remove gm4_balloon_animal_newly_purchased + +# remove balloon effects +effect clear @s levitation +effect clear @s slow_falling +effect clear @s resistance + +# temporary protection +effect give @s slow_falling 5 +effect give @s resistance 5 4 + +# allow aging +data modify entity @s Age set value -12000 diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/animal/locate_cleanse.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/animal/locate_cleanse.mcfunction new file mode 100644 index 0000000000..03691415fe --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/animal/locate_cleanse.mcfunction @@ -0,0 +1,5 @@ +# Delayed activation of cleansing newly purchased animals +# at world spawn +# scheduled by purchase/animal/update + +execute as @e[type=#gm4_balloon_animals:balloon_animal,tag=gm4_balloon_animal_newly_purchased] run function gm4_balloon_animals:purchase/animal/cleanse diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/animal/search.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/animal/search.mcfunction new file mode 100755 index 0000000000..57074edd38 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/animal/search.mcfunction @@ -0,0 +1,13 @@ +# Searches through unpurchased balloon animals for the one that matches the id of the recently purchased animal +# @s = a random animal, tag=gm4_balloon_animal,tag=!gm4_balloon_animal_purchased +# at wandering trader, player just traded with +# run from purchase/trader/check_trade + +# load animal score id +execute store result score $id gm4_balloon_animals_data run data get storage gm4_balloon_animals:temp temp_source[-1].sell.tag.gm4_balloon_animals.id + +# checks all unpurchased balloon animals, if their id matches the recently purchased one then continue +execute as @e[type=#gm4_balloon_animals:balloon_animal,tag=gm4_balloon_animal,tag=!gm4_balloon_animal_purchased] if score @s gm4_balloon_animals_id = $id gm4_balloon_animals_data run function gm4_balloon_animals:purchase/animal/update + +# if animal not found, refund player (in purchased_animal) +execute unless score $trade_success gm4_balloon_animals_data matches 1 run playsound entity.villager.no neutral @a[distance=..8] ~ ~ ~ diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/animal/update.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/animal/update.mcfunction new file mode 100755 index 0000000000..a50f49417d --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/animal/update.mcfunction @@ -0,0 +1,14 @@ +# Tag and complete the ownership of the purchased balloon animal to the player +# @s = purchased balloon animal +# at wandering trader, player just traded with +# run from purchase/animal/search + +tag @s add gm4_balloon_animal_purchased +scoreboard players set $trade_success gm4_balloon_animals_data 1 + +# switch the leasher from the trader to the player +data modify entity @s Leash.UUID set from storage gm4_balloon_animals:temp player.uuid + +# don't know why but having all of these in one file prevents the above line from working properly +tag @s add gm4_balloon_animal_newly_purchased +schedule function gm4_balloon_animals:purchase/animal/locate_cleanse 10t diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/trader/check_trade.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/trader/check_trade.mcfunction new file mode 100755 index 0000000000..e84fc0d411 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/trader/check_trade.mcfunction @@ -0,0 +1,19 @@ +# Checks the uses count for a specific gm4_balloon_animal trade +# @s = wandering trader, tag=gm4_balloon_animal_trader +# at player +# run from purchase/trades/parse_trades + +execute store result score $uses gm4_balloon_animals_data run data get storage gm4_balloon_animals:temp temp_source[-1].uses + +# if uses and maxUses matches, this is the trade we are looking for. +# continue with searching for purchased animal, reposition to trader for playsound +execute if score $uses gm4_balloon_animals_data matches 1 at @s as @e[type=#gm4_balloon_animals:balloon_animal,tag=gm4_balloon_animal,tag=!gm4_balloon_animal_purchased,limit=1] run function gm4_balloon_animals:purchase/animal/search +# update the trade as processed +execute if score $uses gm4_balloon_animals_data matches 1 run function gm4_balloon_animals:purchase/trader/update_trade + +# Typically balloon animal trades' uses will be 0 or 2. +# The maxUses is 1, but we can set any value including higher ones. + +# If the uses is 0, we know that it has not been purchased, +# but if uses is 1, we can set the value higher after checking, +# which guarantees us that trades with a uses of 1 are the specific trade we are looking for diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/trader/parse_trades.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/trader/parse_trades.mcfunction new file mode 100755 index 0000000000..e3cea86482 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/trader/parse_trades.mcfunction @@ -0,0 +1,15 @@ +# Checks each trader's trade for a gm4_balloon_animals.trade nbt +# @s = random wandering trader, tag=gm4_balloon_animal_trader +# at player +# run from purchase/trades/search and self + +data modify storage gm4_balloon_animals:temp temp_source append from storage gm4_balloon_animals:temp trades[0] +data remove storage gm4_balloon_animals:temp trades[0] + +# if current trade is a balloon animal trade, check if it is the one we are looking for +execute store success score $trade_applicable gm4_balloon_animals_data if data storage gm4_balloon_animals:temp temp_source[-1].sell.tag.gm4_balloon_animals.trade +execute if score $trade_applicable gm4_balloon_animals_data matches 1 run function gm4_balloon_animals:purchase/trader/check_trade + +# if any remaining trades, continue looping +execute store result score $trade_count gm4_balloon_animals_data run data get storage gm4_balloon_animals:temp trades +execute if score $trade_found gm4_balloon_animals_data matches 0 if score $trade_count gm4_balloon_animals_data matches 1.. run function gm4_balloon_animals:purchase/trader/parse_trades diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/trader/search.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/trader/search.mcfunction new file mode 100755 index 0000000000..7c1a4ea60d --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/trader/search.mcfunction @@ -0,0 +1,18 @@ +# Search through traders' trades to find the trade that activated the advancement +# @s = wandering trader, tag=gm4_balloon_animal_trader, initially nearest +# at player +# run from purchased_animal or self + +# reset end values +scoreboard players set $trade_found gm4_balloon_animals_data 0 +data remove storage gm4_balloon_animals:temp temp_source + +# load trades, prepare for search +data modify storage gm4_balloon_animals:temp trades set from entity @s Offers.Recipes + +function gm4_balloon_animals:purchase/trader/parse_trades + +tag @s add gm4_balloon_animal_trader_processed + +# if not the trader we are looking for, loop unprocessed traders +execute if score $trade_found gm4_balloon_animals_data matches 0 as @e[type=wandering_trader,tag=!smithed.entity,tag=gm4_balloon_animal_trader,tag=!gm4_balloon_animal_trader_processed,limit=1] run function gm4_balloon_animals:purchase/trader/search diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/trader/update_trade.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/trader/update_trade.mcfunction new file mode 100755 index 0000000000..8bce7a9cae --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchase/trader/update_trade.mcfunction @@ -0,0 +1,11 @@ +# Update the uses count for balloon animal trader's trade +# @s = wandering trader, tag=gm4_balloon_animal_trader +# at player +# run from purchase/trades/check_trade + +# update trade, such that uses (2) > maxUses (1) +data modify storage gm4_balloon_animals:temp temp_source[-1].uses set value 2 + +# update trader with the updated trade +data modify storage gm4_balloon_animals:temp temp_source append from storage gm4_balloon_animals:temp trades[] +data modify entity @s Offers.Recipes set from storage gm4_balloon_animals:temp temp_source diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchased_animal.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchased_animal.mcfunction new file mode 100755 index 0000000000..ec3e65813f --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/purchased_animal.mcfunction @@ -0,0 +1,26 @@ +# Granted upon purchasing a balloon animal from a wandering trader +# @s = trading player +# at @s +# run from advancement purchased_animal + +scoreboard players reset $trade_success gm4_balloon_animals_data + +data modify storage gm4_balloon_animals:temp player.uuid set from entity @s UUID + +# locate trader +execute as @e[type=wandering_trader,tag=gm4_balloon_animal_trader,limit=1,sort=nearest] run function gm4_balloon_animals:purchase/trader/search + +execute if score $trade_success gm4_balloon_animals_data matches 1 run advancement grant @s only gm4:balloon_animals +execute unless score $trade_success gm4_balloon_animals_data matches 1 run give @s emerald 12 + +# clean up +advancement revoke @s only gm4_balloon_animals:purchased_animal + +clear @s lead{gm4_balloon_animals:{animal:1b,trade:1b}} +clear @s lead{gm4_balloon_animals:{animal:2b,trade:2b}} + +scoreboard players reset $trade_applicable gm4_balloon_animals_data +scoreboard players reset $trade_count gm4_balloon_animals_data +scoreboard players reset $uses gm4_balloon_animals_data + +tag @e[type=wandering_trader,tag=gm4_balloon_animal_trader_processed] remove gm4_balloon_animal_trader_processed diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/check_eligibility.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/check_eligibility.mcfunction new file mode 100644 index 0000000000..59ff7a59a0 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/check_eligibility.mcfunction @@ -0,0 +1,24 @@ +# @s = a wandering trader +# at @s +# run from #gm4_trades:register_trades + +scoreboard players set $valid_trader gm4_balloon_animals_data 1 + +# check tags +execute if entity @s[tag=gm4_balloon_animal_eligible_ignore] run scoreboard players set $valid_trader gm4_balloon_animals_data 0 +execute if entity @s[tag=gm4_calling_bell_trader] run scoreboard players set $valid_trader gm4_balloon_animals_data 0 + +data modify storage gm4_balloon_animals:temp trader.uuid set from entity @s UUID +tag @s add gm4_balloon_animal_trader_eligible_check + +# must have 2 llamas leashed +scoreboard players set $trader_llama_count gm4_balloon_animals_data 0 +execute as @e[type=trader_llama,tag=!smithed.entity,distance=..6] on leasher if entity @s[tag=gm4_balloon_animal_trader_eligible_check] run scoreboard players add $trader_llama_count gm4_balloon_animals_data 1 +execute unless score $trader_llama_count gm4_balloon_animals_data matches 2 run scoreboard players set $valid_trader gm4_balloon_animals_data 0 + +tag @s add gm4_balloon_animal_eligible_ignore +tag @s remove gm4_balloon_animal_trader_eligible_check +execute if score $valid_trader gm4_balloon_animals_data matches 1 if predicate gm4_balloon_animals:balloon_trader_chance run function gm4_balloon_animals:wandering_trader/init_trader + +# clean up +scoreboard players reset $trader_llama_count gm4_balloon_animals_data diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/init_trader.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/init_trader.mcfunction new file mode 100755 index 0000000000..38a987c84f --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/init_trader.mcfunction @@ -0,0 +1,20 @@ +# @s = a wandering trader with exactly 2 trader llamas +# at @s +# run from wandering_trader/check_eligibility via #gm4_trades:register_trades + +tag @s add gm4_balloon_animal_trader +tag @s add gm4_balloon_animal_trader_new + +scoreboard players set $llamas_replaced gm4_balloon_animals_data 0 + +# find leashed llamas +execute as @e[type=trader_llama,tag=!smithed.entity,distance=..6] run function gm4_balloon_animals:wandering_trader/llama/check_leasher + +# pick two animals and set up trades +function gm4_balloon_animals:wandering_trader/pick_two_animals + + +# clean up +scoreboard players reset $trader_llama_check gm4_balloon_animals_data + +tag @s remove gm4_balloon_animal_trader_new diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/llama/check_leasher.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/llama/check_leasher.mcfunction new file mode 100755 index 0000000000..10df14b70e --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/llama/check_leasher.mcfunction @@ -0,0 +1,7 @@ +# Checks that this trader llama is attached to the wandering trader that is being checked +# @s = a llama within 5 blocks of the wandering trader being checked +# at @s +# run from wandering_trader/init_trader + +execute store result score $trader_llama_check gm4_balloon_animals_data on leasher if entity @s[tag=gm4_balloon_animal_trader_new] +execute if score $trader_llama_check gm4_balloon_animals_data matches 1 run function gm4_balloon_animals:wandering_trader/llama/kill diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/llama/delay/find_lead.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/llama/delay/find_lead.mcfunction new file mode 100755 index 0000000000..c83596487a --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/llama/delay/find_lead.mcfunction @@ -0,0 +1,6 @@ +# @s = marker, tag=gm4_balloon_animal_item_cleanup +# at @s +# run from wandering_trader/llama/delay/lead_cleanup + +kill @e[type=item,distance=..5,nbt={Age:1s},limit=2] +kill @s diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/llama/delay/lead_cleanup.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/llama/delay/lead_cleanup.mcfunction new file mode 100755 index 0000000000..2fdd5b88c9 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/llama/delay/lead_cleanup.mcfunction @@ -0,0 +1,5 @@ +# Look for gm4_balloon_animal_item_cleanup markers +# at world spawn +# scheduled by wandering_trader/llama/kill + +execute as @e[type=marker,tag=gm4_balloon_animal_item_cleanup] at @s run function gm4_balloon_animals:delay/find_lead diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/llama/kill.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/llama/kill.mcfunction new file mode 100755 index 0000000000..8144334532 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/llama/kill.mcfunction @@ -0,0 +1,12 @@ +# @s = a llama within 5 blocks of the wandering trader being checked +# at @s +# run from wandering_trader/llama/check_leasher + +execute on leasher at @s unless entity @e[type=marker,tag=gm4_balloon_animal_item_cleanup,distance=..0.01,limit=1] summon marker run tag @s add gm4_balloon_animal_item_cleanup + +scoreboard players add $llamas_replaced gm4_balloon_animals_data 1 + +tp @s ~ ~-4096 ~ +kill @s + +schedule function gm4_balloon_animals:wandering_trader/llama/delay/lead_cleanup 1t diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/pick_two_animals.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/pick_two_animals.mcfunction new file mode 100755 index 0000000000..f9f0cd8286 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/pick_two_animals.mcfunction @@ -0,0 +1,9 @@ +# @s = a wandering trader with no trader llamas, tag=gm4_balloon_animal_trader,tag=gm4_balloon_animal_trader_new +# at @s +# run from wandering_trader/init_trader + +data modify storage gm4_balloon_animals:temp gm4_balloon_animals set value {animal:1b,trade:1b} +function gm4_balloon_animals:wandering_trader/trade/pick_animal + +data modify storage gm4_balloon_animals:temp gm4_balloon_animals set value {animal:2b,trade:2b} +function gm4_balloon_animals:wandering_trader/trade/pick_animal diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/add_bee_nest.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/add_bee_nest.mcfunction new file mode 100644 index 0000000000..39d9995699 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/add_bee_nest.mcfunction @@ -0,0 +1,9 @@ +# @s = trader llama +# at wandering trader with no llamas, tag=gm4_balloon_animal_trader,tag=gm4_balloon_animal_trader_new +# run from wandering_trader/trade/pick_animal + +tp @s ~ 0 ~ + +data merge entity @s {Silent:1b,NoGravity:1b,Invulnerable:1b,ChestedHorse:1b,Variant:0,Strength:1,DespawnDelay:1,Tags:["gm4_trade_option"],Items:[{},{id:"minecraft:emerald",Count:8b,Slot:3b},{}],DecorItem:{id:"minecraft:light_blue_carpet",Count:1b,tag:{gm4_trades:{options:{maxUses:1,rewardXp:1b,xp:1,priceMultiplier:0.05f}}}}} + +loot replace entity @s horse.0 loot gm4_balloon_animals:bee_nest diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/add_chicken_egg.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/add_chicken_egg.mcfunction new file mode 100644 index 0000000000..ea2961e60e --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/add_chicken_egg.mcfunction @@ -0,0 +1,9 @@ +# @s = trader llama +# at wandering trader with no llamas, tag=gm4_balloon_animal_trader,tag=gm4_balloon_animal_trader_new +# run from wandering_trader/trade/pick_animal + +tp @s ~ 0 ~ + +data merge entity @s {Silent:1b,NoGravity:1b,Invulnerable:1b,ChestedHorse:1b,Variant:0,Strength:1,DespawnDelay:1,Tags:["gm4_trade_option"],Items:[{},{id:"minecraft:emerald",Count:2b,Slot:3b},{}],DecorItem:{id:"minecraft:light_blue_carpet",Count:1b,tag:{gm4_trades:{options:{maxUses:4,rewardXp:1b,xp:1,priceMultiplier:0.05f}}}}} + +loot replace entity @s horse.0 loot gm4_balloon_animals:chicken_egg diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/add_turtle_egg.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/add_turtle_egg.mcfunction new file mode 100644 index 0000000000..d0dbfb602b --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/add_turtle_egg.mcfunction @@ -0,0 +1,9 @@ +# @s = trader llama +# at wandering trader with no llamas, tag=gm4_balloon_animal_trader,tag=gm4_balloon_animal_trader_new +# run from wandering_trader/trade/pick_animal + +tp @s ~ 0 ~ + +data merge entity @s {Silent:1b,NoGravity:1b,Invulnerable:1b,ChestedHorse:1b,Variant:0,Strength:1,DespawnDelay:1,Tags:["gm4_trade_option"],Items:[{},{id:"minecraft:emerald",Count:8b,Slot:3b},{}],DecorItem:{id:"minecraft:light_blue_carpet",Count:1b,tag:{gm4_trades:{options:{maxUses:1,rewardXp:1b,xp:1,priceMultiplier:0.05f}}}}} + +loot replace entity @s horse.0 loot gm4_balloon_animals:turtle_egg diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/init_animal.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/init_animal.mcfunction new file mode 100755 index 0000000000..4c2090f616 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/init_animal.mcfunction @@ -0,0 +1,20 @@ +# @s = animal to be attached to trader, type=#gm4_balloon_animals:balloon_animal +# at wandering trader with no llamas, tag=gm4_balloon_animal_trader,tag=gm4_balloon_animal_trader_new +# run from wandering_trader/trade/pick_animal + +tag @s add gm4_balloon_animal + +effect give @s levitation infinite 0 true +effect give @s slow_falling infinite 0 true +effect give @s resistance infinite 4 true + +data modify entity @s Age set value -2147483648 +data modify entity @s Leash.UUID set from storage gm4_balloon_animals:temp trader.uuid + +scoreboard players add $id gm4_balloon_animals_id 1 +scoreboard players operation @s gm4_balloon_animals_id = $id gm4_balloon_animals_id +execute store result storage gm4_balloon_animals:temp gm4_balloon_animals.id int 1 run scoreboard players get $id gm4_balloon_animals_id + +execute summon trader_llama run function gm4_balloon_animals:wandering_trader/trade/spawn_trade_llama + +data modify entity @s CustomName set from storage gm4_balloon_animals:temp name_spliced diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/pick_animal.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/pick_animal.mcfunction new file mode 100644 index 0000000000..358f6c41f6 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/pick_animal.mcfunction @@ -0,0 +1,13 @@ +# @s = wandering trader and no trader llamas, tag=gm4_balloon_animal_trader,tag=gm4_balloon_animal_trader_new +# at @s +# run from wandering_trader/pick_two_animals + +execute store result score $animal_id gm4_balloon_animals_data run loot spawn ~ ~-4096 ~ loot gm4_balloon_animals:technical/random/enumeration_value + +for animal in ctx.meta['animals']: + if animal['function'] != 'init_animal': + execute if score $animal_id gm4_balloon_animals_data matches ctx.meta['enumeration'].index(animal['id']) summon minecraft:trader_llama run function f"gm4_balloon_animals:wandering_trader/trade/{animal['function']}" + continue + + 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']}" + diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/spawn_trade_llama.mcfunction b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/spawn_trade_llama.mcfunction new file mode 100644 index 0000000000..9d214d85c6 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/functions/wandering_trader/trade/spawn_trade_llama.mcfunction @@ -0,0 +1,16 @@ +# @s = trader llama +# at wandering trader with no llamas, tag=gm4_balloon_animal_trader,tag=gm4_balloon_animal_trader_new +# run from wandering_trader/trade/pick_animal + +tp @s ~ 0 ~ +data merge entity @s {Silent:1b,NoGravity:1b,Invulnerable:1b,ChestedHorse:1b,Variant:0,Strength:1,DespawnDelay:1,Tags:["gm4_trade_option"],Items:[{},{id:"minecraft:emerald",Count:12b,Slot:3b},{}],DecorItem:{id:"minecraft:light_blue_carpet",Count:1b,tag:{gm4_trades:{options:{maxUses:1,rewardXp:1b,xp:1,priceMultiplier:0.05f}}}}} + +loot replace entity @s horse.0 loot gm4_balloon_animals:lead +item modify entity @s horse.0 gm4_balloon_animals:set_lead_data + +data modify storage gm4_balloon_animals:temp name_json set from entity @s Items[0].tag.display.Lore[0] +data modify storage gm4_balloon_animals:temp name_spliced set string storage gm4_balloon_animals:temp name_json 9 -17 + +# Example Lead display nbt: +# display.Name: {"text":"Cow","italic":false} +# display.Lore[0]: {"text":"Abigail","color":"gray"} diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/guidebook/balloon_animals.json b/gm4_balloon_animals/data/gm4_balloon_animals/guidebook/balloon_animals.json new file mode 100644 index 0000000000..2a19c09555 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/guidebook/balloon_animals.json @@ -0,0 +1,46 @@ +{ + "id": "balloon_animals", + "name": "Balloon Animals", + "module_type": "module", + "icon": { + "item": "minecraft:lead" + }, + "criteria": { + "interact_trader": { + "trigger": "minecraft:player_interacted_with_entity", + "conditions": { + "entity": [ + { + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "nbt": "{Tags:[\"gm4_balloon_animal_trader\"]}" + } + } + ] + } + } + }, + "sections": [ + { + "name": "description", + "enable": [], + "requirements": [ + [ + "interact_trader" + ] + ], + "pages": [ + [ + { + "insert": "title" + }, + { + "translate": "text.gm4.guidebook.balloon_animals.description", + "fallback": "Balloon Animals introduces animal trades to some wandering traders." + } + ] + ] + } + ] +} diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/item_modifiers/set_lead_data.json b/gm4_balloon_animals/data/gm4_balloon_animals/item_modifiers/set_lead_data.json new file mode 100755 index 0000000000..996511bbc9 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/item_modifiers/set_lead_data.json @@ -0,0 +1,14 @@ +{ + "function": "minecraft:copy_nbt", + "source": { + "type": "minecraft:storage", + "source": "gm4_balloon_animals:temp" + }, + "ops": [ + { + "source": "gm4_balloon_animals", + "target": "gm4_balloon_animals", + "op": "merge" + } + ] +} diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/bee_nest.json b/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/bee_nest.json new file mode 100644 index 0000000000..0d7a027ea2 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/bee_nest.json @@ -0,0 +1,19 @@ +{ + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:bee_nest", + "functions": [ + { + "function": "minecraft:set_nbt", + "tag": "{BlockEntityTag:{Bees:[{EntityData:{id:\"minecraft:bee\"}}]}}" + } + ] + } + ] + } + ] +} diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/chicken_egg.json b/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/chicken_egg.json new file mode 100644 index 0000000000..368774d675 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/chicken_egg.json @@ -0,0 +1,19 @@ +{ + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:egg", + "functions": [ + { + "function": "minecraft:set_count", + "count": 8 + } + ] + } + ] + } + ] +} diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/lead.json b/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/lead.json new file mode 100644 index 0000000000..cb83f8eb95 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/lead.json @@ -0,0 +1,69 @@ +entries = [] +for animal in ctx.meta['animals']: + if animal['function'] != "init_animal": + continue + + for name in map(str.strip, animal['names'].split(',')): + entries.append( + { + "type": "minecraft:item", + "name": "minecraft:lead", + "functions": [ + { + "function": "minecraft:copy_nbt", + "source": { + "type": "minecraft:storage", + "source": "gm4_balloon_animals:temp" + }, + "ops": [ + { + "source": "{}", + "target": "{}", + "op": "replace" + } + ] + }, + { + "function": "minecraft:set_name", + "entity": "this", + "name": { + "text": animal['type'], + "italic": False + } + }, + { + "function": "minecraft:set_lore", + "entity": "this", + "lore": [ + { + "text": name, + "color": "gray" + } + ] + } + ], + "conditions": [ + { + "condition": "minecraft:value_check", + "value": { + "type": "minecraft:score", + "target": { + "type": "minecraft:fixed", + "name": "$animal_id" + }, + "score": "gm4_balloon_animals_data" + }, + "range": ctx.meta['enumeration'].index(animal['id']) + } + ] + } + ) + +{ + "pools": [ + { + "rolls": 1, + "entries": entries + } + ] +} diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/technical/random/enumeration_value.json b/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/technical/random/enumeration_value.json new file mode 100644 index 0000000000..dede35cb54 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/technical/random/enumeration_value.json @@ -0,0 +1,19 @@ +{ + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:loot_table", + "weight": 3, + "name": "gm4_balloon_animals:technical/random/pick_common" + }, + { + "type": "minecraft:loot_table", + "weight": 7, + "name": "gm4_balloon_animals:technical/random/pick_rare" + } + ] + } + ] +} diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/technical/random/pick_common.json b/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/technical/random/pick_common.json new file mode 100644 index 0000000000..a7e52b4a70 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/technical/random/pick_common.json @@ -0,0 +1,16 @@ +{ + "pools": [ + { + "rolls": { + "min": 0, + "max": int(f"{ctx.meta['rare_start']-1}") + }, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:stone" + } + ] + } + ] +} diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/technical/random/pick_rare.json b/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/technical/random/pick_rare.json new file mode 100644 index 0000000000..da913e33bf --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/technical/random/pick_rare.json @@ -0,0 +1,16 @@ +{ + "pools": [ + { + "rolls": { + "min": ctx.meta['rare_start'], + "max": int(f"{len(ctx.meta['enumeration'])-1}") + }, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:stone" + } + ] + } + ] +} diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/turtle_egg.json b/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/turtle_egg.json new file mode 100644 index 0000000000..4053008114 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/loot_tables/turtle_egg.json @@ -0,0 +1,13 @@ +{ + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:turtle_egg" + } + ] + } + ] +} diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/predicates/balloon_trader_chance.json b/gm4_balloon_animals/data/gm4_balloon_animals/predicates/balloon_trader_chance.json new file mode 100755 index 0000000000..a3c55f54fe --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/predicates/balloon_trader_chance.json @@ -0,0 +1,4 @@ +{ + "condition": "minecraft:random_chance", + "chance": 0.5 +} diff --git a/gm4_balloon_animals/data/gm4_balloon_animals/tags/entity_types/balloon_animal.json b/gm4_balloon_animals/data/gm4_balloon_animals/tags/entity_types/balloon_animal.json new file mode 100644 index 0000000000..ba44208a70 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_balloon_animals/tags/entity_types/balloon_animal.json @@ -0,0 +1,8 @@ +animals_list = [] + +for animal in ctx.meta['animals']: + animals_list.append(f"{animal['id']}",) + +{ + "values": sorted(animals_list) +} diff --git a/gm4_balloon_animals/data/gm4_trades/tags/functions/register_trades.json b/gm4_balloon_animals/data/gm4_trades/tags/functions/register_trades.json new file mode 100644 index 0000000000..4dca2165e5 --- /dev/null +++ b/gm4_balloon_animals/data/gm4_trades/tags/functions/register_trades.json @@ -0,0 +1,5 @@ +{ + "values": [ + "gm4_balloon_animals:wandering_trader/check_eligibility" + ] +} diff --git a/gm4_balloon_animals/generate.py b/gm4_balloon_animals/generate.py new file mode 100644 index 0000000000..f42d1abc82 --- /dev/null +++ b/gm4_balloon_animals/generate.py @@ -0,0 +1,30 @@ +from pathlib import Path +from typing import List + +from beet import Context + +from gm4.utils import CSV + + +def beet_default(ctx: Context): + + # read csv file + animals = CSV.from_file(Path('gm4_balloon_animals','animals.csv')) + + # sort animals into a common and a rare group + rare_animals: List[str] = [] + common_animals: List[str] = [] + for animal in animals: + if animal['rare'] == "TRUE": + rare_animals.append(str(animal['id'])) + continue + common_animals.append(str(animal['id'])) + + # sort each group alphabetically to ensure .csv-independent id assignments + rare_animals.sort() + common_animals.sort() + + # store to meta + ctx.meta['animals'] = animals + ctx.meta['enumeration'] = [*common_animals, *rare_animals] + ctx.meta['rare_start'] = len(common_animals) diff --git a/gm4_balloon_animals/translations.csv b/gm4_balloon_animals/translations.csv new file mode 100644 index 0000000000..179f54083d --- /dev/null +++ b/gm4_balloon_animals/translations.csv @@ -0,0 +1,5 @@ +key,en_us +advancement.gm4.balloon_animals.title,Party Animals +advancement.gm4.balloon_animals.description,Buy a Balloon Animal from a Wandering Trader +text.gm4.guidebook.module_desc.balloon_animals,Looking for exotic animals? This module makes some Wandering Traders sell cute baby animals! +text.gm4.guidebook.balloon_animals.description,Balloon Animals introduces animal trades to some wandering traders. diff --git a/gm4_guidebook/triggers.json b/gm4_guidebook/triggers.json index 9b0f9fc0da..9c8721e135 100644 --- a/gm4_guidebook/triggers.json +++ b/gm4_guidebook/triggers.json @@ -1,11 +1,12 @@ { "__important__": "Generated by generate_guidebooks.py. Don't manually update this", - "__next__": 117, + "__next__": 118, "animi_shamir": 91, "apple_trees": 83, "arborenda_shamir": 20, "audere_shamir": 8, "auto_crafting": 104, + "balloon_animals": 117, "bat_grenades": 90, "beehive_inspector": 51, "better_armour_stands": 74,