Skip to content

Commit

Permalink
Fix black splashes
Browse files Browse the repository at this point in the history
  • Loading branch information
doctor4t committed Aug 27, 2022
1 parent 0d43342 commit 2cc6035
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 81 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Effective - Changelog:

## Effective 1.2.3 - 1.19.2
- Fixed splashes sometimes being completely black (thanks to lonefelidae16)
- Updated to Minecraft 1.19.2

## Effective 1.2.2 - 1.19
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ladysnake/effective/client/Effective.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Effective implements ClientModInitializer {

// particle types
public static DefaultParticleType SPLASH;
// public static DefaultParticleType LAVA_SPLASH;
// public static DefaultParticleType LAVA_SPLASH;
public static DefaultParticleType DROPLET;
public static DefaultParticleType RIPPLE;
public static DefaultParticleType WATERFALL_CLOUD;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/ladysnake/effective/client/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

@Config(name = Effective.MODID)
public class ModConfig implements ConfigData {
public boolean generateCascades = true;
public boolean generateSplashes = true;
public boolean shouldFlowingWaterSpawnParticlesOnFirstTick = true;
@ConfigEntry.BoundedDiscrete(max = 100)
public long lapisBlockUpdateParticleChance = 10;
public boolean generateCascades = true;
public boolean generateSplashes = true;
public boolean shouldFlowingWaterSpawnParticlesOnFirstTick = true;
@ConfigEntry.BoundedDiscrete(max = 100)
public long lapisBlockUpdateParticleChance = 10;
}
66 changes: 33 additions & 33 deletions src/main/java/ladysnake/effective/client/ModMixinPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,37 @@
import java.util.Set;

public class ModMixinPlugin implements IMixinConfigPlugin {
@Override
public void onLoad(String mixinPackage) {
}

@Override
public String getRefMapperConfig() {
return null;
}

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (mixinClassName.startsWith("ladysnake.effective.mixin.integration.sodium")) {
return FabricLoader.getInstance().isModLoaded("sodium");
}
return true;
}

@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
}

@Override
public List<String> getMixins() {
return null;
}

@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}

@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
@Override
public void onLoad(String mixinPackage) {
}

@Override
public String getRefMapperConfig() {
return null;
}

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (mixinClassName.startsWith("ladysnake.effective.mixin.integration.sodium")) {
return FabricLoader.getInstance().isModLoaded("sodium");
}
return true;
}

@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
}

@Override
public List<String> getMixins() {
return null;
}

@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}

@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import me.shedaniel.autoconfig.AutoConfig;

public class ModMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return screen -> AutoConfig.getConfigScreen(ModConfig.class, screen).get();
}
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return screen -> AutoConfig.getConfigScreen(ModConfig.class, screen).get();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ladysnake.effective.client.particle;

import ladysnake.effective.client.Effective;
import ladysnake.effective.client.render.NoShadingRenderLayer;
import ladysnake.effective.client.render.entity.model.SplashBottomModel;
import ladysnake.effective.client.render.entity.model.SplashModel;
import net.fabricmc.api.EnvType;
Expand Down Expand Up @@ -44,8 +43,8 @@ protected SplashParticle(ClientWorld world, double x, double y, double z, Identi
this.texture2 = texture;
this.waveModel = new SplashModel<>(MinecraftClient.getInstance().getEntityModelLoader().getModelPart(SplashModel.MODEL_LAYER));
this.waveBottomModel = new SplashBottomModel<>(MinecraftClient.getInstance().getEntityModelLoader().getModelPart(SplashBottomModel.MODEL_LAYER));
this.layer1 = NoShadingRenderLayer.get(texture);
this.layer2 = NoShadingRenderLayer.get(texture);
this.layer1 = RenderLayer.getEntityTranslucent(texture);
this.layer2 = RenderLayer.getEntityTranslucent(texture);
this.gravityStrength = 0.0F;
this.widthMultiplier = 0f;
this.heightMultiplier = 0f;
Expand All @@ -67,7 +66,7 @@ public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float ti
int frame1 = Math.round(((float) this.age / (float) this.wave1End) * 12);

this.texture1 = new Identifier(Effective.MODID, "textures/entity/splash/splash_" + frame1 + ".png");
this.layer1 = NoShadingRenderLayer.get(texture1);
this.layer1 = RenderLayer.getEntityTranslucent(texture1);

Vec3d vec3d = camera.getPos();
float f = (float) (MathHelper.lerp(tickDelta, this.prevPosX, this.x) - vec3d.getX());
Expand All @@ -90,7 +89,7 @@ public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float ti
int frame1 = Math.round(((float) this.age / (float) this.wave1End) * 12);

this.texture1 = new Identifier(Effective.MODID, "textures/entity/splash/splash_" + frame1 + ".png");
this.layer1 = NoShadingRenderLayer.get(texture1);
this.layer1 = RenderLayer.getEntityTranslucent(texture1);

Vec3d vec3d = camera.getPos();
float f = (float) (MathHelper.lerp(tickDelta, this.prevPosX, this.x) - vec3d.getX());
Expand All @@ -115,7 +114,7 @@ public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float ti
int frame2 = Math.round(((float) (this.age - wave2Start) / (float) (this.wave2End - this.wave2Start)) * 12);

this.texture2 = new Identifier(Effective.MODID, "textures/entity/splash/splash_" + frame2 + ".png");
this.layer2 = NoShadingRenderLayer.get(texture2);
this.layer2 = RenderLayer.getEntityTranslucent(texture2);

Vec3d vec3d = camera.getPos();
float f = (float) (MathHelper.lerp(tickDelta, this.prevPosX, this.x) - vec3d.getX());
Expand All @@ -138,7 +137,7 @@ public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float ti
int frame2 = Math.round(((float) (this.age - wave2Start) / (float) (this.wave2End - this.wave2Start)) * 12);

this.texture2 = new Identifier(Effective.MODID, "textures/entity/splash/splash_" + frame2 + ".png");
this.layer2 = NoShadingRenderLayer.get(texture2);
this.layer2 = RenderLayer.getEntityTranslucent(texture2);

Vec3d vec3d = camera.getPos();
float f = (float) (MathHelper.lerp(tickDelta, this.prevPosX, this.x) - vec3d.getX());
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import java.util.List;

public class WaterfallCloudGenerators {
public static List<BlockPos> generators = new ArrayList<>();
public static final Object2IntMap<BlockPos> particlesToSpawn = new Object2IntArrayMap<>();
public static List<BlockPos> generators = new ArrayList<>();
private static volatile boolean adding = false;
private static World lastWorld = null;

Expand Down Expand Up @@ -53,8 +53,7 @@ public static void tick() {
world.playSound(pos.getX(), pos.getY(), pos.getZ(), Effective.AMBIENCE_WATERFALL, SoundCategory.AMBIENT, 10f, 1.2f + world.random.nextFloat() / 10f, true);
}
scheduleParticleTick(pos, 6);
}
else {
} else {
generators.remove(i);
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/ladysnake/effective/mixin/EntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
public abstract class EntityMixin {
@Shadow
public World world;
@Shadow
@Final
protected Random random;

@Shadow
public abstract double getX();
Expand All @@ -41,8 +44,6 @@ public abstract class EntityMixin {
@Shadow
public abstract float getWidth();

@Shadow @Final protected Random random;

@Inject(method = "onSwimmingStart", at = @At("TAIL"))
protected void onSwimmingStart(CallbackInfo callbackInfo) {
if (this.world.isClient && Effective.config.generateSplashes) {
Expand All @@ -53,7 +54,7 @@ protected void onSwimmingStart(CallbackInfo callbackInfo) {
if (g > 0.1f) {
for (int i = -10; i < 10; i++) {
if (this.world.getBlockState(new BlockPos(this.getX(), Math.round(this.getY()) + i, this.getZ())).getBlock() == Blocks.WATER && this.world.getBlockState(new BlockPos(this.getX(), Math.round(this.getY()) + i, this.getZ())).getFluidState().isStill() && this.world.getBlockState(new BlockPos(this.getX(), Math.round(this.getY()) + i + 1, this.getZ())).isAir()) {
this.world.playSound(this.getX(), Math.round(this.getY()) + i + 0.9f, this.getZ(), SoundEvents.ENTITY_GENERIC_SPLASH, SoundCategory.AMBIENT, g*10f, 0.8f, true);
this.world.playSound(this.getX(), Math.round(this.getY()) + i + 0.9f, this.getZ(), SoundEvents.ENTITY_GENERIC_SPLASH, SoundCategory.AMBIENT, g * 10f, 0.8f, true);
this.world.addParticle(Effective.SPLASH, this.getX(), Math.round(this.getY()) + i + 0.9f, this.getZ(), 0, 0, 0);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(FluidRenderer.class)
public class FluidRendererMixin {
Expand Down
22 changes: 10 additions & 12 deletions src/main/java/ladysnake/effective/mixin/WaterFluidMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,8 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Random;

@Mixin(WaterFluid.class)
public class WaterFluidMixin {
@Inject(method = "randomDisplayTick", at = @At("HEAD"))
protected void effective$splash(World world, BlockPos pos, FluidState state, net.minecraft.util.math.random.Random random, CallbackInfo ci) {
if (shouldSplash(world, pos.up())) {
Vec3d vec3d = state.getVelocity(world, pos);
for (int i = 0; i < random.nextInt(50); i++) {
world.addParticle(ParticleTypes.SPLASH, pos.getX() + .5 + random.nextGaussian() / 2f, pos.getY() + 1 + random.nextFloat(), pos.getZ() + .5 + random.nextGaussian() / 2f, vec3d.getX() * random.nextFloat(), random.nextFloat() / 10f, vec3d.getZ() * random.nextFloat());
}
}
}

@Unique
private static boolean shouldSplash(World world, BlockPos pos) {
if (Effective.config.generateCascades) {
Expand All @@ -43,4 +31,14 @@ private static boolean shouldSplash(World world, BlockPos pos) {
}
return false;
}

@Inject(method = "randomDisplayTick", at = @At("HEAD"))
protected void effective$splash(World world, BlockPos pos, FluidState state, net.minecraft.util.math.random.Random random, CallbackInfo ci) {
if (shouldSplash(world, pos.up())) {
Vec3d vec3d = state.getVelocity(world, pos);
for (int i = 0; i < random.nextInt(50); i++) {
world.addParticle(ParticleTypes.SPLASH, pos.getX() + .5 + random.nextGaussian() / 2f, pos.getY() + 1 + random.nextFloat(), pos.getZ() + .5 + random.nextGaussian() / 2f, vec3d.getX() * random.nextFloat(), random.nextFloat() / 10f, vec3d.getZ() * random.nextFloat());
}
}
}
}
15 changes: 8 additions & 7 deletions src/main/java/ladysnake/effective/mixin/WorldMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@

@Mixin(World.class)
public abstract class WorldMixin {
@Shadow public abstract FluidState getFluidState(BlockPos pos);
@Shadow
public abstract FluidState getFluidState(BlockPos pos);

@Inject(method = "setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;II)Z", at = @At("RETURN"))
private void effective$flowingWaterCascade(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, CallbackInfoReturnable<Boolean> cir) {
if (cir.getReturnValueZ() && Effective.config.shouldFlowingWaterSpawnParticlesOnFirstTick && getFluidState(pos).getFluid() == Fluids.FLOWING_WATER) {
WaterfallCloudGenerators.addWaterfallCloud(World.class.cast(this), pos);
}
}
@Inject(method = "setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;II)Z", at = @At("RETURN"))
private void effective$flowingWaterCascade(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, CallbackInfoReturnable<Boolean> cir) {
if (cir.getReturnValueZ() && Effective.config.shouldFlowingWaterSpawnParticlesOnFirstTick && getFluidState(pos).getFluid() == Fluids.FLOWING_WATER) {
WaterfallCloudGenerators.addWaterfallCloud(World.class.cast(this), pos);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

@Mixin(FluidRenderer.class)
public class FluidRendererMixin {
@Inject(method = "render", at = @At("HEAD"))
public void effective$generateWaterfall(BlockRenderView world, FluidState fluidState, BlockPos pos, BlockPos offset, ChunkModelBuilder buffers, CallbackInfoReturnable<Boolean> cir) {
WaterfallCloudGenerators.addGenerator(fluidState, pos.toImmutable());
}
@Inject(method = "render", at = @At("HEAD"))
public void effective$generateWaterfall(BlockRenderView world, FluidState fluidState, BlockPos pos, BlockPos offset, ChunkModelBuilder buffers, CallbackInfoReturnable<Boolean> cir) {
WaterfallCloudGenerators.addGenerator(fluidState, pos.toImmutable());
}
}
2 changes: 1 addition & 1 deletion src/main/resources/effective.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"AbstractBlockMixin",
"EntityMixin",
"FluidRendererMixin",
"RenderLayerAccessor",
"WaterFluidMixin",
"WorldMixin",
"RenderLayerAccessor",
"integration.sodium.FluidRendererMixin"
],
"injectors": {
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"authors": [
"doctor4t"
],
"contributors": [
"lonefelidae16"
],
"contact": {
"homepage": "https://illuminations.uuid.gg/",
"sources": "https://github.com/Ladysnake/Effective",
Expand Down

0 comments on commit 2cc6035

Please sign in to comment.