mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 02:39:05 +00:00
1.7.10 Files
Files added
This commit is contained in:
1 parent
393ea9b463
commit
a31efb2dc3
1768 files changed
+84831
No files matched your search
@@ -0,0 +1,88 @@
|
||||
package noppes.npcs.controllers;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class Faction {
|
||||
public String name = "";
|
||||
public int color = Integer.parseInt("FF00", 16);
|
||||
|
||||
public HashSet<Integer> attackFactions;
|
||||
public int id = -1;
|
||||
|
||||
public int neutralPoints = 500;
|
||||
public int friendlyPoints = 1500;
|
||||
|
||||
public int defaultPoints = 1000;
|
||||
|
||||
public boolean hideFaction = false;
|
||||
public boolean getsAttacked = false;
|
||||
|
||||
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){
|
||||
name = compound.getString("Name");
|
||||
color = compound.getInteger("Color");
|
||||
id = compound.getInteger("Slot");
|
||||
|
||||
neutralPoints= compound.getInteger("NeutralPoints");
|
||||
friendlyPoints = compound.getInteger("FriendlyPoints");
|
||||
defaultPoints = compound.getInteger("DefaultPoints");
|
||||
|
||||
hideFaction = compound.getBoolean("HideFaction");
|
||||
getsAttacked = compound.getBoolean("GetsAttacked");
|
||||
|
||||
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);
|
||||
|
||||
compound.setBoolean("HideFaction", hideFaction);
|
||||
compound.setBoolean("GetsAttacked", getsAttacked);
|
||||
|
||||
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 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 isAggressiveToNpc(EntityNPCInterface entity) {
|
||||
return attackFactions.contains(entity.faction.id);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user