From 05c78126859231a68e199dc34613689bd0978e2f Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Mon, 11 Apr 2016 19:44:54 +0300 Subject: Initial commit --- ihl/processing/metallurgy/AchesonFurnaceGui.java | 48 +++ .../metallurgy/AchesonFurnanceContainer.java | 17 + .../metallurgy/AchesonFurnanceTileEntity.java | 150 ++++++++ .../metallurgy/BasicElectricMotorTileEntity.java | 302 ++++++++++++++++ .../metallurgy/BigMachineFrameTileEntity.java | 109 ++++++ ihl/processing/metallurgy/CoilerContainer.java | 65 ++++ ihl/processing/metallurgy/CoilerGui.java | 52 +++ ihl/processing/metallurgy/CoilerModel.java | 103 ++++++ ihl/processing/metallurgy/CoilerRender.java | 83 +++++ ihl/processing/metallurgy/CoilerTileEntity.java | 171 +++++++++ ihl/processing/metallurgy/Crucible.java | 389 ++++++++++++++++++++ ihl/processing/metallurgy/CrucibleContainer.java | 67 ++++ ihl/processing/metallurgy/CrucibleGui.java | 86 +++++ ihl/processing/metallurgy/CrucibleInventory.java | 155 ++++++++ ihl/processing/metallurgy/CrucibleSlot.java | 20 ++ .../DetonationSprayingMachineContainer.java | 39 ++ .../metallurgy/DetonationSprayingMachineGui.java | 54 +++ .../metallurgy/DetonationSprayingMachineModel.java | 65 ++++ .../DetonationSprayingMachineRender.java | 61 ++++ .../DetonationSprayingMachineTileEntity.java | 251 +++++++++++++ .../metallurgy/DrawingDeskContainer.java | 36 ++ ihl/processing/metallurgy/DrawingDeskGui.java | 59 ++++ ihl/processing/metallurgy/DrawingDeskModel.java | 66 ++++ .../metallurgy/DrawingDeskTileEntity.java | 173 +++++++++ .../metallurgy/ElectricEngineInvSlot.java | 54 +++ ihl/processing/metallurgy/ElectricEngineItem.java | 84 +++++ ihl/processing/metallurgy/ExtruderContainer.java | 75 ++++ ihl/processing/metallurgy/ExtruderGui.java | 58 +++ ihl/processing/metallurgy/ExtruderModel.java | 100 ++++++ ihl/processing/metallurgy/ExtruderTileEntity.java | 170 +++++++++ .../metallurgy/GasWeldingStationContainer.java | 99 ++++++ .../metallurgy/GasWeldingStationGui.java | 79 +++++ .../metallurgy/GasWeldingStationModel.java | 108 ++++++ .../metallurgy/GasWeldingStationTileEntity.java | 337 ++++++++++++++++++ ihl/processing/metallurgy/IProductionLine.java | 12 + .../metallurgy/ImpregnatingMachineContainer.java | 114 ++++++ .../metallurgy/ImpregnatingMachineGui.java | 63 ++++ .../metallurgy/ImpregnatingMachineRender.java | 53 +++ .../metallurgy/ImpregnatingMachineTileEntity.java | 393 +++++++++++++++++++++ ihl/processing/metallurgy/InjectionMoldBlock.java | 254 +++++++++++++ .../metallurgy/InjectionMoldTileEntity.java | 194 ++++++++++ ihl/processing/metallurgy/LatheContainer.java | 72 ++++ ihl/processing/metallurgy/LatheGui.java | 60 ++++ ihl/processing/metallurgy/LathePart1Model.java | 93 +++++ .../metallurgy/LathePart1TileEntity.java | 98 +++++ ihl/processing/metallurgy/LathePart2Model.java | 87 +++++ .../metallurgy/LathePart2TileEntity.java | 105 ++++++ .../metallurgy/MachineBaseContainer.java | 74 ++++ .../metallurgy/MachineBaseTileEntity.java | 282 +++++++++++++++ ihl/processing/metallurgy/MuffleFurnaceGui.java | 51 +++ .../metallurgy/MuffleFurnanceContainer.java | 15 + .../metallurgy/MuffleFurnanceTileEntity.java | 135 +++++++ ihl/processing/metallurgy/PassiveBlock.java | 99 ++++++ .../metallurgy/RollingMachineContainer.java | 75 ++++ ihl/processing/metallurgy/RollingMachineGui.java | 59 ++++ .../metallurgy/RollingMachinePart1Model.java | 97 +++++ .../metallurgy/RollingMachinePart1TileEntity.java | 161 +++++++++ .../metallurgy/RollingMachinePart2Model.java | 42 +++ .../metallurgy/RollingMachinePart2TileEntity.java | 105 ++++++ .../metallurgy/RollingMachineRender.java | 84 +++++ .../VacuumInductionMeltingFurnaceContainer.java | 77 ++++ .../VacuumInductionMeltingFurnaceGui.java | 87 +++++ .../VacuumInductionMeltingFurnaceTileEntity.java | 260 ++++++++++++++ .../VulcanizationExtrudingMoldModel.java | 54 +++ .../VulcanizationExtrudingMoldTileEntity.java | 280 +++++++++++++++ ihl/processing/metallurgy/WireMillContainer.java | 113 ++++++ ihl/processing/metallurgy/WireMillGui.java | 72 ++++ ihl/processing/metallurgy/WireMillTileEntity.java | 385 ++++++++++++++++++++ .../metallurgy/WoodenRollingMachineContainer.java | 77 ++++ .../metallurgy/WoodenRollingMachineGui.java | 69 ++++ .../metallurgy/WoodenRollingMachinePart1Model.java | 122 +++++++ .../WoodenRollingMachinePart1TileEntity.java | 171 +++++++++ .../metallurgy/WoodenRollingMachinePart2Model.java | 44 +++ .../WoodenRollingMachinePart2TileEntity.java | 105 ++++++ .../metallurgy/WoodenRollingMachineRender.java | 94 +++++ 75 files changed, 8672 insertions(+) create mode 100644 ihl/processing/metallurgy/AchesonFurnaceGui.java create mode 100644 ihl/processing/metallurgy/AchesonFurnanceContainer.java create mode 100644 ihl/processing/metallurgy/AchesonFurnanceTileEntity.java create mode 100644 ihl/processing/metallurgy/BasicElectricMotorTileEntity.java create mode 100644 ihl/processing/metallurgy/BigMachineFrameTileEntity.java create mode 100644 ihl/processing/metallurgy/CoilerContainer.java create mode 100644 ihl/processing/metallurgy/CoilerGui.java create mode 100644 ihl/processing/metallurgy/CoilerModel.java create mode 100644 ihl/processing/metallurgy/CoilerRender.java create mode 100644 ihl/processing/metallurgy/CoilerTileEntity.java create mode 100644 ihl/processing/metallurgy/Crucible.java create mode 100644 ihl/processing/metallurgy/CrucibleContainer.java create mode 100644 ihl/processing/metallurgy/CrucibleGui.java create mode 100644 ihl/processing/metallurgy/CrucibleInventory.java create mode 100644 ihl/processing/metallurgy/CrucibleSlot.java create mode 100644 ihl/processing/metallurgy/DetonationSprayingMachineContainer.java create mode 100644 ihl/processing/metallurgy/DetonationSprayingMachineGui.java create mode 100644 ihl/processing/metallurgy/DetonationSprayingMachineModel.java create mode 100644 ihl/processing/metallurgy/DetonationSprayingMachineRender.java create mode 100644 ihl/processing/metallurgy/DetonationSprayingMachineTileEntity.java create mode 100644 ihl/processing/metallurgy/DrawingDeskContainer.java create mode 100644 ihl/processing/metallurgy/DrawingDeskGui.java create mode 100644 ihl/processing/metallurgy/DrawingDeskModel.java create mode 100644 ihl/processing/metallurgy/DrawingDeskTileEntity.java create mode 100644 ihl/processing/metallurgy/ElectricEngineInvSlot.java create mode 100644 ihl/processing/metallurgy/ElectricEngineItem.java create mode 100644 ihl/processing/metallurgy/ExtruderContainer.java create mode 100644 ihl/processing/metallurgy/ExtruderGui.java create mode 100644 ihl/processing/metallurgy/ExtruderModel.java create mode 100644 ihl/processing/metallurgy/ExtruderTileEntity.java create mode 100644 ihl/processing/metallurgy/GasWeldingStationContainer.java create mode 100644 ihl/processing/metallurgy/GasWeldingStationGui.java create mode 100644 ihl/processing/metallurgy/GasWeldingStationModel.java create mode 100644 ihl/processing/metallurgy/GasWeldingStationTileEntity.java create mode 100644 ihl/processing/metallurgy/IProductionLine.java create mode 100644 ihl/processing/metallurgy/ImpregnatingMachineContainer.java create mode 100644 ihl/processing/metallurgy/ImpregnatingMachineGui.java create mode 100644 ihl/processing/metallurgy/ImpregnatingMachineRender.java create mode 100644 ihl/processing/metallurgy/ImpregnatingMachineTileEntity.java create mode 100644 ihl/processing/metallurgy/InjectionMoldBlock.java create mode 100644 ihl/processing/metallurgy/InjectionMoldTileEntity.java create mode 100644 ihl/processing/metallurgy/LatheContainer.java create mode 100644 ihl/processing/metallurgy/LatheGui.java create mode 100644 ihl/processing/metallurgy/LathePart1Model.java create mode 100644 ihl/processing/metallurgy/LathePart1TileEntity.java create mode 100644 ihl/processing/metallurgy/LathePart2Model.java create mode 100644 ihl/processing/metallurgy/LathePart2TileEntity.java create mode 100644 ihl/processing/metallurgy/MachineBaseContainer.java create mode 100644 ihl/processing/metallurgy/MachineBaseTileEntity.java create mode 100644 ihl/processing/metallurgy/MuffleFurnaceGui.java create mode 100644 ihl/processing/metallurgy/MuffleFurnanceContainer.java create mode 100644 ihl/processing/metallurgy/MuffleFurnanceTileEntity.java create mode 100644 ihl/processing/metallurgy/PassiveBlock.java create mode 100644 ihl/processing/metallurgy/RollingMachineContainer.java create mode 100644 ihl/processing/metallurgy/RollingMachineGui.java create mode 100644 ihl/processing/metallurgy/RollingMachinePart1Model.java create mode 100644 ihl/processing/metallurgy/RollingMachinePart1TileEntity.java create mode 100644 ihl/processing/metallurgy/RollingMachinePart2Model.java create mode 100644 ihl/processing/metallurgy/RollingMachinePart2TileEntity.java create mode 100644 ihl/processing/metallurgy/RollingMachineRender.java create mode 100644 ihl/processing/metallurgy/VacuumInductionMeltingFurnaceContainer.java create mode 100644 ihl/processing/metallurgy/VacuumInductionMeltingFurnaceGui.java create mode 100644 ihl/processing/metallurgy/VacuumInductionMeltingFurnaceTileEntity.java create mode 100644 ihl/processing/metallurgy/VulcanizationExtrudingMoldModel.java create mode 100644 ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java create mode 100644 ihl/processing/metallurgy/WireMillContainer.java create mode 100644 ihl/processing/metallurgy/WireMillGui.java create mode 100644 ihl/processing/metallurgy/WireMillTileEntity.java create mode 100644 ihl/processing/metallurgy/WoodenRollingMachineContainer.java create mode 100644 ihl/processing/metallurgy/WoodenRollingMachineGui.java create mode 100644 ihl/processing/metallurgy/WoodenRollingMachinePart1Model.java create mode 100644 ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java create mode 100644 ihl/processing/metallurgy/WoodenRollingMachinePart2Model.java create mode 100644 ihl/processing/metallurgy/WoodenRollingMachinePart2TileEntity.java create mode 100644 ihl/processing/metallurgy/WoodenRollingMachineRender.java (limited to 'ihl/processing/metallurgy') diff --git a/ihl/processing/metallurgy/AchesonFurnaceGui.java b/ihl/processing/metallurgy/AchesonFurnaceGui.java new file mode 100644 index 0000000..bafa530 --- /dev/null +++ b/ihl/processing/metallurgy/AchesonFurnaceGui.java @@ -0,0 +1,48 @@ +package ihl.processing.metallurgy; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import org.lwjgl.opengl.GL11; + +public class AchesonFurnaceGui extends GuiContainer { + protected static final ResourceLocation achesonFurnaceBackground = new ResourceLocation("ihl", "textures/gui/GUIAchesonFurnance.png"); + private MachineBaseContainer container; + + public AchesonFurnaceGui(MachineBaseContainer machineBaseContainer) { + //the container is instanciated and passed to the superclass for handling + super(machineBaseContainer); + this.container=machineBaseContainer; + } + + @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(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(50),50); + this.drawTexturedModalRect(64, 63, 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/ihl/processing/metallurgy/AchesonFurnanceContainer.java b/ihl/processing/metallurgy/AchesonFurnanceContainer.java new file mode 100644 index 0000000..140ec97 --- /dev/null +++ b/ihl/processing/metallurgy/AchesonFurnanceContainer.java @@ -0,0 +1,17 @@ +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.inputElectrode, 0, 63, 40)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.inputElectrode, 1, 99, 40)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 81, 40)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 1, 81, 22)); + } + +} diff --git a/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java b/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java new file mode 100644 index 0000000..5d228fc --- /dev/null +++ b/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java @@ -0,0 +1,150 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputOreDict; +import ic2.core.ContainerBase; +import ic2.core.block.invslot.InvSlot.Access; +import ihl.IHLMod; +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 cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class AchesonFurnanceTileEntity extends MachineBaseTileEntity{ + + public final ApparatusProcessableInvSlot inputElectrode; + protected static UniversalRecipeManager recipeManager = new UniversalRecipeManager("achesonfurnace"); + private final RecipeInputOreDict[] validElectrodeTypes=new RecipeInputOreDict[] {new RecipeInputOreDict("stickCoal"),new RecipeInputOreDict("stickGraphite"),new RecipeInputOreDict("plateCoal"),new RecipeInputOreDict("plateGraphite")}; + + public AchesonFurnanceTileEntity() + { + super(2); + inputElectrode = new ApparatusProcessableInvSlot(this, "inputElectrode", 1, Access.IO, 2, 1); + } + + public static void addRecipe(IRecipeInput input1, IRecipeInput input2, String output1) + { + recipeManager.addRecipe(new UniversalRecipeInput(null,Arrays.asList(new IRecipeInput [] {input1,input2})),new UniversalRecipeOutput(null,Arrays.asList(new ItemStack [] {IHLUtils.getThisModItemStack(output1)}),20)); + } + + @Override + public String getStartSoundFile() + { + return "Machines/Electro Furnace/ElectroFurnaceLoop.ogg"; + } + + @Override + public String getLoopSoundFile() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getStopSoundFile() { + // TODO Auto-generated method stub + 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() + { + List output = AchesonFurnanceTileEntity.recipeManager.getOutputFor(getInput(), true, true).getItemOutputs(); + for(int i=0; ii) + { + ItemStack stack = output.get(i).itemStack.copy(); + stack.stackSize=Math.round(output.get(i).quantity); + this.input.put(i,stack); + } + if(this.input.get(i)!=null && this.input.get(i).stackSize<=0) + { + this.input.put(i, null); + } + } + ItemStack crucible = input.getItemStack(IHLMod.crucible); + if(crucible!=null) + { + ItemStack stack = ((Crucible)crucible.getItem()).processContent(crucible, this); + } + } + + @Override + public boolean canOperate() + { + return this.isValidElectrode(this.inputElectrode.get(0)) && + this.isValidElectrode(this.inputElectrode.get(1)) && + 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(), false, false); + } + + private boolean isValidElectrode(ItemStack stack) + { + if(stack!=null) + { + for(int i=0;i nodeList = worldObj.getEntitiesWithinAABB(NodeEntity.class, searchArea); + super.setFacing(facing2); + 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=(NodeEntity) 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() + { + return this.maxStorage-this.energy; + } + + @Override + public int getSinkTier() { + return 4; + } + + @Override + public double injectEnergy(ForgeDirection directionFrom, double amount, + double voltage) { + if(this.energy0D && this.energy=this.energyConsume/this.engine.getEfficiency()) + { + this.energy-=this.energyConsume/this.engine.getEfficiency(); + if (this.progress == 0) + { + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + ++this.progress; + if (this.progress >= this.operationLength) + { + this.operate(); + this.progress = 0; + IC2.network.get().initiateTileEntityEvent(this, 2, true); + } + } + else + { + if (this.progress != 0 && this.getActive()) + { + IC2.network.get().initiateTileEntityEvent(this, 1, true); + } + if (!this.canOperate()) + { + this.progress = 0; + } + } + + } + + 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.energyx-3;ix--) + { + for(iy=y;iy>y-3;iy--) + { + for(iz=z;iz>z-3;iz--) + { + TileEntity te = worldObj.getTileEntity(ix, iy, iz); + if(te instanceof BigMachineFrameTileEntity) + { + x0=ix+1; + y0=iy+1; + z0=iz+1; + } + } + } + } + for(ix=x0-1;ix 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.engine.correctContent()) + { + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 47, 56, xOffset, yOffset); + } + 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/ihl/processing/metallurgy/CoilerModel.java b/ihl/processing/metallurgy/CoilerModel.java new file mode 100644 index 0000000..9c1721e --- /dev/null +++ b/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/ihl/processing/metallurgy/CoilerRender.java b/ihl/processing/metallurgy/CoilerRender.java new file mode 100644 index 0000000..646b342 --- /dev/null +++ b/ihl/processing/metallurgy/CoilerRender.java @@ -0,0 +1,83 @@ +package ihl.processing.metallurgy; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import ic2.api.tile.IWrenchable; +import ihl.IHLModInfo; + +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); + } + if(cte.hasEngine) + { + model.MotorPart1.render(scale); + model.MotorPart2.render(scale); + } + } + model.RotatingPart2.render(scale); + GL11.glPopMatrix(); //end + + } +} \ No newline at end of file diff --git a/ihl/processing/metallurgy/CoilerTileEntity.java b/ihl/processing/metallurgy/CoilerTileEntity.java new file mode 100644 index 0000000..6a671b0 --- /dev/null +++ b/ihl/processing/metallurgy/CoilerTileEntity.java @@ -0,0 +1,171 @@ +package ihl.processing.metallurgy; + +import java.util.List; + +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.block.invslot.InvSlotOutput; +import ic2.core.network.NetworkManager; +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; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class CoilerTileEntity extends BasicElectricMotorTileEntity implements IProductionLine{ + + public final InvSlotOutput output; + private int activeTimer=0; + public boolean hasCoil=false; + public boolean hasEngine=false; + + public CoilerTileEntity() + { + super(); + this.output = new InvSlotOutput(this, "output", 1, 1); + this.isGuiScreenOpened=true; + } + + + @Override + public String getInventoryName() { + return "Coiler"; + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("hasCoil"); + fields.add("hasEngine"); + 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"); + } + if(this.engine.isEmpty() && hasEngine==true) + { + this.hasEngine=false; + IC2.network.get().updateTileEntityField(this, "hasEngine"); + } + else if(this.engine.correctContent() && hasEngine==false) + { + this.hasEngine=true; + IC2.network.get().updateTileEntityField(this, "hasEngine"); + } + + } + + @Override + public void operate() + {} + + + @Override + public List[] getInput() + { + return null; + } + + + @Override + public boolean canProcess(ItemStack cable) { + if(this.engine.correctContent() && this.energy>1D/this.engine.getEfficiency() && 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/this.engine.getEfficiency(); + 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/ihl/processing/metallurgy/Crucible.java b/ihl/processing/metallurgy/Crucible.java new file mode 100644 index 0000000..a435e49 --- /dev/null +++ b/ihl/processing/metallurgy/Crucible.java @@ -0,0 +1,389 @@ +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 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; +import net.minecraftforge.oredict.OreDictionary; +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; + +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, Arrays.asList(new IRecipeInput[] {new RecipeInputOreDict(string)})), new UniversalRecipeOutput(Arrays.asList(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 + */ + @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}),false, false); + 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); + } + } + } + private String getFormattedFluidNameFromMaterialName(String input) + { + if(input.length()<6) + { + return ""; + } + String input2 = input.substring(5); + return "molten."+input2.toLowerCase(); + } + + private String getOreName(ItemStack stack) + { + int[] arrayIDs = OreDictionary.getOreIDs(stack); + for(int i=0; i= 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/ihl/processing/metallurgy/CrucibleContainer.java b/ihl/processing/metallurgy/CrucibleContainer.java new file mode 100644 index 0000000..b3ab3d8 --- /dev/null +++ b/ihl/processing/metallurgy/CrucibleContainer.java @@ -0,0 +1,67 @@ +package ihl.processing.metallurgy; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.util.StackUtil; + +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) + { + NBTTagCompound nbtTagCompoundSlot = 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/ihl/processing/metallurgy/CrucibleGui.java b/ihl/processing/metallurgy/CrucibleGui.java new file mode 100644 index 0000000..b0bfc85 --- /dev/null +++ b/ihl/processing/metallurgy/CrucibleGui.java @@ -0,0 +1,86 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +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; +import ic2.core.util.DrawUtil; +import ic2.core.util.GuiTooltipHelper; + +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) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + 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/ihl/processing/metallurgy/CrucibleInventory.java b/ihl/processing/metallurgy/CrucibleInventory.java new file mode 100644 index 0000000..57d9c17 --- /dev/null +++ b/ihl/processing/metallurgy/CrucibleInventory.java @@ -0,0 +1,155 @@ +package ihl.processing.metallurgy; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.oredict.OreDictionary; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.item.tool.HandHeldInventory; +import ic2.core.util.StackUtil; + +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) { + if(((Crucible)thisItemStack.getItem()).isEmpty(thisItemStack)) + { + int[] arrayIDs = OreDictionary.getOreIDs(stack); + for(int i=0; i= 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/ihl/processing/metallurgy/CrucibleSlot.java b/ihl/processing/metallurgy/CrucibleSlot.java new file mode 100644 index 0000000..e0b702d --- /dev/null +++ b/ihl/processing/metallurgy/CrucibleSlot.java @@ -0,0 +1,20 @@ +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 ? false : inventory.isItemValidForSlot(0, itemstack); + } +} diff --git a/ihl/processing/metallurgy/DetonationSprayingMachineContainer.java b/ihl/processing/metallurgy/DetonationSprayingMachineContainer.java new file mode 100644 index 0000000..3bfd2b0 --- /dev/null +++ b/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/ihl/processing/metallurgy/DetonationSprayingMachineGui.java b/ihl/processing/metallurgy/DetonationSprayingMachineGui.java new file mode 100644 index 0000000..cc4d455 --- /dev/null +++ b/ihl/processing/metallurgy/DetonationSprayingMachineGui.java @@ -0,0 +1,54 @@ +package ihl.processing.metallurgy; + +import java.util.Iterator; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class DetonationSprayingMachineGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIDetonationSprayingMachine.png"); + private DetonationSprayingMachineContainer container; + 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); + 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); + } + + @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/ihl/processing/metallurgy/DetonationSprayingMachineModel.java b/ihl/processing/metallurgy/DetonationSprayingMachineModel.java new file mode 100644 index 0000000..48329d5 --- /dev/null +++ b/ihl/processing/metallurgy/DetonationSprayingMachineModel.java @@ -0,0 +1,65 @@ +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +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); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + @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/ihl/processing/metallurgy/DetonationSprayingMachineRender.java b/ihl/processing/metallurgy/DetonationSprayingMachineRender.java new file mode 100644 index 0000000..9bb0c6e --- /dev/null +++ b/ihl/processing/metallurgy/DetonationSprayingMachineRender.java @@ -0,0 +1,61 @@ +package ihl.processing.metallurgy; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import ic2.api.tile.IWrenchable; +import ihl.IHLModInfo; +import ihl.utils.IHLItemRenderer; + +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(1.0F/16.0F); + 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/ihl/processing/metallurgy/DetonationSprayingMachineTileEntity.java b/ihl/processing/metallurgy/DetonationSprayingMachineTileEntity.java new file mode 100644 index 0000000..590f6e9 --- /dev/null +++ b/ihl/processing/metallurgy/DetonationSprayingMachineTileEntity.java @@ -0,0 +1,251 @@ +package ihl.processing.metallurgy; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import 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 ic2.core.network.NetworkManager; +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; + +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"; + } + + private int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + private int mZ() + { + switch(this.getFacing()) + { + case 3: + return 1; + case 2: + return -1; + case 4: + return 0; + case 5: + return 0; + default: + return -1; + } + } + + private short getFacingFromXZ(int x, int z) + { + switch(x) + { + case -1: + return (short)4; + case 1: + return (short)5; + default: + switch(z) + { + case 1: + return (short)3; + case -1: + return (short)2; + default: + return (short)2; + } + } + } + + + @Override + public void onNetworkEvent(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(), false, false); + } + + 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 output1 = DetonationSprayingMachineTileEntity.recipeManager.getOutputFor(getInput(), false, false).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 dsmInputs1 = new ArrayList(); + dsmInputs1.add(new RecipeInputItemStack(input)); + dsmInputs1.add(new RecipeInputOreDict("dustDiamond")); + dsmInputs1.add(new RecipeInputOreDict("dustGunpowder")); + recipeManager.addRecipe(new UniversalRecipeInput(null, dsmInputs1), new UniversalRecipeOutput(null,Arrays.asList(new ItemStack[] {output}),1)); + } + + public static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output) + { + recipeManager.addRecipe(input, output); + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} \ No newline at end of file diff --git a/ihl/processing/metallurgy/DrawingDeskContainer.java b/ihl/processing/metallurgy/DrawingDeskContainer.java new file mode 100644 index 0000000..ca570a1 --- /dev/null +++ b/ihl/processing/metallurgy/DrawingDeskContainer.java @@ -0,0 +1,36 @@ +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 DrawingDeskContainer extends ContainerBase { + + public DrawingDeskTileEntity tileEntity; + public int lastProgress = -1; + private final static int height=166; + + public DrawingDeskContainer(EntityPlayer entityPlayer, + DrawingDeskTileEntity tileEntity1) { + super(tileEntity1); + tileEntity=tileEntity1; + int col; + + for (col = 0; col < 3; ++col) + { + for (int col1 = 0; col1 < 9; ++col1) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); + } + } + + for (col = 0; col < 9; ++col) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); + } + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 8, 44)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.output, 0, 127, 44)); + } +} diff --git a/ihl/processing/metallurgy/DrawingDeskGui.java b/ihl/processing/metallurgy/DrawingDeskGui.java new file mode 100644 index 0000000..301e072 --- /dev/null +++ b/ihl/processing/metallurgy/DrawingDeskGui.java @@ -0,0 +1,59 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.utils.IHLRenderUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; + +public class DrawingDeskGui extends GuiContainer { + + private DrawingDeskContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUIDrawingDesk.png"); + + public DrawingDeskGui(DrawingDeskContainer latheContainer) { + super(latheContainer); + container = latheContainer; + } + + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(tex); + int i1; + if (this.container.tileEntity.progress > 0) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.99F); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(38),38); + this.drawTexturedModalRect(68, 30, 176, 0, i1 + 1, 10); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(tex); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } + + @Override + public void onGuiClosed() + { + super.onGuiClosed(); + this.container.tileEntity.isGuiScreenOpened=false; + IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, 0); + } + +} diff --git a/ihl/processing/metallurgy/DrawingDeskModel.java b/ihl/processing/metallurgy/DrawingDeskModel.java new file mode 100644 index 0000000..55f1c84 --- /dev/null +++ b/ihl/processing/metallurgy/DrawingDeskModel.java @@ -0,0 +1,66 @@ +package ihl.processing.metallurgy; + +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; +import ihl.model.IHLModelRenderer; + +public class DrawingDeskModel extends ModelBase +{ + //fields + IHLModelRenderer RotatePart; + IHLModelRenderer Piece1; + + public DrawingDeskModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("RotatePart.Shape1", 0, 14); + setTextureOffset("RotatePart.Pipe2", 0, 17); + setTextureOffset("RotatePart.Shape4", 3, 14); + setTextureOffset("RotatePart.Shape3", 0, 26); + setTextureOffset("RotatePart.Pipe5", 16, 20); + setTextureOffset("RotatePart.Pipe6", 0, 18); + setTextureOffset("RotatePart.Pipe11", 13, 22); + setTextureOffset("RotatePart.Pipe12", 13, 22); + setTextureOffset("RotatePart.Pipe13", 13, 22); + setTextureOffset("RotatePart.Pipe14", 13, 22); + setTextureOffset("RotatePart.Pipe15", 13, 22); + setTextureOffset("Piece1.Shape7", 0, 17); + setTextureOffset("Piece1.Shape8", 0, 17); + setTextureOffset("Piece1.PipeW9", 0, 18); + setTextureOffset("Piece1.PipeW10", 0, 20); + setTextureOffset("Piece1.Shape2", 0, 0); + + RotatePart = new IHLModelRenderer(this, "RotatePart"); + RotatePart.setRotationPoint(0F, 23F, -6F); + setRotation(RotatePart, 0.4F, 0F, 0F); + RotatePart.mirror = true; + RotatePart.addBox("Shape1", 7F, -1F, -1F, 1, 2, 16,false); + RotatePart.addTube("Pipe2", -7.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addBox("Shape4", -8F, -1F, -1F, 1, 2, 16,false); + RotatePart.addBox("Shape3", -7F, -1F, -1F, 14, 2, 2,false); + RotatePart.addTube("Pipe5", -5.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe6", -3.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe11", -1.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe12", 0.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe13", 2.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe14", 4.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe15", 6.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + Piece1 = new IHLModelRenderer(this, "Piece1"); + Piece1.setRotationPoint(0F, 16F, 0F); + setRotation(Piece1, 0F, 0F, 0F); + Piece1.mirror = true; + Piece1.addBox("Shape7", 6F, -4F, 6F, 1, 12, 2,false); + Piece1.addBox("Shape8", -7F, -4F, 6F, 1, 12, 2,false); + Piece1.addTube("PipeW9", -6F, 7F, 7F, 12, 1, 1, 0F,1F,ForgeDirection.EAST); + Piece1.addTube("PipeW10", -6F, -4F, 6F, 12, 1, 1, 0F,1F,ForgeDirection.EAST); + Piece1.addBox("Shape2", 0F, 7F, 0F, 4, 1, 1,false); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } +} diff --git a/ihl/processing/metallurgy/DrawingDeskTileEntity.java b/ihl/processing/metallurgy/DrawingDeskTileEntity.java new file mode 100644 index 0000000..aed1a97 --- /dev/null +++ b/ihl/processing/metallurgy/DrawingDeskTileEntity.java @@ -0,0 +1,173 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.api.network.INetworkClientTileEntityEventListener; +import ic2.api.recipe.IRecipeInput; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.network.NetworkManager; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.recipes.RecipeInputWire; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class DrawingDeskTileEntity extends TileEntityInventory implements IHasGui, INetworkClientTileEntityEventListener +{ + protected static UniversalRecipeManager recipeManager = new UniversalRecipeManager("DrawingDesk"); + public short progress; + protected short operationLength=200; + public final ApparatusProcessableInvSlot input; + public final IHLInvSlotOutput output; + boolean isGuiScreenOpened=false; + + public DrawingDeskTileEntity() + { + super(); + input = new ApparatusProcessableInvSlot(this, "input", 0, Access.IO, 1, 64); + output = new IHLInvSlotOutput(this, "output", 1, 1); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if (this.canOperate() && this.isGuiScreenOpened) + { + this.setActive(true); + + if (this.progress == 0) + { + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + ++this.progress; + if (this.progress >= this.operationLength) + { + this.operate(); + this.progress = 0; + IC2.network.get().initiateTileEntityEvent(this, 2, true); + } + } + else + { + if (this.progress != 0 && this.getActive()) + { + IC2.network.get().initiateTileEntityEvent(this, 1, true); + } + if (!this.canOperate()) + { + this.progress = 0; + } + this.setActive(false); + } + } + + @Override + public String getInventoryName() { + return "DrawingDesk"; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("DrawingDesk"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new DrawingDeskGui(new DrawingDeskContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + this.isGuiScreenOpened=true; + return new DrawingDeskContainer(player, this); + } + + public void operate() + { + List input1 = DrawingDeskTileEntity.recipeManager.getRecipeInput(getInput()).getItemInputs(); + List output1 = DrawingDeskTileEntity.recipeManager.getOutputFor(getInput(), false, false).getItemOutputs(); + this.output.add(output1); + if(input1.get(0) instanceof RecipeInputWire) + { + int fiberLength = input1.get(0).getAmount(); + boolean isFiberConsumed = IHLUtils.adjustWireLength(this.input.get(), -fiberLength); + if(isFiberConsumed) + { + this.input.put(null); + } + } + else + { + this.input.consume(0, input1.get(0).getAmount()); + } + } + + public List[] getInput() + { + return new List[] {null,Arrays.asList(new ItemStack[] {input.get()})}; + } + + public boolean canOperate() + { + if(DrawingDeskTileEntity.recipeManager.getOutputFor(getInput(), false, false)==null) return false; + List output1 = DrawingDeskTileEntity.recipeManager.getOutputFor(getInput(), false, false).getItemOutputs(); + return this.output.canAdd(output1); + } + + @Override + public void onGuiClosed(EntityPlayer arg0) {} + + public static void addRecipe(ItemStack input, ItemStack output) + { + if(input==null || output==null) throw new NullPointerException(); + recipeManager.addRecipe(new UniversalRecipeInput(null,Arrays.asList(new ItemStack[] {input})), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {output}),20)); + } + + public int gaugeProgressScaled(int i) + { + return this.progress * i / this.operationLength; + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + switch(event) + { + case 0: + this.isGuiScreenOpened=false; + break; + } + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} diff --git a/ihl/processing/metallurgy/ElectricEngineInvSlot.java b/ihl/processing/metallurgy/ElectricEngineInvSlot.java new file mode 100644 index 0000000..c89c50f --- /dev/null +++ b/ihl/processing/metallurgy/ElectricEngineInvSlot.java @@ -0,0 +1,54 @@ +package ihl.processing.metallurgy; + +import ic2.core.Ic2Items; +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlot; +import net.minecraft.item.ItemStack; + +public class ElectricEngineInvSlot extends InvSlot { + + public ElectricEngineInvSlot(TileEntityInventory base1, String name1, + int oldStartIndex1, Access access1, int count, int stackSizeLimit1) { + super(base1, name1, oldStartIndex1, access1, count); + this.setStackSizeLimit(stackSizeLimit1); + } + + public float getEfficiency() + { + if(this.isEmpty()) + { + return 0F; + } + else if(this.get().getItem() instanceof ElectricEngineItem) + { + return ((ElectricEngineItem)this.get().getItem()).type.efficiency; + } + else if(this.get().getItem() == Ic2Items.elemotor.getItem() && this.get().getItemDamage() == Ic2Items.elemotor.getItemDamage()) + { + return 0.2f; + } + else + { + return 0f; + } + } + + @Override + public boolean accepts(ItemStack stack) + { + if(stack!=null && stack.getItem() == Ic2Items.elemotor.getItem() && stack.getItemDamage() == Ic2Items.elemotor.getItemDamage()) + { + return true; + } + else + { + return stack==null?true:stack.getItem() instanceof ElectricEngineItem; + } + } + + public boolean correctContent() + { + return this.get()==null?false:this.get().stackSize==1 && ((this.get().getItem() instanceof ElectricEngineItem) || (this.get().getItem() == Ic2Items.elemotor.getItem() && this.get().getItemDamage() == Ic2Items.elemotor.getItemDamage())); + } + +} diff --git a/ihl/processing/metallurgy/ElectricEngineItem.java b/ihl/processing/metallurgy/ElectricEngineItem.java new file mode 100644 index 0000000..ec1bdf6 --- /dev/null +++ b/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 net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.Item; +import net.minecraft.util.IIcon; +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; + +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/ihl/processing/metallurgy/ExtruderContainer.java b/ihl/processing/metallurgy/ExtruderContainer.java new file mode 100644 index 0000000..f4af0c0 --- /dev/null +++ b/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.engine,0, 8, 32)); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + if (this.tileEntity.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/ihl/processing/metallurgy/ExtruderGui.java b/ihl/processing/metallurgy/ExtruderGui.java new file mode 100644 index 0000000..1c10b89 --- /dev/null +++ b/ihl/processing/metallurgy/ExtruderGui.java @@ -0,0 +1,58 @@ +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; + +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) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(tex); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.9F); + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(9, 15 + 12 - i1, 176, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18); + this.drawTexturedModalRect(74, 34, 198, 0, i1 + 1, 13); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(tex); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 26, 34, xOffset, yOffset); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(tex); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/ihl/processing/metallurgy/ExtruderModel.java b/ihl/processing/metallurgy/ExtruderModel.java new file mode 100644 index 0000000..fb28d50 --- /dev/null +++ b/ihl/processing/metallurgy/ExtruderModel.java @@ -0,0 +1,100 @@ +package ihl.processing.metallurgy; + +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; +import ihl.model.IHLModelRenderer; + +public class ExtruderModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer Belt; + IHLModelRenderer Belt2; + IHLModelRenderer Extruder; + + public ExtruderModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("RotatingPart2.PipeN7", 49, 23); + setTextureOffset("RotatingPart2.PipeN4", 0, 7); + setTextureOffset("MotorPart1.PipeN41", 0, 0); + setTextureOffset("MotorPart1.PipeN12", 0, 0); + setTextureOffset("MotorPart1.PipeN13", 0, 0); + setTextureOffset("MotorPart2.Shape4", 0, 24); + setTextureOffset("MotorPart2.Shape7", 0, 9); + setTextureOffset("MotorPart2.Shape10", 0, 9); + setTextureOffset("Belt.Shape12", 0, 0); + setTextureOffset("Belt2.Shape13", 0, 0); + setTextureOffset("Extruder.PipeN16", 0, 0); + setTextureOffset("Extruder.PipeN15", 24, 20); + setTextureOffset("Extruder.Shape8", 0, 0); + setTextureOffset("Extruder.PipeU17", 0, 0); + setTextureOffset("Extruder.PipeUC18", 0, 0); + setTextureOffset("Extruder.Shape14", 0, 0); + setTextureOffset("Extruder.PipeN14", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape3", -5F, 0F, -7F, 4, 7, 1); + Base.addBox("Shape16", 3F, 3F, -6F, 3, 4, 1); + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(-3F, 18F, -7F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = true; + RotatingPart2.addTube("PipeN7", -2.5F, -2.5F, -1F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN4", -1F, -1F, 1F, 2, 2, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1 = new IHLModelRenderer(this, "MotorPart1"); + MotorPart1.setRotationPoint(4.5F, 20.5F, 0F); + setRotation(MotorPart1, 0F, 0F, 0F); + MotorPart1.mirror = true; + MotorPart1.addTube("PipeN41", -1.5F, -1.5F, -8F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN12", -0.5F, -0.5F, -7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN13", -1.5F, -1.5F, -5F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + MotorPart2 = new IHLModelRenderer(this, "MotorPart2"); + MotorPart2.setRotationPoint(0F, 16F, 0F); + setRotation(MotorPart2, 0F, 0F, 0F); + MotorPart2.mirror = true; + MotorPart2.addBox("Shape4", 3F, 3F, 0F, 3, 4, 4); + MotorPart2.addBox("Shape7", 6F, 3F, -5F, 2, 4, 5); + MotorPart2.addBox("Shape10", 1F, 3F, -5F, 2, 4, 5); + Belt = new IHLModelRenderer(this, "Belt"); + Belt.setRotationPoint(-3F, 15.5F, -7.9F); + setRotation(Belt, 0F, 0F, 0.45F); + Belt.mirror = true; + Belt.addBox("Shape12", 0.5F, 0F, 0F, 8, 1, 1); + Belt2 = new IHLModelRenderer(this, "Belt2"); + Belt2.setRotationPoint(-3F, 19.5F, -7.9F); + setRotation(Belt2, 0F, 0F, 0.19F); + Belt2.mirror = true; + Belt2.addBox("Shape13", 0F, 0F, 0F, 8, 1, 1); + Extruder = new IHLModelRenderer(this, "Extruder"); + Extruder.setRotationPoint(0F, 16F, 0F); + setRotation(Extruder, 0F, 0F, 0F); + Extruder.mirror = true; + Extruder.addTube("PipeN16", -4.5F, 0.5F, -5F, 3, 3, 12, 0F,1F,ForgeDirection.NORTH); + Extruder.addTube("PipeN15", -5.5F, -0.5F, 0F, 5, 5, 7, 0.5F,1F,ForgeDirection.NORTH); + Extruder.addBox("Shape8", -5F, 4F, 6.9F, 4, 3, 1); + Extruder.addTube("PipeU17", -5.5F, -8F, -5F, 5, 8, 5, 0.8F,1F,ForgeDirection.UP); + Extruder.addTube("PipeUC18", -5.5F, 0F, -5F, 5, 2, 5, 0.8F,0.6F,ForgeDirection.UP); + Extruder.addBox("Shape14", -5F, 3F, -4.9F, 4, 4, 1); + Extruder.addTube("PipeN14", -5.5F, -0.5F, 7F, 5, 5, 1, 0.5F,1F,ForgeDirection.NORTH); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/metallurgy/ExtruderTileEntity.java b/ihl/processing/metallurgy/ExtruderTileEntity.java new file mode 100644 index 0000000..de7a4c7 --- /dev/null +++ b/ihl/processing/metallurgy/ExtruderTileEntity.java @@ -0,0 +1,170 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.network.NetworkManager; +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; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ExtruderTileEntity extends BasicElectricMotorTileEntity{ + + public final ApparatusProcessableInvSlot input; + public final ApparatusProcessableInvSlot input2; + public boolean hasEngine; + 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); + isGuiScreenOpened=true; + } + + + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("hasEngine"); + return fields; + } + + + @Override + public String getInventoryName() { + return "Extruder"; + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if(this.engine.isEmpty() && hasEngine==true) + { + this.hasEngine=false; + IC2.network.get().updateTileEntityField(this, "hasEngine"); + } + else if(this.engine.correctContent() && hasEngine==false) + { + this.hasEngine=true; + IC2.network.get().updateTileEntityField(this, "hasEngine"); + } + 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(0,ri.getItemInputs().get(0).getAmount()); + this.input2.consume(0,ri.getItemInputs().get(1).getAmount()); + } + + public UniversalRecipeOutput getOutput() + { + return ExtruderTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + @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/ihl/processing/metallurgy/GasWeldingStationContainer.java b/ihl/processing/metallurgy/GasWeldingStationContainer.java new file mode 100644 index 0000000..2f9e160 --- /dev/null +++ b/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/ihl/processing/metallurgy/GasWeldingStationGui.java b/ihl/processing/metallurgy/GasWeldingStationGui.java new file mode 100644 index 0000000..7a34fa6 --- /dev/null +++ b/ihl/processing/metallurgy/GasWeldingStationGui.java @@ -0,0 +1,79 @@ +package ihl.processing.metallurgy; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.IC2; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Slot; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import ic2.core.network.NetworkManager; +import ihl.utils.IHLRenderUtils; + +@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"; + } + + private int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + private int mZ() + { + switch(this.getFacing()) + { + case 3: + return 1; + case 2: + return -1; + case 4: + return 0; + case 5: + return 0; + default: + return -1; + } + } + + private short getFacingFromXZ(int x, int z) + { + switch(x) + { + case -1: + return (short)4; + case 1: + return (short)5; + default: + switch(z) + { + case 1: + return (short)3; + case -1: + return (short)2; + default: + return (short)2; + } + } + } + + @Override + @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()}), false, false); + 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()}), false, false); + 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(Arrays.asList(new FluidStack[] {this.flammableGasTank.getLigthestFluid(), this.oxygenTank.getFluid()}), Arrays.asList(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(Arrays.asList(new FluidStack[] {inputFluid}), Arrays.asList(new ItemStack[] {input})), new UniversalRecipeOutput(Arrays.asList(new FluidStack [] {output, output2}),Arrays.asList(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/ihl/processing/metallurgy/IProductionLine.java b/ihl/processing/metallurgy/IProductionLine.java new file mode 100644 index 0000000..5cf7605 --- /dev/null +++ b/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/ihl/processing/metallurgy/ImpregnatingMachineContainer.java b/ihl/processing/metallurgy/ImpregnatingMachineContainer.java new file mode 100644 index 0000000..4489af2 --- /dev/null +++ b/ihl/processing/metallurgy/ImpregnatingMachineContainer.java @@ -0,0 +1,114 @@ +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 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.tileEntity.getTankAmount() != this.lastFluidAmount || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + + if (this.tileEntity.temperature != this.lastTemperature) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.temperature); + } + if (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/ihl/processing/metallurgy/ImpregnatingMachineGui.java b/ihl/processing/metallurgy/ImpregnatingMachineGui.java new file mode 100644 index 0000000..c6a8b0f --- /dev/null +++ b/ihl/processing/metallurgy/ImpregnatingMachineGui.java @@ -0,0 +1,63 @@ +package ihl.processing.metallurgy; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import ihl.utils.IHLRenderUtils; + +@SideOnly(Side.CLIENT) +public class 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/ihl/processing/metallurgy/ImpregnatingMachineRender.java b/ihl/processing/metallurgy/ImpregnatingMachineRender.java new file mode 100644 index 0000000..3231b71 --- /dev/null +++ b/ihl/processing/metallurgy/ImpregnatingMachineRender.java @@ -0,0 +1,53 @@ +package ihl.processing.metallurgy; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; + +import ihl.model.FluidRenderer; + +public class ImpregnatingMachineRender extends TileEntitySpecialRenderer{ + + + +public ImpregnatingMachineRender(){} + +public void renderAModelAt(ImpregnatingMachineTileEntity 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.visibleFluidId == -1 || tile.visibleFluidAmount <= 0) { + return; + } + FluidStack fluidStack = new FluidStack(FluidRegistry.getFluid(tile.visibleFluidId),tile.visibleFluidAmount); + 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 cap = 900F; + 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 par1TileEntity, double par2, double par4, double par6, float par8) + { + this.renderAModelAt((ImpregnatingMachineTileEntity)par1TileEntity, par2, par4, par6, par8); + } +} \ No newline at end of file diff --git a/ihl/processing/metallurgy/ImpregnatingMachineTileEntity.java b/ihl/processing/metallurgy/ImpregnatingMachineTileEntity.java new file mode 100644 index 0000000..89a8a63 --- /dev/null +++ b/ihl/processing/metallurgy/ImpregnatingMachineTileEntity.java @@ -0,0 +1,393 @@ +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 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; +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 ic2.core.network.NetworkManager; +import ihl.interfaces.IHasTemperature; +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; + +public class ImpregnatingMachineTileEntity extends TileEntityInventory implements IHasGui,INetworkTileEntityEventListener, IFluidHandler, IHasTemperature +{ + 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"); + } + temperature=(short) (this.fluidTank.getTemperature()-273); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank); + boolean needsInvUpdate = false; + if (this.canOperate()) + { + this.setActive(true); + if (this.progress == 0) + { + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + + this.progress+=this.operationLength/this.getOutput().getTime(); + if (this.progress >= this.operationLength) + { + this.operate(); + needsInvUpdate = true; + this.progress = 0; + IC2.network.get().initiateTileEntityEvent(this, 2, true); + } + } + else + { + if (this.progress != 0 && this.getActive()) + { + IC2.network.get().initiateTileEntityEvent(this, 1, true); + } + if (!this.canOperate()) + { + this.progress = 0; + } + this.setActive(false); + } + } + + @Override + public FluidStack drain(ForgeDirection from, int amount, boolean doDrain) + { + FluidStack fstack = this.fluidTank.drain(amount, doDrain); + return fstack; + } + + + //1.7.10 API + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return true; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return true; + } + + @Override + public String getInventoryName() { + return "impregnatingMachine"; + } + + private int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + private int mZ() + { + switch(this.getFacing()) + { + case 3: + return 1; + case 2: + return -1; + case 4: + return 0; + case 5: + return 0; + default: + return -1; + } + } + + private short getFacingFromXZ(int x, int z) + { + switch(x) + { + case -1: + return (short)4; + case 1: + return (short)5; + default: + switch(z) + { + case 1: + return (short)3; + case -1: + return (short)2; + default: + return (short)2; + } + } + } + + public float getRenderLiquidLevel() + { + return (float)this.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(), false, false); + } + + public List[] getInput() + { + for(int i=0;i getRecipes() { + return recipeManager.getRecipes(); + } + + public static void addQuenchingRecipe(String nameHot, String nameQuenched) + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {new FluidStack(FluidRegistry.WATER, 50)}), Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack(nameHot)})), new UniversalRecipeOutput(null, Arrays.asList(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 getTemperature() + { + return this.fluidTank.getTemperature(); + } +} \ No newline at end of file diff --git a/ihl/processing/metallurgy/InjectionMoldBlock.java b/ihl/processing/metallurgy/InjectionMoldBlock.java new file mode 100644 index 0000000..68a9ea9 --- /dev/null +++ b/ihl/processing/metallurgy/InjectionMoldBlock.java @@ -0,0 +1,254 @@ +package ihl.processing.metallurgy; + +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.items_blocks.IHLItemBlock; +import ihl.metallurgy.constants.Details; +import ihl.utils.IHLUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +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; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class InjectionMoldBlock extends Block implements ITileEntityProvider{ + + IIcon textureSide; + + public static InjectionMoldBlock instance; + public static int moldDamageForRecipe=0; + public static String[] materials = new String[] {"Bronze","Steel","Gold","Magnesium", "Lithium", "TarPitch"}; + + 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); + } + + + @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) + { + IIcon sideIcon = this.blockIcon; + 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) + { + if (Loader.isModLoaded("NotEnoughItems")) + { + for(int i=0;i16) + { + if(this.timer--==0) + { + String formattedFluidName=this.getFormattedMaterialName(this.getFluidfromTank().getName()); + if(formattedFluidName!="") + { + int fluidAmountPerItem = Details.getMeltingFluidAmount(this.resultSuffix); + int fluidAmountPerItem2 = Details.getMeltingFluidAmount("nugget"); + ArrayList resultList = OreDictionary.getOres(this.resultSuffix+formattedFluidName); + if(resultList.isEmpty()) + { + resultList=new ArrayList(); + if(IHLUtils.getItemStackIfExist(this.resultSuffix+formattedFluidName)!=null)resultList.add(IHLUtils.getItemStackIfExist(this.resultSuffix+formattedFluidName)); + } + 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) + { + if(input.length()<8) + { + return ""; + } + 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/ihl/processing/metallurgy/LatheContainer.java b/ihl/processing/metallurgy/LatheContainer.java new file mode 100644 index 0000000..c863f7b --- /dev/null +++ b/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.engine,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/ihl/processing/metallurgy/LatheGui.java b/ihl/processing/metallurgy/LatheGui.java new file mode 100644 index 0000000..e09f414 --- /dev/null +++ b/ihl/processing/metallurgy/LatheGui.java @@ -0,0 +1,60 @@ +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 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) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + + 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); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(tex); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 47, 56, xOffset, yOffset); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(tex); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/ihl/processing/metallurgy/LathePart1Model.java b/ihl/processing/metallurgy/LathePart1Model.java new file mode 100644 index 0000000..c08b3bf --- /dev/null +++ b/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/ihl/processing/metallurgy/LathePart1TileEntity.java b/ihl/processing/metallurgy/LathePart1TileEntity.java new file mode 100644 index 0000000..9241ba1 --- /dev/null +++ b/ihl/processing/metallurgy/LathePart1TileEntity.java @@ -0,0 +1,98 @@ +package ihl.processing.metallurgy; + +import java.util.List; +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; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class LathePart1TileEntity extends BasicElectricMotorTileEntity implements IWorkspaceElement{ + + public boolean ready=false; + + public LathePart1TileEntity() + { + super(); + this.isGuiScreenOpened=true; + } + + + @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); + } + + + @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/ihl/processing/metallurgy/LathePart2Model.java b/ihl/processing/metallurgy/LathePart2Model.java new file mode 100644 index 0000000..40b9b2a --- /dev/null +++ b/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/ihl/processing/metallurgy/LathePart2TileEntity.java b/ihl/processing/metallurgy/LathePart2TileEntity.java new file mode 100644 index 0000000..4543afa --- /dev/null +++ b/ihl/processing/metallurgy/LathePart2TileEntity.java @@ -0,0 +1,105 @@ +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 ic2.core.network.NetworkManager; +import ihl.utils.IHLUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class 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/ihl/processing/metallurgy/MachineBaseContainer.java b/ihl/processing/metallurgy/MachineBaseContainer.java new file mode 100644 index 0000000..19985fe --- /dev/null +++ b/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/ihl/processing/metallurgy/MachineBaseTileEntity.java b/ihl/processing/metallurgy/MachineBaseTileEntity.java new file mode 100644 index 0000000..51df187 --- /dev/null +++ b/ihl/processing/metallurgy/MachineBaseTileEntity.java @@ -0,0 +1,282 @@ +package ihl.processing.metallurgy; + +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.audio.AudioSource; +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.network.NetworkManager; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.recipes.UniversalRecipeOutput; +import java.util.List; +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; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public abstract class MachineBaseTileEntity extends TileEntityInventory implements IHasGui, IEnergySink +{ + public short progress; + protected short operationLength=200; + private AudioSource startAS; + private AudioSource loopAS; + private AudioSource stopAS; + 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(); + + 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, 14 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(50),50); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + this.drawTexturedModalRect(44, 57, 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/ihl/processing/metallurgy/MuffleFurnanceContainer.java b/ihl/processing/metallurgy/MuffleFurnanceContainer.java new file mode 100644 index 0000000..a36ac3c --- /dev/null +++ b/ihl/processing/metallurgy/MuffleFurnanceContainer.java @@ -0,0 +1,15 @@ +package ihl.processing.metallurgy; + +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; + +public class MuffleFurnanceContainer extends MachineBaseContainer { + + public MuffleFurnanceContainer(EntityPlayer entityPlayer, + MachineBaseTileEntity tileEntity1) { + super(entityPlayer, tileEntity1); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 51, 34)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 1, 69, 34)); + } + +} diff --git a/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java b/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java new file mode 100644 index 0000000..73d12de --- /dev/null +++ b/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java @@ -0,0 +1,135 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.core.ContainerBase; +import ihl.IHLMod; +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 cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class MuffleFurnanceTileEntity extends MachineBaseTileEntity{ + + protected static UniversalRecipeManager recipeManager = new UniversalRecipeManager("mufflefurnace"); + + public MuffleFurnanceTileEntity() + { + super(2); + } + + @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; + } + if(this.getOutput()!=null) + { + List output = MuffleFurnanceTileEntity.recipeManager.getOutputFor(null,this.input.getItemStackList(), true, true).getItemOutputs(); + for(int i=0; i getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public UniversalRecipeOutput getOutput() + { + return MuffleFurnanceTileEntity.recipeManager.getOutputFor(null,this.input.getItemStackList(), false, false); + } + + public static void addRecipe(UniversalRecipeInput universalRecipeInput, UniversalRecipeOutput universalRecipeOutput) + { + recipeManager.addRecipe(universalRecipeInput, universalRecipeOutput); + } + + public static void addRecipe(ItemStack input1, ItemStack output, float f) { + recipeManager.addRecipe(new UniversalRecipeInput(null, Arrays.asList(new ItemStack [] {input1})),new UniversalRecipeOutput(null, Arrays.asList(new RecipeOutputItemStack [] {new RecipeOutputItemStack(output,f)}),20)); + } +} diff --git a/ihl/processing/metallurgy/PassiveBlock.java b/ihl/processing/metallurgy/PassiveBlock.java new file mode 100644 index 0000000..74eb0e8 --- /dev/null +++ b/ihl/processing/metallurgy/PassiveBlock.java @@ -0,0 +1,99 @@ +package ihl.processing.metallurgy; + +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.items_blocks.IHLItemBlock; +import ihl.utils.IHLUtils; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class PassiveBlock extends Block{ + + @SideOnly(Side.CLIENT) + private IIcon[][] textures; + + private static PassiveBlock instance; + + public PassiveBlock() + { + super(Material.iron); + this.setCreativeTab(IHLCreativeTab.tab); + this.setBlockName("IHLShieldAssemblyUnitBlock"); + this.setHardness(2F); + this.setResistance(1F); + instance=this; + } + + public static void init() + { + PassiveBlock block = new PassiveBlock(); + GameRegistry.registerBlock(block, IHLItemBlock.class, "IHLShieldAssemblyUnitBlock"); + Type[] var1 = Type.values(); + for(int i=0;i 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); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(tex); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 47, 56, xOffset, yOffset); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(tex); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/ihl/processing/metallurgy/RollingMachinePart1Model.java b/ihl/processing/metallurgy/RollingMachinePart1Model.java new file mode 100644 index 0000000..460ff62 --- /dev/null +++ b/ihl/processing/metallurgy/RollingMachinePart1Model.java @@ -0,0 +1,97 @@ +package ihl.processing.metallurgy; + + +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; +import ihl.model.IHLModelRenderer; + + +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/ihl/processing/metallurgy/RollingMachinePart1TileEntity.java b/ihl/processing/metallurgy/RollingMachinePart1TileEntity.java new file mode 100644 index 0000000..9c02a47 --- /dev/null +++ b/ihl/processing/metallurgy/RollingMachinePart1TileEntity.java @@ -0,0 +1,161 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.network.NetworkManager; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.recipes.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; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RollingMachinePart1TileEntity extends BasicElectricMotorTileEntity{ + + public final ApparatusProcessableInvSlot input; + public final IHLInvSlotOutput output; + public boolean hasEngine; + 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); + isGuiScreenOpened=true; + } + + public UniversalRecipeOutput getOutput() + { + return RollingMachinePart1TileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("assembled"); + fields.add("hasEngine"); + 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.engine.isEmpty() && hasEngine==true) + { + this.hasEngine=false; + IC2.network.get().updateTileEntityField(this, "hasEngine"); + } + else if(this.engine.correctContent() && hasEngine==false) + { + this.hasEngine=true; + IC2.network.get().updateTileEntityField(this, "hasEngine"); + } + + 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 output = RollingMachinePart1TileEntity.recipeManager.getOutputFor(getInput(), false, false).getItemOutputs(); + this.output.add(output); + this.input.consume(0, 1); + } + + @Override + public List[] getInput() + { + return new List[]{null, Arrays.asList(new ItemStack[] {input.get()})}; + } + + @Override + public boolean canOperate() + { + return this.engine.correctContent() && 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, Arrays.asList(new ItemStack [] {input})), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {output}), 20)); + } + + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} diff --git a/ihl/processing/metallurgy/RollingMachinePart2Model.java b/ihl/processing/metallurgy/RollingMachinePart2Model.java new file mode 100644 index 0000000..b4bda67 --- /dev/null +++ b/ihl/processing/metallurgy/RollingMachinePart2Model.java @@ -0,0 +1,42 @@ +package ihl.processing.metallurgy; + + +import net.minecraft.client.model.ModelBase; +import ihl.model.IHLModelRenderer; + +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/ihl/processing/metallurgy/RollingMachinePart2TileEntity.java b/ihl/processing/metallurgy/RollingMachinePart2TileEntity.java new file mode 100644 index 0000000..6bab8c4 --- /dev/null +++ b/ihl/processing/metallurgy/RollingMachinePart2TileEntity.java @@ -0,0 +1,105 @@ +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 ic2.core.network.NetworkManager; +import ihl.utils.IHLUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class 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/ihl/processing/metallurgy/RollingMachineRender.java b/ihl/processing/metallurgy/RollingMachineRender.java new file mode 100644 index 0000000..ee8b567 --- /dev/null +++ b/ihl/processing/metallurgy/RollingMachineRender.java @@ -0,0 +1,84 @@ +package ihl.processing.metallurgy; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import ic2.api.tile.IWrenchable; +import ihl.IHLModInfo; + +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); + } + if(cte.hasEngine) + { + model.MotorPart1.render(scale); + model.MotorPart2.render(scale); + } + } + GL11.glPopMatrix(); //end + + } +} \ No newline at end of file diff --git a/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceContainer.java b/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceContainer.java new file mode 100644 index 0000000..75c69e8 --- /dev/null +++ b/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceContainer.java @@ -0,0 +1,77 @@ +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.minecraftforge.fluids.FluidStack; + +public class VacuumInductionMeltingFurnaceContainer extends ContainerBase { + public int lastFluidAmount = -1; + public int lastNumberOfFluids = -1; + public short lastProgress = -1; + public short lastEnergy = -1; + public VacuumInductionMeltingFurnaceTileEntity tileEntity; + private final static int height=166; + public List fluidTankFluidList; + private boolean vacuumPumpState=true; + + public VacuumInductionMeltingFurnaceContainer(EntityPlayer entityPlayer, VacuumInductionMeltingFurnaceTileEntity tileEntity1) { + super(tileEntity1); + this.tileEntity=tileEntity1; + fluidTankFluidList = this.tileEntity.fluidTank.getFluidList(); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 141, 8)); + } + @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.fluidTank.getFluidAmount() != this.lastFluidAmount || this.tileEntity.fluidTank.getNumberOfFluids() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + + if (this.tileEntity.vacuumPumpConnected != this.vacuumPumpState) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.vacuumPumpConnected?1:0); + } + } + + this.lastNumberOfFluids = this.tileEntity.fluidTank.getNumberOfFluids(); + this.lastFluidAmount = this.tileEntity.fluidTank.getFluidAmount(); + this.lastProgress = this.tileEntity.progress; + this.vacuumPumpState = this.tileEntity.vacuumPumpConnected; + } + + @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.vacuumPumpConnected=value>0; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceGui.java b/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceGui.java new file mode 100644 index 0000000..8b9ea9e --- /dev/null +++ b/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceGui.java @@ -0,0 +1,87 @@ +package ihl.processing.metallurgy; + +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.collector.GuiMultiTextureButton; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import org.lwjgl.opengl.GL11; + +public class VacuumInductionMeltingFurnaceGui extends GuiContainer { + protected static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIVacuumInductionMeltingFurnace.png"); + private VacuumInductionMeltingFurnaceContainer container; + private GuiMultiTextureButton button1; + private int timer=10; + + + public VacuumInductionMeltingFurnaceGui(VacuumInductionMeltingFurnaceContainer vacuumInductionMeltingFurnaceContainer) { + //the container is instanciated and passed to the superclass for handling + super(vacuumInductionMeltingFurnaceContainer); + this.container=vacuumInductionMeltingFurnaceContainer; + } + + @Override + public void initGui() + { + super.initGui(); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + button1=new GuiMultiTextureButton(0, x+13, y+55, 27, 27, background,13,55,229,229); + this.buttonList.add(button1); + } + + @Override + public void actionPerformed(GuiButton button) + { + super.actionPerformed(button); + IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, button.id); + if (button.id == 0) + { + button1.isActive=false; + timer=10; + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + fontRendererObj.drawString(StatCollector.translateToLocal("ihl.gui.muffleFurnace"), 40, 12, 14722081); + this.mc.renderEngine.bindTexture(background); + 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(50),50); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + 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(background); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + if(timer>0) + { + timer--; + } + if(timer==1) + { + button1.isActive=true; + } + } +} diff --git a/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceTileEntity.java b/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceTileEntity.java new file mode 100644 index 0000000..3fc85a8 --- /dev/null +++ b/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceTileEntity.java @@ -0,0 +1,260 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.Map; + +import ic2.api.network.INetworkClientTileEntityEventListener; +import ic2.core.ContainerBase; +import ihl.IHLMod; +import ihl.processing.chemistry.GaedesMercuryRotaryPumpTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.tunneling_shield.IMultiBlock; +import ihl.tunneling_shield.MultiBlockSpacerBlock; +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.FluidStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class VacuumInductionMeltingFurnaceTileEntity extends MachineBaseTileEntity implements INetworkClientTileEntityEventListener, IMultiBlock{ + + protected static UniversalRecipeManager recipeManager = new UniversalRecipeManager("vacuuminductionmeltingfurnace"); + public final IHLFluidTank fluidTank = new IHLFluidTank(864); + public boolean vacuumPumpConnected=false; + private GaedesMercuryRotaryPumpTileEntity lastGMRP; + private int minX,minY,minZ,maxX,maxY,maxZ; + + public VacuumInductionMeltingFurnaceTileEntity() + { + super(1); + } + + @Override + public void setFacing(short facing1) + { + short facing2 = (short) Math.max(facing1, 2); + super.setFacing(facing2); + switch(facing2) + { + case 0: + setupMultiblockStructure(-1,-2,0); + break; + case 1: + setupMultiblockStructure(-1,0,0); + break; + case 2: + setupMultiblockStructure(-1,0,-2); + break; + case 3: + setupMultiblockStructure(-1,0,0); + break; + case 4: + setupMultiblockStructure(-2,0,-1); + break; + case 5: + setupMultiblockStructure(0,0,-1); + break; + } + } + + @Override + public String getStartSoundFile() { + return null; + } + + @Override + public String getLoopSoundFile() { + return null; + } + + @Override + public String getStopSoundFile() { + return null; + } + + @Override + public String getInventoryName() { + return "VacuumInductionMeltingFurnace"; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new VacuumInductionMeltingFurnaceGui(new VacuumInductionMeltingFurnaceContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new VacuumInductionMeltingFurnaceContainer(player, this); + } + + @Override + public void operate() + { + ItemStack content = this.input.get(); + if(content!=null) + { + UniversalRecipeOutput routput = recipeManager.getOutputFor(null, Arrays.asList(new ItemStack [] {content}),false, false); + if(routput!=null && !routput.getFluidOutputs().isEmpty()) + { + FluidStack fluidStack = routput.getFluidOutputs().get(0).copy(); + fluidStack.amount *= content.stackSize; + this.input.clear(); + this.fluidTank.fill(fluidStack, true); + useVacuumPump(); + } + } + } + + @Override + public boolean canOperate() + { + return checkSpecialConditionVacuumPump() && getOutput()!=null; + } + + private void useVacuumPump() + { + if(lastGMRP!=null && !lastGMRP.isInvalid() && lastGMRP.ready) + { + lastGMRP.ready=false; + } + } + + private boolean checkSpecialConditionVacuumPump() + { + if(lastGMRP!=null && !lastGMRP.isInvalid() && lastGMRP.ready) + { + this.vacuumPumpConnected=true; + return true; + } + int[] xz = new int [] {0,1,1,0,-1,-1,0}; + for(int i0=-1;i0<=0;i0++) + { + for(int i=0;i getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public UniversalRecipeOutput getOutput() + { + return VacuumInductionMeltingFurnaceTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + switch(event) + { + case 0: + TileEntity te = worldObj.getTileEntity(xCoord, yCoord, zCoord); + if(te instanceof InjectionMoldTileEntity) + { + InjectionMoldTileEntity im = (InjectionMoldTileEntity)te; + im.fill(ForgeDirection.UP, this.fluidTank.drain(this.fluidTank.getCapacity(), true), true); + } + break; + } + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + try + { + this.energy = nbttagcompound.getDouble("energy"); + } + catch (Exception var3)//This was blindlessly copied from IC2 source a lot of time ago. And this is not necessary here. And still... + { + this.energy = nbttagcompound.getInteger("energy"); + + if (this.maxStorage > Integer.MAX_VALUE) + { + this.energy *= 10.0D; + } + } + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setDouble("energy", this.energy); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + } + + private void setupMultiblockStructure(int x0,int y0,int z0) + { + minX=xCoord+x0; + maxX=xCoord+x0+3; + minY=yCoord+y0; + maxY=yCoord+y0+3; + minZ=zCoord+z0; + maxZ=zCoord+z0+3; + for(int ix=xCoord+x0;ix=minX && x<=maxX && y>=minY && y<=maxY && z>=minZ && z<=maxZ; + } + + @Override + public boolean getIsInvalid() + { + return this.isInvalid(); + } + +} diff --git a/ihl/processing/metallurgy/VulcanizationExtrudingMoldModel.java b/ihl/processing/metallurgy/VulcanizationExtrudingMoldModel.java new file mode 100644 index 0000000..e3ab6c7 --- /dev/null +++ b/ihl/processing/metallurgy/VulcanizationExtrudingMoldModel.java @@ -0,0 +1,54 @@ +package ihl.processing.metallurgy; + +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; +import ihl.model.IHLModelRenderer; + +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/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java b/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java new file mode 100644 index 0000000..6feca57 --- /dev/null +++ b/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java @@ -0,0 +1,280 @@ +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.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +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(Arrays.asList(new FluidStack[] {inputFluid}),Arrays.asList(new ItemStack[] {input})),new UniversalRecipeOutput(null,Arrays.asList(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 getRecipes() + { + return recipeManager.getRecipes(); + } +} diff --git a/ihl/processing/metallurgy/WireMillContainer.java b/ihl/processing/metallurgy/WireMillContainer.java new file mode 100644 index 0000000..ec1ddc0 --- /dev/null +++ b/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.engine,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/ihl/processing/metallurgy/WireMillGui.java b/ihl/processing/metallurgy/WireMillGui.java new file mode 100644 index 0000000..e09b4ab --- /dev/null +++ b/ihl/processing/metallurgy/WireMillGui.java @@ -0,0 +1,72 @@ +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); + if(!this.container.tileEntity.engine.correctContent()) + { + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 25, 14, xOffset, yOffset); + } + 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/ihl/processing/metallurgy/WireMillTileEntity.java b/ihl/processing/metallurgy/WireMillTileEntity.java new file mode 100644 index 0000000..16eaa4b --- /dev/null +++ b/ihl/processing/metallurgy/WireMillTileEntity.java @@ -0,0 +1,385 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.mutable.MutableObject; + +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.InvSlotConsumableItemStack; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.block.invslot.InvSlot.InvSide; +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.RecipeOutputItemStack; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class 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.isGuiScreenOpened=true; + 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(0, 1); + } + } + 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); + } + 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(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); + } + } + + @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(), false, false); + } + + public static void addRecipe(FluidStack moltenMetal, IRecipeInput inputDice,ItemStack output1) + { + recipeManager.addRecipe(new UniversalRecipeInput(Arrays.asList(new IRecipeInputFluid[] {new RecipeInputFluidDictionary("lubricant", 1),new RecipeInputFluidDictionary("water", 1),new RecipeInputFluidStack(moltenMetal)}),Arrays.asList(new IRecipeInput[] {inputDice})),new UniversalRecipeOutput(null,Arrays.asList(new ItemStack[] {output1}),200)); + } + + public static void addRecipe(String string, FluidStack fluidStack) + { + recipeManager.addRecipe(new UniversalRecipeInput(null, Arrays.asList(new IRecipeInput [] {new RecipeInputOreDict(string)})),new UniversalRecipeOutput(Arrays.asList(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/ihl/processing/metallurgy/WoodenRollingMachineContainer.java b/ihl/processing/metallurgy/WoodenRollingMachineContainer.java new file mode 100644 index 0000000..100da1b --- /dev/null +++ b/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.engine,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/ihl/processing/metallurgy/WoodenRollingMachineGui.java b/ihl/processing/metallurgy/WoodenRollingMachineGui.java new file mode 100644 index 0000000..d7b3456 --- /dev/null +++ b/ihl/processing/metallurgy/WoodenRollingMachineGui.java @@ -0,0 +1,69 @@ +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; + +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) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(tex); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(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); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(tex); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 47, 56, xOffset, yOffset); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(tex); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } + + private int getFrameY(int number) + { + return (number % 10) * 24 + 14; + } + + private int getFrameX(int number) + { + return (number / 10) * 24 + 176; + } +} diff --git a/ihl/processing/metallurgy/WoodenRollingMachinePart1Model.java b/ihl/processing/metallurgy/WoodenRollingMachinePart1Model.java new file mode 100644 index 0000000..ac7799b --- /dev/null +++ b/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/ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java b/ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java new file mode 100644 index 0000000..eb40389 --- /dev/null +++ b/ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java @@ -0,0 +1,171 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.api.recipe.IRecipeInput; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.network.NetworkManager; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.recipes.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; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class WoodenRollingMachinePart1TileEntity extends BasicElectricMotorTileEntity{ + + public final ApparatusProcessableInvSlot input; + public final IHLInvSlotOutput output; + public boolean hasEngine; + 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); + isGuiScreenOpened=true; + } + + public UniversalRecipeOutput getOutput() + { + return WoodenRollingMachinePart1TileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("assembled"); + fields.add("hasEngine"); + 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.engine.isEmpty() && hasEngine==true) + { + this.hasEngine=false; + IC2.network.get().updateTileEntityField(this, "hasEngine"); + } + else if(this.engine.correctContent() && hasEngine==false) + { + this.hasEngine=true; + IC2.network.get().updateTileEntityField(this, "hasEngine"); + } + + 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(), false, false).getItemOutputs(); + this.output.add(rOutput); + for(int i=0;i getRecipes() { + return recipeManager.getRecipes(); + } + + public static void addRecipe(ItemStack input, ItemStack input3, ItemStack output) + { + recipeManager.addRecipe(new UniversalRecipeInput(null, Arrays.asList(new ItemStack[] {input,input3})), new UniversalRecipeOutput(null,Arrays.asList(new ItemStack[] {output}),20)); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} diff --git a/ihl/processing/metallurgy/WoodenRollingMachinePart2Model.java b/ihl/processing/metallurgy/WoodenRollingMachinePart2Model.java new file mode 100644 index 0000000..2673124 --- /dev/null +++ b/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 net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; +import ihl.model.IHLModelRenderer; + +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/ihl/processing/metallurgy/WoodenRollingMachinePart2TileEntity.java b/ihl/processing/metallurgy/WoodenRollingMachinePart2TileEntity.java new file mode 100644 index 0000000..165d84b --- /dev/null +++ b/ihl/processing/metallurgy/WoodenRollingMachinePart2TileEntity.java @@ -0,0 +1,105 @@ +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 ic2.core.network.NetworkManager; +import ihl.utils.IHLUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class 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/ihl/processing/metallurgy/WoodenRollingMachineRender.java b/ihl/processing/metallurgy/WoodenRollingMachineRender.java new file mode 100644 index 0000000..84fbcd6 --- /dev/null +++ b/ihl/processing/metallurgy/WoodenRollingMachineRender.java @@ -0,0 +1,94 @@ +package ihl.processing.metallurgy; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import ic2.api.tile.IWrenchable; +import ihl.IHLModInfo; + +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); + } + if(cte.hasEngine) + { + 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