Skip to content

Commit

Permalink
advancement tree, requisite tag updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
eerussianguy committed Apr 25, 2023
1 parent f355f1b commit 3e10a6c
Show file tree
Hide file tree
Showing 63 changed files with 2,177 additions and 15 deletions.
104 changes: 104 additions & 0 deletions resources/advancements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
from mcresources import ResourceManager, utils, advancements
from mcresources.advancements import AdvancementCategory
from mcresources.type_definitions import Json

from constants import *


def generate(rm: ResourceManager):
story = AdvancementCategory(rm, 'story', 'firmalife:textures/block/sealed_bricks.png')

story.advancement('root', icon('firmalife:empty_jar'), 'Firmalife Story', 'Things to do with Firmalife.', None, root_trigger(), chat=False)
story.advancement('rennet', icon('firmalife:rennet'), 'A Useful Stomach', 'Kill an animal for some rennet.', 'root', inventory_changed('firmalife:rennet'))
story.advancement('cheese_wheel', icon('firmalife:chevre_wheel'), 'A Wheel of Cheese', 'Craft your first cheese wheel.', 'rennet', inventory_changed('#firmalife:cheese_wheels'))
story.advancement('all_cheese', icon('firmalife:food/gouda'), 'Lactose Larry', 'Cut off a slice of every kind of cheese.', 'cheese_wheel', multiple(*[inventory_changed('firmalife:food/%s' % c, name=c) for c in ('gouda', 'chevre', 'cheddar', 'feta', 'rayja_metok', 'shosha')]), requirements=[[c] for c in ('gouda', 'chevre', 'cheddar', 'feta', 'rayja_metok', 'shosha')], frame='challenge')
story.advancement('climate_station', icon('firmalife:climate_station'), 'Climate Control', 'Craft a climate station.', 'root', inventory_changed('firmalife:climate_station'))
story.advancement('cellar', icon('firmalife:sealed_bricks'), 'A Waxy Solution', 'Craft a cellar block.', 'climate_station', inventory_changed('#firmalife:cellar_insulation'))
story.advancement('big_cellar', icon('firmalife:sealed_door'), 'The Dungeon', 'Activate a cellar of more than 200 blocks.', 'cellar', generic('firmalife:big_cellar', None), frame='goal')
story.advancement('shelf', icon('firmalife:wood/food_shelf/kapok'), 'Shelve it', 'Craft a food shelf.', 'cellar', inventory_changed('#firmalife:food_shelves'))
story.advancement('hanger', icon('firmalife:wood/hanger/birch'), 'Hang it', 'Craft a food hanger.', 'cellar', inventory_changed('#firmalife:hangers'))
story.advancement('greenhouse', icon('firmalife:copper_greenhouse_wall'), 'It\'s like a house, but Green.', 'Craft a greenhouse block.', 'climate_station', inventory_changed('#firmalife:greenhouse'))
story.advancement('big_greenhouse', icon('firmalife:stainless_steel_greenhouse_wall'), 'Food for Days', 'Activate a stainless steel greenhouse of more than 200 blocks.', 'greenhouse', generic('firmalife:big_stainless_greenhouse', None), frame='goal')
story.advancement('dribbler', icon('firmalife:dribbler'), 'Dribbler', 'Craft a Dribbler.', 'greenhouse', inventory_changed('firmalife:dribbler'))
story.advancement('sprinkler', icon('firmalife:sprinkler'), 'Sprinkler', 'Craft a Sprinkler.', 'greenhouse', inventory_changed('firmalife:sprinkler'))
story.advancement('planters', icon('firmalife:large_planter'), 'Planter City', 'Craft every kind of greenhouse planter.', 'greenhouse', multiple(*[inventory_changed('firmalife:%s_planter' % p, name=p) for p in PLANTERS]), requirements=[[p] for p in PLANTERS], frame='goal')
story.advancement('nutritive_basin', icon('firmalife:nutritive_basin'), 'Balance (TM)', 'Craft a nutritive basin.', 'greenhouse', inventory_changed('firmalife:nutritive_basin'))
story.advancement('hive', icon('firmalife:beehive'), 'So they just move in on their own?', 'Craft a beehive.', 'root', inventory_changed('firmalife:beehive'))
story.advancement('wax', icon('firmalife:beeswax'), 'Does this hurt the bee?', 'Get some beeswax from a hive.', 'hive', inventory_changed('firmalife:beeswax'))
story.advancement('jars', icon('firmalife:empty_jar'), 'minecraft.jar', 'Craft an empty jar.', 'hive', inventory_changed('firmalife:empty_jar'))
story.advancement('jarbnet', icon('firmalife:wood/jarbnet/palm'), 'Cupholder', 'Craft a jarbnet.', 'jars', inventory_changed('#firmalife:jarbnets'))
story.advancement('preserves', icon('firmalife:blueberry_jar'), 'Cannery', 'Craft fruit preserves.', 'jars', inventory_changed('#firmalife:foods/preserves'))
story.advancement('jarring_station', icon('firmalife:jarring_station'), 'Industrial Cannery', 'Craft a jarring station.', 'preserves', inventory_changed('firmalife:jarring_station'), frame='challenge')
story.advancement('smoker', icon('tfc:food/venison'), 'Up in Smoke', 'Place some string for smoking.', 'root', placed_block('firmalife:wool_string'))
story.advancement('dry', icon('firmalife:drying_mat'), 'Hydrophobic', 'Craft a drying mat.', 'root', inventory_changed('firmalife:drying_mat'))
story.advancement('oven', icon('firmalife:oven_bottom'), 'Bread Machine', 'Craft a top and bottom oven, and a chimney.', 'root', multiple(inventory_changed('firmalife:oven_bottom', name='ob'), inventory_changed('firmalife:oven_top', name='ot'), inventory_changed('firmalife:oven_chimney', name='ot')), requirements=[['ot'], ['oc'], ['ob']])
story.advancement('oven_hopper', icon('firmalife:oven_hopper'), 'Hop it', 'Craft an oven hopper.', 'oven', inventory_changed('firmalife:oven_hopper'))
story.advancement('ashtray', icon('firmalife:ashtray'), 'Free Fertilizer', 'Craft an ashtray.', 'oven', inventory_changed('firmalife:ashtray'))
story.advancement('vat', icon('firmalife:vat'), 'A Large Vat', 'Craft a vat.', 'oven', inventory_changed('firmalife:vat'))
story.advancement('stovetop_pot', icon('tfc:ceramic/pot'), 'Stovetop Pot', 'Put a pot on a bottom oven.', 'oven', generic('firmalife:stovetop_pot', None))
story.advancement('stovetop_grill', icon('tfc:wrought_iron_grill'), 'Stovetop Grill', 'Put a grill on a bottom oven.', 'oven', generic('firmalife:stovetop_grill', None))
story.advancement('oven_finishes', icon('firmalife:oven_insulation'), 'Finish him!', 'Craft all oven finishes, and oven insulation.', 'oven', multiple(*[inventory_changed('firmalife:%s' % c, name=c) for c in ('oven_insulation', 'rustic_finish', 'stone_finish', 'tile_finish')]), requirements=[[c] for c in ('oven_insulation', 'rustic_finish', 'stone_finish', 'tile_finish')])
story.advancement('mixer', icon('firmalife:mixing_bowl'), 'Mixer', 'Craft a mixing bowl.', 'wax', inventory_changed('firmalife:mixing_bowl'))
story.advancement('chocolate', icon('firmalife:food/dark_chocolate'), 'Chocolatier', 'Make some chocolate.', 'mixer', inventory_changed('#firmalife:foods/chocolate'))
story.advancement('chromite', icon('firmalife:ore/small_chromite'), 'Shiny and Chrome', 'Find some chromite.', 'root', inventory_changed('firmalife:ore/small_chromite'))
story.advancement('iron_composter', icon('firmalife:iron_composter'), 'Rusty Composter', 'Craft an iron composter', 'root', inventory_changed('firmalife:iron_composter'))
story.advancement('pizza', icon('firmalife:food/cooked_pizza'), 'Pizzeria', 'Bake some pizza in an oven.', 'oven', inventory_changed('firmalife:food/cooked_pizza'))
story.advancement('pie', icon('firmalife:food/cooked_pie'), 'Pie in the Face', 'Bake a pie.', 'oven', inventory_changed('firmalife:food/cooked_pie'))
story.advancement('burrito_taco', icon('firmalife:food/burrito'), 'Taqueria', 'Make a burrito and a taco.', 'oven', multiple(inventory_changed('firmalife:food/taco', name='taco'), inventory_changed('firmalife:food/burrito', name='burrito')), requirements=[['taco'], ['burrito']], frame='challenge')
story.advancement('baller', icon('firmalife:seed_ball'), 'Baller', 'Craft a seed ball.', 'root', inventory_changed('firmalife:seed_ball'))
story.advancement('pickled_egg', icon('firmalife:food/pickled_egg'), 'You put WHAT in this?', 'Craft a pickled egg.', 'root', inventory_changed('firmalife:food/pickled_egg'))
story.advancement('bacon', icon('firmalife:food/cooked_bacon'), 'Sizzle', 'Cook some bacon', 'root', inventory_changed('firmalife:food/bacon'))

def kill_mob(mob: str, other: Dict = None) -> Json:
return generic('minecraft:player_killed_entity', {'entity': [entity_predicate(mob, other)]})

# if the predicate is (and usually it will be) an EntityPredicate.Composite, this should be inside an array.
# EntityPredicate.Composite wraps a vanilla loot event in a trigger event
def entity_predicate(mob: str, other: Dict = None) -> Json:
dic = {
'condition': 'minecraft:entity_properties',
'predicate': {'type': mob}, # can be a hashtag to refer to entity tags
'entity': 'this',
}
if other is not None:
dic.update(other)
return dic


def consume_item(item: str, name: str = 'item_consumed') -> Json:
if isinstance(item, str) and name == 'item_consumed':
name = item.split(':')[1]
return generic('minecraft:consume_item', {'item': utils.item_predicate(item)}, name=name)

def icon(name: str) -> Json:
return {'item': name}

def biome(biome_name: str) -> Json:
return generic('minecraft:location', {'location': {'biome': 'tfc:%s' % biome_name}}, name=biome_name)

def multiple(*conditions: Json) -> Json:
merged = {}
for c in conditions:
merged.update(c)
return merged

def generic(trigger_type: str, conditions: Json, name: str = 'special_condition') -> Json:
return {name: {'trigger': trigger_type, 'conditions': conditions}}

def inventory_changed(item: str | Json, name: str = 'item_obtained') -> Json:
if isinstance(item, str) and name == 'item_obtained':
name = item.split(':')[1]
return {name: advancements.inventory_changed(item)}

def item_use_on_block(block: str, item: str, name: str = 'item_use_on_block_condition'):
block_json = {'tag': block[1:]} if block[0] == '#' else {'blocks': [block]}
return {name: {'trigger': 'minecraft:item_used_on_block', 'conditions': {
'location': {'block': block_json},
'item': {'items': [item]}
}}}

def placed_block(block: str, name: str = 'block_placed_condition') -> Json:
return {name: {'trigger': 'minecraft:placed_block', 'conditions': {'block': block}}}

def root_trigger() -> Json:
return {'in_game_condition': {'trigger': 'minecraft:tick'}}
8 changes: 4 additions & 4 deletions resources/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def generate(rm: ResourceManager):
block = rm.blockstate('%s_wheel' % cheese, variants=dict(
('age=%s,count=%s' % (a, c), {'model': 'firmalife:block/cheese/%s_%s_%s' % (cheese, a, c)})
for a in ('fresh', 'aged', 'vintage') for c in range(1, 5)
)).with_lang(lang('%s cheese wheel', cheese)).with_tag('cheese_wheels')
)).with_lang(lang('%s cheese wheel', cheese)).with_tag('cheese_wheels').with_item_tag('cheese_wheels')
block.with_block_loot([{
'name': 'firmalife:food/%s' % cheese,
'functions': [loot_tables.set_count(c)],
Expand Down Expand Up @@ -252,12 +252,12 @@ def generate(rm: ResourceManager):
flower_pot_cross(rm, herb, 'firmalife:plant/potted/%s' % herb, 'plant/flowerpot/%s' % herb, 'firmalife:block/plant/%s/1' % herb, 'firmalife:plant/%s' % herb)

for wood in TFC_WOODS.keys():
block = rm.blockstate('firmalife:wood/food_shelf/%s' % wood, variants=four_rotations('firmalife:block/wood/food_shelf/%s' % wood, (270, 180, None, 90)))
block = rm.blockstate('firmalife:wood/food_shelf/%s' % wood, variants=four_rotations('firmalife:block/wood/food_shelf/%s' % wood, (270, 180, None, 90))).with_tag('food_shelves').with_item_tag('food_shelves')
block.with_block_loot('firmalife:wood/food_shelf/%s' % wood).with_lang(lang('%s food shelf', wood)).with_tag('minecraft:mineable/axe')
rm.item_model('firmalife:wood/food_shelf/%s' % wood, parent='firmalife:block/wood/food_shelf/%s' % wood, no_textures=True)
rm.block_model('firmalife:wood/food_shelf/%s' % wood, parent='firmalife:block/food_shelf_base', textures={'wood': 'tfc:block/wood/planks/%s' % wood})

block = rm.blockstate('firmalife:wood/hanger/%s' % wood, model='firmalife:block/wood/hanger/%s' % wood)
block = rm.blockstate('firmalife:wood/hanger/%s' % wood, model='firmalife:block/wood/hanger/%s' % wood).with_tag('hangers').with_item_tag('hangers')
block.with_block_loot('firmalife:wood/hanger/%s' % wood).with_lang(lang('%s hanger' % wood)).with_tag('minecraft:mineable/axe')
rm.item_model('firmalife:wood/hanger/%s' % wood, parent='firmalife:block/wood/hanger/%s' % wood, no_textures=True)
rm.block_model('firmalife:wood/hanger/%s' % wood, parent='firmalife:block/hanger_base', textures={'wood': 'tfc:block/wood/planks/%s' % wood, 'string': 'minecraft:block/white_wool'})
Expand All @@ -266,7 +266,7 @@ def generate(rm: ResourceManager):
**four_rotations('firmalife:block/wood/jarbnet/%s' % wood, (90, None, 180, 270), suffix=',open=true'),
**four_rotations('firmalife:block/wood/jarbnet/%s_shut' % wood, (90, None, 180, 270), suffix=',open=false'),
})
block.with_block_loot('firmalife:wood/jarbnet/%s' % wood).with_lang(lang('%s jarbnet', wood)).with_tag('minecraft:mineable/axe')
block.with_block_loot('firmalife:wood/jarbnet/%s' % wood).with_lang(lang('%s jarbnet', wood)).with_tag('minecraft:mineable/axe').with_tag('jarbnets').with_item_tag('jarbnets')
rm.item_model('firmalife:wood/jarbnet/%s' % wood, parent='firmalife:block/wood/jarbnet/%s' % wood, no_textures=True)
textures = {'planks': 'tfc:block/wood/planks/%s' % wood, 'sheet': 'tfc:block/wood/sheet/%s' % wood, 'log': 'tfc:block/wood/log/%s' % wood}
rm.block_model('firmalife:wood/jarbnet/%s' % wood, parent='firmalife:block/jarbnet', textures=textures)
Expand Down
4 changes: 2 additions & 2 deletions resources/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Wood(NamedTuple):
'exposed_copper': 'copper',
'weathered_treated_wood': 'treated_wood'
}
PLANTERS = ('hanging', 'bonsai', 'quad', 'large', 'trellis')
PLANTERS = ('hanging', 'bonsai', 'quad', 'large', 'trellis', 'hydroponic')

CARVINGS = {
'none': ['XXXXX', 'XXXXX', 'XXXXX', 'X X', 'XXXXX'],
Expand Down Expand Up @@ -220,7 +220,7 @@ def preset_vein(ore: str, vein_type: str, rocks: List[str], spoiler_ore: Optiona
'firmalife.bee.parasitic_infection': 'Parasitic Infection: %s',
**{'firmalife.bee.disease%s' % i: d for i, d in enumerate(GENETIC_DISEASES)},
**{'firmalife.bee.infection%s' % i: d for i, d in enumerate(PARASITIC_INFECTIONS)},
'firmalife.beehive.honey': 'Honey: %s / 16',
'firmalife.beehive.honey': 'Honey: %s / 12',
'firmalife.beehive.bee': 'Frame %s: ',
'firmalife.beehive.bee_cold': 'Too cold! Minimum: %s C, Current: %s C',
'firmalife.beehive.has_queen': 'Has Queen. ',
Expand Down
10 changes: 5 additions & 5 deletions resources/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ def generate(rm: ResourceManager):
rm.block_tag('bee_restoration_plants', *['tfc:plant/%s' % p for p in TFC_FLOWERS])
rm.block_tag('bee_restoration_water_plants', *['tfc:plant/%s' % p for p in TFC_FLOATING_FLOWERS])
rm.block_tag('bee_plants', '#firmalife:bee_restoration_plants', '#firmalife:bee_restoration_water_plants', '#firmalife:planters')
rm.block_tag('all_iron_greenhouse', '#firmalife:iron_greenhouse', '#firmalife:rusted_iron_greenhouse')
rm.block_tag('all_copper_greenhouse', *['#firmalife:%s_greenhouse' % g for g in ('exposed_copper', 'weathered_copper', 'copper', 'oxidized_copper')])
rm.block_tag('all_treated_wood_greenhouse', '#firmalife:treated_wood_greenhouse', '#firmalife:weathered_treated_wood_greenhouse')
rm.block_tag('greenhouse', '#firmalife:all_iron_greenhouse', '#firmalife:all_copper_greenhouse', '#firmalife:all_treated_wood_greenhouse', '#firmalife:stainless_steel_greenhouse')
block_and_item_tag(rm, 'all_iron_greenhouse', '#firmalife:iron_greenhouse', '#firmalife:rusted_iron_greenhouse')
block_and_item_tag(rm, 'all_copper_greenhouse', *['#firmalife:%s_greenhouse' % g for g in ('exposed_copper', 'weathered_copper', 'copper', 'oxidized_copper')])
block_and_item_tag(rm, 'all_treated_wood_greenhouse', '#firmalife:treated_wood_greenhouse', '#firmalife:weathered_treated_wood_greenhouse')
block_and_item_tag(rm, 'greenhouse', '#firmalife:all_iron_greenhouse', '#firmalife:all_copper_greenhouse', '#firmalife:all_treated_wood_greenhouse', '#firmalife:stainless_steel_greenhouse')
block_and_item_tag(rm, 'cellar_insulation', 'firmalife:sealed_bricks', 'firmalife:sealed_door', 'firmalife:sealed_trapdoor', 'firmalife:sealed_wall')
rm.block_tag('drops_fruit_leaf', '#tfc:fruit_tree_leaves')
rm.block_tag('cellar_insulation', 'firmalife:sealed_bricks', 'firmalife:sealed_door', 'firmalife:sealed_trapdoor', 'firmalife:sealed_wall')
rm.block_tag('buzzing_leaves', 'firmalife:plant/fig_leaves')
rm.block_tag('pipe_replaceable', '#tfc:dirt', '#tfc:grass', '#minecraft:base_stone_overworld', '#forge:gravel', '#minecraft:sand', '#tfc:can_carve')
rm.block_tag('tfc:thorny_bushes', 'firmalife:plant/pineapple_bush')
Expand Down
2 changes: 2 additions & 0 deletions resources/generate_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import recipes
import data
import world_gen
import advancements


class ModificationLoggingResourceManager(ResourceManager):
Expand Down Expand Up @@ -52,6 +53,7 @@ def generate_all(rm: ResourceManager):
data.generate(rm)
metal_stuff.generate(rm)
world_gen.generate(rm)
advancements.generate(rm)

rm.flush()

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/eerussianguy/firmalife/FirmaLife.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.eerussianguy.firmalife;

import com.eerussianguy.firmalife.common.util.FLAdvancements;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.InterModComms;
Expand Down Expand Up @@ -84,6 +85,7 @@ public void setup(FMLCommonSetupEvent event)
FLInteractionManager.init();
FLFoodTraits.init();
FLBlocks.registerFlowerPotFlowers();
FLAdvancements.init();
TFCConfig.SERVER.enablePumpkinCarving.set(false);
});
FLItemStackModifiers.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
import java.util.Random;
import java.util.Set;

import com.eerussianguy.firmalife.common.FLHelpers;
import com.eerussianguy.firmalife.common.blocks.FLBlocks;
import com.eerussianguy.firmalife.common.util.FLAdvancements;
import com.eerussianguy.firmalife.common.util.GreenhouseType;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.LivingEntity;
Expand Down Expand Up @@ -100,9 +105,17 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player
else
{
either.ifLeft(info -> {
if (info.positions().size() > 200 && player instanceof ServerPlayer server && info.type().id.toString().contains("stainless_steel"))
{
FLAdvancements.BIG_STAINLESS_GREENHOUSE.trigger(server);
}
player.displayClientMessage(new TranslatableComponent(MOD_ID + ".greenhouse.found", info.positions().size()), true);
});
either.ifRight(positions -> {
if (positions.size() > 200 && player instanceof ServerPlayer server)
{
FLAdvancements.BIG_CELLAR.trigger(server);
}
player.displayClientMessage(new TranslatableComponent(MOD_ID + ".cellar.found", positions.size()), true);
});
return InteractionResult.sidedSuccess(level.isClientSide);
Expand All @@ -113,7 +126,7 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player
@SuppressWarnings("deprecation")
public void randomTick(BlockState state, ServerLevel level, BlockPos pos, Random random)
{
if (random.nextInt(5) == 0)
if (random.nextInt(4) == 0)
{
super.randomTick(state, level, pos, random); // causes a block tick
}
Expand Down
Loading

0 comments on commit 3e10a6c

Please sign in to comment.