Removed redundant ScriptSkinOverlay, using SkinOverlayData in place of it, which now implements ISkinOverlay.

This commit is contained in:
Luis C.M committed 2022-05-17 04:46:06 -05:00
1 parent 8bc3190295
commit 41401d0521
10 files changed
+128 -149

No files matched your search

+14 -16
View File
@@ -2,17 +2,15 @@ package noppes.npcs;
import java.util.*;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.StringUtils;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.controllers.data.SkinOverlayData;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.interfaces.ISkinOverlay;
import noppes.npcs.util.ValueUtil;
import com.google.common.collect.Iterables;
@@ -36,7 +34,7 @@ public class DataDisplay {
public String texture = "customnpcs:textures/entity/humanmale/Steve.png";
public String cloakTexture = "";
public HashMap<Integer, SkinOverlayData> skinOverlays = new HashMap<>();
public HashMap<Integer, ISkinOverlay> skinOverlays = new HashMap<>();
public long overlayRenderTicks = 0;
public String glowTexture = "";
@@ -71,20 +69,20 @@ public class DataDisplay {
public NBTTagCompound writeOverlaysToNBT(NBTTagCompound nbttagcompound) {
NBTTagList overlayList = new NBTTagList();
if (!npc.display.skinOverlays.isEmpty()) {
for (Map.Entry<Integer,SkinOverlayData> overlayData : npc.display.skinOverlays.entrySet()) {
for (Map.Entry<Integer,ISkinOverlay> overlayData : npc.display.skinOverlays.entrySet()) {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("SkinOverlayID", overlayData.getKey());
compound.setString("SkinOverlayTexture", overlayData.getValue().directory);
compound.setBoolean("SkinOverlayGlow", overlayData.getValue().glow);
compound.setFloat("SkinOverlayAlpha", overlayData.getValue().alpha);
compound.setFloat("SkinOverlaySize", overlayData.getValue().size);
compound.setFloat("SkinOverlaySpeedX", overlayData.getValue().speedX);
compound.setFloat("SkinOverlaySpeedY", overlayData.getValue().speedY);
compound.setFloat("SkinOverlayScaleX", overlayData.getValue().scaleX);
compound.setFloat("SkinOverlayScaleY", overlayData.getValue().scaleY);
compound.setFloat("SkinOverlayOffsetX", overlayData.getValue().offsetX);
compound.setFloat("SkinOverlayOffsetY", overlayData.getValue().offsetY);
compound.setFloat("SkinOverlayOffsetZ", overlayData.getValue().offsetZ);
compound.setString("SkinOverlayTexture", overlayData.getValue().getTexture());
compound.setBoolean("SkinOverlayGlow", overlayData.getValue().getGlow());
compound.setFloat("SkinOverlayAlpha", overlayData.getValue().getAlpha());
compound.setFloat("SkinOverlaySize", overlayData.getValue().getSize());
compound.setFloat("SkinOverlaySpeedX", overlayData.getValue().getSpeedX());
compound.setFloat("SkinOverlaySpeedY", overlayData.getValue().getSpeedY());
compound.setFloat("SkinOverlayScaleX", overlayData.getValue().getScaleX());
compound.setFloat("SkinOverlayScaleY", overlayData.getValue().getScaleY());
compound.setFloat("SkinOverlayOffsetX", overlayData.getValue().getOffsetX());
compound.setFloat("SkinOverlayOffsetY", overlayData.getValue().getOffsetY());
compound.setFloat("SkinOverlayOffsetZ", overlayData.getValue().getOffsetZ());
overlayList.appendTag(compound);
}
}
@@ -4,7 +4,6 @@ import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.controllers.data.SkinOverlayData;
import noppes.npcs.entity.EntityNPCInterface;
@@ -13,14 +12,14 @@ import org.lwjgl.opengl.GL11;
public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{
public GuiNpcTextureOverlays(EntityNPCInterface npc,GuiScreen parent){
//super(npc, parent, npc.display.glowTexture.isEmpty()?"customnpcs:textures/overlays/":npc.display.glowTexture);
super(npc, parent, npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).directory : "");
super(npc, parent, npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).getTexture() : "");
title = "Select Overlay";
this.parent = parent;
}
public void initGui(){
super.initGui();
String str = npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).directory : "";
String str = npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).getTexture() : "";
int index = str.lastIndexOf("/");
if(index > 0){
String asset = str.substring(index + 1);
@@ -4,7 +4,6 @@ import com.mojang.authlib.GameProfile;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.CustomNpcs;
import noppes.npcs.DataDisplay;
import noppes.npcs.client.Client;
@@ -79,7 +78,7 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
y+=23;
addLabel(new GuiNpcLabel(9,"display.overlay", guiLeft + 5, y + 5));
addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 80, y, 200, 20, npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).directory : ""));
addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 80, y, 200, 20, npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).getTexture() : ""));
this.addButton(new GuiNpcButton(9, guiLeft + 283, y, 80, 20, "display.selectTexture"));
y+=23;
@@ -1,6 +1,5 @@
package noppes.npcs.client.renderer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.renderer.entity.RenderPlayer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -94,11 +93,11 @@ public class RenderCNPCPlayer extends RenderPlayer {
if (Client.skinOverlays.containsKey(player.getUniqueID())) {
for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) {
if (overlayData.location == null) {
overlayData.location = new ResourceLocation(overlayData.directory);
overlayData.location = new ResourceLocation(overlayData.texture);
} else {
String str = overlayData.location.getResourceDomain()+":"+overlayData.location.getResourcePath();
if (!str.equals(overlayData.directory)) {
overlayData.location = new ResourceLocation(overlayData.directory);
if (!str.equals(overlayData.texture)) {
overlayData.location = new ResourceLocation(overlayData.texture);
}
}
@@ -145,11 +144,11 @@ public class RenderCNPCPlayer extends RenderPlayer {
if (Client.skinOverlays.containsKey(player.getUniqueID())) {
for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) {
if (overlayData.location == null) {
overlayData.location = new ResourceLocation(overlayData.directory);
overlayData.location = new ResourceLocation(overlayData.texture);
} else {
String str = overlayData.location.getResourceDomain()+":"+overlayData.location.getResourcePath();
if (!str.equals(overlayData.directory)) {
overlayData.location = new ResourceLocation(overlayData.directory);
if (!str.equals(overlayData.texture)) {
overlayData.location = new ResourceLocation(overlayData.texture);
}
}
@@ -19,7 +19,6 @@ 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;
@@ -28,6 +27,7 @@ import noppes.npcs.controllers.data.SkinOverlayData;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.interfaces.ISkinOverlay;
import org.lwjgl.opengl.GL11;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
@@ -214,21 +214,21 @@ public class RenderNPCInterface extends RenderLiving{
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
if (!npc.display.skinOverlays.isEmpty()) {
for (SkinOverlayData overlayData : npc.display.skinOverlays.values()) {
for (ISkinOverlay overlayData : npc.display.skinOverlays.values()) {
try {
if (overlayData.location == null) {
overlayData.location = new ResourceLocation(overlayData.directory);
if (overlayData.getLocation() == null) {
overlayData.setLocation(new ResourceLocation(overlayData.getTexture()));
} else {
String str = npc.display.skinOverlays.get(0).location.getResourceDomain()+":"+npc.display.skinOverlays.get(0).location.getResourcePath();
if (!str.equals(overlayData.directory)) {
overlayData.location = new ResourceLocation(overlayData.directory);
String str = npc.display.skinOverlays.get(0).getLocation().getResourceDomain()+":"+npc.display.skinOverlays.get(0).getLocation().getResourcePath();
if (!str.equals(overlayData.getTexture())) {
overlayData.setLocation(new ResourceLocation(overlayData.getTexture()));
}
}
this.bindTexture(overlayData.location);
this.bindTexture(overlayData.getLocation());
// Overlay & Glow
if (overlayData.glow) {
if (overlayData.getGlow()) {
GL11.glDepthFunc(GL11.GL_LEQUAL);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_LIGHTING);
@@ -236,19 +236,19 @@ public class RenderNPCInterface extends RenderLiving{
Minecraft.getMinecraft().entityRenderer.disableLightmap((double) 0);
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, overlayData.alpha);
GL11.glColor4f(1.0F, 1.0F, 1.0F, overlayData.getAlpha());
GL11.glDepthMask(!npc.isInvisible());
GL11.glPushMatrix();
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glLoadIdentity();
GL11.glTranslatef(npc.display.overlayRenderTicks * 0.001F * overlayData.speedX, npc.display.overlayRenderTicks * 0.001F * overlayData.speedY, 0.0F);
GL11.glScalef(overlayData.scaleX, overlayData.scaleY, 1.0F);
GL11.glTranslatef(npc.display.overlayRenderTicks * 0.001F * overlayData.getSpeedX(), npc.display.overlayRenderTicks * 0.001F * overlayData.getSpeedY(), 0.0F);
GL11.glScalef(overlayData.getScaleX(), overlayData.getScaleY(), 1.0F);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
float scale = 1.005f * overlayData.size;
GL11.glTranslatef(overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ);
float scale = 1.005f * overlayData.getSize();
GL11.glTranslatef(overlayData.getOffsetX(), overlayData.getOffsetY(), overlayData.getOffsetZ());
GL11.glScalef(scale, scale, scale);
if(mainModel instanceof ModelMPM){
((ModelMPM)mainModel).isArmor = true;
@@ -1,11 +1,12 @@
package noppes.npcs.controllers.data;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.scripted.interfaces.ISkinOverlay;
public class SkinOverlayData {
public class SkinOverlayData implements ISkinOverlay {
public ResourceLocation location = null;
public String directory;
public boolean glow;
public String texture;
public boolean glow = true;
public float alpha = 1.0F;
public float size = 1.0F;
@@ -19,9 +20,13 @@ public class SkinOverlayData {
public float offsetY = 0.0F;
public float offsetZ = 0.0F;
public SkinOverlayData(String directory, boolean glow, float alpha, float size, float speedX, float speedY,
public SkinOverlayData(String texture) {
this.texture = texture;
}
public SkinOverlayData(String texture, boolean glow, float alpha, float size, float speedX, float speedY,
float scaleX, float scaleY, float offsetX, float offsetY, float offsetZ) {
this.directory = directory;
this.texture = texture;
this.glow = glow;
this.alpha = alpha;
this.size = size;
@@ -33,4 +38,76 @@ public class SkinOverlayData {
this.offsetY = offsetY;
this.offsetZ = offsetZ;
}
public void setTexture(String texture) {
this.texture = texture;
}
public String getTexture() {
return texture;
}
public void setGlow(boolean glow) {
this.glow = glow;
}
public boolean getGlow() {
return glow;
}
public void setAlpha(float alpha) {
this.alpha = alpha;
}
public float getAlpha() {
return alpha;
}
public void setSize(float size) {
this.size = size;
}
public float getSize() {
return size;
}
public void setScale(float scaleX, float scaleY) {
this.scaleX = scaleX;
this.scaleY = scaleY;
}
public float getScaleX() {
return scaleX;
}
public float getScaleY() {
return scaleY;
}
public void setSpeed(float speedX, float speedY) {
this.speedX = speedX;
this.speedY = speedY;
}
public float getSpeedX() {
return speedX;
}
public float getSpeedY() {
return speedY;
}
public void setOffset(float offsetX, float offsetY, float offsetZ) {
this.offsetX = offsetX;
this.offsetY = offsetY;
this.offsetZ = offsetZ;
}
public float getOffsetX() {
return offsetX;
}
public float getOffsetY() {
return offsetY;
}
public float getOffsetZ() {
return offsetZ;
}
public void setLocation(ResourceLocation location) {
this.location = location;
}
public ResourceLocation getLocation() {
return this.location;
}
}
@@ -31,6 +31,7 @@ import net.minecraft.world.WorldServer;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.controllers.*;
import noppes.npcs.controllers.data.SkinOverlayData;
import noppes.npcs.items.ItemScripted;
import noppes.npcs.containers.ContainerNpcInterface;
import noppes.npcs.entity.EntityCustomNpc;
@@ -349,6 +350,6 @@ public class NpcAPI extends AbstractNpcAPI {
}
public ISkinOverlay createSkinOverlay(String texture) {
return new ScriptSkinOverlay(texture);
return new SkinOverlayData(texture);
}
}
@@ -1,89 +0,0 @@
package noppes.npcs.scripted;
import noppes.npcs.scripted.interfaces.ISkinOverlay;
public class ScriptSkinOverlay implements ISkinOverlay {
public String texture;
public boolean glow;
public float alpha = 1.0F;
public float size = 1.0F;
public float speedX = 0.0F;
public float speedY = 0.0F;
public float scaleX = 1.0F;
public float scaleY = 1.0F;
public float offsetX = 0.0F;
public float offsetY = 0.0F;
public float offsetZ = 0.0F;
public ScriptSkinOverlay(String texture) {
this.texture = texture;
}
public void setTexture(String texture) {
this.texture = texture;
}
public String getTexture() {
return texture;
}
public void setGlow(boolean glow) {
this.glow = glow;
}
public boolean getGlow() {
return glow;
}
public void setAlpha(float alpha) {
this.alpha = alpha;
}
public float getAlpha() {
return alpha;
}
public void setSize(float size) {
this.size = size;
}
public float getSize() {
return size;
}
public void setScale(float scaleX, float scaleY) {
this.scaleX = scaleX;
this.scaleY = scaleY;
}
public float getScaleX() {
return scaleX;
}
public float getScaleY() {
return scaleY;
}
public void setSpeed(float speedX, float speedY) {
this.speedX = speedX;
this.speedY = speedY;
}
public float getSpeedX() {
return speedX;
}
public float getSpeedY() {
return speedY;
}
public void setOffset(float offsetX, float offsetY, float offsetZ) {
this.offsetX = offsetX;
this.offsetY = offsetY;
this.offsetZ = offsetZ;
}
public float getOffsetX() {
return offsetX;
}
public float getOffsetY() {
return offsetY;
}
public float getOffsetZ() {
return offsetZ;
}
}
@@ -1,19 +1,14 @@
package noppes.npcs.scripted.entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.Server;
import noppes.npcs.constants.*;
import noppes.npcs.controllers.Line;
import noppes.npcs.controllers.data.SkinOverlayData;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.ScriptFaction;
import noppes.npcs.scripted.ScriptSkinOverlay;
import noppes.npcs.scripted.interfaces.ISkinOverlay;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
@@ -41,7 +36,6 @@ import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.util.ValueUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> implements ICustomNpc {
@@ -1109,16 +1103,12 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
if (!npc.display.skinOverlays.containsKey(0))
return "";
return npc.display.skinOverlays.get(0).directory;
return npc.display.skinOverlays.get(0).getTexture();
}
public void setSkinOverlay(int id, ISkinOverlay overlay) {
if (overlay != null) {
npc.display.skinOverlays.put(id, new SkinOverlayData(
overlay.getTexture(),overlay.getGlow(),overlay.getAlpha(),overlay.getSize(),
overlay.getSpeedX(),overlay.getSpeedY(),overlay.getScaleX(),overlay.getScaleY(),
overlay.getOffsetX(),overlay.getOffsetY(),overlay.getOffsetZ()
));
npc.display.skinOverlays.put(id, overlay);
}
}
@@ -1,5 +1,7 @@
package noppes.npcs.scripted.interfaces;
import net.minecraft.util.ResourceLocation;
public interface ISkinOverlay {
void setTexture(String texture);
@@ -27,4 +29,7 @@ public interface ISkinOverlay {
float getOffsetX();
float getOffsetY();
float getOffsetZ();
ResourceLocation getLocation();
void setLocation(ResourceLocation location);
}