Implemented custom powered textures for NPC's, overlays that can have their textures move.

This commit is contained in:
Luis C.M committed 2022-05-15 16:47:48 -05:00
1 parent ec9466c011
commit aa9a9499aa
5 files changed
+165 -26

No files matched your search

+45 -4
View File
@@ -36,8 +36,19 @@ public class DataDisplay {
public GameProfile playerProfile;
public String texture = "customnpcs:textures/entity/humanmale/Steve.png";
public String cloakTexture = "";
public String glowTexture = "";
public float overlaySize = 1.0F;
public float overlayScaleX = 1.0F;
public float overlayScaleY = 1.0F;
public String poweredTexture = "";
public float poweredSize = 1.0F;
public float poweredSpeedX = 1.0F;
public float poweredSpeedY = 1.0F;
public float poweredScaleX = 1.0F;
public float poweredScaleY = 1.0F;
public int visible = 0; //0:visible 1:Invisible 2:semi-invisible
public int modelSize = 5;
@@ -73,10 +84,21 @@ public class DataDisplay {
nbttagcompound.setString("SkinUrl", url);
nbttagcompound.setString("Texture", texture);
nbttagcompound.setString("CloakTexture", cloakTexture);
nbttagcompound.setString("GlowTexture", glowTexture);
nbttagcompound.setByte("UsingSkinUrl", skinType);
if (this.playerProfile != null)
nbttagcompound.setString("GlowTexture", glowTexture);
nbttagcompound.setFloat("OverlaySize", overlaySize);
nbttagcompound.setFloat("OverlayScaleX", overlayScaleX);
nbttagcompound.setFloat("OverlayScaleY", overlayScaleY);
nbttagcompound.setString("PoweredTexture", poweredTexture);
nbttagcompound.setFloat("PoweredSize", poweredSize);
nbttagcompound.setFloat("PoweredSpeedX", poweredSpeedX);
nbttagcompound.setFloat("PoweredSpeedY", poweredSpeedY);
nbttagcompound.setFloat("PoweredScaleX", poweredScaleX);
nbttagcompound.setFloat("PoweredScaleY", poweredScaleY);
if (this.playerProfile != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
NBTUtil.func_152460_a(nbttagcompound1, this.playerProfile);
@@ -130,8 +152,27 @@ public class DataDisplay {
texture = nbttagcompound.getString("Texture");
cloakTexture = nbttagcompound.getString("CloakTexture");
overlayScaleX = overlayScaleX == 0 ? 1.0F : overlayScaleX;
overlayScaleY = overlayScaleY == 0 ? 1.0F : overlayScaleY;
overlaySize = overlaySize == 0 ? 1.0F : overlaySize;
glowTexture = nbttagcompound.getString("GlowTexture");
overlaySize = nbttagcompound.getFloat("OverlaySize");
overlayScaleX = nbttagcompound.getFloat("OverlayScaleX");
overlayScaleY = nbttagcompound.getFloat("OverlayScaleY");
poweredScaleX = poweredScaleX == 0 ? 1.0F : poweredScaleX;
poweredScaleY = poweredScaleY == 0 ? 1.0F : poweredScaleY;
poweredSpeedX = poweredSpeedX == 0 ? 1.0F : poweredSpeedX;
poweredSpeedY = poweredSpeedY == 0 ? 1.0F : poweredSpeedY;
poweredSize = poweredSize == 0 ? 1.0F : poweredSize;
poweredTexture = nbttagcompound.getString("PoweredTexture");
poweredSize = nbttagcompound.getFloat("PoweredSize");
poweredSpeedX = nbttagcompound.getFloat("PoweredSpeedX");
poweredSpeedY = nbttagcompound.getFloat("PoweredSpeedY");
poweredScaleX = nbttagcompound.getFloat("PoweredScaleX");
poweredScaleY = nbttagcompound.getFloat("PoweredScaleY");
modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE);
if(modelSize > CustomNpcs.NpcSizeLimit)
modelSize = CustomNpcs.NpcSizeLimit;
@@ -19,6 +19,7 @@ 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.ClientProxy;
import noppes.npcs.client.ImageDownloadAlt;
import noppes.npcs.client.model.ModelMPM;
import noppes.npcs.constants.EnumAnimation;
@@ -34,7 +35,6 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
public class RenderNPCInterface extends RenderLiving{
public static long LastTextureTick = 0;
public ModelBase originalModel;
public RenderNPCInterface(ModelBase model, float f){
@@ -213,43 +213,96 @@ public class RenderNPCInterface extends RenderLiving{
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
if (!npc.display.glowTexture.isEmpty())
{
GL11.glDepthFunc(GL11.GL_LEQUAL);
if(npc.textureGlowLocation == null){
npc.textureGlowLocation = new ResourceLocation(npc.display.glowTexture);
}
bindTexture((ResourceLocation) npc.textureGlowLocation);
float f1 = 1.0F;
GL11.glEnable(GL11.GL_BLEND);
// 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);
if (npc.isInvisible())
{
GL11.glDepthMask(false);
}
else
{
GL11.glDepthMask(true);
}
GL11.glDepthMask(!npc.isInvisible());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPushMatrix();
GL11.glScalef(1.001f, 1.001f, 1.001f);
if(mainModel instanceof ModelMPM){
((ModelMPM)mainModel).isArmor = true;
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
((ModelMPM)mainModel).isArmor = false;
}
else
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glLoadIdentity();
GL11.glScalef(npc.display.overlayScaleX, npc.display.overlayScaleY, 1.0F);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
float scale = 1.001f * npc.display.overlaySize;
GL11.glScalef(scale, scale, scale);
if(mainModel instanceof ModelMPM){
((ModelMPM)mainModel).isArmor = true;
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
((ModelMPM)mainModel).isArmor = false;
}
else
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
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);
}
if (!npc.display.poweredTexture.isEmpty())
{
if(npc.texturePoweredLocation == null){
npc.texturePoweredLocation = new ResourceLocation(npc.display.poweredTexture);
}
bindTexture((ResourceLocation) npc.texturePoweredLocation);
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(!npc.isInvisible());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPushMatrix();
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glLoadIdentity();
GL11.glTranslatef(npc.renderTicksPowered * 0.001F * npc.display.poweredSpeedX, npc.renderTicksPowered * 0.001F * npc.display.poweredSpeedY, 0.0F);
GL11.glScalef(npc.display.poweredScaleX, npc.display.poweredScaleY, 1.0F);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
float scale = 1.001f * npc.display.poweredSize;
GL11.glScalef(scale, scale, scale);
GL11.glEnable(GL11.GL_BLEND);
if(mainModel instanceof ModelMPM){
((ModelMPM)mainModel).isArmor = true;
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
((ModelMPM)mainModel).isArmor = false;
}
else
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
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);
npc.renderTicksPowered++;
}
}
@Override
protected float handleRotationFloat(EntityLivingBase par1EntityLiving, float par2){
@@ -120,6 +120,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
public long totalTicksAlive = 0;
private int taskCount = 1;
public int lastInteract = 0;
public long renderTicksPowered = 0;
public Faction faction; //should only be used server side
@@ -130,6 +131,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
public ResourceLocation textureLocation = null;
public ResourceLocation textureGlowLocation = null;
public ResourceLocation texturePoweredLocation = null;
public ResourceLocation textureCloakLocation = null;
public EnumAnimation currentAnimation = EnumAnimation.NONE;
@@ -1098,10 +1098,49 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
npc.display.glowTexture = overlayTexture;
npc.updateClient = true;
}
public String getOverlayTexture() {return npc.display.glowTexture;}
public String getOverlayTexture() {
return npc.display.glowTexture;
public void setOverlaySize(float size) {
npc.display.overlaySize = size;
npc.updateClient = true;
}
public float getOverlaySize() {return npc.display.overlaySize;}
public void setOverlayScale(float scaleX, float scaleY) {
npc.display.overlayScaleX = scaleX;
npc.display.overlayScaleY = scaleY;
npc.updateClient = true;
}
public float getOverlayTextureScaleX() {return npc.display.overlayScaleX;}
public float getOverlayTextureScaleY() {return npc.display.overlayScaleY;}
public void setPoweredTexture(String poweredTexture) {
npc.display.poweredTexture = poweredTexture;
npc.updateClient = true;
}
public String getPoweredTexture() {return npc.display.poweredTexture;}
public void setPoweredSize(float size) {
npc.display.poweredSize = size;
npc.updateClient = true;
}
public float getPoweredSize() {return npc.display.poweredSize;}
public void setPoweredScale(float scaleX, float scaleY) {
npc.display.poweredScaleX = scaleX;
npc.display.poweredScaleY = scaleY;
npc.updateClient = true;
}
public float getPoweredTextureScaleX() {return npc.display.poweredScaleX;}
public float getPoweredTextureScaleY() {return npc.display.poweredScaleY;}
public void setPoweredSpeed(float speedX, float speedY) {
npc.display.poweredSpeedX = speedX;
npc.display.poweredSpeedY = speedY;
npc.updateClient = true;
}
public float getPoweredSpeedX() {return npc.display.poweredSpeedX;}
public float getPoweredSpeedY() {return npc.display.poweredSpeedY;}
public void setCollisionType(int type){
npc.display.collidesWith = type;
@@ -738,6 +738,10 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
String getOverlayTexture();
void setPoweredTexture(String poweredTexture);
String getPoweredTexture();
void setCollisionType(int type);
int getCollisionType();