Search in sources :

Example 1 with SanguinareEffectInstance

use of de.teamlapen.vampirism.effects.SanguinareEffectInstance in project Vampirism by TeamLapen.

the class TotemTileEntity method updateCreaturesOnCapture.

private void updateCreaturesOnCapture(boolean fullConvert) {
    // noinspection ConstantConditions
    List<VillagerEntity> villagerEntities = this.level.getEntitiesOfClass(VillagerEntity.class, getVillageArea());
    if (VampirismEventFactory.fireVillagerCaptureEventPre(this, villagerEntities, fullConvert)) {
        return;
    }
    if (VReference.HUNTER_FACTION.equals(this.capturingFaction)) {
        List<HunterBaseEntity> hunterEntities = this.level.getEntitiesOfClass(HunterBaseEntity.class, getVillageArea());
        int i = Math.max(2, hunterEntities.size() / 2);
        for (HunterBaseEntity hunter : hunterEntities) {
            if (hunter instanceof ICaptureIgnore)
                continue;
            if (i-- > 0) {
                this.spawnVillagerReplace(hunter, true);
            }
        }
        for (int o = i; o > 0; o--) {
            this.spawnVillagerDefault(true);
        }
        for (VillagerEntity villager : villagerEntities) {
            ExtendedCreature.getSafe(villager).ifPresent(e -> e.setPoisonousBlood(true));
        }
        this.updateTrainer(false);
    } else if (VReference.HUNTER_FACTION.equals(this.controllingFaction)) {
        updateTrainer(true);
        for (VillagerEntity villager : villagerEntities) {
            ExtendedCreature.getSafe(villager).ifPresent(e -> e.setPoisonousBlood(false));
        }
        if (fullConvert) {
            List<HunterBaseEntity> hunterEntities = this.level.getEntitiesOfClass(HunterBaseEntity.class, getVillageArea());
            for (HunterBaseEntity hunter : hunterEntities) {
                if (hunter instanceof ICaptureIgnore)
                    continue;
                // noinspection ConstantConditions
                this.spawnEntity(this.getCaptureEntityForFaction(this.capturingFaction).create(this.level), hunter, true, false);
            }
        }
    } else {
        updateTrainer(true);
    }
    if (VReference.VAMPIRE_FACTION.equals(this.capturingFaction)) {
        for (VillagerEntity villager : villagerEntities) {
            if (!fullConvert) {
                if (RNG.nextInt(2) == 1)
                    continue;
                SanguinareEffect.addRandom(villager, false);
            } else {
                villager.addEffect(new SanguinareEffectInstance(11));
            }
        }
    } else if (VReference.VAMPIRE_FACTION.equals(this.controllingFaction)) {
        for (VillagerEntity villager : villagerEntities) {
            if (villager.hasEffect(ModEffects.sanguinare))
                villager.removeEffect(ModEffects.sanguinare);
            if (fullConvert) {
                if (villager instanceof ConvertedVillagerEntity) {
                    this.spawnVillagerReplaceForced(villager, this.capturingFaction == VReference.HUNTER_FACTION);
                }
            }
        }
        if (fullConvert) {
            List<VampireBaseEntity> vampireEntities = this.level.getEntitiesOfClass(VampireBaseEntity.class, getVillageArea());
            for (VampireBaseEntity vampire : vampireEntities) {
                if (vampire instanceof ICaptureIgnore)
                    continue;
                // noinspection ConstantConditions
                this.spawnEntity(this.getCaptureEntityForFaction(this.capturingFaction).create(this.level), vampire, true, false);
            }
        }
    }
    villagerEntities = this.level.getEntitiesOfClass(VillagerEntity.class, getVillageArea());
    for (VillagerEntity villager : villagerEntities) {
        if (villager.getVillagerData().getProfession() instanceof FactionVillagerProfession) {
            villager.setVillagerData(villager.getVillagerData().setProfession(VillagerProfession.NONE));
        }
    }
    VampirismEventFactory.fireVillagerCaptureEventPost(this, villagerEntities, fullConvert);
}
Also used : ConvertedVillagerEntity(de.teamlapen.vampirism.entity.converted.ConvertedVillagerEntity) AggressiveVillagerEntity(de.teamlapen.vampirism.entity.hunter.AggressiveVillagerEntity) VillagerEntity(net.minecraft.entity.merchant.villager.VillagerEntity) ServerWorld(net.minecraft.world.server.ServerWorld) FactionVillagerProfession(de.teamlapen.vampirism.entity.FactionVillagerProfession) ServerMultiBossInfo(de.teamlapen.vampirism.world.ServerMultiBossInfo) HunterBaseEntity(de.teamlapen.vampirism.entity.hunter.HunterBaseEntity) CompoundNBT(net.minecraft.nbt.CompoundNBT) IFormattableTextComponent(net.minecraft.util.text.IFormattableTextComponent) UtilLib(de.teamlapen.lib.lib.util.UtilLib) PointOfInterestManager(net.minecraft.village.PointOfInterestManager) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault) ICaptureAttributes(de.teamlapen.vampirism.api.world.ICaptureAttributes) ConvertedVillagerEntity(de.teamlapen.vampirism.entity.converted.ConvertedVillagerEntity) AggressiveVillagerEntity(de.teamlapen.vampirism.entity.hunter.AggressiveVillagerEntity) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BossInfo(net.minecraft.world.BossInfo) Dist(net.minecraftforge.api.distmarker.Dist) VillagerProfession(net.minecraft.entity.merchant.villager.VillagerProfession) Block(net.minecraft.block.Block) Pair(org.apache.commons.lang3.tuple.Pair) IFactionEntity(de.teamlapen.vampirism.api.entity.factions.IFactionEntity) Event(net.minecraftforge.eventbus.api.Event) BlockState(net.minecraft.block.BlockState) StructureStart(net.minecraft.world.gen.feature.structure.StructureStart) VampirismWorld(de.teamlapen.vampirism.world.VampirismWorld) VillagerEntity(net.minecraft.entity.merchant.villager.VillagerEntity) SanguinareEffectInstance(de.teamlapen.vampirism.effects.SanguinareEffectInstance) ListNBT(net.minecraft.nbt.ListNBT) HunterTrainerEntity(de.teamlapen.vampirism.entity.hunter.HunterTrainerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) GenericParticleData(de.teamlapen.vampirism.particle.GenericParticleData) Sets(com.google.common.collect.Sets) VampirismVillageEvent(de.teamlapen.vampirism.api.event.VampirismVillageEvent) de.teamlapen.vampirism.core(de.teamlapen.vampirism.core) Vector3d(net.minecraft.util.math.vector.Vector3d) List(java.util.List) Logger(org.apache.logging.log4j.Logger) SanguinareEffect(de.teamlapen.vampirism.effects.SanguinareEffect) ITaskMasterEntity(de.teamlapen.vampirism.api.entity.ITaskMasterEntity) ITickableTileEntity(net.minecraft.tileentity.ITickableTileEntity) IFaction(de.teamlapen.vampirism.api.entity.factions.IFaction) VampirismPlayerAttributes(de.teamlapen.vampirism.player.VampirismPlayerAttributes) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) IPlayableFaction(de.teamlapen.vampirism.api.entity.factions.IPlayableFaction) java.util(java.util) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) Structure(net.minecraft.world.gen.feature.structure.Structure) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) VampirismConfig(de.teamlapen.vampirism.config.VampirismConfig) NetworkManager(net.minecraft.network.NetworkManager) ITextComponent(net.minecraft.util.text.ITextComponent) PointOfInterestType(net.minecraft.village.PointOfInterestType) DyeColor(net.minecraft.item.DyeColor) Lists(com.google.common.collect.Lists) EffectInstance(net.minecraft.potion.EffectInstance) SUpdateTileEntityPacket(net.minecraft.network.play.server.SUpdateTileEntityPacket) FactionPlayerHandler(de.teamlapen.vampirism.entity.factions.FactionPlayerHandler) IVillageCaptureEntity(de.teamlapen.vampirism.api.entity.IVillageCaptureEntity) net.minecraft.entity(net.minecraft.entity) BiConsumer(java.util.function.BiConsumer) Difficulty(net.minecraft.world.Difficulty) Nonnull(javax.annotation.Nonnull) INBT(net.minecraft.nbt.INBT) Nullable(javax.annotation.Nullable) Effects(net.minecraft.potion.Effects) ITotem(de.teamlapen.vampirism.api.world.ITotem) TotemTopBlock(de.teamlapen.vampirism.blocks.TotemTopBlock) BushBlock(net.minecraft.block.BushBlock) VampirismAPI(de.teamlapen.vampirism.api.VampirismAPI) VampireBaseEntity(de.teamlapen.vampirism.entity.vampire.VampireBaseEntity) IAggressiveVillager(de.teamlapen.vampirism.api.entity.IAggressiveVillager) BlockPos(net.minecraft.util.math.BlockPos) TotemHelper(de.teamlapen.vampirism.tileentity.TotemHelper) DummyHunterTrainerEntity(de.teamlapen.vampirism.entity.hunter.DummyHunterTrainerEntity) PointOfInterest(net.minecraft.village.PointOfInterest) Blocks(net.minecraft.block.Blocks) ICaptureIgnore(de.teamlapen.vampirism.api.entity.ICaptureIgnore) java.awt(java.awt) TotemBaseBlock(de.teamlapen.vampirism.blocks.TotemBaseBlock) VReference(de.teamlapen.vampirism.api.VReference) MinecraftForge(net.minecraftforge.common.MinecraftForge) ExtendedCreature(de.teamlapen.vampirism.entity.ExtendedCreature) MathHelper(net.minecraft.util.math.MathHelper) ResourceLocation(net.minecraft.util.ResourceLocation) VampirismEventFactory(de.teamlapen.vampirism.util.VampirismEventFactory) TileEntity(net.minecraft.tileentity.TileEntity) LogManager(org.apache.logging.log4j.LogManager) VampirismEntity(de.teamlapen.vampirism.entity.VampirismEntity) WeightedRandom(net.minecraft.util.WeightedRandom) Heightmap(net.minecraft.world.gen.Heightmap) HunterBaseEntity(de.teamlapen.vampirism.entity.hunter.HunterBaseEntity) SanguinareEffectInstance(de.teamlapen.vampirism.effects.SanguinareEffectInstance) ConvertedVillagerEntity(de.teamlapen.vampirism.entity.converted.ConvertedVillagerEntity) VampireBaseEntity(de.teamlapen.vampirism.entity.vampire.VampireBaseEntity) FactionVillagerProfession(de.teamlapen.vampirism.entity.FactionVillagerProfession) List(java.util.List) ICaptureIgnore(de.teamlapen.vampirism.api.entity.ICaptureIgnore)

Aggregations

Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 UtilLib (de.teamlapen.lib.lib.util.UtilLib)1 VReference (de.teamlapen.vampirism.api.VReference)1 VampirismAPI (de.teamlapen.vampirism.api.VampirismAPI)1 IAggressiveVillager (de.teamlapen.vampirism.api.entity.IAggressiveVillager)1 ICaptureIgnore (de.teamlapen.vampirism.api.entity.ICaptureIgnore)1 ITaskMasterEntity (de.teamlapen.vampirism.api.entity.ITaskMasterEntity)1 IVillageCaptureEntity (de.teamlapen.vampirism.api.entity.IVillageCaptureEntity)1 IFaction (de.teamlapen.vampirism.api.entity.factions.IFaction)1 IFactionEntity (de.teamlapen.vampirism.api.entity.factions.IFactionEntity)1 IPlayableFaction (de.teamlapen.vampirism.api.entity.factions.IPlayableFaction)1 VampirismVillageEvent (de.teamlapen.vampirism.api.event.VampirismVillageEvent)1 ICaptureAttributes (de.teamlapen.vampirism.api.world.ICaptureAttributes)1 ITotem (de.teamlapen.vampirism.api.world.ITotem)1 TotemBaseBlock (de.teamlapen.vampirism.blocks.TotemBaseBlock)1 TotemTopBlock (de.teamlapen.vampirism.blocks.TotemTopBlock)1 VampirismConfig (de.teamlapen.vampirism.config.VampirismConfig)1 de.teamlapen.vampirism.core (de.teamlapen.vampirism.core)1 SanguinareEffect (de.teamlapen.vampirism.effects.SanguinareEffect)1