diff --git a/gm4_lavish_livestock/README.md b/gm4_lavish_livestock/README.md new file mode 100644 index 0000000000..0dd7aaaf03 --- /dev/null +++ b/gm4_lavish_livestock/README.md @@ -0,0 +1,7 @@ +# Lavish Livestock + +Selectively breed your livestock for increased yields! Commercialize your farming! + +### Features +- Breeding livestock may result in offspring that is abnormally large +- Larger individuals drop more loot diff --git a/gm4_lavish_livestock/beet.yaml b/gm4_lavish_livestock/beet.yaml new file mode 100644 index 0000000000..b0d9d8b489 --- /dev/null +++ b/gm4_lavish_livestock/beet.yaml @@ -0,0 +1,37 @@ +id: gm4_lavish_livestock +name: Lavish Livestock +version: 1.0.0 + +data_pack: + load: . + +resource_pack: + load: . + +require: + - bolt + +pipeline: + - gm4_lavish_livestock.generate + - gm4.plugins.extend.module + +meta: + gm4: + versioning: + schedule_loops: [] + website: + description: Selectively breed your livestock for increased yields! Commercialize your farming! + recommended: + - gm4_pig_tractors + - metallurgy + video: null + #modrinth: + # project_id: + #smithed: + # pack_id: + #planetminecraft: + # uid: + wiki: https://wiki.gm4.co/wiki/Lavish_Livestock + credits: + Creator: + - Bloo diff --git a/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/advancement/breed.json b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/advancement/breed.json new file mode 100644 index 0000000000..9d687e76e3 --- /dev/null +++ b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/advancement/breed.json @@ -0,0 +1,15 @@ +{ + "criteria": { + "breed_pigs": { + "trigger": "minecraft:bred_animals", + "conditions": { + "child": { + "type": "{{ entity_id }}" + } + } + } + }, + "rewards": { + "function": "gm4_lavish_livestock:{{ entity_id }}/revoke_advancement" + } +} diff --git a/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/determine_parent.mcfunction b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/determine_parent.mcfunction new file mode 100644 index 0000000000..76e26549a4 --- /dev/null +++ b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/determine_parent.mcfunction @@ -0,0 +1,11 @@ +# Stores the size of each parent into a score +# @s = parent of the baby +# at location of player who has fed the parent +# run from gm4_lavish_livestock:{{ entity_id }}/revoke_advancement + +# init score if parent does not have a score +scoreboard players add @s gm4_lavish_livestock_size 0 + +# store size of parent into fixed fake player (only one of these triggers, the other one triggers for the other parent) +execute unless score $parent_a gm4_lavish_livestock_size matches -2147483648..2147483647 run return run scoreboard players operation $parent_a gm4_lavish_livestock_size = @s gm4_lavish_livestock_size +execute unless score $parent_b gm4_lavish_livestock_size matches -2147483648..2147483647 run return run scoreboard players operation $parent_b gm4_lavish_livestock_size = @s gm4_lavish_livestock_size diff --git a/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/find_baby.mcfunction b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/find_baby.mcfunction new file mode 100644 index 0000000000..c349f66f5a --- /dev/null +++ b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/find_baby.mcfunction @@ -0,0 +1,12 @@ +# Selects babies near the breeding site +# @s = breeding site +# at @s +# run from gm4_lavish_livestock:{{ entity_id }}/find_marker + +# cache parent size +scoreboard players reset $size gm4_lavish_livestock_size +scoreboard players operation $size gm4_lavish_livestock_size = @s gm4_lavish_livestock_size +execute as @e[type={{ entity_id }},distance=..10,nbt={Age:-24000},limit=1,sort=nearest] run function gm4_lavish_livestock:{{ entity_id }}/modify_baby + +# remove breeding site marker +kill @s diff --git a/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/find_marker.mcfunction b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/find_marker.mcfunction new file mode 100644 index 0000000000..b726da085e --- /dev/null +++ b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/find_marker.mcfunction @@ -0,0 +1,6 @@ +# Called once the parent has given birth and initiates breeding sites to look for babies. +# @s = undefined +# at undefined +# scheduled from gm4_lavish_livestock:{{ entity_id }}/revoke_advancement + +execute as @e[type=marker,tag=gm4_lavish_livestock_breeding_site,tag=gm4_lavish_livestock_{{ entity_id }}] at @s run function gm4_lavish_livestock:{{ entity_id }}/find_baby diff --git a/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/init.mcfunction b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/init.mcfunction new file mode 100644 index 0000000000..03cc419d13 --- /dev/null +++ b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/init.mcfunction @@ -0,0 +1,7 @@ +execute unless score lavish_livestock gm4_modules matches 1 run data modify storage gm4:log queue append value {type:"install",module:"Lavish Livestock"} +execute unless score lavish_livestock gm4_earliest_version < lavish_livestock gm4_modules run scoreboard players operation lavish_livestock gm4_earliest_version = lavish_livestock gm4_modules +scoreboard players set lavish_livestock gm4_modules 1 + +scoreboard objectives add gm4_lavish_livestock_size dummy + +#$moduleUpdateList diff --git a/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/initialize_marker.mcfunction b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/initialize_marker.mcfunction new file mode 100644 index 0000000000..3d8f92ba62 --- /dev/null +++ b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/initialize_marker.mcfunction @@ -0,0 +1,8 @@ +# Initializes the breeding site marker which sticks around awaiting birth +# @s = new breeding site marker +# at location of player who has fed the parent +# run from gm4_lavish_livestock:{{ entity_id }}/determine_parent + +scoreboard players operation @s gm4_lavish_livestock_size = $parent_a gm4_lavish_livestock_size +tag @s add gm4_lavish_livestock_breeding_site +tag @s add gm4_lavish_livestock_{{ entity_id }} diff --git a/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/modify_baby.mcfunction b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/modify_baby.mcfunction new file mode 100644 index 0000000000..01d07d9f54 --- /dev/null +++ b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/modify_baby.mcfunction @@ -0,0 +1,15 @@ +# Sets the size of the newborn baby +# @s = the newborn baby +# at location of breeding site marker +# run from gm4_lavish_livestock:{{ entity_id }}/find_baby + +# get baby size from marker value +scoreboard players operation @s gm4_lavish_livestock_size = $size gm4_lavish_livestock_size + +# if non-vanilla size: add loot table and tag entity (tag is for future-proofing only, it is not currently read) +execute if score @s gm4_lavish_livestock_size matches 1.. run tag @s add gm4_lavish_livestock_{{ entity_id }} +execute if score @s gm4_lavish_livestock_size matches 1.. run data modify entity @s DeathLootTable set value "gm4_lavish_livestock:{{ entity_id }}/lavish_death" + +# set scale attribute +execute if score @s gm4_lavish_livestock_size matches 1 run attribute @s minecraft:scale modifier add gm4_lavish_livestock:size 0.125 add_multiplied_base +execute if score @s gm4_lavish_livestock_size matches 2 run attribute @s minecraft:scale modifier add gm4_lavish_livestock:size 0.25 add_multiplied_base diff --git a/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/revoke_advancement.mcfunction b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/revoke_advancement.mcfunction new file mode 100644 index 0000000000..4fd873bffa --- /dev/null +++ b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/revoke_advancement.mcfunction @@ -0,0 +1,21 @@ +# Revokes the breeding advancement and initiates baby tracking +# @s = player who bred livestock +# at @s +# run from advancement gm4_lavish_livestock:{{ entity_id }}/breed + +advancement revoke @s only gm4_lavish_livestock:{{ entity_id }}/breed + +# get parent sizes +scoreboard players reset $parent_a gm4_lavish_livestock_size +scoreboard players reset $parent_b gm4_lavish_livestock_size +execute as @e[type={{ entity_id }},distance=..10,limit=2,sort=nearest,nbt=!{InLove:0}] run function gm4_lavish_livestock:{{ entity_id }}/determine_parent + +# if the parents differ in size, chose the smaller one +execute if score $parent_a gm4_lavish_livestock_size > $parent_b gm4_lavish_livestock_size run scoreboard players operation $parent_a gm4_lavish_livestock_size >< $parent_b gm4_lavish_livestock_size + +# if both parents are the same size, roll dice for size increase +execute if score $parent_a gm4_lavish_livestock_size = $parent_b gm4_lavish_livestock_size if predicate {condition:"minecraft:random_chance",chance:0.025} run scoreboard players add $parent_a gm4_lavish_livestock_size 1 + +# store size onto marker and wait for baby to be born +execute summon marker run function gm4_lavish_livestock:{{ entity_id }}/initialize_marker +schedule function gm4_lavish_livestock:{{ entity_id }}/find_marker 1t diff --git a/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/loot_table/lavish_death.json b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/loot_table/lavish_death.json new file mode 100644 index 0000000000..74a9f1e6a2 --- /dev/null +++ b/gm4_lavish_livestock/data/gm4_lavish_livestock/templates/loot_table/lavish_death.json @@ -0,0 +1,23 @@ +{ + "type": "minecraft:entity", + "pools": [ + { + "rolls": { + "type": "minecraft:score", + "target": { + "type": "minecraft:context", + "target": "this" + }, + "score": "gm4_lavish_livestock_size", + "scale": 2.5 + }, + "entries": [ + { + "type": "minecraft:loot_table", + "value": "minecraft:entities/{{ entity_id }}" + } + ] + } + ], + "random_sequence": "minecraft:entities/{{ entity_id }}" +} diff --git a/gm4_lavish_livestock/generate.py b/gm4_lavish_livestock/generate.py new file mode 100644 index 0000000000..477b9981e7 --- /dev/null +++ b/gm4_lavish_livestock/generate.py @@ -0,0 +1,39 @@ +from pathlib import Path +import logging + +from beet import Context, subproject +from gm4.utils import CSV + +logger = logging.getLogger(__name__) + +def beet_default(ctx: Context): + + # load csv + csv = CSV.from_file(Path('gm4_lavish_livestock', 'raw', 'livestock.csv')) + + # prepare list of supported entities + entity_ids = [e.get('entity_id', "").removeprefix('minecraft:').strip() for e in csv] + + # for each wood type in the vanilla doors tag, render a copy of the "templates" directory with the appropriate wood-type + for entity in entity_ids: + subproject_config = { + "data_pack": { + "load": [ + { + f"data/gm4_lavish_livestock/advancement/{entity}": "data/gm4_lavish_livestock/templates/advancement", + f"data/gm4_lavish_livestock/function/{entity}": "data/gm4_lavish_livestock/templates/function", + f"data/gm4_lavish_livestock/loot_table/{entity}": "data/gm4_lavish_livestock/templates/loot_table", + } + ], + "render": { + "advancement": "*", + "function": "*", + "loot_table": "*" + } + }, + "meta": { + "entity_id": entity + } + } + + ctx.require(subproject(subproject_config)) diff --git a/gm4_lavish_livestock/raw/livestock.csv b/gm4_lavish_livestock/raw/livestock.csv new file mode 100644 index 0000000000..6014dc51fe --- /dev/null +++ b/gm4_lavish_livestock/raw/livestock.csv @@ -0,0 +1,8 @@ +entity_id, +chicken, +cow, +hoglin, +mooshroom, +pig, +rabbit, +sheep,