-
-
Notifications
You must be signed in to change notification settings - Fork 64
Lavish Livestock #1194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Lavish Livestock #1194
Changes from all commits
13969a3
797894e
6e5bb63
ed5db55
e49bb83
15ccb8f
ec2607b
d1f705d
0fad944
c6d127a
303ff82
94e6839
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| 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": { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| "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 | ||
|
Comment on lines
+10
to
+11
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be more readable to initialize
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, resetting is worst than setting to a known "uninitialized value" |
||
| 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resetting the size is unnecessary when assigning the value one command later. |
||
| 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 |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
| 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 }}" | ||
| } |
| 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')) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need a CSV for this? Why not a json file or even just a list in this python script |
||
|
|
||
| # 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment is copied from double doors |
||
| 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)) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| entity_id, | ||
| chicken, | ||
| cow, | ||
| hoglin, | ||
| mooshroom, | ||
| pig, | ||
| rabbit, | ||
| sheep, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more clear to swap "individuals" with "livestock" or "animals". While it's unlikely to cause much confusion, I still think it would be better to be more specific.