Added blend attribute to skin overlays.

This commit is contained in:
Luis C.M committed 2022-05-29 05:23:39 -05:00
1 parent 9928482c53
commit f9e92f3172
7 files changed
+33 -32

No files matched your search

@@ -79,10 +79,7 @@ public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{
//npc.display.glowTexture = assets.getAsset(slot.selected);
//npc.textureGlowLocation = null;
npc.display.skinOverlayData.overlayList.put(0,new SkinOverlay(
assets.getAsset(slot.selected), true, 1.0F, 1.0F, 0.0F, 0.0F,
1.0F, 1.0F, 0.0F, 0.0F, 0.0F
));
npc.display.skinOverlayData.overlayList.put(0,new SkinOverlay(assets.getAsset(slot.selected)));
}
}
@@ -132,10 +132,7 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
//npc.textureGlowLocation = null;
//display.glowTexture = textfield.getText();
if (!textfield.getText().isEmpty()) {
npc.display.skinOverlayData.overlayList.put(0, new SkinOverlay(
textfield.getText(), true, 1.0F, 1.0F, 0.0F, 0.0F,
1.0F, 1.0F, 0.0F, 0.0F, 0.0F
));
npc.display.skinOverlayData.overlayList.put(0,new SkinOverlay(textfield.getText()));
}
}
else if(textfield.id == 11){
@@ -45,7 +45,7 @@ public class RenderCNPCPlayer extends RenderPlayer {
this.setRenderManager(RenderManager.instance);
}
private boolean preRenderOverlay(EntityPlayer player, ResourceLocation overlayLocation, boolean glow,
private boolean preRenderOverlay(EntityPlayer player, ResourceLocation overlayLocation, boolean glow, boolean blend,
float alpha, float size, float speedX, float speedY, float scaleX, float scaleY,
float offsetX, float offsetY, float offsetZ) {
if (overlayLocation.getResourcePath().isEmpty())
@@ -67,7 +67,11 @@ public class RenderCNPCPlayer extends RenderPlayer {
// Overlay & Glow
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (blend) {
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
} else {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
if (glow) {
@@ -127,7 +131,7 @@ public class RenderCNPCPlayer extends RenderPlayer {
}
}
if (!preRenderOverlay(player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size,
if (!preRenderOverlay(player, overlayData.location, overlayData.glow, overlayData.blend, overlayData.alpha, overlayData.size,
overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY,
overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ
))
@@ -330,7 +334,7 @@ public class RenderCNPCPlayer extends RenderPlayer {
}
}
if (!preRenderOverlay(player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size,
if (!preRenderOverlay(player, overlayData.location, overlayData.glow, overlayData.blend, overlayData.alpha, overlayData.size,
overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY,
overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ
))
@@ -243,7 +243,11 @@ public class RenderNPCInterface extends RenderLiving{
// Overlay & Glow
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (overlayData.getBlend()) {
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
} else {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
if (overlayData.getGlow()) {
@@ -10,6 +10,7 @@ public class SkinOverlay implements ISkinOverlay {
public ResourceLocation location = null;
public String texture;
public boolean glow = true;
public boolean blend = false;
public float alpha = 1.0F;
public float size = 1.0F;
@@ -30,21 +31,6 @@ public class SkinOverlay implements ISkinOverlay {
this.texture = texture;
}
public SkinOverlay(String texture, boolean glow, float alpha, float size, float speedX, float speedY,
float scaleX, float scaleY, float offsetX, float offsetY, float offsetZ) {
this.texture = texture;
this.glow = glow;
this.alpha = alpha;
this.size = size;
this.speedX = speedX;
this.speedY = speedY;
this.scaleX = scaleX;
this.scaleY = scaleY;
this.offsetX = offsetX;
this.offsetY = offsetY;
this.offsetZ = offsetZ;
}
public void setTexture(String texture) {
this.texture = texture;
this.updateClient();
@@ -61,6 +47,14 @@ public class SkinOverlay implements ISkinOverlay {
return glow;
}
public void setBlend(boolean blend) {
this.blend = blend;
this.updateClient();
}
public boolean getBlend() {
return blend;
}
public void setAlpha(float alpha) {
this.alpha = alpha;
this.updateClient();
@@ -128,6 +122,7 @@ public class SkinOverlay implements ISkinOverlay {
public void readFromNBT(NBTTagCompound compound) {
this.texture = compound.getString("SkinOverlayTexture");
this.glow = compound.getBoolean("SkinOverlayGlow");
this.blend = compound.getBoolean("SkinOverlayBlend");
this.alpha = compound.getFloat("SkinOverlayAlpha");
this.size = compound.getFloat("SkinOverlaySize");
this.speedX = compound.getFloat("SkinOverlaySpeedX");
@@ -142,6 +137,7 @@ public class SkinOverlay implements ISkinOverlay {
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setString("SkinOverlayTexture", this.getTexture());
compound.setBoolean("SkinOverlayGlow", this.getGlow());
compound.setBoolean("SkinOverlayBlend", this.getBlend());
compound.setFloat("SkinOverlayAlpha", this.getAlpha());
compound.setFloat("SkinOverlaySize", this.getSize());
compound.setFloat("SkinOverlaySpeedX", this.getSpeedX());
@@ -19,10 +19,7 @@ public class EntityNPCEnderman extends EntityNpcEnderchibi
super(world);
display.texture = "customnpcs:textures/entity/enderman/enderman.png";
//display.glowTexture = ;
display.skinOverlayData.overlayList.put(0,new SkinOverlay(
"customnpcs:textures/overlays/ender_eyes.png", true, 1.0F, 1.0F, 0.0F, 0.0F,
1.0F, 1.0F, 0.0F, 0.0F, 0.0F
));
display.skinOverlayData.overlayList.put(0,new SkinOverlay("customnpcs:textures/overlays/ender_eyes.png"));
this.width = 0.6F;
this.height = 2.9F;
}
@@ -21,6 +21,12 @@ public interface ISkinOverlay {
void setGlow(boolean glow);
boolean getGlow();
/**
* Sets whether this overlay blends on top of bottom textures at any alpha value.
*/
void setBlend(boolean blend);
boolean getBlend();
/**
* Sets the transparency of the overlay, from 0 to 1.
*/