Ferment that oil...

This commit is contained in:
Flanks255 2022-01-15 12:38:00 -06:00
parent 20a5dc1712
commit 4cfef87a60
11 changed files with 339 additions and 76 deletions

View file

@ -759,6 +759,7 @@ e4d34fc15b29b452172b3c89b989570de83e20cc data/actuallyadditions/recipes/ethetic_
c5ef6af5b4a1c108a1995e29f4889df68e4b1ee5 data/actuallyadditions/recipes/ethetic_white_stairs.json
1b15143d70ee7861ef1097e153b7d5713f7ed72a data/actuallyadditions/recipes/ethetic_white_wall.json
2d997a2f34d94b7199793d603e22d9b0421b3df9 data/actuallyadditions/recipes/farmer.json
de7aabbafa4ce535079baed363c8828bc4efbff3 data/actuallyadditions/recipes/fermenting/refined_canola.json
255265eb6b031195d086e58ea91c3a2d5e22f9f1 data/actuallyadditions/recipes/filter.json
6ed420df34b5b17fcef2ad2c3f4fb4ed35bf739d data/actuallyadditions/recipes/firework_box.json
7faeab31bd3d1e7a935a3f36d82cdd54466a72e4 data/actuallyadditions/recipes/gold_aiot.json

View file

@ -0,0 +1,12 @@
{
"type": "actuallyadditions:fermenting",
"ingredient": {
"fluid": "actuallyadditions:canola_oil",
"amount": 80
},
"result": {
"fluid": "actuallyadditions:refined_canola_oil",
"amount": 80
},
"time": 100
}

View file

@ -19,10 +19,7 @@ import de.ellpeck.actuallyadditions.api.laser.ILaserRelayConnectionHandler;
import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
import de.ellpeck.actuallyadditions.api.recipe.*;
import de.ellpeck.actuallyadditions.mod.crafting.CrushingRecipe;
import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe;
import de.ellpeck.actuallyadditions.mod.crafting.PressingRecipe;
import de.ellpeck.actuallyadditions.mod.crafting.SolidFuelRecipe;
import de.ellpeck.actuallyadditions.mod.crafting.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.Item;
@ -50,6 +47,7 @@ public final class ActuallyAdditionsAPI {
public static final List<SolidFuelRecipe> SOLID_FUEL_RECIPES = new ArrayList<>();
public static final List<PressingRecipe> PRESSING_RECIPES = new ArrayList<>();
public static final List<FermentingRecipe> FERMENTING_RECIPES = new ArrayList<>();
/**
* Farmer behaviors are sorted when first accessed, this will not be done until after loading, but do not add behaviors at runtime.
*/

View file

@ -2,6 +2,7 @@ package de.ellpeck.actuallyadditions.data;
import com.google.gson.JsonObject;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.crafting.FermentingRecipe;
import de.ellpeck.actuallyadditions.mod.crafting.PressingRecipe;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
@ -31,6 +32,9 @@ public class MiscMachineRecipeGenerator extends RecipeProvider {
protected void buildShapelessRecipes(Consumer<IFinishedRecipe> consumer) {
consumer.accept(new PressingRecipe.FinishedRecipe(folderRecipe("pressing", "canola"),
Ingredient.of(ActuallyItems.CANOLA.get()), new FluidStack(InitFluids.CANOLA_OIL.get(), 80)));
consumer.accept(new FermentingRecipe.FinishedRecipe(folderRecipe("fermenting", "refined_canola"),
new FluidStack(InitFluids.CANOLA_OIL.get(), 80), new FluidStack(InitFluids.REFINED_CANOLA_OIL.get(), 80), 100));
}
private ResourceLocation folderRecipe(String folder, String recipe) {

View file

@ -11,14 +11,20 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFermentingBarrel;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
@ -26,6 +32,10 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fml.network.NetworkHooks;
import javax.annotation.Nullable;
public class BlockFermentingBarrel extends BlockContainerBase {
@ -33,23 +43,31 @@ public class BlockFermentingBarrel extends BlockContainerBase {
super(Properties.of(Material.WOOD).harvestTool(ToolType.AXE).harvestLevel(0).strength(0.5F, 5.0F).sound(SoundType.WOOD));
}
//@Override
public TileEntity newBlockEntity(IBlockReader worldIn) {
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new TileEntityFermentingBarrel();
}
@Override
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
if (!world.isClientSide) {
TileEntityFermentingBarrel press = (TileEntityFermentingBarrel) world.getBlockEntity(pos);
if (press != null) {
/* if (!this.tryUseItemOnTank(player, hand, press.tanks.canolaTank) && !this.tryUseItemOnTank(player, hand, press.tanks.oilTank)) {
NetworkHooks.openGui((ServerPlayerEntity) player, press, pos);
public boolean hasTileEntity(BlockState state) {
return true;
}
*/
}
return ActionResultType.PASS;
@Override
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
TileEntityFermentingBarrel tile = (TileEntityFermentingBarrel) world.getBlockEntity(pos);
if (tile == null)
return ActionResultType.PASS; //TODO this logic all needs to be rechecked...
if (world.isClientSide)
return ActionResultType.SUCCESS;
if (!player.isShiftKeyDown()) {
if (FluidUtil.interactWithFluidHandler(player, hand, tile.tanks)) {
ItemStack stack = player.getItemInHand(hand);
world.playSound(null, pos, stack.getItem() == Items.BUCKET ? SoundEvents.BUCKET_EMPTY:SoundEvents.BUCKET_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
} else
NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
return ActionResultType.SUCCESS;
}
return ActionResultType.PASS;
}

View file

@ -21,6 +21,7 @@ public class ActuallyRecipes {
public static final RegistryObject<IRecipeSerializer<?>> CRUSHING_RECIPE = SERIALIZERS.register(CrushingRecipe.NAME, CrushingRecipe.Serializer::new);
public static final RegistryObject<IRecipeSerializer<?>> SOLID_FUEL_RECIPE = SERIALIZERS.register(SolidFuelRecipe.NAME, SolidFuelRecipe.Serializer::new);
public static final RegistryObject<IRecipeSerializer<?>> PRESSING_RECIPE = SERIALIZERS.register(PressingRecipe.NAME, PressingRecipe.Serializer::new);
public static final RegistryObject<IRecipeSerializer<?>> FERMENTING_RECIPE = SERIALIZERS.register(FermentingRecipe.NAME, FermentingRecipe.Serializer::new);
@ -31,6 +32,6 @@ public class ActuallyRecipes {
public static final IRecipeType<SolidFuelRecipe> SOLID_FUEL = IRecipeType.register(ActuallyAdditions.MODID + ":solid_fuel");
//public static final IRecipeType<LiquidFuelRecipe> LIQUIDFUEL = IRecipeType.register(ActuallyAdditions.MODID + ":liquid_fuel");
public static final IRecipeType<PressingRecipe> PRESSING = IRecipeType.register(ActuallyAdditions.MODID + ":pressing");
//public static final IRecipeType<FermentingRecipe> FERMENTING = IRecipeType.register(ActuallyAdditions.MODID + ":fermenting");
public static final IRecipeType<FermentingRecipe> FERMENTING = IRecipeType.register(ActuallyAdditions.MODID + ":fermenting");
}
}

View file

@ -0,0 +1,199 @@
package de.ellpeck.actuallyadditions.mod.crafting;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import net.minecraft.data.IFinishedRecipe;
import net.minecraft.fluid.Fluid;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.ForgeRegistryEntry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class FermentingRecipe implements IRecipe<IInventory> {
public static final String NAME = "fermenting";
private final ResourceLocation ID;
private final FluidStack input;
private final FluidStack output;
private int time;
public FermentingRecipe(ResourceLocation ID, FluidStack input, FluidStack output, int timeIn) {
this.ID = ID;
this.input = input;
this.output = output;
this.time = timeIn;
}
public boolean matches(FluidStack stack) {
return stack.isFluidEqual(this.input);
}
public boolean matches(FluidStack input, FluidStack output) {
return input.isFluidEqual(this.input) && (output.isEmpty() || output.isFluidEqual(this.output) && input.getAmount() >= this.input.getAmount());
}
public int getTime() {
return this.time;
}
public FluidStack getOutput() {
return output;
}
public FluidStack getInput() {
return input;
}
@Override
public boolean matches(IInventory pInv, World pLevel) {
return false;
}
@Override
public ItemStack assemble(IInventory pInv) {
return ItemStack.EMPTY;
}
@Override
public boolean canCraftInDimensions(int pWidth, int pHeight) {
return false;
}
@Override
public ItemStack getResultItem() {
return ItemStack.EMPTY;
}
@Override
public ResourceLocation getId() {
return ID;
}
@Override
public IRecipeSerializer<?> getSerializer() {
return ActuallyRecipes.FERMENTING_RECIPE.get();
}
@Override
public IRecipeType<?> getType() {
return ActuallyRecipes.Types.FERMENTING;
}
public static class Serializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<FermentingRecipe> {
@Nonnull
@Override
public FermentingRecipe fromJson(@Nonnull ResourceLocation pRecipeId, @Nonnull JsonObject pJson) {
JsonObject ingredient = pJson.getAsJsonObject("ingredient");
ResourceLocation fluidRes = new ResourceLocation(JSONUtils.getAsString(ingredient, "fluid"));
Fluid fluid = ForgeRegistries.FLUIDS.getValue(fluidRes);
if (fluid == null)
throw new JsonParseException("Unknown fluid '" + fluidRes + "'");
int inputAmount = JSONUtils.getAsInt(ingredient, "amount", 80);
FluidStack input = new FluidStack(fluid, inputAmount);
JsonObject result = pJson.getAsJsonObject("result");
ResourceLocation fluidOutputRes = new ResourceLocation(JSONUtils.getAsString(result, "fluid"));
int outputAmount = JSONUtils.getAsInt(result, "amount");
Fluid fluidOutput = ForgeRegistries.FLUIDS.getValue(fluidOutputRes);
if(fluidOutput == null)
throw new JsonParseException("Unknown fluid '" + fluidRes + "'");
FluidStack output = new FluidStack(fluidOutput, outputAmount);
int time = JSONUtils.getAsInt(pJson, "time", 100);
return new FermentingRecipe(pRecipeId, input, output, time);
}
@Nullable
@Override
public FermentingRecipe fromNetwork(@Nonnull ResourceLocation pRecipeId, @Nonnull PacketBuffer pBuffer) {
ResourceLocation inputRes = new ResourceLocation(pBuffer.readUtf());
int inputAmount = pBuffer.readInt();
Fluid inputFluid = ForgeRegistries.FLUIDS.getValue(inputRes);
if(inputFluid == null)
throw new JsonParseException("Unknown input fluid '" + inputRes + "'");
FluidStack input = new FluidStack(inputFluid, inputAmount);
ResourceLocation outputRes = new ResourceLocation(pBuffer.readUtf());
int outputAmount = pBuffer.readInt();
Fluid outputFluid = ForgeRegistries.FLUIDS.getValue(outputRes);
if(outputFluid == null)
throw new JsonParseException("Unknown output fluid '" + outputRes + "'");
FluidStack output = new FluidStack(outputFluid, outputAmount);
int time = pBuffer.readInt();
return new FermentingRecipe(pRecipeId, input, output, time);
}
@Override
public void toNetwork(@Nonnull PacketBuffer pBuffer, @Nonnull FermentingRecipe pRecipe) {
pBuffer.writeUtf(pRecipe.input.getFluid().getRegistryName().toString());
pBuffer.writeInt(pRecipe.input.getAmount());
pBuffer.writeUtf(pRecipe.output.getFluid().getRegistryName().toString());
pBuffer.writeInt(pRecipe.output.getAmount());
pBuffer.writeInt(pRecipe.time);
}
}
public static class FinishedRecipe implements IFinishedRecipe {
private final ResourceLocation ID;
private final FluidStack input;
private final FluidStack output;
private final int time;
public FinishedRecipe(ResourceLocation ID, FluidStack input, FluidStack output, int timeIn) {
this.ID = ID;
this.input = input;
this.output = output;
this.time = timeIn;
}
@Override
public void serializeRecipeData(JsonObject pJson) {
JsonObject ingredient = new JsonObject();
ingredient.addProperty("fluid", input.getFluid().getRegistryName().toString());
ingredient.addProperty("amount", input.getAmount());
JsonObject result = new JsonObject();
result.addProperty("fluid", output.getFluid().getRegistryName().toString());
result.addProperty("amount", output.getAmount());
pJson.add("ingredient", ingredient);
pJson.add("result", result);
pJson.addProperty("time", time);
}
@Override
public ResourceLocation getId() {
return ID;
}
@Override
public IRecipeSerializer<?> getType() {
return ActuallyRecipes.FERMENTING_RECIPE.get();
}
@Nullable
@Override
public JsonObject serializeAdvancement() {
return null;
}
@Nullable
@Override
public ResourceLocation getAdvancementId() {
return null;
}
}
}

View file

@ -49,13 +49,11 @@ public class GuiFermentingBarrel extends AAScreen<ContainerFermentingBarrel> {
@Override
public void init() {
super.init();
this.input = new FluidDisplay(this.leftPos + 60, this.topPos + 5, this.press.tanks.canolaTank);
this.output = new FluidDisplay(this.leftPos + 98, this.topPos + 5, this.press.tanks.oilTank);
}
this.input = new FluidDisplay(this.leftPos + 60, this.topPos + 5, this.press.tanks.inputTank);
this.output = new FluidDisplay(this.leftPos + 98, this.topPos + 5, this.press.tanks.outputTank);
@Override
public void renderLabels(@Nonnull MatrixStack matrices, int x, int y) {
AssetUtil.displayNameString(matrices, this.font, this.imageWidth, -10, this.press);
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
titleLabelY = -10;
}
@Override

View file

@ -10,8 +10,9 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.crafting.FermentingRecipe;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFermentingBarrel;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
@ -20,7 +21,7 @@ import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.Direction;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.util.LazyOptional;
@ -31,19 +32,18 @@ import net.minecraftforge.fluids.capability.templates.FluidTank;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Optional;
public class TileEntityFermentingBarrel extends TileEntityBase implements ISharingFluidHandler, INamedContainerProvider {
private static final int PROCESS_TIME = 100;
public final FermentingBarrelMultiTank tanks = new FermentingBarrelMultiTank();
public final LazyOptional<IFluidHandler> fluidOptional = LazyOptional.of(()->tanks);
public int currentProcessTime;
private int lastCanola;
private int lastOil;
private int lastInput;
private int lastOutput;
private int lastProcessTime;
private int lastCompare;
private FermentingRecipe currentRecipe;
public TileEntityFermentingBarrel() {
super(ActuallyBlocks.FERMENTING_BARREL.getTileEntityType());
@ -53,6 +53,8 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari
public void writeSyncableNBT(CompoundNBT compound, NBTType type) {
compound.putInt("ProcessTime", this.currentProcessTime);
compound.put("tanks", tanks.writeNBT());
if (currentRecipe != null)
compound.putString("currentRecipe", currentRecipe.getId().toString());
super.writeSyncableNBT(compound, type);
}
@ -60,7 +62,10 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari
public void readSyncableNBT(CompoundNBT compound, NBTType type) {
this.currentProcessTime = compound.getInt("ProcessTime");
if (compound.contains("tanks")) {
//TODO read
tanks.readNBT(compound.getCompound("tanks"));
}
if (compound.contains("currentRecipe")) {
this.currentRecipe = ActuallyAdditionsAPI.FERMENTING_RECIPES.stream().filter(recipe -> recipe.getId().toString().equals(compound.getString("currentRecipe"))).findFirst().orElse(null);
}
super.readSyncableNBT(compound, type);
}
@ -68,20 +73,29 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari
@Override
public void updateEntity() {
super.updateEntity();
if (!this.level.isClientSide) {
int produce = 80;
if (this.tanks.getFluidInTank(0).getAmount() >= produce && produce <= this.tanks.getTankCapacity(1) - this.tanks.getFluidInTank(1).getAmount()) {
if (this.level.isClientSide)
return;
if (currentRecipe == null) {
this.currentRecipe = ActuallyAdditionsAPI.FERMENTING_RECIPES.stream().filter(recipe -> recipe.matches(this.tanks.getFluidInTank(0), this.tanks.getFluidInTank(1))).findFirst().orElse(null);
} else {
if (this.tanks.getFluidInTank(0).getAmount() >= currentRecipe.getInput().getAmount() &&
this.tanks.getFluidInTank(0).getFluid().isSame(currentRecipe.getInput().getFluid()) &&
(this.tanks.getFluidInTank(1).getFluid().isSame(currentRecipe.getOutput().getFluid()) || tanks.getFluidInTank(1).isEmpty()) &&
currentRecipe.getOutput().getAmount() <= this.tanks.getTankCapacity(1) - this.tanks.getFluidInTank(1).getAmount()) {
this.currentProcessTime++;
if (this.currentProcessTime >= PROCESS_TIME) {
if (this.currentProcessTime >= currentRecipe.getTime()) {
this.currentProcessTime = 0;
this.tanks.oilTank.getFluid().grow(produce);
this.tanks.canolaTank.getFluid().shrink(produce);
this.tanks.outputTank.fill(currentRecipe.getOutput().copy(), IFluidHandler.FluidAction.EXECUTE);
this.tanks.inputTank.getFluid().shrink(currentRecipe.getInput().getAmount());
}
} else {
this.currentProcessTime = 0;
currentRecipe = null;
}
}
int compare = this.getComparatorStrength();
if (compare != this.lastCompare) {
this.lastCompare = compare;
@ -89,11 +103,10 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari
this.setChanged();
}
if ((this.tanks.getFluidInTank(0).getAmount() != this.lastCanola || this.tanks.getFluidInTank(1).getAmount() != this.lastOil || this.currentProcessTime != this.lastProcessTime) && this.sendUpdateWithInterval()) {
if ((this.tanks.getFluidInTank(0).getAmount() != this.lastInput || this.tanks.getFluidInTank(1).getAmount() != this.lastOutput || this.currentProcessTime != this.lastProcessTime) && this.sendUpdateWithInterval()) {
this.lastProcessTime = this.currentProcessTime;
this.lastCanola = this.tanks.getFluidInTank(0).getAmount();
this.lastOil = this.tanks.getFluidInTank(1).getAmount();
}
this.lastInput = this.tanks.getFluidInTank(0).getAmount();
this.lastOutput = this.tanks.getFluidInTank(1).getAmount();
}
}
@ -105,7 +118,10 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari
@OnlyIn(Dist.CLIENT)
public int getProcessScaled(int i) {
return this.currentProcessTime * i / PROCESS_TIME;
if (currentRecipe != null)
return this.currentProcessTime * i / currentRecipe.getTime();
else
return this.currentProcessTime * i / 100;
}
@OnlyIn(Dist.CLIENT)
@ -140,7 +156,7 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari
@Override
public ITextComponent getDisplayName() {
return StringTextComponent.EMPTY;
return new TranslationTextComponent("container.actuallyadditions.fermenting_barrel");
}
@Nullable
@ -149,12 +165,20 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari
return new ContainerFermentingBarrel(windowId, playerInventory, this);
}
public static boolean validInput(FluidStack stack) {
return getRecipeForInput(stack).isPresent();
}
public static Optional<FermentingRecipe> getRecipeForInput(FluidStack stack) {
return ActuallyAdditionsAPI.FERMENTING_RECIPES.stream().filter(recipe -> recipe.matches(stack)).findFirst();
}
public class FermentingBarrelMultiTank implements IFluidHandler {
private int capacity = FluidAttributes.BUCKET_VOLUME * 2;
public FluidTank canolaTank = new FluidTank(capacity);
public FluidTank oilTank = new FluidTank(capacity);
public FluidTank inputTank = new FluidTank(capacity);
public FluidTank outputTank = new FluidTank(capacity);
@Override
public int getTanks() {
@ -164,7 +188,7 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari
@Nonnull
@Override
public FluidStack getFluidInTank(int tank) {
return tank == 0 ? canolaTank.getFluid() : oilTank.getFluid();
return tank == 0 ? inputTank.getFluid() : outputTank.getFluid();
}
@Override
@ -174,35 +198,35 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari
@Override
public boolean isFluidValid(int tank, @Nonnull FluidStack stack) {
return tank == 0? stack.getFluid() == InitFluids.CANOLA_OIL.get():stack.getFluid() == InitFluids.REFINED_CANOLA_OIL.get();
return tank == 0 && TileEntityFermentingBarrel.validInput(stack);
}
@Override
public int fill(FluidStack resource, FluidAction action) {
if (resource.isEmpty() || resource.getFluid() != InitFluids.CANOLA_OIL.get())
if (resource.isEmpty() || !validInput(resource))
return 0;
if(action.simulate())
{
if (canolaTank.isEmpty())
if (inputTank.isEmpty())
return Math.min(capacity, resource.getAmount());
else
return Math.min(capacity - canolaTank.getFluid().getAmount(), resource.getAmount());
return Math.min(capacity - inputTank.getFluid().getAmount(), resource.getAmount());
}
else {
if (canolaTank.isEmpty()) {
canolaTank.fill(new FluidStack(resource, Math.min(capacity, resource.getAmount())), FluidAction.EXECUTE);
if (inputTank.isEmpty()) {
inputTank.fill(new FluidStack(resource, Math.min(capacity, resource.getAmount())), FluidAction.EXECUTE);
//TODO need to set the BE dirty.
return canolaTank.getFluid().getAmount();
return inputTank.getFluid().getAmount();
}
else {
int filledAmt = capacity - canolaTank.getFluid().getAmount();
int filledAmt = capacity - inputTank.getFluid().getAmount();
if (resource.getAmount() < filledAmt) {
canolaTank.getFluid().grow(resource.getAmount());
inputTank.getFluid().grow(resource.getAmount());
filledAmt = resource.getAmount();
}
else
canolaTank.getFluid().setAmount(capacity);
inputTank.getFluid().setAmount(capacity);
if (filledAmt > 0){
//TODO set BE dirty
@ -213,21 +237,26 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari
}
public CompoundNBT writeNBT() {
CompoundNBT canolaNBT = new CompoundNBT();
canolaTank.writeToNBT(canolaNBT);
CompoundNBT oilNBT = new CompoundNBT();
oilTank.writeToNBT(oilNBT);
CompoundNBT inputNBT = new CompoundNBT();
inputTank.writeToNBT(inputNBT);
CompoundNBT outputNBT = new CompoundNBT();
outputTank.writeToNBT(outputNBT);
CompoundNBT nbt = new CompoundNBT();
nbt.put("canolaTank", canolaNBT);
nbt.put("oilTank", oilNBT);
nbt.put("inputTank", inputNBT);
nbt.put("outputTank", outputNBT);
return nbt;
}
public void readNBT(CompoundNBT nbt) {
inputTank.readFromNBT(nbt.getCompound("inputTank"));
outputTank.readFromNBT(nbt.getCompound("outputTank"));
}
@Nonnull
@Override
public FluidStack drain(FluidStack resource, FluidAction action) {
if (resource.isEmpty() || resource.getFluid() != InitFluids.REFINED_CANOLA_OIL.get())
if (resource.isEmpty() || resource.getFluid() != outputTank.getFluid().getFluid())
return FluidStack.EMPTY;
return drain(resource.getAmount(), action);
@ -237,14 +266,14 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari
@Override
public FluidStack drain(int maxDrain, FluidAction action) {
int drained = maxDrain;
if (oilTank.getFluid().getAmount() < drained)
if (outputTank.getFluid().getAmount() < drained)
{
drained = oilTank.getFluid().getAmount();
drained = outputTank.getFluid().getAmount();
}
FluidStack stack = new FluidStack(oilTank.getFluid(), drained);
FluidStack stack = new FluidStack(outputTank.getFluid(), drained);
if (action.execute() && drained > 0)
{
oilTank.getFluid().shrink(drained);
outputTank.getFluid().shrink(drained);
//TODO set BE dirty
}
return stack;

View file

@ -26,5 +26,8 @@ public class ResourceReloader implements IResourceManagerReloadListener {
ActuallyAdditionsAPI.PRESSING_RECIPES.clear();
ActuallyAdditionsAPI.PRESSING_RECIPES.addAll(recipeManager.getAllRecipesFor(ActuallyRecipes.Types.PRESSING));
ActuallyAdditionsAPI.FERMENTING_RECIPES.clear();
ActuallyAdditionsAPI.FERMENTING_RECIPES.addAll(recipeManager.getAllRecipesFor(ActuallyRecipes.Types.FERMENTING));
}
}

View file

@ -643,7 +643,7 @@
"container.actuallyadditions.dropper": "Precision Dropper",
"container.actuallyadditions.crafting": "Crafting Table On A Stick",
"container.actuallyadditions.canola_press": "Canola Press",
"container.actuallyadditions.fermentingBarrel": "Fermenting Barrel",
"container.actuallyadditions.fermenting_barrel": "Fermenting Barrel",
"container.actuallyadditions.coalGenerator": "Coal Generator",
"container.actuallyadditions.oilGenerator": "Oil Generator",
"container.actuallyadditions.phantomPlacer": "Phantom Placer",