Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 KB | None | 0 0
  1. package com.TheRPGAdventurer.ROTD.client.gui;
  2.  
  3. import java.io.IOException;
  4.  
  5. import org.lwjgl.input.Keyboard;
  6.  
  7. import com.TheRPGAdventurer.ROTD.DragonMounts;
  8. import com.TheRPGAdventurer.ROTD.client.inventory.ContainerDragonWand;
  9. import com.TheRPGAdventurer.ROTD.server.entity.EntityTameableDragon;
  10. import com.TheRPGAdventurer.ROTD.server.entity.breeds.EnumDragonBreed;
  11. import com.TheRPGAdventurer.ROTD.util.math.Interpolation;
  12.  
  13. import net.minecraft.client.Minecraft;
  14. import net.minecraft.client.gui.GuiButton;
  15. import net.minecraft.client.gui.GuiTextField;
  16. import net.minecraft.client.gui.inventory.GuiContainer;
  17. import net.minecraft.client.gui.inventory.GuiInventory;
  18. import net.minecraft.client.renderer.GlStateManager;
  19. import net.minecraft.inventory.IInventory;
  20. import net.minecraft.util.ResourceLocation;
  21. import net.minecraftforge.fml.relauncher.Side;
  22. import net.minecraftforge.fml.relauncher.SideOnly;
  23.  
  24. @SideOnly(Side.CLIENT)
  25. public class GuiDragonWand extends GuiContainer {
  26.  
  27. private static final ResourceLocation texture = new ResourceLocation(DragonMounts.MODID, "textures/gui/wand.png");
  28. private static final ResourceLocation gender = new ResourceLocation(DragonMounts.MODID, "textures/gui/gender.png");
  29. private IInventory playerInventory;
  30. private IInventory dragonStats;
  31. private EntityTameableDragon dragon;
  32.  
  33. private EnumDragonBreed currentBreed;
  34. private EnumDragonBreed newBreed;
  35.  
  36. private float mousePosX;
  37. private float mousePosY;
  38.  
  39. private GuiTextField genderText;
  40.  
  41. private GuiButton nextbreed;
  42. private GuiButton prevbreed;
  43.  
  44. private GuiButton genderButton;
  45.  
  46. private GuiButton owner;
  47.  
  48. public GuiDragonWand(IInventory playerInv, EntityTameableDragon dragon) {
  49. super(new ContainerDragonWand(dragon, Minecraft.getMinecraft().player));
  50. this.playerInventory = playerInv;
  51. this.dragonStats = dragon.dragonStats;
  52. this.dragon = dragon;
  53. this.allowUserInput = false;
  54. currentBreed = dragon.getBreedType();
  55. this.ySize = 214;
  56.  
  57. }
  58.  
  59. /**
  60. * Draw the foreground layer for the GuiContainer (everything in front of the
  61. * items)
  62. */
  63. protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
  64. this.fontRenderer.drawString(dragon.hasCustomName() ? dragon.getCustomNameTag() : "Dragon Wand", 8, 6, dragon.getBreed().getColor());
  65. this.mc.getTextureManager().bindTexture(gender);
  66. }
  67.  
  68. @Override
  69. protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
  70. GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  71. this.mc.getTextureManager().bindTexture(texture);
  72. int x = (this.width - this.xSize) / 2;
  73. int y = (this.height - this.ySize) / 2;
  74. this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
  75. if (dragon.isChested()) {
  76. this.drawTexturedModalRect(x + 0, y + 73, 0, 130, 170, 55);
  77. }
  78. GuiInventory.drawEntityOnScreen(x + 88, y + 80, (int) (13 / dragon.getScale()), x + 51 - this.mousePosX, y + 75 - 50 - this.mousePosY,
  79. this.dragon);
  80. }
  81.  
  82. @Override
  83. public void initGui() {
  84. Keyboard.enableRepeatEvents(true);
  85.  
  86. drawEditorGui();
  87. }
  88.  
  89. @Override
  90. protected void actionPerformed(GuiButton button) {
  91. if (!button.enabled) {
  92. return;
  93. } else if(button == genderButton) {
  94. if(dragon.isMale()) {
  95. dragon.setMale(false);
  96. } else if(!dragon.isMale()) {
  97. dragon.setMale(true);
  98. }
  99. drawEditorGui();
  100. } else if(button == nextbreed) {
  101. newBreed.values().clone();
  102. dragon.setBreedType(newBreed);
  103. drawEditorGui();
  104. }
  105. }
  106.  
  107. private void drawEditorGui() {
  108. buttonList.clear();
  109. buttonList.add(genderButton = new GuiButton(0, width / 2 + -5, height / 2 - -1, 20, 20, dragon.isMale() ? "M" : "FM"));
  110. buttonList.add(nextbreed = new GuiButton(1, width / 2 + 25, height / 2 - -1, 20, 20, dragon.getBreedType().toString()));
  111. // buttonList.add(owner = new GuiButton(2, width / 2, height / 2, 10, 20, "OWNER"));
  112. }
  113.  
  114. private EnumDragonBreed cycleThroughBreeds() {
  115. return newBreed;
  116. }
  117.  
  118. @Override
  119. public void drawScreen(int mouseX, int mouseY, float partialTicks) {
  120. this.drawDefaultBackground();
  121. this.mousePosX = mouseX;
  122. this.mousePosY = mouseY;
  123. super.drawScreen(mouseX, mouseY, partialTicks);
  124. this.renderHoveredToolTip(mouseX, mouseY);
  125. }
  126.  
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement