Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't classload FluidRenderHandler on dedicated server #1529

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,7 +14,6 @@
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;

Expand Down Expand Up @@ -51,8 +48,7 @@ private static void initFabricFluidTypes() {
ResourceKey<Fluid> key = entry.getKey();
Fluid fluid = entry.getValue();
if (ModList.get().getModContainerById(key.location().getNamespace()).map(c -> ConnectorEarlyLoader.isConnectorMod(c.getModId())).orElse(false)) {
FluidRenderHandler renderHandler = FluidRenderHandlerRegistry.INSTANCE.get(fluid);
FluidType type = new FabricFluidType(FluidType.Properties.create(), fluid, renderHandler);
FluidType type = new FabricFluidType(FluidType.Properties.create(), fluid);
FABRIC_FLUID_TYPES.put(fluid, type);
FABRIC_FLUID_TYPES_BY_NAME.put(key.location(), type);
}
Expand All @@ -64,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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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());
Expand Down
8 changes: 4 additions & 4 deletions src/mod/resources/connector.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@
"item.IItemExtensionMixin",
"item.ItemStackMixin",
"network.StreamCodecMixin",
"recipebook.RecipeBookCategoriesAccessor",
"recipebook.RecipeBookCategoriesMixin",
"recipebook.RecipeBookManagerMixin",
"registries.DataPackRegistriesHooksAccessor",
"registries.MappedRegistryAccessor",
"registries.NeoForgeRegistriesSetupAccessor",
"registries.BuiltInRegistriesMixin",
"registries.EntityDataSerializersMixin",
"registries.ItemBlockRenderTypesMixin",
"registries.NeoForgeRegistriesSetupMixin",
"registries.NetworkRegistryMixin",
"registries.PoiTypesMixin",
Expand All @@ -34,7 +31,10 @@
"client.ItemColorsMixin",
"client.ItemOverridesMixin",
"client.KeyMappingMixin",
"client.ParticleEngineMixin"
"client.ParticleEngineMixin",
"recipebook.RecipeBookCategoriesAccessor",
"recipebook.RecipeBookCategoriesMixin",
"registries.ItemBlockRenderTypesMixin"
],
"server": [
"boot.ServerMainMixin"
Expand Down
Loading