Removed fluid tank from IndustrialElectrolyzer closes #58

This commit is contained in:
gigabit101 2015-07-02 23:39:36 +01:00
parent b7a9824cd3
commit 26eff9bcbf
7 changed files with 14 additions and 186 deletions

View file

@ -8,9 +8,7 @@ import techreborn.tiles.TileIndustrialElectrolyzer;
public class IndustrialElectrolyzerRecipe extends BaseRecipe {
public FluidStack fluidStack;
public IndustrialElectrolyzerRecipe(ItemStack inputCells, ItemStack input2, FluidStack fluidStack, ItemStack output1, ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int euPerTick)
public IndustrialElectrolyzerRecipe(ItemStack inputCells, ItemStack input2, ItemStack output1, ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int euPerTick)
{
super("industrialElectrolyzerRecipe", tickTime, euPerTick);
if (inputCells != null)
@ -25,26 +23,6 @@ public class IndustrialElectrolyzerRecipe extends BaseRecipe {
addOutput(output3);
if (output4 != null)
addOutput(output4);
this.fluidStack = fluidStack;
}
public IndustrialElectrolyzerRecipe(boolean userOreDic, ItemStack inputCells, ItemStack input2, FluidStack fluidStack, ItemStack output1, ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int euPerTick)
{
super("industrialElectrolyzerRecipe", tickTime, euPerTick);
this.useOreDictionary = userOreDic;
if (inputCells != null)
inputs.add(inputCells);
if( input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
if (output2 != null)
addOutput(output2);
if (output3 != null)
addOutput(output3);
if (output4 != null)
addOutput(output4);
this.fluidStack = fluidStack;
}
@Override
@ -52,49 +30,6 @@ public class IndustrialElectrolyzerRecipe extends BaseRecipe {
return "Industrial Electrolyzer";
}
@Override
public boolean canCraft(TileEntity tile) {
if (fluidStack == null) {
return true;
}
if (tile instanceof TileIndustrialElectrolyzer) {
TileIndustrialElectrolyzer grinder = (TileIndustrialElectrolyzer) 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 (fluidStack == null) {
return true;
}
if (tile instanceof TileIndustrialElectrolyzer) {
TileIndustrialElectrolyzer grinder = (TileIndustrialElectrolyzer) 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;
}
@Override
public boolean useOreDic()
{

View file

@ -33,9 +33,6 @@ public class ContainerIndustrialElectrolyzer extends ContainerCrafting {
this.addSlotToContainer(new SlotOutput(electrolyzer.inventory, 3, 70, 19));
this.addSlotToContainer(new SlotOutput(electrolyzer.inventory, 4, 90, 19));
this.addSlotToContainer(new SlotOutput(electrolyzer.inventory, 5, 110, 19));
// power
this.addSlotToContainer(new Slot(electrolyzer.inventory, 6, 8, 51));
int i;
for (i = 0; i < 3; ++i)

View file

@ -40,25 +40,6 @@ public class GuiIndustrialElectrolyzer extends GuiContainer {
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
if (eletrolyzer.tank.getFluidAmount() != 0)
{
IIcon fluidIcon = eletrolyzer.tank.getFluid().getFluid().getIcon();
if (fluidIcon != null)
{
drawTexturedModalRect(k + 7, l + 15, 176, 31, 20, 55);
this.mc.renderEngine
.bindTexture(TextureMap.locationBlocksTexture);
int liquidHeight = eletrolyzer.tank.getFluidAmount() * 47
/ eletrolyzer.tank.getCapacity();
DrawUtil.drawRepeated(fluidIcon, k + 11, l + 19 + 47
- liquidHeight, 12.0D, liquidHeight, this.zLevel);
this.mc.renderEngine.bindTexture(texture);
drawTexturedModalRect(k + 11, l + 19, 176, 86, 12, 47);
}
}
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_,

View file

@ -2,6 +2,7 @@ package techreborn.compat.nei.recipes;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import ic2.core.util.DrawUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
@ -12,6 +13,7 @@ import techreborn.api.recipe.machines.IndustrialElectrolyzerRecipe;
import techreborn.client.gui.GuiIndustrialElectrolyzer;
import techreborn.util.ItemUtils;
import java.awt.Rectangle;
import java.util.List;
public class IndustrialElectrolyzerRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe {
@ -68,25 +70,9 @@ public class IndustrialElectrolyzerRecipeHandler extends GenericRecipeHander imp
}
@Override
public void drawBackground(int recipeIndex) {
super.drawBackground(recipeIndex);
CachedRecipe recipe = arecipes.get(recipeIndex);
if (recipe instanceof CachedGenericRecipe) {
if (((CachedGenericRecipe) recipe).recipie instanceof IndustrialElectrolyzerRecipe) {
IndustrialElectrolyzerRecipe grinderRecipe = (IndustrialElectrolyzerRecipe) ((CachedGenericRecipe) recipe).recipie;
if (grinderRecipe.fluidStack != null) {
IIcon fluidIcon = grinderRecipe.fluidStack.getFluid().getIcon();
if (fluidIcon != null) {
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
int liquidHeight = grinderRecipe.fluidStack.amount * 100 / 16000;
DrawUtil.drawRepeated(fluidIcon, 7, 22 + 47 - liquidHeight, 14.0D, liquidHeight, GuiDraw.gui.getZLevel());
}
GuiDraw.drawString(grinderRecipe.fluidStack.amount + "mb of " + grinderRecipe.fluidStack.getLocalizedName(), 14, 135, -1);
}
}
public void loadTransferRects() {
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
new Rectangle(80, 20, 15, 15), getNeiBaseRecipe().getRecipeName(), new Object[0]));
}
}
}

View file

@ -1953,7 +1953,6 @@ public class ModRecipes {
static void addIndustrialElectrolyzerRecipes() {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
null,
ItemCells.getCellByName("sulfuricAcid", 7),
null,
ItemCells.getCellByName("hydrogen", 2),
@ -1964,7 +1963,6 @@ public class ModRecipes {
));
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
null,
ItemCells.getCellByName("nitrocarbon", 2),
null,
ItemCells.getCellByName("nitrogen"),
@ -1977,7 +1975,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemDusts.getDustByName("ruby", 6),
IC2Items.getItem("cell"),
null,
ItemDusts.getDustByName("aluminum", 2),
new ItemStack(IC2Items.getItem("cell").getItem(), 1, 5),
ItemDusts.getDustByName("chrome", 1),
@ -1988,7 +1985,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemDusts.getDustByName("sapphire", 5),
IC2Items.getItem("cell"),
null,
ItemDusts.getDustByName("aluminum", 2),
new ItemStack(IC2Items.getItem("cell").getItem(), 1, 5),
null,
@ -1999,7 +1995,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemCells.getCellByName("nitrogenDioxide", 3),
null,
null,
ItemCells.getCellByName("nitrogen", 1),
new ItemStack(IC2Items.getItem("cell").getItem(), 1, 5),
null,
@ -2010,7 +2005,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemCells.getCellByName("sodiumSulfide", 2),
null,
null,
ItemCells.getCellByName("sodium", 1),
ItemDusts.getDustByName("sulfur", 1),
null,
@ -2021,7 +2015,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemDusts.getDustByName("greenSapphire", 5),
IC2Items.getItem("cell"),
null,
ItemDusts.getDustByName("aluminum", 2),
new ItemStack(IC2Items.getItem("cell").getItem(), 1, 5),
null,
@ -2032,7 +2025,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemDusts.getDustByName("emerald", 29),
new ItemStack(IC2Items.getItem("cell").getItem(), 18, 0),
null,
ItemCells.getCellByName("berylium", 3),
ItemDusts.getDustByName("aluminum", 2),
ItemCells.getCellByName("silicon", 6),
@ -2043,7 +2035,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
new ItemStack(IC2Items.getItem("silicondioxideDust").getItem(), 3, 0),
new ItemStack(IC2Items.getItem("cell").getItem(), 2, 0),
null,
ItemCells.getCellByName("silicon", 1),
new ItemStack(IC2Items.getItem("cell").getItem(), 1, 5),
null,
@ -2051,21 +2042,18 @@ public class ModRecipes {
60, 60
));
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(false,
new ItemStack(Items.dye, 3, 15),
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(new ItemStack(Items.dye, 3, 15),
new ItemStack(IC2Items.getItem("cell").getItem(), 1, 0),
null,
ItemCells.getCellByName("calcium", 1),
null,
null,
null,
20, 106
));
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemCells.getCellByName("glyceryl", 20),
null,
null,
ItemCells.getCellByName("carbon", 3),
ItemCells.getCellByName("hydrogen", 5),
ItemCells.getCellByName("nitrogen", 3),
@ -2076,7 +2064,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemDusts.getDustByName("peridot", 9),
new ItemStack(IC2Items.getItem("cell").getItem(), 4, 0),
null,
ItemDusts.getDustByName("magnesium", 2),
ItemDusts.getDustByName("iron"),
ItemCells.getCellByName("silicon", 2),
@ -2087,7 +2074,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemCells.getCellByName("calciumCarbonate", 5),
null,
null,
ItemCells.getCellByName("carbon"),
ItemCells.getCellByName("calcium"),
new ItemStack(IC2Items.getItem("cell").getItem(), 1, 5),
@ -2098,7 +2084,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemCells.getCellByName("sodiumPersulfate", 6),
null,
null,
ItemCells.getCellByName("sodium"),
ItemDusts.getDustByName("sulfur"),
new ItemStack(IC2Items.getItem("cell").getItem(), 2, 5),
@ -2109,7 +2094,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemDusts.getDustByName("pyrope", 20),
new ItemStack(IC2Items.getItem("cell").getItem(), 9, 0),
null,
ItemDusts.getDustByName("aluminum", 2),
ItemDusts.getDustByName("magnesium", 3),
ItemCells.getCellByName("silicon", 3),
@ -2123,7 +2107,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
sand,
new ItemStack(IC2Items.getItem("cell").getItem(), 2, 0),
null,
ItemCells.getCellByName("silicon", 1),
new ItemStack(IC2Items.getItem("cell").getItem(), 1, 5),
null,
@ -2134,7 +2117,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemDusts.getDustByName("almandine", 20),
new ItemStack(IC2Items.getItem("cell").getItem(), 9, 0),
null,
ItemDusts.getDustByName("aluminum", 2),
ItemDusts.getDustByName("iron", 3),
ItemCells.getCellByName("silicon", 3),
@ -2145,7 +2127,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemDusts.getDustByName("spessartine", 20),
new ItemStack(IC2Items.getItem("cell").getItem(), 9, 0),
null,
ItemDusts.getDustByName("aluminum", 2),
ItemDusts.getDustByName("manganese", 3),
ItemCells.getCellByName("silicon", 3),
@ -2156,7 +2137,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemDusts.getDustByName("andradite", 20),
new ItemStack(IC2Items.getItem("cell").getItem(), 12, 0),
null,
ItemCells.getCellByName("calcium", 3),
ItemDusts.getDustByName("iron", 2),
ItemCells.getCellByName("silicon", 3),
@ -2167,7 +2147,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemDusts.getDustByName("grossular", 20),
new ItemStack(IC2Items.getItem("cell").getItem(), 12, 0),
null,
ItemCells.getCellByName("calcium", 3),
ItemDusts.getDustByName("aluminum", 2),
ItemCells.getCellByName("silicon", 3),
@ -2178,7 +2157,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemDusts.getDustByName("Uvarovite", 20),
new ItemStack(IC2Items.getItem("cell").getItem(), 12, 0),
null,
ItemCells.getCellByName("calcium", 3),
ItemDusts.getDustByName("chrome", 2),
ItemCells.getCellByName("silicon", 3),
@ -2189,7 +2167,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
new ItemStack(IC2Items.getItem("cell").getItem(), 6, 10),
null,
null,
ItemCells.getCellByName("hydrogen", 4),
new ItemStack(IC2Items.getItem("cell").getItem(), 1, 5),
new ItemStack(IC2Items.getItem("cell").getItem(), 1, 0),
@ -2200,7 +2177,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
ItemDusts.getDustByName("darkAshes"),
new ItemStack(IC2Items.getItem("cell").getItem(), 2, 0),
null,
ItemCells.getCellByName("carbon", 2),
null,
null,
@ -2214,7 +2190,6 @@ public class ModRecipes {
RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(
salt,
new ItemStack(IC2Items.getItem("cell").getItem(), 2, 0),
null,
ItemCells.getCellByName("sodium"),
ItemCells.getCellByName("chlorine"),
null,

View file

@ -20,12 +20,11 @@ import techreborn.init.ModFluids;
import techreborn.util.Inventory;
import techreborn.util.Tank;
public class TileIndustrialElectrolyzer extends TileMachineBase implements IWrenchable, IEnergyTile, IFluidHandler, IInventory, ISidedInventory {
public class TileIndustrialElectrolyzer extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(7, "TileIndustrialElectrolyzer", 64);
public Tank tank = new Tank("TileIndustrialElectrolyzer", 16000, this);
public RecipeCrafter crafter;
public TileIndustrialElectrolyzer()
@ -36,9 +35,12 @@ public class TileIndustrialElectrolyzer extends TileMachineBase implements IWren
int[] inputs = new int[2];
inputs[0] = 0;
inputs[1] = 1;
int[] outputs = new int[1];
int[] outputs = new int[4];
outputs[0] = 2;
crafter = new RecipeCrafter("industrialelectrolyzerRecipe", this, energy, 2, 1, inventory, inputs, outputs);
outputs[1] = 3;
outputs[2] = 4;
outputs[3] = 5;
crafter = new RecipeCrafter("industrialelectrolyzerRecipe", this, energy, 2, 4, inventory, inputs, outputs);
}
@Override
@ -100,7 +102,6 @@ public class TileIndustrialElectrolyzer extends TileMachineBase implements IWren
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound);
}
@Override
@ -109,7 +110,6 @@ public class TileIndustrialElectrolyzer extends TileMachineBase implements IWren
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
}
@ -217,50 +217,4 @@ public class TileIndustrialElectrolyzer extends TileMachineBase implements IWren
return slotIndex == 2 || slotIndex == 3 || slotIndex == 4 || slotIndex == 5;
}
/* IFluidHandler */
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
if(resource.getFluid() == FluidRegistry.WATER || resource.getFluid() == ModFluids.fluidMercury || resource.getFluid() == ModFluids.fluidSodiumpersulfate) {
int filled = tank.fill(resource, doFill);
tank.compareAndUpdate();
return filled;
}
return 0;
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
if (resource == null || !resource.isFluidEqual(tank.getFluid())) {
return null;
}
FluidStack fluidStack = tank.drain(resource.amount, doDrain);
tank.compareAndUpdate();
return fluidStack;
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
FluidStack drained = tank.drain(maxDrain, doDrain);
tank.compareAndUpdate();
return drained;
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
if(fluid == FluidRegistry.WATER || fluid == ModFluids.fluidMercury || fluid == ModFluids.fluidSodiumpersulfate) {
return true;
}
return false;
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return false;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return new FluidTankInfo[] { tank.getInfo() };
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB