Skip to content

Commit

Permalink
Rewrite cascades
Browse files Browse the repository at this point in the history
  • Loading branch information
doctor4t committed Jan 1, 2025
1 parent dd34ad0 commit f95c46e
Show file tree
Hide file tree
Showing 30 changed files with 167 additions and 124 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Effective 2.4.2 (Alpha) - 1.21.1
------------------------------------------------------
- Rewrote ripples and glow ripples
- Rewrote waterfall clouds
- Renamed to "cascade"
- Added a new particle type for glow cascades instead of changing the regular cascades' rendering

------------------------------------------------------
Effective 2.4.1 (Alpha) - 1.21.1
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ yarn_mappings=1.21.1+build.3
loader_version=0.16.9

# Mod Properties
mod_version=2.4.1-1.21.1
mod_version=2.4.2-1.21.1
maven_group=ladysnake
archives_base_name=effective

Expand Down
6 changes: 4 additions & 2 deletions src/client/java/org/ladysnake/effective/core/Effective.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import net.minecraft.world.World;
import org.ladysnake.effective.core.gui.ParryScreen;
import org.ladysnake.effective.core.index.EffectiveParticles;
import org.ladysnake.effective.core.particle.*;
import org.ladysnake.effective.core.particle.ChorusPetalParticle;
import org.ladysnake.effective.core.particle.EyesParticle;
import org.ladysnake.effective.core.particle.WillOWispParticle;
import org.ladysnake.effective.core.render.entity.model.SplashBottomModel;
import org.ladysnake.effective.core.render.entity.model.SplashBottomRimModel;
import org.ladysnake.effective.core.render.entity.model.SplashModel;
Expand Down Expand Up @@ -54,7 +56,7 @@ public class Effective implements ClientModInitializer {

// particle types
public static SimpleParticleType BUBBLE;
public static SimpleParticleType WATERFALL_CLOUD;
public static SimpleParticleType CASCADE;
public static SimpleParticleType MIST;
public static SimpleParticleType EYES;
public static SimpleParticleType WILL_O_WISP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public interface EffectiveParticles {
SimpleParticleType GLOW_RIPPLE = create("glow_ripple", FabricParticleTypes.simple(true));
SimpleParticleType BUBBLE = create("bubble", FabricParticleTypes.simple(true));
SimpleParticleType END_BUBBLE = create("end_bubble", FabricParticleTypes.simple(true));
SimpleParticleType WATERFALL_CLOUD = create("waterfall_cloud", FabricParticleTypes.simple(true));
SimpleParticleType MIST = create("mist", FabricParticleTypes.simple(true));
SimpleParticleType CASCADE = create("cascade", FabricParticleTypes.simple(true));
SimpleParticleType GLOW_CASCADE = create("glow_cascade", FabricParticleTypes.simple(true));

static void initialize() {
PARTICLES.keySet().forEach(particle -> Registry.register(Registries.PARTICLE_TYPE, PARTICLES.get(particle), particle));
Expand All @@ -49,7 +49,7 @@ private static void registerFactories() {
ParticleFactoryRegistry.getInstance().register(GLOW_RIPPLE, GlowRippleParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(BUBBLE, BubbleParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(END_BUBBLE, EndBubbleParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(WATERFALL_CLOUD, CascadeParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(MIST, MistParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(CASCADE, CascadeParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(GLOW_CASCADE, GlowCascadeParticle.Factory::new);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package org.ladysnake.effective.core.mixin.chest_bubbles;

import net.minecraft.block.*;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.ChestBlockEntity;
import net.minecraft.block.entity.EnderChestBlockEntity;
import net.minecraft.block.entity.LidOpenable;
import net.minecraft.block.enums.ChestType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import org.ladysnake.effective.core.EffectiveConfig;
import org.ladysnake.effective.core.index.EffectiveParticles;
import org.ladysnake.effective.core.utils.EffectiveUtils;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package org.ladysnake.effective.core.mixin.chest_bubbles;

import net.minecraft.block.*;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.ChestBlockEntity;
import net.minecraft.block.entity.EnderChestBlockEntity;
import net.minecraft.block.entity.LidOpenable;
import net.minecraft.block.enums.ChestType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import org.ladysnake.effective.core.EffectiveConfig;
import org.ladysnake.effective.core.utils.EffectiveUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public void tick() {
this.velocityZ *= 1.1;
}

this.velocityX = this.velocityX * (double)this.velocityMultiplier;
this.velocityZ = this.velocityZ * (double)this.velocityMultiplier;
this.velocityX = this.velocityX * (double) this.velocityMultiplier;
this.velocityZ = this.velocityZ * (double) this.velocityMultiplier;
if (this.onGround) {
this.velocityX *= 0.7F;
this.velocityZ *= 0.7F;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.client.world.ClientWorld;
import net.minecraft.particle.SimpleParticleType;
import net.minecraft.util.math.BlockPos;
import org.ladysnake.effective.core.Effective;

public class CascadeParticle extends SpriteBillboardParticle {
private final SpriteProvider spriteProvider;
Expand All @@ -21,15 +20,9 @@ public CascadeParticle(ClientWorld world, double x, double y, double z, double v

this.spriteProvider = spriteProvider;
this.maxAge = 10;
this.scale = .5f;
this.scale = 1f;

this.setSpriteForAge(spriteProvider);

// WorldParticleBuilder.create(Effective.WATERFALL_CLOUD)
// .enableForcedSpawn()
// .enableNoClip()
// .setMotion((world.getRandom().nextFloat() * waterfall.strength()) / 10f * Math.signum(offsetX), (world.getRandom().nextFloat() * waterfall.strength()) / 10f, (world.getRandom().nextFloat() * waterfall.strength()) / 10f * Math.signum(offsetZ))
// .spawn(world, blockPos.getX() + .5 + offsetX, blockPos.getY() + world.getRandom().nextFloat(), blockPos.getZ() + .5 + offsetZ);
}

public ParticleTextureSheet getType() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.ladysnake.effective.core.particle;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleFactory;
import net.minecraft.client.particle.SpriteProvider;
import net.minecraft.client.render.LightmapTextureManager;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.particle.SimpleParticleType;
import net.minecraft.util.math.BlockPos;
import org.ladysnake.effective.core.utils.EffectiveUtils;

import java.awt.*;

public class GlowCascadeParticle extends CascadeParticle {
private GlowCascadeParticle(ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ, SpriteProvider spriteProvider) {
super(world, x, y, z, velocityX, velocityY, velocityZ, spriteProvider);

Color glowingWaterColor = EffectiveUtils.getGlowingWaterColor(world, BlockPos.ofFloored(x, y, z));
this.red = glowingWaterColor.getRed() / 255f;
this.green = glowingWaterColor.getGreen() / 255f;
this.blue = glowingWaterColor.getBlue() / 255f;
}

@Override
protected int getBrightness(float tint) {
return LightmapTextureManager.MAX_LIGHT_COORDINATE;
}

@Environment(EnvType.CLIENT)
public static class Factory implements ParticleFactory<SimpleParticleType> {
private final SpriteProvider spriteProvider;

public Factory(SpriteProvider spriteProvider) {
this.spriteProvider = spriteProvider;
}

@Override
public Particle createParticle(SimpleParticleType parameters, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
return new GlowCascadeParticle(world, x, y, z, velocityX, velocityY, velocityZ, this.spriteProvider);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,22 @@
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleFactory;
import net.minecraft.client.particle.SpriteProvider;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.LightmapTextureManager;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.particle.SimpleParticleType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.LightType;
import org.joml.Quaternionf;
import org.joml.Vector3f;
import org.ladysnake.effective.core.utils.EffectiveUtils;

public class GlowRippleParticle extends RippleParticle {
public BlockPos pos;
import java.awt.*;

public class GlowRippleParticle extends RippleParticle {
private GlowRippleParticle(ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ, SpriteProvider spriteProvider) {
super(world, x, y, z, velocityX, velocityY, velocityZ, spriteProvider);

pos = BlockPos.ofFloored(x, y, z);
float randFloat = random.nextFloat() / 5f;
float redAndGreenRender = Math.min(1, randFloat + world.getLightLevel(LightType.BLOCK, pos) / 15f);
this.red = redAndGreenRender;
this.green = redAndGreenRender;
this.blue = 1.0f;
Color glowingWaterColor = EffectiveUtils.getGlowingWaterColor(world, BlockPos.ofFloored(x, y, z));
this.red = glowingWaterColor.getRed() / 255f;
this.green = glowingWaterColor.getGreen() / 255f;
this.blue = glowingWaterColor.getBlue() / 255f;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.client.render.LightmapTextureManager;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleType;
import net.minecraft.particle.SimpleParticleType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.LightType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,57 +1,60 @@
package org.ladysnake.effective.core.particle;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.particle.*;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.particle.SimpleParticleType;
import org.ladysnake.effective.core.Effective;

public class MistParticle extends SpriteBillboardParticle {
public MistParticle(ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ, SpriteProvider spriteProvider) {
super(world, x, y, z, velocityX, velocityY, velocityZ);

this.velocityX = velocityX;
this.velocityY = velocityY;
this.velocityZ = velocityZ;

this.setSpriteForAge(spriteProvider);


// WorldParticleBuilder.create(Effective.MIST)
// .enableForcedSpawn()
// .setSpinData(SpinParticleData.create((world.random.nextFloat() - world.random.nextFloat()) / 20f).build())
// .setScaleData(GenericParticleData.create(10f + world.random.nextFloat() * 5f).build())
// .setTransparencyData(
// GenericParticleData.create(0.001f, 0.1f, 0f)
// .setEasing(Easing.EXPO_OUT, Easing.SINE_OUT)
// .build()
// )
// .setLifetime(300)
// .enableNoClip()
// .setNaturalLighting()
// .setRenderType(LodestoneWorldParticleRenderType.TRANSPARENT.withDepthFade())
// .setColorData(ColorParticleData.create(waterfall.mistColor(), waterfall.mistColor()).build())
// .setMotion(world.getRandom().nextFloat() / 15f * Math.signum(offsetX), world.getRandom().nextGaussian() / 25f, world.getRandom().nextFloat() / 15f * Math.signum(offsetZ))
// .spawn(world, blockPos.getX() + .5f, blockPos.getY() + .5f, blockPos.getZ() + .5f);
}

@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
}

@Environment(EnvType.CLIENT)
public static class Factory implements ParticleFactory<SimpleParticleType> {
private final SpriteProvider spriteProvider;

public Factory(SpriteProvider spriteProvider) {
this.spriteProvider = spriteProvider;
}

@Override
public Particle createParticle(SimpleParticleType parameters, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
return new MistParticle(world, x, y, z, velocityX, velocityY, velocityZ, this.spriteProvider);
}
}
}
//package org.ladysnake.effective.core.particle;
//
//import net.fabricmc.api.EnvType;
//import net.fabricmc.api.Environment;
//import net.minecraft.client.particle.*;
//import net.minecraft.client.world.ClientWorld;
//import net.minecraft.particle.SimpleParticleType;
//import org.ladysnake.effective.core.Effective;
//
//public class MistParticle extends SpriteBillboardParticle {
// public MistParticle(ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ, SpriteProvider spriteProvider) {
// super(world, x, y, z, velocityX, velocityY, velocityZ);
//
// this.velocityX = velocityX;
// this.velocityY = velocityY;
// this.velocityZ = velocityZ;
//
// this.setSpriteForAge(spriteProvider);
//
// this.scale = 10f + world.random.nextFloat() * 5f;
// this.maxAge = 0;
// this.alpha = 0.01f;
//
//// WorldParticleBuilder.create(Effective.MIST)
//// .enableForcedSpawn()
//// .setSpinData(SpinParticleData.create((world.random.nextFloat() - world.random.nextFloat()) / 20f).build())
//// .setScaleData(GenericParticleData.create(10f + world.random.nextFloat() * 5f).build())
//// .setTransparencyData(
//// GenericParticleData.create(0.001f, 0.1f, 0f)
//// .setEasing(Easing.EXPO_OUT, Easing.SINE_OUT)
//// .build()
//// )
//// .setLifetime(300)
//// .enableNoClip()
//// .setNaturalLighting()
//// .setRenderType(LodestoneWorldParticleRenderType.TRANSPARENT.withDepthFade())
//// .setColorData(ColorParticleData.create(waterfall.mistColor(), waterfall.mistColor()).build())
//// .setMotion(world.getRandom().nextFloat() / 15f * Math.signum(offsetX), world.getRandom().nextGaussian() / 25f, world.getRandom().nextFloat() / 15f * Math.signum(offsetZ))
//// .spawn(world, blockPos.getX() + .5f, blockPos.getY() + .5f, blockPos.getZ() + .5f);
// }
//
// @Override
// public ParticleTextureSheet getType() {
// return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
// }
//
// @Environment(EnvType.CLIENT)
// public static class Factory implements ParticleFactory<SimpleParticleType> {
// private final SpriteProvider spriteProvider;
//
// public Factory(SpriteProvider spriteProvider) {
// this.spriteProvider = spriteProvider;
// }
//
// @Override
// public Particle createParticle(SimpleParticleType parameters, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
// return new MistParticle(world, x, y, z, velocityX, velocityY, velocityZ, this.spriteProvider);
// }
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleType;
import net.minecraft.particle.SimpleParticleType;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.ChestBlockEntity;
import net.minecraft.block.entity.EnderChestBlockEntity;
import net.minecraft.block.entity.LidOpenable;
import net.minecraft.block.enums.ChestType;
import net.minecraft.entity.passive.AllayEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.world.World;
import org.ladysnake.effective.core.Effective;
import org.ladysnake.effective.core.EffectiveConfig;
import org.ladysnake.effective.core.index.EffectiveParticles;
import org.ladysnake.effective.core.sound.WaterfallSoundInstance;
import org.ladysnake.effective.core.utils.EffectiveUtils;

Expand Down Expand Up @@ -148,26 +149,25 @@ private static Waterfall getWaterfallAt(BlockView world, BlockPos pos, FluidStat
}

public static void addWaterfallCloud(World world, Waterfall waterfall) {
boolean isGlowingWater = EffectiveUtils.isGlowingWater(world, waterfall.blockPos());
Color glowingWaterColor = EffectiveUtils.getGlowingWaterColor(world, waterfall.blockPos());
Color white = new Color(0xFFFFFF);
BlockPos blockPos = waterfall.blockPos();

for (int i = 0; i < EffectiveConfig.cascadeCloudDensity; i++) {
if (waterfall != null) {
double offsetX = world.getRandom().nextGaussian() / 5f;
double offsetZ = world.getRandom().nextGaussian() / 5f;
double offsetX = world.getRandom().nextGaussian() / 5f;
double offsetZ = world.getRandom().nextGaussian() / 5f;

}
world.addParticle(EffectiveUtils.isGlowingWater(world, waterfall.blockPos()) ? EffectiveParticles.GLOW_CASCADE : EffectiveParticles.CASCADE, blockPos.getX() + .5 + offsetX, blockPos.getY() + world.getRandom().nextFloat(), blockPos.getZ() + .5 + offsetZ, (world.getRandom().nextFloat() * waterfall.strength()) / 10f * Math.signum(offsetX), (world.getRandom().nextFloat() * waterfall.strength()) / 10f, (world.getRandom().nextFloat() * waterfall.strength()) / 10f * Math.signum(offsetZ));
}

/*
if (EffectiveConfig.cascadeMistDensity > 0f && waterfall.strength() >= 1.6f) {
if ((world.random.nextFloat() * 100f) <= EffectiveConfig.cascadeMistDensity) {
double offsetX = world.getRandom().nextGaussian() / 5f;
double offsetZ = world.getRandom().nextGaussian() / 5f;
world.addParticle(EffectiveParticles.MIST, blockPos.getX() + .5f, blockPos.getY() + .5f, blockPos.getZ() + .5f, world.getRandom().nextFloat() / 15f * Math.signum(offsetX), world.getRandom().nextGaussian() / 25f, world.getRandom().nextFloat() / 15f * Math.signum(offsetZ));
}
}
*/
}

public static void scheduleParticleTick(Waterfall waterfall, int ticks) {
Expand Down
Loading

0 comments on commit f95c46e

Please sign in to comment.