Implemented custom player overlays.

This commit is contained in:
Luis C.M committed 2022-05-16 05:45:00 -05:00
1 parent d6b1dba9bc
commit 9a0aae50e0
6 files changed
+137 -2

No files matched your search

@@ -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<Integer, OverlayCustom> customOverlays = new HashMap<>();
public static ResourceLocation playerOverlay = null;
public static void sendData(EnumPacketServer enu, Object... obs) {
ByteBuf buffer = Unpooled.buffer();
@@ -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)));
@@ -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);
}
}
}
}
@@ -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) {}
}
}
}
@@ -37,5 +37,6 @@ public enum EnumPacketClient {
OVERLAY_DATA,
OVERLAY_CLOSE,
SWING_PLAYER_ARM,
UPDATE_ITEM
UPDATE_ITEM,
PLAYER_OVERLAY
}
@@ -526,6 +526,10 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
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<IQuest> quests = new ArrayList();