Search in sources :

Example 16 with Faction

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;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) Faction(team.cqr.cqrepoured.faction.Faction)

Example 17 with Faction

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);
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) LivingEntity(net.minecraft.entity.LivingEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) AbstractEntityCQR(team.cqr.cqrepoured.entity.bases.AbstractEntityCQR) EffectInstance(net.minecraft.potion.EffectInstance) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Faction(team.cqr.cqrepoured.faction.Faction)

Example 18 with Faction

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;
}
Also used : DungeonInhabitant(team.cqr.cqrepoured.world.structure.generation.inhabitants.DungeonInhabitant) Entity(net.minecraft.entity.Entity) Faction(team.cqr.cqrepoured.faction.Faction)

Aggregations

Faction (team.cqr.cqrepoured.faction.Faction)18 LivingEntity (net.minecraft.entity.LivingEntity)12 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)8 PlayerEntity (net.minecraft.entity.player.PlayerEntity)6 Entity (net.minecraft.entity.Entity)4 EffectInstance (net.minecraft.potion.EffectInstance)3 Vector3d (net.minecraft.util.math.vector.Vector3d)3 EDefaultFaction (team.cqr.cqrepoured.faction.EDefaultFaction)3 ArrayList (java.util.ArrayList)1 CommandException (net.minecraft.command.CommandException)1 WrongUsageException (net.minecraft.command.WrongUsageException)1 MonsterEntity (net.minecraft.entity.monster.MonsterEntity)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 AbstractArrowEntity (net.minecraft.entity.projectile.AbstractArrowEntity)1 SpectralArrowEntity (net.minecraft.entity.projectile.SpectralArrowEntity)1 ThrowableEntity (net.minecraft.entity.projectile.ThrowableEntity)1 AxeItem (net.minecraft.item.AxeItem)1 ItemStack (net.minecraft.item.ItemStack)1 ShieldItem (net.minecraft.item.ShieldItem)1 ResourceLocation (net.minecraft.util.ResourceLocation)1