Guest User

Untitled

a guest
Mar 19th, 2018
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. package com.TheRPGAdventurer.ROTD.client.gui;
  2.  
  3. import com.TheRPGAdventurer.ROTD.client.inventory.ContainerDragon;
  4. import com.TheRPGAdventurer.ROTD.server.entity.EntityTameableDragon;
  5.  
  6. import net.minecraft.client.Minecraft;
  7. import net.minecraft.client.gui.inventory.GuiContainer;
  8. import net.minecraft.client.gui.inventory.GuiInventory;
  9. import net.minecraft.client.renderer.GlStateManager;
  10. import net.minecraft.client.renderer.OpenGlHelper;
  11. import net.minecraft.client.renderer.RenderHelper;
  12. import net.minecraft.client.renderer.entity.RenderManager;
  13. import net.minecraft.inventory.IInventory;
  14. import net.minecraft.util.ResourceLocation;
  15. import net.minecraftforge.fml.relauncher.Side;
  16. import net.minecraftforge.fml.relauncher.SideOnly;
  17.  
  18. @SideOnly(Side.CLIENT)
  19. public class GuiDragon extends GuiContainer {
  20. private static final ResourceLocation texture = new ResourceLocation("rotd:textures/gui/dragon.png");
  21. private IInventory playerInventory;
  22. private IInventory dragonInv;
  23. private EntityTameableDragon dragon;
  24. private float mousePosx;
  25. private float mousePosY;
  26.  
  27. public GuiDragon(IInventory playerInv, EntityTameableDragon dragon) {
  28. super(new ContainerDragon(dragon, Minecraft.getMinecraft().player));
  29. this.playerInventory = playerInv;
  30. this.dragonInv = dragon.dragonInv;
  31. this.dragon = dragon;
  32. this.allowUserInput = false;
  33. this.ySize = 214;
  34. }
  35.  
  36. public static void drawEntityOnScreen(int posX, int posY, int scale, float mouseX, float mouseY, EntityTameableDragon entity) {
  37. GlStateManager.enableColorMaterial();
  38. GlStateManager.pushMatrix();
  39. GlStateManager.translate(posX, posY, 50.0F);
  40. GlStateManager.scale(0.8, 0.8, 0.8);
  41. GlStateManager.scale((float)(-scale), (float)scale, (float)scale);
  42. GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
  43. float f2 = entity.renderYawOffset;
  44. float f3 = entity.rotationYaw;
  45. float f4 = entity.rotationPitch;
  46. float f5 = entity.prevRotationYawHead;
  47. float f6 = entity.rotationYawHead;
  48. GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F);
  49. RenderHelper.enableStandardItemLighting();
  50. GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
  51. GlStateManager.rotate(-((float) Math.atan(mouseY / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F);
  52. entity.renderYawOffset = (float) Math.atan(mouseX / 40.0F) * 20.0F;
  53. entity.rotationYaw = (float) Math.atan(mouseX / 40.0F) * 40.0F;
  54. entity.rotationPitch = -((float) Math.atan(mouseY / 40.0F)) * 20.0F;
  55. entity.rotationYawHead = entity.rotationYaw;
  56. entity.prevRotationYawHead = entity.rotationYaw;
  57. GlStateManager.translate(0.0F, 0.0F, 0.0F);
  58. RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
  59. rendermanager.setPlayerViewY(180.0F);
  60. rendermanager.setRenderShadow(false);
  61. rendermanager.doRenderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
  62. rendermanager.setRenderShadow(true);
  63. entity.renderYawOffset = f2;
  64. entity.rotationYaw = f3;
  65. entity.rotationPitch = f4;
  66. entity.prevRotationYawHead = f5;
  67. entity.rotationYawHead = f6;
  68. GlStateManager.popMatrix();
  69. RenderHelper.disableStandardItemLighting();
  70. GlStateManager.disableRescaleNormal();
  71. GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
  72. GlStateManager.disableTexture2D();
  73. GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
  74. }
  75.  
  76. @Override
  77. protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
  78. GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  79. this.mc.getTextureManager().bindTexture(texture);
  80. int x = (this.width - this.xSize) / 2;
  81. int y = (this.height - this.ySize) / 2; // 73 for y
  82. this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); // height is fixed // 150 for texture y
  83. if (dragon.isChested()) {this.drawTexturedModalRect(x + 0, y + 73, 0, 130, 170, 55);} // 150 9 * 18
  84. drawEntityOnScreen(x + 88, y + 65, 23, x + 51 - this.mousePosx, y + 75 - 50 - this.mousePosY, this.dragon);
  85.  
  86. }
  87.  
  88. @Override
  89. public void drawScreen(int mouseX, int mouseY, float partialTicks) {
  90. this.mousePosx = mouseX;
  91. this.mousePosY = mouseY;
  92. super.drawScreen(mouseX, mouseY, partialTicks);
  93. }
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment