Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
TheThanathor committed May 6, 2024
2 parents 64b1dc8 + 5f59675 commit 0efd793
Show file tree
Hide file tree
Showing 51 changed files with 761 additions and 1 deletion.
4 changes: 4 additions & 0 deletions gm4/modeldata_registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 19 additions & 0 deletions gm4_balloon_animals/animals.csv
Original file line number Diff line number Diff line change
@@ -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,
34 changes: 34 additions & 0 deletions gm4_balloon_animals/beet.yaml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions gm4_balloon_animals/data/gm4/advancements/balloon_animals.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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] ~ ~ ~
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 0efd793

Please sign in to comment.