From e152fa0a89cdcbd2acbfbfea7cb7083dd5d2a547 Mon Sep 17 00:00:00 2001 From: Kino Date: Sun, 30 Dec 2018 02:26:15 -0500 Subject: [PATCH] Fixed additional Battlegear issues --- .../com/legacy/aether/client/ClientProxy.java | 3 + .../client/renders/AetherItemRenderer.java | 419 ++++++++++++------ .../client/AetherClientCompatibility.java | 4 +- .../battlegear2/api/core/BattlegearUtils.java | 17 + .../client/utils/BattlegearRenderHelper.java | 13 + 5 files changed, 316 insertions(+), 140 deletions(-) create mode 100644 src/main/java/mods/battlegear2/api/core/BattlegearUtils.java create mode 100644 src/main/java/mods/battlegear2/client/utils/BattlegearRenderHelper.java diff --git a/src/main/java/com/legacy/aether/client/ClientProxy.java b/src/main/java/com/legacy/aether/client/ClientProxy.java index 9469b7f..68e04de 100644 --- a/src/main/java/com/legacy/aether/client/ClientProxy.java +++ b/src/main/java/com/legacy/aether/client/ClientProxy.java @@ -13,6 +13,7 @@ import com.legacy.aether.client.gui.GuiAetherInGame; import com.legacy.aether.client.gui.GuiSunAltar; import com.legacy.aether.client.renders.AetherEntityRenderer; import com.legacy.aether.client.renders.RendersAether; +import com.legacy.aether.compatibility.client.AetherClientCompatibility; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.RenderingRegistry; @@ -38,6 +39,8 @@ public class ClientProxy extends CommonProxy { registerEvent(new AetherMusicHandler()); registerEvent(new AetherClientEvents()); registerEvent(new GuiAetherInGame(Minecraft.getMinecraft())); + + AetherClientCompatibility.initialization(); } @Override diff --git a/src/main/java/com/legacy/aether/client/renders/AetherItemRenderer.java b/src/main/java/com/legacy/aether/client/renders/AetherItemRenderer.java index 016eae6..420c518 100644 --- a/src/main/java/com/legacy/aether/client/renders/AetherItemRenderer.java +++ b/src/main/java/com/legacy/aether/client/renders/AetherItemRenderer.java @@ -1,8 +1,10 @@ package com.legacy.aether.client.renders; +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON; import static net.minecraftforge.client.IItemRenderer.ItemRenderType.FIRST_PERSON_MAP; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; @@ -10,6 +12,8 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.ItemCloth; import net.minecraft.item.ItemMap; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; @@ -26,6 +30,8 @@ import com.legacy.aether.items.ItemsAether; import com.legacy.aether.items.accessories.ItemAccessory; import com.legacy.aether.player.PlayerAether; +import cpw.mods.fml.common.Loader; + public class AetherItemRenderer extends ItemRenderer { private static final ResourceLocation RES_MAP_BACKGROUND = new ResourceLocation("textures/map/map_background.png"); @@ -85,160 +91,299 @@ public class AetherItemRenderer extends ItemRenderer { @Override public void renderItemInFirstPerson(float partialTicks) { - EntityClientPlayerMP player = this.mc.thePlayer; - PlayerAether playerAether = PlayerAether.get(player); - ItemStack gloves = playerAether.getAccessoryInventory().getStackInSlot(AccessoryType.GLOVES); - ItemStack itemstack = this.itemToRender; + float f1 = this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * partialTicks; + EntityClientPlayerMP entityclientplayermp = this.mc.thePlayer; + float f2 = entityclientplayermp.prevRotationPitch + (entityclientplayermp.rotationPitch - entityclientplayermp.prevRotationPitch) * partialTicks; + GL11.glPushMatrix(); + GL11.glRotatef(f2, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(entityclientplayermp.prevRotationYaw + (entityclientplayermp.rotationYaw - entityclientplayermp.prevRotationYaw) * partialTicks, 0.0F, 1.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glPopMatrix(); + EntityPlayerSP entityplayersp = (EntityPlayerSP)entityclientplayermp; + float f3 = entityplayersp.prevRenderArmPitch + (entityplayersp.renderArmPitch - entityplayersp.prevRenderArmPitch) * partialTicks; + float f4 = entityplayersp.prevRenderArmYaw + (entityplayersp.renderArmYaw - entityplayersp.prevRenderArmYaw) * partialTicks; + GL11.glRotatef((entityclientplayermp.rotationPitch - f3) * 0.1F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef((entityclientplayermp.rotationYaw - f4) * 0.1F, 0.0F, 1.0F, 0.0F); + ItemStack itemstack = this.itemToRender; - super.renderItemInFirstPerson(partialTicks); + if (itemstack != null && itemstack.getItem() instanceof ItemCloth) + { + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + } - if (gloves == null || (itemstack != null && !(itemstack.getItem() instanceof ItemMap))) - { - return; - } + int i = this.mc.theWorld.getLightBrightnessForSkyBlocks(MathHelper.floor_double(entityclientplayermp.posX), MathHelper.floor_double(entityclientplayermp.posY), MathHelper.floor_double(entityclientplayermp.posZ), 0); + int j = i % 65536; + int k = i / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float f5; + float f6; + float f7; - float f1 = this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * partialTicks; - float f2 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTicks; + if (itemstack != null) + { + int l = itemstack.getItem().getColorFromItemStack(itemstack, 0); + f5 = (float)(l >> 16 & 255) / 255.0F; + f6 = (float)(l >> 8 & 255) / 255.0F; + f7 = (float)(l & 255) / 255.0F; + GL11.glColor4f(f5, f6, f7, 1.0F); + } + else + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } - RenderHelper.enableStandardItemLighting(); + float f8; + float f9; + float f10; + float f13; + Render render; + RenderPlayer renderplayer; - int i = this.mc.theWorld.getLightBrightnessForSkyBlocks(MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ), 0); - int j = i % 65536; - int k = i / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - float f5; - float f6; - float f7; + if (itemstack != null && itemstack.getItem() instanceof ItemMap) + { + GL11.glPushMatrix(); + f13 = 0.8F; + f5 = entityclientplayermp.getSwingProgress(partialTicks); + f6 = MathHelper.sin(f5 * (float)Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); + GL11.glTranslatef(-f7 * 0.4F, MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI * 2.0F) * 0.2F, -f6 * 0.2F); + f5 = 1.0F - f2 / 45.0F + 0.1F; - if (itemstack != null) { - int l = itemstack.getItem().getColorFromItemStack(itemstack, 0); - f5 = (float) (l >> 16 & 255) / 255.0F; - f6 = (float) (l >> 8 & 255) / 255.0F; - f7 = (float) (l & 255) / 255.0F; - GL11.glColor4f(f5, f6, f7, 1.0F); - } else { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - } + if (f5 < 0.0F) + { + f5 = 0.0F; + } - float f8; - float f9; - float f10; - float f13; - Render render; - RenderPlayer renderplayer; + if (f5 > 1.0F) + { + f5 = 1.0F; + } - if (itemstack != null && itemstack.getItem() instanceof ItemMap) - { - GL11.glPushMatrix(); - f13 = 0.8F; - f5 = player.getSwingProgress(partialTicks); - f6 = MathHelper.sin(f5 * (float) Math.PI); - f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float) Math.PI); - GL11.glTranslatef(-f7 * 0.4F, MathHelper.sin(MathHelper.sqrt_float(f5) * (float) Math.PI * 2.0F) * 0.2F, -f6 * 0.2F); - f5 = 1.0F - f2 / 45.0F + 0.1F; + f5 = -MathHelper.cos(f5 * (float)Math.PI) * 0.5F + 0.5F; + GL11.glTranslatef(0.0F, 0.0F * f13 - (1.0F - f1) * 1.2F - f5 * 0.5F + 0.04F, -0.9F * f13); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(f5 * -85.0F, 0.0F, 0.0F, 1.0F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + this.mc.getTextureManager().bindTexture(entityclientplayermp.getLocationSkin()); - if (f5 < 0.0F) { - f5 = 0.0F; - } + for (int i1 = 0; i1 < 2; ++i1) + { + int j1 = i1 * 2 - 1; + GL11.glPushMatrix(); + GL11.glTranslatef(-0.0F, -0.6F, 1.1F * (float)j1); + GL11.glRotatef((float)(-45 * j1), 1.0F, 0.0F, 0.0F); + GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(59.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef((float)(-65 * j1), 0.0F, 1.0F, 0.0F); + render = RenderManager.instance.getEntityRenderObject(this.mc.thePlayer); + renderplayer = (RenderPlayer)render; + f10 = 1.0F; + GL11.glScalef(f10, f10, f10); + this.renderFirstPersonArm(renderplayer, this.mc.thePlayer); + GL11.glPopMatrix(); + } - if (f5 > 1.0F) { - f5 = 1.0F; - } + f6 = entityclientplayermp.getSwingProgress(partialTicks); + f7 = MathHelper.sin(f6 * f6 * (float)Math.PI); + f8 = MathHelper.sin(MathHelper.sqrt_float(f6) * (float)Math.PI); + GL11.glRotatef(-f7 * 20.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-f8 * 20.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-f8 * 80.0F, 1.0F, 0.0F, 0.0F); + f9 = 0.38F; + GL11.glScalef(f9, f9, f9); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-1.0F, -1.0F, 0.0F); + f10 = 0.015625F; + GL11.glScalef(f10, f10, f10); + this.mc.getTextureManager().bindTexture(RES_MAP_BACKGROUND); + Tessellator tessellator = Tessellator.instance; + GL11.glNormal3f(0.0F, 0.0F, -1.0F); + tessellator.startDrawingQuads(); + byte b0 = 7; + tessellator.addVertexWithUV((double)(0 - b0), (double)(128 + b0), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)(128 + b0), (double)(128 + b0), 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)(128 + b0), (double)(0 - b0), 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)(0 - b0), (double)(0 - b0), 0.0D, 0.0D, 0.0D); + tessellator.draw(); - f5 = -MathHelper.cos(f5 * (float) Math.PI) * 0.5F + 0.5F; - GL11.glTranslatef(0.0F, 0.0F * f13 - (1.0F - f1) * 1.2F - f5 * 0.5F + 0.04F, -0.9F * f13); - GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(f5 * -85.0F, 0.0F, 0.0F, 1.0F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - this.mc.getTextureManager().bindTexture(player.getLocationSkin()); + IItemRenderer custom = MinecraftForgeClient.getItemRenderer(itemstack, FIRST_PERSON_MAP); + MapData mapdata = ((ItemMap)itemstack.getItem()).getMapData(itemstack, this.mc.theWorld); - for (int i1 = 0; i1 < 2; ++i1) { - int j1 = i1 * 2 - 1; - GL11.glPushMatrix(); - GL11.glTranslatef(-0.0F, -0.6F, 1.1F * (float) j1); - GL11.glRotatef((float) (-45 * j1), 1.0F, 0.0F, 0.0F); - GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(59.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef((float) (-65 * j1), 0.0F, 1.0F, 0.0F); - render = RenderManager.instance.getEntityRenderObject(this.mc.thePlayer); - renderplayer = (RenderPlayer) render; - f10 = 1.0F; - GL11.glScalef(f10, f10, f10); - this.renderFirstPersonArm(renderplayer, this.mc.thePlayer); - GL11.glPopMatrix(); - } + if (custom == null) + { + if (mapdata != null) + { + this.mc.entityRenderer.getMapItemRenderer().func_148250_a(mapdata, false); + } + } + else + { + custom.renderItem(FIRST_PERSON_MAP, itemstack, mc.thePlayer, mc.getTextureManager(), mapdata); + } - f6 = player.getSwingProgress(partialTicks); - f7 = MathHelper.sin(f6 * f6 * (float) Math.PI); - f8 = MathHelper.sin(MathHelper.sqrt_float(f6) * (float) Math.PI); - GL11.glRotatef(-f7 * 20.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-f8 * 20.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(-f8 * 80.0F, 1.0F, 0.0F, 0.0F); - f9 = 0.38F; - GL11.glScalef(f9, f9, f9); - GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); - GL11.glTranslatef(-1.0F, -1.0F, 0.0F); - f10 = 0.015625F; - GL11.glScalef(f10, f10, f10); - this.mc.getTextureManager().bindTexture(RES_MAP_BACKGROUND); - Tessellator tessellator = Tessellator.instance; - GL11.glNormal3f(0.0F, 0.0F, -1.0F); - tessellator.startDrawingQuads(); - byte b0 = 7; - tessellator.addVertexWithUV((double) (0 - b0), (double) (128 + b0), 0.0D, 0.0D, 1.0D); - tessellator.addVertexWithUV((double) (128 + b0), (double) (128 + b0), 0.0D, 1.0D, 1.0D); - tessellator.addVertexWithUV((double) (128 + b0), (double) (0 - b0), 0.0D, 1.0D, 0.0D); - tessellator.addVertexWithUV((double) (0 - b0), (double) (0 - b0), 0.0D, 0.0D, 0.0D); - tessellator.draw(); + GL11.glPopMatrix(); + } + else if (itemstack != null) + { + GL11.glPushMatrix(); + f13 = 0.8F; - IItemRenderer custom = MinecraftForgeClient.getItemRenderer(itemstack, FIRST_PERSON_MAP); - MapData mapdata = ((ItemMap) itemstack.getItem()).getMapData(itemstack, this.mc.theWorld); + if (entityclientplayermp.getItemInUseCount() > 0) + { + EnumAction enumaction = itemstack.getItemUseAction(); - if (custom == null) { - if (mapdata != null) { - this.mc.entityRenderer.getMapItemRenderer().func_148250_a(mapdata, false); - } - } else { - custom.renderItem(FIRST_PERSON_MAP, itemstack, mc.thePlayer, mc.getTextureManager(), mapdata); - } + if (enumaction == EnumAction.eat || enumaction == EnumAction.drink) + { + f6 = (float)entityclientplayermp.getItemInUseCount() - partialTicks + 1.0F; + f7 = 1.0F - f6 / (float)itemstack.getMaxItemUseDuration(); + f8 = 1.0F - f7; + f8 = f8 * f8 * f8; + f8 = f8 * f8 * f8; + f8 = f8 * f8 * f8; + f9 = 1.0F - f8; + GL11.glTranslatef(0.0F, MathHelper.abs(MathHelper.cos(f6 / 4.0F * (float)Math.PI) * 0.1F) * (float)((double)f7 > 0.2D ? 1 : 0), 0.0F); + GL11.glTranslatef(f9 * 0.6F, -f9 * 0.5F, 0.0F); + GL11.glRotatef(f9 * 90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(f9 * 10.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f9 * 30.0F, 0.0F, 0.0F, 1.0F); + } + } + else + { + f5 = entityclientplayermp.getSwingProgress(partialTicks); + f6 = MathHelper.sin(f5 * (float)Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); + GL11.glTranslatef(-f7 * 0.4F, MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI * 2.0F) * 0.2F, -f6 * 0.2F); + } - GL11.glPopMatrix(); - } - else if (!player.isInvisible()) - { - GL11.glPushMatrix(); - f13 = 0.8F; - f5 = player.getSwingProgress(partialTicks); - f6 = MathHelper.sin(f5 * (float) Math.PI); - f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float) Math.PI); - GL11.glTranslatef(-f7 * 0.3F, MathHelper.sin(MathHelper.sqrt_float(f5) * (float) Math.PI * 2.0F) * 0.4F, -f6 * 0.4F); - GL11.glTranslatef(0.8F * f13, -0.75F * f13 - (1.0F - f1) * 0.6F, -0.9F * f13); - GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - f5 = player.getSwingProgress(partialTicks); - f6 = MathHelper.sin(f5 * f5 * (float) Math.PI); - f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float) Math.PI); - GL11.glRotatef(f7 * 70.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-f6 * 20.0F, 0.0F, 0.0F, 1.0F); - this.mc.getTextureManager().bindTexture(player.getLocationSkin()); - GL11.glTranslatef(-1.0F, 3.6F, 3.5F); - GL11.glRotatef(120.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(200.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); - GL11.glScalef(1.0F, 1.0F, 1.0F); - GL11.glTranslatef(5.6F, 0.0F, 0.0F); - render = RenderManager.instance.getEntityRenderObject(this.mc.thePlayer); - renderplayer = (RenderPlayer) render; - f10 = 1.0F; - GL11.glScalef(f10, f10, f10); - this.renderFirstPersonArm(renderplayer, this.mc.thePlayer); - GL11.glPopMatrix(); - } + GL11.glTranslatef(0.7F * f13, -0.65F * f13 - (1.0F - f1) * 0.6F, -0.9F * f13); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + f5 = entityclientplayermp.getSwingProgress(partialTicks); + f6 = MathHelper.sin(f5 * f5 * (float)Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); + GL11.glRotatef(-f6 * 20.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-f7 * 20.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-f7 * 80.0F, 1.0F, 0.0F, 0.0F); + f8 = 0.4F; + GL11.glScalef(f8, f8, f8); + float f11; + float f12; - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - RenderHelper.disableStandardItemLighting(); + if (entityclientplayermp.getItemInUseCount() > 0) + { + EnumAction enumaction1 = itemstack.getItemUseAction(); + + if (enumaction1 == EnumAction.block) + { + GL11.glTranslatef(-0.5F, 0.2F, 0.0F); + GL11.glRotatef(30.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-80.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(60.0F, 0.0F, 1.0F, 0.0F); + } + else if (enumaction1 == EnumAction.bow) + { + GL11.glRotatef(-18.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-12.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-8.0F, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(-0.9F, 0.2F, 0.0F); + f10 = (float)itemstack.getMaxItemUseDuration() - ((float)entityclientplayermp.getItemInUseCount() - partialTicks + 1.0F); + f11 = f10 / 20.0F; + f11 = (f11 * f11 + f11 * 2.0F) / 3.0F; + + if (f11 > 1.0F) + { + f11 = 1.0F; + } + + if (f11 > 0.1F) + { + GL11.glTranslatef(0.0F, MathHelper.sin((f10 - 0.1F) * 1.3F) * 0.01F * (f11 - 0.1F), 0.0F); + } + + GL11.glTranslatef(0.0F, 0.0F, f11 * 0.1F); + GL11.glRotatef(-335.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.5F, 0.0F); + f12 = 1.0F + f11 * 0.2F; + GL11.glScalef(1.0F, 1.0F, f12); + GL11.glTranslatef(0.0F, -0.5F, 0.0F); + GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); + } + } + + if (itemstack.getItem().shouldRotateAroundWhenRendering()) + { + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + } + + if (itemstack.getItem().requiresMultipleRenderPasses()) + { + this.renderItem(entityclientplayermp, itemstack, 0, EQUIPPED_FIRST_PERSON); + for (int x = 1; x < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); x++) + { + int k1 = itemstack.getItem().getColorFromItemStack(itemstack, x); + f10 = (float)(k1 >> 16 & 255) / 255.0F; + f11 = (float)(k1 >> 8 & 255) / 255.0F; + f12 = (float)(k1 & 255) / 255.0F; + GL11.glColor4f(1.0F * f10, 1.0F * f11, 1.0F * f12, 1.0F); + this.renderItem(entityclientplayermp, itemstack, x, EQUIPPED_FIRST_PERSON); + } + } + else + { + this.renderItem(entityclientplayermp, itemstack, 0, EQUIPPED_FIRST_PERSON); + } + + GL11.glPopMatrix(); + } + else if (!entityclientplayermp.isInvisible()) + { + GL11.glPushMatrix(); + f13 = 0.8F; + f5 = entityclientplayermp.getSwingProgress(partialTicks); + f6 = MathHelper.sin(f5 * (float)Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); + GL11.glTranslatef(-f7 * 0.3F, MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI * 2.0F) * 0.4F, -f6 * 0.4F); + GL11.glTranslatef(0.8F * f13, -0.75F * f13 - (1.0F - f1) * 0.6F, -0.9F * f13); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + f5 = entityclientplayermp.getSwingProgress(partialTicks); + f6 = MathHelper.sin(f5 * f5 * (float)Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); + GL11.glRotatef(f7 * 70.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-f6 * 20.0F, 0.0F, 0.0F, 1.0F); + this.mc.getTextureManager().bindTexture(entityclientplayermp.getLocationSkin()); + GL11.glTranslatef(-1.0F, 3.6F, 3.5F); + GL11.glRotatef(120.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(200.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(1.0F, 1.0F, 1.0F); + GL11.glTranslatef(5.6F, 0.0F, 0.0F); + render = RenderManager.instance.getEntityRenderObject(this.mc.thePlayer); + renderplayer = (RenderPlayer)render; + f10 = 1.0F; + GL11.glScalef(f10, f10, f10); + this.renderFirstPersonArm(renderplayer, this.mc.thePlayer); + GL11.glPopMatrix(); + } + + if (itemstack != null && itemstack.getItem() instanceof ItemCloth) + { + GL11.glDisable(GL11.GL_BLEND); + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + + if (Loader.isModLoaded("battlegear2")) + { + mods.battlegear2.client.utils.BattlegearRenderHelper.renderItemInFirstPerson(partialTicks, mc, this); + } } @Override diff --git a/src/main/java/com/legacy/aether/compatibility/client/AetherClientCompatibility.java b/src/main/java/com/legacy/aether/compatibility/client/AetherClientCompatibility.java index c5f1b73..2d9a590 100644 --- a/src/main/java/com/legacy/aether/compatibility/client/AetherClientCompatibility.java +++ b/src/main/java/com/legacy/aether/compatibility/client/AetherClientCompatibility.java @@ -1,7 +1,5 @@ package com.legacy.aether.compatibility.client; -import com.legacy.aether.CommonProxy; - import cpw.mods.fml.common.Loader; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -14,7 +12,7 @@ public class AetherClientCompatibility { if (Loader.isModLoaded("battlegear2")) { - CommonProxy.registerEvent(new BattlegearClientEventHandler()); + mods.battlegear2.api.core.BattlegearUtils.RENDER_BUS.register(new BattlegearClientEventHandler()); } } diff --git a/src/main/java/mods/battlegear2/api/core/BattlegearUtils.java b/src/main/java/mods/battlegear2/api/core/BattlegearUtils.java new file mode 100644 index 0000000..4da0a11 --- /dev/null +++ b/src/main/java/mods/battlegear2/api/core/BattlegearUtils.java @@ -0,0 +1,17 @@ +package mods.battlegear2.api.core; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.eventhandler.EventBus; + +/** + * Store commonly used method, mostly for the {@link EntityPlayer} {@link ItemStack}s management + */ +public class BattlegearUtils { + + /** + * Event bus to which {@link mods.battlegear2.api.RenderPlayerEventChild} events are post to + */ + public static final EventBus RENDER_BUS = new EventBus(); + +} \ No newline at end of file diff --git a/src/main/java/mods/battlegear2/client/utils/BattlegearRenderHelper.java b/src/main/java/mods/battlegear2/client/utils/BattlegearRenderHelper.java new file mode 100644 index 0000000..1d7b4f2 --- /dev/null +++ b/src/main/java/mods/battlegear2/client/utils/BattlegearRenderHelper.java @@ -0,0 +1,13 @@ +package mods.battlegear2.client.utils; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; + +public class BattlegearRenderHelper +{ + + public static void renderItemInFirstPerson(float frame, Minecraft mc, ItemRenderer itemRenderer) { + + } + +} \ No newline at end of file