2013-07-26 21:18:53 -07:00
|
|
|
package tconstruct.client.gui;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
2014-02-01 17:28:41 +11:00
|
|
|
import net.minecraft.util.*;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
2014-02-01 17:28:41 +11:00
|
|
|
import tconstruct.TConstruct;
|
2013-07-26 21:18:53 -07:00
|
|
|
import tconstruct.blocks.logic.StencilTableLogic;
|
2013-12-01 21:42:03 +00:00
|
|
|
import tconstruct.common.TRepo;
|
2013-07-26 21:18:53 -07:00
|
|
|
import tconstruct.inventory.PatternShaperContainer;
|
2014-02-01 17:28:41 +11:00
|
|
|
import tconstruct.util.network.packet.PacketStencilTable;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
public class StencilTableGui extends GuiContainer
|
|
|
|
|
{
|
|
|
|
|
StencilTableLogic logic;
|
|
|
|
|
int patternIndex;
|
|
|
|
|
|
|
|
|
|
public StencilTableGui(InventoryPlayer inventoryplayer, StencilTableLogic shaper, World world, int x, int y, int z)
|
|
|
|
|
{
|
|
|
|
|
super(new PatternShaperContainer(inventoryplayer, shaper));
|
|
|
|
|
logic = shaper;
|
|
|
|
|
patternIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onGuiClosed ()
|
|
|
|
|
{
|
|
|
|
|
super.onGuiClosed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2014-02-01 14:18:17 -05:00
|
|
|
protected void func_146979_b (int par1, int par2)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-01-08 00:45:09 -05:00
|
|
|
field_146289_q.drawString(StatCollector.translateToLocal("crafters.PatternShaper"), 50, 6, 0x404040);
|
2014-02-01 14:18:17 -05:00
|
|
|
field_146289_q.drawString(StatCollector.translateToLocal("container.inventory"), 8, (field_147000_g - 96) + 2, 0x404040);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
2013-08-31 05:13:31 -07:00
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/patternshaper.png");
|
|
|
|
|
|
2014-02-01 14:18:17 -05:00
|
|
|
protected void func_146976_a (float par1, int par2, int par3)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
2014-01-08 00:45:09 -05:00
|
|
|
this.field_146297_k.getTextureManager().bindTexture(background);
|
2014-02-01 14:18:17 -05:00
|
|
|
int cornerX = (this.field_146294_l - this.field_146999_f) / 2;
|
|
|
|
|
int cornerY = (this.field_146295_m - this.field_147000_g) / 2;
|
|
|
|
|
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, this.field_146999_f, this.field_147000_g);
|
2013-07-26 21:18:53 -07:00
|
|
|
if (!logic.isStackInSlot(0))
|
|
|
|
|
{
|
|
|
|
|
this.drawTexturedModalRect(cornerX + 47, cornerY + 34, 176, 0, 18, 18);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void initGui ()
|
|
|
|
|
{
|
|
|
|
|
super.initGui();
|
2014-02-01 14:18:17 -05:00
|
|
|
int cornerX = (this.field_146294_l - this.field_146999_f) / 2;
|
|
|
|
|
int cornerY = (this.field_146295_m - this.field_147000_g) / 2;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-01-09 04:08:38 -05:00
|
|
|
this.field_146292_n.clear();
|
2013-07-26 21:18:53 -07:00
|
|
|
/*ToolGuiElement repair = TConstruct.toolButtons.get(0);
|
|
|
|
|
GuiButtonTool repairButton = new GuiButtonTool(0, cornerX - 110, cornerY, repair.buttonIconX, repair.buttonIconY, repair.texture); // Repair
|
|
|
|
|
repairButton.enabled = false;
|
2014-01-09 04:08:38 -05:00
|
|
|
this.field_146292_n.add(repairButton);*/
|
|
|
|
|
this.field_146292_n.add(new GuiButton(0, cornerX - 120, cornerY, 120, 20, StatCollector.translateToLocal("gui.stenciltable1")));
|
|
|
|
|
this.field_146292_n.add(new GuiButton(1, cornerX - 120, cornerY + 20, 120, 20, StatCollector.translateToLocal("gui.stenciltable1")));
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
//for (int iter = 0; iter < TConstructContent.patternOutputs.length; iter++)
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
/*ToolGuiElement element = TConstruct.toolButtons.get(iter);
|
|
|
|
|
GuiButtonTool button = new GuiButtonTool(iter, cornerX - 110 + 22 * (iter % 5), cornerY + 22 * (iter / 5), element.buttonIconX, element.buttonIconY, element.texture); // Repair
|
2014-01-09 04:08:38 -05:00
|
|
|
this.field_146292_n.add(button);*/
|
2013-07-26 21:18:53 -07:00
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void actionPerformed (GuiButton button)
|
|
|
|
|
{
|
|
|
|
|
ItemStack pattern = logic.getStackInSlot(0);
|
2013-12-01 21:42:03 +00:00
|
|
|
if (pattern != null && pattern.getItem() == TRepo.blankPattern)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
int meta = pattern.getItemDamage();
|
|
|
|
|
if (meta == 0)
|
|
|
|
|
{
|
2014-01-09 04:08:38 -05:00
|
|
|
if (button.field_146127_k == 0)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
patternIndex++;
|
2013-11-25 19:40:43 -05:00
|
|
|
if (patternIndex == 21)
|
2013-07-26 21:18:53 -07:00
|
|
|
patternIndex++;
|
2013-12-01 21:42:03 +00:00
|
|
|
if (patternIndex >= TRepo.patternOutputs.length - 1)
|
2013-07-26 21:18:53 -07:00
|
|
|
patternIndex = 0;
|
|
|
|
|
}
|
2014-01-09 04:08:38 -05:00
|
|
|
else if (button.field_146127_k == 1)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
patternIndex--;
|
|
|
|
|
if (patternIndex < 0)
|
2013-12-01 21:42:03 +00:00
|
|
|
patternIndex = TRepo.patternOutputs.length - 2;
|
2013-11-25 19:40:43 -05:00
|
|
|
if (patternIndex == 21)
|
2013-11-25 14:08:18 -05:00
|
|
|
patternIndex--;
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
2013-12-01 21:42:03 +00:00
|
|
|
ItemStack stack = new ItemStack(TRepo.woodPattern, 1, patternIndex + 1);
|
2013-07-26 21:18:53 -07:00
|
|
|
logic.setInventorySlotContents(1, stack);
|
|
|
|
|
updateServer(stack);
|
|
|
|
|
}
|
2013-08-01 20:54:56 -07:00
|
|
|
/*else if (meta == 1 || meta == 2)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2013-12-01 20:40:42 +01:00
|
|
|
ItemStack stack = new ItemStack(TContent.metalPattern, 1, 0);
|
2013-07-26 21:18:53 -07:00
|
|
|
logic.setInventorySlotContents(1, stack);
|
|
|
|
|
updateServer(stack);
|
2013-08-01 20:54:56 -07:00
|
|
|
}*/
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void updateServer (ItemStack stack)
|
|
|
|
|
{
|
2014-02-01 17:28:41 +11:00
|
|
|
/*ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
2013-07-26 21:18:53 -07:00
|
|
|
DataOutputStream outputStream = new DataOutputStream(bos);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
outputStream.writeByte(2);
|
2014-01-01 14:59:11 -05:00
|
|
|
outputStream.writeInt(logic.getWorld().provider.dimensionId);
|
2014-01-08 21:59:48 -05:00
|
|
|
outputStream.writeInt(logic.field_145851_c);
|
|
|
|
|
outputStream.writeInt(logic.field_145848_d);
|
|
|
|
|
outputStream.writeInt(logic.field_145849_e);
|
2013-07-26 21:18:53 -07:00
|
|
|
outputStream.writeShort(stack.itemID);
|
|
|
|
|
outputStream.writeShort(stack.getItemDamage());
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Packet250CustomPayload packet = new Packet250CustomPayload();
|
|
|
|
|
packet.channel = "TConstruct";
|
|
|
|
|
packet.data = bos.toByteArray();
|
|
|
|
|
packet.length = bos.size();
|
|
|
|
|
|
2014-02-01 17:28:41 +11:00
|
|
|
PacketDispatcher.sendPacketToServer(packet);*/
|
|
|
|
|
|
|
|
|
|
TConstruct.packetPipeline.sendToServer(new PacketStencilTable(logic.field_145851_c, logic.field_145848_d, logic.field_145849_e, stack));
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|