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;
}
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));
}
}
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);
}
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));
}
}
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)));
}
}
Aggregations