2021-12-05 15:04:03 -06:00
|
|
|
package noppes.npcs.scripted.entity;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
2021-12-14 21:41:57 -06:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
import net.minecraft.nbt.NBTTagList;
|
2021-12-05 15:04:03 -06:00
|
|
|
import noppes.npcs.scripted.CustomNPCsException;
|
2021-12-14 21:41:57 -06:00
|
|
|
import noppes.npcs.scripted.NpcAPI;
|
|
|
|
|
import noppes.npcs.scripted.ScriptItemStack;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2021-12-05 15:04:03 -06:00
|
|
|
|
|
|
|
|
public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T>{
|
|
|
|
|
public T player;
|
|
|
|
|
|
|
|
|
|
public ScriptDBCPlayer(T player){
|
|
|
|
|
super(player);
|
|
|
|
|
this.player = player;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setStat(String stat, int value) {
|
|
|
|
|
stat = stat.toLowerCase().trim();
|
|
|
|
|
switch (stat) {
|
|
|
|
|
case "str":
|
|
|
|
|
case "strength":
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcStrI", value);
|
2021-12-05 15:04:03 -06:00
|
|
|
break;
|
|
|
|
|
case "dex":
|
|
|
|
|
case "dexterity":
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcDexI", value);
|
2021-12-05 15:04:03 -06:00
|
|
|
break;
|
|
|
|
|
case "con":
|
|
|
|
|
case "constitution":
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcCnsI", value);
|
2021-12-05 15:04:03 -06:00
|
|
|
break;
|
|
|
|
|
case "wil":
|
|
|
|
|
case "willpower":
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcWilI", value);
|
2021-12-05 15:04:03 -06:00
|
|
|
break;
|
|
|
|
|
case "mnd":
|
|
|
|
|
case "mind":
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcIntI", value);
|
2021-12-05 15:04:03 -06:00
|
|
|
break;
|
|
|
|
|
case "spi":
|
|
|
|
|
case "spirit":
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcCncI", value);
|
2021-12-05 15:04:03 -06:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getStat(String stat) {
|
|
|
|
|
stat = stat.toLowerCase().trim();
|
|
|
|
|
switch (stat) {
|
|
|
|
|
case "str":
|
|
|
|
|
case "strength":
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcStrI");
|
2021-12-05 15:04:03 -06:00
|
|
|
case "dex":
|
|
|
|
|
case "dexterity":
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcDexI");
|
2021-12-05 15:04:03 -06:00
|
|
|
case "con":
|
|
|
|
|
case "constitution":
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcCnsI");
|
2021-12-05 15:04:03 -06:00
|
|
|
case "wil":
|
|
|
|
|
case "willpower":
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcWilI");
|
2021-12-05 15:04:03 -06:00
|
|
|
case "mnd":
|
|
|
|
|
case "mind":
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcIntI");
|
2021-12-05 15:04:03 -06:00
|
|
|
case "spi":
|
|
|
|
|
case "spirit":
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcCncI");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new CustomNPCsException("Invalid stat name: " + stat + "\nValid stat names are:" +
|
|
|
|
|
"\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit",new Object[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setRelease(byte release){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcRelease",release);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public byte getRelease(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcRelease");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setBody(int body){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcBdy",body);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getBody(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcBdy");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setStamina(int stamina){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcStamina",stamina);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getStamina(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcStamina");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setKi(int ki){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcEnrgy",ki);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getKi(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcEnrgy");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setTP(int tp){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcTpint",tp);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getTP(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcTpint");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setGravity(float gravity){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setFloat("jrmcGravForce",gravity);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public float getGravity(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getFloat("jrmcGravForce");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
2021-12-14 21:41:57 -06:00
|
|
|
public boolean isBlocking(){
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
this.player.writeToNBT(compound);
|
|
|
|
|
return compound.getCompoundTag("JRMCEP").getInteger("blocking") == 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setHairCode(String hairCode){
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
this.player.writeToNBT(compound);
|
|
|
|
|
compound.getCompoundTag("JRMCEP").setString("haircode",hairCode);
|
|
|
|
|
}
|
|
|
|
|
public String getHairCode(){
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
this.player.writeToNBT(compound);
|
|
|
|
|
return compound.getCompoundTag("JRMCEP").getString("haircode");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setExtraCode(String extraCode){
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
this.player.writeToNBT(compound);
|
|
|
|
|
compound.getCompoundTag("JRMCEP").setString("extracode",extraCode);
|
|
|
|
|
}
|
|
|
|
|
public String getExtraCode(){
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
this.player.writeToNBT(compound);
|
|
|
|
|
return compound.getCompoundTag("JRMCEP").getString("extracode");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ScriptItemStack[] getInventory(){
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
this.player.writeToNBT(compound);
|
|
|
|
|
|
|
|
|
|
NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag",10);
|
|
|
|
|
ScriptItemStack[] itemList = new ScriptItemStack[list.tagCount()];
|
|
|
|
|
for (int i = 0; i < list.tagCount(); i++) {
|
|
|
|
|
ItemStack itemStack = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i));
|
|
|
|
|
itemList[i] = new ScriptItemStack(itemStack);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return itemList;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-05 15:04:03 -06:00
|
|
|
public void setForm(byte form){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState",form);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public byte getForm(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcState");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public void setForm2(byte form2){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState2",form2);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public byte getForm2(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcState2");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setPowerPoints(int points){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcArcRsrv",points);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getPowerPoints(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcArcRsrv");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAuraColor(int color){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcAuraColor",color);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getAuraColor(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcAuraColor");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
2021-12-15 03:14:48 -06:00
|
|
|
public void setFormLevel(int level){
|
|
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcSSltX","TR"+level);
|
|
|
|
|
}
|
|
|
|
|
public int getFormLevel(){
|
|
|
|
|
return Integer.parseInt(player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcSSltX").replace("TR",""));
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-15 03:19:34 -06:00
|
|
|
public void setSkills(String skills){
|
|
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcSSlts",skills);
|
|
|
|
|
}
|
|
|
|
|
public String getSkills(){
|
|
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcSSlts");
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-05 15:04:03 -06:00
|
|
|
public byte getDBCClass(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcClass");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getRace(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcRace");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getPowerType(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcPwrtyp");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getKillCount(String type){
|
|
|
|
|
type = type.toLowerCase().trim();
|
|
|
|
|
|
2021-12-13 18:33:20 -06:00
|
|
|
int evilKills = player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcKillCountEvil");
|
|
|
|
|
int goodKills = player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcKillCountGood");
|
|
|
|
|
int neutKills = player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcKillCountNeut");
|
2021-12-05 15:04:03 -06:00
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
case "evil":
|
|
|
|
|
return evilKills;
|
|
|
|
|
case "good":
|
|
|
|
|
return goodKills;
|
|
|
|
|
case "neutral":
|
|
|
|
|
return neutKills;
|
|
|
|
|
case "all":
|
|
|
|
|
return evilKills + goodKills + neutKills;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new CustomNPCsException("Invalid kill type: " + type + "\nValid kill types are: evil, good, neutral, all", new Object[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|