Skip to content

Commit

Permalink
- theoretically fix issues with ovens not persisting recipes
Browse files Browse the repository at this point in the history
- allow heat recipes to happen in ovens
- fix issues with firmalife metals not being pileable and not going in molds
- fix jack o lanterns to match tfc
- update hangers/shelves to be better than vessels
- added better oven tooltip
  • Loading branch information
eerussianguy committed Nov 14, 2022
1 parent 8e95921 commit 8eba7c8
Show file tree
Hide file tree
Showing 29 changed files with 145 additions and 113 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ mixin_version=0.8.5
jei_version=9.7.1.232
patchouli_version=1.18.2-70
tfc_version=0.0.0-indev
tfc_identifier=4044049
tfc_identifier=4081689
jade_version=3970956
top_version=3965688
2 changes: 1 addition & 1 deletion resources/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def generate(rm: ResourceManager):
for variant, lang_part in (('lit_pumpkin', 'Jack o\'Lantern'), ('carved_pumpkin', 'Carved Pumpkin')):
name = '%s/%s' % (variant, carving)
rm.block_model(name, parent='minecraft:block/carved_pumpkin', textures={'front': 'firmalife:block/%s/%s' % (variant, carving)})
rm.blockstate(name, variants=four_rotations('firmalife:block/%s' % name, (90, 0, 180, 270))).with_tag('tfc:mineable_with_sharp_tool').with_block_loot('firmalife:%s' % name).with_lang(lang('%s %s', carving, lang_part))
rm.blockstate(name, variants=four_rotations('firmalife:block/%s' % name, (90, 0, 180, 270))).with_tag('tfc:mineable_with_sharp_tool').with_block_loot('firmalife:carved_pumpkin/%s' % carving).with_lang(lang('%s %s', carving, lang_part))
rm.item_model('firmalife:%s' % name, parent='firmalife:block/%s' % name, no_textures=True)

for variant in ('gold', 'red', 'purple'):
Expand Down
2 changes: 2 additions & 0 deletions resources/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def preset_vein(ore: str, vein_type: str, rocks: List[str], spoiler_ore: Optiona

DEFAULT_LANG = {
'effect.firmalife.swarm': 'Swarm',
'entity.firmalife.seed_ball': 'Seed Ball',
'firmalife.tooltip.food_trait.dried': 'Dried',
'firmalife.tooltip.food_trait.aged': 'Aged',
'firmalife.tooltip.food_trait.vintage': 'Vintage',
Expand Down Expand Up @@ -223,6 +224,7 @@ def preset_vein(ore: str, vein_type: str, rocks: List[str], spoiler_ore: Optiona
'firmalife.jade.slices': 'Slices: %s',
'firmalife.jade.cure_time_left': 'Curing Time Left: %s',
'firmalife.jade.cannot_cure': 'Not hot enough to cure!',
'firmalife.jade.cook_left': 'Cook Time: %s',

'death.attack.firmalife.oven': '%1$s died by sticking their hand in a hot oven.',
'death.attack.firmalife.oven.player': '%1$s climbed into an oven to escape %2$s.',
Expand Down
4 changes: 4 additions & 0 deletions resources/metal_stuff.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def item(_variant: str) -> str:
rm.blockstate(('fluid', 'metal', metal)).with_block_model({'particle': 'block/lava_still'}, parent=None).with_lang(lang('Molten %s', metal))
rm.lang('fluid.firmalife.metal.%s' % metal, lang('Molten %s', metal))
rm.fluid_tag(metal, 'firmalife:metal/%s' % metal, 'firmalife:metal/flowing_%s' % metal)
rm.fluid_tag('tfc:molten_metals', *['firmalife:metal/%s' % metal])

item = rm.custom_item_model(('bucket', 'metal', metal), 'forge:bucket', {
'parent': 'forge:item/bucket',
Expand All @@ -87,6 +88,9 @@ def item(_variant: str) -> str:
item.with_lang(lang('molten %s bucket', metal))
rm.lang('metal.firmalife.%s' % metal, lang(metal))

rm.item_tag('tfc:pileable_ingots', '#forge:ingots/%s' % metal)
rm.item_tag('tfc:pileable_sheets', '#forge:sheets/%s' % metal)

def chromium_ore_heats(rm: ResourceManager):
ore = 'chromite'
metal_data = FL_METALS['chromium']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.eerussianguy.firmalife.common.blocks.ICure;
import com.eerussianguy.firmalife.common.blocks.OvenBottomBlock;
import com.eerussianguy.firmalife.common.items.FLFoodTraits;
import com.eerussianguy.firmalife.common.recipes.OvenRecipe;
import com.eerussianguy.firmalife.common.recipes.WrappedHeatingRecipe;
import net.dries007.tfc.common.blockentities.InventoryBlockEntity;
import net.dries007.tfc.common.blockentities.TickableInventoryBlockEntity;
import net.dries007.tfc.common.capabilities.DelegateItemHandler;
Expand Down Expand Up @@ -63,14 +63,13 @@ public static void cure(Level level, BlockState oldState, BlockState newState, B

public static void serverTick(Level level, BlockPos pos, BlockState state, OvenTopBlockEntity oven)
{
oven.checkForLastTickSync();
oven.checkForCalendarUpdate();

if (oven.needsRecipeUpdate)
{
oven.needsRecipeUpdate = false;
oven.updateCaches();
}
oven.checkForLastTickSync();
oven.checkForCalendarUpdate();

if (oven.temperature != oven.targetTemperature)
{
Expand Down Expand Up @@ -109,17 +108,16 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, OvenT
if (!inputStack.isEmpty())
{
inputStack.getCapability(HeatCapability.CAPABILITY).ifPresent(cap -> {

// Always heat up the item regardless if it is melting or not
if (cap.getTemperature() < oven.temperature)
{
HeatCapability.addTemp(cap, oven.temperature, 2 + oven.temperature * 0.0025f); // Breaks even at 400 C
}

final OvenRecipe recipe = oven.cachedRecipes[slot];
final WrappedHeatingRecipe recipe = oven.cachedRecipes[slot];
if (recipe != null && recipe.isValidTemperature(cap.getTemperature()))
{
if (oven.cookTicks[slot]++ > recipe.getDuration())
if (oven.cookTicks[slot]++ > recipe.duration())
{
// Convert input
final ItemStackInventory inventory = new ItemStackInventory(inputStack);
Expand Down Expand Up @@ -153,7 +151,7 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, OvenT
private int targetTemperatureStabilityTicks;
private long lastUpdateTick;
private boolean needsRecipeUpdate;
private final OvenRecipe[] cachedRecipes;
private final WrappedHeatingRecipe[] cachedRecipes;
private int[] cookTicks;
private int cureTicks;

Expand All @@ -162,7 +160,7 @@ public OvenTopBlockEntity(BlockPos pos, BlockState state)
super(FLBlockEntities.OVEN_TOP.get(), pos, state, OvenInventory::new, FLHelpers.blockEntityName("oven_top"));
temperature = targetTemperature = targetTemperatureStabilityTicks = cureTicks = 0;
lastUpdateTick = Calendars.SERVER.getTicks();
cachedRecipes = new OvenRecipe[4];
cachedRecipes = new WrappedHeatingRecipe[4];
cookTicks = new int[] {0, 0, 0, 0};

sidedHeat = new SidedHandler.Noop<>(inventory);
Expand Down Expand Up @@ -245,7 +243,7 @@ public void setLastUpdateTick(long ticks)
public void setAndUpdateSlots(int slot)
{
super.setAndUpdateSlots(slot);
singleRecipeUpdate(slot);
singleRecipeUpdate(slot, true);
}

@Override
Expand All @@ -264,15 +262,15 @@ private void updateCaches()
{
for (int slot = SLOT_INPUT_START; slot <= SLOT_INPUT_END; slot++)
{
singleRecipeUpdate(slot);
singleRecipeUpdate(slot, false);
}
}

private void singleRecipeUpdate(int slot)
private void singleRecipeUpdate(int slot, boolean wipe)
{
OvenRecipe previous = cachedRecipes[slot];
cachedRecipes[slot] = OvenRecipe.getRecipe(inventory.getStackInSlot(slot));
if (previous != cachedRecipes[slot] || cachedRecipes[slot] == null)
final WrappedHeatingRecipe previous = cachedRecipes[slot];
cachedRecipes[slot] = WrappedHeatingRecipe.getRecipe(inventory.getStackInSlot(slot));
if (wipe && previous != cachedRecipes[slot] || cachedRecipes[slot] == null)
{
cookTicks[slot] = 0;
}
Expand All @@ -290,6 +288,27 @@ public void extinguish()
targetTemperatureStabilityTicks = 0;
}

public int getTicksLeft(int slot)
{
assert level != null;
if (cookTicks[slot] == 0)
{
return -1;
}
if (cachedRecipes[slot] == null)
{
if (level.isClientSide)
{
singleRecipeUpdate(slot, true);
}
}
if (cachedRecipes[slot] != null)
{
return cachedRecipes[slot].duration() - cookTicks[slot];
}
return -1;
}

static class OvenInventory implements DelegateItemHandler, IHeatBlock, INBTSerializable<CompoundTag>
{
private final OvenTopBlockEntity oven;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import net.dries007.tfc.common.blockentities.TFCBlockEntities;
import net.dries007.tfc.common.blocks.ExtendedProperties;
import net.dries007.tfc.common.blocks.TFCBlockStateProperties;
import net.dries007.tfc.common.blocks.devices.BottomSupportedDeviceBlock;
import net.dries007.tfc.common.capabilities.food.FoodCapability;
import net.dries007.tfc.util.Helpers;
import net.dries007.tfc.util.calendar.ICalendar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.eerussianguy.firmalife.common.FLHelpers;
import com.eerussianguy.firmalife.common.blockentities.SimpleItemRecipeBlockEntity;
import net.dries007.tfc.common.blocks.ExtendedProperties;
import net.dries007.tfc.common.blocks.devices.BottomSupportedDeviceBlock;
import net.dries007.tfc.common.capabilities.Capabilities;

public class DryingMatBlock extends BottomSupportedDeviceBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import net.dries007.tfc.common.blocks.ExtendedProperties;
import net.dries007.tfc.common.blocks.GroundcoverBlock;
import net.dries007.tfc.common.blocks.TFCMaterials;
import net.dries007.tfc.common.blocks.devices.JackOLanternBlock;
import net.dries007.tfc.common.blocks.plant.PlantBlock;
import net.dries007.tfc.common.blocks.rock.Ore;
import net.dries007.tfc.common.blocks.rock.Rock;
Expand Down Expand Up @@ -115,7 +116,7 @@ public class FLBlocks
);

public static final Map<Carving, RegistryObject<Block>> JACK_O_LANTERNS = Helpers.mapOfKeys(Carving.class, carve ->
register("lit_pumpkin/" + carve.getSerializedName(), () -> new FLJackOLanternBlock(ExtendedProperties.of(Properties.of(Material.VEGETABLE, MaterialColor.COLOR_ORANGE).strength(1.0F).sound(SoundType.WOOD).randomTicks().isValidSpawn(FLBlocks::always).lightLevel(alwaysLit())).blockEntity(FLBlockEntities.TICK_COUNTER), CARVED_PUMPKINS.get(carve)), DECORATIONS)
register("lit_pumpkin/" + carve.getSerializedName(), () -> new JackOLanternBlock(ExtendedProperties.of(Properties.of(Material.VEGETABLE, MaterialColor.COLOR_ORANGE).strength(1.0F).sound(SoundType.WOOD).randomTicks().isValidSpawn(FLBlocks::always).lightLevel(alwaysLit())).blockEntity(FLBlockEntities.TICK_COUNTER), CARVED_PUMPKINS.get(carve)), DECORATIONS)
);

public static final RegistryObject<Block> SMALL_CHROMITE = register("ore/small_chromite", () -> GroundcoverBlock.looseOre(Properties.of(Material.GRASS).strength(0.05F, 0.0F).sound(SoundType.NETHER_ORE).noCollission()), ORES);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import net.dries007.tfc.common.blocks.ExtendedProperties;
import net.dries007.tfc.common.blocks.TFCBlockStateProperties;
import net.dries007.tfc.common.blocks.devices.BottomSupportedDeviceBlock;
import net.dries007.tfc.common.blocks.devices.DeviceBlock;
import net.dries007.tfc.util.Helpers;
import org.jetbrains.annotations.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.eerussianguy.firmalife.common.blockentities.MixingBowlBlockEntity;
import com.eerussianguy.firmalife.common.items.FLItems;
import net.dries007.tfc.common.blocks.ExtendedProperties;
import net.dries007.tfc.common.blocks.devices.BottomSupportedDeviceBlock;
import net.dries007.tfc.common.fluids.FluidHelpers;
import net.dries007.tfc.util.Helpers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.world.phys.shapes.VoxelShape;

import net.dries007.tfc.common.blocks.ExtendedProperties;
import net.dries007.tfc.common.blocks.devices.BottomSupportedDeviceBlock;

public class SolarDrierBlock extends BottomSupportedDeviceBlock
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import com.eerussianguy.firmalife.common.FLHelpers;
import com.eerussianguy.firmalife.common.blockentities.FLBlockEntities;
import com.eerussianguy.firmalife.common.blockentities.SquirtingMoistureTransducerBlockEntity;
import com.eerussianguy.firmalife.common.blocks.BottomSupportedDeviceBlock;
import com.eerussianguy.firmalife.common.blocks.FLBlocks;
import com.eerussianguy.firmalife.common.blocks.FLStateProperties;
import net.dries007.tfc.common.blocks.ExtendedProperties;
import net.dries007.tfc.common.blocks.devices.BottomSupportedDeviceBlock;
import net.dries007.tfc.common.blocks.soil.HoeOverlayBlock;
import net.dries007.tfc.util.Helpers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public static void init() { }
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.7f);
public static final FoodTrait HUNG = register("hung", 0.6f);
public static final FoodTrait SHELVED = register("shelved", 0.4f);
public static final FoodTrait HUNG = register("hung", 0.35f);

private static FoodTrait register(String name, float mod)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.eerussianguy.firmalife.common.recipes;

import java.util.function.Function;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;

import net.dries007.tfc.common.recipes.HeatingRecipe;
import net.dries007.tfc.common.recipes.inventory.ItemStackInventory;
import org.jetbrains.annotations.Nullable;

public record WrappedHeatingRecipe(ResourceLocation id, Function<ItemStackInventory, ItemStack> output, float temperature, int duration, boolean oven)
{
@Nullable
public static WrappedHeatingRecipe getRecipe(ItemStack stack)
{
OvenRecipe recipe = OvenRecipe.getRecipe(stack);
if (recipe != null)
{
return of(recipe);
}
HeatingRecipe heatRecipe = HeatingRecipe.getRecipe(stack);
return heatRecipe == null ? null : of(heatRecipe);
}

public static WrappedHeatingRecipe of(HeatingRecipe recipe)
{
return new WrappedHeatingRecipe(recipe.getId(), recipe::assemble, recipe.getTemperature(), 120, false);
}

public static WrappedHeatingRecipe of(OvenRecipe recipe)
{
return new WrappedHeatingRecipe(recipe.getId(), recipe::assemble, recipe.getTemperature(), recipe.getDuration(), true);
}

public boolean isValidTemperature(float temperature)
{
return temperature >= this.temperature;
}

public ItemStack assemble(ItemStackInventory inventory)
{
return output.apply(inventory);
}
}
Loading

0 comments on commit 8eba7c8

Please sign in to comment.