Fixed Battlegear rendering issues
This commit is contained in:
parent
a3e51ac1b9
commit
cdf65499c9
|
@ -1,11 +1,8 @@
|
|||
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;
|
||||
|
@ -13,8 +10,6 @@ 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;
|
||||
|
@ -45,7 +40,8 @@ public class AetherItemRenderer extends ItemRenderer {
|
|||
|
||||
private int equippedItemSlot = -1;
|
||||
|
||||
public AetherItemRenderer(Minecraft mcIn) {
|
||||
public AetherItemRenderer(Minecraft mcIn)
|
||||
{
|
||||
super(mcIn);
|
||||
|
||||
this.mc = mcIn;
|
||||
|
@ -87,28 +83,26 @@ public class AetherItemRenderer extends ItemRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderItemInFirstPerson(float partialTicks) {
|
||||
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);
|
||||
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;
|
||||
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemCloth) {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
super.renderItemInFirstPerson(partialTicks);
|
||||
|
||||
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);
|
||||
float f1 = this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * partialTicks;
|
||||
float f2 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTicks;
|
||||
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
|
||||
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);
|
||||
|
@ -134,10 +128,11 @@ public class AetherItemRenderer extends ItemRenderer {
|
|||
Render render;
|
||||
RenderPlayer renderplayer;
|
||||
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemMap) {
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemMap)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
f13 = 0.8F;
|
||||
f5 = entityclientplayermp.getSwingProgress(partialTicks);
|
||||
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);
|
||||
|
@ -156,7 +151,7 @@ public class AetherItemRenderer extends ItemRenderer {
|
|||
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());
|
||||
this.mc.getTextureManager().bindTexture(player.getLocationSkin());
|
||||
|
||||
for (int i1 = 0; i1 < 2; ++i1) {
|
||||
int j1 = i1 * 2 - 1;
|
||||
|
@ -174,7 +169,7 @@ public class AetherItemRenderer extends ItemRenderer {
|
|||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
f6 = entityclientplayermp.getSwingProgress(partialTicks);
|
||||
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);
|
||||
|
@ -210,120 +205,24 @@ public class AetherItemRenderer extends ItemRenderer {
|
|||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
} else if (itemstack != null) {
|
||||
}
|
||||
else if (!player.isInvisible())
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
f13 = 0.8F;
|
||||
|
||||
if (entityclientplayermp.getItemInUseCount() > 0) {
|
||||
EnumAction enumaction = itemstack.getItemUseAction();
|
||||
|
||||
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.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;
|
||||
|
||||
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);
|
||||
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 = entityclientplayermp.getSwingProgress(partialTicks);
|
||||
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(entityclientplayermp.getLocationSkin());
|
||||
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);
|
||||
|
@ -338,10 +237,6 @@ public class AetherItemRenderer extends ItemRenderer {
|
|||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemCloth) {
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
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;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class AetherClientCompatibility
|
||||
{
|
||||
|
||||
public static void initialization()
|
||||
{
|
||||
if (Loader.isModLoaded("battlegear2"))
|
||||
{
|
||||
CommonProxy.registerEvent(new BattlegearClientEventHandler());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.legacy.aether.compatibility.client;
|
||||
|
||||
import com.legacy.aether.client.renders.AetherItemRenderer;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import mods.battlegear2.api.RenderPlayerEventChild.PlayerElementType;
|
||||
import mods.battlegear2.api.RenderPlayerEventChild.PostRenderPlayerElement;
|
||||
|
||||
public class BattlegearClientEventHandler
|
||||
{
|
||||
|
||||
@SubscribeEvent
|
||||
public void renderOffhandGloveEvent(PostRenderPlayerElement event)
|
||||
{
|
||||
EntityRenderer renderer = Minecraft.getMinecraft().entityRenderer;
|
||||
|
||||
if (event.type == PlayerElementType.Offhand && event.isFirstPerson && renderer != null && renderer.itemRenderer instanceof AetherItemRenderer)
|
||||
{
|
||||
((AetherItemRenderer)renderer.itemRenderer).renderFirstPersonArm((RenderPlayer) RenderManager.instance.getEntityRenderObject(Minecraft.getMinecraft().thePlayer), Minecraft.getMinecraft().thePlayer);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package mods.battlegear2.api;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
|
||||
/**
|
||||
* Those events are posted to {@link BattlegearUtils.RENDER_BUS} from {@link BattlegearRenderHelper}
|
||||
*/
|
||||
public abstract class RenderPlayerEventChild extends RenderPlayerEvent{
|
||||
public static enum PlayerElementType{
|
||||
Offhand,
|
||||
ItemOffhand,
|
||||
ItemOffhandSheathed,
|
||||
ItemMainhandSheathed,
|
||||
}
|
||||
|
||||
/**
|
||||
* Describe what element is rendered, either the player arm or the item hold/sheathed
|
||||
*/
|
||||
public final PlayerElementType type;
|
||||
/**
|
||||
* True in first person rendering, false in third person rendering
|
||||
*/
|
||||
public final boolean isFirstPerson;
|
||||
/**
|
||||
* The element to be rendered, or null if a player arm
|
||||
*/
|
||||
public final ItemStack element;
|
||||
public RenderPlayerEventChild(RenderPlayerEvent parent, PlayerElementType type, boolean firstPerson, ItemStack item) {
|
||||
super(parent.entityPlayer, parent.renderer, parent.partialRenderTick);
|
||||
this.type = type;
|
||||
this.isFirstPerson = firstPerson;
|
||||
this.element = item;
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class PreRenderPlayerElement extends RenderPlayerEventChild{
|
||||
public PreRenderPlayerElement(RenderPlayerEvent parent, boolean isFirstPerson, PlayerElementType type, ItemStack item) {
|
||||
super(parent, type, isFirstPerson, item);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PostRenderPlayerElement extends RenderPlayerEventChild{
|
||||
public PostRenderPlayerElement(RenderPlayerEvent parent, boolean isFirstPerson, PlayerElementType type, ItemStack item) {
|
||||
super(parent, type, isFirstPerson, item);
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class PreRenderSheathed extends PreRenderPlayerElement{
|
||||
/*
|
||||
* True if the sheathed item is supposed to be on the player back
|
||||
*/
|
||||
public final boolean isOnBack;
|
||||
/*
|
||||
* The number of items supposed to be laying on the player back,
|
||||
* including chest armor
|
||||
*/
|
||||
public final int backCount;
|
||||
public PreRenderSheathed(RenderPlayerEvent parent, boolean isOnBack, int count, boolean isMainHand, ItemStack item) {
|
||||
super(parent, false, isMainHand?PlayerElementType.ItemMainhandSheathed:PlayerElementType.ItemOffhandSheathed, item);
|
||||
this.isOnBack = isOnBack;
|
||||
this.backCount = count;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PostRenderSheathed extends PostRenderPlayerElement{
|
||||
/*
|
||||
* True if the sheathed item is supposed to be on the player back
|
||||
*/
|
||||
public final boolean isOnBack;
|
||||
/*
|
||||
* The number of items supposed to be laying on the player back,
|
||||
* including chest armor
|
||||
*/
|
||||
public final int backCount;
|
||||
public PostRenderSheathed(RenderPlayerEvent parent, boolean isOnBack, int count, boolean isMainHand, ItemStack item) {
|
||||
super(parent, false, isMainHand?PlayerElementType.ItemMainhandSheathed:PlayerElementType.ItemOffhandSheathed, item);
|
||||
this.isOnBack = isOnBack;
|
||||
this.backCount = count;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue