Skip to content

Commit b2dbd30

Browse files
authored
Lavish livestock address review comments (#1244)
* Uninitialized Value * Remove unneeded score reset * Rename advancement criteria * CSV -> List in generate.py * Basic Guidebook * Change guidebook list for translated entity names * beeps is this good? * Move list to beet.yaml * Rename list to `livestock`
1 parent c676c50 commit b2dbd30

File tree

12 files changed

+90
-26
lines changed

12 files changed

+90
-26
lines changed

gm4/modeldata_registry.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,8 @@
16971697
"gm4_metallurgy:shamir/infinitas": 100
16981698
},
16991699
"wheat": {
1700-
"gm4_mysterious_midnights:guidebook_icon/harvest_moons": 1
1700+
"gm4_mysterious_midnights:guidebook_icon/harvest_moons": 1,
1701+
"gm4_lavish_livestock:guidebook_icon/lavish_livestock": 2
17011702
},
17021703
"white_concrete_powder": {
17031704
"gm4_zauber_cauldrons:block/liquid_magicol/white": 300

gm4_guidebook/triggers.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"__important__": "Generated by generate_guidebooks.py. Don't manually update this",
3-
"__next__": 122,
3+
"__next__": 123,
44
"animi_shamir": 91,
55
"apple_trees": 83,
66
"arborenda_shamir": 20,
@@ -56,6 +56,7 @@
5656
"illusioner_nights": 103,
5757
"infinitas_shamir": 23,
5858
"ink_spitting_squid": 78,
59+
"lavish_livestock": 122,
5960
"lightning_in_a_bottle": 109,
6061
"liquid_minecarts": 47,
6162
"liquid_tanks": 63,

gm4_lavish_livestock/beet.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ pipeline:
1616
- gm4.plugins.extend.module
1717

1818
meta:
19+
livestock:
20+
- chicken
21+
- cow
22+
- hoglin
23+
- mooshroom
24+
- pig
25+
- rabbit
26+
- sheep
1927
gm4:
2028
versioning:
2129
schedule_loops: []
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"id": "lavish_livestock",
3+
"name": "Lavish Livestock",
4+
"module_type": "module",
5+
"icon": {
6+
"id": "minecraft:wheat"
7+
},
8+
"criteria": {
9+
"breed": {
10+
"trigger": "minecraft:bred_animals",
11+
"conditions": {
12+
"child": {
13+
"type": "#gm4_lavish_livestock:livestock"
14+
}
15+
}
16+
}
17+
},
18+
"sections": [
19+
{
20+
"name": "display",
21+
"enable": [],
22+
"requirements": [
23+
[
24+
"breed"
25+
]
26+
],
27+
"pages": [
28+
[
29+
{
30+
"insert": "title"
31+
},
32+
{
33+
"text":"\n"
34+
},
35+
{
36+
"translate": "text.gm4.guidebook.lavish_livestock.description",
37+
"fallback": "Breeding livestock may result in offspring that is abnormally large.\n\nLarger livestock drops more loot."
38+
}
39+
],
40+
[
41+
{
42+
"translate":"text.gm4.guidebook.lavish_livestock.list_header",
43+
"fallback":"Livestock",
44+
"underlined":true
45+
},
46+
{"text":"\n\n"},
47+
{"translate":"entity.minecraft.chicken", "underlined":false},
48+
{"text":"\n"},
49+
{"translate":"entity.minecraft.cow", "underlined":false},
50+
{"text":"\n"},
51+
{"translate":"entity.minecraft.hoglin", "underlined":false},
52+
{"text":"\n"},
53+
{"translate":"entity.minecraft.mooshroom", "underlined":false},
54+
{"text":"\n"},
55+
{"translate":"entity.minecraft.pig", "underlined":false},
56+
{"text":"\n"},
57+
{"translate":"entity.minecraft.rabbit", "underlined":false},
58+
{"text":"\n"},
59+
{"translate":"entity.minecraft.sheep", "underlined":false}
60+
]
61+
]
62+
}
63+
]
64+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"values": ctx.meta['livestock']
3+
}

gm4_lavish_livestock/data/gm4_lavish_livestock/templates/advancement/breed.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"criteria": {
3-
"breed_pigs": {
3+
"breed_{{ entity_id }}": {
44
"trigger": "minecraft:bred_animals",
55
"conditions": {
66
"child": {

gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/determine_parent.mcfunction

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
scoreboard players add @s gm4_lavish_livestock_size 0
88

99
# store size of parent into fixed fake player (only one of these triggers, the other one triggers for the other parent)
10-
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
11-
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
10+
execute if score $parent_a gm4_lavish_livestock_size matches -1 run return run scoreboard players operation $parent_a gm4_lavish_livestock_size = @s gm4_lavish_livestock_size
11+
execute if score $parent_b gm4_lavish_livestock_size matches -1 run return run scoreboard players operation $parent_b gm4_lavish_livestock_size = @s gm4_lavish_livestock_size

gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/find_baby.mcfunction

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# run from gm4_lavish_livestock:{{ entity_id }}/find_marker
55

66
# cache parent size
7-
scoreboard players reset $size gm4_lavish_livestock_size
87
scoreboard players operation $size gm4_lavish_livestock_size = @s gm4_lavish_livestock_size
98
execute as @e[type={{ entity_id }},distance=..10,nbt={Age:-24000},limit=1,sort=nearest] run function gm4_lavish_livestock:{{ entity_id }}/modify_baby
109

gm4_lavish_livestock/data/gm4_lavish_livestock/templates/function/revoke_advancement.mcfunction

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
advancement revoke @s only gm4_lavish_livestock:{{ entity_id }}/breed
77

88
# get parent sizes
9-
scoreboard players reset $parent_a gm4_lavish_livestock_size
10-
scoreboard players reset $parent_b gm4_lavish_livestock_size
9+
scoreboard players set $parent_a gm4_lavish_livestock_size -1
10+
scoreboard players set $parent_b gm4_lavish_livestock_size -1
1111
execute as @e[type={{ entity_id }},distance=..10,limit=2,sort=nearest,nbt=!{InLove:0}] run function gm4_lavish_livestock:{{ entity_id }}/determine_parent
1212

1313
# if the parents differ in size, chose the smaller one

gm4_lavish_livestock/generate.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
from pathlib import Path
21
import logging
32

43
from beet import Context, subproject
5-
from gm4.utils import CSV
64

75
logger = logging.getLogger(__name__)
86

97
def beet_default(ctx: Context):
10-
11-
# load csv
12-
csv = CSV.from_file(Path('gm4_lavish_livestock', 'raw', 'livestock.csv'))
13-
14-
# prepare list of supported entities
15-
entity_ids = [e.get('entity_id', "").removeprefix('minecraft:').strip() for e in csv]
16-
8+
# List of supported animals defined in beet.yaml as well as the guidebook page
179
# for each supported entity, render a copy of the "templates" directory with the appropriate entity-id
18-
for entity in entity_ids:
10+
for entity in ctx.meta['livestock']:
1911
subproject_config = {
2012
"data_pack": {
2113
"load": [

0 commit comments

Comments
 (0)