diff --git a/src/main/java/noppes/npcs/client/Client.java b/src/main/java/noppes/npcs/client/Client.java index cb37e5d72..53530e142 100644 --- a/src/main/java/noppes/npcs/client/Client.java +++ b/src/main/java/noppes/npcs/client/Client.java @@ -6,6 +6,7 @@ import io.netty.buffer.Unpooled; import java.io.IOException; import java.util.HashMap; +import net.minecraft.util.ResourceLocation; import noppes.npcs.CustomNpcs; import noppes.npcs.Server; import noppes.npcs.client.gui.customoverlay.OverlayCustom; @@ -14,6 +15,7 @@ import cpw.mods.fml.common.network.internal.FMLProxyPacket; public class Client { public static HashMap customOverlays = new HashMap<>(); + public static ResourceLocation playerOverlay = null; public static void sendData(EnumPacketServer enu, Object... obs) { ByteBuf buffer = Unpooled.buffer(); diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index e0b6b07b9..caa5fc0a4 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -166,7 +166,7 @@ public class ClientProxy extends CommonProxy { RenderingRegistry.registerEntityRenderingHandler(EntityProjectile.class, new RenderProjectile()); RenderingRegistry.registerEntityRenderingHandler(EntityCustomNpc.class, new RenderCustomNpc()); - + RenderingRegistry.registerEntityRenderingHandler(EntityPlayer.class, new RenderCNPCPlayer()); RenderingRegistry.registerEntityRenderingHandler(EntityNPCGolem.class, new RenderNPCHumanMale( new ModelNPCGolem(0), new ModelNPCGolem(1F), new ModelNPCGolem(0.5F))); diff --git a/src/main/java/noppes/npcs/client/PacketHandlerClient.java b/src/main/java/noppes/npcs/client/PacketHandlerClient.java index d3cfca705..0493ab8bf 100644 --- a/src/main/java/noppes/npcs/client/PacketHandlerClient.java +++ b/src/main/java/noppes/npcs/client/PacketHandlerClient.java @@ -16,6 +16,7 @@ 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; @@ -273,5 +274,11 @@ 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); + } + } } } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java new file mode 100644 index 000000000..199dd3a85 --- /dev/null +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -0,0 +1,121 @@ +package noppes.npcs.client.renderer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import noppes.npcs.client.Client; +import org.lwjgl.opengl.GL11; + +public class RenderCNPCPlayer extends RenderPlayer { + + public RenderCNPCPlayer() { + } + + @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_) { + 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); + 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) {} + } + } + else if (!p_77036_1_.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) + { + GL11.glPushMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.15F); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); + 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.glDisable(GL11.GL_BLEND); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glPopMatrix(); + GL11.glDepthMask(true); + } + else + { + this.mainModel.setRotationAngles(p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_, p_77036_1_); + } + } + + public void renderFirstPersonArm(EntityPlayer p_82441_1_) + { + 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.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); + 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.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) {} + } + } +} diff --git a/src/main/java/noppes/npcs/constants/EnumPacketClient.java b/src/main/java/noppes/npcs/constants/EnumPacketClient.java index 4629cb35a..d3c312f7b 100644 --- a/src/main/java/noppes/npcs/constants/EnumPacketClient.java +++ b/src/main/java/noppes/npcs/constants/EnumPacketClient.java @@ -37,5 +37,6 @@ public enum EnumPacketClient { OVERLAY_DATA, OVERLAY_CLOSE, SWING_PLAYER_ARM, - UPDATE_ITEM + UPDATE_ITEM, + PLAYER_OVERLAY } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index e1bdf8721..a79d3c204 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -526,6 +526,10 @@ public class ScriptPlayer extends ScriptLivingBase Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.OVERLAY_CLOSE, id, new NBTTagCompound()); } + public void setPlayerOverlay(String texture) { + Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.PLAYER_OVERLAY, texture); + } + public IQuest[] getFinishedQuests() { PlayerQuestData data = this.getData().questData; List quests = new ArrayList();