mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-02-12 13:25:01 +01:00
Honey Vision
- Moved fluid fog distance and colour handling to their fluid types - Bumped Flywheel
This commit is contained in:
parent
28bc839572
commit
364ad6edf2
3 changed files with 75 additions and 52 deletions
|
@ -23,7 +23,7 @@ use_parchment = true
|
||||||
# dependency versions
|
# dependency versions
|
||||||
registrate_version = MC1.19-1.1.5
|
registrate_version = MC1.19-1.1.5
|
||||||
flywheel_minecraft_version = 1.19.2
|
flywheel_minecraft_version = 1.19.2
|
||||||
flywheel_version = 0.6.9-17
|
flywheel_version = 0.6.9-18
|
||||||
jei_minecraft_version = 1.19.2
|
jei_minecraft_version = 1.19.2
|
||||||
jei_version = 11.2.0.254
|
jei_version = 11.2.0.254
|
||||||
curios_minecraft_version = 1.19.2
|
curios_minecraft_version = 1.19.2
|
||||||
|
|
|
@ -3,16 +3,28 @@ package com.simibubi.create;
|
||||||
import static com.simibubi.create.Create.REGISTRATE;
|
import static com.simibubi.create.Create.REGISTRATE;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.shaders.FogShape;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.math.Vector3f;
|
||||||
import com.simibubi.create.AllTags.AllFluidTags;
|
import com.simibubi.create.AllTags.AllFluidTags;
|
||||||
import com.simibubi.create.content.decoration.palettes.AllPaletteStoneTypes;
|
import com.simibubi.create.content.decoration.palettes.AllPaletteStoneTypes;
|
||||||
import com.simibubi.create.content.fluids.VirtualFluid;
|
import com.simibubi.create.content.fluids.VirtualFluid;
|
||||||
import com.simibubi.create.content.fluids.potion.PotionFluid;
|
import com.simibubi.create.content.fluids.potion.PotionFluid;
|
||||||
import com.simibubi.create.content.fluids.potion.PotionFluid.PotionFluidType;
|
import com.simibubi.create.content.fluids.potion.PotionFluid.PotionFluidType;
|
||||||
|
import com.simibubi.create.foundation.utility.Color;
|
||||||
|
import com.simibubi.create.infrastructure.config.AllConfigs;
|
||||||
|
import com.tterrag.registrate.builders.FluidBuilder.FluidTypeFactory;
|
||||||
import com.tterrag.registrate.util.entry.FluidEntry;
|
import com.tterrag.registrate.util.entry.FluidEntry;
|
||||||
|
|
||||||
|
import net.minecraft.client.Camera;
|
||||||
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
|
import net.minecraft.client.renderer.FogRenderer.FogMode;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.BlockAndTintGetter;
|
import net.minecraft.world.level.BlockAndTintGetter;
|
||||||
|
@ -41,7 +53,9 @@ public class AllFluids {
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final FluidEntry<ForgeFlowingFluid.Flowing> HONEY =
|
public static final FluidEntry<ForgeFlowingFluid.Flowing> HONEY =
|
||||||
REGISTRATE.standardFluid("honey", NoColorFluidAttributes::new)
|
REGISTRATE.standardFluid("honey",
|
||||||
|
SolidRenderedPlaceableFluidType.create(0xEAAE2F,
|
||||||
|
() -> 1f / 8f * AllConfigs.client().honeyTransparencyMultiplier.getF()))
|
||||||
.lang("Honey")
|
.lang("Honey")
|
||||||
.properties(b -> b.viscosity(2000)
|
.properties(b -> b.viscosity(2000)
|
||||||
.density(1400))
|
.density(1400))
|
||||||
|
@ -57,7 +71,9 @@ public class AllFluids {
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final FluidEntry<ForgeFlowingFluid.Flowing> CHOCOLATE =
|
public static final FluidEntry<ForgeFlowingFluid.Flowing> CHOCOLATE =
|
||||||
REGISTRATE.standardFluid("chocolate", NoColorFluidAttributes::new)
|
REGISTRATE.standardFluid("chocolate",
|
||||||
|
SolidRenderedPlaceableFluidType.create(0x622020,
|
||||||
|
() -> 1f / 32f * AllConfigs.client().chocolateTransparencyMultiplier.getF()))
|
||||||
.lang("Chocolate")
|
.lang("Chocolate")
|
||||||
.tag(AllTags.forgeFluidTag("chocolate"))
|
.tag(AllTags.forgeFluidTag("chocolate"))
|
||||||
.properties(b -> b.viscosity(1500)
|
.properties(b -> b.viscosity(1500)
|
||||||
|
@ -149,6 +165,25 @@ public class AllFluids {
|
||||||
public int getTintColor(FluidState state, BlockAndTintGetter getter, BlockPos pos) {
|
public int getTintColor(FluidState state, BlockAndTintGetter getter, BlockPos pos) {
|
||||||
return TintedFluidType.this.getTintColor(state, getter, pos);
|
return TintedFluidType.this.getTintColor(state, getter, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Vector3f modifyFogColor(Camera camera, float partialTick, ClientLevel level,
|
||||||
|
int renderDistance, float darkenWorldAmount, Vector3f fluidFogColor) {
|
||||||
|
Vector3f customFogColor = TintedFluidType.this.getCustomFogColor();
|
||||||
|
return customFogColor == null ? fluidFogColor : customFogColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void modifyFogRender(Camera camera, FogMode mode, float renderDistance, float partialTick,
|
||||||
|
float nearDistance, float farDistance, FogShape shape) {
|
||||||
|
float modifier = TintedFluidType.this.getFogDistanceModifier();
|
||||||
|
float baseWaterFog = 96.0f;
|
||||||
|
if (modifier != 1f) {
|
||||||
|
RenderSystem.setShaderFogShape(FogShape.CYLINDER);
|
||||||
|
RenderSystem.setShaderFogStart(-8);
|
||||||
|
RenderSystem.setShaderFogEnd(baseWaterFog * modifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -156,16 +191,32 @@ public class AllFluids {
|
||||||
protected abstract int getTintColor(FluidStack stack);
|
protected abstract int getTintColor(FluidStack stack);
|
||||||
|
|
||||||
protected abstract int getTintColor(FluidState state, BlockAndTintGetter getter, BlockPos pos);
|
protected abstract int getTintColor(FluidState state, BlockAndTintGetter getter, BlockPos pos);
|
||||||
|
|
||||||
|
protected Vector3f getCustomFogColor() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected float getFogDistanceModifier() {
|
||||||
|
return 1f;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private static class SolidRenderedPlaceableFluidType extends TintedFluidType {
|
||||||
* Removing alpha from tint prevents optifine from forcibly applying biome
|
|
||||||
* colors to modded fluids (Makes translucent fluids disappear)
|
|
||||||
*/
|
|
||||||
private static class NoColorFluidAttributes extends TintedFluidType {
|
|
||||||
|
|
||||||
public NoColorFluidAttributes(Properties properties, ResourceLocation stillTexture,
|
private Vector3f fogColor;
|
||||||
|
private Supplier<Float> fogDistance;
|
||||||
|
|
||||||
|
public static FluidTypeFactory create(int fogColor, Supplier<Float> fogDistance) {
|
||||||
|
return (p, s, f) -> {
|
||||||
|
SolidRenderedPlaceableFluidType fluidType = new SolidRenderedPlaceableFluidType(p, s, f);
|
||||||
|
fluidType.fogColor = new Color(fogColor, false).asVectorF();
|
||||||
|
fluidType.fogDistance = fogDistance;
|
||||||
|
return fluidType;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private SolidRenderedPlaceableFluidType(Properties properties, ResourceLocation stillTexture,
|
||||||
ResourceLocation flowingTexture) {
|
ResourceLocation flowingTexture) {
|
||||||
super(properties, stillTexture, flowingTexture);
|
super(properties, stillTexture, flowingTexture);
|
||||||
}
|
}
|
||||||
|
@ -175,10 +226,25 @@ public class AllFluids {
|
||||||
return NO_TINT;
|
return NO_TINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Removing alpha from tint prevents optifine from forcibly applying biome
|
||||||
|
* colors to modded fluids (this workaround only works for fluids in the solid
|
||||||
|
* render layer)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getTintColor(FluidState state, BlockAndTintGetter world, BlockPos pos) {
|
public int getTintColor(FluidState state, BlockAndTintGetter world, BlockPos pos) {
|
||||||
return 0x00ffffff;
|
return 0x00ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Vector3f getCustomFogColor() {
|
||||||
|
return fogColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float getFogDistanceModifier() {
|
||||||
|
return fogDistance.get();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.simibubi.create.foundation.events;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.simibubi.create.AllFluids;
|
|
||||||
import com.simibubi.create.AllItems;
|
import com.simibubi.create.AllItems;
|
||||||
import com.simibubi.create.AllPackets;
|
import com.simibubi.create.AllPackets;
|
||||||
import com.simibubi.create.Create;
|
import com.simibubi.create.Create;
|
||||||
|
@ -298,20 +297,6 @@ public class ClientEvents {
|
||||||
Fluid fluid = fluidState.getType();
|
Fluid fluid = fluidState.getType();
|
||||||
Entity entity = camera.getEntity();
|
Entity entity = camera.getEntity();
|
||||||
|
|
||||||
if (AllFluids.CHOCOLATE.get()
|
|
||||||
.isSame(fluid)) {
|
|
||||||
event.scaleFarPlaneDistance(1f / 32f * AllConfigs.client().chocolateTransparencyMultiplier.getF());
|
|
||||||
event.setCanceled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AllFluids.HONEY.get()
|
|
||||||
.isSame(fluid)) {
|
|
||||||
event.scaleFarPlaneDistance(1f / 8f * AllConfigs.client().honeyTransparencyMultiplier.getF());
|
|
||||||
event.setCanceled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity.isSpectator())
|
if (entity.isSpectator())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -330,34 +315,6 @@ public class ClientEvents {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void getFogColor(ViewportEvent.ComputeFogColor event) {
|
|
||||||
Camera info = event.getCamera();
|
|
||||||
Level level = Minecraft.getInstance().level;
|
|
||||||
BlockPos blockPos = info.getBlockPosition();
|
|
||||||
FluidState fluidState = level.getFluidState(blockPos);
|
|
||||||
if (info.getPosition().y > blockPos.getY() + fluidState.getHeight(level, blockPos))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Fluid fluid = fluidState.getType();
|
|
||||||
|
|
||||||
if (AllFluids.CHOCOLATE.get()
|
|
||||||
.isSame(fluid)) {
|
|
||||||
event.setRed(98 / 255f);
|
|
||||||
event.setGreen(32 / 255f);
|
|
||||||
event.setBlue(32 / 255f);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AllFluids.HONEY.get()
|
|
||||||
.isSame(fluid)) {
|
|
||||||
event.setRed(234 / 255f);
|
|
||||||
event.setGreen(174 / 255f);
|
|
||||||
event.setBlue(47 / 255f);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void leftClickEmpty(PlayerInteractEvent.LeftClickEmpty event) {
|
public static void leftClickEmpty(PlayerInteractEvent.LeftClickEmpty event) {
|
||||||
ItemStack stack = event.getItemStack();
|
ItemStack stack = event.getItemStack();
|
||||||
|
|
Loading…
Reference in a new issue