Added fluid crafting, updated buildcraft
This commit is contained in:
parent
fd2f5d193a
commit
d68c63a40d
4 changed files with 146 additions and 2 deletions
|
@ -84,7 +84,7 @@ dependencies {
|
|||
compile "codechicken:NotEnoughItems:1.7.10-1.0.4.+:dev"
|
||||
compile "codechicken:ForgeMultipart:1.7.10-1.1.2.331:dev"
|
||||
compile "mcp.mobius.waila:Waila:1.5.10_1.7.10:dev"
|
||||
compile 'com.mod-buildcraft:buildcraft:6.4.8:dev'
|
||||
compile 'com.mod-buildcraft:buildcraft:6.4.15:dev'
|
||||
compile "qmunity:QmunityLib:0.1.+:deobf"
|
||||
compile "com.pahimar.ee3:EquivalentExchange3:1.7.10-0.3.505:dev"
|
||||
grabDep('ThermalFoundation-[1.7.10]1.0.0-81.jar', 'http://addons-origin.cursecdn.com/files/2233/780/ThermalFoundation-[1.7.10]1.0.0-81.jar')
|
||||
|
|
|
@ -6,6 +6,8 @@ import net.minecraft.init.Blocks;
|
|||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import techreborn.api.BlastFurnaceRecipe;
|
||||
import techreborn.api.CentrifugeRecipie;
|
||||
|
@ -16,6 +18,7 @@ import techreborn.config.ConfigTechReborn;
|
|||
import techreborn.recipes.AlloySmelterRecipe;
|
||||
import techreborn.recipes.AssemblingMachineRecipe;
|
||||
import techreborn.recipes.ChemicalReactorRecipe;
|
||||
import techreborn.recipes.GrinderRecipe;
|
||||
import techreborn.recipes.ImplosionCompressorRecipe;
|
||||
import techreborn.recipes.IndustrialSawmillRecipe;
|
||||
import techreborn.recipes.LatheRecipe;
|
||||
|
@ -215,6 +218,8 @@ public class ModRecipes {
|
|||
//TODO
|
||||
RecipeHanderer.addRecipe(new ChemicalReactorRecipe(new ItemStack(Items.coal), new ItemStack(Blocks.sand), new ItemStack(Items.diamond), 120, 5));
|
||||
|
||||
RecipeHanderer.addRecipe(new GrinderRecipe(new ItemStack(Items.diamond), new FluidStack(ModFluids.fluidMercury, 500), new ItemStack(Blocks.brick_block), null, null, null, 400, 5));
|
||||
|
||||
LogHelper.info("Machine Recipes Added");
|
||||
}
|
||||
|
||||
|
|
66
src/main/java/techreborn/recipes/GrinderRecipe.java
Normal file
66
src/main/java/techreborn/recipes/GrinderRecipe.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
package techreborn.recipes;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import techreborn.api.recipe.BaseRecipe;
|
||||
import techreborn.tiles.TileGrinder;
|
||||
|
||||
public class GrinderRecipe extends BaseRecipe {
|
||||
|
||||
public FluidStack fluidStack;
|
||||
|
||||
public GrinderRecipe(ItemStack input1, FluidStack fluidStack, ItemStack output1, ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int euPerTick)
|
||||
{
|
||||
super("grinderRecipe", tickTime, euPerTick);
|
||||
if(input1 != null)
|
||||
inputs.add(input1);
|
||||
if(output1 != null)
|
||||
outputs.add(output1);
|
||||
if(output2 != null)
|
||||
outputs.add(output2);
|
||||
if(output3 != null)
|
||||
outputs.add(output3);
|
||||
if(output4 != null)
|
||||
outputs.add(output4);
|
||||
this.fluidStack = fluidStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCraft(TileEntity tile) {
|
||||
if(tile instanceof TileGrinder){
|
||||
TileGrinder grinder = (TileGrinder) tile;
|
||||
if(grinder.tank.getFluid() == null){
|
||||
return false;
|
||||
}
|
||||
if(grinder.tank.getFluid().getFluidID() == fluidStack.getFluidID()){
|
||||
if(grinder.tank.getFluidAmount() >= fluidStack.amount){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCraft(TileEntity tile) {
|
||||
if(tile instanceof TileGrinder) {
|
||||
TileGrinder grinder = (TileGrinder) tile;
|
||||
if(grinder.tank.getFluid() == null){
|
||||
return false;
|
||||
}
|
||||
if(grinder.tank.getFluid().getFluidID() == fluidStack.getFluidID()){
|
||||
if(grinder.tank.getFluidAmount() >= fluidStack.amount){
|
||||
if(grinder.tank.getFluidAmount() > 0){
|
||||
grinder.tank.setFluid(new FluidStack(fluidStack.getFluid(), grinder.tank.getFluidAmount() - fluidStack.amount));
|
||||
} else {
|
||||
grinder.tank.setFluid(null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -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…
Reference in a new issue