Skip to content

Commit

Permalink
fix: Fix crash on dedicated server due to fluid render handler
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Aug 19, 2024
1 parent 3784052 commit ce1c54d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.blay09.mods.balm.api.entity.BalmEntity;
import net.blay09.mods.balm.api.fluid.BalmFluidTankProvider;
import net.blay09.mods.balm.api.fluid.FluidTank;
import net.blay09.mods.balm.api.proxy.SidedProxy;
import net.blay09.mods.balm.config.ExampleConfig;
import net.blay09.mods.balm.fabric.fluid.BalmFluidStorage;
import net.blay09.mods.balm.fabric.provider.FabricBalmProviders;
Expand All @@ -19,8 +20,12 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container;

import static net.blay09.mods.balm.api.Balm.sidedProxy;

public class FabricBalm implements ModInitializer {

private static final SidedProxy<FabricBalmProxy> proxy = sidedProxy("net.blay09.mods.balm.fabric.FabricBalmProxy", "net.blay09.mods.balm.fabric.client.FabricBalmClientProxy");

@Override
public void onInitialize() {
((FabricBalmHooks) Balm.getHooks()).initialize();
Expand Down Expand Up @@ -58,4 +63,8 @@ public void onInitialize() {

Balm.initializeIfLoaded("team_reborn_energy", "net.blay09.mods.balm.fabric.compat.energy.RebornEnergy");
}

public static FabricBalmProxy getProxy() {
return proxy.get();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package net.blay09.mods.balm.fabric;

import net.blay09.mods.balm.fabric.fluid.SimpleMilkFluid;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.material.Fluid;

public class FabricBalmProxy {
public Fluid enableMilkFluid() {
return Registry.register(BuiltInRegistries.FLUID, new ResourceLocation("balm-fabric", "milk"), new SimpleMilkFluid());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public TagKey<Item> getItemTag(ResourceLocation key) {

@Override
public void enableMilkFluid() {
milkFluid = Registry.register(BuiltInRegistries.FLUID, new ResourceLocation("balm-fabric", "milk"), new SimpleMilkFluid());
FluidRenderHandlerRegistry.INSTANCE.register(milkFluid, new SimpleFluidRenderHandler(SimpleFluidRenderHandler.WATER_STILL, SimpleFluidRenderHandler.WATER_FLOWING, 0xFFFFFFFF));
milkFluid = FabricBalm.getProxy().enableMilkFluid();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package net.blay09.mods.balm.fabric.client;

import net.blay09.mods.balm.fabric.FabricBalmProxy;
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
import net.fabricmc.fabric.api.client.render.fluid.v1.SimpleFluidRenderHandler;
import net.minecraft.world.level.material.Fluid;

public class FabricBalmClientProxy extends FabricBalmProxy {

@Override
public Fluid enableMilkFluid() {
final var fluid = super.enableMilkFluid();
FluidRenderHandlerRegistry.INSTANCE.register(fluid, new SimpleFluidRenderHandler(SimpleFluidRenderHandler.WATER_STILL, SimpleFluidRenderHandler.WATER_FLOWING, 0xFFFFFFFF));
return fluid;
}
}

0 comments on commit ce1c54d

Please sign in to comment.