diff options
Diffstat (limited to 'src/main/java/ihl/processing/chemistry')
56 files changed, 7276 insertions, 0 deletions
diff --git a/src/main/java/ihl/processing/chemistry/ApparatusProcessableInvSlot.java b/src/main/java/ihl/processing/chemistry/ApparatusProcessableInvSlot.java new file mode 100644 index 0000000..bfed5c9 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ApparatusProcessableInvSlot.java @@ -0,0 +1,59 @@ +package ihl.processing.chemistry;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ic2.api.recipe.IRecipeInput;
+import ic2.core.block.TileEntityInventory;
+import ic2.core.block.invslot.InvSlot;
+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, Access.I, count);
+ this.setStackSizeLimit(stackSizeLimit1);
+ }
+
+ public List<ItemStack> getItemStackList() {
+ List<ItemStack> list = new ArrayList<ItemStack>();
+ for (int i = 0; i < this.size(); i++) {
+ if (get(i) != null) {
+ list.add(get(i));
+ }
+ }
+ return list;
+ }
+
+ public ItemStack getItemStack(Item item) {
+ for (int i = 0; i < this.size(); i++) {
+ if (get(i) != null && get(i).getItem() == item) {
+ return get(i);
+ }
+ }
+ return null;
+ }
+
+ public void replaceItemStack(ItemStack stack1) {
+ for (int i = 0; i < this.size(); i++) {
+ if (this.get(i) != null && this.get(i).getItem() == stack1.getItem()) {
+ this.put(i, stack1);
+ }
+ }
+ }
+
+ public void consume(IRecipeInput iRecipeInput) {
+ for (int i = 0; i < this.size(); i++) {
+ if (this.get(i) != null && iRecipeInput.matches(this.get(i))) {
+ this.get(i).stackSize -= iRecipeInput.getAmount();
+ if (this.get(i).stackSize <= 0) {
+ this.put(i, null);
+ return;
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/processing/chemistry/BasicElectricMotorContainer.java b/src/main/java/ihl/processing/chemistry/BasicElectricMotorContainer.java new file mode 100644 index 0000000..a32e006 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/BasicElectricMotorContainer.java @@ -0,0 +1,74 @@ +package ihl.processing.chemistry;
+
+import ic2.core.ContainerBase;
+import ic2.core.slot.SlotInvSlot;
+import ihl.processing.metallurgy.BasicElectricMotorTileEntity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+
+public class BasicElectricMotorContainer<T extends BasicElectricMotorTileEntity> extends ContainerBase<T> {
+
+ protected BasicElectricMotorTileEntity tileEntity;
+ public short lastProgress = -1;
+ public short lastEnergy = -1;
+ private final static int height = 166;
+
+ public BasicElectricMotorContainer(EntityPlayer entityPlayer, T 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.dischargeSlot, 0, 8, 33));
+ for (col = 0; col < 4; ++col) {
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.upgradeSlot, col, 152, 8 + col * 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.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 1:
+ break;
+ case 2:
+ this.tileEntity.energy = value;
+ break;
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/BatteryItem.java b/src/main/java/ihl/processing/chemistry/BatteryItem.java new file mode 100644 index 0000000..b9c5435 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/BatteryItem.java @@ -0,0 +1,194 @@ +package ihl.processing.chemistry;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.item.ElectricItem;
+import ic2.api.item.IElectricItem;
+import ic2.api.item.IItemHudInfo;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+
+public class BatteryItem extends Item implements IElectricItem, IItemHudInfo
+{
+ public int maxCharge=65536;
+ public int transferLimit = 4096;
+ public int tier = 4;
+ private static Map<Integer, IIcon> iconMap = new HashMap<Integer, IIcon>();
+ private static Map<Integer, String> nameMap = new HashMap<Integer, String>();
+ private static Map<Integer, String> descriptionMap = new HashMap<Integer, String>();
+
+ 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<var1.length;i++)
+ {
+ nameMap.put(var1[i].damage,var1[i].unLocalizedName);
+ IHLUtils.registerLocally(var1[i].unLocalizedName, new ItemStack(item,1,var1[i].damage));
+ if(var1[i].description!=null)
+ {
+ descriptionMap.put(var1[i].damage,var1[i].description);
+ }
+ }
+ }
+
+ @Override
+ public boolean canProvideEnergy(ItemStack itemStack)
+ {
+ return true;
+ }
+
+ @Override
+ public Item getChargedItem(ItemStack itemStack)
+ {
+ return this;
+ }
+
+ @Override
+ public Item getEmptyItem(ItemStack itemStack)
+ {
+ return this;
+ }
+
+ @Override
+ public double getMaxCharge(ItemStack itemStack)
+ {
+ return this.maxCharge;
+ }
+
+ @Override
+ public int getTier(ItemStack itemStack)
+ {
+ return this.tier;
+ }
+
+ @Override
+ public double getTransferLimit(ItemStack itemStack)
+ {
+ return this.transferLimit;
+ }
+
+ @Override
+ public List<String> getHudInfo(ItemStack itemStack)
+ {
+ LinkedList<String> info = new LinkedList<String>();
+ 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<var1.length;i++)
+ {
+ iconMap.put(var1[i].damage, register.registerIcon(IHLModInfo.MODID + ":"+var1[i].textureName));
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconFromDamage(int i)
+ {
+ return iconMap.get(0);
+ }
+
+ @Override
+ public String getUnlocalizedName(ItemStack stack)
+ {
+ return nameMap.get(0);//stack.getItemDamage());
+ }
+
+ @SideOnly(Side.CLIENT)
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void func_150895_a(Item item, CreativeTabs par2CreativeTabs, List itemList)
+ {
+ ItemStack itemStack = new ItemStack(this, 1);
+ ItemStack charged;
+
+ if (this.getChargedItem(itemStack) == this)
+ {
+ charged = new ItemStack(this, 1);
+ ElectricItem.manager.charge(charged, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, false);
+ itemList.add(charged);
+ }
+
+ if (this.getEmptyItem(itemStack) == this)
+ {
+ charged = new ItemStack(this, 1);
+ ElectricItem.manager.charge(charged, 0.0D, Integer.MAX_VALUE, true, false);
+ itemList.add(charged);
+ }
+ }
+
+ public static ItemStack getFullyChargedItemStack(String name)
+ {
+ ItemStack stack = IHLUtils.getThisModItemStack(name);
+ ElectricItem.manager.charge(stack, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, false);
+ return stack;
+ }
+
+ @Override
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag)
+ {
+ if(BatteryItem.descriptionMap.containsKey(0))//itemStack.getItemDamage()))
+ {
+ info.add(BatteryItem.descriptionMap.get(0));//itemStack.getItemDamage()));
+ }
+ }
+
+ @Override
+ public double getDurabilityForDisplay(ItemStack stack)
+ {
+ return (this.maxCharge-ElectricItem.manager.getCharge(stack))/this.maxCharge;
+ }
+
+ public enum Type
+ {
+ LeadAcidBattery(0,"leadAcidBattery","Pb/Pb2PbO4 + H2SO4");
+ Type(int damage1,String unlocalizedName1,String description1)
+ {
+ damage=damage1;
+ textureName=oreRegistryName=unLocalizedName=unlocalizedName1;
+ description=description1;
+ }
+ public int damage;
+ public String unLocalizedName;
+ public String oreRegistryName;
+ public String description;
+ public String textureName;
+ }
+
+ public static ItemStack getFullyChargedItemStackWithSize(String name, int stackSize1)
+ {
+ ItemStack stack = getFullyChargedItemStack(name);
+ stack.stackSize=stackSize1;
+ return stack;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/ChemicalReactorContainer.java b/src/main/java/ihl/processing/chemistry/ChemicalReactorContainer.java new file mode 100644 index 0000000..16b6baa --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ChemicalReactorContainer.java @@ -0,0 +1,37 @@ +package ihl.processing.chemistry;
+
+import java.util.List;
+
+import ic2.core.IC2;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraftforge.fluids.FluidStack;
+
+public class ChemicalReactorContainer extends BasicElectricMotorContainer<ChemicalReactorTileEntity> {
+
+ protected ChemicalReactorTileEntity tileEntity;
+ public List<FluidStack> fluidTankFluidList;
+ public int fluidListHash = -1;
+
+ public ChemicalReactorContainer(EntityPlayer entityPlayer, ChemicalReactorTileEntity tileEntity1) {
+ super(entityPlayer, tileEntity1);
+ this.tileEntity = tileEntity1;
+ fluidTankFluidList = tileEntity.getFluidTank().getFluidList();
+ 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));
+ }
+
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ if (this.fluidListHash != fluidTankFluidList.hashCode()) {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList");
+ this.fluidListHash = fluidTankFluidList.hashCode();
+ }
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/ChemicalReactorGui.java b/src/main/java/ihl/processing/chemistry/ChemicalReactorGui.java new file mode 100644 index 0000000..de22f76 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ChemicalReactorGui.java @@ -0,0 +1,79 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+@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);
+ }
+ }
+
+ @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/src/main/java/ihl/processing/chemistry/ChemicalReactorTileEntity.java b/src/main/java/ihl/processing/chemistry/ChemicalReactorTileEntity.java new file mode 100644 index 0000000..7de2ccf --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ChemicalReactorTileEntity.java @@ -0,0 +1,294 @@ +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 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.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;
+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;
+
+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.I, 2, 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);
+ }
+
+ @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 true;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "chemicalReactor";
+ }
+
+ public float getRenderLiquidLevel()
+ {
+ return (float)this.fluidTank.getFluidAmount()/(float)this.fluidTank.getCapacity();
+ }
+
+ @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;
+ }
+
+ @SuppressWarnings("unchecked")
+ public UniversalRecipeOutput getOutput()
+ {
+ return ChemicalReactorTileEntity.recipeManager.getOutputFor(this.getInput()[0],this.getInput()[1]);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public List[] getInput()
+ {
+ return new List[] {fluidTank.getFluidList(), this.input.getItemStackList()};
+ }
+
+ @Override
+ @SuppressWarnings({ "unchecked"})
+ public void operate()
+ {
+ UniversalRecipeInput recipeInput = ChemicalReactorTileEntity.recipeManager.getRecipeInput(this.getInput()[0],this.getInput()[1]);
+ UniversalRecipeOutput output1 = getOutput();
+ for(int i=0; i<recipeInput.getItemInputs().size();i++)
+ {
+ this.input.consume(recipeInput.getItemInputs().get(i));
+ }
+ if(output1.specialConditions)
+ {
+ 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;
+ cgte.fill(ForgeDirection.getOrientation(this.getFacing()).getOpposite(), recipeInput.getFluidInputs().get(0).getInputs().get(0), true);
+ }
+ }
+ this.fluidTank.drain(recipeInput.getFluidInputs(), true);
+ this.fluidTank.fill(output1.getFluidOutputs(), true);
+ 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<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ public static void addRecipe(FluidStack fluidStackInput1, FluidStack fluidStackInput2, ItemStack itemStackInput, FluidStack fluidStackOutput, ItemStack itemStackOutput1, ItemStack itemStackOutput2)
+ {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] {fluidStackInput1, fluidStackInput2}), (new ItemStack[] {itemStackInput})), new UniversalRecipeOutput((new FluidStack[] {fluidStackOutput}), (new ItemStack[] {itemStackOutput1, itemStackOutput2}),200));
+ }
+
+ public static void addSpecialConditionsRecipe(FluidStack fluidStackInput1, FluidStack fluidStackInput2, ItemStack itemStackInput, FluidStack fluidStackOutput, ItemStack itemStackOutput1, ItemStack itemStackOutput2)
+ {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] {fluidStackInput1, fluidStackInput2}), (new ItemStack[] {itemStackInput})), new UniversalRecipeOutput((new FluidStack[] {fluidStackOutput}), (new ItemStack[] {itemStackOutput1, itemStackOutput2}),200, true));
+ }
+
+ public IHLFluidTank getFluidTank()
+ {
+ return this.fluidTank;
+ }
+
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/CryogenicDistillerContainer.java b/src/main/java/ihl/processing/chemistry/CryogenicDistillerContainer.java new file mode 100644 index 0000000..988b844 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/CryogenicDistillerContainer.java @@ -0,0 +1,39 @@ +package ihl.processing.chemistry;
+
+import java.util.List;
+
+import ic2.core.IC2;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraftforge.fluids.FluidStack;
+
+public class CryogenicDistillerContainer extends BasicElectricMotorContainer<CryogenicDistillerTileEntity> {
+
+ public CryogenicDistillerTileEntity tileEntity;
+ private int lastNumberOfFluids = -1;
+ private int lastFluidAmount = -1;
+ public List<FluidStack> fluidTankFluidList;
+
+ public CryogenicDistillerContainer(EntityPlayer entityPlayer,
+ CryogenicDistillerTileEntity lathePart1TileEntity) {
+ super(entityPlayer, lathePart1TileEntity);
+ tileEntity=lathePart1TileEntity;
+ fluidTankFluidList=tileEntity.fluidTankProducts.getFluidList();
+ 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();
+ if (this.tileEntity.fluidTankProducts.getFluidAmount() != this.lastFluidAmount || this.tileEntity.fluidTankProducts.getNumberOfFluids() != this.lastNumberOfFluids)
+ {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList");
+ }
+ this.lastNumberOfFluids = this.tileEntity.fluidTankProducts.getNumberOfFluids();
+ this.lastFluidAmount = this.tileEntity.fluidTankProducts.getFluidAmount();
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/CryogenicDistillerGui.java b/src/main/java/ihl/processing/chemistry/CryogenicDistillerGui.java new file mode 100644 index 0000000..a8f9f0f --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/CryogenicDistillerGui.java @@ -0,0 +1,71 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import ic2.core.IC2;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.GuiButton;
+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;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void initGui() {
+ super.initGui();
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.buttonList.add(new GuiButton(0, x + 7, y + 50, 49, 20, "Empty"));
+ }
+
+ @Override
+ public void actionPerformed(GuiButton button) {
+ super.actionPerformed(button);
+ IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, button.id);
+ }
+
+ @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);
+ }
+ }
+
+ @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/src/main/java/ihl/processing/chemistry/CryogenicDistillerTileEntity.java b/src/main/java/ihl/processing/chemistry/CryogenicDistillerTileEntity.java new file mode 100644 index 0000000..6a156db --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/CryogenicDistillerTileEntity.java @@ -0,0 +1,229 @@ +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 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.init.Blocks;
+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 CryogenicDistillerTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler {
+
+ public final InvSlotConsumableLiquidIHL fillInputSlotInput;
+ public final InvSlotOutput fluidItemsSlot;
+ public final InvSlotConsumableLiquidIHL fillInputSlotProducts;
+
+ private IHLFluidTank fluidTankInput = new IHLFluidTank(8000);
+ public IHLFluidTank fluidTankProducts = new IHLFluidTank(8000);
+ protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("cryogenicdistiller");
+ protected static UniversalRecipeOutput airOutput = new UniversalRecipeOutput(new FluidStack[] {
+ IHLUtils.getFluidStackWithSize("nitrogen", 781), IHLUtils.getFluidStackWithSize("oxygen", 209) }, null, 20,
+ false);
+
+ static {
+ recipeManager.addRecipe(
+ new UniversalRecipeInput(new FluidStack[] { IHLUtils.getFluidStackWithSize("air", 1000) }, null),
+ airOutput);
+ }
+
+ public CryogenicDistillerTileEntity() {
+ super();
+ 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();
+ 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() {
+ UniversalRecipeInput ri = CryogenicDistillerTileEntity.recipeManager.getRecipeInput(getInput());
+ this.fluidTankProducts.fill(getOutput().getFluidOutputs(), true);
+ this.fluidTankInput.drain(ri.getFluidInputs().get(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);
+ }
+ }
+ }
+
+ public UniversalRecipeOutput getOutput() {
+ return CryogenicDistillerTileEntity.recipeManager.getOutputFor(this.getInput());
+ }
+
+ @Override
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public List[] getInput() {
+ return new List[] { Arrays.asList(new FluidStack[] { this.fluidTankInput.getLigthestFluid() }), null };
+ }
+
+ @Override
+ public boolean canOperate() {
+ UniversalRecipeOutput output = this.getOutput();
+ if (output == airOutput) {
+ ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing()).getOpposite();
+ Block block = worldObj.getBlock(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
+ if (!block.isAir(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ)
+ && block != Blocks.air)
+ return false;
+ }
+ return output != null && (this.fluidTankProducts.getCapacity() - this.fluidTankProducts.getFluidAmount()) > 0;
+ }
+
+ @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(new FluidStack[] { input }, null),
+ new UniversalRecipeOutput(new FluidStack[] { output, output2 }, null, 20, specialCondition));
+ } else {
+ recipeManager.addRecipe(new UniversalRecipeInput(new FluidStack[] { input }, null),
+ new UniversalRecipeOutput(new FluidStack[] { output }, null, 20, specialCondition));
+ }
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ public boolean canProcess() {
+ return this.energy >= this.energyConsume;
+ }
+
+ @Override
+ public boolean canDrain(ForgeDirection dir, Fluid arg1) {
+ return dir.equals(ForgeDirection.getOrientation(this.getFacing())) || dir.equals(ForgeDirection.UP);
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection dir, Fluid fluid) {
+ return dir.equals(ForgeDirection.getOrientation(this.getFacing()).getOpposite());
+ }
+
+ @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())) {
+ return this.fluidTankInput.fill(fstack, doFill);
+ }
+ return 0;
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection dir) {
+ return new FluidTankInfo[] { this.fluidTankInput.getInfo(), this.fluidTankProducts.getInfo() };
+ }
+
+ @Override
+ public void onNetworkEvent(EntityPlayer player, int event) {
+ switch (event) {
+ case 0:
+ this.fluidTankProducts.setEmpty();
+ break;
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/processing/chemistry/DosingPumpContainer.java b/src/main/java/ihl/processing/chemistry/DosingPumpContainer.java new file mode 100644 index 0000000..5a4cb21 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/DosingPumpContainer.java @@ -0,0 +1,95 @@ +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 DosingPumpContainer extends ContainerBase<DosingPumpTileEntity> {
+
+ protected DosingPumpTileEntity tileEntity;
+ public int lastFluidAmount = -1;
+ public int lastNumberOfFluids = -1;
+ public short lastProgress = -1;
+ public int lastFluidAmountSetpoint = -1;
+ public short lastEnergy = -1;
+ private final static int height = 166;
+ public List<FluidStack> fluidTankFluidList;
+
+ public DosingPumpContainer(EntityPlayer entityPlayer, DosingPumpTileEntity 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, 44, 50));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 44, 14));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 44, 32));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.dischargeSlot, 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.fluidAmountSetpoint != this.lastFluidAmountSetpoint) {
+ icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.fluidAmountSetpoint);
+ }
+
+ 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.lastFluidAmountSetpoint = this.tileEntity.fluidAmountSetpoint;
+ 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.fluidAmountSetpoint = (short) value;
+ break;
+ case 2:
+ this.tileEntity.energy = value;
+ break;
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/DosingPumpGui.java b/src/main/java/ihl/processing/chemistry/DosingPumpGui.java new file mode 100644 index 0000000..dde4f13 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/DosingPumpGui.java @@ -0,0 +1,103 @@ +package ihl.processing.chemistry;
+
+import java.awt.event.KeyEvent;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.ClientProxy;
+import ihl.IHLMod;
+import ihl.utils.IHLRenderUtils;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiTextField;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+
+@SideOnly(Side.CLIENT)
+public class DosingPumpGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIDosingPump.png");
+ private DosingPumpContainer container;
+ private GuiTextField setpointTextField;
+ private int lastFluidAmountSetpoint = -1;
+ private final static int TANK_HEIGHT = 58;
+
+ public DosingPumpGui(DosingPumpContainer container1) {
+ // the container is instanciated and passed to the superclass for
+ // handling
+ super(container1);
+ this.container = container1;
+ setpointTextField = new GuiTextField(Minecraft.getMinecraft().fontRenderer, 106, 34, 62, 16);
+ setpointTextField.setText(Integer.toString(this.container.tileEntity.fluidAmountSetpoint));
+ setpointTextField.setFocused(true);
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ if(lastFluidAmountSetpoint!= this.container.tileEntity.fluidAmountSetpoint){
+ setpointTextField.setText(Integer.toString(this.container.tileEntity.fluidAmountSetpoint));
+ lastFluidAmountSetpoint= this.container.tileEntity.fluidAmountSetpoint;
+ }
+ 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, 15 + 12 - i1, 179, 12 - i1, 14, i1 + 2);
+ }
+ i1 = TANK_HEIGHT - this.container.tileEntity.fluidAmountSetpoint * TANK_HEIGHT
+ / this.container.tileEntity.getFluidTank().getCapacity();
+ this.drawTexturedModalRect(78, 6 + i1, 176, 14, 25, 7);
+ if (this.container.tileEntity.getTankAmount() > 0) {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 82, 10, 94,
+ 67, zLevel, par1, par2, xOffset, yOffset);
+ }
+ setpointTextField.drawTextBox();
+ IHLRenderUtils.instance.drawTooltip(par1,par2,9,11,xOffset,yOffset,StatCollector.translateToLocal("ihl.dosingPump.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(background);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ }
+
+ @Override
+ protected void keyTyped(char characterTyped, int keyIndex) {
+ super.keyTyped(characterTyped, keyIndex);
+ this.setpointTextField.textboxKeyTyped(characterTyped, keyIndex);
+ // 28 - enter; 156 - numpad enter
+ if (keyIndex == KeyEvent.VK_ACCEPT || keyIndex == KeyEvent.VK_ENTER || keyIndex == 28 || keyIndex == 156) {
+ int fluidAmountSetpoint = (short) Math.max(1,
+ Math.min(this.container.tileEntity.getFluidTank().getCapacity(),
+ IHLUtils.parseIntSafe(this.setpointTextField.getText(), 100)));
+ this.setpointTextField.setText(Integer.toString(fluidAmountSetpoint));
+ this.setpointTextField.setFocused(false);
+ ((ClientProxy)IHLMod.proxy).sendIntegerFieldValueFromClientToServer(fluidAmountSetpoint, "fluidAmountSetpoint", this.container.tileEntity);
+ }
+ }
+ @Override
+ public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ if (mouseX >= x + setpointTextField.xPosition &&
+ mouseX <= x + setpointTextField.xPosition + setpointTextField.width &&
+ mouseY >= y + setpointTextField.yPosition &&
+ mouseY <= y + setpointTextField.yPosition + setpointTextField.height) {
+ setpointTextField.setFocused(true);
+ }
+ }
+
+
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/DosingPumpTileEntity.java b/src/main/java/ihl/processing/chemistry/DosingPumpTileEntity.java new file mode 100644 index 0000000..e1e4996 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/DosingPumpTileEntity.java @@ -0,0 +1,226 @@ +package ihl.processing.chemistry;
+
+import java.util.List;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+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.InvSlotConsumableLiquidIHL;
+import ihl.processing.metallurgy.BasicElectricMotorTileEntity;
+import ihl.utils.IHLFluidTank;
+import ihl.utils.IHLUtils;
+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;
+
+public class DosingPumpTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler {
+ public final InvSlotConsumableLiquidIHL drainInputSlot;
+ public final InvSlotConsumableLiquidIHL fillInputSlot;
+ public final InvSlotOutput emptyFluidItemsSlot;
+ private final IHLFluidTank fluidTank = new IHLFluidTank(8000);
+ public int fluidAmountSetpoint = 8000;
+ private boolean prevIsPowered = false;
+ private boolean tickFree=false;
+
+ public DosingPumpTileEntity() {
+ 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);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound) {
+ super.readFromNBT(nbttagcompound);
+ this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank"));
+ this.fluidAmountSetpoint = nbttagcompound.getInteger("fluidAmountSetpoint");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound) {
+ super.writeToNBT(nbttagcompound);
+ NBTTagCompound fluidTankTag = new NBTTagCompound();
+ this.fluidTank.writeToNBT(fluidTankTag);
+ nbttagcompound.setTag("fluidTank", fluidTankTag);
+ nbttagcompound.setInteger("fluidAmountSetpoint", this.fluidAmountSetpoint);
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing() != side;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("dosingPump");
+ }
+
+ @Override
+ public boolean enableUpdateEntity() {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public void updateEntityServer() {
+ super.updateEntityServer();
+ this.tickFree = true;
+ 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()));
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "dosingPump";
+ }
+
+ public float getRenderLiquidLevel() {
+ return (float) this.fluidTank.getFluidAmount() / (float) this.fluidTank.getCapacity();
+ }
+
+ @Override
+ public int gaugeProgressScaled(int i) {
+ return this.progress * i / operationLength;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new DosingPumpGui(new DosingPumpContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player) {
+ this.fluidTank.sortFluidsByDensity();
+ return new DosingPumpContainer(player, this);
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer player) {
+ }
+
+ @Override
+ public boolean canOperate() {
+ return false;
+ }
+
+ @Override
+ public void operate() {
+ int fluidAmountToDrain = fluidAmountSetpoint;
+ ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing());
+ TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
+ if (te instanceof IFluidHandler) {
+ IFluidHandler fhte = (IFluidHandler) te;
+ for (int i = 0; i < this.fluidTank.getNumberOfFluids(); i++) {
+ FluidStack drained = this.fluidTank.drain(fluidAmountToDrain, true);
+ fluidAmountToDrain -= drained.amount;
+ if (fhte.canFill(dir, drained.getFluid())) {
+ fhte.fill(dir, drained, true);
+ }
+ if (fluidAmountToDrain <= 0) {
+ break;
+ }
+ }
+ }
+ this.energy-=this.energyConsume/10;
+ }
+
+ @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 int getNumberOfFluidsInTank() {
+ return this.fluidTank.getNumberOfFluids();
+ }
+
+ public IHLFluidTank getFluidTank() {
+ return this.fluidTank;
+ }
+
+ @Override
+ public List<?>[] getInput() {
+ return null;
+ }
+
+ public void setPowered(boolean isPowered) {
+ if (isPowered && !prevIsPowered && this.energy > 0 && this.tickFree) {
+ this.operate();
+ }
+ prevIsPowered = isPowered;
+ this.tickFree = false; // Only one operation per tick max
+ }
+
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/ElectricEvaporatorBlock.java b/src/main/java/ihl/processing/chemistry/ElectricEvaporatorBlock.java new file mode 100644 index 0000000..f65b76d --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ElectricEvaporatorBlock.java @@ -0,0 +1,220 @@ +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)
+ {
+ 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/src/main/java/ihl/processing/chemistry/ElectricEvaporatorContainer.java b/src/main/java/ihl/processing/chemistry/ElectricEvaporatorContainer.java new file mode 100644 index 0000000..d981d94 --- /dev/null +++ b/src/main/java/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<ElectricEvaporatorTileEntity> {
+
+ 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/src/main/java/ihl/processing/chemistry/ElectricEvaporatorGui.java b/src/main/java/ihl/processing/chemistry/ElectricEvaporatorGui.java new file mode 100644 index 0000000..4a36631 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ElectricEvaporatorGui.java @@ -0,0 +1,85 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.util.DrawUtil;
+import ic2.core.util.GuiTooltipHelper;
+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;
+
+@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/src/main/java/ihl/processing/chemistry/ElectricEvaporatorTileEntity.java b/src/main/java/ihl/processing/chemistry/ElectricEvaporatorTileEntity.java new file mode 100644 index 0000000..cdf3524 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ElectricEvaporatorTileEntity.java @@ -0,0 +1,430 @@ +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 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.InvSlot.Access;
+import ic2.core.block.invslot.InvSlotUpgrade;
+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;
+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;
+
+public class ElectricEvaporatorTileEntity extends EvaporatorTileEntity implements IEnergySink, IUpgradableBlock, INetworkTileEntityEventListener
+{
+ public final InvSlotUpgrade upgradeSlot;
+ private int tier;
+ 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 int updateChecksum=0;
+ private boolean addedToEnergyNet=false;
+
+ public ElectricEvaporatorTileEntity()
+ {
+ super();
+ this.defaultEnergyConsume = this.energyConsume = 8;
+ this.defaultOperationLength = this.maxProgress = 400;
+ this.energy=0D;
+ 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<String> getNetworkedFields()
+ {
+ List<String> 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<this.upgradeSlot.size();i++)
+ {
+ if(this.upgradeSlot.get(i)!=null)
+ {
+ if(this.upgradeSlot.get(i).getItemDamage()==IC2Items.getItem("overclockerUpgrade").getItemDamage())
+ {
+ speedUp+=this.upgradeSlot.get(i).stackSize;
+ }
+ if(this.upgradeSlot.get(i).getItemDamage()==IC2Items.getItem("transformerUpgrade").getItemDamage())
+ {
+ tierUp+=this.upgradeSlot.get(i).stackSize;
+ }
+ if(this.upgradeSlot.get(i).getItemDamage()==IC2Items.getItem("energyStorageUpgrade").getItemDamage())
+ {
+ capacityUp+=this.upgradeSlot.get(i).stackSize;
+ }
+ }
+ }
+ checksum=speedUp*4096+tierUp*64+capacityUp;
+ if(this.updateChecksum!=checksum)
+ {
+ this.maxProgress=(short)Math.max(this.defaultOperationLength*Math.pow(0.7D, speedUp),2D);
+ this.maxStorage=this.defaultMaxStorage + capacityUp*10000;
+ IC2.network.get().updateTileEntityField(this, "maxStorage");
+ this.energyConsume=(int) Math.min(this.defaultEnergyConsume*Math.pow(1.6D, speedUp),this.maxStorage);
+ this.tier=this.defaultTier+tierUp;
+ IC2.network.get().updateTileEntityField(this, "tier");
+ this.updateChecksum=checksum;
+ };
+ }
+
+ @Override
+ public void onUnloaded()
+ {
+ super.onUnloaded();
+
+ if (IC2.platform.isRendering() && this.audioSource != null)
+ {
+ IC2.audioManager.removeSources(this);
+ this.audioSource = null;
+ }
+
+ if (IC2.platform.isSimulating()&&this.addedToEnergyNet)
+ {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
+ this.addedToEnergyNet = false;
+ }
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ this.energy=nbttagcompound.getDouble("energy");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ nbttagcompound.setDouble("energy", this.energy);
+ }
+
+ @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()));
+ if(this.upgradeSlot.get(0)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(0)));
+ if(this.upgradeSlot.get(1)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(1)));
+ if(this.upgradeSlot.get(2)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(2)));
+ if(this.upgradeSlot.get(3)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(3)));
+ return new ItemStack(IHLMod.electricEvaporatorBlock,1);
+ }
+
+ public int getGUIEnergy(int i)
+ {
+ if(this.energy<Float.MAX_VALUE)
+ {
+ return Math.round((float)this.energy/this.maxStorage*i);
+ }
+ else
+ {
+ return Math.round((float)(this.energy/this.maxStorage)*i);
+ }
+ }
+
+ @Override
+ public boolean enableUpdateEntity()
+ {
+ return true;
+ }
+ @Override
+ public void updateEntityClient()
+ {
+ if(((IHLInvSlotDischarge)this.fuelSlot).tier!=this.tier)
+ {
+ ((IHLInvSlotDischarge)this.fuelSlot).tier=this.tier;
+ }
+ }
+ @Override
+ public void updateEntityServer()
+ {
+ if(((IHLInvSlotDischarge)this.fuelSlot).tier!=this.tier)
+ {
+ ((IHLInvSlotDischarge)this.fuelSlot).tier=this.tier;
+ }
+ if(IC2.platform.isSimulating())
+ {
+ this.setOverclockRates();
+
+ if(this.getDemandedEnergy() > 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();
+ 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);
+ }
+ }
+ }
+ }
+
+ @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<ElectricEvaporatorTileEntity> 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<UpgradableProperty> getUpgradableProperties()
+ {
+ Set<UpgradableProperty> properties = new HashSet<UpgradableProperty>();
+ properties.add(UpgradableProperty.ItemProducing);
+ properties.add(UpgradableProperty.EnergyStorage);
+ properties.add(UpgradableProperty.Transformer);
+ return properties;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/ElectrolysisBathContainer.java b/src/main/java/ihl/processing/chemistry/ElectrolysisBathContainer.java new file mode 100644 index 0000000..13a5ddb --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ElectrolysisBathContainer.java @@ -0,0 +1,79 @@ +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<ElectrolysisBathTileEntity> {
+
+ 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<FluidStack> fluidTankFluidList;
+ public int fluidListHash = -1;
+
+ 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.fluidListHash != fluidTankFluidList.hashCode()) {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList");
+ this.fluidListHash = fluidTankFluidList.hashCode();
+ }
+
+ if (this.tileEntity.progress != this.lastProgress) {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress);
+ }
+
+ }
+
+ this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank();
+ this.lastFluidAmount = this.tileEntity.getTankAmount();
+ 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;
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/ElectrolysisBathGui.java b/src/main/java/ihl/processing/chemistry/ElectrolysisBathGui.java new file mode 100644 index 0000000..404ef94 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ElectrolysisBathGui.java @@ -0,0 +1,100 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.IC2;
+import ihl.utils.GuiMultiTextureButton;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+@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;
+ }
+
+ @SuppressWarnings("unchecked")
+ @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/src/main/java/ihl/processing/chemistry/ElectrolysisBathModel.java b/src/main/java/ihl/processing/chemistry/ElectrolysisBathModel.java new file mode 100644 index 0000000..310ec62 --- /dev/null +++ b/src/main/java/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/src/main/java/ihl/processing/chemistry/ElectrolysisBathTileEntity.java b/src/main/java/ihl/processing/chemistry/ElectrolysisBathTileEntity.java new file mode 100644 index 0000000..ea98a34 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ElectrolysisBathTileEntity.java @@ -0,0 +1,297 @@ +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 ic2.api.network.INetworkClientTileEntityEventListener;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.IHasGui;
+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.flexible_cable.FlexibleCableHolderBaseTileEntity;
+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;
+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;
+
+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);
+ 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);
+ }
+
+ @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();
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank);
+ if (this.canOperate())
+ {
+ this.setActive(true);
+ if (this.progress == 0)
+ {
+ IC2.network.get().initiateTileEntityEvent(this, 0, true);
+ }
+ if(gridID!=-1 && this.getGrid().energy>0D)
+ {
+ double drawEnergy = getEnergyAmountThisNodeWant();
+ this.progress+=drawEnergy;
+ this.getGrid().drawEnergy(drawEnergy, this);
+ }
+
+ 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 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());
+ }
+
+ @SuppressWarnings("rawtypes")
+ public List[] getInput()
+ {
+ for(int i=0;i<fluidTank.getNumberOfFluids();i++)
+ {
+ List[] rInput = new List[] {Arrays.asList(new FluidStack[]{fluidTank.getFluid(i)}), this.input.getItemStackList()};
+ if(ElectrolysisBathTileEntity.recipeManager.getOutputFor(rInput)!=null)
+ {
+ return rInput;
+ }
+ }
+ return new List[] {Arrays.asList(new FluidStack[]{fluidTank.getFluid()}), this.input.getItemStackList()};
+ }
+
+ public void operate() {
+ if (this.fluidTank.getCapacity() > this.fluidTank.getFluidAmount()) {
+ UniversalRecipeInput recipeInput = ElectrolysisBathTileEntity.recipeManager.getRecipeInput(getInput());
+ UniversalRecipeOutput output1 = getOutput();
+ for (int i = 0; i < recipeInput.getItemInputs().size(); i++) {
+ this.input.consume(recipeInput.getItemInputs().get(i));
+ }
+ this.fluidTank.fill(output1.getFluidOutputs(), true);
+ }
+ }
+
+ @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<UniversalRecipeInput, UniversalRecipeOutput> 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>1d?energy:1d:0d;
+ }
+
+ @Override
+ public void injectEnergyInThisNode(double amount, double voltage)
+ {
+ this.progress+=amount;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/EvaporatorBlock.java b/src/main/java/ihl/processing/chemistry/EvaporatorBlock.java new file mode 100644 index 0000000..6994176 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/EvaporatorBlock.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 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)
+ {
+ 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/src/main/java/ihl/processing/chemistry/EvaporatorContainer.java b/src/main/java/ihl/processing/chemistry/EvaporatorContainer.java new file mode 100644 index 0000000..cb83269 --- /dev/null +++ b/src/main/java/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<EvaporatorTileEntity> {
+
+ 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/src/main/java/ihl/processing/chemistry/EvaporatorGui.java b/src/main/java/ihl/processing/chemistry/EvaporatorGui.java new file mode 100644 index 0000000..05f7c31 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/EvaporatorGui.java @@ -0,0 +1,84 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.util.DrawUtil;
+import ic2.core.util.GuiTooltipHelper;
+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;
+
+@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/src/main/java/ihl/processing/chemistry/EvaporatorTileEntity.java b/src/main/java/ihl/processing/chemistry/EvaporatorTileEntity.java new file mode 100644 index 0000000..279fa17 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/EvaporatorTileEntity.java @@ -0,0 +1,290 @@ +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 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;
+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;
+
+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();
+ if (this.needsFluid())
+ {
+ IHLUtils.handleFluidSlotsBehaviour(fillItemsSlot, fluidItemsSlot, emptyFluidItemsSlot, fluidTank);
+ }
+ if (this.fuel <= 0 && this.canOperate() && this.fuelSlot instanceof InvSlotConsumableFuel)
+ {
+ this.fuel = this.maxFuel = ((InvSlotConsumableFuel) this.fuelSlot).consumeFuel();
+ }
+
+ if (this.isBurning() && this.canOperate())
+ {
+ ++this.progress;
+
+ if (this.progress >= maxProgress)
+ {
+ this.progress = 0;
+ this.operate();
+ }
+ }
+ else
+ {
+ this.progress = 0;
+ }
+
+ if (this.fuel > 0)
+ {
+ --this.fuel;
+ }
+
+ if (this.getActive() != this.isBurning())
+ {
+ this.setActive(this.isBurning());
+ }
+ }
+
+ 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);
+ 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<? extends EvaporatorTileEntity> 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((new FluidStack [] {input}),null), new UniversalRecipeOutput(null, (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);
+ return output == null ? null : (this.outputSlot.canAdd(output.getItemOutputs()) ? output : null);
+ }
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/ExtruderModel.java b/src/main/java/ihl/processing/chemistry/ExtruderModel.java new file mode 100644 index 0000000..4d4688a --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ExtruderModel.java @@ -0,0 +1,100 @@ +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +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/src/main/java/ihl/processing/chemistry/FluidizedBedReactorContainer.java b/src/main/java/ihl/processing/chemistry/FluidizedBedReactorContainer.java new file mode 100644 index 0000000..ada1463 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/FluidizedBedReactorContainer.java @@ -0,0 +1,44 @@ +package ihl.processing.chemistry;
+
+import java.util.List;
+
+import ic2.core.IC2;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraftforge.fluids.FluidStack;
+
+public class FluidizedBedReactorContainer extends BasicElectricMotorContainer<FluidizedBedReactorTileEntity> {
+
+ protected FluidizedBedReactorTileEntity tileEntity;
+ public int lastFluidsHash = -1;
+ private final static int height=166;
+ public List<FluidStack> fluidTankFluidList;
+
+ public FluidizedBedReactorContainer(EntityPlayer entityPlayer, FluidizedBedReactorTileEntity tileEntity1){
+ super(entityPlayer, tileEntity1);
+ this.tileEntity = tileEntity1;
+ fluidTankFluidList = this.tileEntity.getFluidTank().getFluidList();
+ 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, 41, 23));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 1, 41, 41));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 76, 33));
+ }
+
+ @Override
+ public void detectAndSendChanges()
+ {
+ super.detectAndSendChanges();
+ if (fluidTankFluidList.hashCode() != this.lastFluidsHash)
+ {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList");
+ this.lastFluidsHash = fluidTankFluidList.hashCode();
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/FluidizedBedReactorGui.java b/src/main/java/ihl/processing/chemistry/FluidizedBedReactorGui.java new file mode 100644 index 0000000..95ba8f0 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/FluidizedBedReactorGui.java @@ -0,0 +1,59 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+@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(12, 16 + 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(58, 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);
+ }
+ }
+
+ @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/src/main/java/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java b/src/main/java/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java new file mode 100644 index 0000000..69dd4e1 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java @@ -0,0 +1,318 @@ +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 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.IHLMod;
+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;
+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;
+
+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;
+
+ 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);
+ }
+
+ @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 true;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "fluidizedBedReactor";
+ }
+
+ @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());
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public List[] getInput()
+ {
+ for(int i=0;i<fluidTank.getNumberOfFluids();i++)
+ {
+ for(int i1=0;i1<fluidTank.getNumberOfFluids();i1++)
+ {
+ if(i!=i1)
+ {
+ List[] rInput = new List[] {Arrays.asList(new FluidStack[]{fluidTank.getFluid(i),fluidTank.getFluid(i1)}), this.input.getItemStackList()};
+ if(FluidizedBedReactorTileEntity.recipeManager.getOutputFor(rInput)!=null)
+ {
+ return rInput;
+ }
+ }
+ }
+ }
+ return new List[] {Arrays.asList(new FluidStack[]{fluidTank.getLigthestFluid()}), this.input.getItemStackList()};
+ }
+
+ @Override
+ public void operate()
+ {
+ UniversalRecipeInput recipeInput = FluidizedBedReactorTileEntity.recipeManager.getRecipeInput(getInput());
+ UniversalRecipeOutput output1 = getOutput();
+ this.fluidTank.drain(recipeInput.getFluidInputs(), true);
+ for (int i = 0; i < recipeInput.getItemInputs().size(); i++) {
+ this.input.consume(recipeInput.getItemInputs().get(i));
+ if (recipeInput.getItemInputs().get(i).getAmount() == 0) {
+ for (int i1 = 0; i1 < this.input.size(); i1++) {
+ ItemStack stack = this.input.get(i1);
+ if (stack != null && recipeInput.getItemInputs().get(i).matches(stack)) {
+ if (stack.stackTagCompound == null) {
+ stack.stackTagCompound = new NBTTagCompound();
+ }
+ stack.stackTagCompound.setInteger("catalyst_uses",
+ stack.stackTagCompound.getInteger("catalyst_uses") + 1);
+ if (stack.stackTagCompound.getInteger("catalyst_uses") > IHLMod.config.maxCatalystUses){
+ stack.stackTagCompound.setInteger("catalyst_uses", 0);
+ if(--stack.stackSize<=0)
+ this.input.put(i1, null);
+ }
+ }
+ }
+ }
+ }
+ 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<UniversalRecipeInput, UniversalRecipeOutput> getRecipes()
+ {
+ return recipeManager.getRecipes();
+ }
+
+ public static void addRecipe(FluidStack fluidStackInput1, ItemStack itemStackInput, FluidStack fluidStackOutput, ItemStack itemStackOutput1)
+ {
+ if(fluidStackOutput!=null)
+ {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] {fluidStackInput1}), (new ItemStack[] {itemStackInput})), new UniversalRecipeOutput((new FluidStack[] {fluidStackOutput}), (new ItemStack[] {itemStackOutput1}),200));
+ }
+ else
+ {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] {fluidStackInput1}), (new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(null, (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((new FluidStack[] {fluidStackInput1}), (new ItemStack[] {itemStackInput})), new UniversalRecipeOutput((new FluidStack[] {fluidStackOutput}), (new RecipeOutputItemStack[] {itemStackOutput1}),200));
+ }
+ else
+ {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] {fluidStackInput1}), (new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(null, (new RecipeOutputItemStack[] {itemStackOutput1}),200));
+ }
+ }
+
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/FractionatorBottomModel.java b/src/main/java/ihl/processing/chemistry/FractionatorBottomModel.java new file mode 100644 index 0000000..c395af7 --- /dev/null +++ b/src/main/java/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/src/main/java/ihl/processing/chemistry/FractionatorBottomTileEntity.java b/src/main/java/ihl/processing/chemistry/FractionatorBottomTileEntity.java new file mode 100644 index 0000000..3d9e95e --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/FractionatorBottomTileEntity.java @@ -0,0 +1,352 @@ +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 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;
+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 FractionatorBottomTileEntity extends TileEntityInventory implements IFluidHandler
+{
+ private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("fractionator");
+ private static float kF = 24000F;
+ 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<FractionatorSectionTileEntity> listOfColumnSections = new ArrayList<FractionatorSectionTileEntity>();
+ 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((new FluidStack[] {fluidIn}), null), new UniversalRecipeOutput((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(this.fluidTank.getFluidList(),null);
+ UniversalRecipeInput rInput = FractionatorBottomTileEntity.recipeManager.getRecipeInput(this.fluidTank.getFluidList(),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 amountOfGasToCondense = Math.min(coolant.amount*50, amountOfVapours);
+ 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<FractionatorSectionTileEntity> 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;
+ }
+
+ @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<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
+ return this.fluidTank.drain(resource, doDrain);
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
+ return this.fluidTank.drain(maxDrain, doDrain);
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection from, Fluid fluid) {
+ return true;
+ }
+
+ @Override
+ public boolean canDrain(ForgeDirection from, Fluid fluid) {
+ return true;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/FractionatorCoverModel.java b/src/main/java/ihl/processing/chemistry/FractionatorCoverModel.java new file mode 100644 index 0000000..451d73c --- /dev/null +++ b/src/main/java/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/src/main/java/ihl/processing/chemistry/FractionatorCoverTileEntity.java b/src/main/java/ihl/processing/chemistry/FractionatorCoverTileEntity.java new file mode 100644 index 0000000..048f953 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/FractionatorCoverTileEntity.java @@ -0,0 +1,104 @@ +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 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<String> getNetworkedFields()
+ {
+ List<String> fields = new ArrayList<String>();
+ 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/src/main/java/ihl/processing/chemistry/FractionatorSectionModel.java b/src/main/java/ihl/processing/chemistry/FractionatorSectionModel.java new file mode 100644 index 0000000..2a20e7b --- /dev/null +++ b/src/main/java/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/src/main/java/ihl/processing/chemistry/FractionatorSectionTileEntity.java b/src/main/java/ihl/processing/chemistry/FractionatorSectionTileEntity.java new file mode 100644 index 0000000..e71c453 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/FractionatorSectionTileEntity.java @@ -0,0 +1,148 @@ +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 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<String> getNetworkedFields()
+ {
+ List<String> fields = new ArrayList<String>();
+ 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)
+ {
+ if(columnBottom!=null)
+ return columnBottom.getTankInfo(arg0);
+ else
+ return new FluidTankInfo[] {new FluidTankInfo(null, 8000)};
+ }
+
+}
diff --git a/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpContainer.java b/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpContainer.java new file mode 100644 index 0000000..b283a48 --- /dev/null +++ b/src/main/java/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<GaedesMercuryRotaryPumpTileEntity> {
+
+ 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.dischargeSlot, 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/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpGui.java b/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpGui.java new file mode 100644 index 0000000..28c9edc --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpGui.java @@ -0,0 +1,60 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+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) {
+ 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);
+ }
+ }
+
+ @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/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpModel.java b/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpModel.java new file mode 100644 index 0000000..607d26a --- /dev/null +++ b/src/main/java/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/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpTileEntity.java b/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpTileEntity.java new file mode 100644 index 0000000..186b606 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpTileEntity.java @@ -0,0 +1,83 @@ +package ihl.processing.chemistry;
+
+import java.util.List;
+
+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;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+
+public class GaedesMercuryRotaryPumpTileEntity extends BasicElectricMotorTileEntity implements IWorkspaceElement{
+
+ public boolean ready=false;
+
+ public GaedesMercuryRotaryPumpTileEntity()
+ {
+ }
+
+ @Override
+ public void operate()
+ {
+ ready=true;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
+ {
+ return IHLUtils.getThisModItemStack("gaedesMercuryRotaryPump");
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @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/src/main/java/ihl/processing/chemistry/LabElectrolyzerContainer.java b/src/main/java/ihl/processing/chemistry/LabElectrolyzerContainer.java new file mode 100644 index 0000000..1be5e01 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LabElectrolyzerContainer.java @@ -0,0 +1,73 @@ +package ihl.processing.chemistry;
+
+import java.util.List;
+
+import ic2.core.IC2;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraftforge.fluids.FluidStack;
+
+public class LabElectrolyzerContainer extends BasicElectricMotorContainer<LabElectrolyzerTileEntity> {
+
+ protected LabElectrolyzerTileEntity tileEntity;
+ public short lastProgress = -1;
+ public short lastTemperature = -1;
+ public short lastEnergy = -1;
+ 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<FluidStack> fluidTankFluidList;
+ public List<FluidStack> fluidTankFluidList2;
+ public List<FluidStack> fluidTankFluidList3;
+
+ public LabElectrolyzerContainer(EntityPlayer entityPlayer, LabElectrolyzerTileEntity tileEntity1) {
+ super(entityPlayer, tileEntity1);
+ this.tileEntity = tileEntity1;
+ fluidTankFluidList = this.tileEntity.getFluidTank().getFluidList();
+ fluidTankFluidList2 = this.tileEntity.fluidTankAnodeOutput.getFluidList();
+ fluidTankFluidList3 = this.tileEntity.fluidTankCathodeOutput.getFluidList();
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 63, 47));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlotAnodeOutput, 0, 109, 47));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlotCathodeOutput, 0, 29, 47));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 63, 11));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 29, 11));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 1, 63, 29));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 2, 109, 11));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 1, 63, 65));
+ }
+
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ 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");
+ }
+
+ this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank();
+ this.lastFluidAmount = this.tileEntity.getTankAmount();
+ 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 boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/LabElectrolyzerGui.java b/src/main/java/ihl/processing/chemistry/LabElectrolyzerGui.java new file mode 100644 index 0000000..3eb14a3 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LabElectrolyzerGui.java @@ -0,0 +1,74 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+@SideOnly(Side.CLIENT)
+public class LabElectrolyzerGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl",
+ "textures/gui/GUILabElectrolyzer.png");
+ private LabElectrolyzerContainer container;
+
+ 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(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(81, 31, getFrameX(i1), getFrameY(i1), 24, 24);
+ }
+ if (this.container.tileEntity.getTankAmount() > 0) {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 83, 15, 104, 81, zLevel,
+ par1, par2, xOffset, yOffset);
+ }
+ if (this.container.tileEntity.fluidTankCathodeOutput.getFluidAmount() > 0) {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.fluidTankCathodeOutput, 48, 24, 59, 81,
+ zLevel, par1, par2, xOffset, yOffset);
+ }
+ if (this.container.tileEntity.fluidTankAnodeOutput.getFluidAmount() > 0) {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.fluidTankAnodeOutput, 128, 24, 139, 81,
+ zLevel, par1, par2, 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/src/main/java/ihl/processing/chemistry/LabElectrolyzerTileEntity.java b/src/main/java/ihl/processing/chemistry/LabElectrolyzerTileEntity.java new file mode 100644 index 0000000..19348b6 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LabElectrolyzerTileEntity.java @@ -0,0 +1,272 @@ +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 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;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTankInfo;
+import net.minecraftforge.fluids.IFluidHandler;
+
+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.energyConsume *= 10;
+ 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);
+ }
+
+ @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 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() < this.fluidTankAnodeOutput.getCapacity()
+ && this.fluidTankAnodeOutput.getFluidAmount() < this.fluidTankCathodeOutput.getCapacity();
+ }
+ }
+ return false;
+ }
+
+ public UniversalRecipeOutput getOutput() {
+ return LabElectrolyzerTileEntity.recipeManager.getOutputFor(this.getInput());
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public List[] getInput() {
+ return new List[] { Arrays.asList(new FluidStack[] { fluidTank.getFluid() }), null };
+ }
+
+ @Override
+ public void operate() {
+ UniversalRecipeInput recipeInput = LabElectrolyzerTileEntity.recipeManager.getRecipeInput(getInput());
+ UniversalRecipeOutput output1 = getOutput();
+ this.fluidTank.drain(recipeInput.getFluidInputs().get(0), true);
+ if (output1.getFluidOutputs().size() > 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 direction, FluidStack fluidStack, boolean doDrain) {
+ if (this.fluidTankAnodeOutput.getFluid().containsFluid(fluidStack)) {
+ return this.fluidTankAnodeOutput.drain(fluidStack.amount, doDrain);
+ } else 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 direction) {
+ if (direction.equals(ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.UP))) {
+ return new FluidTankInfo[] { this.fluidTankAnodeOutput.getInfo() };
+ }
+ if (direction.equals(ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.DOWN))) {
+ return new FluidTankInfo[] { this.fluidTankCathodeOutput.getInfo() };
+ }
+ 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<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ public static void addRecipe(FluidStack fluidStackInput1, FluidStack fluidStackOutputAnode,
+ FluidStack fluidStackOutputCathode, ItemStack itemStackOutput1) {
+ if (itemStackOutput1 != null) {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] { fluidStackInput1 }), null),
+ new UniversalRecipeOutput((new FluidStack[] { fluidStackOutputAnode, fluidStackOutputCathode }),
+ (new ItemStack[] { itemStackOutput1 }), 200));
+ } else {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] { fluidStackInput1 }), null),
+ new UniversalRecipeOutput((new FluidStack[] { fluidStackOutputAnode, fluidStackOutputCathode }),
+ null, 200));
+ }
+ }
+
+ public IHLFluidTank getFluidTank() {
+ return this.fluidTank;
+ }
+
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/LeadOvenContainer.java b/src/main/java/ihl/processing/chemistry/LeadOvenContainer.java new file mode 100644 index 0000000..2f0ff8a --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LeadOvenContainer.java @@ -0,0 +1,95 @@ +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 LeadOvenContainer extends ContainerBase<LeadOvenTileEntity> {
+
+ protected LeadOvenTileEntity tileEntity;
+ public int lastInputFluidAmount = -1;
+ public int lastOutputFluidAmount = -1;
+ public int lastFuel = -1;
+ public short lastProgress = -1;
+ private final static int height = 166;
+ public List<FluidStack> inputTankFluidList;
+ public List<FluidStack> outputTankFluidList;
+
+ public LeadOvenContainer(EntityPlayer entityPlayer, LeadOvenTileEntity tileEntity1) {
+ super(tileEntity1);
+ this.tileEntity = tileEntity1;
+ inputTankFluidList = this.tileEntity.inputTank.getFluidList();
+ outputTankFluidList = this.tileEntity.outputTank.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.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));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 9, 53));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 9, 17));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 9, 35));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot2, 0, 150, 53));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot2, 0, 150, 17));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 1, 150, 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.inputTank.getFluidAmount() != this.lastInputFluidAmount) {
+ IC2.network.get().sendContainerField(this, "inputTankFluidList");
+ }
+ if (this.tileEntity.outputTank.getFluidAmount() != this.lastOutputFluidAmount) {
+ IC2.network.get().sendContainerField(this, "outputTankFluidList");
+ }
+
+ 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;
+ this.lastInputFluidAmount = this.tileEntity.inputTank.getFluidAmount();
+ this.lastOutputFluidAmount = this.tileEntity.outputTank.getFluidAmount();
+ }
+
+ @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/src/main/java/ihl/processing/chemistry/LeadOvenGui.java b/src/main/java/ihl/processing/chemistry/LeadOvenGui.java new file mode 100644 index 0000000..72fb107 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LeadOvenGui.java @@ -0,0 +1,55 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+@SideOnly(Side.CLIENT)
+public class LeadOvenGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUILeadOven.png");
+ private LeadOvenContainer container;
+
+ 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) {
+ 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;
+ if (this.container.tileEntity.inputTank.getFluidAmount() > 0) {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.inputTank, 30, 19, 42, 66, zLevel,
+ par1, par2, x, y);
+ }
+ if (this.container.tileEntity.outputTank.getFluidAmount() > 0) {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.outputTank, 133, 19, 145, 66, zLevel,
+ par1, par2, x, y);
+ }
+ }
+
+ @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/src/main/java/ihl/processing/chemistry/LeadOvenTileEntity.java b/src/main/java/ihl/processing/chemistry/LeadOvenTileEntity.java new file mode 100644 index 0000000..95636ad --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LeadOvenTileEntity.java @@ -0,0 +1,286 @@ +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 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;
+import ic2.core.block.invslot.InvSlot.Access;
+import ic2.core.block.invslot.InvSlotConsumableFuel;
+import ic2.core.block.invslot.InvSlotConsumableLiquid;
+import ic2.core.block.invslot.InvSlotOutput;
+import ihl.processing.invslots.IHLInvSlotOutput;
+import ihl.processing.invslots.InvSlotConsumableLiquidIHL;
+import ihl.recipes.RecipeOutputItemStack;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLFluidTank;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTankInfo;
+import net.minecraftforge.fluids.IFluidHandler;
+
+public class LeadOvenTileEntity extends TileEntityInventory implements IHasGui, IFluidHandler {
+ public final InvSlotConsumableFuel fuelSlot;
+ public final ApparatusProcessableInvSlot inputSlot;
+ public final IHLInvSlotOutput outputSlot;
+ public final IHLFluidTank inputTank = new IHLFluidTank(1000);
+ public final IHLFluidTank outputTank = new IHLFluidTank(1000);
+ public final InvSlotConsumableLiquidIHL drainInputSlot;
+ public final InvSlotConsumableLiquidIHL fillInputSlot;
+ public final InvSlotOutput emptyFluidItemsSlot;
+ public final InvSlotConsumableLiquidIHL drainInputSlot2;
+ public final InvSlotConsumableLiquidIHL fillInputSlot2;
+ 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");
+
+ public LeadOvenTileEntity() {
+ super();
+ 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);
+ 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.drainInputSlot2 = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1,
+ InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain);
+ this.fillInputSlot2 = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1,
+ InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill);
+ this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 2);
+ }
+
+ public static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output) {
+ recipeManager.addRecipe(input, output);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound) {
+ super.readFromNBT(nbttagcompound);
+ this.fuel = nbttagcompound.getInteger("fuel");
+ this.maxFuel = nbttagcompound.getInteger("maxFuel");
+ this.progress = nbttagcompound.getShort("progress");
+ this.inputTank.readFromNBT(nbttagcompound.getCompoundTag("inputTank"));
+ this.outputTank.readFromNBT(nbttagcompound.getCompoundTag("outputTank"));
+ }
+
+ @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 inputTankTag = new NBTTagCompound();
+ this.inputTank.writeToNBT(inputTankTag);
+ nbttagcompound.setTag("inputTank", inputTankTag);
+ NBTTagCompound outputTankTag = new NBTTagCompound();
+ this.outputTank.writeToNBT(outputTankTag);
+ nbttagcompound.setTag("outputTank", outputTankTag);
+ }
+
+ @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();
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, inputTank);
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlot2, drainInputSlot2, emptyFluidItemsSlot, outputTank);
+ if (this.fuel <= 0 && this.canOperate()) {
+ this.fuel = this.maxFuel = this.fuelSlot.consumeFuel();
+ }
+
+ if (this.isBurning() && this.canOperate()) {
+ ++this.progress;
+
+ if (this.progress >= maxProgress) {
+ this.progress = 0;
+ this.operate();
+ }
+ } else {
+ this.progress = 0;
+ }
+
+ if (this.fuel > 0) {
+ --this.fuel;
+ }
+
+ if (this.getActive() != this.isBurning()) {
+ this.setActive(this.isBurning());
+ }
+ }
+
+ 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<LeadOvenTileEntity> 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 UniversalRecipeOutput getOutput() {
+ return LeadOvenTileEntity.recipeManager.getOutputFor(this.getInput());
+ }
+
+ @SuppressWarnings("rawtypes")
+ public List[] getInput() {
+ if (this.inputSlot.get(1) != null) {
+ return new List[] { this.inputTank.getFluidList(),
+ Arrays.asList(new ItemStack[] { this.inputSlot.get(0), this.inputSlot.get(1) }) };
+ }
+ return new List[] { this.inputTank.getFluidList(), Arrays.asList(new ItemStack[] { this.inputSlot.get() }) };
+ }
+
+ public void operate() {
+ UniversalRecipeInput rinput = LeadOvenTileEntity.recipeManager.getRecipeInput(getInput());
+ List<IRecipeInput> rinputItems = rinput.getItemInputs();
+ UniversalRecipeOutput routput = LeadOvenTileEntity.recipeManager.getOutputFor(getInput());
+ List<FluidStack> output2 = routput.getFluidOutputs();
+ if (!output2.isEmpty()) {
+ this.outputTank.fill(output2.get(0), true);
+ }
+ this.inputTank.drain(rinput.getFluidInputs(), true);
+ List<RecipeOutputItemStack> itemOutputs = routput.getItemOutputs();
+ if (itemOutputs != null && !itemOutputs.isEmpty()) {
+ this.outputSlot.add(itemOutputs);
+ }
+ for (int i = 0; i < rinputItems.size(); i++) {
+ this.inputSlot.consume(rinputItems.get(i));
+ }
+
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection from, int amount, boolean doDrain) {
+ switch (from) {
+ case UP:
+ return this.outputTank.drainLightest(amount, doDrain);
+ case NORTH:
+ return this.outputTank.drainLightest(amount, doDrain);
+ case SOUTH:
+ return this.outputTank.drainLightest(amount, doDrain);
+ case WEST:
+ return this.outputTank.drainLightest(amount, doDrain);
+ case EAST:
+ return this.outputTank.drainLightest(amount, doDrain);
+ case DOWN:
+ return this.outputTank.drain(amount, doDrain);
+ default:
+ return this.outputTank.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());
+ }
+
+ public static void addRecipe(UniversalRecipeInput input, FluidStack fluidStackWithSize) {
+ recipeManager.addRecipe(input, new UniversalRecipeOutput((new FluidStack[] { fluidStackWithSize }), null, 20));
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ public static void addRecipe(IRecipeInput recipeInputOreDict, FluidStack fluidStackOutput, ItemStack output) {
+ recipeManager.addRecipe(new UniversalRecipeInput(null, (new IRecipeInput[] { recipeInputOreDict })),
+ new UniversalRecipeOutput((new FluidStack[] { fluidStackOutput }), (new ItemStack[] { output }), 20));
+ }
+
+ public static void addRecipe(IRecipeInput input, ItemStack output) {
+ recipeManager.addRecipe(new UniversalRecipeInput(null, (new IRecipeInput[] { input })),
+ new UniversalRecipeOutput(null, (new ItemStack[] { output }), 20));
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection arg0, FluidStack fluidStack, boolean doDrain) {
+ if (outputTank.getFluid() != null && outputTank.getFluid().containsFluid(fluidStack)) {
+ return this.outputTank.drain(fluidStack, doDrain);
+ }
+ return null;
+ }
+
+ @Override
+ public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) {
+ return this.inputTank.fill(arg1, arg2);
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection arg0) {
+ return new FluidTankInfo[] { this.inputTank.getInfo() };
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/LoomContainer.java b/src/main/java/ihl/processing/chemistry/LoomContainer.java new file mode 100644 index 0000000..2d480ef --- /dev/null +++ b/src/main/java/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<LoomTileEntity> {
+
+ 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/src/main/java/ihl/processing/chemistry/LoomGui.java b/src/main/java/ihl/processing/chemistry/LoomGui.java new file mode 100644 index 0000000..4964687 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LoomGui.java @@ -0,0 +1,60 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import ic2.core.IC2;
+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/src/main/java/ihl/processing/chemistry/LoomModel.java b/src/main/java/ihl/processing/chemistry/LoomModel.java new file mode 100644 index 0000000..31c2724 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LoomModel.java @@ -0,0 +1,66 @@ +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +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/src/main/java/ihl/processing/chemistry/LoomTileEntity.java b/src/main/java/ihl/processing/chemistry/LoomTileEntity.java new file mode 100644 index 0000000..8432a2d --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LoomTileEntity.java @@ -0,0 +1,172 @@ +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 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 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;
+
+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<IRecipeInput> input1 = LoomTileEntity.recipeManager.getRecipeInput(getInput()).getItemInputs();
+ List<?> output1 = LoomTileEntity.recipeManager.getOutputFor(getInput()).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(input1.get(0));
+ }
+ }
+
+ @SuppressWarnings("rawtypes")
+ public List[] getInput()
+ {
+ return new List[] {null,Arrays.asList(new ItemStack[] {input.get()})};
+ }
+
+ public boolean canOperate()
+ {
+ if(LoomTileEntity.recipeManager.getOutputFor(getInput())==null) return false;
+ List<?> output1 = LoomTileEntity.recipeManager.getOutputFor(getInput()).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,new ItemStack[] {input}), new UniversalRecipeOutput(null, 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<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+
+}
diff --git a/src/main/java/ihl/processing/chemistry/PaperMachineContainer.java b/src/main/java/ihl/processing/chemistry/PaperMachineContainer.java new file mode 100644 index 0000000..01db6fd --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/PaperMachineContainer.java @@ -0,0 +1,41 @@ +package ihl.processing.chemistry;
+
+import java.util.List;
+
+import ic2.core.IC2;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraftforge.fluids.FluidStack;
+
+public class PaperMachineContainer extends BasicElectricMotorContainer<PaperMachineTileEntity> {
+
+ protected PaperMachineTileEntity tileEntity;
+ public int lastFluidAmount = -1;
+ public int lastNumberOfFluids = -1;
+ public short lastProgress = -1;
+ public short lastTemperature = -1;
+ public short lastEnergy = -1;
+ public List<FluidStack> fluidTankFluidList;
+
+ public PaperMachineContainer(EntityPlayer entityPlayer, PaperMachineTileEntity tileEntity1){
+ super(entityPlayer, tileEntity1);
+ this.tileEntity = tileEntity1;
+ fluidTankFluidList=this.tileEntity.getFluidTank().getFluidList();
+ 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));
+ }
+
+ @Override
+ public void detectAndSendChanges()
+ {
+ super.detectAndSendChanges();
+ if (this.tileEntity.getTankAmount() != this.lastFluidAmount || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids)
+ {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList");
+ }
+ this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank();
+ this.lastFluidAmount = this.tileEntity.getTankAmount();
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/PaperMachineGui.java b/src/main/java/ihl/processing/chemistry/PaperMachineGui.java new file mode 100644 index 0000000..8fea247 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/PaperMachineGui.java @@ -0,0 +1,79 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+@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);
+ }
+ }
+
+ @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/src/main/java/ihl/processing/chemistry/PaperMachineTileEntity.java b/src/main/java/ihl/processing/chemistry/PaperMachineTileEntity.java new file mode 100644 index 0000000..dddd306 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/PaperMachineTileEntity.java @@ -0,0 +1,261 @@ +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 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;
+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;
+
+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;
+
+ 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);
+ }
+
+ @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("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";
+ }
+
+ public float getRenderLiquidLevel()
+ {
+ return (float)this.fluidTank.getFluidAmount()/(float)this.fluidTank.getCapacity();
+ }
+
+ @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());
+ }
+
+ @Override
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ 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<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ public static void addRecipe(FluidStack fluidStackInput1, ItemStack itemStackOutput1)
+ {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] {fluidStackInput1}), null), new UniversalRecipeOutput(null, (new ItemStack[] {itemStackOutput1}),200));
+ }
+
+ public static void addSpecialConditionsRecipe(FluidStack fluidStackInput1, FluidStack fluidStackInput2, ItemStack itemStackInput, FluidStack fluidStackOutput, ItemStack itemStackOutput1, ItemStack itemStackOutput2)
+ {
+ addRecipe(new UniversalRecipeInput(new FluidStack[] {fluidStackInput1, fluidStackInput2}, (new ItemStack[] {itemStackInput})), new UniversalRecipeOutput((new FluidStack[] {fluidStackOutput}), (new ItemStack[] {itemStackOutput1, itemStackOutput2}),200, true));
+ }
+
+ public IHLFluidTank getFluidTank()
+ {
+ return this.fluidTank;
+ }
+
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/RefluxCondenserModel.java b/src/main/java/ihl/processing/chemistry/RefluxCondenserModel.java new file mode 100644 index 0000000..9cb2f2f --- /dev/null +++ b/src/main/java/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/src/main/java/ihl/processing/chemistry/RefluxCondenserTileEntity.java b/src/main/java/ihl/processing/chemistry/RefluxCondenserTileEntity.java new file mode 100644 index 0000000..83eb108 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/RefluxCondenserTileEntity.java @@ -0,0 +1,148 @@ +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 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<String> getNetworkedFields()
+ {
+ List<String> fields = new ArrayList<String>();
+ 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)
+ {
+ if(columnBottom!=null)
+ return columnBottom.getTankInfo(arg0);
+ else
+ return new FluidTankInfo[] {new FluidTankInfo(null, 8000)};
+ }
+
+}
diff --git a/src/main/java/ihl/processing/chemistry/SolarEvaporatorContainer.java b/src/main/java/ihl/processing/chemistry/SolarEvaporatorContainer.java new file mode 100644 index 0000000..4ecf44d --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/SolarEvaporatorContainer.java @@ -0,0 +1,112 @@ +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 SolarEvaporatorContainer extends ContainerBase<SolarEvaporatorTileEntity> {
+
+ protected SolarEvaporatorTileEntity tileEntity;
+ public int lastFluidAmount = -1;
+ public int lastFuel = -1;
+ public short lastProgress = -1;
+ private final static int height = 166;
+ public int lastNumberOfFluids = -1;
+ public int lastVisibleFluidID = -1;
+ public int lastVisibleFluidAmount = -1;
+
+ public SolarEvaporatorContainer(EntityPlayer entityPlayer, SolarEvaporatorTileEntity 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.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);
+ }
+ if (this.tileEntity.visibleFluidId != this.lastVisibleFluidID)
+ {
+ icrafting.sendProgressBarUpdate(this, 4, this.tileEntity.visibleFluidId);
+ }
+ if (this.tileEntity.visibleFluidAmount != this.lastVisibleFluidAmount)
+ {
+ icrafting.sendProgressBarUpdate(this, 5, this.tileEntity.visibleFluidAmount);
+ }
+ }
+
+ this.lastFluidAmount = this.tileEntity.getFluidTank().getFluidAmount();
+ this.lastFuel = this.tileEntity.fuel;
+ this.lastProgress = this.tileEntity.progress;
+ this.lastVisibleFluidID=this.tileEntity.visibleFluidId;
+ this.lastVisibleFluidAmount=this.tileEntity.visibleFluidAmount;
+ }
+
+ @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;
+ case 4:
+ this.tileEntity.visibleFluidId=value;
+ break;
+ case 5:
+ this.tileEntity.visibleFluidAmount=value;
+ break;
+
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/SolarEvaporatorGui.java b/src/main/java/ihl/processing/chemistry/SolarEvaporatorGui.java new file mode 100644 index 0000000..e97f9e0 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/SolarEvaporatorGui.java @@ -0,0 +1,78 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.util.DrawUtil;
+import ic2.core.util.GuiTooltipHelper;
+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;
+
+@SideOnly(Side.CLIENT)
+public class SolarEvaporatorGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl",
+ "textures/gui/GUISolarEvaporator.png");
+ private SolarEvaporatorContainer container;
+
+ public SolarEvaporatorGui(SolarEvaporatorContainer 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.getActive()) {
+ this.drawTexturedModalRect(9, 16, 176, 0, 14, 14);
+ }
+ 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/src/main/java/ihl/processing/chemistry/SolarEvaporatorTileEntity.java b/src/main/java/ihl/processing/chemistry/SolarEvaporatorTileEntity.java new file mode 100644 index 0000000..947a88a --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/SolarEvaporatorTileEntity.java @@ -0,0 +1,108 @@ +package ihl.processing.chemistry; + +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ihl.interfaces.IFluidTankVisual; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.EnumSkyBlock; + +public class SolarEvaporatorTileEntity extends EvaporatorTileEntity implements IFluidTankVisual { + public int visibleFluidId = -1; + public int visibleFluidAmount = 1; + + public SolarEvaporatorTileEntity(){ + super(); + this.fuelSlot = null; + this.maxProgress = 4500; + } + + @Override + public List<String> getNetworkedFields() + { + List<String> ret = super.getNetworkedFields(); + ret.add("visibleFluidId"); + ret.add("visibleFluidAmount"); + return ret; + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if(this.fluidTank.getFluid()!=null && (visibleFluidId!=this.fluidTank.getFluid().getFluid().getID() || visibleFluidAmount!=this.fluidTank.getFluidAmount())) + { + visibleFluidId = this.fluidTank.getFluid().getFluid().getID(); + visibleFluidAmount = this.fluidTank.getFluidAmount(); + IC2.network.get().updateTileEntityField(this, "visibleFluidId"); + IC2.network.get().updateTileEntityField(this, "visibleFluidAmount"); + } + else if(this.fluidTank.getFluid()==null && visibleFluidId!=-1) + { + visibleFluidId=-1; + IC2.network.get().updateTileEntityField(this, "visibleFluidId"); + } + } + @Override + public boolean isBurning() + { + return this.worldObj.getSkyBlockTypeBrightness(EnumSkyBlock.Sky, xCoord, yCoord, zCoord)>=15; + } + + @Override + public ContainerBase<? extends EvaporatorTileEntity> getGuiContainer(EntityPlayer entityPlayer) + { + return new SolarEvaporatorContainer(entityPlayer, this); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer entityPlayer, boolean isAdmin) + { + return new SolarEvaporatorGui(new SolarEvaporatorContainer(entityPlayer, this)); + } + + @Override + public short getFacing() + { + return 3; + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return false; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("solarEvaporator"); + } + + @Override + public int getVisibleFluidId() { + return this.visibleFluidId; + } + + @Override + public int getVisibleFluidAmount() { + return this.visibleFluidAmount; + } + + @Override + public float getRenderLiquidLevel() + { + return (float)this.visibleFluidAmount/(float)this.fluidTank.getCapacity()/2; + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } +} |
