From d61e185f35471d951bc87f66000f8cc213c7eba1 Mon Sep 17 00:00:00 2001 From: ThatGravyBoat Date: Wed, 19 Jun 2024 00:32:54 -0230 Subject: [PATCH] fix crash if someone used stack sensitive texture on neo fixed crash if someone used stack sensitive texture on neo --- .../fluid/data/ClientFluidProperties.java | 16 ++++---- .../fluid/neoforge/ResourcefulFluidType.java | 40 ++++++++++++++++++- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/common/src/main/java/com/teamresourceful/resourcefullib/client/fluid/data/ClientFluidProperties.java b/common/src/main/java/com/teamresourceful/resourcefullib/client/fluid/data/ClientFluidProperties.java index 1e8596c..42ab7bc 100644 --- a/common/src/main/java/com/teamresourceful/resourcefullib/client/fluid/data/ClientFluidProperties.java +++ b/common/src/main/java/com/teamresourceful/resourcefullib/client/fluid/data/ClientFluidProperties.java @@ -26,11 +26,11 @@ public interface ClientFluidProperties { - ResourceLocation still(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, FluidState state); + ResourceLocation still(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, @Nullable FluidState state); - ResourceLocation flowing(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, FluidState state); + ResourceLocation flowing(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, @Nullable FluidState state); - ResourceLocation overlay(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, FluidState state); + ResourceLocation overlay(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, @Nullable FluidState state); ResourceLocation screenOverlay(); @@ -63,7 +63,7 @@ default void renderOverlay(Minecraft minecraft, PoseStack stack) { } } - int tintColor(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, FluidState state); + int tintColor(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, @Nullable FluidState state); default boolean renderFluid( BlockPos pos, @@ -134,17 +134,17 @@ public ClientFluidProperties build() { return new ClientFluidProperties() { @Override - public ResourceLocation still(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, FluidState state) { + public ResourceLocation still(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, @Nullable FluidState state) { return still.apply(view, pos, state); } @Override - public ResourceLocation flowing(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, FluidState state) { + public ResourceLocation flowing(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, @Nullable FluidState state) { return flowing.apply(view, pos, state); } @Override - public ResourceLocation overlay(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, FluidState state) { + public ResourceLocation overlay(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, @Nullable FluidState state) { return overlay.apply(view, pos, state); } @@ -154,7 +154,7 @@ public ResourceLocation screenOverlay() { } @Override - public int tintColor(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, FluidState state) { + public int tintColor(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, @Nullable FluidState state) { return tintColor.apply(view, pos, state); } diff --git a/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/fluid/neoforge/ResourcefulFluidType.java b/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/fluid/neoforge/ResourcefulFluidType.java index 37fa578..6c18108 100644 --- a/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/fluid/neoforge/ResourcefulFluidType.java +++ b/neoforge/src/main/java/com/teamresourceful/resourcefullib/common/fluid/neoforge/ResourcefulFluidType.java @@ -22,6 +22,7 @@ import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.fluids.FluidType; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.joml.Vector3f; import java.util.function.Consumer; @@ -67,16 +68,46 @@ private ClientFluidProperties properties() { return properties; } + @Override + public @NotNull ResourceLocation getStillTexture() { + return properties().still(null, null, null); + } + + @Override + public @NotNull ResourceLocation getStillTexture(@NotNull FluidStack stack) { + return properties().still(null, null, stack.getFluid().defaultFluidState()); + } + @Override public @NotNull ResourceLocation getStillTexture(@NotNull FluidState state, @NotNull BlockAndTintGetter getter, @NotNull BlockPos pos) { return properties().still(getter, pos, state); } + @Override + public @NotNull ResourceLocation getFlowingTexture() { + return properties().flowing(null, null, null); + } + + @Override + public @NotNull ResourceLocation getFlowingTexture(@NotNull FluidStack stack) { + return properties().flowing(null, null, stack.getFluid().defaultFluidState()); + } + @Override public @NotNull ResourceLocation getFlowingTexture(@NotNull FluidState state, @NotNull BlockAndTintGetter getter, @NotNull BlockPos pos) { return properties().flowing(getter, pos, state); } + @Override + public @Nullable ResourceLocation getOverlayTexture() { + return properties().overlay(null, null, null); + } + + @Override + public @NotNull ResourceLocation getOverlayTexture(@NotNull FluidStack stack) { + return properties().overlay(null, null, stack.getFluid().defaultFluidState()); + } + @Override public @NotNull ResourceLocation getOverlayTexture(@NotNull FluidState state, @NotNull BlockAndTintGetter getter, @NotNull BlockPos pos) { return properties().overlay(getter, pos, state); @@ -88,8 +119,8 @@ public void renderOverlay(@NotNull Minecraft mc, @NotNull PoseStack poseStack) { } @Override - public int getTintColor(@NotNull FluidState state, @NotNull BlockAndTintGetter getter, @NotNull BlockPos pos) { - return properties().tintColor(getter, pos, state); + public int getTintColor() { + return properties().tintColor(null, null, null); } @Override @@ -97,6 +128,11 @@ public int getTintColor(@NotNull FluidStack stack) { return properties().tintColor(null, null, stack.getFluid().defaultFluidState()); } + @Override + public int getTintColor(@NotNull FluidState state, @NotNull BlockAndTintGetter getter, @NotNull BlockPos pos) { + return properties().tintColor(getter, pos, state); + } + @Override public boolean renderFluid(@NotNull FluidState fluidState, @NotNull BlockAndTintGetter getter, @NotNull BlockPos pos, @NotNull VertexConsumer vertexConsumer, @NotNull BlockState blockState) { if (properties().renderFluid(pos, getter, vertexConsumer, blockState, fluidState, FluidSpriteCache::getSprite)) {