Skip to content

Commit

Permalink
fix jei issues (Closes #80), fix jade up, oven config options,
Browse files Browse the repository at this point in the history
  • Loading branch information
eerussianguy committed Sep 13, 2022
1 parent e26a84d commit 579d856
Show file tree
Hide file tree
Showing 16 changed files with 135 additions and 23 deletions.
1 change: 1 addition & 0 deletions resources/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def preset_vein(ore: str, vein_type: str, rocks: List[str], spoiler_ore: Optiona
'firmalife.jade.not_aging': 'Not Aging',
'firmalife.jade.slices': 'Slices: %s',
'firmalife.jade.cure_time_left': 'Curing Time Left: %s',
'firmalife.jade.cannot_cure': 'Not hot enough to cure!',

'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
1 change: 1 addition & 0 deletions resources/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def generate(rm: ResourceManager):
decayable(rm, 'chocolate_blends', '#firmalife:chocolate_blends', Category.dairy)
decayable(rm, 'butter', 'firmalife:food/butter', Category.dairy)
decayable(rm, 'pie_dough', 'firmalife:food/pie_dough', Category.other)
decayable(rm, 'pizza_dough', 'firmalife:food/pizza_dough', Category.other)
food_item(rm, 'pumpkin_chunks', 'firmalife:food/pumpkin_chunks', Category.fruit, 4, 1, 5, 1.5, fruit=1)
decayable(rm, 'pumpkin_pie_dough', 'firmalife:food/pumpkin_pie_dough', Category.other)
decayable(rm, 'raw_pumpkin_pie', 'firmalife:food/raw_pumpkin_pie', Category.other)
Expand Down
2 changes: 1 addition & 1 deletion resources/recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def disable_recipe(rm: ResourceManager, name_parts: ResourceIdentifier):
rm.recipe(name_parts, None, {}, conditions='forge:false')

def meal_shapeless(rm: ResourceManager, name_parts: utils.ResourceIdentifier, ingredients: Json, result: str, mod: str) -> RecipeContext:
return advanced_shapeless(rm, name_parts, ingredients, item_stack_provider(result, other_modifier=mod), primary_ingredient=utils.ingredient('#tfc:foods'))
return advanced_shapeless(rm, name_parts, ingredients, item_stack_provider(result, other_modifier=mod), primary_ingredient=utils.ingredient(ingredients[0]))

def advanced_shapeless(rm: ResourceManager, name_parts: ResourceIdentifier, ingredients: Json, result: Json, primary_ingredient: Json, group: str = None, conditions: Optional[Json] = None) -> RecipeContext:
res = utils.resource_location(rm.domain, name_parts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void render(StringBlockEntity string, float partialTicks, PoseStack poseS
{
poseStack.mulPose(Vector3f.YP.rotationDegrees(90f));
}
ItemStack item = string.readStack();
ItemStack item = string.viewStack();
if (!item.isEmpty())
{
Minecraft.getInstance().getItemRenderer().renderStatic(item, ItemTransforms.TransformType.FIXED, combinedLight, combinedOverlay, poseStack, buffers, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public boolean isClimateValid()
public Component getInvalidReason()
{
assert level != null;
final Direction airFind = airFindOffset();
String complaint = "error_unknown";
if (!climateValid)
{
Expand All @@ -217,7 +218,7 @@ else if (level.getBrightness(LightLayer.SKY, worldPosition.relative(Direction.UP
{
complaint = "no_sky";
}
else if (airFindOffset() != null && !level.getBlockState(worldPosition.relative(airFindOffset())).isAir())
else if (airFind != null && !level.getBlockState(worldPosition.relative(airFind)).isAir())
{
complaint = "air_needed";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.eerussianguy.firmalife.common.blocks.AbstractOvenBlock;
import com.eerussianguy.firmalife.common.blocks.ICure;
import com.eerussianguy.firmalife.common.blocks.OvenBottomBlock;
import net.dries007.tfc.common.TFCTags;
import com.eerussianguy.firmalife.config.FLConfig;
import net.dries007.tfc.common.blockentities.TickableInventoryBlockEntity;
import net.dries007.tfc.common.capabilities.heat.HeatCapability;
import net.dries007.tfc.util.Fuel;
Expand Down Expand Up @@ -66,11 +66,12 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, OvenB
oven.checkForLastTickSync();
oven.checkForCalendarUpdate();

if (level.getGameTime() % 40 == 0)
final int updateInterval = 40;
if (level.getGameTime() % updateInterval == 0)
{
final boolean cured = state.getBlock() instanceof ICure cure && cure.isCured();
if (oven.cureTicks <= CURE_TICKS) oven.cureTicks++;
if (oven.temperature > OvenTopBlockEntity.CURE_TEMP && oven.cureTicks > CURE_TICKS)
if (oven.cureTicks <= FLConfig.SERVER.ovenCureTicks.get()) oven.cureTicks += updateInterval;
if (oven.temperature > (float) FLConfig.SERVER.ovenCureTemperature.get() && oven.cureTicks > FLConfig.SERVER.ovenCureTicks.get())
{
AbstractOvenBlock.cureAllAround(level, pos, !cured);
}
Expand Down Expand Up @@ -121,7 +122,6 @@ else if (oven.burnTemperature > 0)

public static final int SLOT_FUEL_MIN = 0;
public static final int SLOT_FUEL_MAX = 3;
public static final int CURE_TICKS = 40;
private static final int MAX_AIR_TICKS = 600;

private int burnTicks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.INBTSerializable;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;

import com.eerussianguy.firmalife.common.FLHelpers;
import com.eerussianguy.firmalife.common.blocks.AbstractOvenBlock;
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.config.FLConfig;
import net.dries007.tfc.common.blockentities.InventoryBlockEntity;
import net.dries007.tfc.common.blockentities.TickableInventoryBlockEntity;
import net.dries007.tfc.common.capabilities.DelegateItemHandler;
Expand All @@ -30,7 +30,6 @@
import net.dries007.tfc.common.recipes.inventory.ItemStackInventory;
import net.dries007.tfc.util.Helpers;
import net.dries007.tfc.util.calendar.Calendars;
import net.dries007.tfc.util.calendar.ICalendar;
import net.dries007.tfc.util.calendar.ICalendarTickable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -80,10 +79,11 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, OvenT
oven.temperature = HeatCapability.adjustTempTowards(oven.temperature, oven.targetTemperature);
}
final boolean cured = state.getBlock() instanceof ICure cure && cure.isCured();
if (level.getGameTime() % 40 == 0)
final int updateInterval = 40;
if (level.getGameTime() % updateInterval == 0)
{
if (oven.cureTicks < OvenBottomBlockEntity.CURE_TICKS) oven.cureTicks++;
if (oven.temperature > OvenTopBlockEntity.CURE_TEMP && oven.cureTicks > OvenBottomBlockEntity.CURE_TICKS)
if (oven.cureTicks <= FLConfig.SERVER.ovenCureTicks.get()) oven.cureTicks += updateInterval;
if (oven.temperature > (float) FLConfig.SERVER.ovenCureTemperature.get() && oven.cureTicks > FLConfig.SERVER.ovenCureTicks.get())
{
AbstractOvenBlock.cureAllAround(level, pos, !cured);
}
Expand Down Expand Up @@ -117,7 +117,7 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, OvenT
final HeatingRecipe recipe = oven.cachedRecipes[slot];
if (recipe != null && recipe.isValidTemperature(cap.getTemperature()))
{
if (oven.cookTicks[slot]++ > COOK_TIME)
if (oven.cookTicks[slot]++ > FLConfig.SERVER.ovenCookTicks.get())
{
// Convert input
final ItemStackInventory inventory = new ItemStackInventory(inputStack);
Expand All @@ -141,8 +141,6 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, OvenT
public static final int SLOT_INPUT_END = 3;
public static final int SLOT_INPUT_START = 0;
public static final int TARGET_TEMPERATURE_STABILITY_TICKS = 400;
public static final float CURE_TEMP = 600f;
public static final int COOK_TIME = ICalendar.TICKS_IN_HOUR * 2;

private final SidedHandler.Noop<IHeatBlock> sidedHeat;

Expand All @@ -167,6 +165,11 @@ public OvenTopBlockEntity(BlockPos pos, BlockState state)
sidedHeat = new SidedHandler.Noop<>(inventory);
}

public int getCureTicks()
{
return cureTicks;
}

@Override
public void loadAdditional(CompoundTag nbt)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ public int getSlotStackLimit(int slot)

abstract void updateCache();

@Nullable
public T getCachedRecipe()
{
if (cachedRecipe == null && level != null && level.isClientSide)
{
updateCache();
}
return cachedRecipe;
}

public long getTicksLeft()
{
assert level != null;
Expand All @@ -63,7 +73,7 @@ public void start()
updateCache();
if (cachedRecipe != null)
{
startTick = Calendars.SERVER.getTicks();
startTick = Calendars.get(level).getTicks();
if (!level.canSeeSky(worldPosition.above()))
{
startTick += getDuration(); // takes twice as long indoors
Expand Down Expand Up @@ -91,6 +101,11 @@ public void resetCounter()
markForSync();
}

public ItemStack viewStack()
{
return inventory.getStackInSlot(0);
}

public ItemStack readStack()
{
return inventory.getStackInSlot(0).copy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ default void initFoodStats(CraftingContainer inv, FoodHandler.Dynamic handler)
handler.setCreationDate(FoodCapability.getRoundedCreationDate());
}

@Override
default boolean dependsOnInput()
{
return true;
}

default float saturation()
{
return 0.5f;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
package com.eerussianguy.firmalife.compat.tooltip;

import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;

import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;

import com.eerussianguy.firmalife.common.FLHelpers;
import com.eerussianguy.firmalife.common.blockentities.*;
import com.eerussianguy.firmalife.common.blocks.*;
import com.eerussianguy.firmalife.common.blocks.greenhouse.LargePlanterBlock;
import com.eerussianguy.firmalife.common.items.FLFoodTraits;
import com.eerussianguy.firmalife.config.FLConfig;
import net.dries007.tfc.common.capabilities.food.FoodCapability;
import net.dries007.tfc.common.capabilities.food.FoodTrait;
import net.dries007.tfc.common.capabilities.food.IFood;
import net.dries007.tfc.compat.jade.common.BlockEntityTooltip;
import net.dries007.tfc.compat.jade.common.BlockEntityTooltips;
import net.dries007.tfc.compat.jade.common.EntityTooltip;
Expand Down Expand Up @@ -47,16 +56,45 @@ public static void register(BiConsumer<BlockEntityTooltip, Class<? extends Block
};

public static final BlockEntityTooltip DRYING_MAT = (level, state, pos, entity, tooltip) -> {
if (state.getBlock() instanceof DryingMatBlock block && entity instanceof DryingMatBlockEntity mat)
if (state.getBlock() instanceof DryingMatBlock block && entity instanceof DryingMatBlockEntity mat && !mat.viewStack().isEmpty())
{
tooltip.accept(Helpers.translatable("tfc.jade.time_left", delta(level, mat.getTicksLeft())));
if (mat.getCachedRecipe() != null)
{
tooltip.accept(Helpers.translatable("tfc.jade.time_left", delta(level, mat.getTicksLeft())));
}
}
};

public static final BlockEntityTooltip STRING = (level, state, pos, entity, tooltip) -> {
if (state.getBlock() instanceof StringBlock block && entity instanceof StringBlockEntity mat)
{
tooltip.accept(Helpers.translatable("tfc.jade.time_left", delta(level, mat.getTicksLeft())));
final ItemStack item = mat.viewStack();
if (!item.isEmpty())
{
final IFood food = item.getCapability(FoodCapability.CAPABILITY).resolve().orElse(null);
final List<FoodTrait> traits = food == null ? null : food.getTraits();
if (mat.getCachedRecipe() != null)
{
tooltip.accept(Helpers.translatable("tfc.jade.time_left", delta(level, mat.getTicksLeft())));
}
else if (traits != null)
{
final List<Component> text = new ArrayList<>();
if (traits.contains(FLFoodTraits.SMOKED))
{
FLFoodTraits.SMOKED.addTooltipInfo(item, text);
}
if (traits.contains(FLFoodTraits.RANCID_SMOKED))
{
FLFoodTraits.RANCID_SMOKED.addTooltipInfo(item, text);
}
if (!text.isEmpty())
{
text.forEach(tooltip);
}
}

}
}
};

Expand All @@ -82,7 +120,14 @@ public static void register(BiConsumer<BlockEntityTooltip, Class<? extends Block
BlockEntityTooltips.heat(tooltip, oven.getTemperature());
if (state.getBlock() instanceof ICure cure && !cure.isCured())
{
tooltip.accept(Helpers.translatable("firmalife.jade.cure_time_left", delta(level, OvenBottomBlockEntity.CURE_TICKS - oven.getCureTicks())));
if (oven.getTemperature() < FLConfig.SERVER.ovenCureTemperature.get())
{
tooltip.accept(Helpers.translatable("firmalife.jade.cannot_cure"));
}
else
{
tooltip.accept(Helpers.translatable("firmalife.jade.cure_time_left", delta(level, FLConfig.SERVER.ovenCureTicks.get() - oven.getCureTicks())));
}
}
}
};
Expand All @@ -91,6 +136,17 @@ public static void register(BiConsumer<BlockEntityTooltip, Class<? extends Block
if (state.getBlock() instanceof OvenTopBlock block && entity instanceof OvenTopBlockEntity oven)
{
BlockEntityTooltips.heat(tooltip, oven.getTemperature());
if (state.getBlock() instanceof ICure cure && !cure.isCured())
{
if (oven.getTemperature() < FLConfig.SERVER.ovenCureTemperature.get())
{
tooltip.accept(Helpers.translatable("firmalife.jade.cannot_cure"));
}
else
{
tooltip.accept(Helpers.translatable("firmalife.jade.cure_time_left", delta(level, FLConfig.SERVER.ovenCureTicks.get() - oven.getCureTicks())));
}
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public class FLServerConfig
public final IntValue dryingTicks;
public final IntValue smokingTicks;
public final IntValue ironComposterTicks;
public final IntValue ovenCookTicks;
public final IntValue ovenCureTicks;
public final IntValue ovenCureTemperature;
public final BooleanValue ovenRequirePeel;
public final BooleanValue enableSeedBalls;
public final BooleanValue enableBeeSwarm;
Expand All @@ -28,6 +31,9 @@ public class FLServerConfig
dryingTicks = builder.apply("dryingTicks").comment("Ticks to dry something on a drying mat (24000 ticks = 1 day)").defineInRange("dryingTicks", 12000, 1, Integer.MAX_VALUE);
smokingTicks = builder.apply("smokingTicks").comment("Ticks to smoke something on a string (24000 ticks = 1 day)").defineInRange("smokingTicks", 8000, 1, Integer.MAX_VALUE);
ironComposterTicks = builder.apply("ironComposterTicks").comment("Ticks for an iron composter to finish (24000 ticks = 1 day)").defineInRange("ironComposterTicks", 72000, 1, Integer.MAX_VALUE);
ovenCookTicks = builder.apply("ovenCookTicks").comment("Ticks for an oven to cook an item (24000 ticks = 1 day)").defineInRange("ovenCookTicks", 2000, 1, Integer.MAX_VALUE);
ovenCureTicks = builder.apply("ovenCureTicks").comment("Ticks for an oven to cure (24000 ticks = 1 day)").defineInRange("ovenCureTicks", 2000, 1, Integer.MAX_VALUE);
ovenCureTemperature = builder.apply("ovenCureTemperature").comment("Minimum temperature for an oven to start the curing process (24000 ticks = 1 day)").defineInRange("ovenCureTemperature", 600, 1, Integer.MAX_VALUE);
ovenRequirePeel = builder.apply("ovenRequirePeel").comment("If true, ovens will hurt the player if they touch it without a peel in hand.").define("ovenRequirePeel", true);
enableSeedBalls = builder.apply("enableSeedBalls").comment("If true, players can throw seed balls.").define("enableSeedBalls", true);
enableBeeSwarm = builder.apply("enableBeeSwarm").comment("If true, bees can swarm and hurt the player if provoked.").define("enableBeeSwarm", true);
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/assets/firmalife/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@
"firmalife.enum.plantertype.bonsai": "Bonsai Planter",
"firmalife.enum.plantertype.quad": "Quad Planter",
"firmalife.enum.plantertype.large": "Large Planter",
"firmalife.jade.food_age": "Age: %s",
"firmalife.jade.aging": "Currently Aging",
"firmalife.jade.not_aging": "Not Aging",
"firmalife.jade.slices": "Slices: %s",
"firmalife.jade.cure_time_left": "Curing Time Left: %s",
"firmalife.jade.cannot_cure": "Not hot enough to cure!",
"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.",
"death.attack.firmalife.swarm": "%1$s was stung to death by bees.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
]
},
"primary_ingredient": {
"tag": "tfc:foods"
"type": "tfc:not_rotten",
"ingredient": {
"item": "firmalife:food/pie_dough"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
]
},
"primary_ingredient": {
"tag": "tfc:foods"
"type": "tfc:not_rotten",
"ingredient": {
"item": "firmalife:food/pizza_dough"
}
}
}
10 changes: 10 additions & 0 deletions src/main/resources/data/firmalife/tfc/food_items/pizza_dough.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"__comment__": "This file was automatically created by mcresources",
"ingredient": {
"item": "firmalife:food/pizza_dough"
},
"category": "other",
"hunger": 4,
"saturation": 0,
"decay_modifier": 3
}
1 change: 1 addition & 0 deletions src/main/resources/data/tfc/tags/items/foods.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"#firmalife:chocolate_blends",
"firmalife:food/butter",
"firmalife:food/pie_dough",
"firmalife:food/pizza_dough",
"firmalife:food/pumpkin_chunks",
"firmalife:food/pumpkin_pie_dough",
"firmalife:food/raw_pumpkin_pie",
Expand Down

0 comments on commit 579d856

Please sign in to comment.