From 05c78126859231a68e199dc34613689bd0978e2f Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Mon, 11 Apr 2016 19:44:54 +0300 Subject: Initial commit --- ihl/processing/chemistry/AbsorberCoolerModel.java | 78 ++++ .../chemistry/ApparatusProcessableInvSlot.java | 67 ++++ ihl/processing/chemistry/BatteryItem.java | 197 +++++++++ .../chemistry/ChemicalReactorContainer.java | 109 +++++ ihl/processing/chemistry/ChemicalReactorGui.java | 84 ++++ .../chemistry/ChemicalReactorTileEntity.java | 363 +++++++++++++++++ .../chemistry/CryogenicDistillerContainer.java | 90 +++++ .../chemistry/CryogenicDistillerGui.java | 62 +++ .../chemistry/CryogenicDistillerTileEntity.java | 252 ++++++++++++ .../chemistry/ElectricEvaporatorBlock.java | 221 ++++++++++ .../chemistry/ElectricEvaporatorContainer.java | 113 ++++++ .../chemistry/ElectricEvaporatorGui.java | 86 ++++ .../chemistry/ElectricEvaporatorTileEntity.java | 444 +++++++++++++++++++++ .../chemistry/ElectrolysisBathContainer.java | 94 +++++ ihl/processing/chemistry/ElectrolysisBathGui.java | 100 +++++ .../chemistry/ElectrolysisBathModel.java | 86 ++++ .../chemistry/ElectrolysisBathTileEntity.java | 312 +++++++++++++++ ihl/processing/chemistry/EvaporatorBlock.java | 222 +++++++++++ ihl/processing/chemistry/EvaporatorContainer.java | 100 +++++ ihl/processing/chemistry/EvaporatorGui.java | 85 ++++ ihl/processing/chemistry/EvaporatorTileEntity.java | 299 ++++++++++++++ ihl/processing/chemistry/ExplosiveTileEntity.java | 49 +++ ihl/processing/chemistry/ExtruderModel.java | 100 +++++ .../chemistry/FluidizedBedReactorContainer.java | 103 +++++ .../chemistry/FluidizedBedReactorGui.java | 66 +++ .../chemistry/FluidizedBedReactorTileEntity.java | 358 +++++++++++++++++ .../chemistry/FractionatorBottomModel.java | 48 +++ .../chemistry/FractionatorBottomTileEntity.java | 389 ++++++++++++++++++ .../chemistry/FractionatorCoverModel.java | 52 +++ .../chemistry/FractionatorCoverTileEntity.java | 105 +++++ .../chemistry/FractionatorSectionModel.java | 47 +++ .../chemistry/FractionatorSectionTileEntity.java | 146 +++++++ .../GaedesMercuryRotaryPumpContainer.java | 76 ++++ .../chemistry/GaedesMercuryRotaryPumpGui.java | 69 ++++ .../chemistry/GaedesMercuryRotaryPumpModel.java | 64 +++ .../GaedesMercuryRotaryPumpTileEntity.java | 83 ++++ ihl/processing/chemistry/GoldChimneyKneeModel.java | 45 +++ .../chemistry/GoldChimneyKneeRender.java | 50 +++ .../chemistry/GoldChimneyKneeTileEntity.java | 293 ++++++++++++++ .../chemistry/LabElectrolyzerContainer.java | 133 ++++++ ihl/processing/chemistry/LabElectrolyzerGui.java | 83 ++++ .../chemistry/LabElectrolyzerTileEntity.java | 298 ++++++++++++++ ihl/processing/chemistry/LeadOvenContainer.java | 80 ++++ ihl/processing/chemistry/LeadOvenGui.java | 51 +++ ihl/processing/chemistry/LeadOvenTileEntity.java | 343 ++++++++++++++++ ihl/processing/chemistry/LoomContainer.java | 66 +++ ihl/processing/chemistry/LoomGui.java | 61 +++ ihl/processing/chemistry/LoomModel.java | 66 +++ ihl/processing/chemistry/LoomTileEntity.java | 173 ++++++++ .../chemistry/PaperMachineContainer.java | 106 +++++ ihl/processing/chemistry/PaperMachineGui.java | 84 ++++ .../chemistry/PaperMachineTileEntity.java | 320 +++++++++++++++ .../chemistry/PrecipitatorCondenserModel.java | 110 +++++ .../chemistry/PrecipitatorCondenserRender.java | 50 +++ .../chemistry/PrecipitatorCondenserTileEntity.java | 380 ++++++++++++++++++ ihl/processing/chemistry/RefluxCondenserModel.java | 70 ++++ .../chemistry/RefluxCondenserTileEntity.java | 146 +++++++ 57 files changed, 8227 insertions(+) create mode 100644 ihl/processing/chemistry/AbsorberCoolerModel.java create mode 100644 ihl/processing/chemistry/ApparatusProcessableInvSlot.java create mode 100644 ihl/processing/chemistry/BatteryItem.java create mode 100644 ihl/processing/chemistry/ChemicalReactorContainer.java create mode 100644 ihl/processing/chemistry/ChemicalReactorGui.java create mode 100644 ihl/processing/chemistry/ChemicalReactorTileEntity.java create mode 100644 ihl/processing/chemistry/CryogenicDistillerContainer.java create mode 100644 ihl/processing/chemistry/CryogenicDistillerGui.java create mode 100644 ihl/processing/chemistry/CryogenicDistillerTileEntity.java create mode 100644 ihl/processing/chemistry/ElectricEvaporatorBlock.java create mode 100644 ihl/processing/chemistry/ElectricEvaporatorContainer.java create mode 100644 ihl/processing/chemistry/ElectricEvaporatorGui.java create mode 100644 ihl/processing/chemistry/ElectricEvaporatorTileEntity.java create mode 100644 ihl/processing/chemistry/ElectrolysisBathContainer.java create mode 100644 ihl/processing/chemistry/ElectrolysisBathGui.java create mode 100644 ihl/processing/chemistry/ElectrolysisBathModel.java create mode 100644 ihl/processing/chemistry/ElectrolysisBathTileEntity.java create mode 100644 ihl/processing/chemistry/EvaporatorBlock.java create mode 100644 ihl/processing/chemistry/EvaporatorContainer.java create mode 100644 ihl/processing/chemistry/EvaporatorGui.java create mode 100644 ihl/processing/chemistry/EvaporatorTileEntity.java create mode 100644 ihl/processing/chemistry/ExplosiveTileEntity.java create mode 100644 ihl/processing/chemistry/ExtruderModel.java create mode 100644 ihl/processing/chemistry/FluidizedBedReactorContainer.java create mode 100644 ihl/processing/chemistry/FluidizedBedReactorGui.java create mode 100644 ihl/processing/chemistry/FluidizedBedReactorTileEntity.java create mode 100644 ihl/processing/chemistry/FractionatorBottomModel.java create mode 100644 ihl/processing/chemistry/FractionatorBottomTileEntity.java create mode 100644 ihl/processing/chemistry/FractionatorCoverModel.java create mode 100644 ihl/processing/chemistry/FractionatorCoverTileEntity.java create mode 100644 ihl/processing/chemistry/FractionatorSectionModel.java create mode 100644 ihl/processing/chemistry/FractionatorSectionTileEntity.java create mode 100644 ihl/processing/chemistry/GaedesMercuryRotaryPumpContainer.java create mode 100644 ihl/processing/chemistry/GaedesMercuryRotaryPumpGui.java create mode 100644 ihl/processing/chemistry/GaedesMercuryRotaryPumpModel.java create mode 100644 ihl/processing/chemistry/GaedesMercuryRotaryPumpTileEntity.java create mode 100644 ihl/processing/chemistry/GoldChimneyKneeModel.java create mode 100644 ihl/processing/chemistry/GoldChimneyKneeRender.java create mode 100644 ihl/processing/chemistry/GoldChimneyKneeTileEntity.java create mode 100644 ihl/processing/chemistry/LabElectrolyzerContainer.java create mode 100644 ihl/processing/chemistry/LabElectrolyzerGui.java create mode 100644 ihl/processing/chemistry/LabElectrolyzerTileEntity.java create mode 100644 ihl/processing/chemistry/LeadOvenContainer.java create mode 100644 ihl/processing/chemistry/LeadOvenGui.java create mode 100644 ihl/processing/chemistry/LeadOvenTileEntity.java create mode 100644 ihl/processing/chemistry/LoomContainer.java create mode 100644 ihl/processing/chemistry/LoomGui.java create mode 100644 ihl/processing/chemistry/LoomModel.java create mode 100644 ihl/processing/chemistry/LoomTileEntity.java create mode 100644 ihl/processing/chemistry/PaperMachineContainer.java create mode 100644 ihl/processing/chemistry/PaperMachineGui.java create mode 100644 ihl/processing/chemistry/PaperMachineTileEntity.java create mode 100644 ihl/processing/chemistry/PrecipitatorCondenserModel.java create mode 100644 ihl/processing/chemistry/PrecipitatorCondenserRender.java create mode 100644 ihl/processing/chemistry/PrecipitatorCondenserTileEntity.java create mode 100644 ihl/processing/chemistry/RefluxCondenserModel.java create mode 100644 ihl/processing/chemistry/RefluxCondenserTileEntity.java (limited to 'ihl/processing/chemistry') diff --git a/ihl/processing/chemistry/AbsorberCoolerModel.java b/ihl/processing/chemistry/AbsorberCoolerModel.java new file mode 100644 index 0000000..7dac4c9 --- /dev/null +++ b/ihl/processing/chemistry/AbsorberCoolerModel.java @@ -0,0 +1,78 @@ +package ihl.processing.chemistry; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; + +public class AbsorberCoolerModel extends ModelBase +{ + //fields + ModelRenderer Base; + + public AbsorberCoolerModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape1", 26, 0); + setTextureOffset("Base.Shape2", 0, 17); + setTextureOffset("Base.Shape4", 30, 16); + setTextureOffset("Base.Shape3", 0, 15); + setTextureOffset("Base.Shape5", 2, 12); + setTextureOffset("Base.Shape6", 0, 2); + setTextureOffset("Base.Shape7", 24, 4); + setTextureOffset("Base.Shape8", 50, 0); + setTextureOffset("Base.Shape9", 0, 0); + setTextureOffset("Base.Shape10", 0, 0); + setTextureOffset("Base.Shape11", 0, 0); + setTextureOffset("Base.Shape12", 0, 0); + setTextureOffset("Base.Shape13", 0, 0); + setTextureOffset("Base.Shape14", 0, 0); + setTextureOffset("Base.Shape15", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("Base.Shape17", 0, 0); + setTextureOffset("Base.Shape18", 0, 0); + setTextureOffset("Base.Shape19", 0, 0); + setTextureOffset("Base.Shape20", 0, 0); + setTextureOffset("Base.Shape21", 0, 0); + setTextureOffset("Base.Shape22", 0, 0); + setTextureOffset("Base.Shape23", 0, 24); + setTextureOffset("Base.Shape24", 7, 12); + setTextureOffset("Base.Shape25", 21, 8); + setTextureOffset("Base.Shape26", 12, 24); + setTextureOffset("Base.Shape27", 0, 0); + setTextureOffset("Base.Shape28", 0, 18); + setTextureOffset("Base.Shape29", 21, 0); + + Base = new ModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 23F, 0F); + Base.mirror = true; + Base.addBox("Shape1", 6F, -14F, -7F, 1, 14, 14); + Base.addBox("Shape2", -7F, -1F, -8F, 14, 1, 1); + Base.addBox("Shape4", 6F, -14F, -8F, 1, 13, 1); + Base.addBox("Shape3", -7F, -1F, 7F, 14, 1, 1); + Base.addBox("Shape5", -7F, -15F, -8F, 6, 1, 16); + Base.addBox("Shape6", -7F, -14F, 7F, 1, 13, 1); + Base.addBox("Shape7", -7F, -14F, -7F, 1, 14, 14); + Base.addBox("Shape8", -7F, -14F, -8F, 1, 13, 1); + Base.addBox("Shape9", 1F, 0F, -8F, 7, 1, 16); + Base.addBox("Shape10", 6F, -14F, 7F, 1, 13, 1); + Base.addBox("Shape11", 3.5F, -13F, -7F, 1, 1, 14); + Base.addBox("Shape12", 1.5F, -13F, -7F, 1, 1, 14); + Base.addBox("Shape13", -2.5F, -13F, -7F, 1, 1, 14); + Base.addBox("Shape14", -4.5F, -13F, -7F, 1, 1, 14); + Base.addBox("Shape15", -0.5F, -13F, -7F, 1, 1, 14); + Base.addBox("Shape16", -6F, -12.5F, -1.5F, 12, 1, 1); + Base.addBox("Shape17", -6F, -12.5F, -3.5F, 12, 1, 1); + Base.addBox("Shape18", -6F, -12.5F, -5.5F, 12, 1, 1); + Base.addBox("Shape19", -6F, -12.5F, 0.5F, 12, 1, 1); + Base.addBox("Shape20", -6F, -12.5F, 2.5F, 12, 1, 1); + Base.addBox("Shape21", -6F, -12.5F, 4.5F, 12, 1, 1); + Base.addBox("Shape22", -6F, 9F, 7F, 12, 2, 1); + Base.addBox("Shape23", -6F, -14F, -8F, 12, 2, 1); + Base.addBox("Shape24", 1F, -15F, -8F, 6, 1, 16); + Base.addBox("Shape25", -1F, -15F, 1F, 2, 1, 7); + Base.addBox("Shape26", -1F, -15F, -8F, 2, 1, 7); + Base.addBox("Shape27", -8F, 0F, -8F, 7, 1, 16); + Base.addBox("Shape28", -1F, 0F, 1F, 2, 1, 7); + Base.addBox("Shape29", -1F, 0F, -8F, 2, 1, 7); + } +} diff --git a/ihl/processing/chemistry/ApparatusProcessableInvSlot.java b/ihl/processing/chemistry/ApparatusProcessableInvSlot.java new file mode 100644 index 0000000..f0b69b3 --- /dev/null +++ b/ihl/processing/chemistry/ApparatusProcessableInvSlot.java @@ -0,0 +1,67 @@ +package ihl.processing.chemistry; + +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlot; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class ApparatusProcessableInvSlot extends InvSlot { + + public ApparatusProcessableInvSlot(TileEntityInventory base1, String name1, + int oldStartIndex1, Access access1, int count, int stackSizeLimit1) { + super(base1, name1, oldStartIndex1, access1, count); + this.setStackSizeLimit(stackSizeLimit1); + } + + public List getItemStackList() + { + List list = new ArrayList(); + for(int i=0; i iconMap = new HashMap(); + private static Map nameMap = new HashMap(); + private static Map descriptionMap = new HashMap(); + + public BatteryItem() + { + super(); + this.setMaxDamage(27); + this.setCreativeTab(IHLCreativeTab.tab); + this.maxStackSize=1; + this.canRepair=false; + this.setUnlocalizedName("battery"); + } + + public static void init() + { + BatteryItem item = new BatteryItem(); + GameRegistry.registerItem(item,item.getUnlocalizedName()); + Type[] var1 = Type.values(); + for(int i=0;i getHudInfo(ItemStack itemStack) + { + LinkedList info = new LinkedList(); + info.add(ElectricItem.manager.getToolTip(itemStack)); + return info; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) + { + Type[] var1 = Type.values(); + for(int i=0;i fluidTankFluidList; + + public ChemicalReactorContainer(EntityPlayer entityPlayer, ChemicalReactorTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + fluidTankFluidList=tileEntity.getFluidTank().getFluidList(); + int col; + for (col = 0; col < 3; ++col) + { + for (int col1 = 0; col1 < 9; ++col1) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); + } + } + for (col = 0; col < 9; ++col) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); + } + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 60, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 60, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 60, 33)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 122-18, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 1, 122, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 122-18, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 1, 122, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.engine, 0, 8, 33)); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + + if (this.tileEntity.getTankAmount() != this.lastFluidAmount || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + + if (this.tileEntity.temperature != this.lastTemperature) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.temperature); + } + + + if ((short) this.tileEntity.energy != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 2, (short) this.tileEntity.energy); + } + } + + this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank(); + this.lastFluidAmount = this.tileEntity.getTankAmount(); + this.lastProgress = this.tileEntity.progress; + this.lastTemperature = this.tileEntity.temperature; + this.lastEnergy = (short) this.tileEntity.energy; + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + switch (index) + { + case 0: + this.tileEntity.progress=(short) value; + break; + case 1: + this.tileEntity.temperature=(short) value; + break; + case 2: + this.tileEntity.energy=value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/ChemicalReactorGui.java b/ihl/processing/chemistry/ChemicalReactorGui.java new file mode 100644 index 0000000..6342d40 --- /dev/null +++ b/ihl/processing/chemistry/ChemicalReactorGui.java @@ -0,0 +1,84 @@ +package ihl.processing.chemistry; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import ihl.utils.IHLRenderUtils; + +@SideOnly(Side.CLIENT) +public class ChemicalReactorGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIChemicalReactor.png"); + private ChemicalReactorContainer container; + private int mixerFrame=0; + + public ChemicalReactorGui (ChemicalReactorContainer container1) { + //the container is instanciated and passed to the superclass for handling + super(container1); + this.container=container1; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(12, 16 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27); + this.drawTexturedModalRect(30, 29, getFrameX(i1), getFrameY(i1),24,24); + if(mixerFrame++>4) + { + mixerFrame=0; + } + } + else + { + mixerFrame=0; + } + this.drawTexturedModalRect(103-18, 52, 246, 226+6*mixerFrame,10,6); + if (this.container.tileEntity.getTankAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 102-18, 28, 114-18, 59, zLevel, par1, par2, xOffset, yOffset); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(background); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 26, 34, xOffset, yOffset); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } + + private int getFrameY(int number) + { + return (number % 10) * 24 + 14; + } + + private int getFrameX(int number) + { + return (number / 10) * 24 + 176; + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/ChemicalReactorTileEntity.java b/ihl/processing/chemistry/ChemicalReactorTileEntity.java new file mode 100644 index 0000000..7720d2b --- /dev/null +++ b/ihl/processing/chemistry/ChemicalReactorTileEntity.java @@ -0,0 +1,363 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.processing.metallurgy.BasicElectricMotorTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; + +public class ChemicalReactorTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler +{ + private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("chemicalreactor"); + public final ApparatusProcessableInvSlot input; + public final IHLInvSlotOutput outputSlot; + public final InvSlotConsumableLiquidIHL drainInputSlot; + public final InvSlotConsumableLiquidIHL fillInputSlot; + public final InvSlotOutput emptyFluidItemsSlot; + private final IHLFluidTank fluidTank = new IHLFluidTank(8000); + public short temperature=20; + + public ChemicalReactorTileEntity() { + super(); + this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 2); + this.drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); + this.fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 1); + this.input = new ApparatusProcessableInvSlot(this, "input", 3, Access.IO, 2, 64); + this.isGuiScreenOpened=true; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("chemicalReactor"); + } + + @Override + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank); + } + + @Override + public FluidStack drain(ForgeDirection from, int amount, boolean doDrain) + { + switch(from) + { + case UP: + return this.fluidTank.drainLightest(amount, doDrain); + case NORTH: + return this.fluidTank.drainLightest(amount, doDrain); + case SOUTH: + return this.fluidTank.drainLightest(amount, doDrain); + case WEST: + return this.fluidTank.drainLightest(amount, doDrain); + case EAST: + return this.fluidTank.drainLightest(amount, doDrain); + case DOWN: + return this.fluidTank.drain(amount, doDrain); + default: + return this.fluidTank.drain(amount, doDrain); + } + } + + //1.7.10 API + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return true; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return direction.equals(ForgeDirection.getOrientation(this.getFacing()).getOpposite()); + } + + @Override + public String getInventoryName() { + return "chemicalReactor"; + } + + private int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + private int mZ() + { + switch(this.getFacing()) + { + case 3: + return 1; + case 2: + return -1; + case 4: + return 0; + case 5: + return 0; + default: + return -1; + } + } + + private short getFacingFromXZ(int x, int z) + { + switch(x) + { + case -1: + return (short)4; + case 1: + return (short)5; + default: + switch(z) + { + case 1: + return (short)3; + case -1: + return (short)2; + default: + return (short)2; + } + } + } + + public float getRenderLiquidLevel() + { + return (float)this.fluidTank.getFluidAmount()/(float)this.fluidTank.getCapacity(); + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + // TODO Auto-generated method stub + } + + @Override + public int gaugeProgressScaled(int i) + { + return this.progress * i / operationLength; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new ChemicalReactorGui(new ChemicalReactorContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) + { + this.fluidTank.sortFluidsByDensity(); + return new ChemicalReactorContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) {} + + @Override + public boolean canOperate() + { + UniversalRecipeOutput output = getOutput(); + if(output!=null && this.outputSlot.canAdd(getOutput().getItemOutputs())) + { + if(output.specialConditions) + { + return this.checkSpecialConditions(); + } + else + { + return true; + } + } + return false; + } + + private boolean checkSpecialConditions() + { + ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing()); + TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX, yCoord, zCoord+dir.offsetZ); + if(te instanceof CryogenicDistillerTileEntity) + { + CryogenicDistillerTileEntity cgte = (CryogenicDistillerTileEntity)te; + return cgte.getFacing()==this.getFacing() && cgte.canProcess(); + } + return false; + } + + public UniversalRecipeOutput getOutput() + { + return ChemicalReactorTileEntity.recipeManager.getOutputFor(this.getInput()[0],this.getInput()[1], false, false); + } + + @Override + public List[] getInput() + { + for(int i=0;i getRecipes() { + return recipeManager.getRecipes(); + } + + public static void addRecipe(FluidStack fluidStackInput1, FluidStack fluidStackInput2, ItemStack itemStackInput, FluidStack fluidStackOutput, ItemStack itemStackOutput1, ItemStack itemStackOutput2) + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1, fluidStackInput2}), Arrays.asList(new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStackOutput}), Arrays.asList(new ItemStack[] {itemStackOutput1, itemStackOutput2}),200)); + } + + public static void addSpecialConditionsRecipe(FluidStack fluidStackInput1, FluidStack fluidStackInput2, ItemStack itemStackInput, FluidStack fluidStackOutput, ItemStack itemStackOutput1, ItemStack itemStackOutput2) + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1, fluidStackInput2}), Arrays.asList(new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStackOutput}), Arrays.asList(new ItemStack[] {itemStackOutput1, itemStackOutput2}),200, true)); + } + + public IHLFluidTank getFluidTank() + { + return this.fluidTank; + } + +} \ No newline at end of file diff --git a/ihl/processing/chemistry/CryogenicDistillerContainer.java b/ihl/processing/chemistry/CryogenicDistillerContainer.java new file mode 100644 index 0000000..d3ed523 --- /dev/null +++ b/ihl/processing/chemistry/CryogenicDistillerContainer.java @@ -0,0 +1,90 @@ +package ihl.processing.chemistry; + +import java.util.List; + +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraftforge.fluids.FluidStack; + +public class CryogenicDistillerContainer extends ContainerBase { + + public CryogenicDistillerTileEntity tileEntity; + public int lastProgress = -1; + private short lastEnergy = -1; + private int lastNumberOfFluids = -1; + private int lastFluidAmount = -1; + private final static int height=166; + public List fluidTankFluidList; + + public CryogenicDistillerContainer(EntityPlayer entityPlayer, + CryogenicDistillerTileEntity lathePart1TileEntity) { + super(lathePart1TileEntity); + tileEntity=lathePart1TileEntity; + fluidTankFluidList=tileEntity.fluidTankProducts.getFluidList(); + int col; + + for (col = 0; col < 3; ++col) + { + for (int col1 = 0; col1 < 9; ++col1) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); + } + } + + for (col = 0; col < 9; ++col) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); + } + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.engine,0, 8, 32)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.fillInputSlotInput,0, 58, 51)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.fillInputSlotProducts,0, 103, 51)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.fluidItemsSlot,0, 58, 15)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.fluidItemsSlot,1, 103, 15)); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + if (this.tileEntity.getEnergy() != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy()); + } + if (this.tileEntity.fluidTankProducts.getFluidAmount() != this.lastFluidAmount || this.tileEntity.fluidTankProducts.getNumberOfFluids() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + } + this.lastProgress = this.tileEntity.progress; + this.lastNumberOfFluids = this.tileEntity.fluidTankProducts.getNumberOfFluids(); + this.lastFluidAmount = this.tileEntity.fluidTankProducts.getFluidAmount(); + this.lastEnergy = (short) this.tileEntity.getEnergy(); + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + switch (index) + { + case 0: + this.tileEntity.progress=(short) value; + break; + case 1: + this.tileEntity.setEnergy(value); + break; + } + } + +} diff --git a/ihl/processing/chemistry/CryogenicDistillerGui.java b/ihl/processing/chemistry/CryogenicDistillerGui.java new file mode 100644 index 0000000..ef18c53 --- /dev/null +++ b/ihl/processing/chemistry/CryogenicDistillerGui.java @@ -0,0 +1,62 @@ +package ihl.processing.chemistry; + +import org.lwjgl.opengl.GL11; + +import ihl.utils.IHLRenderUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; + +public class CryogenicDistillerGui extends GuiContainer { + + private CryogenicDistillerContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUICryogenicDistiller.png"); + + public CryogenicDistillerGui(CryogenicDistillerContainer latheContainer) { + super(latheContainer); + container = latheContainer; + } + + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(tex); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.9F); + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(9, 15 + 12 - i1, 176, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18); + this.drawTexturedModalRect(81, 35, 198, 0, i1 + 1, 13); + } + if (this.container.tileEntity.fluidTankProducts.getFluid()!=null && this.container.tileEntity.fluidTankProducts.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.fluidTankProducts, 125, 28, 137, 67, zLevel, par1, par2, xOffset, yOffset); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(tex); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 26, 34, xOffset, yOffset); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(tex); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/ihl/processing/chemistry/CryogenicDistillerTileEntity.java b/ihl/processing/chemistry/CryogenicDistillerTileEntity.java new file mode 100644 index 0000000..4c237d3 --- /dev/null +++ b/ihl/processing/chemistry/CryogenicDistillerTileEntity.java @@ -0,0 +1,252 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import ic2.core.ContainerBase; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.processing.metallurgy.BasicElectricMotorTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; +import net.minecraft.block.Block; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class CryogenicDistillerTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler{ + + public final InvSlotConsumableLiquidIHL fillInputSlotInput; + public final InvSlotOutput fluidItemsSlot; + public final InvSlotConsumableLiquidIHL fillInputSlotProducts; + + private int processTimer=0; + private IHLFluidTank fluidTankInput = new IHLFluidTank(8000); + public IHLFluidTank fluidTankProducts = new IHLFluidTank(8000); + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("cryogenicdistiller"); + + public CryogenicDistillerTileEntity() + { + super(); + this.isGuiScreenOpened=true; + this.fillInputSlotInput = new InvSlotConsumableLiquidIHL(this, "fillInputSlotInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.fillInputSlotProducts = new InvSlotConsumableLiquidIHL(this, "fillInputSlotProducts", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.fluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 2); + } + + @Override + public String getInventoryName() { + return "CryogenicDistiller"; + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + ForgeDirection dir = ForgeDirection.getOrientation(getFacing()); + TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX,yCoord+dir.offsetY,zCoord+dir.offsetZ); + if(this.processTimer++>20 && this.engine.correctContent() && this.energy>=this.energyConsume/this.engine.getEfficiency()) + { + this.energy-=this.energyConsume/this.engine.getEfficiency(); + this.processTimer=0; + dir = dir.getOpposite(); + Block block = worldObj.getBlock(xCoord+dir.offsetX,yCoord+dir.offsetY,zCoord+dir.offsetZ); + if(block!=null && block.isAir(worldObj, xCoord+dir.offsetX,yCoord+dir.offsetY,zCoord+dir.offsetZ) && this.fluidTankInput.getFluidAmount()<1000) + { + if(this.fluidTankInput.getFluid()==null || (this.fluidTankInput.getNumberOfFluids()<=1 && this.fluidTankInput.getFluid().getFluid()==FluidRegistry.getFluid("air"))) + { + this.fluidTankInput.fill(IHLUtils.getFluidStackWithSize("air", 1000-(this.fluidTankInput.getFluid()!=null?this.fluidTankInput.getFluid().amount:0)),true); + } + } + TileEntity teOnTop = worldObj.getTileEntity(xCoord, yCoord+1, zCoord); + if(teOnTop instanceof IFluidHandler && this.fluidTankProducts.getLigthestFluid()!=null) + { + IFluidHandler topFH = (IFluidHandler)teOnTop; + if(topFH.canFill(ForgeDirection.DOWN, this.fluidTankProducts.getLigthestFluid().getFluid())) + { + FluidStack fsToDrain = this.fluidTankProducts.getLigthestFluid().copy(); + fsToDrain.amount=topFH.fill(ForgeDirection.DOWN, fsToDrain, true); + this.fluidTankProducts.drain(fsToDrain, true); + } + } + ForgeDirection orientation = ForgeDirection.getOrientation(this.getFacing()); + TileEntity teOnFront = worldObj.getTileEntity(xCoord+orientation.offsetX, yCoord, zCoord+orientation.offsetZ); + if(teOnFront instanceof IFluidHandler && this.fluidTankProducts.getFluid()!=null) + { + IFluidHandler frontFH = (IFluidHandler)teOnFront; + if(frontFH.canFill(orientation, this.fluidTankProducts.getFluid().getFluid())) + { + FluidStack fsToDrain = this.fluidTankProducts.getFluid().copy(); + fsToDrain.amount=frontFH.fill(orientation, fsToDrain, true); + this.fluidTankProducts.drain(fsToDrain, true); + } + } + } + IHLUtils.handleFluidSlotsBehaviour(fillInputSlotProducts, null, fluidItemsSlot, fluidTankProducts); + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("cryogenicDistiller"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new CryogenicDistillerGui(new CryogenicDistillerContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new CryogenicDistillerContainer(player, this); + } + + @Override + public void operate() + { + if (!this.fillInputSlotInput.isEmpty() && this.fluidTankInput.getFluid().getFluid()==FluidRegistry.getFluid("air")) + { + IHLUtils.handleFluidSlotsBehaviour(fillInputSlotInput, null, fluidItemsSlot, fluidTankInput); + } + else + { + UniversalRecipeInput ri = CryogenicDistillerTileEntity.recipeManager.getRecipeInput(getInput()); + Iterator listFluidOutputsIterator = getOutput().getFluidOutputs().iterator(); + while(listFluidOutputsIterator.hasNext()) + { + this.fluidTankProducts.fill(listFluidOutputsIterator.next(), true); + } + this.fluidTankInput.drain(ri.getFluidInputs().get(0), true); + } + } + + public UniversalRecipeOutput getOutput() + { + return CryogenicDistillerTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + @Override + public List[] getInput() + { + return new List [] {Arrays.asList(new FluidStack [] {this.fluidTankInput.getLigthestFluid()}),null}; + } + + @Override + public boolean canOperate() + { + return this.engine.correctContent() && this.getOutput()!=null; + } + + @Override + public void onGuiClosed(EntityPlayer arg0) {} + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.fluidTankInput.readFromNBT(nbttagcompound.getCompoundTag("fluidTankInput")); + this.fluidTankProducts.readFromNBT(nbttagcompound.getCompoundTag("fluidTankProducts")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankInputTag = new NBTTagCompound(); + this.fluidTankInput.writeToNBT(fluidTankInputTag); + nbttagcompound.setTag("fluidTankInput", fluidTankInputTag); + NBTTagCompound fluidTankProductsTag = new NBTTagCompound(); + this.fluidTankProducts.writeToNBT(fluidTankProductsTag); + nbttagcompound.setTag("fluidTankProducts", fluidTankProductsTag); + } + + public static void addRecipe(FluidStack input, FluidStack output, FluidStack output2, boolean specialCondition) + { + if(output2!=null) + { + recipeManager.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {input}),null), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {output,output2}),null,20,specialCondition)); + } + else + { + recipeManager.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {input}),null), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {output}),null,20,specialCondition)); + } + } + + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + public boolean canProcess() + { + return this.engine.correctContent() && this.energy>=this.maxStorage && this.fluidTankInput.getFluidAmount()<1000; + } + + @Override + public boolean canDrain(ForgeDirection dir, Fluid arg1) { + return dir.getOpposite().equals(ForgeDirection.getOrientation(this.getFacing())) || dir.equals(ForgeDirection.UP); + } + + @Override + public boolean canFill(ForgeDirection dir, Fluid fluid) { + return dir.equals(ForgeDirection.getOrientation(this.getFacing())); + } + + @Override + public FluidStack drain(ForgeDirection dir, FluidStack fstack, boolean doDrain) { + if(this.canDrain(dir, null)) + { + return this.fluidTankProducts.drain(fstack, doDrain); + } + return null; + } + + @Override + public FluidStack drain(ForgeDirection dir, int amount, boolean doDrain) { + if(this.canDrain(dir, null)) + { + if(dir.equals(ForgeDirection.UP)) + { + return this.fluidTankProducts.drainLightest(amount, doDrain); + } + return this.fluidTankProducts.drain(amount, doDrain); + } + return null; + } + + @Override + public int fill(ForgeDirection dir, FluidStack fstack, boolean doFill) + { + if(fstack!=null && fstack.getFluid()!=null && this.canFill(dir, fstack.getFluid())) + { + this.fluidTankInput.drain(IHLUtils.getFluidStackWithSize("air", this.fluidTankInput.getCapacity()), true); + return this.fluidTankInput.fill(fstack, doFill); + } + return 0; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection dir) + { + return new FluidTankInfo[] {this.fluidTankInput.getInfo(),this.fluidTankProducts.getInfo()}; + } + +} diff --git a/ihl/processing/chemistry/ElectricEvaporatorBlock.java b/ihl/processing/chemistry/ElectricEvaporatorBlock.java new file mode 100644 index 0000000..2507b2e --- /dev/null +++ b/ihl/processing/chemistry/ElectricEvaporatorBlock.java @@ -0,0 +1,221 @@ +package ihl.processing.chemistry; + +import java.util.Random; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class ElectricEvaporatorBlock extends Block implements ITileEntityProvider{ + + IIcon textureFrontActive, textureSide, textureBottom, textureTop; + + public ElectricEvaporatorBlock(Material material) + { + super(material); + this.setCreativeTab(IHLCreativeTab.tab); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return new ItemStack(Blocks.furnace,1).getItem(); + } + + @Override + public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) + { + ItemStack result = new ItemStack(Blocks.furnace,1); + this.dropBlockAsItem(world, x, y, z, result); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new ElectricEvaporatorTileEntity(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":electricEvaporatorFront"); + this.textureFrontActive = par1IconRegister.registerIcon(IHLModInfo.MODID + ":electricEvaporatorFrontActive"); + this.textureSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":electricEvaporatorSide"); + this.textureTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":electricEvaporatorTop"); + this.textureBottom = par1IconRegister.registerIcon(IHLModInfo.MODID + ":electricEvaporatorBottom"); + } + + @Override + public boolean hasTileEntity(int metadata) + { + return true; + } + + @Override + public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer entityPlayer,int i,float pos_x,float pos_y,float pos_z){ + TileEntity te = world.getTileEntity(x,y,z); + if(te instanceof ElectricEvaporatorTileEntity) + { + ElectricEvaporatorTileEntity bte = (ElectricEvaporatorTileEntity)te; + if (bte == null || entityPlayer.isSneaking()) { + return false; + } + else + { + return bte.getGui(entityPlayer); + } + } + return false; + } + + /** + * Called when the block is placed in the world. + */ + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) + { + int var7 = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + TileEntity t = world.getTileEntity(x, y, z); + if(t!=null && t instanceof ElectricEvaporatorTileEntity) + { + ElectricEvaporatorTileEntity te = (ElectricEvaporatorTileEntity)t; + if(player.isSneaking()) + { + switch(var7) + { + case 0: + te.setFacing((short) 3); + break; + case 1: + te.setFacing((short) 4); + break; + case 2: + te.setFacing((short) 2); + break; + case 3: + te.setFacing((short) 5); + break; + default: + break; + } + } + else + { + switch(var7) + { + case 0: + te.setFacing((short) 2); + break; + case 1: + te.setFacing((short) 5); + break; + case 2: + te.setFacing((short) 3); + break; + case 3: + te.setFacing((short) 4); + break; + default: + break; + } + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) + { + IIcon faceIcon=this.blockIcon; + int facing=3; + int mask[] = { + 0,1,2,3,4,5, + 1,0,3,2,4,5, + 2,3,0,1,4,5, + 2,3,1,0,4,5, + 2,3,5,4,0,1, + 2,3,4,5,1,0 + }; + TileEntity te = world.getTileEntity(x, y, z); + if(te!=null) + { + ElectricEvaporatorTileEntity tebh = (ElectricEvaporatorTileEntity) te; + facing=tebh.getFacing(); + if(tebh.getActive()) + { + faceIcon=this.textureFrontActive; + } + } + + switch (mask[facing*6+side]) + { + case 0: + return faceIcon; + case 1: + return this.textureSide; + case 2: + return this.textureBottom; + case 3: + return this.textureTop; + case 4: + return this.textureSide; + case 5: + return this.textureSide; + default: + return this.textureSide; + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + IIcon sideIcon = this.blockIcon; + switch (side) + { + case 0: + return this.textureBottom; + case 1: + return this.textureTop; + case 2: + return this.textureSide; + case 3: + return this.blockIcon; + case 4: + return this.textureSide; + case 5: + return this.textureSide; + default: + return this.textureSide; + } + } + + @Override + public void randomDisplayTick(World world, int x, int y, int z, Random random) + { + TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof ElectricEvaporatorTileEntity) + { + ElectricEvaporatorTileEntity ete = (ElectricEvaporatorTileEntity) te; + if(ete.getActive()) + { + world.spawnParticle("snowshovel", x+0.2D, y+1.2D, z+0.2D, 0D, 0.05D, 0D); + } + } + } +} diff --git a/ihl/processing/chemistry/ElectricEvaporatorContainer.java b/ihl/processing/chemistry/ElectricEvaporatorContainer.java new file mode 100644 index 0000000..9dc136e --- /dev/null +++ b/ihl/processing/chemistry/ElectricEvaporatorContainer.java @@ -0,0 +1,113 @@ +package ihl.processing.chemistry; + +import ic2.core.ContainerBase; +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class ElectricEvaporatorContainer extends ContainerBase { + + protected ElectricEvaporatorTileEntity tileEntity; + public int lastFluidAmount = -1; + public double lastEnergy = -1; + public short lastProgress = -1; + private final static int height=166; + + public ElectricEvaporatorContainer(EntityPlayer entityPlayer, ElectricEvaporatorTileEntity electricEvaporatorTileEntity){ + super(electricEvaporatorTileEntity); + this.tileEntity = electricEvaporatorTileEntity; + int col; + + for (col = 0; col < 3; ++col) + { + for (int col1 = 0; col1 < 9; ++col1) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); + } + } + + for (col = 0; col < 9; ++col) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); + } + + this.addSlotToContainer(new SlotInvSlot(electricEvaporatorTileEntity.fuelSlot, 0, 8, 32)); + this.addSlotToContainer(new SlotInvSlot(electricEvaporatorTileEntity.fluidItemsSlot, 0, 44, 14)); + this.addSlotToContainer(new SlotInvSlot(electricEvaporatorTileEntity.emptyFluidItemsSlot, 0, 44, 32)); + this.addSlotToContainer(new SlotInvSlot(electricEvaporatorTileEntity.fillItemsSlot, 0, 44, 50)); + this.addSlotToContainer(new SlotInvSlot(electricEvaporatorTileEntity.outputSlot, 0, 117, 32)); + for(int row=0;row<=3;row++) + { + this.addSlotToContainer(new SlotInvSlot(tileEntity.upgradeSlot, row, 152, 8+row*18)); + } + + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + + if (this.tileEntity.getFluidTank().getFluid()!=null && this.tileEntity.getFluidTank().getFluidAmount() != this.lastFluidAmount) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.getFluidTank().getFluid().getFluid().getID()); + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getFluidTank().getFluidAmount()); + } + + if (this.tileEntity.getEnergy() != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 2, ((int)this.tileEntity.getEnergy()>>15) & Short.MAX_VALUE); + icrafting.sendProgressBarUpdate(this, 3, (short)((int)this.tileEntity.getEnergy() & Short.MAX_VALUE)); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 4, this.tileEntity.progress); + icrafting.sendProgressBarUpdate(this, 5, this.tileEntity.maxProgress); + } + } + + this.lastFluidAmount = this.tileEntity.getFluidTank().getFluidAmount(); + this.lastEnergy = this.tileEntity.getEnergy(); + this.lastProgress = this.tileEntity.progress; + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + + switch (index) + { + case 0: + this.tileEntity.getFluidTank().setFluid(new FluidStack(FluidRegistry.getFluid(value), 1000)); + break; + case 1: + this.tileEntity.getFluidTank().setFluid(new FluidStack(this.tileEntity.getFluidTank().getFluid().getFluid(), value)); + break; + case 2: + this.tileEntity.setEnergy(value<<15); + break; + case 3: + this.tileEntity.setEnergy(this.tileEntity.getEnergy()+value); + break; + case 4: + this.tileEntity.progress=(short) value; + break; + case 5: + this.tileEntity.maxProgress=(short) value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/ElectricEvaporatorGui.java b/ihl/processing/chemistry/ElectricEvaporatorGui.java new file mode 100644 index 0000000..016335f --- /dev/null +++ b/ihl/processing/chemistry/ElectricEvaporatorGui.java @@ -0,0 +1,86 @@ +package ihl.processing.chemistry; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; +import ic2.core.util.DrawUtil; +import ic2.core.util.GuiTooltipHelper; + +@SideOnly(Side.CLIENT) +public class ElectricEvaporatorGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIElectricEvaporator.png"); + private ElectricEvaporatorContainer container; + private String title = StatCollector.translateToLocal("ihl.gui.electricEvaporator"); + + public ElectricEvaporatorGui (ElectricEvaporatorContainer electricEvaporatorContainer) { + //the container is instanciated and passed to the superclass for handling + super(electricEvaporatorContainer); + this.container=electricEvaporatorContainer; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + fontRendererObj.drawString(title, 8, 70, 6171880); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) + { + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(9, 15 + 12 - i1, 176, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18); + this.drawTexturedModalRect(99, 34, 198, 0, i1 + 1, 13); + } + + if (this.container.tileEntity.getFluidTank().getFluid()!=null && this.container.tileEntity.getFluidTank().getFluidAmount() > 0) + { + FluidStack fluidStack = this.container.tileEntity.getFluidTank().getFluid(); + if(fluidStack!=null) + { + Fluid fluid = fluidStack.getFluid(); + if(fluid!=null) + { + + IIcon fluidIcon = fluid.getIcon(); + + if (fluidIcon != null) + { + this.mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + int liquidHeight = this.container.tileEntity.gaugeLiquidScaled(47); + + DrawUtil.drawRepeated(fluidIcon, (82), 16 + 47 - liquidHeight, 12.0D, liquidHeight, this.zLevel); + this.mc.renderEngine.bindTexture(background); + } + } + String tooltip = StatCollector.translateToLocal(fluidStack.getFluid().getUnlocalizedName()) + ": " + fluidStack.amount + "mB"; + //GuiTooltiphelper.drawAreaTooltip(par1-90, par2-32, tooltip, xOffset+64, yOffset+23, xOffset+74, yOffset+71); + GuiTooltipHelper.drawAreaTooltip(par1-90, par2-32, tooltip, xOffset-8, yOffset-15, xOffset+2, yOffset+30); + } + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/ElectricEvaporatorTileEntity.java b/ihl/processing/chemistry/ElectricEvaporatorTileEntity.java new file mode 100644 index 0000000..3505cda --- /dev/null +++ b/ihl/processing/chemistry/ElectricEvaporatorTileEntity.java @@ -0,0 +1,444 @@ +package ihl.processing.chemistry; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergySink; +import ic2.api.item.IC2Items; +import ic2.api.network.INetworkTileEntityEventListener; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.audio.AudioSource; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlotUpgrade; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.network.NetworkManager; +import ic2.core.upgrade.IUpgradableBlock; +import ic2.core.upgrade.IUpgradeItem; +import ic2.core.upgrade.UpgradableProperty; +import ihl.IHLMod; +import ihl.utils.IHLInvSlotDischarge; +import ihl.utils.IHLUtils; + +public class ElectricEvaporatorTileEntity extends EvaporatorTileEntity implements IEnergySink, IUpgradableBlock, INetworkTileEntityEventListener +{ + public final InvSlotUpgrade upgradeSlot; + private int tier; + private int lastTier; + public int maxStorage; + private int defaultMaxStorage; + private double energy; + public final int defaultEnergyConsume; + public final int defaultOperationLength; + public final int defaultTier; + public int energyConsume; + public AudioSource audioSource; + private static final int EventStart = 0; + private static final int EventInterrupt = 1; + private static final int EventStop = 2; + private int updateChecksum=0; + private boolean addedToEnergyNet=false; + + public ElectricEvaporatorTileEntity() + { + super(); + this.defaultEnergyConsume = this.energyConsume = 8; + this.defaultOperationLength = this.maxProgress = 400; + this.energy=0D; + this.lastTier = this.tier = this.defaultTier = 1; + this.maxStorage = this.defaultMaxStorage = defaultEnergyConsume * defaultOperationLength; + this.fuelSlot = new IHLInvSlotDischarge(this, 1, Access.IO, this.tier, InvSlot.InvSide.BOTTOM); + this.upgradeSlot = new InvSlotUpgrade(this, "upgrade", 4, 4); + } + + @Override + public void onLoaded() + { + super.onLoaded(); + if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("tier"); + fields.add("maxStorage"); + return fields; + } + + public void setOverclockRates() + { + int speedUp=0; + int tierUp=0; + int capacityUp=0; + int checksum=0; + for(int i=0;i 1.0D) + { + double amount = ((IHLInvSlotDischarge)this.fuelSlot).discharge(this.getDemandedEnergy(), false); + this.energy += amount; + } + if (this.needsFluid()) + { + IHLUtils.handleFluidSlotsBehaviour(null, fluidItemsSlot, emptyFluidItemsSlot, fluidTank); + } + + if (this.canOperate() && this.energy >= this.energyConsume) + { + this.setActive(true); + + if (this.progress == 0) + { + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + ++this.progress; + this.energy -= this.energyConsume; + if (this.progress >= this.maxProgress) + { + this.operate(); + needsInvUpdate = true; + this.progress = 0; + IC2.network.get().initiateTileEntityEvent(this, 2, true); + } + } + else + { + if (this.progress != 0 && this.getActive()) + { + IC2.network.get().initiateTileEntityEvent(this, 1, true); + } + if (!this.canOperate()) + { + this.progress = 0; + } + this.setActive(false); + } + for (int i = 0; i < this.upgradeSlot.size(); ++i) + { + ItemStack stack = this.upgradeSlot.get(i); + + if (stack != null && stack.getItem() instanceof IUpgradeItem && ((IUpgradeItem)stack.getItem()).onTick(stack, this)) + { + needsInvUpdate = true; + } + } + } + } + + private static int applyModifier(int base, int extra, double multiplier) + { + double ret = Math.round(((double)base + (double)extra) * multiplier); + return ret > 2.147483647E9D ? Integer.MAX_VALUE : (int)ret; + } + + @Override + public void onNetworkEvent(int event) + { + if (this.audioSource == null && this.getStartSoundFile() != null) + { + this.audioSource = IC2.audioManager.createSource(this, this.getStartSoundFile()); + } + + switch (event) + { + case 0: + if (this.audioSource != null) + { + this.audioSource.play(); + } + + break; + + case 1: + if (this.audioSource != null) + { + this.audioSource.stop(); + } + + break; + + case 2: + if (this.audioSource != null) + { + this.audioSource.stop(); + } + + } + } + + public String getStartSoundFile() + { + return "Machines/Electro Furnace/ElectroFurnaceLoop.ogg"; + } + + /** + * Returns the name of the inventory + */ + @Override + public String getInventoryName() + { + return "Electric evaporator"; + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer entityPlayer) + { + return new ElectricEvaporatorContainer(entityPlayer, this); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer entityPlayer, boolean isAdmin) + { + return new ElectricEvaporatorGui(new ElectricEvaporatorContainer(entityPlayer, this)); + } + + @Override + public boolean getGui(EntityPlayer player) + { + return this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true) : false; + } + + @Override + public int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + @Override + public int mZ() + { + switch(this.getFacing()) + { + case 2: + return -1; + case 3: + return 1; + default: + return 0; + } + } + + @Override + public double getEnergy() + { + return this.energy; + } + + @Override + public boolean useEnergy(double amount) { + if (this.energy >= amount) + { + this.energy -= amount; + return true; + } + else + { + return false; + } + } + + public void setEnergy(double i) { + this.energy=i; + } + + @Override + public double getDemandedEnergy() + { + return this.maxStorage - this.energy; + } + + @Override + public int getSinkTier() + { + return this.tier; + } + + @Override + public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) + { + if (this.energy >= this.maxStorage) + { + return amount; + } + else + { + this.energy += amount; + return 0.0D; + } + } + + @Override + public boolean acceptsEnergyFrom(TileEntity emitter, + ForgeDirection direction) { + return true; + } + + public ItemStack getOutput(int arg0) + { + return this.outputSlot.get(arg0); + } + + public int getOutputSize() { + return this.outputSlot.size(); + } + + public void setOutput(int arg0, ItemStack arg1) + { + this.outputSlot.put(arg0, arg1); + } + + @Override + public Set getUpgradableProperties() + { + Set properties = new HashSet(); + properties.add(UpgradableProperty.ItemProducing); + properties.add(UpgradableProperty.EnergyStorage); + properties.add(UpgradableProperty.Transformer); + return properties; + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/ElectrolysisBathContainer.java b/ihl/processing/chemistry/ElectrolysisBathContainer.java new file mode 100644 index 0000000..f2cc74e --- /dev/null +++ b/ihl/processing/chemistry/ElectrolysisBathContainer.java @@ -0,0 +1,94 @@ +package ihl.processing.chemistry; + +import java.util.List; + +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraftforge.fluids.FluidStack; + +public class ElectrolysisBathContainer extends ContainerBase { + + protected ElectrolysisBathTileEntity tileEntity; + public int lastFluidAmount = -1; + public int lastNumberOfFluids = -1; + public short lastProgress = -1; + public short lastTemperature = -1; + private final static int height=166; + public List fluidTankFluidList; + + public ElectrolysisBathContainer(EntityPlayer entityPlayer, ElectrolysisBathTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + fluidTankFluidList = this.tileEntity.getFluidTank().getFluidList(); + int col; + for (col = 0; col < 3; ++col) + { + for (int col1 = 0; col1 < 9; ++col1) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); + } + } + for (col = 0; col < 9; ++col) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); + } + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 6, 52)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 6, 16)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 6, 33)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 98, 16)); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + + if (this.tileEntity.getTankAmount() != this.lastFluidAmount || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + + if (this.tileEntity.temperature != this.lastTemperature) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.temperature); + } + } + + this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank(); + this.lastFluidAmount = this.tileEntity.getTankAmount(); + this.lastProgress = this.tileEntity.progress; + this.lastTemperature = this.tileEntity.temperature; + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + switch (index) + { + case 0: + this.tileEntity.progress=(short) value; + break; + case 1: + this.tileEntity.temperature=(short) value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/ElectrolysisBathGui.java b/ihl/processing/chemistry/ElectrolysisBathGui.java new file mode 100644 index 0000000..cb39044 --- /dev/null +++ b/ihl/processing/chemistry/ElectrolysisBathGui.java @@ -0,0 +1,100 @@ +package ihl.processing.chemistry; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.IC2; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import ic2.core.network.NetworkManager; +import ihl.collector.GuiMultiTextureButton; +import ihl.utils.IHLRenderUtils; + +@SideOnly(Side.CLIENT) +public class ElectrolysisBathGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIElectrolysisBath.png"); + private ElectrolysisBathContainer container; + private GuiMultiTextureButton button1; + private int timer=10; + + public ElectrolysisBathGui (ElectrolysisBathContainer container1) { + //the container is instanciated and passed to the superclass for handling + super(container1); + this.container=container1; + } + + @Override + public void initGui() + { + super.initGui(); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + button1=new GuiMultiTextureButton(0, x+97, y+58, 18, 18, background,97,58,238,238); + this.buttonList.add(button1); + } + + @Override + public void actionPerformed(GuiButton button) + { + super.actionPerformed(button); + IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, button.id); + if (button.id == 0) + { + button1.isActive=true; + timer=10; + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int i1; + if (this.container.tileEntity.progress > 0) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27); + this.drawTexturedModalRect(121, 33, getFrameX(i1), getFrameY(i1),24,24); + } + if (this.container.tileEntity.getTankAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 32, 11, 89, 72, zLevel, par1, par2, xOffset, yOffset); + } + this.mc.renderEngine.bindTexture(background); + this.drawTexturedModalRect(60, 3, 252, 0,4,48); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + if(timer>0) + { + timer--; + } + if(timer==1) + { + button1.isActive=false; + } + } + + private int getFrameY(int number) + { + return (number % 10) * 24 + 14; + } + + private int getFrameX(int number) + { + return (number / 10) * 24 + 176; + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/ElectrolysisBathModel.java b/ihl/processing/chemistry/ElectrolysisBathModel.java new file mode 100644 index 0000000..310ec62 --- /dev/null +++ b/ihl/processing/chemistry/ElectrolysisBathModel.java @@ -0,0 +1,86 @@ +package ihl.processing.chemistry; + +// Date: 12.04.2015 13:06:31 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; + +public class ElectrolysisBathModel extends ModelBase +{ + //fields + ModelRenderer Piece1; + ModelRenderer FrontPylone; + ModelRenderer BackPylone; + ModelRenderer LeftPylone; + ModelRenderer RightPylone; + + public ElectrolysisBathModel() + { + textureWidth = 64; + textureHeight = 128; + setTextureOffset("Piece1.Stick01", 48, 4); + setTextureOffset("Piece1.Shape1", 16, 18); + setTextureOffset("Piece1.Body04", 0, 48); + setTextureOffset("Piece1.Shape2", 0, 18); + setTextureOffset("Piece1.Shape3", 16, 0); + setTextureOffset("Piece1.Shape4", 0, 0); + setTextureOffset("Piece1.Box01", 41, 18); + setTextureOffset("Piece1.Shape5", 23, 84); + setTextureOffset("Piece1.Shape6", 23, 84); + setTextureOffset("Piece1.Shape7", 23, 84); + setTextureOffset("Piece1.Shape8", 23, 83); + setTextureOffset("FrontPylone.Shape9", 23, 84); + setTextureOffset("BackPylone.Shape10", 23, 84); + setTextureOffset("LeftPylone.Shape12", 23, 84); + setTextureOffset("RightPylone.Shape11", 23, 82); + + Piece1 = new ModelRenderer(this, "Piece1"); + Piece1.setRotationPoint(0F, 16F, 0F); + setRotation(Piece1, 0F, 0F, 0F); + Piece1.mirror = false; + Piece1.addBox("Stick01", -1F, -16F, -1F, 2, 9, 2); + Piece1.addBox("Shape1", -8F, -8F, -8F, 2, 16, 14); + Piece1.addBox("Body04", -6F, -7F, -6F, 12, 15, 12); + Piece1.addBox("Shape2", 6F, -8F, -6F, 2, 16, 14); + Piece1.addBox("Shape3", -6F, -8F, -8F, 14, 16, 2); + Piece1.addBox("Shape4", -8F, -8F, 6F, 14, 16, 2); + Piece1.addBox("Box01", -2F, -13F, -2F, 4, 2, 4); + Piece1.addBox("Shape5", 5F, -9F, -1.5F, 2, 2, 3); + Piece1.addBox("Shape6", -7F, -9F, -1.5F, 2, 2, 3); + Piece1.addBox("Shape7", -1.5F, -9F, 5F, 3, 2, 2); + Piece1.addBox("Shape8", -1.5F, -9F, -7F, 3, 2, 2); + FrontPylone = new ModelRenderer(this, "FrontPylone"); + FrontPylone.setRotationPoint(0F, 7F, -5F); + setRotation(FrontPylone, -0.9F, 0F, 0); + FrontPylone.mirror = true; + FrontPylone.addBox("Shape9", -1F, -5F, -1F, 2, 6, 1); + BackPylone = new ModelRenderer(this, "BackPylone"); + BackPylone.setRotationPoint(0F, 7F, 5F); + setRotation(BackPylone, 0.9F, 0F, 0F); + BackPylone.mirror = true; + BackPylone.addBox("Shape10", -1F, -5F, 0F, 2, 6, 1); + LeftPylone = new ModelRenderer(this, "LeftPylone"); + LeftPylone.setRotationPoint(5F, 7F, 0F); + setRotation(LeftPylone, 0F, 0F, -0.9F); + LeftPylone.mirror = true; + LeftPylone.addBox("Shape12", 0F, -5F, -1F, 1, 6, 2); + RightPylone = new ModelRenderer(this, "RightPylone"); + RightPylone.setRotationPoint(-5F, 7F, 0F); + setRotation(RightPylone, 0, 0F, 0.9F); + RightPylone.mirror = true; + RightPylone.addBox("Shape11", -1F, -5F, -1F, 1, 6, 2); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/chemistry/ElectrolysisBathTileEntity.java b/ihl/processing/chemistry/ElectrolysisBathTileEntity.java new file mode 100644 index 0000000..b549247 --- /dev/null +++ b/ihl/processing/chemistry/ElectrolysisBathTileEntity.java @@ -0,0 +1,312 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.api.network.INetworkClientTileEntityEventListener; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ic2.core.network.NetworkManager; +import ihl.IHLMod; +import ihl.flexible_cable.FlexibleCableHolderBaseTileEntity; +import ihl.flexible_cable.IHLGrid; +import ihl.flexible_cable.NodeEntity; +import ihl.interfaces.IEnergyNetNode; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; + +public class ElectrolysisBathTileEntity extends FlexibleCableHolderBaseTileEntity implements IHasGui, INetworkClientTileEntityEventListener, IFluidHandler +{ + private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("electrolysisbath"); + public final ApparatusProcessableInvSlot input; + public final InvSlotConsumableLiquidIHL drainInputSlot; + public final InvSlotConsumableLiquidIHL fillInputSlot; + public final InvSlotOutput emptyFluidItemsSlot; + public short progress; + protected short operationLength=20000;//Short.MAX_VALUE=32767 + private final IHLFluidTank fluidTank = new IHLFluidTank(2000); + public short temperature=20; + private final static double resistance=5D; + + public ElectrolysisBathTileEntity() { + super(); + this.drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); + this.fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 1); + this.input = new ApparatusProcessableInvSlot(this, "input", 3, Access.IO, 1, 64); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + NBTTagCompound fractionalOutputNBT = new NBTTagCompound(); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return false; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("electrolysisBath"); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + temperature=(short) (this.fluidTank.getTemperature()-273); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank); + boolean needsInvUpdate = false; + if (this.canOperate()) + { + this.setActive(true); + if (this.progress == 0) + { + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + if(this.getGrid().energy>0D) + { + double voltage = this.getGrid().getSinkVoltage(this); + double drawEnergy = voltage*voltage/resistance; + this.progress+=drawEnergy; + this.getGrid().drawEnergy(drawEnergy, this); + } + + if (this.progress >= this.operationLength) + { + this.operate(); + needsInvUpdate = true; + this.progress = 0; + IC2.network.get().initiateTileEntityEvent(this, 2, true); + } + } + else + { + if (this.progress != 0 && this.getActive()) + { + IC2.network.get().initiateTileEntityEvent(this, 1, true); + } + if (!this.canOperate()) + { + this.progress = 0; + } + this.setActive(false); + } + } + + @Override + public FluidStack drain(ForgeDirection from, int amount, boolean doDrain) + { + FluidStack fstack = this.fluidTank.drain(amount, doDrain); + return fstack; + } + + + //1.7.10 API + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return true; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return true; + } + + @Override + public String getInventoryName() { + return "Electrolysis bath"; + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + TileEntity te = worldObj.getTileEntity(xCoord, yCoord-1, zCoord); + if(te instanceof IFluidHandler && this.fluidTank.getFluid()!=null) + { + IFluidHandler ifhte = (IFluidHandler)te; + if(ifhte.canFill(ForgeDirection.UP, this.fluidTank.getFluid().getFluid())) + { + int filled = ifhte.fill(ForgeDirection.UP, this.fluidTank.drain(this.getTankAmount(), false), true); + this.fluidTank.drain(filled, true); + } + } + } + + public int gaugeProgressScaled(int i) + { + return this.progress * i / operationLength; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new ElectrolysisBathGui(new ElectrolysisBathContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) + { + this.fluidTank.sortFluidsByDensity(); + return new ElectrolysisBathContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) {} + + public boolean canOperate() + { + return getOutput()!=null; + } + + public UniversalRecipeOutput getOutput() + { + return ElectrolysisBathTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + public List[] getInput() + { + for(int i=0;i getRecipes() { + return recipeManager.getRecipes(); + } + + public IHLFluidTank getFluidTank() + { + return this.fluidTank; + } + + @Override + public double getMaxAllowableVoltage() + { + return 64000D; + } + + @Override + public double getEnergyAmountThisNodeWant() + { + double voltage = this.getGrid().getSinkVoltage(this); + double energy = voltage*voltage/resistance; + return this.getOutput()!=null?energy:0; + } + + @Override + public void injectEnergyInThisNode(double amount, double voltage) + { + this.progress+=amount; + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/EvaporatorBlock.java b/ihl/processing/chemistry/EvaporatorBlock.java new file mode 100644 index 0000000..038a044 --- /dev/null +++ b/ihl/processing/chemistry/EvaporatorBlock.java @@ -0,0 +1,222 @@ +package ihl.processing.chemistry; + +import java.util.Random; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class EvaporatorBlock extends Block implements ITileEntityProvider{ + + IIcon textureFrontActive, textureSide, textureBottom, textureTop; + + public EvaporatorBlock(Material material) + { + super(material); + this.setCreativeTab(IHLCreativeTab.tab); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return new ItemStack(Blocks.furnace,1).getItem(); + } + + @Override + public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) + { + ItemStack result = new ItemStack(Blocks.furnace,1); + this.dropBlockAsItem(world, x, y, z, result); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new EvaporatorTileEntity(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":solidFuelEvaporatorFront"); + this.textureFrontActive = par1IconRegister.registerIcon(IHLModInfo.MODID + ":solidFuelEvaporatorFrontActive"); + this.textureSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":solidFuelEvaporatorSide"); + this.textureTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":solidFuelEvaporatorTop"); + this.textureBottom = par1IconRegister.registerIcon(IHLModInfo.MODID + ":solidFuelEvaporatorBottom"); + } + + @Override + public boolean hasTileEntity(int metadata) + { + return true; + } + + @Override + public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer entityPlayer,int i,float pos_x,float pos_y,float pos_z){ + TileEntity te = world.getTileEntity(x,y,z); + if(te instanceof EvaporatorTileEntity) + { + EvaporatorTileEntity bte = (EvaporatorTileEntity)te; + if (bte == null || entityPlayer.isSneaking()) { + return false; + } + else + { + return bte.getGui(entityPlayer); + } + } + return false; + } + + /** + * Called when the block is placed in the world. + */ + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) + { + int var7 = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + TileEntity t = world.getTileEntity(x, y, z); + if(t!=null && t instanceof EvaporatorTileEntity) + { + EvaporatorTileEntity te = (EvaporatorTileEntity)t; + if(player.isSneaking()) + { + switch(var7) + { + case 0: + te.setFacing((short) 3); + break; + case 1: + te.setFacing((short) 4); + break; + case 2: + te.setFacing((short) 2); + break; + case 3: + te.setFacing((short) 5); + break; + default: + break; + } + } + else + { + switch(var7) + { + case 0: + te.setFacing((short) 2); + break; + case 1: + te.setFacing((short) 5); + break; + case 2: + te.setFacing((short) 3); + break; + case 3: + te.setFacing((short) 4); + break; + default: + break; + } + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) + { + IIcon faceIcon=this.blockIcon; + int facing=3; + int mask[] = { + 0,1,2,3,4,5, + 1,0,3,2,4,5, + 2,3,0,1,4,5, + 2,3,1,0,4,5, + 2,3,5,4,0,1, + 2,3,4,5,1,0 + }; + TileEntity te = world.getTileEntity(x, y, z); + if(te!=null) + { + EvaporatorTileEntity tebh = (EvaporatorTileEntity) te; + facing=tebh.getFacing(); + if(tebh.getActive()) + { + faceIcon=this.textureFrontActive; + } + } + + switch (mask[facing*6+side]) + { + case 0: + return faceIcon; + case 1: + return this.textureSide; + case 2: + return this.textureBottom; + case 3: + return this.textureTop; + case 4: + return this.textureSide; + case 5: + return this.textureSide; + default: + return this.textureSide; + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + IIcon sideIcon = this.blockIcon; + switch (side) + { + case 0: + return this.textureTop; + case 1: + return this.textureBottom; + case 2: + return this.textureSide; + case 3: + return this.blockIcon; + case 4: + return this.textureSide; + case 5: + return this.textureSide; + default: + return this.textureSide; + } + } + + @Override + public void randomDisplayTick(World world, int x, int y, int z, Random random) + { + TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof EvaporatorTileEntity) + { + EvaporatorTileEntity ete = (EvaporatorTileEntity) te; + if(ete.getActive()) + { + world.spawnParticle("snowshovel", x+0.2D, y+1.2D, z+0.2D, 0D, 0.05D, 0D); + world.spawnParticle("flame", x+0.5D+ete.mX()*0.5D+(random.nextDouble()*0.4D-0.2D)*ete.mZ(), y+random.nextDouble()*0.25D, z+0.5D+ete.mZ()*0.5D+(random.nextDouble()*0.4D-0.2D)*ete.mX(), 0D, 0.01D, 0D); + } + } + } +} diff --git a/ihl/processing/chemistry/EvaporatorContainer.java b/ihl/processing/chemistry/EvaporatorContainer.java new file mode 100644 index 0000000..1df3d2f --- /dev/null +++ b/ihl/processing/chemistry/EvaporatorContainer.java @@ -0,0 +1,100 @@ +package ihl.processing.chemistry; + +import ic2.core.ContainerBase; +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class EvaporatorContainer extends ContainerBase { + + protected EvaporatorTileEntity tileEntity; + public int lastFluidAmount = -1; + public int lastFuel = -1; + public short lastProgress = -1; + private final static int height=166; + + public EvaporatorContainer(EntityPlayer entityPlayer, EvaporatorTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + int col; + + for (col = 0; col < 3; ++col) + { + for (int col1 = 0; col1 < 9; ++col1) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); + } + } + + for (col = 0; col < 9; ++col) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); + } + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fuelSlot, 0, 8, 32)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fluidItemsSlot, 0, 44, 14)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 44, 32)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillItemsSlot, 0, 44, 50)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 117, 32)); + + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + + if (this.tileEntity.getFluidTank().getFluid()!=null && this.tileEntity.getFluidTank().getFluidAmount() != this.lastFluidAmount) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.getFluidTank().getFluid().getFluid().getID()); + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getFluidTank().getFluidAmount()); + } + + if (this.tileEntity.fuel != this.lastFuel) + { + icrafting.sendProgressBarUpdate(this, 2, this.tileEntity.fuel); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 3, this.tileEntity.progress); + } + } + + this.lastFluidAmount = this.tileEntity.getFluidTank().getFluidAmount(); + this.lastFuel = this.tileEntity.fuel; + this.lastProgress = this.tileEntity.progress; + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + + switch (index) + { + case 0: + this.tileEntity.getFluidTank().setFluid(new FluidStack(FluidRegistry.getFluid(value), 1000)); + break; + case 1: + this.tileEntity.getFluidTank().setFluid(new FluidStack(this.tileEntity.getFluidTank().getFluid().getFluid(), value)); + break; + case 2: + this.tileEntity.fuel=value; + break; + case 3: + this.tileEntity.progress=(short) value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/EvaporatorGui.java b/ihl/processing/chemistry/EvaporatorGui.java new file mode 100644 index 0000000..12edba9 --- /dev/null +++ b/ihl/processing/chemistry/EvaporatorGui.java @@ -0,0 +1,85 @@ +package ihl.processing.chemistry; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; +import ic2.core.util.DrawUtil; +import ic2.core.util.GuiTooltipHelper; + +@SideOnly(Side.CLIENT) +public class EvaporatorGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUISolidFuelEvaporator.png"); + private EvaporatorContainer container; + private String title = StatCollector.translateToLocal("ihl.gui.evaporator"); + + + public EvaporatorGui (EvaporatorContainer container1) { + //the container is instanciated and passed to the superclass for handling + super(container1); + this.container=container1; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + fontRendererObj.drawString(title, 8, 70, 6171880); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int i1; + if (this.container.tileEntity.fuel > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeFuelScaled(12),12); + this.drawTexturedModalRect(9, 16 + 12 - i1, 176, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18); + this.drawTexturedModalRect(99, 34, 198, 0, i1 + 1, 13); + } + + if (this.container.tileEntity.getTankAmount() > 0) + { + FluidStack fluidStack = this.container.tileEntity.getFluidTank().getFluid(); + if(fluidStack!=null) + { + Fluid fluid = fluidStack.getFluid(); + if(fluid!=null) + { + + IIcon fluidIcon = fluid.getIcon(); + + if (fluidIcon != null) + { + this.mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + int liquidHeight = this.container.tileEntity.gaugeLiquidScaled(47); + DrawUtil.drawRepeated(fluidIcon, (82), 16 + 47 - liquidHeight, 12.0D, liquidHeight, this.zLevel); + this.mc.renderEngine.bindTexture(background); + } + } + String tooltip = StatCollector.translateToLocal(fluidStack.getFluid().getUnlocalizedName()) + ": " + fluidStack.amount + "mB"; + GuiTooltipHelper.drawAreaTooltip(par1-90, par2-32, tooltip, xOffset-8, yOffset-15, xOffset+2, yOffset+30); + } + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/EvaporatorTileEntity.java b/ihl/processing/chemistry/EvaporatorTileEntity.java new file mode 100644 index 0000000..e4eb8c0 --- /dev/null +++ b/ihl/processing/chemistry/EvaporatorTileEntity.java @@ -0,0 +1,299 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.Map; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.item.EntityItem; +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.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import ic2.api.item.IC2Items; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.block.TileEntityLiquidTankInventory; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlotConsumableFuel; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ihl.IHLMod; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; + +public class EvaporatorTileEntity extends TileEntityLiquidTankInventory implements IHasGui +{ + public final IHLInvSlotOutput outputSlot; + public InvSlot fuelSlot; + public final InvSlotConsumableLiquidIHL fluidItemsSlot; + public final InvSlotConsumableLiquidIHL fillItemsSlot; + public final InvSlotOutput emptyFluidItemsSlot; + + public short progress = 0; + public short maxProgress = 450; + public int fuel = 0; + public int maxFuel = 0; + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("evaporator"); + + public EvaporatorTileEntity() + { + super(8); + this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 1); + this.fuelSlot = new InvSlotConsumableFuel(this, "fuel", 1, 1, true); + this.fluidItemsSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", 2, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); + this.fillItemsSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", 4, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Fill); + this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 3, 1); + } + + public static void init() + { + addRecipe(new FluidStack(FluidRegistry.getFluid("fluidrubbertreesap"),200), IC2Items.getItem("resin")); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + + try + { + this.fuel = nbttagcompound.getInteger("fuel"); + } + catch (Throwable var4) + { + this.fuel = nbttagcompound.getShort("fuel"); + } + + try + { + this.maxFuel = nbttagcompound.getInteger("maxFuel"); + } + catch (Throwable var3) + { + this.maxFuel = nbttagcompound.getShort("maxFuel"); + } + + this.progress = nbttagcompound.getShort("progress"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setInteger("fuel", this.fuel); + nbttagcompound.setInteger("maxFuel", this.maxFuel); + nbttagcompound.setShort("progress", this.progress); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=(short)side && side!=0 && side!=1; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + if(this.outputSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.outputSlot.get())); + if(this.fuelSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.fuelSlot.get())); + if(this.emptyFluidItemsSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.emptyFluidItemsSlot.get())); + return new ItemStack(IHLMod.evaporatorBlock,1); + } + + public int gaugeProgressScaled(int i) + { + return this.progress * i / maxProgress; + } + + public int gaugeFuelScaled(int i) + { + if (this.maxFuel == 0) + { + this.maxFuel = this.fuel; + + if (this.maxFuel == 0) + { + this.maxFuel = 160; + } + } + + return this.fuel * i / this.maxFuel; + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + boolean needsInvUpdate = false; + if (this.needsFluid()) + { + IHLUtils.handleFluidSlotsBehaviour(fillItemsSlot, fluidItemsSlot, emptyFluidItemsSlot, fluidTank); + } + if (this.fuel <= 0 && this.canOperate()) + { + this.fuel = this.maxFuel = ((InvSlotConsumableFuel) this.fuelSlot).consumeFuel(); + + if (this.fuel > 0) + { + needsInvUpdate = true; + } + } + + if (this.isBurning() && this.canOperate()) + { + ++this.progress; + + if (this.progress >= maxProgress) + { + this.progress = 0; + this.operate(); + needsInvUpdate = true; + } + } + else + { + this.progress = 0; + } + + if (this.fuel > 0) + { + --this.fuel; + } + + if (this.getActive() != this.isBurning()) + { + this.setActive(this.isBurning()); + needsInvUpdate = true; + } + } + + public void operate() + { + UniversalRecipeOutput output = this.getOutput(); + if(output!=null && !output.getItemOutputs().isEmpty()) + { + this.outputSlot.add(this.getOutput().getItemOutputs().get(0).copy()); + } + this.fluidTank.drain(recipeManager.getRecipeInput(Arrays.asList(new FluidStack [] {this.fluidTank.getFluid()}),null).getFluidInputs().get(0).getAmount(), true); + } + + public boolean isBurning() + { + return this.fuel > 0; + } + + public boolean canOperate() + { + if (this.fluidTank.getFluid()==null) + { + return false; + } + else + { + UniversalRecipeOutput output = recipeManager.getOutputFor(Arrays.asList(new FluidStack [] {this.fluidTank.getFluid()}),null, false, false); + return output == null ? false : (this.outputSlot.canAdd(output.getItemOutputs()) ? true : false); + } + } + + /** + * Returns the name of the inventory + */ + @Override + public String getInventoryName() + { + return "Solid fuel evaporator"; + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer entityPlayer) + { + return new EvaporatorContainer(entityPlayer, this); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer entityPlayer, boolean isAdmin) + { + return new EvaporatorGui(new EvaporatorContainer(entityPlayer, this)); + } + + @Override + public void onGuiClosed(EntityPlayer entityPlayer) {} + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return false; + } + + @Override + public boolean canFill(ForgeDirection arg0, Fluid fluid1) { + return true; + } + + public boolean getGui(EntityPlayer player) + { + return this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true) : false; + } + + public int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + public int mZ() + { + switch(this.getFacing()) + { + case 2: + return -1; + case 3: + return 1; + default: + return 0; + } + } + + public static void addRecipe(FluidStack input, ItemStack output) + { + recipeManager.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack [] {input}),null), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {output}),20)); + } + + public UniversalRecipeOutput getOutput() + { + if (this.fluidTank.getFluid()==null) + { + return null; + } + else + { + UniversalRecipeOutput output = recipeManager.getOutputFor(Arrays.asList(new FluidStack [] {this.fluidTank.getFluid()}),null, false, false); + return output == null ? null : (this.outputSlot.canAdd(output.getItemOutputs()) ? output : null); + } + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/ExplosiveTileEntity.java b/ihl/processing/chemistry/ExplosiveTileEntity.java new file mode 100644 index 0000000..777f527 --- /dev/null +++ b/ihl/processing/chemistry/ExplosiveTileEntity.java @@ -0,0 +1,49 @@ +package ihl.processing.chemistry; + +import ic2.core.ExplosionIC2; +import ic2.core.block.EntityIC2Explosive; +import ihl.utils.EntityIHLExplosion; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class ExplosiveTileEntity extends TileEntity { + + public int explosionPower=10000; + public int explosionType=1; + + public void createExplosion(EntityPlayer player) + { + switch(this.explosionType) + { + case 0: + ExplosionIC2 explosion = new ExplosionIC2(this.worldObj, new EntityIC2Explosive(worldObj), xCoord+0.5d, yCoord+0.5d, zCoord+0.5d, this.explosionPower/1000f, 0f, ExplosionIC2.Type.Normal,player, 0); + System.out.println("Start"); + explosion.doExplosion(); + System.out.println("End"); + break; + case 1: + EntityIHLExplosion ex1 = new EntityIHLExplosion(worldObj, xCoord, yCoord, zCoord,this.explosionPower); + worldObj.spawnEntityInWorld(ex1); + break; + } + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + if(nbt!=null) + { + explosionPower=nbt.getInteger("explosionPower"); + explosionType=nbt.getInteger("explosionType"); + } + } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + nbt.setInteger("explosionPower",explosionPower); + nbt.setInteger("explosionType",explosionType); + } + +} diff --git a/ihl/processing/chemistry/ExtruderModel.java b/ihl/processing/chemistry/ExtruderModel.java new file mode 100644 index 0000000..25e1263 --- /dev/null +++ b/ihl/processing/chemistry/ExtruderModel.java @@ -0,0 +1,100 @@ +package ihl.processing.chemistry; + +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; +import ihl.model.IHLModelRenderer; + +public class ExtruderModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer Belt; + IHLModelRenderer Belt2; + IHLModelRenderer Extruder; + + public ExtruderModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("RotatingPart2.PipeN7", 49, 23); + setTextureOffset("RotatingPart2.PipeN4", 0, 7); + setTextureOffset("MotorPart1.PipeN41", 0, 0); + setTextureOffset("MotorPart1.PipeN12", 0, 0); + setTextureOffset("MotorPart1.PipeN13", 0, 0); + setTextureOffset("MotorPart2.Shape4", 0, 24); + setTextureOffset("MotorPart2.Shape7", 0, 9); + setTextureOffset("MotorPart2.Shape10", 0, 9); + setTextureOffset("Belt.Shape12", 0, 0); + setTextureOffset("Belt2.Shape13", 0, 0); + setTextureOffset("Extruder.PipeN16", 0, 0); + setTextureOffset("Extruder.PipeN15", 24, 20); + setTextureOffset("Extruder.Shape8", 0, 0); + setTextureOffset("Extruder.PipeU17", 0, 0); + setTextureOffset("Extruder.PipeUC18", 0, 0); + setTextureOffset("Extruder.Shape14", 0, 0); + setTextureOffset("Extruder.PipeN14", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape3", -5F, 0F, -7F, 4, 7, 1); + Base.addBox("Shape16", 3F, 3F, -6F, 3, 4, 1); + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(-3F, 18F, -7F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = true; + RotatingPart2.addTube("PipeN7", -2.5F, -2.5F, -1F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN4", -1F, -1F, 1F, 2, 2, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1 = new IHLModelRenderer(this, "MotorPart1"); + MotorPart1.setRotationPoint(4.5F, 20.5F, 0F); + setRotation(MotorPart1, 0F, 0F, 0F); + MotorPart1.mirror = true; + MotorPart1.addTube("PipeN41", -1.5F, -1.5F, -8F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN12", -0.5F, -0.5F, -7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN13", -1.5F, -1.5F, -5F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + MotorPart2 = new IHLModelRenderer(this, "MotorPart2"); + MotorPart2.setRotationPoint(0F, 16F, 0F); + setRotation(MotorPart2, 0F, 0F, 0F); + MotorPart2.mirror = true; + MotorPart2.addBox("Shape4", 3F, 3F, 0F, 3, 4, 4); + MotorPart2.addBox("Shape7", 6F, 3F, -5F, 2, 4, 5); + MotorPart2.addBox("Shape10", 1F, 3F, -5F, 2, 4, 5); + Belt = new IHLModelRenderer(this, "Belt"); + Belt.setRotationPoint(-3F, 15.5F, -7.9F); + setRotation(Belt, 0F, 0F, 0.45F); + Belt.mirror = true; + Belt.addBox("Shape12", 0.5F, 0F, 0F, 8, 1, 1); + Belt2 = new IHLModelRenderer(this, "Belt2"); + Belt2.setRotationPoint(-3F, 19.5F, -7.9F); + setRotation(Belt2, 0F, 0F, 0.19F); + Belt2.mirror = true; + Belt2.addBox("Shape13", 0F, 0F, 0F, 8, 1, 1); + Extruder = new IHLModelRenderer(this, "Extruder"); + Extruder.setRotationPoint(0F, 16F, 0F); + setRotation(Extruder, 0F, 0F, 0F); + Extruder.mirror = true; + Extruder.addTube("PipeN16", -4.5F, 0.5F, -5F, 3, 3, 12, 0F,1F,ForgeDirection.NORTH); + Extruder.addTube("PipeN15", -5.5F, -0.5F, 0F, 5, 5, 7, 0.5F,1F,ForgeDirection.NORTH); + Extruder.addBox("Shape8", -5F, 4F, 6.9F, 4, 3, 1); + Extruder.addTube("PipeU17", -5.5F, -8F, -5F, 5, 8, 5, 0.8F,1F,ForgeDirection.UP); + Extruder.addTube("PipeUC18", -5.5F, 0F, -5F, 5, 2, 5, 0.8F,0.6F,ForgeDirection.UP); + Extruder.addBox("Shape14", -5F, 3F, -4.9F, 4, 4, 1); + Extruder.addTube("PipeN14", -5.5F, -0.5F, 7F, 5, 5, 1, 0.5F,1F,ForgeDirection.NORTH); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/chemistry/FluidizedBedReactorContainer.java b/ihl/processing/chemistry/FluidizedBedReactorContainer.java new file mode 100644 index 0000000..4d42d29 --- /dev/null +++ b/ihl/processing/chemistry/FluidizedBedReactorContainer.java @@ -0,0 +1,103 @@ +package ihl.processing.chemistry; + +import java.util.List; + +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraftforge.fluids.FluidStack; + +public class FluidizedBedReactorContainer extends ContainerBase { + + protected FluidizedBedReactorTileEntity tileEntity; + public int lastFluidAmount = -1; + public int lastNumberOfFluids = -1; + public short lastProgress = -1; + public short lastTemperature = -1; + public short lastEnergy = -1; + private final static int height=166; + public List fluidTankFluidList; + + public FluidizedBedReactorContainer(EntityPlayer entityPlayer, FluidizedBedReactorTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + fluidTankFluidList = this.tileEntity.getFluidTank().getFluidList(); + int col; + for (col = 0; col < 3; ++col) + { + for (int col1 = 0; col1 < 9; ++col1) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); + } + } + for (col = 0; col < 9; ++col) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); + } + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 102, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 102, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 102, 33)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 8, 23)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 1, 8, 41)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 43, 33)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.engine, 0, 151, 33)); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + if (this.tileEntity.getTankAmount() != this.lastFluidAmount || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + + if (this.tileEntity.temperature != this.lastTemperature) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.temperature); + } + if ((short) this.tileEntity.energy != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 2, (short) this.tileEntity.energy); + } + } + this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank(); + this.lastFluidAmount = this.tileEntity.getTankAmount(); + this.lastProgress = this.tileEntity.progress; + this.lastTemperature = this.tileEntity.temperature; + this.lastEnergy = (short) this.tileEntity.energy; + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + switch (index) + { + case 0: + this.tileEntity.progress=(short) value; + break; + case 1: + this.tileEntity.temperature=(short) value; + break; + case 2: + this.tileEntity.energy=value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/FluidizedBedReactorGui.java b/ihl/processing/chemistry/FluidizedBedReactorGui.java new file mode 100644 index 0000000..6d07aca --- /dev/null +++ b/ihl/processing/chemistry/FluidizedBedReactorGui.java @@ -0,0 +1,66 @@ +package ihl.processing.chemistry; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import ihl.utils.IHLRenderUtils; + +@SideOnly(Side.CLIENT) +public class FluidizedBedReactorGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIFluidizedBedReactor.png"); + private FluidizedBedReactorContainer container; + private int mixerFrame=0; + + public FluidizedBedReactorGui (FluidizedBedReactorContainer container1) { + //the container is instanciated and passed to the superclass for handling + super(container1); + this.container=container1; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) + { + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(155, 17 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(17),17); + this.drawTexturedModalRect(25, 34, 198, 0,i1,13); + if(mixerFrame++>3) + { + mixerFrame=0; + } + this.drawTexturedModalRect(126, 31, 244, 126+26*mixerFrame,12,26); + } + if (this.container.tileEntity.getTankAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 126, 28, 138, 59, zLevel, par1, par2, xOffset, yOffset); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(background); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 169, 34, xOffset, yOffset); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java b/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java new file mode 100644 index 0000000..e9b2ec5 --- /dev/null +++ b/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java @@ -0,0 +1,358 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.core.ContainerBase; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.processing.metallurgy.BasicElectricMotorTileEntity; +import ihl.recipes.RecipeOutputItemStack; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; + +public class FluidizedBedReactorTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler +{ + private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("fluidizedbedreactor"); + public final ApparatusProcessableInvSlot input; + public final IHLInvSlotOutput outputSlot; + public final InvSlotConsumableLiquidIHL drainInputSlot; + public final InvSlotConsumableLiquidIHL fillInputSlot; + public final InvSlotOutput emptyFluidItemsSlot; + private final IHLFluidTank fluidTank = new IHLFluidTank(8000); + public short temperature=20; + private int fractionalOutputAmount=0; + + public FluidizedBedReactorTileEntity() { + super(); + this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 1); + this.drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); + this.fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 1); + this.input = new ApparatusProcessableInvSlot(this, "input", 3, Access.IO, 2, 64); + this.isGuiScreenOpened=true; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("fluidizedBedReactor"); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank); + } + + @Override + public FluidStack drain(ForgeDirection from, int amount, boolean doDrain) + { + switch(from) + { + case UP: + return this.fluidTank.drainLightest(amount, doDrain); + case NORTH: + return this.fluidTank.drainLightest(amount, doDrain); + case SOUTH: + return this.fluidTank.drainLightest(amount, doDrain); + case WEST: + return this.fluidTank.drainLightest(amount, doDrain); + case EAST: + return this.fluidTank.drainLightest(amount, doDrain); + case DOWN: + return this.fluidTank.drain(amount, doDrain); + default: + return this.fluidTank.drain(amount, doDrain); + } + } + + + //1.7.10 API + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return true; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return direction.equals(ForgeDirection.getOrientation(this.getFacing()).getOpposite()); + } + + @Override + public String getInventoryName() { + return "fluidizedBedReactor"; + } + + private int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + private int mZ() + { + switch(this.getFacing()) + { + case 3: + return 1; + case 2: + return -1; + case 4: + return 0; + case 5: + return 0; + default: + return -1; + } + } + + private short getFacingFromXZ(int x, int z) + { + switch(x) + { + case -1: + return (short)4; + case 1: + return (short)5; + default: + switch(z) + { + case 1: + return (short)3; + case -1: + return (short)2; + default: + return (short)2; + } + } + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + // TODO Auto-generated method stub + } + + @Override + public int gaugeProgressScaled(int i) + { + return this.progress * i / operationLength; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new FluidizedBedReactorGui(new FluidizedBedReactorContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) + { + this.fluidTank.sortFluidsByDensity(); + return new FluidizedBedReactorContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) {} + + @Override + public boolean canOperate() + { + UniversalRecipeOutput output = getOutput(); + if(output!=null && this.outputSlot.canAdd(getOutput().getItemOutputs())) + { + if(output.specialConditions) + { + return this.checkSpecialConditions(); + } + else + { + return true; + } + } + return false; + } + + private boolean checkSpecialConditions() + { + ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing()); + TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX, yCoord, zCoord+dir.offsetZ); + if(te instanceof CryogenicDistillerTileEntity) + { + CryogenicDistillerTileEntity cgte = (CryogenicDistillerTileEntity)te; + return cgte.getFacing()==this.getFacing() && cgte.canProcess(); + } + return false; + } + + public UniversalRecipeOutput getOutput() + { + return FluidizedBedReactorTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + @Override + public List[] getInput() + { + for(int i=0;i1)this.input.consume(1, recipeInput.getItemInputs().get(1).getAmount()); + if(output1.getFluidOutputs().size()>0)this.fluidTank.fill(output1.getFluidOutputs().get(0).copy(), true); + if(output1.getFluidOutputs().size()>1)this.fluidTank.fill(output1.getFluidOutputs().get(1).copy(), true); + if(!output1.getItemOutputs().isEmpty() && output1.getItemOutputs().get(0)!=null)this.outputSlot.add(output1.getItemOutputs()); + + } + + @Override + public FluidStack drain(ForgeDirection arg0, FluidStack fluidStack, boolean doDrain) { + if(fluidTank.getFluid()!=null && fluidTank.getFluid().containsFluid(fluidStack)) + { + return this.fluidTank.drain(fluidStack, doDrain); + } + return null; + } + + @Override + public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return this.fluidTank.fill(arg1, arg2); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) { + return new FluidTankInfo[] {this.fluidTank.getInfo()}; + } + + public boolean needsFluid() + { + return this.fluidTank.getFluidAmount() <= this.fluidTank.getCapacity(); + } + + public FluidStack getFluidStackfromTank() + { + return this.fluidTank.getFluid(); + } + + public int getTankAmount() + { + return this.fluidTank.getFluidAmount(); + } + + public int gaugeLiquidScaled(int i, int index) + { + return this.fluidTank.getFluidAmount() <= 0 ? 0 : this.fluidTank.getFluidAmount(index) * i / this.fluidTank.getCapacity(); + } + public static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output) + { + recipeManager.addRecipe(input, output); + } + + public int getNumberOfFluidsInTank() + { + return this.fluidTank.getNumberOfFluids(); + } + + public static Map getRecipes() + { + return recipeManager.getRecipes(); + } + + public static void addRecipe(FluidStack fluidStackInput1, ItemStack itemStackInput, FluidStack fluidStackOutput, ItemStack itemStackOutput1) + { + if(fluidStackOutput!=null) + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1}), Arrays.asList(new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStackOutput}), Arrays.asList(new ItemStack[] {itemStackOutput1}),200)); + } + else + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1}), Arrays.asList(new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {itemStackOutput1}),200)); + } + } + + public IHLFluidTank getFluidTank() + { + return this.fluidTank; + } + + public static void addRecipe(FluidStack fluidStackInput1, ItemStack itemStackInput, FluidStack fluidStackOutput, RecipeOutputItemStack itemStackOutput1) { + if(fluidStackOutput!=null) + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1}), Arrays.asList(new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStackOutput}), Arrays.asList(new RecipeOutputItemStack[] {itemStackOutput1}),200)); + } + else + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1}), Arrays.asList(new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(null, Arrays.asList(new RecipeOutputItemStack[] {itemStackOutput1}),200)); + } + } + +} \ No newline at end of file diff --git a/ihl/processing/chemistry/FractionatorBottomModel.java b/ihl/processing/chemistry/FractionatorBottomModel.java new file mode 100644 index 0000000..c395af7 --- /dev/null +++ b/ihl/processing/chemistry/FractionatorBottomModel.java @@ -0,0 +1,48 @@ +// Date: 05.04.2015 16:55:22 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class FractionatorBottomModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public FractionatorBottomModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Box03", 0, 0); + setTextureOffset("Base.Box04", 0, 0); + setTextureOffset("Base.Pipeup02", 0, 0); + setTextureOffset("Base.WestPipe03", 0, 0); + setTextureOffset("Base.WestPipe04", 0, 0); + setTextureOffset("Base.PipeUp05", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Box03", 2F, -7.1F, -8F, 6, 15, 16); + Base.addBox("Box04", -8F, 7F, -8F, 16, 1, 16); + Base.addTube("Pipeup02", -8F, -8F, -8F, 16, 1, 16, 0.8F, 1.0F, ForgeDirection.UP); + Base.addTube("WestPipe03", -7.5F, -1.5F, -1.5F, 3, 3, 3, 0.8F, 1.0F, ForgeDirection.WEST); + Base.addTube("WestPipe04", -8F, -2F, -2F, 1, 4, 4, 0.8F, 1.0F, ForgeDirection.WEST); + Base.addTube("PipeUp05", -7F, -7F, -7F, 14, 15, 14, 0.8F, 1.0F, ForgeDirection.UP); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/chemistry/FractionatorBottomTileEntity.java b/ihl/processing/chemistry/FractionatorBottomTileEntity.java new file mode 100644 index 0000000..41840e0 --- /dev/null +++ b/ihl/processing/chemistry/FractionatorBottomTileEntity.java @@ -0,0 +1,389 @@ +package ihl.processing.chemistry; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.api.energy.tile.IHeatSource; +import ic2.core.IC2; +import ic2.core.block.TileEntityInventory; +import ihl.recipes.IRecipeInputFluid; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; +import ihl.worldgen.ores.IHLFluid; + +public class FractionatorBottomTileEntity extends TileEntityInventory +{ + private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("fractionator"); + private static float kF = 24000F; + private static float gasC = 1F; + private static float fluidC = 4F; + private static float H = 2256F; + private final IHLFluidTank waterTank = new IHLFluidTank(100); + private final IHLFluidTank fluidTank = new IHLFluidTank(8000); + private int amountOfGasCondensed=0; + private int amountOfFluidEvaporated=0; + private int systemHeat=0; + private static final int maxSystemHeat=10000; + private final List listOfColumnSections = new ArrayList(); + private FractionatorCoverTileEntity columnCover; + private RefluxCondenserTileEntity refluxCondenser; + private IHeatSource heatSource; + private int fluxRecirculationProportion=10; + + public FractionatorBottomTileEntity() + { + super(); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + this.waterTank.readFromNBT(nbttagcompound.getCompoundTag("waterTank")); + this.amountOfGasCondensed=nbttagcompound.getInteger("amountOfGasCondensed"); + this.systemHeat=nbttagcompound.getInteger("systemHeat"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + + NBTTagCompound waterTankTag = new NBTTagCompound(); + this.waterTank.writeToNBT(waterTankTag); + nbttagcompound.setTag("waterTank", waterTankTag); + + nbttagcompound.setInteger("amountOfGasCondensed",this.amountOfGasCondensed); + nbttagcompound.setInteger("systemHeat",this.systemHeat); + + } + + public static void addRecipe(FluidStack fluidIn, FluidStack fluidOut1, FluidStack fluidOut2) + { + recipeManager.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidIn}), null), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidOut1,fluidOut2}),null,2)); + } + + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=(short)side && side!=0 && side!=1; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("fractionatorBottom"); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if(!this.checkIntegrity()) + { + return; + } + this.fluxRecirculationProportion=100-10000/(100+this.listOfColumnSections.size()*3); + ForgeDirection orientation = ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.UP); + if(systemHeat < maxSystemHeat && this.checkHeatSource(orientation)) + { + systemHeat+=this.heatSource.requestHeat(orientation.getOpposite(), Integer.MAX_VALUE); + } + FluidStack fsCurrentInput = this.fluidTank.getFluid(); + if(fsCurrentInput!=null && fsCurrentInput.amount>100 && systemHeat>0) + { + UniversalRecipeOutput rOutput = FractionatorBottomTileEntity.recipeManager.getOutputFor(Arrays.asList(new FluidStack [] {this.fluidTank.getFluid()}),null, false, false); + UniversalRecipeInput rInput = FractionatorBottomTileEntity.recipeManager.getRecipeInput(Arrays.asList(new FluidStack [] {this.fluidTank.getFluid()}),null); + if(rOutput!=null) + { + IRecipeInputFluid input = rInput.getFluidInputs().get(0); + int rInputAmount = input.getAmount(); + FluidStack result1=rOutput.getFluidOutputs().get(0).copy(); + FluidStack result2=rOutput.getFluidOutputs().get(1).copy(); + //max heat per tick of electric heater is 100 + int amountOfFluidToEvaporate = Math.min(fsCurrentInput.amount*result2.amount/rInputAmount,systemHeat/100); + systemHeat-=amountOfFluidToEvaporate*100; + amountOfFluidEvaporated+=amountOfFluidToEvaporate; + int amountOfVapours=amountOfFluidEvaporated*50; + FluidStack coolant = this.waterTank.getFluid(); + if(coolant!=null && coolant.amount>0) + { + int t1 = this.waterTank.getTemperature(); + float densityOfCoolant = IHLFluid.getRealDensity(coolant.getFluid()); + float densityOfGas = 17.8f; + int boilingPointOfGas = IHLFluid.getBoilingPoint(result2.getFluid()); + int amountOfGasToCondense = this.getAmountOfCondensedGas(coolant.amount, amountOfVapours, boilingPointOfGas, t1, densityOfGas, densityOfCoolant); + amountOfGasCondensed += amountOfGasToCondense; + amountOfFluidEvaporated -= amountOfGasToCondense/50; + } + if(amountOfGasCondensed>10000) + { + int amountToProcess=amountOfGasCondensed*this.fluxRecirculationProportion/5000;//only 10% of condensate will be extracted. + int amount = rInputAmount * amountToProcess / result2.amount; + result1.amount = result1.amount* amountToProcess / result2.amount; + result2.amount = amountToProcess; + this.fluidTank.drain(input,amount, true); + this.fillVatResidueOutputApparatus(orientation.getOpposite(), result1, true); + this.fillCondensateOutputApparatus(ForgeDirection.UP, result2, true); + amountOfGasCondensed=0; + } + } + } + if(this.waterTank.getFluid()!=null) + { + FluidStack coolant = this.waterTank.drain(5, true); + this.fillHeatTransferAgentOutputApparatus(ForgeDirection.UP, coolant, true); + } + } + + + private boolean checkHeatSource(ForgeDirection orientation) + { + if(this.heatSource!=null) + { + return true; + } + else + { + TileEntity te = worldObj.getTileEntity(xCoord+orientation.offsetX, yCoord, zCoord+orientation.offsetZ); + if(te instanceof IHeatSource) + { + if(((IHeatSource)te).maxrequestHeatTick(orientation.getOpposite())>0) + { + this.heatSource=(IHeatSource)te; + return true; + } + } + } + return false; + } + + private boolean checkIntegrity() + { + boolean allright=true; + if(!this.listOfColumnSections.isEmpty() && + this.columnCover!=null && + !this.columnCover.isInvalid() && + this.refluxCondenser!=null && + !this.refluxCondenser.isInvalid()) + { + Iterator sectionsIterator = this.listOfColumnSections.iterator(); + while(sectionsIterator.hasNext()) + { + FractionatorSectionTileEntity section = sectionsIterator.next(); + if(section==null || section.isInvalid()) + { + allright=false; + } + } + } + else + { + allright=false; + } + if(allright) + { + return true; + } + else + { + this.listOfColumnSections.clear(); + this.columnCover=null; + this.refluxCondenser=null; + boolean checking = true; + int height=0; + while(checking) + { + height++; + TileEntity te = worldObj.getTileEntity(xCoord, yCoord+height, zCoord); + if(te instanceof FractionatorSectionTileEntity) + { + FractionatorSectionTileEntity section = (FractionatorSectionTileEntity)te; + section.columnBottom=this; + this.listOfColumnSections.add(section); + } + else if(te instanceof FractionatorCoverTileEntity) + { + if(this.listOfColumnSections.isEmpty()) + { + return false; + } + FractionatorCoverTileEntity fcte = (FractionatorCoverTileEntity)te; + this.columnCover=fcte; + ForgeDirection orientation = ForgeDirection.getOrientation(fcte.getFacing()).getRotation(ForgeDirection.DOWN); + te = worldObj.getTileEntity(xCoord+orientation.offsetX, yCoord+height, zCoord+orientation.offsetZ); + if(te instanceof RefluxCondenserTileEntity) + { + if(((RefluxCondenserTileEntity)te).getFacing()==fcte.getFacing()) + { + this.refluxCondenser=(RefluxCondenserTileEntity)te; + this.refluxCondenser.columnBottom=this; + return true; + } + } + } + else + { + checking=false; + } + } + } + return false; + } + + private int getAmountOfCondensedGas(int amountOfCoolant, int amountOfGas, int boilingPointOfGas, int temperatureOfCoolant, float densityOfGas, float densityOfCoolant) + { + if(amountOfCoolant<=0 || amountOfGas<=0 || boilingPointOfGas-202*dt2) + { + deltaT = (float) ((dt1-dt2)/Math.log((double)dt2/(double)dt1)); + } + else + { + deltaT = (dt1+dt2)*0.5F; + } + float Q1 = kF*deltaT; + if(Q1>=maxQ) + { + break; + } + else + { + int next_L = (int)(Q1/H/densityOfGas); + if(Math.abs(next_L-L)<4) + { + L=next_L; + break; + } + L=next_L; + } + } + if(t1_1>t1) + { + this.waterTank.setTemperature(t1_1); + } + else + { + this.waterTank.setTemperature(t1+1); + } + return L; + } + + @Override + public String getInventoryName() + { + return "fractionator"; + } + + public void onGuiClosed(EntityPlayer entityPlayer) {} + + public int fill(ForgeDirection direction, FluidStack fluidStack, boolean doFill) + { + if(direction.equals(ForgeDirection.UP)) + { + return waterTank.fill(fluidStack, doFill); + } + else + { + return fluidTank.fill(fluidStack, doFill); + } + } + + private int fillCondensateOutputApparatus(ForgeDirection direction,FluidStack fluidStack, boolean doFill) + { + TileEntity te = worldObj.getTileEntity(this.refluxCondenser.xCoord,this.refluxCondenser.yCoord-1,this.refluxCondenser.zCoord); + if(te instanceof IFluidHandler) + { + return ((IFluidHandler)te).fill(direction, fluidStack, doFill); + } + else + { + return 0; + } + } + + + private int fillVatResidueOutputApparatus(ForgeDirection orientation, FluidStack fluidStack, boolean doFill) { + TileEntity te = worldObj.getTileEntity(xCoord+orientation.offsetX,yCoord, zCoord+orientation.offsetZ); + if(te instanceof IFluidHandler) + { + return ((IFluidHandler)te).fill(orientation, fluidStack, doFill); + } + else + { + return 0; + } + } + + private int fillHeatTransferAgentOutputApparatus(ForgeDirection direction,FluidStack fluidStack, boolean doFill) + { + ForgeDirection orientation = ForgeDirection.getOrientation(this.refluxCondenser.getFacing()).getOpposite(); + TileEntity te = worldObj.getTileEntity(this.refluxCondenser.xCoord+orientation.offsetX,this.refluxCondenser.yCoord,this.refluxCondenser.zCoord+orientation.offsetZ); + if(te instanceof IFluidHandler) + { + return ((IFluidHandler)te).fill(orientation, fluidStack, doFill); + } + else + { + return 0; + } + } + + @Override + public void setFacing(short facing1) + { + super.setFacing((short) Math.max(facing1, 2)); + } + + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) { + return new FluidTankInfo[]{this.fluidTank.getInfo(), this.waterTank.getInfo()}; + } + + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/FractionatorCoverModel.java b/ihl/processing/chemistry/FractionatorCoverModel.java new file mode 100644 index 0000000..451d73c --- /dev/null +++ b/ihl/processing/chemistry/FractionatorCoverModel.java @@ -0,0 +1,52 @@ +// Date: 05.04.2015 1:01:48 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class FractionatorCoverModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public FractionatorCoverModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.PipeUp03", 0, 0); + setTextureOffset("Base.ConeUp14to10", 0, 0); + setTextureOffset("Base.PipeUp", 0, 0); + setTextureOffset("Base.KneeUPWEST", 0, 0); + setTextureOffset("Base.WestPipe03", 0, 0); + setTextureOffset("Base.WestPipe04", 0, 0); + setTextureOffset("Base.ConeUp10To3", 0, 0); + setTextureOffset("Base.WestPipe02", 0, 0); + setTextureOffset("Base.WestPipe01", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addTube("PipeUp03", -8F, 7F, -8F, 16, 1, 16, .8F, 1F, ForgeDirection.UP); + Base.addTube("ConeUp14to10", -7F, 2F, -7F, 14, 5, 14, .8F, 0.71F, ForgeDirection.DOWN); + Base.addTube("PipeUp", -1.5F, -2.5F, -1.5F, 3, 3, 3, .8F, 1F, ForgeDirection.UP); + Base.addKnee("KneeUPWEST", -3F, -8.5F, -3F, 6, 6, 6, .8F, 1F, ForgeDirection.DOWN, ForgeDirection.WEST); + Base.addTube("WestPipe03", -7F, -7F, -1.5F, 4, 3, 3, .8F, 1F, ForgeDirection.WEST); + Base.addTube("WestPipe04", -8F, -7.5F, -2F, 1, 4, 4, .6F, 1F, ForgeDirection.WEST); + Base.addTube("ConeUp10To3", -5F, 0F, -5F, 10, 2, 10, .8F, 0.3F, ForgeDirection.DOWN); + Base.addTube("WestPipe02", -8F, 3F, -2F, 1, 4, 4, .6F, 1F, ForgeDirection.WEST); + Base.addTube("WestPipe01", -7F, 3.5F, -1.5F, 3, 3, 3, .8F, 1F, ForgeDirection.WEST); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } +} diff --git a/ihl/processing/chemistry/FractionatorCoverTileEntity.java b/ihl/processing/chemistry/FractionatorCoverTileEntity.java new file mode 100644 index 0000000..d7addf2 --- /dev/null +++ b/ihl/processing/chemistry/FractionatorCoverTileEntity.java @@ -0,0 +1,105 @@ +package ihl.processing.chemistry; + +import java.util.ArrayList; +import java.util.List; + +import ic2.api.network.INetworkDataProvider; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.utils.IHLUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class FractionatorCoverTileEntity extends TileEntity implements IWrenchable, INetworkDataProvider{ + + private short facing=2; + private short lastFacing=2; + public FractionatorBottomTileEntity columnBottom; + + public FractionatorCoverTileEntity() + { + super(); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public List getNetworkedFields() + { + List fields = new ArrayList(); + fields.add("facing"); + return fields; + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(lastFacing!=facing) + { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing=facing; + } + } + + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + + @Override + public short getFacing() { + return this.facing; + } + + + @Override + public void setFacing(short facing1) + { + facing=(short) Math.max(2,facing1); + if(IC2.platform.isSimulating()) + { + IC2.network.get().updateTileEntityField(this, "facing"); + } + } + + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + + @Override + public float getWrenchDropRate() { + return 1F; + } + + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("fractionatorCover"); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + facing=nbttagcompound.getShort("facing"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setShort("facing", facing); + } +} diff --git a/ihl/processing/chemistry/FractionatorSectionModel.java b/ihl/processing/chemistry/FractionatorSectionModel.java new file mode 100644 index 0000000..2a20e7b --- /dev/null +++ b/ihl/processing/chemistry/FractionatorSectionModel.java @@ -0,0 +1,47 @@ +// Date: 05.04.2015 16:59:49 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + + +public class FractionatorSectionModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public FractionatorSectionModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.PipeUp03", 0, 0); + setTextureOffset("Base.Pipeup02", 0, 0); + setTextureOffset("Base.WestPipe03", 0, 0); + setTextureOffset("Base.WestPipe04", 0, 0); + setTextureOffset("Base.PipeUp05", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addTube("PipeUp03", -8F, 7F, -8F, 16, 1, 16, 0.8F, 1.0F, ForgeDirection.UP); + Base.addTube("Pipeup02", -8F, -8F, -8F, 16, 1, 16, 0.8F, 1.0F, ForgeDirection.UP); + Base.addTube("WestPipe03", 4.5F, -1.5F, -1.5F, 3, 3, 3, 0.8F, 1.0F, ForgeDirection.WEST); + Base.addTube("WestPipe04", 7F, -2F, -2F, 1, 4, 4, 0.8F, 1.0F, ForgeDirection.WEST); + Base.addTube("PipeUp05", -7F, -7F, -7F, 14, 14, 14, 0.8F, 1.0F, ForgeDirection.UP); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + +} diff --git a/ihl/processing/chemistry/FractionatorSectionTileEntity.java b/ihl/processing/chemistry/FractionatorSectionTileEntity.java new file mode 100644 index 0000000..18314d6 --- /dev/null +++ b/ihl/processing/chemistry/FractionatorSectionTileEntity.java @@ -0,0 +1,146 @@ +package ihl.processing.chemistry; + +import java.util.ArrayList; +import java.util.List; + +import ic2.api.network.INetworkDataProvider; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.utils.IHLUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class FractionatorSectionTileEntity extends TileEntity implements IWrenchable, INetworkDataProvider, IFluidHandler{ + + private short facing=2; + private short lastFacing=2; + public FractionatorBottomTileEntity columnBottom; + + public FractionatorSectionTileEntity() + { + super(); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public List getNetworkedFields() + { + List fields = new ArrayList(); + fields.add("facing"); + return fields; + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(lastFacing!=facing) + { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing=facing; + } + } + + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + + @Override + public short getFacing() { + return this.facing; + } + + + @Override + public void setFacing(short facing1) + { + facing=(short) Math.max(2,facing1); + if(IC2.platform.isSimulating()) + { + IC2.network.get().updateTileEntityField(this, "facing"); + } + } + + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + + @Override + public float getWrenchDropRate() { + return 1F; + } + + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("fractionatorSection"); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + facing=nbttagcompound.getShort("facing"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setShort("facing", facing); + } + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return false; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.UP).equals(direction); + } + + @Override + public FluidStack drain(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return null; + } + + @Override + public FluidStack drain(ForgeDirection arg0, int arg1, boolean arg2) { + return null; + } + + @Override + public int fill(ForgeDirection direction, FluidStack fluidStack, boolean doFill) { + if(fluidStack!=null && fluidStack.getFluid()!=null && this.canFill(direction, fluidStack.getFluid()) && columnBottom!=null) + { + return columnBottom.fill(direction, fluidStack, doFill); + } + return 0; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) + { + return columnBottom.getTankInfo(arg0); + } + +} diff --git a/ihl/processing/chemistry/GaedesMercuryRotaryPumpContainer.java b/ihl/processing/chemistry/GaedesMercuryRotaryPumpContainer.java new file mode 100644 index 0000000..cbd3239 --- /dev/null +++ b/ihl/processing/chemistry/GaedesMercuryRotaryPumpContainer.java @@ -0,0 +1,76 @@ +package ihl.processing.chemistry; + +import ic2.core.ContainerBase; +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; + +public class GaedesMercuryRotaryPumpContainer extends ContainerBase { + + protected GaedesMercuryRotaryPumpTileEntity tileEntity; + private final static int height=166; + public short lastEnergy = -1; + public short lastProgress = -1; + + public GaedesMercuryRotaryPumpContainer(EntityPlayer entityPlayer, GaedesMercuryRotaryPumpTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + int col; + for (col = 0; col < 3; ++col) + { + for (int col1 = 0; col1 < 9; ++col1) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); + } + } + for (col = 0; col < 9; ++col) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); + } + this.addSlotToContainer(new SlotInvSlot(tileEntity1.engine, 0, 61, 36)); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + if ((short) this.tileEntity.energy != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 2, (short) this.tileEntity.energy); + } + } + + this.lastProgress = this.tileEntity.progress; + this.lastEnergy = (short) this.tileEntity.energy; + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + + switch (index) + { + case 0: + this.tileEntity.progress=(short) value; + break; + case 2: + this.tileEntity.energy=value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/GaedesMercuryRotaryPumpGui.java b/ihl/processing/chemistry/GaedesMercuryRotaryPumpGui.java new file mode 100644 index 0000000..78f1b0c --- /dev/null +++ b/ihl/processing/chemistry/GaedesMercuryRotaryPumpGui.java @@ -0,0 +1,69 @@ +package ihl.processing.chemistry; + +import org.lwjgl.opengl.GL11; + +import ihl.utils.IHLRenderUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; + +public class GaedesMercuryRotaryPumpGui extends GuiContainer { + + private GaedesMercuryRotaryPumpContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUIGaedesMercuryRotaryPump.png"); + + public GaedesMercuryRotaryPumpGui(GaedesMercuryRotaryPumpContainer latheContainer) { + super(latheContainer); + container = latheContainer; + } + + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(tex); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(51, 37 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27); + this.drawTexturedModalRect(17, 30, getFrameX(i1), getFrameY(i1),24,24); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(tex); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 79, 37, xOffset, yOffset); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(tex); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } + + private int getFrameY(int number) + { + return (number % 10) * 24 + 14; + } + + private int getFrameX(int number) + { + return (number / 10) * 24 + 176; + } +} diff --git a/ihl/processing/chemistry/GaedesMercuryRotaryPumpModel.java b/ihl/processing/chemistry/GaedesMercuryRotaryPumpModel.java new file mode 100644 index 0000000..607d26a --- /dev/null +++ b/ihl/processing/chemistry/GaedesMercuryRotaryPumpModel.java @@ -0,0 +1,64 @@ +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +// Date: 17.03.2015 21:30:34 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +public class GaedesMercuryRotaryPumpModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public GaedesMercuryRotaryPumpModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.PipeN1", 0, 0); + setTextureOffset("Base.PipeU3", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.PipeN2", 0, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape7", 0, 0); + setTextureOffset("Base.PipeU4", 0, 0); + setTextureOffset("Base.Shape1", 0, 0); + setTextureOffset("Base.PipeW5", 0, 0); + setTextureOffset("Base.Shape2", 0, 0); + setTextureOffset("Base.Shape4", 0, 0); + setTextureOffset("Base.Shape8", 0, 0); + setTextureOffset("Base.PipeW8", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addTube("PipeN1", -5F, -5F, -6F, 10, 10, 10,0F,1F,ForgeDirection.NORTH); + Base.addTube("PipeU3", -0.5F, -2.5F, -8F, 1, 2, 1,0.1F,1F,ForgeDirection.UP); + Base.addBox("Shape3", -0.5F, -0.5F, -8F, 1, 1, 2); + Base.addTube("PipeN2", -3F, -2F, 4F, 6, 6, 4,0F,1F,ForgeDirection.NORTH); + Base.addBox("Shape5", -7F, 7F, -6F, 14, 1, 14); + Base.addBox("Shape6", 2F, 1F, -5F, 1, 6, 12); + Base.addBox("Shape7", -3F, 1F, -5F, 1, 6, 12); + Base.addTube("PipeU4", 0F, -8F, -5F, 1, 3, 1,0.1F,1F,ForgeDirection.UP); + Base.addBox("Shape1", 0F, -7F, -5F, 1, 1, 1); + Base.addTube("PipeW5", -1F, -7F, -5F, 8, 1, 1,0.1F,1F,ForgeDirection.WEST); + Base.addBox("Shape2", 4F, -8F, -5F, 1, 2, 1); + Base.addBox("Shape4", 4F, -8F, -1F, 1, 8, 1); + Base.addBox("Shape8", -5F, -8F, -1F, 1, 8, 1); + Base.addTube("PipeW8", -4F, -8F, -1F, 8, 1, 1,0.1F,1F,ForgeDirection.WEST); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/chemistry/GaedesMercuryRotaryPumpTileEntity.java b/ihl/processing/chemistry/GaedesMercuryRotaryPumpTileEntity.java new file mode 100644 index 0000000..3a9b814 --- /dev/null +++ b/ihl/processing/chemistry/GaedesMercuryRotaryPumpTileEntity.java @@ -0,0 +1,83 @@ +package ihl.processing.chemistry; + +import java.util.List; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.ContainerBase; +import ihl.interfaces.IWorkspaceElement; +import ihl.processing.metallurgy.BasicElectricMotorTileEntity; +import ihl.utils.IHLUtils; + +public class GaedesMercuryRotaryPumpTileEntity extends BasicElectricMotorTileEntity implements IWorkspaceElement{ + + public boolean ready=false; + + public GaedesMercuryRotaryPumpTileEntity() + { + this.isGuiScreenOpened=true; + } + + @Override + public void operate() + { + ready=true; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) + { + return IHLUtils.getThisModItemStack("gaedesMercuryRotaryPump"); + } + + @Override + public List[] getInput() + { + return null; + } + + @Override + public boolean canOperate() + { + return !ready; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new GaedesMercuryRotaryPumpGui(new GaedesMercuryRotaryPumpContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new GaedesMercuryRotaryPumpContainer(player, this); + } + + @Override + public boolean canBeUsed() + { + return ready; + } + + @Override + public void use() + { + ready=false; + } + + @Override + public boolean getIsInvalid() + { + return this.isInvalid(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} diff --git a/ihl/processing/chemistry/GoldChimneyKneeModel.java b/ihl/processing/chemistry/GoldChimneyKneeModel.java new file mode 100644 index 0000000..f98fe15 --- /dev/null +++ b/ihl/processing/chemistry/GoldChimneyKneeModel.java @@ -0,0 +1,45 @@ +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class GoldChimneyKneeModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public GoldChimneyKneeModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape1", 26, 0); + setTextureOffset("Base.Shape2", 0, 17); + setTextureOffset("Base.Shape4", 30, 16); + setTextureOffset("Base.Shape3", 0, 15); + setTextureOffset("Base.Shape5", 11, 12); + setTextureOffset("Base.Shape6", 9, 2); + setTextureOffset("Base.Shape7", 24, 7); + setTextureOffset("Base.Shape8", 50, 0); + setTextureOffset("Base.Shape9", 0, 0); + setTextureOffset("Base.Shape10", 6, 0); + setTextureOffset("Base.Shape11", 18, 0); + setTextureOffset("Base.Pipe", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 23F, -6F); + Base.mirror = true; + Base.addBox("Shape1", 5F, -14F, 0F, 1, 15, 12, false); + Base.addBox("Shape2", -6F, -1F, 0F, 11, 2, 1, false); + Base.addBox("Shape4", 5F, -14F, -2F, 1, 13, 2, false); + Base.addBox("Shape3", -6F, -2F, -2F, 11, 1, 3, false); + Base.addBox("Shape5", -6F, -14F, -2F, 11, 1, 14, false); + Base.addBox("Shape6", -5F, -13F, 11F, 4, 14, 1, false); + Base.addBox("Shape7", -6F, -13F, 1F, 1, 14, 11, false); + Base.addBox("Shape8", -6F, -13F, -2F, 1, 11, 3, false); + Base.addBox("Shape9", 1F, -13F, 11F, 4, 14, 1, false); + Base.addBox("Shape10", -1F, -13F, 11F, 2, 4, 1, false); + Base.addBox("Shape11", -1F, -7F, 11F, 2, 8, 1, false); + Base.addTube("Pipe", -2F, -10F, 2F, 4, 4, 12, 0.5F, 1F,ForgeDirection.NORTH); + } +} diff --git a/ihl/processing/chemistry/GoldChimneyKneeRender.java b/ihl/processing/chemistry/GoldChimneyKneeRender.java new file mode 100644 index 0000000..d862963 --- /dev/null +++ b/ihl/processing/chemistry/GoldChimneyKneeRender.java @@ -0,0 +1,50 @@ +package ihl.processing.chemistry; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import ihl.IHLModInfo; + +public class GoldChimneyKneeRender extends TileEntitySpecialRenderer{ +private GoldChimneyKneeModel model = new GoldChimneyKneeModel(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/porcelainBox.png"); + +public GoldChimneyKneeRender(){} + +public void renderAModelAt(GoldChimneyKneeTileEntity tile, double d, double d1, double d2, float f) { + int rotation = 0; + if(tile.getWorldObj() != null) + { + switch (tile.getFacing()) + { + case 2: + rotation = 0; + break; + case 5: + rotation = 1; + break; + case 3: + rotation = 2; + break; + case 4: + rotation = 3; + break; + default: + rotation = 0; + } + } + bindTexture(tex); //texture + GL11.glPushMatrix(); + GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.5F, (float)d2 + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F); + model.Base.render(1.0F/16.0F); + GL11.glPopMatrix(); //end +} + + @Override + public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) + { + this.renderAModelAt((GoldChimneyKneeTileEntity)par1TileEntity, par2, par4, par6, par8); + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/GoldChimneyKneeTileEntity.java b/ihl/processing/chemistry/GoldChimneyKneeTileEntity.java new file mode 100644 index 0000000..6c73a5b --- /dev/null +++ b/ihl/processing/chemistry/GoldChimneyKneeTileEntity.java @@ -0,0 +1,293 @@ +package ihl.processing.chemistry; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.api.network.INetworkDataProvider; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; +import ihl.worldgen.ores.IHLFluid; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class GoldChimneyKneeTileEntity extends TileEntity implements IWrenchable, INetworkDataProvider, IFluidHandler { + private short facing=2; + private short lastFacing=2; + private final IHLFluidTank gasBuffer = new IHLFluidTank(10000); + private final IHLFluidTank fluidTank = new IHLFluidTank(10000); + private static UniversalRecipeManager recipeManager = new UniversalRecipeManager("chimneyknee"); + + + public GoldChimneyKneeTileEntity() + { + super(); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.facing!=side; + } + + @Override + public short getFacing() + { + return facing; + } + + @Override + public List getNetworkedFields() + { + List fields = new ArrayList(); + fields.add("facing"); + return fields; + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(IC2.platform.isSimulating()) + { + if(this.facing!=this.lastFacing) + { + IC2.network.get().updateTileEntityField(this, "facing"); + this.lastFacing=this.facing; + } + if(this.fluidTank.getFluid()!=null && this.gasBuffer.getFluid()!=null) + { + if(this.getOutput()!=null) + { + List output = GoldChimneyKneeTileEntity.recipeManager.getOutputFor(getInput(), true, true).getFluidOutputs(); + if(output.size()>0) + { + this.fillOutputApparatus(getConnectDirection(),output.get(0), true); + } + } + } + if(this.fluidTank.getFluid()!=null) + { + if(this.fillOutputApparatus(getConnectDirection(),this.fluidTank.drain(this.fluidTank.getCapacity(), false), false)>0) + { + this.fillOutputApparatus(getConnectDirection(),this.fluidTank.drain(this.fluidTank.getCapacity(), true), true); + } + } + if(this.gasBuffer.getFluid()!=null) + { + if(this.fillOutputApparatus(getConnectDirection(),this.gasBuffer.drain(this.gasBuffer.getCapacity(), false), false)>0) + { + this.fillOutputApparatus(getConnectDirection(),this.gasBuffer.drain(this.gasBuffer.getCapacity(), true), true); + } + } + + } + } + + private int fillOutputApparatus(ForgeDirection direction,FluidStack fluidStack, boolean doFill) + { + TileEntity te = worldObj.getTileEntity(xCoord+mX(),yCoord, zCoord+mZ()); + if(te instanceof IFluidHandler) + { + return ((IFluidHandler)te).fill(direction, fluidStack, doFill); + } + else + { + return 0; + } + } + + @Override + public void setFacing(short facing1) + { + facing=(short) Math.max(2,facing1); + if(IC2.platform.isSimulating()) + { + IC2.network.get().updateTileEntityField(this, "facing"); + } + } + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) + { + return true; + } + + @Override + public float getWrenchDropRate() + { + return 1F; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) + { + return IHLUtils.getThisModItemStack("goldChimneyKnee"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setShort("facing",facing); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + + NBTTagCompound gasBufferTag = new NBTTagCompound(); + this.gasBuffer.writeToNBT(gasBufferTag); + nbttagcompound.setTag("gasBuffer", gasBufferTag); + + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + facing=nbttagcompound.getShort("facing"); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + this.gasBuffer.readFromNBT(nbttagcompound.getCompoundTag("gasBuffer")); + } + + protected int mX() + { + switch(this.getFacing()) + { + case 4: + return 1; + case 5: + return -1; + default: + return 0; + } + } + + protected int mZ() + { + switch(this.getFacing()) + { + case 2: + return 1; + case 3: + return -1; + default: + return 0; + } + } + + public TileEntity getConnectedTileEntity() + { + return worldObj.getTileEntity(xCoord+mX(), yCoord, zCoord+mZ()); + } + + public ForgeDirection getConnectDirection() + { + switch(this.getFacing()) + { + case 2: + return ForgeDirection.NORTH; + case 3: + return ForgeDirection.SOUTH; + case 4: + return ForgeDirection.WEST; + case 5: + return ForgeDirection.EAST; + default: + return ForgeDirection.NORTH; + } + } + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) + { + return false; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid fluid) + { + return fluid.isGaseous() && (direction==ForgeDirection.DOWN || direction==getConnectDirection()); + } + + @Override + public int fill(ForgeDirection direction, FluidStack fluidStack, boolean doFill) + { + if(direction==getConnectDirection() && fluidStack!=null && fluidStack.getFluid()!=null) + { + if(fluidStack.getFluid().isGaseous() && fluidStack.getFluid().getDensity() getRecipes() + { + return recipeManager.getRecipes(); + } +} diff --git a/ihl/processing/chemistry/LabElectrolyzerContainer.java b/ihl/processing/chemistry/LabElectrolyzerContainer.java new file mode 100644 index 0000000..5ee9caf --- /dev/null +++ b/ihl/processing/chemistry/LabElectrolyzerContainer.java @@ -0,0 +1,133 @@ +package ihl.processing.chemistry; + +import java.util.List; + +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraftforge.fluids.FluidStack; + +public class LabElectrolyzerContainer extends ContainerBase { + + protected LabElectrolyzerTileEntity tileEntity; + public short lastProgress = -1; + public short lastTemperature = -1; + public short lastEnergy = -1; + private final static int height=166; + public int lastFluidAmount = -1; + public int lastNumberOfFluids = -1; + public int lastFluidAmount2 = -1; + public int lastNumberOfFluids2 = -1; + public int lastFluidAmount3 = -1; + public int lastNumberOfFluids3 = -1; + public List fluidTankFluidList; + public List fluidTankFluidList2; + public List fluidTankFluidList3; + + public LabElectrolyzerContainer(EntityPlayer entityPlayer, LabElectrolyzerTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + fluidTankFluidList = this.tileEntity.getFluidTank().getFluidList(); + fluidTankFluidList2 = this.tileEntity.fluidTankAnodeOutput.getFluidList(); + fluidTankFluidList3 = this.tileEntity.fluidTankCathodeOutput.getFluidList(); + int col; + for (col = 0; col < 3; ++col) + { + for (int col1 = 0; col1 < 9; ++col1) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); + } + } + for (col = 0; col < 9; ++col) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); + } + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 42, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlotAnodeOutput, 0, 106, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlotCathodeOutput, 0, 8, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 42, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 8, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 1, 42, 33)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 2, 106, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 1, 87, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.engine, 0, 152, 15)); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + + if (this.tileEntity.getTankAmount() != this.lastFluidAmount || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + + if (this.tileEntity.fluidTankAnodeOutput.getFluidAmount() != this.lastFluidAmount2 || this.tileEntity.fluidTankAnodeOutput.getNumberOfFluids() != this.lastNumberOfFluids2) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList2"); + } + + if (this.tileEntity.fluidTankCathodeOutput.getFluidAmount() != this.lastFluidAmount3 || this.tileEntity.fluidTankCathodeOutput.getNumberOfFluids() != this.lastNumberOfFluids3) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList3"); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + + if (this.tileEntity.temperature != this.lastTemperature) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.temperature); + } + + + if ((short) this.tileEntity.energy != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 2, (short) this.tileEntity.energy); + } + } + + this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank(); + this.lastFluidAmount = this.tileEntity.getTankAmount(); + this.lastProgress = this.tileEntity.progress; + this.lastTemperature = this.tileEntity.temperature; + this.lastEnergy = (short) this.tileEntity.energy; + this.lastNumberOfFluids2 = this.tileEntity.fluidTankAnodeOutput.getNumberOfFluids(); + this.lastFluidAmount2 = this.tileEntity.fluidTankAnodeOutput.getFluidAmount(); + this.lastNumberOfFluids3 = this.tileEntity.fluidTankCathodeOutput.getNumberOfFluids(); + this.lastFluidAmount3 = this.tileEntity.fluidTankCathodeOutput.getFluidAmount(); + + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + switch (index) + { + case 0: + this.tileEntity.progress=(short) value; + break; + case 1: + this.tileEntity.temperature=(short) value; + break; + case 2: + this.tileEntity.energy=value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/LabElectrolyzerGui.java b/ihl/processing/chemistry/LabElectrolyzerGui.java new file mode 100644 index 0000000..c5997ca --- /dev/null +++ b/ihl/processing/chemistry/LabElectrolyzerGui.java @@ -0,0 +1,83 @@ +package ihl.processing.chemistry; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import ihl.utils.IHLRenderUtils; + +@SideOnly(Side.CLIENT) +public class LabElectrolyzerGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUILabElectrolyzer.png"); + private LabElectrolyzerContainer container; + private int mixerFrame=0; + + public LabElectrolyzerGui (LabElectrolyzerContainer container1) { + //the container is instanciated and passed to the superclass for handling + super(container1); + this.container=container1; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(142, 16 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27); + this.drawTexturedModalRect(142, 38, getFrameX(i1), getFrameY(i1),24,24); + } + if (this.container.tileEntity.getTankAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 61, 19, 84, 67, zLevel, par1, par2, xOffset, yOffset); + } + if (this.container.tileEntity.fluidTankCathodeOutput.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.fluidTankCathodeOutput, 27, 28, 39, 67, zLevel, par1, par2, xOffset, yOffset); + } + if (this.container.tileEntity.fluidTankAnodeOutput.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.fluidTankAnodeOutput, 125, 28, 137, 67, zLevel, par1, par2, xOffset, yOffset); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(background); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 170, 16, xOffset, yOffset); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } + + private int getFrameY(int number) + { + return (number % 10) * 24 + 14; + } + + private int getFrameX(int number) + { + return (number / 10) * 24 + 176; + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/LabElectrolyzerTileEntity.java b/ihl/processing/chemistry/LabElectrolyzerTileEntity.java new file mode 100644 index 0000000..cde3e39 --- /dev/null +++ b/ihl/processing/chemistry/LabElectrolyzerTileEntity.java @@ -0,0 +1,298 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.processing.metallurgy.BasicElectricMotorTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; + +public class LabElectrolyzerTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler +{ + private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("labelectrolyzer"); + public final IHLInvSlotOutput outputSlot; + public final InvSlotConsumableLiquidIHL drainInputSlot; + public final InvSlotConsumableLiquidIHL fillInputSlot; + public final InvSlotConsumableLiquidIHL fillInputSlotAnodeOutput; + public final InvSlotConsumableLiquidIHL fillInputSlotCathodeOutput; + public final InvSlotOutput emptyFluidItemsSlot; + private final IHLFluidTank fluidTank = new IHLFluidTank(2000); + public final IHLFluidTank fluidTankAnodeOutput = new IHLFluidTank(8000); + public final IHLFluidTank fluidTankCathodeOutput = new IHLFluidTank(8000); + public short temperature=20; + + public LabElectrolyzerTileEntity() { + super(); + this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 2); + this.drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); + this.fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.fillInputSlotAnodeOutput = new InvSlotConsumableLiquidIHL(this, "fillInputAnodeOutput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.fillInputSlotCathodeOutput = new InvSlotConsumableLiquidIHL(this, "fillInputCathodeOutput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 3); + this.isGuiScreenOpened=true; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + this.fluidTankAnodeOutput.readFromNBT(nbttagcompound.getCompoundTag("fluidTankAnodeOutput")); + this.fluidTankCathodeOutput.readFromNBT(nbttagcompound.getCompoundTag("fluidTankCathodeOutput")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + + NBTTagCompound fluidTankAnodeTag = new NBTTagCompound(); + this.fluidTankAnodeOutput.writeToNBT(fluidTankAnodeTag); + nbttagcompound.setTag("fluidTankAnodeOutput", fluidTankAnodeTag); + + NBTTagCompound fluidTankCathodeTag = new NBTTagCompound(); + this.fluidTankCathodeOutput.writeToNBT(fluidTankCathodeTag); + nbttagcompound.setTag("fluidTankCathodeOutput", fluidTankCathodeTag); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("labElectrolyzer"); + } + + @Override + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlotAnodeOutput, null, emptyFluidItemsSlot, fluidTankAnodeOutput); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlotCathodeOutput, null, emptyFluidItemsSlot, fluidTankCathodeOutput); + } + + @Override + public FluidStack drain(ForgeDirection direction, int amount, boolean doDrain) + { + if(this.canDrain(direction, null)) + { + if(direction.equals(ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.UP))) + { + return this.fluidTankAnodeOutput.drain(amount, doDrain); + } + if(direction.equals(ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.DOWN))) + { + return this.fluidTankCathodeOutput.drain(amount, doDrain); + } + return this.fluidTank.drain(amount, doDrain); + } + return null; + } + + + //1.7.10 API + @Override + public boolean canDrain(ForgeDirection direction, Fluid arg1) { + return direction.equals(ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.UP))||direction.equals(ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.DOWN))||direction.equals(ForgeDirection.DOWN); + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return direction.equals(ForgeDirection.getOrientation(this.getFacing()).getOpposite()); + } + + @Override + public String getInventoryName() { + return "labElectrolizer"; + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + // TODO Auto-generated method stub + } + + @Override + public int gaugeProgressScaled(int i) + { + return this.progress * i / operationLength; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new LabElectrolyzerGui(new LabElectrolyzerContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) + { + this.fluidTank.sortFluidsByDensity(); + return new LabElectrolyzerContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) {} + + @Override + public boolean canOperate() + { + UniversalRecipeOutput output = getOutput(); + if(output!=null) + { + if(getOutput().getItemOutputs()!=null && !getOutput().getItemOutputs().isEmpty() && getOutput().getItemOutputs().get(0)!=null) + { + return this.outputSlot.canAdd(getOutput().getItemOutputs()); + } + else + { + return this.fluidTankAnodeOutput.getFluidAmount()0)this.fluidTankAnodeOutput.fill(output1.getFluidOutputs().get(0).copy(), true); + if(output1.getFluidOutputs().size()>1)this.fluidTankCathodeOutput.fill(output1.getFluidOutputs().get(1).copy(), true); + if(!output1.getItemOutputs().isEmpty() && output1.getItemOutputs().get(0)!=null)this.outputSlot.add(output1.getItemOutputs()); + } + + @Override + public FluidStack drain(ForgeDirection arg0, FluidStack fluidStack, boolean doDrain) { + if(this.fluidTankAnodeOutput.getFluid().containsFluid(fluidStack)) + { + return this.fluidTankAnodeOutput.drain(fluidStack.amount, doDrain); + } + if(this.fluidTankCathodeOutput.getFluid().containsFluid(fluidStack)) + { + return this.fluidTankCathodeOutput.drain(fluidStack.amount, doDrain); + } + return null; + } + + @Override + public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return this.fluidTank.fill(arg1, arg2); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) { + return new FluidTankInfo[] {this.fluidTank.getInfo()}; + } + + public boolean needsFluid() + { + return this.fluidTank.getFluidAmount() <= this.fluidTank.getCapacity(); + } + + public FluidStack getFluidStackfromTank() + { + return this.fluidTank.getFluid(); + } + + public int getTankAmount() + { + return this.fluidTank.getFluidAmount(); + } + + public int gaugeLiquidScaled(int i, int index) + { + return this.fluidTank.getFluidAmount() <= 0 ? 0 : this.fluidTank.getFluidAmount(index) * i / this.fluidTank.getCapacity(); + } + public static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output) + { + recipeManager.addRecipe(input, output); + } + + public int getNumberOfFluidsInTank() + { + return this.fluidTank.getNumberOfFluids(); + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + public static void addRecipe(FluidStack fluidStackInput1, FluidStack fluidStackOutputAnode, FluidStack fluidStackOutputCathode, ItemStack itemStackOutput1) + { + if(itemStackOutput1!=null) + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1}), null), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStackOutputAnode, fluidStackOutputCathode}), Arrays.asList(new ItemStack[] {itemStackOutput1}),200)); + } + else + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1}), null), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStackOutputAnode, fluidStackOutputCathode}), null,200)); + } + } + + public IHLFluidTank getFluidTank() + { + return this.fluidTank; + } + +} \ No newline at end of file diff --git a/ihl/processing/chemistry/LeadOvenContainer.java b/ihl/processing/chemistry/LeadOvenContainer.java new file mode 100644 index 0000000..aa0eafc --- /dev/null +++ b/ihl/processing/chemistry/LeadOvenContainer.java @@ -0,0 +1,80 @@ +package ihl.processing.chemistry; + +import ic2.core.ContainerBase; +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; + +public class LeadOvenContainer extends ContainerBase { + + protected LeadOvenTileEntity tileEntity; + public int lastFluidAmount = -1; + public int lastFuel = -1; + public short lastProgress = -1; + private final static int height=166; + + public LeadOvenContainer(EntityPlayer entityPlayer, LeadOvenTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + int col; + for (col = 0; col < 3; ++col) + { + for (int col1 = 0; col1 < 9; ++col1) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); + } + } + for (col = 0; col < 9; ++col) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); + } + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fuelSlot, 0, 56, 53)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.inputSlot, 0, 47, 17)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.inputSlot, 1, 65, 17)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 112, 35)); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + + if (this.tileEntity.fuel != this.lastFuel) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.fuel); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.progress); + } + } + this.lastFuel = this.tileEntity.fuel; + this.lastProgress = this.tileEntity.progress; + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + + switch (index) + { + case 0: + this.tileEntity.fuel=value; + break; + case 1: + this.tileEntity.progress=(short) value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/LeadOvenGui.java b/ihl/processing/chemistry/LeadOvenGui.java new file mode 100644 index 0000000..133cb4e --- /dev/null +++ b/ihl/processing/chemistry/LeadOvenGui.java @@ -0,0 +1,51 @@ +package ihl.processing.chemistry; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class LeadOvenGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUILeadOven.png"); + private LeadOvenContainer container; + private String title = StatCollector.translateToLocal("ihl.gui.leadOven"); + + + public LeadOvenGui (LeadOvenContainer container1) { + //the container is instanciated and passed to the superclass for handling + super(container1); + this.container=container1; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + int i1; + if (this.container.tileEntity.fuel > 0) + { + i1 = this.container.tileEntity.gaugeFuelScaled(12); + this.drawTexturedModalRect(x + 56, y + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2); + } + i1 = this.container.tileEntity.gaugeProgressScaled(24); + this.drawTexturedModalRect(x + 79, y + 34, 176, 14, i1 + 1, 16); + + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/LeadOvenTileEntity.java b/ihl/processing/chemistry/LeadOvenTileEntity.java new file mode 100644 index 0000000..01f69bf --- /dev/null +++ b/ihl/processing/chemistry/LeadOvenTileEntity.java @@ -0,0 +1,343 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.api.recipe.IRecipeInput; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.block.TileEntityLiquidTankInventory; +import ic2.core.block.invslot.InvSlotConsumableFuel; +import ic2.core.block.invslot.InvSlot.Access; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; + +public class LeadOvenTileEntity extends TileEntityLiquidTankInventory implements IHasGui +{ + public final InvSlotConsumableFuel fuelSlot; + public final ApparatusProcessableInvSlot inputSlot; + public final IHLInvSlotOutput outputSlot; + public short progress = 0; + public final short maxProgress = 160; + public int fuel = 0; + public int maxFuel = 0; + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("chemicaloven"); + private ItemStack burnedFuel; + + public LeadOvenTileEntity() + { + super(1000); + this.fuelSlot = new InvSlotConsumableFuel(this, "fuel", 1, 1, true); + this.inputSlot = new ApparatusProcessableInvSlot(this, "input", 2, Access.IO, 2, 64); + this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 1); + } + + public static void addRecipe(UniversalRecipeInput input,UniversalRecipeOutput output) + { + recipeManager.addRecipe(input, output); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + + try + { + this.fuel = nbttagcompound.getInteger("fuel"); + } + catch (Throwable var4) + { + this.fuel = nbttagcompound.getShort("fuel"); + } + + try + { + this.maxFuel = nbttagcompound.getInteger("maxFuel"); + } + catch (Throwable var3) + { + this.maxFuel = nbttagcompound.getShort("maxFuel"); + } + this.progress = nbttagcompound.getShort("progress"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setInteger("fuel", this.fuel); + nbttagcompound.setInteger("maxFuel", this.maxFuel); + nbttagcompound.setShort("progress", this.progress); + NBTTagCompound gasBufferTag = new NBTTagCompound(); + nbttagcompound.setTag("gasBuffer", gasBufferTag); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) + { + return this.getFacing()!=(short)side && side!=0 && side!=1; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) + { + return IHLUtils.getThisModItemStack("leadOven"); + } + + public int gaugeProgressScaled(int i) + { + return this.progress * i / maxProgress; + } + + public int gaugeFuelScaled(int i) + { + if (this.maxFuel == 0) + { + this.maxFuel = this.fuel; + + if (this.maxFuel == 0) + { + this.maxFuel = 160; + } + } + + return this.fuel * i / this.maxFuel; + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if(this.getFluidTank().getFluid()!=null) + { + FluidStack fs; + if(this.maxProgress>0 && this.getOutput()!=null && this.getOutput().getFluidOutputs()!=null && this.getOutput().getFluidOutputs().size()>0) + { + fs = this.getFluidTank().drain(this.getOutput().getFluidOutputs().get(0).amount/this.maxProgress, true); + } + else + { + fs = this.getFluidTank().drain(1000, true); + } + TileEntity te = worldObj.getTileEntity(xCoord, yCoord+1, zCoord); + if(te!=null) + { + ForgeDirection direction = ForgeDirection.DOWN; + if(te instanceof IFluidHandler) + { + ((IFluidHandler)te).fill(direction, fs, true); + } + } + } + boolean needsInvUpdate = false; + if (this.fuel <= 0 && this.canOperate()) + { + if(this.fuelSlot.get()!=null) + { + if(burnedFuel!=null && IHLUtils.isItemsHaveSameOreDictionaryEntry(this.fuelSlot.get(), burnedFuel)) + { + burnedFuel.stackSize++; + } + else if(burnedFuel==null) + { + burnedFuel=this.fuelSlot.get().copy(); + burnedFuel.stackSize=1; + } + } + this.fuel = this.maxFuel = this.fuelSlot.consumeFuel(); + + if (this.fuel > 0) + { + needsInvUpdate = true; + } + } + + if (this.isBurning() && this.canOperate()) + { + ++this.progress; + + if (this.progress >= maxProgress) + { + this.progress = 0; + this.operate(); + needsInvUpdate = true; + } + } + else + { + this.progress = 0; + } + + if (this.fuel > 0) + { + --this.fuel; + } + + if (this.getActive() != this.isBurning()) + { + this.setActive(this.isBurning()); + needsInvUpdate = true; + } + } + + public boolean isBurning() + { + return this.fuel > 0; + } + + public boolean canOperate() + { + return this.getOutput()!=null; + } + + /** + * Returns the name of the inventory + */ + @Override + public String getInventoryName() + { + return "goldOven"; + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer entityPlayer) + { + return new LeadOvenContainer(entityPlayer, this); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer entityPlayer, boolean isAdmin) + { + return new LeadOvenGui(new LeadOvenContainer(entityPlayer, this)); + } + + @Override + public void onGuiClosed(EntityPlayer entityPlayer) {} + + public int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + public int mZ() + { + switch(this.getFacing()) + { + case 2: + return -1; + case 3: + return 1; + default: + return 0; + } + } + + public UniversalRecipeOutput getOutput() + { + return LeadOvenTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + public List[] getInput() + { + if(this.inputSlot.get(1)!=null) + { + return new List[] {null, Arrays.asList(new ItemStack[] {this.inputSlot.get(0),this.inputSlot.get(1)})}; + } + return new List[] {null, Arrays.asList(new ItemStack[] {this.inputSlot.get()})}; + } + + public void operate() + { + List rinput = LeadOvenTileEntity.recipeManager.getRecipeInput(getInput()).getItemInputs(); + UniversalRecipeOutput routput = LeadOvenTileEntity.recipeManager.getOutputFor(getInput(), false, false); + List output2 = routput.getFluidOutputs(); + if(!output2.isEmpty()) + { + this.getFluidTank().fill(output2.get(0), true); + } + List itemOutputs = routput.getItemOutputs(); + if(itemOutputs!=null && !itemOutputs.isEmpty()) + { + this.outputSlot.add(itemOutputs); + } + for(int i=0; i=rinput.get(i).getAmount()) + { + this.burnedFuel.stackSize-=rinput.get(i).getAmount(); + if(this.burnedFuel.stackSize<=0) + { + this.burnedFuel=null; + } + } + else + { + this.inputSlot.consume(i, rinput.get(i).getAmount()); + } + if(this.inputSlot.get(i)!=null && this.inputSlot.get(i).stackSize<=0) + { + this.inputSlot.put(i, null); + } + } + + } + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return false; + } + + @Override + public boolean canFill(ForgeDirection arg0, Fluid arg1) { + return false; + } + + public static void addRecipe(UniversalRecipeInput input, FluidStack fluidStackWithSize) + { + recipeManager.addRecipe(input, new UniversalRecipeOutput(Arrays.asList(new FluidStack[]{fluidStackWithSize}),null,20)); + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + public static void addRecipe(ItemStack input, FluidStack fluidStackOutput, ItemStack output) { + recipeManager.addRecipe(new UniversalRecipeInput(null, Arrays.asList(new ItemStack[] {input})),new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStackOutput}),Arrays.asList(new ItemStack[] {output}),20)); + } + + public static void addRecipe(ItemStack input, ItemStack output) { + recipeManager.addRecipe(new UniversalRecipeInput(null, Arrays.asList(new ItemStack[] {input})),new UniversalRecipeOutput(null,Arrays.asList(new ItemStack[] {output}),20)); + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/LoomContainer.java b/ihl/processing/chemistry/LoomContainer.java new file mode 100644 index 0000000..4b8e182 --- /dev/null +++ b/ihl/processing/chemistry/LoomContainer.java @@ -0,0 +1,66 @@ +package ihl.processing.chemistry; + +import ic2.core.ContainerBase; +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; + +public class LoomContainer extends ContainerBase { + + public LoomTileEntity tileEntity; + public int lastProgress = -1; + private final static int height=166; + + public LoomContainer(EntityPlayer entityPlayer, + LoomTileEntity lathePart1TileEntity) { + super(lathePart1TileEntity); + tileEntity=lathePart1TileEntity; + int col; + + for (col = 0; col < 3; ++col) + { + for (int col1 = 0; col1 < 9; ++col1) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); + } + } + + for (col = 0; col < 9; ++col) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); + } + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.input, 0, 8, 44)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.output, 0, 127, 44)); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + } + this.lastProgress = this.tileEntity.progress; + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + + switch (index) + { + case 0: + this.tileEntity.progress=(short) value; + break; + + } + } + +} diff --git a/ihl/processing/chemistry/LoomGui.java b/ihl/processing/chemistry/LoomGui.java new file mode 100644 index 0000000..1052252 --- /dev/null +++ b/ihl/processing/chemistry/LoomGui.java @@ -0,0 +1,61 @@ +package ihl.processing.chemistry; + +import org.lwjgl.opengl.GL11; + +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.utils.IHLRenderUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class LoomGui extends GuiContainer { + + private LoomContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUILoom.png"); + + public LoomGui(LoomContainer latheContainer) { + super(latheContainer); + container = latheContainer; + } + + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(tex); + int i1; + if (this.container.tileEntity.progress > 0) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.99F); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(38),38); + this.drawTexturedModalRect(68, 30, 176, 0, i1 + 1, 10); + } + IHLRenderUtils.instance.drawTooltip(par1,par2,9,11,xOffset,yOffset,StatCollector.translateToLocal("ihl.coiler.tip")); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(tex); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } + + @Override + public void onGuiClosed() + { + super.onGuiClosed(); + this.container.tileEntity.isGuiScreenOpened=false; + IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, 0); + } + +} diff --git a/ihl/processing/chemistry/LoomModel.java b/ihl/processing/chemistry/LoomModel.java new file mode 100644 index 0000000..afef73d --- /dev/null +++ b/ihl/processing/chemistry/LoomModel.java @@ -0,0 +1,66 @@ +package ihl.processing.chemistry; + +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; +import ihl.model.IHLModelRenderer; + +public class LoomModel extends ModelBase +{ + //fields + IHLModelRenderer RotatePart; + IHLModelRenderer Piece1; + + public LoomModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("RotatePart.Shape1", 0, 14); + setTextureOffset("RotatePart.Pipe2", 0, 17); + setTextureOffset("RotatePart.Shape4", 3, 14); + setTextureOffset("RotatePart.Shape3", 0, 26); + setTextureOffset("RotatePart.Pipe5", 16, 20); + setTextureOffset("RotatePart.Pipe6", 0, 18); + setTextureOffset("RotatePart.Pipe11", 13, 22); + setTextureOffset("RotatePart.Pipe12", 13, 22); + setTextureOffset("RotatePart.Pipe13", 13, 22); + setTextureOffset("RotatePart.Pipe14", 13, 22); + setTextureOffset("RotatePart.Pipe15", 13, 22); + setTextureOffset("Piece1.Shape7", 0, 17); + setTextureOffset("Piece1.Shape8", 0, 17); + setTextureOffset("Piece1.PipeW9", 0, 18); + setTextureOffset("Piece1.PipeW10", 0, 20); + setTextureOffset("Piece1.Shape2", 0, 0); + + RotatePart = new IHLModelRenderer(this, "RotatePart"); + RotatePart.setRotationPoint(0F, 23F, -6F); + setRotation(RotatePart, 0.4F, 0F, 0F); + RotatePart.mirror = true; + RotatePart.addBox("Shape1", 7F, -1F, -1F, 1, 2, 16,false); + RotatePart.addTube("Pipe2", -7.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addBox("Shape4", -8F, -1F, -1F, 1, 2, 16,false); + RotatePart.addBox("Shape3", -7F, -1F, -1F, 14, 2, 2,false); + RotatePart.addTube("Pipe5", -5.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe6", -3.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe11", -1.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe12", 0.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe13", 2.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe14", 4.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe15", 6.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + Piece1 = new IHLModelRenderer(this, "Piece1"); + Piece1.setRotationPoint(0F, 16F, 0F); + setRotation(Piece1, 0F, 0F, 0F); + Piece1.mirror = true; + Piece1.addBox("Shape7", 6F, -4F, 6F, 1, 12, 2,false); + Piece1.addBox("Shape8", -7F, -4F, 6F, 1, 12, 2,false); + Piece1.addTube("PipeW9", -6F, 7F, 7F, 12, 1, 1, 0F,1F,ForgeDirection.EAST); + Piece1.addTube("PipeW10", -6F, -4F, 6F, 12, 1, 1, 0F,1F,ForgeDirection.EAST); + Piece1.addBox("Shape2", 0F, 7F, 0F, 4, 1, 1,false); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } +} diff --git a/ihl/processing/chemistry/LoomTileEntity.java b/ihl/processing/chemistry/LoomTileEntity.java new file mode 100644 index 0000000..df5ce20 --- /dev/null +++ b/ihl/processing/chemistry/LoomTileEntity.java @@ -0,0 +1,173 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.api.network.INetworkClientTileEntityEventListener; +import ic2.api.recipe.IRecipeInput; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.network.NetworkManager; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.recipes.RecipeInputWire; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class LoomTileEntity extends TileEntityInventory implements IHasGui, INetworkClientTileEntityEventListener +{ + protected static UniversalRecipeManager recipeManager = new UniversalRecipeManager("loom"); + public short progress; + protected short operationLength=200; + public final ApparatusProcessableInvSlot input; + public final IHLInvSlotOutput output; + boolean isGuiScreenOpened=false; + + public LoomTileEntity() + { + super(); + input = new ApparatusProcessableInvSlot(this, "input", 0, Access.IO, 1, 64); + output = new IHLInvSlotOutput(this, "output", 1, 1); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if (this.canOperate() && this.isGuiScreenOpened) + { + this.setActive(true); + + if (this.progress == 0) + { + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + ++this.progress; + if (this.progress >= this.operationLength) + { + this.operate(); + this.progress = 0; + IC2.network.get().initiateTileEntityEvent(this, 2, true); + } + } + else + { + if (this.progress != 0 && this.getActive()) + { + IC2.network.get().initiateTileEntityEvent(this, 1, true); + } + if (!this.canOperate()) + { + this.progress = 0; + } + this.setActive(false); + } + } + + @Override + public String getInventoryName() { + return "Loom"; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("loom"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new LoomGui(new LoomContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + this.isGuiScreenOpened=true; + return new LoomContainer(player, this); + } + + public void operate() + { + List input1 = LoomTileEntity.recipeManager.getRecipeInput(getInput()).getItemInputs(); + List output1 = LoomTileEntity.recipeManager.getOutputFor(getInput(), false, false).getItemOutputs(); + this.output.add(output1); + if(input1.get(0) instanceof RecipeInputWire) + { + int fiberLength = input1.get(0).getAmount(); + boolean isFiberConsumed = IHLUtils.adjustWireLength(this.input.get(), -fiberLength); + if(isFiberConsumed) + { + this.input.put(null); + } + } + else + { + this.input.consume(0, input1.get(0).getAmount()); + } + } + + public List[] getInput() + { + return new List[] {null,Arrays.asList(new ItemStack[] {input.get()})}; + } + + public boolean canOperate() + { + if(LoomTileEntity.recipeManager.getOutputFor(getInput(), false, false)==null) return false; + List output1 = LoomTileEntity.recipeManager.getOutputFor(getInput(), false, false).getItemOutputs(); + return this.output.canAdd(output1); + } + + @Override + public void onGuiClosed(EntityPlayer arg0) {} + + public static void addRecipe(ItemStack input, ItemStack output) + { + if(input==null || output==null) throw new NullPointerException(); + recipeManager.addRecipe(new UniversalRecipeInput(null,Arrays.asList(new ItemStack[] {input})), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {output}),20)); + } + + public int gaugeProgressScaled(int i) + { + return this.progress * i / this.operationLength; + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + switch(event) + { + case 0: + this.isGuiScreenOpened=false; + break; + } + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} diff --git a/ihl/processing/chemistry/PaperMachineContainer.java b/ihl/processing/chemistry/PaperMachineContainer.java new file mode 100644 index 0000000..99bfa61 --- /dev/null +++ b/ihl/processing/chemistry/PaperMachineContainer.java @@ -0,0 +1,106 @@ +package ihl.processing.chemistry; + +import java.util.List; + +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraftforge.fluids.FluidStack; + +public class PaperMachineContainer extends ContainerBase { + + protected PaperMachineTileEntity tileEntity; + public int lastFluidAmount = -1; + public int lastNumberOfFluids = -1; + public short lastProgress = -1; + public short lastTemperature = -1; + public short lastEnergy = -1; + private final static int height=166; + public List fluidTankFluidList; + + public PaperMachineContainer(EntityPlayer entityPlayer, PaperMachineTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + fluidTankFluidList=this.tileEntity.getFluidTank().getFluidList(); + int col; + for (col = 0; col < 3; ++col) + { + for (int col1 = 0; col1 < 9; ++col1) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); + } + } + for (col = 0; col < 9; ++col) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); + } + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 78, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 78, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 78, 33)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 122, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.engine, 0, 8, 32)); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + + if (this.tileEntity.getTankAmount() != this.lastFluidAmount || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + + if (this.tileEntity.temperature != this.lastTemperature) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.temperature); + } + + + if ((short) this.tileEntity.energy != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 2, (short) this.tileEntity.energy); + } + } + + this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank(); + this.lastFluidAmount = this.tileEntity.getTankAmount(); + this.lastProgress = this.tileEntity.progress; + this.lastTemperature = this.tileEntity.temperature; + this.lastEnergy = (short) this.tileEntity.energy; + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + switch (index) + { + case 0: + this.tileEntity.progress=(short) value; + break; + case 1: + this.tileEntity.temperature=(short) value; + break; + case 2: + this.tileEntity.energy=value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/PaperMachineGui.java b/ihl/processing/chemistry/PaperMachineGui.java new file mode 100644 index 0000000..4c8cb72 --- /dev/null +++ b/ihl/processing/chemistry/PaperMachineGui.java @@ -0,0 +1,84 @@ +package ihl.processing.chemistry; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import ihl.utils.IHLRenderUtils; + +@SideOnly(Side.CLIENT) +public class PaperMachineGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIPaperMachine.png"); + private PaperMachineContainer container; + private int mixerFrame=0; + + public PaperMachineGui (PaperMachineContainer container1) { + //the container is instanciated and passed to the superclass for handling + super(container1); + this.container=container1; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(12, 16 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27); + this.drawTexturedModalRect(38, 29, getFrameX(i1), getFrameY(i1),24,24); + if(mixerFrame++>4) + { + mixerFrame=0; + } + } + else + { + mixerFrame=0; + } + this.drawTexturedModalRect(103, 52, 246, 226+6*mixerFrame,10,6); + if (this.container.tileEntity.getTankAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 102, 28, 114, 59, zLevel, par1, par2, xOffset, yOffset); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(background); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 26, 34, xOffset, yOffset); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } + + private int getFrameY(int number) + { + return (number % 10) * 24 + 14; + } + + private int getFrameX(int number) + { + return (number / 10) * 24 + 176; + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/PaperMachineTileEntity.java b/ihl/processing/chemistry/PaperMachineTileEntity.java new file mode 100644 index 0000000..a694b82 --- /dev/null +++ b/ihl/processing/chemistry/PaperMachineTileEntity.java @@ -0,0 +1,320 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.processing.metallurgy.BasicElectricMotorTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; + +public class PaperMachineTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler +{ + private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("papermachine"); + public final IHLInvSlotOutput outputSlot; + public final InvSlotConsumableLiquidIHL drainInputSlot; + public final InvSlotConsumableLiquidIHL fillInputSlot; + public final InvSlotOutput emptyFluidItemsSlot; + private final IHLFluidTank fluidTank = new IHLFluidTank(8000); + public short temperature=20; + private int fractionalOutputAmount=0; + + public PaperMachineTileEntity() { + super(); + this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 2); + this.drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); + this.fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 1); + this.isGuiScreenOpened=true; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + NBTTagCompound fractionalOutputNBT = new NBTTagCompound(); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("paperMachine"); + } + + @Override + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank); + } + + @Override + public FluidStack drain(ForgeDirection from, int amount, boolean doDrain) + { + FluidStack fstack = this.fluidTank.drain(amount, doDrain); + return fstack; + } + + + //1.7.10 API + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return true; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return direction.equals(ForgeDirection.UP); + } + + @Override + public String getInventoryName() { + return "chemicalReactor"; + } + + private int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + private int mZ() + { + switch(this.getFacing()) + { + case 3: + return 1; + case 2: + return -1; + case 4: + return 0; + case 5: + return 0; + default: + return -1; + } + } + + private short getFacingFromXZ(int x, int z) + { + switch(x) + { + case -1: + return (short)4; + case 1: + return (short)5; + default: + switch(z) + { + case 1: + return (short)3; + case -1: + return (short)2; + default: + return (short)2; + } + } + } + + public float getRenderLiquidLevel() + { + return (float)this.fluidTank.getFluidAmount()/(float)this.fluidTank.getCapacity(); + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + // TODO Auto-generated method stub + } + + @Override + public int gaugeProgressScaled(int i) + { + return this.progress * i / operationLength; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new PaperMachineGui(new PaperMachineContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) + { + this.fluidTank.sortFluidsByDensity(); + return new PaperMachineContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) {} + + @Override + public boolean canOperate() + { + UniversalRecipeOutput output = getOutput(); + if(output!=null && this.outputSlot.canAdd(getOutput().getItemOutputs())) + { + if(output.specialConditions) + { + return this.checkSpecialConditions(); + } + else + { + return true; + } + } + return false; + } + + private boolean checkSpecialConditions() + { + ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing()); + TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX, yCoord, zCoord+dir.offsetZ); + if(te instanceof CryogenicDistillerTileEntity) + { + CryogenicDistillerTileEntity cgte = (CryogenicDistillerTileEntity)te; + return cgte.getFacing()==this.getFacing() && cgte.canProcess(); + } + return false; + } + + public UniversalRecipeOutput getOutput() + { + return PaperMachineTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + @Override + public List[] getInput() + { + return new List[] {Arrays.asList(new FluidStack[]{fluidTank.getFluid()}), null}; + } + + @Override + public void operate() + { + UniversalRecipeInput recipeInput = PaperMachineTileEntity.recipeManager.getRecipeInput(getInput()); + UniversalRecipeOutput output1 = getOutput(); + this.fluidTank.drain(recipeInput.getFluidInputs(), true); + this.fluidTank.fill(output1.getFluidOutputs(), true); + if(!output1.getItemOutputs().isEmpty() && output1.getItemOutputs().get(0)!=null)this.outputSlot.add(output1.getItemOutputs()); + } + + @Override + public FluidStack drain(ForgeDirection arg0, FluidStack fluidStack, boolean doDrain) { + if(fluidTank.getFluid()!=null && fluidTank.getFluid().containsFluid(fluidStack)) + { + return this.fluidTank.drain(fluidStack, doDrain); + } + return null; + } + + @Override + public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return this.fluidTank.fill(arg1, arg2); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) { + return new FluidTankInfo[] {this.fluidTank.getInfo()}; + } + + public boolean needsFluid() + { + return this.fluidTank.getFluidAmount() <= this.fluidTank.getCapacity(); + } + + public FluidStack getFluidStackfromTank() + { + return this.fluidTank.getFluid(); + } + + public int getTankAmount() + { + return this.fluidTank.getFluidAmount(); + } + + public int gaugeLiquidScaled(int i, int index) + { + return this.fluidTank.getFluidAmount() <= 0 ? 0 : this.fluidTank.getFluidAmount(index) * i / this.fluidTank.getCapacity(); + } + public static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output) + { + recipeManager.addRecipe(input, output); + } + + public int getNumberOfFluidsInTank() + { + return this.fluidTank.getNumberOfFluids(); + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + public static void addRecipe(FluidStack fluidStackInput1, ItemStack itemStackOutput1) + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1}), null), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {itemStackOutput1}),200)); + } + + public static void addSpecialConditionsRecipe(FluidStack fluidStackInput1, FluidStack fluidStackInput2, ItemStack itemStackInput, FluidStack fluidStackOutput, ItemStack itemStackOutput1, ItemStack itemStackOutput2) + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1, fluidStackInput2}), Arrays.asList(new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStackOutput}), Arrays.asList(new ItemStack[] {itemStackOutput1, itemStackOutput2}),200, true)); + } + + public IHLFluidTank getFluidTank() + { + return this.fluidTank; + } + +} \ No newline at end of file diff --git a/ihl/processing/chemistry/PrecipitatorCondenserModel.java b/ihl/processing/chemistry/PrecipitatorCondenserModel.java new file mode 100644 index 0000000..dd6f15a --- /dev/null +++ b/ihl/processing/chemistry/PrecipitatorCondenserModel.java @@ -0,0 +1,110 @@ +package ihl.processing.chemistry; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; + +public class PrecipitatorCondenserModel extends ModelBase +{ + //fields + ModelRenderer Base; + + public PrecipitatorCondenserModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape1", 22, 0); + setTextureOffset("Base.Shape2", 22, 17); + setTextureOffset("Base.Shape4", 30, 16); + setTextureOffset("Base.Shape3", 30, 15); + setTextureOffset("Base.Shape6", 30, 2); + setTextureOffset("Base.Shape7", 20, 0); + setTextureOffset("Base.Shape8", 50, 0); + setTextureOffset("Base.Shape9", 0, 0); + setTextureOffset("Base.Shape10", 24, 0); + setTextureOffset("Base.Shape11", 0, 0); + setTextureOffset("Base.Shape12", 0, 0); + setTextureOffset("Base.Shape13", 0, 0); + setTextureOffset("Base.Shape14", 0, 0); + setTextureOffset("Base.Shape15", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("Base.Shape17", 0, 0); + setTextureOffset("Base.Shape18", 0, 0); + setTextureOffset("Base.Shape19", 0, 0); + setTextureOffset("Base.Shape20", 0, 0); + setTextureOffset("Base.Shape21", 0, 0); + setTextureOffset("Base.Shape25", 0, 1); + setTextureOffset("Base.Shape26", 12, 24); + setTextureOffset("Base.Shape27", 0, 0); + setTextureOffset("Base.Shape28", 0, 18); + setTextureOffset("Base.Shape29", 21, 0); + setTextureOffset("Base.Shape30", 0, 0); + setTextureOffset("Base.Shape31", 0, 0); + setTextureOffset("Base.Shape32", 0, 0); + setTextureOffset("Base.Shape33", 0, 0); + setTextureOffset("Base.Shape34", 0, 0); + setTextureOffset("Base.Shape35", 0, 0); + setTextureOffset("Base.Shape36", 0, 0); + setTextureOffset("Base.Shape37", 0, 0); + setTextureOffset("Base.Shape38", 0, 0); + setTextureOffset("Base.Shape39", 0, 0); + setTextureOffset("Base.Shape40", 0, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Base.Shape23", 31, 0); + setTextureOffset("Base.Shape24", 10, 0); + setTextureOffset("Base.Shape41", 27, 26); + setTextureOffset("Base.Shape42", 0, 0); + setTextureOffset("Base.Shape43", 0, 0); + setTextureOffset("Base.Shape44", 0, 0); + setTextureOffset("Base.Shape45", 0, 0); + setTextureOffset("Base.Shape46", 0, 0); + + Base = new ModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 23F, 0F); + Base.mirror = true; + Base.addBox("Shape1", 6F, -15F, -7F, 1, 12, 14); + Base.addBox("Shape2", -7F, -3F, -8F, 14, 3, 1); + Base.addBox("Shape4", 6F, -15F, -8F, 1, 12, 1); + Base.addBox("Shape3", -7F, -3F, 7F, 14, 3, 1); + Base.addBox("Shape6", -7F, -15F, 7F, 1, 12, 1); + Base.addBox("Shape7", -7F, -15F, -7F, 1, 15, 14); + Base.addBox("Shape8", -7F, -15F, -8F, 1, 12, 1); + Base.addBox("Shape9", 1F, 0F, -8F, 6, 1, 16); + Base.addBox("Shape10", 6F, -15F, 7F, 1, 12, 1); + Base.addBox("Shape11", -4F, -13F, 3F, 1, 12, 3); + Base.addBox("Shape12", 4F, -2F, -1F, 2, 1, 3); + Base.addBox("Shape13", 3F, -13F, -1F, 1, 12, 3); + Base.addBox("Shape14", -3F, -13F, 5F, 9, 12, 1); + Base.addBox("Shape15", -6F, -2F, -2F, 12, 1, 1); + Base.addBox("Shape16", -4F, -13F, -5F, 1, 12, 3); + Base.addBox("Shape17", -6F, -2F, 6F, 12, 1, 1); + Base.addBox("Shape18", -6F, -2F, -7F, 12, 1, 2); + Base.addBox("Shape19", -6F, -2F, -5F, 2, 1, 3); + Base.addBox("Shape20", -6F, -2F, 2F, 12, 1, 1); + Base.addBox("Shape21", -6F, -2F, 3F, 2, 1, 3); + Base.addBox("Shape25", -6F, -15F, 7F, 12, 3, 1); + Base.addBox("Shape26", -6F, -15F, -8F, 12, 3, 1); + Base.addBox("Shape27", -8F, 0F, -8F, 7, 1, 16); + Base.addBox("Shape28", -1F, 0F, 1F, 2, 1, 7); + Base.addBox("Shape29", -1F, 0F, -8F, 2, 1, 7); + Base.addBox("Shape30", -3F, -13F, 3F, 9, 12, 1); + Base.addBox("Shape31", -6F, -13F, 1F, 9, 12, 1); + Base.addBox("Shape32", -6F, -13F, -1F, 9, 12, 1); + Base.addBox("Shape33", -3F, -13F, -3F, 9, 12, 1); + Base.addBox("Shape34", -3F, -13F, -5F, 9, 12, 1); + Base.addBox("Shape35", -6F, -13F, -7F, 12, 1, 2); + Base.addBox("Shape36", -6F, -13F, -2F, 12, 1, 1); + Base.addBox("Shape37", -6F, -13F, 2F, 12, 1, 1); + Base.addBox("Shape38", -6F, -13F, 6F, 12, 1, 1); + Base.addBox("Shape39", -6F, -13F, -5F, 2, 1, 3); + Base.addBox("Shape40", -6F, -13F, 3F, 2, 1, 3); + Base.addBox("Shape5", 4F, -13F, -1F, 2, 1, 3); + Base.addBox("Shape23", 6F, -2F, -7F, 1, 2, 14); + Base.addBox("Shape24", 6F, -3F, 3F, 1, 1, 4); + Base.addBox("Shape41", 6F, -3F, -7F, 1, 1, 5); + Base.addBox("Shape42", 7F, -4F, -2F, 4, 1, 5); + Base.addBox("Shape43", 8F, 0F, -2F, 1, 1, 5); + Base.addBox("Shape44", 10F, -3F, -2F, 1, 4, 5); + Base.addBox("Shape45", 7F, -4F, 3F, 4, 5, 1); + Base.addBox("Shape46", 7F, -4F, -3F, 4, 5, 1); + } +} diff --git a/ihl/processing/chemistry/PrecipitatorCondenserRender.java b/ihl/processing/chemistry/PrecipitatorCondenserRender.java new file mode 100644 index 0000000..ae68bbf --- /dev/null +++ b/ihl/processing/chemistry/PrecipitatorCondenserRender.java @@ -0,0 +1,50 @@ +package ihl.processing.chemistry; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import ihl.IHLModInfo; + +public class PrecipitatorCondenserRender extends TileEntitySpecialRenderer{ +private PrecipitatorCondenserModel model = new PrecipitatorCondenserModel(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/porcelainBox.png"); + +public PrecipitatorCondenserRender(){} + +public void renderAModelAt(PrecipitatorCondenserTileEntity tile, double d, double d1, double d2, float f) { + int rotation = 0; + if(tile.getWorldObj() != null) + { + switch (tile.getFacing()) + { + case 2: + rotation = 0; + break; + case 5: + rotation = 1; + break; + case 3: + rotation = 2; + break; + case 4: + rotation = 3; + break; + default: + rotation = 0; + } + } + bindTexture(tex); //texture + GL11.glPushMatrix(); + GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.5F, (float)d2 + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F); + model.Base.render(1.0F/16.0F); + GL11.glPopMatrix(); //end +} + + @Override + public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) + { + this.renderAModelAt((PrecipitatorCondenserTileEntity)par1TileEntity, par2, par4, par6, par8); + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/PrecipitatorCondenserTileEntity.java b/ihl/processing/chemistry/PrecipitatorCondenserTileEntity.java new file mode 100644 index 0000000..becd7e8 --- /dev/null +++ b/ihl/processing/chemistry/PrecipitatorCondenserTileEntity.java @@ -0,0 +1,380 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.Map; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.core.IC2; +import ic2.core.block.TileEntityInventory; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; +import ihl.worldgen.ores.IHLFluid; + +public class PrecipitatorCondenserTileEntity extends TileEntityInventory implements IFluidHandler +{ + private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("precipitatorcondenser"); + private static float kF = 24000F; + private static float gasC = 1F; + private static float fluidC = 4F; + private static float H = 2256F; + private final IHLFluidTank gasBuffer = new IHLFluidTank(10000); + private final IHLFluidTank fluidTank = new IHLFluidTank(100); + private ForgeDirection gasInputDirection = ForgeDirection.WEST; + private int amountOfGasCondensed=0; + + public PrecipitatorCondenserTileEntity() + { + super(); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + this.gasBuffer.readFromNBT(nbttagcompound.getCompoundTag("gasBuffer")); + this.amountOfGasCondensed=nbttagcompound.getInteger("amountOfGasCondensed"); + } + + public static void addRecipe(String fluidNameIn, String fluidNameOut, int conversionRateToGas) + { + recipeManager.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize(fluidNameIn, conversionRateToGas)}), null), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize(fluidNameOut, 1)}),null,2)); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + + NBTTagCompound gasBufferTag = new NBTTagCompound(); + this.gasBuffer.writeToNBT(gasBufferTag); + nbttagcompound.setTag("gasBuffer", gasBufferTag); + + nbttagcompound.setInteger("amountOfGasCondensed",this.amountOfGasCondensed); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=(short)side && side!=0 && side!=1; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("goldPrecipitatorCondenser"); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + FluidStack fluidStack = this.fluidTank.getFluid(); + FluidStack gasStack = this.gasBuffer.getFluid(); + if(fluidStack!=null && gasStack!=null && fluidStack.amount>0 && gasStack.amount>0) + { + int t1 = this.fluidTank.getTemperature(); + float densityOfCoolant = IHLFluid.getRealDensity(fluidStack.getFluid()); + float densityOfGas = IHLFluid.getRealDensity(gasStack.getFluid()); + int boilingPointOfGas = IHLFluid.getBoilingPoint(gasStack.getFluid()); + amountOfGasCondensed += this.getAmountOfCondensedGas(fluidStack.amount, this.gasBuffer.getFluidAmount(), boilingPointOfGas, t1, densityOfGas, densityOfCoolant); + } + if(amountOfGasCondensed>10000) + { + UniversalRecipeOutput rOutput = null; + UniversalRecipeInput rInput = null; + FluidStack fs = null; + for(int i=0;ithis.gasBuffer.getCapacity()*2) + { + FluidStack passingGas = this.gasBuffer.drainLightest(this.gasBuffer.getCapacity()/2, true); + this.fillGaseousOutputApparatus(gasInputDirection, passingGas, true); + } + if(this.fluidTank.getFluid()!=null) + { + FluidStack coolant = this.fluidTank.drain(5, true); + this.fillHeatTransferAgentOutputApparatus(ForgeDirection.UP, coolant, true); + } + } + + private int getAmountOfCondensedGas(int amountOfCoolant, int amountOfGas, int boilingPointOfGas, int temperatureOfCoolant, float densityOfGas, float densityOfCoolant) + { + if(amountOfCoolant<=0 || amountOfGas<=0 || boilingPointOfGas-202*dt2) + { + deltaT = (float) ((dt1-dt2)/Math.log((double)dt2/(double)dt1)); + } + else + { + deltaT = (dt1+dt2)*0.5F; + } + float Q1 = kF*deltaT; + if(Q1>=maxQ) + { + break; + } + else + { + int next_L = (int)(Q1/H/densityOfGas); + if(Math.abs(next_L-L)<4) + { + L=next_L; + break; + } + L=next_L; + } + } + if(t1_1>t1) + { + this.fluidTank.setTemperature(t1_1); + } + else + { + this.fluidTank.setTemperature(t1+1); + } + return L; + } + + @Override + public String getInventoryName() + { + return "precipitatorCondenser"; + } + + public void onGuiClosed(EntityPlayer entityPlayer) {} + + public int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + public int mZ() + { + switch(this.getFacing()) + { + case 2: + return -1; + case 3: + return 1; + default: + return 0; + } + } + + public int mLZ() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + public int mLX() + { + switch(this.getFacing()) + { + case 2: + return 1; + case 3: + return -1; + default: + return 0; + } + } + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return false; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid fluid) { + return direction==ForgeDirection.UP || (gasCanPass(direction) && fluid.isGaseous()); + } + + @Override + public int fill(ForgeDirection direction, FluidStack fluidStack, boolean doFill) + { + if(fluidStack!=null && fluidStack.getFluid()!=null && fluidStack.amount>0) + { + if(gasCanPass(direction) && fluidStack!=null && fluidStack.getFluid()!=null && fluidStack.amount>0) + { + this.gasInputDirection=direction; + if(fluidStack.getFluid().isGaseous() && fluidStack.getFluid().getDensity() getRecipes() + { + return recipeManager.getRecipes(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/RefluxCondenserModel.java b/ihl/processing/chemistry/RefluxCondenserModel.java new file mode 100644 index 0000000..9cb2f2f --- /dev/null +++ b/ihl/processing/chemistry/RefluxCondenserModel.java @@ -0,0 +1,70 @@ +// Date: 05.04.2015 16:30:47 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + + +public class RefluxCondenserModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPartZ; + + public RefluxCondenserModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.PipeUp03", 0, 0); + setTextureOffset("Base.KneeUpEast", 0, 0); + setTextureOffset("Base.WestPipe03", 0, 0); + setTextureOffset("Base.WestPipe04", 0, 0); + setTextureOffset("Base.WestPipe02", 0, 0); + setTextureOffset("Base.WestPipe01", 0, 0); + setTextureOffset("Base.Shape1", 0, 0); + setTextureOffset("Base.PipeUp06", 0, 0); + setTextureOffset("Base.PipeUp07", 0, 0); + setTextureOffset("Base.PipeNorth07", 0, 0); + setTextureOffset("Base.PipeNorth08", 0, 0); + setTextureOffset("RotatingPartZ.ConeWest05", 0, 0); + setTextureOffset("RotatingPartZ.PipeWest07", 0, 0); + setTextureOffset("RotatingPartZ.ConeEast06", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addTube("PipeUp03", -2F, 7F, -2F, 4, 1, 4, 0.6f, 1f,ForgeDirection.UP); + Base.addKnee("KneeUpEast", -8F, 2F, -3F, 5, 6, 6, .8F, 1F, ForgeDirection.UP, ForgeDirection.EAST); + Base.addTube("WestPipe03", 3.5F, -7F, -1.5F, 4, 3, 3, 0.8f, 1f,ForgeDirection.WEST); + Base.addTube("WestPipe04", 7F, -7.5F, -2F, 1, 4, 4, 0.6f, 1f,ForgeDirection.WEST); + Base.addTube("WestPipe02", 7F, 3F, -2F, 1, 4, 4, 0.6f, 1f,ForgeDirection.WEST); + Base.addTube("WestPipe01", -3F, 3.5F, -1.5F, 10, 3, 3, .8F, 1F, ForgeDirection.WEST); + Base.addTube("Shape1", -2F, -8F, -2F, 4, 1, 4, 0.6f, 1f,ForgeDirection.UP); + Base.addTube("PipeUp06", -1.5F, -7F, -1.5F, 3, 2, 3, 0.8f, 1f,ForgeDirection.UP); + Base.addTube("PipeUp07", -1.5F, 5F, -1.5F, 3, 2, 3, 0.8f, 1f,ForgeDirection.UP); + Base.addTube("PipeNorth07", -2F, -2F, -8F, 4, 4, 1, 0.6f, 1f,ForgeDirection.NORTH); + Base.addTube("PipeNorth08", -1.5F, -1.5F, -7F, 3, 3, 7, 0.8f, 1f,ForgeDirection.NORTH); + RotatingPartZ = new IHLModelRenderer(this, "RotatingPartZ"); + RotatingPartZ.setRotationPoint(3F, 13F, 0F); + setRotation(RotatingPartZ, 0F, 0F, -0.5F); + RotatingPartZ.mirror = true; + RotatingPartZ.addTube("ConeWest05", 1F, -4F, -4F, 2, 8, 8, 0f, 0.8f,ForgeDirection.WEST); + RotatingPartZ.addTube("PipeWest07", -9F, -4F, -4F, 10, 8, 8, 0.8f, 1f,ForgeDirection.WEST); + RotatingPartZ.addTube("ConeEast06", -11F, -4F, -4F, 2, 8, 8, 0f, 0.8f,ForgeDirection.EAST); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + +} diff --git a/ihl/processing/chemistry/RefluxCondenserTileEntity.java b/ihl/processing/chemistry/RefluxCondenserTileEntity.java new file mode 100644 index 0000000..91366fb --- /dev/null +++ b/ihl/processing/chemistry/RefluxCondenserTileEntity.java @@ -0,0 +1,146 @@ +package ihl.processing.chemistry; + +import java.util.ArrayList; +import java.util.List; + +import ic2.api.network.INetworkDataProvider; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.utils.IHLUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class RefluxCondenserTileEntity extends TileEntity implements IWrenchable, INetworkDataProvider, IFluidHandler{ + + private short facing=2; + private short lastFacing=2; + public FractionatorBottomTileEntity columnBottom; + + public RefluxCondenserTileEntity() + { + super(); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public List getNetworkedFields() + { + List fields = new ArrayList(); + fields.add("facing"); + return fields; + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(lastFacing!=facing) + { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing=facing; + } + } + + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + + @Override + public short getFacing() { + return this.facing; + } + + + @Override + public void setFacing(short facing1) + { + facing=(short) Math.max(2,facing1); + if(IC2.platform.isSimulating()) + { + IC2.network.get().updateTileEntityField(this, "facing"); + } + } + + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + + @Override + public float getWrenchDropRate() { + return 1F; + } + + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("refluxCondenser"); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + facing=nbttagcompound.getShort("facing"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setShort("facing", facing); + } + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return false; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return direction.equals(ForgeDirection.UP); + } + + @Override + public FluidStack drain(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return null; + } + + @Override + public FluidStack drain(ForgeDirection arg0, int arg1, boolean arg2) { + return null; + } + + @Override + public int fill(ForgeDirection direction, FluidStack fluidStack, boolean doFill) { + if(fluidStack!=null && fluidStack.getFluid()!=null && this.canFill(direction, fluidStack.getFluid()) && columnBottom!=null) + { + return columnBottom.fill(direction, fluidStack, doFill); + } + return 0; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) + { + return columnBottom.getTankInfo(arg0); + } + +} -- cgit v1.2.3