From b99c98a81c65b8938fdac412057804fd3a82017b Mon Sep 17 00:00:00 2001 From: mDiyo Date: Thu, 10 Oct 2013 02:04:36 -0700 Subject: [PATCH] Garbled Gui, but readable --- src/tconstruct/blocks/SmelteryBlock.java | 1 + .../blocks/component/SmelteryComponent.java | 2 +- .../blocks/logic/AdaptiveSmelteryLogic.java | 83 +---------------- .../client/gui/AdaptiveSmelteryGui.java | 90 +++++++++++-------- .../library/component/TankLayerScan.java | 2 +- 5 files changed, 57 insertions(+), 121 deletions(-) diff --git a/src/tconstruct/blocks/SmelteryBlock.java b/src/tconstruct/blocks/SmelteryBlock.java index 6bdc5056..39733112 100644 --- a/src/tconstruct/blocks/SmelteryBlock.java +++ b/src/tconstruct/blocks/SmelteryBlock.java @@ -205,6 +205,7 @@ public class SmelteryBlock extends InventoryBlock } else { + world.markBlockForUpdate(x, y, z); player.openGui(getModInstance(), integer, world, x, y, z); return true; } diff --git a/src/tconstruct/blocks/component/SmelteryComponent.java b/src/tconstruct/blocks/component/SmelteryComponent.java index ecd7bdf6..572b7460 100644 --- a/src/tconstruct/blocks/component/SmelteryComponent.java +++ b/src/tconstruct/blocks/component/SmelteryComponent.java @@ -100,7 +100,7 @@ public class SmelteryComponent extends LogicComponent hasUse = true; if (activeTemps[i] < maxTemp && activeTemps[i] < meltingTemps[i]) { - activeTemps[i] += 10; + activeTemps[i] += 1; } else if (activeTemps[i] >= meltingTemps[i] && !world.isRemote) { diff --git a/src/tconstruct/blocks/logic/AdaptiveSmelteryLogic.java b/src/tconstruct/blocks/logic/AdaptiveSmelteryLogic.java index 89bd3cee..dd88c003 100644 --- a/src/tconstruct/blocks/logic/AdaptiveSmelteryLogic.java +++ b/src/tconstruct/blocks/logic/AdaptiveSmelteryLogic.java @@ -245,7 +245,7 @@ public class AdaptiveSmelteryLogic extends AdaptiveInventoryLogic implements IAc void updateWorldBlock (int slot, ItemStack itemstack) { - CoordTuple air = structure.airCoords.get(slot);//structure.getAirByIndex(slot); + CoordTuple air = structure.getAirByIndex(slot); if (air != null) { TileEntity te = worldObj.getBlockTileEntity(air.x, air.y, air.z); @@ -425,87 +425,6 @@ public class AdaptiveSmelteryLogic extends AdaptiveInventoryLogic implements IAc return "crafters.Smeltery"; } - /*@Override - public int fill (ForgeDirection from, FluidStack resource, boolean doFill) - { - if (hasValidMaster() && resource != null && canFill(from, resource.getFluid())) - { - if (doFill) - { - AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z); - return smeltery.fill(resource, doFill); - } - else - { - return resource.amount; - } - } - else - { - } - return 0; - } - - @Override - public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain) - { - if (hasValidMaster() && canDrain(from, null)) - { - AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z); - return smeltery.drain(maxDrain, doDrain); - } - else - { - return null; - } - } - - @Override - public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain) - { - return null; - } - - @Override - public boolean canFill (ForgeDirection from, Fluid fluid) - { - return true; - } - - @Override - public boolean canDrain (ForgeDirection from, Fluid fluid) - { - // Check that the drain is coming from the from the front of the block - // and that the fluid to be drained is in the smeltery. - boolean containsFluid = fluid == null; - if (fluid != null) - { - AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z); - for (FluidStack fstack : smeltery.moltenMetal) - { - if (fstack.fluidID == fluid.getID()) - { - containsFluid = true; - break; - } - } - } - //return from == getForgeDirection().getOpposite() && containsFluid; - return containsFluid; - } - - @Override - public FluidTankInfo[] getTankInfo (ForgeDirection from) - { - if (hasValidMaster() && (from == getForgeDirection() || from == getForgeDirection().getOpposite() || from == ForgeDirection.UNKNOWN)) - { - AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z); - return smeltery.getMultiTankInfo(); - //return new FluidTankInfo[] { smeltery.getInfo() }; - } - return null; - }*/ - /* Fluids */ @Override diff --git a/src/tconstruct/client/gui/AdaptiveSmelteryGui.java b/src/tconstruct/client/gui/AdaptiveSmelteryGui.java index 09f99cf4..ade6f8bf 100644 --- a/src/tconstruct/client/gui/AdaptiveSmelteryGui.java +++ b/src/tconstruct/client/gui/AdaptiveSmelteryGui.java @@ -12,8 +12,10 @@ import net.minecraft.util.Icon; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; @@ -106,23 +108,30 @@ public class AdaptiveSmelteryGui extends NewContainerGui int base = 0; int cornerX = (width - xSize) / 2 + 36; int cornerY = (height - ySize) / 2; - - /*for (FluidStack liquid : logic.moltenMetal) + FluidTankInfo[] info = logic.getTankInfo(ForgeDirection.UNKNOWN); + + int capacity = 0; + + for (int i = 0; i < info.length - 1; i++) { + FluidStack liquid = info[i].fluid; + if (liquid != null) + capacity += info[i].capacity; + } + + for (int i = 0; i < info.length - 1; i++) + { + FluidStack liquid = info[i].fluid; int basePos = 54; int initialLiquidSize = 0; - int liquidSize = 0;//liquid.amount * 52 / liquidLayers; - if (logic.getCapacity() > 0) + int liquidSize = 0; + if (capacity > 0) { - int total = logic.getTotalLiquid(); - int liquidLayers = (total / 20000 + 1) * 20000; - if (liquidLayers > 0) - { - liquidSize = liquid.amount * 52 / liquidLayers; - if (liquidSize == 0) - liquidSize = 1; - base += liquidSize; - } + liquidSize = liquid.amount * 52 / capacity; + if (liquidSize == 0) + liquidSize = 1; + base += liquidSize; + } int leftX = cornerX + basePos; @@ -132,10 +141,10 @@ public class AdaptiveSmelteryGui extends NewContainerGui if (mouseX >= leftX && mouseX <= leftX + sizeX && mouseY >= topY && mouseY < topY + sizeY) { drawFluidStackTooltip(liquid, mouseX - cornerX + 36, mouseY - cornerY); - + } } - if (logic.fuelGague > 0) + /*if (logic.fuelGague > 0) { int leftX = cornerX + 117; int topY = (cornerY + 68) - logic.getScaledFuelGague(52); @@ -176,34 +185,41 @@ public class AdaptiveSmelteryGui extends NewContainerGui } }*/ - //Liquids - molten metal - /*int base = 0; - for (FluidStack liquid : logic.moltenMetal) + FluidTankInfo[] info = logic.getTankInfo(ForgeDirection.UNKNOWN); + int capacity = 0; + + for (int i = 0; i < info.length - 1; i++) { + FluidStack liquid = info[i].fluid; + if (liquid != null) + capacity += info[i].capacity; + } + + //Liquids - molten metal + int base = 0; + for (int i = 0; i < info.length - 1; i++) + { + FluidStack liquid = info[i].fluid; Icon renderIndex = liquid.getFluid().getStillIcon(); int basePos = 54; - if (logic.getCapacity() > 0) + if (capacity > 0) { - int total = logic.getTotalLiquid(); - int liquidLayers = (total / 20000 + 1) * 20000; - if (liquidLayers > 0) + int liquidSize = liquid.amount * 52 / capacity; + if (liquidSize == 0) + liquidSize = 1; + while (liquidSize > 0) { - int liquidSize = liquid.amount * 52 / liquidLayers; - if (liquidSize == 0) - liquidSize = 1; - while (liquidSize > 0) - { - int size = liquidSize >= 16 ? 16 : liquidSize; - drawLiquidRect(cornerX + basePos, (cornerY + 68) - size - base, renderIndex, 16, size); - drawLiquidRect(cornerX + basePos + 16, (cornerY + 68) - size - base, renderIndex, 16, size); - drawLiquidRect(cornerX + basePos + 32, (cornerY + 68) - size - base, renderIndex, 16, size); - drawLiquidRect(cornerX + basePos + 48, (cornerY + 68) - size - base, renderIndex, 4, size); - liquidSize -= size; - base += size; - } + int size = liquidSize >= 16 ? 16 : liquidSize; + drawLiquidRect(cornerX + basePos, (cornerY + 68) - size - base, renderIndex, 16, size); + drawLiquidRect(cornerX + basePos + 16, (cornerY + 68) - size - base, renderIndex, 16, size); + drawLiquidRect(cornerX + basePos + 32, (cornerY + 68) - size - base, renderIndex, 16, size); + drawLiquidRect(cornerX + basePos + 48, (cornerY + 68) - size - base, renderIndex, 4, size); + liquidSize -= size; + base += size; + } } - }*/ + } //Liquid gague GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); @@ -413,7 +429,7 @@ public class AdaptiveSmelteryGui extends NewContainerGui tessellator.addVertexWithUV((double) (startU + 0), (double) (startV + 0), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMinV()); //Top left tessellator.draw(); } - + /*@Override public void mouseClicked(int mouseX, int mouseY, int mouseButton) { diff --git a/src/tconstruct/library/component/TankLayerScan.java b/src/tconstruct/library/component/TankLayerScan.java index f4f0bcee..f1409843 100644 --- a/src/tconstruct/library/component/TankLayerScan.java +++ b/src/tconstruct/library/component/TankLayerScan.java @@ -36,7 +36,7 @@ public class TankLayerScan extends LogicComponent protected ArrayList validAirCoords = new ArrayList(); protected CoordTuple returnStone; - private boolean debug = true; + private boolean debug = false; public TankLayerScan(TileEntity te, Block... ids) {