mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 01:27:27 +00:00
Copied doRender code from RenderLiving and RenderLivingEntity for the next changes
This commit is contained in:
1 parent
e46b78ff71
commit
7edfc8f473
1 file changed
+239
-1
@@ -18,7 +18,10 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.boss.BossStatus;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.RenderLivingEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import noppes.npcs.api.ISkinOverlay;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.client.ImageDownloadAlt;
|
||||
@@ -29,6 +32,7 @@ import noppes.npcs.controllers.data.SkinOverlay;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -213,9 +217,243 @@ public class RenderNPCInterface extends RenderLiving{
|
||||
}
|
||||
|
||||
staticRenderManager = this.renderManager;
|
||||
super.doRender(entityliving, d, d1, d2, f, f1);
|
||||
|
||||
doRenderLiving(entityliving, d, d1, d2, f, f1);
|
||||
}
|
||||
|
||||
public void doRenderLiving(EntityLiving p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
|
||||
{
|
||||
if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre(p_76986_1_, this, p_76986_2_, p_76986_4_, p_76986_6_))) return;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
this.mainModel.onGround = this.renderSwingProgress(p_76986_1_, p_76986_9_);
|
||||
|
||||
if (this.renderPassModel != null)
|
||||
{
|
||||
this.renderPassModel.onGround = this.mainModel.onGround;
|
||||
}
|
||||
|
||||
this.mainModel.isRiding = p_76986_1_.isRiding();
|
||||
|
||||
if (this.renderPassModel != null)
|
||||
{
|
||||
this.renderPassModel.isRiding = this.mainModel.isRiding;
|
||||
}
|
||||
|
||||
this.mainModel.isChild = p_76986_1_.isChild();
|
||||
|
||||
if (this.renderPassModel != null)
|
||||
{
|
||||
this.renderPassModel.isChild = this.mainModel.isChild;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
float f2 = this.interpolateRotation(p_76986_1_.prevRenderYawOffset, p_76986_1_.renderYawOffset, p_76986_9_);
|
||||
float f3 = this.interpolateRotation(p_76986_1_.prevRotationYawHead, p_76986_1_.rotationYawHead, p_76986_9_);
|
||||
float f4;
|
||||
|
||||
if (p_76986_1_.isRiding() && p_76986_1_.ridingEntity instanceof EntityLivingBase)
|
||||
{
|
||||
EntityLivingBase entitylivingbase1 = (EntityLivingBase)p_76986_1_.ridingEntity;
|
||||
f2 = this.interpolateRotation(entitylivingbase1.prevRenderYawOffset, entitylivingbase1.renderYawOffset, p_76986_9_);
|
||||
f4 = MathHelper.wrapAngleTo180_float(f3 - f2);
|
||||
|
||||
if (f4 < -85.0F)
|
||||
{
|
||||
f4 = -85.0F;
|
||||
}
|
||||
|
||||
if (f4 >= 85.0F)
|
||||
{
|
||||
f4 = 85.0F;
|
||||
}
|
||||
|
||||
f2 = f3 - f4;
|
||||
|
||||
if (f4 * f4 > 2500.0F)
|
||||
{
|
||||
f2 += f4 * 0.2F;
|
||||
}
|
||||
}
|
||||
|
||||
float f13 = p_76986_1_.prevRotationPitch + (p_76986_1_.rotationPitch - p_76986_1_.prevRotationPitch) * p_76986_9_;
|
||||
this.renderLivingAt(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_);
|
||||
f4 = this.handleRotationFloat(p_76986_1_, p_76986_9_);
|
||||
this.rotateCorpse(p_76986_1_, f4, f2, p_76986_9_);
|
||||
float f5 = 0.0625F;
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glScalef(-1.0F, -1.0F, 1.0F);
|
||||
this.preRenderCallback(p_76986_1_, p_76986_9_);
|
||||
GL11.glTranslatef(0.0F, -24.0F * f5 - 0.0078125F, 0.0F);
|
||||
float f6 = p_76986_1_.prevLimbSwingAmount + (p_76986_1_.limbSwingAmount - p_76986_1_.prevLimbSwingAmount) * p_76986_9_;
|
||||
float f7 = p_76986_1_.limbSwing - p_76986_1_.limbSwingAmount * (1.0F - p_76986_9_);
|
||||
|
||||
if (p_76986_1_.isChild())
|
||||
{
|
||||
f7 *= 3.0F;
|
||||
}
|
||||
|
||||
if (f6 > 1.0F)
|
||||
{
|
||||
f6 = 1.0F;
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
this.mainModel.setLivingAnimations(p_76986_1_, f7, f6, p_76986_9_);
|
||||
this.renderModel(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
|
||||
int j;
|
||||
float f8;
|
||||
float f9;
|
||||
float f10;
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
j = this.shouldRenderPass(p_76986_1_, i, p_76986_9_);
|
||||
|
||||
if (j > 0)
|
||||
{
|
||||
this.renderPassModel.setLivingAnimations(p_76986_1_, f7, f6, p_76986_9_);
|
||||
this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
|
||||
|
||||
if ((j & 240) == 16)
|
||||
{
|
||||
this.func_82408_c(p_76986_1_, i, p_76986_9_);
|
||||
this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
|
||||
}
|
||||
|
||||
if ((j & 15) == 15)
|
||||
{
|
||||
f8 = (float)p_76986_1_.ticksExisted + p_76986_9_;
|
||||
this.bindTexture(new ResourceLocation("textures/misc/enchanted_item_glint.png"));
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
f9 = 0.5F;
|
||||
GL11.glColor4f(f9, f9, f9, 1.0F);
|
||||
GL11.glDepthFunc(GL11.GL_EQUAL);
|
||||
GL11.glDepthMask(false);
|
||||
|
||||
for (int k = 0; k < 2; ++k)
|
||||
{
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
f10 = 0.76F;
|
||||
GL11.glColor4f(0.5F * f10, 0.25F * f10, 0.8F * f10, 1.0F);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glLoadIdentity();
|
||||
float f11 = f8 * (0.001F + (float)k * 0.003F) * 20.0F;
|
||||
float f12 = 0.33333334F;
|
||||
GL11.glScalef(f12, f12, f12);
|
||||
GL11.glRotatef(30.0F - (float)k * 60.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glTranslatef(0.0F, f11, 0.0F);
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
|
||||
}
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glDepthMask(true);
|
||||
this.renderEquippedItems(p_76986_1_, p_76986_9_);
|
||||
float f14 = p_76986_1_.getBrightness(p_76986_9_);
|
||||
j = this.getColorMultiplier(p_76986_1_, f14, p_76986_9_);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
|
||||
if ((j >> 24 & 255) > 0 || p_76986_1_.hurtTime > 0 || p_76986_1_.deathTime > 0)
|
||||
{
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDepthFunc(GL11.GL_EQUAL);
|
||||
|
||||
if (p_76986_1_.hurtTime > 0 || p_76986_1_.deathTime > 0)
|
||||
{
|
||||
GL11.glColor4f(f14, 0.0F, 0.0F, 0.4F);
|
||||
this.mainModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
|
||||
|
||||
for (int l = 0; l < 4; ++l)
|
||||
{
|
||||
if (this.inheritRenderPass(p_76986_1_, l, p_76986_9_) >= 0)
|
||||
{
|
||||
GL11.glColor4f(f14, 0.0F, 0.0F, 0.4F);
|
||||
this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((j >> 24 & 255) > 0)
|
||||
{
|
||||
f8 = (float)(j >> 16 & 255) / 255.0F;
|
||||
f9 = (float)(j >> 8 & 255) / 255.0F;
|
||||
float f15 = (float)(j & 255) / 255.0F;
|
||||
f10 = (float)(j >> 24 & 255) / 255.0F;
|
||||
GL11.glColor4f(f8, f9, f15, f10);
|
||||
this.mainModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
|
||||
|
||||
for (int i1 = 0; i1 < 4; ++i1)
|
||||
{
|
||||
if (this.inheritRenderPass(p_76986_1_, i1, p_76986_9_) >= 0)
|
||||
{
|
||||
GL11.glColor4f(f8, f9, f15, f10);
|
||||
this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glPopMatrix();
|
||||
this.passSpecialRender(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_);
|
||||
MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post(p_76986_1_, this, p_76986_2_, p_76986_4_, p_76986_6_));
|
||||
this.func_110827_b(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);
|
||||
}
|
||||
|
||||
private float interpolateRotation(float p_77034_1_, float p_77034_2_, float p_77034_3_)
|
||||
{
|
||||
float f3;
|
||||
|
||||
for (f3 = p_77034_2_ - p_77034_1_; f3 < -180.0F; f3 += 360.0F)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
while (f3 >= 180.0F)
|
||||
{
|
||||
f3 -= 360.0F;
|
||||
}
|
||||
|
||||
return p_77034_1_ + p_77034_3_ * f3;
|
||||
}
|
||||
|
||||
protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7) {
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
|
||||
if(GeckoAddonClient.Instance.isGeckoModel(mainModel)){
|
||||
|
||||
Reference in new issue
Block a user