Proper Reformating

This commit is contained in:
Kam committed 2025-03-13 17:14:45 -04:00
1 parent ce75880aba
commit 180d257024
1179 files changed
+59847 -61583

No files matched your search

@@ -34,14 +34,15 @@ public class Animation implements IAnimation {
//Client-sided
public boolean paused;
public Animation(){}
public Animation() {
}
public Animation(int id, String name){
public Animation(int id, String name) {
this.name = name;
this.id = id;
}
public Animation(int id, String name, float speed, byte smooth){
public Animation(int id, String name, float speed, byte smooth) {
this.name = name;
this.speed = speed;
this.smooth = smooth;
@@ -174,11 +175,10 @@ public class Animation implements IAnimation {
return time;
}
public void readFromNBT(NBTTagCompound compound){
if(compound.hasKey("ID")){
public void readFromNBT(NBTTagCompound compound) {
if (compound.hasKey("ID")) {
id = compound.getInteger("ID");
}
else if (AnimationController.Instance != null) {
} else if (AnimationController.Instance != null) {
id = AnimationController.Instance.getUnusedId();
}
@@ -206,16 +206,16 @@ public class Animation implements IAnimation {
this.currentFrameTime = compound.getInteger("CurrentFrameTime");
}
public NBTTagCompound writeToNBT(){
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("ID", id);
compound.setString("Name", name);
compound.setFloat("Speed", speed);
compound.setByte("Smooth", smooth);
compound.setInteger("Loop",loop);
compound.setInteger("Loop", loop);
NBTTagList list = new NBTTagList();
for(Frame frame : frames){
for (Frame frame : frames) {
NBTTagCompound item = frame.writeToNBT();
list.appendTag(item);
}
@@ -284,9 +284,9 @@ public class Animation implements IAnimation {
this.currentFrameTime = time;
Frame frame = (Frame) this.currentFrame();
if(frame != null){
if (frame != null) {
for (EnumAnimationPart part : EnumAnimationPart.values()) {
if(part != null){
if (part != null) {
if (frame.frameParts.containsKey(part)) {
frame.frameParts.get(part).jumpToCurrentFrame();
}
@@ -41,7 +41,7 @@ public class AnimationData implements IAnimationData {
public int finishedTime = -1;
public int finishedFrame = -1;
public AnimationData(Object parent){
public AnimationData(Object parent) {
this.parent = parent;
}
@@ -56,7 +56,7 @@ public class AnimationData implements IAnimationData {
if (entity instanceof EntityPlayerMP) {
return PlayerData.get((EntityPlayer) entity).animationData;
} else if (entity instanceof EntityNPCInterface) {
return ((EntityNPCInterface)entity).display.animationData;
return ((EntityNPCInterface) entity).display.animationData;
} else {
return null;
}
@@ -72,7 +72,7 @@ public class AnimationData implements IAnimationData {
public EntityLivingBase getMCEntity() {
if (this.parent instanceof DataDisplay) {
return ((DataDisplay) this.parent).npc;
return ((DataDisplay) this.parent).npc;
} else {
if (this.parent instanceof PlayerData) {
return ((PlayerData) this.parent).player;
@@ -90,7 +90,7 @@ public class AnimationData implements IAnimationData {
EntityLivingBase sendingEntity = parent instanceof PlayerData ? ((PlayerData) parent).player : parent instanceof DataDisplay ? ((DataDisplay) parent).npc : null;
float range = parent instanceof PlayerData ? 160 : 60;
if (sendingEntity != null) {
if(sendingEntity.dimension != sendingEntity.worldObj.provider.dimensionId)
if (sendingEntity.dimension != sendingEntity.worldObj.provider.dimensionId)
sendingEntity.dimension = sendingEntity.worldObj.provider.dimensionId;
this.animatingTime = 0;
@@ -137,7 +137,7 @@ public class AnimationData implements IAnimationData {
return false;
if (this.parent instanceof DataDisplay) {
EntityNPCInterface npc = ((DataDisplay)this.parent).npc;
EntityNPCInterface npc = ((DataDisplay) this.parent).npc;
if (!npc.isEntityAlive())
return false;
@@ -152,7 +152,7 @@ public class AnimationData implements IAnimationData {
if (!player.isEntityAlive())
return false;
boolean moving = Math.sqrt(player.motionX*player.motionX + player.motionY*player.motionY + player.motionZ*player.motionZ) != 0.0D;
boolean moving = Math.sqrt(player.motionX * player.motionX + player.motionY * player.motionY + player.motionZ * player.motionZ) != 0.0D;
return animation.whileAttacking && player.getLastAttackerTime() - player.ticksExisted < 20 || animation.whileMoving && moving || animation.whileStanding && !moving;
}
@@ -20,115 +20,114 @@ import java.util.ArrayList;
import java.util.List;
public class Availability implements ICompatibilty, IAvailability {
public int version = VersionCompatibility.ModRev;
public int version = VersionCompatibility.ModRev;
public EnumAvailabilityDialog dialogAvailable = EnumAvailabilityDialog.Always;
public EnumAvailabilityDialog dialog2Available = EnumAvailabilityDialog.Always;
public EnumAvailabilityDialog dialog3Available = EnumAvailabilityDialog.Always;
public EnumAvailabilityDialog dialog4Available = EnumAvailabilityDialog.Always;
public int dialogId = -1;
public int dialog2Id = -1;
public int dialog3Id = -1;
public int dialog4Id = -1;
public EnumAvailabilityDialog dialogAvailable = EnumAvailabilityDialog.Always;
public EnumAvailabilityDialog dialog2Available = EnumAvailabilityDialog.Always;
public EnumAvailabilityDialog dialog3Available = EnumAvailabilityDialog.Always;
public EnumAvailabilityDialog dialog4Available = EnumAvailabilityDialog.Always;
public int dialogId = -1;
public int dialog2Id = -1;
public int dialog3Id = -1;
public int dialog4Id = -1;
public EnumAvailabilityQuest questAvailable = EnumAvailabilityQuest.Always;
public EnumAvailabilityQuest quest2Available = EnumAvailabilityQuest.Always;
public EnumAvailabilityQuest quest3Available = EnumAvailabilityQuest.Always;
public EnumAvailabilityQuest quest4Available = EnumAvailabilityQuest.Always;
public int questId = -1;
public int quest2Id = -1;
public int quest3Id = -1;
public int quest4Id = -1;
public EnumAvailabilityQuest questAvailable = EnumAvailabilityQuest.Always;
public EnumAvailabilityQuest quest2Available = EnumAvailabilityQuest.Always;
public EnumAvailabilityQuest quest3Available = EnumAvailabilityQuest.Always;
public EnumAvailabilityQuest quest4Available = EnumAvailabilityQuest.Always;
public int questId = -1;
public int quest2Id = -1;
public int quest3Id = -1;
public int quest4Id = -1;
public EnumDayTime daytime = EnumDayTime.Always;
public EnumDayTime daytime = EnumDayTime.Always;
public int factionId = -1;
public int faction2Id = -1;
public int factionId = -1;
public int faction2Id = -1;
public EnumAvailabilityFactionType factionAvailable = EnumAvailabilityFactionType.Always;
public EnumAvailabilityFactionType faction2Available = EnumAvailabilityFactionType.Always;
public EnumAvailabilityFactionType factionAvailable = EnumAvailabilityFactionType.Always;
public EnumAvailabilityFactionType faction2Available = EnumAvailabilityFactionType.Always;
public EnumAvailabilityFaction factionStance = EnumAvailabilityFaction.Friendly;
public EnumAvailabilityFaction faction2Stance = EnumAvailabilityFaction.Friendly;
public EnumAvailabilityFaction factionStance = EnumAvailabilityFaction.Friendly;
public EnumAvailabilityFaction faction2Stance = EnumAvailabilityFaction.Friendly;
public int minPlayerLevel = 0;
public int minPlayerLevel = 0;
public void readFromNBT(NBTTagCompound compound)
{
version = compound.getInteger("ModRev");
VersionCompatibility.CheckAvailabilityCompatibility(this, compound);
public void readFromNBT(NBTTagCompound compound) {
version = compound.getInteger("ModRev");
VersionCompatibility.CheckAvailabilityCompatibility(this, compound);
dialogAvailable = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog")];
dialog2Available = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog2")];
dialog3Available = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog3")];
dialog4Available = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog4")];
dialogAvailable = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog")];
dialog2Available = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog2")];
dialog3Available = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog3")];
dialog4Available = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog4")];
dialogId = compound.getInteger("AvailabilityDialogId");
dialog2Id = compound.getInteger("AvailabilityDialog2Id");
dialog3Id = compound.getInteger("AvailabilityDialog3Id");
dialog4Id = compound.getInteger("AvailabilityDialog4Id");
dialogId = compound.getInteger("AvailabilityDialogId");
dialog2Id = compound.getInteger("AvailabilityDialog2Id");
dialog3Id = compound.getInteger("AvailabilityDialog3Id");
dialog4Id = compound.getInteger("AvailabilityDialog4Id");
questAvailable = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest")];
quest2Available = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest2")];
quest3Available = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest3")];
quest4Available = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest4")];
questAvailable = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest")];
quest2Available = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest2")];
quest3Available = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest3")];
quest4Available = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest4")];
questId = compound.getInteger("AvailabilityQuestId");
quest2Id = compound.getInteger("AvailabilityQuest2Id");
quest3Id = compound.getInteger("AvailabilityQuest3Id");
quest4Id = compound.getInteger("AvailabilityQuest4Id");
questId = compound.getInteger("AvailabilityQuestId");
quest2Id = compound.getInteger("AvailabilityQuest2Id");
quest3Id = compound.getInteger("AvailabilityQuest3Id");
quest4Id = compound.getInteger("AvailabilityQuest4Id");
setFactionAvailability(compound.getInteger("AvailabilityFaction"));
setFactionAvailabilityStance(compound.getInteger("AvailabilityFactionStance"));
setFactionAvailability(compound.getInteger("AvailabilityFaction"));
setFactionAvailabilityStance(compound.getInteger("AvailabilityFactionStance"));
setFaction2Availability(compound.getInteger("AvailabilityFaction2"));
setFaction2AvailabilityStance(compound.getInteger("AvailabilityFaction2Stance"));
setFaction2Availability(compound.getInteger("AvailabilityFaction2"));
setFaction2AvailabilityStance(compound.getInteger("AvailabilityFaction2Stance"));
factionId = compound.getInteger("AvailabilityFactionId");
faction2Id = compound.getInteger("AvailabilityFaction2Id");
factionId = compound.getInteger("AvailabilityFactionId");
faction2Id = compound.getInteger("AvailabilityFaction2Id");
daytime = EnumDayTime.values()[compound.getInteger("AvailabilityDayTime")];
daytime = EnumDayTime.values()[compound.getInteger("AvailabilityDayTime")];
minPlayerLevel = compound.getInteger("AvailabilityMinPlayerLevel");
minPlayerLevel = compound.getInteger("AvailabilityMinPlayerLevel");
}
public NBTTagCompound writeToNBT(NBTTagCompound compound){
compound.setInteger("ModRev", version);
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setInteger("ModRev", version);
compound.setInteger("AvailabilityDialog", dialogAvailable.ordinal());
compound.setInteger("AvailabilityDialog2", dialog2Available.ordinal());
compound.setInteger("AvailabilityDialog3", dialog3Available.ordinal());
compound.setInteger("AvailabilityDialog4", dialog4Available.ordinal());
compound.setInteger("AvailabilityDialog", dialogAvailable.ordinal());
compound.setInteger("AvailabilityDialog2", dialog2Available.ordinal());
compound.setInteger("AvailabilityDialog3", dialog3Available.ordinal());
compound.setInteger("AvailabilityDialog4", dialog4Available.ordinal());
compound.setInteger("AvailabilityDialogId", dialogId);
compound.setInteger("AvailabilityDialog2Id", dialog2Id);
compound.setInteger("AvailabilityDialog3Id", dialog3Id);
compound.setInteger("AvailabilityDialog4Id", dialog4Id);
compound.setInteger("AvailabilityDialogId", dialogId);
compound.setInteger("AvailabilityDialog2Id", dialog2Id);
compound.setInteger("AvailabilityDialog3Id", dialog3Id);
compound.setInteger("AvailabilityDialog4Id", dialog4Id);
compound.setInteger("AvailabilityQuest", questAvailable.ordinal());
compound.setInteger("AvailabilityQuest2", quest2Available.ordinal());
compound.setInteger("AvailabilityQuest3", quest3Available.ordinal());
compound.setInteger("AvailabilityQuest4", quest4Available.ordinal());
compound.setInteger("AvailabilityQuest", questAvailable.ordinal());
compound.setInteger("AvailabilityQuest2", quest2Available.ordinal());
compound.setInteger("AvailabilityQuest3", quest3Available.ordinal());
compound.setInteger("AvailabilityQuest4", quest4Available.ordinal());
compound.setInteger("AvailabilityQuestId", questId);
compound.setInteger("AvailabilityQuest2Id", quest2Id);
compound.setInteger("AvailabilityQuest3Id", quest3Id);
compound.setInteger("AvailabilityQuest4Id", quest4Id);
compound.setInteger("AvailabilityQuestId", questId);
compound.setInteger("AvailabilityQuest2Id", quest2Id);
compound.setInteger("AvailabilityQuest3Id", quest3Id);
compound.setInteger("AvailabilityQuest4Id", quest4Id);
compound.setInteger("AvailabilityFaction", factionAvailable.ordinal());
compound.setInteger("AvailabilityFactionStance", factionStance.ordinal());
compound.setInteger("AvailabilityFaction", factionAvailable.ordinal());
compound.setInteger("AvailabilityFactionStance", factionStance.ordinal());
compound.setInteger("AvailabilityFactionId", factionId);
compound.setInteger("AvailabilityFactionId", factionId);
compound.setInteger("AvailabilityFaction2", faction2Available.ordinal());
compound.setInteger("AvailabilityFaction2Stance", faction2Stance.ordinal());
compound.setInteger("AvailabilityFaction2", faction2Available.ordinal());
compound.setInteger("AvailabilityFaction2Stance", faction2Stance.ordinal());
compound.setInteger("AvailabilityFaction2Id", faction2Id);
compound.setInteger("AvailabilityFaction2Id", faction2Id);
compound.setInteger("AvailabilityDayTime", daytime.ordinal());
compound.setInteger("AvailabilityMinPlayerLevel", minPlayerLevel);
return compound;
compound.setInteger("AvailabilityDayTime", daytime.ordinal());
compound.setInteger("AvailabilityMinPlayerLevel", minPlayerLevel);
return compound;
}
public boolean isDefault() {
@@ -155,58 +154,62 @@ public class Availability implements ICompatibilty, IAvailability {
minPlayerLevel == 0;
}
public void setFactionAvailability(int value) {
factionAvailable = EnumAvailabilityFactionType.values()[value];
}
public void setFaction2Availability(int value) {
faction2Available = EnumAvailabilityFactionType.values()[value];
}
public void setFactionAvailabilityStance(int integer) {
factionStance = EnumAvailabilityFaction.values()[integer];
}
public void setFaction2AvailabilityStance(int integer) {
faction2Stance = EnumAvailabilityFaction.values()[integer];
}
public boolean isAvailable(EntityPlayer player){
if(daytime == EnumDayTime.Day){
long time = player.worldObj.getWorldTime() % 24000;
if(time > 12000)
return false;
}
if(daytime == EnumDayTime.Night){
long time = player.worldObj.getWorldTime() % 24000;
if(time < 12000)
return false;
}
public void setFactionAvailability(int value) {
factionAvailable = EnumAvailabilityFactionType.values()[value];
}
if(!dialogAvailable(dialogId, dialogAvailable, player))
return false;
if(!dialogAvailable(dialog2Id, dialog2Available, player))
return false;
if(!dialogAvailable(dialog3Id, dialog3Available, player))
return false;
if(!dialogAvailable(dialog4Id, dialog4Available, player))
return false;
public void setFaction2Availability(int value) {
faction2Available = EnumAvailabilityFactionType.values()[value];
}
if(!questAvailable(questId, questAvailable, player))
return false;
if(!questAvailable(quest2Id, quest2Available, player))
return false;
if(!questAvailable(quest3Id, quest3Available, player))
return false;
if(!questAvailable(quest4Id, quest4Available, player))
return false;
public void setFactionAvailabilityStance(int integer) {
factionStance = EnumAvailabilityFaction.values()[integer];
}
if(!factionAvailable(factionId, factionStance, factionAvailable, player))
return false;
if(!factionAvailable(faction2Id, faction2Stance, faction2Available, player))
return false;
public void setFaction2AvailabilityStance(int integer) {
faction2Stance = EnumAvailabilityFaction.values()[integer];
}
if(player.experienceLevel < minPlayerLevel)
return false;
public boolean isAvailable(EntityPlayer player) {
if (daytime == EnumDayTime.Day) {
long time = player.worldObj.getWorldTime() % 24000;
if (time > 12000)
return false;
}
if (daytime == EnumDayTime.Night) {
long time = player.worldObj.getWorldTime() % 24000;
if (time < 12000)
return false;
}
return true;
}
if (!dialogAvailable(dialogId, dialogAvailable, player))
return false;
if (!dialogAvailable(dialog2Id, dialog2Available, player))
return false;
if (!dialogAvailable(dialog3Id, dialog3Available, player))
return false;
if (!dialogAvailable(dialog4Id, dialog4Available, player))
return false;
if (!questAvailable(questId, questAvailable, player))
return false;
if (!questAvailable(quest2Id, quest2Available, player))
return false;
if (!questAvailable(quest3Id, quest3Available, player))
return false;
if (!questAvailable(quest4Id, quest4Available, player))
return false;
if (!factionAvailable(factionId, factionStance, factionAvailable, player))
return false;
if (!factionAvailable(faction2Id, faction2Stance, faction2Available, player))
return false;
if (player.experienceLevel < minPlayerLevel)
return false;
return true;
}
@SideOnly(Side.CLIENT)
public List<String> isAvailableText(EntityPlayer player) {
@@ -266,241 +269,243 @@ public class Availability implements ICompatibilty, IAvailability {
return errors;
}
private boolean factionAvailable(int id, EnumAvailabilityFaction stance, EnumAvailabilityFactionType available, EntityPlayer player) {
if(available == EnumAvailabilityFactionType.Always)
return true;
private boolean factionAvailable(int id, EnumAvailabilityFaction stance, EnumAvailabilityFactionType available, EntityPlayer player) {
if (available == EnumAvailabilityFactionType.Always)
return true;
Faction faction = FactionController.getInstance().get(id);
if(faction == null)
return true;
Faction faction = FactionController.getInstance().get(id);
if (faction == null)
return true;
PlayerFactionData data = PlayerData.get(player).factionData;
int points = data.getFactionPoints(id);
PlayerFactionData data = PlayerData.get(player).factionData;
int points = data.getFactionPoints(id);
EnumAvailabilityFaction current = EnumAvailabilityFaction.Neutral;
if(faction.neutralPoints >= points)
current = EnumAvailabilityFaction.Hostile;
if(faction.friendlyPoints < points)
current = EnumAvailabilityFaction.Friendly;
EnumAvailabilityFaction current = EnumAvailabilityFaction.Neutral;
if (faction.neutralPoints >= points)
current = EnumAvailabilityFaction.Hostile;
if (faction.friendlyPoints < points)
current = EnumAvailabilityFaction.Friendly;
if(available == EnumAvailabilityFactionType.Is && stance == current){
return true;
}
if(available == EnumAvailabilityFactionType.IsNot && stance != current){
return true;
}
if (available == EnumAvailabilityFactionType.Is && stance == current) {
return true;
}
if (available == EnumAvailabilityFactionType.IsNot && stance != current) {
return true;
}
return false;
}
return false;
}
public boolean dialogAvailable(int id, EnumAvailabilityDialog en, EntityPlayer player){
if(player == null)
public boolean dialogAvailable(int id, EnumAvailabilityDialog en, EntityPlayer player) {
if (player == null)
return false;
if(en == EnumAvailabilityDialog.Always)
return true;
if (en == EnumAvailabilityDialog.Always)
return true;
PlayerData data = PlayerData.get(player);
if(data == null)
if (data == null)
return false;
boolean hasRead = data.dialogData.dialogsRead.contains(id);
if(hasRead && en == EnumAvailabilityDialog.After)
return true;
else if(!hasRead && en == EnumAvailabilityDialog.Before)
return true;
return false;
}
boolean hasRead = data.dialogData.dialogsRead.contains(id);
if (hasRead && en == EnumAvailabilityDialog.After)
return true;
else if (!hasRead && en == EnumAvailabilityDialog.Before)
return true;
return false;
}
public boolean questAvailable(int id, EnumAvailabilityQuest en, EntityPlayer player){
if(en == EnumAvailabilityQuest.Always)
return true;
else if(en == EnumAvailabilityQuest.After && PlayerQuestController.isQuestFinished(player, id))
return true;
else if(en == EnumAvailabilityQuest.Before && !PlayerQuestController.isQuestFinished(player, id))
return true;
else if(en == EnumAvailabilityQuest.Active && PlayerQuestController.isQuestActive(player, id))
return true;
else if(en == EnumAvailabilityQuest.NotActive && !PlayerQuestController.isQuestActive(player, id))
return true;
else if(en == EnumAvailabilityQuest.Acceptable || en == EnumAvailabilityQuest.NotAcceptable){
public boolean questAvailable(int id, EnumAvailabilityQuest en, EntityPlayer player) {
if (en == EnumAvailabilityQuest.Always)
return true;
else if (en == EnumAvailabilityQuest.After && PlayerQuestController.isQuestFinished(player, id))
return true;
else if (en == EnumAvailabilityQuest.Before && !PlayerQuestController.isQuestFinished(player, id))
return true;
else if (en == EnumAvailabilityQuest.Active && PlayerQuestController.isQuestActive(player, id))
return true;
else if (en == EnumAvailabilityQuest.NotActive && !PlayerQuestController.isQuestActive(player, id))
return true;
else if (en == EnumAvailabilityQuest.Acceptable || en == EnumAvailabilityQuest.NotAcceptable) {
Quest quest = QuestController.Instance.quests.get(id);
if(quest == null)
if (quest == null)
return true;
boolean result = PlayerQuestController.canQuestBeAccepted(quest, player);
return (result && en == EnumAvailabilityQuest.Acceptable) || (!result && en == EnumAvailabilityQuest.NotAcceptable);
}
return false;
}
@Override
public int getVersion() {
return version;
}
@Override
public void setVersion(int version) {
this.version = version;
}
return false;
}
public boolean isAvailable(IPlayer player) {
return this.isAvailable((EntityPlayer)player.getMCEntity());
}
@Override
public int getVersion() {
return version;
}
public int getDaytime() {
return this.daytime.ordinal();
}
@Override
public void setVersion(int version) {
this.version = version;
}
public void setDaytime(int type) {
this.daytime = EnumDayTime.values()[MathHelper.clamp_int(type, 0, 2)];
}
public boolean isAvailable(IPlayer player) {
return this.isAvailable((EntityPlayer) player.getMCEntity());
}
public int getMinPlayerLevel() {
return this.minPlayerLevel;
}
public int getDaytime() {
return this.daytime.ordinal();
}
public void setMinPlayerLevel(int level) {
this.minPlayerLevel = level;
}
public void setDaytime(int type) {
this.daytime = EnumDayTime.values()[MathHelper.clamp_int(type, 0, 2)];
}
public int getDialog(int i) {
if (i < 0 || i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else if (i == 0) {
return this.dialogId;
} else if (i == 1) {
return this.dialog2Id;
} else {
return i == 2 ? this.dialog3Id : this.dialog4Id;
}
}
public int getMinPlayerLevel() {
return this.minPlayerLevel;
}
public void setDialog(int i, int id, int type) {
if (i < 0 || i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else {
EnumAvailabilityDialog e = EnumAvailabilityDialog.values()[MathHelper.clamp_int(type, 0, 2)];
if (i == 0) {
this.dialogId = id;
this.dialogAvailable = e;
} else if (i == 1) {
this.dialog2Id = id;
this.dialog2Available = e;
} else if (i == 2) {
this.dialog3Id = id;
this.dialog3Available = e;
} else if (i == 3) {
this.dialog4Id = id;
this.dialog4Available = e;
}
public void setMinPlayerLevel(int level) {
this.minPlayerLevel = level;
}
}
}
public int getDialog(int i) {
if (i < 0 || i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else if (i == 0) {
return this.dialogId;
} else if (i == 1) {
return this.dialog2Id;
} else {
return i == 2 ? this.dialog3Id : this.dialog4Id;
}
}
public void removeDialog(int i) {
if (i < 0 || i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else {
if (i == 0) {
this.dialogId = -1;
this.dialogAvailable = EnumAvailabilityDialog.Always;
} else if (i == 1) {
this.dialog2Id = -1;
this.dialog2Available = EnumAvailabilityDialog.Always;
} else if (i == 2) {
this.dialog3Id = -1;
this.dialog3Available = EnumAvailabilityDialog.Always;
} else if (i == 3) {
this.dialog4Id = -1;
this.dialog4Available = EnumAvailabilityDialog.Always;
}
public void setDialog(int i, int id, int type) {
if (i < 0 || i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else {
EnumAvailabilityDialog e = EnumAvailabilityDialog.values()[MathHelper.clamp_int(type, 0, 2)];
if (i == 0) {
this.dialogId = id;
this.dialogAvailable = e;
} else if (i == 1) {
this.dialog2Id = id;
this.dialog2Available = e;
} else if (i == 2) {
this.dialog3Id = id;
this.dialog3Available = e;
} else if (i == 3) {
this.dialog4Id = id;
this.dialog4Available = e;
}
}
}
}
}
public int getQuest(int i) {
if (i < 0 || i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else if (i == 0) {
return this.questId;
} else if (i == 1) {
return this.quest2Id;
} else {
return i == 2 ? this.quest3Id : this.quest4Id;
}
}
public void removeDialog(int i) {
if (i < 0 || i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else {
if (i == 0) {
this.dialogId = -1;
this.dialogAvailable = EnumAvailabilityDialog.Always;
} else if (i == 1) {
this.dialog2Id = -1;
this.dialog2Available = EnumAvailabilityDialog.Always;
} else if (i == 2) {
this.dialog3Id = -1;
this.dialog3Available = EnumAvailabilityDialog.Always;
} else if (i == 3) {
this.dialog4Id = -1;
this.dialog4Available = EnumAvailabilityDialog.Always;
}
public void setQuest(int i, int id, int type) {
if (i < 0 || i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else {
EnumAvailabilityQuest e = EnumAvailabilityQuest.values()[MathHelper.clamp_int(type, 0, 5)];
if (i == 0) {
this.questId = id;
this.questAvailable = e;
} else if (i == 1) {
this.quest2Id = id;
this.quest2Available = e;
} else if (i == 2) {
this.quest3Id = id;
this.quest3Available = e;
} else if (i == 3) {
this.quest4Id = id;
this.quest4Available = e;
}
}
}
}
}
public int getQuest(int i) {
if (i < 0 || i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else if (i == 0) {
return this.questId;
} else if (i == 1) {
return this.quest2Id;
} else {
return i == 2 ? this.quest3Id : this.quest4Id;
}
}
public void removeQuest(int i) {
if (i < 0 || i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else {
if (i == 0) {
this.questId = -1;
this.questAvailable = EnumAvailabilityQuest.Always;
} else if (i == 1) {
this.quest2Id = -1;
this.quest2Available = EnumAvailabilityQuest.Always;
} else if (i == 2) {
this.quest3Id = -1;
this.quest3Available = EnumAvailabilityQuest.Always;
} else if (i == 3) {
this.quest4Id = -1;
this.quest4Available = EnumAvailabilityQuest.Always;
}
public void setQuest(int i, int id, int type) {
if (i < 0 || i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else {
EnumAvailabilityQuest e = EnumAvailabilityQuest.values()[MathHelper.clamp_int(type, 0, 5)];
if (i == 0) {
this.questId = id;
this.questAvailable = e;
} else if (i == 1) {
this.quest2Id = id;
this.quest2Available = e;
} else if (i == 2) {
this.quest3Id = id;
this.quest3Available = e;
} else if (i == 3) {
this.quest4Id = id;
this.quest4Available = e;
}
}
}
}
}
public void setFaction(int i, int id, int type, int stance) {
if (i < 0 || i > 1) {
throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]);
} else {
EnumAvailabilityFactionType e = EnumAvailabilityFactionType.values()[MathHelper.clamp_int(type, 0, 2)];
EnumAvailabilityFaction ee = EnumAvailabilityFaction.values()[MathHelper.clamp_int(stance, 0, 2)];
if (i == 0) {
this.factionId = id;
this.factionAvailable = e;
this.factionStance = ee;
} else if (i == 1) {
this.faction2Id = id;
this.faction2Available = e;
this.faction2Stance = ee;
}
public void removeQuest(int i) {
if (i < 0 || i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else {
if (i == 0) {
this.questId = -1;
this.questAvailable = EnumAvailabilityQuest.Always;
} else if (i == 1) {
this.quest2Id = -1;
this.quest2Available = EnumAvailabilityQuest.Always;
} else if (i == 2) {
this.quest3Id = -1;
this.quest3Available = EnumAvailabilityQuest.Always;
} else if (i == 3) {
this.quest4Id = -1;
this.quest4Available = EnumAvailabilityQuest.Always;
}
}
}
}
}
public void removeFaction(int i) {
if (i < 0 || i > 1) {
throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]);
} else {
if (i == 0) {
this.factionId = -1;
this.factionAvailable = EnumAvailabilityFactionType.Always;
this.factionStance = EnumAvailabilityFaction.Friendly;
} else if (i == 1) {
this.faction2Id = -1;
this.faction2Available = EnumAvailabilityFactionType.Always;
this.faction2Stance = EnumAvailabilityFaction.Friendly;
}
public void setFaction(int i, int id, int type, int stance) {
if (i < 0 || i > 1) {
throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]);
} else {
EnumAvailabilityFactionType e = EnumAvailabilityFactionType.values()[MathHelper.clamp_int(type, 0, 2)];
EnumAvailabilityFaction ee = EnumAvailabilityFaction.values()[MathHelper.clamp_int(stance, 0, 2)];
if (i == 0) {
this.factionId = id;
this.factionAvailable = e;
this.factionStance = ee;
} else if (i == 1) {
this.faction2Id = id;
this.faction2Available = e;
this.faction2Stance = ee;
}
}
}
}
}
public void removeFaction(int i) {
if (i < 0 || i > 1) {
throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]);
} else {
if (i == 0) {
this.factionId = -1;
this.factionAvailable = EnumAvailabilityFactionType.Always;
this.factionStance = EnumAvailabilityFaction.Friendly;
} else if (i == 1) {
this.faction2Id = -1;
this.faction2Available = EnumAvailabilityFactionType.Always;
this.faction2Stance = EnumAvailabilityFaction.Friendly;
}
}
}
}
@@ -8,56 +8,57 @@ import java.util.HashMap;
public class Bank {
public int id = -1;
public String name = "";
public HashMap<Integer,Integer> slotTypes;
public int startSlots = 1;
public int maxSlots = 6;
public NpcMiscInventory currencyInventory;
public NpcMiscInventory upgradeInventory;
public Bank(){
slotTypes = new HashMap<Integer, Integer>();
currencyInventory = new NpcMiscInventory(6);
upgradeInventory = new NpcMiscInventory(6);
for(int i = 0; i < 6; i++)
slotTypes.put(i, 0);
}
public void writeEntityToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger("BankID", id);
nbttagcompound.setTag("BankCurrency", currencyInventory.getToNBT());
nbttagcompound.setTag("BankUpgrade", upgradeInventory.getToNBT());
nbttagcompound.setString("Username", name);
nbttagcompound.setInteger("MaxSlots", maxSlots);
nbttagcompound.setInteger("StartSlots", startSlots);
nbttagcompound.setTag("BankTypes", NBTTags.nbtIntegerIntegerMap(slotTypes));
}
public int id = -1;
public String name = "";
public HashMap<Integer, Integer> slotTypes;
public int startSlots = 1;
public int maxSlots = 6;
public NpcMiscInventory currencyInventory;
public NpcMiscInventory upgradeInventory;
public void readEntityFromNBT(NBTTagCompound nbttagcompound) {
id = nbttagcompound.getInteger("BankID");
public Bank() {
slotTypes = new HashMap<Integer, Integer>();
currencyInventory = new NpcMiscInventory(6);
upgradeInventory = new NpcMiscInventory(6);
for (int i = 0; i < 6; i++)
slotTypes.put(i, 0);
}
public void writeEntityToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger("BankID", id);
nbttagcompound.setTag("BankCurrency", currencyInventory.getToNBT());
nbttagcompound.setTag("BankUpgrade", upgradeInventory.getToNBT());
nbttagcompound.setString("Username", name);
nbttagcompound.setInteger("MaxSlots", maxSlots);
nbttagcompound.setInteger("StartSlots", startSlots);
nbttagcompound.setTag("BankTypes", NBTTags.nbtIntegerIntegerMap(slotTypes));
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound) {
id = nbttagcompound.getInteger("BankID");
name = nbttagcompound.getString("Username");
startSlots = nbttagcompound.getInteger("StartSlots");
maxSlots = nbttagcompound.getInteger("MaxSlots");
slotTypes = NBTTags.getIntegerIntegerMap(nbttagcompound.getTagList("BankTypes", 10));
currencyInventory.setFromNBT(nbttagcompound.getCompoundTag("BankCurrency"));
upgradeInventory.setFromNBT(nbttagcompound.getCompoundTag("BankUpgrade"));
}
public boolean isUpgraded(int slot){
return slotTypes.get(slot) != null && slotTypes.get(slot) == 2;
}
currencyInventory.setFromNBT(nbttagcompound.getCompoundTag("BankCurrency"));
upgradeInventory.setFromNBT(nbttagcompound.getCompoundTag("BankUpgrade"));
}
public boolean canBeUpgraded(int slot) {
if(upgradeInventory.getStackInSlot(slot) == null)
return false;
return slotTypes.get(slot) == null || slotTypes.get(slot) == 0;
}
public boolean isUpgraded(int slot) {
return slotTypes.get(slot) != null && slotTypes.get(slot) == 2;
}
public int getMaxSlots() {
for(int i = 0; i < maxSlots; i++){
if(currencyInventory.getStackInSlot(i) == null && i > startSlots-1)
return i;
}
return maxSlots;
}
public boolean canBeUpgraded(int slot) {
if (upgradeInventory.getStackInSlot(slot) == null)
return false;
return slotTypes.get(slot) == null || slotTypes.get(slot) == 0;
}
public int getMaxSlots() {
for (int i = 0; i < maxSlots; i++) {
if (currencyInventory.getStackInSlot(i) == null && i > startSlots - 1)
return i;
}
return maxSlots;
}
}
@@ -18,103 +18,105 @@ import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashMap;
public class BankData {
public HashMap<Integer,NpcMiscInventory> itemSlots;
public HashMap<Integer,Boolean> upgradedSlots;
public int unlockedSlots = 0;
public int bankId = -1;
public HashMap<Integer, NpcMiscInventory> itemSlots;
public HashMap<Integer, Boolean> upgradedSlots;
public int unlockedSlots = 0;
public int bankId = -1;
public BankData(){
itemSlots = new HashMap<Integer,NpcMiscInventory>();
upgradedSlots = new HashMap<Integer,Boolean>();
public BankData() {
itemSlots = new HashMap<Integer, NpcMiscInventory>();
upgradedSlots = new HashMap<Integer, Boolean>();
for(int i = 0; i < 6; i++){
itemSlots.put(i, new NpcMiscInventory(54));
upgradedSlots.put(i, false);
}
}
public void readNBT(NBTTagCompound nbttagcompound) {
bankId = nbttagcompound.getInteger("DataBankId");
for (int i = 0; i < 6; i++) {
itemSlots.put(i, new NpcMiscInventory(54));
upgradedSlots.put(i, false);
}
}
public void readNBT(NBTTagCompound nbttagcompound) {
bankId = nbttagcompound.getInteger("DataBankId");
unlockedSlots = nbttagcompound.getInteger("UnlockedSlots");
itemSlots = getItemSlots(nbttagcompound.getTagList("BankInv", 10));
upgradedSlots = NBTTags.getBooleanList(nbttagcompound.getTagList("UpdatedSlots", 10));
}
private HashMap<Integer, NpcMiscInventory> getItemSlots(NBTTagList tagList) {
HashMap<Integer,NpcMiscInventory> list = new HashMap<Integer,NpcMiscInventory>();
for(int i = 0; i < tagList.tagCount(); i++)
{
}
private HashMap<Integer, NpcMiscInventory> getItemSlots(NBTTagList tagList) {
HashMap<Integer, NpcMiscInventory> list = new HashMap<Integer, NpcMiscInventory>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
int slot = nbttagcompound.getInteger("Slot");
NpcMiscInventory inv = new NpcMiscInventory(54);
inv.setFromNBT(nbttagcompound.getCompoundTag("BankItems"));
list.put(slot, inv);
}
return list;
}
public void writeNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger("DataBankId", bankId);
nbttagcompound.setInteger("UnlockedSlots", unlockedSlots);
nbttagcompound.setTag("UpdatedSlots", NBTTags.nbtBooleanList(upgradedSlots));
nbttagcompound.setTag("BankInv", nbtItemSlots(itemSlots));
}
private NBTTagList nbtItemSlots(HashMap<Integer, NpcMiscInventory> items) {
NBTTagList list = new NBTTagList();
for(int slot: items.keySet()){
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Slot", slot);
return list;
}
nbttagcompound.setTag("BankItems",items.get(slot).getToNBT());
list.appendTag(nbttagcompound);
}
return list;
}
public boolean isUpgraded(Bank bank, int slot) {
if(bank.isUpgraded(slot))
return true;
return bank.canBeUpgraded(slot) && upgradedSlots.get(slot);
}
public void writeNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger("DataBankId", bankId);
nbttagcompound.setInteger("UnlockedSlots", unlockedSlots);
nbttagcompound.setTag("UpdatedSlots", NBTTags.nbtBooleanList(upgradedSlots));
nbttagcompound.setTag("BankInv", nbtItemSlots(itemSlots));
}
public void openBankGui(final EntityPlayer player, EntityNPCInterface npc, int bankId, int slot) {
final Bank bank = BankController.getInstance().getBank(bankId);
private NBTTagList nbtItemSlots(HashMap<Integer, NpcMiscInventory> items) {
NBTTagList list = new NBTTagList();
for (int slot : items.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Slot", slot);
if(bank.getMaxSlots() <= slot)
return;
nbttagcompound.setTag("BankItems", items.get(slot).getToNBT());
list.appendTag(nbttagcompound);
}
return list;
}
if(bank.startSlots > unlockedSlots)
unlockedSlots = bank.startSlots;
public boolean isUpgraded(Bank bank, int slot) {
if (bank.isUpgraded(slot))
return true;
return bank.canBeUpgraded(slot) && upgradedSlots.get(slot);
}
ItemStack currency = null;
if(unlockedSlots <= slot){
currency = bank.currencyInventory.getStackInSlot(slot);
NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankUnlock, npc, slot, bank.id, 0);
}
else if(isUpgraded(bank,slot)){
NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankLarge, npc, slot, bank.id, 0);
}
else if(bank.canBeUpgraded(slot)){
currency = bank.upgradeInventory.getStackInSlot(slot);
NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankUprade, npc, slot, bank.id, 0);
}
else{
NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankSmall, npc, slot, bank.id, 0);
}
final ItemStack item = currency;
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("MaxSlots", bank.getMaxSlots());
compound.setInteger("UnlockedSlots", unlockedSlots);
if (item != null) {
compound.setTag("Currency", NoppesUtilServer.writeItem(item, new NBTTagCompound()));
ContainerNPCBankInterface container = getContainer(player);
if (container != null)
container.setCurrency(item);
}
public void openBankGui(final EntityPlayer player, EntityNPCInterface npc, int bankId, int slot) {
final Bank bank = BankController.getInstance().getBank(bankId);
if (bank.getMaxSlots() <= slot)
return;
if (bank.startSlots > unlockedSlots)
unlockedSlots = bank.startSlots;
ItemStack currency = null;
if (unlockedSlots <= slot) {
currency = bank.currencyInventory.getStackInSlot(slot);
NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankUnlock, npc, slot, bank.id, 0);
} else if (isUpgraded(bank, slot)) {
NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankLarge, npc, slot, bank.id, 0);
} else if (bank.canBeUpgraded(slot)) {
currency = bank.upgradeInventory.getStackInSlot(slot);
NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankUprade, npc, slot, bank.id, 0);
} else {
NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankSmall, npc, slot, bank.id, 0);
}
final ItemStack item = currency;
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("MaxSlots", bank.getMaxSlots());
compound.setInteger("UnlockedSlots", unlockedSlots);
if (item != null) {
compound.setTag("Currency", NoppesUtilServer.writeItem(item, new NBTTagCompound()));
ContainerNPCBankInterface container = getContainer(player);
if (container != null)
container.setCurrency(item);
}
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
}
private ContainerNPCBankInterface getContainer(EntityPlayer player){
Container con = player.openContainer;
if(con == null || !(con instanceof ContainerNPCBankInterface))
return null;
}
return (ContainerNPCBankInterface) con;
}
private ContainerNPCBankInterface getContainer(EntityPlayer player) {
Container con = player.openContainer;
if (con == null || !(con instanceof ContainerNPCBankInterface))
return null;
return (ContainerNPCBankInterface) con;
}
}
@@ -35,7 +35,8 @@ public class CustomEffect implements ICustomEffect {
public int index = 0;
public CustomEffect() {}
public CustomEffect() {
}
public CustomEffect(int id) {
this.id = id;
@@ -298,6 +299,7 @@ public class CustomEffect implements ICustomEffect {
public EffectScript getScriptHandler() {
return CustomEffectController.getInstance().customEffectScriptHandlers.get(this.id);
}
public void setScriptHandler(EffectScript handler) {
CustomEffectController.getInstance().customEffectScriptHandlers.put(this.id, handler);
}
@@ -305,7 +307,7 @@ public class CustomEffect implements ICustomEffect {
public EffectScript getOrCreateScriptHandler() {
EffectScript data = getScriptHandler();
if (data == null)
setScriptHandler(data =new EffectScript());
setScriptHandler(data = new EffectScript());
return data;
}
@@ -30,279 +30,280 @@ import javax.script.ScriptEngine;
import java.util.*;
public class DataScript implements INpcScriptHandler {
public List<ScriptContainer> eventScripts = new ArrayList<>();
public List<ScriptContainer> eventScripts = new ArrayList<>();
private HashMap<EnumScriptType,ScriptContainer> scripts = new HashMap<>();
private final static EntityType entities = new EntityType();
private final static JobType jobs = new JobType();
private final static RoleType roles = new RoleType();
private HashMap<EnumScriptType, ScriptContainer> scripts = new HashMap<>();
private final static EntityType entities = new EntityType();
private final static JobType jobs = new JobType();
private final static RoleType roles = new RoleType();
public String scriptLanguage = "ECMAScript";
private EntityNPCInterface npc;
public boolean enabled = false;
public String scriptLanguage = "ECMAScript";
private EntityNPCInterface npc;
public boolean enabled = false;
public ICustomNpc dummyNpc;
public IWorld dummyWorld;
public boolean clientNeedsUpdate = false;
public boolean aiNeedsUpdate = false;
public boolean hasInited = false;
public ICustomNpc dummyNpc;
public IWorld dummyWorld;
public boolean clientNeedsUpdate = false;
public boolean aiNeedsUpdate = false;
public boolean hasInited = false;
public DataScript(EntityNPCInterface npc) {
for (int i = 0; i < 15; i++) {
this.setNPCScript(i, new ScriptContainer(this));
}
public DataScript(EntityNPCInterface npc) {
for (int i = 0; i < 15; i++) {
this.setNPCScript(i, new ScriptContainer(this));
}
this.npc = npc;
if (npc.wrappedNPC == null) {
npc.wrappedNPC = new ScriptNpc(this.npc);
}
dummyNpc = npc.wrappedNPC;
this.npc = npc;
if (npc.wrappedNPC == null) {
npc.wrappedNPC = new ScriptNpc(this.npc);
}
dummyNpc = npc.wrappedNPC;
if(npc.worldObj instanceof WorldServer)
dummyWorld = NpcAPI.Instance().getIWorld((WorldServer) npc.worldObj);//new ScriptWorld((WorldServer) npc.worldObj);
}
if (npc.worldObj instanceof WorldServer)
dummyWorld = NpcAPI.Instance().getIWorld((WorldServer) npc.worldObj);//new ScriptWorld((WorldServer) npc.worldObj);
}
public void readFromNBT(NBTTagCompound compound) {
scripts = readScript(compound.getTagList("ScriptsContainers", 10));
this.scriptLanguage = compound.getString("ScriptLanguage");
if (!ScriptController.Instance.languages.containsKey(scriptLanguage)) {
if (!ScriptController.Instance.languages.isEmpty()) {
this.scriptLanguage = (String) ScriptController.Instance.languages.keySet().toArray()[0];
} else {
this.scriptLanguage = "ECMAScript";
}
}
public void readFromNBT(NBTTagCompound compound) {
scripts = readScript(compound.getTagList("ScriptsContainers", 10));
this.scriptLanguage = compound.getString("ScriptLanguage");
if (!ScriptController.Instance.languages.containsKey(scriptLanguage)) {
if (!ScriptController.Instance.languages.isEmpty()) {
this.scriptLanguage = (String) ScriptController.Instance.languages.keySet().toArray()[0];
} else {
this.scriptLanguage = "ECMAScript";
}
}
enabled = compound.getBoolean("ScriptEnabled");
}
enabled = compound.getBoolean("ScriptEnabled");
}
public void readEventsFromNBT(NBTTagCompound compound) {
eventScripts = NBTTags.GetScript(compound,this);
}
public void readEventsFromNBT(NBTTagCompound compound) {
eventScripts = NBTTags.GetScript(compound, this);
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setTag("ScriptsContainers", writeScript(scripts));
compound.setString("ScriptLanguage", scriptLanguage);
compound.setBoolean("ScriptEnabled", enabled);
return compound;
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setTag("ScriptsContainers", writeScript(scripts));
compound.setString("ScriptLanguage", scriptLanguage);
compound.setBoolean("ScriptEnabled", enabled);
return compound;
}
public NBTTagCompound writeEventsToNBT(NBTTagCompound compound) {
compound.setInteger("TotalScripts",this.eventScripts.size());
for (int i = 0; i < this.eventScripts.size(); i++) {
compound.setTag("Tab"+i,this.eventScripts.get(i).writeToNBT(new NBTTagCompound()));
}
return compound;
}
public NBTTagCompound writeEventsToNBT(NBTTagCompound compound) {
compound.setInteger("TotalScripts", this.eventScripts.size());
for (int i = 0; i < this.eventScripts.size(); i++) {
compound.setTag("Tab" + i, this.eventScripts.get(i).writeToNBT(new NBTTagCompound()));
}
return compound;
}
private HashMap<EnumScriptType,ScriptContainer> readScript(NBTTagList list){
HashMap<EnumScriptType,ScriptContainer> scripts = new HashMap<>();
for (int i = 0; i < 15; i++) {
scripts.put(EnumScriptType.values()[i], new ScriptContainer(this));
}
private HashMap<EnumScriptType, ScriptContainer> readScript(NBTTagList list) {
HashMap<EnumScriptType, ScriptContainer> scripts = new HashMap<>();
for (int i = 0; i < 15; i++) {
scripts.put(EnumScriptType.values()[i], new ScriptContainer(this));
}
for(int i = 0; i < list.tagCount(); i++){
NBTTagCompound compoundd = list.getCompoundTagAt(i);
ScriptContainer script = new ScriptContainer(this);
script.readFromNBT(compoundd);
if (script.hasCode() || npc.isRemote()) {
scripts.put(EnumScriptType.values()[compoundd.getInteger("Type")], script);
}
}
return scripts;
}
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound compoundd = list.getCompoundTagAt(i);
ScriptContainer script = new ScriptContainer(this);
script.readFromNBT(compoundd);
if (script.hasCode() || npc.isRemote()) {
scripts.put(EnumScriptType.values()[compoundd.getInteger("Type")], script);
}
}
return scripts;
}
private NBTTagList writeScript(HashMap<EnumScriptType,ScriptContainer> scripts){
NBTTagList list = new NBTTagList();
for (Map.Entry<EnumScriptType,ScriptContainer> entry : scripts.entrySet()) {
NBTTagCompound tagCompound = new NBTTagCompound();
ScriptContainer container = entry.getValue();
if (container.hasCode()) {
tagCompound.setInteger("Type", entry.getKey().ordinal());
container.writeToNBT(tagCompound);
list.appendTag(tagCompound);
}
}
return list;
}
private NBTTagList writeScript(HashMap<EnumScriptType, ScriptContainer> scripts) {
NBTTagList list = new NBTTagList();
for (Map.Entry<EnumScriptType, ScriptContainer> entry : scripts.entrySet()) {
NBTTagCompound tagCompound = new NBTTagCompound();
ScriptContainer container = entry.getValue();
if (container.hasCode()) {
tagCompound.setInteger("Type", entry.getKey().ordinal());
container.writeToNBT(tagCompound);
list.appendTag(tagCompound);
}
}
return list;
}
public boolean callScript(EnumScriptType type, Event event, Object... obs){
if(aiNeedsUpdate){
npc.updateAI = true;
aiNeedsUpdate = false;
}
if(clientNeedsUpdate){
npc.updateClient = true;
clientNeedsUpdate = false;
}
if(!isEnabled())
return false;
public boolean callScript(EnumScriptType type, Event event, Object... obs) {
if (aiNeedsUpdate) {
npc.updateAI = true;
aiNeedsUpdate = false;
}
if (clientNeedsUpdate) {
npc.updateClient = true;
clientNeedsUpdate = false;
}
if (!isEnabled())
return false;
if(!hasInited && !npc.isRemote() && type != EnumScriptType.INIT){
hasInited = true;
for (ScriptContainer scriptContainer : this.eventScripts) {
scriptContainer.errored = false;
}
EventHooks.onNPCInit(this.npc);
}
if (!hasInited && !npc.isRemote() && type != EnumScriptType.INIT) {
hasInited = true;
for (ScriptContainer scriptContainer : this.eventScripts) {
scriptContainer.errored = false;
}
EventHooks.onNPCInit(this.npc);
}
for (ScriptContainer script : this.eventScripts) {
script.run(type, event);
}
for (ScriptContainer script : this.eventScripts) {
script.run(type, event);
}
ScriptContainer script = scripts.get(type);
if(script == null || script.errored || !script.hasCode())
return false;
ScriptContainer script = scripts.get(type);
if (script == null || script.errored || !script.hasCode())
return false;
script.setEngine(this.getLanguage());
if(script.engine == null)
return false;
script.setEngine(this.getLanguage());
if (script.engine == null)
return false;
for(int i = 0; i + 1 < obs.length; i += 2){
Object ob = obs[i + 1];
if(ob instanceof Entity)
ob = NpcAPI.Instance().getIEntity((Entity)ob);
script.engine.put(obs[i].toString(), ob);
}
if(ConfigDebug.ScriptLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
if(obs.length > 1 && obs[1] == null){
LogWriter.postScriptLog(npc.field_110179_h, type, String.format("[%s] NPC %s (%s, %s, %s)", ((String)type.function).toUpperCase(), npc.display.name, (int)npc.posX, (int)npc.posY, (int)npc.posZ));
} else {
LogWriter.postScriptLog(npc.field_110179_h, type, String.format("[%s] NPC %s (%s, %s, %s) | Objects: %s", ((String)type.function).toUpperCase(), npc.display.name, (int)npc.posX, (int)npc.posY, (int)npc.posZ, Arrays.toString(obs)));
}
}
return callScript(script, event);
}
for (int i = 0; i + 1 < obs.length; i += 2) {
Object ob = obs[i + 1];
if (ob instanceof Entity)
ob = NpcAPI.Instance().getIEntity((Entity) ob);
script.engine.put(obs[i].toString(), ob);
}
if (ConfigDebug.ScriptLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
if (obs.length > 1 && obs[1] == null) {
LogWriter.postScriptLog(npc.field_110179_h, type, String.format("[%s] NPC %s (%s, %s, %s)", ((String) type.function).toUpperCase(), npc.display.name, (int) npc.posX, (int) npc.posY, (int) npc.posZ));
} else {
LogWriter.postScriptLog(npc.field_110179_h, type, String.format("[%s] NPC %s (%s, %s, %s) | Objects: %s", ((String) type.function).toUpperCase(), npc.display.name, (int) npc.posX, (int) npc.posY, (int) npc.posZ, Arrays.toString(obs)));
}
}
return callScript(script, event);
}
private boolean callScript(ScriptContainer script, Event event){
ScriptEngine engine = script.engine;
engine.put("npc", dummyNpc);
engine.put("world", dummyWorld);
engine.put("event", event);
engine.put("API", NpcAPI.Instance());
engine.put("EntityType", entities);
engine.put("RoleType", roles);
engine.put("JobType", jobs);
for (Map.Entry<String,Object> engineObjects : NpcAPI.engineObjects.entrySet()) {
engine.put(engineObjects.getKey(),engineObjects.getValue());
}
script.run(engine);
private boolean callScript(ScriptContainer script, Event event) {
ScriptEngine engine = script.engine;
engine.put("npc", dummyNpc);
engine.put("world", dummyWorld);
engine.put("event", event);
engine.put("API", NpcAPI.Instance());
engine.put("EntityType", entities);
engine.put("RoleType", roles);
engine.put("JobType", jobs);
for (Map.Entry<String, Object> engineObjects : NpcAPI.engineObjects.entrySet()) {
engine.put(engineObjects.getKey(), engineObjects.getValue());
}
script.run(engine);
if(clientNeedsUpdate){
npc.updateClient = true;
clientNeedsUpdate = false;
}
if(aiNeedsUpdate){
npc.updateAI = true;
aiNeedsUpdate = false;
}
return event.isCanceled();
}
if (clientNeedsUpdate) {
npc.updateClient = true;
clientNeedsUpdate = false;
}
if (aiNeedsUpdate) {
npc.updateAI = true;
aiNeedsUpdate = false;
}
return event.isCanceled();
}
public boolean isEnabled(){
return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty() && ConfigScript.ScriptingEnabled;
}
public boolean isEnabled() {
return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty() && ConfigScript.ScriptingEnabled;
}
public Map<Long, String> getOldConsoleText() {
Map<Long, String> map = new TreeMap<>();
public Map<Long, String> getOldConsoleText() {
Map<Long, String> map = new TreeMap<>();
for (Map.Entry<EnumScriptType,ScriptContainer> entry : scripts.entrySet()) {
for (Map.Entry<Long,String> consoleEntry : entry.getValue().console.entrySet()) {
map.put(consoleEntry.getKey(), " tab " + entry.getKey().ordinal() + ":\n" + consoleEntry.getValue());
}
}
for (Map.Entry<EnumScriptType, ScriptContainer> entry : scripts.entrySet()) {
for (Map.Entry<Long, String> consoleEntry : entry.getValue().console.entrySet()) {
map.put(consoleEntry.getKey(), " tab " + entry.getKey().ordinal() + ":\n" + consoleEntry.getValue());
}
}
return map;
}
return map;
}
public Map<Long, String> getConsoleText() {
TreeMap<Long, String> map = new TreeMap<>();
int tab = 0;
for (ScriptContainer script : this.getScripts()) {
++tab;
public Map<Long, String> getConsoleText() {
TreeMap<Long, String> map = new TreeMap<>();
int tab = 0;
for (ScriptContainer script : this.getScripts()) {
++tab;
for (Map.Entry<Long, String> longStringEntry : script.console.entrySet()) {
map.put(longStringEntry.getKey(), " tab " + tab + ":\n" + longStringEntry.getValue());
}
}
return map;
}
for (Map.Entry<Long, String> longStringEntry : script.console.entrySet()) {
map.put(longStringEntry.getKey(), " tab " + tab + ":\n" + longStringEntry.getValue());
}
}
return map;
}
public void clearConsole() {
for (ScriptContainer script : this.getScripts()) {
script.console.clear();
}
}
public void clearConsole() {
for (ScriptContainer script : this.getScripts()) {
script.console.clear();
}
}
@Override
public void callScript(EnumScriptType type, Event event) {
callScript(type, event, "$$IGNORED$$", null);
}
@Override
public void callScript(EnumScriptType type, Event event) {
callScript(type, event, "$$IGNORED$$", null);
}
@Override
public void callScript(String hookName, Event event) {
try {
EnumScriptType enumScriptType = EnumScriptType.valueOf(hookName);
this.callScript(enumScriptType, event);
} catch (IllegalArgumentException ignored) {}
}
@Override
public void callScript(String hookName, Event event) {
try {
EnumScriptType enumScriptType = EnumScriptType.valueOf(hookName);
this.callScript(enumScriptType, event);
} catch (IllegalArgumentException ignored) {
}
}
public boolean isClient() {
return this.npc.isRemote();
}
public boolean isClient() {
return this.npc.isRemote();
}
public boolean getEnabled() {
return this.enabled;
}
public boolean getEnabled() {
return this.enabled;
}
public void setEnabled(boolean bo) {
this.enabled = bo;
}
public void setEnabled(boolean bo) {
this.enabled = bo;
}
public String getLanguage() {
return this.scriptLanguage;
}
public String getLanguage() {
return this.scriptLanguage;
}
public void setLanguage(String lang) {
this.scriptLanguage = lang;
}
public void setLanguage(String lang) {
this.scriptLanguage = lang;
}
public void setScripts(List<ScriptContainer> list) {
this.eventScripts = list;
}
public void setScripts(List<ScriptContainer> list) {
this.eventScripts = list;
}
public List<ScriptContainer> getScripts() {
return this.eventScripts;
}
public List<ScriptContainer> getScripts() {
return this.eventScripts;
}
public String noticeString() {
//BlockPos pos = this.npc.func_180425_c();
//return MoreObjects.toStringHelper(this.npc).add("x", pos.func_177958_n()).add("y", pos.func_177956_o()).add("z", pos.func_177952_p()).toString();
return "";
}
public String noticeString() {
//BlockPos pos = this.npc.func_180425_c();
//return MoreObjects.toStringHelper(this.npc).add("x", pos.func_177958_n()).add("y", pos.func_177956_o()).add("z", pos.func_177952_p()).toString();
return "";
}
public void setWorld(World world) {
if(world instanceof WorldServer)
dummyWorld = new ScriptWorld((WorldServer) world);
}
public void setWorld(World world) {
if (world instanceof WorldServer)
dummyWorld = new ScriptWorld((WorldServer) world);
}
public ScriptContainer getNPCScript(EnumScriptType scriptType) {
return this.scripts.get(scriptType);
}
public ScriptContainer getNPCScript(EnumScriptType scriptType) {
return this.scripts.get(scriptType);
}
public ScriptContainer getNPCScript(int ordinal) {
return this.getNPCScript(EnumScriptType.values()[ordinal]);
}
public ScriptContainer getNPCScript(int ordinal) {
return this.getNPCScript(EnumScriptType.values()[ordinal]);
}
public void setNPCScript(EnumScriptType scriptType, ScriptContainer container) {
this.scripts.put(scriptType, container);
}
public void setNPCScript(EnumScriptType scriptType, ScriptContainer container) {
this.scripts.put(scriptType, container);
}
public void setNPCScript(int ordinal, ScriptContainer container) {
this.setNPCScript(EnumScriptType.values()[ordinal], container);
}
public void setNPCScript(int ordinal, ScriptContainer container) {
this.setNPCScript(EnumScriptType.values()[ordinal], container);
}
public Collection<ScriptContainer> getNPCScripts() {
return this.scripts.values();
}
public Collection<ScriptContainer> getNPCScripts() {
return this.scripts.values();
}
}
@@ -11,229 +11,230 @@ import noppes.npcs.entity.EntityNPCInterface;
import java.util.Set;
public class DataTransform {
public NBTTagCompound display;
public NBTTagCompound ai;
public NBTTagCompound advanced;
public NBTTagCompound inv;
public NBTTagCompound stats;
public NBTTagCompound role;
public NBTTagCompound job;
public NBTTagCompound display;
public NBTTagCompound ai;
public NBTTagCompound advanced;
public NBTTagCompound inv;
public NBTTagCompound stats;
public NBTTagCompound role;
public NBTTagCompound job;
public boolean hasDisplay, hasAi, hasAdvanced, hasInv, hasStats, hasRole, hasJob, isActive;
public boolean hasDisplay, hasAi, hasAdvanced, hasInv, hasStats, hasRole, hasJob, isActive;
private EntityNPCInterface npc;
private EntityNPCInterface npc;
public boolean editingModus = false;
public boolean editingModus = false;
public DataTransform(EntityNPCInterface npc){
this.npc = npc;
}
public DataTransform(EntityNPCInterface npc) {
this.npc = npc;
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setBoolean("TransformIsActive", isActive);
writeOptions(compound);
if(hasDisplay)
compound.setTag("TransformDisplay", display);
if(hasAi)
compound.setTag("TransformAI", ai);
if(hasAdvanced)
compound.setTag("TransformAdvanced", advanced);
if(hasInv)
compound.setTag("TransformInv", inv);
if(hasStats)
compound.setTag("TransformStats", stats);
if(hasRole)
compound.setTag("TransformRole", role);
if(hasJob)
compound.setTag("TransformJob", job);
compound.setBoolean("TransformIsActive", isActive);
writeOptions(compound);
if (hasDisplay)
compound.setTag("TransformDisplay", display);
if (hasAi)
compound.setTag("TransformAI", ai);
if (hasAdvanced)
compound.setTag("TransformAdvanced", advanced);
if (hasInv)
compound.setTag("TransformInv", inv);
if (hasStats)
compound.setTag("TransformStats", stats);
if (hasRole)
compound.setTag("TransformRole", role);
if (hasJob)
compound.setTag("TransformJob", job);
return compound;
return compound;
}
public NBTTagCompound writeOptions(NBTTagCompound compound) {
compound.setBoolean("TransformHasDisplay", hasDisplay);
compound.setBoolean("TransformHasAI", hasAi);
compound.setBoolean("TransformHasAdvanced", hasAdvanced);
compound.setBoolean("TransformHasInv", hasInv);
compound.setBoolean("TransformHasStats", hasStats);
compound.setBoolean("TransformHasRole", hasRole);
compound.setBoolean("TransformHasJob", hasJob);
compound.setBoolean("TransformEditingModus", editingModus);
return compound;
}
public NBTTagCompound writeOptions(NBTTagCompound compound) {
compound.setBoolean("TransformHasDisplay", hasDisplay);
compound.setBoolean("TransformHasAI", hasAi);
compound.setBoolean("TransformHasAdvanced", hasAdvanced);
compound.setBoolean("TransformHasInv", hasInv);
compound.setBoolean("TransformHasStats", hasStats);
compound.setBoolean("TransformHasRole", hasRole);
compound.setBoolean("TransformHasJob", hasJob);
compound.setBoolean("TransformEditingModus", editingModus);
return compound;
}
public void readToNBT(NBTTagCompound compound) {
isActive = compound.getBoolean("TransformIsActive");
readOptions(compound);
display = hasDisplay?compound.getCompoundTag("TransformDisplay"): getDisplay();
ai = hasAi?compound.getCompoundTag("TransformAI"): npc.ais.writeToNBT(new NBTTagCompound());
advanced = hasAdvanced?compound.getCompoundTag("TransformAdvanced"): getAdvanced();
inv = hasInv?compound.getCompoundTag("TransformInv"): npc.inventory.writeEntityToNBT(new NBTTagCompound());
stats = hasStats?compound.getCompoundTag("TransformStats"): npc.stats.writeToNBT(new NBTTagCompound());
job = hasJob?compound.getCompoundTag("TransformJob"): getJob();
role = hasRole?compound.getCompoundTag("TransformRole"): getRole();
isActive = compound.getBoolean("TransformIsActive");
readOptions(compound);
display = hasDisplay ? compound.getCompoundTag("TransformDisplay") : getDisplay();
ai = hasAi ? compound.getCompoundTag("TransformAI") : npc.ais.writeToNBT(new NBTTagCompound());
advanced = hasAdvanced ? compound.getCompoundTag("TransformAdvanced") : getAdvanced();
inv = hasInv ? compound.getCompoundTag("TransformInv") : npc.inventory.writeEntityToNBT(new NBTTagCompound());
stats = hasStats ? compound.getCompoundTag("TransformStats") : npc.stats.writeToNBT(new NBTTagCompound());
job = hasJob ? compound.getCompoundTag("TransformJob") : getJob();
role = hasRole ? compound.getCompoundTag("TransformRole") : getRole();
}
public NBTTagCompound getJob() {
NBTTagCompound compound = new NBTTagCompound();
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("NpcJob", npc.advanced.job.ordinal());
if (npc.advanced.job != EnumJobType.None && npc.jobInterface != null) {
npc.jobInterface.writeToNBT(compound);
}
return compound;
}
return compound;
}
public NBTTagCompound getRole() {
NBTTagCompound compound = new NBTTagCompound();
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("Role", npc.advanced.role.ordinal());
if (npc.advanced.role != EnumRoleType.None && npc.roleInterface != null) {
npc.roleInterface.writeToNBT(compound);
}
return compound;
}
return compound;
}
public NBTTagCompound getDisplay() {
NBTTagCompound compound = npc.display.writeToNBT(new NBTTagCompound());
if(npc instanceof EntityCustomNpc){
compound.setTag("ModelData", ((EntityCustomNpc)npc).modelData.writeToNBT());
}
NBTTagCompound compound = npc.display.writeToNBT(new NBTTagCompound());
if (npc instanceof EntityCustomNpc) {
compound.setTag("ModelData", ((EntityCustomNpc) npc).modelData.writeToNBT());
}
return compound;
return compound;
}
public NBTTagCompound getAdvanced() {
EnumJobType jopType = npc.advanced.job;
EnumRoleType roleType = npc.advanced.role;
EnumJobType jopType = npc.advanced.job;
EnumRoleType roleType = npc.advanced.role;
npc.advanced.job = EnumJobType.None;
npc.advanced.role = EnumRoleType.None;
npc.advanced.job = EnumJobType.None;
npc.advanced.role = EnumRoleType.None;
NBTTagCompound compound = npc.advanced.writeToNBT(new NBTTagCompound());
compound.removeTag("Role");
compound.removeTag("NpcJob");
NBTTagCompound compound = npc.advanced.writeToNBT(new NBTTagCompound());
compound.removeTag("Role");
compound.removeTag("NpcJob");
npc.advanced.job = jopType;
npc.advanced.role = roleType;
npc.advanced.job = jopType;
npc.advanced.role = roleType;
return compound;
}
public void readOptions(NBTTagCompound compound){
boolean hadDisplay = hasDisplay;
boolean hadAI = hasAi;
boolean hadAdvanced = hasAdvanced;
boolean hadInv = hasInv;
boolean hadStats = hasStats;
boolean hadRole = hasRole;
boolean hadJob = hasJob;
hasDisplay = compound.getBoolean("TransformHasDisplay");
hasAi = compound.getBoolean("TransformHasAI");
hasAdvanced = compound.getBoolean("TransformHasAdvanced");
hasInv = compound.getBoolean("TransformHasInv");
hasStats = compound.getBoolean("TransformHasStats");
hasRole = compound.getBoolean("TransformHasRole");
hasJob = compound.getBoolean("TransformHasJob");
editingModus = compound.getBoolean("TransformEditingModus");
if(hasDisplay && !hadDisplay){
display = getDisplay();
}
if(hasAi && !hadAI)
ai = npc.ais.writeToNBT(new NBTTagCompound());
if(hasStats && !hadStats)
stats = npc.stats.writeToNBT(new NBTTagCompound());
if(hasInv && !hadInv)
inv = npc.inventory.writeEntityToNBT(new NBTTagCompound());
if(hasAdvanced && !hadAdvanced)
advanced = getAdvanced();
if(hasJob && !hadJob)
job = getJob();
if(hasRole && !hadRole)
role = getRole();
}
public boolean isValid(){
return hasAdvanced || hasAi || hasDisplay || hasInv || hasStats || hasJob || hasRole;
return compound;
}
public NBTTagCompound processAdvanced(NBTTagCompound compoundAdv,
NBTTagCompound compoundRole, NBTTagCompound compoundJob) {
public void readOptions(NBTTagCompound compound) {
boolean hadDisplay = hasDisplay;
boolean hadAI = hasAi;
boolean hadAdvanced = hasAdvanced;
boolean hadInv = hasInv;
boolean hadStats = hasStats;
boolean hadRole = hasRole;
boolean hadJob = hasJob;
if(hasAdvanced)
compoundAdv = advanced;
if(hasRole)
compoundRole = role;
if(hasJob)
compoundJob = job;
hasDisplay = compound.getBoolean("TransformHasDisplay");
hasAi = compound.getBoolean("TransformHasAI");
hasAdvanced = compound.getBoolean("TransformHasAdvanced");
hasInv = compound.getBoolean("TransformHasInv");
hasStats = compound.getBoolean("TransformHasStats");
hasRole = compound.getBoolean("TransformHasRole");
hasJob = compound.getBoolean("TransformHasJob");
editingModus = compound.getBoolean("TransformEditingModus");
Set<String> names = compoundRole.func_150296_c();
for(String name : names)
compoundAdv.setTag(name, compoundRole.getTag(name));
if (hasDisplay && !hadDisplay) {
display = getDisplay();
}
if (hasAi && !hadAI)
ai = npc.ais.writeToNBT(new NBTTagCompound());
if (hasStats && !hadStats)
stats = npc.stats.writeToNBT(new NBTTagCompound());
if (hasInv && !hadInv)
inv = npc.inventory.writeEntityToNBT(new NBTTagCompound());
if (hasAdvanced && !hadAdvanced)
advanced = getAdvanced();
if (hasJob && !hadJob)
job = getJob();
if (hasRole && !hadRole)
role = getRole();
}
names = compoundJob.func_150296_c();
for(String name : names)
compoundAdv.setTag(name, compoundJob.getTag(name));
public boolean isValid() {
return hasAdvanced || hasAi || hasDisplay || hasInv || hasStats || hasJob || hasRole;
}
return compoundAdv;
}
public void transform(boolean isActive){
if(this.isActive == isActive)
return;
if(hasDisplay){
NBTTagCompound compound = getDisplay();
npc.display.readToNBT(NBTTags.NBTMerge(compound, display));
if(npc instanceof EntityCustomNpc){
((EntityCustomNpc)npc).modelData.readFromNBT(NBTTags.NBTMerge(compound.getCompoundTag("ModelData"), display.getCompoundTag("ModelData")));
}
display = compound;
}
if(hasStats){
NBTTagCompound compound = npc.stats.writeToNBT(new NBTTagCompound());
npc.stats.readToNBT(NBTTags.NBTMerge(compound, stats));
stats = compound;
}
if(hasAdvanced || hasJob || hasRole){
NBTTagCompound compoundAdv = getAdvanced();
NBTTagCompound compoundRole = getRole();
NBTTagCompound compoundJob = getJob();
public NBTTagCompound processAdvanced(NBTTagCompound compoundAdv,
NBTTagCompound compoundRole, NBTTagCompound compoundJob) {
NBTTagCompound compound = processAdvanced(compoundAdv, compoundRole, compoundJob);
npc.advanced.readToNBT(compound);
if (npc.advanced.role != EnumRoleType.None && npc.roleInterface != null)
npc.roleInterface.readFromNBT(NBTTags.NBTMerge(compoundRole, compound));
if (npc.advanced.job != EnumJobType.None && npc.jobInterface != null)
npc.jobInterface.readFromNBT(NBTTags.NBTMerge(compoundJob, compound));
if (hasAdvanced)
compoundAdv = advanced;
if (hasRole)
compoundRole = role;
if (hasJob)
compoundJob = job;
if(hasAdvanced)
advanced = compoundAdv;
if(hasRole)
role = compoundRole;
if(hasJob)
job = compoundJob;
}
if(hasAi){
NBTTagCompound compound = npc.ais.writeToNBT(new NBTTagCompound());
npc.ais.readToNBT(NBTTags.NBTMerge(compound, ai));
ai = compound;
npc.setCurrentAnimation(EnumAnimation.NONE);
}
if(hasInv){
NBTTagCompound compound = npc.inventory.writeEntityToNBT(new NBTTagCompound());
npc.inventory.readEntityFromNBT(NBTTags.NBTMerge(compound, inv));
inv = compound;
}
npc.updateHitbox();
npc.updateAI = true;
this.isActive = isActive;
npc.updateClient = true;
}
Set<String> names = compoundRole.func_150296_c();
for (String name : names)
compoundAdv.setTag(name, compoundRole.getTag(name));
names = compoundJob.func_150296_c();
for (String name : names)
compoundAdv.setTag(name, compoundJob.getTag(name));
return compoundAdv;
}
public void transform(boolean isActive) {
if (this.isActive == isActive)
return;
if (hasDisplay) {
NBTTagCompound compound = getDisplay();
npc.display.readToNBT(NBTTags.NBTMerge(compound, display));
if (npc instanceof EntityCustomNpc) {
((EntityCustomNpc) npc).modelData.readFromNBT(NBTTags.NBTMerge(compound.getCompoundTag("ModelData"), display.getCompoundTag("ModelData")));
}
display = compound;
}
if (hasStats) {
NBTTagCompound compound = npc.stats.writeToNBT(new NBTTagCompound());
npc.stats.readToNBT(NBTTags.NBTMerge(compound, stats));
stats = compound;
}
if (hasAdvanced || hasJob || hasRole) {
NBTTagCompound compoundAdv = getAdvanced();
NBTTagCompound compoundRole = getRole();
NBTTagCompound compoundJob = getJob();
NBTTagCompound compound = processAdvanced(compoundAdv, compoundRole, compoundJob);
npc.advanced.readToNBT(compound);
if (npc.advanced.role != EnumRoleType.None && npc.roleInterface != null)
npc.roleInterface.readFromNBT(NBTTags.NBTMerge(compoundRole, compound));
if (npc.advanced.job != EnumJobType.None && npc.jobInterface != null)
npc.jobInterface.readFromNBT(NBTTags.NBTMerge(compoundJob, compound));
if (hasAdvanced)
advanced = compoundAdv;
if (hasRole)
role = compoundRole;
if (hasJob)
job = compoundJob;
}
if (hasAi) {
NBTTagCompound compound = npc.ais.writeToNBT(new NBTTagCompound());
npc.ais.readToNBT(NBTTags.NBTMerge(compound, ai));
ai = compound;
npc.setCurrentAnimation(EnumAnimation.NONE);
}
if (hasInv) {
NBTTagCompound compound = npc.inventory.writeEntityToNBT(new NBTTagCompound());
npc.inventory.readEntityFromNBT(NBTTags.NBTMerge(compound, inv));
inv = compound;
}
npc.updateHitbox();
npc.updateAI = true;
this.isActive = isActive;
npc.updateClient = true;
}
}
File diff suppressed because it is too large. Load diff
@@ -11,42 +11,41 @@ import java.util.List;
public class DialogCategory implements IDialogCategory {
public int id = -1;
public String title = "";
public HashMap<Integer,Dialog> dialogs;
public int id = -1;
public String title = "";
public HashMap<Integer, Dialog> dialogs;
public DialogCategory(){
dialogs = new HashMap<Integer, Dialog>();
}
public DialogCategory() {
dialogs = new HashMap<Integer, Dialog>();
}
public void readNBT(NBTTagCompound compound){
public void readNBT(NBTTagCompound compound) {
id = compound.getInteger("Slot");
title = compound.getString("Title");
NBTTagList dialogsList = compound.getTagList("Dialogs", 10);
if(dialogsList != null){
for(int ii = 0; ii < dialogsList.tagCount(); ii++)
{
Dialog dialog = new Dialog();
dialog.category = this;
NBTTagCompound comp = dialogsList.getCompoundTagAt(ii);
dialog.readNBT(comp);
dialog.id = comp.getInteger("DialogId");
dialogs.put(dialog.id, dialog);
if (dialogsList != null) {
for (int ii = 0; ii < dialogsList.tagCount(); ii++) {
Dialog dialog = new Dialog();
dialog.category = this;
NBTTagCompound comp = dialogsList.getCompoundTagAt(ii);
dialog.readNBT(comp);
dialog.id = comp.getInteger("DialogId");
dialogs.put(dialog.id, dialog);
}
}
}
}
public NBTTagCompound writeNBT(NBTTagCompound dialogCat) {
public NBTTagCompound writeNBT(NBTTagCompound dialogCat) {
dialogCat.setInteger("Slot", id);
dialogCat.setString("Title", title);
NBTTagList dialogs = new NBTTagList();
for(Dialog dialog : this.dialogs.values()){
dialogs.appendTag(dialog.writeToNBT(new NBTTagCompound()));
for (Dialog dialog : this.dialogs.values()) {
dialogs.appendTag(dialog.writeToNBT(new NBTTagCompound()));
}
dialogCat.setTag("Dialogs", dialogs);
return dialogCat;
}
}
public NBTTagCompound writeSmallNBT(NBTTagCompound dialogCat) {
dialogCat.setInteger("Slot", id);
@@ -54,27 +53,27 @@ public class DialogCategory implements IDialogCategory {
return dialogCat;
}
public void readSmallNBT(NBTTagCompound compound){
public void readSmallNBT(NBTTagCompound compound) {
id = compound.getInteger("Slot");
title = compound.getString("Title");
}
public List<IDialog> dialogs() {
return new ArrayList(this.dialogs.values());
}
public List<IDialog> dialogs() {
return new ArrayList(this.dialogs.values());
}
public String getName() {
return this.title;
}
public String getName() {
return this.title;
}
public IDialog create() {
Dialog dialog = new Dialog();
dialog.category = this;
return dialog;
}
public IDialog create() {
Dialog dialog = new Dialog();
dialog.category = this;
return dialog;
}
@Override
public int getId() {
return this.id;
}
@Override
public int getId() {
return this.id;
}
}
@@ -6,57 +6,57 @@ import noppes.npcs.constants.EnumOptionType;
import noppes.npcs.controllers.DialogController;
public class DialogOption {
public int dialogId = -1;
public String title = "Talk";
public EnumOptionType optionType = EnumOptionType.DialogOption;
public int optionColor = 0xe0e0e0;
public String command = "";
public void readNBT(NBTTagCompound compound) {
if(compound == null)
return;
title = compound.getString("Title");
dialogId = compound.getInteger("Dialog");
optionColor = compound.getInteger("DialogColor");
optionType = EnumOptionType.values()[compound.getInteger("OptionType")];
command = compound.getString("DialogCommand");
if(optionColor == 0){
optionColor = 0xe0e0e0;
}
}
public int dialogId = -1;
public String title = "Talk";
public EnumOptionType optionType = EnumOptionType.DialogOption;
public int optionColor = 0xe0e0e0;
public String command = "";
public NBTTagCompound writeNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setString("Title", title);
compound.setInteger("OptionType", optionType.ordinal());
compound.setInteger("Dialog", dialogId);
compound.setInteger("DialogColor", optionColor);
compound.setString("DialogCommand", command);
return compound;
}
public void readNBT(NBTTagCompound compound) {
if (compound == null)
return;
title = compound.getString("Title");
dialogId = compound.getInteger("Dialog");
optionColor = compound.getInteger("DialogColor");
optionType = EnumOptionType.values()[compound.getInteger("OptionType")];
command = compound.getString("DialogCommand");
if (optionColor == 0) {
optionColor = 0xe0e0e0;
}
}
public boolean hasDialog(){
if(dialogId <= 0)
return false;
if(!DialogController.Instance.hasDialog(dialogId)){
dialogId = -1;
return false;
}
return true;
}
public NBTTagCompound writeNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setString("Title", title);
compound.setInteger("OptionType", optionType.ordinal());
compound.setInteger("Dialog", dialogId);
compound.setInteger("DialogColor", optionColor);
compound.setString("DialogCommand", command);
return compound;
}
public Dialog getDialog() {
if(!hasDialog())
return null;
return DialogController.Instance.dialogs.get(dialogId);
}
public boolean isAvailable(EntityPlayer player) {
Dialog dialog = getDialog();
if(dialog == null)
return false;
return dialog.availability.isAvailable(player);
}
public boolean hasDialog() {
if (dialogId <= 0)
return false;
if (!DialogController.Instance.hasDialog(dialogId)) {
dialogId = -1;
return false;
}
return true;
}
public Dialog getDialog() {
if (!hasDialog())
return null;
return DialogController.Instance.dialogs.get(dialogId);
}
public boolean isAvailable(EntityPlayer player) {
Dialog dialog = getDialog();
if (dialog == null)
return false;
return dialog.availability.isAvailable(player);
}
}
@@ -114,14 +114,14 @@ public class EffectScript implements INpcScriptHandler {
int tab = 0;
Iterator var3 = this.getScripts().iterator();
while(var3.hasNext()) {
ScriptContainer script = (ScriptContainer)var3.next();
while (var3.hasNext()) {
ScriptContainer script = (ScriptContainer) var3.next();
++tab;
Iterator var5 = script.console.entrySet().iterator();
while(var5.hasNext()) {
Map.Entry<Long, String> longStringEntry = (Map.Entry)var5.next();
map.put(longStringEntry.getKey(), " tab " + tab + ":\n" + (String)longStringEntry.getValue());
while (var5.hasNext()) {
Map.Entry<Long, String> longStringEntry = (Map.Entry) var5.next();
map.put(longStringEntry.getKey(), " tab " + tab + ":\n" + (String) longStringEntry.getValue());
}
}
@@ -132,8 +132,8 @@ public class EffectScript implements INpcScriptHandler {
public void clearConsole() {
Iterator var1 = this.getScripts().iterator();
while(var1.hasNext()) {
ScriptContainer script = (ScriptContainer)var1.next();
while (var1.hasNext()) {
ScriptContainer script = (ScriptContainer) var1.next();
script.console.clear();
}
}
@@ -170,6 +170,7 @@ public class EffectScript implements INpcScriptHandler {
OnRemove("onRemove");
public final String function;
ScriptType(String functionName) {
this.function = functionName;
}
@@ -15,42 +15,44 @@ import java.util.ArrayList;
import java.util.HashSet;
public class Faction implements IFaction {
public String name = "";
public int color = Integer.parseInt("FF00", 16);
public String name = "";
public int color = Integer.parseInt("FF00", 16);
public HashSet<Integer> attackFactions;
public int id = -1;
public HashSet<Integer> attackFactions;
public int id = -1;
public int neutralPoints = 500;
public int friendlyPoints = 1500;
public int neutralPoints = 500;
public int friendlyPoints = 1500;
public int defaultPoints = 1000;
public int defaultPoints = 1000;
public boolean hideFaction = false;
public boolean getsAttacked = false;
public boolean hideFaction = false;
public boolean getsAttacked = false;
public boolean isPassive = false;
public Faction(){
attackFactions = new HashSet<Integer>();
}
public Faction() {
attackFactions = new HashSet<Integer>();
}
public Faction(int id, String name,int color, int defaultPoints){
this.name = name;
this.color = color;
this.defaultPoints = defaultPoints;
this.id = id;
attackFactions = new HashSet<Integer>();
}
public static String formatName(String name){
name = name.toLowerCase().trim();
return name.substring(0, 1).toUpperCase() + name.substring(1);
}
public void readNBT(NBTTagCompound compound){
public Faction(int id, String name, int color, int defaultPoints) {
this.name = name;
this.color = color;
this.defaultPoints = defaultPoints;
this.id = id;
attackFactions = new HashSet<Integer>();
}
public static String formatName(String name) {
name = name.toLowerCase().trim();
return name.substring(0, 1).toUpperCase() + name.substring(1);
}
public void readNBT(NBTTagCompound compound) {
name = compound.getString("Name");
color = compound.getInteger("Color");
id = compound.getInteger("Slot");
neutralPoints= compound.getInteger("NeutralPoints");
neutralPoints = compound.getInteger("NeutralPoints");
friendlyPoints = compound.getInteger("FriendlyPoints");
defaultPoints = compound.getInteger("DefaultPoints");
@@ -59,126 +61,131 @@ public class Faction implements IFaction {
isPassive = compound.getBoolean("IsPassive");
attackFactions = NBTTags.getIntegerSet(compound.getTagList("AttackFactions", 10));
}
public void writeNBT(NBTTagCompound compound){
compound.setInteger("Slot", id);
compound.setString("Name", name);
compound.setInteger("Color", color);
}
compound.setInteger("NeutralPoints", neutralPoints);
compound.setInteger("FriendlyPoints", friendlyPoints);
compound.setInteger("DefaultPoints", defaultPoints);
public void writeNBT(NBTTagCompound compound) {
compound.setInteger("Slot", id);
compound.setString("Name", name);
compound.setInteger("Color", color);
compound.setBoolean("HideFaction", hideFaction);
compound.setBoolean("GetsAttacked", getsAttacked);
compound.setInteger("NeutralPoints", neutralPoints);
compound.setInteger("FriendlyPoints", friendlyPoints);
compound.setInteger("DefaultPoints", defaultPoints);
compound.setBoolean("HideFaction", hideFaction);
compound.setBoolean("GetsAttacked", getsAttacked);
compound.setBoolean("IsPassive", isPassive);
compound.setTag("AttackFactions", NBTTags.nbtIntegerSet(attackFactions));
}
compound.setTag("AttackFactions", NBTTags.nbtIntegerSet(attackFactions));
}
public boolean isFriendlyToPlayer(EntityPlayer player) {
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
return data.getFactionPoints(id) >= friendlyPoints;
}
public boolean isFriendlyToPlayer(EntityPlayer player) {
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
return data.getFactionPoints(id) >= friendlyPoints;
}
public boolean isAggressiveToPlayer(EntityPlayer player) {
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
return data.getFactionPoints(id) < neutralPoints;
}
public boolean isAggressiveToPlayer(EntityPlayer player) {
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
return data.getFactionPoints(id) < neutralPoints;
}
public boolean isNeutralToPlayer(EntityPlayer player) {
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
int points = data.getFactionPoints(id);
return points >= neutralPoints && points < friendlyPoints;
}
public boolean isNeutralToPlayer(EntityPlayer player) {
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
int points = data.getFactionPoints(id);
return points >= neutralPoints && points < friendlyPoints;
}
public boolean isAggressiveToNpc(EntityNPCInterface entity) {
return attackFactions.contains(entity.faction.id);
}
public boolean isAggressiveToNpc(EntityNPCInterface entity) {
return attackFactions.contains(entity.faction.id);
}
public int getId() {
return this.id;
}
public int getId() {
return this.id;
}
public String getName() {
return this.name;
}
public String getName() {
return this.name;
}
public void setName(String name) { this.name = name; }
public void setName(String name) {
this.name = name;
}
public void setDefaultPoints(int points) {
this.defaultPoints = points;
}
public void setDefaultPoints(int points) {
this.defaultPoints = points;
}
public int getDefaultPoints() {
return this.defaultPoints;
}
public int getDefaultPoints() {
return this.defaultPoints;
}
public void setFriendlyPoints(int points) {
this.friendlyPoints = points;
}
public void setFriendlyPoints(int points) {
this.friendlyPoints = points;
}
public int getFriendlyPoints() {
return this.friendlyPoints;
}
public int getFriendlyPoints() {
return this.friendlyPoints;
}
public void setNeutralPoints(int points) {
this.neutralPoints = points;
}
public void setNeutralPoints(int points) {
this.neutralPoints = points;
}
public int getNeutralPoints() {
return this.neutralPoints;
}
public int getNeutralPoints() {
return this.neutralPoints;
}
public void setColor(int color) { this.color = color; }
public void setColor(int color) {
this.color = color;
}
public int getColor() {
return this.color;
}
public int getColor() {
return this.color;
}
public int playerStatus(IPlayer player) {
IPlayerFactionData data = player.getData().getFactionData();
int points = data.getPoints(this.id);
if (points >= this.friendlyPoints) {
return 1;
} else {
return points < this.neutralPoints ? -1 : 0;
}
}
public int playerStatus(IPlayer player) {
IPlayerFactionData data = player.getData().getFactionData();
int points = data.getPoints(this.id);
if (points >= this.friendlyPoints) {
return 1;
} else {
return points < this.neutralPoints ? -1 : 0;
}
}
public boolean isAggressiveToNpc(ICustomNpc npc) {
return this.attackFactions.contains(npc.getFaction().getId());
}
public boolean isAggressiveToNpc(ICustomNpc npc) {
return this.attackFactions.contains(npc.getFaction().getId());
}
public boolean isEnemyFaction(IFaction faction) {
return this.attackFactions.contains(faction.getId());
}
public boolean isEnemyFaction(IFaction faction) {
return this.attackFactions.contains(faction.getId());
}
public IFaction[] getEnemyFactions() {
ArrayList<IFaction> enemyFactions = new ArrayList<>();
public IFaction[] getEnemyFactions() {
ArrayList<IFaction> enemyFactions = new ArrayList<>();
for (int id : this.attackFactions) {
enemyFactions.add(FactionController.getInstance().get(id));
}
for (int id : this.attackFactions) {
enemyFactions.add(FactionController.getInstance().get(id));
}
return enemyFactions.toArray(new IFaction[]{});
}
return enemyFactions.toArray(new IFaction[]{});
}
public void addEnemyFaction(IFaction faction) {
this.attackFactions.add(faction.getId());
}
public void addEnemyFaction(IFaction faction) {
this.attackFactions.add(faction.getId());
}
public void removeEnemyFaction(IFaction faction) {
this.attackFactions.remove(faction.getId());
}
public void removeEnemyFaction(IFaction faction) {
this.attackFactions.remove(faction.getId());
}
public boolean getIsHidden() {
return this.hideFaction;
}
public boolean getIsHidden() {
return this.hideFaction;
}
public void setIsHidden(boolean bo) {
this.hideFaction = bo;
}
public void setIsHidden(boolean bo) {
this.hideFaction = bo;
}
public boolean isPassive() {
return isPassive;
@@ -189,26 +196,26 @@ public class Faction implements IFaction {
}
public boolean attackedByMobs() {
return this.getsAttacked;
}
return this.getsAttacked;
}
public void setAttackedByMobs(boolean bo) {
this.getsAttacked = bo;
}
public void setAttackedByMobs(boolean bo) {
this.getsAttacked = bo;
}
public void save() {
FactionController.getInstance().saveFaction(this);
}
public void save() {
FactionController.getInstance().saveFaction(this);
}
public boolean isFriendlyToPlayer(IPlayer player) {
return this.isFriendlyToPlayer((EntityPlayer) player.getMCEntity());
}
public boolean isFriendlyToPlayer(IPlayer player) {
return this.isFriendlyToPlayer((EntityPlayer) player.getMCEntity());
}
public boolean isNeutralToPlayer(IPlayer player) {
return this.isNeutralToPlayer((EntityPlayer) player.getMCEntity());
}
public boolean isNeutralToPlayer(IPlayer player) {
return this.isNeutralToPlayer((EntityPlayer) player.getMCEntity());
}
public boolean isAggressiveToPlayer(IPlayer player) {
return this.isAggressiveToPlayer((EntityPlayer) player.getMCEntity());
}
public boolean isAggressiveToPlayer(IPlayer player) {
return this.isAggressiveToPlayer((EntityPlayer) player.getMCEntity());
}
}
@@ -8,62 +8,64 @@ import noppes.npcs.controllers.PlayerDataController;
public class FactionOptions {
public boolean decreaseFactionPoints = false;
public boolean decreaseFaction2Points = false;
public boolean decreaseFactionPoints = false;
public boolean decreaseFaction2Points = false;
public int factionId = -1;
public int faction2Id = -1;
public int factionPoints = 100;
public int faction2Points = 100;
public void readFromNBT(NBTTagCompound compound)
{
factionId = compound.getInteger("OptionFactions1");
faction2Id = compound.getInteger("OptionFactions2");
public int factionId = -1;
public int faction2Id = -1;
decreaseFactionPoints = compound.getBoolean("DecreaseFaction1Points");
decreaseFaction2Points = compound.getBoolean("DecreaseFaction2Points");
public int factionPoints = 100;
public int faction2Points = 100;
factionPoints = compound.getInteger("OptionFaction1Points");
faction2Points = compound.getInteger("OptionFaction2Points");
public void readFromNBT(NBTTagCompound compound) {
factionId = compound.getInteger("OptionFactions1");
faction2Id = compound.getInteger("OptionFactions2");
decreaseFactionPoints = compound.getBoolean("DecreaseFaction1Points");
decreaseFaction2Points = compound.getBoolean("DecreaseFaction2Points");
factionPoints = compound.getInteger("OptionFaction1Points");
faction2Points = compound.getInteger("OptionFaction2Points");
}
public NBTTagCompound writeToNBT(NBTTagCompound par1NBTTagCompound)
{
par1NBTTagCompound.setInteger("OptionFactions1", factionId);
par1NBTTagCompound.setInteger("OptionFactions2", faction2Id);
par1NBTTagCompound.setInteger("OptionFaction1Points", factionPoints);
par1NBTTagCompound.setInteger("OptionFaction2Points", faction2Points);
par1NBTTagCompound.setBoolean("DecreaseFaction1Points", decreaseFactionPoints);
par1NBTTagCompound.setBoolean("DecreaseFaction2Points", decreaseFaction2Points);
return par1NBTTagCompound;
public NBTTagCompound writeToNBT(NBTTagCompound par1NBTTagCompound) {
par1NBTTagCompound.setInteger("OptionFactions1", factionId);
par1NBTTagCompound.setInteger("OptionFactions2", faction2Id);
par1NBTTagCompound.setInteger("OptionFaction1Points", factionPoints);
par1NBTTagCompound.setInteger("OptionFaction2Points", faction2Points);
par1NBTTagCompound.setBoolean("DecreaseFaction1Points", decreaseFactionPoints);
par1NBTTagCompound.setBoolean("DecreaseFaction2Points", decreaseFaction2Points);
return par1NBTTagCompound;
}
public boolean hasFaction(int id) {
return factionId == id || faction2Id == id;
}
public void addPoints(EntityPlayer player) {
if(factionId < 0 && faction2Id < 0)
return;
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
if(factionId >= 0 && factionPoints > 0)
addPoints(player, data, factionId, decreaseFactionPoints, factionPoints);
if(faction2Id >= 0 && faction2Points> 0)
addPoints(player, data, faction2Id, decreaseFaction2Points, faction2Points);
}
private void addPoints(EntityPlayer player, PlayerFactionData data, int factionId, boolean decrease, int points) {
Faction faction = FactionController.getInstance().get(factionId);
if(faction == null)
return;
public boolean hasFaction(int id) {
return factionId == id || faction2Id == id;
}
if(!faction.hideFaction){
String message = decrease?"faction.decreasepoints":"faction.increasepoints";
player.addChatMessage(new ChatComponentTranslation(message, faction.name, points));
}
data.increasePoints(factionId, decrease?-points:points,player);
}
public void addPoints(EntityPlayer player) {
if (factionId < 0 && faction2Id < 0)
return;
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
if (factionId >= 0 && factionPoints > 0)
addPoints(player, data, factionId, decreaseFactionPoints, factionPoints);
if (faction2Id >= 0 && faction2Points > 0)
addPoints(player, data, faction2Id, decreaseFaction2Points, faction2Points);
}
private void addPoints(EntityPlayer player, PlayerFactionData data, int factionId, boolean decrease, int points) {
Faction faction = FactionController.getInstance().get(factionId);
if (faction == null)
return;
if (!faction.hideFaction) {
String message = decrease ? "faction.decreasepoints" : "faction.increasepoints";
player.addChatMessage(new ChatComponentTranslation(message, faction.name, points));
}
data.increasePoints(factionId, decrease ? -points : points, player);
}
}
@@ -33,7 +33,7 @@ public class ForgeDataScript implements INpcScriptHandler {
if (compound.hasKey("Scripts")) {
this.scripts = NBTTags.GetScriptOld(compound.getTagList("Scripts", 10), this);
} else {
this.scripts = NBTTags.GetScript(compound,this);
this.scripts = NBTTags.GetScript(compound, this);
}
this.scriptLanguage = compound.getString("ScriptLanguage");
if (!ScriptController.Instance.languages.containsKey(scriptLanguage)) {
@@ -47,9 +47,9 @@ public class ForgeDataScript implements INpcScriptHandler {
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setInteger("TotalScripts",this.scripts.size());
compound.setInteger("TotalScripts", this.scripts.size());
for (int i = 0; i < this.scripts.size(); i++) {
compound.setTag("Tab"+i,this.scripts.get(i).writeToNBT(new NBTTagCompound()));
compound.setTag("Tab" + i, this.scripts.get(i).writeToNBT(new NBTTagCompound()));
}
compound.setString("ScriptLanguage", this.scriptLanguage);
compound.setBoolean("ScriptEnabled", this.enabled);
@@ -62,7 +62,7 @@ public class ForgeDataScript implements INpcScriptHandler {
}
public void callScript(String type, Event event) {
if(this.isEnabled()) {
if (this.isEnabled()) {
if (ScriptController.Instance.lastLoaded > this.lastInited || ScriptController.Instance.lastForgeUpdate > this.lastForgeUpdate) {
this.lastInited = ScriptController.Instance.lastLoaded;
this.lastForgeUpdate = ScriptController.Instance.lastForgeUpdate;
@@ -77,7 +77,7 @@ public class ForgeDataScript implements INpcScriptHandler {
}
for (ScriptContainer script : this.scripts) {
if(script == null || script.errored || !script.hasCode() )
if (script == null || script.errored || !script.hasCode())
continue;
script.run(type, event);
@@ -12,7 +12,7 @@ import java.util.Map;
public class Frame implements IFrame {
public Animation parent;
public HashMap<EnumAnimationPart,FramePart> frameParts = new HashMap<>();
public HashMap<EnumAnimationPart, FramePart> frameParts = new HashMap<>();
public int duration = 0;
boolean customized = false;
@@ -22,7 +22,8 @@ public class Frame implements IFrame {
private int colorMarker = 0xFFFFFF;
private String comment = "";
public Frame(){}
public Frame() {
}
public Frame(int duration) {
this.duration = duration;
@@ -35,7 +36,7 @@ public class Frame implements IFrame {
this.customized = true;
}
public HashMap<EnumAnimationPart,FramePart> getFrameMap() {
public HashMap<EnumAnimationPart, FramePart> getFrameMap() {
return frameParts;
}
@@ -44,14 +45,15 @@ public class Frame implements IFrame {
}
public IFrame addPart(IFramePart partConfig) {
this.frameParts.put(((FramePart)partConfig).getPart(),(FramePart) partConfig);
this.frameParts.put(((FramePart) partConfig).getPart(), (FramePart) partConfig);
return this;
}
public IFrame removePart(String partName) {
try {
this.frameParts.remove(EnumAnimationPart.valueOf(partName));
} catch (IllegalArgumentException ignored) {}
} catch (IllegalArgumentException ignored) {
}
return this;
}
@@ -119,7 +121,7 @@ public class Frame implements IFrame {
this.comment = comment;
}
public void readFromNBT(NBTTagCompound compound){
public void readFromNBT(NBTTagCompound compound) {
duration = compound.getInteger("Duration");
if (compound.hasKey("ColorMarker")) {
this.setColorMarker(compound.getInteger("ColorMarker"));
@@ -129,11 +131,11 @@ public class Frame implements IFrame {
}
// Customized = TRUE if Speed or Smooth Exist
if(compound.hasKey("Speed")){
if (compound.hasKey("Speed")) {
customized = true;
speed = compound.getFloat("Speed");
}
if(compound.hasKey("Smooth")){
if (compound.hasKey("Smooth")) {
customized = true;
smooth = compound.getByte("Smooth");
}
@@ -143,7 +145,7 @@ public class Frame implements IFrame {
this.smooth = parent.smooth;
}
HashMap<EnumAnimationPart,FramePart> frameParts = new HashMap<>();
HashMap<EnumAnimationPart, FramePart> frameParts = new HashMap<>();
NBTTagList list = compound.getTagList("FrameParts", 10);
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound item = list.getCompoundTagAt(i);
@@ -153,24 +155,24 @@ public class Frame implements IFrame {
framePart.smooth = this.smooth;
framePart.speed = this.speed;
}
frameParts.put(framePart.part,framePart);
frameParts.put(framePart.part, framePart);
}
this.frameParts = frameParts;
}
public NBTTagCompound writeToNBT(){
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("Duration", duration);
compound.setInteger("ColorMarker", this.colorMarker);
compound.setString("Comment", this.comment);
if(customized){
if (customized) {
compound.setFloat("Speed", speed);
compound.setByte("Smooth", smooth);
}
NBTTagList list = new NBTTagList();
for(FramePart framePart : frameParts.values()){
for (FramePart framePart : frameParts.values()) {
NBTTagCompound item = framePart.writeToNBT();
list.appendTag(item);
}
@@ -180,9 +182,9 @@ public class Frame implements IFrame {
public Frame copy() {
Frame frame = new Frame(this.duration);
HashMap<EnumAnimationPart,FramePart> frameParts = this.frameParts;
for (Map.Entry<EnumAnimationPart,FramePart> entry : frameParts.entrySet()) {
frame.frameParts.put(entry.getKey(),entry.getValue().copy());
HashMap<EnumAnimationPart, FramePart> frameParts = this.frameParts;
for (Map.Entry<EnumAnimationPart, FramePart> entry : frameParts.entrySet()) {
frame.frameParts.put(entry.getKey(), entry.getValue().copy());
}
frame.parent = this.parent;
frame.duration = this.duration;
@@ -8,232 +8,234 @@ import noppes.npcs.client.ClientEventHandler;
import noppes.npcs.constants.EnumAnimationPart;
public class FramePart implements IFramePart {
public Animation parent;
public EnumAnimationPart part;
public float[] rotation = {0, 0, 0};
public float[] pivot = {0, 0, 0};
public Animation parent;
public EnumAnimationPart part;
public float[] rotation = {0, 0, 0};
public float[] pivot = {0, 0, 0};
boolean customized = false;
boolean customized = false;
public float speed = 1.0F;
//0 - Interpolated, 1 - Linear, 2 - None
public byte smooth = 0;
public float speed = 1.0F;
//0 - Interpolated, 1 - Linear, 2 - None
public byte smooth = 0;
//Client-sided fields (unsaved)
public float[] prevRotations = {0,0,0};
public float[] prevPivots = {0,0,0};
public float partialRotationTick;
public float partialPivotTick;
//Client-sided fields (unsaved)
public float[] prevRotations = {0, 0, 0};
public float[] prevPivots = {0, 0, 0};
public float partialRotationTick;
public float partialPivotTick;
public FramePart(){}
public FramePart() {
}
public FramePart(EnumAnimationPart part){
this.part = part;
}
public FramePart(EnumAnimationPart part) {
this.part = part;
}
public EnumAnimationPart getPart() {
return part;
}
public EnumAnimationPart getPart() {
return part;
}
public String getName() {
return part.name();
}
public String getName() {
return part.name();
}
public int getPartId() {
return part.id;
}
public int getPartId() {
return part.id;
}
public void setPart(EnumAnimationPart part) {
this.part = part;
}
public void setPart(EnumAnimationPart part) {
this.part = part;
}
public IFramePart setPart(String name) {
try {
this.setPart(EnumAnimationPart.valueOf(name));
} catch (IllegalArgumentException ignored) {}
return this;
}
public IFramePart setPart(String name) {
try {
this.setPart(EnumAnimationPart.valueOf(name));
} catch (IllegalArgumentException ignored) {
}
return this;
}
public IFramePart setPart(int partId) {
for (EnumAnimationPart enumPart : EnumAnimationPart.values()) {
if (enumPart.id == partId) {
this.setPart(enumPart);
break;
}
}
return this;
}
public IFramePart setPart(int partId) {
for (EnumAnimationPart enumPart : EnumAnimationPart.values()) {
if (enumPart.id == partId) {
this.setPart(enumPart);
break;
}
}
return this;
}
public float[] getRotations() {
return rotation;
}
public float[] getRotations() {
return rotation;
}
public IFramePart setRotations(float[] rotation) {
this.rotation = rotation;
return this;
}
public IFramePart setRotations(float[] rotation) {
this.rotation = rotation;
return this;
}
public float[] getPivots() {
return pivot;
}
public float[] getPivots() {
return pivot;
}
public IFramePart setPivots(float[] pivot) {
this.pivot = pivot;
return this;
}
public IFramePart setPivots(float[] pivot) {
this.pivot = pivot;
return this;
}
public boolean isCustomized() {
return customized;
}
public boolean isCustomized() {
return customized;
}
public IFramePart setCustomized(boolean customized) {
this.customized = customized;
return this;
}
public IFramePart setCustomized(boolean customized) {
this.customized = customized;
return this;
}
public float getSpeed() {
return speed;
}
public float getSpeed() {
return speed;
}
public IFramePart setSpeed(float speed) {
this.speed = speed;
return this;
}
public IFramePart setSpeed(float speed) {
this.speed = speed;
return this;
}
public byte isSmooth() {
return smooth;
}
public byte isSmooth() {
return smooth;
}
public IFramePart setSmooth(byte smooth) {
this.smooth = smooth;
return this;
}
public IFramePart setSmooth(byte smooth) {
this.smooth = smooth;
return this;
}
public void readFromNBT(NBTTagCompound compound){
part = EnumAnimationPart.valueOf(compound.getString("Part"));
for (int i = 0; i < 3; i++) {
rotation[i] = compound.getFloat("Rotation" + i);
}
for (int i = 0; i < 3; i++) {
pivot[i] = compound.getFloat("Pivot" + i);
}
public void readFromNBT(NBTTagCompound compound) {
part = EnumAnimationPart.valueOf(compound.getString("Part"));
for (int i = 0; i < 3; i++) {
rotation[i] = compound.getFloat("Rotation" + i);
}
for (int i = 0; i < 3; i++) {
pivot[i] = compound.getFloat("Pivot" + i);
}
// Customized = TRUE if Speed or Smooth Exist
if(compound.hasKey("Speed")){
customized = true;
speed = compound.getFloat("Speed");
}
if(compound.hasKey("Smooth")){
customized = true;
smooth = compound.getByte("Smooth");
}
}
// Customized = TRUE if Speed or Smooth Exist
if (compound.hasKey("Speed")) {
customized = true;
speed = compound.getFloat("Speed");
}
if (compound.hasKey("Smooth")) {
customized = true;
smooth = compound.getByte("Smooth");
}
}
public NBTTagCompound writeToNBT(){
NBTTagCompound compound = new NBTTagCompound();
compound.setString("Part", part.toString());
for (int i = 0; i < 3; i++) {
compound.setFloat("Rotation" + i, rotation[i]);
}
for (int i = 0; i < 3; i++) {
compound.setFloat("Pivot" + i, pivot[i]);
}
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setString("Part", part.toString());
for (int i = 0; i < 3; i++) {
compound.setFloat("Rotation" + i, rotation[i]);
}
for (int i = 0; i < 3; i++) {
compound.setFloat("Pivot" + i, pivot[i]);
}
if(customized){
compound.setFloat("Speed", speed);
compound.setByte("Smooth", smooth);
}
if (customized) {
compound.setFloat("Speed", speed);
compound.setByte("Smooth", smooth);
}
return compound;
}
return compound;
}
public FramePart copy() {
FramePart part = new FramePart(this.part);
part.rotation = new float[]{this.rotation[0],this.rotation[1],this.rotation[2]};
part.pivot = new float[]{this.pivot[0],this.pivot[1],this.pivot[2]};
part.customized = this.customized;
part.speed = this.speed;
part.smooth = this.smooth;
return part;
}
public FramePart copy() {
FramePart part = new FramePart(this.part);
part.rotation = new float[]{this.rotation[0], this.rotation[1], this.rotation[2]};
part.pivot = new float[]{this.pivot[0], this.pivot[1], this.pivot[2]};
part.customized = this.customized;
part.speed = this.speed;
part.smooth = this.smooth;
return part;
}
@SideOnly(Side.CLIENT)
public void interpolateAngles() {
if (parent != null && parent.paused)
return;
@SideOnly(Side.CLIENT)
public void interpolateAngles() {
if (parent != null && parent.paused)
return;
float pi = (float) Math.PI / 180;
if (this.smooth == 2) {
this.prevRotations[0] = this.rotation[0] * pi;
this.prevRotations[1] = this.rotation[1] * pi;
this.prevRotations[2] = this.rotation[2] * pi;
} else if (this.partialRotationTick != ClientEventHandler.partialRenderTick) {
this.partialRotationTick = ClientEventHandler.partialRenderTick;
if (this.smooth == 0) {
this.prevRotations[0] = (this.rotation[0] * pi - this.prevRotations[0]) * Math.abs(this.speed) / 10f + this.prevRotations[0];
this.prevRotations[1] = (this.rotation[1] * pi - this.prevRotations[1]) * Math.abs(this.speed) / 10f + this.prevRotations[1];
this.prevRotations[2] = (this.rotation[2] * pi - this.prevRotations[2]) * Math.abs(this.speed) / 10f + this.prevRotations[2];
} else {
int directionX = Float.compare(this.rotation[0] * pi, this.prevRotations[0]);
this.prevRotations[0] += directionX * this.speed / 10f;
this.prevRotations[0] = directionX == 1 ?
Math.min(this.rotation[0] * pi, this.prevRotations[0]) : Math.max(this.rotation[0] * pi, this.prevRotations[0]);
int directionY = Float.compare(this.rotation[1] * pi, this.prevRotations[1]);
this.prevRotations[1] += directionY * this.speed / 10f;
this.prevRotations[1] = directionY == 1 ?
Math.min(this.rotation[1] * pi, this.prevRotations[1]) : Math.max(this.rotation[1] * pi, this.prevRotations[1]);
int directionZ = Float.compare(this.rotation[2] * pi, this.prevRotations[2]);
this.prevRotations[2] += directionZ * this.speed / 10f;
this.prevRotations[2] = directionZ == 1 ?
Math.min(this.rotation[2] * pi, this.prevRotations[2]) : Math.max(this.rotation[2] * pi, this.prevRotations[2]);
}
}
}
float pi = (float) Math.PI / 180;
if (this.smooth == 2) {
this.prevRotations[0] = this.rotation[0] * pi;
this.prevRotations[1] = this.rotation[1] * pi;
this.prevRotations[2] = this.rotation[2] * pi;
} else if (this.partialRotationTick != ClientEventHandler.partialRenderTick) {
this.partialRotationTick = ClientEventHandler.partialRenderTick;
if (this.smooth == 0) {
this.prevRotations[0] = (this.rotation[0] * pi - this.prevRotations[0]) * Math.abs(this.speed) / 10f + this.prevRotations[0];
this.prevRotations[1] = (this.rotation[1] * pi - this.prevRotations[1]) * Math.abs(this.speed) / 10f + this.prevRotations[1];
this.prevRotations[2] = (this.rotation[2] * pi - this.prevRotations[2]) * Math.abs(this.speed) / 10f + this.prevRotations[2];
} else {
int directionX = Float.compare(this.rotation[0] * pi, this.prevRotations[0]);
this.prevRotations[0] += directionX * this.speed / 10f;
this.prevRotations[0] = directionX == 1 ?
Math.min(this.rotation[0] * pi, this.prevRotations[0]) : Math.max(this.rotation[0] * pi, this.prevRotations[0]);
int directionY = Float.compare(this.rotation[1] * pi, this.prevRotations[1]);
this.prevRotations[1] += directionY * this.speed / 10f;
this.prevRotations[1] = directionY == 1 ?
Math.min(this.rotation[1] * pi, this.prevRotations[1]) : Math.max(this.rotation[1] * pi, this.prevRotations[1]);
int directionZ = Float.compare(this.rotation[2] * pi, this.prevRotations[2]);
this.prevRotations[2] += directionZ * this.speed / 10f;
this.prevRotations[2] = directionZ == 1 ?
Math.min(this.rotation[2] * pi, this.prevRotations[2]) : Math.max(this.rotation[2] * pi, this.prevRotations[2]);
}
}
}
@SideOnly(Side.CLIENT)
public void interpolateOffset() {
if (parent != null && parent.paused)
return;
@SideOnly(Side.CLIENT)
public void interpolateOffset() {
if (parent != null && parent.paused)
return;
if (this.smooth == 2) {
this.prevPivots[0] = this.pivot[0];
this.prevPivots[1] = this.pivot[1];
this.prevPivots[2] = this.pivot[2];
} else if (this.partialPivotTick != ClientEventHandler.partialRenderTick) {
this.partialPivotTick = ClientEventHandler.partialRenderTick;
if (this.smooth == 0) {
this.prevPivots[0] = (this.pivot[0] - this.prevPivots[0]) * Math.abs(this.speed) / 10f + this.prevPivots[0];
this.prevPivots[1] = (this.pivot[1] - this.prevPivots[1]) * Math.abs(this.speed) / 10f + this.prevPivots[1];
this.prevPivots[2] = (this.pivot[2] - this.prevPivots[2]) * Math.abs(this.speed) / 10f + this.prevPivots[2];
} else {
int directionX = Float.compare(this.pivot[0], this.prevPivots[0]);
this.prevPivots[0] += directionX * this.speed / 10f;
this.prevPivots[0] = directionX == 1 ?
Math.min(this.pivot[0],this.prevPivots[0]) : Math.max(this.pivot[0],this.prevPivots[0]);
int directionY = Float.compare(this.pivot[1], this.prevPivots[1]);
this.prevPivots[1] += directionY * this.speed / 10f;
this.prevPivots[1] = directionY == 1 ?
Math.min(this.pivot[1],this.prevPivots[1]) : Math.max(this.pivot[1],this.prevPivots[1]);
int directionZ = Float.compare(this.pivot[2], this.prevPivots[2]);
this.prevPivots[2] += directionZ * this.speed / 10f;
this.prevPivots[2] = directionZ == 1 ?
Math.min(this.pivot[2],this.prevPivots[2]) : Math.max(this.pivot[2],this.prevPivots[2]);
}
}
}
if (this.smooth == 2) {
this.prevPivots[0] = this.pivot[0];
this.prevPivots[1] = this.pivot[1];
this.prevPivots[2] = this.pivot[2];
} else if (this.partialPivotTick != ClientEventHandler.partialRenderTick) {
this.partialPivotTick = ClientEventHandler.partialRenderTick;
if (this.smooth == 0) {
this.prevPivots[0] = (this.pivot[0] - this.prevPivots[0]) * Math.abs(this.speed) / 10f + this.prevPivots[0];
this.prevPivots[1] = (this.pivot[1] - this.prevPivots[1]) * Math.abs(this.speed) / 10f + this.prevPivots[1];
this.prevPivots[2] = (this.pivot[2] - this.prevPivots[2]) * Math.abs(this.speed) / 10f + this.prevPivots[2];
} else {
int directionX = Float.compare(this.pivot[0], this.prevPivots[0]);
this.prevPivots[0] += directionX * this.speed / 10f;
this.prevPivots[0] = directionX == 1 ?
Math.min(this.pivot[0], this.prevPivots[0]) : Math.max(this.pivot[0], this.prevPivots[0]);
int directionY = Float.compare(this.pivot[1], this.prevPivots[1]);
this.prevPivots[1] += directionY * this.speed / 10f;
this.prevPivots[1] = directionY == 1 ?
Math.min(this.pivot[1], this.prevPivots[1]) : Math.max(this.pivot[1], this.prevPivots[1]);
int directionZ = Float.compare(this.pivot[2], this.prevPivots[2]);
this.prevPivots[2] += directionZ * this.speed / 10f;
this.prevPivots[2] = directionZ == 1 ?
Math.min(this.pivot[2], this.prevPivots[2]) : Math.max(this.pivot[2], this.prevPivots[2]);
}
}
}
@SideOnly(Side.CLIENT)
public void jumpToCurrentFrame() {
this.partialRotationTick = ClientEventHandler.partialRenderTick;
this.partialPivotTick = ClientEventHandler.partialRenderTick;
@SideOnly(Side.CLIENT)
public void jumpToCurrentFrame() {
this.partialRotationTick = ClientEventHandler.partialRenderTick;
this.partialPivotTick = ClientEventHandler.partialRenderTick;
this.prevPivots[0] = this.pivot[0];
this.prevPivots[1] = this.pivot[1];
this.prevPivots[2] = this.pivot[2];
this.prevPivots[0] = this.pivot[0];
this.prevPivots[1] = this.pivot[1];
this.prevPivots[2] = this.pivot[2];
float pi = (float) Math.PI / 180;
this.prevRotations[0] = this.rotation[0] * pi;
this.prevRotations[1] = this.rotation[1] * pi;
this.prevRotations[2] = this.rotation[2] * pi;
}
float pi = (float) Math.PI / 180;
this.prevRotations[0] = this.rotation[0] * pi;
this.prevRotations[1] = this.rotation[1] * pi;
this.prevRotations[2] = this.rotation[2] * pi;
}
}
@@ -27,18 +27,20 @@ public class GlobalNPCDataScript implements INpcScriptHandler {
public boolean enabled = false;
public GlobalNPCDataScript(EntityNPCInterface npc) {
if(npc != null) {
if (npc != null) {
this.npc = npc;
}
}
public void clear() {
this.scripts = new ArrayList();
}
public void readFromNBT(NBTTagCompound compound) {
if (compound.hasKey("Scripts")) {
this.scripts = NBTTags.GetScriptOld(compound.getTagList("Scripts", 10), this);
} else {
this.scripts = NBTTags.GetScript(compound,this);
this.scripts = NBTTags.GetScript(compound, this);
}
this.scriptLanguage = compound.getString("ScriptLanguage");
if (!ScriptController.Instance.languages.containsKey(scriptLanguage)) {
@@ -50,10 +52,11 @@ public class GlobalNPCDataScript implements INpcScriptHandler {
}
this.enabled = compound.getBoolean("ScriptEnabled");
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setInteger("TotalScripts",this.scripts.size());
compound.setInteger("TotalScripts", this.scripts.size());
for (int i = 0; i < this.scripts.size(); i++) {
compound.setTag("Tab"+i,this.scripts.get(i).writeToNBT(new NBTTagCompound()));
compound.setTag("Tab" + i, this.scripts.get(i).writeToNBT(new NBTTagCompound()));
}
compound.setString("ScriptLanguage", this.scriptLanguage);
compound.setBoolean("ScriptEnabled", this.enabled);
@@ -81,7 +84,7 @@ public class GlobalNPCDataScript implements INpcScriptHandler {
}
for (ScriptContainer script : this.scripts) {
if(script == null || script.errored || !script.hasCode() )
if (script == null || script.errored || !script.hasCode())
continue;
script.run(hookName, event);
@@ -92,32 +95,40 @@ public class GlobalNPCDataScript implements INpcScriptHandler {
public boolean isClient() {
return this.npc.isClientWorld();
}
public boolean getEnabled() {
return this.enabled;
}
public void setEnabled(boolean bo) {
this.enabled = bo;
}
public String getLanguage() {
return this.scriptLanguage;
}
public void setLanguage(String lang) {
this.scriptLanguage = lang;
}
public void setScripts(List<ScriptContainer> list) {
this.scripts = list;
}
public List<ScriptContainer> getScripts() {
return this.scripts;
}
public String noticeString() {
if(this.npc == null) {
if (this.npc == null) {
return "Global script";
} else {
BlockPos pos = new BlockPos(this.npc);
return GlobalNPCDataScript.toStringHelper(this.npc).add("x", pos.getX()).add("y", pos.getY()).add("z", pos.getZ()).toString();
}
}
public ICustomNpc getNpc() {
if (this.npcAPI == null) {
this.npcAPI = (ICustomNpc) NpcAPI.Instance().getIEntity(this.npc);
@@ -150,6 +161,7 @@ public class GlobalNPCDataScript implements INpcScriptHandler {
private GlobalNPCDataScript.ToStringHelper.ValueHolder holderTail;
private boolean omitNullValues;
private boolean omitEmptyValues;
private ToStringHelper(String className) {
this.holderHead = new GlobalNPCDataScript.ToStringHelper.ValueHolder();
this.holderTail = this.holderHead;
@@ -157,81 +169,98 @@ public class GlobalNPCDataScript implements INpcScriptHandler {
this.omitEmptyValues = false;
this.className = (String) Preconditions.checkNotNull(className);
}
public GlobalNPCDataScript.ToStringHelper omitNullValues() {
this.omitNullValues = true;
return this;
}
public GlobalNPCDataScript.ToStringHelper add(String name, @CheckForNull Object value) {
return this.addHolder(name, value);
}
public GlobalNPCDataScript.ToStringHelper add(String name, boolean value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public GlobalNPCDataScript.ToStringHelper add(String name, char value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public GlobalNPCDataScript.ToStringHelper add(String name, double value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public GlobalNPCDataScript.ToStringHelper add(String name, float value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public GlobalNPCDataScript.ToStringHelper add(String name, int value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public GlobalNPCDataScript.ToStringHelper add(String name, long value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public GlobalNPCDataScript.ToStringHelper addValue(@CheckForNull Object value) {
return this.addHolder(value);
}
public GlobalNPCDataScript.ToStringHelper addValue(boolean value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public GlobalNPCDataScript.ToStringHelper addValue(char value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public GlobalNPCDataScript.ToStringHelper addValue(double value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public GlobalNPCDataScript.ToStringHelper addValue(float value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public GlobalNPCDataScript.ToStringHelper addValue(int value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public GlobalNPCDataScript.ToStringHelper addValue(long value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
private static boolean isEmpty(Object value) {
if (value instanceof CharSequence) {
return ((CharSequence)value).length() == 0;
return ((CharSequence) value).length() == 0;
} else if (value instanceof Collection) {
return ((Collection)value).isEmpty();
return ((Collection) value).isEmpty();
} else if (value instanceof Map) {
return ((Map)value).isEmpty();
return ((Map) value).isEmpty();
} else if (value instanceof Optional) {
return !((Optional)value).isPresent();
return !((Optional) value).isPresent();
} else if (value instanceof OptionalInt) {
return !((OptionalInt)value).isPresent();
return !((OptionalInt) value).isPresent();
} else if (value instanceof OptionalLong) {
return !((OptionalLong)value).isPresent();
return !((OptionalLong) value).isPresent();
} else if (value instanceof OptionalDouble) {
return !((OptionalDouble)value).isPresent();
return !((OptionalDouble) value).isPresent();
} else if (value instanceof com.google.common.base.Optional) {
return !((com.google.common.base.Optional)value).isPresent();
return !((com.google.common.base.Optional) value).isPresent();
} else if (value.getClass().isArray()) {
return Array.getLength(value) == 0;
} else {
return false;
}
}
public String toString() {
boolean omitNullValuesSnapshot = this.omitNullValues;
boolean omitEmptyValuesSnapshot = this.omitEmptyValues;
String nextSeparator = "";
StringBuilder builder = (new StringBuilder(32)).append(this.className).append('{');
for(GlobalNPCDataScript.ToStringHelper.ValueHolder valueHolder = this.holderHead.next; valueHolder != null; valueHolder = valueHolder.next) {
for (GlobalNPCDataScript.ToStringHelper.ValueHolder valueHolder = this.holderHead.next; valueHolder != null; valueHolder = valueHolder.next) {
Object value = valueHolder.value;
if (!(valueHolder instanceof GlobalNPCDataScript.ToStringHelper.UnconditionalValueHolder)) {
if (value == null) {
@@ -257,43 +286,51 @@ public class GlobalNPCDataScript implements INpcScriptHandler {
}
return builder.append('}').toString();
}
private GlobalNPCDataScript.ToStringHelper.ValueHolder addHolder() {
GlobalNPCDataScript.ToStringHelper.ValueHolder valueHolder = new GlobalNPCDataScript.ToStringHelper.ValueHolder();
this.holderTail = this.holderTail.next = valueHolder;
return valueHolder;
}
private GlobalNPCDataScript.ToStringHelper addHolder(@CheckForNull Object value) {
GlobalNPCDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder();
valueHolder.value = value;
return this;
}
private GlobalNPCDataScript.ToStringHelper addHolder(String name, @CheckForNull Object value) {
GlobalNPCDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder();
valueHolder.value = value;
valueHolder.name = (String)Preconditions.checkNotNull(name);
valueHolder.name = (String) Preconditions.checkNotNull(name);
return this;
}
private GlobalNPCDataScript.ToStringHelper.UnconditionalValueHolder addUnconditionalHolder() {
GlobalNPCDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = new GlobalNPCDataScript.ToStringHelper.UnconditionalValueHolder();
this.holderTail = this.holderTail.next = valueHolder;
return valueHolder;
}
private GlobalNPCDataScript.ToStringHelper addUnconditionalHolder(Object value) {
GlobalNPCDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder();
valueHolder.value = value;
return this;
}
private GlobalNPCDataScript.ToStringHelper addUnconditionalHolder(String name, Object value) {
GlobalNPCDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder();
valueHolder.value = value;
valueHolder.name = (String)Preconditions.checkNotNull(name);
valueHolder.name = (String) Preconditions.checkNotNull(name);
return this;
}
private static final class UnconditionalValueHolder extends GlobalNPCDataScript.ToStringHelper.ValueHolder {
private UnconditionalValueHolder() {
super();
}
}
private static class ValueHolder {
@CheckForNull
String name;
@@ -301,10 +338,12 @@ public class GlobalNPCDataScript implements INpcScriptHandler {
Object value;
@CheckForNull
GlobalNPCDataScript.ToStringHelper.ValueHolder next;
private ValueHolder() {
}
}
}
public static GlobalNPCDataScript.ToStringHelper toStringHelper(Object self) {
return new GlobalNPCDataScript.ToStringHelper(self.getClass().getSimpleName());
}
@@ -11,12 +11,12 @@ public class HitboxData {
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setBoolean("HitboxEnabled", hitboxEnabled);
if(hitboxEnabled) {
if(widthScale > ConfigMain.HitBoxScaleMax)
if (hitboxEnabled) {
if (widthScale > ConfigMain.HitBoxScaleMax)
widthScale = ConfigMain.HitBoxScaleMax;
nbttagcompound.setFloat("HitboxWidthScale", widthScale);
if(heightScale > ConfigMain.HitBoxScaleMax)
if (heightScale > ConfigMain.HitBoxScaleMax)
heightScale = ConfigMain.HitBoxScaleMax;
nbttagcompound.setFloat("HitboxHeightScale", heightScale);
}
@@ -25,13 +25,13 @@ public class HitboxData {
public void readFromNBT(NBTTagCompound nbttagcompound) {
hitboxEnabled = nbttagcompound.getBoolean("HitboxEnabled");
if(hitboxEnabled) {
if (hitboxEnabled) {
widthScale = nbttagcompound.getFloat("HitboxWidthScale");
if(widthScale > ConfigMain.HitBoxScaleMax)
if (widthScale > ConfigMain.HitBoxScaleMax)
widthScale = ConfigMain.HitBoxScaleMax;
heightScale = nbttagcompound.getFloat("HitboxHeightScale");
if(heightScale > ConfigMain.HitBoxScaleMax)
if (heightScale > ConfigMain.HitBoxScaleMax)
heightScale = ConfigMain.HitBoxScaleMax;
}
}
@@ -2,7 +2,7 @@ package noppes.npcs.controllers.data;
import noppes.npcs.api.IBlock;
public interface IScriptBlockHandler extends INpcScriptHandler{
public interface IScriptBlockHandler extends INpcScriptHandler {
public IBlock getBlock();
}
@@ -1,7 +1,7 @@
package noppes.npcs.controllers.data;
public class InnDoorData {
public int x = 0;
public int y = 0;
public int z = 0;
public int x = 0;
public int y = 0;
public int z = 0;
}
@@ -8,66 +8,67 @@ import noppes.npcs.api.handler.data.ILine;
public class Line implements ILine {
public Line(){
}
public Line(String text){
this.text = text;
}
public Line() {
public String text = "";
public String sound = "";
public boolean hideText = false;
public ILine copy() {
Line line = new Line(text);
line.sound = sound;
line.hideText = hideText;
return line;
}
public ILine formatTarget(EntityLivingBase entity) {
if(entity == null)
return this;
Line line = (Line) copy();
if(entity instanceof EntityPlayer)
line.text = line.text.replace("@target", ((EntityPlayer) entity).getDisplayName());
else
line.text = line.text.replace("@target", entity.getCommandSenderName());
return line;
}
}
public ILine formatTarget(IEntityLivingBase entityLivingBase) {
return this.formatTarget(entityLivingBase.getMCEntity());
}
public Line(String text) {
this.text = text;
}
@Override
public String getText() {
return this.text;
}
public String text = "";
public String sound = "";
public boolean hideText = false;
@Override
public void setText(String text) {
this.text = text;
}
public ILine copy() {
Line line = new Line(text);
line.sound = sound;
line.hideText = hideText;
return line;
}
@Override
public String getSound() {
return this.sound;
}
public ILine formatTarget(EntityLivingBase entity) {
if (entity == null)
return this;
Line line = (Line) copy();
if (entity instanceof EntityPlayer)
line.text = line.text.replace("@target", ((EntityPlayer) entity).getDisplayName());
else
line.text = line.text.replace("@target", entity.getCommandSenderName());
return line;
}
@Override
public void setSound(String sound) {
this.sound = sound;
}
public ILine formatTarget(IEntityLivingBase entityLivingBase) {
return this.formatTarget(entityLivingBase.getMCEntity());
}
@Override
public void hideText(boolean hide) {
this.hideText = hide;
}
@Override
public String getText() {
return this.text;
}
@Override
public boolean hideText() {
return this.hideText;
}
@Override
public void setText(String text) {
this.text = text;
}
@Override
public String getSound() {
return this.sound;
}
@Override
public void setSound(String sound) {
this.sound = sound;
}
@Override
public void hideText(boolean hide) {
this.hideText = hide;
}
@Override
public boolean hideText() {
return this.hideText;
}
}
@@ -11,88 +11,86 @@ import java.util.List;
import java.util.Random;
public class Lines implements ILines {
private static final Random random = new Random();
private int lastLine = -1;
private static final Random random = new Random();
private int lastLine = -1;
public HashMap<Integer,Line> lines = new HashMap<Integer,Line>();
public HashMap<Integer, Line> lines = new HashMap<Integer, Line>();
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
NBTTagList nbttaglist = new NBTTagList();
for(int slot : lines.keySet())
{
Line line = lines.get(slot);
for (int slot : lines.keySet()) {
Line line = lines.get(slot);
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Slot", slot);
nbttagcompound.setString("Line", line.text);
nbttagcompound.setString("Song", line.sound);
nbttaglist.appendTag(nbttagcompound);
}
compound.setTag("Lines", nbttaglist);
return compound;
}
public void readNBT(NBTTagCompound compound) {
NBTTagList nbttaglist = compound.getTagList("Lines", 10);
compound.setTag("Lines", nbttaglist);
return compound;
}
HashMap<Integer, Line> map = new HashMap<Integer, Line>();
for(int i = 0; i < nbttaglist.tagCount(); i++)
{
public void readNBT(NBTTagCompound compound) {
NBTTagList nbttaglist = compound.getTagList("Lines", 10);
HashMap<Integer, Line> map = new HashMap<Integer, Line>();
for (int i = 0; i < nbttaglist.tagCount(); i++) {
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
Line line = new Line();
line.text = nbttagcompound.getString("Line");
line.sound = nbttagcompound.getString("Song");
map.put(nbttagcompound.getInteger("Slot"), line);
}
lines = map;
}
}
public ILine createLine(String text) {
return new Line(text);
}
public ILine createLine(String text) {
return new Line(text);
}
public ILine getLine(boolean isRandom) {
if(lines.isEmpty())
return null;
if(isRandom){
List<Line> lines = new ArrayList<Line>(this.lines.values());
return lines.get(random.nextInt(lines.size()));
}
lastLine++;
while(true){
lastLine %= 8;
Line line = lines.get(lastLine);
if(line != null)
return line.copy();
lastLine++;
}
}
public ILine getLine(boolean isRandom) {
if (lines.isEmpty())
return null;
if (isRandom) {
List<Line> lines = new ArrayList<Line>(this.lines.values());
return lines.get(random.nextInt(lines.size()));
}
lastLine++;
while (true) {
lastLine %= 8;
Line line = lines.get(lastLine);
if (line != null)
return line.copy();
lastLine++;
}
}
public ILine getLine(int lineIndex) {
return lines.get(lineIndex);
}
public ILine getLine(int lineIndex) {
return lines.get(lineIndex);
}
public void setLine(int lineIndex, ILine line) {
lines.put(lineIndex, (Line) line);
}
public void setLine(int lineIndex, ILine line) {
lines.put(lineIndex, (Line) line);
}
public void removeLine(int lineIndex) {
lines.remove(lineIndex);
}
public void removeLine(int lineIndex) {
lines.remove(lineIndex);
}
public void clear() {
lines.clear();
}
public void clear() {
lines.clear();
}
public boolean isEmpty() {
return lines.isEmpty();
}
public boolean isEmpty() {
return lines.isEmpty();
}
public Integer[] getKeys() {
return lines.keySet().toArray(new Integer[0]);
}
public Integer[] getKeys() {
return lines.keySet().toArray(new Integer[0]);
}
}
@@ -52,8 +52,8 @@ public class LinkedItem implements ILinkedItem {
compound.setTag("Display", this.display.writeToNBT());
compound.setDouble("DurabilityValue",this.durabilityValue);
compound.setInteger("MaxStackSize",this.stackSize);
compound.setDouble("DurabilityValue", this.durabilityValue);
compound.setInteger("MaxStackSize", this.stackSize);
compound.setBoolean("IsTool", this.isTool);
compound.setBoolean("IsNormalItem", this.isNormalItem);
@@ -248,7 +248,7 @@ public class LinkedItem implements ILinkedItem {
public LinkedItemScript getOrCreateScriptHandler() {
LinkedItemScript data = getScriptHandler();
if (data == null)
setScriptHandler(data =new LinkedItemScript());
setScriptHandler(data = new LinkedItemScript());
return data;
}
}
@@ -108,14 +108,14 @@ public class LinkedItemScript implements INpcScriptHandler {
int tab = 0;
Iterator var3 = this.getScripts().iterator();
while(var3.hasNext()) {
ScriptContainer script = (ScriptContainer)var3.next();
while (var3.hasNext()) {
ScriptContainer script = (ScriptContainer) var3.next();
++tab;
Iterator var5 = script.console.entrySet().iterator();
while(var5.hasNext()) {
Map.Entry<Long, String> longStringEntry = (Map.Entry)var5.next();
map.put(longStringEntry.getKey(), " tab " + tab + ":\n" + (String)longStringEntry.getValue());
while (var5.hasNext()) {
Map.Entry<Long, String> longStringEntry = (Map.Entry) var5.next();
map.put(longStringEntry.getKey(), " tab " + tab + ":\n" + (String) longStringEntry.getValue());
}
}
@@ -126,8 +126,8 @@ public class LinkedItemScript implements INpcScriptHandler {
public void clearConsole() {
Iterator var1 = this.getScripts().iterator();
while(var1.hasNext()) {
ScriptContainer script = (ScriptContainer)var1.next();
while (var1.hasNext()) {
ScriptContainer script = (ScriptContainer) var1.next();
script.console.clear();
}
}
@@ -24,7 +24,8 @@ public class Magic implements IMagic {
public String iconTexture = "";
public Map<Integer, Float> interactions = new HashMap<>();
public Magic() {}
public Magic() {
}
public Magic(int id, String name, int color) {
this.name = name;
@@ -46,7 +47,7 @@ public class Magic implements IMagic {
type = EnumTextureType.values()[compound.getInteger("Type")];
iconTexture = compound.getString("IconTexture");
if(type == EnumTextureType.ITEM && !iconTexture.isEmpty()){
if (type == EnumTextureType.ITEM && !iconTexture.isEmpty()) {
String[] parts = iconTexture.split(":");
if (parts.length == 2) {
String modID = parts[0];
@@ -57,9 +58,9 @@ public class Magic implements IMagic {
}
interactions.clear();
if(compound.hasKey("Interactions")) {
if (compound.hasKey("Interactions")) {
NBTTagList interactionsList = compound.getTagList("Interactions", 10);
for (int i = 0; i < interactionsList.tagCount(); i++){
for (int i = 0; i < interactionsList.tagCount(); i++) {
NBTTagCompound interactionTag = interactionsList.getCompoundTagAt(i);
int magicId = interactionTag.getInteger("MagicID");
float percentage = interactionTag.getFloat("Percentage");
@@ -76,7 +77,7 @@ public class Magic implements IMagic {
compound.setString("IconTexture", iconTexture);
compound.setInteger("Type", type.ordinal());
NBTTagList interactionsList = new NBTTagList();
for (Map.Entry<Integer, Float> entry : interactions.entrySet()){
for (Map.Entry<Integer, Float> entry : interactions.entrySet()) {
NBTTagCompound interactionTag = new NBTTagCompound();
interactionTag.setInteger("MagicID", entry.getKey());
interactionTag.setFloat("Percentage", entry.getValue());
@@ -84,7 +85,7 @@ public class Magic implements IMagic {
}
compound.setTag("Interactions", interactionsList);
if(type == EnumTextureType.ITEM && !iconTexture.isEmpty()){
if (type == EnumTextureType.ITEM && !iconTexture.isEmpty()) {
String[] parts = iconTexture.split(":");
if (parts.length == 2) {
String modID = parts[0];
@@ -130,7 +131,7 @@ public class Magic implements IMagic {
public void setItem(ItemStack item) {
GameRegistry.UniqueIdentifier identifier = GameRegistry.findUniqueIdentifierFor(item.getItem());
if(identifier != null){
if (identifier != null) {
this.item = item;
this.type = EnumTextureType.ITEM;
this.iconTexture = identifier.modId + ":" + identifier.name;
@@ -16,7 +16,9 @@ public class MagicCycle {
public String displayName = "";
public EnumDiagramLayout layout = EnumDiagramLayout.CIRCULAR;
public HashMap<Integer, MagicAssociation> associations = new HashMap<>();
public MagicCycle() {}
public MagicCycle() {
}
public void readNBT(NBTTagCompound compound) {
id = compound.getInteger("ID");
@@ -19,7 +19,7 @@ public class MagicData implements IMagicData {
public void readToNBT(NBTTagCompound compound) {
NBTTagCompound magicData = compound.getCompoundTag("MagicData");
magics.clear();
if(magicData == null)
if (magicData == null)
return;
for (Object key : magicData.func_150296_c()) {
int i = Integer.parseInt((String) key);
@@ -19,49 +19,49 @@ import java.util.List;
public class MarkData implements IExtendedEntityProperties {
private static final String CNPCMARK = "cnpcmark";
private EntityLivingBase entity;
private EntityLivingBase entity;
public List<Mark> marks = new ArrayList<Mark>();
public List<Mark> marks = new ArrayList<Mark>();
public void setNBT(NBTTagCompound compound){
List<Mark> marks = new ArrayList<Mark>();
NBTTagList list = compound.getTagList("marks", 10);
for(int i = 0; i < list.tagCount(); i++){
NBTTagCompound c = list.getCompoundTagAt(i);
Mark m = new Mark();
m.type = c.getInteger("type");
m.color = c.getInteger("color");
m.availability.readFromNBT(c.getCompoundTag("availability"));
marks.add(m);
}
this.marks = marks;
}
public void setNBT(NBTTagCompound compound) {
List<Mark> marks = new ArrayList<Mark>();
NBTTagList list = compound.getTagList("marks", 10);
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound c = list.getCompoundTagAt(i);
Mark m = new Mark();
m.type = c.getInteger("type");
m.color = c.getInteger("color");
m.availability.readFromNBT(c.getCompoundTag("availability"));
marks.add(m);
}
this.marks = marks;
}
public NBTTagCompound getNBT() {
NBTTagCompound compound = new NBTTagCompound();
NBTTagList list = new NBTTagList();
for(Mark m : marks){
NBTTagCompound c = new NBTTagCompound();
c.setInteger("type", m.type);
c.setInteger("color", m.color);
c.setTag("availability", m.availability.writeToNBT(new NBTTagCompound()));
list.appendTag(c);
}
compound.setTag("marks", list);
return compound;
}
public NBTTagCompound getNBT() {
NBTTagCompound compound = new NBTTagCompound();
NBTTagList list = new NBTTagList();
for (Mark m : marks) {
NBTTagCompound c = new NBTTagCompound();
c.setInteger("type", m.type);
c.setInteger("color", m.color);
c.setTag("availability", m.availability.writeToNBT(new NBTTagCompound()));
list.appendTag(c);
}
compound.setTag("marks", list);
return compound;
}
public static boolean has(EntityLivingBase entity) {
return entity.getExtendedProperties(CNPCMARK) != null;
}
public static MarkData get(EntityNPCInterface npc){
if(!MarkData.has(npc)){
public static MarkData get(EntityNPCInterface npc) {
if (!MarkData.has(npc)) {
npc.registerExtendedProperties(CNPCMARK, new MarkData());
}
MarkData data = (MarkData) npc.getExtendedProperties(CNPCMARK);
if(data.entity == null){
if (data.entity == null) {
data.entity = npc;
data.setNBT(npc.getEntityData().getCompoundTag(CNPCMARK));
}
@@ -96,48 +96,50 @@ public class MarkData implements IExtendedEntityProperties {
}
@Override
public void loadNBTData(NBTTagCompound compound) {}
public void loadNBTData(NBTTagCompound compound) {
}
@Override
public void init(Entity entity, World world) {}
public void init(Entity entity, World world) {
}
public void syncClients() {
PacketHandler.Instance.sendToAll(new MarkDataPacket(entity.getEntityId(), getNBT()));
}
public class Mark implements IMark {
public int type = MarkType.NONE;
public Availability availability = new Availability();
public int color = 0xFFED51;
public int type = MarkType.NONE;
public Availability availability = new Availability();
public int color = 0xFFED51;
@Override
public IAvailability getAvailability() {
return availability;
}
@Override
public IAvailability getAvailability() {
return availability;
}
@Override
public int getColor() {
return color;
}
@Override
public int getColor() {
return color;
}
@Override
public void setColor(int color) {
this.color = color;
}
@Override
public void setColor(int color) {
this.color = color;
}
@Override
public int getType() {
return type;
}
@Override
public int getType() {
return type;
}
@Override
public void setType(int type) {
this.type = type;
}
@Override
public void setType(int type) {
this.type = type;
}
@Override
public void update() {
MarkData.this.syncClients();
}
}
@Override
public void update() {
MarkData.this.syncClients();
}
}
}
@@ -93,8 +93,8 @@ public class Party implements IParty {
}
public EnumPartyObjectives getObjectiveRequirement() {
if(getQuestData() != null){
if(getQuestData().quest != null){
if (getQuestData() != null) {
if (getQuestData().quest != null) {
return getQuestData().quest.partyOptions.objectiveRequirement;
}
}
@@ -114,7 +114,7 @@ public class Party implements IParty {
public boolean addPlayer(EntityPlayer player) {
if (player == null) return false;
if(partyMembers.containsKey(player.getUniqueID())){
if (partyMembers.containsKey(player.getUniqueID())) {
return false;
}
@@ -130,12 +130,12 @@ public class Party implements IParty {
if (player == null) return false;
UUID uuid = player.getUniqueID();
if(partyMembers.containsKey(uuid)){
if (partyMembers.containsKey(uuid)) {
partyMembers.remove(uuid);
partyOrder.remove(uuid);
if(uuid.equals(partyLeader)){
if(partyMembers.size() > 0){
if (uuid.equals(partyLeader)) {
if (partyMembers.size() > 0) {
partyLeader = partyOrder.get(0);
}
}
@@ -151,11 +151,11 @@ public class Party implements IParty {
public boolean removePlayer(UUID uuid) {
if (uuid == null) return false;
if(partyMembers.containsKey(uuid)){
if (partyMembers.containsKey(uuid)) {
partyMembers.remove(uuid);
partyOrder.remove(uuid);
if(uuid.equals(partyLeader)){
if(!partyMembers.isEmpty()){
if (uuid.equals(partyLeader)) {
if (!partyMembers.isEmpty()) {
partyLeader = partyOrder.get(0);
}
}
@@ -179,12 +179,12 @@ public class Party implements IParty {
@Override
public boolean addPlayer(IPlayer player) {
return player != null && this.addPlayer((EntityPlayerMP)player.getMCEntity());
return player != null && this.addPlayer((EntityPlayerMP) player.getMCEntity());
}
@Override
public boolean removePlayer(IPlayer player) {
return player != null && this.removePlayer((EntityPlayerMP)player.getMCEntity());
return player != null && this.removePlayer((EntityPlayerMP) player.getMCEntity());
}
public boolean hasPlayer(EntityPlayer player) {
@@ -193,16 +193,16 @@ public class Party implements IParty {
@Override
public boolean hasPlayer(IPlayer player) {
if(player == null)
if (player == null)
return false;
EntityPlayer entityPlayer = (EntityPlayer)player.getMCEntity();
EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity();
return partyMembers.containsKey(entityPlayer.getUniqueID());
}
@Override
public boolean hasPlayer(String playerName) {
UUID uuid = getUUID(playerName);
if (uuid == null){
if (uuid == null) {
return false;
}
return partyMembers.containsKey(uuid);
@@ -221,13 +221,13 @@ public class Party implements IParty {
}
}
public boolean setLeader(EntityPlayer player){
public boolean setLeader(EntityPlayer player) {
UUID uuid = player.getUniqueID();
if(partyLeader != null && partyLeader.equals(uuid)){
if (partyLeader != null && partyLeader.equals(uuid)) {
return false;
}
if(!partyMembers.containsKey(uuid)){
if (!partyMembers.containsKey(uuid)) {
return false;
}
@@ -274,7 +274,7 @@ public class Party implements IParty {
// Called when Set Quest is Called
@Override
public boolean validateQuest(int questID, boolean sendLeaderMessages){
public boolean validateQuest(int questID, boolean sendLeaderMessages) {
IQuest quest = QuestController.Instance.get(questID);
if (quest == null) {
return false;
@@ -304,7 +304,7 @@ public class Party implements IParty {
EnumPartyRequirements partyRequirements = EnumPartyRequirements.values()[partyReq];
if (partyRequirements == EnumPartyRequirements.Leader) {
boolean leaderBool = isValidLeaderQuest(leader, questID);
if(!leaderBool){
if (!leaderBool) {
sendInfoMessage(leader, "\u00A7cYou are invalid for this quest", sendLeaderMessages);
}
return leaderBool;
@@ -355,7 +355,7 @@ public class Party implements IParty {
}
private void sendInfoMessage(EntityPlayer player, String message, boolean send) {
if(!send)
if (!send)
return;
player.addChatMessage(new ChatComponentText(String.format("\u00A7c%s", message)));
@@ -376,12 +376,13 @@ public class Party implements IParty {
try {
BufferedReader in = new BufferedReader(new InputStreamReader(new URL("https://api.mojang.com/users/profiles/minecraft/" + name).openStream()));
String uuidString;
uuidString = (((JsonObject)new JsonParser().parse(in)).get("id")).toString().replaceAll("\"", "");
uuidString = (((JsonObject) new JsonParser().parse(in)).get("id")).toString().replaceAll("\"", "");
uuidString = uuidString.replaceAll("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5");
in.close();
uuid = UUID.fromString(uuidString);
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
return uuid;
}
@@ -441,14 +442,14 @@ public class Party implements IParty {
}
@Override
public void updateQuestObjectiveData(){
public void updateQuestObjectiveData() {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
PartyController.Instance().pingPartyQuestObjectiveUpdate(this);
}
}
@Override
public void updatePartyData(){
public void updatePartyData() {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
PartyController.Instance().pingPartyUpdate(this);
}
@@ -10,123 +10,120 @@ import noppes.npcs.constants.EnumPartyRequirements;
import java.util.Vector;
public class PartyOptions implements IPartyOptions {
public boolean allowParty = false;
public boolean allowParty = false;
public boolean onlyParty = false;
public EnumPartyRequirements partyRequirements = EnumPartyRequirements.Leader;
public EnumPartyExchange rewardControl = EnumPartyExchange.Leader;
public EnumPartyExchange completeFor = EnumPartyExchange.Leader;
public EnumPartyExchange completeFor = EnumPartyExchange.Leader;
public EnumPartyExchange executeCommand = EnumPartyExchange.Leader;
public EnumPartyObjectives objectiveRequirement = EnumPartyObjectives.Shared;
public int minPartySize = ConfigMain.DefaultMinPartySize;
public int maxPartySize = ConfigMain.DefaultMaxPartySize;
public int maxPartySize = ConfigMain.DefaultMaxPartySize;
public void readFromNBT(NBTTagCompound compound)
{
// Party Management
allowParty = compound.getBoolean("AllowParty");
if(allowParty){
public void readFromNBT(NBTTagCompound compound) {
// Party Management
allowParty = compound.getBoolean("AllowParty");
if (allowParty) {
onlyParty = compound.getBoolean("OnlyParty");
partyRequirements = EnumPartyRequirements.values()[compound.getInteger("PartyRequirements")];
rewardControl = EnumPartyExchange.values()[compound.getInteger("RewardControl")];
completeFor = EnumPartyExchange.values()[compound.getInteger("CompleteFor")];
partyRequirements = EnumPartyRequirements.values()[compound.getInteger("PartyRequirements")];
rewardControl = EnumPartyExchange.values()[compound.getInteger("RewardControl")];
completeFor = EnumPartyExchange.values()[compound.getInteger("CompleteFor")];
executeCommand = EnumPartyExchange.values()[compound.getInteger("ExecuteCommand")];
minPartySize = compound.getInteger("MinPartySize");
maxPartySize = compound.getInteger("MaxPartySize");
maxPartySize = compound.getInteger("MaxPartySize");
objectiveRequirement = EnumPartyObjectives.values()[compound.getInteger("ObjectiveRequirement")];
}
else {
if(compound.hasKey("OnlyParty")){
} else {
if (compound.hasKey("OnlyParty")) {
compound.removeTag("OnlyParty");
}
if(compound.hasKey("PartyRequirements")){
compound.removeTag("PartyRequirements");
}
if(compound.hasKey("RewardControl")){
compound.removeTag("RewardControl");
}
if(compound.hasKey("CompleteFor")){
compound.removeTag("CompleteFor");
}
if(compound.hasKey("ExecuteCommand")){
if (compound.hasKey("PartyRequirements")) {
compound.removeTag("PartyRequirements");
}
if (compound.hasKey("RewardControl")) {
compound.removeTag("RewardControl");
}
if (compound.hasKey("CompleteFor")) {
compound.removeTag("CompleteFor");
}
if (compound.hasKey("ExecuteCommand")) {
compound.removeTag("ExecuteCommand");
}
if(compound.hasKey("MinPartySize")){
if (compound.hasKey("MinPartySize")) {
compound.removeTag("MinPartySize");
}
if(compound.hasKey("MaxPartySize")){
compound.removeTag("MaxPartySize");
}
if(compound.hasKey("ObjectiveRequirement")){
if (compound.hasKey("MaxPartySize")) {
compound.removeTag("MaxPartySize");
}
if (compound.hasKey("ObjectiveRequirement")) {
compound.removeTag("ObjectiveRequirement");
}
onlyParty = false;
partyRequirements = EnumPartyRequirements.Leader;
rewardControl = EnumPartyExchange.Leader;
completeFor = EnumPartyExchange.Leader;
rewardControl = EnumPartyExchange.Leader;
completeFor = EnumPartyExchange.Leader;
executeCommand = EnumPartyExchange.Leader;
minPartySize = ConfigMain.DefaultMinPartySize;
maxPartySize = ConfigMain.DefaultMaxPartySize;
maxPartySize = ConfigMain.DefaultMaxPartySize;
objectiveRequirement = EnumPartyObjectives.Shared;
}
}
}
public NBTTagCompound writeToNBT()
{
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("AllowParty", allowParty);
if(allowParty){
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("AllowParty", allowParty);
if (allowParty) {
compound.setBoolean("OnlyParty", onlyParty);
compound.setInteger("PartyRequirements", partyRequirements.ordinal());
compound.setInteger("RewardControl", rewardControl.ordinal());
compound.setInteger("CompleteFor", completeFor.ordinal());
compound.setInteger("PartyRequirements", partyRequirements.ordinal());
compound.setInteger("RewardControl", rewardControl.ordinal());
compound.setInteger("CompleteFor", completeFor.ordinal());
compound.setInteger("ExecuteCommand", executeCommand.ordinal());
compound.setInteger("MinPartySize", minPartySize);
compound.setInteger("MaxPartySize", maxPartySize);
compound.setInteger("MaxPartySize", maxPartySize);
compound.setInteger("ObjectiveRequirement", objectiveRequirement.ordinal());
}
else {
if(compound.hasKey("OnlyParty")){
} else {
if (compound.hasKey("OnlyParty")) {
compound.removeTag("OnlyParty");
}
if(compound.hasKey("PartyRequirements")){
compound.removeTag("PartyRequirements");
}
if(compound.hasKey("RewardControl")){
compound.removeTag("RewardControl");
}
if(compound.hasKey("CompleteFor")){
compound.removeTag("CompleteFor");
}
if(compound.hasKey("ExecuteCommand")){
if (compound.hasKey("PartyRequirements")) {
compound.removeTag("PartyRequirements");
}
if (compound.hasKey("RewardControl")) {
compound.removeTag("RewardControl");
}
if (compound.hasKey("CompleteFor")) {
compound.removeTag("CompleteFor");
}
if (compound.hasKey("ExecuteCommand")) {
compound.removeTag("ExecuteCommand");
}
if(compound.hasKey("MinPartySize")){
if (compound.hasKey("MinPartySize")) {
compound.removeTag("MinPartySize");
}
if(compound.hasKey("MaxPartySize")){
compound.removeTag("MaxPartySize");
}
if(compound.hasKey("ObjectiveRequirement")){
if (compound.hasKey("MaxPartySize")) {
compound.removeTag("MaxPartySize");
}
if (compound.hasKey("ObjectiveRequirement")) {
compound.removeTag("ObjectiveRequirement");
}
}
}
return compound;
return compound;
}
@Override
public boolean isAllowParty() {
return allowParty;
}
public boolean isAllowParty() {
return allowParty;
}
@Override
public void setAllowParty(boolean allowParty) {
this.allowParty = allowParty;
}
public void setAllowParty(boolean allowParty) {
this.allowParty = allowParty;
}
@Override
public boolean isOnlyParty() {
@@ -139,43 +136,43 @@ public class PartyOptions implements IPartyOptions {
}
@Override
public int getPartyRequirements() {
return partyRequirements.ordinal();
}
public int getPartyRequirements() {
return partyRequirements.ordinal();
}
@Override
public void setPartyRequirements(int partyReq) {
if (partyReq < 0 || partyReq >= EnumPartyRequirements.values().length) {
return;
}
this.partyRequirements = EnumPartyRequirements.values()[partyReq];
}
public void setPartyRequirements(int partyReq) {
if (partyReq < 0 || partyReq >= EnumPartyRequirements.values().length) {
return;
}
this.partyRequirements = EnumPartyRequirements.values()[partyReq];
}
@Override
public int getRewardControl() {
return rewardControl.ordinal();
}
public int getRewardControl() {
return rewardControl.ordinal();
}
@Override
public void setRewardControl(int rewardCon) {
if (rewardCon < 0 || rewardCon >= EnumPartyExchange.values().length) {
return;
}
this.rewardControl = EnumPartyExchange.values()[rewardCon];
}
public void setRewardControl(int rewardCon) {
if (rewardCon < 0 || rewardCon >= EnumPartyExchange.values().length) {
return;
}
this.rewardControl = EnumPartyExchange.values()[rewardCon];
}
@Override
public int getCompleteFor() {
return completeFor.ordinal();
}
public int getCompleteFor() {
return completeFor.ordinal();
}
@Override
public void setCompleteFor(int compFor) {
if (compFor < 0 || compFor >= EnumPartyExchange.values().length) {
return;
}
this.completeFor = EnumPartyExchange.values()[compFor];
}
public void setCompleteFor(int compFor) {
if (compFor < 0 || compFor >= EnumPartyExchange.values().length) {
return;
}
this.completeFor = EnumPartyExchange.values()[compFor];
}
@Override
public int getExecuteCommandFor() {
@@ -210,31 +207,31 @@ public class PartyOptions implements IPartyOptions {
@Override
public void setMinPartySize(int newSize) {
if(newSize < 1)
if (newSize < 1)
newSize = 1;
if(newSize > maxPartySize)
if (newSize > maxPartySize)
newSize = maxPartySize;
minPartySize = newSize;
}
@Override
public int getMaxPartySize() {
return maxPartySize;
}
public int getMaxPartySize() {
return maxPartySize;
}
@Override
public void setMaxPartySize(int newSize) {
if(newSize < minPartySize)
@Override
public void setMaxPartySize(int newSize) {
if (newSize < minPartySize)
newSize = minPartySize;
maxPartySize = newSize;
}
maxPartySize = newSize;
}
public Vector<String> getPartyOptionsList() {
Vector<String> vec = new Vector<String>();
if(onlyParty){
if (onlyParty) {
vec.add("party.only" + ":" + "gui.yes");
}
vec.add("party.partyRequirements" + ":" + partyRequirements.name);
@@ -8,58 +8,60 @@ import noppes.npcs.controllers.BankController;
import java.util.HashMap;
public class PlayerBankData implements IPlayerBankData {
private final PlayerData parent;
public HashMap<Integer,BankData> banks;
private final PlayerData parent;
public HashMap<Integer, BankData> banks;
public PlayerBankData(PlayerData parent){
banks = new HashMap<Integer,BankData>();
this.parent = parent;
}
public void loadNBTData(NBTTagCompound compound) {
HashMap<Integer,BankData> banks = new HashMap<Integer,BankData>();
public PlayerBankData(PlayerData parent) {
banks = new HashMap<Integer, BankData>();
this.parent = parent;
}
public void loadNBTData(NBTTagCompound compound) {
HashMap<Integer, BankData> banks = new HashMap<Integer, BankData>();
NBTTagList list = compound.getTagList("BankData", 10);
if(list == null){
return;
if (list == null) {
return;
}
for(int i = 0; i < list.tagCount(); i++)
{
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
BankData data = new BankData();
BankData data = new BankData();
data.readNBT(nbttagcompound);
banks.put(data.bankId, data);
}
this.banks = banks;
}
}
public void saveNBTData(NBTTagCompound playerData){
NBTTagList list = new NBTTagList();
for(BankData data : banks.values()){
NBTTagCompound nbttagcompound = new NBTTagCompound();
data.writeNBT(nbttagcompound);
list.appendTag(nbttagcompound);
}
playerData.setTag("BankData", list);
}
public void saveNBTData(NBTTagCompound playerData) {
NBTTagList list = new NBTTagList();
for (BankData data : banks.values()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
data.writeNBT(nbttagcompound);
list.appendTag(nbttagcompound);
}
playerData.setTag("BankData", list);
}
public BankData getBank(int bankId) {
return banks.get(bankId);
}
public BankData getBankOrDefault(int bankId) {
BankData data = banks.get(bankId);
if(data != null)
return data;
Bank bank = BankController.getInstance().getBank(bankId);
return banks.get(bank.id);
}
public boolean hasBank(int bank) {
return banks.containsKey(bank);
}
public void loadNew(int bank) {
BankData data = new BankData();
data.bankId = bank;
banks.put(bank, data);
}
public BankData getBank(int bankId) {
return banks.get(bankId);
}
public BankData getBankOrDefault(int bankId) {
BankData data = banks.get(bankId);
if (data != null)
return data;
Bank bank = BankController.getInstance().getBank(bankId);
return banks.get(bank.id);
}
public boolean hasBank(int bank) {
return banks.containsKey(bank);
}
public void loadNew(int bank) {
BankData data = new BankData();
data.bankId = bank;
banks.put(bank, data);
}
}
@@ -38,43 +38,43 @@ import java.util.HashSet;
import java.util.UUID;
public class PlayerData implements IExtendedEntityProperties, IPlayerData {
public PlayerDialogData dialogData = new PlayerDialogData(this);
public PlayerBankData bankData = new PlayerBankData(this);
public PlayerQuestData questData = new PlayerQuestData(this);
public PlayerTransportData transportData = new PlayerTransportData(this);
public PlayerFactionData factionData = new PlayerFactionData(this);
public PlayerItemGiverData itemgiverData = new PlayerItemGiverData(this);
public PlayerMailData mailData = new PlayerMailData(this);
public AnimationData animationData = new AnimationData(this);
public PlayerDialogData dialogData = new PlayerDialogData(this);
public PlayerBankData bankData = new PlayerBankData(this);
public PlayerQuestData questData = new PlayerQuestData(this);
public PlayerTransportData transportData = new PlayerTransportData(this);
public PlayerFactionData factionData = new PlayerFactionData(this);
public PlayerItemGiverData itemgiverData = new PlayerItemGiverData(this);
public PlayerMailData mailData = new PlayerMailData(this);
public AnimationData animationData = new AnimationData(this);
public PlayerEffectData effectData = new PlayerEffectData(this);
public DataTimers timers = new DataTimers(this);
public DataSkinOverlays skinOverlays = new DataSkinOverlays(this);
public DataTimers timers = new DataTimers(this);
public DataSkinOverlays skinOverlays = new DataSkinOverlays(this);
public MagicData magicData = new MagicData();
public EntityNPCInterface editingNpc;
public NBTTagCompound cloned;
public EntityNPCInterface editingNpc;
public NBTTagCompound cloned;
public UUID partyUUID = null;
private final HashSet<UUID> partyInvites = new HashSet<>();
public UUID partyUUID = null;
private final HashSet<UUID> partyInvites = new HashSet<>();
public EntityPlayer player;
public EntityPlayer player;
public String playername = "";
public String uuid = "";
public String playername = "";
public String uuid = "";
private EntityNPCInterface activeCompanion = null;
public int companionID = 0;
private EntityNPCInterface activeCompanion = null;
public int companionID = 0;
public boolean isGUIOpen = false;
public boolean isGUIOpen = false;
public boolean hadInteract = true;
public boolean updateClient = false;
public ScreenSize screenSize = new ScreenSize(-1,-1);
public ScreenSize screenSize = new ScreenSize(-1, -1);
public int profileSlot = 0;
public void onLogin() {
public void onLogin() {
// Continue playing animation for self when re-logging
AnimationData animationData = this.animationData;
if (animationData != null && animationData.isClientAnimating()) {
@@ -92,57 +92,57 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
}
}
public void onLogout() {
this.partyInvites.clear();
}
public void onLogout() {
this.partyInvites.clear();
}
@Override
public void saveNBTData(NBTTagCompound nbtTagCompound) {
}
@Override
public void saveNBTData(NBTTagCompound nbtTagCompound) {
}
@Override
public void loadNBTData(NBTTagCompound compound) {
}
@Override
public void loadNBTData(NBTTagCompound compound) {
}
public void setNBT(NBTTagCompound data){
dialogData.loadNBTData(data);
bankData.loadNBTData(data);
questData.loadNBTData(data);
transportData.loadNBTData(data);
factionData.loadNBTData(data);
itemgiverData.loadNBTData(data);
mailData.loadNBTData(data);
timers.readFromNBT(data);
skinOverlays.readFromNBT(data);
animationData.readFromNBT(data);
public void setNBT(NBTTagCompound data) {
dialogData.loadNBTData(data);
bankData.loadNBTData(data);
questData.loadNBTData(data);
transportData.loadNBTData(data);
factionData.loadNBTData(data);
itemgiverData.loadNBTData(data);
mailData.loadNBTData(data);
timers.readFromNBT(data);
skinOverlays.readFromNBT(data);
animationData.readFromNBT(data);
effectData.readFromNBT(data);
magicData.readToNBT(data);
if(player != null){
playername = player.getCommandSenderName();
uuid = player.getPersistentID().toString();
}
else{
playername = data.getString("PlayerName");
uuid = data.getString("UUID");
}
companionID = data.getInteger("PlayerCompanionId");
if (player != null) {
playername = player.getCommandSenderName();
uuid = player.getPersistentID().toString();
} else {
playername = data.getString("PlayerName");
uuid = data.getString("UUID");
}
companionID = data.getInteger("PlayerCompanionId");
profileSlot = data.getInteger("ProfileSlot");
if(data.hasKey("PlayerCompanion") && !hasCompanion()){
EntityCustomNpc npc = new EntityCustomNpc(player.worldObj);
npc.readEntityFromNBT(data.getCompoundTag("PlayerCompanion"));
npc.setPosition(player.posX, player.posY, player.posZ);
if(npc.advanced.role == EnumRoleType.Companion){
setCompanion(npc);
((RoleCompanion)npc.roleInterface).setSitting(false);
player.worldObj.spawnEntityInWorld(npc);
}
}
isGUIOpen = data.getBoolean("isGUIOpen");
if (data.hasKey("PlayerCompanion") && !hasCompanion()) {
EntityCustomNpc npc = new EntityCustomNpc(player.worldObj);
npc.readEntityFromNBT(data.getCompoundTag("PlayerCompanion"));
npc.setPosition(player.posX, player.posY, player.posZ);
if (npc.advanced.role == EnumRoleType.Companion) {
setCompanion(npc);
((RoleCompanion) npc.roleInterface).setSitting(false);
player.worldObj.spawnEntityInWorld(npc);
}
}
isGUIOpen = data.getBoolean("isGUIOpen");
DBCAddon.instance.readFromNBT(this, data);
}
}
public NBTTagCompound getNBT() {
if(player != null){
if (player != null) {
playername = player.getCommandSenderName();
uuid = player.getPersistentID().toString();
}
@@ -163,19 +163,19 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
compound.setString("PlayerName", playername);
compound.setString("UUID", uuid);
compound.setInteger("PlayerCompanionId", companionID);
compound.setBoolean("isGUIOpen",isGUIOpen);
compound.setBoolean("isGUIOpen", isGUIOpen);
compound.setInteger("ProfileSlot", profileSlot);
if(hasCompanion()){
if (hasCompanion()) {
NBTTagCompound nbt = new NBTTagCompound();
if(activeCompanion.writeToNBTOptional(nbt))
if (activeCompanion.writeToNBTOptional(nbt))
compound.setTag("PlayerCompanion", nbt);
}
DBCAddon.instance.writeToNBT(this, compound);
return compound;
}
public NBTTagCompound getSyncNBT(){
public NBTTagCompound getSyncNBT() {
NBTTagCompound compound = new NBTTagCompound();
dialogData.saveNBTData(compound);
questData.saveNBTData(compound);
@@ -183,24 +183,24 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
return compound;
}
public void setSyncNBT(NBTTagCompound data){
public void setSyncNBT(NBTTagCompound data) {
dialogData.loadNBTData(data);
questData.loadNBTData(data);
factionData.loadNBTData(data);
}
public NBTTagCompound getPlayerEffects(){
public NBTTagCompound getPlayerEffects() {
NBTTagCompound compound = new NBTTagCompound();
effectData.writeToNBT(compound);
return compound;
}
public void setPlayerEffects(NBTTagCompound data){
public void setPlayerEffects(NBTTagCompound data) {
effectData.readFromNBT(data);
}
public NBTTagCompound getSyncNBTFull() {
if(player != null){
if (player != null) {
playername = player.getCommandSenderName();
uuid = player.getPersistentID().toString();
}
@@ -217,114 +217,113 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
return compound;
}
public void setSyncNBTFull(NBTTagCompound data){
public void setSyncNBTFull(NBTTagCompound data) {
dialogData.loadNBTData(data);
bankData.loadNBTData(data);
questData.loadNBTData(data);
transportData.loadNBTData(data);
factionData.loadNBTData(data);
mailData.loadNBTData(data);
if(player != null){
if (player != null) {
playername = player.getCommandSenderName();
uuid = player.getPersistentID().toString();
}
else{
} else {
playername = data.getString("PlayerName");
uuid = data.getString("UUID");
}
DBCAddon.instance.readFromNBT(this, data);
}
public void getDBCSync(NBTTagCompound compound){
public void getDBCSync(NBTTagCompound compound) {
DBCAddon.instance.writeToNBT(this, compound);
}
public void setDBCSync(NBTTagCompound data){
public void setDBCSync(NBTTagCompound data) {
DBCAddon.instance.readFromNBT(this, data);
}
@Override
public void init(Entity entity, World world) {
@Override
public void init(Entity entity, World world) {
}
}
public void setGUIOpen(boolean bool) {
this.isGUIOpen = bool;
}
public void setGUIOpen(boolean bool) {
this.isGUIOpen = bool;
}
public boolean getGUIOpen() {
return this.isGUIOpen;
}
public boolean getGUIOpen() {
return this.isGUIOpen;
}
public ScreenSize getScreenSize(){
return screenSize;
}
public ScreenSize getScreenSize() {
return screenSize;
}
public void setScreenSize(ScreenSize size){
screenSize = size;
}
public void setScreenSize(ScreenSize size) {
screenSize = size;
}
public boolean hasCompanion(){
return activeCompanion != null && !activeCompanion.isDead;
}
public boolean hasCompanion() {
return activeCompanion != null && !activeCompanion.isDead;
}
public void setCompanion(EntityNPCInterface npc) {
if(npc != null && npc.advanced.role != EnumRoleType.Companion)//shouldnt happen
return;
companionID++;
activeCompanion = npc;
if(npc != null)
((RoleCompanion)npc.roleInterface).companionID = companionID;
save();
}
public void setCompanion(EntityNPCInterface npc) {
if (npc != null && npc.advanced.role != EnumRoleType.Companion)//shouldnt happen
return;
companionID++;
activeCompanion = npc;
if (npc != null)
((RoleCompanion) npc.roleInterface).companionID = companionID;
save();
}
public void updateCompanion(World world) {
if(!hasCompanion() || world == activeCompanion.worldObj)
return;
RoleCompanion role = (RoleCompanion) activeCompanion.roleInterface;
role.owner = player;
if(!role.isFollowing())
return;
NBTTagCompound nbt = new NBTTagCompound();
activeCompanion.writeToNBTOptional(nbt);
activeCompanion.isDead = true;
public void updateCompanion(World world) {
if (!hasCompanion() || world == activeCompanion.worldObj)
return;
RoleCompanion role = (RoleCompanion) activeCompanion.roleInterface;
role.owner = player;
if (!role.isFollowing())
return;
NBTTagCompound nbt = new NBTTagCompound();
activeCompanion.writeToNBTOptional(nbt);
activeCompanion.isDead = true;
EntityCustomNpc npc = new EntityCustomNpc(world);
npc.readEntityFromNBT(nbt);
npc.setPosition(player.posX, player.posY, player.posZ);
setCompanion(npc);
((RoleCompanion)npc.roleInterface).setSitting(false);
world.spawnEntityInWorld(npc);
}
EntityCustomNpc npc = new EntityCustomNpc(world);
npc.readEntityFromNBT(nbt);
npc.setPosition(player.posX, player.posY, player.posZ);
setCompanion(npc);
((RoleCompanion) npc.roleInterface).setSitting(false);
world.spawnEntityInWorld(npc);
}
public void inviteToParty(Party party) {
if (party != null && this.partyUUID == null && !this.partyInvites.contains(party.getPartyUUID())) {
this.partyInvites.add(party.getPartyUUID());
public void inviteToParty(Party party) {
if (party != null && this.partyUUID == null && !this.partyInvites.contains(party.getPartyUUID())) {
this.partyInvites.add(party.getPartyUUID());
AchievementPacket.sendAchievement((EntityPlayerMP) player, true, "party.inviteAlert", party.getPartyLeader().getCommandSenderName());
ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, "\u00A7a", "party.inviteChat", " ", party.getPartyLeader().getCommandSenderName(), "!");
}
}
}
}
public void ignoreInvite(UUID uuid) {
if (uuid != null) {
this.partyInvites.remove(uuid);
PartyInvitePacket.sendInviteData((EntityPlayerMP) player);
}
}
public void ignoreInvite(UUID uuid) {
if (uuid != null) {
this.partyInvites.remove(uuid);
PartyInvitePacket.sendInviteData((EntityPlayerMP) player);
}
}
public void acceptInvite(UUID uuid) {
if (uuid != null) {
this.partyInvites.remove(uuid);
Party party = PartyController.Instance().getParty(uuid);
if(party != null){
public void acceptInvite(UUID uuid) {
if (uuid != null) {
this.partyInvites.remove(uuid);
Party party = PartyController.Instance().getParty(uuid);
if (party != null) {
if (!party.getIsLocked()) {
party.addPlayer(player);
PartyController.Instance().pingPartyUpdate(party);
}
}
}
}
}
}
public Party getPlayerParty() {
if (partyUUID != null) {
@@ -333,100 +332,100 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
return null;
}
public HashSet<UUID> getPartyInvites() {
return (HashSet<UUID>) this.partyInvites.clone();
}
public HashSet<UUID> getPartyInvites() {
return (HashSet<UUID>) this.partyInvites.clone();
}
public void setCompanion(ICustomNpc npc) {
this.setCompanion((EntityNPCInterface) npc.getMCEntity());
}
public void setCompanion(ICustomNpc npc) {
this.setCompanion((EntityNPCInterface) npc.getMCEntity());
}
public ICustomNpc getCompanion() {
return (ICustomNpc) NpcAPI.Instance().getIEntity(activeCompanion);
}
public ICustomNpc getCompanion() {
return (ICustomNpc) NpcAPI.Instance().getIEntity(activeCompanion);
}
public int getCompanionID() {
return companionID;
}
public int getCompanionID() {
return companionID;
}
public IPlayerDialogData getDialogData() {
return dialogData;
}
public IPlayerDialogData getDialogData() {
return dialogData;
}
public IPlayerBankData getBankData() {
return bankData;
}
public IPlayerBankData getBankData() {
return bankData;
}
public IPlayerQuestData getQuestData() {
return questData;
}
public IPlayerQuestData getQuestData() {
return questData;
}
public IPlayerTransportData getTransportData() {
return transportData;
}
public IPlayerTransportData getTransportData() {
return transportData;
}
public IPlayerFactionData getFactionData() {
return factionData;
}
public IPlayerFactionData getFactionData() {
return factionData;
}
public IPlayerItemGiverData getItemGiverData() {
return itemgiverData;
}
public IPlayerItemGiverData getItemGiverData() {
return itemgiverData;
}
public IPlayerMailData getMailData() {
return mailData;
}
public IPlayerMailData getMailData() {
return mailData;
}
public synchronized void save() {
public synchronized void save() {
// Don't Save this is a Modification of a Profile's PlayerData
Profile profile = ProfileController.Instance.getProfile(UUID.fromString(uuid));
if(profile != null && profile.currentSlotId != this.profileSlot){
if (profile != null && profile.currentSlotId != this.profileSlot) {
ProfileController.Instance.saveOffline(profile, UUID.fromString(uuid));
return;
}
final NBTTagCompound compound = getNBT();
final String filename;
if(ConfigMain.DatFormat){
filename = uuid + ".dat";
} else {
filename = uuid + ".json";
}
PlayerDataController.Instance.putPlayerMap(playername, uuid);
PlayerDataController.Instance.putPlayerDataCache(uuid, this);
CustomNPCsThreader.customNPCThread.execute(() -> {
try {
File saveDir = PlayerDataController.Instance.getSaveDir();
File file = new File(saveDir, filename + "_new");
File file1 = new File(saveDir, filename);
if(ConfigMain.DatFormat){
CompressedStreamTools.writeCompressed(compound, new FileOutputStream(file));
} else {
NBTJsonUtil.SaveFile(file, compound);
}
if(file1.exists()){
file1.delete();
}
file.renameTo(file1);
} catch (Exception e) {
LogWriter.except(e);
}
});
}
final NBTTagCompound compound = getNBT();
final String filename;
if (ConfigMain.DatFormat) {
filename = uuid + ".dat";
} else {
filename = uuid + ".json";
}
PlayerDataController.Instance.putPlayerMap(playername, uuid);
PlayerDataController.Instance.putPlayerDataCache(uuid, this);
CustomNPCsThreader.customNPCThread.execute(() -> {
try {
File saveDir = PlayerDataController.Instance.getSaveDir();
File file = new File(saveDir, filename + "_new");
File file1 = new File(saveDir, filename);
if (ConfigMain.DatFormat) {
CompressedStreamTools.writeCompressed(compound, new FileOutputStream(file));
} else {
NBTJsonUtil.SaveFile(file, compound);
}
if (file1.exists()) {
file1.delete();
}
file.renameTo(file1);
} catch (Exception e) {
LogWriter.except(e);
}
});
}
public void load() {
NBTTagCompound data = PlayerDataController.Instance.loadPlayerData(player.getPersistentID().toString());
if(data.hasNoTags()){
data = PlayerDataController.Instance.loadPlayerDataOld(player.getCommandSenderName());
}
if(data.hasNoTags()){
public void load() {
NBTTagCompound data = PlayerDataController.Instance.loadPlayerData(player.getPersistentID().toString());
if (data.hasNoTags()) {
data = PlayerDataController.Instance.loadPlayerDataOld(player.getCommandSenderName());
}
if (data.hasNoTags()) {
data = getNBT();
}
setNBT(data);
}
setNBT(data);
}
public static PlayerData get(EntityPlayer player) {
if(player.worldObj.isRemote)
if (player.worldObj.isRemote)
return CustomNpcs.proxy.getPlayerData(player);
return PlayerDataController.Instance.getPlayerData(player);
@@ -29,18 +29,20 @@ public class PlayerDataScript implements INpcScriptHandler {
public boolean enabled = false;
public PlayerDataScript(EntityPlayer player) {
if(player != null) {
if (player != null) {
this.player = player;
}
}
public void clear() {
this.scripts = new ArrayList();
}
public void readFromNBT(NBTTagCompound compound) {
if (compound.hasKey("Scripts")) {
this.scripts = NBTTags.GetScriptOld(compound.getTagList("Scripts", 10), this);
} else {
this.scripts = NBTTags.GetScript(compound,this);
this.scripts = NBTTags.GetScript(compound, this);
}
this.scriptLanguage = compound.getString("ScriptLanguage");
if (!ScriptController.Instance.languages.containsKey(scriptLanguage)) {
@@ -52,10 +54,11 @@ public class PlayerDataScript implements INpcScriptHandler {
}
this.enabled = compound.getBoolean("ScriptEnabled");
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setInteger("TotalScripts",this.scripts.size());
compound.setInteger("TotalScripts", this.scripts.size());
for (int i = 0; i < this.scripts.size(); i++) {
compound.setTag("Tab"+i,this.scripts.get(i).writeToNBT(new NBTTagCompound()));
compound.setTag("Tab" + i, this.scripts.get(i).writeToNBT(new NBTTagCompound()));
}
compound.setString("ScriptLanguage", this.scriptLanguage);
compound.setBoolean("ScriptEnabled", this.enabled);
@@ -82,13 +85,13 @@ public class PlayerDataScript implements INpcScriptHandler {
}
if (!Objects.equals(hookName, EnumScriptType.INIT.function)) {
noppes.npcs.scripted.event.PlayerEvent playerEvent = (noppes.npcs.scripted.event.PlayerEvent)event;
noppes.npcs.scripted.event.PlayerEvent playerEvent = (noppes.npcs.scripted.event.PlayerEvent) event;
EventHooks.onPlayerInit(this, playerEvent.player);
}
}
for (ScriptContainer script : this.scripts) {
if(script == null || script.errored || !script.hasCode() )
if (script == null || script.errored || !script.hasCode())
continue;
script.run(hookName, event);
@@ -99,33 +102,41 @@ public class PlayerDataScript implements INpcScriptHandler {
public boolean isClient() {
return this.player != null && this.player.isClientWorld();
}
public boolean getEnabled() {
return ScriptController.Instance.playerScripts.enabled;
}
public void setEnabled(boolean bo) {
ScriptController.Instance.playerScripts.enabled = bo;
this.enabled = bo;
}
public String getLanguage() {
return ScriptController.Instance.playerScripts.scriptLanguage;
}
public void setLanguage(String lang) {
this.scriptLanguage = lang;
}
public void setScripts(List<ScriptContainer> list) {
this.scripts = list;
}
public List<ScriptContainer> getScripts() {
return this.scripts;
}
public String noticeString() {
if(this.player == null) {
if (this.player == null) {
return "Global script";
} else {
BlockPos pos = new BlockPos(this.player);
return PlayerDataScript.toStringHelper(this.player).add("x", pos.getX()).add("y", pos.getY()).add("z", pos.getZ()).toString();
}
}
public IPlayer getPlayer() {
if (this.playerAPI == null) {
this.playerAPI = (IPlayer) NpcAPI.Instance().getIEntity(this.player);
@@ -158,6 +169,7 @@ public class PlayerDataScript implements INpcScriptHandler {
private PlayerDataScript.ToStringHelper.ValueHolder holderTail;
private boolean omitNullValues;
private boolean omitEmptyValues;
private ToStringHelper(String className) {
this.holderHead = new PlayerDataScript.ToStringHelper.ValueHolder();
this.holderTail = this.holderHead;
@@ -165,81 +177,98 @@ public class PlayerDataScript implements INpcScriptHandler {
this.omitEmptyValues = false;
this.className = (String) Preconditions.checkNotNull(className);
}
public PlayerDataScript.ToStringHelper omitNullValues() {
this.omitNullValues = true;
return this;
}
public PlayerDataScript.ToStringHelper add(String name, @CheckForNull Object value) {
return this.addHolder(name, value);
}
public PlayerDataScript.ToStringHelper add(String name, boolean value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public PlayerDataScript.ToStringHelper add(String name, char value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public PlayerDataScript.ToStringHelper add(String name, double value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public PlayerDataScript.ToStringHelper add(String name, float value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public PlayerDataScript.ToStringHelper add(String name, int value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public PlayerDataScript.ToStringHelper add(String name, long value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public PlayerDataScript.ToStringHelper addValue(@CheckForNull Object value) {
return this.addHolder(value);
}
public PlayerDataScript.ToStringHelper addValue(boolean value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public PlayerDataScript.ToStringHelper addValue(char value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public PlayerDataScript.ToStringHelper addValue(double value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public PlayerDataScript.ToStringHelper addValue(float value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public PlayerDataScript.ToStringHelper addValue(int value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public PlayerDataScript.ToStringHelper addValue(long value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
private static boolean isEmpty(Object value) {
if (value instanceof CharSequence) {
return ((CharSequence)value).length() == 0;
return ((CharSequence) value).length() == 0;
} else if (value instanceof Collection) {
return ((Collection)value).isEmpty();
return ((Collection) value).isEmpty();
} else if (value instanceof Map) {
return ((Map)value).isEmpty();
return ((Map) value).isEmpty();
} else if (value instanceof Optional) {
return !((Optional)value).isPresent();
return !((Optional) value).isPresent();
} else if (value instanceof OptionalInt) {
return !((OptionalInt)value).isPresent();
return !((OptionalInt) value).isPresent();
} else if (value instanceof OptionalLong) {
return !((OptionalLong)value).isPresent();
return !((OptionalLong) value).isPresent();
} else if (value instanceof OptionalDouble) {
return !((OptionalDouble)value).isPresent();
return !((OptionalDouble) value).isPresent();
} else if (value instanceof com.google.common.base.Optional) {
return !((com.google.common.base.Optional)value).isPresent();
return !((com.google.common.base.Optional) value).isPresent();
} else if (value.getClass().isArray()) {
return Array.getLength(value) == 0;
} else {
return false;
}
}
public String toString() {
boolean omitNullValuesSnapshot = this.omitNullValues;
boolean omitEmptyValuesSnapshot = this.omitEmptyValues;
String nextSeparator = "";
StringBuilder builder = (new StringBuilder(32)).append(this.className).append('{');
for(PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.holderHead.next; valueHolder != null; valueHolder = valueHolder.next) {
for (PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.holderHead.next; valueHolder != null; valueHolder = valueHolder.next) {
Object value = valueHolder.value;
if (!(valueHolder instanceof PlayerDataScript.ToStringHelper.UnconditionalValueHolder)) {
if (value == null) {
@@ -265,43 +294,51 @@ public class PlayerDataScript implements INpcScriptHandler {
}
return builder.append('}').toString();
}
private PlayerDataScript.ToStringHelper.ValueHolder addHolder() {
PlayerDataScript.ToStringHelper.ValueHolder valueHolder = new PlayerDataScript.ToStringHelper.ValueHolder();
this.holderTail = this.holderTail.next = valueHolder;
return valueHolder;
}
private PlayerDataScript.ToStringHelper addHolder(@CheckForNull Object value) {
PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder();
valueHolder.value = value;
return this;
}
private PlayerDataScript.ToStringHelper addHolder(String name, @CheckForNull Object value) {
PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder();
valueHolder.value = value;
valueHolder.name = (String)Preconditions.checkNotNull(name);
valueHolder.name = (String) Preconditions.checkNotNull(name);
return this;
}
private PlayerDataScript.ToStringHelper.UnconditionalValueHolder addUnconditionalHolder() {
PlayerDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = new PlayerDataScript.ToStringHelper.UnconditionalValueHolder();
this.holderTail = this.holderTail.next = valueHolder;
return valueHolder;
}
private PlayerDataScript.ToStringHelper addUnconditionalHolder(Object value) {
PlayerDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder();
valueHolder.value = value;
return this;
}
private PlayerDataScript.ToStringHelper addUnconditionalHolder(String name, Object value) {
PlayerDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder();
valueHolder.value = value;
valueHolder.name = (String)Preconditions.checkNotNull(name);
valueHolder.name = (String) Preconditions.checkNotNull(name);
return this;
}
private static final class UnconditionalValueHolder extends PlayerDataScript.ToStringHelper.ValueHolder {
private UnconditionalValueHolder() {
super();
}
}
private static class ValueHolder {
@CheckForNull
String name;
@@ -309,10 +346,12 @@ public class PlayerDataScript implements INpcScriptHandler {
Object value;
@CheckForNull
PlayerDataScript.ToStringHelper.ValueHolder next;
private ValueHolder() {
}
}
}
public static PlayerDataScript.ToStringHelper toStringHelper(Object self) {
return new PlayerDataScript.ToStringHelper(self.getClass().getSimpleName());
}
@@ -7,50 +7,49 @@ import noppes.npcs.api.handler.IPlayerDialogData;
import java.util.HashSet;
public class PlayerDialogData implements IPlayerDialogData {
private final PlayerData parent;
public HashSet<Integer> dialogsRead = new HashSet<Integer>();
private final PlayerData parent;
public HashSet<Integer> dialogsRead = new HashSet<Integer>();
public PlayerDialogData(PlayerData parent) {
this.parent = parent;
}
public void loadNBTData(NBTTagCompound compound) {
HashSet<Integer> dialogsRead = new HashSet<Integer>();
if(compound == null)
return;
public PlayerDialogData(PlayerData parent) {
this.parent = parent;
}
public void loadNBTData(NBTTagCompound compound) {
HashSet<Integer> dialogsRead = new HashSet<Integer>();
if (compound == null)
return;
NBTTagList list = compound.getTagList("DialogData", 10);
if(list == null){
return;
if (list == null) {
return;
}
for(int i = 0; i < list.tagCount(); i++)
{
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
dialogsRead.add(nbttagcompound.getInteger("Dialog"));
}
this.dialogsRead = dialogsRead;
}
}
public void saveNBTData(NBTTagCompound compound) {
NBTTagList list = new NBTTagList();
for(int dia : dialogsRead){
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Dialog", dia);
list.appendTag(nbttagcompound);
}
compound.setTag("DialogData", list);
}
public void saveNBTData(NBTTagCompound compound) {
NBTTagList list = new NBTTagList();
for (int dia : dialogsRead) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Dialog", dia);
list.appendTag(nbttagcompound);
}
public boolean hasReadDialog(int id) {
return dialogsRead.contains(id);
}
compound.setTag("DialogData", list);
}
public void readDialog(int id) {
dialogsRead.add(id);
}
public boolean hasReadDialog(int id) {
return dialogsRead.contains(id);
}
public void unreadDialog(int id) {
dialogsRead.remove(id);
}
public void readDialog(int id) {
dialogsRead.add(id);
}
public void unreadDialog(int id) {
dialogsRead.remove(id);
}
}
@@ -51,7 +51,7 @@ public class PlayerEffect implements IPlayerEffect {
@Override
public String getName() {
CustomEffect effect = CustomEffectController.getInstance().get(this.id, this.index);
if(effect != null)
if (effect != null)
return effect.getName();
return "UNKNOWN";
@@ -61,7 +61,7 @@ public class PlayerEffect implements IPlayerEffect {
public void performEffect(IPlayer player) {
if (player != null && player.getMCEntity() != null && player.getMCEntity() instanceof EntityPlayer) {
CustomEffect effect = CustomEffectController.getInstance().get(this.id, this.index);
if(effect != null)
if (effect != null)
effect.onTick((EntityPlayer) player.getMCEntity(), this);
}
}
@@ -12,7 +12,7 @@ public class PlayerEffectData {
private final PlayerData parent;
private ConcurrentHashMap<EffectKey, PlayerEffect> effects = new ConcurrentHashMap<>();
public PlayerEffectData(PlayerData playerData){
public PlayerEffectData(PlayerData playerData) {
this.parent = playerData;
}
@@ -14,96 +14,95 @@ import noppes.npcs.scripted.event.FactionEvent;
import java.util.HashMap;
public class PlayerFactionData implements IPlayerFactionData {
private final PlayerData parent;
public HashMap<Integer,Integer> factionData = new HashMap<Integer,Integer>();
private final PlayerData parent;
public HashMap<Integer, Integer> factionData = new HashMap<Integer, Integer>();
public PlayerFactionData() {
parent = null;
}
public PlayerFactionData() {
parent = null;
}
public PlayerFactionData(PlayerData parent) {
this.parent = parent;
}
public PlayerFactionData(PlayerData parent) {
this.parent = parent;
}
public void loadNBTData(NBTTagCompound compound) {
HashMap<Integer,Integer> factionData = new HashMap<Integer,Integer>();
if(compound == null)
return;
public void loadNBTData(NBTTagCompound compound) {
HashMap<Integer, Integer> factionData = new HashMap<Integer, Integer>();
if (compound == null)
return;
NBTTagList list = compound.getTagList("FactionData", 10);
if(list == null){
return;
if (list == null) {
return;
}
for(int i = 0; i < list.tagCount(); i++)
{
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
factionData.put(nbttagcompound.getInteger("Faction"),nbttagcompound.getInteger("Points"));
factionData.put(nbttagcompound.getInteger("Faction"), nbttagcompound.getInteger("Points"));
}
this.factionData = factionData;
}
}
public void saveNBTData(NBTTagCompound compound) {
NBTTagList list = new NBTTagList();
for(int faction : factionData.keySet()){
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Faction", faction);
nbttagcompound.setInteger("Points", factionData.get(faction));
list.appendTag(nbttagcompound);
}
compound.setTag("FactionData", list);
}
public void saveNBTData(NBTTagCompound compound) {
NBTTagList list = new NBTTagList();
for (int faction : factionData.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Faction", faction);
nbttagcompound.setInteger("Points", factionData.get(faction));
list.appendTag(nbttagcompound);
}
public int getFactionPoints(int id) {
if(!factionData.containsKey(id)){
Faction faction = FactionController.getInstance().get(id);
factionData.put(id, faction == null? -1 : faction.defaultPoints);
}
return factionData.get(id);
}
compound.setTag("FactionData", list);
}
public void increasePoints(int factionId, int points, EntityPlayer player) {
if (EventHooks.onFactionPoints(new FactionEvent.FactionPoints((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), FactionController.getInstance().get(factionId), points < 0, points)))
return;
public int getFactionPoints(int id) {
if (!factionData.containsKey(id)) {
Faction faction = FactionController.getInstance().get(id);
factionData.put(id, faction == null ? -1 : faction.defaultPoints);
}
return factionData.get(id);
}
if(!factionData.containsKey(factionId)){
Faction faction = FactionController.getInstance().get(factionId);
factionData.put(factionId, faction == null? -1 : faction.defaultPoints);
}
factionData.put(factionId, factionData.get(factionId) + points);
}
public NBTTagCompound getPlayerGuiData(){
NBTTagCompound compound = new NBTTagCompound();
saveNBTData(compound);
NBTTagList list = new NBTTagList();
for(int id : factionData.keySet()){
Faction faction = FactionController.getInstance().get(id);
if(faction == null || faction.hideFaction)
continue;
NBTTagCompound com = new NBTTagCompound();
faction.writeNBT(com);
list.appendTag(com);
}
compound.setTag("FactionList", list);
return compound;
}
public void increasePoints(int factionId, int points, EntityPlayer player) {
if (EventHooks.onFactionPoints(new FactionEvent.FactionPoints((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), FactionController.getInstance().get(factionId), points < 0, points)))
return;
public int getPoints(int id) {
return this.getFactionPoints(id);
}
if (!factionData.containsKey(factionId)) {
Faction faction = FactionController.getInstance().get(factionId);
factionData.put(factionId, faction == null ? -1 : faction.defaultPoints);
}
factionData.put(factionId, factionData.get(factionId) + points);
}
public void addPoints(int id, int points) {
if (parent != null) {
this.increasePoints(id, points, parent.player);
}
}
public NBTTagCompound getPlayerGuiData() {
NBTTagCompound compound = new NBTTagCompound();
saveNBTData(compound);
public void setPoints(int id, int points) {
if (parent != null) {
increasePoints(id, points-getFactionPoints(id), parent.player);
}
}
NBTTagList list = new NBTTagList();
for (int id : factionData.keySet()) {
Faction faction = FactionController.getInstance().get(id);
if (faction == null || faction.hideFaction)
continue;
NBTTagCompound com = new NBTTagCompound();
faction.writeNBT(com);
list.appendTag(com);
}
compound.setTag("FactionList", list);
return compound;
}
public int getPoints(int id) {
return this.getFactionPoints(id);
}
public void addPoints(int id, int points) {
if (parent != null) {
this.increasePoints(id, points, parent.player);
}
}
public void setPoints(int id, int points) {
if (parent != null) {
increasePoints(id, points - getFactionPoints(id), parent.player);
}
}
}
@@ -9,51 +9,55 @@ import noppes.npcs.roles.JobItemGiver;
import java.util.HashMap;
public class PlayerItemGiverData implements IPlayerItemGiverData {
private final PlayerData parent;
private HashMap<Integer, Long> itemgivers = new HashMap<Integer,Long>();
private HashMap<Integer, Integer> chained = new HashMap<Integer,Integer>();
private final PlayerData parent;
private HashMap<Integer, Long> itemgivers = new HashMap<Integer, Long>();
private HashMap<Integer, Integer> chained = new HashMap<Integer, Integer>();
public PlayerItemGiverData(PlayerData parent) {
this.parent = parent;
}
public PlayerItemGiverData(PlayerData parent) {
this.parent = parent;
}
public void loadNBTData(NBTTagCompound compound) {
chained = NBTTags.getIntegerIntegerMap(compound.getTagList("ItemGiverChained", 10));
itemgivers = NBTTags.getIntegerLongMap(compound.getTagList("ItemGiversList", 10));
}
public void loadNBTData(NBTTagCompound compound) {
chained = NBTTags.getIntegerIntegerMap(compound.getTagList("ItemGiverChained", 10));
itemgivers = NBTTags.getIntegerLongMap(compound.getTagList("ItemGiversList", 10));
}
public void saveNBTData(NBTTagCompound compound) {
compound.setTag("ItemGiverChained", NBTTags.nbtIntegerIntegerMap(chained));
compound.setTag("ItemGiversList", NBTTags.nbtIntegerLongMap(itemgivers));
}
public boolean hasInteractedBefore(JobItemGiver jobItemGiver) {
return itemgivers.containsKey(jobItemGiver.itemGiverId);
}
public void saveNBTData(NBTTagCompound compound) {
compound.setTag("ItemGiverChained", NBTTags.nbtIntegerIntegerMap(chained));
compound.setTag("ItemGiversList", NBTTags.nbtIntegerLongMap(itemgivers));
}
public long getTime(JobItemGiver jobItemGiver){
return itemgivers.get(jobItemGiver.itemGiverId);
}
public void setTime(JobItemGiver jobItemGiver, long day) {
itemgivers.put(jobItemGiver.itemGiverId, day);
}
public int getItemIndex(JobItemGiver jobItemGiver) {
if(chained.containsKey(jobItemGiver.itemGiverId))
return chained.get(jobItemGiver.itemGiverId);
return 0;
}
public void setItemIndex(JobItemGiver jobItemGiver, int i) {
chained.put(jobItemGiver.itemGiverId, i);
}
public boolean hasInteractedBefore(JobItemGiver jobItemGiver) {
return itemgivers.containsKey(jobItemGiver.itemGiverId);
}
public long getTime(IJobItemGiver jobItemGiver){
return itemgivers.get(((JobItemGiver) jobItemGiver).itemGiverId);
}
public long getTime(JobItemGiver jobItemGiver) {
return itemgivers.get(jobItemGiver.itemGiverId);
}
public void setTime(IJobItemGiver jobItemGiver, long day) {
itemgivers.put(((JobItemGiver) jobItemGiver).itemGiverId, day);
}
public void setTime(JobItemGiver jobItemGiver, long day) {
itemgivers.put(jobItemGiver.itemGiverId, day);
}
public boolean hasInteractedBefore(IJobItemGiver jobItemGiver) {
return itemgivers.containsKey(((JobItemGiver) jobItemGiver).itemGiverId);
}
public int getItemIndex(JobItemGiver jobItemGiver) {
if (chained.containsKey(jobItemGiver.itemGiverId))
return chained.get(jobItemGiver.itemGiverId);
return 0;
}
public void setItemIndex(JobItemGiver jobItemGiver, int i) {
chained.put(jobItemGiver.itemGiverId, i);
}
public long getTime(IJobItemGiver jobItemGiver) {
return itemgivers.get(((JobItemGiver) jobItemGiver).itemGiverId);
}
public void setTime(IJobItemGiver jobItemGiver, long day) {
itemgivers.put(((JobItemGiver) jobItemGiver).itemGiverId, day);
}
public boolean hasInteractedBefore(IJobItemGiver jobItemGiver) {
return itemgivers.containsKey(((JobItemGiver) jobItemGiver).itemGiverId);
}
}
@@ -15,292 +15,275 @@ import noppes.npcs.scripted.NpcAPI;
import java.util.ArrayList;
public class PlayerMail implements IInventory, IPlayerMail {
public String subject = "";
public String sender = "";
public NBTTagCompound message = new NBTTagCompound();
public long time = 0;
public boolean beenRead = false;
public int questId = -1;
public String questTitle = "";
public ItemStack[] items = new ItemStack[4];
public String subject = "";
public String sender = "";
public NBTTagCompound message = new NBTTagCompound();
public long time = 0;
public boolean beenRead = false;
public int questId = -1;
public String questTitle = "";
public ItemStack[] items = new ItemStack[4];
public long timePast;
public long timePast;
public void readNBT(NBTTagCompound compound) {
subject = compound.getString("Subject");
sender = compound.getString("Sender");
time = compound.getLong("Time");
beenRead = compound.getBoolean("BeenRead");
message = compound.getCompoundTag("Message");
timePast = compound.getLong("TimePast");
if(compound.hasKey("MailQuest"))
questId = compound.getInteger("MailQuest");
questTitle = compound.getString("MailQuestTitle");
public void readNBT(NBTTagCompound compound) {
subject = compound.getString("Subject");
sender = compound.getString("Sender");
time = compound.getLong("Time");
beenRead = compound.getBoolean("BeenRead");
message = compound.getCompoundTag("Message");
timePast = compound.getLong("TimePast");
if (compound.hasKey("MailQuest"))
questId = compound.getInteger("MailQuest");
questTitle = compound.getString("MailQuestTitle");
this.items = new ItemStack[this.getSizeInventory()];
NBTTagList nbttaglist = compound.getTagList("MailItems", 10);
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
int j = nbttagcompound1.getByte("Slot") & 255;
if (j >= 0 && j < this.items.length)
{
if (j >= 0 && j < this.items.length) {
this.items[j] = NoppesUtilServer.readItem(nbttagcompound1);
}
}
}
}
public NBTTagCompound writeNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setString("Subject", subject);
compound.setString("Sender", sender);
compound.setLong("Time", time);
compound.setBoolean("BeenRead", beenRead);
compound.setTag("Message", message);
compound.setLong("TimePast", System.currentTimeMillis() - time);
compound.setInteger("MailQuest", questId);
public NBTTagCompound writeNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setString("Subject", subject);
compound.setString("Sender", sender);
compound.setLong("Time", time);
compound.setBoolean("BeenRead", beenRead);
compound.setTag("Message", message);
compound.setLong("TimePast", System.currentTimeMillis() - time);
compound.setInteger("MailQuest", questId);
if(hasQuest())
compound.setString("MailQuestTitle", getQuest().title);
if (hasQuest())
compound.setString("MailQuestTitle", getQuest().title);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.items.length; ++i)
{
if (this.items[i] != null)
{
for (int i = 0; i < this.items.length; ++i) {
if (this.items[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte)i);
NoppesUtilServer.writeItem(this.items[i], nbttagcompound1);
nbttagcompound1.setByte("Slot", (byte) i);
NoppesUtilServer.writeItem(this.items[i], nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
compound.setTag("MailItems", nbttaglist);
return compound;
}
return compound;
}
public boolean isValid(){
return !subject.isEmpty() && !message.hasNoTags() && !sender.isEmpty();
}
public boolean isValid() {
return !subject.isEmpty() && !message.hasNoTags() && !sender.isEmpty();
}
public boolean hasQuest() {
return getQuest() != null;
}
public Quest getQuest() {
return QuestController.Instance != null?QuestController.Instance.quests.get(questId):null;
}
public boolean hasQuest() {
return getQuest() != null;
}
@Override
public int getSizeInventory() {
return 4;
}
public Quest getQuest() {
return QuestController.Instance != null ? QuestController.Instance.quests.get(questId) : null;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public int getSizeInventory() {
return 4;
}
@Override
public ItemStack getStackInSlot(int var1) {
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public ItemStack getStackInSlot(int var1) {
return this.items[var1];
}
}
@Override
public ItemStack decrStackSize(int par1, int par2) {
if (this.items[par1] != null)
{
@Override
public ItemStack decrStackSize(int par1, int par2) {
if (this.items[par1] != null) {
ItemStack itemstack;
if (this.items[par1].stackSize <= par2)
{
if (this.items[par1].stackSize <= par2) {
itemstack = this.items[par1];
this.items[par1] = null;
this.markDirty();
return itemstack;
}
else
{
} else {
itemstack = this.items[par1].splitStack(par2);
if (this.items[par1].stackSize == 0)
{
if (this.items[par1].stackSize == 0) {
this.items[par1] = null;
}
this.markDirty();
return itemstack;
}
}
else
{
} else {
return null;
}
}
}
@Override
public ItemStack getStackInSlotOnClosing(int var1) {
if (this.items[var1] != null)
{
@Override
public ItemStack getStackInSlotOnClosing(int var1) {
if (this.items[var1] != null) {
ItemStack itemstack = this.items[var1];
this.items[var1] = null;
return itemstack;
}
else
{
} else {
return null;
}
}
}
@Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack) {
@Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack) {
this.items[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) {
par2ItemStack.stackSize = this.getInventoryStackLimit();
}
this.markDirty();
}
}
@Override
public String getInventoryName() {
@Override
public String getInventoryName() {
return null;
}
return null;
}
@Override
public boolean hasCustomInventoryName() {
@Override
public boolean hasCustomInventoryName() {
return false;
}
return false;
}
@Override
public void markDirty() {
@Override
public void markDirty() {
}
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1) {
return true;
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1) {
return true;
}
@Override
public void openInventory() {
@Override
public void openInventory() {
}
}
@Override
public void closeInventory() {
}
@Override
public void closeInventory() {
}
@Override
public boolean isItemValidForSlot(int var1, ItemStack var2) {
return true;
}
@Override
public boolean isItemValidForSlot(int var1, ItemStack var2) {
return true;
}
public PlayerMail copy() {
PlayerMail mail = new PlayerMail();
mail.readNBT(writeNBT());
return mail;
}
public PlayerMail copy() {
PlayerMail mail = new PlayerMail();
mail.readNBT(writeNBT());
return mail;
}
public void setPageText(String[] pages) {
NBTTagList bookPages = new NBTTagList();
for (String text : pages) {
bookPages.appendTag(new NBTTagString(text));
}
public void setPageText(String[] pages) {
NBTTagList bookPages = new NBTTagList();
for (String text : pages) {
bookPages.appendTag(new NBTTagString(text));
}
message.setTag("pages", bookPages);
}
message.setTag("pages", bookPages);
}
public String[] getPageText() {
NBTTagList bookPages = new NBTTagList();
public String[] getPageText() {
NBTTagList bookPages = new NBTTagList();
if(message.hasKey("pages"))
bookPages = message.getTagList("pages", 8);
if (message.hasKey("pages"))
bookPages = message.getTagList("pages", 8);
if (bookPages != null)
{
bookPages = (NBTTagList)bookPages.copy();
ArrayList<String> pageStrings = new ArrayList<>();
if (bookPages != null) {
bookPages = (NBTTagList) bookPages.copy();
ArrayList<String> pageStrings = new ArrayList<>();
for (int i = 0; i < bookPages.tagCount(); i++) {
pageStrings.add(bookPages.getStringTagAt(i));
}
for (int i = 0; i < bookPages.tagCount(); i++) {
pageStrings.add(bookPages.getStringTagAt(i));
}
return pageStrings.toArray(new String[0]);
} else {
return new String[]{""};
}
}
return pageStrings.toArray(new String[0]);
} else {
return new String[]{""};
}
}
public int getPageCount() {
NBTTagList bookPages = new NBTTagList();
public int getPageCount() {
NBTTagList bookPages = new NBTTagList();
if(message.hasKey("pages"))
bookPages = message.getTagList("pages", 8);
if (message.hasKey("pages"))
bookPages = message.getTagList("pages", 8);
int bookTotalPages = 0;
if (bookPages != null)
{
bookPages = (NBTTagList)bookPages.copy();
bookTotalPages = bookPages.tagCount();
int bookTotalPages = 0;
if (bookPages != null) {
bookPages = (NBTTagList) bookPages.copy();
bookTotalPages = bookPages.tagCount();
if (bookTotalPages < 1)
{
bookTotalPages = 1;
}
if (bookTotalPages < 1) {
bookTotalPages = 1;
}
return bookTotalPages;
}
return bookTotalPages;
}
return 0;
}
return 0;
}
public void setSender(String sender) {
this.sender = sender;
}
public void setSender(String sender) {
this.sender = sender;
}
public String getSender() {
return sender;
}
public String getSender() {
return sender;
}
public void setSubject(String subject) {
this.subject = subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getSubject() {
return subject;
}
public String getSubject() {
return subject;
}
public long getTimePast() {
return timePast;
}
public long getTimePast() {
return timePast;
}
public long getTimeSent() {
return time;
}
public long getTimeSent() {
return time;
}
public IItemStack[] getItems() {
ArrayList<IItemStack> list = new ArrayList<>();
for (ItemStack itemStack : items) {
list.add(NpcAPI.Instance().getIItemStack(itemStack));
}
public IItemStack[] getItems() {
ArrayList<IItemStack> list = new ArrayList<>();
for (ItemStack itemStack : items) {
list.add(NpcAPI.Instance().getIItemStack(itemStack));
}
return list.toArray(new IItemStack[0]);
}
return list.toArray(new IItemStack[0]);
}
public void setItems(IItemStack[] items) {
ArrayList<ItemStack> list = new ArrayList<>();
for (IItemStack itemStack : items) {
list.add(itemStack.getMCItemStack());
}
public void setItems(IItemStack[] items) {
ArrayList<ItemStack> list = new ArrayList<>();
for (IItemStack itemStack : items) {
list.add(itemStack.getMCItemStack());
}
this.items = list.toArray(new ItemStack[0]);
}
this.items = list.toArray(new ItemStack[0]);
}
}
@@ -8,98 +8,98 @@ import noppes.npcs.api.handler.data.IPlayerMail;
import java.util.ArrayList;
public class PlayerMailData implements IPlayerMailData {
private final PlayerData parent;
public ArrayList<PlayerMail> playermail = new ArrayList<PlayerMail>();
private final PlayerData parent;
public ArrayList<PlayerMail> playermail = new ArrayList<PlayerMail>();
public PlayerMailData() {
this.parent = null;
}
public PlayerMailData() {
this.parent = null;
}
public PlayerMailData(PlayerData parent) {
this.parent = parent;
}
public PlayerMailData(PlayerData parent) {
this.parent = parent;
}
public void loadNBTData(NBTTagCompound compound) {
ArrayList<PlayerMail> newmail = new ArrayList<PlayerMail>();
NBTTagList list = compound.getTagList("MailData", 10);
if(list == null)
return;
for(int i = 0; i < list.tagCount(); i++){
PlayerMail mail = new PlayerMail();
mail.readNBT(list.getCompoundTagAt(i));
newmail.add(mail);
}
playermail = newmail;
}
public void loadNBTData(NBTTagCompound compound) {
ArrayList<PlayerMail> newmail = new ArrayList<PlayerMail>();
NBTTagList list = compound.getTagList("MailData", 10);
if (list == null)
return;
public NBTTagCompound saveNBTData(NBTTagCompound compound) {
NBTTagList list = new NBTTagList();
for(PlayerMail mail : playermail){
list.appendTag(mail.writeNBT());
}
compound.setTag("MailData", list);
return compound;
}
for (int i = 0; i < list.tagCount(); i++) {
PlayerMail mail = new PlayerMail();
mail.readNBT(list.getCompoundTagAt(i));
newmail.add(mail);
}
playermail = newmail;
}
public boolean hasMail() {
for(PlayerMail mail : playermail)
if(!mail.beenRead)
return true;
return false;
}
public NBTTagCompound saveNBTData(NBTTagCompound compound) {
NBTTagList list = new NBTTagList();
public void addMail(IPlayerMail mail) {
playermail.add((PlayerMail) mail);
}
for (PlayerMail mail : playermail) {
list.appendTag(mail.writeNBT());
}
public void removeMail(IPlayerMail mail) {
playermail.remove((PlayerMail) mail);
}
compound.setTag("MailData", list);
return compound;
}
public boolean hasMail(IPlayerMail mail) {
return playermail.contains((PlayerMail) mail);
}
public boolean hasMail() {
for (PlayerMail mail : playermail)
if (!mail.beenRead)
return true;
return false;
}
public IPlayerMail[] getAllMail() {
return playermail.toArray(new IPlayerMail[0]);
}
public void addMail(IPlayerMail mail) {
playermail.add((PlayerMail) mail);
}
public IPlayerMail[] getUnreadMail() {
ArrayList<IPlayerMail> mails = new ArrayList<>();
public void removeMail(IPlayerMail mail) {
playermail.remove((PlayerMail) mail);
}
for (PlayerMail mail : playermail) {
if (!mail.beenRead) {
mails.add(mail);
}
}
public boolean hasMail(IPlayerMail mail) {
return playermail.contains((PlayerMail) mail);
}
return mails.toArray(new IPlayerMail[0]);
}
public IPlayerMail[] getAllMail() {
return playermail.toArray(new IPlayerMail[0]);
}
public IPlayerMail[] getReadMail() {
ArrayList<IPlayerMail> mails = new ArrayList<>();
public IPlayerMail[] getUnreadMail() {
ArrayList<IPlayerMail> mails = new ArrayList<>();
for (PlayerMail mail : playermail) {
if (mail.beenRead) {
mails.add(mail);
}
}
for (PlayerMail mail : playermail) {
if (!mail.beenRead) {
mails.add(mail);
}
}
return mails.toArray(new IPlayerMail[0]);
}
return mails.toArray(new IPlayerMail[0]);
}
public IPlayerMail[] getMailFrom(String sender) {
ArrayList<IPlayerMail> mails = new ArrayList<>();
public IPlayerMail[] getReadMail() {
ArrayList<IPlayerMail> mails = new ArrayList<>();
for (PlayerMail mail : playermail) {
if (mail.sender.equals(sender)) {
mails.add(mail);
}
}
for (PlayerMail mail : playermail) {
if (mail.beenRead) {
mails.add(mail);
}
}
return mails.toArray(new IPlayerMail[0]);
}
return mails.toArray(new IPlayerMail[0]);
}
public IPlayerMail[] getMailFrom(String sender) {
ArrayList<IPlayerMail> mails = new ArrayList<>();
for (PlayerMail mail : playermail) {
if (mail.sender.equals(sender)) {
mails.add(mail);
}
}
return mails.toArray(new IPlayerMail[0]);
}
}
@@ -14,7 +14,6 @@ import noppes.npcs.api.handler.IPlayerQuestData;
import noppes.npcs.api.handler.data.IParty;
import noppes.npcs.api.handler.data.IQuest;
import noppes.npcs.constants.EnumQuestCompletion;
import noppes.npcs.constants.EnumQuestRepeat;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.PartyController;
import noppes.npcs.controllers.PlayerDataController;
@@ -29,103 +28,101 @@ import java.util.HashMap;
import java.util.List;
public class PlayerQuestData implements IPlayerQuestData {
private final PlayerData parent;
private IQuest trackedQuest = null;
private final PlayerData parent;
private IQuest trackedQuest = null;
public HashMap<Integer,QuestData> activeQuests = new HashMap<Integer,QuestData>();
public HashMap<Integer,Long> finishedQuests = new HashMap<Integer,Long>();
public HashMap<Integer, QuestData> activeQuests = new HashMap<Integer, QuestData>();
public HashMap<Integer, Long> finishedQuests = new HashMap<Integer, Long>();
public PlayerQuestData(PlayerData parent) {
this.parent = parent;
}
public PlayerQuestData(PlayerData parent) {
this.parent = parent;
}
public void loadNBTData(NBTTagCompound mainCompound) {
if(mainCompound == null)
return;
NBTTagCompound compound = mainCompound.getCompoundTag("QuestData");
public void loadNBTData(NBTTagCompound mainCompound) {
if (mainCompound == null)
return;
NBTTagCompound compound = mainCompound.getCompoundTag("QuestData");
NBTTagList list = compound.getTagList("CompletedQuests", 10);
if(list != null){
HashMap<Integer,Long> finishedQuests = new HashMap<Integer,Long>();
for(int i = 0; i < list.tagCount(); i++)
{
if (list != null) {
HashMap<Integer, Long> finishedQuests = new HashMap<Integer, Long>();
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
finishedQuests.put(nbttagcompound.getInteger("Quest"),nbttagcompound.getLong("Date"));
finishedQuests.put(nbttagcompound.getInteger("Quest"), nbttagcompound.getLong("Date"));
}
this.finishedQuests = finishedQuests;
}
NBTTagList list2 = compound.getTagList("ActiveQuests", 10);
if(list2 != null){
HashMap<Integer,QuestData> activeQuests = new HashMap<Integer,QuestData>();
for(int i = 0; i < list2.tagCount(); i++)
{
if (list2 != null) {
HashMap<Integer, QuestData> activeQuests = new HashMap<Integer, QuestData>();
for (int i = 0; i < list2.tagCount(); i++) {
NBTTagCompound nbttagcompound = list2.getCompoundTagAt(i);
int id = nbttagcompound.getInteger("Quest");
Quest quest = QuestController.Instance.quests.get(id);
if(quest == null)
continue;
if (quest == null)
continue;
QuestData data = new QuestData(quest);
data.readEntityFromNBT(nbttagcompound);
activeQuests.put(id,data);
activeQuests.put(id, data);
}
this.activeQuests = activeQuests;
}
this.trackedQuest = QuestController.Instance.get(mainCompound.getInteger("TrackedQuestID"));
}
this.trackedQuest = QuestController.Instance.get(mainCompound.getInteger("TrackedQuestID"));
}
public void saveNBTData(NBTTagCompound maincompound) {
NBTTagCompound compound = new NBTTagCompound();
NBTTagList list = new NBTTagList();
for(int quest : finishedQuests.keySet()){
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Quest", quest);
nbttagcompound.setLong("Date", finishedQuests.get(quest));
list.appendTag(nbttagcompound);
}
public void saveNBTData(NBTTagCompound maincompound) {
NBTTagCompound compound = new NBTTagCompound();
NBTTagList list = new NBTTagList();
for (int quest : finishedQuests.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Quest", quest);
nbttagcompound.setLong("Date", finishedQuests.get(quest));
list.appendTag(nbttagcompound);
}
compound.setTag("CompletedQuests", list);
compound.setTag("CompletedQuests", list);
NBTTagList list2 = new NBTTagList();
for(int quest : activeQuests.keySet()){
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Quest", quest);
activeQuests.get(quest).writeEntityToNBT(nbttagcompound);
list2.appendTag(nbttagcompound);
}
NBTTagList list2 = new NBTTagList();
for (int quest : activeQuests.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Quest", quest);
activeQuests.get(quest).writeEntityToNBT(nbttagcompound);
list2.appendTag(nbttagcompound);
}
compound.setTag("ActiveQuests", list2);
compound.setTag("ActiveQuests", list2);
maincompound.setTag("QuestData", compound);
maincompound.setTag("QuestData", compound);
if (this.trackedQuest != null) {
maincompound.setInteger("TrackedQuestID", this.trackedQuest.getId());
} else {
maincompound.setInteger("TrackedQuestID", -1);
}
}
if (this.trackedQuest != null) {
maincompound.setInteger("TrackedQuestID", this.trackedQuest.getId());
} else {
maincompound.setInteger("TrackedQuestID", -1);
}
}
public QuestData getQuestCompletion(EntityPlayer player,EntityNPCInterface npc) {
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
for(QuestData data : activeQuests.values()){
Quest quest = data.quest;
if(quest != null && quest.completion == EnumQuestCompletion.Npc && quest.completerNpc.equals(npc.getCommandSenderName()) && quest.questInterface.isCompleted(playerData)){
return data;
}
}
return null;
}
public Party getPartyQuestCompletion(EntityPlayer player,EntityNPCInterface npc) {
public QuestData getQuestCompletion(EntityPlayer player, EntityNPCInterface npc) {
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
if(playerData != null){
for (QuestData data : activeQuests.values()) {
Quest quest = data.quest;
if (quest != null && quest.completion == EnumQuestCompletion.Npc && quest.completerNpc.equals(npc.getCommandSenderName()) && quest.questInterface.isCompleted(playerData)) {
return data;
}
}
return null;
}
public Party getPartyQuestCompletion(EntityPlayer player, EntityNPCInterface npc) {
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
if (playerData != null) {
Party party = playerData.getPlayerParty();
if(party != null){
if (party != null) {
QuestData data = party.getQuestData();
if(data != null){
if (data != null) {
Quest quest = data.quest;
if(quest != null && quest.completion == EnumQuestCompletion.Npc && quest.completerNpc.equals(npc.getCommandSenderName()) && quest.questInterface.isPartyCompleted(party)){
if (quest != null && quest.completion == EnumQuestCompletion.Npc && quest.completerNpc.equals(npc.getCommandSenderName()) && quest.questInterface.isPartyCompleted(party)) {
return party;
}
}
@@ -134,64 +131,64 @@ public class PlayerQuestData implements IPlayerQuestData {
return null;
}
public boolean checkQuestCompletion(PlayerData playerData,EnumQuestType type) {
boolean bo = false;
EntityPlayer player = playerData.player;
public boolean checkQuestCompletion(PlayerData playerData, EnumQuestType type) {
boolean bo = false;
EntityPlayer player = playerData.player;
int partyQuestID = -1;
if(playerData.partyUUID != null){
if (playerData.partyUUID != null) {
Party party = PartyController.Instance().getParty(playerData.partyUUID);
if(party != null){
if (party != null) {
IQuest quest = party.getQuest();
if(quest != null){
if (quest != null) {
partyQuestID = quest.getId();
}
}
}
ArrayList<QuestData> activeQuestValues = new ArrayList<>(this.activeQuests.values());
for(QuestData data : activeQuestValues){
if(data.quest.type != type && type != null)
continue;
ArrayList<QuestData> activeQuestValues = new ArrayList<>(this.activeQuests.values());
for (QuestData data : activeQuestValues) {
if (data.quest.type != type && type != null)
continue;
// Check if Active Quest = Party Quest
if(partyQuestID != -1 && data.quest.id == partyQuestID && data.quest.partyOptions.isAllowParty()){
if (partyQuestID != -1 && data.quest.id == partyQuestID && data.quest.partyOptions.isAllowParty()) {
continue;
}
if(data.quest.partyOptions.allowParty && data.quest.partyOptions.onlyParty)
if (data.quest.partyOptions.allowParty && data.quest.partyOptions.onlyParty)
continue;
QuestInterface inter = data.quest.questInterface;
if(inter.isCompleted(playerData)){
if((!data.isCompleted && data.quest.completion == EnumQuestCompletion.Npc) || data.quest.instantComplete(player,data)){
data.isCompleted = true;
if (data.quest.completion == EnumQuestCompletion.Npc) {
EventHooks.onQuestFinished(player, data.quest);
}
bo = true;
}
} else {
data.isCompleted = false;
}
QuestInterface inter = data.quest.questInterface;
if (inter.isCompleted(playerData)) {
if ((!data.isCompleted && data.quest.completion == EnumQuestCompletion.Npc) || data.quest.instantComplete(player, data)) {
data.isCompleted = true;
if (data.quest.completion == EnumQuestCompletion.Npc) {
EventHooks.onQuestFinished(player, data.quest);
}
bo = true;
}
} else {
data.isCompleted = false;
}
if (this.trackedQuest != null && data.quest.getId() == this.trackedQuest.getId()) {
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) player);
}
}
QuestItem.pickedUp = null;
return bo;
}
if (this.trackedQuest != null && data.quest.getId() == this.trackedQuest.getId()) {
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) player);
}
}
QuestItem.pickedUp = null;
return bo;
}
public void trackQuest(IQuest quest) {
if (this.trackedQuest == null || quest.getId() != this.trackedQuest.getId()) {
this.trackedQuest = quest;
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) this.parent.player);
}
}
public void trackQuest(IQuest quest) {
if (this.trackedQuest == null || quest.getId() != this.trackedQuest.getId()) {
this.trackedQuest = quest;
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) this.parent.player);
}
}
public void trackParty(IParty party) {
if(party == null)
if (party == null)
return;
IQuest quest = party.getQuest();
@@ -201,101 +198,101 @@ public class PlayerQuestData implements IPlayerQuestData {
}
}
public void untrackQuest() {
if (this.trackedQuest != null) {
this.trackedQuest = null;
public void untrackQuest() {
if (this.trackedQuest != null) {
this.trackedQuest = null;
PacketHandler.Instance.sendToPlayer(new OverlayQuestTrackingPacket(new NBTTagCompound()), (EntityPlayerMP) this.parent.player);
}
}
}
public IQuest getTrackedQuest() {
return this.trackedQuest;
}
public IQuest getTrackedQuest() {
return this.trackedQuest;
}
public void startQuest(int id) {
Quest quest = QuestController.Instance.quests.get(id);
if (quest == null)
return;
if(activeQuests.containsKey(id))
return;
QuestData questdata = new QuestData(quest);
activeQuests.put(id, questdata);
public void startQuest(int id) {
Quest quest = QuestController.Instance.quests.get(id);
if (quest == null)
return;
if (activeQuests.containsKey(id))
return;
QuestData questdata = new QuestData(quest);
activeQuests.put(id, questdata);
AchievementPacket.sendAchievement((EntityPlayerMP) parent.player, false, "quest.newquest", quest.title);
ChatAlertPacket.sendChatAlert((EntityPlayerMP) parent.player, "quest.newquest", ": ", quest.title);
parent.updateClient = true;
}
}
public void finishQuest(int id) {
Quest quest = QuestController.Instance.quests.get(id);
if (quest == null)
return;
public void finishQuest(int id) {
Quest quest = QuestController.Instance.quests.get(id);
if (quest == null)
return;
PlayerQuestController.setQuestFinished(quest, parent.player);
parent.updateClient = true;
}
}
public void stopQuest(int id) {
Quest quest = QuestController.Instance.quests.get(id);
if (quest == null)
return;
activeQuests.remove(id);
public void stopQuest(int id) {
Quest quest = QuestController.Instance.quests.get(id);
if (quest == null)
return;
activeQuests.remove(id);
parent.updateClient = true;
}
}
public void removeQuest(int id) {
Quest quest = QuestController.Instance.quests.get(id);
if (quest == null)
return;
activeQuests.remove(id);
finishedQuests.remove(id);
public void removeQuest(int id) {
Quest quest = QuestController.Instance.quests.get(id);
if (quest == null)
return;
activeQuests.remove(id);
finishedQuests.remove(id);
parent.updateClient = true;
}
}
public boolean hasFinishedQuest(int id){
return finishedQuests.containsKey(id);
}
public boolean hasFinishedQuest(int id) {
return finishedQuests.containsKey(id);
}
public boolean hasActiveQuest(int id){
return activeQuests.containsKey(id);
}
public boolean hasActiveQuest(int id) {
return activeQuests.containsKey(id);
}
public IQuest[] getActiveQuests() {
List<IQuest> quests = new ArrayList<>();
public IQuest[] getActiveQuests() {
List<IQuest> quests = new ArrayList<>();
for (int id : activeQuests.keySet()) {
IQuest quest = (IQuest) QuestController.Instance.quests.get(id);
if (quest != null) {
quests.add(quest);
}
}
for (int id : activeQuests.keySet()) {
IQuest quest = (IQuest) QuestController.Instance.quests.get(id);
if (quest != null) {
quests.add(quest);
}
}
return (IQuest[])quests.toArray(new IQuest[0]);
}
return (IQuest[]) quests.toArray(new IQuest[0]);
}
public IQuest[] getFinishedQuests() {
List<IQuest> quests = new ArrayList<>();
public IQuest[] getFinishedQuests() {
List<IQuest> quests = new ArrayList<>();
for (int id : finishedQuests.keySet()) {
IQuest quest = (IQuest) QuestController.Instance.quests.get(id);
if (quest != null) {
quests.add(quest);
}
}
for (int id : finishedQuests.keySet()) {
IQuest quest = (IQuest) QuestController.Instance.quests.get(id);
if (quest != null) {
quests.add(quest);
}
}
return (IQuest[])quests.toArray(new IQuest[0]);
}
return (IQuest[]) quests.toArray(new IQuest[0]);
}
public long getLastCompletedTime(int id) {
if (this.hasFinishedQuest(id)) {
return this.finishedQuests.get(id);
}
return 0;
}
public long getLastCompletedTime(int id) {
if (this.hasFinishedQuest(id)) {
return this.finishedQuests.get(id);
}
return 0;
}
public void setLastCompletedTime(int id,long time) {
Quest quest = QuestController.Instance.quests.get(id);
if (quest == null)
return;
this.finishedQuests.put(id,time);
}
public void setLastCompletedTime(int id, long time) {
Quest quest = QuestController.Instance.quests.get(id);
if (quest == null)
return;
this.finishedQuests.put(id, time);
}
}
@@ -10,68 +10,67 @@ import java.util.ArrayList;
import java.util.HashSet;
public class PlayerTransportData implements IPlayerTransportData {
private final PlayerData parent;
public HashSet<Integer> transports = new HashSet<Integer>();
private final PlayerData parent;
public HashSet<Integer> transports = new HashSet<Integer>();
public PlayerTransportData(PlayerData parent) {
this.parent = parent;
}
public PlayerTransportData(PlayerData parent) {
this.parent = parent;
}
public void loadNBTData(NBTTagCompound compound) {
HashSet<Integer> dialogsRead = new HashSet<Integer>();
if(compound == null)
return;
public void loadNBTData(NBTTagCompound compound) {
HashSet<Integer> dialogsRead = new HashSet<Integer>();
if (compound == null)
return;
NBTTagList list = compound.getTagList("TransportData", 10);
if(list == null){
return;
if (list == null) {
return;
}
for(int i = 0; i < list.tagCount(); i++)
{
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
dialogsRead.add(nbttagcompound.getInteger("Transport"));
}
this.transports = dialogsRead;
}
}
public void saveNBTData(NBTTagCompound compound) {
NBTTagList list = new NBTTagList();
for(int dia : transports){
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Transport", dia);
list.appendTag(nbttagcompound);
}
compound.setTag("TransportData", list);
}
public void saveNBTData(NBTTagCompound compound) {
NBTTagList list = new NBTTagList();
for (int dia : transports) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Transport", dia);
list.appendTag(nbttagcompound);
}
public boolean hasTransport(int id) {
return transports.contains(id);
}
compound.setTag("TransportData", list);
}
public void addTransport(int id) {
transports.add(id);
}
public boolean hasTransport(int id) {
return transports.contains(id);
}
public void addTransport(ITransportLocation location) {
transports.add(location.getId());
}
public void addTransport(int id) {
transports.add(id);
}
public ITransportLocation getTransport(int id) {
return TransportController.getInstance().getTransport(id);
}
public void addTransport(ITransportLocation location) {
transports.add(location.getId());
}
public ITransportLocation[] getTransports() {
ArrayList<ITransportLocation> list = new ArrayList<>();
for (int id : transports) {
ITransportLocation location = TransportController.getInstance().getTransport(id);
list.add(location);
}
public ITransportLocation getTransport(int id) {
return TransportController.getInstance().getTransport(id);
}
return list.toArray(new ITransportLocation[0]);
}
public ITransportLocation[] getTransports() {
ArrayList<ITransportLocation> list = new ArrayList<>();
for (int id : transports) {
ITransportLocation location = TransportController.getInstance().getTransport(id);
list.add(location);
}
public void removeTransport(int id) {
transports.remove(id);
}
return list.toArray(new ITransportLocation[0]);
}
public void removeTransport(int id) {
transports.remove(id);
}
}
@@ -5,71 +5,68 @@ import noppes.npcs.api.handler.data.IProfileOptions;
import noppes.npcs.constants.EnumProfileSync;
public class ProfileOptions implements IProfileOptions {
public boolean enableOptions = false;
public boolean enableOptions = false;
public EnumProfileSync cooldownControl = EnumProfileSync.Individual;
public EnumProfileSync completeControl = EnumProfileSync.Individual;
public EnumProfileSync completeControl = EnumProfileSync.Individual;
public void readFromNBT(NBTTagCompound compound)
{
// Party Management
public void readFromNBT(NBTTagCompound compound) {
// Party Management
enableOptions = compound.getBoolean("EnableProfiles");
if(enableOptions){
if (enableOptions) {
cooldownControl = EnumProfileSync.values()[compound.getInteger("CooldownControl")];
completeControl = EnumProfileSync.values()[compound.getInteger("CompleteControl")];
}
else {
if(compound.hasKey("CooldownControl")){
} else {
if (compound.hasKey("CooldownControl")) {
compound.removeTag("CooldownControl");
}
if(compound.hasKey("CompleteControl")){
compound.removeTag("CompleteControl");
}
if (compound.hasKey("CompleteControl")) {
compound.removeTag("CompleteControl");
}
cooldownControl = EnumProfileSync.Individual;
completeControl = EnumProfileSync.Individual;
}
}
}
public NBTTagCompound writeToNBT()
{
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("EnableProfiles", enableOptions);
if(enableOptions){
compound.setInteger("CooldownControl", cooldownControl.ordinal());
compound.setInteger("CompleteControl", completeControl.ordinal());
}
else {
if(compound.hasKey("CooldownControl")){
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("EnableProfiles", enableOptions);
if (enableOptions) {
compound.setInteger("CooldownControl", cooldownControl.ordinal());
compound.setInteger("CompleteControl", completeControl.ordinal());
} else {
if (compound.hasKey("CooldownControl")) {
compound.removeTag("CooldownControl");
}
if(compound.hasKey("CompleteControl")){
compound.removeTag("CompleteControl");
}
}
if (compound.hasKey("CompleteControl")) {
compound.removeTag("CompleteControl");
}
}
return compound;
return compound;
}
@Override
public boolean hasProfileOptions() {
return enableOptions;
}
public boolean hasProfileOptions() {
return enableOptions;
}
@Override
public void setProfileOptions(boolean enable) {
this.enableOptions = enable;
}
public void setProfileOptions(boolean enable) {
this.enableOptions = enable;
}
@Override
public void setCooldownControl(int profileType) {
if (profileType < 0 || profileType >= EnumProfileSync.values().length) {
return;
}
this.cooldownControl = EnumProfileSync.values()[profileType];
}
public void setCooldownControl(int profileType) {
if (profileType < 0 || profileType >= EnumProfileSync.values().length) {
return;
}
this.cooldownControl = EnumProfileSync.values()[profileType];
}
@Override
public int getCooldownControl(){
public int getCooldownControl() {
return this.cooldownControl.ordinal();
}
@@ -82,7 +79,7 @@ public class ProfileOptions implements IProfileOptions {
}
@Override
public int getCompleteControl(){
public int getCompleteControl() {
return this.completeControl.ordinal();
}
}
@@ -1,7 +1,6 @@
package noppes.npcs.controllers.data;
import kamkeel.npcs.controllers.ProfileController;
import noppes.npcs.api.handler.data.ISlot;
import kamkeel.npcs.controllers.data.profile.Profile;
import kamkeel.npcs.network.packets.data.QuestCompletionPacket;
import net.minecraft.entity.player.EntityPlayer;
@@ -25,148 +24,149 @@ import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.NpcAPI;
public class Quest implements ICompatibilty, IQuest {
public int version = VersionCompatibility.ModRev;
public int id = -1;
public EnumQuestType type = EnumQuestType.Item;
public EnumQuestRepeat repeat = EnumQuestRepeat.NONE;
public EnumQuestCompletion completion = EnumQuestCompletion.Npc;
public String title = "default";
public QuestCategory category;
public String logText = "";
public String completeText = "";
public String completerNpc = "";
public int nextQuestid = -1;
public String nextQuestTitle = "";
public PlayerMail mail = new PlayerMail();
public String command = "";
public int version = VersionCompatibility.ModRev;
public int id = -1;
public EnumQuestType type = EnumQuestType.Item;
public EnumQuestRepeat repeat = EnumQuestRepeat.NONE;
public EnumQuestCompletion completion = EnumQuestCompletion.Npc;
public String title = "default";
public QuestCategory category;
public String logText = "";
public String completeText = "";
public String completerNpc = "";
public int nextQuestid = -1;
public String nextQuestTitle = "";
public PlayerMail mail = new PlayerMail();
public String command = "";
public QuestInterface questInterface = new QuestItem();
public QuestInterface questInterface = new QuestItem();
public long customCooldown = 0;
public int rewardExp = 0;
public NpcMiscInventory rewardItems = new NpcMiscInventory(9);
public boolean randomReward = false;
public FactionOptions factionOptions = new FactionOptions();
public PartyOptions partyOptions = new PartyOptions();
public int rewardExp = 0;
public NpcMiscInventory rewardItems = new NpcMiscInventory(9);
public boolean randomReward = false;
public FactionOptions factionOptions = new FactionOptions();
public PartyOptions partyOptions = new PartyOptions();
public ProfileOptions profileOptions = new ProfileOptions();
public void readNBT(NBTTagCompound compound) {
id = compound.getInteger("Id");
readNBTPartial(compound);
}
public void readNBTPartial(NBTTagCompound compound) {
version = compound.getInteger("ModRev");
VersionCompatibility.CheckAvailabilityCompatibility(this, compound);
public void readNBT(NBTTagCompound compound) {
id = compound.getInteger("Id");
readNBTPartial(compound);
}
setType(EnumQuestType.values()[compound.getInteger("Type")]);
title = compound.getString("Title");
logText = compound.getString("Text");
completeText = compound.getString("CompleteText");
completerNpc = compound.getString("CompleterNpc");
command = compound.getString("QuestCommand");
nextQuestid = compound.getInteger("NextQuestId");
nextQuestTitle = compound.getString("NextQuestTitle");
if(hasNewQuest())
nextQuestTitle = getNextQuest().title;
else
nextQuestTitle = "";
randomReward = compound.getBoolean("RandomReward");
rewardExp = compound.getInteger("RewardExp");
rewardItems.setFromNBT(compound.getCompoundTag("Rewards"));
public void readNBTPartial(NBTTagCompound compound) {
version = compound.getInteger("ModRev");
VersionCompatibility.CheckAvailabilityCompatibility(this, compound);
completion = EnumQuestCompletion.values()[compound.getInteger("QuestCompletion")];
repeat = EnumQuestRepeat.values()[compound.getInteger("QuestRepeat")];
setType(EnumQuestType.values()[compound.getInteger("Type")]);
title = compound.getString("Title");
logText = compound.getString("Text");
completeText = compound.getString("CompleteText");
completerNpc = compound.getString("CompleterNpc");
command = compound.getString("QuestCommand");
nextQuestid = compound.getInteger("NextQuestId");
nextQuestTitle = compound.getString("NextQuestTitle");
if (hasNewQuest())
nextQuestTitle = getNextQuest().title;
else
nextQuestTitle = "";
randomReward = compound.getBoolean("RandomReward");
rewardExp = compound.getInteger("RewardExp");
rewardItems.setFromNBT(compound.getCompoundTag("Rewards"));
completion = EnumQuestCompletion.values()[compound.getInteger("QuestCompletion")];
repeat = EnumQuestRepeat.values()[compound.getInteger("QuestRepeat")];
customCooldown = compound.getLong("CustomCooldown");
questInterface.readEntityFromNBT(compound);
questInterface.readEntityFromNBT(compound);
factionOptions.readFromNBT(compound.getCompoundTag("QuestFactionPoints"));
partyOptions.readFromNBT(compound.getCompoundTag("PartyOptions"));
factionOptions.readFromNBT(compound.getCompoundTag("QuestFactionPoints"));
partyOptions.readFromNBT(compound.getCompoundTag("PartyOptions"));
profileOptions.readFromNBT(compound.getCompoundTag("ProfileOptions"));
mail.readNBT(compound.getCompoundTag("QuestMail"));
}
mail.readNBT(compound.getCompoundTag("QuestMail"));
}
public void setType(EnumQuestType questType) {
type = questType;
if(type == EnumQuestType.Item)
questInterface = new QuestItem();
else if(type == EnumQuestType.Dialog)
questInterface = new QuestDialog();
else if(type == EnumQuestType.Kill || type == EnumQuestType.AreaKill)
questInterface = new QuestKill();
else if(type == EnumQuestType.Location)
questInterface = new QuestLocation();
else if(type == EnumQuestType.Manual)
public void setType(EnumQuestType questType) {
type = questType;
if (type == EnumQuestType.Item)
questInterface = new QuestItem();
else if (type == EnumQuestType.Dialog)
questInterface = new QuestDialog();
else if (type == EnumQuestType.Kill || type == EnumQuestType.AreaKill)
questInterface = new QuestKill();
else if (type == EnumQuestType.Location)
questInterface = new QuestLocation();
else if (type == EnumQuestType.Manual)
questInterface = new QuestManual();
if(questInterface != null)
questInterface.questId = id;
}
if (questInterface != null)
questInterface.questId = id;
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setInteger("Id", id);
return writeToNBTPartial(compound);
}
public NBTTagCompound writeToNBTPartial(NBTTagCompound compound) {
compound.setInteger("ModRev", version);
compound.setInteger("Type", type.ordinal());
compound.setString("Title", title);
compound.setString("Text", logText);
compound.setString("CompleteText", completeText);
compound.setString("CompleterNpc", completerNpc);
compound.setInteger("NextQuestId", nextQuestid);
compound.setString("NextQuestTitle", nextQuestTitle);
compound.setInteger("RewardExp", rewardExp);
compound.setTag("Rewards", rewardItems.getToNBT());
compound.setString("QuestCommand", command);
compound.setBoolean("RandomReward", randomReward);
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setInteger("Id", id);
return writeToNBTPartial(compound);
}
public NBTTagCompound writeToNBTPartial(NBTTagCompound compound) {
compound.setInteger("ModRev", version);
compound.setInteger("Type", type.ordinal());
compound.setString("Title", title);
compound.setString("Text", logText);
compound.setString("CompleteText", completeText);
compound.setString("CompleterNpc", completerNpc);
compound.setInteger("NextQuestId", nextQuestid);
compound.setString("NextQuestTitle", nextQuestTitle);
compound.setInteger("RewardExp", rewardExp);
compound.setTag("Rewards", rewardItems.getToNBT());
compound.setString("QuestCommand", command);
compound.setBoolean("RandomReward", randomReward);
compound.setLong("CustomCooldown", customCooldown);
compound.setInteger("QuestCompletion", completion.ordinal());
compound.setInteger("QuestRepeat", repeat.ordinal());
compound.setInteger("QuestCompletion", completion.ordinal());
compound.setInteger("QuestRepeat", repeat.ordinal());
this.questInterface.writeEntityToNBT(compound);
compound.setTag("QuestFactionPoints", factionOptions.writeToNBT(new NBTTagCompound()));
compound.setTag("PartyOptions", partyOptions.writeToNBT());
this.questInterface.writeEntityToNBT(compound);
compound.setTag("QuestFactionPoints", factionOptions.writeToNBT(new NBTTagCompound()));
compound.setTag("PartyOptions", partyOptions.writeToNBT());
compound.setTag("ProfileOptions", profileOptions.writeToNBT());
compound.setTag("QuestMail", mail.writeNBT());
compound.setTag("QuestMail", mail.writeNBT());
return compound;
}
return compound;
}
public boolean hasNewQuest()
{
return getNextQuest() != null;
}
public Quest getNextQuest()
{
return QuestController.Instance == null?null:QuestController.Instance.quests.get(nextQuestid);
}
public boolean hasNewQuest() {
return getNextQuest() != null;
}
public boolean instantComplete(EntityPlayer player, QuestData data) {
if(completion == EnumQuestCompletion.Instant && NoppesUtilPlayer.questCompletion((EntityPlayerMP) player, data.quest.id)){
QuestCompletionPacket.sendQuestComplete((EntityPlayerMP)player, data.quest.writeToNBT(new NBTTagCompound()));
return true;
}
return false;
}
public Quest getNextQuest() {
return QuestController.Instance == null ? null : QuestController.Instance.quests.get(nextQuestid);
}
public boolean instantComplete(EntityPlayer player, QuestData data) {
if (completion == EnumQuestCompletion.Instant && NoppesUtilPlayer.questCompletion((EntityPlayerMP) player, data.quest.id)) {
QuestCompletionPacket.sendQuestComplete((EntityPlayerMP) player, data.quest.writeToNBT(new NBTTagCompound()));
return true;
}
return false;
}
public boolean instantPartyComplete(Party party) {
return completion == EnumQuestCompletion.Instant && NoppesUtilPlayer.questPartyCompletion(party);
}
public Quest copy(){
Quest quest = new Quest();
quest.readNBT(this.writeToNBT(new NBTTagCompound()));
return quest;
}
public Quest copy() {
Quest quest = new Quest();
quest.readNBT(this.writeToNBT(new NBTTagCompound()));
return quest;
}
public long getTimeUntilRepeat(EntityPlayer player) {
if(ConfigMain.ProfilesEnabled && profileOptions.enableOptions && profileOptions.cooldownControl == EnumProfileSync.Shared){
if (ConfigMain.ProfilesEnabled && profileOptions.enableOptions && profileOptions.cooldownControl == EnumProfileSync.Shared) {
Profile profile = ProfileController.Instance.getProfile(player);
IPlayer iPlayer = NoppesUtilServer.getIPlayer(player);
long timeRemaining = 0L;
for(ISlot slot : profile.getSlots().values()){
for (ISlot slot : profile.getSlots().values()) {
IPlayerData playerData = ProfileController.Instance.getSlotPlayerData(iPlayer, slot.getId());
IPlayerQuestData iPlayerQuestData = playerData.getQuestData();
timeRemaining = Math.max(timeRemaining, getTimeUntilRepeatQuestData(player, iPlayerQuestData));
@@ -177,7 +177,7 @@ public class Quest implements ICompatibilty, IQuest {
return getTimeUntilRepeatQuestData(player, questData);
}
public long getTimeUntilRepeatQuestData(EntityPlayer player, IPlayerQuestData questData){
public long getTimeUntilRepeatQuestData(EntityPlayer player, IPlayerQuestData questData) {
long questTime = questData.getLastCompletedTime(this.id);
switch (repeat) {
@@ -251,123 +251,124 @@ public class Quest implements ICompatibilty, IQuest {
@Override
public int getVersion() {
return version;
}
@Override
public void setVersion(int version) {
this.version = version;
}
public int getVersion() {
return version;
}
public int getId() {
return this.id;
}
@Override
public void setVersion(int version) {
this.version = version;
}
public String getName() {
return this.title;
}
public int getId() {
return this.id;
}
public int getType() {
return this.type.ordinal();
}
public String getName() {
return this.title;
}
public void setType(int questType) {
if(questType < 0 || questType >= EnumQuestType.values().length)
return;
public int getType() {
return this.type.ordinal();
}
EnumQuestType type = EnumQuestType.values()[questType];
setType(type);
}
public void setType(int questType) {
if (questType < 0 || questType >= EnumQuestType.values().length)
return;
public IQuestCategory getCategory() {
return this.category;
}
EnumQuestType type = EnumQuestType.values()[questType];
setType(type);
}
public void save() {
QuestController.Instance.saveQuest(this.category.id, this);
}
public IQuestCategory getCategory() {
return this.category;
}
public void setName(String name) {
this.title = name;
}
public void save() {
QuestController.Instance.saveQuest(this.category.id, this);
}
public String getLogText() {
return this.logText;
}
public void setName(String name) {
this.title = name;
}
public void setLogText(String text) {
this.logText = text;
}
public String getLogText() {
return this.logText;
}
public String getCompleteText() {
return this.completeText;
}
public void setLogText(String text) {
this.logText = text;
}
public void setCompleteText(String text) {
this.completeText = text;
}
public String getCompleteText() {
return this.completeText;
}
public void setNextQuest(IQuest quest) {
if (quest == null) {
this.nextQuestid = -1;
this.nextQuestTitle = "";
} else {
if (quest.getId() < 0) {
throw new CustomNPCsException("Quest id is lower than 0", new Object[0]);
}
public void setCompleteText(String text) {
this.completeText = text;
}
this.nextQuestid = quest.getId();
this.nextQuestTitle = quest.getName();
}
public void setNextQuest(IQuest quest) {
if (quest == null) {
this.nextQuestid = -1;
this.nextQuestTitle = "";
} else {
if (quest.getId() < 0) {
throw new CustomNPCsException("Quest id is lower than 0", new Object[0]);
}
}
this.nextQuestid = quest.getId();
this.nextQuestTitle = quest.getName();
}
public String getNpcName() {
return this.completerNpc;
}
}
public void setNpcName(String name) {
this.completerNpc = name;
}
public String getNpcName() {
return this.completerNpc;
}
public IQuestObjective[] getObjectives(IPlayer player) {
if (!player.hasActiveQuest(this.id)) {
throw new CustomNPCsException("Player doesnt have this quest active.", new Object[0]);
} else {
return this.questInterface.getObjectives((EntityPlayer) player.getMCEntity());
}
}
public void setNpcName(String name) {
this.completerNpc = name;
}
public boolean getIsRepeatable() {
return this.repeat != EnumQuestRepeat.NONE;
}
public IQuestObjective[] getObjectives(IPlayer player) {
if (!player.hasActiveQuest(this.id)) {
throw new CustomNPCsException("Player doesnt have this quest active.", new Object[0]);
} else {
return this.questInterface.getObjectives((EntityPlayer) player.getMCEntity());
}
}
public long getTimeUntilRepeat(IPlayer player) {
return this.getTimeUntilRepeat((EntityPlayer) player.getMCEntity());
}
public boolean getIsRepeatable() {
return this.repeat != EnumQuestRepeat.NONE;
}
public void setRepeatType(int type) {
if (type < 0 || type >= EnumQuestRepeat.values().length) {
return;
}
this.repeat = EnumQuestRepeat.values()[type];
}
public long getTimeUntilRepeat(IPlayer player) {
return this.getTimeUntilRepeat((EntityPlayer) player.getMCEntity());
}
public int getRepeatType() {
return this.repeat.ordinal();
}
public void setRepeatType(int type) {
if (type < 0 || type >= EnumQuestRepeat.values().length) {
return;
}
this.repeat = EnumQuestRepeat.values()[type];
}
public IContainer getRewards() {
return NpcAPI.Instance().getIContainer(this.rewardItems);
}
public int getRepeatType() {
return this.repeat.ordinal();
}
public IQuestInterface getQuestInterface(){
return this.questInterface;
}
public IContainer getRewards() {
return NpcAPI.Instance().getIContainer(this.rewardItems);
}
public IPartyOptions getPartyOptions() {
return this.partyOptions;
}
public IQuestInterface getQuestInterface() {
return this.questInterface;
}
public IPartyOptions getPartyOptions() {
return this.partyOptions;
}
public IProfileOptions getProfileOptions() {
return this.profileOptions;
@@ -10,43 +10,42 @@ import java.util.HashMap;
import java.util.List;
public class QuestCategory implements IQuestCategory {
public HashMap<Integer,Quest> quests;
public int id = -1;
public String title = "";
public HashMap<Integer, Quest> quests;
public int id = -1;
public String title = "";
public QuestCategory(){
quests = new HashMap<Integer, Quest>();
}
public QuestCategory() {
quests = new HashMap<Integer, Quest>();
}
public void readNBT(NBTTagCompound nbttagcompound) {
public void readNBT(NBTTagCompound nbttagcompound) {
id = nbttagcompound.getInteger("Slot");
title = nbttagcompound.getString("Title");
NBTTagList questList = nbttagcompound.getTagList("Quests", 10);
if(questList != null){
for(int ii = 0; ii < questList.tagCount(); ii++)
{
if (questList != null) {
for (int ii = 0; ii < questList.tagCount(); ii++) {
NBTTagCompound nbttagcompound2 = questList.getCompoundTagAt(ii);
Quest quest = new Quest();
quest.readNBT(nbttagcompound2);
quest.category = this;
quests.put(quest.id, quest);
quests.put(quest.id, quest);
}
}
}
}
public NBTTagCompound writeNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger("Slot", id);
nbttagcompound.setString("Title", title);
public NBTTagCompound writeNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger("Slot", id);
nbttagcompound.setString("Title", title);
NBTTagList quests = new NBTTagList();
for(int questID : this.quests.keySet()){
Quest quest = this.quests.get(questID);
quests.appendTag(quest.writeToNBT(new NBTTagCompound()));
for (int questID : this.quests.keySet()) {
Quest quest = this.quests.get(questID);
quests.appendTag(quest.writeToNBT(new NBTTagCompound()));
}
nbttagcompound.setTag("Quests", quests);
return nbttagcompound;
}
}
public NBTTagCompound writeSmallNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger("Slot", id);
@@ -3,21 +3,24 @@ package noppes.npcs.controllers.data;
import net.minecraft.nbt.NBTTagCompound;
public class QuestData {
public Quest quest;
public boolean isCompleted;
public boolean sendAlerts = true;
public NBTTagCompound extraData = new NBTTagCompound();
public QuestData(Quest quest){
this.quest = quest;
}
public void writeEntityToNBT(NBTTagCompound nbttagcompound){
nbttagcompound.setBoolean("QuestCompleted", isCompleted);
nbttagcompound.setBoolean("SendAlerts", sendAlerts);
nbttagcompound.setTag("ExtraData", extraData);
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound){
isCompleted = nbttagcompound.getBoolean("QuestCompleted");
sendAlerts = nbttagcompound.getBoolean("SendAlerts");
extraData = nbttagcompound.getCompoundTag("ExtraData");
}
public Quest quest;
public boolean isCompleted;
public boolean sendAlerts = true;
public NBTTagCompound extraData = new NBTTagCompound();
public QuestData(Quest quest) {
this.quest = quest;
}
public void writeEntityToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setBoolean("QuestCompleted", isCompleted);
nbttagcompound.setBoolean("SendAlerts", sendAlerts);
nbttagcompound.setTag("ExtraData", extraData);
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound) {
isCompleted = nbttagcompound.getBoolean("QuestCompleted");
sendAlerts = nbttagcompound.getBoolean("SendAlerts");
extraData = nbttagcompound.getCompoundTag("ExtraData");
}
}
@@ -23,7 +23,8 @@ public class RecipeAnvil implements IAnvilRecipe {
private boolean isAnvil = true;
public RecipeAnvil() { }
public RecipeAnvil() {
}
public RecipeAnvil(String name, ItemStack itemToRepair, ItemStack repairMaterial, int xpCost, float repairPercentage) {
this.name = name;
@@ -56,10 +57,10 @@ public class RecipeAnvil implements IAnvilRecipe {
compound.setTag("Availability", availability.writeToNBT(new NBTTagCompound()));
compound.setInteger("XPCost", xpCost);
compound.setFloat("RepairPercentage", repairPercentage);
if(itemToRepair != null){
if (itemToRepair != null) {
compound.setTag("ItemToRepair", NoppesUtilServer.writeItem(itemToRepair, new NBTTagCompound()));
}
if(repairMaterial != null){
if (repairMaterial != null) {
compound.setTag("RepairMaterial", NoppesUtilServer.writeItem(repairMaterial, new NBTTagCompound()));
}
compound.setBoolean("IgnoreRepairMatNBT", ignoreRepairMaterialNBT);
@@ -144,7 +145,8 @@ public class RecipeAnvil implements IAnvilRecipe {
this.ignoreRepairMaterialDamage = recipe.ignoreRepairMaterialDamage;
this.ignoreRepairItemNBT = recipe.ignoreRepairItemNBT;
this.ignoreRepairMaterialNBT = recipe.ignoreRepairMaterialNBT;
this.repairPercentage = recipe.repairPercentage;;
this.repairPercentage = recipe.repairPercentage;
;
this.xpCost = recipe.xpCost;
}
}
@@ -17,55 +17,56 @@ import java.io.IOException;
import java.util.HashMap;
public class RecipeCarpentry extends ShapedRecipes implements IRecipe {
public int id = -1;
public String name = "";
public int id = -1;
public String name = "";
public Availability availability = new Availability();
public boolean isGlobal = false;
public boolean ignoreDamage = false;
public boolean ignoreNBT = false;
public RecipeCarpentry(int width, int height, ItemStack[] recipe, ItemStack result){
super(width, height, recipe, result);
}
public RecipeCarpentry(String name){
super(0, 0, new ItemStack[0], null);
this.name = name;
public RecipeCarpentry(int width, int height, ItemStack[] recipe, ItemStack result) {
super(width, height, recipe, result);
}
public static RecipeCarpentry read(NBTTagCompound compound){
RecipeCarpentry recipe = new RecipeCarpentry(compound.getInteger("Width"), compound.getInteger("Height"),
NBTTags.getItemStackArray(compound.getTagList("Materials", 10)), NoppesUtilServer.readItem(compound.getCompoundTag("Item")));
recipe.name = compound.getString("Name");
recipe.id = compound.getInteger("ID");
recipe.availability.readFromNBT(compound.getCompoundTag("Availability"));
recipe.ignoreDamage = compound.getBoolean("IgnoreDamage");
recipe.ignoreNBT = compound.getBoolean("IgnoreNBT");
recipe.isGlobal = compound.getBoolean("Global");
return recipe;
public RecipeCarpentry(String name) {
super(0, 0, new ItemStack[0], null);
this.name = name;
}
public NBTTagCompound writeNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("ID", id);
compound.setInteger("Width", recipeWidth);
compound.setInteger("Height", recipeHeight);
if(getRecipeOutput() != null)
compound.setTag("Item", NoppesUtilServer.writeItem(getRecipeOutput(), new NBTTagCompound()));
compound.setTag("Materials", NBTTags.nbtItemStackArray(recipeItems));
compound.setTag("Availability", availability.writeToNBT(new NBTTagCompound()));
compound.setString("Name", name);
compound.setBoolean("Global", isGlobal);
compound.setBoolean("IgnoreDamage", ignoreDamage);
compound.setBoolean("IgnoreNBT", ignoreNBT);
return compound;
}
public static RecipeCarpentry read(NBTTagCompound compound) {
RecipeCarpentry recipe = new RecipeCarpentry(compound.getInteger("Width"), compound.getInteger("Height"),
NBTTags.getItemStackArray(compound.getTagList("Materials", 10)), NoppesUtilServer.readItem(compound.getCompoundTag("Item")));
recipe.name = compound.getString("Name");
recipe.id = compound.getInteger("ID");
recipe.availability.readFromNBT(compound.getCompoundTag("Availability"));
recipe.ignoreDamage = compound.getBoolean("IgnoreDamage");
recipe.ignoreNBT = compound.getBoolean("IgnoreNBT");
recipe.isGlobal = compound.getBoolean("Global");
@Override
public boolean matches(InventoryCrafting par1InventoryCrafting, World world) {
for (int i = 0; i <= 4 - this.recipeWidth; ++i){
for (int j = 0; j <= 4 - this.recipeHeight; ++j){
return recipe;
}
public NBTTagCompound writeNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("ID", id);
compound.setInteger("Width", recipeWidth);
compound.setInteger("Height", recipeHeight);
if (getRecipeOutput() != null)
compound.setTag("Item", NoppesUtilServer.writeItem(getRecipeOutput(), new NBTTagCompound()));
compound.setTag("Materials", NBTTags.nbtItemStackArray(recipeItems));
compound.setTag("Availability", availability.writeToNBT(new NBTTagCompound()));
compound.setString("Name", name);
compound.setBoolean("Global", isGlobal);
compound.setBoolean("IgnoreDamage", ignoreDamage);
compound.setBoolean("IgnoreNBT", ignoreNBT);
return compound;
}
@Override
public boolean matches(InventoryCrafting par1InventoryCrafting, World world) {
for (int i = 0; i <= 4 - this.recipeWidth; ++i) {
for (int j = 0; j <= 4 - this.recipeHeight; ++j) {
if (this.checkMatch(par1InventoryCrafting, i, j, true))
return true;
@@ -74,21 +75,20 @@ public class RecipeCarpentry extends ShapedRecipes implements IRecipe {
}
}
return false;
}
}
/**
* Checks if the region of a crafting inventory is match for the recipe.
*/
private boolean checkMatch(InventoryCrafting par1InventoryCrafting, int par2, int par3, boolean par4){
for (int i = 0; i < 4; i++){
for (int j = 0; j < 4; j++){
private boolean checkMatch(InventoryCrafting par1InventoryCrafting, int par2, int par3, boolean par4) {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
int var7 = i - par2;
int var8 = j - par3;
ItemStack var9 = null;
if (var7 >= 0 && var8 >= 0 && var7 < this.recipeWidth && var8 < this.recipeHeight){
if (var7 >= 0 && var8 >= 0 && var7 < this.recipeWidth && var8 < this.recipeHeight) {
if (par4)
var9 = this.recipeItems[this.recipeWidth - var7 - 1 + var8 * this.recipeWidth];
else
@@ -97,8 +97,8 @@ public class RecipeCarpentry extends ShapedRecipes implements IRecipe {
ItemStack var10 = par1InventoryCrafting.getStackInRowAndColumn(i, j);
if ((var10 != null || var9 != null) && !NoppesUtilPlayer.compareItems(var9, var10, ignoreDamage, ignoreNBT)){
return false;
if ((var10 != null || var9 != null) && !NoppesUtilPlayer.compareItems(var9, var10, ignoreDamage, ignoreNBT)) {
return false;
}
}
}
@@ -106,44 +106,39 @@ public class RecipeCarpentry extends ShapedRecipes implements IRecipe {
return true;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting var1) {
if(getRecipeOutput() == null)
return null;
return getRecipeOutput().copy();
}
@Override
public ItemStack getCraftingResult(InventoryCrafting var1) {
if (getRecipeOutput() == null)
return null;
return getRecipeOutput().copy();
}
@Override
public int getRecipeSize() {
return 16;
}
@Override
public int getRecipeSize() {
return 16;
}
public static RecipeCarpentry saveRecipe(RecipeCarpentry recipe, ItemStack par1ItemStack, Object ... par2ArrayOfObj){
public static RecipeCarpentry saveRecipe(RecipeCarpentry recipe, ItemStack par1ItemStack, Object... par2ArrayOfObj) {
String var3 = "";
int var4 = 0;
int var5 = 0;
int var6 = 0;
int var9;
if (par2ArrayOfObj[var4] instanceof String[])
{
String[] var7 = (String[])((String[])par2ArrayOfObj[var4++]);
if (par2ArrayOfObj[var4] instanceof String[]) {
String[] var7 = (String[]) ((String[]) par2ArrayOfObj[var4++]);
String[] var8 = var7;
var9 = var7.length;
for (int var10 = 0; var10 < var9; ++var10)
{
for (int var10 = 0; var10 < var9; ++var10) {
String var11 = var8[var10];
++var6;
var5 = var11.length();
var3 = var3 + var11;
}
}
else
{
while (par2ArrayOfObj[var4] instanceof String)
{
String var13 = (String)par2ArrayOfObj[var4++];
} else {
while (par2ArrayOfObj[var4] instanceof String) {
String var13 = (String) par2ArrayOfObj[var4++];
++var6;
var5 = var13.length();
var3 = var3 + var13;
@@ -152,22 +147,16 @@ public class RecipeCarpentry extends ShapedRecipes implements IRecipe {
HashMap var14;
for (var14 = new HashMap(); var4 < par2ArrayOfObj.length; var4 += 2)
{
Character var16 = (Character)par2ArrayOfObj[var4];
for (var14 = new HashMap(); var4 < par2ArrayOfObj.length; var4 += 2) {
Character var16 = (Character) par2ArrayOfObj[var4];
ItemStack var17 = null;
if (par2ArrayOfObj[var4 + 1] instanceof Item)
{
var17 = new ItemStack((Item)par2ArrayOfObj[var4 + 1]);
}
else if (par2ArrayOfObj[var4 + 1] instanceof Block)
{
var17 = new ItemStack((Block)par2ArrayOfObj[var4 + 1], 1, -1);
}
else if (par2ArrayOfObj[var4 + 1] instanceof ItemStack)
{
var17 = (ItemStack)par2ArrayOfObj[var4 + 1];
if (par2ArrayOfObj[var4 + 1] instanceof Item) {
var17 = new ItemStack((Item) par2ArrayOfObj[var4 + 1]);
} else if (par2ArrayOfObj[var4 + 1] instanceof Block) {
var17 = new ItemStack((Block) par2ArrayOfObj[var4 + 1], 1, -1);
} else if (par2ArrayOfObj[var4 + 1] instanceof ItemStack) {
var17 = (ItemStack) par2ArrayOfObj[var4 + 1];
}
var14.put(var16, var17);
@@ -175,54 +164,52 @@ public class RecipeCarpentry extends ShapedRecipes implements IRecipe {
ItemStack[] var15 = new ItemStack[var5 * var6];
for (var9 = 0; var9 < var5 * var6; ++var9)
{
for (var9 = 0; var9 < var5 * var6; ++var9) {
char var18 = var3.charAt(var9);
if (var14.containsKey(Character.valueOf(var18)))
{
var15[var9] = ((ItemStack)var14.get(Character.valueOf(var18))).copy();
}
else
{
if (var14.containsKey(Character.valueOf(var18))) {
var15[var9] = ((ItemStack) var14.get(Character.valueOf(var18))).copy();
} else {
var15[var9] = null;
}
}
RecipeCarpentry newrecipe = new RecipeCarpentry(var5, var6, var15, par1ItemStack);
newrecipe.copy(recipe);
if(var5 == 4 || var6 == 4)
newrecipe.isGlobal = false;
if (var5 == 4 || var6 == 4)
newrecipe.isGlobal = false;
return newrecipe;
}
public void copy(RecipeCarpentry recipe) {
this.id = recipe.id;
this.name = recipe.name;
this.availability = recipe.availability;
this.isGlobal = recipe.isGlobal;
this.ignoreDamage = recipe.ignoreDamage;
this.ignoreNBT = recipe.ignoreNBT;
}
this.id = recipe.id;
this.name = recipe.name;
this.availability = recipe.availability;
this.isGlobal = recipe.isGlobal;
this.ignoreDamage = recipe.ignoreDamage;
this.ignoreNBT = recipe.ignoreNBT;
}
public ItemStack getCraftingItem(int i){
if(recipeItems == null || i >= recipeItems.length)
return null;
return recipeItems[i];
public ItemStack getCraftingItem(int i) {
if (recipeItems == null || i >= recipeItems.length)
return null;
return recipeItems[i];
}
public void setCraftingItem(int i, ItemStack item){
if(i < recipeItems.length)
recipeItems[i] = item;
public void setCraftingItem(int i, ItemStack item) {
if (i < recipeItems.length)
recipeItems[i] = item;
}
public boolean isValid() {
if (recipeItems.length == 0 || getRecipeOutput() == null)
return false;
for (ItemStack item : recipeItems) {
if (item != null)
return true;
}
return false;
}
public boolean isValid() {
if(recipeItems.length == 0 || getRecipeOutput() == null)
return false;
for(ItemStack item : recipeItems){
if(item != null)
return true;
}
return false;
}
public String getName() {
return this.name;
@@ -10,185 +10,186 @@ import noppes.npcs.config.ConfigItem;
import noppes.npcs.controllers.RecipeController;
public class RecipesDefault {
public static void addRecipe(String name, Object ob, boolean isGlobal, Object... recipe){
ItemStack item;
if(ob instanceof Item)
item = new ItemStack((Item)ob);
else if(ob instanceof Block)
item = new ItemStack((Block)ob);
else
item = (ItemStack) ob;
public static void addRecipe(String name, Object ob, boolean isGlobal, Object... recipe) {
ItemStack item;
if (ob instanceof Item)
item = new ItemStack((Item) ob);
else if (ob instanceof Block)
item = new ItemStack((Block) ob);
else
item = (ItemStack) ob;
RecipeCarpentry recipeCarpentry = new RecipeCarpentry(name);
recipeCarpentry.isGlobal = isGlobal;
recipeCarpentry = RecipeCarpentry.saveRecipe(recipeCarpentry, item, recipe);
RecipeController.Instance.addRecipe(recipeCarpentry);
}
public static void loadDefaultRecipes(int i) {
if(i < 0){
addRecipe("Npc Wand", CustomItems.wand, true, "XX"," Y"," Y",'X', Items.bread,'Y', Items.stick);
addRecipe("Mob Cloner", CustomItems.cloner, true, "XX","XY"," Y",'X', Items.bread,'Y', Items.stick);
addRecipe("Carpentry Bench", CustomItems.carpentyBench, true, "XYX","Z Z","Z Z", 'X', Blocks.planks, 'Z', Items.stick, 'Y', Blocks.crafting_table);
RecipeCarpentry recipeCarpentry = new RecipeCarpentry(name);
recipeCarpentry.isGlobal = isGlobal;
recipeCarpentry = RecipeCarpentry.saveRecipe(recipeCarpentry, item, recipe);
RecipeController.Instance.addRecipe(recipeCarpentry);
}
public static void loadDefaultRecipes(int i) {
if (i < 0) {
addRecipe("Npc Wand", CustomItems.wand, true, "XX", " Y", " Y", 'X', Items.bread, 'Y', Items.stick);
addRecipe("Mob Cloner", CustomItems.cloner, true, "XX", "XY", " Y", 'X', Items.bread, 'Y', Items.stick);
addRecipe("Carpentry Bench", CustomItems.carpentyBench, true, "XYX", "Z Z", "Z Z", 'X', Blocks.planks, 'Z', Items.stick, 'Y', Blocks.crafting_table);
ItemStack anvil = new ItemStack(CustomItems.carpentyBench);
anvil.setItemDamage(1);
addRecipe("Anvil", anvil, true, "XXX","Z Z","Z Z", 'X', Blocks.iron_block, 'Z', Items.iron_ingot);
addRecipe("Anvil", anvil, true, "XXX", "Z Z", "Z Z", 'X', Blocks.iron_block, 'Z', Items.iron_ingot);
if(!ConfigItem.DisableExtraItems){
addRecipe("Mana", CustomItems.mana, true, "XY",'X',Items.redstone,'Y',Items.glowstone_dust);
addRecipe("Gun Wooden", CustomItems.gunWood, false, "XXXY"," ZM "," M ",'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button,'X', Blocks.planks);
addRecipe("Gun Stone", CustomItems.gunStone, false, "XXXY"," ZM "," M ",'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button,'X', Blocks.cobblestone);
addRecipe("Gun Iron", CustomItems.gunIron, false, "XXXY"," ZM "," M ",'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button,'X', Items.iron_ingot);
addRecipe("Gun Gold", CustomItems.gunGold, false, "XXXY"," ZM "," M ",'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button,'X', Items.gold_ingot);
addRecipe("Gun Diamond", CustomItems.gunDiamond, false, "XXXY"," ZM "," M ",'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button,'X', Items.diamond);
addRecipe("Gun Emerald", CustomItems.gunEmerald, false, "XXXY"," ZM "," M ",'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button,'X', Items.emerald);
addRecipe("Gun Bronze", CustomItems.gunBronze, false, "XXXY"," ZM "," M ",'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button,'X', CustomItems.bronze_ingot);
if (!ConfigItem.DisableExtraItems) {
addRecipe("Mana", CustomItems.mana, true, "XY", 'X', Items.redstone, 'Y', Items.glowstone_dust);
addRecipe("Gun Wooden", CustomItems.gunWood, false, "XXXY", " ZM ", " M ", 'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button, 'X', Blocks.planks);
addRecipe("Gun Stone", CustomItems.gunStone, false, "XXXY", " ZM ", " M ", 'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button, 'X', Blocks.cobblestone);
addRecipe("Gun Iron", CustomItems.gunIron, false, "XXXY", " ZM ", " M ", 'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button, 'X', Items.iron_ingot);
addRecipe("Gun Gold", CustomItems.gunGold, false, "XXXY", " ZM ", " M ", 'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button, 'X', Items.gold_ingot);
addRecipe("Gun Diamond", CustomItems.gunDiamond, false, "XXXY", " ZM ", " M ", 'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button, 'X', Items.diamond);
addRecipe("Gun Emerald", CustomItems.gunEmerald, false, "XXXY", " ZM ", " M ", 'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button, 'X', Items.emerald);
addRecipe("Gun Bronze", CustomItems.gunBronze, false, "XXXY", " ZM ", " M ", 'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button, 'X', CustomItems.bronze_ingot);
addRecipe("Bullet Wooden", CustomItems.bulletWood, true, "X",'X', Blocks.planks);
addRecipe("Bullet Stone", CustomItems.bulletStone, true, "X",'X', Blocks.cobblestone);
addRecipe("Bullet Iron", CustomItems.bulletIron, true, "X",'X', Items.iron_ingot);
addRecipe("Bullet Gold", CustomItems.bulletGold, true, "X",'X', Items.gold_ingot);
addRecipe("Bullet Diamond", CustomItems.bulletDiamond, true, "X",'X', Items.diamond);
addRecipe("Bullet Emerald", CustomItems.bulletEmerald, true, "X",'X', Items.emerald);
addRecipe("Bullet Bronze", CustomItems.bulletBronze, true, "X",'X', CustomItems.bronze_ingot);
}
}
if(i < 1){
if(!ConfigItem.DisableExtraBlock){
addRecipe("WallBanner Wooden", new ItemStack(CustomItems.wallBanner, 1, 0), false, "XXX","ZZZ","ZZZ","Z Z",'Z', Blocks.wool, 'X', Blocks.planks);
addRecipe("WallBanner Stone", new ItemStack(CustomItems.wallBanner, 1, 1), false, "XXX","ZZZ","ZZZ","Z Z",'Z', Blocks.wool, 'X', Blocks.cobblestone);
addRecipe("WallBanner Iron", new ItemStack(CustomItems.wallBanner, 1, 2), false, "XXX","ZZZ","ZZZ","Z Z",'Z', Blocks.wool, 'X', Items.iron_ingot);
addRecipe("WallBanner Gold", new ItemStack(CustomItems.wallBanner, 1, 3), false, "XXX","ZZZ","ZZZ","Z Z",'Z', Blocks.wool, 'X', Items.gold_ingot);
addRecipe("WallBanner Diamond", new ItemStack(CustomItems.wallBanner, 1, 4), false, "XXX","ZZZ","ZZZ","Z Z",'Z', Blocks.wool, 'X', Items.diamond);
addRecipe("Bullet Wooden", CustomItems.bulletWood, true, "X", 'X', Blocks.planks);
addRecipe("Bullet Stone", CustomItems.bulletStone, true, "X", 'X', Blocks.cobblestone);
addRecipe("Bullet Iron", CustomItems.bulletIron, true, "X", 'X', Items.iron_ingot);
addRecipe("Bullet Gold", CustomItems.bulletGold, true, "X", 'X', Items.gold_ingot);
addRecipe("Bullet Diamond", CustomItems.bulletDiamond, true, "X", 'X', Items.diamond);
addRecipe("Bullet Emerald", CustomItems.bulletEmerald, true, "X", 'X', Items.emerald);
addRecipe("Bullet Bronze", CustomItems.bulletBronze, true, "X", 'X', CustomItems.bronze_ingot);
}
}
if (i < 1) {
if (!ConfigItem.DisableExtraBlock) {
addRecipe("WallBanner Wooden", new ItemStack(CustomItems.wallBanner, 1, 0), false, "XXX", "ZZZ", "ZZZ", "Z Z", 'Z', Blocks.wool, 'X', Blocks.planks);
addRecipe("WallBanner Stone", new ItemStack(CustomItems.wallBanner, 1, 1), false, "XXX", "ZZZ", "ZZZ", "Z Z", 'Z', Blocks.wool, 'X', Blocks.cobblestone);
addRecipe("WallBanner Iron", new ItemStack(CustomItems.wallBanner, 1, 2), false, "XXX", "ZZZ", "ZZZ", "Z Z", 'Z', Blocks.wool, 'X', Items.iron_ingot);
addRecipe("WallBanner Gold", new ItemStack(CustomItems.wallBanner, 1, 3), false, "XXX", "ZZZ", "ZZZ", "Z Z", 'Z', Blocks.wool, 'X', Items.gold_ingot);
addRecipe("WallBanner Diamond", new ItemStack(CustomItems.wallBanner, 1, 4), false, "XXX", "ZZZ", "ZZZ", "Z Z", 'Z', Blocks.wool, 'X', Items.diamond);
addRecipe("Banner Wooden", new ItemStack(CustomItems.banner, 1, 0), false, " X "," Z "," Z ","ZZZ", 'X', new ItemStack(CustomItems.wallBanner,1,0), 'Z', Blocks.planks);
addRecipe("Banner Stone", new ItemStack(CustomItems.banner, 1, 1), false, " X "," Z "," Z ","ZZZ", 'X', new ItemStack(CustomItems.wallBanner,1,1), 'Z', Blocks.cobblestone);
addRecipe("Banner Iron", new ItemStack(CustomItems.banner, 1, 2), false, " X "," Z "," Z ","ZZZ", 'X', new ItemStack(CustomItems.wallBanner,1,2), 'Z', Items.iron_ingot);
addRecipe("Banner Gold", new ItemStack(CustomItems.banner, 1, 3), false, " X "," Z "," Z ","ZZZ", 'X', new ItemStack(CustomItems.wallBanner,1,3), 'Z', Items.gold_ingot);
addRecipe("Banner Diamond", new ItemStack(CustomItems.banner, 1, 4), false, " X "," Z "," Z ","ZZZ", 'X', new ItemStack(CustomItems.wallBanner,1,4), 'Z', Items.diamond);
addRecipe("Banner Wooden", new ItemStack(CustomItems.banner, 1, 0), false, " X ", " Z ", " Z ", "ZZZ", 'X', new ItemStack(CustomItems.wallBanner, 1, 0), 'Z', Blocks.planks);
addRecipe("Banner Stone", new ItemStack(CustomItems.banner, 1, 1), false, " X ", " Z ", " Z ", "ZZZ", 'X', new ItemStack(CustomItems.wallBanner, 1, 1), 'Z', Blocks.cobblestone);
addRecipe("Banner Iron", new ItemStack(CustomItems.banner, 1, 2), false, " X ", " Z ", " Z ", "ZZZ", 'X', new ItemStack(CustomItems.wallBanner, 1, 2), 'Z', Items.iron_ingot);
addRecipe("Banner Gold", new ItemStack(CustomItems.banner, 1, 3), false, " X ", " Z ", " Z ", "ZZZ", 'X', new ItemStack(CustomItems.wallBanner, 1, 3), 'Z', Items.gold_ingot);
addRecipe("Banner Diamond", new ItemStack(CustomItems.banner, 1, 4), false, " X ", " Z ", " Z ", "ZZZ", 'X', new ItemStack(CustomItems.wallBanner, 1, 4), 'Z', Items.diamond);
addRecipe("Lamp Wooden", new ItemStack(CustomItems.tallLamp, 1, 0), false, "YXY"," Z "," Z ","ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Blocks.planks);
addRecipe("Lamp Stone", new ItemStack(CustomItems.tallLamp, 1, 1), false, "YXY"," Z "," Z ","ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Blocks.cobblestone);
addRecipe("Lamp Iron", new ItemStack(CustomItems.tallLamp, 1, 2), false, "YXY"," Z "," Z ","ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Items.iron_ingot);
addRecipe("Lamp Gold", new ItemStack(CustomItems.tallLamp, 1, 3), false, "YXY"," Z "," Z ","ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Items.gold_ingot);
addRecipe("Lamp Diamond", new ItemStack(CustomItems.tallLamp, 1, 4), false, "YXY"," Z "," Z ","ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Items.diamond);
addRecipe("Lamp Wooden", new ItemStack(CustomItems.tallLamp, 1, 0), false, "YXY", " Z ", " Z ", "ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Blocks.planks);
addRecipe("Lamp Stone", new ItemStack(CustomItems.tallLamp, 1, 1), false, "YXY", " Z ", " Z ", "ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Blocks.cobblestone);
addRecipe("Lamp Iron", new ItemStack(CustomItems.tallLamp, 1, 2), false, "YXY", " Z ", " Z ", "ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Items.iron_ingot);
addRecipe("Lamp Gold", new ItemStack(CustomItems.tallLamp, 1, 3), false, "YXY", " Z ", " Z ", "ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Items.gold_ingot);
addRecipe("Lamp Diamond", new ItemStack(CustomItems.tallLamp, 1, 4), false, "YXY", " Z ", " Z ", "ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Items.diamond);
addRecipe("Chair Wooden1", new ItemStack(CustomItems.chair, 1, 0), false, " X", " X","XXX","X X", 'X', new ItemStack(Blocks.planks,1,0));
addRecipe("Chair Wooden2", new ItemStack(CustomItems.chair, 1, 1), false, " X", " X","XXX","X X", 'X', new ItemStack(Blocks.planks,1,1));
addRecipe("Chair Wooden3", new ItemStack(CustomItems.chair, 1, 2), false, " X", " X","XXX","X X", 'X', new ItemStack(Blocks.planks,1,2));
addRecipe("Chair Wooden4", new ItemStack(CustomItems.chair, 1, 3), false, " X", " X","XXX","X X", 'X', new ItemStack(Blocks.planks,1,3));
addRecipe("Chair Wooden5", new ItemStack(CustomItems.chair, 1, 4), false, " X", " X","XXX","X X", 'X', new ItemStack(Blocks.planks,1,4));
addRecipe("Chair Wooden6", new ItemStack(CustomItems.chair, 1, 5), false, " X", " X","XXX","X X", 'X', new ItemStack(Blocks.planks,1,5));
addRecipe("Chair Wooden1", new ItemStack(CustomItems.chair, 1, 0), false, " X", " X", "XXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 0));
addRecipe("Chair Wooden2", new ItemStack(CustomItems.chair, 1, 1), false, " X", " X", "XXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 1));
addRecipe("Chair Wooden3", new ItemStack(CustomItems.chair, 1, 2), false, " X", " X", "XXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 2));
addRecipe("Chair Wooden4", new ItemStack(CustomItems.chair, 1, 3), false, " X", " X", "XXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 3));
addRecipe("Chair Wooden5", new ItemStack(CustomItems.chair, 1, 4), false, " X", " X", "XXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 4));
addRecipe("Chair Wooden6", new ItemStack(CustomItems.chair, 1, 5), false, " X", " X", "XXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 5));
addRecipe("Crate Wooden1", new ItemStack(CustomItems.crate, 1, 0), false, "XXXX","X X","X X","XXXX", 'X', new ItemStack(Blocks.planks,1,0));
addRecipe("Crate Wooden2", new ItemStack(CustomItems.crate, 1, 1), false, "XXXX","X X","X X","XXXX", 'X', new ItemStack(Blocks.planks,1,1));
addRecipe("Crate Wooden3", new ItemStack(CustomItems.crate, 1, 2), false, "XXXX","X X","X X","XXXX", 'X', new ItemStack(Blocks.planks,1,2));
addRecipe("Crate Wooden4", new ItemStack(CustomItems.crate, 1, 3), false, "XXXX","X X","X X","XXXX", 'X', new ItemStack(Blocks.planks,1,3));
addRecipe("Crate Wooden5", new ItemStack(CustomItems.crate, 1, 4), false, "XXXX","X X","X X","XXXX", 'X', new ItemStack(Blocks.planks,1,4));
addRecipe("Crate Wooden6", new ItemStack(CustomItems.crate, 1, 5), false, "XXXX","X X","X X","XXXX", 'X', new ItemStack(Blocks.planks,1,5));
addRecipe("Crate Wooden1", new ItemStack(CustomItems.crate, 1, 0), false, "XXXX", "X X", "X X", "XXXX", 'X', new ItemStack(Blocks.planks, 1, 0));
addRecipe("Crate Wooden2", new ItemStack(CustomItems.crate, 1, 1), false, "XXXX", "X X", "X X", "XXXX", 'X', new ItemStack(Blocks.planks, 1, 1));
addRecipe("Crate Wooden3", new ItemStack(CustomItems.crate, 1, 2), false, "XXXX", "X X", "X X", "XXXX", 'X', new ItemStack(Blocks.planks, 1, 2));
addRecipe("Crate Wooden4", new ItemStack(CustomItems.crate, 1, 3), false, "XXXX", "X X", "X X", "XXXX", 'X', new ItemStack(Blocks.planks, 1, 3));
addRecipe("Crate Wooden5", new ItemStack(CustomItems.crate, 1, 4), false, "XXXX", "X X", "X X", "XXXX", 'X', new ItemStack(Blocks.planks, 1, 4));
addRecipe("Crate Wooden6", new ItemStack(CustomItems.crate, 1, 5), false, "XXXX", "X X", "X X", "XXXX", 'X', new ItemStack(Blocks.planks, 1, 5));
addRecipe("WeaponRack Wooden1", new ItemStack(CustomItems.weaponsRack, 1, 0), false, "XXX","XYX","XYX","XXX", 'X', new ItemStack(Blocks.planks,1,0),'Y', Items.stick);
addRecipe("WeaponRack Wooden2", new ItemStack(CustomItems.weaponsRack, 1, 1), false, "XXX","XYX","XYX","XXX", 'X', new ItemStack(Blocks.planks,1,1),'Y', Items.stick);
addRecipe("WeaponRack Wooden3", new ItemStack(CustomItems.weaponsRack, 1, 2), false, "XXX","XYX","XYX","XXX", 'X', new ItemStack(Blocks.planks,1,2),'Y', Items.stick);
addRecipe("WeaponRack Wooden4", new ItemStack(CustomItems.weaponsRack, 1, 3), false, "XXX","XYX","XYX","XXX", 'X', new ItemStack(Blocks.planks,1,3),'Y', Items.stick);
addRecipe("WeaponRack Wooden5", new ItemStack(CustomItems.weaponsRack, 1, 4), false, "XXX","XYX","XYX","XXX", 'X', new ItemStack(Blocks.planks,1,4),'Y', Items.stick);
addRecipe("WeaponRack Wooden6", new ItemStack(CustomItems.weaponsRack, 1, 5), false, "XXX","XYX","XYX","XXX", 'X', new ItemStack(Blocks.planks,1,5),'Y', Items.stick);
addRecipe("WeaponRack Wooden1", new ItemStack(CustomItems.weaponsRack, 1, 0), false, "XXX", "XYX", "XYX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 0), 'Y', Items.stick);
addRecipe("WeaponRack Wooden2", new ItemStack(CustomItems.weaponsRack, 1, 1), false, "XXX", "XYX", "XYX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 1), 'Y', Items.stick);
addRecipe("WeaponRack Wooden3", new ItemStack(CustomItems.weaponsRack, 1, 2), false, "XXX", "XYX", "XYX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 2), 'Y', Items.stick);
addRecipe("WeaponRack Wooden4", new ItemStack(CustomItems.weaponsRack, 1, 3), false, "XXX", "XYX", "XYX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 3), 'Y', Items.stick);
addRecipe("WeaponRack Wooden5", new ItemStack(CustomItems.weaponsRack, 1, 4), false, "XXX", "XYX", "XYX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 4), 'Y', Items.stick);
addRecipe("WeaponRack Wooden6", new ItemStack(CustomItems.weaponsRack, 1, 5), false, "XXX", "XYX", "XYX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 5), 'Y', Items.stick);
addRecipe("Couch Wooden1", new ItemStack(CustomItems.couchWood, 1, 0), false, " X"," X","XXXX","X X", 'X', new ItemStack(Blocks.planks,1,0));
addRecipe("Couch Wooden2", new ItemStack(CustomItems.couchWood, 1, 1), false, " X"," X","XXXX","X X", 'X', new ItemStack(Blocks.planks,1,1));
addRecipe("Couch Wooden3", new ItemStack(CustomItems.couchWood, 1, 2), false, " X"," X","XXXX","X X", 'X', new ItemStack(Blocks.planks,1,2));
addRecipe("Couch Wooden4", new ItemStack(CustomItems.couchWood, 1, 3), false, " X"," X","XXXX","X X", 'X', new ItemStack(Blocks.planks,1,3));
addRecipe("Couch Wooden5", new ItemStack(CustomItems.couchWood, 1, 4), false, " X"," X","XXXX","X X", 'X', new ItemStack(Blocks.planks,1,4));
addRecipe("Couch Wooden6", new ItemStack(CustomItems.couchWood, 1, 5), false, " X"," X","XXXX","X X", 'X', new ItemStack(Blocks.planks,1,5));
addRecipe("Couch Wooden1", new ItemStack(CustomItems.couchWood, 1, 0), false, " X", " X", "XXXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 0));
addRecipe("Couch Wooden2", new ItemStack(CustomItems.couchWood, 1, 1), false, " X", " X", "XXXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 1));
addRecipe("Couch Wooden3", new ItemStack(CustomItems.couchWood, 1, 2), false, " X", " X", "XXXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 2));
addRecipe("Couch Wooden4", new ItemStack(CustomItems.couchWood, 1, 3), false, " X", " X", "XXXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 3));
addRecipe("Couch Wooden5", new ItemStack(CustomItems.couchWood, 1, 4), false, " X", " X", "XXXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 4));
addRecipe("Couch Wooden6", new ItemStack(CustomItems.couchWood, 1, 5), false, " X", " X", "XXXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 5));
addRecipe("Couch Wool1", new ItemStack(CustomItems.couchWool, 1, 0), false, " Z", " Z","ZZZZ","X X", 'X', new ItemStack(Blocks.planks,1,0), 'Z', Blocks.wool);
addRecipe("Couch Wool2", new ItemStack(CustomItems.couchWool, 1, 1), false, " Z", " Z","ZZZZ","X X", 'X', new ItemStack(Blocks.planks,1,1), 'Z', Blocks.wool);
addRecipe("Couch Wool3", new ItemStack(CustomItems.couchWool, 1, 2), false, " Z", " Z","ZZZZ","X X", 'X', new ItemStack(Blocks.planks,1,2), 'Z', Blocks.wool);
addRecipe("Couch Wool4", new ItemStack(CustomItems.couchWool, 1, 3), false, " Z", " Z","ZZZZ","X X", 'X', new ItemStack(Blocks.planks,1,3), 'Z', Blocks.wool);
addRecipe("Couch Wool5", new ItemStack(CustomItems.couchWool, 1, 4), false, " Z", " Z","ZZZZ","X X", 'X', new ItemStack(Blocks.planks,1,4), 'Z', Blocks.wool);
addRecipe("Couch Wool6", new ItemStack(CustomItems.couchWool, 1, 5), false, " Z", " Z","ZZZZ","X X", 'X', new ItemStack(Blocks.planks,1,5), 'Z', Blocks.wool);
addRecipe("Couch Wool1", new ItemStack(CustomItems.couchWool, 1, 0), false, " Z", " Z", "ZZZZ", "X X", 'X', new ItemStack(Blocks.planks, 1, 0), 'Z', Blocks.wool);
addRecipe("Couch Wool2", new ItemStack(CustomItems.couchWool, 1, 1), false, " Z", " Z", "ZZZZ", "X X", 'X', new ItemStack(Blocks.planks, 1, 1), 'Z', Blocks.wool);
addRecipe("Couch Wool3", new ItemStack(CustomItems.couchWool, 1, 2), false, " Z", " Z", "ZZZZ", "X X", 'X', new ItemStack(Blocks.planks, 1, 2), 'Z', Blocks.wool);
addRecipe("Couch Wool4", new ItemStack(CustomItems.couchWool, 1, 3), false, " Z", " Z", "ZZZZ", "X X", 'X', new ItemStack(Blocks.planks, 1, 3), 'Z', Blocks.wool);
addRecipe("Couch Wool5", new ItemStack(CustomItems.couchWool, 1, 4), false, " Z", " Z", "ZZZZ", "X X", 'X', new ItemStack(Blocks.planks, 1, 4), 'Z', Blocks.wool);
addRecipe("Couch Wool6", new ItemStack(CustomItems.couchWool, 1, 5), false, " Z", " Z", "ZZZZ", "X X", 'X', new ItemStack(Blocks.planks, 1, 5), 'Z', Blocks.wool);
addRecipe("Table Wood1", new ItemStack(CustomItems.table, 1, 0), false, "XXXX","X X","X X", 'X', new ItemStack(Blocks.planks,1,0), 'Z', Blocks.wool);
addRecipe("Table Wood2", new ItemStack(CustomItems.table, 1, 1), false, "XXXX","X X","X X", 'X', new ItemStack(Blocks.planks,1,1), 'Z', Blocks.wool);
addRecipe("Table Wood3", new ItemStack(CustomItems.table, 1, 2), false, "XXXX","X X","X X", 'X', new ItemStack(Blocks.planks,1,2), 'Z', Blocks.wool);
addRecipe("Table Wood4", new ItemStack(CustomItems.table, 1, 3), false, "XXXX","X X","X X", 'X', new ItemStack(Blocks.planks,1,3), 'Z', Blocks.wool);
addRecipe("Table Wood5", new ItemStack(CustomItems.table, 1, 4), false, "XXXX","X X","X X", 'X', new ItemStack(Blocks.planks,1,4), 'Z', Blocks.wool);
addRecipe("Table Wood6", new ItemStack(CustomItems.table, 1, 5), false, "XXXX","X X","X X", 'X', new ItemStack(Blocks.planks,1,5), 'Z', Blocks.wool);
addRecipe("Table Wood1", new ItemStack(CustomItems.table, 1, 0), false, "XXXX", "X X", "X X", 'X', new ItemStack(Blocks.planks, 1, 0), 'Z', Blocks.wool);
addRecipe("Table Wood2", new ItemStack(CustomItems.table, 1, 1), false, "XXXX", "X X", "X X", 'X', new ItemStack(Blocks.planks, 1, 1), 'Z', Blocks.wool);
addRecipe("Table Wood3", new ItemStack(CustomItems.table, 1, 2), false, "XXXX", "X X", "X X", 'X', new ItemStack(Blocks.planks, 1, 2), 'Z', Blocks.wool);
addRecipe("Table Wood4", new ItemStack(CustomItems.table, 1, 3), false, "XXXX", "X X", "X X", 'X', new ItemStack(Blocks.planks, 1, 3), 'Z', Blocks.wool);
addRecipe("Table Wood5", new ItemStack(CustomItems.table, 1, 4), false, "XXXX", "X X", "X X", 'X', new ItemStack(Blocks.planks, 1, 4), 'Z', Blocks.wool);
addRecipe("Table Wood6", new ItemStack(CustomItems.table, 1, 5), false, "XXXX", "X X", "X X", 'X', new ItemStack(Blocks.planks, 1, 5), 'Z', Blocks.wool);
addRecipe("noppes.npcs.client.model.blocks.Stool Wood1", new ItemStack(CustomItems.stool, 1, 0), false, "XXX"," X ","X X", 'X', new ItemStack(Blocks.planks,1,0));
addRecipe("noppes.npcs.client.model.blocks.Stool Wood2", new ItemStack(CustomItems.stool, 1, 1), false, "XXX"," X ","X X", 'X', new ItemStack(Blocks.planks,1,1));
addRecipe("noppes.npcs.client.model.blocks.Stool Wood3", new ItemStack(CustomItems.stool, 1, 2), false, "XXX"," X ","X X", 'X', new ItemStack(Blocks.planks,1,2));
addRecipe("noppes.npcs.client.model.blocks.Stool Wood4", new ItemStack(CustomItems.stool, 1, 3), false, "XXX"," X ","X X", 'X', new ItemStack(Blocks.planks,1,3));
addRecipe("noppes.npcs.client.model.blocks.Stool Wood5", new ItemStack(CustomItems.stool, 1, 4), false, "XXX"," X ","X X", 'X', new ItemStack(Blocks.planks,1,4));
addRecipe("noppes.npcs.client.model.blocks.Stool Wood6", new ItemStack(CustomItems.stool, 1, 5), false, "XXX"," X ","X X", 'X', new ItemStack(Blocks.planks,1,5));
addRecipe("noppes.npcs.client.model.blocks.Stool Wood1", new ItemStack(CustomItems.stool, 1, 0), false, "XXX", " X ", "X X", 'X', new ItemStack(Blocks.planks, 1, 0));
addRecipe("noppes.npcs.client.model.blocks.Stool Wood2", new ItemStack(CustomItems.stool, 1, 1), false, "XXX", " X ", "X X", 'X', new ItemStack(Blocks.planks, 1, 1));
addRecipe("noppes.npcs.client.model.blocks.Stool Wood3", new ItemStack(CustomItems.stool, 1, 2), false, "XXX", " X ", "X X", 'X', new ItemStack(Blocks.planks, 1, 2));
addRecipe("noppes.npcs.client.model.blocks.Stool Wood4", new ItemStack(CustomItems.stool, 1, 3), false, "XXX", " X ", "X X", 'X', new ItemStack(Blocks.planks, 1, 3));
addRecipe("noppes.npcs.client.model.blocks.Stool Wood5", new ItemStack(CustomItems.stool, 1, 4), false, "XXX", " X ", "X X", 'X', new ItemStack(Blocks.planks, 1, 4));
addRecipe("noppes.npcs.client.model.blocks.Stool Wood6", new ItemStack(CustomItems.stool, 1, 5), false, "XXX", " X ", "X X", 'X', new ItemStack(Blocks.planks, 1, 5));
addRecipe("Barrel Wood1", new ItemStack(CustomItems.barrel, 1, 0), false, "XXX","X X","X X", "XXX", 'X', new ItemStack(Blocks.planks,1,0));
addRecipe("Barrel Wood2", new ItemStack(CustomItems.barrel, 1, 1), false, "XXX","X X","X X", "XXX", 'X', new ItemStack(Blocks.planks,1,1));
addRecipe("Barrel Wood3", new ItemStack(CustomItems.barrel, 1, 2), false, "XXX","X X","X X", "XXX", 'X', new ItemStack(Blocks.planks,1,2));
addRecipe("Barrel Wood4", new ItemStack(CustomItems.barrel, 1, 3), false, "XXX","X X","X X", "XXX", 'X', new ItemStack(Blocks.planks,1,3));
addRecipe("Barrel Wood5", new ItemStack(CustomItems.barrel, 1, 4), false, "XXX","X X","X X", "XXX", 'X', new ItemStack(Blocks.planks,1,4));
addRecipe("Barrel Wood6", new ItemStack(CustomItems.barrel, 1, 5), false, "XXX","X X","X X", "XXX", 'X', new ItemStack(Blocks.planks,1,5));
addRecipe("Barrel Wood1", new ItemStack(CustomItems.barrel, 1, 0), false, "XXX", "X X", "X X", "XXX", 'X', new ItemStack(Blocks.planks, 1, 0));
addRecipe("Barrel Wood2", new ItemStack(CustomItems.barrel, 1, 1), false, "XXX", "X X", "X X", "XXX", 'X', new ItemStack(Blocks.planks, 1, 1));
addRecipe("Barrel Wood3", new ItemStack(CustomItems.barrel, 1, 2), false, "XXX", "X X", "X X", "XXX", 'X', new ItemStack(Blocks.planks, 1, 2));
addRecipe("Barrel Wood4", new ItemStack(CustomItems.barrel, 1, 3), false, "XXX", "X X", "X X", "XXX", 'X', new ItemStack(Blocks.planks, 1, 3));
addRecipe("Barrel Wood5", new ItemStack(CustomItems.barrel, 1, 4), false, "XXX", "X X", "X X", "XXX", 'X', new ItemStack(Blocks.planks, 1, 4));
addRecipe("Barrel Wood6", new ItemStack(CustomItems.barrel, 1, 5), false, "XXX", "X X", "X X", "XXX", 'X', new ItemStack(Blocks.planks, 1, 5));
addRecipe("Shelf Wood1", new ItemStack(CustomItems.shelf, 2, 0), false, "XXX","XY ","X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks,1,0));
addRecipe("Shelf Wood2", new ItemStack(CustomItems.shelf, 2, 1), false, "XXX","XY ","X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks,1,1));
addRecipe("Shelf Wood3", new ItemStack(CustomItems.shelf, 2, 2), false, "XXX","XY ","X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks,1,2));
addRecipe("Shelf Wood4", new ItemStack(CustomItems.shelf, 2, 3), false, "XXX","XY ","X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks,1,3));
addRecipe("Shelf Wood5", new ItemStack(CustomItems.shelf, 2, 4), false, "XXX","XY ","X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks,1,4));
addRecipe("Shelf Wood6", new ItemStack(CustomItems.shelf, 2, 5), false, "XXX","XY ","X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks,1,5));
addRecipe("Shelf Wood1", new ItemStack(CustomItems.shelf, 2, 0), false, "XXX", "XY ", "X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks, 1, 0));
addRecipe("Shelf Wood2", new ItemStack(CustomItems.shelf, 2, 1), false, "XXX", "XY ", "X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks, 1, 1));
addRecipe("Shelf Wood3", new ItemStack(CustomItems.shelf, 2, 2), false, "XXX", "XY ", "X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks, 1, 2));
addRecipe("Shelf Wood4", new ItemStack(CustomItems.shelf, 2, 3), false, "XXX", "XY ", "X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks, 1, 3));
addRecipe("Shelf Wood5", new ItemStack(CustomItems.shelf, 2, 4), false, "XXX", "XY ", "X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks, 1, 4));
addRecipe("Shelf Wood6", new ItemStack(CustomItems.shelf, 2, 5), false, "XXX", "XY ", "X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks, 1, 5));
addRecipe("Beam Wood1", new ItemStack(CustomItems.beam, 2, 0), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,0));
addRecipe("Beam Wood2", new ItemStack(CustomItems.beam, 2, 1), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,1));
addRecipe("Beam Wood3", new ItemStack(CustomItems.beam, 2, 2), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,2));
addRecipe("Beam Wood4", new ItemStack(CustomItems.beam, 2, 3), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,3));
addRecipe("Beam Wood5", new ItemStack(CustomItems.beam, 2, 4), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,4));
addRecipe("Beam Wood6", new ItemStack(CustomItems.beam, 2, 5), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,5));
addRecipe("Beam Wood1", new ItemStack(CustomItems.beam, 2, 0), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 0));
addRecipe("Beam Wood2", new ItemStack(CustomItems.beam, 2, 1), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 1));
addRecipe("Beam Wood3", new ItemStack(CustomItems.beam, 2, 2), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 2));
addRecipe("Beam Wood4", new ItemStack(CustomItems.beam, 2, 3), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 3));
addRecipe("Beam Wood5", new ItemStack(CustomItems.beam, 2, 4), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 4));
addRecipe("Beam Wood6", new ItemStack(CustomItems.beam, 2, 5), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 5));
addRecipe("Sign Wood1", new ItemStack(CustomItems.sign, 1, 0), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,0), 'Y', Items.iron_ingot);
addRecipe("Sign Wood2", new ItemStack(CustomItems.sign, 1, 1), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,1), 'Y', Items.iron_ingot);
addRecipe("Sign Wood3", new ItemStack(CustomItems.sign, 1, 2), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,2), 'Y', Items.iron_ingot);
addRecipe("Sign Wood4", new ItemStack(CustomItems.sign, 1, 3), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,3), 'Y', Items.iron_ingot);
addRecipe("Sign Wood5", new ItemStack(CustomItems.sign, 1, 4), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,4), 'Y', Items.iron_ingot);
addRecipe("Sign Wood6", new ItemStack(CustomItems.sign, 1, 5), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,5), 'Y', Items.iron_ingot);
addRecipe("Sign Wood1", new ItemStack(CustomItems.sign, 1, 0), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 0), 'Y', Items.iron_ingot);
addRecipe("Sign Wood2", new ItemStack(CustomItems.sign, 1, 1), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 1), 'Y', Items.iron_ingot);
addRecipe("Sign Wood3", new ItemStack(CustomItems.sign, 1, 2), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 2), 'Y', Items.iron_ingot);
addRecipe("Sign Wood4", new ItemStack(CustomItems.sign, 1, 3), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 3), 'Y', Items.iron_ingot);
addRecipe("Sign Wood5", new ItemStack(CustomItems.sign, 1, 4), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 4), 'Y', Items.iron_ingot);
addRecipe("Sign Wood6", new ItemStack(CustomItems.sign, 1, 5), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 5), 'Y', Items.iron_ingot);
addRecipe("Lamp", new ItemStack(CustomItems.lantern), false, "XXX","YZY","XXX", 'X', Items.iron_ingot, 'Y', Blocks.glass, 'Z', Blocks.torch);
addRecipe("Candle", new ItemStack(CustomItems.candle), false, "XZX"," X ", 'X', Items.iron_ingot, 'Z', Blocks.torch);
addRecipe("BigSign", new ItemStack(CustomItems.bigsign, 2), false, "XXX","XXX","XXX", 'X', Blocks.planks);
addRecipe("Lamp", new ItemStack(CustomItems.lantern), false, "XXX", "YZY", "XXX", 'X', Items.iron_ingot, 'Y', Blocks.glass, 'Z', Blocks.torch);
addRecipe("Candle", new ItemStack(CustomItems.candle), false, "XZX", " X ", 'X', Items.iron_ingot, 'Z', Blocks.torch);
addRecipe("BigSign", new ItemStack(CustomItems.bigsign, 2), false, "XXX", "XXX", "XXX", 'X', Blocks.planks);
}
if(!ConfigItem.DisableExtraItems){
addRecipe("Battle Axe1", CustomItems.battleAxeWood, false, "XX","XY"," Y", " Y", 'Y', Items.stick, 'X', Blocks.planks);
addRecipe("Battle Axe2", CustomItems.battleAxeStone, false, "XX","XY"," Y", " Y", 'Y', Items.stick, 'X', Blocks.cobblestone);
addRecipe("Battle Axe3", CustomItems.battleAxeIron, false, "XX","XY"," Y", " Y", 'Y', Items.stick, 'X', Items.iron_ingot);
addRecipe("Battle Axe4", CustomItems.battleAxeGold, false, "XX","XY"," Y", " Y", 'Y', Items.stick, 'X', Items.gold_ingot);
addRecipe("Battle Axe5", CustomItems.battleAxeDiamond, false, "XX","XY"," Y", " Y", 'Y', Items.stick, 'X', Items.diamond);
addRecipe("Battle Axe6", CustomItems.battleAxeBronze, false, "XX","XY"," Y", " Y", 'Y', Items.stick, 'X', CustomItems.bronze_ingot);
addRecipe("Battle Axe7", CustomItems.battleAxeEmerald, false, "XX","XY"," Y", " Y", 'Y', Items.stick, 'X', Items.emerald);
}
if (!ConfigItem.DisableExtraItems) {
addRecipe("Battle Axe1", CustomItems.battleAxeWood, false, "XX", "XY", " Y", " Y", 'Y', Items.stick, 'X', Blocks.planks);
addRecipe("Battle Axe2", CustomItems.battleAxeStone, false, "XX", "XY", " Y", " Y", 'Y', Items.stick, 'X', Blocks.cobblestone);
addRecipe("Battle Axe3", CustomItems.battleAxeIron, false, "XX", "XY", " Y", " Y", 'Y', Items.stick, 'X', Items.iron_ingot);
addRecipe("Battle Axe4", CustomItems.battleAxeGold, false, "XX", "XY", " Y", " Y", 'Y', Items.stick, 'X', Items.gold_ingot);
addRecipe("Battle Axe5", CustomItems.battleAxeDiamond, false, "XX", "XY", " Y", " Y", 'Y', Items.stick, 'X', Items.diamond);
addRecipe("Battle Axe6", CustomItems.battleAxeBronze, false, "XX", "XY", " Y", " Y", 'Y', Items.stick, 'X', CustomItems.bronze_ingot);
addRecipe("Battle Axe7", CustomItems.battleAxeEmerald, false, "XX", "XY", " Y", " Y", 'Y', Items.stick, 'X', Items.emerald);
addRecipe("Halberd1", CustomItems.halberdWood, false, " X ","XYX"," Y ", " Y ", 'Y', Items.stick, 'X', Blocks.planks);
addRecipe("Halberd2", CustomItems.halberdStone, false, " X ","XYX"," Y ", " Y ", 'Y', Items.stick, 'X', Blocks.cobblestone);
addRecipe("Halberd3", CustomItems.halberdIron, false, " X ","XYX"," Y ", " Y ", 'Y', Items.stick, 'X', Items.iron_ingot);
addRecipe("Halberd4", CustomItems.halberdGold, false, " X ","XYX"," Y ", " Y ", 'Y', Items.stick, 'X', Items.gold_ingot);
addRecipe("Halberd5", CustomItems.halberdDiamond, false, " X ","XYX"," Y ", " Y ", 'Y', Items.stick, 'X', Items.diamond);
addRecipe("Halberd6", CustomItems.halberdBronze, false, " X ","XYX"," Y ", " Y ", 'Y', Items.stick, 'X', CustomItems.bronze_ingot);
addRecipe("Halberd7", CustomItems.halberdEmerald, false, " X ","XYX"," Y ", " Y ", 'Y', Items.stick, 'X', Items.emerald);
addRecipe("Halberd1", CustomItems.halberdWood, false, " X ", "XYX", " Y ", " Y ", 'Y', Items.stick, 'X', Blocks.planks);
addRecipe("Halberd2", CustomItems.halberdStone, false, " X ", "XYX", " Y ", " Y ", 'Y', Items.stick, 'X', Blocks.cobblestone);
addRecipe("Halberd3", CustomItems.halberdIron, false, " X ", "XYX", " Y ", " Y ", 'Y', Items.stick, 'X', Items.iron_ingot);
addRecipe("Halberd4", CustomItems.halberdGold, false, " X ", "XYX", " Y ", " Y ", 'Y', Items.stick, 'X', Items.gold_ingot);
addRecipe("Halberd5", CustomItems.halberdDiamond, false, " X ", "XYX", " Y ", " Y ", 'Y', Items.stick, 'X', Items.diamond);
addRecipe("Halberd6", CustomItems.halberdBronze, false, " X ", "XYX", " Y ", " Y ", 'Y', Items.stick, 'X', CustomItems.bronze_ingot);
addRecipe("Halberd7", CustomItems.halberdEmerald, false, " X ", "XYX", " Y ", " Y ", 'Y', Items.stick, 'X', Items.emerald);
addRecipe("Glaive1", CustomItems.glaiveWood, false, "X "," Y "," Y ", " X", 'Y', Items.stick, 'X', Blocks.planks);
addRecipe("Glaive2", CustomItems.glaiveStone, false, "X "," Y "," Y ", " X", 'Y', Items.stick, 'X', Blocks.cobblestone);
addRecipe("Glaive3", CustomItems.glaiveIron, false, "X "," Y "," Y ", " X", 'Y', Items.stick, 'X', Items.iron_ingot);
addRecipe("Glaive4", CustomItems.glaiveGold, false, "X "," Y "," Y ", " X", 'Y', Items.stick, 'X', Items.gold_ingot);
addRecipe("Glaive5", CustomItems.glaiveDiamond, false, "X "," Y "," Y ", " X", 'Y', Items.stick, 'X', Items.diamond);
addRecipe("Glaive6", CustomItems.glaiveBronze, false, "X "," Y "," Y ", " X", 'Y', Items.stick, 'X', CustomItems.bronze_ingot);
addRecipe("Glaive7", CustomItems.glaiveEmerald, false, "X "," Y "," Y ", " X", 'Y', Items.stick, 'X', Items.emerald);
addRecipe("Glaive1", CustomItems.glaiveWood, false, "X ", " Y ", " Y ", " X", 'Y', Items.stick, 'X', Blocks.planks);
addRecipe("Glaive2", CustomItems.glaiveStone, false, "X ", " Y ", " Y ", " X", 'Y', Items.stick, 'X', Blocks.cobblestone);
addRecipe("Glaive3", CustomItems.glaiveIron, false, "X ", " Y ", " Y ", " X", 'Y', Items.stick, 'X', Items.iron_ingot);
addRecipe("Glaive4", CustomItems.glaiveGold, false, "X ", " Y ", " Y ", " X", 'Y', Items.stick, 'X', Items.gold_ingot);
addRecipe("Glaive5", CustomItems.glaiveDiamond, false, "X ", " Y ", " Y ", " X", 'Y', Items.stick, 'X', Items.diamond);
addRecipe("Glaive6", CustomItems.glaiveBronze, false, "X ", " Y ", " Y ", " X", 'Y', Items.stick, 'X', CustomItems.bronze_ingot);
addRecipe("Glaive7", CustomItems.glaiveEmerald, false, "X ", " Y ", " Y ", " X", 'Y', Items.stick, 'X', Items.emerald);
addRecipe("Trident1", CustomItems.tridentWood, false, "X X"," X "," Y ", " Y ", 'Y', Items.stick, 'X', Blocks.planks);
addRecipe("Trident2", CustomItems.tridentStone, false, "X X"," X "," Y ", " Y ", 'Y', Items.stick, 'X', Blocks.cobblestone);
addRecipe("Trident3", CustomItems.tridentIron, false, "X X"," X "," Y ", " Y ", 'Y', Items.stick, 'X', Items.iron_ingot);
addRecipe("Trident4", CustomItems.tridentGold, false, "X X"," X "," Y ", " Y ", 'Y', Items.stick, 'X', Items.gold_ingot);
addRecipe("Trident5", CustomItems.tridentDiamond, false, "X X"," X "," Y ", " Y ", 'Y', Items.stick, 'X', Items.diamond);
addRecipe("Trident6", CustomItems.tridentBronze, false, "X X"," X "," Y ", " Y ", 'Y', Items.stick, 'X', CustomItems.bronze_ingot);
addRecipe("Trident7", CustomItems.tridentEmerald, false, "X X"," X "," Y ", " Y ", 'Y', Items.stick, 'X', Items.emerald);
addRecipe("Trident1", CustomItems.tridentWood, false, "X X", " X ", " Y ", " Y ", 'Y', Items.stick, 'X', Blocks.planks);
addRecipe("Trident2", CustomItems.tridentStone, false, "X X", " X ", " Y ", " Y ", 'Y', Items.stick, 'X', Blocks.cobblestone);
addRecipe("Trident3", CustomItems.tridentIron, false, "X X", " X ", " Y ", " Y ", 'Y', Items.stick, 'X', Items.iron_ingot);
addRecipe("Trident4", CustomItems.tridentGold, false, "X X", " X ", " Y ", " Y ", 'Y', Items.stick, 'X', Items.gold_ingot);
addRecipe("Trident5", CustomItems.tridentDiamond, false, "X X", " X ", " Y ", " Y ", 'Y', Items.stick, 'X', Items.diamond);
addRecipe("Trident6", CustomItems.tridentBronze, false, "X X", " X ", " Y ", " Y ", 'Y', Items.stick, 'X', CustomItems.bronze_ingot);
addRecipe("Trident7", CustomItems.tridentEmerald, false, "X X", " X ", " Y ", " Y ", 'Y', Items.stick, 'X', Items.emerald);
}
}
}
}
}
}
}
@@ -37,6 +37,7 @@ public class SkinOverlay implements ISkinOverlay {
this.texture = texture;
this.updateClient();
}
public String getTexture() {
return this.texture;
}
@@ -45,6 +46,7 @@ public class SkinOverlay implements ISkinOverlay {
this.glow = glow;
this.updateClient();
}
public boolean getGlow() {
return glow;
}
@@ -53,6 +55,7 @@ public class SkinOverlay implements ISkinOverlay {
this.blend = blend;
this.updateClient();
}
public boolean getBlend() {
return blend;
}
@@ -61,6 +64,7 @@ public class SkinOverlay implements ISkinOverlay {
this.alpha = alpha;
this.updateClient();
}
public float getAlpha() {
return alpha;
}
@@ -69,6 +73,7 @@ public class SkinOverlay implements ISkinOverlay {
this.size = size;
this.updateClient();
}
public float getSize() {
return size;
}
@@ -78,9 +83,11 @@ public class SkinOverlay implements ISkinOverlay {
this.scaleY = scaleY;
this.updateClient();
}
public float getTextureScaleX() {
return scaleX;
}
public float getTextureScaleY() {
return scaleY;
}
@@ -90,9 +97,11 @@ public class SkinOverlay implements ISkinOverlay {
this.speedY = speedY;
this.updateClient();
}
public float getSpeedX() {
return speedX;
}
public float getSpeedY() {
return speedY;
}
@@ -103,12 +112,15 @@ public class SkinOverlay implements ISkinOverlay {
this.offsetZ = offsetZ;
this.updateClient();
}
public float getOffsetX() {
return offsetX;
}
public float getOffsetY() {
return offsetY;
}
public float getOffsetZ() {
return offsetZ;
}
@@ -15,187 +15,187 @@ import noppes.npcs.scripted.NpcAPI;
import java.util.*;
public class SpawnData extends WeightedRandom.Item implements INaturalSpawn {
public List<String> biomes = new ArrayList<>();
public HashSet<Integer> dimensions = new HashSet<>();
public int id = -1;
public String name = "";
public List<String> biomes = new ArrayList<>();
public HashSet<Integer> dimensions = new HashSet<>();
public int id = -1;
public String name = "";
public HashMap<Integer,NBTTagCompound> spawnCompounds = new HashMap<>();
public HashMap<Integer, NBTTagCompound> spawnCompounds = new HashMap<>();
public boolean animalSpawning = true;
public boolean monsterSpawning = false;
public boolean liquidSpawning = false;
public boolean airSpawning = false;
public boolean animalSpawning = true;
public boolean monsterSpawning = false;
public boolean liquidSpawning = false;
public boolean airSpawning = false;
public int spawnHeightMin;
public int spawnHeightMax = 100;
public int spawnHeightMin;
public int spawnHeightMax = 100;
public SpawnData() {
super(10);
}
public SpawnData() {
super(10);
}
public void readNBT(NBTTagCompound compound) {
id = compound.getInteger("SpawnId");
name = compound.getString("SpawnName");
itemWeight = compound.getInteger("SpawnWeight");
if(itemWeight == 0)
itemWeight = 1;
public void readNBT(NBTTagCompound compound) {
id = compound.getInteger("SpawnId");
name = compound.getString("SpawnName");
itemWeight = compound.getInteger("SpawnWeight");
if (itemWeight == 0)
itemWeight = 1;
biomes = NBTTags.getStringList(compound.getTagList("SpawnBiomes", 10));
if (!compound.hasKey("SpawnDimensions")) {
dimensions.addAll(Arrays.asList(DimensionManager.getStaticDimensionIDs()));
} else {
dimensions = NBTTags.getIntegerSet(compound.getTagList("SpawnDimensions", 10));
}
biomes = NBTTags.getStringList(compound.getTagList("SpawnBiomes", 10));
if (!compound.hasKey("SpawnDimensions")) {
dimensions.addAll(Arrays.asList(DimensionManager.getStaticDimensionIDs()));
} else {
dimensions = NBTTags.getIntegerSet(compound.getTagList("SpawnDimensions", 10));
}
this.spawnCompounds.clear();
Set<?> keys = compound.func_150296_c();
for (Object key : keys) {
if (((String)key).startsWith("SpawnCompound")) {
int i = Integer.parseInt(((String)key).replace("SpawnCompound",""));
this.spawnCompounds.put(i,compound.getCompoundTag("SpawnCompound"+i));
}
}
this.spawnCompounds.clear();
Set<?> keys = compound.func_150296_c();
for (Object key : keys) {
if (((String) key).startsWith("SpawnCompound")) {
int i = Integer.parseInt(((String) key).replace("SpawnCompound", ""));
this.spawnCompounds.put(i, compound.getCompoundTag("SpawnCompound" + i));
}
}
animalSpawning = compound.getBoolean("AnimalSpawning");
monsterSpawning = compound.getBoolean("MonsterSpawning");
liquidSpawning = compound.getBoolean("LiquidSpawning");
airSpawning = compound.getBoolean("CaveSpawning");
animalSpawning = compound.getBoolean("AnimalSpawning");
monsterSpawning = compound.getBoolean("MonsterSpawning");
liquidSpawning = compound.getBoolean("LiquidSpawning");
airSpawning = compound.getBoolean("CaveSpawning");
spawnHeightMin = compound.getInteger("HeightMin");
if (!compound.hasKey("HeightMax")) {
spawnHeightMax = 100;
} else {
spawnHeightMax = compound.getInteger("HeightMax");
}
}
spawnHeightMin = compound.getInteger("HeightMin");
if (!compound.hasKey("HeightMax")) {
spawnHeightMax = 100;
} else {
spawnHeightMax = compound.getInteger("HeightMax");
}
}
public NBTTagCompound writeNBT(NBTTagCompound compound) {
compound.setInteger("SpawnId", id);
compound.setString("SpawnName", name);
compound.setInteger("SpawnWeight", itemWeight);
compound.setTag("SpawnBiomes", NBTTags.nbtStringList(biomes));
if (!this.dimensions.isEmpty()) {
compound.setTag("SpawnDimensions", NBTTags.nbtIntegerSet(dimensions));
}
public NBTTagCompound writeNBT(NBTTagCompound compound) {
compound.setInteger("SpawnId", id);
compound.setString("SpawnName", name);
compound.setInteger("SpawnWeight", itemWeight);
Set<Map.Entry<Integer,NBTTagCompound>> entries = this.spawnCompounds.entrySet();
for (Map.Entry<Integer,NBTTagCompound> entry : entries) {
compound.setTag("SpawnCompound" + entry.getKey(), entry.getValue() != null ? entry.getValue() : new NBTTagCompound());
}
compound.setTag("SpawnBiomes", NBTTags.nbtStringList(biomes));
if (!this.dimensions.isEmpty()) {
compound.setTag("SpawnDimensions", NBTTags.nbtIntegerSet(dimensions));
}
compound.setBoolean("AnimalSpawning", animalSpawning);
compound.setBoolean("MonsterSpawning", monsterSpawning);
compound.setBoolean("LiquidSpawning", liquidSpawning);
compound.setBoolean("CaveSpawning", airSpawning);
Set<Map.Entry<Integer, NBTTagCompound>> entries = this.spawnCompounds.entrySet();
for (Map.Entry<Integer, NBTTagCompound> entry : entries) {
compound.setTag("SpawnCompound" + entry.getKey(), entry.getValue() != null ? entry.getValue() : new NBTTagCompound());
}
compound.setInteger("HeightMin", spawnHeightMin);
compound.setInteger("HeightMax", spawnHeightMax);
return compound;
}
compound.setBoolean("AnimalSpawning", animalSpawning);
compound.setBoolean("MonsterSpawning", monsterSpawning);
compound.setBoolean("LiquidSpawning", liquidSpawning);
compound.setBoolean("CaveSpawning", airSpawning);
public void setName(String name) {
if (name != null && !name.isEmpty()) {
this.name = name;
}
}
compound.setInteger("HeightMin", spawnHeightMin);
compound.setInteger("HeightMax", spawnHeightMax);
return compound;
}
public String getName() {
return this.name;
}
public void setName(String name) {
if (name != null && !name.isEmpty()) {
this.name = name;
}
}
public void setEntity(IEntity entity, int slot) {
NBTTagCompound compound = new NBTTagCompound();
if (entity != null && !entity.getMCEntity().writeToNBTOptional(compound)) {
throw new CustomNPCsException("Entity could not be written to NBT");
} else {
this.spawnCompounds.put(slot,compound);
}
}
public String getName() {
return this.name;
}
public IEntity getEntity(IWorld world, int slot) {
if (!this.spawnCompounds.containsKey(slot)) {
return null;
}
try {
Entity entity = EntityList.createEntityFromNBT(this.spawnCompounds.get(slot), world.getMCWorld());
return NpcAPI.Instance().getIEntity(entity);
} catch (Exception e) {
throw new CustomNPCsException("Error creating entity from spawn data:\n" + e.getMessage());
}
}
public void setEntity(IEntity entity, int slot) {
NBTTagCompound compound = new NBTTagCompound();
if (entity != null && !entity.getMCEntity().writeToNBTOptional(compound)) {
throw new CustomNPCsException("Entity could not be written to NBT");
} else {
this.spawnCompounds.put(slot, compound);
}
}
public Integer[] getSlots() {
return this.spawnCompounds.keySet().toArray(new Integer[0]);
}
public IEntity getEntity(IWorld world, int slot) {
if (!this.spawnCompounds.containsKey(slot)) {
return null;
}
try {
Entity entity = EntityList.createEntityFromNBT(this.spawnCompounds.get(slot), world.getMCWorld());
return NpcAPI.Instance().getIEntity(entity);
} catch (Exception e) {
throw new CustomNPCsException("Error creating entity from spawn data:\n" + e.getMessage());
}
}
public void setWeight(int weight) {
if (weight < 1)
weight = 1;
if (weight > 100)
weight = 100;
public Integer[] getSlots() {
return this.spawnCompounds.keySet().toArray(new Integer[0]);
}
this.itemWeight = weight;
}
public void setWeight(int weight) {
if (weight < 1)
weight = 1;
if (weight > 100)
weight = 100;
public int getWeight() {
return this.itemWeight;
}
this.itemWeight = weight;
}
public void setMinHeight(int height) {
this.spawnHeightMin = height;
}
public int getWeight() {
return this.itemWeight;
}
public int getMinHeight() {
return this.spawnHeightMin;
}
public void setMinHeight(int height) {
this.spawnHeightMin = height;
}
public void setMaxHeight(int height) {
this.spawnHeightMax = height;
}
public int getMinHeight() {
return this.spawnHeightMin;
}
public int getMaxHeight() {
return this.spawnHeightMax;
}
public void setMaxHeight(int height) {
this.spawnHeightMax = height;
}
public void spawnsLikeAnimal(boolean spawns) {
this.animalSpawning = spawns;
}
public int getMaxHeight() {
return this.spawnHeightMax;
}
public boolean spawnsLikeAnimal() {
return animalSpawning;
}
public void spawnsLikeAnimal(boolean spawns) {
this.animalSpawning = spawns;
}
public void spawnsLikeMonster(boolean spawns) {
this.monsterSpawning = spawns;
}
public boolean spawnsLikeAnimal() {
return animalSpawning;
}
public boolean spawnsLikeMonster() {
return monsterSpawning;
}
public void spawnsLikeMonster(boolean spawns) {
this.monsterSpawning = spawns;
}
public void spawnsInLiquid(boolean spawns) {
this.liquidSpawning = spawns;
}
public boolean spawnsLikeMonster() {
return monsterSpawning;
}
public boolean spawnsInLiquid() {
return this.liquidSpawning;
}
public void spawnsInLiquid(boolean spawns) {
this.liquidSpawning = spawns;
}
public void spawnsInAir(boolean spawns) {
this.airSpawning = spawns;
}
public boolean spawnsInLiquid() {
return this.liquidSpawning;
}
public boolean spawnsInAir() {
return this.airSpawning;
}
public void spawnsInAir(boolean spawns) {
this.airSpawning = spawns;
}
public String[] getBiomes() {
return biomes.toArray(new String[]{});
}
public boolean spawnsInAir() {
return this.airSpawning;
}
public void setBiomes(String[] biomes) {
this.biomes = new ArrayList<>(Arrays.asList(biomes));
}
public String[] getBiomes() {
return biomes.toArray(new String[]{});
}
public void setBiomes(String[] biomes) {
this.biomes = new ArrayList<>(Arrays.asList(biomes));
}
}
@@ -9,75 +9,85 @@ import java.util.UUID;
import static java.util.UUID.randomUUID;
public class Tag implements ITag {
public String name = "";
public int color = Integer.parseInt("FF00", 16);
public int id = -1;
public UUID uuid = randomUUID();
public boolean hideTag = false;
public String name = "";
public int color = Integer.parseInt("FF00", 16);
public int id = -1;
public UUID uuid = randomUUID();
public boolean hideTag = false;
public Tag(){}
public Tag() {
}
public Tag(int id, String name, int color){
this.name = name;
this.color = color;
this.id = id;
}
public static String formatName(String name){
name = name.toLowerCase().trim();
return name.substring(0, 1).toUpperCase() + name.substring(1);
}
public void readNBT(NBTTagCompound compound){
public Tag(int id, String name, int color) {
this.name = name;
this.color = color;
this.id = id;
}
public static String formatName(String name) {
name = name.toLowerCase().trim();
return name.substring(0, 1).toUpperCase() + name.substring(1);
}
public void readNBT(NBTTagCompound compound) {
name = compound.getString("Name");
color = compound.getInteger("Color");
id = compound.getInteger("Slot");
hideTag = compound.getBoolean("HideTag");
uuid = UUID.fromString(compound.getString("Uuid"));
}
public void writeNBT(NBTTagCompound compound){
compound.setInteger("Slot", id);
compound.setString("Name", name);
compound.setInteger("Color", color);
compound.setString("Uuid", uuid.toString());
compound.setBoolean("HideTag", hideTag);
}
public void readShortNBT(NBTTagCompound compound){
name = compound.getString("Name");
uuid = UUID.fromString(compound.getString("Uuid"));
}
public void writeShortNBT(NBTTagCompound compound){
compound.setString("Name", name);
compound.setString("Uuid", uuid.toString());
}
uuid = UUID.fromString(compound.getString("Uuid"));
}
public int getId() {
return this.id;
}
public void writeNBT(NBTTagCompound compound) {
compound.setInteger("Slot", id);
compound.setString("Name", name);
compound.setInteger("Color", color);
compound.setString("Uuid", uuid.toString());
compound.setBoolean("HideTag", hideTag);
}
public String getUuid() {
return this.uuid.toString();
}
public void readShortNBT(NBTTagCompound compound) {
name = compound.getString("Name");
uuid = UUID.fromString(compound.getString("Uuid"));
}
public String getName() {
return this.name;
}
public void writeShortNBT(NBTTagCompound compound) {
compound.setString("Name", name);
compound.setString("Uuid", uuid.toString());
}
public void setName(String name) { this.name = name; }
public int getId() {
return this.id;
}
public void setColor(int color) { this.color = color; }
public String getUuid() {
return this.uuid.toString();
}
public int getColor() {
return this.color;
}
public String getName() {
return this.name;
}
public boolean getIsHidden() {
return this.hideTag;
}
public void setName(String name) {
this.name = name;
}
public void setIsHidden(boolean bo) {
this.hideTag = bo;
}
public void setColor(int color) {
this.color = color;
}
public void save() {
TagController.getInstance().saveTag(this);
}
public int getColor() {
return this.color;
}
public boolean getIsHidden() {
return this.hideTag;
}
public void setIsHidden(boolean bo) {
this.hideTag = bo;
}
public void save() {
TagController.getInstance().saveTag(this);
}
}
@@ -7,104 +7,103 @@ import net.minecraft.nbt.NBTTagString;
import java.util.*;
public class TagMap {
public int cloneTab;
public HashMap<String, HashSet<UUID>> tagMap;
public int cloneTab;
public HashMap<String, HashSet<UUID>> tagMap;
public TagMap(int tab){
this.cloneTab = tab;
this.tagMap = new HashMap<String, HashSet<UUID>>();
}
public TagMap(int tab) {
this.cloneTab = tab;
this.tagMap = new HashMap<String, HashSet<UUID>>();
}
public void readNBT(NBTTagCompound compound){
this.tagMap = new HashMap<String, HashSet<UUID>>();
NBTTagList list = compound.getTagList("TagMap", 10);
if(list != null){
for(int i = 0; i < list.tagCount(); i++)
{
NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
String cloneName = nbttagcompound.getString("Clone");
public void readNBT(NBTTagCompound compound) {
this.tagMap = new HashMap<String, HashSet<UUID>>();
NBTTagList list = compound.getTagList("TagMap", 10);
if (list != null) {
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
String cloneName = nbttagcompound.getString("Clone");
HashSet<UUID> uuids = new HashSet<UUID>();
NBTTagList nbtTagList = nbttagcompound.getTagList("TagUUIDs",8);
for (int j = 0; j < nbtTagList.tagCount(); j++) {
String uuid = nbtTagList.getStringTagAt(j);
if(!uuid.isEmpty()){
uuids.add(UUID.fromString(uuid));
}
}
tagMap.put(cloneName, uuids);
}
}
}
HashSet<UUID> uuids = new HashSet<UUID>();
NBTTagList nbtTagList = nbttagcompound.getTagList("TagUUIDs", 8);
for (int j = 0; j < nbtTagList.tagCount(); j++) {
String uuid = nbtTagList.getStringTagAt(j);
if (!uuid.isEmpty()) {
uuids.add(UUID.fromString(uuid));
}
}
tagMap.put(cloneName, uuids);
}
}
}
public NBTTagCompound writeNBT(){
NBTTagCompound nbt = new NBTTagCompound();
NBTTagList cloneList = new NBTTagList();
for(String key: tagMap.keySet()){
HashSet<UUID> uuidSet = tagMap.get(key);
if(uuidSet.size() > 0){
NBTTagCompound cloneCompound = new NBTTagCompound();
cloneCompound.setString("Clone", key);
NBTTagList nbtTagList = new NBTTagList();
for (UUID uuid : uuidSet) {
nbtTagList.appendTag(new NBTTagString(uuid.toString()));
}
cloneCompound.setTag("TagUUIDs", nbtTagList);
cloneList.appendTag(cloneCompound);
}
}
nbt.setTag("TagMap", cloneList);
return nbt;
}
public NBTTagCompound writeNBT() {
NBTTagCompound nbt = new NBTTagCompound();
NBTTagList cloneList = new NBTTagList();
for (String key : tagMap.keySet()) {
HashSet<UUID> uuidSet = tagMap.get(key);
if (uuidSet.size() > 0) {
NBTTagCompound cloneCompound = new NBTTagCompound();
cloneCompound.setString("Clone", key);
NBTTagList nbtTagList = new NBTTagList();
for (UUID uuid : uuidSet) {
nbtTagList.appendTag(new NBTTagString(uuid.toString()));
}
cloneCompound.setTag("TagUUIDs", nbtTagList);
cloneList.appendTag(cloneCompound);
}
}
nbt.setTag("TagMap", cloneList);
return nbt;
}
public int getCloneTab() {
return this.cloneTab;
}
public int getCloneTab() {
return this.cloneTab;
}
public boolean hasClone(String cloneName) {
return tagMap.containsKey(cloneName);
}
public boolean hasClone(String cloneName) {
return tagMap.containsKey(cloneName);
}
public HashSet<UUID> getUUIDs(String cloneName) {
if(hasClone(cloneName)){
return tagMap.get(cloneName);
}
return null;
}
public HashSet<UUID> getUUIDs(String cloneName) {
if (hasClone(cloneName)) {
return tagMap.get(cloneName);
}
return null;
}
public List<UUID> getUUIDsList(String cloneName) {
HashSet<UUID> uuids = getUUIDs(cloneName);
if(uuids != null){
List<UUID> tagUUIDS = new ArrayList<>(uuids);
Collections.sort(tagUUIDS);
return tagUUIDS;
}
public List<UUID> getUUIDsList(String cloneName) {
HashSet<UUID> uuids = getUUIDs(cloneName);
if (uuids != null) {
List<UUID> tagUUIDS = new ArrayList<>(uuids);
Collections.sort(tagUUIDS);
return tagUUIDS;
}
return null;
}
return null;
}
public boolean removeClone(String cloneName) {
return tagMap.remove(cloneName) != null;
}
public boolean removeClone(String cloneName) {
return tagMap.remove(cloneName) != null;
}
public void putClone(String cloneName, HashSet<UUID> uuids) {
tagMap.put(cloneName, uuids);
}
public void putClone(String cloneName, HashSet<UUID> uuids) {
tagMap.put(cloneName, uuids);
}
public boolean hasTag(String cloneName, UUID tag) {
HashSet<UUID> uuids = getUUIDs(cloneName);
if(uuids == null){
return false;
}
return uuids.contains(tag);
}
public boolean hasTag(String cloneName, UUID tag) {
HashSet<UUID> uuids = getUUIDs(cloneName);
if (uuids == null) {
return false;
}
return uuids.contains(tag);
}
public HashSet<UUID> getAllUUIDs() {
HashSet<UUID> uuids = new HashSet<UUID>();
for(HashSet<UUID> uuids1 : tagMap.values()){
uuids.addAll(uuids1);
}
return uuids;
}
public HashSet<UUID> getAllUUIDs() {
HashSet<UUID> uuids = new HashSet<UUID>();
for (HashSet<UUID> uuids1 : tagMap.values()) {
uuids.addAll(uuids1);
}
return uuids;
}
}
@@ -12,7 +12,7 @@ public class TintData {
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setBoolean("TintEnabled", tintEnabled);
if(tintEnabled) {
if (tintEnabled) {
nbttagcompound.setBoolean("HurtTintEnabled", hurtTintEnabled);
nbttagcompound.setBoolean("GeneralTintEnabled", generalTintEnabled);
nbttagcompound.setInteger("HurtTint", hurtTint);
@@ -24,7 +24,7 @@ public class TintData {
public void readFromNBT(NBTTagCompound nbttagcompound) {
tintEnabled = nbttagcompound.getBoolean("TintEnabled");
if(tintEnabled) {
if (tintEnabled) {
hurtTintEnabled = nbttagcompound.getBoolean("HurtTintEnabled");
generalTintEnabled = nbttagcompound.getBoolean("GeneralTintEnabled");
hurtTint = nbttagcompound.getInteger("HurtTint");
@@ -81,8 +81,8 @@ public class TintData {
this.generalAlpha = generalAlpha;
}
public boolean processColor(boolean isHurt){
if(isHurt){
public boolean processColor(boolean isHurt) {
if (isHurt) {
return (isTintEnabled() && (!isHurtTintEnabled() && !isGeneralTintEnabled()));
} else {
return !(isTintEnabled() && isGeneralTintEnabled());
@@ -11,95 +11,95 @@ import java.util.Map;
import java.util.Vector;
public class TransportCategory implements ITransportCategory {
public int id = -1;
public String title = "";
public HashMap<Integer,TransportLocation> locations;
public int id = -1;
public String title = "";
public HashMap<Integer, TransportLocation> locations;
public TransportCategory(){
locations = new HashMap<Integer, TransportLocation>();
}
public TransportCategory() {
locations = new HashMap<Integer, TransportLocation>();
}
public Vector<TransportLocation> getDefaultLocations() {
Vector<TransportLocation> list = new Vector<TransportLocation>();
for(TransportLocation loc : locations.values())
if(loc.isDefault())
list.add(loc);
return list;
}
public Vector<TransportLocation> getDefaultLocations() {
Vector<TransportLocation> list = new Vector<TransportLocation>();
for (TransportLocation loc : locations.values())
if (loc.isDefault())
list.add(loc);
return list;
}
public void readNBT(NBTTagCompound compound){
id = compound.getInteger("CategoryId");
title = compound.getString("CategoryTitle");
public void readNBT(NBTTagCompound compound) {
id = compound.getInteger("CategoryId");
title = compound.getString("CategoryTitle");
NBTTagList locs = compound.getTagList("CategoryLocations", 10);
if(locs == null || locs.tagCount() == 0)
return;
NBTTagList locs = compound.getTagList("CategoryLocations", 10);
if (locs == null || locs.tagCount() == 0)
return;
for(int ii = 0; ii < locs.tagCount(); ii++)
{
TransportLocation location = new TransportLocation();
location.readNBT(locs.getCompoundTagAt(ii));
location.category = this;
locations.put(location.id,location);
for (int ii = 0; ii < locs.tagCount(); ii++) {
TransportLocation location = new TransportLocation();
location.readNBT(locs.getCompoundTagAt(ii));
location.category = this;
locations.put(location.id, location);
}
}
}
public void writeNBT(NBTTagCompound compound){
compound.setInteger("CategoryId", id);
compound.setString("CategoryTitle", title);
public void writeNBT(NBTTagCompound compound) {
compound.setInteger("CategoryId", id);
compound.setString("CategoryTitle", title);
NBTTagList locs = new NBTTagList();
for(TransportLocation location : locations.values()){
locs.appendTag(location.writeNBT());
}
compound.setTag("CategoryLocations", locs);
}
for (TransportLocation location : locations.values()) {
locs.appendTag(location.writeNBT());
}
compound.setTag("CategoryLocations", locs);
}
public int getId() {
return id;
}
public int getId() {
return id;
}
public void setTitle(String title) {
this.title = title;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
public String getTitle() {
return title;
}
public void addLocation(String name) {
int id = TransportController.getInstance().getUniqueIdLocation();
TransportLocation location = new TransportLocation();
location.id = id;
location.name = name;
location.category = this;
public void addLocation(String name) {
int id = TransportController.getInstance().getUniqueIdLocation();
TransportLocation location = new TransportLocation();
location.id = id;
location.name = name;
location.category = this;
TransportController.getInstance().setLocation(location);
}
TransportController.getInstance().setLocation(location);
}
public ITransportLocation getLocation(String name) {
TransportLocation location = null;
for (TransportLocation l : locations.values()) {
if (l.getName().equals(name)) {
location = l;
break;
}
}
public ITransportLocation getLocation(String name) {
TransportLocation location = null;
for (TransportLocation l : locations.values()) {
if (l.getName().equals(name)) {
location = l;
break;
}
}
return location;
}
return location;
}
public void removeLocation(String name) {
int id = -1;
for (Map.Entry<Integer,TransportLocation> entry : locations.entrySet()) {
if (entry.getValue().getName().equals(name)) {
id = entry.getKey();;
locations.remove(entry.getKey());
break;
}
}
public void removeLocation(String name) {
int id = -1;
for (Map.Entry<Integer, TransportLocation> entry : locations.entrySet()) {
if (entry.getValue().getName().equals(name)) {
id = entry.getKey();
;
locations.remove(entry.getKey());
break;
}
}
if (id >= 0) {
TransportController.getInstance().removeLocation(id);
}
}
if (id >= 0) {
TransportController.getInstance().removeLocation(id);
}
}
}
@@ -7,102 +7,102 @@ import noppes.npcs.controllers.TransportController;
import noppes.npcs.scripted.NpcAPI;
public class TransportLocation implements ITransportLocation {
public int id = -1;
public String name = "default name";
public double posX;
public double posY;
public double posZ;
public int type = 0;
public int dimension = 0;
public TransportCategory category;
public void readNBT(NBTTagCompound compound) {
if(compound == null)
return;
id = compound.getInteger("Id");
posX = compound.getDouble("PosX");
posY = compound.getDouble("PosY");
posZ = compound.getDouble("PosZ");
type = compound.getInteger("Type");
dimension = compound.getInteger("Dimension");
name = compound.getString("Name");
}
public int id = -1;
public String name = "default name";
public double posX;
public double posY;
public double posZ;
public NBTTagCompound writeNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("Id", id);
compound.setDouble("PosX", posX);
compound.setDouble("PosY", posY);
compound.setDouble("PosZ", posZ);
compound.setInteger("Type", type);
compound.setInteger("Dimension", dimension);
compound.setString("Name", name);
return compound;
}
public int type = 0;
public int dimension = 0;
public boolean isDefault() {
return type == 1;
}
public TransportCategory category;
public int getId() {
return id;
}
public void readNBT(NBTTagCompound compound) {
if (compound == null)
return;
id = compound.getInteger("Id");
posX = compound.getDouble("PosX");
posY = compound.getDouble("PosY");
posZ = compound.getDouble("PosZ");
type = compound.getInteger("Type");
dimension = compound.getInteger("Dimension");
name = compound.getString("Name");
}
public void setName(String name) {
this.name = name;
}
public NBTTagCompound writeNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("Id", id);
compound.setDouble("PosX", posX);
compound.setDouble("PosY", posY);
compound.setDouble("PosZ", posZ);
compound.setInteger("Type", type);
compound.setInteger("Dimension", dimension);
compound.setString("Name", name);
return compound;
}
public String getName() {
return name;
}
public boolean isDefault() {
return type == 1;
}
public void setDimension(int dimension) {
this.dimension = dimension;
}
public int getId() {
return id;
}
public int getDimension() {
return dimension;
}
public void setName(String name) {
this.name = name;
}
public void setType(int type) {
this.type = type;
}
public String getName() {
return name;
}
public int getType() {
return type;
}
public void setDimension(int dimension) {
this.dimension = dimension;
}
public void setPosition(int x, int y, int z) {
this.posX = x;
this.posY = y;
this.posZ = z;
}
public int getDimension() {
return dimension;
}
public void setPosition(IPos pos) {
this.posX = pos.getX();
this.posY = pos.getY();
this.posZ = pos.getZ();
}
public void setType(int type) {
this.type = type;
}
public IPos getPos() {
return NpcAPI.Instance().getIPos(this.posX, this.posY, this.posZ);
}
public int getType() {
return type;
}
public double getX() {
return posX;
}
public void setPosition(int x, int y, int z) {
this.posX = x;
this.posY = y;
this.posZ = z;
}
public double getY() {
return posY;
}
public void setPosition(IPos pos) {
this.posX = pos.getX();
this.posY = pos.getY();
this.posZ = pos.getZ();
}
public double getZ() {
return posZ;
}
public IPos getPos() {
return NpcAPI.Instance().getIPos(this.posX, this.posY, this.posZ);
}
public void save() {
TransportController.getInstance().saveLocation(this.category.id, this);
}
public double getX() {
return posX;
}
public double getY() {
return posY;
}
public double getZ() {
return posZ;
}
public void save() {
TransportController.getInstance().saveLocation(this.category.id, this);
}
}