Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.TheRPGAdventurer.ROTD.client.gui;
- import com.TheRPGAdventurer.ROTD.client.inventory.ContainerDragon;
- import com.TheRPGAdventurer.ROTD.server.entity.EntityTameableDragon;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.gui.inventory.GuiContainer;
- import net.minecraft.client.gui.inventory.GuiInventory;
- import net.minecraft.client.renderer.GlStateManager;
- import net.minecraft.client.renderer.OpenGlHelper;
- import net.minecraft.client.renderer.RenderHelper;
- import net.minecraft.client.renderer.entity.RenderManager;
- import net.minecraft.inventory.IInventory;
- import net.minecraft.util.ResourceLocation;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- @SideOnly(Side.CLIENT)
- public class GuiDragon extends GuiContainer {
- private static final ResourceLocation texture = new ResourceLocation("rotd:textures/gui/dragon.png");
- private IInventory playerInventory;
- private IInventory dragonInv;
- private EntityTameableDragon dragon;
- private float mousePosx;
- private float mousePosY;
- public GuiDragon(IInventory playerInv, EntityTameableDragon dragon) {
- super(new ContainerDragon(dragon, Minecraft.getMinecraft().player));
- this.playerInventory = playerInv;
- this.dragonInv = dragon.dragonInv;
- this.dragon = dragon;
- this.allowUserInput = false;
- this.ySize = 214;
- }
- public static void drawEntityOnScreen(int posX, int posY, int scale, float mouseX, float mouseY, EntityTameableDragon entity) {
- GlStateManager.enableColorMaterial();
- GlStateManager.pushMatrix();
- GlStateManager.translate(posX, posY, 50.0F);
- GlStateManager.scale(0.8, 0.8, 0.8);
- GlStateManager.scale((float)(-scale), (float)scale, (float)scale);
- GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
- float f2 = entity.renderYawOffset;
- float f3 = entity.rotationYaw;
- float f4 = entity.rotationPitch;
- float f5 = entity.prevRotationYawHead;
- float f6 = entity.rotationYawHead;
- GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F);
- RenderHelper.enableStandardItemLighting();
- GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
- GlStateManager.rotate(-((float) Math.atan(mouseY / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F);
- entity.renderYawOffset = (float) Math.atan(mouseX / 40.0F) * 20.0F;
- entity.rotationYaw = (float) Math.atan(mouseX / 40.0F) * 40.0F;
- entity.rotationPitch = -((float) Math.atan(mouseY / 40.0F)) * 20.0F;
- entity.rotationYawHead = entity.rotationYaw;
- entity.prevRotationYawHead = entity.rotationYaw;
- GlStateManager.translate(0.0F, 0.0F, 0.0F);
- RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
- rendermanager.setPlayerViewY(180.0F);
- rendermanager.setRenderShadow(false);
- rendermanager.doRenderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
- rendermanager.setRenderShadow(true);
- entity.renderYawOffset = f2;
- entity.rotationYaw = f3;
- entity.rotationPitch = f4;
- entity.prevRotationYawHead = f5;
- entity.rotationYawHead = f6;
- GlStateManager.popMatrix();
- RenderHelper.disableStandardItemLighting();
- GlStateManager.disableRescaleNormal();
- GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
- GlStateManager.disableTexture2D();
- GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
- }
- @Override
- protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- this.mc.getTextureManager().bindTexture(texture);
- int x = (this.width - this.xSize) / 2;
- int y = (this.height - this.ySize) / 2; // 73 for y
- this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); // height is fixed // 150 for texture y
- if (dragon.isChested()) {this.drawTexturedModalRect(x + 0, y + 73, 0, 130, 170, 55);} // 150 9 * 18
- drawEntityOnScreen(x + 88, y + 65, 23, x + 51 - this.mousePosx, y + 75 - 50 - this.mousePosY, this.dragon);
- }
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- this.mousePosx = mouseX;
- this.mousePosY = mouseY;
- super.drawScreen(mouseX, mouseY, partialTicks);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment