mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 08:38:31 +00:00
Players can now have multiple skin overlays, just like GUI overlays.
This commit is contained in:
1 parent
9a0aae50e0
commit
dbfbab7be2
10 files changed
+162
-76
No files matched your search
@@ -3,54 +3,76 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.data.SkinOverlayData;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class RenderCNPCPlayer extends RenderPlayer {
|
||||
|
||||
public RenderCNPCPlayer() {
|
||||
}
|
||||
|
||||
private boolean preRenderOverlay(EntityPlayer player, ResourceLocation overlayLocation) {
|
||||
try {
|
||||
this.bindTexture(overlayLocation);
|
||||
} catch (Exception exception) {
|
||||
return false;
|
||||
}
|
||||
// Overlay & Glow
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
GL11.glDepthMask(!player.isInvisible());
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glScalef(1.0F, 1.0F, 1.0F);
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
float scale = 1.001f;
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
|
||||
return true;
|
||||
}
|
||||
public void postRenderOverlay(EntityPlayer player) {
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderModel(EntityLivingBase p_77036_1_, float p_77036_2_, float p_77036_3_, float p_77036_4_, float p_77036_5_, float p_77036_6_, float p_77036_7_) {
|
||||
EntityPlayer player = (EntityPlayer) p_77036_1_;
|
||||
this.bindEntityTexture(p_77036_1_);
|
||||
|
||||
if (!p_77036_1_.isInvisible())
|
||||
{
|
||||
this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_);
|
||||
|
||||
if (Client.playerOverlay != null) {
|
||||
try {
|
||||
this.bindTexture(Client.playerOverlay);
|
||||
float f1 = 1.0F;
|
||||
// Overlay & Glow
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
GL11.glDepthMask(!p_77036_1_.isInvisible());
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glScalef(1.0F, 1.0F, 1.0F);
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
float scale = 1.001f;
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
if (Client.skinOverlays.containsKey(player.getUniqueID())) {
|
||||
for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) {
|
||||
if (!preRenderOverlay(player, overlayData.location))
|
||||
return;
|
||||
this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, f1);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
} catch (Exception ignored) {}
|
||||
postRenderOverlay(player);
|
||||
}
|
||||
} else if(player.getEntityData().hasKey("SkinOverlayData")) {
|
||||
Client.sendData(EnumPacketServer.SERVER_UPDATE_SKIN_OVERLAYS, new Object[0]);
|
||||
}
|
||||
}
|
||||
else if (!p_77036_1_.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer))
|
||||
@@ -73,49 +95,26 @@ public class RenderCNPCPlayer extends RenderPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
public void renderFirstPersonArm(EntityPlayer p_82441_1_)
|
||||
public void renderFirstPersonArm(EntityPlayer player)
|
||||
{
|
||||
float f = 1.0F;
|
||||
GL11.glColor3f(f, f, f);
|
||||
this.modelBipedMain.onGround = 0.0F;
|
||||
this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, p_82441_1_);
|
||||
this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, player);
|
||||
this.modelBipedMain.bipedRightArm.render(0.0625F);
|
||||
|
||||
if (Client.playerOverlay != null) {
|
||||
try {
|
||||
this.bindTexture(Client.playerOverlay);
|
||||
float f1 = 1.0F;
|
||||
// Overlay & Glow
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
GL11.glDepthMask(!p_82441_1_.isInvisible());
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glScalef(1.0F, 1.0F, 1.0F);
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
float scale = 1.001f;
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
if (Client.skinOverlays.containsKey(player.getUniqueID())) {
|
||||
for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) {
|
||||
if (!preRenderOverlay(player, overlayData.location))
|
||||
return;
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
this.modelBipedMain.onGround = 0.0F;
|
||||
this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, p_82441_1_);
|
||||
this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, player);
|
||||
this.modelBipedMain.bipedRightArm.render(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, f1);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
} catch (Exception ignored) {}
|
||||
postRenderOverlay(player);
|
||||
}
|
||||
} else if(player.getEntityData().hasKey("SkinOverlayData")) {
|
||||
Client.sendData(EnumPacketServer.SERVER_UPDATE_SKIN_OVERLAYS, new Object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user