Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.khalid.learning.fluid;
- import com.mojang.blaze3d.shaders.FogShape;
- import com.mojang.blaze3d.systems.RenderSystem;
- import net.minecraft.client.Camera;
- import net.minecraft.client.multiplayer.ClientLevel;
- import net.minecraft.client.renderer.FogRenderer;
- import net.minecraft.resources.ResourceLocation;
- import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
- import net.minecraftforge.fluids.FluidStack;
- import net.minecraftforge.fluids.FluidType;
- import org.jetbrains.annotations.NotNull;
- import org.jetbrains.annotations.Nullable;
- import org.joml.Vector3f;
- import java.util.function.Consumer;
- public class BaseFluidType extends FluidType {
- //Textures
- private final ResourceLocation stillTexture;
- private final ResourceLocation flowingTexture;
- private final ResourceLocation overlayTexture;
- //Colors
- private final int tintColor;
- private final Vector3f fogColor;
- //Constructor
- public BaseFluidType(final ResourceLocation stillTexture, final ResourceLocation flowingTexture, final ResourceLocation overlayTexture, final int tintColor,
- final Vector3f fogColor, final Properties properties) {
- super(properties);
- this.stillTexture = stillTexture;
- this.flowingTexture = flowingTexture;
- this.overlayTexture = overlayTexture;
- this.tintColor = tintColor;
- this.fogColor = fogColor;
- }
- //Initializer
- @Override
- public void initializeClient(Consumer<IClientFluidTypeExtensions> consumer) {
- consumer.accept(new IClientFluidTypeExtensions() {
- //Texture return methods
- @Override
- public ResourceLocation getStillTexture() {
- return stillTexture;
- }
- @Override
- public ResourceLocation getFlowingTexture(FluidStack stack) {
- return flowingTexture;
- }
- @Override
- public @Nullable ResourceLocation getOverlayTexture() {
- return overlayTexture;
- }
- //Tint color return method
- @Override
- public int getTintColor() {
- return tintColor;
- }
- //Fog color and distance modifiers
- @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);
- }
- });
- }
- //Getters
- public ResourceLocation getStillTexture() {
- return stillTexture;
- }
- public ResourceLocation getFlowingTexture() {
- return flowingTexture;
- }
- public ResourceLocation getOverlayTexture() {
- return overlayTexture;
- }
- public int getTintColor() {
- return tintColor;
- }
- public Vector3f getFogColor() {
- return fogColor;
- }
- }
Add Comment
Please, Sign In to add comment