use of team.cqr.cqrepoured.faction.Faction in project ChocolateQuestRepoured by TeamChocoQuest.
the class EntityAIHurtByTarget method canUse.
@Override
public boolean canUse() {
if (this.world.getDifficulty() == Difficulty.PEACEFUL) {
return false;
}
if (this.entity.getLastHurtByMobTimestamp() == this.prevRevengeTimer) {
return false;
}
LivingEntity revengeTarget = this.entity.getLastHurtByMob();
if (!TargetUtil.PREDICATE_ATTACK_TARGET.apply(revengeTarget)) {
return false;
}
if (!revengeTarget.isAlive()) {
return false;
}
Faction faction = this.entity.getFaction();
if (faction == null) {
return false;
}
if (!isEnemyCheckingLeadersWhenAttacked(this.entity, revengeTarget)) {
return false;
}
if (!this.entity.isInSightRange(revengeTarget)) {
return false;
}
this.attackTarget = revengeTarget;
return true;
}
use of team.cqr.cqrepoured.faction.Faction in project ChocolateQuestRepoured by TeamChocoQuest.
the class EntitySummoningCircle method tick.
@Override
public void tick() {
super.tick();
if (!this.level.isClientSide) {
if (this.tickCount >= EntitySummoningCircle.BORDER_WHEN_TO_SPAWN_IN_TICKS * this.timeMultiplierForSummon) {
Entity summon = EntityList.createEntityByIDFromName(this.entityToSpawn, this.level);
if (summon != null) {
// summon.setPosition(this.posX, this.posY + 0.5D, this.posZ);
summon.setPos(this.position().x, this.position().y + 0.5D, this.position().z);
if (this.velForSummon != null) {
/*summon.motionX = this.velForSummon.x;
summon.motionY = this.velForSummon.y;
summon.motionZ = this.velForSummon.z;
summon.velocityChanged = true;*/
summon.setDeltaMovement(this.velForSummon);
summon.hasImpulse = true;
}
if (this.summonerLiving instanceof PlayerEntity && summon instanceof AbstractEntityCQR) {
Arrays.stream(EquipmentSlotType.values()).forEach(slot -> ((AbstractEntityCQR) summon).setDropChance(slot, 1.01F));
}
this.level.addFreshEntity(summon);
if (this.summonerLiving != null && summon instanceof AbstractEntityCQR) {
((AbstractEntityCQR) summon).setLeader(this.summonerLiving);
Faction faction = FactionRegistry.instance(this).getFactionOf(this.summonerLiving);
if (faction != null) {
((AbstractEntityCQR) summon).setFaction(faction.getName());
}
}
if (this.summoner != null && !this.summoner.getSummoner().isDeadOrDying()) {
this.summoner.setSummonedEntityFaction(summon);
this.summoner.tryEquipSummon(summon, this.level.random);
this.summoner.addSummonedEntityToList(summon);
}
}
this.remove();
}
} else {
if (this.tickCount >= EntitySummoningCircle.BORDER_WHEN_TO_SPAWN_IN_TICKS * this.timeMultiplierForSummon * 0.8F) {
for (int i = 0; i < 4; i++) {
this.level.addParticle(ParticleTypes.WITCH, this.position().x, this.position().y + 0.02D, this.position().z, this.random.nextDouble(), this.random.nextDouble(), this.random.nextDouble());
}
if (!this.level.isClientSide) {
Faction faction = this.summoner != null ? this.summoner.getSummonerFaction() : null;
for (Entity ent : this.level.getEntities(this, new AxisAlignedBB(this.position().add(this.getBbWidth() / 2, 0, this.getBbWidth() / 2), this.position().add(-this.getBbWidth() / 2, 3, -this.getBbWidth() / 2)), faction != null ? TargetUtil.createPredicateNonAlly(faction) : TargetUtil.PREDICATE_LIVING)) {
if (ent != null && ent.isAlive() && ent instanceof LivingEntity) {
((LivingEntity) ent).addEffect(new EffectInstance(Effects.WITHER, 80, 0));
}
}
}
// this.world.spawnParticle(EnumParticleTypes.SPELL_WITCH, this.posX, this.posY + 0.02D, this.posZ, 1.0F, 0.0F, 0.0F,
// 20);
// this.world.spawnParticle(EnumParticleTypes.SPELL_WITCH, this.posX, this.posY + 0.02D, this.posZ, 0.5F, 0.0F, 0.5F,
// 1);
// this.world.spawnParticle(EnumParticleTypes.SPELL_WITCH, this.posX, this.posY + 0.02D, this.posZ, 0.5F, 0.0F, -0.5F,
// 1);
// this.world.spawnParticle(EnumParticleTypes.SPELL_WITCH, this.posX, this.posY + 0.02D, this.posZ, -0.5F, 0.0F, 0.5F,
// 1);
// this.world.spawnParticle(EnumParticleTypes.SPELL_WITCH, this.posX, this.posY + 0.02D, this.posZ, -0.5F, 0.0F, -0.5F,
// 1);
}
}
}
use of team.cqr.cqrepoured.faction.Faction in project ChocolateQuestRepoured by TeamChocoQuest.
the class CastleRoomSelector method selectJailInhabitant.
private DungeonInhabitant selectJailInhabitant(World world, DungeonInhabitant mainInhabitant) {
Faction inhaFaction;
DungeonInhabitant jailed = null;
String factionOverride = mainInhabitant.getFactionOverride();
if (factionOverride != null) {
inhaFaction = FactionRegistry.instance(world).getFactionInstance(factionOverride);
} else {
Entity entity = EntityList.createEntityByIDFromName(mainInhabitant.getEntityID(), world);
// It is possible for entity to be null here but getFactionOf handles that case with a default value
inhaFaction = FactionRegistry.instance(world).getFactionOf(entity);
}
List<Faction> enemies = inhaFaction.getEnemies();
Collections.shuffle(enemies, this.random);
// Keep trying until we find a faction with potential enemies
for (Faction enemyFaction : enemies) {
List<DungeonInhabitant> possibleJailed = DungeonInhabitantManager.instance().getListOfFactionInhabitants(enemyFaction, world);
if (!possibleJailed.isEmpty()) {
jailed = possibleJailed.get(this.random.nextInt(possibleJailed.size()));
break;
}
}
return jailed;
}
Aggregations