mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-22 13:09:53 +00:00
Fix JABBA-related issues with crafting station slots (#54)
* Fix shift-merging tools voiding items fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392> * Change 0-sized ItemStacks into null stacks in crafting station attached slots Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425> * Update buildscript * spotlessApply
This commit is contained in:
1 parent
18bfeaff32
commit
39be06c23b
571 files changed
+25959
-28223
No files matched your search
@@ -12,28 +12,24 @@ import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.tools.logic.BattlesignLogic;
|
||||
import tconstruct.util.network.SignDataPacket;
|
||||
|
||||
public class BattlesignGui extends GuiScreen
|
||||
{
|
||||
public class BattlesignGui extends GuiScreen {
|
||||
private BattlesignLogic battlesign;
|
||||
|
||||
private float bgColR = 1F;
|
||||
private float bgColG = 1F;
|
||||
private float bgColB = 1F;
|
||||
private static ResourceLocation background = new ResourceLocation("tinker:textures/gui/battlesignText.png");
|
||||
private String[] text = { "", "", "", "", "" };
|
||||
private String[] text = {"", "", "", "", ""};
|
||||
int currentLine = 0;
|
||||
|
||||
public BattlesignGui(BattlesignLogic logic)
|
||||
{
|
||||
public BattlesignGui(BattlesignLogic logic) {
|
||||
this.battlesign = logic;
|
||||
|
||||
ItemStack stack = logic.getEquipmentItem();
|
||||
if (stack != null)
|
||||
{
|
||||
if (stack != null) {
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
|
||||
if (tag != null)
|
||||
{
|
||||
if (tag != null) {
|
||||
int head = tag.getInteger("Head");
|
||||
|
||||
int bgCol = TConstructRegistry.getMaterial(head).primaryColor();
|
||||
@@ -46,8 +42,7 @@ public class BattlesignGui extends GuiScreen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui ()
|
||||
{
|
||||
public void initGui() {
|
||||
buttonList.clear();
|
||||
|
||||
super.initGui();
|
||||
@@ -61,8 +56,7 @@ public class BattlesignGui extends GuiScreen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen (int mouseX, int mouseY, float something)
|
||||
{
|
||||
public void drawScreen(int mouseX, int mouseY, float something) {
|
||||
Tessellator t = Tessellator.instance;
|
||||
|
||||
GL11.glColor4f(bgColR, bgColG, bgColB, 1F);
|
||||
@@ -77,100 +71,103 @@ public class BattlesignGui extends GuiScreen
|
||||
GL11.glPushMatrix();
|
||||
|
||||
float lum = calcLuminance(bgColR, bgColG, bgColB);
|
||||
for (int i = 0; i < text.length; i++)
|
||||
{
|
||||
fontRendererObj.drawString((lum >= 35F ? EnumChatFormatting.BLACK : lum >= 31F ? EnumChatFormatting.GRAY : EnumChatFormatting.WHITE) + (i == currentLine ? "> " : "") + text[i] + (i == currentLine ? " \u00A7r" + (lum >= 35F ? EnumChatFormatting.BLACK : lum >= 31F ? EnumChatFormatting.GRAY : EnumChatFormatting.WHITE) + "<" : ""), k - fontRendererObj.getStringWidth((i == currentLine ? "> " : "") + text[i] + (i == currentLine ? " <" : "")) / 2 + 51, l + 4 + 10 * i, 0);
|
||||
for (int i = 0; i < text.length; i++) {
|
||||
fontRendererObj.drawString(
|
||||
(lum >= 35F
|
||||
? EnumChatFormatting.BLACK
|
||||
: lum >= 31F ? EnumChatFormatting.GRAY : EnumChatFormatting.WHITE)
|
||||
+ (i == currentLine ? "> " : "")
|
||||
+ text[i]
|
||||
+ (i == currentLine
|
||||
? " \u00A7r"
|
||||
+ (lum >= 35F
|
||||
? EnumChatFormatting.BLACK
|
||||
: lum >= 31F ? EnumChatFormatting.GRAY : EnumChatFormatting.WHITE)
|
||||
+ "<"
|
||||
: ""),
|
||||
k
|
||||
- fontRendererObj.getStringWidth(
|
||||
(i == currentLine ? "> " : "") + text[i] + (i == currentLine ? " <" : ""))
|
||||
/ 2
|
||||
+ 51,
|
||||
l + 4 + 10 * i,
|
||||
0);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped (char c, int i)
|
||||
{
|
||||
protected void keyTyped(char c, int i) {
|
||||
super.keyTyped(c, i);
|
||||
|
||||
if (fontRendererObj.getStringWidth(text[currentLine]) < 90 && ChatAllowedCharacters.isAllowedCharacter(c))
|
||||
{
|
||||
if (Keyboard.isKeyDown(56) && c == 'f' && (text[currentLine].length() == 0 || text[currentLine].charAt(text[currentLine].length() - 1) != '\u00A7'))
|
||||
{
|
||||
if (fontRendererObj.getStringWidth(text[currentLine]) < 90 && ChatAllowedCharacters.isAllowedCharacter(c)) {
|
||||
if (Keyboard.isKeyDown(56)
|
||||
&& c == 'f'
|
||||
&& (text[currentLine].length() == 0
|
||||
|| text[currentLine].charAt(text[currentLine].length() - 1) != '\u00A7')) {
|
||||
text[currentLine] += "\u00A7";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
text[currentLine] += c;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 14:
|
||||
if (text[currentLine].length() > 0)
|
||||
{
|
||||
text[currentLine] = text[currentLine].substring(0, text[currentLine].length() - 1);
|
||||
}
|
||||
} else {
|
||||
switch (i) {
|
||||
case 14:
|
||||
if (text[currentLine].length() > 0) {
|
||||
text[currentLine] = text[currentLine].substring(0, text[currentLine].length() - 1);
|
||||
}
|
||||
|
||||
break;
|
||||
case 28:
|
||||
moveLine(1);
|
||||
break;
|
||||
case 200:
|
||||
moveLine(-1);
|
||||
break;
|
||||
case 208:
|
||||
moveLine(1);
|
||||
break;
|
||||
break;
|
||||
case 28:
|
||||
moveLine(1);
|
||||
break;
|
||||
case 200:
|
||||
moveLine(-1);
|
||||
break;
|
||||
case 208:
|
||||
moveLine(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void moveLine (int i)
|
||||
{
|
||||
if (i < 0)
|
||||
{
|
||||
if (currentLine <= 0)
|
||||
{
|
||||
private void moveLine(int i) {
|
||||
if (i < 0) {
|
||||
if (currentLine <= 0) {
|
||||
currentLine = text.length - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
currentLine--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentLine >= text.length - 1)
|
||||
{
|
||||
} else {
|
||||
if (currentLine >= text.length - 1) {
|
||||
currentLine = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
currentLine++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed ()
|
||||
{
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
|
||||
TConstruct.packetPipeline.sendToServer(new SignDataPacket(battlesign.getWorldObj().provider.dimensionId, battlesign.xCoord, battlesign.yCoord, battlesign.zCoord, text));
|
||||
TConstruct.packetPipeline.sendToServer(new SignDataPacket(
|
||||
battlesign.getWorldObj().provider.dimensionId,
|
||||
battlesign.xCoord,
|
||||
battlesign.yCoord,
|
||||
battlesign.zCoord,
|
||||
text));
|
||||
}
|
||||
|
||||
private float calcLuminance (float r, float g, float b)
|
||||
{
|
||||
private float calcLuminance(float r, float g, float b) {
|
||||
return (r * 255 * 0.299f + g * 255 * 0.587f + b * 255 * 0.114f) / 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed (GuiButton button)
|
||||
{
|
||||
if (button.id == 0)
|
||||
{
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
if (button.id == 0) {
|
||||
this.mc.displayGuiScreen((GuiScreen) null);
|
||||
this.mc.setIngameFocus();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ChestSlot extends Slot {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean func_111238_b/*isEnabled*/() {
|
||||
public boolean func_111238_b /*isEnabled*/() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@@ -57,4 +57,10 @@ public class ChestSlot extends Slot {
|
||||
}
|
||||
return super.canTakeStack(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
ItemStack stack = super.getStack();
|
||||
return (stack != null && stack.stackSize > 0) ? stack : null;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,9 @@ import codechicken.nei.VisiblityData;
|
||||
import codechicken.nei.api.INEIGuiHandler;
|
||||
import codechicken.nei.api.TaggedInventoryArea;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -22,17 +25,13 @@ import tconstruct.library.tools.ToolMaterial;
|
||||
import tconstruct.library.util.HarvestLevels;
|
||||
import tconstruct.tools.logic.CraftingStationLogic;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems")
|
||||
public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
/*
|
||||
* Slider/slots related. Taken & adapted from Tinkers Construct 1.12 under the MIT License
|
||||
*/
|
||||
private static final ResourceLocation gui_inventory = new ResourceLocation("tinker", "textures/gui/generic.png");
|
||||
|
||||
|
||||
public static final GuiElementScalable slotElement = new GuiElementScalable(7, 7, 18, 18, 64, 64);
|
||||
public static final GuiElementScalable slotEmptyElement = new GuiElementScalable(7 + 18, 7, 18, 18, 64, 64);
|
||||
|
||||
@@ -44,7 +43,8 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
private static final GuiElementScalable sliderBackground = new GuiElementScalable(43, 8, 12, 30, 64, 64);
|
||||
private static final GuiElementScalable textBackground = new GuiElementScalable(7 + 18, 7, 18, 10, 64, 64);
|
||||
|
||||
private final GuiSliderWidget slider = new GuiSliderWidget(sliderNormal, sliderHigh, sliderLow, sliderTop, sliderBottom, sliderBackground);
|
||||
private final GuiSliderWidget slider =
|
||||
new GuiSliderWidget(sliderNormal, sliderHigh, sliderLow, sliderTop, sliderBottom, sliderBackground);
|
||||
private final GuiBorderWidget border = new GuiBorderWidget();
|
||||
|
||||
private int firstSlotId;
|
||||
@@ -52,7 +52,7 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
private int chestSlotCount;
|
||||
|
||||
/* end slider/slots */
|
||||
|
||||
|
||||
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");
|
||||
@@ -64,19 +64,19 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
public GuiTextField text;
|
||||
public String title, body = "";
|
||||
CraftingStationLogic logic;
|
||||
|
||||
|
||||
private int craftingLeft = 0;
|
||||
private int craftingTop = 0;
|
||||
private int craftingTextLeft = 0;
|
||||
private int descLeft = 0;
|
||||
private int descTop = 0;
|
||||
private int descTextLeft = 0;
|
||||
|
||||
|
||||
private int chestLeft = 0;
|
||||
private int chestTop = 0;
|
||||
private int chestWidth = 0;
|
||||
private int chestHeight = 0;
|
||||
|
||||
|
||||
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;
|
||||
@@ -119,43 +119,52 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
if (logic.chest != null) {
|
||||
if (logic.chest.get() instanceof TileEntity) {
|
||||
TileEntity te = (TileEntity) logic.chest.get();
|
||||
if (te == null || te.getWorldObj().getTileEntity(te.xCoord, te.yCoord, te.zCoord) == null && te.getWorldObj().isRemote) {
|
||||
if (te == null
|
||||
|| te.getWorldObj().getTileEntity(te.xCoord, te.yCoord, te.zCoord) == null
|
||||
&& te.getWorldObj().isRemote) {
|
||||
mc.thePlayer.closeScreen();
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal(logic.chest.get().getInventoryName()), 8, 6, 0x202020);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal(logic.chest.get().getInventoryName()), 8, 6, 0x202020);
|
||||
}
|
||||
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal(logic.tinkerTable ? "crafters.TinkerTable" : logic.getInvName()), craftingTextLeft + 8, 6, 0x202020);
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), craftingTextLeft + 8, 72, 0x202020);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal(logic.tinkerTable ? "crafters.TinkerTable" : logic.getInvName()),
|
||||
craftingTextLeft + 8,
|
||||
6,
|
||||
0x202020);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("container.inventory"), craftingTextLeft + 8, 72, 0x202020);
|
||||
|
||||
if (logic.tinkerTable) {
|
||||
if (logic.isStackInSlot(0)) // output slot = modified item
|
||||
drawToolStats(logic.getStackInSlot(0));
|
||||
drawToolStats(logic.getStackInSlot(0));
|
||||
else if (logic.isStackInSlot(5)) { // center slot if no output item
|
||||
// other slots empty?
|
||||
if (!logic.isStackInSlot(1) && !logic.isStackInSlot(2) && !logic.isStackInSlot(3) && !logic.isStackInSlot(4)
|
||||
&& !logic.isStackInSlot(6) && !logic.isStackInSlot(7) && !logic.isStackInSlot(8) && !logic.isStackInSlot(9))
|
||||
drawToolStats(logic.getStackInSlot(5));
|
||||
else
|
||||
drawToolInformation();
|
||||
} else
|
||||
drawToolInformation();
|
||||
if (!logic.isStackInSlot(1)
|
||||
&& !logic.isStackInSlot(2)
|
||||
&& !logic.isStackInSlot(3)
|
||||
&& !logic.isStackInSlot(4)
|
||||
&& !logic.isStackInSlot(6)
|
||||
&& !logic.isStackInSlot(7)
|
||||
&& !logic.isStackInSlot(8)
|
||||
&& !logic.isStackInSlot(9)) drawToolStats(logic.getStackInSlot(5));
|
||||
else drawToolInformation();
|
||||
} else drawToolInformation();
|
||||
}
|
||||
}
|
||||
|
||||
void drawToolStats(ItemStack stack) {
|
||||
if (stack.getItem() instanceof IModifyable)
|
||||
ToolStationGuiHelper.drawToolStats(stack, descTextLeft + 10, 0);
|
||||
if (stack.getItem() instanceof IModifyable) ToolStationGuiHelper.drawToolStats(stack, descTextLeft + 10, 0);
|
||||
|
||||
int matID = PatternBuilder.instance.getPartID(stack);
|
||||
|
||||
if (matID != Short.MAX_VALUE && matID > 0) {
|
||||
ToolMaterial material = TConstructRegistry.getMaterial(matID);
|
||||
|
||||
if (material != null)
|
||||
drawMaterialStats(material);
|
||||
if (material != null) drawMaterialStats(material);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,17 +183,44 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
|
||||
drawCenteredString(this.fontRendererObj, centerTitle, baseX + 55, baseY, 16777215);
|
||||
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter4") + materialEnum.durability(), baseX, baseY + 16, 16777215);
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter5") + materialEnum.handleDurability() + "x", baseX, baseY + 27, 16777215);
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter6") + materialEnum.toolSpeed() / 100f, baseX, baseY + 38, 16777215);
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter7") + HarvestLevels.getHarvestLevelName(materialEnum.harvestLevel()), baseX, baseY + 49, 16777215);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter4") + materialEnum.durability(),
|
||||
baseX,
|
||||
baseY + 16,
|
||||
16777215);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter5") + materialEnum.handleDurability() + "x",
|
||||
baseX,
|
||||
baseY + 27,
|
||||
16777215);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter6") + materialEnum.toolSpeed() / 100f,
|
||||
baseX,
|
||||
baseY + 38,
|
||||
16777215);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter7")
|
||||
+ HarvestLevels.getHarvestLevelName(materialEnum.harvestLevel()),
|
||||
baseX,
|
||||
baseY + 49,
|
||||
16777215);
|
||||
|
||||
int attack = materialEnum.attack();
|
||||
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
|
||||
String heart = attack == 2
|
||||
? StatCollector.translateToLocal("gui.partcrafter8")
|
||||
: StatCollector.translateToLocal("gui.partcrafter9");
|
||||
if (attack % 2 == 0)
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter10") + attack / 2 + heart, baseX, baseY + 60, 0xffffff);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter10") + attack / 2 + heart,
|
||||
baseX,
|
||||
baseY + 60,
|
||||
0xffffff);
|
||||
else
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter10") + attack / 2f + heart, baseX, baseY + 60, 0xffffff);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter10") + attack / 2f + heart,
|
||||
baseX,
|
||||
baseY + 60,
|
||||
0xffffff);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -207,9 +243,8 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
|
||||
this.mc.getTextureManager().bindTexture(gui_inventory);
|
||||
if(hasChest()) {
|
||||
if (hasChest()) {
|
||||
chestLeft += border.w;
|
||||
chestTop += border.h;
|
||||
|
||||
@@ -243,7 +278,6 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
this.mc.getTextureManager().bindTexture(description);
|
||||
this.drawTexturedModalRect(this.descLeft, this.descTop, 0, 0, 126, 172);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -275,19 +309,19 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
@Override
|
||||
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
|
||||
final int cw = (logic.chest != null ? chestWidth : 0);
|
||||
if(logic.chest != null) {
|
||||
if (logic.chest != null) {
|
||||
final Rectangle blah = new Rectangle(x, y, w, h);
|
||||
final Rectangle chestRectangle = new Rectangle(
|
||||
chestLeft, chestTop, chestWidth, chestHeight + (shouldDrawName() ? textBackground.y : 0) + (border.h * 2)
|
||||
);
|
||||
|
||||
if(chestRectangle.intersects(blah))
|
||||
return true;
|
||||
chestLeft,
|
||||
chestTop,
|
||||
chestWidth,
|
||||
chestHeight + (shouldDrawName() ? textBackground.y : 0) + (border.h * 2));
|
||||
|
||||
if (chestRectangle.intersects(blah)) return true;
|
||||
}
|
||||
|
||||
if (y + h - 4 < guiTop || y + 4 > guiTop + ySize)
|
||||
return false;
|
||||
|
||||
|
||||
if (y + h - 4 < guiTop || y + 4 > guiTop + ySize) return false;
|
||||
|
||||
return x - w - 4 >= guiLeft + cw && x + 4 <= guiLeft + xSize + cw + (logic.tinkerTable ? 126 : 0);
|
||||
}
|
||||
|
||||
@@ -298,14 +332,16 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
public boolean isMouseInChest(int mouseX, int mouseY) {
|
||||
final int xMod = (slider.isEnabled() ? slider.width : 0) + border.w;
|
||||
final int yMod = (shouldDrawName() ? textBackground.y : 0) + (border.h * 2);
|
||||
|
||||
return mouseX >= (this.chestLeft - xMod) && mouseX < (chestLeft + chestWidth + xMod) &&
|
||||
mouseY >= (this.chestTop - yMod) && mouseY < (chestTop + chestHeight + yMod);
|
||||
|
||||
return mouseX >= (this.chestLeft - xMod)
|
||||
&& mouseX < (chestLeft + chestWidth + xMod)
|
||||
&& mouseY >= (this.chestTop - yMod)
|
||||
&& mouseY < (chestTop + chestHeight + yMod);
|
||||
}
|
||||
|
||||
public boolean isMouseOverFullSlot(int mouseX, int mouseY) {
|
||||
for(final Object slot : inventorySlots.inventorySlots) {
|
||||
if(isMouseOverSlot((Slot)slot, mouseX, mouseY) && ((Slot)slot).getHasStack()) {
|
||||
for (final Object slot : inventorySlots.inventorySlots) {
|
||||
if (isMouseOverSlot((Slot) slot, mouseX, mouseY) && ((Slot) slot).getHasStack()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -313,22 +349,24 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
}
|
||||
|
||||
protected boolean shouldDrawName() {
|
||||
return this.logic.chest != null && this.logic.chest.get().getInventoryName() != null && !this.logic.chest.get().getInventoryName().isEmpty();
|
||||
return this.logic.chest != null
|
||||
&& this.logic.chest.get().getInventoryName() != null
|
||||
&& !this.logic.chest.get().getInventoryName().isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void func_146977_a/*drawSlot*/(Slot slot) {
|
||||
if(!slot.func_111238_b/*isEnabled*/()) return;
|
||||
|
||||
public void func_146977_a /*drawSlot*/(Slot slot) {
|
||||
if (!slot.func_111238_b /*isEnabled*/()) return;
|
||||
|
||||
super.func_146977_a(slot);
|
||||
}
|
||||
|
||||
|
||||
public boolean shouldDrawSlot(Slot slot) {
|
||||
if(!(slot instanceof ChestSlot)) return true;
|
||||
if (!(slot instanceof ChestSlot)) return true;
|
||||
ChestSlot chestSlot = (ChestSlot) slot;
|
||||
|
||||
// all visible
|
||||
if(!slider.isEnabled()) return true;
|
||||
if (!slider.isEnabled()) return true;
|
||||
|
||||
return firstSlotId <= chestSlot.getVisualIndex() && lastSlotId > chestSlot.getVisualIndex();
|
||||
}
|
||||
@@ -337,7 +375,7 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
public boolean isMouseOverSlot(Slot slotIn, int mouseX, int mouseY) {
|
||||
return super.isMouseOverSlot(slotIn, mouseX, mouseY) && shouldDrawSlot(slotIn);
|
||||
}
|
||||
|
||||
|
||||
private int getDisplayedRows() {
|
||||
return chestHeight / slotElement.h;
|
||||
}
|
||||
@@ -346,7 +384,7 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
int h = slotElement.h * logic.invRows;
|
||||
|
||||
// not higher than the max
|
||||
while(h > max) {
|
||||
while (h > max) {
|
||||
h -= slotElement.h;
|
||||
}
|
||||
return h;
|
||||
@@ -362,28 +400,32 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
chestSlotCount = logic.slotCount;
|
||||
|
||||
// slider needed?
|
||||
if(getDisplayedRows() < logic.invRows) {
|
||||
if (getDisplayedRows() < logic.invRows) {
|
||||
slider.enable();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
slider.disable();
|
||||
}
|
||||
|
||||
chestWidth = logic.invColumns * CraftingStationGui.slotElement.w + 2 * border.w + (slider.isEnabled() ? slider.width : 0);
|
||||
chestWidth = logic.invColumns * CraftingStationGui.slotElement.w
|
||||
+ 2 * border.w
|
||||
+ (slider.isEnabled() ? slider.width : 0);
|
||||
|
||||
chestLeft = guiLeft - chestWidth;
|
||||
chestTop = guiTop;
|
||||
|
||||
// Leaving out the xSize increase by chestSize and adjusting where it's used, because otherwise it shifts both the bookmarks and item panel
|
||||
// Leaving out the xSize increase by chestSize and adjusting where it's used, because otherwise it shifts both
|
||||
// the bookmarks and item panel
|
||||
// way too far out. If anything (mouseClick, for example) relies on xSize, you'll need to hack it like below.
|
||||
// xSize += guiLeft - chestLeft;
|
||||
// xSize += guiLeft - chestLeft;
|
||||
guiLeft = chestLeft;
|
||||
|
||||
border.setPosition(chestLeft, chestTop);
|
||||
border.setSize(chestWidth, chestHeight + (shouldDrawName() ? textBackground.h : 0) + 2 * border.h);
|
||||
|
||||
slider.show();
|
||||
slider.setPosition(chestLeft + logic.invColumns * slotElement.w + border.w, chestTop + (shouldDrawName() ? textBackground.h : 0) + border.h);
|
||||
slider.setPosition(
|
||||
chestLeft + logic.invColumns * slotElement.w + border.w,
|
||||
chestTop + (shouldDrawName() ? textBackground.h : 0) + border.h);
|
||||
slider.setSize(chestHeight);
|
||||
slider.setSliderParameters(0, logic.invRows - getDisplayedRows(), 1);
|
||||
|
||||
@@ -393,7 +435,7 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int button) {
|
||||
// Hacks
|
||||
final int height = ySize;
|
||||
final int height = ySize;
|
||||
|
||||
if (logic.chest != null && x >= guiLeft && x <= guiLeft + chestWidth) {
|
||||
ySize = border.height;
|
||||
@@ -404,11 +446,11 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
xSize -= chestWidth;
|
||||
ySize = height;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void mouseMovedOrUp(int x, int y, int button) {
|
||||
// Hacks
|
||||
final int height = ySize;
|
||||
final int height = ySize;
|
||||
|
||||
if (logic.chest != null && x >= guiLeft && x <= guiLeft + chestWidth) {
|
||||
ySize = border.height;
|
||||
@@ -419,29 +461,29 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
xSize -= chestWidth;
|
||||
ySize = height;
|
||||
}
|
||||
|
||||
|
||||
// updates slot visibility
|
||||
protected void updateChestSlots() {
|
||||
if(!hasChest()) return;
|
||||
|
||||
if (!hasChest()) return;
|
||||
|
||||
final IInventory secondInventory = logic.getSecondInventory();
|
||||
|
||||
|
||||
int xOffset = border.w;
|
||||
int yOffset = border.h;
|
||||
|
||||
if(shouldDrawName()) {
|
||||
|
||||
if (shouldDrawName()) {
|
||||
yOffset += textBackground.h;
|
||||
}
|
||||
|
||||
|
||||
firstSlotId = slider.getValue() * logic.invColumns;
|
||||
lastSlotId = Math.min(chestSlotCount, firstSlotId + getDisplayedRows() * logic.invColumns);
|
||||
|
||||
for(Object o : inventorySlots.inventorySlots) {
|
||||
if(!(o instanceof ChestSlot)) continue;
|
||||
|
||||
final ChestSlot slot = (ChestSlot)o;
|
||||
|
||||
if(shouldDrawSlot(slot)) {
|
||||
|
||||
for (Object o : inventorySlots.inventorySlots) {
|
||||
if (!(o instanceof ChestSlot)) continue;
|
||||
|
||||
final ChestSlot slot = (ChestSlot) o;
|
||||
|
||||
if (shouldDrawSlot(slot)) {
|
||||
slot.enable();
|
||||
// calc position of the slot
|
||||
final int offset = slot.getVisualIndex() - firstSlotId;
|
||||
@@ -450,39 +492,36 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
|
||||
slot.xDisplayPosition = x + xOffset + 1 /*- this.chestWidth*/;
|
||||
slot.yDisplayPosition = y + yOffset + 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
slot.disable();
|
||||
slot.xDisplayPosition = 0;
|
||||
slot.yDisplayPosition = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// drawSlots
|
||||
protected void drawChestSlots(int xPos, int yPos) {
|
||||
if(!hasChest()) return;
|
||||
|
||||
if (!hasChest()) return;
|
||||
|
||||
int width = logic.invColumns * slotElement.w;
|
||||
int height = chestHeight - border.h * 2;
|
||||
|
||||
int fullRows = (lastSlotId - firstSlotId) / logic.invColumns;
|
||||
int slotsLeft = (lastSlotId - firstSlotId) % logic.invColumns;
|
||||
|
||||
|
||||
int y; // We use it after the loop
|
||||
for(y = 0; y < fullRows * slotElement.h && y < height; y += slotElement.h) {
|
||||
for (y = 0; y < fullRows * slotElement.h && y < height; y += slotElement.h) {
|
||||
slotElement.drawScaledX(xPos, yPos + y, width);
|
||||
}
|
||||
|
||||
// draw partial row and unused slots
|
||||
if(slotsLeft > 0) {
|
||||
if (slotsLeft > 0) {
|
||||
slotElement.drawScaledX(xPos, yPos + y, slotsLeft * slotElement.w);
|
||||
// empty slots that don't exist
|
||||
slotEmptyElement.drawScaledX(xPos + slotsLeft * slotElement.w, yPos + y, width - slotsLeft * slotElement.w);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Hide the deprecated stuff at the bottom
|
||||
|
||||
@@ -7,35 +7,31 @@ import net.minecraft.world.World;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tconstruct.tools.logic.FrypanLogic;
|
||||
|
||||
public class FrypanGui extends GuiContainer
|
||||
{
|
||||
public class FrypanGui extends GuiContainer {
|
||||
public FrypanLogic logic;
|
||||
|
||||
public FrypanGui(InventoryPlayer inventoryplayer, FrypanLogic frypan, World world, int x, int y, int z)
|
||||
{
|
||||
public FrypanGui(InventoryPlayer inventoryplayer, FrypanLogic frypan, World world, int x, int y, int z) {
|
||||
super(frypan.getGuiContainer(inventoryplayer, world, x, y, z));
|
||||
logic = frypan;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
||||
{
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("crafters.Frypan"), 60, 6, 0x404040);
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/frypan.png");
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer (float f, int i, int j)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (logic.fuel > 0) {
|
||||
int fuel = logic.gaugeFuelScaled(12);
|
||||
drawTexturedModalRect(cornerX + 27, (cornerY + 40) - fuel, 176, 12 - fuel, 14, fuel + 2);
|
||||
}
|
||||
|
||||
@@ -10,13 +10,12 @@ import tconstruct.tools.inventory.FurnaceContainer;
|
||||
import tconstruct.tools.logic.FurnaceLogic;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class FurnaceGui extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation furnaceGuiTextures = new ResourceLocation("textures/gui/container/furnace.png");
|
||||
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)
|
||||
{
|
||||
public FurnaceGui(InventoryPlayer inventory, FurnaceLogic furnace) {
|
||||
super(new FurnaceContainer(inventory, furnace));
|
||||
this.logic = furnace;
|
||||
}
|
||||
@@ -26,8 +25,7 @@ public class FurnaceGui extends GuiContainer
|
||||
* the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
||||
{
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
String s = this.logic.isInvNameLocalized() ? this.logic.getInvName() : I18n.format(this.logic.getInvName());
|
||||
this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
@@ -38,8 +36,7 @@ public class FurnaceGui extends GuiContainer
|
||||
* items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
|
||||
{
|
||||
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;
|
||||
@@ -47,8 +44,7 @@ public class FurnaceGui extends GuiContainer
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
int i1;
|
||||
|
||||
if (this.logic.isBurning())
|
||||
{
|
||||
if (this.logic.isBurning()) {
|
||||
i1 = this.logic.gaugeFuelScaled(12);
|
||||
this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
package tconstruct.tools.gui;
|
||||
|
||||
/*
|
||||
* Taken from Tinker's Construct 1.12 under the MIT License
|
||||
*
|
||||
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* Taken from Tinker's Construct 1.12 under the MIT License
|
||||
*
|
||||
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
public class GuiBorderWidget {
|
||||
// all elements based on generic gui
|
||||
@@ -44,7 +44,7 @@ public class GuiBorderWidget {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
|
||||
/** Sets the size so that the given point is the upper left corner of the inside */
|
||||
public void setPosInner(int x, int y) {
|
||||
setPosition(x - cornerTopLeft.w, y - cornerTopLeft.h);
|
||||
|
||||
@@ -6,20 +6,20 @@ import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tconstruct.library.client.StencilGuiElement;
|
||||
|
||||
public class GuiButtonStencil extends GuiButton
|
||||
{
|
||||
public class GuiButtonStencil extends GuiButton {
|
||||
/**
|
||||
* True for pointing right (next page), false for pointing left (previous
|
||||
* page).
|
||||
*/
|
||||
int textureX;
|
||||
|
||||
int textureY;
|
||||
public String texture;
|
||||
public StencilGuiElement element;
|
||||
private static ResourceLocation background;
|
||||
|
||||
public GuiButtonStencil(int id, int posX, int posY, int texX, int texY, String domain, String tex, StencilGuiElement e)
|
||||
{
|
||||
public GuiButtonStencil(
|
||||
int id, int posX, int posY, int texX, int texY, String domain, String tex, StencilGuiElement e) {
|
||||
super(id, posX, posY, 18, 18, "");
|
||||
textureX = texX;
|
||||
textureY = texY;
|
||||
@@ -32,15 +32,19 @@ public class GuiButtonStencil extends GuiButton
|
||||
* Draws this button to the screen.
|
||||
*/
|
||||
@Override
|
||||
public void drawButton (Minecraft mc, int mouseX, int mouseY)
|
||||
{
|
||||
if (this.visible)
|
||||
{
|
||||
boolean var4 = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (this.visible) {
|
||||
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_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||
this.field_146123_n = mouseX >= this.xPosition
|
||||
&& mouseY >= this.yPosition
|
||||
&& mouseX < this.xPosition + this.width
|
||||
&& mouseY < this.yPosition + this.height;
|
||||
int var5 = this.getHoverState(this.field_146123_n);
|
||||
int index = 18 * getHoverState(field_146123_n);
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, 144 + index * 2, 234, 18, 18);
|
||||
|
||||
@@ -8,22 +8,21 @@ import org.lwjgl.opengl.GL11;
|
||||
import tconstruct.library.client.ToolGuiElement;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiButtonTool extends GuiButton
|
||||
{
|
||||
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 ResourceLocation background;// = new
|
||||
// ResourceLocation("tinker",
|
||||
// "textures/gui/armorextended.png");
|
||||
private 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)
|
||||
{
|
||||
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;
|
||||
@@ -36,15 +35,19 @@ public class GuiButtonTool extends GuiButton
|
||||
* Draws this button to the screen.
|
||||
*/
|
||||
@Override
|
||||
public void drawButton (Minecraft mc, int mouseX, int mouseY)
|
||||
{
|
||||
if (this.visible)
|
||||
{
|
||||
boolean var4 = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (this.visible) {
|
||||
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_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||
this.field_146123_n = mouseX >= this.xPosition
|
||||
&& mouseY >= this.yPosition
|
||||
&& mouseX < this.xPosition + this.width
|
||||
&& mouseY < this.yPosition + this.height;
|
||||
int var5 = this.getHoverState(this.field_146123_n);
|
||||
int index = 18 * getHoverState(field_146123_n);
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, 144 + index * 2, 216, 18, 18);
|
||||
|
||||
@@ -5,20 +5,20 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
/*
|
||||
* Taken from Mantle 1.12-1.3.3.49 under the MIT License
|
||||
*
|
||||
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* Taken from Mantle 1.12-1.3.3.49 under the MIT License
|
||||
*
|
||||
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiElementDuex {
|
||||
@@ -88,4 +88,4 @@ public class GuiElementDuex {
|
||||
return new GuiElementDuex(x, y, w, h, this.w, this.h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,20 +5,20 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
/*
|
||||
* Taken from Mantle 1.12-1.3.3.49 under the MIT License
|
||||
*
|
||||
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* Taken from Mantle 1.12-1.3.3.49 under the MIT License
|
||||
*
|
||||
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiElementScalable extends GuiElementDuex {
|
||||
@@ -32,12 +32,12 @@ public class GuiElementScalable extends GuiElementDuex {
|
||||
}
|
||||
|
||||
public int drawScaledX(int xPos, int yPos, int width) {
|
||||
for(int i = 0; i < width / w; i++) {
|
||||
for (int i = 0; i < width / w; i++) {
|
||||
draw(xPos + i * w, yPos);
|
||||
}
|
||||
// remainder that doesn't fit total width
|
||||
int remainder = width % w;
|
||||
if(remainder > 0) {
|
||||
if (remainder > 0) {
|
||||
GuiScreen.func_146110_a(xPos + width - remainder, yPos, x, y, remainder, h, texW, texH);
|
||||
}
|
||||
|
||||
@@ -45,12 +45,12 @@ public class GuiElementScalable extends GuiElementDuex {
|
||||
}
|
||||
|
||||
public int drawScaledY(int xPos, int yPos, int height) {
|
||||
for(int i = 0; i < height / h; i++) {
|
||||
for (int i = 0; i < height / h; i++) {
|
||||
draw(xPos, yPos + i * h);
|
||||
}
|
||||
// remainder that doesn't fit total width
|
||||
int remainder = height % h;
|
||||
if(remainder > 0) {
|
||||
if (remainder > 0) {
|
||||
// drawModalRectWithCustomSizedTexture
|
||||
GuiScreen.func_146110_a(xPos, yPos + height - remainder, x, y, w, remainder, texW, texH);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class GuiElementScalable extends GuiElementDuex {
|
||||
public int drawScaled(int xPos, int yPos, int width, int height) {
|
||||
// we draw full height row-wise
|
||||
int full = height / this.h;
|
||||
for(int i = 0; i < full; i++) {
|
||||
for (int i = 0; i < full; i++) {
|
||||
drawScaledX(xPos, yPos + i * this.h, width);
|
||||
}
|
||||
|
||||
@@ -70,12 +70,12 @@ public class GuiElementScalable extends GuiElementDuex {
|
||||
// and the remainder is drawn manually
|
||||
int yRest = height % this.h;
|
||||
// the same as drawScaledX but with the remaining height
|
||||
for(int i = 0; i < width / w; i++) {
|
||||
for (int i = 0; i < width / w; i++) {
|
||||
drawScaledY(xPos + i * w, yPos, yRest);
|
||||
}
|
||||
// remainder that doesn't fit total width
|
||||
int remainder = width % w;
|
||||
if(remainder > 0) {
|
||||
if (remainder > 0) {
|
||||
// drawModalRectWithCustomSizedTexture
|
||||
GuiScreen.func_146110_a(xPos + width - remainder, yPos, x, y, remainder, yRest, texW, texH);
|
||||
}
|
||||
@@ -89,4 +89,4 @@ public class GuiElementScalable extends GuiElementDuex {
|
||||
element.setTextureSize(texW, texH);
|
||||
return element;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,20 +5,20 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
/*
|
||||
* Taken from Mantle 1.12-1.3.3.49 under the MIT License
|
||||
*
|
||||
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* Taken from Mantle 1.12-1.3.3.49 under the MIT License
|
||||
*
|
||||
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
// a vertical slider!
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -51,7 +51,13 @@ public class GuiSliderWidget {
|
||||
private int clickY;
|
||||
private boolean clickedBar; // if the bar has already been clicked and not released
|
||||
|
||||
public GuiSliderWidget(GuiElementDuex slider, GuiElementDuex sliderHighlighted, GuiElementDuex sliderDisabled, GuiElementDuex slideBarTop, GuiElementDuex slideBarBottom, GuiElementScalable slideBar) {
|
||||
public GuiSliderWidget(
|
||||
GuiElementDuex slider,
|
||||
GuiElementDuex sliderHighlighted,
|
||||
GuiElementDuex sliderDisabled,
|
||||
GuiElementDuex slideBarTop,
|
||||
GuiElementDuex slideBarBottom,
|
||||
GuiElementScalable slideBar) {
|
||||
this.slider = slider;
|
||||
this.sliderHighlighted = sliderHighlighted;
|
||||
this.sliderDisabled = sliderDisabled;
|
||||
@@ -244,8 +250,7 @@ public class GuiSliderWidget {
|
||||
}
|
||||
}
|
||||
// not scrolling yet but possibly inside the slider
|
||||
else if (x >= 0 && y >= getSliderTop() &&
|
||||
x - sliderOffset <= slider.w && y <= getSliderTop() + slider.h) {
|
||||
else if (x >= 0 && y >= getSliderTop() && x - sliderOffset <= slider.w && y <= getSliderTop() + slider.h) {
|
||||
isHighlighted = true;
|
||||
if (mouseDown) {
|
||||
isScrolling = true;
|
||||
@@ -254,9 +259,7 @@ public class GuiSliderWidget {
|
||||
}
|
||||
}
|
||||
// not on the slider but clicked on the bar
|
||||
else if (mouseDown && !clickedBar &&
|
||||
x >= 0 && y >= 0 &&
|
||||
x <= slideBar.w && y <= height) {
|
||||
else if (mouseDown && !clickedBar && x >= 0 && y >= 0 && x <= slideBar.w && y <= height) {
|
||||
if (y < getSliderTop()) {
|
||||
decrement();
|
||||
} else {
|
||||
@@ -278,4 +281,4 @@ public class GuiSliderWidget {
|
||||
setSliderValue(currentValue + increment);
|
||||
return currentValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import codechicken.nei.VisiblityData;
|
||||
import codechicken.nei.api.INEIGuiHandler;
|
||||
import codechicken.nei.api.TaggedInventoryArea;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -19,12 +21,8 @@ import tconstruct.smeltery.inventory.ActiveContainer;
|
||||
import tconstruct.tools.inventory.PartCrafterChestContainer;
|
||||
import tconstruct.tools.logic.PartBuilderLogic;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems")
|
||||
public class PartCrafterGui extends GuiContainer implements INEIGuiHandler
|
||||
{
|
||||
public class PartCrafterGui extends GuiContainer implements INEIGuiHandler {
|
||||
PartBuilderLogic logic;
|
||||
String title, otherTitle = "";
|
||||
boolean drawChestPart;
|
||||
@@ -52,8 +50,8 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler
|
||||
private int chestLeft = 0;
|
||||
private int chestTop = 0;
|
||||
|
||||
public PartCrafterGui(InventoryPlayer inventoryplayer, PartBuilderLogic partlogic, World world, int x, int y, int z)
|
||||
{
|
||||
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 = inventorySlots instanceof PartCrafterChestContainer;
|
||||
@@ -62,8 +60,7 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui ()
|
||||
{
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
this.xSize = CRAFT_WIDTH;
|
||||
@@ -78,120 +75,166 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler
|
||||
this.descLeft = this.craftingLeft + CRAFT_WIDTH;
|
||||
this.descTop = this.craftingTop;
|
||||
|
||||
if (drawChestPart)
|
||||
{
|
||||
if (drawChestPart) {
|
||||
this.xSize += CHEST_WIDTH - 6;
|
||||
this.guiLeft -= CHEST_WIDTH - 6;
|
||||
|
||||
|
||||
this.chestLeft = this.guiLeft;
|
||||
this.chestTop = this.guiTop + 11;
|
||||
}
|
||||
|
||||
|
||||
this.craftingTextLeft = this.craftingLeft - this.guiLeft;
|
||||
this.descTextLeft = this.descLeft - this.guiLeft;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
||||
{
|
||||
if (drawChestPart)
|
||||
{
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
if (drawChestPart) {
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("inventory.PatternChest"), 14, 17, 4210752);
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
drawMaterialInformation();
|
||||
}
|
||||
|
||||
void drawDefaultInformation ()
|
||||
{
|
||||
void drawDefaultInformation() {
|
||||
title = "\u00A7n" + StatCollector.translateToLocal("gui.partcrafter2");
|
||||
this.drawCenteredString(fontRendererObj, title, descTextLeft + DESC_WIDTH / 2, 8, 16777215);
|
||||
fontRendererObj.drawSplitString(StatCollector.translateToLocal("gui.partcrafter3"), descTextLeft + 8, 24, 115, 16777215);
|
||||
fontRendererObj.drawSplitString(
|
||||
StatCollector.translateToLocal("gui.partcrafter3"), descTextLeft + 8, 24, 115, 16777215);
|
||||
}
|
||||
|
||||
void drawMaterialInformation ()
|
||||
{
|
||||
void drawMaterialInformation() {
|
||||
ItemStack top = logic.getStackInSlot(2);
|
||||
//ItemStack topResult = logic.getStackInSlot(4);
|
||||
// ItemStack topResult = logic.getStackInSlot(4);
|
||||
ItemStack bottom = logic.getStackInSlot(3);
|
||||
//ItemStack bottomResult = logic.getStackInSlot(6);
|
||||
if (topMaterial != top)
|
||||
{
|
||||
// ItemStack bottomResult = logic.getStackInSlot(6);
|
||||
if (topMaterial != top) {
|
||||
topMaterial = top;
|
||||
int topID = PatternBuilder.instance.getPartID(top);
|
||||
|
||||
if (topID != Short.MAX_VALUE)// && topResult != null)
|
||||
if (topID != Short.MAX_VALUE) // && topResult != null)
|
||||
{
|
||||
topEnum = TConstructRegistry.getMaterial(topID);
|
||||
hasTop = true;
|
||||
title = "\u00A7n" + topEnum.localizedName();
|
||||
}
|
||||
else
|
||||
hasTop = false;
|
||||
} else hasTop = false;
|
||||
}
|
||||
|
||||
if (bottomMaterial != bottom)
|
||||
{
|
||||
if (bottomMaterial != bottom) {
|
||||
bottomMaterial = bottom;
|
||||
int bottomID = PatternBuilder.instance.getPartID(bottom);
|
||||
|
||||
if (bottomID != Short.MAX_VALUE)// && bottomResult != null)
|
||||
if (bottomID != Short.MAX_VALUE) // && bottomResult != null)
|
||||
{
|
||||
bottomEnum = TConstructRegistry.getMaterial(bottomID);
|
||||
hasBottom = true;
|
||||
otherTitle = "\u00A7n" + bottomEnum.localizedName();
|
||||
}
|
||||
else
|
||||
hasBottom = false;
|
||||
} else hasBottom = false;
|
||||
}
|
||||
|
||||
int offset = 8;
|
||||
if (hasTop)
|
||||
{
|
||||
if (hasTop) {
|
||||
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);
|
||||
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);
|
||||
|
||||
int attack = topEnum.attack();
|
||||
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
|
||||
String heart = attack == 2
|
||||
? StatCollector.translateToLocal("gui.partcrafter8")
|
||||
: StatCollector.translateToLocal("gui.partcrafter9");
|
||||
if (attack % 2 == 0)
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter10") + attack / 2 + heart, descTextLeft + 8, offset + 60, 0xffffff);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter10") + attack / 2 + heart,
|
||||
descTextLeft + 8,
|
||||
offset + 60,
|
||||
0xffffff);
|
||||
else
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter10") + attack / 2f + heart, descTextLeft + 8, offset + 60, 0xffffff);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter10") + attack / 2f + heart,
|
||||
descTextLeft + 8,
|
||||
offset + 60,
|
||||
0xffffff);
|
||||
}
|
||||
|
||||
offset = 90;
|
||||
if (hasBottom)
|
||||
{
|
||||
if (hasBottom) {
|
||||
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);
|
||||
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);
|
||||
int attack = bottomEnum.attack();
|
||||
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
|
||||
String heart = attack == 2
|
||||
? StatCollector.translateToLocal("gui.partcrafter8")
|
||||
: StatCollector.translateToLocal("gui.partcrafter9");
|
||||
if (attack % 2 == 0)
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter10") + attack / 2 + heart, descTextLeft + 8, offset + 60, 0xffffff);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter10") + attack / 2 + heart,
|
||||
descTextLeft + 8,
|
||||
offset + 60,
|
||||
0xffffff);
|
||||
else
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter10") + attack / 2f + heart, descTextLeft + 8, offset + 60, 0xffffff);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter10") + attack / 2f + heart,
|
||||
descTextLeft + 8,
|
||||
offset + 60,
|
||||
0xffffff);
|
||||
}
|
||||
|
||||
if (!hasTop && !hasBottom)
|
||||
drawDefaultInformation();
|
||||
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 minichest =
|
||||
new ResourceLocation("tinker", "textures/gui/patternchestmini.png");
|
||||
private static final ResourceLocation description = new ResourceLocation("tinker", "textures/gui/description.png");
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
|
||||
{
|
||||
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);
|
||||
@@ -199,26 +242,21 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler
|
||||
|
||||
// Draw Slots
|
||||
this.drawTexturedModalRect(craftingLeft + 39, craftingTop + 26, 0, 166, 98, 36);
|
||||
if (!logic.isStackInSlot(0))
|
||||
{
|
||||
if (!logic.isStackInSlot(0)) {
|
||||
this.drawTexturedModalRect(craftingLeft + 39, craftingTop + 26, 176, 0, 18, 18);
|
||||
}
|
||||
if (!logic.isStackInSlot(2))
|
||||
{
|
||||
if (!logic.isStackInSlot(2)) {
|
||||
this.drawTexturedModalRect(craftingLeft + 57, craftingTop + 26, 176, 18, 18, 18);
|
||||
}
|
||||
if (!logic.isStackInSlot(1))
|
||||
{
|
||||
if (!logic.isStackInSlot(1)) {
|
||||
this.drawTexturedModalRect(craftingLeft + 39, craftingTop + 44, 176, 0, 18, 18);
|
||||
}
|
||||
if (!logic.isStackInSlot(3))
|
||||
{
|
||||
if (!logic.isStackInSlot(3)) {
|
||||
this.drawTexturedModalRect(craftingLeft + 57, craftingTop + 44, 176, 36, 18, 18);
|
||||
}
|
||||
|
||||
// Draw chest
|
||||
if (drawChestPart)
|
||||
{
|
||||
if (drawChestPart) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(minichest);
|
||||
this.drawTexturedModalRect(chestLeft, chestTop, 0, 0, CHEST_WIDTH, CHEST_HEIGHT);
|
||||
@@ -231,19 +269,14 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisiblityData modifyVisiblity (GuiContainer gui, VisiblityData currentVisibility)
|
||||
{
|
||||
if (width - xSize < 107)
|
||||
{
|
||||
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
|
||||
if (width - xSize < 107) {
|
||||
currentVisibility.showWidgets = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
currentVisibility.showWidgets = true;
|
||||
}
|
||||
|
||||
if (guiLeft < 58)
|
||||
{
|
||||
if (guiLeft < 58) {
|
||||
currentVisibility.showStateButtons = false;
|
||||
}
|
||||
|
||||
@@ -251,33 +284,26 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Integer> getItemSpawnSlots (GuiContainer gui, ItemStack item)
|
||||
{
|
||||
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaggedInventoryArea> getInventoryAreas (GuiContainer gui)
|
||||
{
|
||||
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleDragNDrop (GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button)
|
||||
{
|
||||
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;
|
||||
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 - w - 4 < guiLeft - 40 || x + 4 > guiLeft + xSize + DESC_WIDTH)
|
||||
return false;
|
||||
if (x - w - 4 < guiLeft - 40 || x + 4 > guiLeft + xSize + DESC_WIDTH) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,11 @@ import net.minecraft.world.World;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tconstruct.tools.logic.PatternChestLogic;
|
||||
|
||||
public class PatternChestGui extends GuiContainer
|
||||
{
|
||||
public class PatternChestGui extends GuiContainer {
|
||||
public PatternChestLogic logic;
|
||||
|
||||
public PatternChestGui(InventoryPlayer inventoryplayer, PatternChestLogic holder, World world, int x, int y, int z)
|
||||
{
|
||||
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;
|
||||
@@ -20,17 +19,16 @@ public class PatternChestGui extends GuiContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
||||
{
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("inventory.PatternChest"), 60, 6, 0x404040);
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 17, (ySize - 96) + 2, 0x404040);
|
||||
fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("container.inventory"), 17, (ySize - 96) + 2, 0x404040);
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/patternchest.png");
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer (float f, int i, int j)
|
||||
{
|
||||
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;
|
||||
|
||||
@@ -4,6 +4,8 @@ import codechicken.nei.VisiblityData;
|
||||
import codechicken.nei.api.INEIGuiHandler;
|
||||
import codechicken.nei.api.TaggedInventoryArea;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -18,56 +20,48 @@ import tconstruct.tools.inventory.PatternShaperContainer;
|
||||
import tconstruct.tools.logic.StencilTableLogic;
|
||||
import tconstruct.util.network.PatternTablePacket;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems")
|
||||
public class StencilTableGui extends GuiContainer implements INEIGuiHandler
|
||||
{
|
||||
int[] buttonsLeftRect = new int[]{ Integer.MAX_VALUE, Integer.MIN_VALUE };
|
||||
int[] buttonsRightRect = new int[]{ Integer.MIN_VALUE, Integer.MIN_VALUE };
|
||||
public class StencilTableGui extends GuiContainer implements INEIGuiHandler {
|
||||
int[] buttonsLeftRect = new int[] {Integer.MAX_VALUE, Integer.MIN_VALUE};
|
||||
int[] buttonsRightRect = new int[] {Integer.MIN_VALUE, Integer.MIN_VALUE};
|
||||
StencilTableLogic logic;
|
||||
int activeButton;
|
||||
|
||||
public StencilTableGui(InventoryPlayer inventoryplayer, StencilTableLogic shaper, World world, int x, int y, int z)
|
||||
{
|
||||
public StencilTableGui(
|
||||
InventoryPlayer inventoryplayer, StencilTableLogic shaper, World world, int x, int y, int z) {
|
||||
super(new PatternShaperContainer(inventoryplayer, shaper));
|
||||
logic = shaper;
|
||||
activeButton = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed ()
|
||||
{
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
||||
{
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("crafters.PatternShaper"), 50, 6, 0x404040);
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/patternshaper.png");
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
|
||||
{
|
||||
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))
|
||||
{
|
||||
if (!logic.isStackInSlot(0)) {
|
||||
this.drawTexturedModalRect(cornerX + 47, cornerY + 34, 176, 0, 18, 18);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui ()
|
||||
{
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
int bpr = 4; // buttons per row!
|
||||
@@ -75,16 +69,22 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler
|
||||
int cornerY = this.guiTop + 2;
|
||||
|
||||
this.buttonList.clear();
|
||||
this.buttonsLeftRect = new int[]{ Integer.MAX_VALUE, Integer.MIN_VALUE };
|
||||
this.buttonsRightRect = new int[]{ Integer.MIN_VALUE, Integer.MIN_VALUE };
|
||||
this.buttonsLeftRect = new int[] {Integer.MAX_VALUE, Integer.MIN_VALUE};
|
||||
this.buttonsRightRect = new int[] {Integer.MIN_VALUE, Integer.MIN_VALUE};
|
||||
|
||||
int id = 0;
|
||||
for (int iter = 0; iter < TConstructClientRegistry.stencilButtons.size(); iter++)
|
||||
{
|
||||
for (int iter = 0; iter < TConstructClientRegistry.stencilButtons.size(); iter++) {
|
||||
StencilGuiElement element = TConstructClientRegistry.stencilButtons.get(iter);
|
||||
if (element.stencilIndex == -1)
|
||||
continue;
|
||||
GuiButtonStencil button = new GuiButtonStencil(id++, cornerX + 22 * (iter % bpr), cornerY + 22 * (iter / bpr), element.buttonIconX, element.buttonIconY, element.domain, element.texture, element);
|
||||
if (element.stencilIndex == -1) continue;
|
||||
GuiButtonStencil button = new GuiButtonStencil(
|
||||
id++,
|
||||
cornerX + 22 * (iter % bpr),
|
||||
cornerY + 22 * (iter / bpr),
|
||||
element.buttonIconX,
|
||||
element.buttonIconY,
|
||||
element.domain,
|
||||
element.texture,
|
||||
element);
|
||||
this.buttonList.add(button);
|
||||
this.buttonsLeftRect[0] = Math.min(button.xPosition, this.buttonsLeftRect[0]);
|
||||
this.buttonsLeftRect[1] = Math.max(button.yPosition + button.height, this.buttonsLeftRect[1]);
|
||||
@@ -93,12 +93,18 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler
|
||||
// secondary buttons, yay!
|
||||
// these are to use for other mods :I
|
||||
cornerX = this.guiLeft + this.xSize + 4;
|
||||
for (int iter = 0; iter < TConstructClientRegistry.stencilButtons2.size(); iter++)
|
||||
{
|
||||
for (int iter = 0; iter < TConstructClientRegistry.stencilButtons2.size(); iter++) {
|
||||
StencilGuiElement element = TConstructClientRegistry.stencilButtons2.get(iter);
|
||||
if (element.stencilIndex == -1)
|
||||
continue;
|
||||
GuiButtonStencil button = new GuiButtonStencil(id++, cornerX + 22 * (iter % bpr), cornerY + 22 * (iter / bpr), element.buttonIconX, element.buttonIconY, element.domain, element.texture, element);
|
||||
if (element.stencilIndex == -1) continue;
|
||||
GuiButtonStencil button = new GuiButtonStencil(
|
||||
id++,
|
||||
cornerX + 22 * (iter % bpr),
|
||||
cornerY + 22 * (iter / bpr),
|
||||
element.buttonIconX,
|
||||
element.buttonIconY,
|
||||
element.domain,
|
||||
element.texture,
|
||||
element);
|
||||
this.buttonList.add(button);
|
||||
this.buttonsRightRect[0] = Math.max(button.xPosition + button.width, this.buttonsRightRect[0]);
|
||||
this.buttonsRightRect[1] = Math.max(button.yPosition + button.height, this.buttonsRightRect[1]);
|
||||
@@ -106,29 +112,24 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler
|
||||
|
||||
// get the correct setting :I
|
||||
ItemStack stack;
|
||||
if (logic.getStackInSlot(1) != null)
|
||||
{
|
||||
if (logic.getStackInSlot(1) != null) {
|
||||
activeButton = StencilBuilder.getId(logic.getStackInSlot(1));
|
||||
setActiveButton(activeButton);
|
||||
stack = StencilBuilder.getStencil(((GuiButtonStencil) this.buttonList.get(activeButton)).element.stencilIndex);
|
||||
}
|
||||
else
|
||||
stack = null;
|
||||
stack = StencilBuilder.getStencil(
|
||||
((GuiButtonStencil) this.buttonList.get(activeButton)).element.stencilIndex);
|
||||
} else stack = null;
|
||||
|
||||
logic.setSelectedPattern(stack);
|
||||
updateServer(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed (GuiButton button)
|
||||
{
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
ItemStack pattern = logic.getStackInSlot(0);
|
||||
if (pattern != null && StencilBuilder.isBlank(pattern))
|
||||
{
|
||||
if (pattern != null && StencilBuilder.isBlank(pattern)) {
|
||||
int id = ((GuiButtonStencil) button).element.stencilIndex;
|
||||
ItemStack stack = StencilBuilder.getStencil(id);
|
||||
if (stack != null)
|
||||
{
|
||||
if (stack != null) {
|
||||
logic.setSelectedPattern(stack);
|
||||
updateServer(stack);
|
||||
}
|
||||
@@ -137,8 +138,7 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler
|
||||
setActiveButton(button.id);
|
||||
}
|
||||
|
||||
private void setActiveButton (int id)
|
||||
{
|
||||
private void setActiveButton(int id) {
|
||||
// deactivate old button
|
||||
((GuiButton) this.buttonList.get(activeButton)).enabled = true;
|
||||
// update active button
|
||||
@@ -147,8 +147,7 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler
|
||||
((GuiButton) this.buttonList.get(activeButton)).enabled = false;
|
||||
}
|
||||
|
||||
void updateServer (ItemStack stack)
|
||||
{
|
||||
void updateServer(ItemStack stack) {
|
||||
TConstruct.packetPipeline.sendToServer(new PatternTablePacket(logic.xCoord, logic.yCoord, logic.zCoord, stack));
|
||||
}
|
||||
|
||||
@@ -173,11 +172,13 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hideItemPanelSlot(GuiContainer guiContainer, int x, int y, int w, int h)
|
||||
{
|
||||
public boolean hideItemPanelSlot(GuiContainer guiContainer, int x, int y, int w, int h) {
|
||||
|
||||
// is it in the horizontal column of the right buttons?
|
||||
if (x > this.guiLeft + this.xSize && x < this.buttonsRightRect[0] && y + h > this.guiTop && y < this.buttonsRightRect[1]) {
|
||||
if (x > this.guiLeft + this.xSize
|
||||
&& x < this.buttonsRightRect[0]
|
||||
&& y + h > this.guiTop
|
||||
&& y < this.buttonsRightRect[1]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -188,4 +189,4 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,45 +9,64 @@ import tconstruct.library.client.*;
|
||||
import tconstruct.tools.logic.ToolForgeLogic;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ToolForgeGui extends ToolStationGui
|
||||
{
|
||||
public class ToolForgeGui extends ToolStationGui {
|
||||
int selectedButton;
|
||||
|
||||
public ToolForgeGui(InventoryPlayer inventoryplayer, ToolForgeLogic stationlogic, World world, int x, int y, int z)
|
||||
{
|
||||
public ToolForgeGui(
|
||||
InventoryPlayer inventoryplayer, ToolForgeLogic stationlogic, World world, int x, int y, int z) {
|
||||
super(inventoryplayer, stationlogic, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui ()
|
||||
{
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
this.buttonList.clear();
|
||||
ToolGuiElement repair = TConstructClientRegistry.toolButtons.get(0);
|
||||
GuiButtonTool repairButton = new GuiButtonTool(0, this.guiLeft, this.guiTop, repair.buttonIconX, repair.buttonIconY, repair.domain, repair.texture, repair); // Repair
|
||||
GuiButtonTool repairButton = new GuiButtonTool(
|
||||
0,
|
||||
this.guiLeft,
|
||||
this.guiTop,
|
||||
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++)
|
||||
{
|
||||
for (int iter = 0; iter < TConstructClientRegistry.tierTwoButtons.size(); iter++) {
|
||||
ToolGuiElement element = TConstructClientRegistry.tierTwoButtons.get(iter);
|
||||
GuiButtonTool button = new GuiButtonTool(iter + 1, this.guiLeft + 22 * ((iter + 1) % 5), this.guiTop + 22 * ((iter + 1) / 5), element.buttonIconX, element.buttonIconY, element.domain, element.texture, element);
|
||||
GuiButtonTool button = new GuiButtonTool(
|
||||
iter + 1,
|
||||
this.guiLeft + 22 * ((iter + 1) % 5),
|
||||
this.guiTop + 22 * ((iter + 1) / 5),
|
||||
element.buttonIconX,
|
||||
element.buttonIconY,
|
||||
element.domain,
|
||||
element.texture,
|
||||
element);
|
||||
this.buttonList.add(button);
|
||||
}
|
||||
|
||||
for (int iter = 1; iter < TConstructClientRegistry.toolButtons.size(); iter++)
|
||||
{
|
||||
for (int iter = 1; iter < TConstructClientRegistry.toolButtons.size(); iter++) {
|
||||
ToolGuiElement element = TConstructClientRegistry.toolButtons.get(iter);
|
||||
GuiButtonTool button = new GuiButtonTool(iter + offset, this.guiLeft + 22 * ((iter + offset) % 5), this.guiTop + 22 * ((iter + offset) / 5), element.buttonIconX, element.buttonIconY, element.domain, element.texture, element);
|
||||
GuiButtonTool button = new GuiButtonTool(
|
||||
iter + offset,
|
||||
this.guiLeft + 22 * ((iter + offset) % 5),
|
||||
this.guiTop + 22 * ((iter + offset) / 5),
|
||||
element.buttonIconX,
|
||||
element.buttonIconY,
|
||||
element.domain,
|
||||
element.texture,
|
||||
element);
|
||||
this.buttonList.add(button);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed (GuiButton button)
|
||||
{
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
GuiButtonTool b = (GuiButtonTool) button;
|
||||
((GuiButton) this.buttonList.get(selectedButton)).enabled = true;
|
||||
selectedButton = button.id;
|
||||
@@ -58,73 +77,70 @@ public class ToolForgeGui extends ToolStationGui
|
||||
iconY = b.element.iconsY;
|
||||
title = "\u00A7n" + b.element.title;
|
||||
body = StatCollector.translateToLocal(b.element.body);
|
||||
if(body != null) {
|
||||
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);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void resetGui ()
|
||||
{
|
||||
void resetGui() {
|
||||
this.text.setText("");
|
||||
selectedButton = 0;
|
||||
setSlotType(0);
|
||||
iconX = new int[] { 0, 1, 2, 13 };
|
||||
iconY = new int[] { 13, 13, 13, 13 };
|
||||
iconX = new int[] {0, 1, 2, 13};
|
||||
iconY = new int[] {13, 13, 13, 13};
|
||||
title = "\u00A7n" + StatCollector.translateToLocal("gui.toolforge1");
|
||||
body = StatCollector.translateToLocal("gui.toolforge2");
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
case 8:
|
||||
slotX = new int[] { 20, 38, 56, 38 }; // Double head middle
|
||||
slotY = new int[] { 28, 46, 28, 28 };
|
||||
break;
|
||||
case 9:
|
||||
slotX = new int[] { 38, 56, 47, 47 }; // Four parts, crossbow.
|
||||
slotY = new int[] { 37, 37, 55, 19 };
|
||||
break;
|
||||
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;
|
||||
case 8:
|
||||
slotX = new int[] {20, 38, 56, 38}; // Double head middle
|
||||
slotY = new int[] {28, 46, 28, 28};
|
||||
break;
|
||||
case 9:
|
||||
slotX = new int[] {38, 56, 47, 47}; // Four parts, crossbow.
|
||||
slotY = new int[] {37, 37, 55, 19};
|
||||
break;
|
||||
}
|
||||
toolSlots.resetSlots(slotX, slotY);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import codechicken.nei.api.TaggedInventoryArea;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
@@ -24,13 +26,9 @@ import tconstruct.tools.inventory.ToolStationContainer;
|
||||
import tconstruct.tools.logic.ToolStationLogic;
|
||||
import tconstruct.util.network.ToolStationPacket;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems")
|
||||
public class ToolStationGui extends GuiContainer implements INEIGuiHandler
|
||||
{
|
||||
public class ToolStationGui extends GuiContainer implements INEIGuiHandler {
|
||||
public ToolStationLogic logic;
|
||||
public ToolStationContainer toolSlots;
|
||||
public GuiTextField text;
|
||||
@@ -40,8 +38,8 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
|
||||
public boolean active;
|
||||
public String title, body = "";
|
||||
|
||||
public ToolStationGui(InventoryPlayer inventoryplayer, ToolStationLogic stationlogic, World world, int x, int y, int z)
|
||||
{
|
||||
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) inventorySlots;
|
||||
@@ -58,11 +56,9 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked (int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
if (mouseButton == 0)
|
||||
{
|
||||
if (mouseButton == 0) {
|
||||
int gLeft = this.guiLeft + 68 + 110;
|
||||
int gTop = this.guiTop + 6;
|
||||
int gwidth = 102;
|
||||
@@ -71,41 +67,53 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
|
||||
}
|
||||
}
|
||||
|
||||
void resetGui ()
|
||||
{
|
||||
void resetGui() {
|
||||
this.text.setText("");
|
||||
guiType = 0;
|
||||
setSlotType(0);
|
||||
iconX = new int[] { 0, 1, 2 };
|
||||
iconY = new int[] { 13, 13, 13 };
|
||||
iconX = new int[] {0, 1, 2};
|
||||
iconY = new int[] {13, 13, 13};
|
||||
title = "\u00A7n" + StatCollector.translateToLocal("gui.toolforge1");
|
||||
body = StatCollector.translateToLocal("gui.toolforge2");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui ()
|
||||
{
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.xSize = 176 + 110;
|
||||
this.guiLeft = (this.width - 176) / 2 - 110;
|
||||
|
||||
this.buttonList.clear();
|
||||
ToolGuiElement repair = TConstructClientRegistry.toolButtons.get(0);
|
||||
GuiButtonTool repairButton = new GuiButtonTool(0, this.guiLeft, this.guiTop, repair.buttonIconX, repair.buttonIconY, repair.domain, repair.texture, repair); // Repair
|
||||
GuiButtonTool repairButton = new GuiButtonTool(
|
||||
0,
|
||||
this.guiLeft,
|
||||
this.guiTop,
|
||||
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++)
|
||||
{
|
||||
for (int iter = 1; iter < TConstructClientRegistry.toolButtons.size(); iter++) {
|
||||
ToolGuiElement element = TConstructClientRegistry.toolButtons.get(iter);
|
||||
GuiButtonTool button = new GuiButtonTool(iter, this.guiLeft + 22 * (iter % 5), this.guiTop + 22 * (iter / 5), element.buttonIconX, element.buttonIconY, element.domain, element.texture, element);
|
||||
GuiButtonTool button = new GuiButtonTool(
|
||||
iter,
|
||||
this.guiLeft + 22 * (iter % 5),
|
||||
this.guiTop + 22 * (iter / 5),
|
||||
element.buttonIconX,
|
||||
element.buttonIconY,
|
||||
element.domain,
|
||||
element.texture,
|
||||
element);
|
||||
this.buttonList.add(button);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed (GuiButton button)
|
||||
{
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
((GuiButton) this.buttonList.get(guiType)).enabled = true;
|
||||
guiType = button.id;
|
||||
button.enabled = false;
|
||||
@@ -116,47 +124,44 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
|
||||
iconY = element.iconsY;
|
||||
title = "\u00A7n" + element.title;
|
||||
body = StatCollector.translateToLocal(element.body);
|
||||
if(body != null) {
|
||||
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);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen ()
|
||||
{
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
this.text.updateCursorCounter();
|
||||
}
|
||||
@@ -166,20 +171,17 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
|
||||
* the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer (int par1, int par2)
|
||||
{
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
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(
|
||||
StatCollector.translateToLocal("container.inventory"), 118, this.ySize - 96 + 2, 0x000000);
|
||||
this.fontRendererObj.drawString(toolName + "_", 180, 8, 0xffffff);
|
||||
|
||||
if (logic.isStackInSlot(0))
|
||||
ToolStationGuiHelper.drawToolStats(logic.getStackInSlot(0), 294, 0);
|
||||
else
|
||||
drawToolInformation();
|
||||
if (logic.isStackInSlot(0)) ToolStationGuiHelper.drawToolStats(logic.getStackInSlot(0), 294, 0);
|
||||
else drawToolInformation();
|
||||
}
|
||||
|
||||
protected void drawToolInformation ()
|
||||
{
|
||||
protected void drawToolInformation() {
|
||||
this.drawCenteredString(fontRendererObj, title, 349, 8, 0xffffff);
|
||||
fontRendererObj.drawSplitString(body, 294, 24, 115, 0xffffff);
|
||||
}
|
||||
@@ -193,16 +195,14 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
|
||||
* items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
|
||||
{
|
||||
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);
|
||||
final int cornerX = this.guiLeft + 110;
|
||||
this.drawTexturedModalRect(cornerX, this.guiTop, 0, 0, 176, this.ySize);
|
||||
|
||||
if (active)
|
||||
{
|
||||
if (active) {
|
||||
this.drawTexturedModalRect(cornerX + 62, this.guiTop, 0, this.ySize, 112, 22);
|
||||
}
|
||||
|
||||
@@ -210,12 +210,11 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
|
||||
this.mc.getTextureManager().bindTexture(icons);
|
||||
// Draw the slots
|
||||
|
||||
for (int i = 0; i < slotX.length; i++)
|
||||
{
|
||||
for (int i = 0; i < slotX.length; i++) {
|
||||
this.drawTexturedModalRect(cornerX + slotX[i], this.guiTop + slotY[i], 144, 216, 18, 18);
|
||||
if (!logic.isStackInSlot(i + 1))
|
||||
{
|
||||
this.drawTexturedModalRect(cornerX + slotX[i], this.guiTop + slotY[i], 18 * iconX[i], 18 * iconY[i], 18, 18);
|
||||
if (!logic.isStackInSlot(i + 1)) {
|
||||
this.drawTexturedModalRect(
|
||||
cornerX + slotX[i], this.guiTop + slotY[i], 18 * iconX[i], 18 * iconY[i], 18, 18);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,21 +222,16 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(description);
|
||||
this.drawTexturedModalRect(cornerX + 176, this.guiTop, 0, 0, 126, this.ySize + 30);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped (char par1, int keyCode)
|
||||
{
|
||||
if (keyCode == 1 || (!active && keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode()))
|
||||
{
|
||||
protected void keyTyped(char par1, int keyCode) {
|
||||
if (keyCode == 1 || (!active && keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode())) {
|
||||
logic.setToolname("");
|
||||
updateServer("");
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
this.mc.thePlayer.closeScreen();
|
||||
}
|
||||
else if (active)
|
||||
{
|
||||
} else if (active) {
|
||||
text.textboxKeyTyped(par1, keyCode);
|
||||
toolName = text.getText().trim();
|
||||
logic.setToolname(toolName);
|
||||
@@ -245,8 +239,7 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
|
||||
}
|
||||
}
|
||||
|
||||
void updateServer (String name)
|
||||
{
|
||||
void updateServer(String name) {
|
||||
/*
|
||||
* ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
||||
* DataOutputStream outputStream = new DataOutputStream(bos); try {
|
||||
@@ -256,11 +249,11 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
|
||||
* 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);
|
||||
*/
|
||||
|
||||
@@ -274,19 +267,14 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
|
||||
*/
|
||||
|
||||
@Override
|
||||
public VisiblityData modifyVisiblity (GuiContainer gui, VisiblityData currentVisibility)
|
||||
{
|
||||
if (width - xSize < 107)
|
||||
{
|
||||
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
|
||||
if (width - xSize < 107) {
|
||||
currentVisibility.showWidgets = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
currentVisibility.showWidgets = true;
|
||||
}
|
||||
|
||||
if (guiLeft < 58)
|
||||
{
|
||||
if (guiLeft < 58) {
|
||||
currentVisibility.showStateButtons = false;
|
||||
}
|
||||
|
||||
@@ -294,31 +282,25 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Integer> getItemSpawnSlots (GuiContainer gui, ItemStack item)
|
||||
{
|
||||
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaggedInventoryArea> getInventoryAreas (GuiContainer gui)
|
||||
{
|
||||
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleDragNDrop (GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button)
|
||||
{
|
||||
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;
|
||||
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 - w - 4 < guiLeft - 40 || x + 4 > guiLeft + xSize + 126)
|
||||
return false;
|
||||
if (x - w - 4 < guiLeft - 40 || x + 4 > guiLeft + xSize + 126) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package tconstruct.tools.gui;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -11,21 +15,12 @@ import tconstruct.library.accessory.AccessoryCore;
|
||||
import tconstruct.library.armor.ArmorCore;
|
||||
import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.DualHarvestTool;
|
||||
import tconstruct.library.tools.HarvestTool;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.library.util.HarvestLevels;
|
||||
import tconstruct.library.weaponry.AmmoWeapon;
|
||||
import tconstruct.library.weaponry.IAmmo;
|
||||
import tconstruct.library.weaponry.ProjectileWeapon;
|
||||
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public final class ToolStationGuiHelper {
|
||||
// non-instantiable
|
||||
private ToolStationGuiHelper() {}
|
||||
@@ -33,23 +28,21 @@ public final class ToolStationGuiHelper {
|
||||
private static final FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRenderer;
|
||||
private static int xPos, yPos;
|
||||
|
||||
private static final DecimalFormat df = new DecimalFormat("#.##");
|
||||
private static final DecimalFormat df = new DecimalFormat("#.##");
|
||||
|
||||
private static void newline()
|
||||
{
|
||||
private static void newline() {
|
||||
yPos += 10;
|
||||
}
|
||||
|
||||
|
||||
private static void write(String s)
|
||||
{
|
||||
private static void write(String s) {
|
||||
fontRendererObj.drawString(s, xPos, yPos, 0xffffffff);
|
||||
newline();
|
||||
}
|
||||
|
||||
public static void drawToolStats (ItemStack stack, int x, int y)
|
||||
{
|
||||
String name = stack.getItem() instanceof ToolCore ? ((ToolCore) stack.getItem()).getLocalizedToolName() : stack.getDisplayName();
|
||||
public static void drawToolStats(ItemStack stack, int x, int y) {
|
||||
String name = stack.getItem() instanceof ToolCore
|
||||
? ((ToolCore) stack.getItem()).getLocalizedToolName()
|
||||
: stack.getDisplayName();
|
||||
Item item = stack.getItem();
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
Collection<String> categories = new LinkedList<String>();
|
||||
@@ -59,7 +52,7 @@ public final class ToolStationGuiHelper {
|
||||
yPos = y + 8;
|
||||
|
||||
// get the correct tags
|
||||
if(item instanceof IModifyable) {
|
||||
if (item instanceof IModifyable) {
|
||||
IModifyable modifyable = (IModifyable) item;
|
||||
tags = tags.getCompoundTag(modifyable.getBaseTagName());
|
||||
categories = Arrays.asList(modifyable.getTraits());
|
||||
@@ -70,24 +63,19 @@ public final class ToolStationGuiHelper {
|
||||
newline();
|
||||
|
||||
// does it have ammo instead of durability?
|
||||
if(item instanceof IAmmo)
|
||||
drawAmmo((IAmmo) item, stack);
|
||||
if (item instanceof IAmmo) drawAmmo((IAmmo) item, stack);
|
||||
// regular durability?
|
||||
else if(item instanceof ToolCore || item instanceof ArmorCore)
|
||||
drawDurability(tags);
|
||||
else if (item instanceof ToolCore || item instanceof ArmorCore) drawDurability(tags);
|
||||
|
||||
// tools
|
||||
if(item instanceof ToolCore) {
|
||||
if (item instanceof ToolCore) {
|
||||
ToolCore tool = (ToolCore) item;
|
||||
// DualHarvest tool?
|
||||
if (categories.contains("dualharvest"))
|
||||
drawDualHarvestStats(tool, tags);
|
||||
if (categories.contains("dualharvest")) drawDualHarvestStats(tool, tags);
|
||||
// or regular Harvest tool?
|
||||
else if (categories.contains("harvest"))
|
||||
drawHarvestStats(tool, tags);
|
||||
else if (categories.contains("harvest")) drawHarvestStats(tool, tags);
|
||||
// weapon?
|
||||
if (categories.contains("weapon"))
|
||||
drawWeaponStats(tool, tags);
|
||||
if (categories.contains("weapon")) drawWeaponStats(tool, tags);
|
||||
// throwing weapon?
|
||||
if (categories.contains("thrown") && tool instanceof AmmoWeapon)
|
||||
drawThrowingWeaponStats((AmmoWeapon) tool, tags);
|
||||
@@ -95,18 +83,15 @@ public final class ToolStationGuiHelper {
|
||||
if (categories.contains("bow") && tool instanceof ProjectileWeapon)
|
||||
drawProjectileWeaponStats((ProjectileWeapon) tool, tags, stack);
|
||||
// projectile?
|
||||
if (categories.contains("projectile"))
|
||||
drawProjectileStats(tags);
|
||||
if (categories.contains("projectile")) drawProjectileStats(tags);
|
||||
}
|
||||
// armor
|
||||
if(item instanceof ArmorCore)
|
||||
{
|
||||
if (item instanceof ArmorCore) {
|
||||
ArmorCore armor = (ArmorCore) item;
|
||||
drawArmorStats(armor, tags, stack);
|
||||
}
|
||||
// Accessory
|
||||
if(item instanceof AccessoryCore)
|
||||
{
|
||||
if (item instanceof AccessoryCore) {
|
||||
AccessoryCore accessory = (AccessoryCore) item;
|
||||
drawAccessoryStats(accessory, tags);
|
||||
}
|
||||
@@ -123,31 +108,25 @@ public final class ToolStationGuiHelper {
|
||||
final int availableDurability = maxDur - durability;
|
||||
|
||||
// big durabilities have to split to 2 lines
|
||||
if (maxDur >= 10000)
|
||||
{
|
||||
if (maxDur >= 10000) {
|
||||
write(StatCollector.translateToLocal("gui.toolstation1"));
|
||||
write("- " + availableDurability + "/" + maxDur);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
write(StatCollector.translateToLocal("gui.toolstation2") + availableDurability + "/" + maxDur);
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawAmmo(IAmmo ammoItem, ItemStack stack)
|
||||
{
|
||||
private static void drawAmmo(IAmmo ammoItem, ItemStack stack) {
|
||||
final int max = ammoItem.getMaxAmmo(stack);
|
||||
final int current = ammoItem.getAmmoCount(stack);
|
||||
|
||||
write(StatCollector.translateToLocal("gui.toolstation21") + current + "/" + max);
|
||||
write(StatCollector.translateToLocal("gui.toolstation21") + current + "/" + max);
|
||||
}
|
||||
|
||||
private static void drawModifiers(NBTTagCompound tags)
|
||||
{
|
||||
private static void drawModifiers(NBTTagCompound tags) {
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
// remaining modifiers
|
||||
if (modifiers != 0)
|
||||
write(StatCollector.translateToLocal("gui.toolstation18") + modifiers);
|
||||
if (modifiers != 0) write(StatCollector.translateToLocal("gui.toolstation18") + modifiers);
|
||||
|
||||
// Modifier-header (if we have modifiers)
|
||||
if (tags.hasKey("ModifierTip1")) {
|
||||
@@ -160,14 +139,15 @@ public final class ToolStationGuiHelper {
|
||||
String locString = "modifier.toolstation." + tipName;
|
||||
// strip out the '(X of Y)' in some for the localization strings.. sigh
|
||||
int bracket = tipName.indexOf("(");
|
||||
if(bracket > 0)
|
||||
locString = "modifier.toolstation." + tipName.substring(0, bracket);
|
||||
if (bracket > 0) locString = "modifier.toolstation." + tipName.substring(0, bracket);
|
||||
locString = EnumChatFormatting.getTextWithoutFormattingCodes(locString.replace(" ", ""));
|
||||
|
||||
if(StatCollector.canTranslate(locString)) {
|
||||
tipName = tipName.replace(EnumChatFormatting.getTextWithoutFormattingCodes(tipName), StatCollector.translateToLocal(locString));
|
||||
if (StatCollector.canTranslate(locString)) {
|
||||
tipName = tipName.replace(
|
||||
EnumChatFormatting.getTextWithoutFormattingCodes(tipName),
|
||||
StatCollector.translateToLocal(locString));
|
||||
// re-add the X/Y
|
||||
if(bracket > 0)
|
||||
if (bracket > 0)
|
||||
tipName += " " + tags.getString(tooltip + tipNum).substring(bracket);
|
||||
}
|
||||
write("- " + tipName);
|
||||
@@ -176,40 +156,41 @@ public final class ToolStationGuiHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawHarvestStats(ToolCore tool, NBTTagCompound tags)
|
||||
{
|
||||
private static void drawHarvestStats(ToolCore tool, NBTTagCompound tags) {
|
||||
float mineSpeed = AbilityHelper.calcToolSpeed(tool, tags);
|
||||
float stoneboundSpeed = AbilityHelper.calcStoneboundBonus(tool, tags);
|
||||
|
||||
write(StatCollector.translateToLocal("gui.toolstation14") + df.format(mineSpeed));
|
||||
if(stoneboundSpeed != 0)
|
||||
{
|
||||
String bloss = stoneboundSpeed > 0 ? StatCollector.translateToLocal("gui.toolstation4") : StatCollector.translateToLocal("gui.toolstation5");
|
||||
if (stoneboundSpeed != 0) {
|
||||
String bloss = stoneboundSpeed > 0
|
||||
? StatCollector.translateToLocal("gui.toolstation4")
|
||||
: StatCollector.translateToLocal("gui.toolstation5");
|
||||
write(bloss + df.format(stoneboundSpeed));
|
||||
}
|
||||
write(StatCollector.translateToLocal("gui.toolstation15") + HarvestLevels.getHarvestLevelName(tags.getInteger("HarvestLevel")));
|
||||
write(StatCollector.translateToLocal("gui.toolstation15")
|
||||
+ HarvestLevels.getHarvestLevelName(tags.getInteger("HarvestLevel")));
|
||||
}
|
||||
|
||||
private static void drawDualHarvestStats(ToolCore tool, NBTTagCompound tags)
|
||||
{
|
||||
private static void drawDualHarvestStats(ToolCore tool, NBTTagCompound tags) {
|
||||
float mineSpeed = AbilityHelper.calcDualToolSpeed(tool, tags, false);
|
||||
float mineSpeed2 = AbilityHelper.calcDualToolSpeed(tool, tags, true);
|
||||
float stoneboundSpeed = AbilityHelper.calcStoneboundBonus(tool, tags);
|
||||
|
||||
write(StatCollector.translateToLocal("gui.toolstation12"));
|
||||
write("- " + df.format(mineSpeed) + ", " + df.format(mineSpeed2));
|
||||
if (stoneboundSpeed != 0)
|
||||
{
|
||||
String bloss = stoneboundSpeed > 0 ? StatCollector.translateToLocal("gui.toolstation4") : StatCollector.translateToLocal("gui.toolstation5");
|
||||
if (stoneboundSpeed != 0) {
|
||||
String bloss = stoneboundSpeed > 0
|
||||
? StatCollector.translateToLocal("gui.toolstation4")
|
||||
: StatCollector.translateToLocal("gui.toolstation5");
|
||||
write(bloss + df.format(stoneboundSpeed));
|
||||
}
|
||||
|
||||
write(StatCollector.translateToLocal("gui.toolstation13"));
|
||||
write("- " + HarvestLevels.getHarvestLevelName(tags.getInteger("HarvestLevel")) + ", " + HarvestLevels.getHarvestLevelName(tags.getInteger("HarvestLevel2")));
|
||||
write("- " + HarvestLevels.getHarvestLevelName(tags.getInteger("HarvestLevel")) + ", "
|
||||
+ HarvestLevels.getHarvestLevelName(tags.getInteger("HarvestLevel2")));
|
||||
}
|
||||
|
||||
private static void drawWeaponStats(ToolCore tool, NBTTagCompound tags)
|
||||
{
|
||||
private static void drawWeaponStats(ToolCore tool, NBTTagCompound tags) {
|
||||
// DAMAGE
|
||||
int attack = (tags.getInteger("Attack"));
|
||||
|
||||
@@ -218,19 +199,21 @@ public final class ToolStationGuiHelper {
|
||||
attack += stoneboundDamage;
|
||||
attack *= tool.getDamageModifier();
|
||||
|
||||
if (attack < 1)
|
||||
attack = 1;
|
||||
if (attack < 1) attack = 1;
|
||||
|
||||
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
|
||||
if (attack % 2 == 0)
|
||||
write(StatCollector.translateToLocal("gui.toolstation3") + attack / 2 + heart);
|
||||
else
|
||||
write(StatCollector.translateToLocal("gui.toolstation3") + df.format(attack / 2f) + heart);
|
||||
String heart = attack == 2
|
||||
? StatCollector.translateToLocal("gui.partcrafter8")
|
||||
: StatCollector.translateToLocal("gui.partcrafter9");
|
||||
if (attack % 2 == 0) write(StatCollector.translateToLocal("gui.toolstation3") + attack / 2 + heart);
|
||||
else write(StatCollector.translateToLocal("gui.toolstation3") + df.format(attack / 2f) + heart);
|
||||
|
||||
if (stoneboundDamage != 0)
|
||||
{
|
||||
heart = stoneboundDamage == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
|
||||
String bloss = stoneboundDamage > 0 ? StatCollector.translateToLocal("gui.toolstation4") : StatCollector.translateToLocal("gui.toolstation5");
|
||||
if (stoneboundDamage != 0) {
|
||||
heart = stoneboundDamage == 2
|
||||
? StatCollector.translateToLocal("gui.partcrafter8")
|
||||
: StatCollector.translateToLocal("gui.partcrafter9");
|
||||
String bloss = stoneboundDamage > 0
|
||||
? StatCollector.translateToLocal("gui.toolstation4")
|
||||
: StatCollector.translateToLocal("gui.toolstation5");
|
||||
write(bloss + df.format(stoneboundDamage / 2f) + heart);
|
||||
}
|
||||
}
|
||||
@@ -240,20 +223,18 @@ public final class ToolStationGuiHelper {
|
||||
attackf *= weapon.getDamageModifier();
|
||||
attackf *= weapon.getProjectileSpeed();
|
||||
|
||||
if (attackf < 1)
|
||||
attackf = 1;
|
||||
if (attackf < 1) attackf = 1;
|
||||
|
||||
int attack = (int)attackf;
|
||||
int attack = (int) attackf;
|
||||
|
||||
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
|
||||
if (attack % 2 == 0)
|
||||
write(StatCollector.translateToLocal("gui.toolstation23") + attack / 2 + heart);
|
||||
else
|
||||
write(StatCollector.translateToLocal("gui.toolstation23") + df.format(attack / 2f) + heart);
|
||||
String heart = attack == 2
|
||||
? StatCollector.translateToLocal("gui.partcrafter8")
|
||||
: StatCollector.translateToLocal("gui.partcrafter9");
|
||||
if (attack % 2 == 0) write(StatCollector.translateToLocal("gui.toolstation23") + attack / 2 + heart);
|
||||
else write(StatCollector.translateToLocal("gui.toolstation23") + df.format(attack / 2f) + heart);
|
||||
}
|
||||
|
||||
private static void drawProjectileWeaponStats(ProjectileWeapon weapon, NBTTagCompound tags, ItemStack stack)
|
||||
{
|
||||
private static void drawProjectileWeaponStats(ProjectileWeapon weapon, NBTTagCompound tags, ItemStack stack) {
|
||||
// drawspeed
|
||||
final int drawSpeed = weapon.getWindupTime(stack);
|
||||
final float trueDraw = drawSpeed / 20f;
|
||||
@@ -264,8 +245,7 @@ public final class ToolStationGuiHelper {
|
||||
write(StatCollector.translateToLocal("gui.toolstation7") + df.format(flightSpeed) + "x");
|
||||
}
|
||||
|
||||
private static void drawProjectileStats(NBTTagCompound tags)
|
||||
{
|
||||
private static void drawProjectileStats(NBTTagCompound tags) {
|
||||
// weight
|
||||
final float weight = tags.getFloat("Mass");
|
||||
write(StatCollector.translateToLocal("gui.toolstation8") + df.format(weight));
|
||||
@@ -279,23 +259,22 @@ public final class ToolStationGuiHelper {
|
||||
write(StatCollector.translateToLocal("gui.toolstation22") + df.format(breakChance) + "%");
|
||||
}
|
||||
|
||||
private static void drawArmorStats(ArmorCore armor, NBTTagCompound tags, ItemStack stack)
|
||||
{
|
||||
private static void drawArmorStats(ArmorCore armor, NBTTagCompound tags, ItemStack stack) {
|
||||
// Damage reduction
|
||||
double damageReduction = tags.getDouble("DamageReduction");
|
||||
if(damageReduction > 0)
|
||||
if (damageReduction > 0)
|
||||
write(StatCollector.translateToLocal("gui.toolstation19") + df.format(damageReduction));
|
||||
|
||||
// Protection
|
||||
double protection = armor.getProtection(stack);
|
||||
double maxProtection = tags.getDouble("MaxDefense");
|
||||
|
||||
write(StatCollector.translateToLocal("gui.toolstation20") + df.format(protection) + "/" + df.format(maxProtection));
|
||||
write(StatCollector.translateToLocal("gui.toolstation20") + df.format(protection) + "/"
|
||||
+ df.format(maxProtection));
|
||||
}
|
||||
|
||||
private static void drawAccessoryStats(AccessoryCore core, NBTTagCompound tags)
|
||||
{
|
||||
if(tags.hasKey("MiningSpeed")) {
|
||||
private static void drawAccessoryStats(AccessoryCore core, NBTTagCompound tags) {
|
||||
if (tags.hasKey("MiningSpeed")) {
|
||||
float mineSpeed = tags.getInteger("MiningSpeed");
|
||||
float trueSpeed = mineSpeed / (100f);
|
||||
write(StatCollector.translateToLocal("gui.toolstation16") + trueSpeed);
|
||||
@@ -306,8 +285,9 @@ public final class ToolStationGuiHelper {
|
||||
* Renders the specified text to the screen, center-aligned.
|
||||
* Copied out of GUI
|
||||
*/
|
||||
public static void drawCenteredString(FontRenderer p_73732_1_, String p_73732_2_, int p_73732_3_, int p_73732_4_, int p_73732_5_)
|
||||
{
|
||||
p_73732_1_.drawStringWithShadow(p_73732_2_, p_73732_3_ - p_73732_1_.getStringWidth(p_73732_2_) / 2, p_73732_4_, p_73732_5_);
|
||||
public static void drawCenteredString(
|
||||
FontRenderer p_73732_1_, String p_73732_2_, int p_73732_3_, int p_73732_4_, int p_73732_5_) {
|
||||
p_73732_1_.drawStringWithShadow(
|
||||
p_73732_2_, p_73732_3_ - p_73732_1_.getStringWidth(p_73732_2_) / 2, p_73732_4_, p_73732_5_);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user