diff --git a/src/main/java/kasuga/lib/core/KasugaLibStacks.java b/src/main/java/kasuga/lib/core/KasugaLibStacks.java index 6687fd0b..26801acc 100644 --- a/src/main/java/kasuga/lib/core/KasugaLibStacks.java +++ b/src/main/java/kasuga/lib/core/KasugaLibStacks.java @@ -57,7 +57,7 @@ public class KasugaLibStacks { private final FontRegistry FONTS; private final RandomSource random = RandomSource.create(); private final HashMap BLOCK_RENDERERS; - public static final HashMap, RenderType> FLUID_RENDERS = new HashMap<>(); + public static final HashMap, String> FLUID_RENDERS = new HashMap<>(); public final JavascriptApi JAVASCRIPT = new JavascriptApi(); diff --git a/src/main/java/kasuga/lib/example_env/AllExampleElements.java b/src/main/java/kasuga/lib/example_env/AllExampleElements.java index 4c72f56f..8d020428 100644 --- a/src/main/java/kasuga/lib/example_env/AllExampleElements.java +++ b/src/main/java/kasuga/lib/example_env/AllExampleElements.java @@ -157,7 +157,7 @@ public class AllExampleElements { .blockType((fluid, properties) -> new ExampleFluidBlock(fluid, BlockBehaviour.Properties.copy(Blocks.WATER))) .noLootAndOcclusion() - .setRenderType(RenderType.translucent()) + .setRenderType("translucent") .tab(tab) .submit(REGISTRY); diff --git a/src/main/java/kasuga/lib/registrations/common/FluidReg.java b/src/main/java/kasuga/lib/registrations/common/FluidReg.java index 70a1db12..b4f5d03e 100644 --- a/src/main/java/kasuga/lib/registrations/common/FluidReg.java +++ b/src/main/java/kasuga/lib/registrations/common/FluidReg.java @@ -23,8 +23,12 @@ import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.material.Fluid; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.client.NamedRenderTypeManager; import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions; import net.minecraftforge.common.SoundAction; import net.minecraftforge.common.SoundActions; @@ -63,7 +67,7 @@ public class FluidReg extends Reg { private int tintColor = 0xffffff; boolean registerItem = false, registerBlock = false, registerMenu = false; private final FluidTagReg tag; - private RenderType renderType = null; + private String renderType = "solid"; private Vector3f fogColor = null; /** @@ -434,20 +438,26 @@ public FluidReg sound(SoundEvent fillSound, SoundEvent emptySound, SoundEvent return bucketFillSound(fillSound).bucketEmptySound(emptySound).vaporizeSound(vaporizeSound); } + @Optional + public FluidReg blockSound(SoundType sound) { + block.withSound(sound); + return this; + } + @Optional public FluidReg defaultSounds() { return sound(SoundEvents.BUCKET_FILL, SoundEvents.BUCKET_EMPTY, SoundEvents.FIRE_EXTINGUISH); } @Optional - public FluidReg setRenderType(RenderType type) { + public FluidReg setRenderType(String type) { this.renderType = type; return this; } @Optional public FluidReg setTranslucentRenderType() { - this.renderType = RenderType.translucent(); + this.renderType = "translucent"; return this; } @@ -543,10 +553,15 @@ public LiquidBlock legacyBlock() { return block.getBlock(); } - public RenderType getRenderType() { + public String getRenderType() { return renderType; } + @OnlyIn(Dist.CLIENT) + public RenderType genRenderType() { + return NamedRenderTypeManager.get(new ResourceLocation(renderType)).block(); + } + @Override public String getIdentifier() { return "fluid"; diff --git a/src/main/java/kasuga/lib/registrations/registry/SimpleRegistry.java b/src/main/java/kasuga/lib/registrations/registry/SimpleRegistry.java index 4ec1fd4a..be301e03 100644 --- a/src/main/java/kasuga/lib/registrations/registry/SimpleRegistry.java +++ b/src/main/java/kasuga/lib/registrations/registry/SimpleRegistry.java @@ -34,11 +34,13 @@ import net.minecraft.world.level.material.Fluid; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.client.NamedRenderTypeManager; import net.minecraftforge.client.event.ModelEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fluids.FluidType; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; +import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; @@ -443,10 +445,11 @@ public void onCustomItemRendererReg(Map registry) @Inner @SubscribeEvent @OnlyIn(Dist.CLIENT) - public void hookFluidAndRenders(FMLLoadCompleteEvent event) { - for (Map.Entry, RenderType> entry : KasugaLibStacks.FLUID_RENDERS.entrySet()) { - ItemBlockRenderTypes.setRenderLayer(entry.getKey().stillFluid(), entry.getValue()); - ItemBlockRenderTypes.setRenderLayer(entry.getKey().flowingFluid(), entry.getValue()); + public void hookFluidAndRenders(FMLCommonSetupEvent event) { + for (Map.Entry, String> entry : KasugaLibStacks.FLUID_RENDERS.entrySet()) { + RenderType type = NamedRenderTypeManager.get(new ResourceLocation(entry.getValue())).block(); + ItemBlockRenderTypes.setRenderLayer(entry.getKey().stillFluid(), type); + ItemBlockRenderTypes.setRenderLayer(entry.getKey().flowingFluid(), type); } }