From ba4bf107b56a6f668157866d6cec5dbd7f4973f8 Mon Sep 17 00:00:00 2001 From: luisc Date: Wed, 8 Dec 2021 23:29:08 -0600 Subject: [PATCH] Added npc.setPoweredTexture(directory) and npc.getPoweredTexture() functions, along with a new powered texture resource. Sample code: npc.setPoweredTexture("customnpcs:textures/entity/npc_armor.png"); --- src/main/java/noppes/npcs/DataDisplay.java | 5 ++- .../npcs/client/renderer/RenderCustomNpc.java | 42 ++++++++++++++++++ .../npcs/entity/EntityNPCInterface.java | 4 ++ .../npcs/scripted/entity/ScriptNpc.java | 9 ++++ .../npcs/scripted/interfaces/ICustomNpc.java | 4 ++ .../customnpcs/textures/entity/npc_armor.png | Bin 0 -> 1681 bytes 6 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/assets/customnpcs/textures/entity/npc_armor.png diff --git a/src/main/java/noppes/npcs/DataDisplay.java b/src/main/java/noppes/npcs/DataDisplay.java index 1bda8ee33..a18bcd6a7 100644 --- a/src/main/java/noppes/npcs/DataDisplay.java +++ b/src/main/java/noppes/npcs/DataDisplay.java @@ -37,7 +37,8 @@ public class DataDisplay { public String texture = "customnpcs:textures/entity/humanmale/Steve.png"; public String cloakTexture = ""; public String glowTexture = ""; - + public String poweredTexture = ""; + public int visible = 0; //0:visible 1:Invisible 2:semi-invisible public int modelSize = 5; @@ -102,6 +103,7 @@ public class DataDisplay { nbttagcompound.setString("Texture", texture); nbttagcompound.setString("CloakTexture", cloakTexture); nbttagcompound.setString("GlowTexture", glowTexture); + nbttagcompound.setString("PoweredTexture", poweredTexture); nbttagcompound.setByte("UsingSkinUrl", skinType); if (this.playerProfile != null) @@ -157,6 +159,7 @@ public class DataDisplay { texture = nbttagcompound.getString("Texture"); cloakTexture = nbttagcompound.getString("CloakTexture"); glowTexture = nbttagcompound.getString("GlowTexture"); + poweredTexture = nbttagcompound.getString("PoweredTexture"); modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE); modelType = nbttagcompound.getInteger("modelType"); diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java b/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java index 57e9dd460..9ef6ab233 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java @@ -11,6 +11,7 @@ import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.BossStatus; +import net.minecraft.util.ResourceLocation; import noppes.npcs.client.model.ModelMPM; import noppes.npcs.client.model.util.ModelRenderPassHelper; import noppes.npcs.constants.EnumStandingType; @@ -88,6 +89,47 @@ public class RenderCustomNpc extends RenderNPCHumanMale{ @Override protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3){ + EntityNPCInterface npc = (EntityNPCInterface) par1EntityLivingBase; + if (npc.hasPoweredTexture()) + { + if (npc.isInvisible()) + { + GL11.glDepthMask(false); + } + else + { + GL11.glDepthMask(true); + } + + if (par2 == 1) + { + ResourceLocation poweredNPCTexture = new ResourceLocation(npc.display.poweredTexture);//customnpcs:textures/entity/npc_armor.png + float f1 = (float)npc.ticksExisted + par3; + this.bindTexture(poweredNPCTexture); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + float f2 = f1 * 0.01F; + float f3 = f1 * 0.01F; + GL11.glTranslatef(f2, f3, 0.0F); + this.setRenderPassModel(this.originalModel); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glEnable(GL11.GL_BLEND); + float f4 = 0.5F; + GL11.glColor4f(f4, f4, f4, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + return 1; + } + + if (par2 == 2) + { + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + } + } if(renderEntity != null){ return NPCRendererHelper.shouldRenderPass(entity, par2, par3, renderEntity); } diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 991ba265f..9c0947b19 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -1732,4 +1732,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti { this.display.modelType = val; } + + public boolean hasPoweredTexture() { + return !("".equals(this.display.poweredTexture)); + } } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index 64cd375b6..2c36a142c 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -1006,4 +1006,13 @@ public class ScriptNpc extends ScriptLiving imp public String getOverlayTexture() { return npc.display.glowTexture; } + + public void setPoweredTexture(String poweredTexture) { + npc.display.poweredTexture = poweredTexture; + npc.updateClient = true; + } + + public String getPoweredTexture() { + return npc.display.poweredTexture; + } } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java b/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java index c92d8c7ae..ff0df53b0 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java @@ -703,4 +703,8 @@ public interface ICustomNpc extends IEntityLiving { public void setOverlayTexture(String overlayTexture); public String getOverlayTexture(); + + public void setPoweredTexture(String poweredTexture); + + public String getPoweredTexture(); } diff --git a/src/main/resources/assets/customnpcs/textures/entity/npc_armor.png b/src/main/resources/assets/customnpcs/textures/entity/npc_armor.png new file mode 100644 index 0000000000000000000000000000000000000000..73a5d7ce29a4a895aa17d6fb196a5fd897067527 GIT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