Added fluid crafting, updated buildcraft
This commit is contained in:
parent
fd2f5d193a
commit
d68c63a40d
4 changed files with 146 additions and 2 deletions
|
@ -4,22 +4,42 @@ import ic2.api.energy.tile.IEnergyTile;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
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.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import techreborn.api.recipe.RecipeCrafter;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.util.FluidUtils;
|
||||
import techreborn.util.Inventory;
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import ic2.api.tile.IWrenchable;
|
||||
|
||||
public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergyTile {
|
||||
public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergyTile, IFluidHandler {
|
||||
|
||||
public int tickTime;
|
||||
public BasicSink energy;
|
||||
public Inventory inventory = new Inventory(6, "TileGrinder", 64);
|
||||
public FluidTank tank = new FluidTank(16000);
|
||||
public RecipeCrafter crafter;
|
||||
|
||||
public TileGrinder() {
|
||||
//TODO configs
|
||||
energy = new BasicSink(this, 1000,
|
||||
ConfigTechReborn.CentrifugeTier);
|
||||
|
||||
int[] inputs = new int[1];
|
||||
inputs[0] = 0;
|
||||
int[] outputs = new int[4];
|
||||
outputs[0] = 2;
|
||||
outputs[1] = 3;
|
||||
outputs[2] = 4;
|
||||
outputs[3] = 5;
|
||||
crafter = new RecipeCrafter("grinderRecipe", this, energy, 1, 4, inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,12 +86,23 @@ public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergy
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
energy.updateEntity();
|
||||
crafter.updateEntity();
|
||||
FluidUtils.drainContainers(this, inventory, 1, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readFromNBT(tagCompound);
|
||||
inventory.readFromNBT(tagCompound);
|
||||
energy.readFromNBT(tagCompound);
|
||||
tank.readFromNBT(tagCompound);
|
||||
crafter.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,6 +111,8 @@ public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergy
|
|||
super.writeToNBT(tagCompound);
|
||||
inventory.writeToNBT(tagCompound);
|
||||
energy.writeToNBT(tagCompound);
|
||||
tank.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,4 +126,44 @@ public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergy
|
|||
energy.onChunkUnload();
|
||||
}
|
||||
|
||||
/* IFluidHandler */
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
return tank.fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
if (resource == null || !resource.isFluidEqual(tank.getFluid()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return tank.drain(resource.amount, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return tank.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
return new FluidTankInfo[] { tank.getInfo() };
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue