mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-27 23:45:48 +00:00
Move to Maven structure
This commit is contained in:
1 parent
ad86fccb88
commit
5cdc894dad
537 files changed
No files matched your search
@@ -0,0 +1,505 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.*;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.*;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.component.SmelteryComponent;
|
||||
import tconstruct.blocks.logic.AdaptiveSmelteryLogic;
|
||||
import tconstruct.inventory.*;
|
||||
import tconstruct.library.component.MultiFluidTank;
|
||||
|
||||
public class AdaptiveSmelteryGui extends NewContainerGui
|
||||
{
|
||||
public AdaptiveSmelteryLogic logic;
|
||||
String username;
|
||||
boolean isScrolling = false;
|
||||
boolean wasClicking;
|
||||
float currentScroll = 0.0F;
|
||||
int slotPos = 0;
|
||||
int prevSlotPos = 0;
|
||||
private final SmelteryComponent scomp;
|
||||
private final MultiFluidTank multitank;
|
||||
|
||||
public AdaptiveSmelteryGui(InventoryPlayer inventoryplayer, AdaptiveSmelteryLogic smeltery, World world, int x, int y, int z)
|
||||
{
|
||||
super((ActiveContainer) smeltery.getGuiContainer(inventoryplayer, world, x, y, z));
|
||||
logic = smeltery;
|
||||
username = inventoryplayer.player.username;
|
||||
xSize = 248;
|
||||
scomp = logic.getSmeltery();
|
||||
multitank = logic.getMultiTank();
|
||||
scomp.update();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen (int mouseX, int mouseY, float par3)
|
||||
{
|
||||
super.drawScreen(mouseX, mouseY, par3);
|
||||
updateScrollbar(mouseX, mouseY, par3);
|
||||
}
|
||||
|
||||
protected void updateScrollbar (int mouseX, int mouseY, float par3)
|
||||
{
|
||||
if (logic.getSizeInventory() > 24)
|
||||
{
|
||||
boolean mouseDown = Mouse.isButtonDown(0);
|
||||
int lefto = this.guiLeft;
|
||||
int topo = this.guiTop;
|
||||
int xScroll = lefto + 67;
|
||||
int yScroll = topo + 8;
|
||||
int scrollWidth = xScroll + 14;
|
||||
int scrollHeight = yScroll + 144;
|
||||
|
||||
if (!this.wasClicking && mouseDown && mouseX >= xScroll && mouseY >= yScroll && mouseX < scrollWidth && mouseY < scrollHeight)
|
||||
{
|
||||
this.isScrolling = true;
|
||||
}
|
||||
|
||||
if (!mouseDown)
|
||||
{
|
||||
this.isScrolling = false;
|
||||
}
|
||||
|
||||
if (wasClicking && !isScrolling && slotPos != prevSlotPos)
|
||||
{
|
||||
prevSlotPos = slotPos;
|
||||
}
|
||||
|
||||
this.wasClicking = mouseDown;
|
||||
|
||||
if (this.isScrolling)
|
||||
{
|
||||
this.currentScroll = (mouseY - yScroll - 7.5F) / (scrollHeight - yScroll - 15.0F);
|
||||
|
||||
if (this.currentScroll < 0.0F)
|
||||
{
|
||||
this.currentScroll = 0.0F;
|
||||
}
|
||||
|
||||
if (this.currentScroll > 1.0F)
|
||||
{
|
||||
this.currentScroll = 1.0F;
|
||||
}
|
||||
|
||||
int s = ((AdaptiveSmelteryContainer) this.container).scrollTo(this.currentScroll);
|
||||
if (s != -1)
|
||||
slotPos = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer (int mouseX, int mouseY)
|
||||
{
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("crafters.Smeltery"), 86, 5, 0x404040);
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 90, (ySize - 96) + 2, 0x404040);
|
||||
|
||||
int base = 0;
|
||||
int cornerX = (width - xSize) / 2 + 36;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
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;
|
||||
if (capacity > 0)
|
||||
{
|
||||
liquidSize = liquid.amount * 52 / capacity;
|
||||
if (liquidSize == 0)
|
||||
liquidSize = 1;
|
||||
base += liquidSize;
|
||||
|
||||
}
|
||||
|
||||
int leftX = cornerX + basePos;
|
||||
int topY = (cornerY + 68) - base;
|
||||
int sizeX = 52;
|
||||
int sizeY = liquidSize;
|
||||
if (mouseX >= leftX && mouseX <= leftX + sizeX && mouseY >= topY && mouseY < topY + sizeY)
|
||||
{
|
||||
drawFluidStackTooltip(liquid, mouseX - cornerX + 36, mouseY - cornerY);
|
||||
|
||||
}
|
||||
}
|
||||
if (scomp.fuelGague > 0)
|
||||
{
|
||||
int leftX = cornerX + 117;
|
||||
int topY = (cornerY + 68) - scomp.getScaledFuelGague(52);
|
||||
int sizeX = 12;
|
||||
int sizeY = scomp.getScaledFuelGague(52);
|
||||
if (mouseX >= leftX && mouseX <= leftX + sizeX && mouseY >= topY && mouseY < topY + sizeY)
|
||||
{
|
||||
drawFluidStackTooltip(new FluidStack(-37, scomp.fuelAmount), mouseX - cornerX + 36, mouseY - cornerY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/smeltery.png");
|
||||
private static final ResourceLocation backgroundSide = new ResourceLocation("tinker", "textures/gui/smelteryside.png");
|
||||
private static final ResourceLocation terrain = new ResourceLocation("terrain.png");
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer (float f, int mouseX, int mouseY)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(background);
|
||||
int cornerX = (width - xSize) / 2 + 36;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
drawTexturedModalRect(cornerX + 46, cornerY, 0, 0, 176, ySize);
|
||||
|
||||
//Fuel - Lava
|
||||
this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
if (scomp.fuelGague > 0)
|
||||
{
|
||||
Icon lavaIcon = Block.lavaStill.getIcon(0, 0);
|
||||
int fuel = scomp.getScaledFuelGague(52);
|
||||
int count = 0;
|
||||
while (fuel > 0)
|
||||
{
|
||||
int size = fuel >= 16 ? 16 : fuel;
|
||||
fuel -= size;
|
||||
drawLiquidRect(cornerX + 117, (cornerY + 68) - size - 16 * count, lavaIcon, 12, size);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
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 (capacity > 0)
|
||||
{
|
||||
int liquidSize = liquid.amount * 52 / capacity;
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Liquid gague
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
this.mc.getTextureManager().bindTexture(background);
|
||||
drawTexturedModalRect(cornerX + 54, cornerY + 16, 176, 76, 52, 52);
|
||||
|
||||
//Side inventory
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(backgroundSide);
|
||||
//if (logic.layers > 0)
|
||||
{
|
||||
/*if (logic.layers == 1)
|
||||
{
|
||||
drawTexturedModalRect(cornerX - 46, cornerY, 0, 0, 98, 43);
|
||||
drawTexturedModalRect(cornerX - 46, cornerY + 43, 0, 133, 98, 25);
|
||||
}
|
||||
else if (logic.layers == 2)
|
||||
{
|
||||
drawTexturedModalRect(cornerX - 46, cornerY, 0, 0, 98, 61);
|
||||
drawTexturedModalRect(cornerX - 46, cornerY + 61, 0, 97, 98, 61);
|
||||
}
|
||||
else*/
|
||||
{
|
||||
drawTexturedModalRect(cornerX - 46, cornerY, 0, 0, 98, ySize - 8);
|
||||
}
|
||||
drawTexturedModalRect(cornerX + 32, (int) (cornerY + 8 + 127 * currentScroll), 98, 0, 12, 15);
|
||||
}
|
||||
|
||||
//Temperature
|
||||
int slotSize = logic.getSizeInventory();
|
||||
if (slotSize > 24)
|
||||
slotSize = 24;
|
||||
for (int iter = 0; iter < slotSize; iter++)
|
||||
{
|
||||
int slotTemp = logic.getTempForSlot(iter + slotPos * 3) - 20;
|
||||
int maxTemp = logic.getMeltingPointForSlot(iter + slotPos * 3) - 20;
|
||||
if (slotTemp > 0 && maxTemp > 0)
|
||||
{
|
||||
int size = 16 * slotTemp / maxTemp + 1;
|
||||
drawTexturedModalRect(cornerX - 38 + (iter % 3 * 22), cornerY + 8 + (iter / 3 * 18) + 16 - size, 98, 15 + 16 - size, 5, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawFluidStackTooltip (FluidStack par1ItemStack, int par2, int par3)
|
||||
{
|
||||
this.zLevel = 100;
|
||||
List list = getLiquidTooltip(par1ItemStack, this.mc.gameSettings.advancedItemTooltips);
|
||||
|
||||
for (int k = 0; k < list.size(); ++k)
|
||||
{
|
||||
list.set(k, EnumChatFormatting.GRAY + (String) list.get(k));
|
||||
}
|
||||
|
||||
this.drawToolTip(list, par2, par3);
|
||||
this.zLevel = 0;
|
||||
}
|
||||
|
||||
public List getLiquidTooltip (FluidStack liquid, boolean par2)
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
if (liquid.fluidID == -37)
|
||||
{
|
||||
list.add("\u00A7fFuel");
|
||||
list.add("mB: " + liquid.amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
String name = StatCollector.translateToLocal(FluidRegistry.getFluidName(liquid));
|
||||
list.add("\u00A7f" + name);
|
||||
if (name.equals("liquified emerald"))
|
||||
{
|
||||
list.add("Emeralds: " + liquid.amount / 320f);
|
||||
}
|
||||
else if (name.contains("Molten"))
|
||||
{
|
||||
int ingots = liquid.amount / TConstruct.ingotLiquidValue;
|
||||
if (ingots > 0)
|
||||
list.add("Ingots: " + ingots);
|
||||
int mB = liquid.amount % TConstruct.ingotLiquidValue;
|
||||
if (mB > 0)
|
||||
{
|
||||
int nuggets = mB / TConstruct.nuggetLiquidValue;
|
||||
int junk = (mB % TConstruct.nuggetLiquidValue);
|
||||
if (nuggets > 0)
|
||||
list.add("Nuggets: " + nuggets);
|
||||
if (junk > 0)
|
||||
list.add("mB: " + junk);
|
||||
}
|
||||
}
|
||||
else if (name.equals("Seared Stone"))
|
||||
{
|
||||
int ingots = liquid.amount / TConstruct.ingotLiquidValue;
|
||||
if (ingots > 0)
|
||||
list.add("Blocks: " + ingots);
|
||||
int mB = liquid.amount % TConstruct.ingotLiquidValue;
|
||||
if (mB > 0)
|
||||
list.add("mB: " + mB);
|
||||
}
|
||||
else if (name.equals("Molten Glass"))
|
||||
{
|
||||
int blocks = liquid.amount / 1000;
|
||||
if (blocks > 0)
|
||||
list.add("Blocks: " + blocks);
|
||||
int panels = (liquid.amount % 1000) / 250;
|
||||
if (panels > 0)
|
||||
list.add("Panels: " + panels);
|
||||
int mB = (liquid.amount % 1000) % 250;
|
||||
if (mB > 0)
|
||||
list.add("mB: " + mB);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.add("mB: " + liquid.amount);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
protected void drawToolTip (List par1List, int par2, int par3)
|
||||
{
|
||||
if (!par1List.isEmpty())
|
||||
{
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
int k = 0;
|
||||
Iterator iterator = par1List.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
String s = (String) iterator.next();
|
||||
int l = this.fontRenderer.getStringWidth(s);
|
||||
|
||||
if (l > k)
|
||||
{
|
||||
k = l;
|
||||
}
|
||||
}
|
||||
|
||||
int i1 = par2 + 12;
|
||||
int j1 = par3 - 12;
|
||||
int k1 = 8;
|
||||
|
||||
if (par1List.size() > 1)
|
||||
{
|
||||
k1 += 2 + (par1List.size() - 1) * 10;
|
||||
}
|
||||
|
||||
if (i1 + k > this.width)
|
||||
{
|
||||
i1 -= 28 + k;
|
||||
}
|
||||
|
||||
if (j1 + k1 + 6 > this.height)
|
||||
{
|
||||
j1 = this.height - k1 - 6;
|
||||
}
|
||||
|
||||
this.zLevel = 300.0F;
|
||||
itemRenderer.zLevel = 300.0F;
|
||||
int l1 = -267386864;
|
||||
this.drawGradientRect(i1 - 3, j1 - 4, i1 + k + 3, j1 - 3, l1, l1);
|
||||
this.drawGradientRect(i1 - 3, j1 + k1 + 3, i1 + k + 3, j1 + k1 + 4, l1, l1);
|
||||
this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 + k1 + 3, l1, l1);
|
||||
this.drawGradientRect(i1 - 4, j1 - 3, i1 - 3, j1 + k1 + 3, l1, l1);
|
||||
this.drawGradientRect(i1 + k + 3, j1 - 3, i1 + k + 4, j1 + k1 + 3, l1, l1);
|
||||
int i2 = 1347420415;
|
||||
int j2 = (i2 & 16711422) >> 1 | i2 & -16777216;
|
||||
this.drawGradientRect(i1 - 3, j1 - 3 + 1, i1 - 3 + 1, j1 + k1 + 3 - 1, i2, j2);
|
||||
this.drawGradientRect(i1 + k + 2, j1 - 3 + 1, i1 + k + 3, j1 + k1 + 3 - 1, i2, j2);
|
||||
this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2);
|
||||
this.drawGradientRect(i1 - 3, j1 + k1 + 2, i1 + k + 3, j1 + k1 + 3, j2, j2);
|
||||
|
||||
for (int k2 = 0; k2 < par1List.size(); ++k2)
|
||||
{
|
||||
String s1 = (String) par1List.get(k2);
|
||||
this.fontRenderer.drawStringWithShadow(s1, i1, j1, -1);
|
||||
|
||||
if (k2 == 0)
|
||||
{
|
||||
j1 += 2;
|
||||
}
|
||||
|
||||
j1 += 10;
|
||||
}
|
||||
|
||||
this.zLevel = 0.0F;
|
||||
itemRenderer.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
public void drawLiquidRect (int startU, int startV, Icon par3Icon, int endU, int endV)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV(startU + 0, startV + endV, this.zLevel, par3Icon.getMinU(), par3Icon.getMaxV());//Bottom left
|
||||
tessellator.addVertexWithUV(startU + endU, startV + endV, this.zLevel, par3Icon.getMaxU(), par3Icon.getMaxV());//Bottom right
|
||||
tessellator.addVertexWithUV(startU + endU, startV + 0, this.zLevel, par3Icon.getMaxU(), par3Icon.getMinV());//Top right
|
||||
tessellator.addVertexWithUV(startU + 0, startV + 0, this.zLevel, par3Icon.getMinU(), par3Icon.getMinV()); //Top left
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
int base = 0;
|
||||
int cornerX = (width - xSize) / 2 + 36;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
int fluidToBeBroughtUp = -1;
|
||||
|
||||
for (FluidStack liquid : multitank.getAllFluids())
|
||||
{
|
||||
int basePos = 54;
|
||||
int initialLiquidSize = 0;
|
||||
int liquidSize = 0;//liquid.amount * 52 / liquidLayers;
|
||||
if (multitank.getCapacity() > 0)
|
||||
{
|
||||
int total = multitank.getFluidAmount();
|
||||
int liquidLayers = (total / 20000 + 1) * 20000;
|
||||
if (liquidLayers > 0)
|
||||
{
|
||||
liquidSize = liquid.amount * 52 / liquidLayers;
|
||||
if (liquidSize == 0)
|
||||
liquidSize = 1;
|
||||
base += liquidSize;
|
||||
}
|
||||
}
|
||||
|
||||
int leftX = cornerX + basePos;
|
||||
int topY = (cornerY + 68) - base;
|
||||
int sizeX = 52;
|
||||
int sizeY = liquidSize;
|
||||
if (mouseX >= leftX && mouseX <= leftX + sizeX && mouseY >= topY && mouseY < topY + sizeY)
|
||||
{
|
||||
fluidToBeBroughtUp = liquid.fluidID;
|
||||
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(bos);
|
||||
|
||||
try
|
||||
{
|
||||
dos.write(11);
|
||||
|
||||
dos.writeInt(logic.worldObj.provider.dimensionId);
|
||||
dos.writeInt(logic.xCoord);
|
||||
dos.writeInt(logic.yCoord);
|
||||
dos.writeInt(logic.zCoord);
|
||||
|
||||
dos.writeBoolean(this.isShiftKeyDown());
|
||||
|
||||
dos.writeInt(fluidToBeBroughtUp);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
packet.channel = "TConstruct";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
|
||||
PacketDispatcher.sendPacketToServer(packet);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void onGuiClosed ()
|
||||
{
|
||||
super.onGuiClosed();
|
||||
logic.worldObj.markBlockForUpdate(logic.xCoord, logic.yCoord, logic.zCoord);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.InventoryEffectRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import tconstruct.client.tabs.InventoryTabArmorExtended;
|
||||
import tconstruct.client.tabs.TabRegistry;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.inventory.ArmorExtendedContainer;
|
||||
import tconstruct.util.player.ArmorExtended;
|
||||
|
||||
public class ArmorExtendedGui extends InventoryEffectRenderer
|
||||
{
|
||||
public InventoryPlayer inv;
|
||||
public ArmorExtended stats;
|
||||
|
||||
private float xSize_lo;
|
||||
private float ySize_lo;
|
||||
|
||||
public ArmorExtendedGui(InventoryPlayer inventoryplayer, ArmorExtended holder)
|
||||
{
|
||||
super(new ArmorExtendedContainer(inventoryplayer, holder));
|
||||
inv = inventoryplayer;
|
||||
stats = holder;
|
||||
}
|
||||
|
||||
public void initGui ()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
int cornerX = guiLeft;
|
||||
int cornerY = (this.height - this.ySize) / 2;
|
||||
this.buttonList.clear();
|
||||
|
||||
// InventoryTab tab = new InventoryTab(2, cornerX, cornerY - 28, new ItemStack(Block.workbench), 0);
|
||||
// this.buttonList.add(tab);
|
||||
// tab = new InventoryTab(3, cornerX + 28, cornerY - 28, new ItemStack(Item.plateDiamond), 1);
|
||||
// tab.enabled = false;
|
||||
// this.buttonList.add(tab);
|
||||
|
||||
TabRegistry.updateTabValues(cornerX, cornerY, InventoryTabArmorExtended.class);
|
||||
TabRegistry.addTabsToList(this.buttonList);
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
||||
{
|
||||
//fontRenderer.drawString(StatCollector.translateToLocal("inventory.armorextended"), 60, 6, 0x404040);
|
||||
//fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 17, (ySize - 96) + 2, 0x404040);
|
||||
}
|
||||
|
||||
public void drawScreen (int par1, int par2, float par3)
|
||||
{
|
||||
super.drawScreen(par1, par2, par3);
|
||||
this.xSize_lo = (float) par1;
|
||||
this.ySize_lo = (float) par2;
|
||||
// if (stats.inventory[2] != null && stats.inventory[2].getItem() == TContent.knapsack)
|
||||
// {
|
||||
// if (this.buttonList.size() < 3)
|
||||
// {
|
||||
// int cornerX = guiLeft;
|
||||
// int cornerY = (this.height - this.ySize) / 2;
|
||||
// InventoryTab tab = new InventoryTab(4, cornerX + 56, cornerY - 28, new ItemStack(TContent.knapsack), 1);
|
||||
// this.buttonList.add(tab);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (this.buttonList.size() >= 3)
|
||||
// {
|
||||
// buttonList.remove(2);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/armorextended.png");
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer (float f, int i, int j)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
//mc.renderEngine.bindTexture("/mods/tinker/textures/gui/armorextended.png");
|
||||
this.mc.getTextureManager().bindTexture(background);
|
||||
int cornerX = guiLeft;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize);
|
||||
|
||||
if (!stats.isStackInSlot(0))
|
||||
drawTexturedModalRect(cornerX + 79, cornerY + 16, 176, 9, 18, 18);
|
||||
if (!stats.isStackInSlot(1))
|
||||
drawTexturedModalRect(cornerX + 79, cornerY + 34, 176, 27, 18, 18);
|
||||
if (!stats.isStackInSlot(2))
|
||||
drawTexturedModalRect(cornerX + 115, cornerY + 16, 212, 9, 18, 18);
|
||||
if (!stats.isStackInSlot(3))
|
||||
drawTexturedModalRect(cornerX + 115, cornerY + 34, 212, 27, 18, 18);
|
||||
if (!stats.isStackInSlot(4))
|
||||
drawTexturedModalRect(cornerX + 151, cornerY + 16, 230, 0, 18, 18);
|
||||
if (!stats.isStackInSlot(5))
|
||||
drawTexturedModalRect(cornerX + 151, cornerY + 34, 230, 18, 18, 18);
|
||||
if (!stats.isStackInSlot(6))
|
||||
drawTexturedModalRect(cornerX + 151, cornerY + 52, 230, 36, 18, 18);
|
||||
|
||||
cornerX = this.guiLeft;
|
||||
cornerY = this.guiTop;
|
||||
drawPlayerOnGui(this.mc, cornerX + 33, cornerY + 75, 30, (float) (cornerX + 51) - this.xSize_lo, (float) (cornerY + 75 - 50) - this.ySize_lo);
|
||||
}
|
||||
|
||||
public static void drawPlayerOnGui (Minecraft par0Minecraft, int par1, int par2, int par3, float par4, float par5)
|
||||
{
|
||||
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) par1, (float) par2, 50.0F);
|
||||
GL11.glScalef((float) (-par3), (float) par3, (float) par3);
|
||||
GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
|
||||
float f2 = par0Minecraft.thePlayer.renderYawOffset;
|
||||
float f3 = par0Minecraft.thePlayer.rotationYaw;
|
||||
float f4 = par0Minecraft.thePlayer.rotationPitch;
|
||||
par4 -= 19;
|
||||
GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(-((float) Math.atan((double) (par5 / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
|
||||
par0Minecraft.thePlayer.renderYawOffset = (float) Math.atan((double) (par4 / 40.0F)) * 20.0F;
|
||||
par0Minecraft.thePlayer.rotationYaw = (float) Math.atan((double) (par4 / 40.0F)) * 40.0F;
|
||||
par0Minecraft.thePlayer.rotationPitch = -((float) Math.atan((double) (par5 / 40.0F))) * 20.0F;
|
||||
par0Minecraft.thePlayer.rotationYawHead = par0Minecraft.thePlayer.rotationYaw;
|
||||
GL11.glTranslatef(0.0F, par0Minecraft.thePlayer.yOffset, 0.0F);
|
||||
RenderManager.instance.playerViewY = 180.0F;
|
||||
RenderManager.instance.renderEntityWithPosYaw(par0Minecraft.thePlayer, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
|
||||
par0Minecraft.thePlayer.renderYawOffset = f2;
|
||||
par0Minecraft.thePlayer.rotationYaw = f3;
|
||||
par0Minecraft.thePlayer.rotationPitch = f4;
|
||||
GL11.glPopMatrix();
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
}
|
||||
|
||||
/*protected void keyTyped(char par1, int par2)
|
||||
{
|
||||
if (par2 == TControls.armorKey.keyCode)
|
||||
{
|
||||
this.mc.thePlayer.closeScreen();
|
||||
}
|
||||
|
||||
super.keyTyped(par1, par2);
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,398 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.blocks.logic.CraftingStationLogic;
|
||||
import tconstruct.library.armor.ArmorCore;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class CraftingStationGui extends GuiContainer
|
||||
{
|
||||
public boolean active;
|
||||
public String toolName;
|
||||
public GuiTextField text;
|
||||
public String title, body = "";
|
||||
CraftingStationLogic logic;
|
||||
|
||||
public CraftingStationGui(InventoryPlayer inventory, CraftingStationLogic logic, World world, int x, int y, int z)
|
||||
{
|
||||
super(logic.getGuiContainer(inventory, world, x, y, z));
|
||||
this.logic = logic;
|
||||
//text = new GuiTextField(this.fontRenderer, this.xSize / 2 - 5, 8, 30, 12);
|
||||
//this.text.setText("");
|
||||
title = "\u00A7nRepair and Modification";
|
||||
body = "The main way to repair or change your tools or armor.\n\nPlace an item and a material on the left to get started.";
|
||||
toolName = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
||||
{
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal(logic.tinkerTable ? "crafters.TinkerTable" : logic.getInvName()), 8, 6, 0x202020);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 0x202020);
|
||||
if (logic.chest != null)
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal(logic.chest.get().getInvName()), -108, this.ySize - 160, 0x202020);
|
||||
//this.fontRenderer.drawString(toolName + "_", this.xSize / 2 - 18, 8, 0xffffff);
|
||||
|
||||
if (logic.tinkerTable)
|
||||
{
|
||||
if (logic.isStackInSlot(0))
|
||||
drawToolStats();
|
||||
else
|
||||
drawToolInformation();
|
||||
}
|
||||
}
|
||||
|
||||
void drawToolStats ()
|
||||
{
|
||||
ItemStack stack = logic.getStackInSlot(0);
|
||||
if (stack.getItem() instanceof ToolCore)
|
||||
{
|
||||
ToolCore tool = (ToolCore) stack.getItem();
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
this.drawCenteredString(fontRenderer, "\u00A7n" + tool.getToolName(), xSize + 63, 8, 0xffffff);
|
||||
|
||||
drawModularToolStats(stack, tool, tags);
|
||||
}
|
||||
else if (stack.getItem() instanceof ArmorCore)
|
||||
{
|
||||
ArmorCore armor = (ArmorCore) stack.getItem();
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("TinkerArmor");
|
||||
this.drawCenteredString(fontRenderer, "\u00A7n" + StatCollector.translateToLocal("armortype."+armor.getArmorName()), xSize + 63, 8, 0xffffff);
|
||||
|
||||
drawModularArmorStats(stack, armor, tags);
|
||||
}
|
||||
}
|
||||
|
||||
void drawModularArmorStats (ItemStack stack, ArmorCore tool, NBTTagCompound tags)
|
||||
{
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
int base = 24;
|
||||
int offset = 0;
|
||||
if (modifiers > 0)
|
||||
{
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation18") + tags.getInteger("Modifiers"), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
}
|
||||
|
||||
boolean displayToolTips = true;
|
||||
int tipNum = 0;
|
||||
while (displayToolTips)
|
||||
{
|
||||
tipNum++;
|
||||
String tooltip = "ModifierTip" + tipNum;
|
||||
if (tags.hasKey(tooltip))
|
||||
{
|
||||
String tipName = tags.getString(tooltip);
|
||||
fontRenderer.drawString("- " + tipName, xSize + 8, base + (offset + tipNum) * 10, 0xffffff);
|
||||
}
|
||||
else
|
||||
displayToolTips = false;
|
||||
}
|
||||
}
|
||||
|
||||
void drawModularToolStats (ItemStack stack, ToolCore tool, NBTTagCompound tags)
|
||||
{
|
||||
List categories = Arrays.asList(tool.toolCategories());
|
||||
final int durability = tags.getInteger("Damage");
|
||||
final int maxDur = tags.getInteger("TotalDurability");
|
||||
int availableDurability = maxDur - durability;
|
||||
|
||||
//Durability
|
||||
int base = 24;
|
||||
int offset = 0;
|
||||
if (maxDur > 0)
|
||||
{
|
||||
if (maxDur >= 10000)
|
||||
{
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation1"), xSize + 8, base + offset * 11, 0xffffff);
|
||||
offset++;
|
||||
fontRenderer.drawString("- " + availableDurability + "/" + maxDur, xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation2") + availableDurability + "/" + maxDur, xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
|
||||
final float stonebound = tags.getFloat("Shoddy");
|
||||
//Attack
|
||||
if (categories.contains("weapon"))
|
||||
{
|
||||
int attack = (int) (tags.getInteger("Attack"));
|
||||
float stoneboundDamage = (float) Math.log(durability / 72f + 1) * -2 * stonebound;
|
||||
attack += stoneboundDamage;
|
||||
attack *= tool.getDamageModifier();
|
||||
if (attack < 1)
|
||||
attack = 1;
|
||||
|
||||
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter9") : StatCollector.translateToLocal("gui.partcrafter10");
|
||||
if (attack % 2 == 0)
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation3") + attack / 2 + heart, xSize + 8, base + offset * 10, 0xffffff);
|
||||
else
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation3") + attack / 2f + heart, xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
|
||||
if (stoneboundDamage != 0)
|
||||
{
|
||||
heart = stoneboundDamage == 2 ? StatCollector.translateToLocal("gui.partcrafter9") : StatCollector.translateToLocal("gui.partcrafter10");
|
||||
String bloss = stoneboundDamage > 0 ? StatCollector.translateToLocal("gui.toolstation4") : StatCollector.translateToLocal("gui.toolstation5");
|
||||
this.fontRenderer.drawString(bloss + (int) stoneboundDamage / 2 + heart, xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
}
|
||||
offset++;
|
||||
}
|
||||
|
||||
if (categories.contains("bow"))
|
||||
{
|
||||
DecimalFormat df = new DecimalFormat("##.##");
|
||||
df.setRoundingMode(RoundingMode.DOWN);
|
||||
int drawSpeed = tags.getInteger("DrawSpeed");
|
||||
float flightSpeed = tags.getFloat("FlightSpeed");
|
||||
float trueDraw = drawSpeed / 20f * flightSpeed;
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation6") + df.format(trueDraw) + "s", xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation7") + df.format(flightSpeed) + "x", xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
offset++;
|
||||
}
|
||||
|
||||
if (categories.contains("ammo"))
|
||||
{
|
||||
DecimalFormat df = new DecimalFormat("##.##");
|
||||
df.setRoundingMode(RoundingMode.DOWN);
|
||||
int attack = (int) (tags.getInteger("Attack"));
|
||||
float mass = tags.getFloat("Mass");
|
||||
float shatter = tags.getFloat("BreakChance");
|
||||
float accuracy = tags.getFloat("Accuracy");
|
||||
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation10"), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter9") : StatCollector.translateToLocal("gui.partcrafter10");
|
||||
if (attack % 2 == 0)
|
||||
this.fontRenderer.drawString("- " + attack / 2 + heart, xSize + 8, base + offset * 10, 0xffffff);
|
||||
else
|
||||
this.fontRenderer.drawString("- " + attack / 2f + heart, xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
int minAttack = attack;
|
||||
int maxAttack = attack * 2;
|
||||
heart = StatCollector.translateToLocal("gui.partcrafter10");
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation11"), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
this.fontRenderer.drawString(df.format(minAttack / 2f) + "-" + df.format(maxAttack / 2f) + heart, xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
offset++;
|
||||
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation8") + df.format(mass), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation9") + df.format(accuracy - 4) + "%", xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
/*this.fontRenderer.drawString("Chance to break: " + df.format(shatter)+"%", xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;*/
|
||||
offset++;
|
||||
}
|
||||
|
||||
//Mining
|
||||
if (categories.contains("dualharvest"))
|
||||
{
|
||||
float mineSpeed = tags.getInteger("MiningSpeed") / 100f;
|
||||
float mineSpeed2 = tags.getInteger("MiningSpeed2") / 100f;
|
||||
float stoneboundSpeed = (float) Math.log(durability / 90f + 1) * 2 * stonebound;
|
||||
DecimalFormat df = new DecimalFormat("##.##");
|
||||
df.setRoundingMode(RoundingMode.DOWN);
|
||||
float trueSpeed = mineSpeed + stoneboundSpeed;
|
||||
float trueSpeed2 = mineSpeed + stoneboundSpeed;
|
||||
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation12"), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
fontRenderer.drawString("- " + df.format(trueSpeed) + ", " + df.format(trueSpeed2), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
if (stoneboundSpeed != 0)
|
||||
{
|
||||
String bloss = stoneboundSpeed > 0 ? StatCollector.translateToLocal("gui.toolstation4") : StatCollector.translateToLocal("gui.toolstation5");
|
||||
fontRenderer.drawString(bloss + df.format(stoneboundSpeed), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
}
|
||||
offset++;
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation13"), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
fontRenderer
|
||||
.drawString("- " + getHarvestLevelName(tags.getInteger("HarvestLevel")) + ", " + getHarvestLevelName(tags.getInteger("HarvestLevel2")), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
offset++;
|
||||
}
|
||||
else if (categories.contains("harvest"))
|
||||
{
|
||||
float mineSpeed = tags.getInteger("MiningSpeed");
|
||||
int heads = 1;
|
||||
|
||||
if (tags.hasKey("MiningSpeed2"))
|
||||
{
|
||||
mineSpeed += tags.getInteger("MiningSpeed2");
|
||||
heads++;
|
||||
}
|
||||
|
||||
if (tags.hasKey("MiningSpeedHandle"))
|
||||
{
|
||||
mineSpeed += tags.getInteger("MiningSpeedHandle");
|
||||
heads++;
|
||||
}
|
||||
|
||||
if (tags.hasKey("MiningSpeedExtra"))
|
||||
{
|
||||
mineSpeed += tags.getInteger("MiningSpeedExtra");
|
||||
heads++;
|
||||
}
|
||||
|
||||
float trueSpeed = mineSpeed / (heads * 100f);
|
||||
|
||||
float stoneboundSpeed = (float) Math.log(durability / 90f + 1) * 2 * stonebound;
|
||||
DecimalFormat df = new DecimalFormat("##.##");
|
||||
df.setRoundingMode(RoundingMode.DOWN);
|
||||
trueSpeed += stoneboundSpeed;
|
||||
if (trueSpeed < 0)
|
||||
trueSpeed = 0;
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation14") + df.format(trueSpeed), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
if (stoneboundSpeed != 0)
|
||||
{
|
||||
String bloss = stoneboundSpeed > 0 ? StatCollector.translateToLocal("gui.toolstation4") : StatCollector.translateToLocal("gui.toolstation5");
|
||||
fontRenderer.drawString(bloss + df.format(stoneboundSpeed), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
}
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation15") + getHarvestLevelName(tags.getInteger("HarvestLevel")), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
offset++;
|
||||
}
|
||||
else if (categories.contains("utility"))
|
||||
{
|
||||
float mineSpeed = tags.getInteger("MiningSpeed");
|
||||
float trueSpeed = mineSpeed / (100f);
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation16") + trueSpeed, xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
offset++;
|
||||
}
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
if (modifiers > 0)
|
||||
{
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation18") + tags.getInteger("Modifiers"), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
}
|
||||
if (tags.hasKey("Tooltip1"))
|
||||
{
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation17"), xSize + 8, base + offset * 10, 0xffffff);
|
||||
}
|
||||
|
||||
boolean displayToolTips = true;
|
||||
int tipNum = 0;
|
||||
while (displayToolTips)
|
||||
{
|
||||
tipNum++;
|
||||
String tooltip = "ModifierTip" + tipNum;
|
||||
if (tags.hasKey(tooltip))
|
||||
{
|
||||
String tipName = tags.getString(tooltip);
|
||||
fontRenderer.drawString("- " + tipName, xSize + 8, base + (offset + tipNum) * 10, 0xffffff);
|
||||
}
|
||||
else
|
||||
displayToolTips = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected String getHarvestLevelName (int num)
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
case 0:
|
||||
return StatCollector.translateToLocal("gui.partcrafter.mining1");
|
||||
case 1:
|
||||
return StatCollector.translateToLocal("gui.partcrafter.mining2");
|
||||
case 2:
|
||||
return StatCollector.translateToLocal("gui.partcrafter.mining3");
|
||||
case 3:
|
||||
return StatCollector.translateToLocal("gui.partcrafter.mining4");
|
||||
case 4:
|
||||
return StatCollector.translateToLocal("gui.partcrafter.mining5");
|
||||
case 5:
|
||||
return StatCollector.translateToLocal("gui.partcrafter.mining6");
|
||||
default:
|
||||
return String.valueOf(num);
|
||||
}
|
||||
}
|
||||
|
||||
void drawToolInformation ()
|
||||
{
|
||||
this.drawCenteredString(fontRenderer, title, xSize + 63, 8, 0xffffff);
|
||||
fontRenderer.drawSplitString(body, xSize + 8, 24, 115, 0xffffff);
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/tinkertable.png");
|
||||
private static final ResourceLocation description = new ResourceLocation("tinker", "textures/gui/description.png");
|
||||
private static final ResourceLocation icons = new ResourceLocation("tinker", "textures/gui/icons.png");
|
||||
private static final ResourceLocation chest = new ResourceLocation("tinker", "textures/gui/chestside.png");
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
|
||||
{
|
||||
// Draw the background
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(background);
|
||||
int cornerX = (this.width - this.xSize) / 2;
|
||||
int cornerY = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
if (active)
|
||||
{
|
||||
this.drawTexturedModalRect(cornerX + 62, cornerY, 0, this.ySize, 112, 22);
|
||||
}
|
||||
|
||||
this.mc.getTextureManager().bindTexture(icons);
|
||||
// Draw the slots
|
||||
|
||||
if (logic.tinkerTable && !logic.isStackInSlot(5))
|
||||
this.drawTexturedModalRect(cornerX + 47, cornerY + 33, 0, 233, 18, 18);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(icons);
|
||||
|
||||
//Draw chest side
|
||||
if (logic.chest != null)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(chest);
|
||||
if (logic.doubleChest == null)
|
||||
this.drawTexturedModalRect(cornerX - 116, cornerY, 0, 0, 121, this.ySize);
|
||||
else
|
||||
this.drawTexturedModalRect(cornerX - 116, cornerY, 125, 0, 122, this.ySize + 21);
|
||||
}
|
||||
|
||||
// Draw description
|
||||
if (logic.tinkerTable)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(description);
|
||||
cornerX = (this.width + this.xSize) / 2;
|
||||
cornerY = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, 126, this.ySize + 30);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.blocks.logic.FrypanLogic;
|
||||
|
||||
public class FrypanGui extends GuiContainer
|
||||
{
|
||||
public FrypanLogic logic;
|
||||
|
||||
public FrypanGui(InventoryPlayer inventoryplayer, FrypanLogic frypan, World world, int x, int y, int z)
|
||||
{
|
||||
super(frypan.getGuiContainer(inventoryplayer, world, x, y, z));
|
||||
logic = frypan;
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
||||
{
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("crafters.Frypan"), 60, 6, 0x404040);
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/frypan.png");
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer (float f, int i, int j)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(background);
|
||||
int cornerX = (width - xSize) / 2;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize);
|
||||
if (logic.fuel > 0)
|
||||
{
|
||||
int fuel = logic.gaugeFuelScaled(12);
|
||||
drawTexturedModalRect(cornerX + 27, (cornerY + 40) - fuel, 176, 12 - fuel, 14, fuel + 2);
|
||||
}
|
||||
int fuelgague = logic.gaugeProgressScaled(24);
|
||||
drawTexturedModalRect(cornerX + 140, cornerY + 8, 176, 14, fuelgague, 16);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.blocks.logic.FurnaceLogic;
|
||||
import tconstruct.inventory.FurnaceContainer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class FurnaceGui extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation furnaceGuiTextures = new ResourceLocation("textures/gui/container/furnace.png");
|
||||
private FurnaceLogic logic;
|
||||
|
||||
public FurnaceGui(InventoryPlayer inventory, FurnaceLogic furnace)
|
||||
{
|
||||
super(new FurnaceContainer(inventory, furnace));
|
||||
this.logic = furnace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
||||
{
|
||||
String s = this.logic.isInvNameLocalized() ? this.logic.getInvName() : I18n.getString(this.logic.getInvName());
|
||||
this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);
|
||||
this.fontRenderer.drawString(I18n.getString("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the background layer for the GuiContainer (everything behind the items)
|
||||
*/
|
||||
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(furnaceGuiTextures);
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
int i1;
|
||||
|
||||
if (this.logic.isBurning())
|
||||
{
|
||||
i1 = this.logic.gaugeFuelScaled(12);
|
||||
this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
|
||||
}
|
||||
|
||||
i1 = this.logic.gaugeProgressScaled(24);
|
||||
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.library.client.ToolGuiElement;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiButtonTool extends GuiButton
|
||||
{
|
||||
/**
|
||||
* True for pointing right (next page), false for pointing left (previous page).
|
||||
*/
|
||||
int textureX;
|
||||
int textureY;
|
||||
public String texture;
|
||||
public ToolGuiElement element;
|
||||
private static ResourceLocation background;// = new ResourceLocation("tinker", "textures/gui/armorextended.png");
|
||||
|
||||
public GuiButtonTool(int id, int posX, int posY, int texX, int texY, String domain, String tex, ToolGuiElement e)
|
||||
{
|
||||
super(id, posX, posY, 18, 18, "");
|
||||
textureX = texX;
|
||||
textureY = texY;
|
||||
texture = tex;
|
||||
element = e;
|
||||
background = new ResourceLocation(domain, tex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws this button to the screen.
|
||||
*/
|
||||
public void drawButton (Minecraft mc, int mouseX, int mouseY)
|
||||
{
|
||||
if (this.drawButton)
|
||||
{
|
||||
boolean var4 = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.getTextureManager().bindTexture(background);
|
||||
|
||||
this.field_82253_i = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||
int var5 = this.getHoverState(this.field_82253_i);
|
||||
int index = 18 * getHoverState(field_82253_i);
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, 144 + index * 2, 216, 18, 18);
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, textureX * 18, textureY * 18, 18, 18);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.inventory.ContainerLandmine;
|
||||
import tconstruct.util.landmine.behavior.Behavior;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class GuiLandmine extends GuiContainer
|
||||
{
|
||||
|
||||
ContainerLandmine container;
|
||||
|
||||
ResourceLocation background = new ResourceLocation("tinker:textures/gui/landmine.png");
|
||||
|
||||
public GuiLandmine(ContainerLandmine par1Container)
|
||||
{
|
||||
super(par1Container);
|
||||
container = par1Container;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawItemStackTooltip (ItemStack par1ItemStack, int par2, int par3)
|
||||
{
|
||||
List list = par1ItemStack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
|
||||
|
||||
Behavior b = Behavior.getBehaviorFromStack(par1ItemStack);
|
||||
if (b != null)
|
||||
{
|
||||
b.getInformation(par1ItemStack, list);
|
||||
}
|
||||
|
||||
for (int k = 0; k < list.size(); ++k)
|
||||
{
|
||||
if (k == 0)
|
||||
{
|
||||
list.set(k, "\u00a7" + Integer.toHexString(par1ItemStack.getRarity().rarityColor) + (String) list.get(k));
|
||||
}
|
||||
else
|
||||
{
|
||||
list.set(k, EnumChatFormatting.GRAY + (String) list.get(k));
|
||||
}
|
||||
}
|
||||
|
||||
FontRenderer font = par1ItemStack.getItem().getFontRenderer(par1ItemStack);
|
||||
drawHoveringText(list, par2, par3, (font == null ? fontRenderer : font));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer (int i, int j)
|
||||
{
|
||||
if (container.te != null)
|
||||
{
|
||||
fontRenderer.drawString(container.te.getInvName(), 8, 5, 4210752);
|
||||
}
|
||||
else
|
||||
{
|
||||
fontRenderer.drawString("Landmine", 8, 5, 4210752);
|
||||
}
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 3, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer (float f, int i, int j)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.renderEngine.bindTexture(background);
|
||||
int x = (width - xSize) / 2;
|
||||
int y = (height - ySize) / 2;
|
||||
this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import tconstruct.client.RenderItemCopy;
|
||||
import tconstruct.client.TProxyClient;
|
||||
import tconstruct.client.block.SmallFontRenderer;
|
||||
import tconstruct.client.pages.BookPage;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiManual extends GuiScreen
|
||||
{
|
||||
ItemStack itemstackBook;
|
||||
Document manual;
|
||||
public RenderItemCopy renderitem = new RenderItemCopy();
|
||||
int bookImageWidth = 206;
|
||||
int bookImageHeight = 200;
|
||||
int bookTotalPages = 1;
|
||||
int currentPage;
|
||||
int maxPages;
|
||||
|
||||
private TurnPageButton buttonNextPage;
|
||||
private TurnPageButton buttonPreviousPage;
|
||||
|
||||
BookPage pageLeft;
|
||||
BookPage pageRight;
|
||||
|
||||
public SmallFontRenderer fonts = TProxyClient.smallFontRenderer;
|
||||
|
||||
public GuiManual(ItemStack stack, Document doc)
|
||||
{
|
||||
this.mc = Minecraft.getMinecraft();
|
||||
this.itemstackBook = stack;
|
||||
currentPage = 0; //Stack page
|
||||
manual = doc;
|
||||
//renderitem.renderInFrame = true;
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void setWorldAndResolution (Minecraft minecraft, int w, int h)
|
||||
{
|
||||
this.guiParticles = new GuiParticle(minecraft);
|
||||
this.mc = minecraft;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
this.buttonList.clear();
|
||||
this.initGui();
|
||||
}*/
|
||||
|
||||
public void initGui ()
|
||||
{
|
||||
maxPages = manual.getElementsByTagName("page").getLength();
|
||||
updateText();
|
||||
int xPos = (this.width) / 2;
|
||||
this.buttonList.add(this.buttonNextPage = new TurnPageButton(1, xPos + bookImageWidth - 50, 180, true));
|
||||
this.buttonList.add(this.buttonPreviousPage = new TurnPageButton(2, xPos - bookImageWidth + 24, 180, false));
|
||||
}
|
||||
|
||||
protected void actionPerformed (GuiButton button)
|
||||
{
|
||||
if (button.enabled)
|
||||
{
|
||||
if (button.id == 1)
|
||||
currentPage += 2;
|
||||
if (button.id == 2)
|
||||
currentPage -= 2;
|
||||
|
||||
updateText();
|
||||
}
|
||||
}
|
||||
|
||||
void updateText ()
|
||||
{
|
||||
if (maxPages % 2 == 1)
|
||||
{
|
||||
if (currentPage > maxPages)
|
||||
currentPage = maxPages;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentPage >= maxPages)
|
||||
currentPage = maxPages - 2;
|
||||
}
|
||||
if (currentPage % 2 == 1)
|
||||
currentPage--;
|
||||
if (currentPage < 0)
|
||||
currentPage = 0;
|
||||
|
||||
NodeList nList = manual.getElementsByTagName("page");
|
||||
|
||||
Node node = nList.item(currentPage);
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE)
|
||||
{
|
||||
Element element = (Element) node;
|
||||
Class clazz = TProxyClient.getPageClass(element.getAttribute("type"));
|
||||
if (clazz != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
pageLeft = (BookPage) clazz.newInstance();
|
||||
pageLeft.init(this, 0);
|
||||
pageLeft.readPageFromXML(element);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pageLeft = null;
|
||||
}
|
||||
}
|
||||
|
||||
node = nList.item(currentPage + 1);
|
||||
if (node != null && node.getNodeType() == Node.ELEMENT_NODE)
|
||||
{
|
||||
Element element = (Element) node;
|
||||
Class clazz = TProxyClient.getPageClass(element.getAttribute("type"));
|
||||
if (clazz != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
pageRight = (BookPage) clazz.newInstance();
|
||||
pageRight.init(this, 1);
|
||||
pageRight.readPageFromXML(element);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pageLeft = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pageRight = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static final ResourceLocation bookRight = new ResourceLocation("tinker", "textures/gui/bookright.png");
|
||||
private static final ResourceLocation bookLeft = new ResourceLocation("tinker", "textures/gui/bookleft.png");
|
||||
|
||||
public void drawScreen (int par1, int par2, float par3)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(bookRight);
|
||||
int localWidth = (this.width) / 2;
|
||||
byte localHeight = 8;
|
||||
this.drawTexturedModalRect(localWidth, localHeight, 0, 0, this.bookImageWidth, this.bookImageHeight);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(bookLeft);
|
||||
localWidth = localWidth - this.bookImageWidth;
|
||||
this.drawTexturedModalRect(localWidth, localHeight, 256 - this.bookImageWidth, 0, this.bookImageWidth, this.bookImageHeight);
|
||||
|
||||
super.drawScreen(par1, par2, par3); //16, 12, 220, 12
|
||||
|
||||
if (pageLeft != null)
|
||||
pageLeft.renderBackgroundLayer(localWidth + 16, localHeight + 12);
|
||||
if (pageRight != null)
|
||||
pageRight.renderBackgroundLayer(localWidth + 220, localHeight + 12);
|
||||
|
||||
if (pageLeft != null)
|
||||
pageLeft.renderContentLayer(localWidth + 16, localHeight + 12);
|
||||
if (pageRight != null)
|
||||
pageRight.renderContentLayer(localWidth + 220, localHeight + 12);
|
||||
}
|
||||
|
||||
public Minecraft getMC ()
|
||||
{
|
||||
return mc;
|
||||
}
|
||||
|
||||
public boolean doesGuiPauseGame ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tconstruct.client.tabs.InventoryTabKnapsack;
|
||||
import tconstruct.client.tabs.TabRegistry;
|
||||
import tconstruct.inventory.KnapsackContainer;
|
||||
import tconstruct.util.player.KnapsackInventory;
|
||||
|
||||
public class KnapsackGui extends GuiContainer
|
||||
{
|
||||
public InventoryPlayer inv;
|
||||
public KnapsackInventory stats;
|
||||
|
||||
public KnapsackGui(InventoryPlayer inventoryplayer, KnapsackInventory holder)
|
||||
{
|
||||
super(new KnapsackContainer(inventoryplayer, holder));
|
||||
inv = inventoryplayer;
|
||||
stats = holder;
|
||||
}
|
||||
|
||||
public void initGui ()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
int cornerX = guiLeft;
|
||||
int cornerY = (this.height - this.ySize) / 2;
|
||||
this.buttonList.clear();
|
||||
|
||||
TabRegistry.updateTabValues(cornerX, cornerY, InventoryTabKnapsack.class);
|
||||
TabRegistry.addTabsToList(this.buttonList);
|
||||
|
||||
// InventoryTab tab = new InventoryTab(2, cornerX, cornerY - 28, new ItemStack(Block.workbench), 0);
|
||||
// this.buttonList.add(tab);
|
||||
// tab = new InventoryTab(3, cornerX + 28, cornerY - 28, new ItemStack(Item.plateDiamond), 1);
|
||||
// this.buttonList.add(tab);
|
||||
// tab = new InventoryTab(4, cornerX + 56, cornerY - 28, new ItemStack(TContent.knapsack), 1);
|
||||
// tab.enabled = false;
|
||||
// this.buttonList.add(tab);
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
||||
{
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("inventory.knapsack"), 8, 6, 0x404040);
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 4, 0x404040);
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/knapsack.png");
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer (float f, int i, int j)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(background);
|
||||
int cornerX = guiLeft;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
/*protected void keyTyped(char par1, int par2)
|
||||
{
|
||||
if (par2 == TControls.armorKey.keyCode)
|
||||
{
|
||||
this.mc.thePlayer.closeScreen();
|
||||
}
|
||||
|
||||
super.keyTyped(par1, par2);
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,904 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import tconstruct.inventory.ActiveContainer;
|
||||
import tconstruct.inventory.ActiveSlot;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class NewContainerGui extends GuiScreen
|
||||
{
|
||||
/** Stacks renderer. Icons, stack size, health, etc... */
|
||||
protected static RenderItem itemRenderer = new RenderItem();
|
||||
|
||||
/** The X/Y size of the inventory window in stretched pixels. */
|
||||
protected int xSize = 176;
|
||||
protected int ySize = 166;
|
||||
|
||||
/** A list of the players inventory slots. */
|
||||
public ActiveContainer container;
|
||||
|
||||
/**
|
||||
* Starting X/Y position for the Gui. Inconsistent use for Gui backgrounds.
|
||||
*/
|
||||
protected int guiLeft;
|
||||
protected int guiTop;
|
||||
|
||||
protected Slot mainSlot;
|
||||
|
||||
/** Used when touchscreen is enabled */
|
||||
protected Slot clickedSlot = null;
|
||||
protected boolean isRightMouseClick = false;
|
||||
protected ItemStack draggedStack = null;
|
||||
|
||||
protected int field_85049_r = 0;
|
||||
protected int field_85048_s = 0;
|
||||
protected Slot returningStackDestSlot = null;
|
||||
protected long returningStackTime = 0L;
|
||||
|
||||
/** Used when touchscreen is enabled */
|
||||
protected ItemStack returningStack = null;
|
||||
protected Slot field_92033_y = null;
|
||||
protected long field_92032_z = 0L;
|
||||
protected final Set field_94077_p = new HashSet();
|
||||
protected boolean field_94076_q;
|
||||
protected int field_94071_C = 0;
|
||||
protected int field_94067_D = 0;
|
||||
protected boolean field_94068_E = false;
|
||||
protected int field_94069_F;
|
||||
protected long field_94070_G = 0L;
|
||||
protected Slot field_94072_H = null;
|
||||
protected int field_94073_I = 0;
|
||||
protected boolean field_94074_J;
|
||||
protected ItemStack field_94075_K = null;
|
||||
|
||||
public NewContainerGui(ActiveContainer container)
|
||||
{
|
||||
this.container = container;
|
||||
this.field_94068_E = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the buttons (and other controls) to the screen in question.
|
||||
*/
|
||||
public void initGui ()
|
||||
{
|
||||
super.initGui();
|
||||
this.mc.thePlayer.openContainer = this.container;
|
||||
this.guiLeft = (this.width - this.xSize) / 2;
|
||||
this.guiTop = (this.height - this.ySize) / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the screen and all the components in it.
|
||||
*/
|
||||
public void drawScreen (int mouseX, int mouseY, float par3)
|
||||
{
|
||||
this.drawDefaultBackground();
|
||||
int gLeft = this.guiLeft;
|
||||
int gTop = this.guiTop;
|
||||
this.drawGuiContainerBackgroundLayer(par3, mouseX, mouseY);
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
super.drawScreen(mouseX, mouseY, par3);
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) gLeft, (float) gTop, 0.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
this.mainSlot = null;
|
||||
short short1 = 240;
|
||||
short short2 = 240;
|
||||
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) short1 / 1.0F, (float) short2 / 1.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int slotXPos;
|
||||
int slotYPos;
|
||||
|
||||
for (int slotIter = 0; slotIter < this.container.inventorySlots.size(); ++slotIter)
|
||||
{
|
||||
Slot slot = (Slot) this.container.inventorySlots.get(slotIter);
|
||||
if (!(slot instanceof ActiveSlot) || ((ActiveSlot) slot).getActive())
|
||||
{
|
||||
this.drawSlotInventory(slot);
|
||||
|
||||
if (this.isMouseOverSlot(slot, mouseX, mouseY))
|
||||
{
|
||||
this.mainSlot = slot;
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
slotXPos = slot.xDisplayPosition;
|
||||
slotYPos = slot.yDisplayPosition;
|
||||
this.drawGradientRect(slotXPos, slotYPos, slotXPos + 16, slotYPos + 16, -2130706433, -2130706433);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*for (int slotIter = 0; slotIter < this.container.otherInventorySlots.size(); ++slotIter)
|
||||
{
|
||||
ActiveSlot slot = (ActiveSlot) this.container.otherInventorySlots.get(slotIter);
|
||||
if (slot.getActive())
|
||||
{
|
||||
this.drawSlotInventory(slot);
|
||||
|
||||
if (this.isMouseOverSlot(slot, mouseX, mouseY))
|
||||
{
|
||||
this.mainSlot = slot;
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
slotXPos = slot.xDisplayPosition;
|
||||
slotYPos = slot.yDisplayPosition;
|
||||
this.drawGradientRect(slotXPos, slotYPos, slotXPos + 16, slotYPos + 16, -2130706433, -2130706433);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
this.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
InventoryPlayer inventoryplayer = this.mc.thePlayer.inventory;
|
||||
ItemStack itemstack = this.draggedStack == null ? inventoryplayer.getItemStack() : this.draggedStack;
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
byte b0 = 8;
|
||||
slotYPos = this.draggedStack == null ? 8 : 16;
|
||||
String s = null;
|
||||
|
||||
if (this.draggedStack != null && this.isRightMouseClick)
|
||||
{
|
||||
itemstack = itemstack.copy();
|
||||
itemstack.stackSize = MathHelper.ceiling_float_int((float) itemstack.stackSize / 2.0F);
|
||||
}
|
||||
else if (this.field_94076_q && this.field_94077_p.size() > 1)
|
||||
{
|
||||
itemstack = itemstack.copy();
|
||||
itemstack.stackSize = this.field_94069_F;
|
||||
|
||||
if (itemstack.stackSize == 0)
|
||||
{
|
||||
s = "" + EnumChatFormatting.YELLOW + "0";
|
||||
}
|
||||
}
|
||||
|
||||
this.drawItemStack(itemstack, mouseX - gLeft - b0, mouseY - gTop - slotYPos, s);
|
||||
}
|
||||
|
||||
if (this.returningStack != null)
|
||||
{
|
||||
float f1 = (float) (Minecraft.getSystemTime() - this.returningStackTime) / 100.0F;
|
||||
|
||||
if (f1 >= 1.0F)
|
||||
{
|
||||
f1 = 1.0F;
|
||||
this.returningStack = null;
|
||||
}
|
||||
|
||||
slotXPos = this.returningStackDestSlot.xDisplayPosition - this.field_85049_r;
|
||||
slotYPos = this.returningStackDestSlot.yDisplayPosition - this.field_85048_s;
|
||||
int xPos = this.field_85049_r + (int) ((float) slotXPos * f1);
|
||||
int yPos = this.field_85048_s + (int) ((float) slotYPos * f1);
|
||||
this.drawItemStack(this.returningStack, xPos, yPos, (String) null);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (inventoryplayer.getItemStack() == null && this.mainSlot != null && this.mainSlot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = this.mainSlot.getStack();
|
||||
this.drawItemStackTooltip(itemstack1, mouseX, mouseY);
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
}
|
||||
|
||||
protected void drawItemStack (ItemStack par1ItemStack, int par2, int par3, String par4Str)
|
||||
{
|
||||
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
|
||||
this.zLevel = 200.0F;
|
||||
itemRenderer.zLevel = 200.0F;
|
||||
itemRenderer.renderItemAndEffectIntoGUI(this.fontRenderer, this.mc.renderEngine, par1ItemStack, par2, par3);
|
||||
itemRenderer.renderItemOverlayIntoGUI(this.fontRenderer, this.mc.renderEngine, par1ItemStack, par2, par3 - (this.draggedStack == null ? 0 : 8), par4Str);
|
||||
this.zLevel = 0.0F;
|
||||
itemRenderer.zLevel = 0.0F;
|
||||
}
|
||||
|
||||
protected void drawItemStackTooltip (ItemStack par1ItemStack, int par2, int par3)
|
||||
{
|
||||
List list = par1ItemStack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
|
||||
|
||||
for (int k = 0; k < list.size(); ++k)
|
||||
{
|
||||
if (k == 0)
|
||||
{
|
||||
list.set(k, "\u00a7" + Integer.toHexString(par1ItemStack.getRarity().rarityColor) + (String) list.get(k));
|
||||
}
|
||||
else
|
||||
{
|
||||
list.set(k, EnumChatFormatting.GRAY + (String) list.get(k));
|
||||
}
|
||||
}
|
||||
|
||||
this.func_102021_a(list, par2, par3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the text when mouse is over creative inventory tab. Params: current creative tab to be checked, current
|
||||
* mouse x position, current mouse y position.
|
||||
*/
|
||||
protected void drawCreativeTabHoveringText (String par1Str, int par2, int par3)
|
||||
{
|
||||
this.func_102021_a(Arrays.asList(new String[] { par1Str }), par2, par3);
|
||||
}
|
||||
|
||||
protected void func_102021_a (List par1List, int par2, int par3)
|
||||
{
|
||||
if (!par1List.isEmpty())
|
||||
{
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
int k = 0;
|
||||
Iterator iterator = par1List.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
String s = (String) iterator.next();
|
||||
int l = this.fontRenderer.getStringWidth(s);
|
||||
|
||||
if (l > k)
|
||||
{
|
||||
k = l;
|
||||
}
|
||||
}
|
||||
|
||||
int i1 = par2 + 12;
|
||||
int j1 = par3 - 12;
|
||||
int k1 = 8;
|
||||
|
||||
if (par1List.size() > 1)
|
||||
{
|
||||
k1 += 2 + (par1List.size() - 1) * 10;
|
||||
}
|
||||
|
||||
if (i1 + k > this.width)
|
||||
{
|
||||
i1 -= 28 + k;
|
||||
}
|
||||
|
||||
if (j1 + k1 + 6 > this.height)
|
||||
{
|
||||
j1 = this.height - k1 - 6;
|
||||
}
|
||||
|
||||
this.zLevel = 300.0F;
|
||||
itemRenderer.zLevel = 300.0F;
|
||||
int l1 = -267386864;
|
||||
this.drawGradientRect(i1 - 3, j1 - 4, i1 + k + 3, j1 - 3, l1, l1);
|
||||
this.drawGradientRect(i1 - 3, j1 + k1 + 3, i1 + k + 3, j1 + k1 + 4, l1, l1);
|
||||
this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 + k1 + 3, l1, l1);
|
||||
this.drawGradientRect(i1 - 4, j1 - 3, i1 - 3, j1 + k1 + 3, l1, l1);
|
||||
this.drawGradientRect(i1 + k + 3, j1 - 3, i1 + k + 4, j1 + k1 + 3, l1, l1);
|
||||
int i2 = 1347420415;
|
||||
int j2 = (i2 & 16711422) >> 1 | i2 & -16777216;
|
||||
this.drawGradientRect(i1 - 3, j1 - 3 + 1, i1 - 3 + 1, j1 + k1 + 3 - 1, i2, j2);
|
||||
this.drawGradientRect(i1 + k + 2, j1 - 3 + 1, i1 + k + 3, j1 + k1 + 3 - 1, i2, j2);
|
||||
this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2);
|
||||
this.drawGradientRect(i1 - 3, j1 + k1 + 2, i1 + k + 3, j1 + k1 + 3, j2, j2);
|
||||
|
||||
for (int k2 = 0; k2 < par1List.size(); ++k2)
|
||||
{
|
||||
String s1 = (String) par1List.get(k2);
|
||||
this.fontRenderer.drawStringWithShadow(s1, i1, j1, -1);
|
||||
|
||||
if (k2 == 0)
|
||||
{
|
||||
j1 += 2;
|
||||
}
|
||||
|
||||
j1 += 10;
|
||||
}
|
||||
|
||||
this.zLevel = 0.0F;
|
||||
itemRenderer.zLevel = 0.0F;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the background layer for the GuiContainer (everything behind the items)
|
||||
*/
|
||||
protected abstract void drawGuiContainerBackgroundLayer (float f, int i, int j);
|
||||
|
||||
/**
|
||||
* Draws an inventory slot
|
||||
*/
|
||||
protected void drawSlotInventory (Slot par1Slot)
|
||||
{
|
||||
int i = par1Slot.xDisplayPosition;
|
||||
int j = par1Slot.yDisplayPosition;
|
||||
ItemStack itemstack = par1Slot.getStack();
|
||||
boolean flag = false;
|
||||
boolean flag1 = par1Slot == this.clickedSlot && this.draggedStack != null && !this.isRightMouseClick;
|
||||
ItemStack itemstack1 = this.mc.thePlayer.inventory.getItemStack();
|
||||
String s = null;
|
||||
|
||||
if (par1Slot == this.clickedSlot && this.draggedStack != null && this.isRightMouseClick && itemstack != null)
|
||||
{
|
||||
itemstack = itemstack.copy();
|
||||
itemstack.stackSize /= 2;
|
||||
}
|
||||
else if (this.field_94076_q && this.field_94077_p.contains(par1Slot) && itemstack1 != null)
|
||||
{
|
||||
if (this.field_94077_p.size() == 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Container.func_94527_a(par1Slot, itemstack1, true) && this.container.canDragIntoSlot(par1Slot))
|
||||
{
|
||||
itemstack = itemstack1.copy();
|
||||
flag = true;
|
||||
Container.func_94525_a(this.field_94077_p, this.field_94071_C, itemstack, par1Slot.getStack() == null ? 0 : par1Slot.getStack().stackSize);
|
||||
|
||||
if (itemstack.stackSize > itemstack.getMaxStackSize())
|
||||
{
|
||||
s = EnumChatFormatting.YELLOW + "" + itemstack.getMaxStackSize();
|
||||
itemstack.stackSize = itemstack.getMaxStackSize();
|
||||
}
|
||||
|
||||
if (itemstack.stackSize > par1Slot.getSlotStackLimit())
|
||||
{
|
||||
s = EnumChatFormatting.YELLOW + "" + par1Slot.getSlotStackLimit();
|
||||
itemstack.stackSize = par1Slot.getSlotStackLimit();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.field_94077_p.remove(par1Slot);
|
||||
this.func_94066_g();
|
||||
}
|
||||
}
|
||||
|
||||
this.zLevel = 100.0F;
|
||||
itemRenderer.zLevel = 100.0F;
|
||||
|
||||
if (itemstack == null)
|
||||
{
|
||||
Icon icon = par1Slot.getBackgroundIconIndex();
|
||||
|
||||
if (icon != null)
|
||||
{
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
this.mc.getTextureManager().bindTexture(TextureMap.locationItemsTexture);
|
||||
this.drawTexturedModelRectFromIcon(i, j, icon, 16, 16);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
flag1 = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag1)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
drawRect(i, j, i + 16, j + 16, -2130706433);
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
itemRenderer.renderItemAndEffectIntoGUI(this.fontRenderer, this.mc.renderEngine, itemstack, i, j);
|
||||
itemRenderer.renderItemOverlayIntoGUI(this.fontRenderer, this.mc.renderEngine, itemstack, i, j, s);
|
||||
}
|
||||
|
||||
itemRenderer.zLevel = 0.0F;
|
||||
this.zLevel = 0.0F;
|
||||
}
|
||||
|
||||
protected void func_94066_g ()
|
||||
{
|
||||
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
|
||||
|
||||
if (itemstack != null && this.field_94076_q)
|
||||
{
|
||||
this.field_94069_F = itemstack.stackSize;
|
||||
ItemStack itemstack1;
|
||||
int i;
|
||||
|
||||
for (Iterator iterator = this.field_94077_p.iterator(); iterator.hasNext(); this.field_94069_F -= itemstack1.stackSize - i)
|
||||
{
|
||||
Slot slot = (Slot) iterator.next();
|
||||
itemstack1 = itemstack.copy();
|
||||
i = slot.getStack() == null ? 0 : slot.getStack().stackSize;
|
||||
Container.func_94525_a(this.field_94077_p, this.field_94071_C, itemstack1, i);
|
||||
|
||||
if (itemstack1.stackSize > itemstack1.getMaxStackSize())
|
||||
{
|
||||
itemstack1.stackSize = itemstack1.getMaxStackSize();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize > slot.getSlotStackLimit())
|
||||
{
|
||||
itemstack1.stackSize = slot.getSlotStackLimit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the slot at the given coordinates or null if there is none.
|
||||
*/
|
||||
protected Slot getSlotAtPosition (int mouseX, int mouseY)
|
||||
{
|
||||
for (int k = 0; k < this.container.inventorySlots.size(); ++k)
|
||||
{
|
||||
Slot slot = (Slot) this.container.inventorySlots.get(k);
|
||||
|
||||
if (this.isMouseOverSlot(slot, mouseX, mouseY))
|
||||
{
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the mouse is clicked.
|
||||
*/
|
||||
protected void mouseClicked (int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
boolean flag = mouseButton == this.mc.gameSettings.keyBindPickBlock.keyCode + 100;
|
||||
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
|
||||
long l = Minecraft.getSystemTime();
|
||||
this.field_94074_J = this.field_94072_H == slot && l - this.field_94070_G < 250L && this.field_94073_I == mouseButton;
|
||||
this.field_94068_E = false;
|
||||
|
||||
if (mouseButton == 0 || mouseButton == 1 || flag)
|
||||
{
|
||||
int gLeft = this.guiLeft;
|
||||
int gTop = this.guiTop;
|
||||
boolean flag1 = mouseX < gLeft || mouseY < gTop || mouseX >= gLeft + this.xSize || mouseY >= gTop + this.ySize;
|
||||
int k1 = -1;
|
||||
|
||||
if (slot != null)
|
||||
{
|
||||
k1 = slot.slotNumber;
|
||||
}
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
k1 = -999;
|
||||
}
|
||||
|
||||
if (this.mc.gameSettings.touchscreen && flag1 && this.mc.thePlayer.inventory.getItemStack() == null)
|
||||
{
|
||||
this.mc.displayGuiScreen((GuiScreen) null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (k1 != -1)
|
||||
{
|
||||
if (this.mc.gameSettings.touchscreen)
|
||||
{
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
this.clickedSlot = slot;
|
||||
this.draggedStack = null;
|
||||
this.isRightMouseClick = mouseButton == 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.clickedSlot = null;
|
||||
}
|
||||
}
|
||||
else if (!this.field_94076_q)
|
||||
{
|
||||
if (this.mc.thePlayer.inventory.getItemStack() == null)
|
||||
{
|
||||
if (mouseButton == this.mc.gameSettings.keyBindPickBlock.keyCode + 100)
|
||||
{
|
||||
this.handleMouseClick(slot, k1, mouseButton, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean flag2 = k1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54));
|
||||
byte b0 = 0;
|
||||
|
||||
if (flag2)
|
||||
{
|
||||
this.field_94075_K = slot != null && slot.getHasStack() ? slot.getStack() : null;
|
||||
b0 = 1;
|
||||
}
|
||||
else if (k1 == -999)
|
||||
{
|
||||
b0 = 4;
|
||||
}
|
||||
|
||||
this.handleMouseClick(slot, k1, mouseButton, b0);
|
||||
}
|
||||
|
||||
this.field_94068_E = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.field_94076_q = true;
|
||||
this.field_94067_D = mouseButton;
|
||||
this.field_94077_p.clear();
|
||||
|
||||
if (mouseButton == 0)
|
||||
{
|
||||
this.field_94071_C = 0;
|
||||
}
|
||||
else if (mouseButton == 1)
|
||||
{
|
||||
this.field_94071_C = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.field_94072_H = slot;
|
||||
this.field_94070_G = l;
|
||||
this.field_94073_I = mouseButton;
|
||||
}
|
||||
|
||||
protected void func_85041_a (int par1, int par2, int par3, long par4)
|
||||
{
|
||||
Slot slot = this.getSlotAtPosition(par1, par2);
|
||||
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
|
||||
|
||||
if (this.clickedSlot != null && this.mc.gameSettings.touchscreen)
|
||||
{
|
||||
if (par3 == 0 || par3 == 1)
|
||||
{
|
||||
if (this.draggedStack == null)
|
||||
{
|
||||
if (slot != this.clickedSlot)
|
||||
{
|
||||
this.draggedStack = this.clickedSlot.getStack().copy();
|
||||
}
|
||||
}
|
||||
else if (this.draggedStack.stackSize > 1 && slot != null && Container.func_94527_a(slot, this.draggedStack, false))
|
||||
{
|
||||
long i1 = Minecraft.getSystemTime();
|
||||
|
||||
if (this.field_92033_y == slot)
|
||||
{
|
||||
if (i1 - this.field_92032_z > 500L)
|
||||
{
|
||||
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0);
|
||||
this.handleMouseClick(slot, slot.slotNumber, 1, 0);
|
||||
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0);
|
||||
this.field_92032_z = i1 + 750L;
|
||||
--this.draggedStack.stackSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.field_92033_y = slot;
|
||||
this.field_92032_z = i1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this.field_94076_q && slot != null && itemstack != null && itemstack.stackSize > this.field_94077_p.size() && Container.func_94527_a(slot, itemstack, true)
|
||||
&& slot.isItemValid(itemstack) && this.container.canDragIntoSlot(slot))
|
||||
{
|
||||
this.field_94077_p.add(slot);
|
||||
this.func_94066_g();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the mouse is moved or a mouse button is released. Signature: (mouseX, mouseY, which) which==-1 is
|
||||
* mouseMove, which==0 or which==1 is mouseUp
|
||||
*/
|
||||
protected void mouseMovedOrUp (int par1, int par2, int par3)
|
||||
{
|
||||
Slot slot = this.getSlotAtPosition(par1, par2);
|
||||
int l = this.guiLeft;
|
||||
int i1 = this.guiTop;
|
||||
boolean flag = par1 < l || par2 < i1 || par1 >= l + this.xSize || par2 >= i1 + this.ySize;
|
||||
int j1 = -1;
|
||||
|
||||
if (slot != null)
|
||||
{
|
||||
j1 = slot.slotNumber;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
j1 = -999;
|
||||
}
|
||||
|
||||
Slot slot1;
|
||||
Iterator iterator;
|
||||
|
||||
if (this.field_94074_J && slot != null && par3 == 0 && this.container.func_94530_a((ItemStack) null, slot))
|
||||
{
|
||||
if (isShiftKeyDown())
|
||||
{
|
||||
if (slot != null && slot.inventory != null && this.field_94075_K != null)
|
||||
{
|
||||
iterator = this.container.inventorySlots.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
slot1 = (Slot) iterator.next();
|
||||
|
||||
if (slot1 != null && slot1.canTakeStack(this.mc.thePlayer) && slot1.getHasStack() && slot1.inventory == slot.inventory
|
||||
&& Container.func_94527_a(slot1, this.field_94075_K, true))
|
||||
{
|
||||
this.handleMouseClick(slot1, slot1.slotNumber, par3, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.handleMouseClick(slot, j1, par3, 6);
|
||||
}
|
||||
|
||||
this.field_94074_J = false;
|
||||
this.field_94070_G = 0L;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.field_94076_q && this.field_94067_D != par3)
|
||||
{
|
||||
this.field_94076_q = false;
|
||||
this.field_94077_p.clear();
|
||||
this.field_94068_E = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.field_94068_E)
|
||||
{
|
||||
this.field_94068_E = false;
|
||||
return;
|
||||
}
|
||||
|
||||
boolean flag1;
|
||||
|
||||
if (this.clickedSlot != null && this.mc.gameSettings.touchscreen)
|
||||
{
|
||||
if (par3 == 0 || par3 == 1)
|
||||
{
|
||||
if (this.draggedStack == null && slot != this.clickedSlot)
|
||||
{
|
||||
this.draggedStack = this.clickedSlot.getStack();
|
||||
}
|
||||
|
||||
flag1 = Container.func_94527_a(slot, this.draggedStack, false);
|
||||
|
||||
if (j1 != -1 && this.draggedStack != null && flag1)
|
||||
{
|
||||
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, par3, 0);
|
||||
this.handleMouseClick(slot, j1, 0, 0);
|
||||
|
||||
if (this.mc.thePlayer.inventory.getItemStack() != null)
|
||||
{
|
||||
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, par3, 0);
|
||||
this.field_85049_r = par1 - l;
|
||||
this.field_85048_s = par2 - i1;
|
||||
this.returningStackDestSlot = this.clickedSlot;
|
||||
this.returningStack = this.draggedStack;
|
||||
this.returningStackTime = Minecraft.getSystemTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.returningStack = null;
|
||||
}
|
||||
}
|
||||
else if (this.draggedStack != null)
|
||||
{
|
||||
this.field_85049_r = par1 - l;
|
||||
this.field_85048_s = par2 - i1;
|
||||
this.returningStackDestSlot = this.clickedSlot;
|
||||
this.returningStack = this.draggedStack;
|
||||
this.returningStackTime = Minecraft.getSystemTime();
|
||||
}
|
||||
|
||||
this.draggedStack = null;
|
||||
this.clickedSlot = null;
|
||||
}
|
||||
}
|
||||
else if (this.field_94076_q && !this.field_94077_p.isEmpty())
|
||||
{
|
||||
this.handleMouseClick((Slot) null, -999, Container.func_94534_d(0, this.field_94071_C), 5);
|
||||
iterator = this.field_94077_p.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
slot1 = (Slot) iterator.next();
|
||||
this.handleMouseClick(slot1, slot1.slotNumber, Container.func_94534_d(1, this.field_94071_C), 5);
|
||||
}
|
||||
|
||||
this.handleMouseClick((Slot) null, -999, Container.func_94534_d(2, this.field_94071_C), 5);
|
||||
}
|
||||
else if (this.mc.thePlayer.inventory.getItemStack() != null)
|
||||
{
|
||||
if (par3 == this.mc.gameSettings.keyBindPickBlock.keyCode + 100)
|
||||
{
|
||||
this.handleMouseClick(slot, j1, par3, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
flag1 = j1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54));
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
this.field_94075_K = slot != null && slot.getHasStack() ? slot.getStack() : null;
|
||||
}
|
||||
|
||||
this.handleMouseClick(slot, j1, par3, flag1 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.mc.thePlayer.inventory.getItemStack() == null)
|
||||
{
|
||||
this.field_94070_G = 0L;
|
||||
}
|
||||
|
||||
this.field_94076_q = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the passed mouse position is over the specified slot.
|
||||
*/
|
||||
protected boolean isMouseOverSlot (Slot slot, int mouseX, int mouseY)
|
||||
{
|
||||
if (!(slot instanceof ActiveSlot) || ((ActiveSlot) slot).getActive())
|
||||
{
|
||||
return this.isPointInRegion(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mouseX, mouseY);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Args: left, top, width, height, pointX, pointY. Note: left, top are local to Gui, pointX, pointY are local to
|
||||
* screen
|
||||
*/
|
||||
protected boolean isPointInRegion (int par1, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
int k1 = this.guiLeft;
|
||||
int l1 = this.guiTop;
|
||||
par5 -= k1;
|
||||
par6 -= l1;
|
||||
return par5 >= par1 - 1 && par5 < par1 + par3 + 1 && par6 >= par2 - 1 && par6 < par2 + par4 + 1;
|
||||
}
|
||||
|
||||
protected void handleMouseClick (Slot par1Slot, int par2, int par3, int par4)
|
||||
{
|
||||
if (par1Slot != null)
|
||||
{
|
||||
par2 = par1Slot.slotNumber;
|
||||
}
|
||||
|
||||
this.mc.playerController.windowClick(this.container.windowId, par2, par3, par4, this.mc.thePlayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
|
||||
*/
|
||||
protected void keyTyped (char par1, int par2)
|
||||
{
|
||||
if (par2 == 1 || par2 == this.mc.gameSettings.keyBindInventory.keyCode)
|
||||
{
|
||||
this.mc.thePlayer.closeScreen();
|
||||
}
|
||||
|
||||
this.checkHotbarKeys(par2);
|
||||
|
||||
if (this.mainSlot != null && this.mainSlot.getHasStack())
|
||||
{
|
||||
if (par2 == this.mc.gameSettings.keyBindPickBlock.keyCode)
|
||||
{
|
||||
this.handleMouseClick(this.mainSlot, this.mainSlot.slotNumber, 0, 3);
|
||||
}
|
||||
else if (par2 == this.mc.gameSettings.keyBindDrop.keyCode)
|
||||
{
|
||||
this.handleMouseClick(this.mainSlot, this.mainSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is what controls the hotbar shortcut check when you press a number key when hovering a stack.
|
||||
*/
|
||||
protected boolean checkHotbarKeys (int par1)
|
||||
{
|
||||
if (this.mc.thePlayer.inventory.getItemStack() == null && this.mainSlot != null)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
if (par1 == 2 + j)
|
||||
{
|
||||
this.handleMouseClick(this.mainSlot, this.mainSlot.slotNumber, j, 2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the screen is unloaded. Used to disable keyboard repeat events
|
||||
*/
|
||||
public void onGuiClosed ()
|
||||
{
|
||||
if (this.mc.thePlayer != null)
|
||||
{
|
||||
this.container.onContainerClosed(this.mc.thePlayer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this GUI should pause the game when it is displayed in single-player
|
||||
*/
|
||||
public boolean doesGuiPauseGame ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the main game loop to update the screen.
|
||||
*/
|
||||
public void updateScreen ()
|
||||
{
|
||||
super.updateScreen();
|
||||
|
||||
if (!this.mc.thePlayer.isEntityAlive() || this.mc.thePlayer.isDead)
|
||||
{
|
||||
this.mc.thePlayer.closeScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,299 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.blocks.logic.PartBuilderLogic;
|
||||
import tconstruct.inventory.ActiveContainer;
|
||||
import tconstruct.inventory.PartCrafterChestContainer;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.library.tools.ToolMaterial;
|
||||
|
||||
public class PartCrafterGui extends NewContainerGui
|
||||
{
|
||||
PartBuilderLogic logic;
|
||||
String title, otherTitle = "";
|
||||
boolean drawChestPart;
|
||||
boolean hasTop, hasBottom;
|
||||
ItemStack topMaterial, bottomMaterial;
|
||||
ToolMaterial topEnum, bottomEnum;
|
||||
|
||||
public PartCrafterGui(InventoryPlayer inventoryplayer, PartBuilderLogic partlogic, World world, int x, int y, int z)
|
||||
{
|
||||
super((ActiveContainer) partlogic.getGuiContainer(inventoryplayer, world, x, y, z));
|
||||
logic = partlogic;
|
||||
drawChestPart = container instanceof PartCrafterChestContainer;
|
||||
|
||||
title = "\u00A7nTool Part Crafting";
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
||||
{
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("crafters.PartBuilder"), 6, 6, 4210752);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
if (drawChestPart)
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("inventory.PatternChest"), -108, this.ySize - 148, 4210752);
|
||||
|
||||
drawMaterialInformation();
|
||||
}
|
||||
|
||||
void drawDefaultInformation ()
|
||||
{
|
||||
title = "\u00A7nTool Part Building";
|
||||
this.drawCenteredString(fontRenderer, title, xSize + 63, 8, 16777215);
|
||||
fontRenderer.drawSplitString("Place a pattern and a material on the left to get started.", xSize + 8, 24, 115, 16777215);
|
||||
}
|
||||
|
||||
void drawMaterialInformation ()
|
||||
{
|
||||
ItemStack top = logic.getStackInSlot(2);
|
||||
//ItemStack topResult = logic.getStackInSlot(4);
|
||||
ItemStack bottom = logic.getStackInSlot(3);
|
||||
//ItemStack bottomResult = logic.getStackInSlot(6);
|
||||
if (topMaterial != top)
|
||||
{
|
||||
topMaterial = top;
|
||||
int topID = PatternBuilder.instance.getPartID(top);
|
||||
|
||||
if (topID != Short.MAX_VALUE)// && topResult != null)
|
||||
{
|
||||
topEnum = TConstructRegistry.getMaterial(topID);
|
||||
hasTop = true;
|
||||
title = "\u00A7n" + topEnum.name();
|
||||
}
|
||||
else
|
||||
hasTop = false;
|
||||
}
|
||||
|
||||
if (bottomMaterial != bottom)
|
||||
{
|
||||
bottomMaterial = bottom;
|
||||
int bottomID = PatternBuilder.instance.getPartID(bottom);
|
||||
|
||||
if (bottomID != Short.MAX_VALUE)// && bottomResult != null)
|
||||
{
|
||||
bottomEnum = TConstructRegistry.getMaterial(bottomID);
|
||||
hasBottom = true;
|
||||
otherTitle = "\u00A7n" + bottomEnum.name();
|
||||
}
|
||||
else
|
||||
hasBottom = false;
|
||||
}
|
||||
|
||||
int offset = 8;
|
||||
if (hasTop)
|
||||
{
|
||||
this.drawCenteredString(fontRenderer, title, xSize + 63, offset, 16777215);
|
||||
this.fontRenderer.drawString("Base Durability: " + topEnum.durability(), xSize + 8, offset + 16, 16777215);
|
||||
this.fontRenderer.drawString("Handle Modifier: " + topEnum.handleDurability() + "x", xSize + 8, offset + 27, 16777215);
|
||||
this.fontRenderer.drawString("Mining Speed: " + topEnum.toolSpeed() / 100f, xSize + 8, offset + 38, 16777215);
|
||||
this.fontRenderer.drawString("Mining Level: " + getHarvestLevelName(topEnum.harvestLevel()), xSize + 8, offset + 49, 16777215);
|
||||
|
||||
int attack = topEnum.attack();
|
||||
String heart = attack == 2 ? " Heart" : " Hearts";
|
||||
if (attack % 2 == 0)
|
||||
this.fontRenderer.drawString("Attack: " + attack / 2 + heart, xSize + 8, offset + 60, 0xffffff);
|
||||
else
|
||||
this.fontRenderer.drawString("Attack: " + attack / 2f + heart, xSize + 8, offset + 60, 0xffffff);
|
||||
}
|
||||
|
||||
offset = 90;
|
||||
if (hasBottom)
|
||||
{
|
||||
this.drawCenteredString(fontRenderer, otherTitle, xSize + 63, offset, 16777215);
|
||||
this.fontRenderer.drawString("Base Durability: " + bottomEnum.durability(), xSize + 8, offset + 16, 16777215);
|
||||
this.fontRenderer.drawString("Handle Modifier: " + bottomEnum.handleDurability() + "x", xSize + 8, offset + 27, 16777215);
|
||||
this.fontRenderer.drawString("Mining Speed: " + bottomEnum.toolSpeed() / 100f, xSize + 8, offset + 38, 16777215);
|
||||
this.fontRenderer.drawString("Mining Level: " + getHarvestLevelName(bottomEnum.harvestLevel()), xSize + 8, offset + 49, 16777215);
|
||||
int attack = bottomEnum.attack();
|
||||
String heart = attack == 2 ? " Heart" : " Hearts";
|
||||
if (attack % 2 == 0)
|
||||
this.fontRenderer.drawString("Attack: " + attack / 2 + heart, xSize + 8, offset + 60, 0xffffff);
|
||||
else
|
||||
this.fontRenderer.drawString("Attack: " + attack / 2f + heart, xSize + 8, offset + 60, 0xffffff);
|
||||
}
|
||||
|
||||
if (!hasTop && !hasBottom)
|
||||
drawDefaultInformation();
|
||||
}
|
||||
|
||||
public static String getHarvestLevelName (int num)
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
case 0:
|
||||
return "Stone";
|
||||
case 1:
|
||||
return "Iron";
|
||||
case 2:
|
||||
return "Redstone";
|
||||
case 3:
|
||||
return "Obsidian";
|
||||
case 4:
|
||||
return "Cobalt";
|
||||
case 5:
|
||||
return "Manyullyn";
|
||||
default:
|
||||
return String.valueOf(num);
|
||||
}
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/toolparts.png");
|
||||
private static final ResourceLocation minichest = new ResourceLocation("tinker", "textures/gui/patternchestmini.png");
|
||||
private static final ResourceLocation description = new ResourceLocation("tinker", "textures/gui/description.png");
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
|
||||
{
|
||||
// Draw the background
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(background);
|
||||
int cornerX = (this.width - this.xSize) / 2;
|
||||
int cornerY = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
// Draw Slots
|
||||
this.drawTexturedModalRect(cornerX + 39, cornerY + 26, 0, 166, 98, 36);
|
||||
if (!logic.isStackInSlot(0))
|
||||
{
|
||||
this.drawTexturedModalRect(cornerX + 39, cornerY + 26, 176, 0, 18, 18);
|
||||
}
|
||||
if (!logic.isStackInSlot(2))
|
||||
{
|
||||
this.drawTexturedModalRect(cornerX + 57, cornerY + 26, 176, 18, 18, 18);
|
||||
}
|
||||
if (!logic.isStackInSlot(1))
|
||||
{
|
||||
this.drawTexturedModalRect(cornerX + 39, cornerY + 44, 176, 0, 18, 18);
|
||||
}
|
||||
if (!logic.isStackInSlot(3))
|
||||
{
|
||||
this.drawTexturedModalRect(cornerX + 57, cornerY + 44, 176, 36, 18, 18);
|
||||
}
|
||||
|
||||
// Draw chest
|
||||
if (drawChestPart)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(minichest);
|
||||
this.drawTexturedModalRect(cornerX - 116, cornerY + 11, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
|
||||
// Draw description
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(description);
|
||||
cornerX = (this.width + this.xSize) / 2;
|
||||
cornerY = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(cornerX, cornerY, 126, 0, 126, this.ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked (int mouseX, int mouseY, int clickNum)
|
||||
{
|
||||
boolean flag = clickNum == this.mc.gameSettings.keyBindPickBlock.keyCode + 100;
|
||||
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
|
||||
long l = Minecraft.getSystemTime();
|
||||
this.field_94074_J = this.field_94072_H == slot && l - this.field_94070_G < 250L && this.field_94073_I == clickNum;
|
||||
this.field_94068_E = false;
|
||||
|
||||
int offsetLeft = drawChestPart ? 108 : 0;
|
||||
|
||||
if (clickNum == 0 || clickNum == 1 || flag)
|
||||
{
|
||||
int i1 = this.guiLeft;
|
||||
int j1 = this.guiTop;
|
||||
boolean flag1 = mouseX < i1 - offsetLeft || mouseY < j1 || mouseX >= i1 + this.xSize || mouseY >= j1 + this.ySize;
|
||||
int k1 = -1;
|
||||
|
||||
if (slot != null)
|
||||
{
|
||||
k1 = slot.slotNumber;
|
||||
}
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
k1 = -999;
|
||||
}
|
||||
|
||||
if (this.mc.gameSettings.touchscreen && flag1 && this.mc.thePlayer.inventory.getItemStack() == null)
|
||||
{
|
||||
this.mc.displayGuiScreen((GuiScreen) null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (k1 != -1)
|
||||
{
|
||||
if (this.mc.gameSettings.touchscreen)
|
||||
{
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
this.clickedSlot = slot;
|
||||
this.draggedStack = null;
|
||||
this.isRightMouseClick = clickNum == 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.clickedSlot = null;
|
||||
}
|
||||
}
|
||||
else if (!this.field_94076_q)
|
||||
{
|
||||
if (this.mc.thePlayer.inventory.getItemStack() == null)
|
||||
{
|
||||
if (clickNum == this.mc.gameSettings.keyBindPickBlock.keyCode + 100)
|
||||
{
|
||||
this.handleMouseClick(slot, k1, clickNum, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean flag2 = k1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54));
|
||||
byte b0 = 0;
|
||||
|
||||
if (flag2)
|
||||
{
|
||||
this.field_94075_K = slot != null && slot.getHasStack() ? slot.getStack() : null;
|
||||
b0 = 1;
|
||||
}
|
||||
else if (k1 == -999)
|
||||
{
|
||||
b0 = 4;
|
||||
}
|
||||
|
||||
this.handleMouseClick(slot, k1, clickNum, b0);
|
||||
}
|
||||
|
||||
this.field_94068_E = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.field_94076_q = true;
|
||||
this.field_94067_D = clickNum;
|
||||
this.field_94077_p.clear();
|
||||
|
||||
if (clickNum == 0)
|
||||
{
|
||||
this.field_94071_C = 0;
|
||||
}
|
||||
else if (clickNum == 1)
|
||||
{
|
||||
this.field_94071_C = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.field_94072_H = slot;
|
||||
this.field_94070_G = l;
|
||||
this.field_94073_I = clickNum;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.blocks.logic.PatternChestLogic;
|
||||
|
||||
public class PatternChestGui extends GuiContainer
|
||||
{
|
||||
public PatternChestLogic logic;
|
||||
|
||||
public PatternChestGui(InventoryPlayer inventoryplayer, PatternChestLogic holder, World world, int x, int y, int z)
|
||||
{
|
||||
super(holder.getGuiContainer(inventoryplayer, world, x, y, z));
|
||||
logic = holder;
|
||||
xSize = 194;
|
||||
ySize = 168;
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
||||
{
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("inventory.PatternChest"), 60, 6, 0x404040);
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 17, (ySize - 96) + 2, 0x404040);
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/patternchest.png");
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer (float f, int i, int j)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(background);
|
||||
int cornerX = (width - xSize) / 2;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,483 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.*;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.*;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.SmelteryLogic;
|
||||
import tconstruct.inventory.*;
|
||||
|
||||
public class SmelteryGui extends NewContainerGui
|
||||
{
|
||||
public SmelteryLogic logic;
|
||||
String username;
|
||||
boolean isScrolling = false;
|
||||
boolean wasClicking;
|
||||
float currentScroll = 0.0F;
|
||||
int slotPos = 0;
|
||||
int prevSlotPos = 0;
|
||||
|
||||
public SmelteryGui(InventoryPlayer inventoryplayer, SmelteryLogic smeltery, World world, int x, int y, int z)
|
||||
{
|
||||
super((ActiveContainer) smeltery.getGuiContainer(inventoryplayer, world, x, y, z));
|
||||
logic = smeltery;
|
||||
username = inventoryplayer.player.username;
|
||||
xSize = 248;
|
||||
smeltery.updateFuelDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen (int mouseX, int mouseY, float par3)
|
||||
{
|
||||
super.drawScreen(mouseX, mouseY, par3);
|
||||
updateScrollbar(mouseX, mouseY, par3);
|
||||
}
|
||||
|
||||
protected void updateScrollbar (int mouseX, int mouseY, float par3)
|
||||
{
|
||||
if (logic.layers > 2)
|
||||
{
|
||||
boolean mouseDown = Mouse.isButtonDown(0);
|
||||
int lefto = this.guiLeft;
|
||||
int topo = this.guiTop;
|
||||
int xScroll = lefto + 67;
|
||||
int yScroll = topo + 8;
|
||||
int scrollWidth = xScroll + 14;
|
||||
int scrollHeight = yScroll + 144;
|
||||
|
||||
if (!this.wasClicking && mouseDown && mouseX >= xScroll && mouseY >= yScroll && mouseX < scrollWidth && mouseY < scrollHeight)
|
||||
{
|
||||
this.isScrolling = true;
|
||||
}
|
||||
|
||||
if (!mouseDown)
|
||||
{
|
||||
this.isScrolling = false;
|
||||
}
|
||||
|
||||
if (wasClicking && !isScrolling && slotPos != prevSlotPos)
|
||||
{
|
||||
prevSlotPos = slotPos;
|
||||
}
|
||||
|
||||
this.wasClicking = mouseDown;
|
||||
|
||||
if (this.isScrolling)
|
||||
{
|
||||
this.currentScroll = (mouseY - yScroll - 7.5F) / (scrollHeight - yScroll - 15.0F);
|
||||
|
||||
if (this.currentScroll < 0.0F)
|
||||
{
|
||||
this.currentScroll = 0.0F;
|
||||
}
|
||||
|
||||
if (this.currentScroll > 1.0F)
|
||||
{
|
||||
this.currentScroll = 1.0F;
|
||||
}
|
||||
|
||||
int s = ((SmelteryContainer) this.container).scrollTo(this.currentScroll);
|
||||
if (s != -1)
|
||||
slotPos = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer (int mouseX, int mouseY)
|
||||
{
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("crafters.Smeltery"), 86, 5, 0x404040);
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 90, (ySize - 96) + 2, 0x404040);
|
||||
|
||||
int base = 0;
|
||||
int cornerX = (width - xSize) / 2 + 36;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
|
||||
for (FluidStack liquid : logic.moltenMetal)
|
||||
{
|
||||
int basePos = 54;
|
||||
int initialLiquidSize = 0;
|
||||
int liquidSize = 0;//liquid.amount * 52 / liquidLayers;
|
||||
if (logic.getCapacity() > 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;
|
||||
}
|
||||
}
|
||||
|
||||
int leftX = cornerX + basePos;
|
||||
int topY = (cornerY + 68) - base;
|
||||
int sizeX = 52;
|
||||
int sizeY = liquidSize;
|
||||
if (mouseX >= leftX && mouseX <= leftX + sizeX && mouseY >= topY && mouseY < topY + sizeY)
|
||||
{
|
||||
drawFluidStackTooltip(liquid, mouseX - cornerX + 36, mouseY - cornerY);
|
||||
|
||||
}
|
||||
}
|
||||
if (logic.fuelGague > 0)
|
||||
{
|
||||
int leftX = cornerX + 117;
|
||||
int topY = (cornerY + 68) - logic.getScaledFuelGague(52);
|
||||
int sizeX = 12;
|
||||
int sizeY = logic.getScaledFuelGague(52);
|
||||
if (mouseX >= leftX && mouseX <= leftX + sizeX && mouseY >= topY && mouseY < topY + sizeY)
|
||||
{
|
||||
drawFluidStackTooltip(new FluidStack(-37, logic.fuelAmount), mouseX - cornerX + 36, mouseY - cornerY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/smeltery.png");
|
||||
private static final ResourceLocation backgroundSide = new ResourceLocation("tinker", "textures/gui/smelteryside.png");
|
||||
private static final ResourceLocation terrain = new ResourceLocation("terrain.png");
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer (float f, int mouseX, int mouseY)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(background);
|
||||
int cornerX = (width - xSize) / 2 + 36;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
drawTexturedModalRect(cornerX + 46, cornerY, 0, 0, 176, ySize);
|
||||
|
||||
//Fuel - Lava
|
||||
this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
if (logic.fuelGague > 0)
|
||||
{
|
||||
Icon lavaIcon = Block.lavaStill.getIcon(0, 0);
|
||||
int fuel = logic.getScaledFuelGague(52);
|
||||
int count = 0;
|
||||
while (fuel > 0)
|
||||
{
|
||||
int size = fuel >= 16 ? 16 : fuel;
|
||||
fuel -= size;
|
||||
drawLiquidRect(cornerX + 117, (cornerY + 68) - size - 16 * count, lavaIcon, 12, size);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
//Liquids - molten metal
|
||||
int base = 0;
|
||||
for (FluidStack liquid : logic.moltenMetal)
|
||||
{
|
||||
Icon renderIndex = liquid.getFluid().getStillIcon();
|
||||
int basePos = 54;
|
||||
if (logic.getCapacity() > 0)
|
||||
{
|
||||
int total = logic.getTotalLiquid();
|
||||
int liquidLayers = (total / 20000 + 1) * 20000;
|
||||
if (liquidLayers > 0)
|
||||
{
|
||||
int liquidSize = liquid.amount * 52 / liquidLayers;
|
||||
if (liquidSize == 0)
|
||||
liquidSize = 1;
|
||||
while (liquidSize > 0)
|
||||
{
|
||||
int size = liquidSize >= 16 ? 16 : liquidSize;
|
||||
if (renderIndex != null)
|
||||
{
|
||||
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);
|
||||
|
||||
this.mc.getTextureManager().bindTexture(background);
|
||||
drawTexturedModalRect(cornerX + 54, cornerY + 16, 176, 76, 52, 52);
|
||||
|
||||
//Side inventory
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(backgroundSide);
|
||||
if (logic.layers > 0)
|
||||
{
|
||||
if (logic.layers == 1)
|
||||
{
|
||||
drawTexturedModalRect(cornerX - 46, cornerY, 0, 0, 98, 43);
|
||||
drawTexturedModalRect(cornerX - 46, cornerY + 43, 0, 133, 98, 25);
|
||||
}
|
||||
else if (logic.layers == 2)
|
||||
{
|
||||
drawTexturedModalRect(cornerX - 46, cornerY, 0, 0, 98, 61);
|
||||
drawTexturedModalRect(cornerX - 46, cornerY + 61, 0, 97, 98, 61);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawTexturedModalRect(cornerX - 46, cornerY, 0, 0, 98, ySize - 8);
|
||||
}
|
||||
drawTexturedModalRect(cornerX + 32, (int) (cornerY + 8 + 127 * currentScroll), 98, 0, 12, 15);
|
||||
}
|
||||
|
||||
//Temperature
|
||||
int slotSize = logic.layers * 9;
|
||||
if (slotSize > 24)
|
||||
slotSize = 24;
|
||||
for (int iter = 0; iter < slotSize; iter++)
|
||||
{
|
||||
int slotTemp = logic.getTempForSlot(iter + slotPos * 3) - 20;
|
||||
int maxTemp = logic.getMeltingPointForSlot(iter + slotPos * 3) - 20;
|
||||
if (slotTemp > 0 && maxTemp > 0)
|
||||
{
|
||||
int size = 16 * slotTemp / maxTemp + 1;
|
||||
drawTexturedModalRect(cornerX - 38 + (iter % 3 * 22), cornerY + 8 + (iter / 3 * 18) + 16 - size, 98, 15 + 16 - size, 5, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawFluidStackTooltip (FluidStack par1ItemStack, int par2, int par3)
|
||||
{
|
||||
this.zLevel = 100;
|
||||
List list = getLiquidTooltip(par1ItemStack, this.mc.gameSettings.advancedItemTooltips);
|
||||
|
||||
for (int k = 0; k < list.size(); ++k)
|
||||
{
|
||||
list.set(k, EnumChatFormatting.GRAY + (String) list.get(k));
|
||||
}
|
||||
|
||||
this.drawToolTip(list, par2, par3);
|
||||
this.zLevel = 0;
|
||||
}
|
||||
|
||||
public List getLiquidTooltip (FluidStack liquid, boolean par2)
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
if (liquid.fluidID == -37)
|
||||
{
|
||||
list.add("\u00A7fFuel");
|
||||
list.add("mB: " + liquid.amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
String name = StatCollector.translateToLocal("fluid." + FluidRegistry.getFluidName(liquid));
|
||||
list.add("\u00A7f" + name);
|
||||
if (name.equals("Liquified Emerald"))
|
||||
{
|
||||
list.add("Emeralds: " + liquid.amount / 640f);
|
||||
}
|
||||
else if (name.equals("Molten Glass"))
|
||||
{
|
||||
int blocks = liquid.amount / 1000;
|
||||
if (blocks > 0)
|
||||
list.add("Blocks: " + blocks);
|
||||
int panels = (liquid.amount % 1000) / 250;
|
||||
if (panels > 0)
|
||||
list.add("Panels: " + panels);
|
||||
int mB = (liquid.amount % 1000) % 250;
|
||||
if (mB > 0)
|
||||
list.add("mB: " + mB);
|
||||
}
|
||||
else if (name.contains("Molten"))
|
||||
{
|
||||
int ingots = liquid.amount / TConstruct.ingotLiquidValue;
|
||||
if (ingots > 0)
|
||||
list.add("Ingots: " + ingots);
|
||||
int mB = liquid.amount % TConstruct.ingotLiquidValue;
|
||||
if (mB > 0)
|
||||
{
|
||||
int nuggets = mB / TConstruct.nuggetLiquidValue;
|
||||
int junk = (mB % TConstruct.nuggetLiquidValue);
|
||||
if (nuggets > 0)
|
||||
list.add("Nuggets: " + nuggets);
|
||||
if (junk > 0)
|
||||
list.add("mB: " + junk);
|
||||
}
|
||||
}
|
||||
else if (name.equals("Seared Stone"))
|
||||
{
|
||||
int ingots = liquid.amount / TConstruct.ingotLiquidValue;
|
||||
if (ingots > 0)
|
||||
list.add("Blocks: " + ingots);
|
||||
int mB = liquid.amount % TConstruct.ingotLiquidValue;
|
||||
if (mB > 0)
|
||||
list.add("mB: " + mB);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.add("mB: " + liquid.amount);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
protected void drawToolTip (List par1List, int par2, int par3)
|
||||
{
|
||||
if (!par1List.isEmpty())
|
||||
{
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
int k = 0;
|
||||
Iterator iterator = par1List.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
String s = (String) iterator.next();
|
||||
int l = this.fontRenderer.getStringWidth(s);
|
||||
|
||||
if (l > k)
|
||||
{
|
||||
k = l;
|
||||
}
|
||||
}
|
||||
|
||||
int i1 = par2 + 12;
|
||||
int j1 = par3 - 12;
|
||||
int k1 = 8;
|
||||
|
||||
if (par1List.size() > 1)
|
||||
{
|
||||
k1 += 2 + (par1List.size() - 1) * 10;
|
||||
}
|
||||
|
||||
if (i1 + k > this.width)
|
||||
{
|
||||
i1 -= 28 + k;
|
||||
}
|
||||
|
||||
if (j1 + k1 + 6 > this.height)
|
||||
{
|
||||
j1 = this.height - k1 - 6;
|
||||
}
|
||||
|
||||
this.zLevel = 300.0F;
|
||||
itemRenderer.zLevel = 300.0F;
|
||||
int l1 = -267386864;
|
||||
this.drawGradientRect(i1 - 3, j1 - 4, i1 + k + 3, j1 - 3, l1, l1);
|
||||
this.drawGradientRect(i1 - 3, j1 + k1 + 3, i1 + k + 3, j1 + k1 + 4, l1, l1);
|
||||
this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 + k1 + 3, l1, l1);
|
||||
this.drawGradientRect(i1 - 4, j1 - 3, i1 - 3, j1 + k1 + 3, l1, l1);
|
||||
this.drawGradientRect(i1 + k + 3, j1 - 3, i1 + k + 4, j1 + k1 + 3, l1, l1);
|
||||
int i2 = 1347420415;
|
||||
int j2 = (i2 & 16711422) >> 1 | i2 & -16777216;
|
||||
this.drawGradientRect(i1 - 3, j1 - 3 + 1, i1 - 3 + 1, j1 + k1 + 3 - 1, i2, j2);
|
||||
this.drawGradientRect(i1 + k + 2, j1 - 3 + 1, i1 + k + 3, j1 + k1 + 3 - 1, i2, j2);
|
||||
this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2);
|
||||
this.drawGradientRect(i1 - 3, j1 + k1 + 2, i1 + k + 3, j1 + k1 + 3, j2, j2);
|
||||
|
||||
for (int k2 = 0; k2 < par1List.size(); ++k2)
|
||||
{
|
||||
String s1 = (String) par1List.get(k2);
|
||||
this.fontRenderer.drawStringWithShadow(s1, i1, j1, -1);
|
||||
|
||||
if (k2 == 0)
|
||||
{
|
||||
j1 += 2;
|
||||
}
|
||||
|
||||
j1 += 10;
|
||||
}
|
||||
|
||||
this.zLevel = 0.0F;
|
||||
itemRenderer.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
public void drawLiquidRect (int startU, int startV, Icon par3Icon, int endU, int endV)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV(startU + 0, startV + endV, this.zLevel, par3Icon.getMinU(), par3Icon.getMaxV());//Bottom left
|
||||
tessellator.addVertexWithUV(startU + endU, startV + endV, this.zLevel, par3Icon.getMaxU(), par3Icon.getMaxV());//Bottom right
|
||||
tessellator.addVertexWithUV(startU + endU, startV + 0, this.zLevel, par3Icon.getMaxU(), par3Icon.getMinV());//Top right
|
||||
tessellator.addVertexWithUV(startU + 0, startV + 0, this.zLevel, par3Icon.getMinU(), par3Icon.getMinV()); //Top left
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked (int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
int base = 0;
|
||||
int cornerX = (width - xSize) / 2 + 36;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
int fluidToBeBroughtUp = -1;
|
||||
|
||||
for (FluidStack liquid : logic.moltenMetal)
|
||||
{
|
||||
int basePos = 54;
|
||||
int initialLiquidSize = 0;
|
||||
int liquidSize = 0;//liquid.amount * 52 / liquidLayers;
|
||||
if (logic.getCapacity() > 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;
|
||||
}
|
||||
}
|
||||
|
||||
int leftX = cornerX + basePos;
|
||||
int topY = (cornerY + 68) - base;
|
||||
int sizeX = 52;
|
||||
int sizeY = liquidSize;
|
||||
if (mouseX >= leftX && mouseX <= leftX + sizeX && mouseY >= topY && mouseY < topY + sizeY)
|
||||
{
|
||||
fluidToBeBroughtUp = liquid.fluidID;
|
||||
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(bos);
|
||||
|
||||
try
|
||||
{
|
||||
dos.write(11);
|
||||
|
||||
dos.writeInt(logic.worldObj.provider.dimensionId);
|
||||
dos.writeInt(logic.xCoord);
|
||||
dos.writeInt(logic.yCoord);
|
||||
dos.writeInt(logic.zCoord);
|
||||
|
||||
dos.writeBoolean(this.isShiftKeyDown());
|
||||
|
||||
dos.writeInt(fluidToBeBroughtUp);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
packet.channel = "TConstruct";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
|
||||
PacketDispatcher.sendPacketToServer(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.blocks.logic.StencilTableLogic;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.inventory.PatternShaperContainer;
|
||||
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
|
||||
public class StencilTableGui extends GuiContainer
|
||||
{
|
||||
StencilTableLogic logic;
|
||||
int patternIndex;
|
||||
|
||||
public StencilTableGui(InventoryPlayer inventoryplayer, StencilTableLogic shaper, World world, int x, int y, int z)
|
||||
{
|
||||
super(new PatternShaperContainer(inventoryplayer, shaper));
|
||||
logic = shaper;
|
||||
patternIndex = 0;
|
||||
}
|
||||
|
||||
public void onGuiClosed ()
|
||||
{
|
||||
super.onGuiClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
||||
{
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("crafters.PatternShaper"), 50, 6, 0x404040);
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/patternshaper.png");
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(background);
|
||||
int cornerX = (this.width - this.xSize) / 2;
|
||||
int cornerY = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, this.xSize, this.ySize);
|
||||
if (!logic.isStackInSlot(0))
|
||||
{
|
||||
this.drawTexturedModalRect(cornerX + 47, cornerY + 34, 176, 0, 18, 18);
|
||||
}
|
||||
}
|
||||
|
||||
public void initGui ()
|
||||
{
|
||||
super.initGui();
|
||||
int cornerX = (this.width - this.xSize) / 2;
|
||||
int cornerY = (this.height - this.ySize) / 2;
|
||||
|
||||
this.buttonList.clear();
|
||||
/*ToolGuiElement repair = TConstruct.toolButtons.get(0);
|
||||
GuiButtonTool repairButton = new GuiButtonTool(0, cornerX - 110, cornerY, repair.buttonIconX, repair.buttonIconY, repair.texture); // Repair
|
||||
repairButton.enabled = false;
|
||||
this.buttonList.add(repairButton);*/
|
||||
this.buttonList.add(new GuiButton(0, cornerX - 120, cornerY, 120, 20, "Next Pattern"));
|
||||
this.buttonList.add(new GuiButton(1, cornerX - 120, cornerY + 20, 120, 20, "Previous Pattern"));
|
||||
|
||||
//for (int iter = 0; iter < TConstructContent.patternOutputs.length; iter++)
|
||||
//{
|
||||
|
||||
/*ToolGuiElement element = TConstruct.toolButtons.get(iter);
|
||||
GuiButtonTool button = new GuiButtonTool(iter, cornerX - 110 + 22 * (iter % 5), cornerY + 22 * (iter / 5), element.buttonIconX, element.buttonIconY, element.texture); // Repair
|
||||
this.buttonList.add(button);*/
|
||||
//}
|
||||
}
|
||||
|
||||
protected void actionPerformed (GuiButton button)
|
||||
{
|
||||
ItemStack pattern = logic.getStackInSlot(0);
|
||||
if (pattern != null && pattern.getItem() == TContent.blankPattern)
|
||||
{
|
||||
int meta = pattern.getItemDamage();
|
||||
if (meta == 0)
|
||||
{
|
||||
if (button.id == 0)
|
||||
{
|
||||
patternIndex++;
|
||||
if (patternIndex == 21)
|
||||
patternIndex++;
|
||||
if (patternIndex >= TContent.patternOutputs.length - 1)
|
||||
patternIndex = 0;
|
||||
}
|
||||
else if (button.id == 1)
|
||||
{
|
||||
patternIndex--;
|
||||
if (patternIndex < 0)
|
||||
patternIndex = TContent.patternOutputs.length - 2;
|
||||
if (patternIndex == 21)
|
||||
patternIndex--;
|
||||
}
|
||||
ItemStack stack = new ItemStack(TContent.woodPattern, 1, patternIndex + 1);
|
||||
logic.setInventorySlotContents(1, stack);
|
||||
updateServer(stack);
|
||||
}
|
||||
/*else if (meta == 1 || meta == 2)
|
||||
{
|
||||
ItemStack stack = new ItemStack(TContent.metalPattern, 1, 0);
|
||||
logic.setInventorySlotContents(1, stack);
|
||||
updateServer(stack);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
void updateServer (ItemStack stack)
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
try
|
||||
{
|
||||
outputStream.writeByte(2);
|
||||
outputStream.writeInt(logic.worldObj.provider.dimensionId);
|
||||
outputStream.writeInt(logic.xCoord);
|
||||
outputStream.writeInt(logic.yCoord);
|
||||
outputStream.writeInt(logic.zCoord);
|
||||
outputStream.writeShort(stack.itemID);
|
||||
outputStream.writeShort(stack.getItemDamage());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.channel = "TConstruct";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
|
||||
PacketDispatcher.sendPacketToServer(packet);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import tconstruct.blocks.logic.ToolForgeLogic;
|
||||
import tconstruct.library.client.TConstructClientRegistry;
|
||||
import tconstruct.library.client.ToolGuiElement;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ToolForgeGui extends ToolStationGui
|
||||
{
|
||||
int selectedButton;
|
||||
|
||||
public ToolForgeGui(InventoryPlayer inventoryplayer, ToolForgeLogic stationlogic, World world, int x, int y, int z)
|
||||
{
|
||||
super(inventoryplayer, stationlogic, world, x, y, z);
|
||||
}
|
||||
|
||||
protected void mouseClicked (int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
if (mouseButton == 0)
|
||||
{
|
||||
int gLeft = this.guiLeft + 68;
|
||||
int gTop = this.guiTop + 6;
|
||||
int gWidth = 102;
|
||||
int gHeight = 12;
|
||||
active = mouseX > gLeft && mouseX < gLeft + gWidth && mouseY > gTop && mouseY < gTop + gHeight;
|
||||
}
|
||||
}
|
||||
|
||||
public void initGui ()
|
||||
{
|
||||
super.initGui();
|
||||
int cornerX = (this.width - this.xSize) / 2;
|
||||
int cornerY = (this.height - this.ySize) / 2;
|
||||
|
||||
this.buttonList.clear();
|
||||
ToolGuiElement repair = TConstructClientRegistry.toolButtons.get(0);
|
||||
GuiButtonTool repairButton = new GuiButtonTool(0, cornerX - 110, cornerY, repair.buttonIconX, repair.buttonIconY, repair.domain, repair.texture, repair); // Repair
|
||||
repairButton.enabled = false;
|
||||
this.buttonList.add(repairButton);
|
||||
int offset = TConstructClientRegistry.tierTwoButtons.size();
|
||||
|
||||
for (int iter = 0; iter < TConstructClientRegistry.tierTwoButtons.size(); iter++)
|
||||
{
|
||||
ToolGuiElement element = TConstructClientRegistry.tierTwoButtons.get(iter);
|
||||
GuiButtonTool button = new GuiButtonTool(iter + 1, cornerX - 110 + 22 * ((iter + 1) % 5), cornerY + 22 * ((iter + 1) / 5), element.buttonIconX, element.buttonIconY, repair.domain,
|
||||
element.texture, element);
|
||||
this.buttonList.add(button);
|
||||
}
|
||||
|
||||
for (int iter = 1; iter < TConstructClientRegistry.toolButtons.size(); iter++)
|
||||
{
|
||||
ToolGuiElement element = TConstructClientRegistry.toolButtons.get(iter);
|
||||
GuiButtonTool button = new GuiButtonTool(iter + offset, cornerX - 110 + 22 * ((iter + offset) % 5), cornerY + 22 * ((iter + offset) / 5), element.buttonIconX, element.buttonIconY,
|
||||
repair.domain, element.texture, element);
|
||||
this.buttonList.add(button);
|
||||
}
|
||||
}
|
||||
|
||||
protected void actionPerformed (GuiButton button)
|
||||
{
|
||||
GuiButtonTool b = (GuiButtonTool) button;
|
||||
((GuiButton) this.buttonList.get(selectedButton)).enabled = true;
|
||||
selectedButton = button.id;
|
||||
button.enabled = false;
|
||||
|
||||
setSlotType(b.element.slotType);
|
||||
iconX = b.element.iconsX;
|
||||
iconY = b.element.iconsY;
|
||||
title = "\u00A7n" + b.element.title;
|
||||
body = b.element.body;
|
||||
}
|
||||
|
||||
@Override
|
||||
void resetGui ()
|
||||
{
|
||||
this.text.setText("");
|
||||
selectedButton = 0;
|
||||
setSlotType(0);
|
||||
iconX = new int[] { 0, 1, 2, 13 };
|
||||
iconY = new int[] { 13, 13, 13, 13 };
|
||||
title = "\u00A7nRepair and Modification";
|
||||
body = "The main way to repair or change your tools. Place a tool and a material on the left to get started.";
|
||||
}
|
||||
|
||||
void setSlotType (int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
slotX = new int[] { 56, 38, 38, 14 }; // Repair
|
||||
slotY = new int[] { 37, 28, 46, 37 };
|
||||
break;
|
||||
case 1:
|
||||
slotX = new int[] { 56, 56, 56, 14 }; // Three parts
|
||||
slotY = new int[] { 19, 55, 37, 37 };
|
||||
break;
|
||||
case 2:
|
||||
slotX = new int[] { 56, 56, 14, 14 }; // Two parts
|
||||
slotY = new int[] { 28, 46, 28, 46 };
|
||||
break;
|
||||
case 3:
|
||||
slotX = new int[] { 38, 47, 56, 14 }; // Double head
|
||||
slotY = new int[] { 28, 46, 28, 37 };
|
||||
break;
|
||||
case 4:
|
||||
slotX = new int[] { 47, 38, 56, 47 }; // Four parts
|
||||
slotY = new int[] { 19, 37, 37, 55 };
|
||||
break;
|
||||
case 5:
|
||||
slotX = new int[] { 38, 47, 56, 47 }; // Four parts, double head
|
||||
slotY = new int[] { 19, 55, 19, 37 };
|
||||
break;
|
||||
case 6:
|
||||
slotX = new int[] { 38, 38, 20, 56 }; // Double head
|
||||
slotY = new int[] { 28, 46, 28, 28 };
|
||||
break;
|
||||
case 7:
|
||||
slotX = new int[] { 56, 56, 56, 14 }; // Three parts reverse
|
||||
slotY = new int[] { 19, 37, 55, 37 };
|
||||
break;
|
||||
}
|
||||
toolSlots.resetSlots(slotX, slotY);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,516 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.blocks.logic.ToolStationLogic;
|
||||
import tconstruct.inventory.ActiveContainer;
|
||||
import tconstruct.inventory.ToolStationContainer;
|
||||
import tconstruct.library.client.TConstructClientRegistry;
|
||||
import tconstruct.library.client.ToolGuiElement;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ToolStationGui extends NewContainerGui
|
||||
{
|
||||
public ToolStationLogic logic;
|
||||
public ToolStationContainer toolSlots;
|
||||
public GuiTextField text;
|
||||
public String toolName;
|
||||
public int guiType;
|
||||
public int[] slotX, slotY, iconX, iconY;
|
||||
public boolean active;
|
||||
public String title, body = "";
|
||||
|
||||
public ToolStationGui(InventoryPlayer inventoryplayer, ToolStationLogic stationlogic, World world, int x, int y, int z)
|
||||
{
|
||||
super((ActiveContainer) stationlogic.getGuiContainer(inventoryplayer, world, x, y, z));
|
||||
this.logic = stationlogic;
|
||||
toolSlots = (ToolStationContainer) container;
|
||||
text = new GuiTextField(this.fontRenderer, this.xSize / 2 - 5, 8, 30, 12);
|
||||
this.text.setMaxStringLength(40);
|
||||
this.text.setEnableBackgroundDrawing(false);
|
||||
this.text.setVisible(true);
|
||||
this.text.setCanLoseFocus(false);
|
||||
this.text.setFocused(true);
|
||||
this.text.setTextColor(0xffffff);
|
||||
toolName = "";
|
||||
resetGui();
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
}
|
||||
|
||||
protected void mouseClicked (int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
if (mouseButton == 0)
|
||||
{
|
||||
int gLeft = this.guiLeft + 68;
|
||||
int gTop = this.guiTop + 6;
|
||||
int gWidth = 102;
|
||||
int gHeight = 12;
|
||||
active = mouseX > gLeft && mouseX < gLeft + gWidth && mouseY > gTop && mouseY < gTop + gHeight;
|
||||
}
|
||||
}
|
||||
|
||||
void resetGui ()
|
||||
{
|
||||
this.text.setText("");
|
||||
guiType = 0;
|
||||
setSlotType(0);
|
||||
iconX = new int[] { 0, 1, 2 };
|
||||
iconY = new int[] { 13, 13, 13 };
|
||||
title = "\u00A7nRepair and Modification";
|
||||
body = "The main way to repair or change your tools. Place a tool and a material on the left to get started.";
|
||||
}
|
||||
|
||||
public void initGui ()
|
||||
{
|
||||
super.initGui();
|
||||
int cornerX = (this.width - this.xSize) / 2;
|
||||
int cornerY = (this.height - this.ySize) / 2;
|
||||
|
||||
this.buttonList.clear();
|
||||
ToolGuiElement repair = TConstructClientRegistry.toolButtons.get(0);
|
||||
GuiButtonTool repairButton = new GuiButtonTool(0, cornerX - 110, cornerY, repair.buttonIconX, repair.buttonIconY, repair.domain, repair.texture, repair); // Repair
|
||||
repairButton.enabled = false;
|
||||
this.buttonList.add(repairButton);
|
||||
|
||||
for (int iter = 1; iter < TConstructClientRegistry.toolButtons.size(); iter++)
|
||||
{
|
||||
ToolGuiElement element = TConstructClientRegistry.toolButtons.get(iter);
|
||||
GuiButtonTool button = new GuiButtonTool(iter, cornerX - 110 + 22 * (iter % 5), cornerY + 22 * (iter / 5), element.buttonIconX, element.buttonIconY, repair.domain, element.texture,
|
||||
element);
|
||||
this.buttonList.add(button);
|
||||
}
|
||||
}
|
||||
|
||||
protected void actionPerformed (GuiButton button)
|
||||
{
|
||||
((GuiButton) this.buttonList.get(guiType)).enabled = true;
|
||||
guiType = button.id;
|
||||
button.enabled = false;
|
||||
|
||||
ToolGuiElement element = TConstructClientRegistry.toolButtons.get(guiType);
|
||||
setSlotType(element.slotType);
|
||||
iconX = element.iconsX;
|
||||
iconY = element.iconsY;
|
||||
title = "\u00A7n" + element.title;
|
||||
body = element.body;
|
||||
}
|
||||
|
||||
void setSlotType (int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
slotX = new int[] { 56, 38, 38 }; // Repair
|
||||
slotY = new int[] { 37, 28, 46 };
|
||||
break;
|
||||
case 1:
|
||||
slotX = new int[] { 56, 56, 56 }; // Three parts
|
||||
slotY = new int[] { 19, 55, 37 };
|
||||
break;
|
||||
case 2:
|
||||
slotX = new int[] { 56, 56, 14 }; // Two parts
|
||||
slotY = new int[] { 28, 46, 37 };
|
||||
break;
|
||||
case 3:
|
||||
slotX = new int[] { 38, 47, 56 }; // Double head
|
||||
slotY = new int[] { 28, 46, 28 };
|
||||
break;
|
||||
case 7:
|
||||
slotX = new int[] { 56, 56, 56 }; // Three parts reverse
|
||||
slotY = new int[] { 19, 37, 55 };
|
||||
break;
|
||||
}
|
||||
toolSlots.resetSlots(slotX, slotY);
|
||||
}
|
||||
|
||||
public void updateScreen ()
|
||||
{
|
||||
super.updateScreen();
|
||||
this.text.updateCursorCounter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
||||
{
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal(logic.getInvName()), 6, 8, 0x000000);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 0x000000);
|
||||
this.fontRenderer.drawString(toolName + "_", this.xSize / 2 - 18, 8, 0xffffff);
|
||||
|
||||
if (logic.isStackInSlot(0))
|
||||
drawToolStats();
|
||||
else
|
||||
drawToolInformation();
|
||||
|
||||
//this.fontRenderer.drawString("Namebox active: "+active, this.xSize / 2 - 18, -10, 0xffffff);
|
||||
}
|
||||
|
||||
void drawToolStats ()
|
||||
{
|
||||
ItemStack stack = logic.getStackInSlot(0);
|
||||
if (stack.getItem() instanceof ToolCore)
|
||||
{
|
||||
ToolCore tool = (ToolCore) stack.getItem();
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
this.drawCenteredString(fontRenderer, "\u00A7n" + tool.getToolName(), xSize + 63, 8, 0xffffff);
|
||||
|
||||
drawModularToolStats(stack, tool, tags);
|
||||
}
|
||||
}
|
||||
|
||||
void drawModularToolStats (ItemStack stack, ToolCore tool, NBTTagCompound tags)
|
||||
{
|
||||
List categories = Arrays.asList(tool.toolCategories());
|
||||
final int durability = tags.getInteger("Damage");
|
||||
final int maxDur = tags.getInteger("TotalDurability");
|
||||
int availableDurability = maxDur - durability;
|
||||
|
||||
//Durability
|
||||
int base = 24;
|
||||
int offset = 0;
|
||||
if (maxDur > 0)
|
||||
{
|
||||
if (maxDur >= 10000)
|
||||
{
|
||||
fontRenderer.drawString("Durability:", xSize + 8, base + offset * 11, 0xffffff);
|
||||
offset++;
|
||||
fontRenderer.drawString("- " + availableDurability + "/" + maxDur, xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fontRenderer.drawString("Durability: " + availableDurability + "/" + maxDur, xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
|
||||
final float stonebound = tags.getFloat("Shoddy");
|
||||
//Attack
|
||||
if (categories.contains("weapon"))
|
||||
{
|
||||
int attack = (int) (tags.getInteger("Attack"));
|
||||
float stoneboundDamage = (float) Math.log(durability / 72f + 1) * -2 * stonebound;
|
||||
attack += stoneboundDamage;
|
||||
attack *= tool.getDamageModifier();
|
||||
if (attack < 1)
|
||||
attack = 1;
|
||||
|
||||
String heart = attack == 2 ? " Heart" : " Hearts";
|
||||
if (attack % 2 == 0)
|
||||
this.fontRenderer.drawString("Attack: " + attack / 2 + heart, xSize + 8, base + offset * 10, 0xffffff);
|
||||
else
|
||||
this.fontRenderer.drawString("Attack: " + attack / 2f + heart, xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
|
||||
if (stoneboundDamage != 0)
|
||||
{
|
||||
heart = stoneboundDamage == 2 ? " Heart" : " Hearts";
|
||||
String bloss = stoneboundDamage > 0 ? "Bonus: " : "Loss: ";
|
||||
this.fontRenderer.drawString(bloss + (int) stoneboundDamage / 2 + heart, xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
}
|
||||
offset++;
|
||||
}
|
||||
|
||||
if (categories.contains("bow"))
|
||||
{
|
||||
DecimalFormat df = new DecimalFormat("##.##");
|
||||
df.setRoundingMode(RoundingMode.DOWN);
|
||||
int drawSpeed = tags.getInteger("DrawSpeed");
|
||||
float flightSpeed = tags.getFloat("FlightSpeed");
|
||||
float trueDraw = drawSpeed / 20f * flightSpeed;
|
||||
this.fontRenderer.drawString("Draw Speed: " + df.format(trueDraw) + "s", xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
this.fontRenderer.drawString("Arrow Speed: " + df.format(flightSpeed) + "x", xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
offset++;
|
||||
}
|
||||
|
||||
if (categories.contains("ammo"))
|
||||
{
|
||||
DecimalFormat df = new DecimalFormat("##.##");
|
||||
df.setRoundingMode(RoundingMode.DOWN);
|
||||
int attack = (int) (tags.getInteger("Attack"));
|
||||
float mass = tags.getFloat("Mass");
|
||||
float shatter = tags.getFloat("BreakChance");
|
||||
float accuracy = tags.getFloat("Accuracy");
|
||||
|
||||
this.fontRenderer.drawString("Base Attack:", xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
String heart = attack == 2 ? " Heart" : " Hearts";
|
||||
if (attack % 2 == 0)
|
||||
this.fontRenderer.drawString("- " + attack / 2 + heart, xSize + 8, base + offset * 10, 0xffffff);
|
||||
else
|
||||
this.fontRenderer.drawString("- " + attack / 2f + heart, xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
int minAttack = attack;
|
||||
int maxAttack = attack * 2;
|
||||
heart = " Hearts";
|
||||
this.fontRenderer.drawString("Shortbow Attack:", xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
this.fontRenderer.drawString(df.format(minAttack / 2f) + "-" + df.format(maxAttack / 2f) + heart, xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
offset++;
|
||||
|
||||
this.fontRenderer.drawString("Weight: " + df.format(mass), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
this.fontRenderer.drawString("Accuracy: " + df.format(accuracy - 4) + "%", xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
/*this.fontRenderer.drawString("Chance to break: " + df.format(shatter)+"%", xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;*/
|
||||
offset++;
|
||||
}
|
||||
|
||||
//Mining
|
||||
if (categories.contains("dualharvest"))
|
||||
{
|
||||
float mineSpeed = tags.getInteger("MiningSpeed") / 100f;
|
||||
float mineSpeed2 = tags.getInteger("MiningSpeed2") / 100f;
|
||||
float stoneboundSpeed = (float) Math.log(durability / 90f + 1) * 2 * stonebound;
|
||||
DecimalFormat df = new DecimalFormat("##.##");
|
||||
df.setRoundingMode(RoundingMode.DOWN);
|
||||
float trueSpeed = mineSpeed + stoneboundSpeed;
|
||||
float trueSpeed2 = mineSpeed + stoneboundSpeed;
|
||||
|
||||
fontRenderer.drawString("Mining Speeds: ", xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
fontRenderer.drawString("- " + df.format(trueSpeed) + ", " + df.format(trueSpeed2), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
if (stoneboundSpeed != 0)
|
||||
{
|
||||
String bloss = stoneboundSpeed > 0 ? "Bonus: " : "Loss: ";
|
||||
fontRenderer.drawString(bloss + df.format(stoneboundSpeed), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
}
|
||||
offset++;
|
||||
fontRenderer.drawString("Harvest Levels:", xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
fontRenderer
|
||||
.drawString("- " + getHarvestLevelName(tags.getInteger("HarvestLevel")) + ", " + getHarvestLevelName(tags.getInteger("HarvestLevel2")), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
offset++;
|
||||
}
|
||||
else if (categories.contains("harvest"))
|
||||
{
|
||||
float mineSpeed = tags.getInteger("MiningSpeed");
|
||||
int heads = 1;
|
||||
|
||||
if (tags.hasKey("MiningSpeed2"))
|
||||
{
|
||||
mineSpeed += tags.getInteger("MiningSpeed2");
|
||||
heads++;
|
||||
}
|
||||
|
||||
if (tags.hasKey("MiningSpeedHandle"))
|
||||
{
|
||||
mineSpeed += tags.getInteger("MiningSpeedHandle");
|
||||
heads++;
|
||||
}
|
||||
|
||||
if (tags.hasKey("MiningSpeedExtra"))
|
||||
{
|
||||
mineSpeed += tags.getInteger("MiningSpeedExtra");
|
||||
heads++;
|
||||
}
|
||||
|
||||
float trueSpeed = mineSpeed / (heads * 100f);
|
||||
|
||||
float stoneboundSpeed = (float) Math.log(durability / 90f + 1) * 2 * stonebound;
|
||||
DecimalFormat df = new DecimalFormat("##.##");
|
||||
df.setRoundingMode(RoundingMode.DOWN);
|
||||
trueSpeed += stoneboundSpeed;
|
||||
if (trueSpeed < 0)
|
||||
trueSpeed = 0;
|
||||
fontRenderer.drawString("Mining Speed: " + df.format(trueSpeed), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
if (stoneboundSpeed != 0)
|
||||
{
|
||||
String bloss = stoneboundSpeed > 0 ? "Bonus: " : "Loss: ";
|
||||
fontRenderer.drawString(bloss + df.format(stoneboundSpeed), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
}
|
||||
fontRenderer.drawString("Mining Level: " + getHarvestLevelName(tags.getInteger("HarvestLevel")), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
offset++;
|
||||
}
|
||||
else if (categories.contains("utility"))
|
||||
{
|
||||
float mineSpeed = tags.getInteger("MiningSpeed");
|
||||
float trueSpeed = mineSpeed / (100f);
|
||||
fontRenderer.drawString("Usage Speed: " + trueSpeed, xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
offset++;
|
||||
}
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
if (modifiers > 0)
|
||||
{
|
||||
fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
}
|
||||
if (tags.hasKey("Tooltip1"))
|
||||
{
|
||||
fontRenderer.drawString("Modifiers:", xSize + 8, base + offset * 10, 0xffffff);
|
||||
}
|
||||
|
||||
boolean displayToolTips = true;
|
||||
int tipNum = 0;
|
||||
while (displayToolTips)
|
||||
{
|
||||
tipNum++;
|
||||
String tooltip = "ModifierTip" + tipNum;
|
||||
if (tags.hasKey(tooltip))
|
||||
{
|
||||
String tipName = tags.getString(tooltip);
|
||||
fontRenderer.drawString("- " + tipName, xSize + 8, base + (offset + tipNum) * 10, 0xffffff);
|
||||
}
|
||||
else
|
||||
displayToolTips = false;
|
||||
}
|
||||
}
|
||||
|
||||
void drawToolInformation ()
|
||||
{
|
||||
this.drawCenteredString(fontRenderer, title, xSize + 63, 8, 0xffffff);
|
||||
fontRenderer.drawSplitString(body, xSize + 8, 24, 115, 0xffffff);
|
||||
}
|
||||
|
||||
protected String getHarvestLevelName (int num)
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
case 0:
|
||||
return "Stone";
|
||||
case 1:
|
||||
return "Iron";
|
||||
case 2:
|
||||
return "Redstone";
|
||||
case 3:
|
||||
return "Obsidian"; //Mithril
|
||||
case 4:
|
||||
return "Cobalt";
|
||||
case 5:
|
||||
return "Manyullyn";
|
||||
default:
|
||||
return String.valueOf(num);
|
||||
}
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/toolstation.png");
|
||||
private static final ResourceLocation icons = new ResourceLocation("tinker", "textures/gui/icons.png");
|
||||
private static final ResourceLocation description = new ResourceLocation("tinker", "textures/gui/description.png");
|
||||
|
||||
/**
|
||||
* Draw the background layer for the GuiContainer (everything behind the items)
|
||||
*/
|
||||
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
|
||||
{
|
||||
// Draw the background
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(background);
|
||||
int cornerX = (this.width - this.xSize) / 2;
|
||||
int cornerY = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
if (active)
|
||||
{
|
||||
this.drawTexturedModalRect(cornerX + 62, cornerY, 0, this.ySize, 112, 22);
|
||||
}
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(icons);
|
||||
// Draw the slots
|
||||
|
||||
for (int i = 0; i < slotX.length; i++)
|
||||
{
|
||||
this.drawTexturedModalRect(cornerX + slotX[i] - 4, cornerY + slotY[i] - 4, 140, 212, 28, 28);
|
||||
if (!logic.isStackInSlot(i + 1))
|
||||
{
|
||||
this.drawTexturedModalRect(cornerX + slotX[i], cornerY + slotY[i], 18 * iconX[i], 18 * iconY[i], 18, 18);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw description
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(description);
|
||||
cornerX = (this.width + this.xSize) / 2;
|
||||
cornerY = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, 126, this.ySize + 30);
|
||||
|
||||
}
|
||||
|
||||
protected void keyTyped (char par1, int keyCode)
|
||||
{
|
||||
if (keyCode == 1 || (!active && keyCode == this.mc.gameSettings.keyBindInventory.keyCode))
|
||||
{
|
||||
logic.setToolname("");
|
||||
updateServer("");
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
this.mc.thePlayer.closeScreen();
|
||||
}
|
||||
else if (active)
|
||||
{
|
||||
text.textboxKeyTyped(par1, keyCode);
|
||||
toolName = text.getText().trim();
|
||||
logic.setToolname(toolName);
|
||||
updateServer(toolName);
|
||||
}
|
||||
}
|
||||
|
||||
void updateServer (String name)
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
try
|
||||
{
|
||||
outputStream.writeByte(1);
|
||||
outputStream.writeInt(logic.worldObj.provider.dimensionId);
|
||||
outputStream.writeInt(logic.xCoord);
|
||||
outputStream.writeInt(logic.yCoord);
|
||||
outputStream.writeInt(logic.zCoord);
|
||||
outputStream.writeUTF(name);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.channel = "TConstruct";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
|
||||
PacketDispatcher.sendPacketToServer(packet);
|
||||
}
|
||||
|
||||
/*protected void mouseClicked(int par1, int par2, int par3)
|
||||
{
|
||||
super.mouseClicked(par1, par2, par3);
|
||||
text.mouseClicked(par1, par2, par3);
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package tconstruct.client.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TurnPageButton extends GuiButton
|
||||
{
|
||||
/**
|
||||
* True for pointing right (next page), false for pointing left (previous page).
|
||||
*/
|
||||
private final boolean nextPage;
|
||||
|
||||
public TurnPageButton(int par1, int par2, int par3, boolean par4)
|
||||
{
|
||||
super(par1, par2, par3, 23, 13, "");
|
||||
this.nextPage = par4;
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/bookleft.png");
|
||||
|
||||
/**
|
||||
* Draws this button to the screen.
|
||||
*/
|
||||
public void drawButton (Minecraft par1Minecraft, int par2, int par3)
|
||||
{
|
||||
if (this.drawButton)
|
||||
{
|
||||
boolean var4 = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
par1Minecraft.getTextureManager().bindTexture(background);
|
||||
int var5 = 0;
|
||||
int var6 = 192;
|
||||
|
||||
if (var4)
|
||||
{
|
||||
var5 += 23;
|
||||
}
|
||||
|
||||
if (!this.nextPage)
|
||||
{
|
||||
var6 += 13;
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, var5, var6, 23, 13);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user