Skip to content

Commit

Permalink
Radiance
Browse files Browse the repository at this point in the history
  • Loading branch information
SammySemicolon committed Nov 1, 2023
1 parent 8a85e21 commit 9053318
Show file tree
Hide file tree
Showing 14 changed files with 313 additions and 155 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.501
lodestoneVersion=1.4.2.504
forgegradleVersion=5.1.53
mixingradleVersion=0.7-SNAPSHOT
librarianVersion=1.+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.sammy.malum.registry.common.block.*;
import com.sammy.malum.registry.common.item.*;
import com.sammy.malum.visual_effects.*;
import com.sammy.malum.visual_effects.networked.*;
import com.sammy.malum.visual_effects.networked.data.*;
import net.minecraft.core.*;
import net.minecraft.nbt.*;
Expand All @@ -13,27 +14,13 @@
import net.minecraft.util.*;
import net.minecraft.world.entity.item.*;
import net.minecraft.world.item.*;
import net.minecraft.world.level.*;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.*;
import net.minecraft.world.phys.*;
import net.minecraft.world.phys.shapes.*;
import team.lodestar.lodestone.helpers.*;
import team.lodestar.lodestone.setup.*;
import team.lodestar.lodestone.systems.blockentity.*;
import team.lodestar.lodestone.systems.easing.*;
import team.lodestar.lodestone.systems.particle.*;
import team.lodestar.lodestone.systems.particle.builder.*;
import team.lodestar.lodestone.systems.particle.data.*;
import team.lodestar.lodestone.systems.particle.data.color.*;
import team.lodestar.lodestone.systems.particle.data.spin.*;
import team.lodestar.lodestone.systems.particle.render_types.*;
import team.lodestar.lodestone.systems.particle.world.*;

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

public class VoidConduitBlockEntity extends LodestoneBlockEntity {

Expand Down Expand Up @@ -79,6 +66,9 @@ public void load(CompoundTag compound) {
@Override
public void tick() {
super.tick();
if (lingeringRadiance > 0) {
lingeringRadiance--;
}
if (level instanceof ServerLevel serverLevel) {
if (serverLevel.getGameTime() % 100L == 0) {
level.playSound(null, worldPosition, SoundRegistry.UNCANNY_VALLEY.get(), SoundSource.HOSTILE, 1f, Mth.nextFloat(level.getRandom(), 0.55f, 1.75f));
Expand All @@ -93,6 +83,7 @@ public void tick() {
progress++;
if (progress >= 80) {
int resultingProgress = 60;
ParticleEffectType particleEffectType = ParticleEffectTypeRegistry.WEEPING_WELL_REACTS;
ItemStack stack = eatenItems.get(eatenItems.size()-1);
if (stack.getItem().equals(ItemRegistry.BLIGHTED_GUNK.get())) {
resultingProgress +=streak/2f;
Expand All @@ -103,12 +94,13 @@ public void tick() {
else {
Item result = spitOutItem(stack);
if (result.equals(ItemRegistry.FUSED_CONSCIOUSNESS.get())) {
lingeringRadiance = 3600;
lingeringRadiance = 200;
particleEffectType = ParticleEffectTypeRegistry.WEEPING_WELL_EMITS_RADIANCE;
}
}
progress = resultingProgress;
eatenItems.remove(eatenItems.size()-1);
ParticleEffectTypeRegistry.WEEPING_WELL_REACTS.createPositionedEffect(level, new PositionEffectData(worldPosition.getX()+0.5f, worldPosition.getY()+0.75f, worldPosition.getZ()+0.5f));
particleEffectType.createPositionedEffect(level, new PositionEffectData(worldPosition.getX()+0.5f, worldPosition.getY()+0.6f, worldPosition.getZ()+0.5f));
BlockHelper.updateAndNotifyState(level, worldPosition);
}
if (eatenItems.isEmpty()) {
Expand All @@ -120,8 +112,11 @@ else if (streak != 0) {
}
}
else {
WeepingWellParticleEffects.passiveWeepingWellParticles(this);
WeepingWellParticleEffects.radiantWeepingWellParticles(this);
if (lingeringRadiance == 0) {
WeepingWellParticleEffects.passiveWeepingWellParticles(this);
} else {
RadiantParticleEffects.radiantWeepingWellParticles(this);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void tick() {
.setRandomOffset(0.15f, 0.2f)
.addMotion(0, 0.0035f, 0)
.setRandomMotion(0.001f, 0.005f)
.addActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.985f-level.random.nextFloat() * 0.04f)))
.addTickActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.985f-level.random.nextFloat() * 0.04f)))
.enableNoClip()
.setDiscardFunction(SimpleParticleOptions.ParticleDiscardFunctionType.ENDING_CURVE_INVISIBLE)
.spawn(level, x, y, z);
Expand All @@ -173,7 +173,7 @@ public void tick() {
.setRandomOffset(0.1f, 0.225f)
.addMotion(0, velocity / 2f, 0)
.setRandomMotion(0, 0.015f)
.addActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.97f-level.random.nextFloat() * 0.025f)))
.addTickActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.97f-level.random.nextFloat() * 0.025f)))
.enableNoClip()
.setDiscardFunction(SimpleParticleOptions.ParticleDiscardFunctionType.ENDING_CURVE_INVISIBLE)
.spawn(level, x, y, z);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void execute(Supplier<NetworkEvent.Context> context) {
.enableNoClip()
.setRandomOffset(0.2f, 0.2f)
.setRandomMotion(0.02f)
.addActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.95f)))
.addTickActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.95f)))
.repeat(level, posX, posY, posZ, 8);
}
WorldParticleBuilder.create(LodestoneParticleRegistry.WISP_PARTICLE)
Expand All @@ -54,7 +54,7 @@ public void execute(Supplier<NetworkEvent.Context> context) {
.enableNoClip()
.setRandomOffset(0.05f, 0.05f)
.setRandomMotion(0.05f)
.addActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.5f)))
.addTickActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.5f)))
.repeat(level, posX, posY, posZ, 12);

WorldParticleBuilder.create(LodestoneParticleRegistry.SMOKE_PARTICLE)
Expand All @@ -66,7 +66,7 @@ public void execute(Supplier<NetworkEvent.Context> context) {
.enableNoClip()
.setRandomOffset(0.15f, 0.15f)
.setRandomMotion(0.015f, 0.015f)
.addActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.92f)))
.addTickActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.92f)))
.repeat(level, posX, posY, posZ, 20);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static ParticleEffectSpawner<ItemCrumbParticleBuilder> spawnGlowingItemCr
final Consumer<LodestoneWorldParticleActor> slowDown = p -> p.setParticleMotion(p.getParticleSpeed().scale(0.925f));
int lifetime = RandomHelper.randomBetween(rand, 30, 40);
final ItemCrumbParticleBuilder worldParticleBuilder = makeCrumbles(rand, stack, spinData, lifetime, slowDown);
final WorldParticleBuilder bloomParticleBuilder = SpiritLightSpecs.spiritBloom(level, spiritType, spinData, lifetime).addActor(slowDown);
final WorldParticleBuilder bloomParticleBuilder = SpiritLightSpecs.spiritBloom(level, spiritType, spinData, lifetime).addTickActor(slowDown);
return new ParticleEffectSpawner<>(level, pos, worldParticleBuilder, bloomParticleBuilder);
}

Expand All @@ -49,6 +49,6 @@ public static ItemCrumbParticleBuilder makeCrumbles(Random rand, ItemStack stack
.setLifetime(lifetime)
.setDiscardFunction(SimpleParticleOptions.ParticleDiscardFunctionType.ENDING_CURVE_INVISIBLE)
.setRenderType(ParticleRenderType.TERRAIN_SHEET)
.addActor(slowDown);
.addTickActor(slowDown);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package com.sammy.malum.visual_effects;

import com.sammy.malum.common.block.curiosities.weeping_well.*;
import com.sammy.malum.visual_effects.networked.data.*;
import net.minecraft.core.*;
import net.minecraft.world.level.*;
import net.minecraft.world.phys.*;
import team.lodestar.lodestone.helpers.*;
import team.lodestar.lodestone.setup.*;
import team.lodestar.lodestone.systems.easing.*;
import team.lodestar.lodestone.systems.particle.*;
import team.lodestar.lodestone.systems.particle.builder.*;
import team.lodestar.lodestone.systems.particle.data.*;
import team.lodestar.lodestone.systems.particle.data.color.*;
import team.lodestar.lodestone.systems.particle.data.spin.*;
import team.lodestar.lodestone.systems.particle.render_types.*;

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

import static com.sammy.malum.visual_effects.WeepingWellParticleEffects.getWeepingWellSmokeColor;

public class RadiantParticleEffects {
public static final java.util.List<Color> RADIANT_COLORS = List.of(
new Color(179, 35, 218),
new Color(224, 210, 68),
new Color(42, 146, 218));

public static void spitOutWeepingWellRadiance(Level level, PositionEffectData positionEffectData) {
double posX = positionEffectData.posX;
double posY = positionEffectData.posY;
double posZ = positionEffectData.posZ;
Vec3 pos = new Vec3(posX, posY, posZ);
Random rand = level.random;
Consumer<LodestoneWorldParticleActor> spawnBehavior = p -> p.tickParticle(2);
for (int i = 0; i < 64; i++) {
Color color = RADIANT_COLORS.get((i % 12) / 4);
final ColorParticleData colorData = ColorParticleData.create(color.brighter(), color).setCoefficient(0.5f).build();
float xVelocity = RandomHelper.randomBetween(rand, 0f, 0.15f) * (rand.nextBoolean() ? 1 : -1);
float yVelocity = RandomHelper.randomBetween(rand, 0.5f, 1f);
float zVelocity = RandomHelper.randomBetween(rand, 0f, 0.15f) * (rand.nextBoolean() ? 1 : -1);
float gravityStrength = RandomHelper.randomBetween(rand, 0.75f, 1f);
if (rand.nextFloat() < 0.85f) {
var sparkParticles = WeepingWellParticleEffects.weepingWellSparks(level, pos, colorData, LodestoneWorldParticleRenderType.ADDITIVE);
sparkParticles.getBuilder()
.addSpawnActor(spawnBehavior)
.disableNoClip()
.setGravityStrength(gravityStrength/2f)
.setMotion(xVelocity, yVelocity, zVelocity)
.modifyData(SparkParticleBuilder::getTransparencyData, d -> d.multiplyValue(2f))
.modifyData(SparkParticleBuilder::getScaleData, d -> d.multiplyValue(1.5f));
sparkParticles.getBloomBuilder()
.addSpawnActor(spawnBehavior)
.disableNoClip()
.setGravityStrength(gravityStrength/2f)
.setMotion(xVelocity, yVelocity, zVelocity)
.modifyData(WorldParticleBuilder::getTransparencyData, d -> d.multiplyValue(1.25f));
sparkParticles.spawnParticles();
}
if (rand.nextFloat() < 0.85f) {
xVelocity *= 1.25f;
yVelocity *= 0.75f;
zVelocity *= 1.25f;
var lightSpecs = WeepingWellParticleEffects.weepingWellSpecs(level, pos, colorData, LodestoneWorldParticleRenderType.ADDITIVE);
lightSpecs.getBuilder()
.addSpawnActor(spawnBehavior)
.disableNoClip()
.setGravityStrength(gravityStrength)
.setMotion(xVelocity, yVelocity, zVelocity)
.modifyData(WorldParticleBuilder::getScaleData, d -> d.multiplyValue(1.5f));
lightSpecs.getBloomBuilder()
.addSpawnActor(spawnBehavior)
.disableNoClip()
.setGravityStrength(gravityStrength)
.setMotion(xVelocity, yVelocity, zVelocity)
.modifyData(WorldParticleBuilder::getTransparencyData, d -> d.multiplyValue(1.25f));
lightSpecs.spawnParticles();
}
}
int spinOffset = rand.nextInt(360);
for (int i = 0; i < 3; i++) {
int lifeDelay = 4 * i;
Color color = RADIANT_COLORS.get((int) ((level.getGameTime() % 3 + i) % 3));
final ColorParticleData colorData = ColorParticleData.create(color.brighter(), color).setCoefficient(0.5f).build();
int spinDirection = (rand.nextBoolean() ? 1 : -1);
WorldParticleBuilder.create(LodestoneParticleRegistry.SPARKLE_PARTICLE)
.setTransparencyData(GenericParticleData.create(0.1f, 0.4f, 0).setEasing(Easing.QUAD_IN, Easing.CIRC_IN).build())
.setSpinData(SpinParticleData.create((0.125f + rand.nextFloat() * 0.075f) * spinDirection).setSpinOffset(spinOffset).build())
.setScaleData(GenericParticleData.create(3f, 5f, 0.6f).setEasing(Easing.QUARTIC_OUT, Easing.SINE_IN).build())
.setColorData(colorData)
.setLifeDelay(lifeDelay)
.setLifetime(25+lifeDelay)
.setRandomOffset(0.6f)
.enableNoClip()
.setRandomMotion(0.02f, 0.02f)
.setDiscardFunction(SimpleParticleOptions.ParticleDiscardFunctionType.ENDING_CURVE_INVISIBLE)
.repeat(level, posX, posY+0.25f, posZ, 5);

}
for (int i = 0; i < 27; i++) {
int finalI = 4+i;
Color color = RADIANT_COLORS.get(((int) (level.getGameTime()-27+i) % 27) / 9);
final ColorParticleData colorData = ColorParticleData.create(color.brighter(), color).setCoefficient(0.5f).build();
var squares = WeepingWellParticleEffects.weepingWellSquare(level, pos, colorData);
squares.getBuilder().addSpawnActor(p -> p.tickParticle(finalI));
squares.spawnParticles();
}
}

public static void radiantWeepingWellParticles(VoidConduitBlockEntity voidConduit) {
Level level = voidConduit.getLevel();
Random rand = level.random;
Color color = RADIANT_COLORS.get(((int) level.getGameTime() % 27) / 9);
final BlockPos blockPos = voidConduit.getBlockPos();
final ColorParticleData colorData = ColorParticleData.create(color.brighter(), color).setCoefficient(0.5f).build();
if (level.getGameTime() % 3L == 0) {
WeepingWellParticleEffects.weepingWellSquare(level, new Vec3(blockPos.getX()+0.5f, blockPos.getY()+0.75f, blockPos.getZ()+0.5f), colorData).spawnParticles();
}

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() % 2L == 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 = WeepingWellParticleEffects.weepingWellSpecs(level, offsetPosition, colorData, LodestoneWorldParticleRenderType.ADDITIVE);
lightSpecs.getBuilder().addTickActor(behavior);
lightSpecs.getBloomBuilder().addTickActor(behavior);
lightSpecs.spawnParticles();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
public class SparkParticleEffects {

public static ParticleEffectSpawner<SparkParticleBuilder> spiritMotionSparks(Level level, Vec3 pos, MalumSpiritType spiritType) {
return spiritMotionSparks(level, pos, spiritType.createMainColorData(1.25f).build(), spiritType.createBloomColorData().build());
}

public static ParticleEffectSpawner<SparkParticleBuilder> spiritMotionSparks(Level level, Vec3 pos, ColorParticleData colorData, ColorParticleData bloomColorData) {
Random rand = level.getRandom();
final ColorParticleData colorData = spiritType.createMainColorData(1.25f).build();
final SpinParticleData spinData = SpinParticleData.createRandomDirection(rand, nextFloat(rand, 0.05f, 0.1f)).randomSpinOffset(rand).build();
final Consumer<LodestoneWorldParticleActor> slowDown = p -> p.setParticleMotion(p.getParticleSpeed().scale(0.95f));
int lifetime = RandomHelper.randomBetween(rand, 10, 20);
Expand All @@ -32,8 +35,8 @@ public static ParticleEffectSpawner<SparkParticleBuilder> spiritMotionSparks(Lev
.setColorData(colorData)
.setLifetime(lifetime)
.enableNoClip()
.addActor(slowDown);
final WorldParticleBuilder bloomParticleBuilder = SpiritLightSpecs.spiritBloom(level, spiritType, spinData, lifetime).addActor(slowDown);
.addTickActor(slowDown);
final WorldParticleBuilder bloomParticleBuilder = SpiritLightSpecs.spiritBloom(level, bloomColorData, spinData, lifetime).addTickActor(slowDown);

return new ParticleEffectSpawner<>(level, pos, sparkParticleBuilder, bloomParticleBuilder);
}
Expand Down
Loading

0 comments on commit 9053318

Please sign in to comment.