mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 11:29:23 +01:00
Removed SolidFuelRecipe.java, migrated Coal generators to use any burnable item. Closes #1435
This commit is contained in:
parent
77c29a6b74
commit
d5757a1453
17 changed files with 41 additions and 266 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"type": "actuallyadditions:solid_fuel",
|
||||
"burn_time": 1600,
|
||||
"item": {
|
||||
"item": "minecraft:charcoal"
|
||||
},
|
||||
"total_energy": 32000
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"type": "actuallyadditions:solid_fuel",
|
||||
"burn_time": 16000,
|
||||
"item": {
|
||||
"tag": "c:storage_blocks/coal"
|
||||
},
|
||||
"total_energy": 320000
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"type": "actuallyadditions:solid_fuel",
|
||||
"burn_time": 1600,
|
||||
"item": {
|
||||
"item": "minecraft:coal"
|
||||
},
|
||||
"total_energy": 32000
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"type": "actuallyadditions:solid_fuel",
|
||||
"burn_time": 20000,
|
||||
"item": {
|
||||
"item": "minecraft:lava_bucket"
|
||||
},
|
||||
"total_energy": 400000
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"type": "actuallyadditions:solid_fuel",
|
||||
"burn_time": 100,
|
||||
"item": {
|
||||
"item": "minecraft:stick"
|
||||
},
|
||||
"total_energy": 2000
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"type": "actuallyadditions:solid_fuel",
|
||||
"burn_time": 200,
|
||||
"item": {
|
||||
"tag": "actuallyadditions:tiny_coals"
|
||||
},
|
||||
"total_energy": 4000
|
||||
}
|
|
@ -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<RecipeHolder<CrushingRecipe>> CRUSHER_RECIPES = new ArrayList<>();
|
||||
public static final List<RecipeHolder<EmpowererRecipe>> EMPOWERER_RECIPES = new ArrayList<>();
|
||||
public static final List<RecipeHolder<ColorChangeRecipe>> COLOR_CHANGE_RECIPES = new ArrayList<>();
|
||||
public static final List<RecipeHolder<SolidFuelRecipe>> SOLID_FUEL_RECIPES = new ArrayList<>();
|
||||
public static final List<RecipeHolder<LiquidFuelRecipe>> LIQUID_FUEL_RECIPES = new ArrayList<>();
|
||||
public static final List<RecipeHolder<PressingRecipe>> PRESSING_RECIPES = new ArrayList<>();
|
||||
public static final List<RecipeHolder<FermentingRecipe>> FERMENTING_RECIPES = new ArrayList<>();
|
||||
|
|
|
@ -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<Item> tag, int energy, int burnTime) {
|
||||
ResourceLocation id = ActuallyAdditions.modLoc("solid_fuel/"+name);
|
||||
consumer.accept(id, new SolidFuelRecipe(Ingredient.of(tag), energy, burnTime), null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ public class ActuallyRecipes {
|
|||
public static final Supplier<RecipeSerializer<?>> LASER_RECIPE = SERIALIZERS.register(LaserRecipe.NAME, LaserRecipe.Serializer::new);
|
||||
public static final Supplier<RecipeSerializer<?>> EMPOWERING_RECIPE = SERIALIZERS.register(EmpowererRecipe.NAME, EmpowererRecipe.Serializer::new);
|
||||
public static final Supplier<RecipeSerializer<?>> CRUSHING_RECIPE = SERIALIZERS.register(CrushingRecipe.NAME, CrushingRecipe.Serializer::new);
|
||||
public static final Supplier<RecipeSerializer<?>> SOLID_FUEL_RECIPE = SERIALIZERS.register(SolidFuelRecipe.NAME, SolidFuelRecipe.Serializer::new);
|
||||
public static final Supplier<RecipeSerializer<?>> LIQUID_FUEL_RECIPE = SERIALIZERS.register(LiquidFuelRecipe.NAME, LiquidFuelRecipe.Serializer::new);
|
||||
public static final Supplier<RecipeSerializer<?>> PRESSING_RECIPE = SERIALIZERS.register(PressingRecipe.NAME, PressingRecipe.Serializer::new);
|
||||
public static final Supplier<RecipeSerializer<?>> FERMENTING_RECIPE = SERIALIZERS.register(FermentingRecipe.NAME, FermentingRecipe.Serializer::new);
|
||||
|
@ -41,7 +40,6 @@ public class ActuallyRecipes {
|
|||
public static final Supplier<RecipeType<LaserRecipe>> LASER = RECIPE_TYPES.register("laser", RecipeType::simple);
|
||||
public static final Supplier<RecipeType<EmpowererRecipe>> EMPOWERING = RECIPE_TYPES.register("empower", RecipeType::simple);
|
||||
public static final Supplier<RecipeType<CrushingRecipe>> CRUSHING = RECIPE_TYPES.register("crushing", RecipeType::simple);
|
||||
public static final Supplier<RecipeType<SolidFuelRecipe>> SOLID_FUEL = RECIPE_TYPES.register("solid_fuel", RecipeType::simple);
|
||||
public static final Supplier<RecipeType<LiquidFuelRecipe>> LIQUID_FUEL = RECIPE_TYPES.register("liquid_fuel", RecipeType::simple);
|
||||
public static final Supplier<RecipeType<PressingRecipe>> PRESSING = RECIPE_TYPES.register("pressing", RecipeType::simple);
|
||||
public static final Supplier<RecipeType<FermentingRecipe>> FERMENTING = RECIPE_TYPES.register("fermenting", RecipeType::simple);
|
||||
|
|
|
@ -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<SingleRecipeInput> {
|
||||
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<SolidFuelRecipe> {
|
||||
private static final MapCodec<SolidFuelRecipe> 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<RegistryFriendlyByteBuf, SolidFuelRecipe> STREAM_CODEC = StreamCodec.of(
|
||||
SolidFuelRecipe.Serializer::toNetwork, SolidFuelRecipe.Serializer::fromNetwork
|
||||
);
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public MapCodec<SolidFuelRecipe> codec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public StreamCodec<RegistryFriendlyByteBuf, SolidFuelRecipe> 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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<ContainerCoalGenerator> {
|
||||
|
@ -63,4 +67,20 @@ public class GuiCoalGenerator extends AAScreen<ContainerCoalGenerator> {
|
|||
|
||||
this.energy.draw(guiGraphics);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected List<Component> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<SolidFuelRecipe> 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<SolidFuelRecipe> 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<SolidFuelRecipe> 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;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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()));
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue