use of hellfirepvp.astralsorcery.client.effect.vfx.FXSpritePlane in project AstralSorcery by HellFirePvP.
the class FountainEffectVortex method tickEffects.
@OnlyIn(Dist.CLIENT)
private void tickEffects(TileFountain fountain, VortexContext ctx, int operationTick, OperationSegment currentSegment) {
if (currentSegment.isLaterOrEqualTo(OperationSegment.STARTUP)) {
FXSpritePlane sprite = (FXSpritePlane) ctx.fountainSprite;
if (sprite == null) {
sprite = EffectHelper.of(EffectTemplatesAS.TEXTURE_SPRITE).spawn(new Vector3(fountain).add(0.5, 0.5, 0.5)).setAxis(Vector3.RotAxis.Y_AXIS).setNoRotation(45).setSprite(SpritesAS.SPR_FOUNTAIN_VORTEX).setAlphaMultiplier(1F).alpha((fx, alphaIn, pTicks) -> this.getSegmentPercent(OperationSegment.STARTUP, fountain.getTickActiveFountainEffect())).setScaleMultiplier(5.5F).refresh(RefreshFunction.tileExistsAnd(fountain, (tile, fx) -> tile.getCurrentEffect() == this));
} else if (sprite.isRemoved() || sprite.canRemove()) {
EffectHelper.refresh(sprite, EffectTemplatesAS.TEXTURE_SPRITE);
}
ctx.fountainSprite = sprite;
}
BlockPos fountainPos = fountain.getPos();
float segmentPercent = getSegmentPercent(currentSegment, operationTick);
switch(currentSegment) {
case STARTUP:
playFountainVortexParticles(fountainPos, segmentPercent);
playFountainArcs(fountainPos, segmentPercent);
playCoreParticles(fountainPos, segmentPercent);
break;
case PREPARATION:
playFountainArcs(fountainPos, 1F - segmentPercent);
playFountainVortexParticles(fountainPos, 1F - segmentPercent);
playCoreParticles(fountainPos, 1F - segmentPercent * 2F);
playCorePrimerParticles(fountainPos, segmentPercent);
break;
case RUNNING:
playFountainVortexParticles(fountainPos, 0.2F);
playFountainArcs(fountainPos, 0.6F);
playFountainVortexLowerParticles(fountainPos);
playVortexEffects(fountainPos, fountain, ctx);
break;
}
}
use of hellfirepvp.astralsorcery.client.effect.vfx.FXSpritePlane in project AstralSorcery by HellFirePvP.
the class EffectLuminescenceFlare method onTick.
@Override
@OnlyIn(Dist.CLIENT)
public void onTick(TileAltar altar, ActiveSimpleAltarRecipe.CraftingState state) {
ActiveSimpleAltarRecipe recipe = altar.getActiveRecipe();
if (recipe != null && state == ActiveSimpleAltarRecipe.CraftingState.ACTIVE) {
ResourceLocation recipeName = recipe.getRecipeToCraft().getId();
FXSpritePlane spr = recipe.getEffectContained(INDEX_CRAFT_FLARE, i -> {
return EffectHelper.of(EffectTemplatesAS.TEXTURE_SPRITE).spawn(new Vector3(altar).add(0.5, 0.04, 0.5)).setSprite(SpritesAS.SPR_CRAFT_FLARE).setAxis(Vector3.RotAxis.Y_AXIS).setNoRotation(0).color(VFXColorFunction.constant(ColorsAS.EFFECT_CRAFT_FLARE)).alpha(VFXAlphaFunction.fadeIn(30)).setScaleMultiplier(9F).setAlphaMultiplier(0.65F).refresh(RefreshFunction.tileExistsAnd(altar, (tAltar, fx) -> tAltar.getActiveRecipe() != null && tAltar.getActiveRecipe().getState() == ActiveSimpleAltarRecipe.CraftingState.ACTIVE && recipeName.equals(tAltar.getActiveRecipe().getRecipeToCraft().getId())));
});
EffectHelper.refresh(spr, EffectTemplatesAS.TEXTURE_SPRITE);
}
}
use of hellfirepvp.astralsorcery.client.effect.vfx.FXSpritePlane in project AstralSorcery by HellFirePvP.
the class FountainEffectLiquid method tickEffects.
@OnlyIn(Dist.CLIENT)
private void tickEffects(TileFountain fountain, LiquidContext ctx, int operationTick, OperationSegment currentSegment) {
if (currentSegment.isLaterOrEqualTo(OperationSegment.STARTUP)) {
FXSpritePlane sprite = (FXSpritePlane) ctx.fountainSprite;
if (sprite == null) {
sprite = EffectHelper.of(EffectTemplatesAS.TEXTURE_SPRITE).spawn(new Vector3(fountain).add(0.5, 0.5, 0.5)).setAxis(Vector3.RotAxis.Y_AXIS).setNoRotation(45).setSprite(SpritesAS.SPR_FOUNTAIN_LIQUID).setAlphaMultiplier(1F).alpha((fx, alphaIn, pTicks) -> this.getSegmentPercent(OperationSegment.STARTUP, fountain.getTickActiveFountainEffect())).setScaleMultiplier(5.5F).refresh(RefreshFunction.tileExistsAnd(fountain, (tile, fx) -> tile.getCurrentEffect() == this));
} else if (sprite.isRemoved() || sprite.canRemove()) {
EffectHelper.refresh(sprite, EffectTemplatesAS.TEXTURE_SPRITE);
}
ctx.fountainSprite = sprite;
}
BlockPos fountainPos = fountain.getPos();
float segmentPercent = getSegmentPercent(currentSegment, operationTick);
switch(currentSegment) {
case STARTUP:
playFountainVortexParticles(fountainPos, segmentPercent);
playFountainArcs(fountainPos, segmentPercent);
break;
case PREPARATION:
playFountainArcs(fountainPos, 1F - segmentPercent);
playFountainVortexParticles(fountainPos, 1F - segmentPercent);
playDigPreparation(fountainPos, segmentPercent);
break;
case RUNNING:
playFountainVortexParticles(fountainPos, 0.2F);
playFountainArcs(fountainPos, 0.6F);
playDigParticles(fountainPos);
if (fountain.getTicksExisted() % 40 == 0) {
playDigLightbeam(fountainPos);
}
break;
}
}
use of hellfirepvp.astralsorcery.client.effect.vfx.FXSpritePlane in project AstralSorcery by HellFirePvP.
the class TileRefractionTable method playEngravingEffects.
@OnlyIn(Dist.CLIENT)
private void playEngravingEffects() {
if (this.runTick <= 0) {
return;
}
if (this.effectHalo != null && ((FXSpritePlane) this.effectHalo).isRemoved()) {
EffectHelper.refresh((FXSpritePlane) this.effectHalo, EffectTemplatesAS.TEXTURE_SPRITE);
}
if (this.effectHalo == null) {
this.effectHalo = EffectHelper.of(EffectTemplatesAS.TEXTURE_SPRITE).spawn(new Vector3(this).add(0.5, 0.8, 0.5)).setSprite(SpritesAS.SPR_HALO_INFUSION).setAxis(Vector3.RotAxis.Y_AXIS).setNoRotation(0).setScaleMultiplier(0.8F).setAlphaMultiplier(0.8F).alpha(((fx, alpha, pTicks) -> MathHelper.clamp(alpha * getRunProgress(), 0F, 1F))).refresh(RefreshFunction.tileExistsAnd(this, (thisTile, fx) -> thisTile.getRunProgress() > 0));
}
Vector3 offset = new Vector3(-5.0 / 16.0, 1.505, -3.0 / 16.0);
int random = rand.nextInt(ColorsAS.REFRACTION_TABLE_COLORS.length);
if (random >= ColorsAS.REFRACTION_TABLE_COLORS.length / 2) {
// 0-5 is left, 6-11 is right
offset.addX(24.0 / 16.0);
}
offset.addZ((random % (ColorsAS.REFRACTION_TABLE_COLORS.length / 2)) * (4.0 / 16.0));
offset.add(rand.nextFloat() * 0.1, 0, rand.nextFloat() * 0.1).add(pos);
Color color = ColorsAS.REFRACTION_TABLE_COLORS[random];
EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(offset).setGravityStrength(-0.002F).setScaleMultiplier(0.15F + rand.nextFloat() * 0.1F).alpha(VFXAlphaFunction.FADE_OUT).color(VFXColorFunction.constant(color)).setMaxAge(30 + rand.nextInt(30));
if (rand.nextFloat() < (getRunProgress() * 2F)) {
Vector3 target = new Vector3(this).add(0.5, 0.9, 0.5);
EffectHelper.of(EffectTemplatesAS.LIGHTNING).spawn(offset).makeDefault(target).color(VFXColorFunction.constant(color));
FXFacingParticle p = EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(offset).setScaleMultiplier(0.15F + rand.nextFloat() * 0.1F).alpha(VFXAlphaFunction.proximity(target::clone, 1F)).color(VFXColorFunction.constant(color)).setMaxAge(45);
Vector3 mov = target.clone().subtract(offset).normalize().multiply(0.05 * rand.nextFloat());
p.setMotion(mov);
}
if (rand.nextInt(3) == 0) {
EffectHelper.of(EffectTemplatesAS.LIGHTBEAM).spawn(offset).setup(offset.clone().addY(0.56F + rand.nextFloat() * 0.2F), 0.25F, 0.25F).color(VFXColorFunction.constant(color));
}
if (rand.nextInt(4) == 0) {
Color beamColor = MiscUtils.eitherOf(rand, ColorsAS.CONSTELLATION_TYPE_MAJOR, ColorsAS.CONSTELLATION_TYPE_WEAK, ColorsAS.CONSTELLATION_TYPE_MINOR);
Vector3 beamOffset = new Vector3(this).add(0.1 + rand.nextFloat() * 0.8, 0.8, 0.1 + rand.nextFloat() * 0.8F);
EffectHelper.of(EffectTemplatesAS.LIGHTBEAM).spawn(beamOffset).setup(beamOffset.clone().addY(1 + rand.nextFloat() * 0.5), 0.5F, 0.5F).color(VFXColorFunction.constant(beamColor)).setMaxAge(25 + rand.nextInt(5));
}
}
use of hellfirepvp.astralsorcery.client.effect.vfx.FXSpritePlane in project AstralSorcery by HellFirePvP.
the class TileRitualPedestal method playEffects.
// =========================================================================================
// Client effects
// =========================================================================================
@OnlyIn(Dist.CLIENT)
private void playEffects() {
float alphaDaytime = DayTimeHelper.getCurrentDaytimeDistribution(getWorld());
alphaDaytime *= 0.8F;
float percRunning = this.effectWork.getAsPercentage();
int chance = 15 + (int) ((1F - percRunning) * 50);
if (rand.nextInt(chance) == 0) {
Vector3 from = new Vector3(this).add(0.5, 0.05, 0.5);
MiscUtils.applyRandomOffset(from, rand, 0.05F);
EffectHelper.of(EffectTemplatesAS.LIGHTBEAM).setOwner(this.ownerUUID).spawn(from).setup(from.clone().addY(6), 1.5F, 1.5F).setAlphaMultiplier(0.5F + (0.5F * alphaDaytime)).setMaxAge(64);
}
if (this.ritualLinkTo != null) {
if (rand.nextBoolean()) {
Vector3 at = new Vector3(this).add(0, 0.1, 0);
at.add(rand.nextFloat() * 0.5 + 0.25, 0, rand.nextFloat() * 0.5 + 0.25);
EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).setOwner(this.ownerUUID).spawn(at).setAlphaMultiplier(0.7F).color(VFXColorFunction.WHITE).setMotion(Vector3.positiveYRandom(rand).addY(2).normalize().multiply(0.4F)).setScaleMultiplier(0.2F + rand.nextFloat() * 0.15F).motion(VFXMotionController.target(() -> new Vector3(this).add(RITUAL_ANCHOR_OFFEST).add(0.5, 0.5, 0.5), 0.1F)).setMaxAge(30 + rand.nextInt(50));
}
}
List<BlockPos> activeMirrors = this.offsetMirrors.entrySet().stream().filter(Map.Entry::getValue).map(Map.Entry::getKey).collect(Collectors.toList());
IWeakConstellation ritualConstellation = getRitualConstellation();
if (this.working && ritualConstellation != null) {
if (!activeMirrors.isEmpty() && DayTimeHelper.isNight(getWorld())) {
if (rand.nextInt(chance * 2) == 0) {
Vector3 from = new Vector3(this).add(0.5, 0.1, 0.5);
MiscUtils.applyRandomOffset(from, rand, 2F);
from.setY(getPos().getY() - 0.6 + 1 * rand.nextFloat() * (rand.nextBoolean() ? 1 : -1));
EffectHelper.of(EffectTemplatesAS.LIGHTBEAM).setOwner(this.ownerUUID).spawn(from).setup(from.clone().addY(5 + rand.nextInt(3)), 1.3F, 1.3F).setAlphaMultiplier(alphaDaytime).color(VFXColorFunction.constant(ritualConstellation.getConstellationColor())).setMaxAge(64);
}
}
if (this.ritualHaloEffect == null) {
this.ritualHaloEffect = EffectHelper.of(EffectTemplatesAS.TEXTURE_SPRITE).spawn(new Vector3(this).add(0.5, 0.05, 0.5)).setSprite(SpritesAS.SPR_HALO_RITUAL).setAxis(Vector3.RotAxis.Y_AXIS).setNoRotation(25).setScaleMultiplier(6.5F).refresh(RefreshFunction.tileExistsAnd(this, (tile, effect) -> tile.isWorking() && !tile.getCurrentCrystal().isEmpty()));
}
if (this.ritualHaloEffect != null) {
FXSpritePlane effectPlane = ((FXSpritePlane) this.ritualHaloEffect);
EffectHelper.refresh(effectPlane, EffectTemplatesAS.TEXTURE_SPRITE);
float dayTimeMul = DayTimeHelper.getCurrentDaytimeDistribution(this.getWorld());
effectPlane.setAlphaMultiplier(Math.max(0.05F, dayTimeMul * 0.75F));
}
Vector3 offset = Vector3.random().setY(0).normalize().multiply(rand.nextFloat() * 4 * (rand.nextBoolean() ? 1 : -1));
EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).setOwner(this.ownerUUID).spawn(new Vector3(this).add(0.5, 0.02, 0.5).add(offset)).setAlphaMultiplier(1F).setGravityStrength(-0.001F).color(VFXColorFunction.constant(ritualConstellation.getConstellationColor())).alpha(VFXAlphaFunction.FADE_OUT).setScaleMultiplier(0.3F + rand.nextFloat() * 0.15F).setMaxAge(25 + rand.nextInt(15));
if (this.clientEffectInstance != null && !this.clientEffectInstance.getConstellation().equals(ritualConstellation)) {
this.clientEffectInstance = null;
}
if (this.clientEffectInstance == null) {
this.clientEffectInstance = ConstellationEffectRegistry.createInstance(ILocatable.fromPos(getPos()), ritualConstellation);
}
if (this.clientEffectInstance != null) {
clientEffectInstance.playClientEffect(getWorld(), getPos(), this, percRunning, this.isFullyEnhanced());
if (this.ritualLinkTo != null && getWorld().isBlockPresent(this.ritualLinkTo)) {
clientEffectInstance.playClientEffect(getWorld(), this.ritualLinkTo, this, percRunning, this.isFullyEnhanced());
}
}
CrystalAttributes prop = this.getAttributes();
if (prop != null && rand.nextInt(3) == 0) {
for (int i = 0; i < 3; i++) {
Vector3 at = new Vector3(this).add(0.5, 1.35, 0.5).add(Vector3.random().multiply(0.6F));
Vector3 motion = Vector3.random().multiply(0.02F);
EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).setOwner(this.ownerUUID).spawn(at).setMotion(motion).setAlphaMultiplier(1F).color(VFXColorFunction.constant(ritualConstellation.getConstellationColor())).alpha(VFXAlphaFunction.FADE_OUT).setScaleMultiplier(0.15F + rand.nextFloat() * 0.05F).setMaxAge(16 + rand.nextInt(15));
}
if (rand.nextInt(3) == 0) {
Vector3 from = new Vector3(this).add(0.5, 1.2, 0.5);
Vector3 to;
if (activeMirrors.isEmpty()) {
to = new Vector3(this).add(0.5, 3.5 + rand.nextFloat() * 2.5, 0.5);
} else {
BlockPos mirror = MiscUtils.getRandomEntry(activeMirrors, rand).add(this.getPos());
to = new Vector3(mirror).add(0.5, 0.5, 0.5);
}
EffectHelper.of(EffectTemplatesAS.LIGHTNING).setOwner(this.ownerUUID).spawn(from).makeDefault(to).color(VFXColorFunction.constant(ritualConstellation.getConstellationColor()));
}
}
}
for (BlockPos mirror : this.offsetMirrors.keySet()) {
if (ticksExisted % 32 == 0) {
Vector3 source = new Vector3(this).add(0.5, 0.9, 0.5);
Vector3 to = new Vector3(this).add(mirror).add(0.5, 0.5, 0.5);
EffectHelper.of(EffectTemplatesAS.LIGHTBEAM).setOwner(this.ownerUUID).spawn(source).setup(to, 0.8F, 0.8F);
if (this.ritualLinkTo != null && this.offsetMirrors.get(mirror)) {
source = new Vector3(this).add(RITUAL_ANCHOR_OFFEST).add(0.5, 0.5, 0.5);
EffectHelper.of(EffectTemplatesAS.LIGHTBEAM).setOwner(this.ownerUUID).spawn(source).setup(to, 0.8F, 0.8F).color(VFXColorFunction.random());
}
}
}
}
Aggregations