Skip to content

Commit

Permalink
Agh
Browse files Browse the repository at this point in the history
  • Loading branch information
SammySemicolon committed Jan 1, 2024
1 parent 7c1b9d0 commit 5a34e58
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,16 @@ public InteractionResult onUse(Player player, InteractionHand hand) {
@Override
public void tick() {
super.tick();
if (level.isClientSide) {
RitualPlinthParticleEffects.passiveRitualPlinthParticles(this);
}
}

// public Vec3 getItemPos() {
// final BlockPos blockPos = getBlockPos();
// final Vec3 offset = getCentralItemOffset();
// return new Vec3(blockPos.getX() + offset.x, blockPos.getY() + offset.y, blockPos.getZ() + offset.z);
// }
//
// public Vec3 getCentralItemOffset() {
// return ALTAR_ITEM_OFFSET;
// }
public Vec3 getParticlePositionPosition(Direction direction) {
final BlockPos blockPos = getBlockPos();
float x = blockPos.getX() + 0.5f + direction.getStepX()*0.7f;
float y = blockPos.getY() + 0.85f;
float z = blockPos.getZ() + 0.5f + direction.getStepZ()*0.7f;
return new Vec3(x, y, z);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.sammy.malum.visual_effects;

import com.sammy.malum.common.block.curiosities.ritual_plinth.RitualPlinthBlockEntity;
import com.sammy.malum.common.block.curiosities.spirit_altar.SpiritAltarBlockEntity;
import com.sammy.malum.core.systems.spirit.MalumSpiritType;
import com.sammy.malum.registry.common.SpiritTypeRegistry;
import net.minecraft.core.Direction;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import team.lodestar.lodestone.helpers.RandomHelper;
import team.lodestar.lodestone.systems.particle.builder.SparkParticleBuilder;

import static com.sammy.malum.visual_effects.SpiritLightSpecs.spiritLightSpecs;

public class RitualPlinthParticleEffects {
public static void passiveRitualPlinthParticles(RitualPlinthBlockEntity plinth) {
Level level = plinth.getLevel();
MalumSpiritType spiritType = SpiritTypeRegistry.INFERNAL_SPIRIT;
RandomSource random = level.random;
for (Direction direction : Direction.values()) {
if (direction.getAxis().equals(Direction.Axis.Y)) {
continue;
}
Vec3 particlePosition = plinth.getParticlePositionPosition(direction);
Vec3 particleVelocity = new Vec3(0.03f * direction.getStepX(), 0, 0.03f * direction.getStepZ());
if (level.getGameTime() % 3L == 0) {
Vec3 randomizedVelocity = particleVelocity.scale(RandomHelper.randomBetween(random, 0.8f, 1f));
var lightSpecs = spiritLightSpecs(level, particlePosition, spiritType);
lightSpecs.getBuilder().setMotion(randomizedVelocity);
lightSpecs.getBloomBuilder().setMotion(randomizedVelocity);
lightSpecs.spawnParticles();
}
if (level.getGameTime() % 4L == 0) {
Vec3 randomizedVelocity = particleVelocity.scale(RandomHelper.randomBetween(random, 0.8f, 1f));
Vec3 sparkPos = particlePosition.add(0.05f - random.nextFloat() * 0.1f, 0.05f - random.nextFloat() * 0.1f, 0.05f - random.nextFloat() * 0.1f);
var sparkParticles = SparkParticleEffects.spiritMotionSparks(level, sparkPos, spiritType);
sparkParticles.getBuilder().setMotion(randomizedVelocity)
.modifyData(SparkParticleBuilder::getScaleData, d -> d.multiplyValue(1.5f))
.modifyData(SparkParticleBuilder::getLengthData, d -> d.multiplyValue(2f).multiplyCoefficient(0.75f))
.modifyColorData(c -> c.multiplyCoefficient(0.8f));
sparkParticles.getBloomBuilder().setMotion(randomizedVelocity);
sparkParticles.spawnParticlesRaw();
}

}
}
}

0 comments on commit 5a34e58

Please sign in to comment.