use of com.lying.variousoddities.world.savedata.FactionManager.Faction in project VariousOddities by Lyinginbedmon.
the class FactionReputation method resetPlayerReputation.
/**
* Returns the given player's reputation with the given faction to its configured starting value
* @param player
* @param factionName
* @return
*/
public static int resetPlayerReputation(PlayerEntity player, String factionName) {
factionName = validateName(factionName);
FactionManager manager = FactionManager.get(player.getEntityWorld());
Faction faction = manager.getFaction(factionName);
int rep = faction == null ? 0 : faction.startingRep;
PlayerData data = PlayerData.forPlayer(player);
if (data != null)
data.reputation.setReputation(factionName, rep);
return rep;
}
use of com.lying.variousoddities.world.savedata.FactionManager.Faction in project VariousOddities by Lyinginbedmon.
the class NearestAttackableTargetGoalMixin method getPredicate.
private static Predicate<LivingEntity> getPredicate(LivingEntity goalOwnerIn) {
return new Predicate<LivingEntity>() {
public boolean test(LivingEntity target) {
// Undead mobs do not target other undead
if (goalOwnerIn.isNonBoss() && goalOwnerIn.isEntityUndead())
if (target.isEntityUndead())
return false;
// Mobs do not attack creatures that have mind-controlled them somehow
LivingData mobData = LivingData.forEntity(goalOwnerIn);
if (mobData != null && mobData.isTargetingHindered(target))
return false;
// Faction mobs do not attack mobs with good reputation
if (goalOwnerIn instanceof IFactionMob) {
FactionManager factionManager = FactionManager.get(target.getEntityWorld());
Faction ownerFaction = factionManager.getFaction(goalOwnerIn);
if (ownerFaction != null)
if (target.getType() == EntityType.PLAYER) {
PlayerData data = PlayerData.forPlayer((PlayerEntity) target);
if (data != null) {
int reputation = data.reputation.getReputation(ownerFaction.name);
if (reputation == Integer.MIN_VALUE) {
data.reputation.setReputation(ownerFaction.name, ownerFaction.startingRep);
reputation = ownerFaction.startingRep;
}
return EnumAttitude.fromRep(reputation).allowsInteraction(EnumInteraction.ATTACK);
}
} else if (target instanceof IFactionMob) {
Faction inputFaction = factionManager.getFaction(target);
if (inputFaction != null)
return ownerFaction.relationWith(inputFaction.name).allowsInteraction(EnumInteraction.ATTACK);
}
}
return true;
}
};
}
use of com.lying.variousoddities.world.savedata.FactionManager.Faction in project VariousOddities by Lyinginbedmon.
the class FactionReputation method getPlayerReputation.
public static int getPlayerReputation(PlayerEntity player, String factionName) {
factionName = validateName(factionName);
PlayerData data = PlayerData.forPlayer(player);
if (data == null)
return 0;
int rep = data.reputation.getReputation(factionName);
if (rep == Integer.MIN_VALUE) {
// Set to starting reputation
FactionManager manager = FactionManager.get(player.getEntityWorld());
Faction faction = manager.getFaction(factionName);
if (faction != null)
rep = faction.startingRep;
else
rep = 0;
}
return rep;
}
use of com.lying.variousoddities.world.savedata.FactionManager.Faction in project VariousOddities by Lyinginbedmon.
the class CommandFaction method getFaction.
public static Faction getFaction(CommandContext<CommandSource> context, String name) throws CommandSyntaxException {
FactionManager manager = FactionManager.get(context.getSource().getWorld());
Faction faction = manager.getFaction(name);
if (faction == null)
throw FACTION_NOT_FOUND.create();
else
return faction;
}
Aggregations