mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-15 18:24:51 +00:00
More Class Refactoring for TintData and HitboxData
This commit is contained in:
1 parent
982ceb4aa4
commit
0b73ae91bb
10 files changed
+379
-387
No files matched your search
@@ -11,8 +11,8 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.StringUtils;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.controllers.data.AnimationData;
|
||||
import noppes.npcs.controllers.data.CustomHitboxData;
|
||||
import noppes.npcs.controllers.data.CustomTintData;
|
||||
import noppes.npcs.controllers.data.HitboxData;
|
||||
import noppes.npcs.controllers.data.TintData;
|
||||
import noppes.npcs.controllers.data.SkinOverlay;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.entity.data.DataSkinOverlays;
|
||||
@@ -23,192 +23,187 @@ import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DataDisplay {
|
||||
public EntityNPCInterface npc;
|
||||
public EntityNPCInterface npc;
|
||||
|
||||
public String name;
|
||||
public String title = "";
|
||||
public String name;
|
||||
public String title = "";
|
||||
|
||||
private int markovGeneratorId = 8; //roman,japanese,slavic,welsh,sami,oldnorse,ancientgreek,aztec,classic,spanish (0 - 9 inclusively)
|
||||
private int markovGender = 0; //0:random, 1:male, 2:female
|
||||
private int markovGeneratorId = 8; //roman,japanese,slavic,welsh,sami,oldnorse,ancientgreek,aztec,classic,spanish (0 - 9 inclusively)
|
||||
private int markovGender = 0; //0:random, 1:male, 2:female
|
||||
|
||||
public byte skinType = 0; //0:normal, 1:player, 2:url, 3:url64
|
||||
public byte skinType = 0; //0:normal, 1:player, 2:url, 3:url64
|
||||
|
||||
public String url = "";
|
||||
public String url = "";
|
||||
|
||||
public GameProfile playerProfile;
|
||||
public String texture = "customnpcs:textures/entity/humanmale/Steve.png";
|
||||
public String cloakTexture = "";
|
||||
public GameProfile playerProfile;
|
||||
public String texture = "customnpcs:textures/entity/humanmale/Steve.png";
|
||||
public String cloakTexture = "";
|
||||
|
||||
public DataSkinOverlays skinOverlayData;
|
||||
public long overlayRenderTicks = 0;
|
||||
public DataSkinOverlays skinOverlayData;
|
||||
public long overlayRenderTicks = 0;
|
||||
|
||||
public AnimationData animationData;
|
||||
public AnimationData animationData;
|
||||
public HitboxData hitboxData;
|
||||
public TintData tintData;
|
||||
|
||||
public String glowTexture = "";
|
||||
public String glowTexture = "";
|
||||
|
||||
public int visible = 0; //0:visible 1:Invisible 2:semi-invisible
|
||||
public int visible = 0; //0:visible 1:Invisible 2:semi-invisible
|
||||
public int modelSize = 5;
|
||||
public int showName = 0;
|
||||
public int modelType = 0;
|
||||
|
||||
public int modelSize = 5;
|
||||
public boolean disableLivingAnimation = false;
|
||||
public byte showBossBar = 0;
|
||||
|
||||
public int showName = 0;
|
||||
public ArrayList<UUID> invisibleToList = new ArrayList<>();
|
||||
|
||||
public int modelType = 0;
|
||||
// 0 - Yes, 1 - No, 2 - Only NPCs, 3 - Only Players, 4 - NPCs and Players
|
||||
public int collidesWith = 1;
|
||||
|
||||
public boolean disableLivingAnimation = false;
|
||||
public DataDisplay(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1);
|
||||
skinOverlayData = new DataSkinOverlays(npc);
|
||||
name = getRandomName();
|
||||
animationData = new AnimationData(this);
|
||||
hitboxData = new HitboxData();
|
||||
tintData = new TintData();
|
||||
}
|
||||
|
||||
public byte showBossBar = 0;
|
||||
public String getRandomName() {
|
||||
return CustomNpcs.MARKOV_GENERATOR[markovGeneratorId].fetch(markovGender);
|
||||
}
|
||||
|
||||
public ArrayList<UUID> invisibleToList = new ArrayList<>();
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setString("Name", name);
|
||||
nbttagcompound.setInteger("MarkovGeneratorId", markovGeneratorId);
|
||||
nbttagcompound.setInteger("MarkovGender", markovGender);
|
||||
nbttagcompound.setString("Title", title);
|
||||
nbttagcompound.setString("SkinUrl", url);
|
||||
nbttagcompound.setString("Texture", texture);
|
||||
|
||||
//0 - Yes, 1 - No, 2 - Only NPCs, 3 - Only Players, 4 - NPCs and Players
|
||||
public int collidesWith = 1;
|
||||
|
||||
public CustomHitboxData customHitboxData;
|
||||
public CustomTintData customTintData;
|
||||
nbttagcompound.setString("CloakTexture", cloakTexture);
|
||||
nbttagcompound.setByte("UsingSkinUrl", skinType);
|
||||
nbttagcompound.setString("GlowTexture", glowTexture);
|
||||
|
||||
public DataDisplay(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1);
|
||||
skinOverlayData = new DataSkinOverlays(npc);
|
||||
name = getRandomName();
|
||||
animationData = new AnimationData(this);
|
||||
customHitboxData = new CustomHitboxData();
|
||||
customTintData = new CustomTintData();
|
||||
}
|
||||
nbttagcompound = skinOverlayData.writeToNBT(nbttagcompound);
|
||||
|
||||
public String getRandomName() {
|
||||
return CustomNpcs.MARKOV_GENERATOR[markovGeneratorId].fetch(markovGender);
|
||||
}
|
||||
nbttagcompound = animationData.writeToNBT(nbttagcompound);
|
||||
nbttagcompound = hitboxData.writeToNBT(nbttagcompound);
|
||||
nbttagcompound = tintData.writeToNBT(nbttagcompound);
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setString("Name", name);
|
||||
nbttagcompound.setInteger("MarkovGeneratorId", markovGeneratorId);
|
||||
nbttagcompound.setInteger("MarkovGender", markovGender);
|
||||
nbttagcompound.setString("Title", title);
|
||||
nbttagcompound.setString("SkinUrl", url);
|
||||
nbttagcompound.setString("Texture", texture);
|
||||
|
||||
nbttagcompound.setString("CloakTexture", cloakTexture);
|
||||
nbttagcompound.setByte("UsingSkinUrl", skinType);
|
||||
nbttagcompound.setString("GlowTexture", glowTexture);
|
||||
|
||||
nbttagcompound = skinOverlayData.writeToNBT(nbttagcompound);
|
||||
|
||||
nbttagcompound = animationData.writeToNBT(nbttagcompound);
|
||||
nbttagcompound = customHitboxData.writeToNBT(nbttagcompound);
|
||||
nbttagcompound = customTintData.writeToNBT(nbttagcompound);
|
||||
|
||||
if (this.playerProfile != null)
|
||||
if (this.playerProfile != null)
|
||||
{
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
NBTUtil.func_152460_a(nbttagcompound1, this.playerProfile);
|
||||
nbttagcompound.setTag("SkinUsername", nbttagcompound1);
|
||||
}
|
||||
|
||||
nbttagcompound.setInteger("Size", modelSize);
|
||||
nbttagcompound.setInteger("modelType", modelType);
|
||||
nbttagcompound.setInteger("Size", modelSize);
|
||||
nbttagcompound.setInteger("modelType", modelType);
|
||||
|
||||
nbttagcompound.setInteger("ShowName", showName);
|
||||
nbttagcompound.setInteger("NpcVisible", visible);
|
||||
nbttagcompound.setInteger("ShowName", showName);
|
||||
nbttagcompound.setInteger("NpcVisible", visible);
|
||||
|
||||
nbttagcompound.setBoolean("NoLivingAnimation", disableLivingAnimation);
|
||||
nbttagcompound.setByte("BossBar", showBossBar);
|
||||
nbttagcompound.setBoolean("NoLivingAnimation", disableLivingAnimation);
|
||||
nbttagcompound.setByte("BossBar", showBossBar);
|
||||
|
||||
nbttagcompound.setInteger("CollidesWith",collidesWith);
|
||||
nbttagcompound.setInteger("CollidesWith",collidesWith);
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(UUID uuid : invisibleToList){
|
||||
list.appendTag(new NBTTagString(uuid.toString()));
|
||||
}
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(UUID uuid : invisibleToList){
|
||||
list.appendTag(new NBTTagString(uuid.toString()));
|
||||
}
|
||||
|
||||
nbttagcompound.setTag("InvisibleToList", list);
|
||||
return nbttagcompound;
|
||||
}
|
||||
public void readToNBT(NBTTagCompound nbttagcompound) {
|
||||
setName(nbttagcompound.getString("Name"));
|
||||
setMarkovGeneratorId(nbttagcompound.getInteger("MarkovGeneratorId"));
|
||||
setMarkovGender(nbttagcompound.getInteger("MarkovGender"));
|
||||
nbttagcompound.setTag("InvisibleToList", list);
|
||||
return nbttagcompound;
|
||||
}
|
||||
public void readToNBT(NBTTagCompound nbttagcompound) {
|
||||
setName(nbttagcompound.getString("Name"));
|
||||
setMarkovGeneratorId(nbttagcompound.getInteger("MarkovGeneratorId"));
|
||||
setMarkovGender(nbttagcompound.getInteger("MarkovGender"));
|
||||
|
||||
title = nbttagcompound.getString("Title");
|
||||
title = nbttagcompound.getString("Title");
|
||||
|
||||
url = nbttagcompound.getString("SkinUrl");
|
||||
url = nbttagcompound.getString("SkinUrl");
|
||||
|
||||
int prevSkinType = skinType;
|
||||
skinType = nbttagcompound.getByte("UsingSkinUrl");
|
||||
int prevSkinType = skinType;
|
||||
skinType = nbttagcompound.getByte("UsingSkinUrl");
|
||||
|
||||
this.playerProfile = null;
|
||||
if(skinType == 1){
|
||||
if (nbttagcompound.hasKey("SkinUsername", 10)){
|
||||
this.playerProfile = NBTUtil.func_152459_a(nbttagcompound.getCompoundTag("SkinUsername"));
|
||||
}
|
||||
else if (nbttagcompound.hasKey("SkinUsername", 8) && !StringUtils.isNullOrEmpty(nbttagcompound.getString("SkinUsername"))){
|
||||
this.playerProfile = new GameProfile(null, nbttagcompound.getString("SkinUsername"));
|
||||
}
|
||||
this.loadProfile();
|
||||
}
|
||||
this.playerProfile = null;
|
||||
if(skinType == 1){
|
||||
if (nbttagcompound.hasKey("SkinUsername", 10)){
|
||||
this.playerProfile = NBTUtil.func_152459_a(nbttagcompound.getCompoundTag("SkinUsername"));
|
||||
}
|
||||
else if (nbttagcompound.hasKey("SkinUsername", 8) && !StringUtils.isNullOrEmpty(nbttagcompound.getString("SkinUsername"))){
|
||||
this.playerProfile = new GameProfile(null, nbttagcompound.getString("SkinUsername"));
|
||||
}
|
||||
this.loadProfile();
|
||||
}
|
||||
|
||||
String prevTexture = texture;
|
||||
|
||||
texture = nbttagcompound.getString("Texture");
|
||||
texture = nbttagcompound.getString("Texture");
|
||||
|
||||
cloakTexture = nbttagcompound.getString("CloakTexture");
|
||||
glowTexture = nbttagcompound.getString("GlowTexture");
|
||||
cloakTexture = nbttagcompound.getString("CloakTexture");
|
||||
glowTexture = nbttagcompound.getString("GlowTexture");
|
||||
|
||||
if (!nbttagcompound.hasKey("SkinOverlayData") && !glowTexture.isEmpty()) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("SkinOverlayID", 0); //unique glow texture ID
|
||||
if (!nbttagcompound.hasKey("SkinOverlayData") && !glowTexture.isEmpty()) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("SkinOverlayID", 0); //unique glow texture ID
|
||||
|
||||
(new SkinOverlay(glowTexture)).writeToNBT(compound);
|
||||
(new SkinOverlay(glowTexture)).writeToNBT(compound);
|
||||
|
||||
if (!nbttagcompound.hasKey("SkinOverlayData")) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
tagList.appendTag(compound);
|
||||
nbttagcompound.setTag("SkinOverlayData", tagList);
|
||||
} else if (!glowTexture.isEmpty()) {
|
||||
nbttagcompound.getTagList("SkinOverlayData", 10).appendTag(compound);
|
||||
glowTexture = "";
|
||||
}
|
||||
}
|
||||
if (!nbttagcompound.hasKey("SkinOverlayData")) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
tagList.appendTag(compound);
|
||||
nbttagcompound.setTag("SkinOverlayData", tagList);
|
||||
} else if (!glowTexture.isEmpty()) {
|
||||
nbttagcompound.getTagList("SkinOverlayData", 10).appendTag(compound);
|
||||
glowTexture = "";
|
||||
}
|
||||
}
|
||||
|
||||
skinOverlayData.readFromNBT(nbttagcompound);
|
||||
skinOverlayData.readFromNBT(nbttagcompound);
|
||||
|
||||
animationData.readFromNBT(nbttagcompound);
|
||||
customHitboxData.readFromNBT(nbttagcompound);
|
||||
customTintData.readFromNBT(nbttagcompound);
|
||||
|
||||
modelSize = ValueUtil.clamp(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE);
|
||||
if(modelSize > ConfigMain.NpcSizeLimit)
|
||||
modelSize = ConfigMain.NpcSizeLimit;
|
||||
animationData.readFromNBT(nbttagcompound);
|
||||
hitboxData.readFromNBT(nbttagcompound);
|
||||
tintData.readFromNBT(nbttagcompound);
|
||||
|
||||
modelType = nbttagcompound.getInteger("modelType");
|
||||
modelSize = ValueUtil.clamp(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE);
|
||||
if(modelSize > ConfigMain.NpcSizeLimit)
|
||||
modelSize = ConfigMain.NpcSizeLimit;
|
||||
|
||||
showName = nbttagcompound.getInteger("ShowName");
|
||||
visible = nbttagcompound.getInteger("NpcVisible");
|
||||
modelType = nbttagcompound.getInteger("modelType");
|
||||
|
||||
disableLivingAnimation = nbttagcompound.getBoolean("NoLivingAnimation");
|
||||
showBossBar = nbttagcompound.getByte("BossBar");
|
||||
showName = nbttagcompound.getInteger("ShowName");
|
||||
visible = nbttagcompound.getInteger("NpcVisible");
|
||||
|
||||
NBTTagList tagList = (NBTTagList)nbttagcompound.getTag("InvisibleToList");
|
||||
if(tagList != null) {
|
||||
invisibleToList.clear();
|
||||
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||
String nbtTagString = tagList.getStringTagAt(i);
|
||||
invisibleToList.add(UUID.fromString(nbtTagString));
|
||||
}
|
||||
}
|
||||
else {
|
||||
invisibleToList = new ArrayList<>();
|
||||
}
|
||||
disableLivingAnimation = nbttagcompound.getBoolean("NoLivingAnimation");
|
||||
showBossBar = nbttagcompound.getByte("BossBar");
|
||||
|
||||
if(nbttagcompound.hasKey("CollidesWith"))
|
||||
collidesWith = nbttagcompound.getInteger("CollidesWith");
|
||||
else
|
||||
collidesWith = 1;
|
||||
NBTTagList tagList = (NBTTagList)nbttagcompound.getTag("InvisibleToList");
|
||||
if(tagList != null) {
|
||||
invisibleToList.clear();
|
||||
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||
String nbtTagString = tagList.getStringTagAt(i);
|
||||
invisibleToList.add(UUID.fromString(nbtTagString));
|
||||
}
|
||||
}
|
||||
else {
|
||||
invisibleToList = new ArrayList<>();
|
||||
}
|
||||
|
||||
if(prevSkinType != skinType || !texture.equals(prevTexture))
|
||||
npc.textureLocation = null;
|
||||
npc.updateHitbox();
|
||||
}
|
||||
if(nbttagcompound.hasKey("CollidesWith"))
|
||||
collidesWith = nbttagcompound.getInteger("CollidesWith");
|
||||
else
|
||||
collidesWith = 1;
|
||||
|
||||
if(prevSkinType != skinType || !texture.equals(prevTexture))
|
||||
npc.textureLocation = null;
|
||||
npc.updateHitbox();
|
||||
}
|
||||
|
||||
public void loadProfile(){
|
||||
if (this.playerProfile != null && !StringUtils.isNullOrEmpty(this.playerProfile.getName()) && MinecraftServer.getServer() != null){
|
||||
@@ -228,53 +223,53 @@ public class DataDisplay {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean showName() {
|
||||
if(npc.isKilled())
|
||||
return false;
|
||||
return showName == 0 || (showName == 2 && npc.isAttacking());
|
||||
}
|
||||
public boolean showName() {
|
||||
if(npc.isKilled())
|
||||
return false;
|
||||
return showName == 0 || (showName == 2 && npc.isAttacking());
|
||||
}
|
||||
|
||||
public String getSkinTexture(){
|
||||
return texture;
|
||||
}
|
||||
public String getSkinTexture(){
|
||||
return texture;
|
||||
}
|
||||
|
||||
public void setSkinTexture(String texture){
|
||||
if(this.texture.equals(texture))
|
||||
return;
|
||||
this.texture = texture;
|
||||
npc.textureLocation = null;
|
||||
skinType = 0;
|
||||
npc.updateClient = true;
|
||||
}
|
||||
public void setSkinTexture(String texture){
|
||||
if(this.texture.equals(texture))
|
||||
return;
|
||||
this.texture = texture;
|
||||
npc.textureLocation = null;
|
||||
skinType = 0;
|
||||
npc.updateClient = true;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name){
|
||||
if(this.name.equals(name))
|
||||
return;
|
||||
this.name = name;
|
||||
npc.updateClient = true;
|
||||
}
|
||||
public void setName(String name){
|
||||
if(this.name.equals(name))
|
||||
return;
|
||||
this.name = name;
|
||||
npc.updateClient = true;
|
||||
}
|
||||
|
||||
public int getMarkovGender(){
|
||||
return markovGender;
|
||||
}
|
||||
public int getMarkovGender(){
|
||||
return markovGender;
|
||||
}
|
||||
|
||||
public void setMarkovGender(int gender) {
|
||||
if(markovGender == gender)
|
||||
return;
|
||||
this.markovGender = ValueUtil.clamp(gender, 0, 2);
|
||||
}
|
||||
public void setMarkovGender(int gender) {
|
||||
if(markovGender == gender)
|
||||
return;
|
||||
this.markovGender = ValueUtil.clamp(gender, 0, 2);
|
||||
}
|
||||
|
||||
public int getMarkovGeneratorId(){
|
||||
return markovGeneratorId;
|
||||
}
|
||||
public int getMarkovGeneratorId(){
|
||||
return markovGeneratorId;
|
||||
}
|
||||
|
||||
public void setMarkovGeneratorId(int id) {
|
||||
if(markovGeneratorId == id)
|
||||
return;
|
||||
this.markovGeneratorId = ValueUtil.clamp(id, 0, CustomNpcs.MARKOV_GENERATOR.length-1);
|
||||
}
|
||||
public void setMarkovGeneratorId(int id) {
|
||||
if(markovGeneratorId == id)
|
||||
return;
|
||||
this.markovGeneratorId = ValueUtil.clamp(id, 0, CustomNpcs.MARKOV_GENERATOR.length-1);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user