2013-07-26 21:18:53 -07:00
|
|
|
package tconstruct.client.gui;
|
|
|
|
|
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.text.DecimalFormat;
|
2014-02-05 10:28:54 -05:00
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
|
import net.minecraft.client.gui.GuiTextField;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2014-02-05 10:28:54 -05:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
|
import net.minecraft.util.StatCollector;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.world.World;
|
2014-02-05 10:28:54 -05:00
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
import org.lwjgl.input.Keyboard;
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
2014-02-05 10:28:54 -05:00
|
|
|
|
2014-02-01 17:28:41 +11:00
|
|
|
import tconstruct.TConstruct;
|
2013-07-26 21:18:53 -07:00
|
|
|
import tconstruct.blocks.logic.ToolStationLogic;
|
2014-02-05 10:28:54 -05:00
|
|
|
import tconstruct.inventory.ActiveContainer;
|
|
|
|
|
import tconstruct.inventory.ToolStationContainer;
|
|
|
|
|
import tconstruct.library.client.TConstructClientRegistry;
|
|
|
|
|
import tconstruct.library.client.ToolGuiElement;
|
2013-07-26 21:18:53 -07:00
|
|
|
import tconstruct.library.tools.ToolCore;
|
2014-02-01 17:28:41 +11:00
|
|
|
import tconstruct.util.network.packet.PacketToolStation;
|
2014-02-05 10:28:54 -05:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
@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;
|
2014-02-05 08:28:53 -05:00
|
|
|
text = new GuiTextField(this.fontRendererObj, 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);
|
2013-07-26 21:18:53 -07:00
|
|
|
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;
|
2014-02-05 08:28:53 -05:00
|
|
|
int gwidth = 102;
|
|
|
|
|
int gheight = 12;
|
|
|
|
|
active = mouseX > gLeft && mouseX < gLeft + gwidth && mouseY > gTop && mouseY < gTop + gheight;
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void resetGui ()
|
|
|
|
|
{
|
2014-02-05 08:28:53 -05:00
|
|
|
this.text.setText("");
|
2013-07-26 21:18:53 -07:00
|
|
|
guiType = 0;
|
|
|
|
|
setSlotType(0);
|
|
|
|
|
iconX = new int[] { 0, 1, 2 };
|
|
|
|
|
iconY = new int[] { 13, 13, 13 };
|
2014-02-08 18:48:09 +01:00
|
|
|
title = "\u00A7n" + StatCollector.translateToLocal("gui.toolforge1");
|
|
|
|
|
body = StatCollector.translateToLocal("gui.toolforge2");
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void initGui ()
|
|
|
|
|
{
|
|
|
|
|
super.initGui();
|
2014-02-05 08:28:53 -05:00
|
|
|
int cornerX = (this.width - this.xSize) / 2;
|
|
|
|
|
int cornerY = (this.height - this.ySize) / 2;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-02-05 08:28:53 -05:00
|
|
|
this.buttonList.clear();
|
2013-07-26 21:18:53 -07:00
|
|
|
ToolGuiElement repair = TConstructClientRegistry.toolButtons.get(0);
|
|
|
|
|
GuiButtonTool repairButton = new GuiButtonTool(0, cornerX - 110, cornerY, repair.buttonIconX, repair.buttonIconY, repair.domain, repair.texture, repair); // Repair
|
2014-02-05 08:28:53 -05:00
|
|
|
repairButton.enabled = false;
|
|
|
|
|
this.buttonList.add(repairButton);
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
for (int iter = 1; iter < TConstructClientRegistry.toolButtons.size(); iter++)
|
|
|
|
|
{
|
|
|
|
|
ToolGuiElement element = TConstructClientRegistry.toolButtons.get(iter);
|
2013-08-31 05:13:31 -07:00
|
|
|
GuiButtonTool button = new GuiButtonTool(iter, cornerX - 110 + 22 * (iter % 5), cornerY + 22 * (iter / 5), element.buttonIconX, element.buttonIconY, repair.domain, element.texture,
|
|
|
|
|
element);
|
2014-02-05 08:28:53 -05:00
|
|
|
this.buttonList.add(button);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void actionPerformed (GuiButton button)
|
|
|
|
|
{
|
2014-02-05 08:28:53 -05:00
|
|
|
((GuiButton) this.buttonList.get(guiType)).enabled = true;
|
|
|
|
|
guiType = button.id;
|
|
|
|
|
button.enabled = false;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
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();
|
2014-02-05 08:28:53 -05:00
|
|
|
this.text.updateCursorCounter();
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
|
|
|
|
*/
|
|
|
|
|
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
|
|
|
|
{
|
2014-02-05 08:28:53 -05:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal(logic.getInvName()), 6, 8, 0x000000);
|
|
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 0x000000);
|
|
|
|
|
this.fontRendererObj.drawString(toolName + "_", this.xSize / 2 - 18, 8, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
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");
|
2014-02-05 08:28:53 -05:00
|
|
|
this.drawCenteredString(fontRendererObj, "\u00A7n" + tool.getToolName(), xSize + 63, 8, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2014-02-05 08:28:53 -05:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation1"), xSize + 8, base + offset * 11, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
2014-02-05 08:28:53 -05:00
|
|
|
fontRendererObj.drawString("- " + availableDurability + "/" + maxDur, xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-02-05 08:28:53 -05:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation2") + availableDurability + "/" + maxDur, xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
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;
|
2013-09-23 06:12:02 -07:00
|
|
|
attack *= tool.getDamageModifier();
|
2013-07-26 21:18:53 -07:00
|
|
|
if (attack < 1)
|
|
|
|
|
attack = 1;
|
|
|
|
|
|
2014-02-08 18:48:09 +01:00
|
|
|
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
|
2013-07-26 21:18:53 -07:00
|
|
|
if (attack % 2 == 0)
|
2014-02-05 08:28:53 -05:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation3") + attack / 2 + heart, xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
else
|
2014-02-05 08:28:53 -05:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation3") + attack / 2f + heart, xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
|
|
|
|
|
if (stoneboundDamage != 0)
|
|
|
|
|
{
|
2014-02-08 18:48:09 +01:00
|
|
|
heart = stoneboundDamage == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
|
2013-12-01 21:42:03 +00:00
|
|
|
String bloss = stoneboundDamage > 0 ? StatCollector.translateToLocal("gui.toolstation4") : StatCollector.translateToLocal("gui.toolstation5");
|
2014-02-05 08:28:53 -05:00
|
|
|
this.fontRendererObj.drawString(bloss + (int) stoneboundDamage / 2 + heart, xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
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;
|
2014-02-05 08:28:53 -05:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation6") + df.format(trueDraw) + "s", xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
2014-02-05 08:28:53 -05:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation7") + df.format(flightSpeed) + "x", xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
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");
|
|
|
|
|
|
2014-02-05 08:28:53 -05:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation10"), xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
2014-02-08 18:48:09 +01:00
|
|
|
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
|
2013-07-26 21:18:53 -07:00
|
|
|
if (attack % 2 == 0)
|
2014-02-05 08:28:53 -05:00
|
|
|
this.fontRendererObj.drawString("- " + attack / 2 + heart, xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
else
|
2014-02-05 08:28:53 -05:00
|
|
|
this.fontRendererObj.drawString("- " + attack / 2f + heart, xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
int minAttack = attack;
|
|
|
|
|
int maxAttack = attack * 2;
|
2014-02-08 18:48:09 +01:00
|
|
|
heart = StatCollector.translateToLocal("gui.partcrafter9");
|
2014-02-05 08:28:53 -05:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation11"), xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
2014-02-05 08:28:53 -05:00
|
|
|
this.fontRendererObj.drawString(df.format(minAttack / 2f) + "-" + df.format(maxAttack / 2f) + heart, xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
offset++;
|
|
|
|
|
|
2014-02-05 08:28:53 -05:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation8") + df.format(mass), xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
2014-02-05 08:28:53 -05:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation9") + df.format(accuracy - 4) + "%", xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
2014-02-05 08:28:53 -05:00
|
|
|
/*this.fontRendererObj.drawString("Chance to break: " + df.format(shatter)+"%", xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
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;
|
|
|
|
|
|
2014-02-05 08:28:53 -05:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation12"), xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
2014-02-05 08:28:53 -05:00
|
|
|
fontRendererObj.drawString("- " + df.format(trueSpeed) + ", " + df.format(trueSpeed2), xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
if (stoneboundSpeed != 0)
|
|
|
|
|
{
|
2013-12-01 21:42:03 +00:00
|
|
|
String bloss = stoneboundSpeed > 0 ? StatCollector.translateToLocal("gui.toolstation4") : StatCollector.translateToLocal("gui.toolstation5");
|
2014-02-05 08:28:53 -05:00
|
|
|
fontRendererObj.drawString(bloss + df.format(stoneboundSpeed), xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
offset++;
|
2014-02-05 08:28:53 -05:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation13"), xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
2014-02-05 09:11:06 -05:00
|
|
|
fontRendererObj.drawString("- " + getHarvestLevelName(tags.getInteger("HarvestLevel")) + ", " + getHarvestLevelName(tags.getInteger("HarvestLevel2")), xSize + 8, base + offset * 10,
|
|
|
|
|
0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
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;
|
2014-02-05 08:28:53 -05:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation14") + df.format(trueSpeed), xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
if (stoneboundSpeed != 0)
|
|
|
|
|
{
|
2013-12-01 21:42:03 +00:00
|
|
|
String bloss = stoneboundSpeed > 0 ? StatCollector.translateToLocal("gui.toolstation4") : StatCollector.translateToLocal("gui.toolstation5");
|
2014-02-05 08:28:53 -05:00
|
|
|
fontRendererObj.drawString(bloss + df.format(stoneboundSpeed), xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
}
|
2014-02-05 08:28:53 -05:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation15") + getHarvestLevelName(tags.getInteger("HarvestLevel")), xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
else if (categories.contains("utility"))
|
|
|
|
|
{
|
|
|
|
|
float mineSpeed = tags.getInteger("MiningSpeed");
|
|
|
|
|
float trueSpeed = mineSpeed / (100f);
|
2014-02-05 08:28:53 -05:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation16") + trueSpeed, xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-01 21:42:03 +00:00
|
|
|
int modifiers = tags.getInteger("Modifiers");
|
2013-07-26 21:18:53 -07:00
|
|
|
if (modifiers > 0)
|
|
|
|
|
{
|
2014-02-05 08:28:53 -05:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation18") + tags.getInteger("Modifiers"), xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
if (tags.hasKey("Tooltip1"))
|
|
|
|
|
{
|
2014-02-05 08:28:53 -05:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation17"), xSize + 8, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boolean displayToolTips = true;
|
|
|
|
|
int tipNum = 0;
|
|
|
|
|
while (displayToolTips)
|
|
|
|
|
{
|
|
|
|
|
tipNum++;
|
|
|
|
|
String tooltip = "ModifierTip" + tipNum;
|
|
|
|
|
if (tags.hasKey(tooltip))
|
|
|
|
|
{
|
|
|
|
|
String tipName = tags.getString(tooltip);
|
2014-02-05 08:28:53 -05:00
|
|
|
fontRendererObj.drawString("- " + tipName, xSize + 8, base + (offset + tipNum) * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
displayToolTips = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void drawToolInformation ()
|
|
|
|
|
{
|
2014-02-05 08:28:53 -05:00
|
|
|
this.drawCenteredString(fontRendererObj, title, xSize + 63, 8, 0xffffff);
|
|
|
|
|
fontRendererObj.drawSplitString(body, xSize + 8, 24, 115, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2013-10-26 15:55:53 +09:00
|
|
|
protected String getHarvestLevelName (int num)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
switch (num)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
2013-12-01 21:42:03 +00:00
|
|
|
return StatCollector.translateToLocal("gui.partcrafter.mining1");
|
2013-07-26 21:18:53 -07:00
|
|
|
case 1:
|
2013-12-01 21:42:03 +00:00
|
|
|
return StatCollector.translateToLocal("gui.partcrafter.mining2");
|
2013-07-26 21:18:53 -07:00
|
|
|
case 2:
|
2013-12-01 21:42:03 +00:00
|
|
|
return StatCollector.translateToLocal("gui.partcrafter.mining3");
|
2013-07-26 21:18:53 -07:00
|
|
|
case 3:
|
2013-12-01 21:42:03 +00:00
|
|
|
return StatCollector.translateToLocal("gui.partcrafter.mining4"); //Mithril
|
2013-07-26 21:18:53 -07:00
|
|
|
case 4:
|
2013-12-01 21:42:03 +00:00
|
|
|
return StatCollector.translateToLocal("gui.partcrafter.mining5");
|
2013-07-26 21:18:53 -07:00
|
|
|
case 5:
|
2013-12-01 21:42:03 +00:00
|
|
|
return StatCollector.translateToLocal("gui.partcrafter.mining6");
|
2013-07-26 21:18:53 -07:00
|
|
|
default:
|
|
|
|
|
return String.valueOf(num);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-08-31 05:13:31 -07:00
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
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);
|
2014-02-05 08:28:53 -05:00
|
|
|
this.mc.getTextureManager().bindTexture(background);
|
|
|
|
|
int cornerX = (this.width - this.xSize) / 2;
|
|
|
|
|
int cornerY = (this.height - this.ySize) / 2;
|
2013-07-26 21:18:53 -07:00
|
|
|
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);
|
2014-02-05 08:28:53 -05:00
|
|
|
this.mc.getTextureManager().bindTexture(icons);
|
2013-07-26 21:18:53 -07:00
|
|
|
// 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);
|
2014-02-05 08:28:53 -05:00
|
|
|
this.mc.getTextureManager().bindTexture(description);
|
|
|
|
|
cornerX = (this.width + this.xSize) / 2;
|
|
|
|
|
cornerY = (this.height - this.ySize) / 2;
|
2013-07-26 21:18:53 -07:00
|
|
|
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, 126, this.ySize + 30);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void keyTyped (char par1, int keyCode)
|
|
|
|
|
{
|
2014-02-05 08:28:53 -05:00
|
|
|
if (keyCode == 1 || (!active && keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode()))
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
logic.setToolname("");
|
|
|
|
|
updateServer("");
|
|
|
|
|
Keyboard.enableRepeatEvents(false);
|
2014-02-05 08:28:53 -05:00
|
|
|
this.mc.thePlayer.closeScreen();
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
else if (active)
|
|
|
|
|
{
|
2014-02-05 08:28:53 -05:00
|
|
|
text.textboxKeyTyped(par1, keyCode);
|
|
|
|
|
toolName = text.getText().trim();
|
2013-07-26 21:18:53 -07:00
|
|
|
logic.setToolname(toolName);
|
|
|
|
|
updateServer(toolName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void updateServer (String name)
|
|
|
|
|
{
|
2014-02-01 17:28:41 +11:00
|
|
|
/*ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
2013-07-26 21:18:53 -07:00
|
|
|
DataOutputStream outputStream = new DataOutputStream(bos);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
outputStream.writeByte(1);
|
2014-01-01 14:59:11 -05:00
|
|
|
outputStream.writeInt(logic.getWorld().provider.dimensionId);
|
2014-02-05 08:28:53 -05:00
|
|
|
outputStream.writeInt(logic.xCoord);
|
|
|
|
|
outputStream.writeInt(logic.yCoord);
|
|
|
|
|
outputStream.writeInt(logic.zCoord);
|
2013-07-26 21:18:53 -07:00
|
|
|
outputStream.writeUTF(name);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Packet250CustomPayload packet = new Packet250CustomPayload();
|
|
|
|
|
packet.channel = "TConstruct";
|
|
|
|
|
packet.data = bos.toByteArray();
|
|
|
|
|
packet.length = bos.size();
|
|
|
|
|
|
2014-02-01 17:28:41 +11:00
|
|
|
PacketDispatcher.sendPacketToServer(packet);*/
|
2014-02-05 09:11:06 -05:00
|
|
|
|
2014-02-05 08:28:53 -05:00
|
|
|
TConstruct.packetPipeline.sendToServer(new PacketToolStation(logic.xCoord, logic.yCoord, logic.zCoord, name));
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*protected void mouseClicked(int par1, int par2, int par3)
|
|
|
|
|
{
|
|
|
|
|
super.mouseClicked(par1, par2, par3);
|
|
|
|
|
text.mouseClicked(par1, par2, par3);
|
|
|
|
|
}*/
|
|
|
|
|
}
|