Search in sources :

Example 1 with ConstellationEffectProperties

use of hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties in project AstralSorcery by HellFirePvP.

the class CEffectBootes method playEffect.

@Override
public boolean playEffect(World world, BlockPos pos, ConstellationEffectProperties properties, @Nullable IMinorConstellation trait) {
    boolean didEffect = false;
    List<LivingEntity> entities = this.collectEntities(world, pos, properties);
    Collections.shuffle(entities);
    entities.subList(0, Math.min(25, entities.size()));
    for (LivingEntity entity : entities) {
        AnimalHelper.HerdableAnimal animal = AnimalHelper.getHandler(entity);
        if (animal == null) {
            continue;
        }
        if (properties.isCorrupted()) {
            entity.hurtResistantTime = 0;
            entity.addPotionEffect(new EffectInstance(EffectsAS.EFFECT_DROP_MODIFIER, 1000, 5));
            if (DamageUtil.attackEntityFrom(entity, CommonProxy.DAMAGE_SOURCE_STELLAR, 5_000)) {
                didEffect = true;
            }
            continue;
        }
        if (rand.nextFloat() < CONFIG.herdingChance.get()) {
            didEffect = MiscUtils.executeWithChunk(world, entity.getPosition(), didEffect, (didEffectFlag) -> {
                List<ItemStack> rawDrops = EntityUtils.generateLoot(entity, rand, CommonProxy.DAMAGE_SOURCE_STELLAR, null);
                List<ItemStack> drops = new ArrayList<>();
                rawDrops.forEach(drop -> {
                    for (int i = 0; i < drop.getCount(); i++) {
                        drops.add(ItemUtils.copyStackWithSize(drop, 1));
                    }
                });
                for (ItemStack drop : drops) {
                    if (rand.nextFloat() < CONFIG.herdingLootChance.get() && ItemUtils.dropItemNaturally(world, entity.getPosX(), entity.getPosY(), entity.getPosZ(), drop) != null) {
                        didEffectFlag = true;
                    }
                }
                return didEffectFlag;
            }, false);
            sendConstellationPing(world, Vector3.atEntityCorner(entity));
        }
    }
    return didEffect;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) TileRitualPedestal(hellfirepvp.astralsorcery.common.tile.TileRitualPedestal) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) DamageUtil(hellfirepvp.astralsorcery.common.util.DamageUtil) CommonProxy(hellfirepvp.astralsorcery.common.CommonProxy) ForgeConfigSpec(net.minecraftforge.common.ForgeConfigSpec) IMinorConstellation(hellfirepvp.astralsorcery.common.constellation.IMinorConstellation) ConstellationsAS(hellfirepvp.astralsorcery.common.lib.ConstellationsAS) PlayerAffectionFlags(hellfirepvp.astralsorcery.common.event.PlayerAffectionFlags) Dist(net.minecraftforge.api.distmarker.Dist) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) EffectInstance(net.minecraft.potion.EffectInstance) ILocatable(hellfirepvp.astralsorcery.common.util.block.ILocatable) EffectTemplatesAS(hellfirepvp.astralsorcery.client.lib.EffectTemplatesAS) MiscUtils(hellfirepvp.astralsorcery.common.util.MiscUtils) AnimalHelper(hellfirepvp.astralsorcery.common.auxiliary.AnimalHelper) ColorsAS(hellfirepvp.astralsorcery.common.lib.ColorsAS) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) VFXAlphaFunction(hellfirepvp.astralsorcery.client.effect.function.VFXAlphaFunction) LivingEntity(net.minecraft.entity.LivingEntity) World(net.minecraft.world.World) BlockPos(net.minecraft.util.math.BlockPos) ConstellationEffectEntityCollect(hellfirepvp.astralsorcery.common.constellation.effect.base.ConstellationEffectEntityCollect) EffectHelper(hellfirepvp.astralsorcery.client.effect.handler.EffectHelper) EntityUtils(hellfirepvp.astralsorcery.common.util.entity.EntityUtils) List(java.util.List) VFXColorFunction(hellfirepvp.astralsorcery.client.effect.function.VFXColorFunction) EffectsAS(hellfirepvp.astralsorcery.common.lib.EffectsAS) ItemUtils(hellfirepvp.astralsorcery.common.util.item.ItemUtils) Collections(java.util.Collections) ConstellationEffectProperties(hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties) ArrayList(java.util.ArrayList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) AnimalHelper(hellfirepvp.astralsorcery.common.auxiliary.AnimalHelper) EffectInstance(net.minecraft.potion.EffectInstance)

Example 2 with ConstellationEffectProperties

use of hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties in project AstralSorcery by HellFirePvP.

the class CEffectBootes method playClientEffect.

@Override
@OnlyIn(Dist.CLIENT)
public void playClientEffect(World world, BlockPos pos, TileRitualPedestal pedestal, float alphaMultiplier, boolean extended) {
    if (rand.nextInt(3) == 0) {
        ConstellationEffectProperties prop = this.createProperties(pedestal.getMirrorCount());
        Vector3 playAt = new Vector3(pos).add(0.5, 0.5, 0.5).add(rand.nextFloat() * (prop.getSize() / 2F) * (rand.nextBoolean() ? 1 : -1), rand.nextFloat() * (prop.getSize() / 4F), rand.nextFloat() * (prop.getSize() / 2F) * (rand.nextBoolean() ? 1 : -1));
        Vector3 motion = Vector3.random().multiply(0.015);
        EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(playAt).setMotion(motion).color(VFXColorFunction.constant(ColorsAS.CONSTELLATION_BOOTES)).alpha(VFXAlphaFunction.FADE_OUT).setScaleMultiplier(0.5F).setMaxAge(30 + rand.nextInt(20));
        EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(playAt).setMotion(motion.clone().negate()).color(VFXColorFunction.constant(ColorsAS.CONSTELLATION_BOOTES)).alpha(VFXAlphaFunction.FADE_OUT).setScaleMultiplier(0.5F).setMaxAge(30 + rand.nextInt(20));
    }
}
Also used : ConstellationEffectProperties(hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 3 with ConstellationEffectProperties

use of hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties in project AstralSorcery by HellFirePvP.

the class CEffectFornax method playEffect.

@Override
public boolean playEffect(World world, BlockPos pos, ConstellationEffectProperties properties, @Nullable IMinorConstellation trait) {
    if (!(world instanceof ServerWorld)) {
        return false;
    }
    Consumer<ItemStack> dropResult = stack -> ItemUtils.dropItemNaturally(world, pos.getX() + 0.5, pos.getY() + 1.2, pos.getZ() + 0.5, stack);
    return this.peekNewPosition(world, pos, properties).mapLeft(newEntry -> {
        BlockPos at = newEntry.getPos();
        if (properties.isCorrupted()) {
            WorldFreezingRecipe freezingRecipe = WorldFreezingRegistry.INSTANCE.getRecipeFor(world, at);
            if (freezingRecipe != null) {
                freezingRecipe.doOutput(world, at, world.getBlockState(at), dropResult);
                return true;
            }
            sendConstellationPing(world, new Vector3(at).add(0.5, 0.5, 0.5));
            return false;
        }
        WorldMeltableRecipe meltRecipe = WorldMeltableRegistry.INSTANCE.getRecipeFor(world, at);
        if (meltRecipe != null) {
            meltRecipe.doOutput(world, at, world.getBlockState(at), dropResult);
            return true;
        }
        sendConstellationPing(world, new Vector3(at).add(0.5, 0.5, 0.5));
        return false;
    }).left().orElse(false);
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) TileRitualPedestal(hellfirepvp.astralsorcery.common.tile.TileRitualPedestal) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) ServerWorld(net.minecraft.world.server.ServerWorld) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) BlockPositionGenerator(hellfirepvp.astralsorcery.common.util.block.iterator.BlockPositionGenerator) WorldMeltableRegistry(hellfirepvp.astralsorcery.common.crafting.nojson.WorldMeltableRegistry) ForgeConfigSpec(net.minecraftforge.common.ForgeConfigSpec) IMinorConstellation(hellfirepvp.astralsorcery.common.constellation.IMinorConstellation) CompoundNBT(net.minecraft.nbt.CompoundNBT) ConstellationsAS(hellfirepvp.astralsorcery.common.lib.ConstellationsAS) WorldFreezingRegistry(hellfirepvp.astralsorcery.common.crafting.nojson.WorldFreezingRegistry) PlayerAffectionFlags(hellfirepvp.astralsorcery.common.event.PlayerAffectionFlags) Dist(net.minecraftforge.api.distmarker.Dist) ItemStack(net.minecraft.item.ItemStack) BlockRandomPositionGenerator(hellfirepvp.astralsorcery.common.util.block.iterator.BlockRandomPositionGenerator) ILocatable(hellfirepvp.astralsorcery.common.util.block.ILocatable) EffectTemplatesAS(hellfirepvp.astralsorcery.client.lib.EffectTemplatesAS) MiscUtils(hellfirepvp.astralsorcery.common.util.MiscUtils) WorldFreezingRecipe(hellfirepvp.astralsorcery.common.crafting.nojson.freezing.WorldFreezingRecipe) ColorsAS(hellfirepvp.astralsorcery.common.lib.ColorsAS) Nonnull(javax.annotation.Nonnull) WorldMeltableRecipe(hellfirepvp.astralsorcery.common.crafting.nojson.meltable.WorldMeltableRecipe) Nullable(javax.annotation.Nullable) VFXAlphaFunction(hellfirepvp.astralsorcery.client.effect.function.VFXAlphaFunction) World(net.minecraft.world.World) BlockPos(net.minecraft.util.math.BlockPos) EffectHelper(hellfirepvp.astralsorcery.client.effect.handler.EffectHelper) ListEntries(hellfirepvp.astralsorcery.common.constellation.effect.base.ListEntries) java.awt(java.awt) Consumer(java.util.function.Consumer) VFXColorFunction(hellfirepvp.astralsorcery.client.effect.function.VFXColorFunction) ItemUtils(hellfirepvp.astralsorcery.common.util.item.ItemUtils) ConstellationEffectProperties(hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties) CEffectAbstractList(hellfirepvp.astralsorcery.common.constellation.effect.base.CEffectAbstractList) WorldMeltableRecipe(hellfirepvp.astralsorcery.common.crafting.nojson.meltable.WorldMeltableRecipe) BlockPos(net.minecraft.util.math.BlockPos) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) ItemStack(net.minecraft.item.ItemStack) WorldFreezingRecipe(hellfirepvp.astralsorcery.common.crafting.nojson.freezing.WorldFreezingRecipe)

Example 4 with ConstellationEffectProperties

use of hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties in project AstralSorcery by HellFirePvP.

the class CEffectMineralis method playClientEffect.

@Override
@OnlyIn(Dist.CLIENT)
public void playClientEffect(World world, BlockPos pos, TileRitualPedestal pedestal, float alphaMultiplier, boolean extended) {
    ConstellationEffectProperties prop = this.createProperties(pedestal.getMirrorCount());
    if (rand.nextFloat() < 0.6F) {
        Color c = MiscUtils.eitherOf(rand, () -> ColorsAS.CONSTELLATION_MINERALIS, () -> ColorsAS.CONSTELLATION_MINERALIS.brighter());
        Vector3 at = Vector3.random().normalize().multiply(rand.nextFloat() * prop.getSize()).add(pos).add(0.5, 0.5, 0.5);
        EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(at).alpha(VFXAlphaFunction.FADE_OUT).setMotion(Vector3.random().multiply(0.05F)).color(VFXColorFunction.constant(c)).setScaleMultiplier(0.5F + rand.nextFloat() * 0.25F).setMaxAge(50 + rand.nextInt(40));
    }
}
Also used : ConstellationEffectProperties(hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 5 with ConstellationEffectProperties

use of hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties in project AstralSorcery by HellFirePvP.

the class CEffectPelotrio method playClientEffect.

@Override
@OnlyIn(Dist.CLIENT)
public void playClientEffect(World world, BlockPos pos, TileRitualPedestal pedestal, float alphaMultiplier, boolean extended) {
    ConstellationEffectProperties prop = this.createProperties(pedestal.getMirrorCount());
    if (rand.nextFloat() < 0.2F) {
        Vector3 at = Vector3.random().normalize().multiply(rand.nextFloat() * prop.getSize()).add(pos).add(0.5, 0.5, 0.5);
        EffectHelper.spawnSource(new FXOrbitalPelotrio(at).setOrbitAxis(Vector3.random()).setOrbitRadius(0.8 + rand.nextFloat() * 0.7).setTicksPerRotation(20 + rand.nextInt(20)));
    }
}
Also used : ConstellationEffectProperties(hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties) FXOrbitalPelotrio(hellfirepvp.astralsorcery.client.effect.source.orbital.FXOrbitalPelotrio) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Aggregations

ConstellationEffectProperties (hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties)13 Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)11 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)10 IMinorConstellation (hellfirepvp.astralsorcery.common.constellation.IMinorConstellation)5 World (net.minecraft.world.World)5 TileRitualPedestal (hellfirepvp.astralsorcery.common.tile.TileRitualPedestal)4 MiscUtils (hellfirepvp.astralsorcery.common.util.MiscUtils)4 Nullable (javax.annotation.Nullable)4 ItemStack (net.minecraft.item.ItemStack)4 VFXColorFunction (hellfirepvp.astralsorcery.client.effect.function.VFXColorFunction)3 EffectHelper (hellfirepvp.astralsorcery.client.effect.handler.EffectHelper)3 EffectTemplatesAS (hellfirepvp.astralsorcery.client.lib.EffectTemplatesAS)3 PlayerAffectionFlags (hellfirepvp.astralsorcery.common.event.PlayerAffectionFlags)3 ColorsAS (hellfirepvp.astralsorcery.common.lib.ColorsAS)3 ConstellationsAS (hellfirepvp.astralsorcery.common.lib.ConstellationsAS)3 ILocatable (hellfirepvp.astralsorcery.common.util.block.ILocatable)3 ItemUtils (hellfirepvp.astralsorcery.common.util.item.ItemUtils)3 Nonnull (javax.annotation.Nonnull)3 LivingEntity (net.minecraft.entity.LivingEntity)3 CompoundNBT (net.minecraft.nbt.CompoundNBT)3