From d5757a1453ba857ed49c599fc2740a12941b8800 Mon Sep 17 00:00:00 2001 From: Flanks255 <32142731+Flanks255@users.noreply.github.com> Date: Sat, 14 Dec 2024 10:30:47 -0600 Subject: [PATCH] Removed SolidFuelRecipe.java, migrated Coal generators to use any burnable item. Closes #1435 --- CHANGELOG.md | 1 + .../2a0621f54729484bb667bdf33a347c218c756998 | 8 +- .../recipe/solid_fuel/charcoal.json | 8 -- .../recipe/solid_fuel/coal-block.json | 8 -- .../recipe/solid_fuel/coal.json | 8 -- .../recipe/solid_fuel/lava.json | 8 -- .../recipe/solid_fuel/stick.json | 8 -- .../recipe/solid_fuel/tiny-coal.json | 8 -- .../api/ActuallyAdditionsAPI.java | 19 +-- .../data/FuelRecipeGenerator.java | 28 ---- .../mod/crafting/ActuallyRecipes.java | 2 - .../mod/crafting/SolidFuelRecipe.java | 128 ------------------ .../mod/inventory/ContainerCoalGenerator.java | 3 +- .../mod/inventory/gui/GuiCoalGenerator.java | 20 +++ .../mod/tile/TileEntityCoalGenerator.java | 46 ++----- .../mod/util/ResourceReloader.java | 3 - .../assets/actuallyadditions/lang/en_us.json | 1 + 17 files changed, 41 insertions(+), 266 deletions(-) delete mode 100644 src/generated/resources/data/actuallyadditions/recipe/solid_fuel/charcoal.json delete mode 100644 src/generated/resources/data/actuallyadditions/recipe/solid_fuel/coal-block.json delete mode 100644 src/generated/resources/data/actuallyadditions/recipe/solid_fuel/coal.json delete mode 100644 src/generated/resources/data/actuallyadditions/recipe/solid_fuel/lava.json delete mode 100644 src/generated/resources/data/actuallyadditions/recipe/solid_fuel/stick.json delete mode 100644 src/generated/resources/data/actuallyadditions/recipe/solid_fuel/tiny-coal.json delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/crafting/SolidFuelRecipe.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 7376a8389..0d47d0be2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Fixed the farmer not funneling seeds back to the seed slots. * Added crops block-tag to Canola/Flax/Rice * Fixed the drill block placement augment. +* Migrated the Coal generator to using any burnable item, Removed Solid fuel recipes. # 1.3.11+mc1.21.1 * Fixed Farmer not playing well with non-vanilla farmland. diff --git a/src/generated/resources/.cache/2a0621f54729484bb667bdf33a347c218c756998 b/src/generated/resources/.cache/2a0621f54729484bb667bdf33a347c218c756998 index d979e1282..879c3fef9 100644 --- a/src/generated/resources/.cache/2a0621f54729484bb667bdf33a347c218c756998 +++ b/src/generated/resources/.cache/2a0621f54729484bb667bdf33a347c218c756998 @@ -1,11 +1,5 @@ -// 1.21.1 2024-11-17T13:53:47.3739458 Fuel Recipes +// 1.21.1 2024-12-14T10:16:17.1144713 Fuel Recipes 76f02a2cc4d39ec2adb71fbe0ac6da3a1b31ff9d data/actuallyadditions/recipe/liquid_fuel/canola_oil.json 6b23d46a93b3e67bb58858c13becd6bd3f348f6f data/actuallyadditions/recipe/liquid_fuel/crystallized_canola_oil.json 056a848bc5c836985a9f080c3a540bf97e710f2a data/actuallyadditions/recipe/liquid_fuel/empowered_canola_oil.json 0f6dd7157c080d139886b390000aa075aaa658cd data/actuallyadditions/recipe/liquid_fuel/refined_canola_oil.json -0732b5aebc03718a2adf8710c149021b1bc05eb7 data/actuallyadditions/recipe/solid_fuel/charcoal.json -390939de1b4699a714ed3d5c3e67e4e5df7b5135 data/actuallyadditions/recipe/solid_fuel/coal-block.json -d6dbd4428a27289d3407a7609c5e8342a0c72b1a data/actuallyadditions/recipe/solid_fuel/coal.json -50885f04b21b6cdb4a1d41b8d4f1210762c21db9 data/actuallyadditions/recipe/solid_fuel/lava.json -5bc9490d9ce3874d628644059d2ab3738b267242 data/actuallyadditions/recipe/solid_fuel/stick.json -df8a71b8bd2bc3594381e1337c65a0963dd06714 data/actuallyadditions/recipe/solid_fuel/tiny-coal.json diff --git a/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/charcoal.json b/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/charcoal.json deleted file mode 100644 index 81f66b6e7..000000000 --- a/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/charcoal.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type": "actuallyadditions:solid_fuel", - "burn_time": 1600, - "item": { - "item": "minecraft:charcoal" - }, - "total_energy": 32000 -} \ No newline at end of file diff --git a/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/coal-block.json b/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/coal-block.json deleted file mode 100644 index 51f31c8da..000000000 --- a/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/coal-block.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type": "actuallyadditions:solid_fuel", - "burn_time": 16000, - "item": { - "tag": "c:storage_blocks/coal" - }, - "total_energy": 320000 -} \ No newline at end of file diff --git a/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/coal.json b/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/coal.json deleted file mode 100644 index 2d346daa2..000000000 --- a/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/coal.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type": "actuallyadditions:solid_fuel", - "burn_time": 1600, - "item": { - "item": "minecraft:coal" - }, - "total_energy": 32000 -} \ No newline at end of file diff --git a/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/lava.json b/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/lava.json deleted file mode 100644 index 37ed35865..000000000 --- a/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/lava.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type": "actuallyadditions:solid_fuel", - "burn_time": 20000, - "item": { - "item": "minecraft:lava_bucket" - }, - "total_energy": 400000 -} \ No newline at end of file diff --git a/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/stick.json b/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/stick.json deleted file mode 100644 index 4155a6bce..000000000 --- a/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/stick.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type": "actuallyadditions:solid_fuel", - "burn_time": 100, - "item": { - "item": "minecraft:stick" - }, - "total_energy": 2000 -} \ No newline at end of file diff --git a/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/tiny-coal.json b/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/tiny-coal.json deleted file mode 100644 index d6de6bb3f..000000000 --- a/src/generated/resources/data/actuallyadditions/recipe/solid_fuel/tiny-coal.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type": "actuallyadditions:solid_fuel", - "burn_time": 200, - "item": { - "tag": "actuallyadditions:tiny_coals" - }, - "total_energy": 4000 -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java index 143ece197..954ff831d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java @@ -21,22 +21,8 @@ import de.ellpeck.actuallyadditions.api.lens.LensConversion; import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.api.recipe.WeightedOre; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe; -import de.ellpeck.actuallyadditions.mod.crafting.ColorChangeRecipe; -import de.ellpeck.actuallyadditions.mod.crafting.CrushingRecipe; -import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe; -import de.ellpeck.actuallyadditions.mod.crafting.FermentingRecipe; -import de.ellpeck.actuallyadditions.mod.crafting.LaserRecipe; -import de.ellpeck.actuallyadditions.mod.crafting.LiquidFuelRecipe; -import de.ellpeck.actuallyadditions.mod.crafting.MiningLensRecipe; -import de.ellpeck.actuallyadditions.mod.crafting.PressingRecipe; -import de.ellpeck.actuallyadditions.mod.crafting.SolidFuelRecipe; -import de.ellpeck.actuallyadditions.mod.items.lens.LensColor; -import de.ellpeck.actuallyadditions.mod.items.lens.LensDeath; -import de.ellpeck.actuallyadditions.mod.items.lens.LensDetonation; -import de.ellpeck.actuallyadditions.mod.items.lens.LensDisenchanting; -import de.ellpeck.actuallyadditions.mod.items.lens.LensKiller; -import de.ellpeck.actuallyadditions.mod.items.lens.LensMining; +import de.ellpeck.actuallyadditions.mod.crafting.*; +import de.ellpeck.actuallyadditions.mod.items.lens.*; import net.minecraft.core.NonNullList; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; @@ -56,7 +42,6 @@ public final class ActuallyAdditionsAPI { public static final List> CRUSHER_RECIPES = new ArrayList<>(); public static final List> EMPOWERER_RECIPES = new ArrayList<>(); public static final List> COLOR_CHANGE_RECIPES = new ArrayList<>(); - public static final List> SOLID_FUEL_RECIPES = new ArrayList<>(); public static final List> LIQUID_FUEL_RECIPES = new ArrayList<>(); public static final List> PRESSING_RECIPES = new ArrayList<>(); public static final List> FERMENTING_RECIPES = new ArrayList<>(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/FuelRecipeGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/FuelRecipeGenerator.java index 3abad0aea..07f77d7b6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/FuelRecipeGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/FuelRecipeGenerator.java @@ -1,21 +1,13 @@ package de.ellpeck.actuallyadditions.data; -import de.ellpeck.actuallyadditions.api.ActuallyTags; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.crafting.LiquidFuelRecipe; -import de.ellpeck.actuallyadditions.mod.crafting.SolidFuelRecipe; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.util.NoAdvRecipeOutput; import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.data.recipes.RecipeProvider; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Items; -import net.minecraft.world.item.crafting.Ingredient; -import net.neoforged.neoforge.common.Tags; import net.neoforged.neoforge.fluids.FluidStack; import javax.annotation.Nonnull; @@ -35,13 +27,6 @@ public class FuelRecipeGenerator extends RecipeProvider { protected void buildRecipes(@Nonnull RecipeOutput output) { var recipeOutput = new NoAdvRecipeOutput(output); - addSolid(recipeOutput, "coal", Items.COAL, 32000, 1600); - addSolid(recipeOutput, "stick", Items.STICK, 2000, 100); - addSolid(recipeOutput, "tiny-coal", ActuallyTags.Items.TINY_COALS, 4000, 200); - addSolid(recipeOutput, "charcoal", Items.CHARCOAL, 32000, 1600); - addSolid(recipeOutput, "coal-block", Tags.Items.STORAGE_BLOCKS_COAL, 320000, 16000); - addSolid(recipeOutput, "lava", Items.LAVA_BUCKET, 400000, 20000); - recipeOutput.accept(ActuallyAdditions.modLoc("liquid_fuel/canola_oil"), new LiquidFuelRecipe( new FluidStack(InitFluids.CANOLA_OIL.get(), 50), 4000, 100), null); @@ -55,17 +40,4 @@ public class FuelRecipeGenerator extends RecipeProvider { recipeOutput.accept(ActuallyAdditions.modLoc("liquid_fuel/empowered_canola_oil"), new LiquidFuelRecipe( new FluidStack(InitFluids.EMPOWERED_OIL.get(), 50), 48000, 400), null); } - - private void addSolid(RecipeOutput consumer, String name, Item item, int energy, int burnTime) { - ResourceLocation id = ActuallyAdditions.modLoc("solid_fuel/"+name); - consumer.accept(id, new SolidFuelRecipe(Ingredient.of(item), energy, burnTime), null); - } - private void addSolid(RecipeOutput consumer, String name, Ingredient item, int energy, int burnTime) { - ResourceLocation id = ActuallyAdditions.modLoc("solid_fuel/"+name); - consumer.accept(id, new SolidFuelRecipe(item, energy, burnTime), null); - } - private void addSolid(RecipeOutput consumer, String name, TagKey tag, int energy, int burnTime) { - ResourceLocation id = ActuallyAdditions.modLoc("solid_fuel/"+name); - consumer.accept(id, new SolidFuelRecipe(Ingredient.of(tag), energy, burnTime), null); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ActuallyRecipes.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ActuallyRecipes.java index 65775baf7..50185491b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ActuallyRecipes.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ActuallyRecipes.java @@ -25,7 +25,6 @@ public class ActuallyRecipes { public static final Supplier> LASER_RECIPE = SERIALIZERS.register(LaserRecipe.NAME, LaserRecipe.Serializer::new); public static final Supplier> EMPOWERING_RECIPE = SERIALIZERS.register(EmpowererRecipe.NAME, EmpowererRecipe.Serializer::new); public static final Supplier> CRUSHING_RECIPE = SERIALIZERS.register(CrushingRecipe.NAME, CrushingRecipe.Serializer::new); - public static final Supplier> SOLID_FUEL_RECIPE = SERIALIZERS.register(SolidFuelRecipe.NAME, SolidFuelRecipe.Serializer::new); public static final Supplier> LIQUID_FUEL_RECIPE = SERIALIZERS.register(LiquidFuelRecipe.NAME, LiquidFuelRecipe.Serializer::new); public static final Supplier> PRESSING_RECIPE = SERIALIZERS.register(PressingRecipe.NAME, PressingRecipe.Serializer::new); public static final Supplier> FERMENTING_RECIPE = SERIALIZERS.register(FermentingRecipe.NAME, FermentingRecipe.Serializer::new); @@ -41,7 +40,6 @@ public class ActuallyRecipes { public static final Supplier> LASER = RECIPE_TYPES.register("laser", RecipeType::simple); public static final Supplier> EMPOWERING = RECIPE_TYPES.register("empower", RecipeType::simple); public static final Supplier> CRUSHING = RECIPE_TYPES.register("crushing", RecipeType::simple); - public static final Supplier> SOLID_FUEL = RECIPE_TYPES.register("solid_fuel", RecipeType::simple); public static final Supplier> LIQUID_FUEL = RECIPE_TYPES.register("liquid_fuel", RecipeType::simple); public static final Supplier> PRESSING = RECIPE_TYPES.register("pressing", RecipeType::simple); public static final Supplier> FERMENTING = RECIPE_TYPES.register("fermenting", RecipeType::simple); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/SolidFuelRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/SolidFuelRecipe.java deleted file mode 100644 index a721f7efe..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/SolidFuelRecipe.java +++ /dev/null @@ -1,128 +0,0 @@ -package de.ellpeck.actuallyadditions.mod.crafting; - -import com.mojang.serialization.Codec; -import com.mojang.serialization.MapCodec; -import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.core.HolderLookup; -import net.minecraft.network.RegistryFriendlyByteBuf; -import net.minecraft.network.codec.StreamCodec; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.Recipe; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.RecipeType; -import net.minecraft.world.item.crafting.SingleRecipeInput; -import net.minecraft.world.level.Level; - -import javax.annotation.Nonnull; - -public class SolidFuelRecipe implements Recipe { - public static String NAME = "solid_fuel"; - private final Ingredient itemIngredient; - private final int burnTime; - private final int totalEnergy; - - public SolidFuelRecipe(Ingredient itemIngredient, int totalEnergy, int burnTime) { - this.itemIngredient = itemIngredient; - this.burnTime = burnTime; - this.totalEnergy = totalEnergy; - } - - public int getBurnTime() { - return burnTime; - } - - public int getTotalEnergy() { - return totalEnergy; - } - - @Override - public boolean matches(SingleRecipeInput pInv, @Nonnull Level pLevel) { - return itemIngredient.test(pInv.getItem(0)); - } - - public boolean matches(ItemStack stack) { - return this.itemIngredient.test(stack); - } - - @Override - public boolean isSpecial() { - return true; - } - - @Nonnull - @Override - public ItemStack assemble(@Nonnull SingleRecipeInput pInv, @Nonnull HolderLookup.Provider registries) { - return ItemStack.EMPTY; - } - - @Override - public boolean canCraftInDimensions(int pWidth, int pHeight) { - return false; - } - - @Nonnull - @Override - public ItemStack getResultItem(@Nonnull HolderLookup.Provider provider) { - return ItemStack.EMPTY; - } - - @Nonnull - @Override - public RecipeSerializer getSerializer() { - return ActuallyRecipes.SOLID_FUEL_RECIPE.get(); - } - - @Nonnull - @Override - public RecipeType getType() { - return ActuallyRecipes.Types.SOLID_FUEL.get(); - } - - public static class Serializer implements RecipeSerializer { - private static final MapCodec CODEC = RecordCodecBuilder.mapCodec( - instance -> instance.group( - Ingredient.CODEC_NONEMPTY.fieldOf("item").forGetter(recipe -> recipe.itemIngredient), - Codec.INT.fieldOf("total_energy").forGetter(recipe -> recipe.totalEnergy), - Codec.INT.fieldOf("burn_time").forGetter(recipe -> recipe.burnTime) - ) - .apply(instance, SolidFuelRecipe::new) - ); - public static final StreamCodec STREAM_CODEC = StreamCodec.of( - SolidFuelRecipe.Serializer::toNetwork, SolidFuelRecipe.Serializer::fromNetwork - ); - - @Nonnull - @Override - public MapCodec codec() { - return CODEC; - } - - @Nonnull - @Override - public StreamCodec streamCodec() { - return STREAM_CODEC; - } - -// @Override -// public SolidFuelRecipe fromJson(ResourceLocation pId, JsonObject pJson) { -// Ingredient itemIngredient = Ingredient.fromJson(pJson.get("item")); -// int totalEnergy = pJson.get("total_energy").getAsInt(); -// int burnTime = pJson.get("burn_time").getAsInt(); -// return new SolidFuelRecipe(pId, itemIngredient, totalEnergy, burnTime); -// } - - public static SolidFuelRecipe fromNetwork(RegistryFriendlyByteBuf pBuffer) { - Ingredient itemIngredient = Ingredient.CONTENTS_STREAM_CODEC.decode(pBuffer); - int totalEnergy = pBuffer.readInt(); - int burnTime = pBuffer.readInt(); - return new SolidFuelRecipe(itemIngredient, totalEnergy, burnTime); - } - - public static void toNetwork(RegistryFriendlyByteBuf pBuffer, SolidFuelRecipe pRecipe) { - Ingredient.CONTENTS_STREAM_CODEC.encode(pBuffer, pRecipe.itemIngredient); - pBuffer.writeInt(pRecipe.totalEnergy); - pBuffer.writeInt(pRecipe.burnTime); - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoalGenerator.java index 42a8b779f..752d951d6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoalGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoalGenerator.java @@ -18,6 +18,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeType; import javax.annotation.Nonnull; import java.util.Objects; @@ -63,7 +64,7 @@ public class ContainerCoalGenerator extends AbstractContainerMenu { //Other Slots in Inventory excluded if (slot >= inventoryStart) { //Shift from Inventory - if (newStack.getBurnTime(null) > 0) { + if (newStack.getBurnTime(RecipeType.SMELTING) > 0) { if (!this.moveItemStackTo(newStack, 0, 1, false)) { return ItemStack.EMPTY; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoalGenerator.java index e2477faca..b678d1076 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoalGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoalGenerator.java @@ -14,12 +14,16 @@ import com.mojang.blaze3d.systems.RenderSystem; import de.ellpeck.actuallyadditions.mod.inventory.ContainerCoalGenerator; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; +import net.minecraft.ChatFormatting; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeType; import javax.annotation.Nonnull; +import java.util.List; public class GuiCoalGenerator extends AAScreen { @@ -63,4 +67,20 @@ public class GuiCoalGenerator extends AAScreen { this.energy.draw(guiGraphics); } + + @Nonnull + @Override + protected List getTooltipFromContainerItem(@Nonnull ItemStack stack) { + var tooltip = super.getTooltipFromContainerItem(stack); + + int burnTime = stack.getBurnTime(RecipeType.SMELTING); + if (burnTime > 0) { + tooltip.add(Component.translatable("tooltip.actuallyadditions.coal_generator_stats", + burnTime * TileEntityCoalGenerator.ENERGY_PER_TICK, + TileEntityCoalGenerator.ENERGY_PER_TICK, + burnTime).withStyle(ChatFormatting.GRAY)); + } + + return tooltip; + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java index af9cd9e01..88dd2cca9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java @@ -10,10 +10,8 @@ package de.ellpeck.actuallyadditions.mod.tile; -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents; -import de.ellpeck.actuallyadditions.mod.crafting.SolidFuelRecipe; import de.ellpeck.actuallyadditions.mod.inventory.ContainerCoalGenerator; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; @@ -24,13 +22,12 @@ import net.minecraft.core.HolderLookup; import net.minecraft.core.component.DataComponentMap; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.RecipeHolder; +import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; @@ -42,18 +39,21 @@ import javax.annotation.Nullable; public class TileEntityCoalGenerator extends TileEntityInventoryBase implements MenuProvider, ISharingEnergyProvider, IEnergyDisplay { public final CustomEnergyStorage storage = new CustomEnergyStorage(60000, 0, 80); + public static final int ENERGY_PER_TICK = 20; public int maxBurnTime; public int currentBurnTime; private int lastEnergy; private int lastBurnTime; private int lastCurrentBurnTime; private int lastCompare; - private RecipeHolder currentRecipe = null; public TileEntityCoalGenerator(BlockPos pos, BlockState state) { super(ActuallyBlocks.COAL_GENERATOR.getTileEntityType(), pos, state, 1); } + private int getBurnTime(@Nonnull ItemStack stack) { + return stack.getBurnTime(RecipeType.SMELTING); + } public int getEnergyScaled(int i) { return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored(); @@ -69,8 +69,6 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements if (type != NBTType.SAVE_BLOCK) { compound.putInt("BurnTime", this.currentBurnTime); compound.putInt("MaxBurnTime", this.maxBurnTime); - if (currentRecipe != null) - compound.putString("currentRecipe", currentRecipe.id().toString()); } this.storage.writeToNBT(compound); super.writeSyncableNBT(compound, lookupProvider, type); @@ -81,15 +79,6 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements if (type != NBTType.SAVE_BLOCK) { this.currentBurnTime = compound.getInt("BurnTime"); this.maxBurnTime = compound.getInt("MaxBurnTime"); - if (compound.contains("currentRecipe")) { - ResourceLocation id = ResourceLocation.tryParse(compound.getString("currentRecipe")); - for (RecipeHolder fuelRecipe : ActuallyAdditionsAPI.SOLID_FUEL_RECIPES) { - if (fuelRecipe.id().equals(id)) { - this.currentRecipe = fuelRecipe; - break; - } - } - } } this.storage.readFromNBT(compound); super.readSyncableNBT(compound, lookupProvider, type); @@ -107,25 +96,21 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements boolean flag = tile.currentBurnTime > 0; - if (tile.currentBurnTime > 0 && tile.currentRecipe != null) { + if (tile.currentBurnTime > 0) { tile.currentBurnTime--; - int produce = tile.currentRecipe.value().getTotalEnergy() / tile.currentRecipe.value().getBurnTime(); - if (produce > 0) { - tile.storage.receiveEnergyInternal(produce, false); - } + tile.storage.receiveEnergyInternal(ENERGY_PER_TICK, false); } if (!tile.isRedstonePowered && tile.currentBurnTime <= 0 && tile.storage.getEnergyStored() < tile.storage.getMaxEnergyStored()) { ItemStack stack = tile.inv.getStackInSlot(0); if (!stack.isEmpty()) { - ActuallyAdditionsAPI.SOLID_FUEL_RECIPES.stream().filter(r -> r.value().matches(stack)).findFirst().ifPresent(recipe -> { - tile.currentRecipe = recipe; - tile.maxBurnTime = recipe.value().getBurnTime(); + int time = tile.getBurnTime(stack); + if (time > 0) { + tile.maxBurnTime = tile.getBurnTime(stack); tile.currentBurnTime = tile.maxBurnTime; tile.inv.setStackInSlot(0, StackUtil.shrinkForContainer(stack, 1)); - }); - } else - tile.currentRecipe = null; + } + } } if (flag != tile.currentBurnTime > 0 || tile.lastCompare != tile.getComparatorStrength()) { @@ -150,10 +135,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements @Override public IAcceptor getAcceptor() { return (slot, stack, automation) -> { - for (RecipeHolder recipe : ActuallyAdditionsAPI.SOLID_FUEL_RECIPES) { - if (recipe.value().matches(stack))return true; - } - return false; + return stack.getBurnTime(RecipeType.SMELTING) > 0; }; } @@ -163,7 +145,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements if (!automation) { return true; } - return this.inv.getStackInSlot(0).getBurnTime(null) <= 0; + return this.inv.getStackInSlot(0).getBurnTime(RecipeType.SMELTING) <= 0; }; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ResourceReloader.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ResourceReloader.java index f9de804fa..d5ce73ced 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ResourceReloader.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ResourceReloader.java @@ -21,9 +21,6 @@ public class ResourceReloader implements ResourceManagerReloadListener { ActuallyAdditionsAPI.EMPOWERER_RECIPES.clear(); ActuallyAdditionsAPI.EMPOWERER_RECIPES.addAll(recipeManager.getAllRecipesFor(ActuallyRecipes.Types.EMPOWERING.get())); - ActuallyAdditionsAPI.SOLID_FUEL_RECIPES.clear(); - ActuallyAdditionsAPI.SOLID_FUEL_RECIPES.addAll(recipeManager.getAllRecipesFor(ActuallyRecipes.Types.SOLID_FUEL.get())); - ActuallyAdditionsAPI.LIQUID_FUEL_RECIPES.clear(); ActuallyAdditionsAPI.LIQUID_FUEL_RECIPES.addAll(recipeManager.getAllRecipesFor(ActuallyRecipes.Types.LIQUID_FUEL.get())); diff --git a/src/main/resources/assets/actuallyadditions/lang/en_us.json b/src/main/resources/assets/actuallyadditions/lang/en_us.json index f041e69b8..53b14d24c 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_us.json +++ b/src/main/resources/assets/actuallyadditions/lang/en_us.json @@ -443,6 +443,7 @@ "tooltip.actuallyadditions.item_filling_wand.selected_block.none": "None", "tooltip.actuallyadditions.coffeeCup.noEffect": "No Effects", "tooltip.actuallyadditions.item_tag.no_tag": "Use Anvil to set tag.", + "tooltip.actuallyadditions.coal_generator_stats": "Generates %d CF (%d CF/t for %d ticks)", "tooltip.actuallyadditions.placer_augment": "Placing blocks from hotbar slot %d", "_comment": "Gui Information", "info.actuallyadditions.gui.animals": "Animals",