From 579d8563094858a068c2f4c135b96e85d8bbdd4b Mon Sep 17 00:00:00 2001 From: EERussianguy Date: Mon, 12 Sep 2022 20:00:23 -0400 Subject: [PATCH] fix jei issues (Closes #80), fix jade up, oven config options, --- resources/constants.py | 1 + resources/data.py | 1 + resources/recipes.py | 2 +- .../render/StringBlockEntityRenderer.java | 2 +- .../LargePlanterBlockEntity.java | 3 +- .../blockentities/OvenBottomBlockEntity.java | 10 +-- .../blockentities/OvenTopBlockEntity.java | 19 +++--- .../SimpleItemRecipeBlockEntity.java | 17 ++++- .../recipes/data/CustomFoodModifier.java | 6 ++ .../firmalife/compat/tooltip/FLTooltips.java | 64 +++++++++++++++++-- .../firmalife/config/FLServerConfig.java | 6 ++ .../assets/firmalife/lang/en_us.json | 6 ++ .../recipes/crafting/filled_pie.json | 5 +- .../firmalife/recipes/crafting/raw_pizza.json | 5 +- .../firmalife/tfc/food_items/pizza_dough.json | 10 +++ .../resources/data/tfc/tags/items/foods.json | 1 + 16 files changed, 135 insertions(+), 23 deletions(-) create mode 100644 src/main/resources/data/firmalife/tfc/food_items/pizza_dough.json diff --git a/resources/constants.py b/resources/constants.py index c676a783..47a5fcdf 100644 --- a/resources/constants.py +++ b/resources/constants.py @@ -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.', diff --git a/resources/data.py b/resources/data.py index 12a9d7ae..3cb8442e 100644 --- a/resources/data.py +++ b/resources/data.py @@ -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) diff --git a/resources/recipes.py b/resources/recipes.py index 036cb5f6..8390599a 100644 --- a/resources/recipes.py +++ b/resources/recipes.py @@ -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) diff --git a/src/main/java/com/eerussianguy/firmalife/client/render/StringBlockEntityRenderer.java b/src/main/java/com/eerussianguy/firmalife/client/render/StringBlockEntityRenderer.java index 774e4398..8d17ab67 100644 --- a/src/main/java/com/eerussianguy/firmalife/client/render/StringBlockEntityRenderer.java +++ b/src/main/java/com/eerussianguy/firmalife/client/render/StringBlockEntityRenderer.java @@ -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); diff --git a/src/main/java/com/eerussianguy/firmalife/common/blockentities/LargePlanterBlockEntity.java b/src/main/java/com/eerussianguy/firmalife/common/blockentities/LargePlanterBlockEntity.java index a0d5929c..f0ae71ad 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/blockentities/LargePlanterBlockEntity.java +++ b/src/main/java/com/eerussianguy/firmalife/common/blockentities/LargePlanterBlockEntity.java @@ -208,6 +208,7 @@ public boolean isClimateValid() public Component getInvalidReason() { assert level != null; + final Direction airFind = airFindOffset(); String complaint = "error_unknown"; if (!climateValid) { @@ -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"; } diff --git a/src/main/java/com/eerussianguy/firmalife/common/blockentities/OvenBottomBlockEntity.java b/src/main/java/com/eerussianguy/firmalife/common/blockentities/OvenBottomBlockEntity.java index 47ab27c0..81e57bce 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/blockentities/OvenBottomBlockEntity.java +++ b/src/main/java/com/eerussianguy/firmalife/common/blockentities/OvenBottomBlockEntity.java @@ -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; @@ -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); } @@ -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; diff --git a/src/main/java/com/eerussianguy/firmalife/common/blockentities/OvenTopBlockEntity.java b/src/main/java/com/eerussianguy/firmalife/common/blockentities/OvenTopBlockEntity.java index 2f6051df..4343a38a 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/blockentities/OvenTopBlockEntity.java +++ b/src/main/java/com/eerussianguy/firmalife/common/blockentities/OvenTopBlockEntity.java @@ -10,7 +10,6 @@ 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; @@ -18,6 +17,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.config.FLConfig; import net.dries007.tfc.common.blockentities.InventoryBlockEntity; import net.dries007.tfc.common.blockentities.TickableInventoryBlockEntity; import net.dries007.tfc.common.capabilities.DelegateItemHandler; @@ -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; @@ -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); } @@ -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); @@ -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 sidedHeat; @@ -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) { diff --git a/src/main/java/com/eerussianguy/firmalife/common/blockentities/SimpleItemRecipeBlockEntity.java b/src/main/java/com/eerussianguy/firmalife/common/blockentities/SimpleItemRecipeBlockEntity.java index b46f76e5..12322327 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/blockentities/SimpleItemRecipeBlockEntity.java +++ b/src/main/java/com/eerussianguy/firmalife/common/blockentities/SimpleItemRecipeBlockEntity.java @@ -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; @@ -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 @@ -91,6 +101,11 @@ public void resetCounter() markForSync(); } + public ItemStack viewStack() + { + return inventory.getStackInSlot(0); + } + public ItemStack readStack() { return inventory.getStackInSlot(0).copy(); diff --git a/src/main/java/com/eerussianguy/firmalife/common/recipes/data/CustomFoodModifier.java b/src/main/java/com/eerussianguy/firmalife/common/recipes/data/CustomFoodModifier.java index 5293105c..c2893c47 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/recipes/data/CustomFoodModifier.java +++ b/src/main/java/com/eerussianguy/firmalife/common/recipes/data/CustomFoodModifier.java @@ -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; diff --git a/src/main/java/com/eerussianguy/firmalife/compat/tooltip/FLTooltips.java b/src/main/java/com/eerussianguy/firmalife/compat/tooltip/FLTooltips.java index 85f09e00..110881e6 100644 --- a/src/main/java/com/eerussianguy/firmalife/compat/tooltip/FLTooltips.java +++ b/src/main/java/com/eerussianguy/firmalife/compat/tooltip/FLTooltips.java @@ -1,9 +1,13 @@ 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; @@ -11,6 +15,11 @@ 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; @@ -47,16 +56,45 @@ public static void register(BiConsumer { - 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 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 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); + } + } + + } } }; @@ -82,7 +120,14 @@ public static void register(BiConsumer