Advertisement
Guest User

Untitled

a guest
Nov 20th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. public class GuiDuel extends GuiContainer
  2. {
  3. private static final ResourceLocation DUELFIELD_GUI_TEXTURE = new ResourceLocation(
  4. Reference.MODID + ":textures/gui/container/duelGui2.png");
  5. private InventoryPlayer playerInv;
  6. private GuiButton attackButton;
  7. private GuiButton quitButton;
  8. private TileEntityDuelField tile;
  9.  
  10. public GuiDuel(EntityPlayer player, TileEntityDuelField tileDuelField)
  11. {
  12. super(new ContainerDuel(player, tileDuelField));
  13. this.playerInv = player.inventory;
  14. this.tile = tileDuelField;
  15. }
  16.  
  17. @Override
  18. public void initGui()
  19. {
  20. super.initGui();
  21.  
  22. attackButton = new GuiButton(0, 13, 20, 60, 20, "Attack");
  23. quitButton = new GuiButton(1, 13, 40, 60, 20, "Quit duel");
  24.  
  25. this.buttonList.add(attackButton);
  26. this.buttonList.add(quitButton);
  27. }
  28.  
  29. /**
  30. * Returns true if this GUI should pause the game when it is displayed in
  31. * single-player
  32. */
  33. @Override
  34. public boolean doesGuiPauseGame()
  35. {
  36. return false;
  37. }
  38.  
  39. @Override
  40. protected void actionPerformed(GuiButton parButton)
  41. {
  42. if (parButton.id == 0 && this.tile.getWorld() != null && this.tile.getWorld().isRemote)
  43. {
  44. //NetworkHandler.NETWORK.sendToServer(new PacketAttack(tileDuelField.getPos()));
  45. }
  46. else if(parButton.id == 1 && this.tile.getWorld() != null && this.tile.getWorld().isRemote)
  47. {
  48. NetworkHandler.NETWORK.sendToServer(new PacketQuitDuel(tile.getPos()));
  49. this.mc.displayGuiScreen(null);
  50. }
  51. }
  52.  
  53. @Override
  54. protected void keyTyped(char typedChar, int keyCode) throws IOException
  55. {
  56. if (keyCode == 1 || this.mc.gameSettings.keyBindInventory.isActiveAndMatches(keyCode))
  57. {
  58. return;
  59. }
  60. }
  61.  
  62. @Override
  63. public void drawScreen(int mouseX, int mouseY, float partialTicks)
  64. {
  65. super.drawScreen(mouseX, mouseY, partialTicks);
  66.  
  67. this.zLevel = 50;
  68.  
  69. World world = this.mc.theWorld;
  70. if(world != null)
  71. {
  72. TileEntityDuelField teN = (TileEntityDuelField) world.getTileEntity(tile.getPos().north(10));
  73. TileEntityDuelField teS = (TileEntityDuelField) world.getTileEntity(tile.getPos().south(10));
  74.  
  75. if(teN != null)
  76. {
  77. ItemStackHandler inv = teN.inventory();
  78. ItemStack stack = inv.getStackInSlot(4);
  79. if(stack != null)
  80. {
  81. this.itemRender.renderItemAndEffectIntoGUI(stack, 130, 40);
  82. this.itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, stack, 120, 50, stack.getDisplayName());
  83. }
  84. }
  85. else if(teS != null)
  86. {
  87. ItemStackHandler inv = teS.inventory();
  88. ItemStack stack = inv.getStackInSlot(4);
  89. if(stack != null)
  90. {
  91. this.itemRender.renderItemAndEffectIntoGUI(stack, 130, 40);
  92. this.itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, stack, 120, 50, stack.getDisplayName());
  93. }
  94. }
  95. }
  96.  
  97. this.zLevel = 0;
  98. }
  99.  
  100. /**
  101. * Draw the foreground layer for the GuiContainer (everything in front of
  102. * the items)
  103. */
  104. protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
  105. {
  106. String s = I18n.format("Your side");
  107. String r = I18n.format("Opponent's side");
  108. this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 50, 4210752);
  109. this.fontRendererObj.drawString(r, this.xSize / 2 - this.fontRendererObj.getStringWidth(r) / 2, -20, 4210752);
  110. this.fontRendererObj.drawString("Hand", 35, 165, 4210752);
  111. }
  112.  
  113. /**
  114. * Draws the background layer of this container (behind the items).
  115. */
  116. protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
  117. {
  118. GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  119. this.mc.getTextureManager().bindTexture(DUELFIELD_GUI_TEXTURE);
  120. int i = (this.width - this.xSize) / 2;
  121. int j = (this.height - this.ySize) / 2;
  122. this.drawTexturedModalRect(i, j - 35, 0, 0, this.xSize, 250);
  123. }
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement