Skip to content

Commit

Permalink
Some changes:
Browse files Browse the repository at this point in the history
- Make food stack more often when removed from firmalife devices
- Added new textures for some prepared foods
- Fix plates not giving effects / not returning the bowl / not acting as expected
- Make food traits configurable
- Allow composting nightshade
  • Loading branch information
eerussianguy committed May 28, 2023
1 parent 06ed163 commit f5e9469
Show file tree
Hide file tree
Showing 30 changed files with 178 additions and 31 deletions.
2 changes: 1 addition & 1 deletion resources/advancements.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def generate(rm: ResourceManager):
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', 'rajya_metok', 'shosha')]), requirements=[[c] for c in ('gouda', 'chevre', 'cheddar', 'feta', 'rayja_metok', 'shosha')], frame='challenge')
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', 'rajya_metok', 'shosha')]), requirements=[[c] for c in ('gouda', 'chevre', 'cheddar', 'feta', 'rajya_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')
Expand Down
1 change: 1 addition & 0 deletions resources/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def generate(rm: ResourceManager):
rm.item_tag('contains_pie_pan', 'firmalife:food/cooked_pumpkin_pie')
rm.item_tag('can_be_hung', '#tfc:foods/meats', 'tfc:food/garlic')
rm.item_tag('tfc:compost_greens_low', 'firmalife:fruit_leaf')
rm.item_tag('tfc:compost_greens', 'firmalife:food/nightshade_berry')
rm.item_tag('foods/cooked_meats_and_substitutes', '#tfc:foods/cooked_meats', 'firmalife:food/tofu')
rm.item_tag('forge:leather', 'firmalife:pineapple_leather')
rm.item_tag('usable_in_stovetop_soup', '#tfc:foods/usable_in_soup')
Expand Down
2 changes: 1 addition & 1 deletion resources/recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def craft_decorations(recipe_name: str, base_block: str):
#rm.crafting_shaped('crafting/squirting_moisture_transducer', ['XYX', 'XZX', 'XYX'], {'X': '#forge:sheets/stainless_steel', 'Y': 'tfc:brass_mechanisms', 'Z': '#forge:rods/nickel'}, 'firmalife:squirting_moisture_transducer').with_advancement('#forge:rods/stainless_steel')
#rm.crafting_shaped('crafting/embedded_pipe', ['XY', 'XY', 'ZZ'], {'X': '#forge:rods/stainless_steel', 'Y': '#forge:rods/copper', 'Z': 'firmalife:beeswax'}, '6 firmalife:embedded_pipe').with_advancement('#forge:rods/stainless_steel')
rm.crafting_shaped('crafting/treated_wood', ['XX', 'XX'], {'X': 'firmalife:treated_lumber'}, 'firmalife:treated_wood').with_advancement('firmalife:treated_lumber')
damage_shapeless(rm, 'crafting/pumpkin_chunks_bulk', ('#tfc:hammers', *('tfc:pumpkin' for _ in range(0, 8))), '8 firmalife:food/pumpkin_chunks').with_advancement('tfc:pumpkin')
damage_shapeless(rm, 'crafting/pumpkin_chunks_bulk', ('#tfc:hammers', *(not_rotten('tfc:pumpkin') for _ in range(0, 8))), '8 firmalife:food/pumpkin_chunks').with_advancement('tfc:pumpkin')
rm.crafting_shapeless('crafting/garlic_bread', ('firmalife:food/toast', 'firmalife:food/butter', 'tfc:food/garlic'), 'firmalife:food/garlic_bread').with_advancement('tfc:food/garlic')
damage_shapeless(rm, 'crafting/salsa', ('tfc:food/tomato', 'tfc:powder/salt', 'firmalife:plant/cilantro', '#tfc:knives'), '5 firmalife:food/salsa').with_advancement('tfc:food/tomato')
rm.domain = 'tfc'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.mojang.serialization.JsonOps;
import net.dries007.tfc.common.blockentities.TickCounterBlockEntity;
import net.dries007.tfc.common.capabilities.Capabilities;
import net.dries007.tfc.common.capabilities.food.FoodCapability;
import net.dries007.tfc.util.Helpers;
import net.dries007.tfc.util.JsonHelpers;

Expand Down Expand Up @@ -195,6 +196,11 @@ public static String getEnumTranslationKey(Enum<?> anEnum, String enumName)
return String.join(".", MOD_ID, "enum", enumName, anEnum.name()).toLowerCase(Locale.ROOT);
}

public static void roundCreationDate(ItemStack stack)
{
stack.getCapability(FoodCapability.CAPABILITY).ifPresent(cap -> cap.setCreationDate(FoodCapability.getRoundedCreationDate(cap.getCreationDate())));
}

public static ResourceLocation[] arrayOfResourceLocationsFromJson(JsonObject json, String field)
{
final JsonArray array = JsonHelpers.getAsJsonArray(json, field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ else if (held.isEmpty())
ItemStack stack = inventory.extractItem(0, player.isShiftKeyDown() ? Integer.MAX_VALUE : 1, false);
if (stack.isEmpty()) return InteractionResult.PASS;
FoodCapability.removeTrait(stack, getFoodTrait());
FLHelpers.roundCreationDate(stack);
ItemHandlerHelper.giveItemToPlayer(player, stack);
res = InteractionResult.sidedSuccess(level.isClientSide);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.items.ItemHandlerHelper;

import net.dries007.tfc.common.blocks.ExtendedProperties;
import net.dries007.tfc.common.blocks.devices.BottomSupportedDeviceBlock;
Expand Down Expand Up @@ -46,8 +47,9 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player
final IFood cap = Helpers.getCapability(stack, FoodCapability.CAPABILITY);
if (!stack.isEmpty() && cap != null && player.isShiftKeyDown() && player.getFoodData() instanceof TFCFoodData data && data.needsFood())
{
data.eat(cap);
final ItemStack newItem = stack.getItem().finishUsingItem(stack, level, player);
stack.shrink(1);
ItemHandlerHelper.giveItemToPlayer(player, newItem);
Helpers.playSound(level, pos, SoundEvents.GENERIC_EAT);
return InteractionResult.sidedSuccess(level.isClientSide);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static InteractionResult use(Level level, BlockPos pos, Player player, In
else if (!inv.getStackInSlot(0).isEmpty() && held.isEmpty() && player.isShiftKeyDown())
{
mat.markForSync();
FLHelpers.roundCreationDate(inv.getStackInSlot(0));
return FLHelpers.takeOne(level, 0, inv, player);
}
return InteractionResult.PASS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,12 @@ public InteractionResult takeSlot(Level level, LargePlanterBlockEntity planter,
if (!seed.isEmpty())
{
seed.setCount(seedAmount);
FLHelpers.roundCreationDate(seed);
ItemHandlerHelper.giveItemToPlayer(player, seed);
}
ItemHandlerHelper.giveItemToPlayer(player, plant.getCrop());
ItemStack crop = plant.getCrop();
FLHelpers.roundCreationDate(crop);
ItemHandlerHelper.giveItemToPlayer(player, crop);
planter.setGrowth(slot, resetGrowthTo());
return InteractionResult.sidedSuccess(level.isClientSide);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
public class FLPlayerDataCapability
{
public static final Capability<FLPlayerData> CAPABILITY = CapabilityManager.get(new CapabilityToken<>() {});
public static final ResourceLocation KEY = FLHelpers.identifier("player_glow");
public static final ResourceLocation KEY = FLHelpers.identifier("player_data");
}
123 changes: 106 additions & 17 deletions src/main/java/com/eerussianguy/firmalife/common/items/FLFoodTraits.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,118 @@
package com.eerussianguy.firmalife.common.items;

import java.util.List;
import java.util.Locale;
import java.util.function.Supplier;
import com.eerussianguy.firmalife.common.FLHelpers;
import com.eerussianguy.firmalife.config.FLConfig;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;

import net.dries007.tfc.common.capabilities.food.FoodTrait;
import net.dries007.tfc.util.Helpers;

public class FLFoodTraits
{
public enum Default
{
DRIED(0.5f),
FRESH(1.1f),
AGED(0.9f),
VINTAGE(0.6f),
OVEN_BAKED(0.9f),
SMOKED(0.7f),
RANCID_SMOKED(2.0f),
RAW(1f),
SHELVED(0.4f),
SHELVED_2(0.35f),
SHELVED_3(0.25f),
HUNG(0.35f),
HUNG_2(0.3f),
HUNG_3(0.25f)
;

private final float mod;
private final String name;

Default(float mod)
{
this.mod = mod;
this.name = name().toLowerCase(Locale.ROOT);
}

public String getName()
{
return name;
}

public String getCapitalizedName()
{
return name.substring(0, 1).toUpperCase(Locale.ROOT) + name.substring(1);
}

public float getMod()
{
return mod;
}
}

public static void init() { }

public static final FoodTrait DRIED = register("dried", 0.5f);
public static final FoodTrait FRESH = register("fresh", 1.1f);
public static final FoodTrait AGED = register("aged", 0.9f);
public static final FoodTrait VINTAGE = register("vintage", 0.6f);
public static final FoodTrait OVEN_BAKED = register("oven_baked", 0.9f);
public static final FoodTrait SMOKED = register("smoked", 0.7f);
public static final FoodTrait RANCID_SMOKED = register("rancid_smoked", 2.0f);
public static final FoodTrait RAW = register("raw", 1f);
public static final FoodTrait SHELVED = register("shelved", 0.4f);
public static final FoodTrait SHELVED_2 = register("shelved_2", 0.35f);
public static final FoodTrait SHELVED_3 = register("shelved_3", 0.25f);
public static final FoodTrait HUNG = register("hung", 0.35f);
public static final FoodTrait HUNG_2 = register("hung_2", 0.3f);
public static final FoodTrait HUNG_3 = register("hung_3", 0.25f);

private static FoodTrait register(String name, float mod)
public static final FoodTrait DRIED = register(Default.DRIED);
public static final FoodTrait FRESH = register(Default.FRESH);
public static final FoodTrait AGED = register(Default.AGED);
public static final FoodTrait VINTAGE = register(Default.VINTAGE);
public static final FoodTrait OVEN_BAKED = register(Default.OVEN_BAKED);
public static final FoodTrait SMOKED = register(Default.SMOKED);
public static final FoodTrait RANCID_SMOKED = register(Default.RANCID_SMOKED);
public static final FoodTrait RAW = register(Default.RAW);
public static final FoodTrait SHELVED = register(Default.SHELVED);
public static final FoodTrait SHELVED_2 = register(Default.SHELVED_2);
public static final FoodTrait SHELVED_3 = register(Default.SHELVED_3);
public static final FoodTrait HUNG = register(Default.HUNG);
public static final FoodTrait HUNG_2 = register(Default.HUNG_2);
public static final FoodTrait HUNG_3 = register(Default.HUNG_3);

private static FoodTrait register(FLFoodTraits.Default trait)
{
return FoodTrait.register(FLHelpers.identifier(name), new FoodTrait(mod, "firmalife.tooltip.food_trait." + name));
return FoodTrait.register(FLHelpers.identifier(trait.name), new WrappedFT(() -> FLConfig.SERVER.foodTraits.get(trait).get().floatValue(), "firmalife.tooltip.food_trait." + trait.name));
}

private static class WrappedFT extends FoodTrait
{
private final Supplier<Float> decayModifier;
@Nullable private final String translationKey;

public WrappedFT(Supplier<Float> decayModifier, @Nullable String translationKey)
{
super(1f, translationKey);
this.decayModifier = decayModifier;
this.translationKey = translationKey;
}

@Override
public float getDecayModifier()
{
return decayModifier.get();
}

@Override
public void addTooltipInfo(ItemStack stack, List<Component> text)
{
if (this.translationKey != null)
{
MutableComponent component = Helpers.translatable(this.translationKey);
if (this.decayModifier.get() > 1.0F)
{
component.withStyle(ChatFormatting.RED);
}

text.add(component);
}
}

}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.eerussianguy.firmalife.config;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;

import com.eerussianguy.firmalife.common.items.FLFoodTraits;
import net.minecraftforge.common.ForgeConfigSpec.*;

import static com.eerussianguy.firmalife.FirmaLife.MOD_ID;
Expand All @@ -26,6 +30,7 @@ public class FLServerConfig
public final DoubleValue greenhouseGrowthDays;
public final DoubleValue greenhouseWaterDays;
public final DoubleValue greenhouseNutrientDays;
public final Map<FLFoodTraits.Default, DoubleValue> foodTraits;


FLServerConfig(Builder innerBuilder)
Expand Down Expand Up @@ -53,6 +58,14 @@ public class FLServerConfig
greenhouseWaterDays = builder.apply("greenhouseWaterDays").comment("The average amount of days for a crop in a greenhouse to consume all its water.").defineInRange("greenhouseWaterDays", 12d, 0, Double.MAX_VALUE);
greenhouseNutrientDays = builder.apply("greenhouseNutrientDays").comment("The average amount of days for a crop to consume all of a nutrient. You should probably not configure this value unless you know what it does in the code. For regular crops this value is 12.").defineInRange("greenhouseNutrientDays", 8d, 0, Double.MAX_VALUE);

innerBuilder.pop().push("foodTraits");

foodTraits = new HashMap<>();
Arrays.stream(FLFoodTraits.Default.values()).forEach(trait ->
foodTraits.put(trait, builder.apply("trait" + trait.getCapitalizedName() + "Modifier").comment("The modifier for the '" + trait.getCapitalizedName() + "' food trait. Values less than 1 extend food lifetime, values greater than one decrease it. A value of zero stops decay.")
.defineInRange("trait" + trait.getCapitalizedName() + "Modifier", trait.getMod(), 0, Double.MAX_VALUE))
);

innerBuilder.pop();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/firmalife/textures/item/pie_pan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"feta"
],
[
"rayja_metok"
"rajya_metok"
],
[
"shosha"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,52 @@
"tag": "tfc:hammers"
},
{
"item": "tfc:pumpkin"
"type": "tfc:not_rotten",
"ingredient": {
"item": "tfc:pumpkin"
}
},
{
"item": "tfc:pumpkin"
"type": "tfc:not_rotten",
"ingredient": {
"item": "tfc:pumpkin"
}
},
{
"item": "tfc:pumpkin"
"type": "tfc:not_rotten",
"ingredient": {
"item": "tfc:pumpkin"
}
},
{
"item": "tfc:pumpkin"
"type": "tfc:not_rotten",
"ingredient": {
"item": "tfc:pumpkin"
}
},
{
"item": "tfc:pumpkin"
"type": "tfc:not_rotten",
"ingredient": {
"item": "tfc:pumpkin"
}
},
{
"item": "tfc:pumpkin"
"type": "tfc:not_rotten",
"ingredient": {
"item": "tfc:pumpkin"
}
},
{
"item": "tfc:pumpkin"
"type": "tfc:not_rotten",
"ingredient": {
"item": "tfc:pumpkin"
}
},
{
"item": "tfc:pumpkin"
"type": "tfc:not_rotten",
"ingredient": {
"item": "tfc:pumpkin"
}
}
],
"result": {
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/data/tfc/tags/items/compost_greens.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"__comment__": "This file was automatically created by mcresources",
"replace": false,
"values": [
"firmalife:food/nightshade_berry"
]
}

0 comments on commit f5e9469

Please sign in to comment.