2018-09-13 12:03:28 -04:00
|
|
|
package noppes.npcs;
|
|
|
|
|
|
2021-11-22 23:34:02 -06:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
2018-09-13 12:03:28 -04:00
|
|
|
import java.util.Random;
|
2021-11-22 23:34:02 -06:00
|
|
|
import java.util.UUID;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2021-11-22 23:34:02 -06:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
2018-09-13 12:03:28 -04:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2021-11-22 23:34:02 -06:00
|
|
|
import net.minecraft.nbt.NBTTagList;
|
|
|
|
|
import net.minecraft.nbt.NBTTagString;
|
2018-09-13 12:03:28 -04:00
|
|
|
import net.minecraft.nbt.NBTUtil;
|
|
|
|
|
import net.minecraft.server.MinecraftServer;
|
|
|
|
|
import net.minecraft.util.StringUtils;
|
|
|
|
|
import noppes.npcs.entity.EntityNPCInterface;
|
|
|
|
|
import noppes.npcs.util.ValueUtil;
|
|
|
|
|
|
|
|
|
|
import com.google.common.collect.Iterables;
|
|
|
|
|
import com.mojang.authlib.GameProfile;
|
|
|
|
|
import com.mojang.authlib.properties.Property;
|
|
|
|
|
|
|
|
|
|
public class DataDisplay {
|
|
|
|
|
EntityNPCInterface npc;
|
|
|
|
|
|
|
|
|
|
public String name;
|
|
|
|
|
public String title = "";
|
|
|
|
|
|
2021-06-13 19:26:00 -04:00
|
|
|
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
|
|
|
|
|
|
2021-05-04 03:52:44 -04:00
|
|
|
public byte skinType = 0; //0:normal, 1:player, 2:url, 3:url64
|
2021-05-06 01:27:24 -04:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public String url = "";
|
2021-05-06 01:27:24 -04:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public GameProfile playerProfile;
|
2021-05-09 02:58:18 -04:00
|
|
|
public String texture = "customnpcs:textures/entity/humanmale/Steve.png";
|
2018-09-13 12:03:28 -04:00
|
|
|
public String cloakTexture = "";
|
|
|
|
|
public String glowTexture = "";
|
|
|
|
|
|
2021-05-04 03:52:44 -04:00
|
|
|
public int visible = 0; //0:visible 1:Invisible 2:semi-invisible
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
public int modelSize = 5;
|
|
|
|
|
|
|
|
|
|
public int showName = 0;
|
2021-04-29 20:42:52 -04:00
|
|
|
|
|
|
|
|
public int modelType = 0;
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public boolean disableLivingAnimation = false;
|
|
|
|
|
|
|
|
|
|
public byte showBossBar = 0;
|
2021-04-29 14:37:33 -04:00
|
|
|
|
2021-11-22 23:34:02 -06:00
|
|
|
public ArrayList<UUID> invisibleToList = new ArrayList<>();
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public DataDisplay(EntityNPCInterface npc){
|
|
|
|
|
this.npc = npc;
|
2021-06-13 19:26:00 -04:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Implementing MarkovNames generator. You can blame this blunder on Nikedemos.
|
|
|
|
|
|
|
|
|
|
Please refer to nikedemos.markovnames.generators.MarkovCustomNPCsClassic.java
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
String[] names = { "Noppes", "Noppes", "Noppes", "Noppes", "Atesson",
|
|
|
|
|
"Rothcersul", "Achdranys", "Pegato", "Chald", "Gareld",
|
|
|
|
|
"Nalworche", "Ineald", "Tia'kim", "Torerod", "Turturdar",
|
|
|
|
|
"Ranler", "Dyntan", "Oldrake", "Gharis", "Elmn", "Tanal",
|
|
|
|
|
"Waran-ess", "Ach-aldhat", "Athi", "Itageray", "Tasr",
|
|
|
|
|
"Ightech", "Gakih", "Adkal", "Qua'an", "Sieq", "Urnp", "Rods",
|
|
|
|
|
"Vorbani", "Smaik", "Fian", "Hir", "Ristai", "Kineth", "Naif",
|
|
|
|
|
"Issraya", "Arisotura", "Honf", "Rilfom", "Estz", "Ghatroth",
|
|
|
|
|
"Yosil", "Darage", "Aldny", "Tyltran", "Armos", "Loxiku",
|
|
|
|
|
"Burhat", "Tinlt", "Ightyd", "Mia",
|
2021-06-13 19:26:00 -04:00
|
|
|
"Ken", "Karla", "Lily", "Carina", "Daniel", "Slater", "Zidane", "Valentine", "Eirina",
|
|
|
|
|
"Carnow", "Grave", "Shadow", "Drakken", "Kaoz", "Silk", "Drake", "Oldam", "Lynxx", "Lenyx",
|
|
|
|
|
"Winter", "Seth", "Apolitho", "Amethyst", "Ankin", "Seinkan", "Ayumu", "Sakamoto", "Divina",
|
|
|
|
|
"Div", "Magia", "Magnus", "Tiakono", "Ruin", "Hailinx", "Ethan", "Wate", "Carter", "William",
|
2018-09-13 12:03:28 -04:00
|
|
|
"Brion", "Sparrow", "Basrrelen", "Gyaku", "Claire", "Crowfeather", "Blackwell", "Raven", "Farcri",
|
2021-06-13 19:26:00 -04:00
|
|
|
"Lucas", "Bangheart", "Kamoku", "Kyoukan", "Blaze", "Benjamin", "Larianne", "Kakaragon",
|
|
|
|
|
"Melancholy", "Epodyno", "Thanato", "Mika", "Dacks", "Ylander", "Neve", "Meadow", "Cuero",
|
|
|
|
|
"Embrera", "Eldamore", "Faolan", "Chim", "Nasu", "Kathrine", "Ariel", "Arei", "Demytrix",
|
|
|
|
|
"Kora", "Ava", "Larson", "Leonardo", "Wyrl", "Sakiama", "Lambton", "Kederath", "Malus", "Riplette",
|
|
|
|
|
"Andern", "Ezall", "Lucien", "Droco", "Cray", "Tymen", "Zenix", "Entranger",
|
2021-04-29 01:10:15 -04:00
|
|
|
"Saenorath", "Chris", "Christine", "Marble", "Mable", "Ross", "Rose", "Xalgan ", "Kennet", "Kamkeel"
|
2018-09-13 12:03:28 -04:00
|
|
|
};
|
|
|
|
|
name = names[new Random().nextInt(names.length)];
|
2021-06-13 19:26:00 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1);
|
|
|
|
|
name = getRandomName();
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
2021-06-13 19:26:00 -04:00
|
|
|
|
|
|
|
|
public String getRandomName() {
|
|
|
|
|
return CustomNpcs.MARKOV_GENERATOR[markovGeneratorId].fetch(markovGender);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
|
|
|
|
nbttagcompound.setString("Name", name);
|
2021-06-13 19:26:00 -04:00
|
|
|
nbttagcompound.setInteger("MarkovGeneratorId", markovGeneratorId);
|
|
|
|
|
nbttagcompound.setInteger("MarkovGender", markovGender);
|
2018-09-13 12:03:28 -04:00
|
|
|
nbttagcompound.setString("Title", title);
|
|
|
|
|
nbttagcompound.setString("SkinUrl", url);
|
|
|
|
|
nbttagcompound.setString("Texture", texture);
|
|
|
|
|
nbttagcompound.setString("CloakTexture", cloakTexture);
|
|
|
|
|
nbttagcompound.setString("GlowTexture", glowTexture);
|
|
|
|
|
nbttagcompound.setByte("UsingSkinUrl", skinType);
|
2021-04-29 20:42:52 -04:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
if (this.playerProfile != null)
|
|
|
|
|
{
|
|
|
|
|
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
|
|
|
|
NBTUtil.func_152460_a(nbttagcompound1, this.playerProfile);
|
|
|
|
|
nbttagcompound.setTag("SkinUsername", nbttagcompound1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nbttagcompound.setInteger("Size", modelSize);
|
2021-04-29 20:42:52 -04:00
|
|
|
nbttagcompound.setInteger("modelType", modelType);
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
nbttagcompound.setInteger("ShowName", showName);
|
|
|
|
|
nbttagcompound.setInteger("NpcVisible", visible);
|
|
|
|
|
|
|
|
|
|
nbttagcompound.setBoolean("NoLivingAnimation", disableLivingAnimation);
|
|
|
|
|
nbttagcompound.setByte("BossBar", showBossBar);
|
|
|
|
|
|
2021-11-22 23:34:02 -06:00
|
|
|
NBTTagList list = new NBTTagList();
|
|
|
|
|
for(UUID uuid : invisibleToList){
|
|
|
|
|
list.appendTag(new NBTTagString(uuid.toString()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nbttagcompound.setTag("InvisibleToList", list);
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
return nbttagcompound;
|
|
|
|
|
}
|
|
|
|
|
public void readToNBT(NBTTagCompound nbttagcompound) {
|
2021-06-13 19:26:00 -04:00
|
|
|
setName(nbttagcompound.getString("Name"));
|
|
|
|
|
setMarkovGeneratorId(nbttagcompound.getInteger("MarkovGeneratorId"));
|
|
|
|
|
setMarkovGender(nbttagcompound.getInteger("MarkovGender"));
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
title = nbttagcompound.getString("Title");
|
|
|
|
|
|
|
|
|
|
url = nbttagcompound.getString("SkinUrl");
|
2021-05-06 01:27:24 -04:00
|
|
|
|
|
|
|
|
int prevSkinType = skinType;
|
2018-09-13 12:03:28 -04:00
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String prevTexture = texture;
|
|
|
|
|
|
|
|
|
|
texture = nbttagcompound.getString("Texture");
|
|
|
|
|
cloakTexture = nbttagcompound.getString("CloakTexture");
|
|
|
|
|
glowTexture = nbttagcompound.getString("GlowTexture");
|
|
|
|
|
|
2021-05-09 02:58:18 -04:00
|
|
|
modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, 30);
|
2021-04-29 20:42:52 -04:00
|
|
|
modelType = nbttagcompound.getInteger("modelType");
|
2021-05-08 01:56:39 -04:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
showName = nbttagcompound.getInteger("ShowName");
|
|
|
|
|
visible = nbttagcompound.getInteger("NpcVisible");
|
|
|
|
|
|
|
|
|
|
disableLivingAnimation = nbttagcompound.getBoolean("NoLivingAnimation");
|
|
|
|
|
showBossBar = nbttagcompound.getByte("BossBar");
|
|
|
|
|
|
2021-11-22 23:34:02 -06:00
|
|
|
invisibleToList.clear();
|
|
|
|
|
NBTTagList tagList = (NBTTagList)nbttagcompound.getTag("InvisibleToList");
|
|
|
|
|
for(int i = 0; i < tagList.tagCount(); i++){
|
|
|
|
|
String nbtTagString = tagList.getStringTagAt(i);
|
|
|
|
|
invisibleToList.add(UUID.fromString(nbtTagString));
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
if(prevSkinType != skinType || !texture.equals(prevTexture))
|
|
|
|
|
npc.textureLocation = null;
|
|
|
|
|
npc.textureGlowLocation = null;
|
|
|
|
|
npc.textureCloakLocation = null;
|
|
|
|
|
npc.updateHitbox();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void loadProfile(){
|
|
|
|
|
if (this.playerProfile != null && !StringUtils.isNullOrEmpty(this.playerProfile.getName()) && MinecraftServer.getServer() != null){
|
|
|
|
|
if (!this.playerProfile.isComplete() || !this.playerProfile.getProperties().containsKey("textures")){
|
|
|
|
|
GameProfile gameprofile = MinecraftServer.getServer().func_152358_ax().func_152655_a(this.playerProfile.getName());
|
|
|
|
|
|
|
|
|
|
if (gameprofile != null){
|
|
|
|
|
Property property = (Property)Iterables.getFirst(gameprofile.getProperties().get("textures"), (Object)null);
|
|
|
|
|
|
|
|
|
|
if (property == null){
|
|
|
|
|
gameprofile = MinecraftServer.getServer().func_147130_as().fillProfileProperties(gameprofile, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.playerProfile = gameprofile;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean showName() {
|
|
|
|
|
if(npc.isKilled())
|
|
|
|
|
return false;
|
|
|
|
|
return showName == 0 || (showName == 2 && npc.isAttacking());
|
|
|
|
|
}
|
2021-04-27 11:56:36 -04:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-13 19:26:00 -04:00
|
|
|
public String getName(){
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setName(String name){
|
|
|
|
|
if(this.name.equals(name))
|
|
|
|
|
return;
|
|
|
|
|
this.name = name;
|
|
|
|
|
npc.updateClient = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getMarkovGender(){
|
|
|
|
|
return markovGender;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setMarkovGender(int gender) {
|
|
|
|
|
if(markovGender == gender)
|
|
|
|
|
return;
|
|
|
|
|
this.markovGender = ValueUtil.CorrectInt(gender, 0, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getMarkovGeneratorId(){
|
|
|
|
|
return markovGeneratorId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setMarkovGeneratorId(int id) {
|
|
|
|
|
if(markovGeneratorId == id)
|
|
|
|
|
return;
|
|
|
|
|
this.markovGeneratorId = ValueUtil.CorrectInt(id, 0, CustomNpcs.MARKOV_GENERATOR.length-1);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|