Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GuiDuel extends GuiContainer
- {
- private static final ResourceLocation DUELFIELD_GUI_TEXTURE = new ResourceLocation(
- Reference.MODID + ":textures/gui/container/duelGui2.png");
- private InventoryPlayer playerInv;
- private GuiButton attackButton;
- private GuiButton quitButton;
- private TileEntityDuelField tile;
- public GuiDuel(EntityPlayer player, TileEntityDuelField tileDuelField)
- {
- super(new ContainerDuel(player, tileDuelField));
- this.playerInv = player.inventory;
- this.tile = tileDuelField;
- }
- @Override
- public void initGui()
- {
- super.initGui();
- attackButton = new GuiButton(0, 13, 20, 60, 20, "Attack");
- quitButton = new GuiButton(1, 13, 40, 60, 20, "Quit duel");
- this.buttonList.add(attackButton);
- this.buttonList.add(quitButton);
- }
- /**
- * Returns true if this GUI should pause the game when it is displayed in
- * single-player
- */
- @Override
- public boolean doesGuiPauseGame()
- {
- return false;
- }
- @Override
- protected void actionPerformed(GuiButton parButton)
- {
- if (parButton.id == 0 && this.tile.getWorld() != null && this.tile.getWorld().isRemote)
- {
- //NetworkHandler.NETWORK.sendToServer(new PacketAttack(tileDuelField.getPos()));
- }
- else if(parButton.id == 1 && this.tile.getWorld() != null && this.tile.getWorld().isRemote)
- {
- NetworkHandler.NETWORK.sendToServer(new PacketQuitDuel(tile.getPos()));
- this.mc.displayGuiScreen(null);
- }
- }
- @Override
- protected void keyTyped(char typedChar, int keyCode) throws IOException
- {
- if (keyCode == 1 || this.mc.gameSettings.keyBindInventory.isActiveAndMatches(keyCode))
- {
- return;
- }
- }
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks)
- {
- super.drawScreen(mouseX, mouseY, partialTicks);
- this.zLevel = 50;
- World world = this.mc.theWorld;
- if(world != null)
- {
- TileEntityDuelField teN = (TileEntityDuelField) world.getTileEntity(tile.getPos().north(10));
- TileEntityDuelField teS = (TileEntityDuelField) world.getTileEntity(tile.getPos().south(10));
- if(teN != null)
- {
- ItemStackHandler inv = teN.inventory();
- ItemStack stack = inv.getStackInSlot(4);
- if(stack != null)
- {
- this.itemRender.renderItemAndEffectIntoGUI(stack, 130, 40);
- this.itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, stack, 120, 50, stack.getDisplayName());
- }
- }
- else if(teS != null)
- {
- ItemStackHandler inv = teS.inventory();
- ItemStack stack = inv.getStackInSlot(4);
- if(stack != null)
- {
- this.itemRender.renderItemAndEffectIntoGUI(stack, 130, 40);
- this.itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, stack, 120, 50, stack.getDisplayName());
- }
- }
- }
- this.zLevel = 0;
- }
- /**
- * Draw the foreground layer for the GuiContainer (everything in front of
- * the items)
- */
- protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
- {
- String s = I18n.format("Your side");
- String r = I18n.format("Opponent's side");
- this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 50, 4210752);
- this.fontRendererObj.drawString(r, this.xSize / 2 - this.fontRendererObj.getStringWidth(r) / 2, -20, 4210752);
- this.fontRendererObj.drawString("Hand", 35, 165, 4210752);
- }
- /**
- * Draws the background layer of this container (behind the items).
- */
- protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
- {
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- this.mc.getTextureManager().bindTexture(DUELFIELD_GUI_TEXTURE);
- int i = (this.width - this.xSize) / 2;
- int j = (this.height - this.ySize) / 2;
- this.drawTexturedModalRect(i, j - 35, 0, 0, this.xSize, 250);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement