2014-07-05 21:08:58 -08:00
|
|
|
package tconstruct.tools.gui;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-09-24 02:15:56 +02:00
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
2014-09-23 23:34:30 +02: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;
|
2014-09-23 23:34:30 +02: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-09-23 23:34:30 +02:00
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
import org.lwjgl.opengl.GL11;
|
2014-09-23 23:34:30 +02:00
|
|
|
|
2014-09-24 02:15:56 +02:00
|
|
|
import codechicken.nei.VisiblityData;
|
|
|
|
|
import codechicken.nei.api.INEIGuiHandler;
|
|
|
|
|
import codechicken.nei.api.TaggedInventoryArea;
|
|
|
|
|
import cpw.mods.fml.common.Optional;
|
2013-07-26 21:18:53 -07:00
|
|
|
import tconstruct.library.TConstructRegistry;
|
|
|
|
|
import tconstruct.library.crafting.PatternBuilder;
|
2014-06-30 22:26:00 -08:00
|
|
|
import tconstruct.library.tools.ToolMaterial;
|
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.PartCrafterChestContainer;
|
|
|
|
|
import tconstruct.tools.logic.PartBuilderLogic;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-09-24 02:15:56 +02:00
|
|
|
@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems")
|
|
|
|
|
public class PartCrafterGui extends GuiContainer implements INEIGuiHandler
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2013-08-16 13:51:33 -07:00
|
|
|
PartBuilderLogic logic;
|
2013-07-26 21:18:53 -07:00
|
|
|
String title, otherTitle = "";
|
|
|
|
|
boolean drawChestPart;
|
|
|
|
|
boolean hasTop, hasBottom;
|
|
|
|
|
ItemStack topMaterial, bottomMaterial;
|
2014-06-30 22:26:00 -08:00
|
|
|
ToolMaterial topEnum, bottomEnum;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-09-24 02:15:56 +02:00
|
|
|
private static final int CRAFT_WIDTH = 176;
|
|
|
|
|
private static final int CRAFT_HEIGHT = 166;
|
|
|
|
|
private static final int DESC_WIDTH = 126;
|
|
|
|
|
private static final int DESC_HEIGHT = 166;
|
|
|
|
|
private static final int CHEST_WIDTH = 122;
|
|
|
|
|
private static final int CHEST_HEIGHT = 114;
|
|
|
|
|
|
2014-09-23 23:34:30 +02:00
|
|
|
// Panel positions
|
|
|
|
|
|
2014-09-24 02:15:56 +02:00
|
|
|
private int craftingLeft = 0;
|
|
|
|
|
private int craftingTop = 0;
|
|
|
|
|
private int craftingTextLeft = 0;
|
2014-09-23 23:34:30 +02:00
|
|
|
|
2014-09-24 02:15:56 +02:00
|
|
|
private int descLeft = 0;
|
|
|
|
|
private int descTop = 0;
|
|
|
|
|
private int descTextLeft = 0;
|
2014-09-23 23:34:30 +02:00
|
|
|
|
2014-09-24 02:15:56 +02:00
|
|
|
private int chestLeft = 0;
|
|
|
|
|
private int chestTop = 0;
|
2014-09-23 23:34:30 +02:00
|
|
|
|
2013-08-16 13:51:33 -07:00
|
|
|
public PartCrafterGui(InventoryPlayer inventoryplayer, PartBuilderLogic partlogic, World world, int x, int y, int z)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
super((ActiveContainer) partlogic.getGuiContainer(inventoryplayer, world, x, y, z));
|
|
|
|
|
logic = partlogic;
|
2014-09-23 23:34:30 +02:00
|
|
|
drawChestPart = inventorySlots instanceof PartCrafterChestContainer;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-02-05 09:11:06 -05:00
|
|
|
title = "\u00A7n" + (StatCollector.translateToLocal("gui.partcrafter1"));
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2014-09-23 23:34:30 +02:00
|
|
|
@Override
|
|
|
|
|
public void initGui ()
|
|
|
|
|
{
|
|
|
|
|
super.initGui();
|
|
|
|
|
|
2014-09-24 16:14:18 +02:00
|
|
|
this.xSize = CRAFT_WIDTH;
|
2014-09-24 02:15:56 +02:00
|
|
|
this.ySize = CRAFT_HEIGHT;
|
2014-09-23 23:34:30 +02:00
|
|
|
|
2014-09-24 02:15:56 +02:00
|
|
|
this.craftingLeft = (this.width - CRAFT_WIDTH) / 2;
|
|
|
|
|
this.craftingTop = (this.height - CRAFT_HEIGHT) / 2;
|
2014-09-23 23:34:30 +02:00
|
|
|
|
2014-09-24 02:15:56 +02:00
|
|
|
this.guiLeft = this.craftingLeft;
|
|
|
|
|
this.guiTop = this.craftingTop;
|
|
|
|
|
|
|
|
|
|
this.descLeft = this.craftingLeft + CRAFT_WIDTH;
|
2014-09-23 23:34:30 +02:00
|
|
|
this.descTop = this.craftingTop;
|
|
|
|
|
|
|
|
|
|
if (drawChestPart)
|
|
|
|
|
{
|
2014-09-24 02:15:56 +02:00
|
|
|
this.xSize += CHEST_WIDTH - 6;
|
|
|
|
|
this.guiLeft -= CHEST_WIDTH - 6;
|
|
|
|
|
|
|
|
|
|
this.chestLeft = this.guiLeft;
|
2014-09-23 23:34:30 +02:00
|
|
|
this.chestTop = this.guiTop + 11;
|
|
|
|
|
}
|
2014-09-24 02:15:56 +02:00
|
|
|
|
|
|
|
|
this.craftingTextLeft = this.craftingLeft - this.guiLeft;
|
|
|
|
|
this.descTextLeft = this.descLeft - this.guiLeft;
|
2014-09-23 23:34:30 +02: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)
|
|
|
|
|
{
|
|
|
|
|
if (drawChestPart)
|
2014-09-23 23:34:30 +02:00
|
|
|
{
|
|
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("inventory.PatternChest"), 14, 17, 4210752);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-24 02:15:56 +02:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("crafters.PartBuilder"), craftingTextLeft + 6, 6, 4210752);
|
|
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), craftingTextLeft + 8, this.ySize - 96 + 2, 4210752);
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
drawMaterialInformation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void drawDefaultInformation ()
|
|
|
|
|
{
|
2013-12-01 21:42:03 +00:00
|
|
|
title = "\u00A7n" + StatCollector.translateToLocal("gui.partcrafter2");
|
2014-09-24 02:15:56 +02:00
|
|
|
this.drawCenteredString(fontRendererObj, title, descTextLeft + DESC_WIDTH / 2, 8, 16777215);
|
|
|
|
|
fontRendererObj.drawSplitString(StatCollector.translateToLocal("gui.partcrafter3"), descTextLeft + 8, 24, 115, 16777215);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void drawMaterialInformation ()
|
|
|
|
|
{
|
|
|
|
|
ItemStack top = logic.getStackInSlot(2);
|
2014-02-17 01:27:15 -05:00
|
|
|
//ItemStack topResult = logic.getStackInSlot(4);
|
2013-07-26 21:18:53 -07:00
|
|
|
ItemStack bottom = logic.getStackInSlot(3);
|
2014-02-17 01:27:15 -05:00
|
|
|
//ItemStack bottomResult = logic.getStackInSlot(6);
|
2013-07-26 21:18:53 -07:00
|
|
|
if (topMaterial != top)
|
|
|
|
|
{
|
|
|
|
|
topMaterial = top;
|
|
|
|
|
int topID = PatternBuilder.instance.getPartID(top);
|
|
|
|
|
|
2013-07-17 02:04:28 -07:00
|
|
|
if (topID != Short.MAX_VALUE)// && topResult != null)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
topEnum = TConstructRegistry.getMaterial(topID);
|
|
|
|
|
hasTop = true;
|
2014-09-01 22:40:00 +02:00
|
|
|
title = "\u00A7n" + topEnum.localizedName();
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
hasTop = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bottomMaterial != bottom)
|
|
|
|
|
{
|
|
|
|
|
bottomMaterial = bottom;
|
|
|
|
|
int bottomID = PatternBuilder.instance.getPartID(bottom);
|
|
|
|
|
|
2013-07-17 02:04:28 -07:00
|
|
|
if (bottomID != Short.MAX_VALUE)// && bottomResult != null)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
bottomEnum = TConstructRegistry.getMaterial(bottomID);
|
|
|
|
|
hasBottom = true;
|
2014-09-01 22:40:00 +02:00
|
|
|
otherTitle = "\u00A7n" + bottomEnum.localizedName();
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
hasBottom = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int offset = 8;
|
|
|
|
|
if (hasTop)
|
|
|
|
|
{
|
2014-09-24 02:15:56 +02:00
|
|
|
this.drawCenteredString(fontRendererObj, title, descTextLeft + DESC_WIDTH / 2, offset, 16777215);
|
|
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter4") + topEnum.durability(), descTextLeft + 8, offset + 16, 16777215);
|
|
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter5") + topEnum.handleDurability() + "x", descTextLeft + 8, offset + 27, 16777215);
|
|
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter6") + topEnum.toolSpeed() / 100f, descTextLeft + 8, offset + 38, 16777215);
|
|
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter7") + HarvestLevels.getHarvestLevelName(topEnum.harvestLevel()), descTextLeft + 8, offset + 49, 16777215);
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
int attack = topEnum.attack();
|
2013-12-01 20:39:36 +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 02:15:56 +02:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter10") + attack / 2 + heart, descTextLeft + 8, offset + 60, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
else
|
2014-09-24 02:15:56 +02:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter10") + attack / 2f + heart, descTextLeft + 8, offset + 60, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
offset = 90;
|
|
|
|
|
if (hasBottom)
|
|
|
|
|
{
|
2014-09-24 02:15:56 +02:00
|
|
|
this.drawCenteredString(fontRendererObj, otherTitle, descTextLeft + DESC_WIDTH / 2, offset, 16777215);
|
|
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter4") + bottomEnum.durability(), descTextLeft + 8, offset + 16, 16777215);
|
|
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter5") + bottomEnum.handleDurability() + "x", descTextLeft + 8, offset + 27, 16777215);
|
|
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter6") + bottomEnum.toolSpeed() / 100f, descTextLeft + 8, offset + 38, 16777215);
|
|
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter7") + HarvestLevels.getHarvestLevelName(bottomEnum.harvestLevel()), descTextLeft + 8, offset + 49, 16777215);
|
2013-07-26 21:18:53 -07:00
|
|
|
int attack = bottomEnum.attack();
|
2013-12-01 21:42:03 +00: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 02:15:56 +02:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter10") + attack / 2 + heart, descTextLeft + 8, offset + 60, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
else
|
2014-09-24 02:15:56 +02:00
|
|
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter10") + attack / 2f + heart, descTextLeft + 8, offset + 60, 0xffffff);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!hasTop && !hasBottom)
|
|
|
|
|
drawDefaultInformation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
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-09-24 02:15:56 +02:00
|
|
|
this.drawTexturedModalRect(craftingLeft, craftingTop, 0, 0, CRAFT_WIDTH, CRAFT_HEIGHT);
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
// Draw Slots
|
2014-09-23 23:34:30 +02:00
|
|
|
this.drawTexturedModalRect(craftingLeft + 39, craftingTop + 26, 0, 166, 98, 36);
|
2013-07-26 21:18:53 -07:00
|
|
|
if (!logic.isStackInSlot(0))
|
|
|
|
|
{
|
2014-09-23 23:34:30 +02:00
|
|
|
this.drawTexturedModalRect(craftingLeft + 39, craftingTop + 26, 176, 0, 18, 18);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
if (!logic.isStackInSlot(2))
|
|
|
|
|
{
|
2014-09-23 23:34:30 +02:00
|
|
|
this.drawTexturedModalRect(craftingLeft + 57, craftingTop + 26, 176, 18, 18, 18);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
if (!logic.isStackInSlot(1))
|
|
|
|
|
{
|
2014-09-23 23:34:30 +02:00
|
|
|
this.drawTexturedModalRect(craftingLeft + 39, craftingTop + 44, 176, 0, 18, 18);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
if (!logic.isStackInSlot(3))
|
|
|
|
|
{
|
2014-09-23 23:34:30 +02:00
|
|
|
this.drawTexturedModalRect(craftingLeft + 57, craftingTop + 44, 176, 36, 18, 18);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Draw chest
|
|
|
|
|
if (drawChestPart)
|
|
|
|
|
{
|
|
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
2014-02-05 08:28:53 -05:00
|
|
|
this.mc.getTextureManager().bindTexture(minichest);
|
2014-09-24 02:15:56 +02:00
|
|
|
this.drawTexturedModalRect(chestLeft, chestTop, 0, 0, CHEST_WIDTH, CHEST_HEIGHT);
|
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-09-24 02:15:56 +02:00
|
|
|
this.drawTexturedModalRect(descLeft, descTop, DESC_WIDTH, 0, DESC_WIDTH, DESC_HEIGHT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public VisiblityData modifyVisiblity (GuiContainer gui, VisiblityData currentVisibility)
|
|
|
|
|
{
|
2014-09-24 16:14:18 +02:00
|
|
|
if (width - xSize < 107)
|
|
|
|
|
{
|
|
|
|
|
currentVisibility.showWidgets = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
currentVisibility.showWidgets = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (guiLeft < 58)
|
|
|
|
|
{
|
|
|
|
|
currentVisibility.showStateButtons = false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-24 02:15:56 +02:00
|
|
|
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;
|
|
|
|
|
|
2014-09-24 16:14:18 +02:00
|
|
|
if (x + 4 > guiLeft + xSize + DESC_WIDTH)
|
2014-09-24 02:15:56 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2014-02-17 01:27:15 -05:00
|
|
|
}
|