Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions gm4_lavish_livestock/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Lavish Livestock<!--$headerTitle--><!--$pmc:delete-->

Selectively breed your livestock for increased yields! Commercialize your farming!<!--$pmc:headerSize-->

### Features
- Breeding livestock may result in offspring that is abnormally large
- Larger individuals drop more loot
37 changes: 37 additions & 0 deletions gm4_lavish_livestock/beet.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 }}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 }}"
}
39 changes: 39 additions & 0 deletions gm4_lavish_livestock/generate.py
Original file line number Diff line number Diff line change
@@ -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))
8 changes: 8 additions & 0 deletions gm4_lavish_livestock/raw/livestock.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
entity_id,
chicken,
cow,
hoglin,
mooshroom,
pig,
rabbit,
sheep,
Loading