diff --git a/src/mod/java/org/sinytra/connector/mod/compat/FluidHandlerCompat.java b/src/mod/java/org/sinytra/connector/mod/compat/FluidHandlerCompat.java index 40f8790..a56a6ea 100644 --- a/src/mod/java/org/sinytra/connector/mod/compat/FluidHandlerCompat.java +++ b/src/mod/java/org/sinytra/connector/mod/compat/FluidHandlerCompat.java @@ -1,8 +1,6 @@ package org.sinytra.connector.mod.compat; import com.mojang.logging.LogUtils; -import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler; -import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariantAttributes; import net.minecraft.core.registries.BuiltInRegistries; @@ -12,12 +10,10 @@ import net.minecraft.world.level.material.Fluid; import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.ModList; -import net.neoforged.fml.loading.FMLEnvironment; import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.fluids.FluidType; import net.neoforged.neoforge.registries.NeoForgeRegistries; import net.neoforged.neoforge.registries.RegisterEvent; -import org.jetbrains.annotations.Nullable; import org.sinytra.connector.ConnectorEarlyLoader; import org.slf4j.Logger; @@ -52,13 +48,7 @@ private static void initFabricFluidTypes() { ResourceKey key = entry.getKey(); Fluid fluid = entry.getValue(); if (ModList.get().getModContainerById(key.location().getNamespace()).map(c -> ConnectorEarlyLoader.isConnectorMod(c.getModId())).orElse(false)) { - FluidType type; - if (FMLEnvironment.dist.isClient()) { - FluidRenderHandler renderHandler = FluidRenderHandlerRegistry.INSTANCE.get(fluid); - type = new FabricFluidType(FluidType.Properties.create(), fluid, renderHandler); - } else { - type = new FabricFluidType(FluidType.Properties.create(), fluid, null); - } + FluidType type = new FabricFluidType(FluidType.Properties.create(), fluid); FABRIC_FLUID_TYPES.put(fluid, type); FABRIC_FLUID_TYPES_BY_NAME.put(key.location(), type); } @@ -70,20 +60,13 @@ private static void onRegisterFluids(RegisterEvent event) { } static class FabricFluidType extends FluidType { - @Nullable - private final FluidRenderHandler renderHandler; private final Component name; - public FabricFluidType(Properties properties, Fluid fluid, @Nullable FluidRenderHandler renderHandler) { + public FabricFluidType(Properties properties, Fluid fluid) { super(properties); - this.renderHandler = renderHandler; this.name = FluidVariantAttributes.getName(FluidVariant.of(fluid)); } - public FluidRenderHandler getRenderHandler() { - return renderHandler; - } - @Override public Component getDescription() { return this.name.copy(); diff --git a/src/mod/java/org/sinytra/connector/mod/compat/FluidHandlerCompatClient.java b/src/mod/java/org/sinytra/connector/mod/compat/FluidHandlerCompatClient.java index aecd515..11dc2e1 100644 --- a/src/mod/java/org/sinytra/connector/mod/compat/FluidHandlerCompatClient.java +++ b/src/mod/java/org/sinytra/connector/mod/compat/FluidHandlerCompatClient.java @@ -1,6 +1,7 @@ package org.sinytra.connector.mod.compat; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler; +import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceLocation; @@ -14,7 +15,7 @@ public final class FluidHandlerCompatClient { public static void onRegisterClientExtensions(RegisterClientExtensionsEvent event) { FluidHandlerCompat.getFabricFluidTypes().forEach((fluid, type) -> { - FluidRenderHandler renderHandler = ((FluidHandlerCompat.FabricFluidType) type).getRenderHandler(); + FluidRenderHandler renderHandler = FluidRenderHandlerRegistry.INSTANCE.get(fluid); event.registerFluidType(new IClientFluidTypeExtensions() { private TextureAtlasSprite[] getSprites() { return renderHandler.getFluidSprites(null, null, fluid.defaultFluidState());