Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 47 additions & 5 deletions src/main/java/net/doppelr/lemonmates/fluid/BaseFluidType.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
package net.doppelr.lemonmates.fluid;

import com.mojang.blaze3d.shaders.FogShape;
import com.mojang.blaze3d.systems.RenderSystem;
import net.doppelr.lemonmates.LemonMates;
import net.minecraft.client.Camera;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.FogRenderer;
import net.minecraft.resources.ResourceLocation;
import net.neoforged.neoforge.client.extensions.common.IClientFluidTypeExtensions;
import net.neoforged.neoforge.fluids.FluidType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3f;

/**
* Basic implementation of {@link FluidType} that supports specifying still and flowing textures in the constructor.
*
* @author Choonster (<a href="https://github.com/Choonster-Minecraft-Mods/TestMod3/blob/1.19.x/LICENSE.txt">MIT License</a>)
*/
/**
* Basic implementation of {@link FluidType} that supports specifying still and flowing textures in the constructor.
*
* @author Choonster (<a href="https://github.com/Choonster-Minecraft-Mods/TestMod3/blob/1.19.x/LICENSE.txt">MIT License</a>)
* Change by: Kaupenjoe
* Added overlayTexture and tintColor as well. Also converts tint color into fog color
*/
public class BaseFluidType extends FluidType {
private final ResourceLocation stillTexture;
private final ResourceLocation flowingTexture;
private final ResourceLocation overlayTexture;
private final int tintColor;
private final Vector3f fogColor;

public BaseFluidType(final String stillTexture, final String flowingTexture,
final Properties properties) {
public BaseFluidType(final ResourceLocation stillTexture, final ResourceLocation flowingTexture, final ResourceLocation overlayTexture,
final int tintColor, final Vector3f fogColor, final Properties properties) {
super(properties);
this.stillTexture = LemonMates.rl("block/" + stillTexture);
this.flowingTexture = LemonMates.rl("block/" + flowingTexture);

this.stillTexture = stillTexture;
this.flowingTexture = flowingTexture;
this.overlayTexture = overlayTexture;
this.tintColor = tintColor;
this.fogColor = fogColor;
}

public IClientFluidTypeExtensions getClientFluidTypeExtensions() {
Expand All @@ -34,6 +54,28 @@ public ResourceLocation getFlowingTexture() {
return flowingTexture;
}

@Override
public @Nullable ResourceLocation getOverlayTexture() {
return overlayTexture;
}

@Override
public int getTintColor() {
return tintColor;
}

@Override
public @NotNull Vector3f modifyFogColor(Camera camera, float partialTick, ClientLevel level,
int renderDistance, float darkenWorldAmount, Vector3f fluidFogColor) {
return fogColor;
}

@Override
public void modifyFogRender(Camera camera, FogRenderer.FogMode mode, float renderDistance, float partialTick,
float nearDistance, float farDistance, FogShape shape) {
RenderSystem.setShaderFogStart(1f);
RenderSystem.setShaderFogEnd(6f); // distance when the fog starts
}
};
}
}
Loading