Skip to content

Commit dc659e3

Browse files
Bloo-devBPR02
andauthored
Lavish Livestock (#1194)
Introduces the Lavish Livestock module which allows players to gain access to slightly larger versions of livestock via selective breeding. --------- Co-authored-by: BPR <[email protected]>
1 parent 6a71b61 commit dc659e3

File tree

13 files changed

+209
-0
lines changed

13 files changed

+209
-0
lines changed

gm4_lavish_livestock/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Lavish Livestock<!--$headerTitle--><!--$pmc:delete-->
2+
3+
Selectively breed your livestock for increased yields! Commercialize your farming!<!--$pmc:headerSize-->
4+
5+
### Features
6+
- Breeding livestock may result in offspring that is abnormally large
7+
- Larger livestock drops more loot

gm4_lavish_livestock/beet.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
id: gm4_lavish_livestock
2+
name: Lavish Livestock
3+
version: 1.0.0
4+
5+
data_pack:
6+
load: .
7+
8+
resource_pack:
9+
load: .
10+
11+
require:
12+
- bolt
13+
14+
pipeline:
15+
- gm4_lavish_livestock.generate
16+
- gm4.plugins.extend.module
17+
18+
meta:
19+
gm4:
20+
versioning:
21+
schedule_loops: []
22+
website:
23+
description: Selectively breed your livestock for increased yields! Commercialize your farming!
24+
recommended:
25+
- gm4_pig_tractors
26+
- metallurgy
27+
video: null
28+
#modrinth:
29+
# project_id:
30+
#smithed:
31+
# pack_id:
32+
#planetminecraft:
33+
# uid:
34+
wiki: https://wiki.gm4.co/wiki/Lavish_Livestock
35+
credits:
36+
Creator:
37+
- Bloo
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
execute unless score lavish_livestock gm4_modules matches 1 run data modify storage gm4:log queue append value {type:"install",module:"Lavish Livestock"}
2+
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
3+
scoreboard players set lavish_livestock gm4_modules 1
4+
5+
scoreboard objectives add gm4_lavish_livestock_size dummy
6+
7+
#$moduleUpdateList
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"criteria": {
3+
"breed_pigs": {
4+
"trigger": "minecraft:bred_animals",
5+
"conditions": {
6+
"child": {
7+
"type": "{{ entity_id }}"
8+
}
9+
}
10+
}
11+
},
12+
"rewards": {
13+
"function": "gm4_lavish_livestock:{{ entity_id }}/revoke_advancement"
14+
}
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Stores the size of each parent into a score
2+
# @s = parent of the baby
3+
# at location of player who has fed the parent
4+
# run from gm4_lavish_livestock:{{ entity_id }}/revoke_advancement
5+
6+
# init score if parent does not have a score
7+
scoreboard players add @s gm4_lavish_livestock_size 0
8+
9+
# 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
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Selects babies near the breeding site
2+
# @s = breeding site
3+
# at @s
4+
# run from gm4_lavish_livestock:{{ entity_id }}/find_marker
5+
6+
# cache parent size
7+
scoreboard players reset $size gm4_lavish_livestock_size
8+
scoreboard players operation $size gm4_lavish_livestock_size = @s gm4_lavish_livestock_size
9+
execute as @e[type={{ entity_id }},distance=..10,nbt={Age:-24000},limit=1,sort=nearest] run function gm4_lavish_livestock:{{ entity_id }}/modify_baby
10+
11+
# remove breeding site marker
12+
kill @s
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Called once the parent has given birth and initiates breeding sites to look for babies.
2+
# @s = undefined
3+
# at undefined
4+
# scheduled from gm4_lavish_livestock:{{ entity_id }}/revoke_advancement
5+
6+
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
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Initializes the breeding site marker which sticks around awaiting birth
2+
# @s = new breeding site marker
3+
# at location of player who has fed the parent
4+
# run from gm4_lavish_livestock:{{ entity_id }}/determine_parent
5+
6+
scoreboard players operation @s gm4_lavish_livestock_size = $parent_a gm4_lavish_livestock_size
7+
tag @s add gm4_lavish_livestock_breeding_site
8+
tag @s add gm4_lavish_livestock_{{ entity_id }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Sets the size of the newborn baby
2+
# @s = the newborn baby
3+
# at location of breeding site marker
4+
# run from gm4_lavish_livestock:{{ entity_id }}/find_baby
5+
6+
# get baby size from marker value
7+
scoreboard players operation @s gm4_lavish_livestock_size = $size gm4_lavish_livestock_size
8+
9+
# if non-vanilla size: add loot table and tag entity (tag is for future-proofing only, it is not currently read)
10+
execute if score @s gm4_lavish_livestock_size matches 1.. run tag @s add gm4_lavish_livestock_{{ entity_id }}
11+
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"
12+
13+
# set scale attribute
14+
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
15+
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
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Revokes the breeding advancement and initiates baby tracking
2+
# @s = player who bred livestock
3+
# at @s
4+
# run from advancement gm4_lavish_livestock:{{ entity_id }}/breed
5+
6+
advancement revoke @s only gm4_lavish_livestock:{{ entity_id }}/breed
7+
8+
# get parent sizes
9+
scoreboard players reset $parent_a gm4_lavish_livestock_size
10+
scoreboard players reset $parent_b gm4_lavish_livestock_size
11+
execute as @e[type={{ entity_id }},distance=..10,limit=2,sort=nearest,nbt=!{InLove:0}] run function gm4_lavish_livestock:{{ entity_id }}/determine_parent
12+
13+
# if the parents differ in size, chose the smaller one
14+
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
15+
16+
# if both parents are the same size, roll dice for size increase
17+
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
18+
19+
# store size onto marker and wait for baby to be born
20+
execute summon marker run function gm4_lavish_livestock:{{ entity_id }}/initialize_marker
21+
schedule function gm4_lavish_livestock:{{ entity_id }}/find_marker 1t

0 commit comments

Comments
 (0)