From 0427ab89f1753a44b30cbc35ce021cbbdc845109 Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Thu, 10 Aug 2017 18:52:45 +0300 Subject: fix missing source folder --- .../processing/metallurgy/AchesonFurnaceGui.java | 46 +++ .../metallurgy/AchesonFurnanceContainer.java | 16 + .../metallurgy/AchesonFurnanceTileEntity.java | 101 ++++++ .../metallurgy/BasicElectricMotorTileEntity.java | 272 +++++++++++++++ .../ihl/processing/metallurgy/CoilerContainer.java | 65 ++++ .../java/ihl/processing/metallurgy/CoilerGui.java | 48 +++ .../ihl/processing/metallurgy/CoilerModel.java | 103 ++++++ .../ihl/processing/metallurgy/CoilerRender.java | 80 +++++ .../processing/metallurgy/CoilerTileEntity.java | 155 +++++++++ .../java/ihl/processing/metallurgy/Crucible.java | 366 ++++++++++++++++++++ .../processing/metallurgy/CrucibleContainer.java | 66 ++++ .../ihl/processing/metallurgy/CrucibleGui.java | 84 +++++ .../processing/metallurgy/CrucibleInventory.java | 126 +++++++ .../ihl/processing/metallurgy/CrucibleSlot.java | 18 + .../DetonationSprayingMachineContainer.java | 39 +++ .../metallurgy/DetonationSprayingMachineGui.java | 48 +++ .../metallurgy/DetonationSprayingMachineModel.java | 57 ++++ .../DetonationSprayingMachineRender.java | 61 ++++ .../DetonationSprayingMachineTileEntity.java | 198 +++++++++++ .../processing/metallurgy/ElectricEngineItem.java | 84 +++++ .../processing/metallurgy/ExtruderContainer.java | 75 ++++ .../ihl/processing/metallurgy/ExtruderGui.java | 49 +++ .../ihl/processing/metallurgy/ExtruderModel.java | 100 ++++++ .../processing/metallurgy/ExtruderTileEntity.java | 155 +++++++++ .../metallurgy/GasWeldingStationContainer.java | 99 ++++++ .../metallurgy/GasWeldingStationGui.java | 78 +++++ .../metallurgy/GasWeldingStationModel.java | 108 ++++++ .../metallurgy/GasWeldingStationTileEntity.java | 286 ++++++++++++++++ .../ihl/processing/metallurgy/IProductionLine.java | 12 + .../metallurgy/ImpregnatingMachineContainer.java | 105 ++++++ .../metallurgy/ImpregnatingMachineGui.java | 63 ++++ .../metallurgy/ImpregnatingMachineRender.java | 55 +++ .../metallurgy/ImpregnatingMachineTileEntity.java | 343 +++++++++++++++++++ .../processing/metallurgy/InjectionMoldBlock.java | 248 ++++++++++++++ .../metallurgy/InjectionMoldTileEntity.java | 201 +++++++++++ .../ihl/processing/metallurgy/LatheContainer.java | 72 ++++ .../java/ihl/processing/metallurgy/LatheGui.java | 51 +++ .../ihl/processing/metallurgy/LathePart1Model.java | 93 +++++ .../metallurgy/LathePart1TileEntity.java | 99 ++++++ .../ihl/processing/metallurgy/LathePart2Model.java | 87 +++++ .../metallurgy/LathePart2TileEntity.java | 104 ++++++ .../metallurgy/MachineBaseContainer.java | 74 ++++ .../metallurgy/MachineBaseTileEntity.java | 279 +++++++++++++++ .../processing/metallurgy/MuffleFurnaceGui.java | 48 +++ .../metallurgy/MuffleFurnanceContainer.java | 16 + .../metallurgy/MuffleFurnanceTileEntity.java | 119 +++++++ .../metallurgy/RollingMachineContainer.java | 75 ++++ .../processing/metallurgy/RollingMachineGui.java | 50 +++ .../metallurgy/RollingMachinePart1Model.java | 97 ++++++ .../metallurgy/RollingMachinePart1TileEntity.java | 149 ++++++++ .../metallurgy/RollingMachinePart2Model.java | 42 +++ .../metallurgy/RollingMachinePart2TileEntity.java | 104 ++++++ .../metallurgy/RollingMachineRender.java | 81 +++++ .../VulcanizationExtrudingMoldModel.java | 54 +++ .../VulcanizationExtrudingMoldTileEntity.java | 256 ++++++++++++++ .../processing/metallurgy/WireMillContainer.java | 113 ++++++ .../ihl/processing/metallurgy/WireMillGui.java | 68 ++++ .../processing/metallurgy/WireMillTileEntity.java | 378 +++++++++++++++++++++ .../metallurgy/WoodenRollingMachineContainer.java | 77 +++++ .../metallurgy/WoodenRollingMachineGui.java | 60 ++++ .../metallurgy/WoodenRollingMachinePart1Model.java | 122 +++++++ .../WoodenRollingMachinePart1TileEntity.java | 158 +++++++++ .../metallurgy/WoodenRollingMachinePart2Model.java | 44 +++ .../WoodenRollingMachinePart2TileEntity.java | 104 ++++++ .../metallurgy/WoodenRollingMachineRender.java | 91 +++++ 65 files changed, 7175 insertions(+) create mode 100644 src/main/java/ihl/processing/metallurgy/AchesonFurnaceGui.java create mode 100644 src/main/java/ihl/processing/metallurgy/AchesonFurnanceContainer.java create mode 100644 src/main/java/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/CoilerContainer.java create mode 100644 src/main/java/ihl/processing/metallurgy/CoilerGui.java create mode 100644 src/main/java/ihl/processing/metallurgy/CoilerModel.java create mode 100644 src/main/java/ihl/processing/metallurgy/CoilerRender.java create mode 100644 src/main/java/ihl/processing/metallurgy/CoilerTileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/Crucible.java create mode 100644 src/main/java/ihl/processing/metallurgy/CrucibleContainer.java create mode 100644 src/main/java/ihl/processing/metallurgy/CrucibleGui.java create mode 100644 src/main/java/ihl/processing/metallurgy/CrucibleInventory.java create mode 100644 src/main/java/ihl/processing/metallurgy/CrucibleSlot.java create mode 100644 src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineContainer.java create mode 100644 src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineGui.java create mode 100644 src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineModel.java create mode 100644 src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineRender.java create mode 100644 src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineTileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/ElectricEngineItem.java create mode 100644 src/main/java/ihl/processing/metallurgy/ExtruderContainer.java create mode 100644 src/main/java/ihl/processing/metallurgy/ExtruderGui.java create mode 100644 src/main/java/ihl/processing/metallurgy/ExtruderModel.java create mode 100644 src/main/java/ihl/processing/metallurgy/ExtruderTileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/GasWeldingStationContainer.java create mode 100644 src/main/java/ihl/processing/metallurgy/GasWeldingStationGui.java create mode 100644 src/main/java/ihl/processing/metallurgy/GasWeldingStationModel.java create mode 100644 src/main/java/ihl/processing/metallurgy/GasWeldingStationTileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/IProductionLine.java create mode 100644 src/main/java/ihl/processing/metallurgy/ImpregnatingMachineContainer.java create mode 100644 src/main/java/ihl/processing/metallurgy/ImpregnatingMachineGui.java create mode 100644 src/main/java/ihl/processing/metallurgy/ImpregnatingMachineRender.java create mode 100644 src/main/java/ihl/processing/metallurgy/ImpregnatingMachineTileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/InjectionMoldBlock.java create mode 100644 src/main/java/ihl/processing/metallurgy/InjectionMoldTileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/LatheContainer.java create mode 100644 src/main/java/ihl/processing/metallurgy/LatheGui.java create mode 100644 src/main/java/ihl/processing/metallurgy/LathePart1Model.java create mode 100644 src/main/java/ihl/processing/metallurgy/LathePart1TileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/LathePart2Model.java create mode 100644 src/main/java/ihl/processing/metallurgy/LathePart2TileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/MachineBaseContainer.java create mode 100644 src/main/java/ihl/processing/metallurgy/MachineBaseTileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/MuffleFurnaceGui.java create mode 100644 src/main/java/ihl/processing/metallurgy/MuffleFurnanceContainer.java create mode 100644 src/main/java/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/RollingMachineContainer.java create mode 100644 src/main/java/ihl/processing/metallurgy/RollingMachineGui.java create mode 100644 src/main/java/ihl/processing/metallurgy/RollingMachinePart1Model.java create mode 100644 src/main/java/ihl/processing/metallurgy/RollingMachinePart1TileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/RollingMachinePart2Model.java create mode 100644 src/main/java/ihl/processing/metallurgy/RollingMachinePart2TileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/RollingMachineRender.java create mode 100644 src/main/java/ihl/processing/metallurgy/VulcanizationExtrudingMoldModel.java create mode 100644 src/main/java/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/WireMillContainer.java create mode 100644 src/main/java/ihl/processing/metallurgy/WireMillGui.java create mode 100644 src/main/java/ihl/processing/metallurgy/WireMillTileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/WoodenRollingMachineContainer.java create mode 100644 src/main/java/ihl/processing/metallurgy/WoodenRollingMachineGui.java create mode 100644 src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart1Model.java create mode 100644 src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart2Model.java create mode 100644 src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart2TileEntity.java create mode 100644 src/main/java/ihl/processing/metallurgy/WoodenRollingMachineRender.java (limited to 'src/main/java/ihl/processing/metallurgy') diff --git a/src/main/java/ihl/processing/metallurgy/AchesonFurnaceGui.java b/src/main/java/ihl/processing/metallurgy/AchesonFurnaceGui.java new file mode 100644 index 0000000..6f8238a --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/AchesonFurnaceGui.java @@ -0,0 +1,46 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class AchesonFurnaceGui extends GuiContainer { + protected static final ResourceLocation achesonFurnaceBackground = new ResourceLocation("ihl", "textures/gui/GUIAchesonFurnace.png"); + private MachineBaseContainer container; + + public AchesonFurnaceGui(MachineBaseContainer machineBaseContainer) { + super(machineBaseContainer); + this.container=machineBaseContainer; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(achesonFurnaceBackground); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) + { + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(8, 6 + 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(70,34, 197, 0, i1 + 1, 13); + } + fontRendererObj.drawStringWithShadow(StatCollector.translateToLocal("ihl.gui.achesonFurnance"), 40, 12, 16768125); + } + + @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(achesonFurnaceBackground); + 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/metallurgy/AchesonFurnanceContainer.java b/src/main/java/ihl/processing/metallurgy/AchesonFurnanceContainer.java new file mode 100644 index 0000000..2580c6c --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/AchesonFurnanceContainer.java @@ -0,0 +1,16 @@ +package ihl.processing.metallurgy; + +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; + +public class AchesonFurnanceContainer extends MachineBaseContainer { + + public AchesonFurnanceContainer(EntityPlayer entityPlayer, + AchesonFurnanceTileEntity tileEntity1) { + super(entityPlayer, tileEntity1); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 40, 22)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 1, 40, 40)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 98, 32)); + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java b/src/main/java/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java new file mode 100644 index 0000000..75efd70 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java @@ -0,0 +1,101 @@ +package ihl.processing.metallurgy; + +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 ihl.IHLMod; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.recipes.RecipeOutputItemStack; +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 AchesonFurnanceTileEntity extends MachineBaseTileEntity { + + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("achesonfurnace"); + public final IHLInvSlotOutput outputSlot; + + public AchesonFurnanceTileEntity() { + super(2); + this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 1); + } + + public static void addRecipe(IRecipeInput input1, IRecipeInput input2, String output1) { + recipeManager.addRecipe(new UniversalRecipeInput(null, new IRecipeInput[] { input1, input2 }), + new UniversalRecipeOutput(null, new ItemStack[] { IHLUtils.getThisModItemStack(output1) }, 20)); + } + + @Override + public String getStartSoundFile() { + return "Machines/Electro Furnace/ElectroFurnaceLoop.ogg"; + } + + @Override + public String getLoopSoundFile() { + return null; + } + + @Override + public String getStopSoundFile() { + return null; + } + + @Override + public String getInventoryName() { + return "AchesonFurnance"; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new AchesonFurnaceGui(new AchesonFurnanceContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new AchesonFurnanceContainer(player, this); + } + + @Override + public void operate() { + ItemStack crucible = input.getItemStack(IHLMod.crucible); + if (crucible != null) { + ((Crucible) crucible.getItem()).processContent(crucible, this); + return; + } + List output = recipeManager + .getOutputFor(getInput()).getItemOutputs(); + List rinput = recipeManager.getRecipeInput(getInput()).getItemInputs(); + for (int i = 0; i < rinput.size(); i++) { + this.input.consume(rinput.get(i)); + } + this.outputSlot.add(output); + } + + @Override + public boolean canOperate() { + return this.getOutput() != null; + } + + @Override + public List[] getInput() { + return new List[] { null, this.input.getItemStackList() }; + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public UniversalRecipeOutput getOutput() { + return AchesonFurnanceTileEntity.recipeManager.getOutputFor(this.getInput()); + } +} diff --git a/src/main/java/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java b/src/main/java/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java new file mode 100644 index 0000000..a546b0a --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java @@ -0,0 +1,272 @@ +package ihl.processing.metallurgy; + +import java.util.Iterator; +import java.util.List; + +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergySink; +import ic2.api.network.INetworkClientTileEntityEventListener; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlot.Access; +import ihl.IHLMod; +import ihl.flexible_cable.FlexibleCableHolderBaseTileEntity; +import ihl.flexible_cable.NodeEntity; +import ihl.processing.invslots.InvSlotUpgradeIHL; +import ihl.utils.IHLInvSlotDischarge; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; + +public abstract class BasicElectricMotorTileEntity extends FlexibleCableHolderBaseTileEntity + implements IHasGui, INetworkClientTileEntityEventListener, IEnergySink { + + public final IHLInvSlotDischarge dischargeSlot; + public final InvSlotUpgradeIHL upgradeSlot; + public short progress; + protected short operationLength = 6000; + protected double energyConsume = 1d; + public double energy = 0d; + public int maxStorage = 128; + private boolean addedToEnergyNet = false; + + public BasicElectricMotorTileEntity() { + super(); + energyConsume = IHLMod.config.machineryEnergyConsume/100d; + dischargeSlot = new IHLInvSlotDischarge(this, 1, Access.I, 4, InvSlot.InvSide.BOTTOM); + upgradeSlot = new InvSlotUpgradeIHL(this, 1, Access.I, 4, InvSlot.InvSide.BOTTOM); + } + + @Override + public String getInventoryName() { + return "Lathe"; + } + + public boolean enableUpdateEntity() { + return IC2.platform.isSimulating(); + } + + @Override + public void onLoaded() { + super.onLoaded(); + if (IC2.platform.isSimulating() && !this.addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + } + + @Override + public void onUnloaded() { + if (IC2.platform.isSimulating() && this.addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + + super.onUnloaded(); + } + + @SuppressWarnings("unchecked") + @Override + public void setFacing(short facing1) { + double d = 0.3D; + double f = -0.1D; + if (IC2.platform.isSimulating() && this.addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + double range = 2D; + AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(connectionX - range, connectionY - range, + connectionZ - range, connectionX + range, connectionY + range, connectionZ + range); + List nodeList = worldObj.getEntitiesWithinAABB(NodeEntity.class, searchArea); + super.setFacing(facing1); + switch (getFacing()) { + case 4: + setConnectionX(this.xCoord + 0.5D); + setConnectionY(this.yCoord + d); + setConnectionZ(this.zCoord + 1D - f); + break; + case 5: + setConnectionX(this.xCoord + 0.5D); + setConnectionY(this.yCoord + d); + setConnectionZ(this.zCoord + f); + break; + case 2: + setConnectionX(this.xCoord + 1D - f); + setConnectionY(this.yCoord + d); + setConnectionZ(this.zCoord + 0.5D); + break; + case 3: + setConnectionX(this.xCoord + f); + setConnectionY(this.yCoord + d); + setConnectionZ(this.zCoord + 0.5D); + break; + default: + setConnectionX(this.xCoord + 1D - f); + setConnectionY(this.yCoord + d); + setConnectionZ(this.zCoord + 0.5D); + break; + + } + if (!nodeList.isEmpty()) { + Iterator ei = nodeList.iterator(); + while (ei.hasNext()) { + NodeEntity ne = ei.next(); + if ((ne.prevAnchorEntity == null || ne.nextAnchorEntity == null) + && this.cableListContains(ne.getChainUniqueID())) { + ne.setVirtualNodePos(connectionX, connectionY, connectionZ); + } + } + } + if (IC2.platform.isSimulating() && !this.addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + } + + @Override + public double getDemandedEnergy() { + if(this.getMaxStorage() - this.energy <= 1d) + { + return 0d; + } + return this.getMaxStorage() - this.energy; + } + + @Override + public int getSinkTier() { + return 4; + } + + @Override + public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { + if (this.energy < this.getMaxStorage()) { + this.energy += amount; + return 0.0D; + } else { + return amount; + } + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing() != (short) side; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setShort("progress", this.progress); + nbt.setDouble("energy", this.energy); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + this.progress = nbt.getShort("progress"); + this.energy = nbt.getDouble("energy"); + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) { + switch (event) { + case 0: + break; + } + } + + public abstract void operate(); + + @Override + public void updateEntityServer() { + if (this.getDemandedEnergy() > 1.0D) { + double amount = this.dischargeSlot.discharge(this.getDemandedEnergy(), false); + this.energy += amount; + } + if (this.gridID != -1 && this.getGrid().energy > 0D && this.energy < this.getMaxStorage()) { + this.energy += energyConsume * 10D; + this.getGrid().drawEnergy(energyConsume * 10D, this); + } + if (this.canOperate() && this.energy >= this.energyConsume) { + this.energy -= this.energyConsume * this.upgradeSlot.getPowerConsumtionMultiplier(); + if (this.progress == 0) { + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + this.progress+=(short)(10*this.upgradeSlot.getProgressMultiplier()); + 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; + } + } + + } + + private double getMaxStorage() { + return maxStorage+this.upgradeSlot.getAdditionalEnergyStorage(); + } + + public abstract List[] getInput(); + + public abstract boolean canOperate(); + + @Override + public void onGuiClosed(EntityPlayer arg0) { + } + + public int getEnergy() { + return (int) this.energy; + } + + public int getGUIEnergy(int i) { + if (this.energy < Float.MAX_VALUE) { + return Math.round((float) (this.energy / this.getMaxStorage() * i)); + } else { + return Math.round((float) (this.energy / this.getMaxStorage()) * i); + } + } + + public int gaugeProgressScaled(int i) { + return this.progress * i / this.operationLength; + } + + public void setEnergy(int value) { + this.energy = value; + } + + @Override + public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { + return true; + } + + @Override + public double getMaxAllowableVoltage() { + return 64000D; + } + + @Override + public double getEnergyAmountThisNodeWant() { + return this.getMaxStorage()-this.energy; + } + + public double drawEnergyToGrid(double amount) { + return 0d; + } + + @Override + public void injectEnergyInThisNode(double amount, double voltage) { + this.energy += amount; + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/CoilerContainer.java b/src/main/java/ihl/processing/metallurgy/CoilerContainer.java new file mode 100644 index 0000000..710a708 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CoilerContainer.java @@ -0,0 +1,65 @@ +package ihl.processing.metallurgy; + +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 CoilerContainer extends ContainerBase { + + public CoilerTileEntity tileEntity; + private short lastEnergy = -1; + private final static int height=166; + + public CoilerContainer(EntityPlayer entityPlayer, + CoilerTileEntity 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.output, 0, 69, 22)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.dischargeSlot,0, 22, 55)); + } + + @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.getEnergy() != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy()); + } + } + this.lastEnergy = (short) this.tileEntity.getEnergy(); + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + + switch (index) + { + case 1: + this.tileEntity.setEnergy(value); + break; + } + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/CoilerGui.java b/src/main/java/ihl/processing/metallurgy/CoilerGui.java new file mode 100644 index 0000000..b635506 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CoilerGui.java @@ -0,0 +1,48 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +import ihl.utils.IHLRenderUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class CoilerGui extends GuiContainer { + + private CoilerContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUICoiler.png"); + + public CoilerGui(CoilerContainer 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); + fontRendererObj.drawStringWithShadow(StatCollector.translateToLocal("ihl.gui.coiler"), 40, 12, 16768125); + this.mc.renderEngine.bindTexture(tex); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) + { + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(39, 55 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + 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); + } +} diff --git a/src/main/java/ihl/processing/metallurgy/CoilerModel.java b/src/main/java/ihl/processing/metallurgy/CoilerModel.java new file mode 100644 index 0000000..9c1721e --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CoilerModel.java @@ -0,0 +1,103 @@ +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class CoilerModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer Belt; + IHLModelRenderer Belt2; + IHLModelRenderer CoilRotating; + IHLModelRenderer Coil; + + public CoilerModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape2", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("RotatingPart2.PipeN1", 0, 0); + setTextureOffset("RotatingPart2.PipeN7", 49, 23); + setTextureOffset("RotatingPart2.PipeN4", 0, 17); + setTextureOffset("RotatingPart2.PipeN14", 0, 19); + setTextureOffset("RotatingPart2.PipeN17", 0, 17); + 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("CoilRotating.PipeN15", 22, 19); + setTextureOffset("Coil.Shape1", 22, 30); + + 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("Shape2", -5.5F, -1F, 7F, 5, 8, 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("PipeN1", -0.5F, -0.5F, 0F, 1, 1, 14, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN7", -2.5F, -2.5F, -1F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN4", -4F, -4F, 2F, 8, 8, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN14", -4F, -4F, 12F, 8, 8, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN17", -1F, -1F, 3F, 2, 2, 9, 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); + CoilRotating = new IHLModelRenderer(this, "CoilRotating"); + CoilRotating.setRotationPoint(-3F, 18F, -7F); + setRotation(CoilRotating, 0F, 0F, 0F); + CoilRotating.mirror = true; + CoilRotating.addTube("PipeN15", -2F, -2F, 3F, 4, 4, 9, 0F,1F,ForgeDirection.NORTH); + Coil = new IHLModelRenderer(this, "Coil"); + Coil.setRotationPoint(-0.25F, 16F, 0F); + setRotation(Coil, 0F, 0F, -0.2F); + Coil.mirror = true; + Coil.addTube("Shape1", -8F, -0.25F, -0.5F, 5, 1, 1, 0F,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/metallurgy/CoilerRender.java b/src/main/java/ihl/processing/metallurgy/CoilerRender.java new file mode 100644 index 0000000..26ee32f --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CoilerRender.java @@ -0,0 +1,80 @@ +package ihl.processing.metallurgy; +import org.lwjgl.opengl.GL11; + +import ic2.api.tile.IWrenchable; +import ihl.IHLModInfo; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; + +public class CoilerRender extends TileEntitySpecialRenderer{ +private CoilerModel model = new CoilerModel(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png"); +private final float scale=1F/16F; + + public CoilerRender() {} + + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par8) + { + int rotation = 0; + if(tile.getWorldObj() != null) + { + switch (((IWrenchable)tile).getFacing()) + { + case 2: + rotation = 0; + break; + case 5: + rotation = 1; + break; + case 3: + rotation = 2; + break; + case 4: + rotation = 3; + break; + default: + rotation = 0; + } + } + else + { + return; + } + CoilerTileEntity cte = (CoilerTileEntity)tile; + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F); + + bindTexture(tex); + model.Base.render(scale); + model.Belt.render(scale); + model.Belt2.render(scale); + if(cte.getActive()) + { + model.Coil.render(scale); + model.CoilRotating.rotateAngleZ+=0.02F; + model.CoilRotating.render(scale); + model.RotatingPart2.rotateAngleZ+=0.02F; + model.MotorPart1.rotateAngleZ+=0.03F; + model.MotorPart1.render(scale); + model.MotorPart2.render(scale); + } + else + { + + if(cte.hasCoil) + { + model.CoilRotating.render(scale); + } + model.MotorPart1.render(scale); + model.MotorPart2.render(scale); + } + model.RotatingPart2.render(scale); + GL11.glPopMatrix(); //end + + } +} \ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/CoilerTileEntity.java b/src/main/java/ihl/processing/metallurgy/CoilerTileEntity.java new file mode 100644 index 0000000..3853a0e --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CoilerTileEntity.java @@ -0,0 +1,155 @@ +package ihl.processing.metallurgy; + +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.InvSlotOutput; +import ihl.interfaces.IWire; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public class CoilerTileEntity extends BasicElectricMotorTileEntity implements IProductionLine{ + + public final InvSlotOutput output; + private int activeTimer=0; + public boolean hasCoil=false; + + public CoilerTileEntity() + { + super(); + this.output = new InvSlotOutput(this, "output", 1, 1); + } + + + @Override + public String getInventoryName() { + return "Coiler"; + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("hasCoil"); + return fields; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("coiler"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new CoilerGui(new CoilerContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) + { + return new CoilerContainer(player, this); + } + + @Override + public boolean canOperate() + { + return false; + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if(activeTimer>0) + { + activeTimer--; + } + else + { + setActive(false); + } + if(this.output.isEmpty() && hasCoil==true) + { + this.hasCoil=false; + IC2.network.get().updateTileEntityField(this, "hasCoil"); + } + else if(!this.output.isEmpty() && hasCoil==false) + { + this.hasCoil=true; + IC2.network.get().updateTileEntityField(this, "hasCoil"); + } + } + + @Override + public void operate() + {} + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public List[] getInput() + { + return null; + } + + @Override + public boolean canProcess(ItemStack cable) { + if(this.energy>1D && cable.getItem() instanceof IWire) + { + if(this.output.isEmpty()) + { + return true; + } + else if(this.output.get().getItem() instanceof IWire) + { + return ((IWire)this.output.get().getItem()).isSameWire(this.output.get(), cable); + } + else + { + return this.output.get().isItemEqual(cable); + } + } + return false; + } + + + @Override + public void process(ItemStack cable) { + if(cable.getItem() instanceof IWire) + { + this.energy-=1D; + if(this.output.isEmpty()) + { + setActive(true); + activeTimer=800; + this.output.put(cable); + this.hasCoil=true; + IC2.network.get().updateTileEntityField(this, "hasCoil"); + } + else + { + setActive(true); + activeTimer=800; + int length = this.output.get().stackTagCompound.getInteger(((IWire)this.output.get().getItem()).getTag()); + int fullLength = this.output.get().stackTagCompound.getInteger(((IWire)this.output.get().getItem()).getTagSecondary()); + int lengthToAdd = cable.stackTagCompound.getInteger(((IWire)cable.getItem()).getTag()); + int fullLengthToAdd = cable.stackTagCompound.getInteger(((IWire)cable.getItem()).getTagSecondary()); + this.output.get().stackTagCompound.setInteger(((IWire)this.output.get().getItem()).getTag(), length+lengthToAdd); + this.output.get().stackTagCompound.setInteger(((IWire)this.output.get().getItem()).getTagSecondary(),fullLength+fullLengthToAdd); + } + } + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/Crucible.java b/src/main/java/ihl/processing/metallurgy/Crucible.java new file mode 100644 index 0000000..220b505 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/Crucible.java @@ -0,0 +1,366 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +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.IItemHudInfo; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputOreDict; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.item.IHandHeldInventory; +import ic2.core.util.LiquidUtil; +import ic2.core.util.StackUtil; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; +import net.minecraftforge.fluids.IFluidHandler; + +public class Crucible extends Item implements IHandHeldInventory, IFluidContainerItem, IItemHudInfo{ + + public int capacity=864; + private String itemName; + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("crucible"); + + @SideOnly(Side.CLIENT) + private IIcon iconHot; + + public Crucible() { + super(); + this.itemName="crucible"; + this.setUnlocalizedName(itemName); + GameRegistry.registerItem(this, this.itemName); + this.setCreativeTab(IHLCreativeTab.tab); + this.maxStackSize=1; + this.setCreativeTab(IHLCreativeTab.tab); + this.setMaxDamage(0); + } + + public static void addRecipe(String string, FluidStack output) + { + recipeManager.addRecipe(new UniversalRecipeInput(null, new IRecipeInput[] {new RecipeInputOreDict(string)}), new UniversalRecipeOutput(new FluidStack[] {output},null,20)); + } + + @Override + public IHasGui getInventory(EntityPlayer entityPlayer, ItemStack itemStack) + { + return new CrucibleInventory(entityPlayer, itemStack); + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) + { + if (IC2.platform.isSimulating()) + { + IC2.platform.launchGui(entityPlayer, this.getInventory(entityPlayer, itemStack)); + } + return itemStack; + } + + /** + * allows items to add custom lines of information to the mouseover description + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean b) + { + super.addInformation(itemStack, player, info, b); + FluidStack fs = this.getFluid(itemStack); + + if (fs != null) + { + info.add("< " + FluidRegistry.getFluidName(fs) + ", " + fs.amount + " mB >"); + } + else + { + info.add(StatCollector.translateToLocal("ic2.item.FluidContainer.Empty")); + } + } + + @Override + public List getHudInfo(ItemStack itemStack) + { + LinkedList info = new LinkedList(); + FluidStack fs = this.getFluid(itemStack); + + if (fs != null) + { + info.add("< " + FluidRegistry.getFluidName(fs) + ", " + fs.amount + " mB >"); + } + else + { + info.add(StatCollector.translateToLocal("ic2.item.FluidContainer.Empty")); + } + + return info; + } + + @Override + public FluidStack getFluid(ItemStack stack) + { + NBTTagCompound nbtTagCompound = StackUtil.getOrCreateNbtData(stack); + NBTTagCompound fluidTag = nbtTagCompound.getCompoundTag("Fluid"); + return FluidStack.loadFluidStackFromNBT(fluidTag); + } + + public boolean isEmpty(ItemStack stack) + { + return this.getFluid(stack) == null; + } + + @Override + public int getCapacity(ItemStack container) + { + return this.capacity; + } + + public boolean canfill(Fluid var1) + { + return true; + } + + public ItemStack processContent(ItemStack itemStack, IInventory inventoryContainer) + { + CrucibleInventory inventory = new CrucibleInventory(inventoryContainer, itemStack); + ItemStack content = inventory.getStackInSlot(0); + if(content!=null) + { + UniversalRecipeOutput routput = recipeManager.getOutputFor(null, Arrays.asList(new ItemStack [] {content})); + if(routput!=null && !routput.getFluidOutputs().isEmpty()) + { + FluidStack fluidStack = routput.getFluidOutputs().get(0).copy(); + fluidStack.amount *= content.stackSize; + itemStack.stackTagCompound = new NBTTagCompound(); + this.fill(itemStack, fluidStack, true); + return itemStack; + } + } + return itemStack; + } + + @Override + public int fill(ItemStack stack, FluidStack resource, boolean doFill) + { + if (stack.stackSize != 1) + { + return 0; + } + else if (resource == null) + { + return 0; + } + else if (!this.canfill(resource.getFluid())) + { + return 0; + } + else + { + NBTTagCompound nbtTagCompound = StackUtil.getOrCreateNbtData(stack); + NBTTagCompound fluidTag = nbtTagCompound.getCompoundTag("Fluid"); + FluidStack fs = FluidStack.loadFluidStackFromNBT(fluidTag); + + if (fs == null) + { + fs = new FluidStack(resource, 0); + } + + if (!fs.isFluidEqual(resource)) + { + return 0; + } + else + { + int amount = Math.min(this.capacity - fs.amount, resource.amount); + + if (doFill && amount > 0) + { + fs.amount += amount; + fs.writeToNBT(fluidTag); + nbtTagCompound.setTag("Fluid", fluidTag); + if(fs.getFluid().getTemperature()>900)stack.setItemDamage(1); + } + + return amount; + } + } + } + + @Override + public FluidStack drain(ItemStack stack, int maxDrain, boolean doDrain) + { + if (stack.stackSize != 1) + { + return null; + } + else + { + NBTTagCompound nbtTagCompound = StackUtil.getOrCreateNbtData(stack); + NBTTagCompound fluidTag = nbtTagCompound.getCompoundTag("Fluid"); + FluidStack fs = FluidStack.loadFluidStackFromNBT(fluidTag); + + if (fs == null) + { + return null; + } + else + { + maxDrain = Math.min(fs.amount, maxDrain); + + if (doDrain) + { + fs.amount -= maxDrain; + + if (fs.amount <= 0) + { + nbtTagCompound.removeTag("Fluid"); + stack.setItemDamage(0); + } + else + { + fs.writeToNBT(fluidTag); + nbtTagCompound.setTag("Fluid", fluidTag); + } + } + + return new FluidStack(fs, maxDrain); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) + { + itemIcon=register.registerIcon(IHLModInfo.MODID + ":crucible"); + iconHot=register.registerIcon(IHLModInfo.MODID + ":crucibleHot"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int meta) + { + switch(meta) + { + case 0: + return this.itemIcon; + case 1: + return this.iconHot; + default: + return this.itemIcon; + } + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) + { + if (!IC2.platform.isSimulating()) + { + return false; + } + else if (this.interactWithTank(stack, player, world, x, y, z, side)) + { + return true; + } + return false; + } + + + private boolean interactWithTank(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side) + { + if (!IC2.platform.isSimulating()) + { + return false; + } + else + { + TileEntity te = world.getTileEntity(x, y, z); + + if (!(te instanceof IFluidHandler)) + { + return false; + } + else + { + IFluidHandler handler = (IFluidHandler)te; + ForgeDirection dir = ForgeDirection.getOrientation(side); + FluidStack fs = this.getFluid(stack); + int amount; + + if (fs != null && (!player.isSneaking() || fs.amount >= this.capacity)) + { + amount = handler.fill(dir, fs, false); + + if (amount <= 0) + { + return false; + } + else + { + fs = LiquidUtil.drainContainerStack(stack, player, amount, false); + + if (fs != null && fs.amount > 0) + { + handler.fill(dir, fs, true); + return true; + } + else + { + return false; + } + } + } + else + { + amount = fs == null ? this.capacity : this.capacity - fs.amount; + FluidStack input = handler.drain(dir, amount, false); + + if (input != null && input.amount > 0) + { + amount = LiquidUtil.fillContainerStack(stack, player, input, false); + + if (amount <= 0) + { + return false; + } + else + { + handler.drain(dir, amount, true); + return true; + } + } + else + { + return false; + } + } + } + } + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/CrucibleContainer.java b/src/main/java/ihl/processing/metallurgy/CrucibleContainer.java new file mode 100644 index 0000000..20ec65e --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CrucibleContainer.java @@ -0,0 +1,66 @@ +package ihl.processing.metallurgy; + +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.util.StackUtil; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class CrucibleContainer extends ContainerBase +{ + public CrucibleInventory box; + public CrucibleContainer(EntityPlayer entityPlayer, CrucibleInventory box) + { + super(box); + this.box = box; + int col; + if(((Crucible)this.box.thisItemStack.getItem()).isEmpty(this.box.thisItemStack)) + { + this.addSlotToContainer(new CrucibleSlot(this.box, 0, 81, 42)); + } + 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, 84 + col * 18)); + } + } + + for (col = 0; col < 9; ++col) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, 142)); + } + } + + @Override + public ItemStack slotClick(int slot, int button, int par3, EntityPlayer player) + { + if (player instanceof EntityPlayerMP && IC2.platform.isSimulating() && slot == -999 && (button == 0 || button == 1)) + { + ItemStack stack = player.inventory.getItemStack(); + + if (stack != null) + { + StackUtil.getOrCreateNbtData(stack); + + if (this.box.isThisContainer(stack)) + { + ((EntityPlayerMP)player).closeScreen(); + } + } + } + return super.slotClick(slot, button, par3, player); + } + + /** + * Called when the container is closed. + */ + @Override + public void onContainerClosed(EntityPlayer entityPlayer) + { + this.box.onGuiClosed(entityPlayer); + super.onContainerClosed(entityPlayer); + } +} diff --git a/src/main/java/ihl/processing/metallurgy/CrucibleGui.java b/src/main/java/ihl/processing/metallurgy/CrucibleGui.java new file mode 100644 index 0000000..f05e7bb --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CrucibleGui.java @@ -0,0 +1,84 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +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.item.ItemStack; +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; + +public class CrucibleGui extends GuiContainer +{ + public CrucibleContainer container; + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUICrucible.png"); + private static final String title = StatCollector.translateToLocal("item.crucible.name"); + + public CrucibleGui(CrucibleContainer container1) + { + super(container1); + this.container = container1; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + fontRendererObj.drawString(title, 68, 0, 6171880); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + @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); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.mc.renderEngine.bindTexture(background); + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + if(this.getItemStack().getItemDamage()==1) + { + this.drawTexturedModalRect(x+67, y+26, 198, 52, 58, 39); + } + FluidStack fluidStack = this.getItemInstance().getFluid(this.getItemStack()); + if (fluidStack!=null && fluidStack.amount > 0) + { + Fluid fluid = fluidStack.getFluid(); + if(fluid!=null) + { + IIcon fluidIcon = fluid.getIcon(); + if (fluidIcon != null) + { + this.mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + int liquidHeight = fluidStack.amount*20/getItemInstance().capacity; + DrawUtil.drawRepeated(fluidIcon, x+71, y+ 41 + 20 - liquidHeight, 35.0D, liquidHeight, this.zLevel); + } + } + String tooltip = StatCollector.translateToLocal(fluidStack.getFluid().getName()) + ": " + fluidStack.amount + "mB"; + GuiTooltipHelper.drawAreaTooltip(par2, par3, tooltip, x-16, y+10, x+16, y+29); + } + this.mc.renderEngine.bindTexture(background); + if(this.getItemStack().getItemDamage()==1) + { + this.drawTexturedModalRect(x+68, y+40, 198, 26, 58, 26); + } + else + { + this.drawTexturedModalRect(x+68, y+40, 198, 0, 58, 26); + } + } + + private Crucible getItemInstance() + { + return ((Crucible)this.container.box.thisItemStack.getItem()); + } + + private ItemStack getItemStack() + { + return this.container.box.thisItemStack; + } +} \ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/CrucibleInventory.java b/src/main/java/ihl/processing/metallurgy/CrucibleInventory.java new file mode 100644 index 0000000..253483f --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CrucibleInventory.java @@ -0,0 +1,126 @@ +package ihl.processing.metallurgy; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.item.tool.HandHeldInventory; +import ic2.core.util.StackUtil; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +public class CrucibleInventory extends HandHeldInventory { + + ItemStack thisItemStack; + IInventory inventoryContainer; + + public CrucibleInventory(EntityPlayer player, ItemStack stack) { + super(player, stack, 1); + thisItemStack = stack; + inventoryContainer = player.inventory; + } + + public CrucibleInventory(IInventory inventoryContainer1, ItemStack stack) { + super(null, stack, 1); + thisItemStack = stack; + inventoryContainer = inventoryContainer1; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new CrucibleGui(new CrucibleContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new CrucibleContainer(player, this); + } + + @Override + public String getInventoryName() { + return "crucible"; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public boolean isItemValidForSlot(int arg0, ItemStack stack) { + return true; + } + + @Override + public int getInventoryStackLimit() { + return 6; + } + + @Override + public void save() { + if (IC2.platform.isSimulating()) { + NBTTagCompound nbtTagCompound = StackUtil.getOrCreateNbtData(this.thisItemStack); + + for (int nbtTagList = 0; nbtTagList < this.getSizeInventory(); ++nbtTagList) { + if (this.inventory[nbtTagList] != null) { + NBTTagCompound i = StackUtil.getOrCreateNbtData(this.inventory[nbtTagList]); + + if (nbtTagCompound.getInteger("uid") == i.getInteger("uid")) { + this.thisItemStack.stackSize = 1; + this.inventory[nbtTagList] = null; + break; + } + } + } + + NBTTagList var7 = new NBTTagList(); + int var8; + + for (var8 = 0; var8 < this.inventory.length; ++var8) { + if (this.inventory[var8] != null) { + NBTTagCompound itemStackSlot = new NBTTagCompound(); + itemStackSlot.setByte("Slot", (byte) var8); + this.inventory[var8].writeToNBT(itemStackSlot); + var7.appendTag(itemStackSlot); + } + } + + nbtTagCompound.setTag("Items", var7); + + for (var8 = -1; var8 < inventoryContainer.getSizeInventory(); ++var8) { + ItemStack var9 = null; + + if (var8 == -1 && inventoryContainer instanceof InventoryPlayer) { + var9 = ((InventoryPlayer) inventoryContainer).getItemStack(); + } else if (var8 >= 0) { + var9 = inventoryContainer.getStackInSlot(var8); + } + + if (var9 != null) { + NBTTagCompound nbtTagCompoundSlot = var9.getTagCompound(); + + if (nbtTagCompoundSlot != null + && nbtTagCompound.getInteger("uid") == nbtTagCompoundSlot.getInteger("uid")) { + this.thisItemStack.stackSize = 1; + + if (var8 == -1 && inventoryContainer instanceof InventoryPlayer) { + ((InventoryPlayer) inventoryContainer).setItemStack(this.thisItemStack); + } else { + inventoryContainer.setInventorySlotContents(var8, this.thisItemStack); + } + + break; + } + } + } + + } + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/CrucibleSlot.java b/src/main/java/ihl/processing/metallurgy/CrucibleSlot.java new file mode 100644 index 0000000..5fc6a33 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CrucibleSlot.java @@ -0,0 +1,18 @@ +package ihl.processing.metallurgy; + +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class CrucibleSlot extends Slot { + CrucibleInventory inventory; + + public CrucibleSlot(CrucibleInventory arg0, int arg1, int arg2, int arg3) { + super(arg0, arg1, arg2, arg3); + inventory = arg0; + } + + @Override + public boolean isItemValid(ItemStack itemstack) { + return itemstack != null; + } +} diff --git a/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineContainer.java b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineContainer.java new file mode 100644 index 0000000..94d479c --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineContainer.java @@ -0,0 +1,39 @@ +package ihl.processing.metallurgy; + +import ic2.core.ContainerBase; +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Slot; + +public class DetonationSprayingMachineContainer extends ContainerBase { + + protected DetonationSprayingMachineTileEntity tileEntity; + public int lastFluidAmount = -1; + public short lastProgress = -1; + private final static int height=166; + + public DetonationSprayingMachineContainer(EntityPlayer entityPlayer, DetonationSprayingMachineTileEntity detonationSprayingMachineTileEntity){ + super(detonationSprayingMachineTileEntity); + this.tileEntity = detonationSprayingMachineTileEntity; + 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(detonationSprayingMachineTileEntity.input, 0, 10, 17)); + this.addSlotToContainer(new SlotInvSlot(detonationSprayingMachineTileEntity.input, 1, 98, 17)); + this.addSlotToContainer(new SlotInvSlot(detonationSprayingMachineTileEntity.input, 2, 117, 17)); + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineGui.java b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineGui.java new file mode 100644 index 0000000..8cd29d0 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineGui.java @@ -0,0 +1,48 @@ +package ihl.processing.metallurgy; + +import java.util.Iterator; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +@SideOnly(Side.CLIENT) +public class DetonationSprayingMachineGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIDetonationSprayingMachine.png"); + private static final String hint = StatCollector.translateToLocal("ihl.dsmhint"); + + public DetonationSprayingMachineGui (DetonationSprayingMachineContainer detonationSprayingMachineContainer) { + //the container is instanciated and passed to the superclass for handling + super(detonationSprayingMachineContainer); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + } + + @SuppressWarnings("unchecked") + @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); + Iterator noteListIterator = this.mc.fontRenderer.listFormattedStringToWidth(hint, 140).iterator(); + int yTextPos=40; + while(noteListIterator.hasNext()) + { + GuiDraw.fontRenderer.drawStringWithShadow(noteListIterator.next(), x+15, y+yTextPos, 16777215); + yTextPos+=10; + } + } +} \ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineModel.java b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineModel.java new file mode 100644 index 0000000..7335125 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineModel.java @@ -0,0 +1,57 @@ +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraft.entity.Entity; +import net.minecraftforge.common.util.ForgeDirection; + +public class DetonationSprayingMachineModel extends ModelBase { + //fields + IHLModelRenderer Base; + + public DetonationSprayingMachineModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape1", 20, 0); + setTextureOffset("Base.Shape2", 34, 0); + setTextureOffset("Base.Shape3", 23, 0); + setTextureOffset("Base.Shape4", 23, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Base.Tube1", 0, 0); + setTextureOffset("Base.Tube2", 0, 0); + setTextureOffset("Base.Shape12", 0, 20); + setTextureOffset("Base.Shape13", 0, 20); + setTextureOffset("Base.Shape14", 0, 20); + setTextureOffset("Base.Shape7", 26, 22); + setTextureOffset("Base.Shape8", 18, 19); + setTextureOffset("Base.Shape9", 18, 22); + setTextureOffset("Base.Tube11", 8, 5); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 8F, 0F); + Base.mirror = true; + Base.addBox("Shape1", 4F, 6F, 7F, 2, 9, 1, false); + Base.addBox("Shape2", -7F, 4F, 6F, 14, 11, 1, false); + Base.addBox("Shape3", -1F, 6F, 7F, 2, 9, 1, false); + Base.addBox("Shape4", -6F, 6F, 7F, 2, 9, 1, false); + Base.addBox("Shape5", -8F, 15F, -8F, 16, 1, 16, false); + Base.addTube("Tube1", -1F, 10F, -7F, 2, 2, 6, 0.5F,1F,ForgeDirection.NORTH); + Base.addTube("Tube2", -2.5F, 10.5F, -6F, 5, 1, 1, 0F,1F,ForgeDirection.EAST); + Base.addBox("Shape12", -2.5F, 11.7F, -2.2F, 5, 4, 1, false); + Base.addBox("Shape13", 1F, 9F, -8F, 1, 6, 6, false); + Base.addBox("Shape14", -2F, 9F, -8F, 1, 6, 6, false); + Base.addBox("Shape7", -1F, 14F, -8F, 2, 1, 5, false); + Base.addBox("Shape8", 2F, 14F, -8F, 2, 1, 9, false); + Base.addBox("Shape9", -4F, 14F, -8F, 2, 1, 9, false); + Base.addTube("Tube11", -1F, 10F, -8F, 2, 2, 1, 0F,1F,ForgeDirection.NORTH); + } + + @Override + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + } +} + + diff --git a/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineRender.java b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineRender.java new file mode 100644 index 0000000..b68f8b3 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineRender.java @@ -0,0 +1,61 @@ +package ihl.processing.metallurgy; +import org.lwjgl.opengl.GL11; + +import ic2.api.tile.IWrenchable; +import ihl.IHLModInfo; +import ihl.utils.IHLItemRenderer; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; + +public class DetonationSprayingMachineRender extends TileEntitySpecialRenderer{ +private DetonationSprayingMachineModel model = new DetonationSprayingMachineModel(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/detonationSprayingMachine.png"); +private final float scale=1F/16F; +private IHLItemRenderer itemRenderer=new IHLItemRenderer(true); + +public DetonationSprayingMachineRender(){} + +public void renderAModelAt(DetonationSprayingMachineTileEntity tile, double x, double y, double z, float f) { + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y+0.5F, (float)z + 0.5F); + int rotation = 0; + if(tile.getWorldObj() != null) + { + switch (((IWrenchable)tile).getFacing()) + { + case 2: + rotation = 0; + break; + case 5: + rotation = 1; + break; + case 3: + rotation = 2; + break; + case 4: + rotation = 3; + break; + default: + rotation = 0; + } + } + GL11.glRotatef(-rotation*90f, 0F, 1F, 0F); + if(tile.input.get()!=null) + { + this.itemRenderer.doRender(RenderManager.instance,tile.input.get(),0F,-0.2F,-0.35F); + } + bindTexture(tex); //texture + GL11.glScalef(1F, -1F, -1F); + GL11.glTranslatef(0F, -1.0F, 0F); + model.Base.render(scale); + GL11.glPopMatrix(); +} + + @Override + public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) + { + this.renderAModelAt((DetonationSprayingMachineTileEntity)par1TileEntity, par2, par4, par6, par8); + } +} \ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineTileEntity.java b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineTileEntity.java new file mode 100644 index 0000000..411b8db --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineTileEntity.java @@ -0,0 +1,198 @@ +package ihl.processing.metallurgy; + +import java.util.List; +import java.util.Map; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.network.INetworkTileEntityEventListener; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeInputOreDict; +import ic2.core.ContainerBase; +import ic2.core.ExplosionIC2; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.audio.AudioSource; +import ic2.core.audio.PositionSpec; +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlot.Access; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.recipes.RecipeOutputItemStack; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class DetonationSprayingMachineTileEntity extends TileEntityInventory implements IHasGui, INetworkTileEntityEventListener +{ + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("detonationsprayingmachine"); + public final ApparatusProcessableInvSlot input; + private AudioSource explosion; + + public DetonationSprayingMachineTileEntity() { + super(); + this.input = new ApparatusProcessableInvSlot(this, "input", 0, Access.IO, 3, 64); + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + return fields; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return false; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("cannonBronze"); + } + + @Override + public String getInventoryName() { + return "detonationSprayingMachine"; + } + + @Override + public void onNetworkEvent(int event) + { + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "random.explode", 4.0F, 1.0F); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new DetonationSprayingMachineGui(new DetonationSprayingMachineContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new DetonationSprayingMachineContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) {} + + public boolean canOperate() + { + return getOutput()!=null; + } + + public UniversalRecipeOutput getOutput() + { + return DetonationSprayingMachineTileEntity.recipeManager.getOutputFor(this.getInput()); + } + + public List[] getInput() + { + return new List[] {null,this.input.getItemStackList()}; + } + + @Override + public void onLoaded() + { + super.onLoaded(); + if (IC2.platform.isRendering() && this.explosion==null) + { + this.explosion = IC2.audioManager.createSource(this, PositionSpec.Center, "Machines/MinerOp.ogg",false,false, 0.5F); + } + } + + + public void operate() + {//diamond file max durability - 128000 + //file tags - "GT.ToolStats"->"MaxDamage" & "Damage" + if(this.canOperate()) + { + List input1 = DetonationSprayingMachineTileEntity.recipeManager.getRecipeInput(getInput()).getItemInputs(); + List output1 = DetonationSprayingMachineTileEntity.recipeManager.getOutputFor(getInput()).getItemOutputs(); + ItemStack resultStack = output1.get(0).itemStack.copy(); + resultStack.stackSize=this.input.get(0).stackSize; + if(resultStack.stackTagCompound==null) + { + resultStack.stackTagCompound=this.input.get(0).stackTagCompound; + } + if(resultStack.stackTagCompound!=null && resultStack.stackTagCompound.hasKey("GT.ToolStats")) + { + NBTTagCompound gtTagCompound = resultStack.stackTagCompound.getCompoundTag("GT.ToolStats"); + if(gtTagCompound!=null && gtTagCompound.hasKey("MaxDamage")) + { + int maxDamage = gtTagCompound.getInteger("MaxDamage"); + int damage = 0; + if(gtTagCompound.hasKey("Damage")) + { + damage = gtTagCompound.getInteger("Damage"); + } + if(damage getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} \ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/ElectricEngineItem.java b/src/main/java/ihl/processing/metallurgy/ElectricEngineItem.java new file mode 100644 index 0000000..c1e0003 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ElectricEngineItem.java @@ -0,0 +1,84 @@ +package ihl.processing.metallurgy; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +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 ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.Item; +import net.minecraft.util.IIcon; + +public class ElectricEngineItem extends Item{ + + public Type type; + public static List instances = new ArrayList (); + private static Map iconMap = new HashMap(); + + + public ElectricEngineItem(Type type1) + { + super(); + this.type=type1; + this.setCreativeTab(IHLCreativeTab.tab); + this.setUnlocalizedName(type.unLocalizedName); + this.setMaxStackSize(1); + instances.add(this); + } + + public static void init() + { + Type[] var1 = Type.values(); + for(int i=0;i ii = instances.iterator(); + while(ii.hasNext()) + { + ElectricEngineItem instance = ii.next(); + GameRegistry.registerItem(instance,instance.type.unLocalizedName); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) + { + iconMap.put(this.type, register.registerIcon(IHLModInfo.MODID + ":"+this.type.unLocalizedName)); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int i) + { + return iconMap.get(type); + } + + + public enum Type + { + LVLEElectricEngine("electricMotorLVLEDC", 600,400,0.2F,1500); + Type(String unlocalizedName1, int maxVoltage1, int generatedVoltage1, float efficiency1,int rpm1) + { + unLocalizedName=unlocalizedName1; + maxVoltage=maxVoltage1; + generatedVoltage=generatedVoltage1; + efficiency=efficiency1; + rpm=rpm1; + } + + public String unLocalizedName; + public int maxVoltage=600; + public int generatedVoltage=400; + public float efficiency = 0.2F; + public int rpm=1500;//at max voltage + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/ExtruderContainer.java b/src/main/java/ihl/processing/metallurgy/ExtruderContainer.java new file mode 100644 index 0000000..77b92e6 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ExtruderContainer.java @@ -0,0 +1,75 @@ +package ihl.processing.metallurgy; + +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 ExtruderContainer extends ContainerBase { + + public ExtruderTileEntity tileEntity; + public int lastProgress = -1; + private short lastEnergy = -1; + private final static int height=166; + + public ExtruderContainer(EntityPlayer entityPlayer, + ExtruderTileEntity 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, 39, 32)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.input2, 0, 57, 32)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.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.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + if (this.tileEntity.getEnergy() != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy()); + } + } + this.lastProgress = this.tileEntity.progress; + this.lastEnergy = (short) this.tileEntity.getEnergy(); + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + + switch (index) + { + case 0: + this.tileEntity.progress=(short) value; + break; + case 1: + this.tileEntity.setEnergy(value); + break; + } + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/ExtruderGui.java b/src/main/java/ihl/processing/metallurgy/ExtruderGui.java new file mode 100644 index 0000000..acf1a76 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ExtruderGui.java @@ -0,0 +1,49 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; + +public class ExtruderGui extends GuiContainer { + + private ExtruderContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUIExtruder.png"); + + public ExtruderGui(ExtruderContainer 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); + 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(74, 34, 198, 0, i1 + 1, 13); + } + } + + @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/metallurgy/ExtruderModel.java b/src/main/java/ihl/processing/metallurgy/ExtruderModel.java new file mode 100644 index 0000000..fcff405 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ExtruderModel.java @@ -0,0 +1,100 @@ +package ihl.processing.metallurgy; + +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/metallurgy/ExtruderTileEntity.java b/src/main/java/ihl/processing/metallurgy/ExtruderTileEntity.java new file mode 100644 index 0000000..a46ae62 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ExtruderTileEntity.java @@ -0,0 +1,155 @@ +package ihl.processing.metallurgy; + +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.Access; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.IFluidHandler; + +public class ExtruderTileEntity extends BasicElectricMotorTileEntity{ + + public final ApparatusProcessableInvSlot input; + public final ApparatusProcessableInvSlot input2; + private int processTimer=0; + private FluidTank fluidTank = new FluidTank(1000); + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("extruder"); + + public ExtruderTileEntity() + { + super(); + input = new ApparatusProcessableInvSlot(this, "input", 1, Access.IO, 1, 64); + input2 = new ApparatusProcessableInvSlot(this, "input2", 2, Access.IO, 1, 64); + } + + + + @Override + public List getNetworkedFields() + { + return super.getNetworkedFields(); + } + + + @Override + public String getInventoryName() { + return "Extruder"; + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + ForgeDirection dir = ForgeDirection.getOrientation(getFacing()); + TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX,yCoord+dir.offsetY,zCoord+dir.offsetZ); + if(checkCorrectAccembly() && this.fluidTank.getFluidAmount()>0 && this.processTimer++>20) + { + this.processTimer=0; + ((IFluidHandler)te).fill(ForgeDirection.getOrientation(getFacing()), this.fluidTank.drain(this.fluidTank.getCapacity(), true), true); + } + + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("extruder"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new ExtruderGui(new ExtruderContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new ExtruderContainer(player, this); + } + + @Override + public void operate() + { + UniversalRecipeInput ri = ExtruderTileEntity.recipeManager.getRecipeInput(getInput()); + this.fluidTank.fill(getOutput().getFluidOutputs().get(0), true); + this.input.consume(ri.getItemInputs().get(0)); + this.input2.consume(ri.getItemInputs().get(1)); + } + + public UniversalRecipeOutput getOutput() + { + return ExtruderTileEntity.recipeManager.getOutputFor(this.getInput()); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public List[] getInput() + { + return new List[]{null,Arrays.asList(new ItemStack[] {input.get(),input2.get()})}; + } + + @Override + public boolean canOperate() + { + return this.fluidTank.getFluidAmount() getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/GasWeldingStationContainer.java b/src/main/java/ihl/processing/metallurgy/GasWeldingStationContainer.java new file mode 100644 index 0000000..e960edb --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/GasWeldingStationContainer.java @@ -0,0 +1,99 @@ +package ihl.processing.metallurgy; + +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 GasWeldingStationContainer extends ContainerBase { + + protected GasWeldingStationTileEntity tileEntity; + public short lastProgress2 = -1; + private final static int height=166; + public int lastFluidAmount = -1; + public int lastNumberOfFluids = -1; + public int lastFluidAmount2 = -1; + public int lastNumberOfFluids2 = -1; + public List fluidTankFluidList; + public List fluidTankFluidList2; + + public GasWeldingStationContainer(EntityPlayer entityPlayer, GasWeldingStationTileEntity weldingStation){ + super(weldingStation); + this.tileEntity = weldingStation; + fluidTankFluidList = this.tileEntity.flammableGasTank.getFluidList(); + fluidTankFluidList2 = this.tileEntity.oxygenTank.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(tileEntity.drainInputSlotOxygen, 0, 8, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.drainInputSlotFlammableGas, 0, 44, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.fillInputSlotOxygen, 0, 8, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.fillInputSlotFlammableGas, 0, 44, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.emptyFluidItemsSlot, 0, 8, 33)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.emptyFluidItemsSlot, 1, 44, 33)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.input, 0, 62, 51)); + } + + @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.progress2 != this.lastProgress2) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.progress2); + } + if (this.tileEntity.flammableGasTank.getFluidAmount() != this.lastFluidAmount || this.tileEntity.flammableGasTank.getNumberOfFluids() != this.lastNumberOfFluids) + { + + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + + if (this.tileEntity.oxygenTank.getFluidAmount() != this.lastFluidAmount2 || this.tileEntity.oxygenTank.getNumberOfFluids() != this.lastNumberOfFluids2) + { + + IC2.network.get().sendContainerField(this, "fluidTankFluidList2"); + } + } + + + this.lastProgress2 = this.tileEntity.progress2; + this.lastNumberOfFluids = this.tileEntity.flammableGasTank.getNumberOfFluids(); + this.lastFluidAmount = this.tileEntity.flammableGasTank.getFluidAmount(); + this.lastNumberOfFluids2 = this.tileEntity.oxygenTank.getNumberOfFluids(); + this.lastFluidAmount2 = this.tileEntity.oxygenTank.getFluidAmount(); + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + switch (index) + { + case 1: + this.tileEntity.progress2=(short) value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/src/main/java/ihl/processing/metallurgy/GasWeldingStationGui.java b/src/main/java/ihl/processing/metallurgy/GasWeldingStationGui.java new file mode 100644 index 0000000..79becd5 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/GasWeldingStationGui.java @@ -0,0 +1,78 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.IC2; +import ihl.utils.IHLRenderUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Slot; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class GasWeldingStationGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIGasWeldingStation.png"); + private GasWeldingStationContainer container; + private int outputslotoffset=45; + + public GasWeldingStationGui (GasWeldingStationContainer detonationSprayingMachineContainer) { + //the container is instanciated and passed to the superclass for handling + super(detonationSprayingMachineContainer); + this.container=detonationSprayingMachineContainer; + } + + @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.progress2 > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27); + this.drawTexturedModalRect(90, 30, getFrameX(i1), getFrameY(i1),24,24); + } + if (this.container.tileEntity.flammableGasTank.getFluid()!=null && this.container.tileEntity.flammableGasTank.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.flammableGasTank, 64, 28, 76, 67, zLevel, par1, par2, xOffset, yOffset); + } + if (this.container.tileEntity.oxygenTank.getFluid()!=null && this.container.tileEntity.oxygenTank.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.oxygenTank, 28, 28, 40, 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(background); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } + + @Override + public void handleMouseClick(Slot slot,int arg1,int arg2,int arg3) + { + if(slot!=null && slot.slotNumber>=outputslotoffset && slot.slotNumber getNetworkedFields() + { + List fields = super.getNetworkedFields(); + return fields; + } + + @Override + public void updateEntityServer() + { + if (this.canProduceGas()) + { + ++this.progress2; + if (this.progress2 >= this.operationLength) + { + this.produceGas(); + this.progress2 = 0; + } + } + else + { + if (!this.canProduceGas()) + { + this.progress2 = 0; + } + } + IHLUtils.handleFluidSlotsBehaviour(fillInputSlotFlammableGas, drainInputSlotFlammableGas, emptyFluidItemsSlot, flammableGasTank); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlotOxygen, drainInputSlotOxygen, emptyFluidItemsSlot, oxygenTank); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.flammableGasTank.readFromNBT(nbttagcompound.getCompoundTag("flammableGasTank")); + this.oxygenTank.readFromNBT(nbttagcompound.getCompoundTag("oxygenTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound flammableGasTankNBT = new NBTTagCompound(); + this.flammableGasTank.writeToNBT(flammableGasTankNBT); + nbttagcompound.setTag("flammableGasTank", flammableGasTankNBT); + NBTTagCompound oxygenTankNBT = new NBTTagCompound(); + this.oxygenTank.writeToNBT(oxygenTankNBT); + nbttagcompound.setTag("oxygenTank", oxygenTankNBT); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return false; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("gasWeldingStation"); + } + + @Override + public String getInventoryName() { + return "detonationSprayingMachine"; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new GasWeldingStationGui(new GasWeldingStationContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new GasWeldingStationContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) {} + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + } + + public boolean canProduceGas() + { + UniversalRecipeOutput rOutput = GasWeldingStationTileEntity.acetyleneRecipeManager.getOutputFor(Arrays.asList(new FluidStack[]{this.flammableGasTank.getFluid()}), Arrays.asList(new ItemStack[]{this.input.get()})); + return rOutput!=null; + } + + public void produceGas() + { + if(canProduceGas()) + { + UniversalRecipeInput rInput = GasWeldingStationTileEntity.acetyleneRecipeManager.getRecipeInput(Arrays.asList(new FluidStack[]{this.flammableGasTank.getFluid()}), Arrays.asList(new ItemStack[]{this.input.get()})); + UniversalRecipeOutput rOutput = GasWeldingStationTileEntity.acetyleneRecipeManager.getOutputFor(Arrays.asList(new FluidStack[]{this.flammableGasTank.getFluid()}), Arrays.asList(new ItemStack[]{this.input.get()})); + FluidStack output1 = rOutput.getFluidOutputs().get(0).copy(); + FluidStack output2 = rOutput.getFluidOutputs().get(1).copy(); + this.flammableGasTank.drain(rInput.getFluidInputs().get(0), true); + this.input.get().stackSize-=rInput.getItemInputs().get(0).getAmount(); + if(this.input.get().stackSize<=0) + { + this.input.clear(); + } + this.flammableGasTank.fill(output1, true); + this.flammableGasTank.fill(output2, true); + } + } + + + public UniversalRecipeInput getInput() + { + return new UniversalRecipeInput(new FluidStack[] {this.flammableGasTank.getLigthestFluid(), this.oxygenTank.getFluid()}, new ItemStack[]{this.input.get(0),this.input.get(1),this.input.get(2)}); + } + + public static void addGasRecipe(ItemStack input, FluidStack inputFluid, FluidStack output, FluidStack output2) + { + acetyleneRecipeManager.addRecipe(new UniversalRecipeInput(new FluidStack[] {inputFluid},new ItemStack[] {input}), new UniversalRecipeOutput(new FluidStack [] {output, output2},new ItemStack [] {}, 20)); + } + + public static Map getGasRecipes() { + return acetyleneRecipeManager.getRecipes(); + } + + @Override + public FluidStack drain(ForgeDirection from, int amount, boolean doDrain) + { + FluidStack fstack = this.flammableGasTank.drain(amount, doDrain); + return fstack; + } + + @Override + public FluidStack drain(ForgeDirection arg0, FluidStack fluidStack, boolean doDrain) { + if(this.flammableGasTank.getFluid().containsFluid(fluidStack)) + { + return this.flammableGasTank.drain(fluidStack.amount, doDrain); + } + return null; + } + + @Override + public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return this.oxygenTank.fill(arg1, arg2); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) { + return new FluidTankInfo[] {this.flammableGasTank.getInfo(),this.oxygenTank.getInfo()}; + } + + + //1.7.10 API + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return true; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return true; + } + + public int gaugeProgressScaled(int i) + { + return this.progress2 * i / this.operationLength; + } + + public int gaugeFlammableGasScaled(int i) + { + if(this.flammableGasTank.getFluid()!=null) + { + return this.flammableGasTank.getFluidAmount() * i /this.flammableGasTank.getCapacity(); + } + else + { + return 0; + } + } + + public int gaugeOxygenScaled(int i) + { + if(this.oxygenTank.getFluid()!=null) + { + return this.oxygenTank.getFluidAmount() * i /this.oxygenTank.getCapacity(); + } + else + { + return 0; + } + } + + @Override + public boolean canBeUsed() + { + return + this.flammableGasTank.getFluid()!=null && + this.flammableGasTank.getLigthestFluid().getFluid().getName().equals("acetylene") && + this.flammableGasTank.getLigthestFluid().amount>=20 && + this.oxygenTank.getFluid()!=null && + this.oxygenTank.getLigthestFluid().getFluid().getName().equals("oxygen") && + this.oxygenTank.getLigthestFluid().amount>=20; + } + + @Override + public void use() + { + this.flammableGasTank.drain(IHLUtils.getFluidStackWithSize("acetylene", 20), true); + this.oxygenTank.drain(IHLUtils.getFluidStackWithSize("oxygen", 20), true); + } + + @Override + public boolean getIsInvalid() + { + return this.isInvalid(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } +} \ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/IProductionLine.java b/src/main/java/ihl/processing/metallurgy/IProductionLine.java new file mode 100644 index 0000000..5cf7605 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/IProductionLine.java @@ -0,0 +1,12 @@ +package ihl.processing.metallurgy; + +import net.minecraft.item.ItemStack; + +public interface IProductionLine +{ + + short getFacing(); + boolean canProcess(ItemStack stack); + void process(ItemStack stack); + +} diff --git a/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineContainer.java b/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineContainer.java new file mode 100644 index 0000000..d166889 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineContainer.java @@ -0,0 +1,105 @@ +package ihl.processing.metallurgy; + +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 ImpregnatingMachineContainer extends ContainerBase { + + protected ImpregnatingMachineTileEntity tileEntity; + public int lastFluidAmount = -1; + public int lastNumberOfFluids = -1; + public int lastVisibleFluidID = -1; + public int lastVisibleFluidAmount = -1; + public short lastProgress = -1; + public short lastTemperature = -1; + private final static int height = 166; + public List fluidTankFluidList; + public int fluidListHash = -1; + + public ImpregnatingMachineContainer(EntityPlayer entityPlayer, ImpregnatingMachineTileEntity 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.drainInputSlot, 0, 24, 16)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 24, 34)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 24, 52)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 116, 16)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 116, 41)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 1, 116, 59)); + } + + @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); + } + + if (this.tileEntity.temperature != this.lastTemperature) { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.temperature); + } + if (this.tileEntity.visibleFluidId != this.lastVisibleFluidID) { + icrafting.sendProgressBarUpdate(this, 2, this.tileEntity.visibleFluidId); + } + if (this.tileEntity.visibleFluidAmount != this.lastVisibleFluidAmount) { + icrafting.sendProgressBarUpdate(this, 3, this.tileEntity.visibleFluidAmount); + } + } + + this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank(); + this.lastFluidAmount = this.tileEntity.getTankAmount(); + this.lastProgress = this.tileEntity.progress; + this.lastTemperature = this.tileEntity.temperature; + 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.progress = (short) value; + break; + case 1: + this.tileEntity.temperature = (short) value; + break; + case 2: + this.tileEntity.visibleFluidId = value; + break; + case 3: + this.tileEntity.visibleFluidAmount = value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineGui.java b/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineGui.java new file mode 100644 index 0000000..29ba298 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineGui.java @@ -0,0 +1,63 @@ +package ihl.processing.metallurgy; + +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 ImpregnatingMachineGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUITubBronze.png"); + private ImpregnatingMachineContainer container; + + + public ImpregnatingMachineGui (ImpregnatingMachineContainer 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, 0.5F); + 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(138, 28, getFrameX(i1), getFrameY(i1),24,24); + } + if (this.container.tileEntity.getTankAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 50, 11, 107, 72, 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/metallurgy/ImpregnatingMachineRender.java b/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineRender.java new file mode 100644 index 0000000..9529186 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineRender.java @@ -0,0 +1,55 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +import ihl.interfaces.IFluidTankVisual; +import ihl.model.FluidRenderer; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class ImpregnatingMachineRender extends TileEntitySpecialRenderer { + + private float cap; + + public ImpregnatingMachineRender(float capIn) { + cap = capIn; + } + + public void renderAModelAt(IFluidTankVisual tile, double x, double y, double z, float f) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F); + float rotation = 0F; + GL11.glRotatef(-rotation, 0F, 1F, 0F); + GL11.glScalef(1F, -1F, -1F); + GL11.glTranslatef(0F, -1.0F, 0F); + GL11.glPopMatrix(); + if (tile.getVisibleFluidId() == -1 || tile.getVisibleFluidAmount() <= 0) { + return; + } + FluidStack fluidStack = new FluidStack(FluidRegistry.getFluid(tile.getVisibleFluidId()), + tile.getVisibleFluidAmount()); + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glTranslatef((float) x, (float) y + 0.1F, (float) z); + GL11.glScalef(0.99F, 0.8F * tile.getRenderLiquidLevel(), 0.99F); + int[] displayLists = FluidRenderer.getLiquidDisplayLists(fluidStack); + if (displayLists != null) { + float level = Math.min(fluidStack.amount, cap) / cap; + bindTexture(FluidRenderer.getFluidSheet(fluidStack)); + GL11.glCallList(displayLists[(int) (level * (FluidRenderer.DISPLAY_STAGES - 1))]); + } + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + + } + + @Override + public void renderTileEntityAt(TileEntity tile, double par2, double par4, double par6, float par8) { + this.renderAModelAt((IFluidTankVisual) tile, par2, par4, par6, par8); + } +} \ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineTileEntity.java b/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineTileEntity.java new file mode 100644 index 0000000..4f7c529 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineTileEntity.java @@ -0,0 +1,343 @@ +package ihl.processing.metallurgy; + +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.INetworkTileEntityEventListener; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ihl.interfaces.IFluidTankVisual; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.chemistry.ChemicalReactorTileEntity; +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.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.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class ImpregnatingMachineTileEntity extends TileEntityInventory implements IHasGui,IFluidTankVisual,INetworkTileEntityEventListener, IFluidHandler +{ + private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("tub"); + public final ApparatusProcessableInvSlot input; + public final IHLInvSlotOutput outputSlot; + public final InvSlotConsumableLiquidIHL drainInputSlot; + public final InvSlotConsumableLiquidIHL fillInputSlot; + public final InvSlotOutput emptyFluidItemsSlot; + public short progress; + protected short operationLength=Short.MAX_VALUE/2; + private final IHLFluidTank fluidTank = new IHLFluidTank(8000); + public short temperature=20; + public int visibleFluidId = -1; + public int visibleFluidAmount = 1; + + public ImpregnatingMachineTileEntity() { + super(); + this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 2); + this.drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); + this.fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 1); + this.input = new ApparatusProcessableInvSlot(this, "input", 3, Access.IO, 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("tubBronze"); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public List getNetworkedFields() + { + List ret = super.getNetworkedFields(); + ret.add("visibleFluidId"); + ret.add("visibleFluidAmount"); + return ret; + } + + @Override + public void updateEntityServer() + { + if(this.fluidTank.getFluid()!=null) + { + if(this.fluidTank.getLigthestFluid().getFluid().isGaseous()) + { + this.fluidTank.drainLightest(10, true); + } + } + 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"); + } + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank); + if (this.canOperate()) + { + this.setActive(true); + if (this.progress == 0) + { + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + + this.progress+=this.operationLength/this.getOutput().getTime(); + 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 "impregnatingMachine"; + } + + public float getRenderLiquidLevel() + { + return (float)this.visibleFluidAmount/(float)this.fluidTank.getCapacity(); + } + + @Override + public void onNetworkEvent(int event) + { + } + + public int gaugeProgressScaled(int i) + { + return this.progress * i / operationLength; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new ImpregnatingMachineGui(new ImpregnatingMachineContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) + { + this.fluidTank.sortFluidsByDensity(); + return new ImpregnatingMachineContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) {} + + public boolean canOperate() + { + return getOutput()!=null && this.outputSlot.canAdd(getOutput().getItemOutputs()); + } + + public UniversalRecipeOutput getOutput() + { + return ImpregnatingMachineTileEntity.recipeManager.getOutputFor(this.getInput()); + } + + @SuppressWarnings("rawtypes") + public List[] getInput() + { + for(int i=0;i getRecipes() { + return recipeManager.getRecipes(); + } + + public static void addQuenchingRecipe(String nameHot, String nameQuenched) + { + addRecipe(new UniversalRecipeInput((new FluidStack[] {new FluidStack(FluidRegistry.WATER, 50)}), (new ItemStack[] {IHLUtils.getThisModItemStack(nameHot)})), new UniversalRecipeOutput(null, (new ItemStack[] {IHLUtils.getThisModItemStack(nameQuenched)}),2)); + } + + public IHLFluidTank getFluidTank() + { + return this.fluidTank; + } + + public static void addChemicalRecipe(UniversalRecipeInput universalRecipeInput, UniversalRecipeOutput universalRecipeOutput) + { + addRecipe(universalRecipeInput,universalRecipeOutput); + ChemicalReactorTileEntity.addRecipe(universalRecipeInput,universalRecipeOutput); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + + @Override + public int getVisibleFluidId() { + return this.visibleFluidId; + } + + @Override + public int getVisibleFluidAmount() { + return this.visibleFluidAmount; + } +} \ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/InjectionMoldBlock.java b/src/main/java/ihl/processing/metallurgy/InjectionMoldBlock.java new file mode 100644 index 0000000..bbea1cb --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/InjectionMoldBlock.java @@ -0,0 +1,248 @@ +package ihl.processing.metallurgy; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.items_blocks.IHLItemBlock; +import ihl.metallurgy.constants.Details; +import ihl.utils.IHLUtils; +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.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidStack; + +public class InjectionMoldBlock extends Block implements ITileEntityProvider{ + + IIcon textureSide; + + public static InjectionMoldBlock instance; + public static String[] materials = new String[] {"Bronze","Steel","Gold","Magnesium", "Lithium", "TarPitch", "Potassium", "Sodium"}; + + public InjectionMoldBlock() + { + super(Material.rock); + this.setResistance(0.5F); + this.setHardness(0.5F); + this.setBlockName("injectionMold"); + this.setCreativeTab(IHLCreativeTab.tab); + instance=this; + } + + public static void init() + { + GameRegistry.registerBlock(new InjectionMoldBlock(),IHLItemBlock.class,"injectionMold"); + GameRegistry.registerTileEntity(InjectionMoldTileEntity.class,"injectionMoldTileEntity"); + } + + @Override + public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) + { + super.dropBlockAsItemWithChance(world, x, y, z, meta, chance, flag); + } + + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) + { + ItemStack result = new ItemStack(item); + result.stackTagCompound=new NBTTagCompound(); + result.stackTagCompound.setString("resultSuffix", "ingot"); + itemList.add(result); + } + + + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new InjectionMoldTileEntity(); + } + + @Override + public void onBlockPreDestroy(World world, int x, int y, int z, int meta) + { + if(!world.isRemote) + { + TileEntity te = world.getTileEntity(x, y, z); + if(te!=null && te instanceof InjectionMoldTileEntity) + { + InjectionMoldTileEntity gte = (InjectionMoldTileEntity) te; + gte.dropContents(); + } + } + super.onBlockPreDestroy(world, x, y, z, meta); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) + { + ArrayList drops = new ArrayList(); + TileEntity t = world.getTileEntity(x, y, z); + if(t!=null) + { + InjectionMoldTileEntity te = (InjectionMoldTileEntity)t; + if(te.result!=null)drops.add(te.result); + if(te.result2!=null)drops.add(te.result2); + } + return drops; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":injectionMoldTop"); + this.textureSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":injectionMoldSide"); + } + + @Override + public boolean hasTileEntity(int metadata) + { + return true; + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) + { + TileEntity t = world.getTileEntity(x, y, z); + if(t!=null && t instanceof InjectionMoldTileEntity) + { + InjectionMoldTileEntity te = (InjectionMoldTileEntity)t; + te.resultSuffix=itemStack.stackTagCompound.getString("resultSuffix"); + if(itemStack.stackTagCompound.hasKey("isContainStearin")) + { + te.isContainStearin=itemStack.stackTagCompound.getBoolean("isContainStearin"); + } + if(itemStack.stackTagCompound.hasKey("maxAmount")) + { + te.maxAmount=itemStack.stackTagCompound.getByte("maxAmount"); + } + + } + } + @Override + public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer player,int i,float pos_x,float pos_y,float pos_z) + { + if(player.getCurrentEquippedItem()!=null && player.getCurrentEquippedItem().getItem() instanceof Crucible) + { + if(!world.isRemote) + { + return ((Crucible)player.getCurrentEquippedItem().getItem()).onItemUse(player.getCurrentEquippedItem(), player, world, x, y, z, 0, pos_x, pos_y, pos_z); + } + return true; + } + return false; + } + + + + /** + * Called when the block is placed in the world. + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) + { + switch (side) + { + case 1: + return this.blockIcon; + case 0: + return this.textureSide; + case 2: + return this.textureSide; + case 3: + return this.textureSide; + 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 1: + return this.blockIcon; + case 0: + return this.textureSide; + case 2: + return this.textureSide; + case 3: + return this.textureSide; + case 4: + return this.textureSide; + case 5: + return this.textureSide; + default: + return this.textureSide; + } + } + + public ItemStack getSandInjectionMoldForResult(String result1) + { + ItemStack stack = new ItemStack(this); + stack.stackTagCompound=new NBTTagCompound(); + stack.stackTagCompound.setString("resultSuffix", result1); + registerRecipes(result1, stack); + return stack; + } + + public ItemStack getGypsumInjectionMoldForResult(String result1) + { + ItemStack stack = new ItemStack(this); + stack.stackTagCompound=new NBTTagCompound(); + stack.stackTagCompound.setString("resultSuffix", result1); + stack.stackTagCompound.setByte("maxAmount", (byte)1); + stack.stackTagCompound.setBoolean("isContainStearin", true); + registerRecipes(result1, stack); + return stack; + } + + public static void registerRecipes(String result1,ItemStack stack1) + { + for(int i=0;i16) + { + if(this.timer--==0) + { + String formattedFluidName=this.getFormattedMaterialName(this.getFluidfromTank().getName()); + if(formattedFluidName!="") + { + int fluidAmountPerItem = Details.getMeltingFluidAmount(this.resultSuffix); + ArrayList resultList = OreDictionary.getOres(this.resultSuffix+formattedFluidName); + if(resultList.isEmpty() || fluidAmountPerItem<=0) + { + resultList=new ArrayList(); + List fi = Arrays.asList(new FluidStack[] {this.fluidTank.getFluid()}); + List ii = Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStackWithDamage("injectionMold", this.resultSuffix.hashCode() & Integer.MAX_VALUE)}); + UniversalRecipeOutput ro = recipeManager.getOutputFor(fi, ii); + if(ro!=null) + { + ItemStack stack = ro.getItemOutputs().get(0).itemStack.copy(); + stack.stackSize=Math.round(ro.getItemOutputs().get(0).quantity); + resultList.add(stack); + UniversalRecipeInput ri = recipeManager.getRecipeInput(fi, ii); + fluidAmountPerItem = ri.getFluidInputs().get(0).getAmount(); + } + } + int fluidAmountPerItem2 = Details.getMeltingFluidAmount("nugget"); + ArrayList resultList2 = OreDictionary.getOres("nugget"+formattedFluidName); + if(!resultList.isEmpty()) + { + if(fluidAmountPerItem>0) + { + int stackSize1=Math.min(this.maxAmount,this.getFluidStackfromTank().amount/fluidAmountPerItem); + if(stackSize1>0) + { + result=resultList.get(0).copy(); + result.stackSize=stackSize1; + } + } + } + if(!resultList2.isEmpty()) + { + int stackSize1=this.getFluidStackfromTank().amount/fluidAmountPerItem2; + if(result!=null) + { + stackSize1=(this.getFluidStackfromTank().amount % fluidAmountPerItem)/fluidAmountPerItem2; + } + if(stackSize1>0) + { + result2=resultList2.get(0).copy(); + result2.stackSize=stackSize1; + } + } + } + } + } + } + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return false; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid fluid1) { + return direction==ForgeDirection.UP && !isContainStearin; + } + + public String getInventoryName() { + return "injectionMold"; + } + + private String getFormattedMaterialName(String input) + { + String input2 = input.replace("molten.", "").replace(".molten", ""); + String firstletter = String.valueOf(input2.charAt(0)).toUpperCase(); + input2 = input2.replaceFirst(".", firstletter); + return input2; + } + + public FluidTank getFluidTank() + { + return this.fluidTank; + } + + public FluidStack getFluidStackfromTank() + { + return this.getFluidTank().getFluid(); + } + + public Fluid getFluidfromTank() + { + return this.getFluidStackfromTank().getFluid(); + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) + { + return this.canFill(from, resource.getFluid()) ? this.getFluidTank().fill(resource, doFill) : 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) + { + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) + { + return this.getFluidTank().drain(maxDrain, doDrain); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) + { + return new FluidTankInfo[] {this.getFluidTank().getInfo()}; + } + + public void dropContents() + { + if(result!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, result)); + if(result2!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, result2)); + } + + public static Map getRecipes() + { + return recipeManager.getRecipes(); + } +} \ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/LatheContainer.java b/src/main/java/ihl/processing/metallurgy/LatheContainer.java new file mode 100644 index 0000000..5e79a2a --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/LatheContainer.java @@ -0,0 +1,72 @@ +package ihl.processing.metallurgy; + +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 LatheContainer extends ContainerBase { + + public LathePart1TileEntity tileEntity; + public int lastProgress = -1; + private short lastEnergy = -1; + private final static int height=166; + + public LatheContainer(EntityPlayer entityPlayer, + LathePart1TileEntity 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.dischargeSlot,0, 22, 55)); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + if (this.tileEntity.getEnergy() != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy()); + } + } + this.lastProgress = this.tileEntity.progress; + this.lastEnergy = (short) this.tileEntity.getEnergy(); + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + + switch (index) + { + case 0: + this.tileEntity.progress=(short) value; + break; + case 1: + this.tileEntity.setEnergy(value); + break; + } + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/LatheGui.java b/src/main/java/ihl/processing/metallurgy/LatheGui.java new file mode 100644 index 0000000..16f64c5 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/LatheGui.java @@ -0,0 +1,51 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class LatheGui extends GuiContainer { + + private LatheContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUILathe.png"); + + public LatheGui(LatheContainer latheContainer) { + super(latheContainer); + container = latheContainer; + } + + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + fontRendererObj.drawString(StatCollector.translateToLocal("ihl.gui.lathe"), 50, 10, 14722081); + this.mc.renderEngine.bindTexture(tex); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) + { + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(39, 55 + 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); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(50),50); + this.drawTexturedModalRect(64, 63, 197, 0, i1 + 1, 13); + } + } + + @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/metallurgy/LathePart1Model.java b/src/main/java/ihl/processing/metallurgy/LathePart1Model.java new file mode 100644 index 0000000..c08b3bf --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/LathePart1Model.java @@ -0,0 +1,93 @@ +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class LathePart1Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer Belt; + IHLModelRenderer Belt2; + + public LathePart1Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape2", 0, 0); + setTextureOffset("Base.NewShape4", 0, 0); + setTextureOffset("RotatingPart2.PipeN1", 0, 0); + setTextureOffset("RotatingPart2.PipeN7", 49, 23); + setTextureOffset("RotatingPart2.Shape1", 56, 19); + setTextureOffset("RotatingPart2.Shape5", 0, 8); + setTextureOffset("RotatingPart2.Shape8", 0, 11); + setTextureOffset("RotatingPart2.PipeN4", 0, 0); + setTextureOffset("RotatingPart2.Shape9", 0, 0); + 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", 46, 0); + setTextureOffset("Belt2.Shape13", 46, 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", -5.5F, -1.5F, -7F, 7, 9, 1); + Base.addBox("Shape2", -5.5F, -0.5F, -4F, 5, 8, 1); + Base.addBox("NewShape4", 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("PipeN1", -1.5F, -1.5F, 0F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN7", -2.5F, -2.5F, -1F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addBox("Shape1", 2F, -0.5F, 8.5F, 3, 1, 1); + RotatingPart2.addBox("Shape5", -0.5F, -5F, 8.5F, 1, 3, 1); + RotatingPart2.addBox("Shape8", -5F, -0.5F, 8.5F, 3, 1, 1); + RotatingPart2.addTube("PipeN4", -4F, -4F, 4F, 8, 8, 5, 0.3F,1F,ForgeDirection.NORTH); + RotatingPart2.addBox("Shape9", -0.5F, 2F, 8.5F, 1, 3, 1); + MotorPart1 = new IHLModelRenderer(this, "MotorPart1"); + MotorPart1.setRotationPoint(0F, 21F, 0F); + setRotation(MotorPart1, 0F, 0F, 0F); + MotorPart1.mirror = true; + MotorPart1.addTube("PipeN41", 3F, -2F, -8F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN12", 4F, -1F, -7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN13", 3F, -2F, -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", 0F, 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); + } + + 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/metallurgy/LathePart1TileEntity.java b/src/main/java/ihl/processing/metallurgy/LathePart1TileEntity.java new file mode 100644 index 0000000..788bfd4 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/LathePart1TileEntity.java @@ -0,0 +1,99 @@ +package ihl.processing.metallurgy; + +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.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +public class LathePart1TileEntity extends BasicElectricMotorTileEntity implements IWorkspaceElement{ + + public boolean ready=false; + + public LathePart1TileEntity() + { + super(); + } + + + @Override + public String getInventoryName() { + return "Lathe"; + } + + @Override + public void operate() + { + ready=true; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("lathePart1"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new LatheGui(new LatheContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new LatheContainer(player, this); + } + + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public List[] getInput() + { + return null; + } + + @Override + public boolean canOperate() + { + TileEntity te = worldObj.getTileEntity(xCoord+ForgeDirection.getOrientation(getFacing()).offsetX,yCoord,zCoord+ForgeDirection.getOrientation(getFacing()).offsetZ); + if(te!=null && te instanceof LathePart2TileEntity) + { + return !ready; + } + return false; + } + + @Override + public void onGuiClosed(EntityPlayer arg0) {} + + @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/metallurgy/LathePart2Model.java b/src/main/java/ihl/processing/metallurgy/LathePart2Model.java new file mode 100644 index 0000000..40b9b2a --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/LathePart2Model.java @@ -0,0 +1,87 @@ +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class LathePart2Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public LathePart2Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape1", 0, 0); + setTextureOffset("Base.Shape2", 38, 5); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape4", 0, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Base.PipeN7", 0, 0); + setTextureOffset("Base.Shape7", 0, 0); + setTextureOffset("Base.PipeW9", 0, 0); + setTextureOffset("Base.PipeW9", 0, 0); + setTextureOffset("Base.Shape9", 0, 0); + setTextureOffset("Base.Shape10", 0, 0); + setTextureOffset("Base.Shape11", 0, 0); + setTextureOffset("Base.Shape12", 0, 0); + setTextureOffset("Base.PipeW13", 0, 0); + setTextureOffset("Base.PipeN13", 0, 0); + setTextureOffset("Base.Shape13", 0, 0); + setTextureOffset("Base.Shape14", 0, 0); + setTextureOffset("Base.PipeU15", 0, 0); + setTextureOffset("Base.PipeU16", 0, 0); + setTextureOffset("Base.PipeU17", 0, 0); + setTextureOffset("Base.PipeU18", 0, 0); + setTextureOffset("Base.Shape15", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("Base.PipeW20", 0, 0); + setTextureOffset("Base.PipeW19", 0, 0); + setTextureOffset("Base.PipeN21", 0, 0); + setTextureOffset("Base.PipeN22", 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, 14, 1, 16); + Base.addBox("Shape1", 0F, 1F, 0F, 4, 1, 4); + Base.addBox("Shape2", -2F, 2F, 1F, 5, 1, 1); + Base.addBox("Shape3", 0F, 3F, 0F, 4, 2, 4); + Base.addBox("Shape4", 2F, 6F, -8F, 1, 1, 16); + Base.addBox("Shape5", 5F, 6F, -8F, 1, 1, 13); + Base.addTube("PipeN7", 3.5F, 6F, -7F, 1, 1, 12, 0F,1F,ForgeDirection.NORTH); + Base.addBox("Shape7", 3F, 6F, -8F, 2, 1, 1); + Base.addTube("PipeW9", 6F, 5F, 5F, 1, 3, 3, 0F,1F,ForgeDirection.WEST); + Base.addTube("PipeW9", 7F, 6F, 5.2F, 1, 1, 1, 0F,1F,ForgeDirection.WEST); + Base.addBox("Shape9", 3F, 5F, 5F, 3, 2, 3); + Base.addBox("Shape10", -2F, 5F, 0F, 8, 1, 1); + Base.addBox("Shape11", -2F, 5F, 3F, 8, 1, 1); + Base.addBox("Shape12", 1F, 5F, 1F, 2, 1, 2); + Base.addTube("PipeW13", -1F, 5F, 1.5F, 6, 1, 1, 0F,1F,ForgeDirection.WEST); + Base.addTube("PipeN13", -4F, 1F, 3F, 2, 2, 3, 0F,1F,ForgeDirection.NORTH); + Base.addBox("Shape13", -3.5F, 2F, 3.8F, 1, 5, 2); + Base.addBox("Shape14", -4.5F, 6F, 2F, 3, 1, 4); + Base.addTube("PipeU15", 0F, 2F, 3F, 1, 1, 1, 0F,1F,ForgeDirection.UP); + Base.addTube("PipeU16", 3F, 2F, 3F, 1, 1, 1, 0F,1F,ForgeDirection.UP); + Base.addTube("PipeU17", 3F, 2F, 0F, 1, 1, 1, 0F,1F,ForgeDirection.UP); + Base.addTube("PipeU18", 0F, 2F, 0F, 1, 1, 1, 0F,1F,ForgeDirection.UP); + Base.addBox("Shape15", 5F, 5F, 1F, 1, 1, 2); + Base.addBox("Shape16", -2F, 5F, 1F, 1, 1, 2); + Base.addTube("PipeW20", 6F, 4F, 0.5F, 1, 3, 3, 0F,1F,ForgeDirection.WEST); + Base.addTube("PipeW19", 7F, 5F, 0.8F, 1, 1, 1, 0F,1F,ForgeDirection.WEST); + Base.addTube("PipeN21", -4.5F, 0.5F, 6F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + Base.addTube("PipeN22", -3F, 1F, 7F, 1, 1, 1, 0F,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/metallurgy/LathePart2TileEntity.java b/src/main/java/ihl/processing/metallurgy/LathePart2TileEntity.java new file mode 100644 index 0000000..7d4dac7 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/LathePart2TileEntity.java @@ -0,0 +1,104 @@ +package ihl.processing.metallurgy; + +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 LathePart2TileEntity extends TileEntity implements IWrenchable, INetworkDataProvider{ + + private short facing=2; + private short lastFacing=2; + + public LathePart2TileEntity() + { + super(); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public List getNetworkedFields() + { + List fields = new ArrayList(); + fields.add("facing"); + return fields; + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(lastFacing!=facing) + { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing=facing; + } + } + + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + + @Override + public short getFacing() { + return this.facing; + } + + + @Override + public void setFacing(short facing1) + { + facing=(short) Math.max(2,facing1); + if(IC2.platform.isSimulating()) + { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing=facing; + } + } + + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + + @Override + public float getWrenchDropRate() { + return 1F; + } + + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("lathePart2"); + } + + @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/metallurgy/MachineBaseContainer.java b/src/main/java/ihl/processing/metallurgy/MachineBaseContainer.java new file mode 100644 index 0000000..d7e3ac7 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/MachineBaseContainer.java @@ -0,0 +1,74 @@ +package ihl.processing.metallurgy; + +import ic2.core.ContainerBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; + +public class MachineBaseContainer extends ContainerBase { + + protected MachineBaseTileEntity tileEntity; + public int lastProgress = -1; + private short lastEnergy; + private final static int height=166; + + public MachineBaseContainer(EntityPlayer entityPlayer, MachineBaseTileEntity 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)); + } + + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + if (this.tileEntity.getEnergy() != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy()); + } + } + 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; + case 1: + this.tileEntity.setEnergy(value); + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/src/main/java/ihl/processing/metallurgy/MachineBaseTileEntity.java b/src/main/java/ihl/processing/metallurgy/MachineBaseTileEntity.java new file mode 100644 index 0000000..79763b5 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/MachineBaseTileEntity.java @@ -0,0 +1,279 @@ +package ihl.processing.metallurgy; + +import java.util.List; + +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.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.chemistry.ApparatusProcessableInvSlot; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; + +public abstract class MachineBaseTileEntity extends TileEntityInventory implements IHasGui, IEnergySink +{ + public short progress; + protected short operationLength=200; + protected double energy; + public int maxStorage; + public int energyConsume; + public final ApparatusProcessableInvSlot input; + private boolean addedToEnergyNet=false; + + public MachineBaseTileEntity(int inputCount) + { + input = new ApparatusProcessableInvSlot(this, "input", 0, Access.IO, inputCount, 64); + maxStorage=128; + energyConsume=5; + } + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + return fields; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.progress = nbttagcompound.getShort("progress"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setShort("progress", this.progress); + } + + @Override + public void onLoaded() + { + super.onLoaded(); + if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + } + + @Override + public void onUnloaded() + { + if (IC2.platform.isSimulating()&&this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + + super.onUnloaded(); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=(short)side; + } + + @Override + public void setFacing(short facing1) + { + if (IC2.platform.isSimulating()&&this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + super.setFacing(facing1); + if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + public abstract String getStartSoundFile(); + + public abstract String getLoopSoundFile(); + + public abstract String getStopSoundFile(); + + @Override + public void updateEntityServer() + { + if(this.energy>this.maxStorage) + { + this.energy=this.maxStorage; + } + + 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.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); + } + } + + protected int mX() + { + switch(this.getFacing()) + { + case 4: + return 1; + case 5: + return -1; + default: + return 0; + } + } + + protected int mY() + { + switch(this.getFacing()) + { + case 0: + return -1; + case 1: + return 1; + default: + return 0; + } + } + + protected int mZ() + { + switch(this.getFacing()) + { + case 2: + return 1; + case 3: + return -1; + default: + return 0; + } + } + + @Override + public abstract String getInventoryName(); + + @Override + @SideOnly(Side.CLIENT) + public abstract GuiScreen getGui(EntityPlayer arg0, boolean arg1); + + @Override + public abstract ContainerBase getGuiContainer(EntityPlayer arg0); + + @Override + public void onGuiClosed(EntityPlayer arg0) {} + + public int gaugeProgressScaled(int i) + { + return this.progress * i / this.operationLength; + } + + public boolean canOperate() + { + return getOutput()!=null; + } + + public abstract UniversalRecipeOutput getOutput(); + + @SuppressWarnings("rawtypes") + public List[] getInput() + { + return new List[]{null, this.input.getItemStackList()}; + } + + + @Override + public double getDemandedEnergy() + { + return this.maxStorage - this.energy; + } + + @Override + public int getSinkTier() + { + return 4; + } + + @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 abstract void operate(); + public short getEnergy() { + return (short)this.energy; + } + public void setEnergy(int value) + { + this.energy=value; + } + public int getGUIEnergy(int i) { + if(this.energy 0D) + { + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(8, 6 + 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(70,34, 197, 0, i1 + 1, 13); + } + fontRendererObj.drawStringWithShadow(StatCollector.translateToLocal("ihl.gui.muffleFurnace"), 40, 12, 16768125); + + } + + @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(muffleFurnaceBackground); + 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/metallurgy/MuffleFurnanceContainer.java b/src/main/java/ihl/processing/metallurgy/MuffleFurnanceContainer.java new file mode 100644 index 0000000..1ae7203 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/MuffleFurnanceContainer.java @@ -0,0 +1,16 @@ +package ihl.processing.metallurgy; + +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; + +public class MuffleFurnanceContainer extends MachineBaseContainer { + + public MuffleFurnanceContainer(EntityPlayer entityPlayer, + MuffleFurnanceTileEntity tileEntity1) { + super(entityPlayer, tileEntity1); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 40, 22)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 1, 40, 40)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 98, 32)); + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java b/src/main/java/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java new file mode 100644 index 0000000..6f811cb --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java @@ -0,0 +1,119 @@ +package ihl.processing.metallurgy; + +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 ihl.IHLMod; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.recipes.RecipeOutputItemStack; +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 MuffleFurnanceTileEntity extends MachineBaseTileEntity { + + protected static UniversalRecipeManager recipeManager = new UniversalRecipeManager("mufflefurnace"); + public final IHLInvSlotOutput outputSlot; + + public MuffleFurnanceTileEntity() { + super(2); + this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 1); + } + + @Override + public String getStartSoundFile() { + return null; + } + + @Override + public String getLoopSoundFile() { + return null; + } + + @Override + public String getStopSoundFile() { + return null; + } + + @Override + public String getInventoryName() { + return "MuffleFurnance"; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new MuffleFurnaceGui(new MuffleFurnanceContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new MuffleFurnanceContainer(player, this); + } + + @Override + public boolean canOperate() { + ItemStack crucible = input.getItemStack(IHLMod.crucible); + if (crucible != null) { + return true; + } + ItemStack mold = input.getItemStack(IHLUtils.getThisModItem("injectionMold")); + if (mold != null) { + return true; + } + return getOutput() != null; + } + + @Override + public void operate() { + ItemStack crucible = input.getItemStack(IHLMod.crucible); + if (crucible != null) { + ((Crucible) crucible.getItem()).processContent(crucible, this); + return; + } + ItemStack mold = input.getItemStack(IHLUtils.getThisModItem("injectionMold")); + if (mold != null) { + mold.stackTagCompound.setBoolean("isContainStearin", false); + return; + } + List output = recipeManager + .getOutputFor(getInput()).getItemOutputs(); + List rinput = recipeManager.getRecipeInput(getInput()).getItemInputs(); + for (int i = 0; i < rinput.size(); i++) { + this.input.consume(rinput.get(i)); + } + this.outputSlot.add(output); + } + + public static void addRecipe(IRecipeInput recipeInputOreDict, ItemStack output) { + recipeManager.addRecipe(new UniversalRecipeInput(null, (new IRecipeInput[] { recipeInputOreDict })), + new UniversalRecipeOutput(null, (new ItemStack[] { output }), 20)); + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public UniversalRecipeOutput getOutput() { + return MuffleFurnanceTileEntity.recipeManager.getOutputFor(null, this.input.getItemStackList()); + } + + public static void addRecipe(UniversalRecipeInput universalRecipeInput, + UniversalRecipeOutput universalRecipeOutput) { + recipeManager.addRecipe(universalRecipeInput, universalRecipeOutput); + } + + public static void addRecipe(IRecipeInput recipeInputOreDict, ItemStack output, float f) { + recipeManager.addRecipe(new UniversalRecipeInput(null, (new IRecipeInput[] { recipeInputOreDict })), new UniversalRecipeOutput( + null, (new RecipeOutputItemStack[] { new RecipeOutputItemStack(output, f) }), 20)); + } +} diff --git a/src/main/java/ihl/processing/metallurgy/RollingMachineContainer.java b/src/main/java/ihl/processing/metallurgy/RollingMachineContainer.java new file mode 100644 index 0000000..7a83d9d --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/RollingMachineContainer.java @@ -0,0 +1,75 @@ +package ihl.processing.metallurgy; + +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 RollingMachineContainer extends ContainerBase { + + public RollingMachinePart1TileEntity tileEntity; + public int lastProgress = -1; + private short lastEnergy = -1; + private final static int height=166; + + public RollingMachineContainer(EntityPlayer entityPlayer, + RollingMachinePart1TileEntity 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, 54, 25)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.output, 0, 105, 25)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.dischargeSlot,0, 22, 55)); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + if (this.tileEntity.getEnergy() != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy()); + } + } + this.lastProgress = this.tileEntity.progress; + this.lastEnergy = (short) this.tileEntity.getEnergy(); + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + + switch (index) + { + case 0: + this.tileEntity.progress=(short) value; + break; + case 1: + this.tileEntity.setEnergy(value); + break; + } + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/RollingMachineGui.java b/src/main/java/ihl/processing/metallurgy/RollingMachineGui.java new file mode 100644 index 0000000..a792bd3 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/RollingMachineGui.java @@ -0,0 +1,50 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; + +public class RollingMachineGui extends GuiContainer { + + private RollingMachineContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUIRollingMachine.png"); + + public RollingMachineGui(RollingMachineContainer 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(39, 55 + 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(50),50); + this.drawTexturedModalRect(64, 63, 197, 0, i1 + 1, 13); + } + } + + @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/metallurgy/RollingMachinePart1Model.java b/src/main/java/ihl/processing/metallurgy/RollingMachinePart1Model.java new file mode 100644 index 0000000..fe062f8 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/RollingMachinePart1Model.java @@ -0,0 +1,97 @@ +package ihl.processing.metallurgy; + + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + + +public class RollingMachinePart1Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer RotatingPart1; + IHLModelRenderer Plate; + + public RollingMachinePart1Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Base.Shape8", 0, 0); + setTextureOffset("Base.Shape11", 0, 0); + setTextureOffset("Base.Shape9", 0, 0); + setTextureOffset("RotatingPart2.PipeN7", 0, 0); + setTextureOffset("RotatingPart2.PipeN17", 0, 0); + setTextureOffset("RotatingPart2.Shape3", 0, 0); + setTextureOffset("RotatingPart2.Shape12", 0, 0); + 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("RotatingPart1.Shape1", 0, 0); + setTextureOffset("RotatingPart1.Shape2", 0, 0); + setTextureOffset("RotatingPart1.Shape13", 0, 0); + setTextureOffset("Plate.Shape14", 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("Shape16", -3F, -7F, -6F, 9, 14, 1); + Base.addBox("Shape5", 2F, -1F, -5F, 6, 1, 13); + Base.addBox("Shape8", -8F, -1F, -5F, 6, 1, 13); + Base.addBox("Shape11", 3F, 0F, 7F, 4, 7, 1); + Base.addBox("Shape9", -7F, 0F, 7F, 4, 7, 1); + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(0F, 16F, -7F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = true; + RotatingPart2.addTube("PipeN7", -5.5F, -5.5F, -0.9F, 11, 11, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN17", -2F, -2F, 2F, 4, 4, 26, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("Shape3", -2.5F, -2.5F, 0F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("Shape12", -1F, -1F, 28F, 2, 2, 3, 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); + RotatingPart1 = new IHLModelRenderer(this, "RotatingPart1"); + RotatingPart1.setRotationPoint(0F, 11.9F, -5F); + setRotation(RotatingPart1, 0F, 0F, 0F); + RotatingPart1.mirror = true; + RotatingPart1.addTube("Shape1", -2F, -2F, 0F, 4, 4, 26, 0F,1F,ForgeDirection.NORTH); + RotatingPart1.addTube("Shape2", -2.5F, -2.5F, -1.9F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart1.addTube("Shape13", -1F, -1F, 26F, 2, 2, 3, 0F,1F,ForgeDirection.NORTH); + Plate = new IHLModelRenderer(this, "Plate"); + Plate.setRotationPoint(0F, 13.5F, 0F); + setRotation(Plate, 0F, 0F, 0F); + Plate.mirror = true; + Plate.addBox("Shape14", -18F, 0F, 0F, 16, 1, 16); + } + + 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/metallurgy/RollingMachinePart1TileEntity.java b/src/main/java/ihl/processing/metallurgy/RollingMachinePart1TileEntity.java new file mode 100644 index 0000000..da60877 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/RollingMachinePart1TileEntity.java @@ -0,0 +1,149 @@ +package ihl.processing.metallurgy; + +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.block.invslot.InvSlot.Access; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.recipes.RecipeOutputItemStack; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +public class RollingMachinePart1TileEntity extends BasicElectricMotorTileEntity{ + + public final ApparatusProcessableInvSlot input; + public final IHLInvSlotOutput output; + public boolean assembled; + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("rollingmachine"); + + public RollingMachinePart1TileEntity() + { + super(); + input = new ApparatusProcessableInvSlot(this, "input", 1, Access.IO, 1, 64); + output = new IHLInvSlotOutput(this, "output", 2, 1); + } + + public UniversalRecipeOutput getOutput() + { + return RollingMachinePart1TileEntity.recipeManager.getOutputFor(this.getInput()); + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("assembled"); + return fields; + } + + + @Override + public String getInventoryName() { + return "RollingMachine"; + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if(assembled && !this.checkCorrectAccembly()) + { + assembled=false; + IC2.network.get().updateTileEntityField(this, "assembled"); + } + else if(!assembled && this.checkCorrectAccembly()) + { + assembled=true; + IC2.network.get().updateTileEntityField(this, "assembled"); + } + if (this.getActive() && this.progress == 0 && !this.canOperate()) + { + this.setActive(false); + } + + if (!this.getActive() && this.progress>0 && this.canOperate()) + { + this.setActive(true); + } + + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("rollingMachinePart1"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new RollingMachineGui(new RollingMachineContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new RollingMachineContainer(player, this); + } + + @Override + public void operate() + { + List rinput = recipeManager.getRecipeInput(getInput()).getItemInputs(); + List output = RollingMachinePart1TileEntity.recipeManager.getOutputFor(getInput()).getItemOutputs(); + this.output.add(output); + this.input.consume(rinput.get(0)); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public List[] getInput() + { + return new List[]{null, Arrays.asList(new ItemStack[] {input.get()})}; + } + + @Override + public boolean canOperate() + { + return this.getOutput()!=null && this.output.canAdd(this.getOutput().getItemOutputs()) && checkCorrectAccembly(); + } + + private boolean checkCorrectAccembly() + { + TileEntity te = worldObj.getTileEntity(xCoord+ForgeDirection.getOrientation(getFacing()).offsetX,yCoord+ForgeDirection.getOrientation(getFacing()).offsetY,zCoord+ForgeDirection.getOrientation(getFacing()).offsetZ); + return te!=null && te instanceof RollingMachinePart2TileEntity && ((RollingMachinePart2TileEntity)te).getFacing()==this.getFacing(); + } + + @Override + public void onGuiClosed(EntityPlayer arg0) {} + + public static void addRecipe(ItemStack input, ItemStack output) + { + recipeManager.addRecipe(new UniversalRecipeInput(null, (new ItemStack [] {input})), new UniversalRecipeOutput(null, (new ItemStack[] {output}), 20)); + } + + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/RollingMachinePart2Model.java b/src/main/java/ihl/processing/metallurgy/RollingMachinePart2Model.java new file mode 100644 index 0000000..39fd1f5 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/RollingMachinePart2Model.java @@ -0,0 +1,42 @@ +package ihl.processing.metallurgy; + + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; + +public class RollingMachinePart2Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public RollingMachinePart2Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Base.Shape8", 0, 0); + setTextureOffset("Base.Shape11", 0, 0); + setTextureOffset("Base.Shape9", 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("Shape16", -3F, -7F, 5F, 6, 14, 1); + Base.addBox("Shape5", 2F, -1F, -8F, 6, 1, 13); + Base.addBox("Shape8", -8F, -1F, -8F, 6, 1, 13); + Base.addBox("Shape11", 3F, 0F, -8F, 4, 7, 1); + Base.addBox("Shape9", -7F, 0F, -8F, 4, 7, 1); + } + + 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/metallurgy/RollingMachinePart2TileEntity.java b/src/main/java/ihl/processing/metallurgy/RollingMachinePart2TileEntity.java new file mode 100644 index 0000000..13f4f6c --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/RollingMachinePart2TileEntity.java @@ -0,0 +1,104 @@ +package ihl.processing.metallurgy; + +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 RollingMachinePart2TileEntity extends TileEntity implements IWrenchable, INetworkDataProvider{ + + private short facing=2; + private short lastFacing=2; + + public RollingMachinePart2TileEntity() + { + super(); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public List getNetworkedFields() + { + List fields = new ArrayList(); + fields.add("facing"); + return fields; + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(lastFacing!=facing) + { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing=facing; + } + } + + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + + @Override + public short getFacing() { + return this.facing; + } + + + @Override + public void setFacing(short facing1) + { + facing=(short) Math.max(2,facing1); + if(IC2.platform.isSimulating()) + { + IC2.network.get().updateTileEntityField(this, "facing"); + } + } + + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + + @Override + public float getWrenchDropRate() { + return 1F; + } + + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("rollingMachinePart2"); + } + + @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/metallurgy/RollingMachineRender.java b/src/main/java/ihl/processing/metallurgy/RollingMachineRender.java new file mode 100644 index 0000000..f347a73 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/RollingMachineRender.java @@ -0,0 +1,81 @@ +package ihl.processing.metallurgy; +import org.lwjgl.opengl.GL11; + +import ic2.api.tile.IWrenchable; +import ihl.IHLModInfo; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; + +public class RollingMachineRender extends TileEntitySpecialRenderer{ +private RollingMachinePart1Model model = new RollingMachinePart1Model(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png"); +private final float scale=1F/16F; + + public RollingMachineRender() {} + + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par8) + { + int rotation = 0; + if(tile.getWorldObj() != null) + { + switch (((IWrenchable)tile).getFacing()) + { + case 2: + rotation = 0; + break; + case 5: + rotation = 1; + break; + case 3: + rotation = 2; + break; + case 4: + rotation = 3; + break; + default: + rotation = 0; + } + } + else + { + return; + } + RollingMachinePart1TileEntity cte = (RollingMachinePart1TileEntity)tile; + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F); + + bindTexture(tex); + model.Base.render(scale); + if(cte.getActive()) + { + model.RotatingPart1.rotateAngleZ-=0.01F; + model.RotatingPart2.rotateAngleZ+=0.01F; + model.RotatingPart1.render(scale); + model.RotatingPart2.render(scale); + model.MotorPart1.rotateAngleZ-=0.03F; + model.MotorPart1.render(scale); + model.MotorPart2.render(scale); + model.Plate.offsetX+=0.001F; + if(model.Plate.offsetX>1F){model.Plate.offsetX=0;} + model.Plate.render(scale); + } + else + { + model.Plate.offsetX=0F; + if(cte.assembled) + { + model.RotatingPart1.render(scale); + model.RotatingPart2.render(scale); + } + model.MotorPart1.render(scale); + model.MotorPart2.render(scale); + } + GL11.glPopMatrix(); //end + + } +} \ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/VulcanizationExtrudingMoldModel.java b/src/main/java/ihl/processing/metallurgy/VulcanizationExtrudingMoldModel.java new file mode 100644 index 0000000..9ce0f01 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/VulcanizationExtrudingMoldModel.java @@ -0,0 +1,54 @@ +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class VulcanizationExtrudingMoldModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public VulcanizationExtrudingMoldModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("Base.PipeW161", 0, 0); + setTextureOffset("Base.PipeN16", 0, 0); + setTextureOffset("Base.PipeW15", 22, 22); + setTextureOffset("Base.PipeW17", 0, 0); + setTextureOffset("Base.Shape14", 0, 0); + setTextureOffset("Base.PipeN14", 0, 0); + setTextureOffset("Base.Shape2", 0, 0); + setTextureOffset("Base.Shape4", 42, 17); + setTextureOffset("Base.Shape5", 37, 17); + + 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", 6.9F, 3F, -1.5F, 1, 4, 3); + Base.addTube("PipeW161", -7F, 0.5F, -1.5F, 15, 3, 3, 0.5F,1F,ForgeDirection.WEST); + Base.addTube("PipeN16", -4.5F, 0.5F, -6F, 3, 3, 6, 0.8F,1F,ForgeDirection.NORTH); + Base.addTube("PipeW15", -5.5F, -0.5F, -2.5F, 12, 5, 5, 0.5F,1F,ForgeDirection.WEST); + Base.addTube("PipeW17", -8F, -0.5F, -2.5F, 1, 5, 5, 0.1F,1F,ForgeDirection.WEST); + Base.addBox("Shape14", -5F, 3F, -4.9F, 4, 4, 1); + Base.addTube("PipeN14", -5.5F, -0.5F, -8F, 5, 5, 1, 0.5F,1F,ForgeDirection.NORTH); + Base.addBox("Shape2", -7F, 3F, -1.5F, 1, 4, 3); + Base.addBox("Shape4", 5F, 3F, 1F, 1, 4, 1); + Base.addBox("Shape5", 5F, 6F, 2F, 3, 1, 1); + } + + 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/metallurgy/VulcanizationExtrudingMoldTileEntity.java b/src/main/java/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java new file mode 100644 index 0000000..bb51ced --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java @@ -0,0 +1,256 @@ +package ihl.processing.metallurgy; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergySink; +import ic2.api.network.INetworkDataProvider; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ihl.items_blocks.FlexibleCableItem; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +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.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class VulcanizationExtrudingMoldTileEntity extends TileEntity + implements IWrenchable, INetworkDataProvider, IEnergySink, IProductionLine, IFluidHandler { + + private short facing = 2; + private short lastFacing = 2; + public double energy; + public int maxStorage = 64; + private double energyConsume = 16D; + private boolean addedToEnergyNet = false; + private FluidTank fluidTank = new FluidTank(5000); + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager( + "vulcanizationextrudingmold"); + + public VulcanizationExtrudingMoldTileEntity() { + super(); + } + + public static void addRecipe(FluidStack inputFluid, ItemStack input, ItemStack output1) { + recipeManager.addRecipe( + new UniversalRecipeInput((new FluidStack[] { inputFluid }), + (new IRecipeInput[] { new RecipeInputItemStack(input) })), + new UniversalRecipeOutput(null, (new ItemStack[] { output1 }), 200)); + } + + public boolean enableUpdateEntity() { + return IC2.platform.isSimulating(); + } + + @Override + public void invalidate() { + if (IC2.platform.isSimulating() && this.addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + super.invalidate(); + } + + @Override + public List getNetworkedFields() { + List fields = new ArrayList(); + fields.add("facing"); + return fields; + } + + @Override + public void updateEntity() { + super.updateEntity(); + if (IC2.platform.isSimulating() && !this.addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + + 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) { + if (IC2.platform.isSimulating() && this.addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + facing = (short) Math.max(2, facing1); + if (IC2.platform.isSimulating()) { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing = facing; + } + if (IC2.platform.isSimulating() && !this.addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + } + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + @Override + public float getWrenchDropRate() { + return 1F; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("vulcanizationExtrudingMold"); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + super.readFromNBT(nbttagcompound); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + facing = nbttagcompound.getShort("facing"); + energy = nbttagcompound.getDouble("energy"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + nbttagcompound.setShort("facing", facing); + nbttagcompound.setDouble("energy", this.energy); + } + + @Override + public double getDemandedEnergy() { + return this.maxStorage - this.energy; + } + + @Override + public int getSinkTier() { + return 4; + } + + @Override + public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { + if (this.energy < this.maxStorage) { + this.energy += amount; + return 0.0D; + } else { + return amount; + } + } + + @Override + public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { + return true; + } + + private ItemStack processWire(ItemStack wire, boolean doProcess) { + UniversalRecipeOutput rOutput = VulcanizationExtrudingMoldTileEntity.recipeManager.getOutputFor( + Arrays.asList(new FluidStack[] { this.fluidTank.getFluid() }), Arrays.asList(new ItemStack[] { wire })); + if (rOutput == null || this.energy < this.energyConsume) { + return wire; + } + UniversalRecipeInput rInput = VulcanizationExtrudingMoldTileEntity.recipeManager.getRecipeInput( + Arrays.asList(new FluidStack[] { this.fluidTank.getFluid() }), Arrays.asList(new ItemStack[] { wire })); + ItemStack cableAsRO = rOutput.getItemOutputs().get(0).itemStack; + ItemStack cable = wire.copy(); + FlexibleCableItem fci = (FlexibleCableItem) cableAsRO.getItem(); + cable.stackTagCompound.setString("insulationMaterial", fci.getInsulationMaterial(cableAsRO)); + cable.stackTagCompound.setInteger("insulationThickness", fci.getInsulationThickness(cableAsRO)); + cable.stackTagCompound.setInteger("maxVoltage", IHLUtils + .getInsulationMaxVoltage(fci.getInsulationMaterial(cableAsRO), fci.getInsulationThickness(cableAsRO))); + if (doProcess) { + this.energy -= this.energyConsume; + this.fluidTank.drain(rInput.getFluidInputs().get(0).getAmount() * IHLUtils.getWireLength(cable), true); + } + return cable; + } + + @Override + public boolean canProcess(ItemStack wire) { + ItemStack cable = this.processWire(wire, false); + ForgeDirection dir = ForgeDirection.getOrientation(getFacing()).getRotation(ForgeDirection.UP); + TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ); + if (te instanceof IProductionLine) { + if (ForgeDirection.getOrientation(((IProductionLine) te).getFacing()) + .equals(dir.getRotation(ForgeDirection.DOWN))) { + return ((IProductionLine) te).canProcess(cable); + } + } + return false; + } + + @Override + public void process(ItemStack wire) { + ItemStack cable = this.processWire(wire, true); + ForgeDirection dir = ForgeDirection.getOrientation(getFacing()).getRotation(ForgeDirection.UP); + TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ); + if (te instanceof IProductionLine && ForgeDirection.getOrientation(((IProductionLine) te).getFacing()) + .equals(dir.getRotation(ForgeDirection.DOWN))) { + ((IProductionLine) te).process(cable); + } + } + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return false; + } + + @Override + public boolean canFill(ForgeDirection arg0, Fluid arg1) { + return ForgeDirection.getOrientation(this.facing) == arg0; + } + + @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 arg0, FluidStack arg1, boolean arg2) { + return this.fluidTank.fill(arg1, arg2); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) { + return new FluidTankInfo[] {this.fluidTank.getInfo()}; + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } +} diff --git a/src/main/java/ihl/processing/metallurgy/WireMillContainer.java b/src/main/java/ihl/processing/metallurgy/WireMillContainer.java new file mode 100644 index 0000000..34f79de --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WireMillContainer.java @@ -0,0 +1,113 @@ +package ihl.processing.metallurgy; + +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 WireMillContainer extends ContainerBase { + + public WireMillTileEntity tileEntity; + public int lastProgress = -1; + private 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; + private final static int height=166; + public List fluidTankFluidList; + public List fluidTankFluidList2; + public List fluidTankFluidList3; + + public WireMillContainer(EntityPlayer entityPlayer, + WireMillTileEntity lathePart1TileEntity) { + super(lathePart1TileEntity); + tileEntity=lathePart1TileEntity; + fluidTankFluidList = this.tileEntity.waterFluidTank.getFluidList(); + fluidTankFluidList2 = this.tileEntity.oilFluidTank.getFluidList(); + fluidTankFluidList3 = this.tileEntity.metalFluidTank.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(tileEntity.dice, 0, 99+18, 31)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.drainInputSlot, 0, 26+18, 14)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.fillInputSlot, 0, 26+18, 50)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.emptyFluidItemsSlot, 0, 26+18, 32)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.dischargeSlot,0, 8, 14)); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + if (this.tileEntity.getEnergy() != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy()); + } + + if (this.tileEntity.waterFluidTank.getFluidAmount() != this.lastFluidAmount || this.tileEntity.waterFluidTank.getNumberOfFluids() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + + if (this.tileEntity.oilFluidTank.getFluidAmount() != this.lastFluidAmount2 || this.tileEntity.oilFluidTank.getNumberOfFluids() != this.lastNumberOfFluids2) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList2"); + } + + if (this.tileEntity.metalFluidTank.getFluidAmount() != this.lastFluidAmount3 || this.tileEntity.metalFluidTank.getNumberOfFluids() != this.lastNumberOfFluids3) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList3"); + } + } + this.lastNumberOfFluids = this.tileEntity.waterFluidTank.getNumberOfFluids(); + this.lastFluidAmount = this.tileEntity.waterFluidTank.getFluidAmount(); + this.lastNumberOfFluids2 = this.tileEntity.oilFluidTank.getNumberOfFluids(); + this.lastFluidAmount2 = this.tileEntity.oilFluidTank.getFluidAmount(); + this.lastNumberOfFluids3 = this.tileEntity.metalFluidTank.getNumberOfFluids(); + this.lastFluidAmount3 = this.tileEntity.metalFluidTank.getFluidAmount(); + this.lastProgress = this.tileEntity.progress; + this.lastEnergy = (short) this.tileEntity.getEnergy(); + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + switch (index) + { + case 0: + this.tileEntity.progress=(short) value; + break; + case 1: + this.tileEntity.setEnergy(value); + break; + } + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/WireMillGui.java b/src/main/java/ihl/processing/metallurgy/WireMillGui.java new file mode 100644 index 0000000..8a3d583 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WireMillGui.java @@ -0,0 +1,68 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +import ihl.utils.IHLRenderUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class WireMillGui extends GuiContainer { + + private WireMillContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUIWireMill.png"); + + public WireMillGui(WireMillContainer latheContainer) { + super(latheContainer); + container = latheContainer; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(tex); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.9F); + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(27, 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(134, 33, 198, 0, i1 + 1, 13); + } + if (this.container.tileEntity.oilFluidTank.getFluid()!=null && this.container.tileEntity.oilFluidTank.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.oilFluidTank, 81, 16, 93, 63, zLevel, par1, par2, xOffset, yOffset); + } + if (this.container.tileEntity.waterFluidTank.getFluid()!=null && this.container.tileEntity.waterFluidTank.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.waterFluidTank, 64, 16, 76, 63, zLevel, par1, par2, xOffset, yOffset); + } + if (this.container.tileEntity.metalFluidTank.getFluid()!=null && this.container.tileEntity.metalFluidTank.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.metalFluidTank, 98, 16, 110, 63, zLevel, par1, par2, xOffset, yOffset); + } + + this.mc.renderEngine.bindTexture(tex); + IHLRenderUtils.instance.drawTooltip(par1,par2,9,11,xOffset,yOffset,StatCollector.translateToLocal("ihl.wiremill.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); + } +} diff --git a/src/main/java/ihl/processing/metallurgy/WireMillTileEntity.java b/src/main/java/ihl/processing/metallurgy/WireMillTileEntity.java new file mode 100644 index 0000000..d93eb4f --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WireMillTileEntity.java @@ -0,0 +1,378 @@ +package ihl.processing.metallurgy; + +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.api.recipe.RecipeInputOreDict; +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.items_blocks.IHLTool; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.recipes.IRecipeInputFluid; +import ihl.recipes.RecipeInputDie; +import ihl.recipes.RecipeInputFluidDictionary; +import ihl.recipes.RecipeInputFluidStack; +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 WireMillTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler{ + + public final ApparatusProcessableInvSlot dice; + public final InvSlotConsumableLiquidIHL fillInputSlot; + public final InvSlotConsumableLiquidIHL drainInputSlot; + public final InvSlotOutput emptyFluidItemsSlot; + public final IHLFluidTank oilFluidTank = new IHLFluidTank(1100); + public final IHLFluidTank waterFluidTank = new IHLFluidTank(1100); + public final IHLFluidTank metalFluidTank = new IHLFluidTank(1100); + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("wiremill"); + protected static final UniversalRecipeManager recipeManagerMelting = new UniversalRecipeManager("wiremillMelting"); + + public WireMillTileEntity() + { + super(); + emptyFluidItemsSlot = new InvSlotOutput(this, "emptyWaterFluidItemsSlot", 2, 1); + fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Drain, "ingot"); + dice = new ApparatusProcessableInvSlot(this, "dice", 3, Access.IO, 1, 64); + this.operationLength=600; + } + + + @Override + public String getInventoryName() { + return "WireMill"; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("wireMill"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) + { + return new WireMillGui(new WireMillContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) + { + return new WireMillContainer(player, this); + } + + @Override + public void operate() + { + UniversalRecipeInput rInput = WireMillTileEntity.recipeManager.getRecipeInput(getInput()); + IRecipeInput rInputDice = rInput.getItemInputs().get(0); + UniversalRecipeOutput rOutput = this.getOutput(); + ItemStack rOutputItemStack=null; + if(!rOutput.getItemOutputs().isEmpty()) + { + rOutputItemStack = rOutput.getItemOutputs().get(0).itemStack.copy(); + } + List rInputFluidStacks = rInput.getFluidInputs(); + int consumeMoltenMetalAmount=1; + if(!rInputFluidStacks.isEmpty() && rOutputItemStack!=null && rInputDice!=null && rInputDice instanceof RecipeInputDie) + { + if(rInputFluidStacks.size()>=3) + { + consumeMoltenMetalAmount=rInputFluidStacks.get(2).getAmount(); + } + else + { + consumeMoltenMetalAmount=rInputFluidStacks.get(0).getAmount(); + } + if(rOutputItemStack!=null && rInputDice!=null && rInputDice instanceof RecipeInputDie) + { + consumeMoltenMetalAmount*=((RecipeInputDie)rInputDice).transformOutput(this.dice.get(), rOutputItemStack); + } + } + if(dice.get()!=null) + { + if(dice.get().getItem() instanceof IHLTool) + { + IHLUtils.damageItemViaNBTTag(dice.get(), 1); + if(dice.get().stackSize<=0) + { + dice.put(null); + } + } + else + { + dice.consume(rInputDice); + } + } + if(this.drainInputSlot.get()!=null && !rInput.getItemInputs().isEmpty() && rInput.getItemInputs().get(0).matches(this.drainInputSlot.get())) + { + this.drainInputSlot.consume(1); + } + if(!rOutput.getFluidOutputs().isEmpty()) + { + this.metalFluidTank.fill(rOutput.getFluidOutputs().get(0), true); + } + TileEntity te = worldObj.getTileEntity(xCoord+ForgeDirection.getOrientation(getFacing()).offsetX,yCoord+ForgeDirection.getOrientation(getFacing()).offsetY,zCoord+ForgeDirection.getOrientation(getFacing()).offsetZ); + if(rOutputItemStack!=null && te instanceof IProductionLine) + { + if(!rInputFluidStacks.isEmpty()) + { + this.oilFluidTank.drain(1, true); + this.waterFluidTank.drain(1, true); + this.metalFluidTank.drain(consumeMoltenMetalAmount, true); + } + ((IProductionLine)te).process(rOutputItemStack); + } + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public List[] getInput() + { + return new List[]{Arrays.asList(new FluidStack[] {this.oilFluidTank.getFluid(),this.waterFluidTank.getFluid(),this.metalFluidTank.getFluid()}),Arrays.asList(new ItemStack[] {dice.get(),drainInputSlot.get()})}; + } + + public UniversalRecipeOutput getOutput() + { + return WireMillTileEntity.recipeManager.getOutputFor(this.getInput()); + } + + public static void addRecipe(FluidStack moltenMetal, IRecipeInput inputDice,ItemStack output1) + { + recipeManager.addRecipe(new UniversalRecipeInput((new IRecipeInputFluid[] {new RecipeInputFluidDictionary("lubricant", 1),new RecipeInputFluidDictionary("water", 1),new RecipeInputFluidStack(moltenMetal)}),(new IRecipeInput[] {inputDice})),new UniversalRecipeOutput(null,(new ItemStack[] {output1}),200)); + } + + public static void addRecipe(String string, FluidStack fluidStack) + { + recipeManager.addRecipe(new UniversalRecipeInput(null, (new IRecipeInput [] {new RecipeInputOreDict(string)})),new UniversalRecipeOutput((new FluidStack[] {fluidStack}),null,200)); + } + + + @Override + public boolean canOperate() + { + UniversalRecipeOutput output = this.getOutput(); + if(output!=null) + { + ForgeDirection dir = ForgeDirection.getOrientation(getFacing()).getRotation(ForgeDirection.DOWN); + TileEntity te = worldObj.getTileEntity(xCoord+ForgeDirection.getOrientation(getFacing()).offsetX,yCoord+ForgeDirection.getOrientation(getFacing()).offsetY,zCoord+ForgeDirection.getOrientation(getFacing()).offsetZ); + if(te instanceof IProductionLine && !output.getItemOutputs().isEmpty()) + { + ItemStack isOut=this.getOutput().getItemOutputs().get(0).itemStack.copy(); + if(this.dice.get()!=null) + { + isOut.stackTagCompound.setInteger("transverseSection", this.dice.get().stackTagCompound.getInteger("transverseSection")); + } + return ForgeDirection.getOrientation(((IProductionLine)te).getFacing()).equals(dir) && ((IProductionLine)te).canProcess(isOut); + } + else if(!output.getFluidOutputs().isEmpty()) + { + FluidStack fstack = output.getFluidOutputs().get(0); + return metalFluidTank.fill(fstack, false)==fstack.amount; + } + } + return false; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.oilFluidTank.readFromNBT(nbttagcompound.getCompoundTag("oilFluidTank")); + this.waterFluidTank.readFromNBT(nbttagcompound.getCompoundTag("waterFluidTank")); + this.metalFluidTank.readFromNBT(nbttagcompound.getCompoundTag("metalFluidTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound oilFluidTankTag = new NBTTagCompound(); + this.oilFluidTank.writeToNBT(oilFluidTankTag); + nbttagcompound.setTag("oilFluidTank", oilFluidTankTag); + NBTTagCompound waterFluidTankTag = new NBTTagCompound(); + this.waterFluidTank.writeToNBT(waterFluidTankTag); + nbttagcompound.setTag("waterFluidTank", waterFluidTankTag); + NBTTagCompound metalFluidTankTag = new NBTTagCompound(); + this.metalFluidTank.writeToNBT(metalFluidTankTag); + nbttagcompound.setTag("metalFluidTank", metalFluidTankTag); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + FluidStack drainSlotContent = drainInputSlot.drain(null, Integer.MAX_VALUE, null, true); + if(drainSlotContent!=null) + { + String fluidDictionaryName = IHLMod.fluidDictionary.getFluidName(drainSlotContent.getFluid()); + if(fluidDictionaryName!=null && fluidDictionaryName.equals("lubricant")) + { + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, oilFluidTank); + } + else if(fluidDictionaryName!=null && fluidDictionaryName.equals("water")) + { + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, waterFluidTank); + } + else + { + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, metalFluidTank); + } + } + else + { + if(metalFluidTank.getNumberOfFluids()>0) + { + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, metalFluidTank); + } + else if(oilFluidTank.getNumberOfFluids()>0) + { + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, oilFluidTank); + } + else + { + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, waterFluidTank); + } + } + + } + public int gaugeLiquidScaled(int i) { + if(this.oilFluidTank.getFluid()!=null) + { + return this.oilFluidTank.getFluidAmount() * i /this.oilFluidTank.getCapacity(); + } + else + { + return 0; + } + } + + @Override + public int gaugeProgressScaled(int i) + { + return this.progress * i / this.operationLength; + } + + public int gaugeWaterScaled(int i) + { + if(this.waterFluidTank.getFluid()!=null) + { + return this.waterFluidTank.getFluidAmount() * i /this.waterFluidTank.getCapacity(); + } + else + { + return 0; + } + } + + public static Map getRecipes() + { + return recipeManager.getRecipes(); + } + + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return true; + } + + + @Override + public boolean canFill(ForgeDirection arg0, Fluid arg1) { + return true; + } + + + @Override + public FluidStack drain(ForgeDirection direction, FluidStack arg1, boolean arg2) + { + if(direction.equals(ForgeDirection.DOWN)) + { + return this.metalFluidTank.drain(arg1, arg2); + } + else if(direction.equals(ForgeDirection.UP)) + { + return this.waterFluidTank.drain(arg1, arg2); + } + else + { + return this.oilFluidTank.drain(arg1, arg2); + } + } + + + @Override + public FluidStack drain(ForgeDirection direction, int arg1, boolean arg2) + { + if(direction.equals(ForgeDirection.DOWN)) + { + return this.metalFluidTank.drain(arg1, arg2); + } + else if(direction.equals(ForgeDirection.UP)) + { + return this.waterFluidTank.drain(arg1, arg2); + } + else + { + return this.oilFluidTank.drain(arg1, arg2); + } + } + + + @Override + public int fill(ForgeDirection direction, FluidStack arg1, boolean arg2) + { + if(direction.equals(ForgeDirection.DOWN)) + { + return this.metalFluidTank.fill(arg1, arg2); + } + else if(direction.equals(ForgeDirection.UP)) + { + return this.waterFluidTank.fill(arg1, arg2); + } + else + { + return this.oilFluidTank.fill(arg1, arg2); + } + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection direction) + { + if(direction.equals(ForgeDirection.DOWN)) + { + return new FluidTankInfo[] {this.metalFluidTank.getInfo()}; + } + else if(direction.equals(ForgeDirection.UP)) + { + return new FluidTankInfo[] {this.waterFluidTank.getInfo()}; + } + else + { + return new FluidTankInfo[] {this.oilFluidTank.getInfo()}; + } + } +} diff --git a/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineContainer.java b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineContainer.java new file mode 100644 index 0000000..ba191f8 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineContainer.java @@ -0,0 +1,77 @@ +package ihl.processing.metallurgy; + +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 WoodenRollingMachineContainer extends ContainerBase { + + public WoodenRollingMachinePart1TileEntity tileEntity; + public int lastProgress = -1; + private short lastEnergy = -1; + private final static int height=166; + + public WoodenRollingMachineContainer(EntityPlayer entityPlayer, + WoodenRollingMachinePart1TileEntity 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.output, 0, 54, 25)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.input, 0, 123, 15)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.input, 1, 123, 34)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.input, 2, 123, 53)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.dischargeSlot,0, 22, 55)); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + if (this.tileEntity.getEnergy() != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy()); + } + } + this.lastProgress = this.tileEntity.progress; + this.lastEnergy = (short) this.tileEntity.getEnergy(); + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + + switch (index) + { + case 0: + this.tileEntity.progress=(short) value; + break; + case 1: + this.tileEntity.setEnergy(value); + break; + } + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineGui.java b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineGui.java new file mode 100644 index 0000000..085dae5 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineGui.java @@ -0,0 +1,60 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; + +public class WoodenRollingMachineGui extends GuiContainer { + + private WoodenRollingMachineContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUIWoodenRollingMachine.png"); + + public WoodenRollingMachineGui(WoodenRollingMachineContainer 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(39, 55 + 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(18, 22, 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/metallurgy/WoodenRollingMachinePart1Model.java b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart1Model.java new file mode 100644 index 0000000..ac7799b --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart1Model.java @@ -0,0 +1,122 @@ +// Date: 15.02.2015 11:28:39 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class WoodenRollingMachinePart1Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer RotatingPart1; + IHLModelRenderer RotatingPart3; + IHLModelRenderer RotatingPart4; + IHLModelRenderer Belt1; + IHLModelRenderer Belt2; + + public WoodenRollingMachinePart1Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 15); + setTextureOffset("Base.Shape16", 0, 23); + setTextureOffset("Base.PipeN18", 0, 0); + setTextureOffset("Base.PipeN19", 0, 0); + setTextureOffset("RotatingPart2.PipeN17", 0, 0); + setTextureOffset("RotatingPart2.PipeN21", 0, 0); + setTextureOffset("RotatingPart2.PipeN25", 0, 0); + setTextureOffset("MotorPart1.PipeN41", 0, 0); + setTextureOffset("MotorPart1.PipeN13", 0, 0); + setTextureOffset("MotorPart1.PipeN12", 0, 0); + setTextureOffset("MotorPart1.PipeN16", 0, 0); + setTextureOffset("MotorPart2.Shape4", 0, 24); + setTextureOffset("MotorPart2.Shape7", 0, 9); + setTextureOffset("MotorPart2.Shape10", 0, 9); + setTextureOffset("RotatingPart1.PipeN27", 0, 0); + setTextureOffset("RotatingPart1.PipN119", 0, 0); + setTextureOffset("RotatingPart1.pipeN24", 0, 0); + setTextureOffset("RotatingPart3.PipeN23", 0, 0); + setTextureOffset("RotatingPart3.PipeN22", 0, 0); + setTextureOffset("RotatingPart3.PipeN26", 0, 0); + setTextureOffset("RotatingPart4.PipeN28", 0, 0); + setTextureOffset("Belt1.Shape12", 60, 0); + setTextureOffset("Belt2.Shape17", 60, 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("Shape16", -6F, -1F, -7F, 12, 8, 1); + Base.addTube("PipeN18", -5F, -6.1F, -7.1F, 10, 10, 1, 0.9F,1F,ForgeDirection.NORTH); + Base.addTube("PipeN19", -1.5F, -6F, -7F, 3, 3, 1, 0.25F,1F,ForgeDirection.NORTH);; + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(-2.2F, 16F, -8F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = true; + RotatingPart2.addTube("PipeN17", -2F, -2F, 2F, 4, 4, 28, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN21", -0.5F, -0.5F, 0F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN25", -0.5F, -0.5F, 30F, 1, 1, 2, 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); + RotatingPart1 = new IHLModelRenderer(this, "RotatingPart1"); + RotatingPart1.setRotationPoint(0F, 11.5F, -6F); + setRotation(RotatingPart1, 0F, 0F, 0F); + RotatingPart1.mirror = true; + RotatingPart1.addTube("PipeN27", -2F, -2F, 0F, 4, 4, 28, 0F,1F,ForgeDirection.NORTH); + RotatingPart1.addTube("PipN119", -0.5F, -0.5F, -2F, 1, 1, 2, 0F,1F,ForgeDirection.NORTH); + RotatingPart1.addTube("pipeN24", -0.5F, -0.5F, 28F, 1, 1, 2, 0F,1F,ForgeDirection.NORTH); + RotatingPart3 = new IHLModelRenderer(this, "RotatingPart3"); + RotatingPart3.setRotationPoint(2.2F, 16F, -8F); + setRotation(RotatingPart3, 0F, 0F, 0F); + RotatingPart3.mirror = true; + RotatingPart3.addTube("PipeN23", -2F, -2F, 2F, 4, 4, 28, 0F,1F,ForgeDirection.NORTH); + RotatingPart3.addTube("PipeN22", -1.5F, -1.5F, 0F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart3.addTube("PipeN26", -0.5F, -0.5F, 30F, 1, 1, 2, 0F,1F,ForgeDirection.NORTH); + RotatingPart4 = new IHLModelRenderer(this, "RotatingPart4"); + RotatingPart4.setRotationPoint(0F, 15F, -5F); + setRotation(RotatingPart3, 0F, 0F, 0F); + RotatingPart4.mirror = true; + RotatingPart4.addTube("PipeN28", -0.5F, -0.5F, 0F, 1, 1, 27, 0F,1F,ForgeDirection.NORTH); + Belt1 = new IHLModelRenderer(this, "Belt1"); + Belt1.setRotationPoint(2.5F, 16F, -7.9F); + setRotation(Belt1, 0F, 0F, -0.45F); + Belt1.mirror = true; + Belt1.addBox("Shape12", 0F, 0F, 0F, 1, 5, 1); + Belt2 = new IHLModelRenderer(this, "Belt2"); + Belt2.setRotationPoint(2F, 16F, -7.9F); + setRotation(Belt2, 0F, 0F, -0.45F); + Belt2.mirror = true; + Belt2.addBox("Shape17", -1F, 0F, 0F, 1, 6, 1); + } + + + 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/metallurgy/WoodenRollingMachinePart1TileEntity.java b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java new file mode 100644 index 0000000..857575a --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java @@ -0,0 +1,158 @@ +package ihl.processing.metallurgy; + +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.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeInputOreDict; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.block.invslot.InvSlot.Access; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.recipes.RecipeOutputItemStack; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +public class WoodenRollingMachinePart1TileEntity extends BasicElectricMotorTileEntity{ + + public final ApparatusProcessableInvSlot input; + public final IHLInvSlotOutput output; + public boolean assembled; + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("woodenrollingmachine"); + + public WoodenRollingMachinePart1TileEntity() + { + super(); + input = new ApparatusProcessableInvSlot(this, "input", 1, Access.IO, 3, 64); + output = new IHLInvSlotOutput(this, "output", 2, 1); + } + + public UniversalRecipeOutput getOutput() + { + return WoodenRollingMachinePart1TileEntity.recipeManager.getOutputFor(this.getInput()); + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("assembled"); + return fields; + } + + + @Override + public String getInventoryName() { + return "WoodenRollingMachine"; + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if(assembled && !this.checkCorrectAccembly()) + { + assembled=false; + IC2.network.get().updateTileEntityField(this, "assembled"); + } + else if(!assembled && this.checkCorrectAccembly()) + { + assembled=true; + IC2.network.get().updateTileEntityField(this, "assembled"); + } + if (this.getActive() && this.progress == 0 && !this.canOperate()) + { + this.setActive(false); + } + + if (!this.getActive() && this.progress>0 && this.canOperate()) + { + this.setActive(true); + } + + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("woodenRollingMachinePart1"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new WoodenRollingMachineGui(new WoodenRollingMachineContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new WoodenRollingMachineContainer(player, this); + } + + @Override + public void operate() + { + List rInput = WoodenRollingMachinePart1TileEntity.recipeManager.getRecipeInput(getInput()).getItemInputs(); + List rOutput = WoodenRollingMachinePart1TileEntity.recipeManager.getOutputFor(getInput()).getItemOutputs(); + this.output.add(rOutput); + for(int i=0;i getRecipes() { + return recipeManager.getRecipes(); + } + + public static void addRecipe(RecipeInputOreDict recipeInputOreDict, RecipeInputOreDict recipeInputOreDict2, ItemStack output) + { + recipeManager.addRecipe(new UniversalRecipeInput(null, (new IRecipeInput[] {recipeInputOreDict,recipeInputOreDict2})), new UniversalRecipeOutput(null,(new ItemStack[] {output}),20)); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart2Model.java b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart2Model.java new file mode 100644 index 0000000..6ebc58e --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart2Model.java @@ -0,0 +1,44 @@ +// Date: 15.02.2015 11:31:12 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class WoodenRollingMachinePart2Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public WoodenRollingMachinePart2Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 15); + setTextureOffset("Base.Shape16", 0, 23); + setTextureOffset("Base.PipeN18", 0, 0); + setTextureOffset("Base.PipeN19", 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("Shape16", -6F, -1F, 6F, 12, 8, 1); + Base.addTube("PipeN18", -5F, -6.1F, 6.1F, 10, 10, 1, 0.9F,1F,ForgeDirection.NORTH); + Base.addTube("PipeN19", -1.5F, -6F, 6F, 3, 3, 1, 0.25F,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/metallurgy/WoodenRollingMachinePart2TileEntity.java b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart2TileEntity.java new file mode 100644 index 0000000..9aec41b --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart2TileEntity.java @@ -0,0 +1,104 @@ +package ihl.processing.metallurgy; + +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 WoodenRollingMachinePart2TileEntity extends TileEntity implements IWrenchable, INetworkDataProvider{ + + private short facing=2; + private short lastFacing=2; + + public WoodenRollingMachinePart2TileEntity() + { + super(); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public List getNetworkedFields() + { + List fields = new ArrayList(); + fields.add("facing"); + return fields; + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(lastFacing!=facing) + { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing=facing; + } + } + + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + + @Override + public short getFacing() { + return this.facing; + } + + + @Override + public void setFacing(short facing1) + { + facing=(short) Math.max(2,facing1); + if(IC2.platform.isSimulating()) + { + IC2.network.get().updateTileEntityField(this, "facing"); + } + } + + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + + @Override + public float getWrenchDropRate() { + return 1F; + } + + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("woodenRollingMachinePart2"); + } + + @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/metallurgy/WoodenRollingMachineRender.java b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineRender.java new file mode 100644 index 0000000..f180f75 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineRender.java @@ -0,0 +1,91 @@ +package ihl.processing.metallurgy; +import org.lwjgl.opengl.GL11; + +import ic2.api.tile.IWrenchable; +import ihl.IHLModInfo; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; + +public class WoodenRollingMachineRender extends TileEntitySpecialRenderer{ +private WoodenRollingMachinePart1Model model = new WoodenRollingMachinePart1Model(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/woodenRollingMachine.png"); +private final float scale=1F/16F; + + public WoodenRollingMachineRender() {} + + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par8) + { + int rotation = 0; + if(tile.getWorldObj() != null) + { + switch (((IWrenchable)tile).getFacing()) + { + case 2: + rotation = 0; + break; + case 5: + rotation = 1; + break; + case 3: + rotation = 2; + break; + case 4: + rotation = 3; + break; + default: + rotation = 0; + } + } + else + { + return; + } + WoodenRollingMachinePart1TileEntity cte = (WoodenRollingMachinePart1TileEntity)tile; + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F); + + bindTexture(tex); + model.Base.render(scale); + if(cte.getActive()) + { + model.RotatingPart1.rotateAngleZ+=0.01F; + model.RotatingPart2.rotateAngleZ+=0.01F; + model.RotatingPart3.rotateAngleZ+=0.01F; + model.RotatingPart4.rotateAngleZ-=0.01F; + model.RotatingPart1.render(scale); + model.RotatingPart2.render(scale); + model.RotatingPart3.render(scale); + model.RotatingPart4.render(scale); + model.MotorPart1.rotateAngleZ-=0.03F; + model.MotorPart1.render(scale); + model.MotorPart2.render(scale); + model.Belt1.render(scale); + model.Belt2.render(scale); + } + else + { + model.RotatingPart1.rotateAngleZ=0.0F; + model.RotatingPart2.rotateAngleZ=0.0F; + model.RotatingPart3.rotateAngleZ=0.0F; + model.RotatingPart4.rotateAngleZ=0.0F; + if(cte.assembled) + { + model.RotatingPart1.render(scale); + model.RotatingPart2.render(scale); + model.RotatingPart3.render(scale); + model.RotatingPart4.render(scale); + } + model.MotorPart1.render(scale); + model.MotorPart2.render(scale); + model.Belt1.render(scale); + model.Belt2.render(scale); + } + GL11.glPopMatrix(); //end + + } +} \ No newline at end of file -- cgit v1.2.3