2014-07-05 21:08:58 -08:00
|
|
|
package tconstruct.tools.gui;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-09-24 16:14:18 +02:00
|
|
|
import cpw.mods.fml.common.Optional;
|
2014-09-09 18:30:15 +10:00
|
|
|
import cpw.mods.fml.relauncher.*;
|
2014-09-24 16:14:18 +02:00
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.text.DecimalFormat;
|
2014-09-09 18:30:15 +10:00
|
|
|
import java.util.*;
|
2014-09-24 16:14:18 +02:00
|
|
|
|
2014-09-09 18:30:15 +10:00
|
|
|
import net.minecraft.client.gui.*;
|
2014-05-14 09:52:04 -05:00
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
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-09-09 18:30:15 +10:00
|
|
|
import net.minecraft.util.*;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.world.World;
|
2014-09-24 16:14:18 +02:00
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
import org.lwjgl.input.Keyboard;
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
2014-09-24 16:14:18 +02:00
|
|
|
|
|
|
|
|
import codechicken.nei.VisiblityData;
|
|
|
|
|
import codechicken.nei.api.INEIGuiHandler;
|
|
|
|
|
import codechicken.nei.api.TaggedInventoryArea;
|
2014-02-01 17:28:41 +11:00
|
|
|
import tconstruct.TConstruct;
|
2014-09-24 11:39:56 +02:00
|
|
|
import tconstruct.library.accessory.AccessoryCore;
|
|
|
|
|
import tconstruct.library.armor.ArmorCore;
|
2014-09-09 18:30:15 +10:00
|
|
|
import tconstruct.library.client.*;
|
|
|
|
|
import tconstruct.library.tools.*;
|
2014-08-20 17:39:54 +02:00
|
|
|
import tconstruct.library.util.HarvestLevels;
|
2014-06-04 21:44:48 -08:00
|
|
|
import tconstruct.smeltery.inventory.ActiveContainer;
|
|
|
|
|
import tconstruct.tools.inventory.ToolStationContainer;
|
|
|
|
|
import tconstruct.tools.logic.ToolStationLogic;
|
2014-07-21 12:52:39 -08:00
|
|
|
import tconstruct.util.network.ToolStationPacket;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2014-09-24 16:14:18 +02:00
|
|
|
@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems")
|
|
|
|
|
public class ToolStationGui extends GuiContainer implements INEIGuiHandler
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
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;
|
2014-05-14 09:52:04 -05:00
|
|
|
toolSlots = (ToolStationContainer) inventorySlots;
|
|
|
|
|
text = new GuiTextField(this.fontRendererObj, 83, 8, 30, 12);
|
2014-02-05 08:28:53 -05:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2013-07-26 21:18:53 -07:00
|
|
|
protected void mouseClicked (int mouseX, int mouseY, int mouseButton)
|
|
|
|
|
{
|
|
|
|
|
super.mouseClicked(mouseX, mouseY, mouseButton);
|
|
|
|
|
if (mouseButton == 0)
|
|
|
|
|
{
|
2014-07-05 21:08:58 -08:00
|
|
|
int gLeft = this.guiLeft + 68 + 110;
|
2013-07-26 21:18:53 -07:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2013-07-26 21:18:53 -07:00
|
|
|
public void initGui ()
|
|
|
|
|
{
|
|
|
|
|
super.initGui();
|
2014-09-24 16:14:18 +02:00
|
|
|
this.xSize = 176 + 110;
|
|
|
|
|
this.guiLeft = (this.width - 176) / 2 - 110;
|
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);
|
2014-05-14 09:52:04 -05:00
|
|
|
GuiButtonTool repairButton = new GuiButtonTool(0, this.guiLeft, this.guiTop, 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);
|
2014-09-09 18:30:15 +10:00
|
|
|
GuiButtonTool button = new GuiButtonTool(iter, this.guiLeft + 22 * (iter % 5), this.guiTop + 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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
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;
|
2014-10-22 22:22:00 +02:00
|
|
|
body = StatCollector.translateToLocal(element.body);
|
|
|
|
|
if(body != null) {
|
|
|
|
|
int i;
|
|
|
|
|
// for some really weird reason replaceAll doesn't find "\\n", but indexOf does. We have to replace manually.
|
|
|
|
|
while((i = body.indexOf("\\n")) >= 0)
|
|
|
|
|
{
|
|
|
|
|
body = body.substring(0, i) + '\n' + body.substring(i+2);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2013-07-26 21:18:53 -07:00
|
|
|
public void updateScreen ()
|
|
|
|
|
{
|
|
|
|
|
super.updateScreen();
|
2014-02-05 08:28:53 -05:00
|
|
|
this.text.updateCursorCounter();
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-02-16 14:23:50 -05:00
|
|
|
* Draw the foreground layer for the GuiContainer (everything in front of
|
|
|
|
|
* the items)
|
2013-07-26 21:18:53 -07:00
|
|
|
*/
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2013-07-26 21:18:53 -07:00
|
|
|
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
|
|
|
|
{
|
2014-05-14 09:52:04 -05:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal(logic.getInvName()), 116, 8, 0x000000);
|
|
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 118, this.ySize - 96 + 2, 0x000000);
|
|
|
|
|
this.fontRendererObj.drawString(toolName + "_", 180, 8, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
if (logic.isStackInSlot(0))
|
|
|
|
|
drawToolStats();
|
|
|
|
|
else
|
|
|
|
|
drawToolInformation();
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-24 11:39:56 +02:00
|
|
|
protected void drawToolStats ()
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
ItemStack stack = logic.getStackInSlot(0);
|
|
|
|
|
if (stack.getItem() instanceof ToolCore)
|
|
|
|
|
{
|
|
|
|
|
ToolCore tool = (ToolCore) stack.getItem();
|
2014-09-24 11:39:56 +02:00
|
|
|
NBTTagCompound tags = stack.getTagCompound().getCompoundTag(tool.getBaseTagName());
|
2014-09-01 23:52:04 +02:00
|
|
|
this.drawCenteredString(fontRendererObj, "\u00A7n" + tool.getLocalizedToolName(), 349, 8, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-09-24 11:39:56 +02:00
|
|
|
drawModularToolStats(stack, tool, tags, 294, 24);
|
|
|
|
|
}
|
|
|
|
|
if(stack.getItem() instanceof ArmorCore)
|
|
|
|
|
{
|
|
|
|
|
ArmorCore armor = (ArmorCore) stack.getItem();
|
|
|
|
|
NBTTagCompound tags = stack.getTagCompound().getCompoundTag(armor.getBaseTagName());
|
2014-09-24 11:46:25 +02:00
|
|
|
this.drawCenteredString(fontRendererObj, "\u00A7n" + stack.getDisplayName(), 349, 8, 0xffffff); // todo: localize
|
2014-09-24 11:39:56 +02:00
|
|
|
|
|
|
|
|
drawModularArmorStats(stack, armor, tags, 294, 24);
|
|
|
|
|
}
|
|
|
|
|
if(stack.getItem() instanceof AccessoryCore)
|
|
|
|
|
{
|
|
|
|
|
AccessoryCore accessory = (AccessoryCore) stack.getItem();
|
|
|
|
|
NBTTagCompound tags = stack.getTagCompound().getCompoundTag(accessory.getBaseTagName());
|
|
|
|
|
this.drawCenteredString(fontRendererObj, "\u00A7n" + stack.getDisplayName(), 349, 8, 0xffffff); // todo: localize
|
|
|
|
|
|
|
|
|
|
drawModularAccessoryStats(stack, accessory, tags, 294, 24);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-24 11:39:56 +02:00
|
|
|
protected void drawModularToolStats (ItemStack stack, ToolCore tool, NBTTagCompound tags, int x, int y)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-06-30 22:26:00 -08:00
|
|
|
List categories = Arrays.asList(tool.getTraits());
|
2013-07-26 21:18:53 -07:00
|
|
|
final int durability = tags.getInteger("Damage");
|
|
|
|
|
final int maxDur = tags.getInteger("TotalDurability");
|
|
|
|
|
int availableDurability = maxDur - durability;
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
// Durability
|
2014-09-24 11:39:56 +02:00
|
|
|
int base = y;
|
2013-07-26 21:18:53 -07:00
|
|
|
int offset = 0;
|
|
|
|
|
if (maxDur > 0)
|
|
|
|
|
{
|
|
|
|
|
if (maxDur >= 10000)
|
|
|
|
|
{
|
2014-09-24 11:39:56 +02:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation1"), x, base + offset * 11, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
2014-09-24 11:39:56 +02:00
|
|
|
fontRendererObj.drawString("- " + availableDurability + "/" + maxDur, x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-09-24 11:39:56 +02:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation2") + availableDurability + "/" + maxDur, x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final float stonebound = tags.getFloat("Shoddy");
|
2014-02-16 14:23:50 -05:00
|
|
|
// Attack
|
2013-07-26 21:18:53 -07:00
|
|
|
if (categories.contains("weapon"))
|
|
|
|
|
{
|
2014-03-15 07:11:06 -04:00
|
|
|
int attack = (int) (tags.getInteger("Attack")) + 1;
|
2013-07-26 21:18:53 -07:00
|
|
|
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-09-24 11:39:56 +02:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation3") + attack / 2 + heart, x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
else
|
2014-09-24 11:39:56 +02:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation3") + attack / 2f + heart, x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
|
|
|
|
|
if (stoneboundDamage != 0)
|
|
|
|
|
{
|
2014-04-09 13:48:28 -07:00
|
|
|
DecimalFormat df = new DecimalFormat("##.##");
|
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-09-24 11:39:56 +02:00
|
|
|
this.fontRendererObj.drawString(bloss + df.format(stoneboundDamage / 2f) + heart, x, 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");
|
2014-10-09 17:35:49 +02:00
|
|
|
float trueDraw = drawSpeed / 20f;
|
2014-09-24 11:39:56 +02:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation6") + df.format(trueDraw) + "s", x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
2014-09-24 11:39:56 +02:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation7") + df.format(flightSpeed) + "x", x, 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-09-24 11:39:56 +02:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation10"), x, 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-09-24 11:39:56 +02:00
|
|
|
this.fontRendererObj.drawString("- " + attack / 2 + heart, x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
else
|
2014-09-24 11:39:56 +02:00
|
|
|
this.fontRendererObj.drawString("- " + attack / 2f + heart, x, 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-09-24 11:39:56 +02:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation11"), x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
2014-09-24 11:39:56 +02:00
|
|
|
this.fontRendererObj.drawString(df.format(minAttack / 2f) + "-" + df.format(maxAttack / 2f) + heart, x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
offset++;
|
|
|
|
|
|
2014-09-24 11:39:56 +02:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation8") + df.format(mass), x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
2014-09-24 11:39:56 +02:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation9") + df.format(accuracy - 4) + "%", x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
2014-02-16 14:23:50 -05:00
|
|
|
/*
|
|
|
|
|
* this.fontRendererObj.drawString("Chance to break: " +
|
|
|
|
|
* df.format(shatter)+"%", xSize + 8, base + offset * 10, 0xffffff);
|
|
|
|
|
* offset++;
|
|
|
|
|
*/
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
// Mining
|
2013-07-26 21:18:53 -07:00
|
|
|
if (categories.contains("dualharvest"))
|
|
|
|
|
{
|
2014-04-14 20:08:09 -08:00
|
|
|
float mineSpeed = tags.getInteger("MiningSpeed") / 100f * ((HarvestTool) tool).breakSpeedModifier();
|
|
|
|
|
float mineSpeed2 = tags.getInteger("MiningSpeed2") / 100f * ((HarvestTool) tool).breakSpeedModifier();
|
|
|
|
|
float stoneboundSpeed = (float) Math.log(durability / ((HarvestTool) tool).stoneboundModifier() + 1) * 2 * stonebound;
|
2013-07-26 21:18:53 -07:00
|
|
|
DecimalFormat df = new DecimalFormat("##.##");
|
|
|
|
|
df.setRoundingMode(RoundingMode.DOWN);
|
|
|
|
|
float trueSpeed = mineSpeed + stoneboundSpeed;
|
2014-04-09 13:48:28 -07:00
|
|
|
float trueSpeed2 = mineSpeed2 + stoneboundSpeed;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-09-24 11:39:56 +02:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation12"), x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
2014-09-24 11:39:56 +02:00
|
|
|
fontRendererObj.drawString("- " + df.format(trueSpeed) + ", " + df.format(trueSpeed2), x, 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-09-24 11:39:56 +02:00
|
|
|
fontRendererObj.drawString(bloss + df.format(stoneboundSpeed), x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
offset++;
|
2014-09-24 11:39:56 +02:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation13"), x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
2014-09-24 11:39:56 +02:00
|
|
|
fontRendererObj.drawString("- " + HarvestLevels.getHarvestLevelName(tags.getInteger("HarvestLevel")) + ", " + HarvestLevels.getHarvestLevelName(tags.getInteger("HarvestLevel2")), x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
else if (categories.contains("harvest"))
|
|
|
|
|
{
|
2014-08-28 14:26:57 +02:00
|
|
|
float trueSpeed = AbilityHelper.calcToolSpeed(tool, tags);
|
|
|
|
|
float stoneboundSpeed = AbilityHelper.calcToolSpeed(tool, tags);
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
DecimalFormat df = new DecimalFormat("##.##");
|
|
|
|
|
df.setRoundingMode(RoundingMode.DOWN);
|
|
|
|
|
trueSpeed += stoneboundSpeed;
|
|
|
|
|
if (trueSpeed < 0)
|
|
|
|
|
trueSpeed = 0;
|
2014-09-24 11:39:56 +02:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation14") + df.format(trueSpeed), x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
2014-09-09 18:30:15 +10:00
|
|
|
if (stoneboundSpeed != 0 && !Float.isNaN(stoneboundSpeed))
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2013-12-01 21:42:03 +00:00
|
|
|
String bloss = stoneboundSpeed > 0 ? StatCollector.translateToLocal("gui.toolstation4") : StatCollector.translateToLocal("gui.toolstation5");
|
2014-09-24 11:39:56 +02:00
|
|
|
fontRendererObj.drawString(bloss + df.format(stoneboundSpeed), x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
}
|
2014-09-24 11:39:56 +02:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation15") + HarvestLevels.getHarvestLevelName(tags.getInteger("HarvestLevel")), x, 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-09-24 11:39:56 +02:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation16") + trueSpeed, x, 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-09-24 11:39:56 +02:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation18") + tags.getInteger("Modifiers"), x, base + offset * 10, 0xffffff);
|
|
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
if (tags.hasKey("Tooltip1"))
|
|
|
|
|
{
|
|
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation17"), x, 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);
|
|
|
|
|
fontRendererObj.drawString("- " + tipName, x, base + (offset + tipNum) * 10, 0xffffff);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
displayToolTips = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static DecimalFormat df = new DecimalFormat("##.#");
|
|
|
|
|
|
|
|
|
|
// todo: do this properly, quick and dirty fix
|
|
|
|
|
protected void drawModularArmorStats (ItemStack stack, ArmorCore armor, NBTTagCompound tags, int x, int y)
|
|
|
|
|
{
|
|
|
|
|
List categories = Arrays.asList(armor.getTraits());
|
|
|
|
|
int base = y;
|
|
|
|
|
int offset = 0;
|
|
|
|
|
|
|
|
|
|
// durability
|
|
|
|
|
final int durability = tags.getInteger("Damage");
|
|
|
|
|
final int maxDur = tags.getInteger("TotalDurability");
|
|
|
|
|
int availableDurability = maxDur - durability;
|
|
|
|
|
|
|
|
|
|
// Durability
|
|
|
|
|
if (maxDur > 0)
|
|
|
|
|
{
|
|
|
|
|
if (maxDur >= 10000)
|
|
|
|
|
{
|
|
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation1"), x, base + offset * 11, 0xffffff);
|
|
|
|
|
offset++;
|
|
|
|
|
fontRendererObj.drawString("- " + availableDurability + "/" + maxDur, x, base + offset * 10, 0xffffff);
|
|
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation2") + availableDurability + "/" + maxDur, x, base + offset * 10, 0xffffff);
|
|
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Damage reduction
|
|
|
|
|
double damageReduction = tags.getDouble("DamageReduction");
|
|
|
|
|
if(damageReduction > 0.000001d)
|
|
|
|
|
{
|
|
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation19") + df.format(damageReduction), x, base + offset * 10, 0xffffff);
|
|
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Protection
|
|
|
|
|
double protection = armor.getProtection(stack);
|
|
|
|
|
double maxProtection = tags.getDouble("MaxDefense");
|
|
|
|
|
//if(maxProtection > protection)
|
|
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation20") + df.format(protection) + "/" + df.format(maxProtection), 294, base + offset * 10, 0xffffff);
|
|
|
|
|
//else
|
|
|
|
|
// fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation20") + df.format(protection), x, base + offset * 10, 0xffffff);
|
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
|
|
offset++;
|
|
|
|
|
int modifiers = tags.getInteger("Modifiers");
|
|
|
|
|
if (modifiers > 0)
|
|
|
|
|
{
|
|
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation18") + tags.getInteger("Modifiers"), x, base + offset * 10, 0xffffff);
|
|
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
if (tags.hasKey("Tooltip1"))
|
|
|
|
|
{
|
|
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation17"), x, 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);
|
|
|
|
|
fontRendererObj.drawString("- " + tipName, x, base + (offset + tipNum) * 10, 0xffffff);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
displayToolTips = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// todo: also quick and dirty fix
|
|
|
|
|
protected void drawModularAccessoryStats (ItemStack stack, AccessoryCore accessory, NBTTagCompound tags, int x, int y)
|
|
|
|
|
{
|
|
|
|
|
List categories = Arrays.asList(accessory.getTraits());
|
|
|
|
|
int base = y;
|
|
|
|
|
int offset = 0;
|
|
|
|
|
|
|
|
|
|
if (categories.contains("utility"))
|
|
|
|
|
{
|
|
|
|
|
float mineSpeed = tags.getInteger("MiningSpeed");
|
|
|
|
|
float trueSpeed = mineSpeed / (100f);
|
|
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation16") + trueSpeed, x, base + offset * 10, 0xffffff);
|
|
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
offset++;
|
|
|
|
|
int modifiers = tags.getInteger("Modifiers");
|
|
|
|
|
if (modifiers > 0)
|
|
|
|
|
{
|
|
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation18") + tags.getInteger("Modifiers"), x, base + offset * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
offset++;
|
|
|
|
|
}
|
|
|
|
|
if (tags.hasKey("Tooltip1"))
|
|
|
|
|
{
|
2014-09-24 11:39:56 +02:00
|
|
|
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation17"), x, 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-09-24 11:39:56 +02:00
|
|
|
fontRendererObj.drawString("- " + tipName, x, base + (offset + tipNum) * 10, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
displayToolTips = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-24 11:39:56 +02:00
|
|
|
protected void drawToolInformation ()
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-05-14 09:52:04 -05:00
|
|
|
this.drawCenteredString(fontRendererObj, title, 349, 8, 0xffffff);
|
|
|
|
|
fontRendererObj.drawSplitString(body, 294, 24, 115, 0xffffff);
|
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");
|
|
|
|
|
|
|
|
|
|
/**
|
2014-02-16 14:23:50 -05:00
|
|
|
* Draw the background layer for the GuiContainer (everything behind the
|
|
|
|
|
* items)
|
2013-07-26 21:18:53 -07:00
|
|
|
*/
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2013-07-26 21:18:53 -07:00
|
|
|
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);
|
2014-05-14 09:52:04 -05:00
|
|
|
final int cornerX = this.guiLeft + 110;
|
|
|
|
|
this.drawTexturedModalRect(cornerX, this.guiTop, 0, 0, 176, this.ySize);
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
if (active)
|
|
|
|
|
{
|
2014-05-14 09:52:04 -05:00
|
|
|
this.drawTexturedModalRect(cornerX + 62, this.guiTop, 0, this.ySize, 112, 22);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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++)
|
|
|
|
|
{
|
2014-08-20 22:31:52 +02:00
|
|
|
this.drawTexturedModalRect(cornerX + slotX[i], this.guiTop + slotY[i], 144, 216, 18, 18);
|
2013-07-26 21:18:53 -07:00
|
|
|
if (!logic.isStackInSlot(i + 1))
|
|
|
|
|
{
|
2014-05-14 09:52:04 -05:00
|
|
|
this.drawTexturedModalRect(cornerX + slotX[i], this.guiTop + slotY[i], 18 * iconX[i], 18 * iconY[i], 18, 18);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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);
|
2014-05-14 09:52:04 -05:00
|
|
|
this.drawTexturedModalRect(cornerX + 176, this.guiTop, 0, 0, 126, this.ySize + 30);
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2013-07-26 21:18:53 -07:00
|
|
|
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-16 14:23:50 -05:00
|
|
|
/*
|
|
|
|
|
* ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
|
|
|
|
* DataOutputStream outputStream = new DataOutputStream(bos); try {
|
|
|
|
|
* outputStream.writeByte(1);
|
|
|
|
|
* outputStream.writeInt(logic.getWorld().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);
|
|
|
|
|
*/
|
2014-02-05 09:11:06 -05:00
|
|
|
|
2014-07-21 12:52:39 -08:00
|
|
|
TConstruct.packetPipeline.sendToServer(new ToolStationPacket(logic.xCoord, logic.yCoord, logic.zCoord, name));
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/*
|
|
|
|
|
* protected void mouseClicked(int par1, int par2, int par3) {
|
|
|
|
|
* super.mouseClicked(par1, par2, par3); text.mouseClicked(par1, par2,
|
|
|
|
|
* par3); }
|
|
|
|
|
*/
|
2014-09-24 16:14:18 +02:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public VisiblityData modifyVisiblity (GuiContainer gui, VisiblityData currentVisibility)
|
|
|
|
|
{
|
|
|
|
|
if (width - xSize < 107)
|
|
|
|
|
{
|
|
|
|
|
currentVisibility.showWidgets = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
currentVisibility.showWidgets = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (guiLeft < 58)
|
|
|
|
|
{
|
|
|
|
|
currentVisibility.showStateButtons = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return currentVisibility;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Iterable<Integer> getItemSpawnSlots (GuiContainer gui, ItemStack item)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<TaggedInventoryArea> getInventoryAreas (GuiContainer gui)
|
|
|
|
|
{
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean handleDragNDrop (GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean hideItemPanelSlot (GuiContainer gui, int x, int y, int w, int h)
|
|
|
|
|
{
|
|
|
|
|
if (y + h - 4 < guiTop || y + 4 > guiTop + ySize)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (x + 4 > guiLeft + xSize + 126)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|