mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 09:39:48 +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
@@ -5,6 +5,7 @@ import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
@@ -12,10 +13,11 @@ import noppes.npcs.Server;
|
||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import noppes.npcs.controllers.data.SkinOverlayData;
|
||||
|
||||
public class Client {
|
||||
public static HashMap<Integer, OverlayCustom> customOverlays = new HashMap<>();
|
||||
public static ResourceLocation playerOverlay = null;
|
||||
public static HashMap<UUID, HashMap<Integer, SkinOverlayData>> skinOverlays = new HashMap<>();
|
||||
|
||||
public static void sendData(EnumPacketServer enu, Object... obs) {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Util;
|
||||
@@ -35,6 +36,7 @@ import noppes.npcs.constants.EnumPlayerPacket;
|
||||
import noppes.npcs.controllers.Dialog;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.Quest;
|
||||
import noppes.npcs.controllers.data.SkinOverlayData;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import org.lwjgl.Sys;
|
||||
@@ -70,6 +72,19 @@ public class NoppesUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateSkinOverlayData(EntityPlayer player, NBTTagCompound compound) {
|
||||
HashMap<Integer, SkinOverlayData> skinOverlays = new HashMap<>();
|
||||
NBTTagList skinOverlayList = compound.getTagList("SkinOverlayData",10);
|
||||
|
||||
for (int i = 0; i < skinOverlayList.tagCount(); i++) {
|
||||
int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID");
|
||||
String tagString = skinOverlayList.getCompoundTagAt(i).getString("SkinOverlayTexture");
|
||||
|
||||
skinOverlays.put(tagID,new SkinOverlayData(new ResourceLocation(tagString)));
|
||||
}
|
||||
Client.skinOverlays.put(player.getUniqueID(), skinOverlays);
|
||||
}
|
||||
|
||||
public static void spawnScriptedParticle(ByteBuf buffer){
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
@@ -274,11 +273,8 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
else if(type == EnumPacketClient.SWING_PLAYER_ARM){
|
||||
Minecraft.getMinecraft().thePlayer.swingItem();
|
||||
}
|
||||
else if(type == EnumPacketClient.PLAYER_OVERLAY) {
|
||||
String overlayString = Server.readString(buffer);
|
||||
if (overlayString != null) {
|
||||
Client.playerOverlay = new ResourceLocation(overlayString);
|
||||
}
|
||||
else if(type == EnumPacketClient.CLIENT_UPDATE_SKIN_OVERLAYS) {
|
||||
NoppesUtil.updateSkinOverlayData(player, Server.readNBT(buffer));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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