mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-28 15:56:07 +00:00
More progress on the still.
This commit is contained in:
1 parent
66544c83f8
commit
51865af400
22 files changed
+401
-145
No files matched your search
@@ -13,6 +13,8 @@ public interface IEnderIoRecipe {
|
||||
|
||||
public static final String SAG_MILL_ID = ModObject.blockSagMill.unlocalisedName;
|
||||
|
||||
public static final String STILL_ID = ModObject.blockAlloySmelter.unlocalisedName;
|
||||
|
||||
String getCrafterId();
|
||||
|
||||
List<IRecipeInput> getInputs();
|
||||
|
||||
@@ -23,8 +23,11 @@ public class BlockFluidEio extends BlockFluidClassic {
|
||||
return res;
|
||||
}
|
||||
|
||||
protected Fluid fluid;
|
||||
|
||||
protected BlockFluidEio(Fluid fluid, Material material) {
|
||||
super(fluid, material);
|
||||
this.fluid = fluid;
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
@@ -42,11 +45,10 @@ public class BlockFluidEio extends BlockFluidClassic {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
//nutrientdistillation_still.png
|
||||
//nutrientdistillation_still.png
|
||||
icons = new IIcon[] { iconRegister.registerIcon("enderio:" + fluidName + "_still"),
|
||||
iconRegister.registerIcon("enderio:" + fluidName + "_flow") };
|
||||
|
||||
fluid.setIcons(icons[0], icons[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -395,6 +395,10 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements IIn
|
||||
}
|
||||
|
||||
private void updateCapacitorFromSlot() {
|
||||
if(slotDefinition.getNumUpgradeSlots() <= 0) {
|
||||
setCapacitor(Capacitors.BASIC_CAPACITOR);
|
||||
return;
|
||||
}
|
||||
ItemStack contents = inventory[slotDefinition.minUpgradeSlot];
|
||||
if(contents == null || contents.getItem() != EnderIO.itemBasicCapacitor) {
|
||||
setCapacitor(Capacitors.BASIC_CAPACITOR);
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import crazypants.enderio.machine.IMachineRecipe.ResultStack;
|
||||
|
||||
public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity implements ISidedInventory {
|
||||
|
||||
@@ -118,27 +120,15 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
|
||||
if(currentTask != null) {
|
||||
lastCompletedRecipe = currentTask.getRecipe();
|
||||
ItemStack[] output = currentTask.getCompletedResult();
|
||||
ResultStack[] output = currentTask.getCompletedResult();
|
||||
if(output != null && output.length > 0) {
|
||||
ItemStack[] results = currentTask.getCompletedResult();
|
||||
for (ItemStack result : results) {
|
||||
ResultStack[] results = currentTask.getCompletedResult();
|
||||
for (ResultStack result : results) {
|
||||
if(result != null) {
|
||||
int toMerge = result.stackSize;
|
||||
for (int i = slotDefinition.getMinOutputSlot(); i <= slotDefinition.getMaxOutputSlot() && toMerge > 0; i++) {
|
||||
int outputIndex = i;
|
||||
if(inventory[outputIndex] == null) {
|
||||
inventory[outputIndex] = result.copy();
|
||||
toMerge = 0;
|
||||
} else {
|
||||
int newStackSize = Math.min(inventory[outputIndex].stackSize + getNumCanMerge(inventory[outputIndex], result),
|
||||
inventory[outputIndex].getMaxStackSize());
|
||||
int merged = newStackSize - inventory[outputIndex].stackSize;
|
||||
toMerge -= merged;
|
||||
if(merged > 0) {
|
||||
inventory[outputIndex] = result.copy();
|
||||
inventory[outputIndex].stackSize = newStackSize;
|
||||
}
|
||||
}
|
||||
if(result.item != null) {
|
||||
mergeItemResult(result);
|
||||
} else if(result.fluid != null) {
|
||||
mergeFluidResult(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,6 +137,36 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
currentTask = null;
|
||||
}
|
||||
|
||||
protected void mergeFluidResult(ResultStack result) {
|
||||
}
|
||||
|
||||
protected void drainInputFluid(MachineRecipeInput fluid) {
|
||||
}
|
||||
|
||||
protected boolean canInsertResultFluid(ResultStack fluid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void mergeItemResult(ResultStack result) {
|
||||
int toMerge = result.item.stackSize;
|
||||
for (int i = slotDefinition.getMinOutputSlot(); i <= slotDefinition.getMaxOutputSlot() && toMerge > 0; i++) {
|
||||
int outputIndex = i;
|
||||
if(inventory[outputIndex] == null) {
|
||||
inventory[outputIndex] = result.item.copy();
|
||||
toMerge = 0;
|
||||
} else {
|
||||
int newStackSize = Math.min(inventory[outputIndex].stackSize + getNumCanMerge(inventory[outputIndex], result.item),
|
||||
inventory[outputIndex].getMaxStackSize());
|
||||
int merged = newStackSize - inventory[outputIndex].stackSize;
|
||||
toMerge -= merged;
|
||||
if(merged > 0) {
|
||||
inventory[outputIndex] = result.item.copy();
|
||||
inventory[outputIndex].stackSize = newStackSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected MachineRecipeInput[] getInputs() {
|
||||
MachineRecipeInput[] res = new MachineRecipeInput[slotDefinition.getNumInputSlots()];
|
||||
int fromSlot = slotDefinition.minInputSlot;
|
||||
@@ -169,31 +189,32 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
|
||||
protected boolean canInsertResult(float chance, IMachineRecipe nextRecipe) {
|
||||
|
||||
// if we have an empty output, all good
|
||||
for (int i = slotDefinition.minOutputSlot; i <= slotDefinition.maxOutputSlot; i++) {
|
||||
if(inventory[i] == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack[] nextResults = nextRecipe.getCompletedResult(chance, getInputs());
|
||||
ResultStack[] nextResults = nextRecipe.getCompletedResult(chance, getInputs());
|
||||
ItemStack[] outputStacks = new ItemStack[slotDefinition.getNumOutputSlots()];
|
||||
int copyIndex = 0;
|
||||
for (int i = slotDefinition.minOutputSlot; i <= slotDefinition.maxOutputSlot; i++) {
|
||||
ItemStack inv = inventory[i];
|
||||
if(inv != null) {
|
||||
outputStacks[copyIndex] = inv.copy();
|
||||
if(slotDefinition.getNumOutputSlots() > 0) {
|
||||
for (int i = slotDefinition.minOutputSlot; i <= slotDefinition.maxOutputSlot; i++) {
|
||||
ItemStack inv = inventory[i];
|
||||
if(inv != null) {
|
||||
outputStacks[copyIndex] = inv.copy();
|
||||
}
|
||||
copyIndex++;
|
||||
}
|
||||
copyIndex++;
|
||||
}
|
||||
|
||||
for (ItemStack result : nextResults) {
|
||||
int canMerge = 0;
|
||||
for (ItemStack outStack : outputStacks) {
|
||||
canMerge += getNumCanMerge(outStack, result);
|
||||
}
|
||||
if(canMerge < result.stackSize) {
|
||||
return false;
|
||||
for (ResultStack result : nextResults) {
|
||||
if(result.item != null) {
|
||||
int canMerge = 0;
|
||||
for (ItemStack outStack : outputStacks) {
|
||||
canMerge += getNumCanMerge(outStack, result.item);
|
||||
}
|
||||
if(canMerge < result.item.stackSize) {
|
||||
return false;
|
||||
}
|
||||
} else if(result.fluid != null) {
|
||||
if(!canInsertResultFluid(result)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,10 +244,15 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
// then get our recipe and take away the source items
|
||||
currentTask = new PoweredTask(nextRecipe, chance, getInputs());
|
||||
|
||||
MachineRecipeInput[] consumed = nextRecipe.getQuantitiesConsumed(getInputs());
|
||||
List<MachineRecipeInput> consumed = nextRecipe.getQuantitiesConsumed(getInputs());
|
||||
for (MachineRecipeInput item : consumed) {
|
||||
if(item != null && item.item != null && item.item.stackSize > 0) {
|
||||
decrStackSize(item.slotNumber, item.item.stackSize);
|
||||
if(item != null) {
|
||||
if(item.item != null && item.item.stackSize > 0) {
|
||||
decrStackSize(item.slotNumber, item.item.stackSize);
|
||||
} else if(item.fluid != null) {
|
||||
drainInputFluid(item);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -3,6 +3,7 @@ package crazypants.enderio.machine;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import crazypants.enderio.crafting.IEnderIoRecipe;
|
||||
|
||||
/**
|
||||
@@ -57,7 +58,7 @@ public interface IMachineRecipe {
|
||||
* @param inputs
|
||||
* @return
|
||||
*/
|
||||
ItemStack[] getCompletedResult(float randomChance, MachineRecipeInput... inputs);
|
||||
ResultStack[] getCompletedResult(float randomChance, MachineRecipeInput... inputs);
|
||||
|
||||
/**
|
||||
* Returns the experience a user gains when this recipe has generated the
|
||||
@@ -91,7 +92,7 @@ public interface IMachineRecipe {
|
||||
* @param inputs
|
||||
* @return
|
||||
*/
|
||||
MachineRecipeInput[] getQuantitiesConsumed(MachineRecipeInput[] inputs);
|
||||
List<MachineRecipeInput> getQuantitiesConsumed(MachineRecipeInput[] inputs);
|
||||
|
||||
/**
|
||||
* Returns all possible outputs from the recipe.
|
||||
@@ -100,4 +101,26 @@ public interface IMachineRecipe {
|
||||
*/
|
||||
List<IEnderIoRecipe> getAllRecipes();
|
||||
|
||||
public static class ResultStack {
|
||||
|
||||
public final ItemStack item;
|
||||
public final FluidStack fluid;
|
||||
|
||||
public ResultStack(ItemStack item, FluidStack fluid) {
|
||||
this.item = item;
|
||||
this.fluid = fluid;
|
||||
}
|
||||
|
||||
public ResultStack(ItemStack item) {
|
||||
this.item = item;
|
||||
this.fluid = null;
|
||||
}
|
||||
|
||||
public ResultStack(FluidStack fluid) {
|
||||
this.item = null;
|
||||
this.fluid = fluid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class MachineRecipeInput {
|
||||
@@ -35,4 +36,37 @@ public class MachineRecipeInput {
|
||||
this.fluid = fluid;
|
||||
}
|
||||
|
||||
public MachineRecipeInput(int slotNumber, ItemStack item, FluidStack fluid) {
|
||||
this.slotNumber = slotNumber;
|
||||
this.item = item;
|
||||
this.fluid = fluid;
|
||||
}
|
||||
|
||||
public static MachineRecipeInput readFromNBT(NBTTagCompound root) {
|
||||
int slotNum = root.getInteger("slotNum");
|
||||
ItemStack item = null;
|
||||
FluidStack fluid = null;
|
||||
if(root.hasKey("itemStack")) {
|
||||
NBTTagCompound stackRoot = root.getCompoundTag("itemStack");
|
||||
item = ItemStack.loadItemStackFromNBT(stackRoot);
|
||||
} else if(root.hasKey("fluidStack")) {
|
||||
NBTTagCompound stackRoot = root.getCompoundTag("fluidStack");
|
||||
fluid = FluidStack.loadFluidStackFromNBT(stackRoot);
|
||||
}
|
||||
return new MachineRecipeInput(slotNum, item, fluid);
|
||||
}
|
||||
|
||||
public void writeToNbt(NBTTagCompound root) {
|
||||
if(item != null) {
|
||||
NBTTagCompound stackRoot = new NBTTagCompound();
|
||||
item.writeToNBT(stackRoot);
|
||||
root.setTag("itemStack", stackRoot);
|
||||
} else if(fluid != null) {
|
||||
NBTTagCompound stackRoot = new NBTTagCompound();
|
||||
fluid.writeToNBT(stackRoot);
|
||||
root.setTag("fluidStack", stackRoot);
|
||||
}
|
||||
root.setInteger("slotNum", slotNumber);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,17 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import crazypants.enderio.machine.IMachineRecipe.ResultStack;
|
||||
|
||||
public class PoweredTask {
|
||||
|
||||
public static final String KEY_INPUTS_SLOTS = "inputsSlots";
|
||||
public static final String KEY_INPUTS_STACKS = "inputsStacks";
|
||||
public static final String KEY_INPUT_STACKS = "inputsStacks";
|
||||
|
||||
public static final String KEY_RECIPE = "recipeUid";
|
||||
public static final String KEY_USED_ENERGY = "usedEnergy";
|
||||
private static final String KEY_CHANCE = "chance";
|
||||
@@ -31,7 +34,7 @@ public class PoweredTask {
|
||||
this.inputs = inputsIn;
|
||||
int numInputs = 0;
|
||||
for (int i = 0; i < inputsIn.length; i++) {
|
||||
if(inputsIn[i] != null && inputsIn[i].item != null) {
|
||||
if(inputsIn[i] != null && (inputsIn[i].item != null || inputsIn[i].fluid != null)) {
|
||||
numInputs++;
|
||||
}
|
||||
}
|
||||
@@ -39,9 +42,14 @@ public class PoweredTask {
|
||||
inputs = new MachineRecipeInput[numInputs];
|
||||
int index = 0;
|
||||
for (int i = 0; i < inputsIn.length; i++) {
|
||||
if(inputsIn[i] != null && inputsIn[i].item != null) {
|
||||
inputs[index] = new MachineRecipeInput(inputsIn[i].slotNumber, inputsIn[i].item.copy());
|
||||
index++;
|
||||
if(inputsIn[i] != null) {
|
||||
if(inputsIn[i].item != null) {
|
||||
inputs[index] = new MachineRecipeInput(inputsIn[i].slotNumber, inputsIn[i].item.copy());
|
||||
index++;
|
||||
} else if(inputsIn[i].fluid != null) {
|
||||
inputs[index] = new MachineRecipeInput(inputsIn[i].slotNumber, inputsIn[i].fluid.copy());
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,26 +71,21 @@ public class PoweredTask {
|
||||
return MathHelper.clamp_float(usedEnergy / requiredEnergy, 0, 1);
|
||||
}
|
||||
|
||||
public ItemStack[] getCompletedResult() {
|
||||
public ResultStack[] getCompletedResult() {
|
||||
return recipe.getCompletedResult(chance, inputs);
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbtRoot) {
|
||||
NBTTagCompound stackRoot;
|
||||
|
||||
int[] inputSlots = new int[inputs.length];
|
||||
for (int i = 0; i < inputSlots.length; i++) {
|
||||
inputSlots[i] = inputs[i].slotNumber;
|
||||
}
|
||||
nbtRoot.setIntArray(KEY_INPUTS_SLOTS, inputSlots);
|
||||
|
||||
NBTTagList inputItems = new NBTTagList();
|
||||
for (MachineRecipeInput ri : inputs) {
|
||||
stackRoot = new NBTTagCompound();
|
||||
ri.item.writeToNBT(stackRoot);
|
||||
ri.writeToNbt(stackRoot);
|
||||
inputItems.appendTag(stackRoot);
|
||||
}
|
||||
nbtRoot.setTag(KEY_INPUTS_STACKS, inputItems);
|
||||
|
||||
nbtRoot.setTag(KEY_INPUT_STACKS, inputItems);
|
||||
|
||||
nbtRoot.setString(KEY_RECIPE, recipe.getUid());
|
||||
nbtRoot.setFloat(KEY_USED_ENERGY, usedEnergy);
|
||||
@@ -100,26 +103,22 @@ public class PoweredTask {
|
||||
float usedEnergy = nbtRoot.getFloat(KEY_USED_ENERGY);
|
||||
float chance = nbtRoot.getFloat(KEY_CHANCE);
|
||||
|
||||
int[] inputSlots = nbtRoot.getIntArray(KEY_INPUTS_SLOTS);
|
||||
if(inputSlots == null || inputSlots.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
NBTTagList inputItems = (NBTTagList) nbtRoot.getTag(KEY_INPUTS_STACKS);
|
||||
if(inputItems == null || inputItems.tagCount() != inputSlots.length) {
|
||||
NBTTagList inputItems = (NBTTagList) nbtRoot.getTag(KEY_INPUT_STACKS);
|
||||
if(inputItems == null || inputItems.tagCount() < 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
MachineRecipeInput[] inputs = new MachineRecipeInput[inputSlots.length];
|
||||
for (int i = 0; i < inputSlots.length; i++) {
|
||||
List<MachineRecipeInput> ins = new ArrayList<MachineRecipeInput>(3);
|
||||
for (int i = 0; i < inputItems.tagCount(); i++) {
|
||||
NBTTagCompound stackTag = inputItems.getCompoundTagAt(i);
|
||||
ItemStack item = ItemStack.loadItemStackFromNBT(stackTag);
|
||||
inputs[i] = new MachineRecipeInput(inputSlots[i], item);
|
||||
MachineRecipeInput mi = MachineRecipeInput.readFromNBT(stackTag);
|
||||
ins.add(mi);
|
||||
}
|
||||
|
||||
String uid = nbtRoot.getString(KEY_RECIPE);
|
||||
recipe = MachineRecipeRegistry.instance.getRecipeForUid(uid);
|
||||
if(recipe != null) {
|
||||
return new PoweredTask(recipe, usedEnergy, chance, inputs);
|
||||
return new PoweredTask(recipe, usedEnergy, chance, ins.toArray(new MachineRecipeInput[ins.size()]));
|
||||
}
|
||||
return null;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import crazypants.enderio.Log;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractPoweredTaskEntity;
|
||||
import crazypants.enderio.machine.IMachineRecipe;
|
||||
import crazypants.enderio.machine.IMachineRecipe.ResultStack;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.machine.SlotDefinition;
|
||||
@@ -60,7 +61,7 @@ public class TileAlloySmelter extends AbstractPoweredTaskEntity {
|
||||
if(mode == Mode.FURNACE) {
|
||||
VanillaSmeltingRecipe vr = AlloyRecipeManager.getInstance().vanillaRecipe;
|
||||
if(vr.isRecipe(getInputs())) {
|
||||
ItemStack[] res = vr.getCompletedResult(chance, getInputs());
|
||||
ResultStack[] res = vr.getCompletedResult(chance, getInputs());
|
||||
if(res == null || res.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class VanillaSmeltingRecipe implements IMachineRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
ItemStack output = null;
|
||||
int inputCount = 0;
|
||||
for (MachineRecipeInput ri : inputs) {
|
||||
@@ -103,11 +103,11 @@ public class VanillaSmeltingRecipe implements IMachineRecipe {
|
||||
}
|
||||
}
|
||||
if(output == null) {
|
||||
return new ItemStack[0];
|
||||
return new ResultStack[0];
|
||||
}
|
||||
ItemStack result = output.copy();
|
||||
result.stackSize = result.stackSize * getNumInputs(inputs);
|
||||
return new ItemStack[] { result };
|
||||
return new ResultStack[] { new ResultStack(result) };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,7 +140,7 @@ public class VanillaSmeltingRecipe implements IMachineRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MachineRecipeInput[] getQuantitiesConsumed(MachineRecipeInput[] inputs) {
|
||||
public List<MachineRecipeInput> getQuantitiesConsumed(MachineRecipeInput[] inputs) {
|
||||
int consumed = 0;
|
||||
List<MachineRecipeInput> result = new ArrayList<MachineRecipeInput>();
|
||||
for (MachineRecipeInput ri : inputs) {
|
||||
@@ -156,7 +156,7 @@ public class VanillaSmeltingRecipe implements IMachineRecipe {
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toArray(new MachineRecipeInput[result.size()]);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package crazypants.enderio.machine.painter;
|
||||
|
||||
import static crazypants.enderio.machine.MachineRecipeInput.getInputForSlot;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -47,7 +51,7 @@ public abstract class BasicPainterTemplate implements IMachineRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
ItemStack target = getTarget(inputs);
|
||||
ItemStack paintSource = getPaintSource(inputs);
|
||||
if(target == null || paintSource == null) {
|
||||
@@ -55,7 +59,7 @@ public abstract class BasicPainterTemplate implements IMachineRecipe {
|
||||
}
|
||||
ItemStack result = new ItemStack(getResultId(target), 1, target.getItemDamage());
|
||||
PainterUtil.setSourceBlock(result, Util.getBlockFromItemId(paintSource), paintSource.getItemDamage());
|
||||
return new ItemStack[] { result };
|
||||
return new ResultStack[] { new ResultStack(result) };
|
||||
}
|
||||
|
||||
public ItemStack getTarget(MachineRecipeInput... inputs) {
|
||||
@@ -128,7 +132,7 @@ public abstract class BasicPainterTemplate implements IMachineRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MachineRecipeInput[] getQuantitiesConsumed(MachineRecipeInput[] inputs) {
|
||||
public List<MachineRecipeInput> getQuantitiesConsumed(MachineRecipeInput[] inputs) {
|
||||
MachineRecipeInput consume = null;
|
||||
for (MachineRecipeInput input : inputs) {
|
||||
if(input != null && input.slotNumber == 0 && input.item != null) {
|
||||
@@ -138,7 +142,7 @@ public abstract class BasicPainterTemplate implements IMachineRecipe {
|
||||
}
|
||||
}
|
||||
if(consume != null) {
|
||||
return new MachineRecipeInput[] { consume };
|
||||
return Collections.singletonList(consume);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -265,9 +265,9 @@ public class BlockPaintedFence extends BlockFence implements ITileEntityProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
ItemStack paintSource = MachineRecipeInput.getInputForSlot(1, inputs);
|
||||
return new ItemStack[] { createItemStackForSourceBlock(getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage()) };
|
||||
return new ResultStack[] { new ResultStack(createItemStackForSourceBlock(getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage())) };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -232,9 +232,9 @@ public class BlockPaintedFenceGate extends BlockFenceGate implements ITileEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
ItemStack paintSource = MachineRecipeInput.getInputForSlot(1, inputs);
|
||||
return new ItemStack[] { createItemStackForSourceBlock(Block.getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage()) };
|
||||
return new ResultStack[] { new ResultStack(createItemStackForSourceBlock(Block.getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage())) };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -244,12 +244,12 @@ public class BlockPaintedSlab extends BlockSlab implements ITileEntityProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
ItemStack paintSource = MachineRecipeInput.getInputForSlot(1, inputs);
|
||||
if(paintSource == null) {
|
||||
return new ItemStack[0];
|
||||
return new ResultStack[0];
|
||||
}
|
||||
return new ItemStack[] { createItemStackForSourceBlock(Block.getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage()) };
|
||||
return new ResultStack[] { new ResultStack(createItemStackForSourceBlock(Block.getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage())) };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -241,12 +241,12 @@ public class BlockPaintedStair extends BlockStairs implements ITileEntityProvide
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
ItemStack paintSource = MachineRecipeInput.getInputForSlot(1, inputs);
|
||||
if(paintSource == null) {
|
||||
return new ItemStack[0];
|
||||
return new ResultStack[0];
|
||||
}
|
||||
return new ItemStack[] { createItemStackForSourceBlock(Block.getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage()) };
|
||||
return new ResultStack[] { new ResultStack(createItemStackForSourceBlock(Block.getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage())) };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -239,9 +239,9 @@ public class BlockPaintedWall extends BlockWall implements ITileEntityProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
ItemStack paintSource = MachineRecipeInput.getInputForSlot(1, inputs);
|
||||
return new ItemStack[] { createItemStackForSourceBlock(Block.getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage()) };
|
||||
return new ResultStack[] { new ResultStack(createItemStackForSourceBlock(Block.getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage())) };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,21 +21,21 @@ public abstract class AbstractMachineRecipe implements IMachineRecipe {
|
||||
public abstract IRecipe getRecipeForInputs(MachineRecipeInput[] inputs);
|
||||
|
||||
@Override
|
||||
public MachineRecipeInput[] getQuantitiesConsumed(MachineRecipeInput[] inputs) {
|
||||
public List<MachineRecipeInput> getQuantitiesConsumed(MachineRecipeInput[] inputs) {
|
||||
IRecipe rec = getRecipeForInputs(inputs);
|
||||
|
||||
List<MachineRecipeInput> result = new ArrayList<MachineRecipeInput>();
|
||||
for (MachineRecipeInput input : inputs) {
|
||||
if(input != null && input.item != null) {
|
||||
if(input != null && (input.item != null || input.fluid != null)) {
|
||||
for (RecipeInput ri : rec.getInputs()) {
|
||||
if(ri.isInput(input.item)) {
|
||||
result.add(new MachineRecipeInput(input.slotNumber, ri.getInput().copy()));
|
||||
} else if(ri.isInput(input.fluid)) {
|
||||
result.add(new MachineRecipeInput(input.slotNumber, ri.getFluidInput().copy()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result.toArray(new MachineRecipeInput[result.size()]);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,25 +53,29 @@ public abstract class AbstractMachineRecipe implements IMachineRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
if(inputs == null || inputs.length <= 0) {
|
||||
return new ItemStack[0];
|
||||
return new ResultStack[0];
|
||||
}
|
||||
IRecipe recipe = getRecipeForInputs(inputs);
|
||||
if(recipe == null) {
|
||||
return new ItemStack[0];
|
||||
return new ResultStack[0];
|
||||
}
|
||||
RecipeOutput[] outputs = recipe.getOutputs();
|
||||
if(outputs == null) {
|
||||
return new ItemStack[0];
|
||||
return new ResultStack[0];
|
||||
}
|
||||
List<ItemStack> result = new ArrayList<ItemStack>();
|
||||
List<ResultStack> result = new ArrayList<ResultStack>();
|
||||
for (RecipeOutput output : outputs) {
|
||||
if(output.getChance() >= chance) {
|
||||
result.add(output.getOutput());
|
||||
if(output.isFluid()) {
|
||||
result.add(new ResultStack(output.getFluidOutput()));
|
||||
} else {
|
||||
result.add(new ResultStack(output.getOutput()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toArray(new ItemStack[result.size()]);
|
||||
return result.toArray(new ResultStack[result.size()]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -66,4 +66,8 @@ public class RecipeOutput {
|
||||
return outputFluid;
|
||||
}
|
||||
|
||||
public boolean isFluid() {
|
||||
return outputFluid != null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package crazypants.enderio.machine.still;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -28,17 +31,50 @@ public class GuiStill extends GuiMachineBase {
|
||||
int guiTop = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
// int i1 = tileEntity.getProgressScaled(24);
|
||||
// int i1 = still.getProgressScaled(24);
|
||||
// drawTexturedModalRect(guiLeft + 79, guiTop + 31, 200, 0, 18, i1 + 1);
|
||||
|
||||
if(still.getProgress() < 1 && still.getProgress() > 0) {
|
||||
int scaled = still.getProgressScaled(12);
|
||||
drawTexturedModalRect(guiLeft + 89, guiTop + 76 - scaled, 176, 12 - scaled, 14, scaled + 2);
|
||||
drawTexturedModalRect(guiLeft + 81, guiTop + 76 - scaled, 176, 12 - scaled, 14, scaled + 2);
|
||||
}
|
||||
|
||||
RenderUtil.bindBlockTexture();
|
||||
renderTank(still.inputTank, 30);
|
||||
renderTank(still.outputTank, 132);
|
||||
|
||||
RenderUtil.bindTexture("enderio:textures/gui/still.png");
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
}
|
||||
|
||||
private void renderTank(FluidTank tank, int x) {
|
||||
FluidStack fluid = tank.getFluid();
|
||||
if(fluid == null || fluid.getFluid() == null || fluid.amount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
IIcon icon = fluid.getFluid().getStillIcon();
|
||||
if(icon == null) {
|
||||
icon = fluid.getFluid().getIcon();
|
||||
if(icon == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
float fullness = (float) tank.getFluidAmount() / (float) tank.getCapacity();
|
||||
int height = Math.round(47 * fullness);
|
||||
|
||||
x = guiLeft + x;
|
||||
int y = guiTop + 12;
|
||||
y = y + (47 - height);
|
||||
|
||||
GL11.glColor4f(1, 1, 1, 0.75f);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
drawTexturedModelRectFromIcon(x, y, icon, 15, height);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPowerX() {
|
||||
return 10;
|
||||
|
||||
@@ -3,23 +3,21 @@ package crazypants.enderio.machine.still;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.crafting.IEnderIoRecipe;
|
||||
import crazypants.enderio.crafting.IRecipeComponent;
|
||||
import crazypants.enderio.crafting.IRecipeInput;
|
||||
import crazypants.enderio.crafting.IRecipeOutput;
|
||||
import crazypants.enderio.crafting.impl.EnderIoRecipe;
|
||||
import crazypants.enderio.crafting.impl.RecipeInput;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.recipe.AbstractMachineRecipe;
|
||||
import crazypants.enderio.machine.recipe.IRecipe;
|
||||
|
||||
public class StillMachineRecipe extends AbstractMachineRecipe {
|
||||
|
||||
private StillRecipe nutDistRecipe = new StillRecipe(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), new FluidStack(
|
||||
EnderIO.fluidNutrientDistillation, FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(Items.rotten_flesh), new ItemStack(Items.nether_wart));
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return "StillRecipe";
|
||||
@@ -27,7 +25,6 @@ public class StillMachineRecipe extends AbstractMachineRecipe {
|
||||
|
||||
@Override
|
||||
public IRecipe getRecipeForInputs(MachineRecipeInput[] inputs) {
|
||||
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
List<FluidStack> fluids = new ArrayList<FluidStack>();
|
||||
for (MachineRecipeInput mi : inputs) {
|
||||
@@ -48,7 +45,6 @@ public class StillMachineRecipe extends AbstractMachineRecipe {
|
||||
return false;
|
||||
}
|
||||
return StillRecipeManager.instance.isValidInput(input);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,31 +52,25 @@ public class StillMachineRecipe extends AbstractMachineRecipe {
|
||||
return ModObject.blockStill.unlocalisedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExperianceForOutput(ItemStack output) {
|
||||
// //return AlloyRecipeManager.instance.getExperianceForOutput(output);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IEnderIoRecipe> getAllRecipes() {
|
||||
List<IEnderIoRecipe> result = new ArrayList<IEnderIoRecipe>();
|
||||
// List<IAlloyRecipe> recipes = AlloyRecipeManager.getInstance().getRecipes();
|
||||
// for (IRecipe cr : recipes) {
|
||||
// List<IRecipeComponent> components = new ArrayList<IRecipeComponent>();
|
||||
// for (crazypants.enderio.machine.recipe.RecipeInput ri : cr.getInputs()) {
|
||||
// if(ri.getInput() != null) {
|
||||
// IRecipeInput input = new RecipeInput(ri.getInput(), -1, ri.getEquivelentInputs());
|
||||
// components.add(input);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (RecipeOutput co : cr.getOutputs()) {
|
||||
// IRecipeOutput output = new crazypants.enderio.crafting.impl.RecipeOutput(co.getOutput(), co.getChance());
|
||||
// components.add(output);
|
||||
// }
|
||||
// result.add(new EnderIoRecipe(IEnderIoRecipe.ALLOY_SMELTER_ID, cr.getEnergyRequired(), components));
|
||||
// }
|
||||
List<IRecipe> recipes = StillRecipeManager.getInstance().getRecipes();
|
||||
for (IRecipe cr : recipes) {
|
||||
List<IRecipeComponent> components = new ArrayList<IRecipeComponent>();
|
||||
for (crazypants.enderio.machine.recipe.RecipeInput ri : cr.getInputs()) {
|
||||
if(ri.getInput() != null) {
|
||||
IRecipeInput input = new RecipeInput(ri.getInput(), -1, ri.getEquivelentInputs());
|
||||
components.add(input);
|
||||
}
|
||||
}
|
||||
|
||||
for (crazypants.enderio.machine.recipe.RecipeOutput co : cr.getOutputs()) {
|
||||
IRecipeOutput output = new crazypants.enderio.crafting.impl.RecipeOutput(co.getOutput(), co.getChance());
|
||||
components.add(output);
|
||||
}
|
||||
result.add(new EnderIoRecipe(IEnderIoRecipe.STILL_ID, cr.getEnergyRequired(), components));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ public class StillRecipe implements IRecipe {
|
||||
}
|
||||
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
if(!containsInput(inputs[i], test)) {
|
||||
if(!inputs[i].isFluid() && !containsInput(inputs[i], test)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.Log;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
@@ -39,9 +38,10 @@ public class StillRecipeManager {
|
||||
// } else {
|
||||
// Log.error("Could not load recipes for SAG Mill.");
|
||||
// }
|
||||
FluidStack resStack = FluidRegistry.getFluidStack("nutrientdistillation", FluidContainerRegistry.BUCKET_VOLUME);
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockStill.unlocalisedName, new StillMachineRecipe());
|
||||
addRecipe(new StillRecipe(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), new FluidStack(
|
||||
EnderIO.fluidNutrientDistillation, FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(Items.rotten_flesh), new ItemStack(Items.nether_wart)));
|
||||
addRecipe(new StillRecipe(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), resStack, new ItemStack(Items.rotten_flesh),
|
||||
new ItemStack(Items.nether_wart)));
|
||||
}
|
||||
|
||||
public void addCustumRecipes(String xmlDef) {
|
||||
|
||||
@@ -1,12 +1,29 @@
|
||||
package crazypants.enderio.machine.still;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractPoweredTaskEntity;
|
||||
import crazypants.enderio.machine.IMachineRecipe.ResultStack;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.SlotDefinition;
|
||||
|
||||
public class TileStill extends AbstractPoweredTaskEntity {
|
||||
public class TileStill extends AbstractPoweredTaskEntity implements IFluidHandler {
|
||||
|
||||
private static final FluidStack WATER = new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME);
|
||||
|
||||
final FluidTank inputTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 8);
|
||||
final FluidTank outputTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 8);
|
||||
|
||||
boolean tanksDirty = false;
|
||||
|
||||
public TileStill() {
|
||||
super(new SlotDefinition(0, 1, -1, -1, -1, -1));
|
||||
@@ -32,4 +49,114 @@ public class TileStill extends AbstractPoweredTaskEntity {
|
||||
return StillRecipeManager.getInstance().isValidInput(new MachineRecipeInput(i, itemstack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
if(resource == null || !resource.isFluidEqual(WATER)) {
|
||||
return 0;
|
||||
}
|
||||
tanksDirty = true;
|
||||
return inputTank.fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
if(outputTank.getFluid() == null || resource == null || !resource.isFluidEqual(outputTank.getFluid())) {
|
||||
return null;
|
||||
}
|
||||
tanksDirty = true;
|
||||
return outputTank.drain(resource.amount, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
tanksDirty = true;
|
||||
return outputTank.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean processTasks(boolean redstoneChecksPassed) {
|
||||
boolean res = super.processTasks(redstoneChecksPassed) || tanksDirty;
|
||||
tanksDirty = false;
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mergeFluidResult(ResultStack result) {
|
||||
outputTank.fill(result.fluid, true);
|
||||
tanksDirty = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drainInputFluid(MachineRecipeInput fluid) {
|
||||
System.out.println("TileStill.drainInputFluid: ");
|
||||
inputTank.drain(fluid.fluid.amount, true);
|
||||
tanksDirty = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canInsertResultFluid(ResultStack fluid) {
|
||||
int res = outputTank.fill(fluid.fluid, false);
|
||||
return res >= fluid.fluid.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MachineRecipeInput[] getInputs() {
|
||||
MachineRecipeInput[] res = new MachineRecipeInput[slotDefinition.getNumInputSlots() + 1];
|
||||
int fromSlot = slotDefinition.minInputSlot;
|
||||
for (int i = 0; i < res.length - 1; i++) {
|
||||
res[i] = new MachineRecipeInput(fromSlot, inventory[fromSlot]);
|
||||
fromSlot++;
|
||||
}
|
||||
|
||||
res[res.length - 1] = new MachineRecipeInput(0, inputTank.getFluid());
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
if(fluid == null || fluid.getID() != WATER.getFluid().getID()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return outputTank.getFluid() != null && outputTank.getFluid().getFluid().getID() == fluid.getID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return new FluidTankInfo[] { inputTank.getInfo(), outputTank.getInfo() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound nbtRoot) {
|
||||
super.readCustomNBT(nbtRoot);
|
||||
|
||||
NBTTagCompound tankRoot = (NBTTagCompound) nbtRoot.getTag("inputTank");
|
||||
if(tankRoot != null) {
|
||||
inputTank.readFromNBT(tankRoot);
|
||||
}
|
||||
tankRoot = (NBTTagCompound) nbtRoot.getTag("outputTank");
|
||||
if(tankRoot != null) {
|
||||
outputTank.readFromNBT(tankRoot);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomNBT(NBTTagCompound nbtRoot) {
|
||||
super.writeCustomNBT(nbtRoot);
|
||||
NBTTagCompound tankRoot = new NBTTagCompound();
|
||||
inputTank.writeToNBT(tankRoot);
|
||||
nbtRoot.setTag("inputTank", tankRoot);
|
||||
|
||||
tankRoot = new NBTTagCompound();
|
||||
outputTank.writeToNBT(tankRoot);
|
||||
nbtRoot.setTag("outputTank", tankRoot);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user