Skip to content

Commit

Permalink
fix crash if someone used stack sensitive texture on neo
Browse files Browse the repository at this point in the history
<log>fixed crash if someone used stack sensitive texture on neo</log>
  • Loading branch information
ThatGravyBoat committed Jun 19, 2024
1 parent 849183d commit d61e185
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -88,15 +119,20 @@ 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
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)) {
Expand Down

0 comments on commit d61e185

Please sign in to comment.