From 2db8e30b1d2151fdde5d08a6c06aef55f0c397d2 Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Fri, 27 Jan 2017 11:32:28 +0300 Subject: License, readme and stuff --- ihl/flexible_cable/AnchorBlock.java | 11 - ihl/flexible_cable/AnchorTileEntity.java | 7 +- .../BatterySwitchUnitTileEntity.java | 7 - .../FlexibleCableHolderBaseTileEntity.java | 20 +- ihl/flexible_cable/IHLENet.java | 4 +- ihl/flexible_cable/IHLGrid.java | 21 +- ihl/flexible_cable/InvSlotOutputInProgress.java | 2 +- .../InvSlotProcessableIronWorkbench.java | 27 +- ihl/flexible_cable/InvSlotTool.java | 76 ++--- ihl/flexible_cable/InvSlotWorkspaceElement.java | 16 +- ihl/flexible_cable/IronWorkbenchContainer.java | 8 +- ihl/flexible_cable/IronWorkbenchGui.java | 11 - ihl/flexible_cable/IronWorkbenchInvSlot.java | 2 +- ihl/flexible_cable/IronWorkbenchRender.java | 4 - ihl/flexible_cable/IronWorkbenchRender.java~ | 40 --- ihl/flexible_cable/IronWorkbenchTileEntity.java | 71 +++- ihl/flexible_cable/IronWorkbenchTileEntity.java~ | 367 --------------------- ihl/flexible_cable/NodeEntity.java | 27 +- ihl/flexible_cable/NodeRender.java | 9 - ihl/flexible_cable/PowerCableNodeEntity.java | 16 +- .../RectifierTransformerUnitTileEntity.java | 7 +- ihl/flexible_cable/SetOfDiesMiniGUI.java | 4 - ihl/flexible_cable/SubAnchorEnergyNetNode.java | 8 +- ihl/flexible_cable/SubRTUEnergyNetNode.java | 6 +- 24 files changed, 145 insertions(+), 626 deletions(-) delete mode 100644 ihl/flexible_cable/IronWorkbenchRender.java~ delete mode 100644 ihl/flexible_cable/IronWorkbenchTileEntity.java~ (limited to 'ihl/flexible_cable') diff --git a/ihl/flexible_cable/AnchorBlock.java b/ihl/flexible_cable/AnchorBlock.java index 7c12b49..9d9c1dc 100644 --- a/ihl/flexible_cable/AnchorBlock.java +++ b/ihl/flexible_cable/AnchorBlock.java @@ -1,10 +1,5 @@ package ihl.flexible_cable; -import ic2.core.IC2; -import ic2.core.item.tool.ItemToolWrench; -import ihl.IHLCreativeTab; import ihl.IHLModInfo; -import ihl.enviroment.LightBulbTileEntity; -import ihl.utils.IHLUtils; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -12,19 +7,14 @@ import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; -import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class AnchorBlock extends Block implements ITileEntityProvider { - private String unlocalizedName; private IIcon blockIconSide; public AnchorBlock(String unlocalizedName1) @@ -170,7 +160,6 @@ public class AnchorBlock extends Block implements ITileEntityProvider { { AnchorTileEntity ate = (AnchorTileEntity) te; float portSize=0.1f; - boolean firstBB=false; float bbMinX = 1f; float bbMaxX = 0f; float bbMinY = 1f; diff --git a/ihl/flexible_cable/AnchorTileEntity.java b/ihl/flexible_cable/AnchorTileEntity.java index b9057ba..b03a3d9 100644 --- a/ihl/flexible_cable/AnchorTileEntity.java +++ b/ihl/flexible_cable/AnchorTileEntity.java @@ -8,8 +8,6 @@ import ic2.api.energy.tile.IEnergySource; import ic2.core.ExplosionIC2; import ic2.core.IC2; import ic2.core.block.TileEntityBlock; -import ihl.IHLMod; -import ihl.interfaces.ICableHolder; import ihl.interfaces.IEnergyNetNode; import ihl.interfaces.IMultiPowerCableHolder; import ihl.utils.IHLUtils; @@ -19,15 +17,11 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; @@ -406,6 +400,7 @@ public class AnchorTileEntity extends TileEntityBlock implements IEnergySink, IE } } + @Override public boolean isCableRemoved(int chainUniqueID) { if(!checkCables) diff --git a/ihl/flexible_cable/BatterySwitchUnitTileEntity.java b/ihl/flexible_cable/BatterySwitchUnitTileEntity.java index 375cb21..f4fc6c1 100644 --- a/ihl/flexible_cable/BatterySwitchUnitTileEntity.java +++ b/ihl/flexible_cable/BatterySwitchUnitTileEntity.java @@ -12,19 +12,12 @@ import ic2.api.energy.tile.IEnergySource; import ic2.api.network.INetworkClientTileEntityEventListener; import ic2.core.ExplosionIC2; import ic2.core.IC2; -import ic2.core.block.TileEntityBlock; -import ihl.IHLMod; -import ihl.flexible_cable.IHLGrid; -import ihl.flexible_cable.NodeEntity; -import ihl.interfaces.IEnergyNetNode; import ihl.utils.IHLUtils; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; diff --git a/ihl/flexible_cable/FlexibleCableHolderBaseTileEntity.java b/ihl/flexible_cable/FlexibleCableHolderBaseTileEntity.java index ee8ebf7..34455ac 100644 --- a/ihl/flexible_cable/FlexibleCableHolderBaseTileEntity.java +++ b/ihl/flexible_cable/FlexibleCableHolderBaseTileEntity.java @@ -1,18 +1,10 @@ package ihl.flexible_cable; -import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; -import ic2.api.energy.event.EnergyTileLoadEvent; -import ic2.api.energy.event.EnergyTileUnloadEvent; -import ic2.api.energy.tile.IEnergySource; -import ic2.api.network.INetworkClientTileEntityEventListener; -import ic2.core.ExplosionIC2; -import ic2.core.IC2; -import ic2.core.block.TileEntityBlock; import ic2.core.block.TileEntityInventory; import ihl.IHLMod; import ihl.flexible_cable.IHLGrid; @@ -20,16 +12,10 @@ import ihl.flexible_cable.NodeEntity; import ihl.interfaces.IEnergyNetNode; import ihl.utils.IHLUtils; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import net.minecraft.server.MinecraftServer; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.util.ForgeDirection; public abstract class FlexibleCableHolderBaseTileEntity extends TileEntityInventory implements IEnergyNetNode{ @@ -43,7 +29,7 @@ public abstract class FlexibleCableHolderBaseTileEntity extends TileEntityInvent public FlexibleCableHolderBaseTileEntity() { super(); - cableList=new HashSet(); + cableList=new HashSet(); } @Override @@ -57,6 +43,7 @@ public abstract class FlexibleCableHolderBaseTileEntity extends TileEntityInvent } } + @SuppressWarnings("unchecked") @Override public void setFacing(short facing1) { @@ -70,7 +57,7 @@ public abstract class FlexibleCableHolderBaseTileEntity extends TileEntityInvent setConnectionZ(this.zCoord+0.5D); if(!nodeList.isEmpty()) { - Iterator ei = nodeList.iterator(); + Iterator ei = nodeList.iterator(); while(ei.hasNext()) { NodeEntity ne=(NodeEntity) ei.next(); @@ -174,7 +161,6 @@ public abstract class FlexibleCableHolderBaseTileEntity extends TileEntityInvent if(newGridID!=-1) { this.gridID=newGridID; - IHLGrid newGrid = IHLMod.enet.getGrid(newGridID); IHLMod.enet.getGrid(newGridID).add(this); } else diff --git a/ihl/flexible_cable/IHLENet.java b/ihl/flexible_cable/IHLENet.java index 2429aa7..32b5ebf 100644 --- a/ihl/flexible_cable/IHLENet.java +++ b/ihl/flexible_cable/IHLENet.java @@ -12,8 +12,8 @@ import net.minecraft.nbt.NBTTagCompound; public class IHLENet { - public Map grids = new HashMap(); - public Map cablesToGrids = new HashMap(); + public Map grids = new HashMap(); + public Map cablesToGrids = new HashMap(); private int griduid=0; diff --git a/ihl/flexible_cable/IHLGrid.java b/ihl/flexible_cable/IHLGrid.java index 04a9d4c..a47c229 100644 --- a/ihl/flexible_cable/IHLGrid.java +++ b/ihl/flexible_cable/IHLGrid.java @@ -18,22 +18,21 @@ import net.minecraft.server.MinecraftServer; public class IHLGrid { private static final double powerLossLimitPerMeter=1.6D; - public final Set telist = new HashSet(); + public final Set telist = new HashSet(); public double energy=0D; private IEnergyNetNode sink; private IEnergyNetNode source; private double voltage; - private short frequency=0; private double lastVoltage; public boolean isGridValid=true; private double total20TicksEU; private int lastTickCounter=0; private int tickCounterFireStart=0; - public final List calculatedSinks = new ArrayList(); - public final List calculatedSources = new ArrayList(); - public final Set cablesOnFire = new HashSet(); - private final Map energyLossSinkMap = new HashMap(); - private final Map voltageSinkMap = new HashMap(); + public final List calculatedSinks = new ArrayList(); + public final List calculatedSources = new ArrayList(); + public final Set cablesOnFire = new HashSet (); + private final Map energyLossSinkMap = new HashMap(); + private final Map voltageSinkMap = new HashMap(); private double averageEUTransfered; private double lastAverageEUTransfered=0D; @@ -151,10 +150,10 @@ public class IHLGrid this.averageEUTransfered>this.lastAverageEUTransfered || this.voltage!=this.lastVoltage)) { - Map map = new HashMap(); - Set templist = new HashSet(); - Set processlist = new HashSet(); - Set templist2 = new HashSet(); + Map map = new HashMap(); + Set templist = new HashSet(); + Set processlist = new HashSet(); + Set templist2 = new HashSet(); templist.addAll(telist); processlist.add(sink); int threads=0; diff --git a/ihl/flexible_cable/InvSlotOutputInProgress.java b/ihl/flexible_cable/InvSlotOutputInProgress.java index 2b5bfda..3694aee 100644 --- a/ihl/flexible_cable/InvSlotOutputInProgress.java +++ b/ihl/flexible_cable/InvSlotOutputInProgress.java @@ -79,7 +79,7 @@ public class InvSlotOutputInProgress extends IronWorkbenchInvSlot{ public List getRecipeOutputs(int currentSlot) { int slotRecipeIndex=this.slotRecipe[currentSlot]; - List list = new ArrayList(); + List list = new ArrayList(); for(int i=0;i materials, int multiplier) + public Set substract(List materials, int multiplier) { + Set output = new HashSet(); Iterator i1 = materials.iterator(); while(i1.hasNext()) { @@ -59,6 +64,25 @@ public class InvSlotProcessableIronWorkbench extends IronWorkbenchInvSlot { is.stackSize=0; } } + else if(is1 instanceof RecipeInputFluidContainer) + { + if(is.stackSize==1) + { + output.add(FluidContainerRegistry.drainFluidContainer(is)); + is.stackSize=0; + } + else + { + is.stackSize-=is1.getAmount()*multiplier; + ItemStack iscopy = is.copy(); + iscopy.stackSize=1; + ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(iscopy); + if(emptyContainer!=null) + { + output.add(emptyContainer); + } + } + } else { is.stackSize-=is1.getAmount()*multiplier; @@ -71,6 +95,7 @@ public class InvSlotProcessableIronWorkbench extends IronWorkbenchInvSlot { } } } + return output; } public int getAmountOf(ItemStack rubber) diff --git a/ihl/flexible_cable/InvSlotTool.java b/ihl/flexible_cable/InvSlotTool.java index b3a3855..0ffbcd9 100644 --- a/ihl/flexible_cable/InvSlotTool.java +++ b/ihl/flexible_cable/InvSlotTool.java @@ -9,77 +9,61 @@ import ic2.core.IC2; import ic2.core.Ic2Items; import ic2.core.item.ItemUpgradeModule; import ihl.interfaces.IWire; +import ihl.recipes.IronWorkbenchRecipe; import ihl.utils.IHLUtils; public class InvSlotTool extends IronWorkbenchInvSlot { - public InvSlotTool(IronWorkbenchTileEntity base1, String name1, - int oldStartIndex1, Access access1, int count) { + public InvSlotTool(IronWorkbenchTileEntity base1, String name1, int oldStartIndex1, Access access1, int count) { super(base1, name1, oldStartIndex1, access1, count); // TODO Auto-generated constructor stub } - public void damage(List tools) - { - if(tools!=null && !tools.isEmpty()) - { - for(int i=0;i tools) { + if (tools != null && !tools.isEmpty()) { + for (int i = 0; i < this.size(); i++) { ItemStack is = this.get(i); - Iterator i1 = tools.iterator(); - while(i1.hasNext()) - { + Iterator i1 = tools.iterator(); + while (i1.hasNext()) { IRecipeInput is1 = i1.next(); - if(is!=null && (is1.matches(is))) - { - if(!is.attemptDamageItem(1, IC2.random)) - { - if(is.stackTagCompound!=null && is.stackTagCompound.hasKey("GT.ToolStats")) - { + if (is != null && (is1.matches(is))) { + if (!is.attemptDamageItem(1, IC2.random)) { + if (is.stackTagCompound != null && is.stackTagCompound.hasKey("GT.ToolStats")) { IHLUtils.damageItemViaNBTTag(is, 1); } } - if(is.stackSize<=0) - { - this.put(i,null); + if (is.stackSize <= 0) { + this.put(i, null); } } } } } } - + @Override - public void put(int index, ItemStack content) - { + public void put(int index, ItemStack content) { super.put(index, content); - if(IC2.platform.isSimulating() && ((IronWorkbenchTileEntity)this.base).container!=null) - { - ((IronWorkbenchTileEntity)this.base).resetOutput(); - ((IronWorkbenchTileEntity)this.base).container.detectAndSendChanges(); + if (IC2.platform.isSimulating() && ((IronWorkbenchTileEntity) this.base).container != null) { + ((IronWorkbenchTileEntity) this.base).resetOutput(); + ((IronWorkbenchTileEntity) this.base).container.detectAndSendChanges(); } - } - + } + @Override - public boolean accepts(ItemStack itemStack) - { - if (itemStack != null && (itemStack.getItem() instanceof ItemUpgradeModule || itemStack.getItem() instanceof IWire|| itemStack.getItem()==Ic2Items.rubber.getItem())) - { - return false; - } - else - { - return true; - } - } + public boolean accepts(ItemStack itemStack) { + for (IronWorkbenchRecipe recipe : IronWorkbenchTileEntity.recipes) { + if (recipe.isTool(itemStack)) { + return true; + } + } + return false; + } - public boolean contain(ItemStack is1) - { - for(int i=0;i getItemStackList() { - List list = new ArrayList(); + List list = new ArrayList(); for(int i=1; i { protected IronWorkbenchTileEntity tileEntity; private int lastProgress1 = -1; @@ -37,14 +37,14 @@ public class IronWorkbenchContainer extends ContainerBase { { for(col=0;col<=1;col++) { - this.addSlotToContainer(new SlotInvSlot(tileEntity1.tools, row+col*6, 26+col*18, 8+row*18)); + this.addSlotToContainer(new SlotInvSlotIronWorkbench(tileEntity1.tools, row+col*6, 26+col*18, 8+row*18)); } } for(row=0;row<6;row++) { for(col=0;col<=1;col++) { - this.addSlotToContainer(new SlotInvSlot(tileEntity1.inputMaterial, row+col*6, 65+col*18, 8+row*18)); + this.addSlotToContainer(new SlotInvSlotIronWorkbench(tileEntity1.inputMaterial, row+col*6, 65+col*18, 8+row*18)); } } for (row = 0; row<6; ++row) diff --git a/ihl/flexible_cable/IronWorkbenchGui.java b/ihl/flexible_cable/IronWorkbenchGui.java index 131f2f7..dedb9d8 100644 --- a/ihl/flexible_cable/IronWorkbenchGui.java +++ b/ihl/flexible_cable/IronWorkbenchGui.java @@ -9,7 +9,6 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -import ic2.core.network.NetworkManager; import ihl.interfaces.IItemHasMiniGUI; import ihl.interfaces.ItemMiniGUI; import ihl.utils.IHLRenderUtils; @@ -22,20 +21,11 @@ public class IronWorkbenchGui extends GuiContainer { private static final short outputslotoffset=66; public IronWorkbenchGui (IronWorkbenchContainer container1) { - //the container is instanciated and passed to the superclass for handling super(container1); this.container=container1; this.ySize=IronWorkbenchContainer.height; } - @Override - public void initGui() - { - super.initGui(); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - } - @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { @@ -103,7 +93,6 @@ public class IronWorkbenchGui extends GuiContainer { this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); if (this.container.tileEntity.progress > 0) { - int progressLevel=Math.min(Math.round(this.container.tileEntity.progress*16.0F/this.container.tileEntity.maxProgress),16); int frameNum=0; short slotRecipeNum=this.container.tileEntity.output.slotRecipe[0]; for(int row = 0;row<6;row++) diff --git a/ihl/flexible_cable/IronWorkbenchInvSlot.java b/ihl/flexible_cable/IronWorkbenchInvSlot.java index 830f9b4..380b6d3 100644 --- a/ihl/flexible_cable/IronWorkbenchInvSlot.java +++ b/ihl/flexible_cable/IronWorkbenchInvSlot.java @@ -15,7 +15,7 @@ public class IronWorkbenchInvSlot extends InvSlot { public List getItemStackList() { - List list = new ArrayList(); + List list = new ArrayList(); for(int i=0; i= 4 ? -0.5f : 0f; - float ix = (index % 2) * 0.4f-0.2f; - float iz = (index / 2) * 0.4f-0.2f + iy; - this.itemRenderer.doRender(RenderManager.instance,tile.tools.get(i),ix,iz,iy-0.002f*index); - index++; - } - } - GL11.glPopMatrix(); -} - - @Override - public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) - { - this.renderAModelAt((IronWorkbenchTileEntity)par1TileEntity, par2, par4, par6, par8); - } -} diff --git a/ihl/flexible_cable/IronWorkbenchTileEntity.java b/ihl/flexible_cable/IronWorkbenchTileEntity.java index 3821a0c..73a3eb1 100644 --- a/ihl/flexible_cable/IronWorkbenchTileEntity.java +++ b/ihl/flexible_cable/IronWorkbenchTileEntity.java @@ -3,9 +3,11 @@ package ihl.flexible_cable; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -14,29 +16,26 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import ic2.api.network.INetworkClientTileEntityEventListener; import ic2.api.network.INetworkTileEntityEventListener; import ic2.api.recipe.IRecipeInput; -import ic2.api.recipe.RecipeInputItemStack; import ic2.core.ContainerBase; -import ic2.core.IC2; import ic2.core.IHasGui; -import ic2.core.Ic2Items; import ic2.core.block.TileEntityInventory; import ic2.core.block.invslot.InvSlot.Access; import ihl.IHLMod; import ihl.interfaces.IWire; -import ihl.items_blocks.FlexibleCableItem; -import ihl.processing.chemistry.GaedesMercuryRotaryPumpTileEntity; -import ihl.processing.metallurgy.GasWeldingStationTileEntity; import ihl.recipes.IronWorkbenchRecipe; +import ihl.recipes.RecipeInputDetonator; import ihl.recipes.RecipeInputDie; import ihl.recipes.RecipeInputObjectInstance; import ihl.utils.IHLUtils; public class IronWorkbenchTileEntity extends TileEntityInventory implements IHasGui, INetworkClientTileEntityEventListener, INetworkTileEntityEventListener{ - public static List recipes = new ArrayList(); + public static List recipes = new ArrayList(); public int progress; public int currentSlot=-1; public final int maxProgress; @@ -49,7 +48,8 @@ public class IronWorkbenchTileEntity extends TileEntityInventory implements IHas private boolean outputDefined=false; private EntityPlayer crafter; public ContainerBase container; - private Map slotRecipeMap = new HashMap(); + private Map slotRecipeMap = new HashMap(); + private boolean firstTick = true; public IronWorkbenchTileEntity() { @@ -77,7 +77,18 @@ public class IronWorkbenchTileEntity extends TileEntityInventory implements IHas { return IHLUtils.getThisModItemStack("ironWorkbench"); } - + + @Override + @SideOnly(Side.CLIENT) + public void updateEntityClient() + { + if(firstTick) + { + IHLMod.proxy.requestTileEntityInitdataFromClientToServer(xCoord, yCoord, zCoord); + this.firstTick=false; + } + } + @Override public void updateEntityServer() { @@ -102,6 +113,13 @@ public class IronWorkbenchTileEntity extends TileEntityInventory implements IHas newOutputs = ((RecipeInputDie)rinput).transformOutput(this.getMatchedItemStack(rinput),recipe.outputs); } } + for(IRecipeInput rinput:recipe.materials) + { + if(rinput instanceof RecipeInputDetonator) + { + newOutputs = ((RecipeInputDetonator)rinput).transformOutput(this.getMatchedItemStack(rinput),recipe.outputs); + } + } int slot = this.output.put(newOutputs); if(slot<0)break; slotRecipeMap.put(slot, recipe); @@ -109,7 +127,6 @@ public class IronWorkbenchTileEntity extends TileEntityInventory implements IHas } } } - List processingMaterials = new ArrayList(); for(int i=0; i crafterEmptyInventorySlotsList = getCrafterEmptyInventorySlotsList(); + Set crafterEmptyInventorySlotsList = getCrafterEmptyInventorySlotsList(); if(startProcess && crafterEmptyInventorySlotsList.size()>=this.slotRecipeMap.get(currentSlot).outputs.size()) { if(++this.progress>=this.maxProgress) @@ -150,10 +167,8 @@ public class IronWorkbenchTileEntity extends TileEntityInventory implements IHas { int slot = emptySlotsIterator.next(); ItemStack stack = optsi.next(); - this.crafter.inventory.mainInventory[slot]=stack.copy(); if(stack.getItem() instanceof IWire) { - System.out.println(multiplier); this.crafter.inventory.mainInventory[slot]=IHLUtils.getWireItemStackCopyWithLengthMultiplied(stack,multiplier); } else @@ -162,8 +177,23 @@ public class IronWorkbenchTileEntity extends TileEntityInventory implements IHas this.crafter.inventory.mainInventory[slot].stackSize*=multiplier; } } + Iterator emptyContainers = this.inputMaterial.substract(crecipe.materials, multiplier).iterator(); + while(emptyContainers.hasNext()) + { + if(emptySlotsIterator.hasNext()) + { + int slot = emptySlotsIterator.next(); + ItemStack stack = emptyContainers.next(); + this.crafter.inventory.mainInventory[slot]=stack.copy(); + this.crafter.inventory.mainInventory[slot].stackSize*=multiplier; + } + else + { + EntityItem eistack = new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, emptyContainers.next()); + this.worldObj.spawnEntityInWorld(eistack); + } + } this.crafter.inventoryContainer.detectAndSendChanges(); - this.inputMaterial.substract(crecipe.materials, multiplier); this.tools.damage(crecipe.tools); if(!crecipe.workspaceElements.isEmpty()) { @@ -196,9 +226,9 @@ public class IronWorkbenchTileEntity extends TileEntityInventory implements IHas return null; } - private List getCrafterEmptyInventorySlotsList() + private Set getCrafterEmptyInventorySlotsList() { - List list = new ArrayList(); + Set list = new HashSet(4); if(this.crafter!=null) { for (int var1 = 0; var1 < this.crafter.inventory.mainInventory.length; ++var1) @@ -213,7 +243,7 @@ public class IronWorkbenchTileEntity extends TileEntityInventory implements IHas } private List getListOfSameWires(ItemStack stack1) { - List list = new ArrayList(); + List list = new ArrayList(); for(int i=0; i recipes = new ArrayList(); - public int progress; - public int currentSlot=-1; - public final int maxProgress; - public final InvSlotTool tools; - public final InvSlotWorkspaceElement workspaceElements; - public final InvSlotProcessableIronWorkbench inputMaterial; - public final InvSlotOutputInProgress output; - public boolean isGuiScreenOpened=false; - private boolean startProcess=false; - private boolean outputDefined=false; - private EntityPlayer crafter; - public ContainerBase container; - private Map slotRecipeMap = new HashMap(); - - public IronWorkbenchTileEntity() - { - this.maxProgress=80; - this.workspaceElements = new InvSlotWorkspaceElement(this, "workspaceElements", 3, Access.NONE, 6); - this.tools=new InvSlotTool(this, "tools", 0, Access.IO, 12); - this.inputMaterial=new InvSlotProcessableIronWorkbench(this, "input", 1, Access.IO, 12); - this.output=new InvSlotOutputInProgress(this, "output", 2, 18); - } - - public static void addRecipe(IronWorkbenchRecipe recipe) - { - IronWorkbenchTileEntity.recipes.add(recipe); - } - - @Override - public String getInventoryName() - { - return "ironWorkbench"; - } - - - @Override - public ItemStack getWrenchDrop(EntityPlayer player) - { - return IHLUtils.getThisModItemStack("ironWorkbench"); - } - - @Override - public void updateEntityServer() - { - if(this.isGuiScreenOpened) - { - if(this.output.isEmpty() && !outputDefined) - { - this.workspaceElements.reset(); - Iterator iwri=IronWorkbenchTileEntity.recipes.iterator(); - while(iwri.hasNext()) - { - IronWorkbenchRecipe recipe = iwri.next(); - if(recipe.isCanBeCrafted(this.tools.getItemStackList(), this.inputMaterial.getItemStackList(), this.workspaceElements.getItemStackList())) - { - if(recipe.workspaceElements==null || recipe.workspaceElements.isEmpty() || this.workspaceElements.containsAndCanUse(recipe.workspaceElements)) - { - List newOutputs = recipe.outputs; - for(IRecipeInput rinput:recipe.tools) - { - if(rinput instanceof RecipeInputDie) - { - newOutputs = ((RecipeInputDie)rinput).transformOutput(this.getMatchedItemStack(rinput),recipe.outputs); - } - } - int slot = this.output.put(newOutputs); - if(slot<0)break; - slotRecipeMap.put(slot, recipe); - this.startProcess=false; - } - } - } - List processingMaterials = new ArrayList(); - for(int i=0; i list = this.getListOfSameWires(stack); - ItemStack result = stack.copy(); - result.stackTagCompound.setInteger("length", fullLength); - result.stackTagCompound.setInteger("fullLength", fullLength); - IronWorkbenchRecipe recipe = new IronWorkbenchRecipe(null, list, Arrays.asList(new ItemStack[] {result})); - int slot = this.output.put(recipe.outputs); - if(slot<0)break; - slotRecipeMap.put(slot, recipe); - this.startProcess=false; - break; - } - } - outputDefined=true; - } - else if(!this.output.isEmpty()) - { - List crafterEmptyInventorySlotsList = getCrafterEmptyInventorySlotsList(); - if(startProcess && crafterEmptyInventorySlotsList.size()>=this.slotRecipeMap.get(currentSlot).outputs.size()) - { - if(++this.progress>=this.maxProgress) - { - IronWorkbenchRecipe crecipe = this.slotRecipeMap.get(currentSlot); - List opts = this.output.getRecipeOutputs(currentSlot); - int multiplier = this.inputMaterial.getMultiplier(crecipe.materials); - Iterator optsi = opts.iterator(); - Iterator emptySlotsIterator = crafterEmptyInventorySlotsList.iterator(); - while(optsi.hasNext()) - { - int slot = emptySlotsIterator.next(); - ItemStack stack = optsi.next(); - this.crafter.inventory.mainInventory[slot]=stack.copy(); - if(stack.getItem() instanceof IWire) - { - System.out.println(multiplier); - this.crafter.inventory.mainInventory[slot]=IHLUtils.getWireItemStackCopyWithLengthMultiplied(stack,multiplier); - } - else - { - this.crafter.inventory.mainInventory[slot]=stack.copy(); - this.crafter.inventory.mainInventory[slot].stackSize*=multiplier; - } - } - this.crafter.inventoryContainer.detectAndSendChanges(); - this.inputMaterial.substract(crecipe.materials, multiplier); - this.tools.damage(crecipe.tools); - if(!crecipe.workspaceElements.isEmpty()) - { - this.workspaceElements.use(crecipe.workspaceElements); - } - this.resetOutput(); - } - } - } - } - } - - private ItemStack getMatchedItemStack(IRecipeInput rinput) - { - for(ItemStack tool:this.tools.getItemStackList()) - { - if(rinput.matches(tool)) - { - return tool; - } - } - for(ItemStack material:this.inputMaterial.getItemStackList()) - { - if(rinput.matches(material)) - { - return material; - } - } - - return null; - } - - private List getCrafterEmptyInventorySlotsList() - { - List list = new ArrayList(); - if(this.crafter!=null) - { - for (int var1 = 0; var1 < this.crafter.inventory.mainInventory.length; ++var1) - { - if (this.crafter.inventory.mainInventory[var1] == null) - { - list.add(var1); - } - } - } - return list; - } - - private List getListOfSameWires(ItemStack stack1) { - List list = new ArrayList(); - for(int i=0; i getGuiContainer(EntityPlayer player) { - resetOutput(); - this.isGuiScreenOpened=true; - this.crafter=player; - container = new IronWorkbenchContainer(player, this); - return container; - } - - @Override - public void onGuiClosed(EntityPlayer arg0) - { - this.isGuiScreenOpened=false; - } - - @Override - public void onNetworkEvent(EntityPlayer player, int event) - { - if(event==16) - { - this.isGuiScreenOpened=false; - this.crafter=null; - this.container=null; - return; - } - for(int i=event;i>=0;i--) - { - if(this.slotRecipeMap.containsKey(i)) - { - if(!this.slotRecipeMap.get(i).isCanBeCrafted(this.tools.getItemStackList(), this.inputMaterial.getItemStackList(), this.workspaceElements.getItemStackList())) - { - resetOutput(); - } - else - { - this.currentSlot=i; - this.startProcess=true; - return; - } - } - } - } - - public void resetOutput() - { - this.output.clear(); - this.slotRecipeMap.clear(); - this.progress=0; - this.startProcess=false; - this.currentSlot=-1; - this.outputDefined=false; - } - - - public void dropContents() { - for(int i=0;i recipeOutputsItems) - { - Iterator ri = recipes.iterator(); - while(ri.hasNext()) - { - IronWorkbenchRecipe recipe = ri.next(); - boolean removeEntry=false; - Iterator roi = recipe.outputs.iterator(); - while(roi.hasNext()) - { - if(IHLUtils.isItemStacksIsEqual(recipeOutputsItems.get(0), roi.next(), true)) - { - removeEntry=true; - } - } - if(removeEntry) - { - ri.remove(); - } - } - - } - - public static void removeRecipeByInput(List recipeInputsTools1,List recipeInputsItems1,List recipeInputsMachines) { - List recipeInputsTools = IHLUtils.convertRecipeInputToItemStackList(recipeInputsTools1); - List recipeInputsItems = IHLUtils.convertRecipeInputToItemStackList(recipeInputsItems1); - Iterator ri = recipes.iterator(); - while(ri.hasNext()) - { - IronWorkbenchRecipe recipe = ri.next(); - if(recipe.isCanBeCrafted(recipeInputsTools, recipeInputsItems, recipeInputsMachines)) - { - ri.remove(); - } - } - - } - -} diff --git a/ihl/flexible_cable/NodeEntity.java b/ihl/flexible_cable/NodeEntity.java index 623c9a1..b734cd1 100644 --- a/ihl/flexible_cable/NodeEntity.java +++ b/ihl/flexible_cable/NodeEntity.java @@ -6,36 +6,25 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -import org.lwjgl.opengl.GL11; - -import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import cpw.mods.fml.common.network.internal.FMLProxyPacket; import ihl.IHLMod; import ihl.IHLModInfo; import ihl.interfaces.ICableHolder; -import ihl.interfaces.IDataCableHolder; -import ihl.interfaces.IEnergyNetNode; import ihl.interfaces.IMultiPowerCableHolder; import ihl.interfaces.INetworkListener; import ihl.items_blocks.FlexibleCableItem; -import ihl.utils.IHLUtils; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufInputStream; import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.Unpooled; import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; @@ -109,6 +98,7 @@ public class NodeEntity extends Entity implements INetworkListener{ @Override public void travelToDimension(int dimensionId){} + @Override public void setSize(float width, float heigth) { super.setSize(width, heigth); @@ -122,6 +112,7 @@ public class NodeEntity extends Entity implements INetworkListener{ this.registerAndSendData(null); } + @Override public void registerAndSendData(EntityPlayerMP player) { if(!worldObj.isRemote) @@ -135,7 +126,7 @@ public class NodeEntity extends Entity implements INetworkListener{ } else { - nes=new HashSet(); + nes=new HashSet(); IHLMod.proxy.nodeEntityRegistry.put(this.getChainUniqueID(),nes); } nes.add(this); @@ -172,7 +163,8 @@ public class NodeEntity extends Entity implements INetworkListener{ } } - @Override + @SuppressWarnings("unchecked") + @Override public void onUpdate() { super.onUpdate(); @@ -194,7 +186,7 @@ public class NodeEntity extends Entity implements INetworkListener{ List eItemsList = this.worldObj.getEntitiesWithinAABB(NodeEntity.class, searchArea); if(!eItemsList.isEmpty()) { - Iterator ei = eItemsList.iterator(); + Iterator ei = eItemsList.iterator(); while(ei.hasNext()) { NodeEntity node=(NodeEntity) ei.next(); @@ -227,7 +219,7 @@ public class NodeEntity extends Entity implements INetworkListener{ List eItemsList = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, searchArea); if(!eItemsList.isEmpty()) { - Iterator ei = eItemsList.iterator(); + Iterator ei = eItemsList.iterator(); while(ei.hasNext()) { EntityPlayer player=(EntityPlayer) ei.next(); @@ -415,15 +407,10 @@ public class NodeEntity extends Entity implements INetworkListener{ xi=(dx1-2*x1+2*dx0+2*x0-dx0)*i*i*i+(3*x1-dx1-3*dx0-3*x0+dx0)*i*i+dx0*i+x0; yi=(dy1-2*y1+2*dy0+2*y0-dy0)*i*i*i+(3*y1-dy1-3*dy0-3*y0+dy0)*i*i+dy0*i+y0; zi=(dz1-2*z1+2*dz0+2*z0-dz0)*i*i*i+(3*z1-dz1-3*dz0-3*z0+dz0)*i*i+dz0*i+z0; - int blockX=(int)xi; - int blockY=(int)yi; - int blockZ=(int)zi; dxi-=xi; dyi-=yi; dzi-=zi; double var7 = MathHelper.sqrt_double(dxi * dxi + dzi * dzi); - float var9 = (float)(Math.atan2(dzi, dxi) * 180.0D / Math.PI) - 90.0F; - float var10 = (float)(-(Math.atan2(dyi, var7) * 180.0D / Math.PI)); float rotationPitch = (float) Math.atan2(dxi, dzi); float rotationYaw = (float) (-Math.atan2(dyi, var7)); rotationPitchArray[i1]=rotationPitch; diff --git a/ihl/flexible_cable/NodeRender.java b/ihl/flexible_cable/NodeRender.java index 61c272b..157be67 100644 --- a/ihl/flexible_cable/NodeRender.java +++ b/ihl/flexible_cable/NodeRender.java @@ -1,19 +1,11 @@ package ihl.flexible_cable; import ihl.IHLModInfo; -import ihl.model.IHLModelRenderer; import ihl.model.ModelTube; -import ihl.utils.IHLMathUtils; -import ihl.utils.IHLRenderUtils; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelBox; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; -import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.ForgeDirection; @@ -26,7 +18,6 @@ public class NodeRender extends Render private ModelTube modelThin; private ResourceLocation tex; private float scale; - private boolean firstTick=true; public NodeRender() { diff --git a/ihl/flexible_cable/PowerCableNodeEntity.java b/ihl/flexible_cable/PowerCableNodeEntity.java index 42d07fd..ed5a7ea 100644 --- a/ihl/flexible_cable/PowerCableNodeEntity.java +++ b/ihl/flexible_cable/PowerCableNodeEntity.java @@ -1,34 +1,22 @@ package ihl.flexible_cable; -import java.util.ArrayList; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; -import ic2.api.network.INetworkClientTileEntityEventListener; -import ic2.core.IC2; import ic2.core.IC2DamageSource; import ic2.core.item.armor.ItemArmorHazmat; import ihl.IHLMod; import ihl.IHLModInfo; -import ihl.interfaces.IDataCableHolder; import ihl.interfaces.IEnergyNetNode; import ihl.utils.IHLUtils; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.network.play.server.S26PacketMapChunkBulk; import net.minecraft.network.play.server.S29PacketSoundEffect; import net.minecraft.network.play.server.S2APacketParticles; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class PowerCableNodeEntity extends NodeEntity implements IEnergyNetNode{ @@ -56,6 +44,8 @@ public class PowerCableNodeEntity extends NodeEntity implements IEnergyNetNode{ return !worldObj.isRemote && !this.noClip; } + @SuppressWarnings("unchecked") + @Override public void onUpdate() { super.onUpdate(); @@ -191,7 +181,7 @@ public class PowerCableNodeEntity extends NodeEntity implements IEnergyNetNode{ public Set getCableList() { if(cableList==null) { - cableList=new HashSet(1); + cableList=new HashSet(1); if(this.cable!=null) { cableList.add(this.cable); diff --git a/ihl/flexible_cable/RectifierTransformerUnitTileEntity.java b/ihl/flexible_cable/RectifierTransformerUnitTileEntity.java index 1d13d0a..484df85 100644 --- a/ihl/flexible_cable/RectifierTransformerUnitTileEntity.java +++ b/ihl/flexible_cable/RectifierTransformerUnitTileEntity.java @@ -1,6 +1,5 @@ package ihl.flexible_cable; -import java.util.Iterator; import java.util.List; import ic2.api.energy.event.EnergyTileLoadEvent; @@ -8,15 +7,10 @@ import ic2.api.energy.event.EnergyTileUnloadEvent; import ic2.api.energy.tile.IEnergySink; import ic2.api.network.INetworkClientTileEntityEventListener; import ic2.core.IC2; -import ic2.core.block.TileEntityBlock; import ic2.core.block.TileEntityInventory; -import ihl.IHLMod; -import ihl.flexible_cable.IHLGrid; -import ihl.flexible_cable.NodeEntity; import ihl.interfaces.IEnergyNetNode; import ihl.interfaces.IMultiPowerCableHolder; import ihl.utils.IHLUtils; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -280,6 +274,7 @@ public class RectifierTransformerUnitTileEntity extends TileEntityInventory impl return amount; } + @Override public boolean isCableRemoved(int chainUniqueID) { if(!checkCables) diff --git a/ihl/flexible_cable/SetOfDiesMiniGUI.java b/ihl/flexible_cable/SetOfDiesMiniGUI.java index c00a19b..43f905d 100644 --- a/ihl/flexible_cable/SetOfDiesMiniGUI.java +++ b/ihl/flexible_cable/SetOfDiesMiniGUI.java @@ -1,9 +1,6 @@ package ihl.flexible_cable; import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.util.regex.Pattern; - import org.lwjgl.opengl.GL11; import net.minecraft.client.gui.GuiTextField; @@ -20,7 +17,6 @@ public class SetOfDiesMiniGUI extends ItemMiniGUI private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIIronWorkbench.png"); private int transverseSectionValue; private GuiTextField transverseSectionTextField; - private boolean leftMouseButtonPressed=false; private int xPos; private int yPos; diff --git a/ihl/flexible_cable/SubAnchorEnergyNetNode.java b/ihl/flexible_cable/SubAnchorEnergyNetNode.java index 6b84dd8..33f9fb3 100644 --- a/ihl/flexible_cable/SubAnchorEnergyNetNode.java +++ b/ihl/flexible_cable/SubAnchorEnergyNetNode.java @@ -1,13 +1,9 @@ package ihl.flexible_cable; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; @@ -16,9 +12,7 @@ import net.minecraftforge.common.util.ForgeDirection; import ic2.api.energy.EnergyNet; import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; -import ic2.api.energy.tile.IEnergyConductor; import ic2.api.energy.tile.IEnergySink; -import ic2.api.energy.tile.IEnergySource; import ic2.core.IC2; import ihl.IHLMod; import ihl.interfaces.IEnergyNetNode; @@ -29,7 +23,7 @@ public class SubAnchorEnergyNetNode implements IEnergyNetNode{ private AnchorTileEntity base; private short facing; private int gridID=-1; - private Set cableList = new HashSet(); + private Set cableList = new HashSet(); public SubAnchorEnergyNetNode(AnchorTileEntity base1, short facing1) { diff --git a/ihl/flexible_cable/SubRTUEnergyNetNode.java b/ihl/flexible_cable/SubRTUEnergyNetNode.java index 2dd0673..c068ba0 100644 --- a/ihl/flexible_cable/SubRTUEnergyNetNode.java +++ b/ihl/flexible_cable/SubRTUEnergyNetNode.java @@ -1,13 +1,9 @@ package ihl.flexible_cable; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.common.MinecraftForge; @@ -23,7 +19,7 @@ public class SubRTUEnergyNetNode implements IEnergyNetNode{ private RectifierTransformerUnitTileEntity base; private short side; private int gridID=-1; - private Set cableList = new HashSet(); + private Set cableList = new HashSet(); public SubRTUEnergyNetNode(RectifierTransformerUnitTileEntity base1, short facing1) { -- cgit v1.2.3