mirror of
https://github.com/GTNewHorizons/BloodMagic.git
synced 2026-11-27 07:13:14 +00:00
Experimentation with rendering the armour of the player.
This commit is contained in:
1 parent
bf068d1487
commit
19ed528d13
5 files changed
+313
-4
No files matched your search
@@ -0,0 +1,223 @@
|
||||
package WayofTime.alchemicalWizardry.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemCloth;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
public class ClientUtils
|
||||
{
|
||||
public static Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public static void renderPlayerArmourInPOV(EntityPlayer player, float partialTickTime)
|
||||
{
|
||||
float f1 = 1.0f;//this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * partialTickTime;
|
||||
EntityClientPlayerMP entityclientplayermp = mc.thePlayer;
|
||||
float f2 = entityclientplayermp.prevRotationPitch + (entityclientplayermp.rotationPitch - entityclientplayermp.prevRotationPitch) * partialTickTime;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(f2, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(entityclientplayermp.prevRotationYaw + (entityclientplayermp.rotationYaw - entityclientplayermp.prevRotationYaw) * partialTickTime, 0.0F, 1.0F, 0.0F);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glPopMatrix();
|
||||
EntityPlayerSP entityplayersp = (EntityPlayerSP)entityclientplayermp;
|
||||
float f3 = entityplayersp.prevRenderArmPitch + (entityplayersp.renderArmPitch - entityplayersp.prevRenderArmPitch) * partialTickTime;
|
||||
float f4 = entityplayersp.prevRenderArmYaw + (entityplayersp.renderArmYaw - entityplayersp.prevRenderArmYaw) * partialTickTime;
|
||||
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 = player.getCurrentEquippedItem();
|
||||
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemCloth)
|
||||
{
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
}
|
||||
|
||||
int i = 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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
float f8;
|
||||
float f9;
|
||||
float f10;
|
||||
float f13;
|
||||
Render render;
|
||||
RenderPlayer renderplayer;
|
||||
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
f13 = 0.8F;
|
||||
|
||||
if (entityclientplayermp.getItemInUseCount() > 0)
|
||||
{
|
||||
EnumAction enumaction = itemstack.getItemUseAction();
|
||||
|
||||
if (enumaction == EnumAction.eat || enumaction == EnumAction.drink)
|
||||
{
|
||||
f6 = (float)entityclientplayermp.getItemInUseCount() - partialTickTime + 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(partialTickTime);
|
||||
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.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(partialTickTime);
|
||||
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;
|
||||
|
||||
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() - partialTickTime + 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);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else if (!entityclientplayermp.isInvisible())
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
f13 = 0.8F;
|
||||
f5 = entityclientplayermp.getSwingProgress(partialTickTime);
|
||||
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(partialTickTime);
|
||||
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);
|
||||
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(mc.thePlayer);
|
||||
renderplayer = (RenderPlayer)render;
|
||||
f10 = 1.0F;
|
||||
GL11.glScalef(f10, f10, f10);
|
||||
renderFirstPersonArm(renderplayer, mc.thePlayer);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemCloth)
|
||||
{
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
}
|
||||
|
||||
public static void renderFirstPersonArm(RenderPlayer renderer, EntityPlayer player)
|
||||
{
|
||||
float f = 1.0F;
|
||||
GL11.glColor3f(f, f, f);
|
||||
renderer.modelBipedMain.onGround = 0.0F;
|
||||
renderer.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, player);
|
||||
renderer.modelBipedMain.bipedRightArm.addChild(new POVArmourModelWrapper(renderer.modelBipedMain));
|
||||
renderer.modelBipedMain.bipedRightArm.render(0.0625F);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user