-Overlays for players and NPCs are now grouped in an "overlay handler" object, similar to how you retrieve timers.

-Fixed client NPC overlay updates.
This commit is contained in:
Luis C.M committed 2022-05-23 20:41:32 -05:00
1 parent 6fa5d0d8de
commit 6220a8ce14
20 files changed
+203 -164

No files matched your search

+6 -54
View File
@@ -10,6 +10,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.StringUtils;
import noppes.npcs.controllers.data.SkinOverlayData;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.entity.data.DataSkinOverlays;
import noppes.npcs.scripted.interfaces.ISkinOverlay;
import noppes.npcs.util.ValueUtil;
@@ -34,7 +35,7 @@ public class DataDisplay {
public String texture = "customnpcs:textures/entity/humanmale/Steve.png";
public String cloakTexture = "";
public HashMap<Integer, ISkinOverlay> skinOverlays = new HashMap<>();
public DataSkinOverlays skinOverlayData;
public long overlayRenderTicks = 0;
public String glowTexture = "";
@@ -59,6 +60,7 @@ public class DataDisplay {
public DataDisplay(EntityNPCInterface npc){
this.npc = npc;
markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1);
skinOverlayData = new DataSkinOverlays(npc);
name = getRandomName();
}
@@ -66,30 +68,6 @@ public class DataDisplay {
return CustomNpcs.MARKOV_GENERATOR[markovGeneratorId].fetch(markovGender);
}
public NBTTagCompound writeOverlaysToNBT(NBTTagCompound nbttagcompound) {
NBTTagList overlayList = new NBTTagList();
if (!npc.display.skinOverlays.isEmpty()) {
for (Map.Entry<Integer,ISkinOverlay> overlayData : npc.display.skinOverlays.entrySet()) {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("SkinOverlayID", overlayData.getKey());
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);
}
}
nbttagcompound.setTag("SkinOverlayData",overlayList);
return nbttagcompound;
}
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setString("Name", name);
nbttagcompound.setInteger("MarkovGeneratorId", markovGeneratorId);
@@ -101,7 +79,7 @@ public class DataDisplay {
nbttagcompound.setByte("UsingSkinUrl", skinType);
nbttagcompound.setString("GlowTexture", glowTexture);
nbttagcompound = writeOverlaysToNBT(nbttagcompound);
nbttagcompound = skinOverlayData.writeToNBT(nbttagcompound);
if (this.playerProfile != null)
{
@@ -162,17 +140,7 @@ public class DataDisplay {
if (!nbttagcompound.hasKey("SkinOverlayData") && !glowTexture.isEmpty()) {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("SkinOverlayID", 0); //unique glow texture ID
compound.setString("SkinOverlayTexture", glowTexture);
compound.setBoolean("SkinOverlayGlow", true);
compound.setFloat("SkinOverlayAlpha", 1.0F);
compound.setFloat("SkinOverlaySize", 1.0F);
compound.setFloat("SkinOverlaySpeedX", 0.0F);
compound.setFloat("SkinOverlaySpeedY", 0.0F);
compound.setFloat("SkinOverlayScaleX", 1.0F);
compound.setFloat("SkinOverlayScaleY", 1.0F);
compound.setFloat("SkinOverlayOffsetX", 0.0F);
compound.setFloat("SkinOverlayOffsetY", 0.0F);
compound.setFloat("SkinOverlayOffsetZ", 0.0F);
(new SkinOverlayData(glowTexture)).writeToNBT(nbttagcompound);
if (!nbttagcompound.hasKey("SkinOverlayData")) {
NBTTagList tagList = new NBTTagList();
@@ -184,23 +152,7 @@ public class DataDisplay {
}
}
NBTTagList skinOverlayList = nbttagcompound.getTagList("SkinOverlayData",10);
for (int i = 0; i < skinOverlayList.tagCount(); i++) {
int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID");
String tagString = skinOverlayList.getCompoundTagAt(i).getString("SkinOverlayTexture");
boolean glow = skinOverlayList.getCompoundTagAt(i).getBoolean("SkinOverlayGlow");
float alpha = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayAlpha");
float size = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySize");
float speedX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySpeedX");
float speedY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySpeedY");
float scaleX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayScaleX");
float scaleY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayScaleY");
float offsetX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetX");
float offsetY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetY");
float offsetZ = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetZ");
skinOverlays.put(tagID,new SkinOverlayData(tagString,glow,alpha,size,speedX,speedY,scaleX,scaleY,offsetX,offsetY,offsetZ));
}
skinOverlayData.readFromNBT(nbttagcompound);
modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE);
if(modelSize > CustomNpcs.NpcSizeLimit)
@@ -434,14 +434,14 @@ public class ScriptPlayerEventHandler {
EventHooks.onPlayerLogin(handler, scriptPlayer);
//Loads other players' and own player's skin overlays if they have them
/*
List<EntityPlayerMP> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
for (EntityPlayerMP playerMP : list) {
if (playerMP.getEntityData().hasKey("SkinOverlayData")) {
NBTTagCompound data = new NBTTagCompound();
data.setTag("SkinOverlayData",playerMP.getEntityData().getTagList("SkinOverlayData",10));
Server.sendData(playerMP, EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS, data);
}
}
}*/
}
}
@@ -7,8 +7,6 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.UUID;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.CustomNpcs;
import noppes.npcs.Server;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
@@ -13,8 +13,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@@ -39,7 +37,6 @@ import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.data.SkinOverlayData;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.Sys;
@@ -81,19 +78,7 @@ public class NoppesUtil {
for (int i = 0; i < skinOverlayList.tagCount(); i++) {
int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID");
String tagString = skinOverlayList.getCompoundTagAt(i).getString("SkinOverlayTexture");
boolean glow = skinOverlayList.getCompoundTagAt(i).getBoolean("SkinOverlayGlow");
float alpha = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayAlpha");
float size = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySize");
float speedX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySpeedX");
float speedY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySpeedY");
float scaleX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayScaleX");
float scaleY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayScaleY");
float offsetX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetX");
float offsetY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetY");
float offsetZ = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetZ");
skinOverlays.put(tagID,new SkinOverlayData(tagString,glow,alpha,size,speedX,speedY,scaleX,scaleY,offsetX,offsetY,offsetZ));
skinOverlays.put(tagID, (SkinOverlayData) SkinOverlayData.overlayFromNBT(skinOverlayList.getCompoundTagAt(i)));
}
Client.skinOverlays.put(player.getUniqueID(), skinOverlays);
}
@@ -12,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).getTexture() : "");
super(npc, parent, npc.display.skinOverlayData.overlayList.containsKey(0) ? npc.display.skinOverlayData.overlayList.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).getTexture() : "";
String str = npc.display.skinOverlayData.overlayList.containsKey(0) ? npc.display.skinOverlayData.overlayList.get(0).getTexture() : "";
int index = str.lastIndexOf("/");
if(index > 0){
String asset = str.substring(index + 1);
@@ -79,8 +79,8 @@ public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{
//npc.display.glowTexture = assets.getAsset(slot.selected);
npc.textureGlowLocation = null;
npc.display.skinOverlays.put(0,new SkinOverlayData(
assets.getAsset(slot.selected), true, 0.8F, 1.0F, 0.0F, 0.0F,
npc.display.skinOverlayData.overlayList.put(0,new SkinOverlayData(
assets.getAsset(slot.selected), true, 1.0F, 1.0F, 0.0F, 0.0F,
1.0F, 1.0F, 0.0F, 0.0F, 0.0F
));
}
@@ -78,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).getTexture() : ""));
addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 80, y, 200, 20, npc.display.skinOverlayData.overlayList.containsKey(0) ? npc.display.skinOverlayData.overlayList.get(0).getTexture() : ""));
this.addButton(new GuiNpcButton(9, guiLeft + 283, y, 80, 20, "display.selectTexture"));
y+=23;
@@ -131,8 +131,8 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
else if(textfield.id == 9){
npc.textureGlowLocation = null;
//display.glowTexture = textfield.getText();
npc.display.skinOverlays.put(0,new SkinOverlayData(
textfield.getText(), true, 0.8F, 1.0F, 0.0F, 0.0F,
npc.display.skinOverlayData.overlayList.put(0,new SkinOverlayData(
textfield.getText(), true, 1.0F, 1.0F, 0.0F, 0.0F,
1.0F, 1.0F, 0.0F, 0.0F, 0.0F
));
}
@@ -232,7 +232,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol
}
}
//npc.display.glowTexture = "";
npc.display.skinOverlays.remove(0);
npc.display.skinOverlayData.overlayList.remove(0);
npc.textureLocation = null;
npc.textureGlowLocation = null;
npc.updateHitbox();
@@ -340,7 +340,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol
npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png";
}
//npc.display.glowTexture = "";
npc.display.skinOverlays.remove(0);
npc.display.skinOverlayData.overlayList.remove(0);
npc.textureLocation = null;
npc.textureGlowLocation = null;
npc.updateHitbox();
@@ -130,7 +130,7 @@ public class GuiEntitySelection extends GuiNPCInterface
npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png";
}
//npc.display.glowTexture = "";
npc.display.skinOverlays.remove(0);
npc.display.skinOverlayData.overlayList.remove(0);
npc.textureLocation = null;
npc.textureGlowLocation = null;
npc.updateHitbox();
@@ -213,13 +213,13 @@ public class RenderNPCInterface extends RenderLiving{
super.renderModel(entityliving, par2, par3, par4, par5, par6, par7);
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
if (!npc.display.skinOverlays.isEmpty()) {
for (ISkinOverlay overlayData : npc.display.skinOverlays.values()) {
if (!npc.display.skinOverlayData.overlayList.isEmpty()) {
for (ISkinOverlay overlayData : npc.display.skinOverlayData.overlayList.values()) {
try {
if (overlayData.getLocation() == null) {
overlayData.setLocation(new ResourceLocation(overlayData.getTexture()));
} else {
String str = npc.display.skinOverlays.get(0).getLocation().getResourceDomain()+":"+npc.display.skinOverlays.get(0).getLocation().getResourcePath();
String str = npc.display.skinOverlayData.overlayList.get(0).getLocation().getResourceDomain()+":"+npc.display.skinOverlayData.overlayList.get(0).getLocation().getResourcePath();
if (!str.equals(overlayData.getTexture())) {
overlayData.setLocation(new ResourceLocation(overlayData.getTexture()));
}
@@ -11,6 +11,7 @@ import noppes.npcs.LogWriter;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.entity.data.DataSkinOverlays;
import noppes.npcs.entity.data.DataTimers;
import noppes.npcs.roles.RoleCompanion;
import noppes.npcs.util.NBTJsonUtil;
@@ -27,6 +28,7 @@ public class PlayerData implements IExtendedEntityProperties{
public PlayerItemGiverData itemgiverData = new PlayerItemGiverData();
public PlayerMailData mailData = new PlayerMailData();
public DataTimers timers = new DataTimers(this);
public DataSkinOverlays skinOverlays = new DataSkinOverlays(this);
public EntityNPCInterface editingNpc;
public NBTTagCompound cloned;
@@ -64,6 +66,7 @@ public class PlayerData implements IExtendedEntityProperties{
itemgiverData.loadNBTData(data);
mailData.loadNBTData(data);
timers.readFromNBT(data);
skinOverlays.readFromNBT(data);
if(player != null){
playername = player.getCommandSenderName();
@@ -100,6 +103,7 @@ public class PlayerData implements IExtendedEntityProperties{
itemgiverData.saveNBTData(compound);
mailData.saveNBTData(compound);
timers.writeToNBT(compound);
skinOverlays.writeToNBT(compound);
compound.setString("PlayerName", playername);
compound.setString("UUID", uuid);
@@ -1,9 +1,13 @@
package noppes.npcs.controllers.data;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.entity.data.DataSkinOverlays;
import noppes.npcs.scripted.interfaces.ISkinOverlay;
public class SkinOverlayData implements ISkinOverlay {
public DataSkinOverlays parent;
public ResourceLocation location = null;
public String texture;
public boolean glow = true;
@@ -20,6 +24,9 @@ public class SkinOverlayData implements ISkinOverlay {
public float offsetY = 0.0F;
public float offsetZ = 0.0F;
public SkinOverlayData() {
}
public SkinOverlayData(String texture) {
this.texture = texture;
}
@@ -41,6 +48,7 @@ public class SkinOverlayData implements ISkinOverlay {
public void setTexture(String texture) {
this.texture = texture;
this.updateClient();
}
public String getTexture() {
return texture;
@@ -48,6 +56,7 @@ public class SkinOverlayData implements ISkinOverlay {
public void setGlow(boolean glow) {
this.glow = glow;
this.updateClient();
}
public boolean getGlow() {
return glow;
@@ -55,6 +64,7 @@ public class SkinOverlayData implements ISkinOverlay {
public void setAlpha(float alpha) {
this.alpha = alpha;
this.updateClient();
}
public float getAlpha() {
return alpha;
@@ -62,6 +72,7 @@ public class SkinOverlayData implements ISkinOverlay {
public void setSize(float size) {
this.size = size;
this.updateClient();
}
public float getSize() {
return size;
@@ -70,6 +81,7 @@ public class SkinOverlayData implements ISkinOverlay {
public void setScale(float scaleX, float scaleY) {
this.scaleX = scaleX;
this.scaleY = scaleY;
this.updateClient();
}
public float getScaleX() {
return scaleX;
@@ -81,6 +93,7 @@ public class SkinOverlayData implements ISkinOverlay {
public void setSpeed(float speedX, float speedY) {
this.speedX = speedX;
this.speedY = speedY;
this.updateClient();
}
public float getSpeedX() {
return speedX;
@@ -93,6 +106,7 @@ public class SkinOverlayData implements ISkinOverlay {
this.offsetX = offsetX;
this.offsetY = offsetY;
this.offsetZ = offsetZ;
this.updateClient();
}
public float getOffsetX() {
return offsetX;
@@ -106,8 +120,51 @@ public class SkinOverlayData implements ISkinOverlay {
public void setLocation(ResourceLocation location) {
this.location = location;
this.updateClient();
}
public ResourceLocation getLocation() {
return this.location;
}
public void readFromNBT(NBTTagCompound compound) {
this.texture = compound.getString("SkinOverlayTexture");
this.glow = compound.getBoolean("SkinOverlayGlow");
this.alpha = compound.getFloat("SkinOverlayAlpha");
this.size = compound.getFloat("SkinOverlaySize");
this.speedX = compound.getFloat("SkinOverlaySpeedX");
this.speedY = compound.getFloat("SkinOverlaySpeedY");
this.scaleX = compound.getFloat("SkinOverlayScaleX");
this.scaleY = compound.getFloat("SkinOverlayScaleY");
this.offsetX = compound.getFloat("SkinOverlayOffsetX");
this.offsetY = compound.getFloat("SkinOverlayOffsetY");
this.offsetZ = compound.getFloat("SkinOverlayOffsetZ");
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setString("SkinOverlayTexture", this.getTexture());
compound.setBoolean("SkinOverlayGlow", this.getGlow());
compound.setFloat("SkinOverlayAlpha", this.getAlpha());
compound.setFloat("SkinOverlaySize", this.getSize());
compound.setFloat("SkinOverlaySpeedX", this.getSpeedX());
compound.setFloat("SkinOverlaySpeedY", this.getSpeedY());
compound.setFloat("SkinOverlayScaleX", this.getScaleX());
compound.setFloat("SkinOverlayScaleY", this.getScaleY());
compound.setFloat("SkinOverlayOffsetX", this.getOffsetX());
compound.setFloat("SkinOverlayOffsetY", this.getOffsetY());
compound.setFloat("SkinOverlayOffsetZ", this.getOffsetZ());
return compound;
}
public static ISkinOverlay overlayFromNBT(NBTTagCompound compound) {
SkinOverlayData overlay = new SkinOverlayData();
overlay.readFromNBT(compound);
return overlay;
}
private void updateClient() {
if (this.parent != null) {
this.parent.updateClient();
}
}
}
@@ -0,0 +1,82 @@
package noppes.npcs.entity.data;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.data.SkinOverlayData;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.interfaces.ISkinOverlay;
import noppes.npcs.scripted.interfaces.handler.IOverlayHandler;
import java.util.HashMap;
import java.util.Map;
public class DataSkinOverlays implements IOverlayHandler {
public final Object parent;
public HashMap<Integer, ISkinOverlay> overlayList = new HashMap<>();
public DataSkinOverlays(Object parent) {
this.parent = parent;
}
public void readFromNBT(NBTTagCompound nbtTagCompound) {
HashMap<Integer,ISkinOverlay> skinOverlays = new HashMap<>();
NBTTagList skinOverlayList = nbtTagCompound.getTagList("SkinOverlayData",10);
for (int i = 0; i < skinOverlayList.tagCount(); i++) {
int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID");
SkinOverlayData skinOverlay = (SkinOverlayData) SkinOverlayData.overlayFromNBT(skinOverlayList.getCompoundTagAt(i));
skinOverlays.put(tagID, skinOverlay);
}
this.overlayList = skinOverlays;
}
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
NBTTagList overlayList = new NBTTagList();
if (!this.overlayList.isEmpty()) {
for (Map.Entry<Integer,ISkinOverlay> overlayData : this.overlayList.entrySet()) {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("SkinOverlayID", overlayData.getKey());
compound = ((SkinOverlayData) overlayData.getValue()).writeToNBT(compound);
overlayList.appendTag(compound);
}
}
nbttagcompound.setTag("SkinOverlayData",overlayList);
return nbttagcompound;
}
public void updateClient() {
if (parent instanceof PlayerData) {
NBTTagCompound compound = this.writeToNBT(new NBTTagCompound());
((PlayerData) parent).player.getEntityData().setTag("SkinOverlayData", compound.getTagList("SkinOverlayData",10));
} else if (parent instanceof EntityNPCInterface) {
((EntityNPCInterface) parent).updateClient = true;
}
}
public void add(int id, ISkinOverlay data) {
((SkinOverlayData) data).parent = this;
this.overlayList.put(id, data);
updateClient();
}
public ISkinOverlay get(int id) {
return this.overlayList.get(id);
}
public boolean has(int id) {
return this.overlayList.containsKey(id);
}
public boolean remove(int id) {
boolean removed = this.overlayList.remove(id) != null;
updateClient();
return removed;
}
public int size() { return this.overlayList.size(); }
public void clear() {
this.overlayList.clear();
updateClient();
}
}
@@ -18,7 +18,7 @@ import noppes.npcs.controllers.PlayerData;
import noppes.npcs.scripted.CustomNPCsException;
public class DataTimers implements ITimers {
private Object parent;
private final Object parent;
private Map<Integer, DataTimers.Timer> timers = new HashMap();
public DataTimers(Object parent) {
@@ -20,8 +20,8 @@ public class EntityNPCEnderman extends EntityNpcEnderchibi
super(world);
display.texture = "customnpcs:textures/entity/enderman/enderman.png";
//display.glowTexture = ;
display.skinOverlays.put(0,new SkinOverlayData(
"customnpcs:textures/overlays/ender_eyes.png", true, 0.8F, 1.0F, 0.0F, 0.0F,
display.skinOverlayData.overlayList.put(0,new SkinOverlayData(
"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
));
this.width = 0.6F;
@@ -45,7 +45,6 @@ import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
import noppes.npcs.scripted.interfaces.entity.IEntity;
import noppes.npcs.scripted.interfaces.gui.ICustomGui;
import noppes.npcs.scripted.interfaces.item.IItemCustom;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.interfaces.AbstractNpcAPI;
import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay;
@@ -12,6 +12,7 @@ import noppes.npcs.scripted.ScriptFaction;
import noppes.npcs.scripted.interfaces.ISkinOverlay;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.handler.IOverlayHandler;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.constants.AnimationType;
import noppes.npcs.scripted.constants.EntityType;
@@ -1097,23 +1098,19 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
}
public void setOverlayTexture(String overlayTexture) {
this.setSkinOverlay(0, NpcAPI.Instance().createSkinOverlay(overlayTexture));
this.getOverlays().add(0, NpcAPI.Instance().createSkinOverlay(overlayTexture));
npc.updateClient = true;
}
public String getOverlayTexture() {
if (!npc.display.skinOverlays.containsKey(0))
if (!npc.display.skinOverlayData.overlayList.containsKey(0))
return "";
return npc.display.skinOverlays.get(0).getTexture();
return npc.display.skinOverlayData.overlayList.get(0).getTexture();
}
public void setSkinOverlay(int id, ISkinOverlay overlay) {
if (overlay != null) {
npc.display.skinOverlays.put(id, overlay);
}
}
public void removeSkinOverlay(int id) {
npc.display.skinOverlays.remove(id);
public IOverlayHandler getOverlays() {
return npc.display.skinOverlayData;
}
public void setCollisionType(int type){
@@ -22,6 +22,7 @@ import noppes.npcs.scripted.*;
import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.scripted.interfaces.entity.IEntity;
import noppes.npcs.scripted.interfaces.handler.IOverlayHandler;
import noppes.npcs.scripted.interfaces.handler.data.IQuest;
import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
@@ -32,12 +33,10 @@ import noppes.npcs.scripted.overlay.ScriptOverlay;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.util.ValueUtil;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.*;
public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T> implements IPlayer {
public HashMap<Integer, ISkinOverlay> skinOverlays = new HashMap<>();
public T player;
private PlayerData data;
@@ -527,58 +526,8 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.OVERLAY_CLOSE, id, new NBTTagCompound());
}
public void setSkinOverlay(int id, ISkinOverlay overlay) {
if (id < 0) {
throw new CustomNPCsException("Skin overlay ID must be greater than 0.");
}
if (overlay != null) {
NBTTagCompound data = new NBTTagCompound();
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("SkinOverlayID", id);
compound.setString("SkinOverlayTexture", overlay.getTexture());
compound.setBoolean("SkinOverlayGlow", overlay.getGlow());
compound.setFloat("SkinOverlayAlpha", overlay.getAlpha());
compound.setFloat("SkinOverlaySize", overlay.getSize());
compound.setFloat("SkinOverlaySpeedX", overlay.getSpeedX());
compound.setFloat("SkinOverlaySpeedY", overlay.getSpeedY());
compound.setFloat("SkinOverlayScaleX", overlay.getScaleX());
compound.setFloat("SkinOverlayScaleY", overlay.getScaleY());
compound.setFloat("SkinOverlayOffsetX", overlay.getOffsetX());
compound.setFloat("SkinOverlayOffsetY", overlay.getOffsetY());
compound.setFloat("SkinOverlayOffsetZ", overlay.getOffsetZ());
if (!player.getEntityData().hasKey("SkinOverlayData")) {
NBTTagList tagList = new NBTTagList();
tagList.appendTag(compound);
player.getEntityData().setTag("SkinOverlayData", tagList);
} else {
for (int i = 0; i < player.getEntityData().getTagList("SkinOverlayData", 10).tagCount(); i++) {
int tagID = player.getEntityData().getTagList("SkinOverlayData", 10).getCompoundTagAt(i).getInteger("SkinOverlayID");
if (tagID == id) {
player.getEntityData().getTagList("SkinOverlayData", 10).removeTag(i);
}
}
player.getEntityData().getTagList("SkinOverlayData", 10).appendTag(compound);
}
data.setTag("SkinOverlayData",player.getEntityData().getTagList("SkinOverlayData",10));
Server.sendData((EntityPlayerMP) this.entity, EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS, data);
}
}
public void removeSkinOverlay(int id) {
if (player.getEntityData().hasKey("SkinOverlayData")) {
NBTTagCompound data = new NBTTagCompound();
for (int i = 0; i < player.getEntityData().getTagList("SkinOverlayData",10).tagCount(); i++) {
int tagID = player.getEntityData().getTagList("SkinOverlayData",10).getCompoundTagAt(i).getInteger("SkinOverlayID");
if (tagID == id) {
player.getEntityData().getTagList("SkinOverlayData",10).removeTag(i);
}
}
data.setTag("SkinOverlayData",player.getEntityData().getTagList("SkinOverlayData",10));
Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS, data);
}
public IOverlayHandler getOverlays() {
return this.getData().skinOverlays;
}
public IQuest[] getFinishedQuests() {
@@ -8,6 +8,7 @@ package noppes.npcs.scripted.interfaces.entity;
import net.minecraft.entity.EntityCreature;
import noppes.npcs.scripted.ScriptFaction;
import noppes.npcs.scripted.interfaces.ISkinOverlay;
import noppes.npcs.scripted.interfaces.handler.IOverlayHandler;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.interfaces.ITimers;
import noppes.npcs.scripted.roles.*;
@@ -747,9 +748,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
String getOverlayTexture();
void setSkinOverlay(int id, ISkinOverlay overlay);
void removeSkinOverlay(int id);
IOverlayHandler getOverlays();
void setCollisionType(int type);
@@ -4,6 +4,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.scripted.ScriptBlock;
import noppes.npcs.scripted.entity.ScriptDBCPlayer;
import noppes.npcs.scripted.interfaces.handler.IOverlayHandler;
import noppes.npcs.scripted.interfaces.handler.data.IQuest;
import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.interfaces.gui.ICustomGui;
@@ -225,9 +226,7 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
void closeOverlay(int id);
void setSkinOverlay(int id, ISkinOverlay overlay);
void removeSkinOverlay(int id);
IOverlayHandler getOverlays();
IQuest[] getFinishedQuests();
}
@@ -0,0 +1,18 @@
package noppes.npcs.scripted.interfaces.handler;
import noppes.npcs.scripted.interfaces.ISkinOverlay;
public interface IOverlayHandler {
void add(int id, ISkinOverlay overlay);
ISkinOverlay get(int id);
boolean has(int id);
boolean remove(int id);
int size();
void clear();
}