Skip to content

Commit

Permalink
Weeping well radiance test
Browse files Browse the repository at this point in the history
  • Loading branch information
SammySemicolon committed Oct 29, 2023
1 parent 7b9c58c commit 859028a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.daemon=false
# Dependency Version
minecraftVersion=1.18.2
forgeVersion=40.2.0
lodestoneVersion=1.4.2.496
lodestoneVersion=1.4.2.501
forgegradleVersion=5.1.53
mixingradleVersion=0.7-SNAPSHOT
librarianVersion=1.+
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sammy.malum.visual_effects;

import com.sammy.malum.common.block.curiosities.weeping_well.*;
import com.sammy.malum.common.entity.nitrate.*;
import com.sammy.malum.registry.client.*;
import net.minecraft.core.*;
import net.minecraft.world.level.*;
Expand All @@ -19,12 +20,19 @@

import java.awt.*;
import java.util.*;
import java.util.List;
import java.util.function.*;

import static com.sammy.malum.common.entity.nitrate.VividNitrateEntity.COLOR_FUNCTION;
import static com.sammy.malum.visual_effects.SpiritLightSpecs.spiritLightSpecs;

public class WeepingWellParticleEffects {

public static final List<Color> RADIANT_COLORS = List.of(
new Color(249, 206, 77),
new Color(145, 42, 247),
new Color(48, 208, 242));

private static final VoxelShape WELL_SHAPE = Block.box(-16.0D, 11.0D, -16.0D, 32.0D, 13.0D, 32.0D);
private static final GenericParticleData SMOKE_TRANSPARENCY = GenericParticleData.create(0, 0.2f, 0f).setEasing(Easing.SINE_IN, Easing.SINE_OUT).build();

Expand Down Expand Up @@ -73,36 +81,63 @@ public static void passiveWeepingWellParticles(VoidConduitBlockEntity voidCondui
}
}


public static void radiantWeepingWellParticles(VoidConduitBlockEntity voidConduit) {
Level level = voidConduit.getLevel();
final BlockPos blockPos = voidConduit.getBlockPos();
Random rand = level.random;
int lifetime = RandomHelper.randomBetween(rand, 40, 80);
float xMotion = 0;
float yMotion = RandomHelper.randomBetween(rand, -0.05f, 0.05f);
float zMotion = 0;
Vec3 motion = new Vec3(xMotion, yMotion, zMotion);
DirectionalParticleBuilder.create(ParticleRegistry.SQUARE)
.setDirection(motion.normalize().scale(Math.PI*2))
.setLifetime(lifetime)
.setMotion(motion)
.setRenderType(LodestoneWorldParticleRenderType.LUMITRANSPARENT)
.spawn(level, blockPos.getX(), blockPos.getY()+4, blockPos.getZ());
Color color = RADIANT_COLORS.get(((int) level.getGameTime() % 18) / 6);
final BlockPos blockPos = voidConduit.getBlockPos();
final ColorParticleData colorData = ColorParticleData.create(color, color.darker()).setCoefficient(0.5f).build();

if (level.getGameTime() % 6L == 0) {
final Consumer<LodestoneWorldParticleActor> slowDown = p -> p.setParticleMotion(p.getParticleSpeed().scale(0.95f));
int lifetime = RandomHelper.randomBetween(rand, 100, 120);
float yMotion = RandomHelper.randomBetween(rand, 0.01f, 0.02f);
Vec3 motion = new Vec3(0f, yMotion, 0f);
DirectionalParticleBuilder.create(ParticleRegistry.SQUARE)
.setTransparencyData(GenericParticleData.create(0.2f, 0.5f, 0f).setEasing(Easing.CUBIC_OUT, Easing.EXPO_IN).build())
.setScaleData(GenericParticleData.create(0.1f, RandomHelper.randomBetween(rand, 1.85f, 2f)).setEasing(Easing.SINE_OUT).setCoefficient(RandomHelper.randomBetween(rand, 1f, 1.5f)).build())
.setColorData(colorData)
.setLifetime(lifetime)
.setMotion(motion)
.setDirection(motion.normalize())
.enableNoClip()
.addActor(slowDown)
.spawn(level, blockPos.getX() + 0.5f, blockPos.getY() + 0.75f, blockPos.getZ() + 0.5f);
}

final float acceleration = RandomHelper.randomBetween(rand, 0.002f, 0.02f);
final long gameTime = level.getGameTime();
final Consumer<LodestoneWorldParticleActor> behavior = p -> {
if (level.getGameTime() < gameTime + 5) {
p.setParticleMotion(p.getParticleSpeed().add(0, acceleration, 0));
}
};
if (level.getGameTime() % 2 == 0) {
int rotation = (int) (level.getGameTime() / 2f % 16);
Vec3 offsetPosition = DataHelper.rotatingRadialOffset(new Vec3(blockPos.getX() + 0.5f, blockPos.getY() + 0.75f, blockPos.getZ() + 0.5f), 1.1f, rotation, 16, voidConduit.getLevel().getGameTime(), 640);
var lightSpecs = weepingWellSpecs(level, offsetPosition, colorData, LodestoneWorldParticleRenderType.ADDITIVE);
lightSpecs.getBuilder().addActor(behavior);
lightSpecs.getBloomBuilder().addActor(behavior);
lightSpecs.spawnParticles();
}
}

public static ParticleEffectSpawner<WorldParticleBuilder> weepingWellSpecs(Level level, Vec3 pos) {
Random rand = level.random;
Color color = getWeepingWellSmokeColor(rand);
ColorParticleData colorData = ColorParticleData.create(color, color.darker()).setCoefficient(0.5f).build();
return weepingWellSpecs(level, pos, colorData, LodestoneWorldParticleRenderType.LUMITRANSPARENT);
}
public static ParticleEffectSpawner<WorldParticleBuilder> weepingWellSpecs(Level level, Vec3 pos, ColorParticleData colorData, LodestoneWorldParticleRenderType renderType) {
Random rand = level.random;
var lightSpecs = spiritLightSpecs(level, pos, colorData, colorData, ParticleRegistry.LIGHT_SPEC_SMALL);
lightSpecs.getBuilder().act(b -> b
.setRenderType(LodestoneWorldParticleRenderType.LUMITRANSPARENT)
.setRenderType(renderType)
.multiplyLifetime(6f)
.modifyData(b::getTransparencyData, d -> d.multiplyValue(RandomHelper.randomBetween(rand, 0.75f, 1f)))
.modifyData(b::getScaleData, d -> d.multiplyValue(RandomHelper.randomBetween(rand, 1.5f, 3.5f))));
lightSpecs.getBloomBuilder().act(b -> b
.setRenderType(LodestoneWorldParticleRenderType.LUMITRANSPARENT)
.setRenderType(renderType)
.multiplyLifetime(6f)
.setTransparencyData(GenericParticleData.create(0f, 0.75f, 0.25f).build())
.setDiscardFunction(SimpleParticleOptions.ParticleDiscardFunctionType.ENDING_CURVE_INVISIBLE)
Expand Down

0 comments on commit 859028a

Please sign in to comment.