mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-20 20:22:35 +00:00
Refactor Distillery
This commit is contained in:
1 parent
e5f01e82a2
commit
1d96c9d349
12 files changed
+288
-276
No files matched your search
@@ -36,14 +36,12 @@ public class Machine implements INetworkedEntity, INbtReadable, INbtWritable, IN
|
||||
private Map<Class<? extends MachineComponent>, MachineComponent> componentMap;
|
||||
private TileEntity tile;
|
||||
private boolean queuedInventoryUpdate;
|
||||
private int nextProgressBarID;
|
||||
private GameProfile owner;
|
||||
|
||||
public Machine(final MachinePackage pack, final TileEntity tile) {
|
||||
this.componentInterfaceMap = new LinkedHashMap<>();
|
||||
this.componentMap = new LinkedHashMap<>();
|
||||
this.queuedInventoryUpdate = false;
|
||||
this.nextProgressBarID = 0;
|
||||
this.owner = null;
|
||||
this.tile = tile;
|
||||
pack.createMachine(this);
|
||||
@@ -248,10 +246,6 @@ public class Machine implements INetworkedEntity, INbtReadable, INbtWritable, IN
|
||||
}
|
||||
}
|
||||
|
||||
public int getUniqueProgressBarID() {
|
||||
return this.nextProgressBarID++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile getOwner() {
|
||||
return this.owner;
|
||||
|
||||
+11
-11
@@ -12,22 +12,22 @@ import binnie.craftgui.minecraft.control.ControlProgressBase;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
import binnie.extratrees.machines.Distillery;
|
||||
import binnie.extratrees.machines.distillery.DistilleryLogic;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ControlDistilleryProgress extends ControlProgressBase {
|
||||
static Texture DistilleryBase = new StandardTexture(43, 0, 58, 66, ExtraTreeTexture.Gui);
|
||||
static Texture DistilleryOverlay = new StandardTexture(139, 0, 18, 66, ExtraTreeTexture.Gui);
|
||||
static Texture LiquidFlow = new StandardTexture(101, 0, 38, 66, ExtraTreeTexture.Gui);
|
||||
static Texture Output = new StandardTexture(68, 66, 17, 7, ExtraTreeTexture.Gui);
|
||||
public static final Texture DISTILLERY_BASE = new StandardTexture(43, 0, 58, 66, ExtraTreeTexture.Gui);
|
||||
public static final Texture DISTILLERY_OVERLAY = new StandardTexture(139, 0, 18, 66, ExtraTreeTexture.Gui);
|
||||
public static final Texture LIQUID_FLOW = new StandardTexture(101, 0, 38, 66, ExtraTreeTexture.Gui);
|
||||
public static final Texture OUTPUT = new StandardTexture(68, 66, 17, 7, ExtraTreeTexture.Gui);
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.texture(ControlDistilleryProgress.DistilleryBase, new IPoint(0.0f, 0.0f));
|
||||
CraftGUI.Render.texturePercentage(ControlDistilleryProgress.LiquidFlow, new IArea(18.0f, 0.0f, 38.0f, 66.0f), Position.Left, this.progress);
|
||||
final Distillery.ComponentDistilleryLogic component = Machine.getInterface(Distillery.ComponentDistilleryLogic.class, Window.get(this).getInventory());
|
||||
CraftGUI.Render.texture(DISTILLERY_BASE, new IPoint(0.0f, 0.0f));
|
||||
CraftGUI.Render.texturePercentage(LIQUID_FLOW, new IArea(18.0f, 0.0f, 38.0f, 66.0f), Position.Left, this.progress);
|
||||
final DistilleryLogic component = Machine.getInterface(DistilleryLogic.class, Window.get(this).getInventory());
|
||||
FluidStack stack = null;
|
||||
if (component != null) {
|
||||
stack = component.currentFluid;
|
||||
@@ -41,11 +41,11 @@ public class ControlDistilleryProgress extends ControlProgressBase {
|
||||
|
||||
@Override
|
||||
public void onRenderForeground() {
|
||||
Distillery.ComponentDistilleryLogic distilleryLogic = Machine.getInterface(Distillery.ComponentDistilleryLogic.class, Window.get(this).getInventory());
|
||||
DistilleryLogic distilleryLogic = Machine.getInterface(DistilleryLogic.class, Window.get(this).getInventory());
|
||||
if (distilleryLogic != null) {
|
||||
final int level = distilleryLogic.level;
|
||||
CraftGUI.Render.texture(ControlDistilleryProgress.Output, new IPoint(47.0f, 14 + level * 15));
|
||||
CraftGUI.Render.texture(ControlDistilleryProgress.DistilleryOverlay, new IPoint(0.0f, 0.0f));
|
||||
CraftGUI.Render.texture(OUTPUT, new IPoint(47.0f, 14 + level * 15));
|
||||
CraftGUI.Render.texture(DISTILLERY_OVERLAY, new IPoint(0.0f, 0.0f));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import binnie.craftgui.minecraft.control.ControlErrorState;
|
||||
import binnie.craftgui.minecraft.control.ControlLiquidTank;
|
||||
import binnie.craftgui.minecraft.control.ControlPlayerInventory;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.machines.Distillery;
|
||||
import binnie.extratrees.machines.distillery.DistilleryMachine;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -33,11 +33,11 @@ public class WindowDistillery extends Window {
|
||||
public void initialiseClient() {
|
||||
this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName());
|
||||
int x = 16;
|
||||
new ControlLiquidTank(this, x, 35).setTankID(Distillery.tankInput);
|
||||
new ControlLiquidTank(this, x, 35).setTankID(DistilleryMachine.TANK_INPUT);
|
||||
x += 34;
|
||||
new ControlDistilleryProgress(this, x, 32.0f);
|
||||
x += 64;
|
||||
new ControlLiquidTank(this, x, 35).setTankID(Distillery.tankOutput);
|
||||
new ControlLiquidTank(this, x, 35).setTankID(DistilleryMachine.TANK_OUTPUT);
|
||||
x += 34;
|
||||
new ControlEnergyBar(this, x, 36, 60, 16, Position.Left);
|
||||
new ControlPlayerInventory(this);
|
||||
|
||||
@@ -13,7 +13,7 @@ import binnie.extratrees.item.ExtraTreeItems;
|
||||
import binnie.extratrees.item.Food;
|
||||
import binnie.extratrees.machines.brewery.BrewedGrainRecipe;
|
||||
import binnie.extratrees.machines.brewery.BreweryRecipes;
|
||||
import binnie.extratrees.machines.Distillery;
|
||||
import binnie.extratrees.machines.distillery.DistilleryRecipes;
|
||||
import binnie.extratrees.machines.fruitpress.FruitPressRecipes;
|
||||
import forestry.api.recipes.ISqueezerRecipe;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
@@ -132,12 +132,14 @@ public class ModuleAlcohol implements IInitializable {
|
||||
this.addDistillery(Alcohol.Corn, Spirit.CornWhiskey, Spirit.Vodka, Spirit.NeutralSpirit);
|
||||
}
|
||||
|
||||
private void addDistillery(final IFluidType source, final IFluidType a, final IFluidType b, final IFluidType c) {
|
||||
Distillery.addRecipe(source.get(5), a.get(4), 0);
|
||||
Distillery.addRecipe(source.get(5), b.get(2), 1);
|
||||
Distillery.addRecipe(source.get(5), c.get(1), 2);
|
||||
Distillery.addRecipe(a.get(5), b.get(2), 0);
|
||||
Distillery.addRecipe(a.get(5), b.get(1), 1);
|
||||
Distillery.addRecipe(b.get(5), c.get(2), 0);
|
||||
private void addDistillery(final IFluidType source, final IFluidType singleDistilled, final IFluidType doubleDistilled, final IFluidType tripleDistilled) {
|
||||
DistilleryRecipes.addRecipe(source.get(5), singleDistilled.get(4), 0);
|
||||
DistilleryRecipes.addRecipe(source.get(5), doubleDistilled.get(2), 1);
|
||||
DistilleryRecipes.addRecipe(source.get(5), tripleDistilled.get(1), 2);
|
||||
|
||||
DistilleryRecipes.addRecipe(singleDistilled.get(5), doubleDistilled.get(2), 0);
|
||||
DistilleryRecipes.addRecipe(singleDistilled.get(5), tripleDistilled.get(1), 1);
|
||||
|
||||
DistilleryRecipes.addRecipe(doubleDistilled.get(5), tripleDistilled.get(2), 0);
|
||||
}
|
||||
}
|
||||
@@ -1,243 +0,0 @@
|
||||
package binnie.extratrees.machines;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.MachineSide;
|
||||
import binnie.core.machines.inventory.TankValidator;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
import binnie.extratrees.core.ExtraTreesGUID;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Distillery {
|
||||
public static int tankInput = 0;
|
||||
public static int tankOutput = 1;
|
||||
static List<Map<Fluid, FluidStack>> recipes;
|
||||
|
||||
public static FluidStack getOutput(final FluidStack fluid, final int level) {
|
||||
if (fluid == null) {
|
||||
return null;
|
||||
}
|
||||
return Distillery.recipes.get(level).get(fluid.getFluid());
|
||||
}
|
||||
|
||||
public static boolean isValidInputLiquid(final FluidStack fluid) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (Distillery.recipes.get(i).containsKey(fluid.getFluid())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isValidOutputLiquid(final FluidStack fluid) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (final Map.Entry<Fluid, FluidStack> entry : Distillery.recipes.get(i).entrySet()) {
|
||||
if (entry.getValue().isFluidEqual(fluid)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void addRecipe(final FluidStack input, final FluidStack output, final int level) {
|
||||
Distillery.recipes.get(level).put(input.getFluid(), output);
|
||||
}
|
||||
|
||||
static {
|
||||
(Distillery.recipes = new ArrayList<>()).add(new HashMap<>());
|
||||
Distillery.recipes.add(new HashMap<>());
|
||||
Distillery.recipes.add(new HashMap<>());
|
||||
}
|
||||
|
||||
public static class PackageDistillery extends ExtraTreeMachine.PackageExtraTreeMachine implements IMachineInformation {
|
||||
public PackageDistillery() {
|
||||
super("distillery", ExtraTreeTexture.distilleryTexture, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ExtraTreeMachine.ComponentExtraTreeGUI(machine, ExtraTreesGUID.Distillery);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(Distillery.tankInput, "input", 5000);
|
||||
tanks.getTankSlot(Distillery.tankInput).setValidator(new TankValidatorDistilleryInput());
|
||||
tanks.getTankSlot(Distillery.tankInput).setOutputSides(MachineSide.TopAndBottom);
|
||||
tanks.addTank(Distillery.tankOutput, "output", 5000);
|
||||
tanks.getTankSlot(Distillery.tankOutput).setValidator(new TankValidatorDistilleryOutput());
|
||||
tanks.getTankSlot(Distillery.tankOutput).setReadOnly();
|
||||
tanks.getTankSlot(Distillery.tankOutput).setOutputSides(MachineSide.Sides);
|
||||
new ComponentPowerReceptor(machine);
|
||||
new ComponentDistilleryLogic(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentDistilleryLogic extends ComponentProcessSetCost implements IProcess, INetwork.SendGuiNBT, INetwork.RecieveGuiNBT {
|
||||
public FluidStack currentFluid;
|
||||
public int level;
|
||||
int guiLevel;
|
||||
|
||||
public ComponentDistilleryLogic(final Machine machine) {
|
||||
super(machine, 16000, 800);
|
||||
this.currentFluid = null;
|
||||
this.level = 0;
|
||||
this.guiLevel = machine.getUniqueProgressBarID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEnergyPerTick() {
|
||||
return 2.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
return 2000 + 800 * this.level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.level = nbt.getByte("dlevel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(final NBTTagCompound nbt2) {
|
||||
NBTTagCompound nbt = super.writeToNBT(nbt2);
|
||||
nbt.setByte("dlevel", (byte) this.level);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isTankEmpty(Distillery.tankInput) && this.currentFluid == null) {
|
||||
return new ErrorState.InsufficientLiquid("No Input Liquid", Distillery.tankInput);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (this.currentFluid == null) {
|
||||
return new ErrorState("Distillery Empty", "No liquid in Distillery");
|
||||
}
|
||||
if (!this.getUtil().isTankEmpty(Distillery.tankOutput) && this.getOutput() != null && !this.getOutput().isFluidEqual(this.getUtil().getFluid(Distillery.tankOutput))) {
|
||||
return new ErrorState.Tank("No Room", "No room for liquid", new int[]{Distillery.tankOutput});
|
||||
}
|
||||
if (this.getUtil().getFluid(Distillery.tankOutput) != null && !this.getUtil().getFluid(Distillery.tankOutput).isFluidEqual(Distillery.getOutput(this.getUtil().getFluid(Distillery.tankInput), this.level))) {
|
||||
return new ErrorState.TankSpace("Different fluid in tank", Distillery.tankOutput);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
private FluidStack getOutput() {
|
||||
return Distillery.getOutput(this.getUtil().getFluid(Distillery.tankInput), this.level);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
final FluidStack output = Distillery.getOutput(this.currentFluid, this.level).copy();
|
||||
output.amount = 1000;
|
||||
this.getUtil().fillTank(Distillery.tankOutput, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveGuiNBT(final Side side, final EntityPlayer player, final String name, final NBTTagCompound nbt) {
|
||||
if (name.equals("still-level")) {
|
||||
this.level = nbt.getByte("i");
|
||||
}
|
||||
if (name.equals("still-recipe")) {
|
||||
if (nbt.getBoolean("null")) {
|
||||
this.currentFluid = null;
|
||||
} else {
|
||||
this.currentFluid = FluidStack.loadFluidStackFromNBT(nbt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendGuiNBT(final Map<String, NBTTagCompound> data) {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
if (this.currentFluid == null) {
|
||||
nbt.setBoolean("null", true);
|
||||
} else {
|
||||
this.currentFluid.writeToNBT(nbt);
|
||||
}
|
||||
data.put("still-recipe", nbt);
|
||||
final NBTTagCompound nbt2 = new NBTTagCompound();
|
||||
nbt.setByte("i", (byte) this.level);
|
||||
data.put("still-level", nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
if (this.canWork() == null && this.currentFluid == null && this.getUtil().getTank(Distillery.tankInput).getFluidAmount() >= 1000) {
|
||||
final FluidStack stack = this.getUtil().drainTank(Distillery.tankInput, 1000);
|
||||
this.currentFluid = stack;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
if (this.currentFluid == null) {
|
||||
return "Empty";
|
||||
}
|
||||
return "Creating " + Distillery.getOutput(this.currentFluid, this.level).getFluid().getLocalizedName(this.currentFluid);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TankValidatorDistilleryInput extends TankValidator {
|
||||
@Override
|
||||
public boolean isValid(final FluidStack itemStack) {
|
||||
return Distillery.isValidInputLiquid(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Distillable Liquids";
|
||||
}
|
||||
}
|
||||
|
||||
public static class TankValidatorDistilleryOutput extends TankValidator {
|
||||
@Override
|
||||
public boolean isValid(final FluidStack itemStack) {
|
||||
return Distillery.isValidOutputLiquid(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Distilled Liquids";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import binnie.core.resource.ResourceType;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.core.ExtraTreesGUID;
|
||||
import binnie.extratrees.machines.brewery.BreweryMachine;
|
||||
import binnie.extratrees.machines.distillery.DistilleryMachine;
|
||||
import binnie.extratrees.machines.lumbermill.LumbermillMachine;
|
||||
import binnie.extratrees.machines.fruitpress.FruitPressMachine;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -28,7 +29,7 @@ public enum ExtraTreeMachine implements IMachineType {
|
||||
Nursery(Nursery.PackageNursery.class),
|
||||
Press(FruitPressMachine.class),
|
||||
Brewery(BreweryMachine.class),
|
||||
Distillery(Distillery.PackageDistillery.class),
|
||||
Distillery(DistilleryMachine.class),
|
||||
Glassworker(Designer.PackageGlassworker.class),
|
||||
Tileworker(Designer.PackageTileworker.class);
|
||||
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package binnie.extratrees.machines.distillery;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class DistilleryLogic extends ComponentProcessSetCost implements IProcess, INetwork.SendGuiNBT, INetwork.RecieveGuiNBT {
|
||||
public FluidStack currentFluid;
|
||||
public int level;
|
||||
|
||||
public DistilleryLogic(final Machine machine) {
|
||||
super(machine, 16000, 800);
|
||||
this.currentFluid = null;
|
||||
this.level = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEnergyPerTick() {
|
||||
return 2.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
return 2000 + 800 * this.level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.level = nbt.getByte("dlevel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(final NBTTagCompound nbt2) {
|
||||
NBTTagCompound nbt = super.writeToNBT(nbt2);
|
||||
nbt.setByte("dlevel", (byte) this.level);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isTankEmpty(DistilleryMachine.TANK_INPUT) && this.currentFluid == null) {
|
||||
return new ErrorState.InsufficientLiquid("No Input Liquid", DistilleryMachine.TANK_INPUT);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (this.currentFluid == null) {
|
||||
return new ErrorState("Distillery Empty", "No liquid in Distillery");
|
||||
}
|
||||
|
||||
FluidStack fluidInOutputTank = this.getUtil().getFluid(DistilleryMachine.TANK_OUTPUT);
|
||||
if (fluidInOutputTank != null) {
|
||||
FluidStack inputFluid = this.getUtil().getFluid(DistilleryMachine.TANK_INPUT);
|
||||
FluidStack recipeOutput = DistilleryRecipes.getOutput(inputFluid, this.level);
|
||||
if (recipeOutput != null && !recipeOutput.isFluidEqual(fluidInOutputTank)) {
|
||||
return new ErrorState.TankSpace("Different fluid in tank", DistilleryMachine.TANK_OUTPUT);
|
||||
}
|
||||
}
|
||||
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
final FluidStack output = DistilleryRecipes.getOutput(this.currentFluid, this.level).copy();
|
||||
output.amount = 1000;
|
||||
this.getUtil().fillTank(DistilleryMachine.TANK_OUTPUT, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveGuiNBT(final Side side, final EntityPlayer player, final String name, final NBTTagCompound nbt) {
|
||||
if (name.equals("still-level")) {
|
||||
this.level = nbt.getByte("i");
|
||||
this.setProgress(0);
|
||||
}
|
||||
if (name.equals("still-recipe")) {
|
||||
if (nbt.getBoolean("null")) {
|
||||
this.currentFluid = null;
|
||||
} else {
|
||||
this.currentFluid = FluidStack.loadFluidStackFromNBT(nbt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendGuiNBT(final Map<String, NBTTagCompound> data) {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
if (this.currentFluid == null) {
|
||||
nbt.setBoolean("null", true);
|
||||
} else {
|
||||
this.currentFluid.writeToNBT(nbt);
|
||||
}
|
||||
data.put("still-recipe", nbt);
|
||||
nbt.setByte("i", (byte) this.level);
|
||||
data.put("still-level", nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
if (this.canWork() == null && this.currentFluid == null && this.getUtil().getTank(DistilleryMachine.TANK_INPUT).getFluidAmount() >= 1000) {
|
||||
this.currentFluid = this.getUtil().drainTank(DistilleryMachine.TANK_INPUT, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
if (this.currentFluid == null) {
|
||||
return "Empty";
|
||||
}
|
||||
return "Creating " + DistilleryRecipes.getOutput(this.currentFluid, this.level).getFluid().getLocalizedName(this.currentFluid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package binnie.extratrees.machines.distillery;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.MachineSide;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
import binnie.extratrees.core.ExtraTreesGUID;
|
||||
import binnie.extratrees.machines.ExtraTreeMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class DistilleryMachine extends ExtraTreeMachine.PackageExtraTreeMachine implements IMachineInformation {
|
||||
public static final int TANK_INPUT = 0;
|
||||
public static final int TANK_OUTPUT = 1;
|
||||
|
||||
public DistilleryMachine() {
|
||||
super("distillery", ExtraTreeTexture.distilleryTexture, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ExtraTreeMachine.ComponentExtraTreeGUI(machine, ExtraTreesGUID.Distillery);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(TANK_INPUT, "input", 5000);
|
||||
tanks.getTankSlot(TANK_INPUT).setValidator(new TankValidatorDistilleryInput());
|
||||
tanks.getTankSlot(TANK_INPUT).setOutputSides(MachineSide.TopAndBottom);
|
||||
tanks.addTank(TANK_OUTPUT, "output", 5000);
|
||||
tanks.getTankSlot(TANK_OUTPUT).setValidator(new TankValidatorDistilleryOutput());
|
||||
tanks.getTankSlot(TANK_OUTPUT).setReadOnly();
|
||||
tanks.getTankSlot(TANK_OUTPUT).setOutputSides(MachineSide.Sides);
|
||||
new ComponentPowerReceptor(machine);
|
||||
new DistilleryLogic(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package binnie.extratrees.machines.distillery;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DistilleryRecipes {
|
||||
private static final List<Map<Fluid, FluidStack>> recipes = new ArrayList<>();
|
||||
|
||||
static {
|
||||
recipes.add(new HashMap<>());
|
||||
recipes.add(new HashMap<>());
|
||||
recipes.add(new HashMap<>());
|
||||
}
|
||||
|
||||
public static FluidStack getOutput(@Nullable final FluidStack fluid, final int level) {
|
||||
if (fluid == null) {
|
||||
return null;
|
||||
}
|
||||
return recipes.get(level).get(fluid.getFluid());
|
||||
}
|
||||
|
||||
public static boolean isValidInputLiquid(final FluidStack fluid) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (recipes.get(i).containsKey(fluid.getFluid())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isValidOutputLiquid(final FluidStack fluid) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (final Map.Entry<Fluid, FluidStack> entry : recipes.get(i).entrySet()) {
|
||||
if (entry.getValue().isFluidEqual(fluid)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void addRecipe(final FluidStack input, final FluidStack output, final int level) {
|
||||
recipes.get(level).put(input.getFluid(), output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package binnie.extratrees.machines.distillery;
|
||||
|
||||
import binnie.core.machines.inventory.TankValidator;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class TankValidatorDistilleryInput extends TankValidator {
|
||||
@Override
|
||||
public boolean isValid(final FluidStack itemStack) {
|
||||
return DistilleryRecipes.isValidInputLiquid(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Distillable Liquids";
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package binnie.extratrees.machines.distillery;
|
||||
|
||||
import binnie.core.machines.inventory.TankValidator;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class TankValidatorDistilleryOutput extends TankValidator {
|
||||
@Override
|
||||
public boolean isValid(final FluidStack itemStack) {
|
||||
return DistilleryRecipes.isValidOutputLiquid(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Distilled Liquids";
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import binnie.extratrees.machines.brewery.BreweryRecipes;
|
||||
import binnie.extratrees.machines.Distillery;
|
||||
import binnie.extratrees.machines.distillery.DistilleryRecipes;
|
||||
import binnie.extratrees.machines.fruitpress.FruitPressRecipes;
|
||||
import forestry.api.recipes.ICentrifugeRecipe;
|
||||
import forestry.api.recipes.ISqueezerRecipe;
|
||||
@@ -150,9 +150,9 @@ public abstract class AnalystPageProduce extends ControlAnalystPage {
|
||||
protected Collection<? extends FluidStack> getAllProducts(final FluidStack stack) {
|
||||
final Collection<FluidStack> fluids = new UniqueFluidStackSet();
|
||||
fluids.add(BreweryRecipes.getOutput(stack));
|
||||
fluids.add(Distillery.getOutput(stack, 0));
|
||||
fluids.add(Distillery.getOutput(stack, 1));
|
||||
fluids.add(Distillery.getOutput(stack, 2));
|
||||
fluids.add(DistilleryRecipes.getOutput(stack, 0));
|
||||
fluids.add(DistilleryRecipes.getOutput(stack, 1));
|
||||
fluids.add(DistilleryRecipes.getOutput(stack, 2));
|
||||
return fluids;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user