diff --git a/src/main/java/vazkii/quark/addons/oddities/block/pipe/BasePipeBlock.java b/src/main/java/vazkii/quark/addons/oddities/block/pipe/BasePipeBlock.java index 960bc30f09..8ac4d271a4 100644 --- a/src/main/java/vazkii/quark/addons/oddities/block/pipe/BasePipeBlock.java +++ b/src/main/java/vazkii/quark/addons/oddities/block/pipe/BasePipeBlock.java @@ -26,8 +26,8 @@ import vazkii.quark.addons.oddities.block.be.PipeBlockEntity; import vazkii.quark.addons.oddities.module.PipesModule; import vazkii.quark.base.block.QuarkBlock; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.registry.RenderLayerRegistry; import javax.annotation.Nonnull; import java.util.HashSet; @@ -63,7 +63,7 @@ protected BasePipeBlock(String name, ZetaModule module) { .noOcclusion()); registerDefaultState(getDefaultPipeState()); - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); } public BlockState getDefaultPipeState() { diff --git a/src/main/java/vazkii/quark/base/block/QuarkBushBlock.java b/src/main/java/vazkii/quark/base/block/QuarkBushBlock.java index 3080377422..5a53213b01 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkBushBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkBushBlock.java @@ -11,8 +11,8 @@ import net.minecraft.world.level.block.BushBlock; import vazkii.quark.base.Quark; import vazkii.quark.base.handler.CreativeTabHandler; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.registry.RenderLayerRegistry; public class QuarkBushBlock extends BushBlock implements IQuarkBlock { @@ -27,7 +27,7 @@ public QuarkBushBlock(String regname, ZetaModule module, CreativeModeTab creativ CreativeTabHandler.addTab(this, creativeTab); - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); } @Override diff --git a/src/main/java/vazkii/quark/base/block/QuarkDoorBlock.java b/src/main/java/vazkii/quark/base/block/QuarkDoorBlock.java index 8fba5b8b83..c9bddc1f14 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkDoorBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkDoorBlock.java @@ -12,12 +12,11 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.DoorBlock; -import vazkii.quark.base.Quark; import vazkii.quark.base.handler.CreativeTabHandler; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.quark.base.item.QuarkDoubleHighBlockItem; import vazkii.zeta.module.ZetaModule; import vazkii.zeta.registry.IZetaBlockItemProvider; +import vazkii.zeta.registry.RenderLayerRegistry; public class QuarkDoorBlock extends DoorBlock implements IQuarkBlock, IZetaBlockItemProvider { @@ -28,8 +27,8 @@ public QuarkDoorBlock(String regname, ZetaModule module, CreativeModeTab creativ super(properties); this.module = module; - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); - Quark.ZETA.registry.registerBlock(this, regname, true); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); + module.zeta.registry.registerBlock(this, regname, true); CreativeTabHandler.addTab(this, creativeTab); } diff --git a/src/main/java/vazkii/quark/base/block/QuarkGlassBlock.java b/src/main/java/vazkii/quark/base/block/QuarkGlassBlock.java index 97cd8003e7..5ae521d5d7 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkGlassBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkGlassBlock.java @@ -14,8 +14,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.registry.RenderLayerRegistry; /** * @author WireSegal @@ -30,8 +30,8 @@ public QuarkGlassBlock(String regname, ZetaModule module, CreativeModeTab creati .isRedstoneConductor((state, world, pos) -> false) .isSuffocating((state, world, pos) -> false) .isViewBlocking((state, world, pos) -> false)); - - RenderLayerHandler.setRenderType(this, translucent ? RenderLayerHandler.RenderTypeSkeleton.TRANSLUCENT : RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + + module.zeta.renderLayerRegistry.put(this, translucent ? RenderLayerRegistry.Layer.TRANSLUCENT : RenderLayerRegistry.Layer.CUTOUT); } @Override diff --git a/src/main/java/vazkii/quark/base/block/QuarkInheritedPaneBlock.java b/src/main/java/vazkii/quark/base/block/QuarkInheritedPaneBlock.java index 0a5166bee2..8a597af8aa 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkInheritedPaneBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkInheritedPaneBlock.java @@ -6,7 +6,7 @@ import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import vazkii.quark.base.handler.RenderLayerHandler; +import vazkii.quark.base.Quark; import vazkii.zeta.registry.IZetaBlockColorProvider; import vazkii.zeta.registry.IZetaItemColorProvider; @@ -22,7 +22,7 @@ public QuarkInheritedPaneBlock(IQuarkBlock parent, String name, Block.Properties super(name, parent.getModule(), properties, null); this.parent = parent; - RenderLayerHandler.setInherited(this, parent.getBlock()); + Quark.ZETA.renderLayerRegistry.mock(this, parent.getBlock()); } public QuarkInheritedPaneBlock(IQuarkBlock parent, Block.Properties properties) { diff --git a/src/main/java/vazkii/quark/base/block/QuarkLeavesBlock.java b/src/main/java/vazkii/quark/base/block/QuarkLeavesBlock.java index 6b65a953be..9598383821 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkLeavesBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkLeavesBlock.java @@ -10,10 +10,9 @@ import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.MaterialColor; -import vazkii.quark.base.Quark; import vazkii.quark.base.handler.CreativeTabHandler; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.registry.RenderLayerRegistry; public class QuarkLeavesBlock extends LeavesBlock implements IQuarkBlock { @@ -32,10 +31,10 @@ public QuarkLeavesBlock(String name, ZetaModule module, MaterialColor color) { this.module = module; - Quark.ZETA.registry.registerBlock(this, name + "_leaves", true); + module.zeta.registry.registerBlock(this, name + "_leaves", true); CreativeTabHandler.addTab(this, CreativeModeTab.TAB_DECORATIONS); - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT_MIPPED); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT_MIPPED); } @Nullable diff --git a/src/main/java/vazkii/quark/base/block/QuarkPaneBlock.java b/src/main/java/vazkii/quark/base/block/QuarkPaneBlock.java index 0b57f3baaf..8ea3df4b8e 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkPaneBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkPaneBlock.java @@ -5,10 +5,8 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.IronBarsBlock; -import vazkii.quark.base.Quark; import vazkii.quark.base.handler.CreativeTabHandler; -import vazkii.quark.base.handler.RenderLayerHandler; -import vazkii.quark.base.handler.RenderLayerHandler.RenderTypeSkeleton; +import vazkii.zeta.registry.RenderLayerRegistry.Layer; import vazkii.zeta.module.ZetaModule; import javax.annotation.Nonnull; @@ -20,15 +18,15 @@ public class QuarkPaneBlock extends IronBarsBlock implements IQuarkBlock { public final ZetaModule module; private BooleanSupplier enabledSupplier = () -> true; - public QuarkPaneBlock(String name, ZetaModule module, Block.Properties properties, RenderTypeSkeleton renderType) { + public QuarkPaneBlock(String name, ZetaModule module, Block.Properties properties, Layer renderLayer) { super(properties); this.module = module; - Quark.ZETA.registry.registerBlock(this, name, true); + module.zeta.registry.registerBlock(this, name, true); CreativeTabHandler.addTab(this, CreativeModeTab.TAB_DECORATIONS); - if(renderType != null) - RenderLayerHandler.setRenderType(this, renderType); + if(renderLayer != null) + module.zeta.renderLayerRegistry.put(this, renderLayer); } @Override diff --git a/src/main/java/vazkii/quark/base/block/QuarkSaplingBlock.java b/src/main/java/vazkii/quark/base/block/QuarkSaplingBlock.java index 1bafbeb187..63d98b7167 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkSaplingBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkSaplingBlock.java @@ -11,10 +11,9 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.SaplingBlock; import net.minecraft.world.level.block.grower.AbstractTreeGrower; -import vazkii.quark.base.Quark; import vazkii.quark.base.handler.CreativeTabHandler; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.registry.RenderLayerRegistry; public abstract class QuarkSaplingBlock extends SaplingBlock implements IQuarkBlock { @@ -25,10 +24,10 @@ public QuarkSaplingBlock(String name, ZetaModule module, AbstractTreeGrower tree super(tree, Block.Properties.copy(Blocks.OAK_SAPLING)); this.module = module; - Quark.ZETA.registry.registerBlock(this, name + "_sapling", true); + module.zeta.registry.registerBlock(this, name + "_sapling", true); CreativeTabHandler.addTab(this, CreativeModeTab.TAB_DECORATIONS); - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); } @Override diff --git a/src/main/java/vazkii/quark/base/block/QuarkSlabBlock.java b/src/main/java/vazkii/quark/base/block/QuarkSlabBlock.java index 697e9e3b30..4d9879c5c2 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkSlabBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkSlabBlock.java @@ -11,7 +11,6 @@ import net.minecraft.world.level.block.state.BlockState; import vazkii.quark.base.Quark; import vazkii.quark.base.handler.CreativeTabHandler; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.quark.base.handler.VariantHandler; import vazkii.zeta.module.ZetaModule; import vazkii.zeta.registry.IZetaBlockColorProvider; @@ -35,7 +34,7 @@ public QuarkSlabBlock(IQuarkBlock parent) { CreativeTabHandler.addTab(this, CreativeModeTab.TAB_BUILDING_BLOCKS); - RenderLayerHandler.setInherited(this, parent.getBlock()); + Quark.ZETA.renderLayerRegistry.mock(this, parent.getBlock()); } @Override diff --git a/src/main/java/vazkii/quark/base/block/QuarkStairsBlock.java b/src/main/java/vazkii/quark/base/block/QuarkStairsBlock.java index 599670374a..2219be6c4c 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkStairsBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkStairsBlock.java @@ -16,7 +16,6 @@ import net.minecraft.world.level.block.state.BlockState; import vazkii.quark.base.Quark; import vazkii.quark.base.handler.CreativeTabHandler; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.quark.base.handler.VariantHandler; import vazkii.zeta.module.ZetaModule; import vazkii.zeta.registry.IZetaBlockColorProvider; @@ -36,7 +35,7 @@ public QuarkStairsBlock(IQuarkBlock parent) { CreativeTabHandler.addTab(this, CreativeModeTab.TAB_BUILDING_BLOCKS); - RenderLayerHandler.setInherited(this, parent.getBlock()); + Quark.ZETA.renderLayerRegistry.mock(this, parent.getBlock()); } @Override diff --git a/src/main/java/vazkii/quark/base/block/QuarkTrapdoorBlock.java b/src/main/java/vazkii/quark/base/block/QuarkTrapdoorBlock.java index 0b1cb2ac75..61f0d8b805 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkTrapdoorBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkTrapdoorBlock.java @@ -9,10 +9,9 @@ import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.TrapDoorBlock; -import vazkii.quark.base.Quark; import vazkii.quark.base.handler.CreativeTabHandler; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.registry.RenderLayerRegistry; public class QuarkTrapdoorBlock extends TrapDoorBlock implements IQuarkBlock { @@ -23,8 +22,8 @@ public QuarkTrapdoorBlock(String regname, ZetaModule module, CreativeModeTab cre super(properties); this.module = module; - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); - Quark.ZETA.registry.registerBlock(this, regname, true); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); + module.zeta.registry.registerBlock(this, regname, true); CreativeTabHandler.addTab(this, creativeTab); diff --git a/src/main/java/vazkii/quark/base/block/QuarkVineBlock.java b/src/main/java/vazkii/quark/base/block/QuarkVineBlock.java index c07d06e764..56558a0a56 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkVineBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkVineBlock.java @@ -18,10 +18,9 @@ import net.minecraft.world.level.block.VineBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; -import vazkii.quark.base.Quark; import vazkii.quark.base.handler.CreativeTabHandler; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.registry.RenderLayerRegistry; public class QuarkVineBlock extends VineBlock implements IQuarkBlock { @@ -32,8 +31,8 @@ public QuarkVineBlock(ZetaModule module, String name, boolean creative) { super(Block.Properties.of(Material.REPLACEABLE_PLANT).noCollission().randomTicks().strength(0.2F).sound(SoundType.GRASS)); this.module = module; - Quark.ZETA.registry.registerBlock(this, name, true); - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + module.zeta.registry.registerBlock(this, name, true); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); if (creative) CreativeTabHandler.addTab(this, CreativeModeTab.TAB_DECORATIONS); } diff --git a/src/main/java/vazkii/quark/base/block/QuarkWallBlock.java b/src/main/java/vazkii/quark/base/block/QuarkWallBlock.java index 48d0e7cc87..bc52d8cc7e 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkWallBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkWallBlock.java @@ -9,7 +9,6 @@ import net.minecraft.world.level.block.state.BlockState; import vazkii.quark.base.Quark; import vazkii.quark.base.handler.CreativeTabHandler; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.quark.base.handler.VariantHandler; import vazkii.zeta.module.ZetaModule; import vazkii.zeta.registry.IZetaBlockColorProvider; @@ -32,7 +31,7 @@ public QuarkWallBlock(IQuarkBlock parent) { Quark.ZETA.registry.registerBlock(this, resloc, true); CreativeTabHandler.addTab(this, CreativeModeTab.TAB_DECORATIONS); - RenderLayerHandler.setInherited(this, parent.getBlock()); + Quark.ZETA.renderLayerRegistry.mock(this, parent.getBlock()); } @Override diff --git a/src/main/java/vazkii/quark/base/handler/FuelHandler.java b/src/main/java/vazkii/quark/base/handler/FuelHandler.java index 3f26de9940..616e7e83fd 100644 --- a/src/main/java/vazkii/quark/base/handler/FuelHandler.java +++ b/src/main/java/vazkii/quark/base/handler/FuelHandler.java @@ -10,7 +10,6 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SlabBlock; import net.minecraft.world.level.material.Material; -import net.minecraftforge.event.furnace.FurnaceFuelBurnTimeEvent; import vazkii.quark.base.Quark; import vazkii.quark.content.building.block.VerticalSlabBlock; import vazkii.zeta.event.ZFurnaceFuelBurnTime; diff --git a/src/main/java/vazkii/quark/base/handler/QuarkSounds.java b/src/main/java/vazkii/quark/base/handler/QuarkSounds.java index b1245fe4f5..020b150067 100644 --- a/src/main/java/vazkii/quark/base/handler/QuarkSounds.java +++ b/src/main/java/vazkii/quark/base/handler/QuarkSounds.java @@ -5,7 +5,6 @@ import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; -import net.minecraftforge.registries.GameData; import vazkii.quark.base.Quark; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; diff --git a/src/main/java/vazkii/quark/base/handler/RenderLayerHandler.java b/src/main/java/vazkii/quark/base/handler/RenderLayerHandler.java deleted file mode 100644 index c61fc338f6..0000000000 --- a/src/main/java/vazkii/quark/base/handler/RenderLayerHandler.java +++ /dev/null @@ -1,81 +0,0 @@ -package vazkii.quark.base.handler; - -import net.minecraft.client.renderer.ItemBlockRenderTypes; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.world.level.block.Block; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.DistExecutor; -import vazkii.zeta.event.bus.LoadEvent; -import vazkii.zeta.client.event.ZClientSetup; - -import java.util.HashMap; -import java.util.Map; - -public class RenderLayerHandler { - - public static void setRenderType(Block block, RenderTypeSkeleton skeleton) { - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> Client.setRenderTypeClient(block, skeleton)); - } - - public static void setInherited(Block block, Block parent) { - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> Client.setInheritedClient(block, parent)); - } - - public enum RenderTypeSkeleton { - SOLID, - CUTOUT, - CUTOUT_MIPPED, - TRANSLUCENT - } - - public static class Client { - - private static final Map mapping = new HashMap<>(); - private static final Map inheritances = new HashMap<>(); - private static Map renderTypes; - - @LoadEvent - public static void clientSetup(ZClientSetup event) { - for(Block b : inheritances.keySet()) { - Block inherit = inheritances.get(b); - if(mapping.containsKey(inherit)) - mapping.put(b, mapping.get(inherit)); - } - - for(Block b : mapping.keySet()) - doSetRenderLayer(b, renderTypes.get(mapping.get(b))); - - inheritances.clear(); - mapping.clear(); - } - - //Forge has some weirdo extension, they want you to use json or something. - //Doing it from java is easier and more akin to how it happens on Fabric. - @SuppressWarnings("removal") - private static void doSetRenderLayer(Block block, RenderType type) { - ItemBlockRenderTypes.setRenderLayer(block, type); - } - - private static void setRenderTypeClient(Block block, RenderTypeSkeleton skeleton) { - resolveRenderTypes(); - mapping.put(block, skeleton); - } - - private static void setInheritedClient(Block block, Block parent) { - resolveRenderTypes(); - inheritances.put(block, parent); - } - - private static void resolveRenderTypes() { - if(renderTypes == null) { - renderTypes = new HashMap<>(); - - renderTypes.put(RenderTypeSkeleton.SOLID, RenderType.solid()); - renderTypes.put(RenderTypeSkeleton.CUTOUT, RenderType.cutout()); - renderTypes.put(RenderTypeSkeleton.CUTOUT_MIPPED, RenderType.cutoutMipped()); - renderTypes.put(RenderTypeSkeleton.TRANSLUCENT, RenderType.translucent()); - } - } - } -} diff --git a/src/main/java/vazkii/quark/base/handler/VariantHandler.java b/src/main/java/vazkii/quark/base/handler/VariantHandler.java index 13af6e8718..8eb24bb1d1 100644 --- a/src/main/java/vazkii/quark/base/handler/VariantHandler.java +++ b/src/main/java/vazkii/quark/base/handler/VariantHandler.java @@ -12,6 +12,7 @@ import vazkii.quark.base.block.QuarkSlabBlock; import vazkii.quark.base.block.QuarkStairsBlock; import vazkii.quark.base.block.QuarkWallBlock; +import vazkii.zeta.registry.RenderLayerRegistry; import java.util.LinkedList; import java.util.List; @@ -55,7 +56,7 @@ public static FlowerPotBlock addFlowerPot(Block block, String name, Function (FlowerPotBlock) Blocks.FLOWER_POT, () -> block, props); - RenderLayerHandler.setRenderType(potted, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + Quark.ZETA.renderLayerRegistry.put(potted, RenderLayerRegistry.Layer.CUTOUT); ResourceLocation resLoc = Quark.ZETA.registry.getRegistryName(block, Registry.BLOCK); if (resLoc == null) resLoc = new ResourceLocation("missingno"); diff --git a/src/main/java/vazkii/quark/base/proxy/ClientProxy.java b/src/main/java/vazkii/quark/base/proxy/ClientProxy.java index 6d0ece7866..463b5b0c50 100644 --- a/src/main/java/vazkii/quark/base/proxy/ClientProxy.java +++ b/src/main/java/vazkii/quark/base/proxy/ClientProxy.java @@ -13,9 +13,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.ConfigScreenHandler.ConfigScreenFactory; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import vazkii.quark.base.Quark; import vazkii.quark.base.QuarkClient; import vazkii.quark.base.client.config.QButtonHandler; @@ -27,11 +25,11 @@ import vazkii.zeta.client.TopLayerTooltipHandler; import vazkii.quark.base.handler.ContributorRewardHandler; import vazkii.quark.base.handler.MiscUtil; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.quark.base.handler.WoodSetHandler; import vazkii.quark.base.network.QuarkNetwork; import vazkii.quark.base.network.message.structural.C2SUpdateFlag; import vazkii.quark.mixin.client.accessor.AccessorMultiPlayerGameMode; +import vazkii.zeta.registry.RenderLayerRegistry; import java.io.File; import java.io.FileOutputStream; @@ -57,7 +55,7 @@ public void start() { Quark.ZETA.loadBus .subscribe(ModelHandler.class) //TODO: Make this especially not a singleton, move it into respective modules .subscribe(ContributorRewardHandler.Client.class) - .subscribe(RenderLayerHandler.Client.class) + .subscribe(new RenderLayerRegistry.Client(Quark.ZETA.renderLayerRegistry)) .subscribe(WoodSetHandler.Client.class); Quark.ZETA.playBus diff --git a/src/main/java/vazkii/quark/content/automation/block/ChuteBlock.java b/src/main/java/vazkii/quark/content/automation/block/ChuteBlock.java index c3e4b20db7..ac3d558a6b 100755 --- a/src/main/java/vazkii/quark/content/automation/block/ChuteBlock.java +++ b/src/main/java/vazkii/quark/content/automation/block/ChuteBlock.java @@ -19,9 +19,9 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import vazkii.quark.base.block.QuarkBlock; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; import vazkii.quark.content.automation.block.be.ChuteBlockEntity; +import vazkii.zeta.registry.RenderLayerRegistry; public class ChuteBlock extends QuarkBlock implements EntityBlock { @@ -36,7 +36,7 @@ public ChuteBlock(String regname, ZetaModule module, CreativeModeTab creativeTab super(regname, module, creativeTab, properties); registerDefaultState(defaultBlockState().setValue(ENABLED, true)); - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT_MIPPED); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT_MIPPED); } @Override diff --git a/src/main/java/vazkii/quark/content/automation/block/IronRodBlock.java b/src/main/java/vazkii/quark/content/automation/block/IronRodBlock.java index f2519b3149..b77a5f5735 100644 --- a/src/main/java/vazkii/quark/content/automation/block/IronRodBlock.java +++ b/src/main/java/vazkii/quark/content/automation/block/IronRodBlock.java @@ -16,12 +16,11 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.material.Material; import vazkii.zeta.api.ICollateralMover; -import vazkii.quark.base.Quark; import vazkii.quark.base.block.IQuarkBlock; import vazkii.quark.base.handler.CreativeTabHandler; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; import vazkii.quark.content.automation.module.IronRodModule; +import vazkii.zeta.registry.RenderLayerRegistry; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -40,10 +39,10 @@ public IronRodBlock(ZetaModule module) { .sound(SoundType.METAL) .noOcclusion()); - Quark.ZETA.registry.registerBlock(this, "iron_rod", true); + module.zeta.registry.registerBlock(this, "iron_rod", true); CreativeTabHandler.addTab(this, CreativeModeTab.TAB_DECORATIONS); - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); this.module = module; } diff --git a/src/main/java/vazkii/quark/content/automation/block/RedstoneRandomizerBlock.java b/src/main/java/vazkii/quark/content/automation/block/RedstoneRandomizerBlock.java index dc046dc765..7d0341f2fc 100644 --- a/src/main/java/vazkii/quark/content/automation/block/RedstoneRandomizerBlock.java +++ b/src/main/java/vazkii/quark/content/automation/block/RedstoneRandomizerBlock.java @@ -31,9 +31,9 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.event.ForgeEventFactory; import vazkii.quark.base.block.QuarkBlock; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; import vazkii.quark.content.automation.base.RandomizerPowerState; +import vazkii.zeta.registry.RenderLayerRegistry; /** * @author WireSegal @@ -54,7 +54,7 @@ public RedstoneRandomizerBlock(String regname, ZetaModule module, CreativeModeTa .setValue(FACING, Direction.NORTH) .setValue(POWERED, RandomizerPowerState.OFF)); - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); } @Override diff --git a/src/main/java/vazkii/quark/content/building/block/GrateBlock.java b/src/main/java/vazkii/quark/content/building/block/GrateBlock.java index 577e3c3a61..47a1fb7360 100755 --- a/src/main/java/vazkii/quark/content/building/block/GrateBlock.java +++ b/src/main/java/vazkii/quark/content/building/block/GrateBlock.java @@ -8,7 +8,7 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.ExperienceOrb; -import net.minecraft.world.entity.SpawnPlacements.Type; +import net.minecraft.world.entity.SpawnPlacements; import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.entity.animal.WaterAnimal; import net.minecraft.world.entity.item.ItemEntity; @@ -38,8 +38,8 @@ import vazkii.quark.api.ICrawlSpaceBlock; import vazkii.quark.base.block.QuarkBlock; import vazkii.quark.base.block.SimpleFluidloggedBlock; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.registry.RenderLayerRegistry; import javax.annotation.Nonnull; @@ -58,7 +58,7 @@ public GrateBlock(ZetaModule module) { .noOcclusion()); registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false).setValue(LAVALOGGED, false)); - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); } private static VoxelShape createNewBox(double stepHeight) { @@ -151,7 +151,7 @@ public boolean propagatesSkylightDown(@Nonnull BlockState state, @Nonnull BlockG } @Override - public boolean isValidSpawn(BlockState state, BlockGetter world, BlockPos pos, Type type, EntityType entityType) { + public boolean isValidSpawn(BlockState state, BlockGetter world, BlockPos pos, SpawnPlacements.Type type, EntityType entityType) { return false; } diff --git a/src/main/java/vazkii/quark/content/building/block/HedgeBlock.java b/src/main/java/vazkii/quark/content/building/block/HedgeBlock.java index 6749284ae9..37e7ba9677 100644 --- a/src/main/java/vazkii/quark/content/building/block/HedgeBlock.java +++ b/src/main/java/vazkii/quark/content/building/block/HedgeBlock.java @@ -33,11 +33,11 @@ import vazkii.quark.base.Quark; import vazkii.quark.base.block.IQuarkBlock; import vazkii.quark.base.handler.CreativeTabHandler; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; import vazkii.quark.content.building.module.HedgesModule; import vazkii.quark.content.world.block.BlossomLeavesBlock; import vazkii.zeta.registry.IZetaBlockColorProvider; +import vazkii.zeta.registry.RenderLayerRegistry; //TODO ZETA: extend QuarkFenceBlock public class HedgeBlock extends FenceBlock implements IQuarkBlock, IZetaBlockColorProvider { @@ -75,7 +75,7 @@ public HedgeBlock(ZetaModule module, Block fence, Block leaf) { } CreativeTabHandler.addTab(this, CreativeModeTab.TAB_DECORATIONS); - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); registerDefaultState(defaultBlockState().setValue(EXTEND, false)); diff --git a/src/main/java/vazkii/quark/content/building/block/HollowLogBlock.java b/src/main/java/vazkii/quark/content/building/block/HollowLogBlock.java index 0dc404f03c..454b79ae93 100644 --- a/src/main/java/vazkii/quark/content/building/block/HollowLogBlock.java +++ b/src/main/java/vazkii/quark/content/building/block/HollowLogBlock.java @@ -8,8 +8,8 @@ import net.minecraft.world.level.block.state.BlockState; import vazkii.quark.base.block.IQuarkBlock; import vazkii.quark.base.handler.MiscUtil; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.registry.RenderLayerRegistry; public class HollowLogBlock extends HollowPillarBlock { @@ -25,7 +25,7 @@ public HollowLogBlock(String name, Block sourceLog, ZetaModule module, boolean f .isSuffocating((s, g, p) -> false)); this.flammable = flammable; - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT_MIPPED); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT_MIPPED); } diff --git a/src/main/java/vazkii/quark/content/building/block/HollowWoodBlock.java b/src/main/java/vazkii/quark/content/building/block/HollowWoodBlock.java index 4797d1ba9c..e76619bb59 100644 --- a/src/main/java/vazkii/quark/content/building/block/HollowWoodBlock.java +++ b/src/main/java/vazkii/quark/content/building/block/HollowWoodBlock.java @@ -19,8 +19,8 @@ import org.jetbrains.annotations.Nullable; import vazkii.quark.base.block.IQuarkBlock; import vazkii.quark.base.handler.MiscUtil; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.registry.RenderLayerRegistry; import javax.annotation.Nonnull; @@ -50,7 +50,7 @@ public HollowWoodBlock(String name, Block sourceLog, ZetaModule module, boolean .isSuffocating((s, g, p) -> false)); this.flammable = flammable; - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT_MIPPED); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT_MIPPED); registerDefaultState(defaultBlockState() .setValue(DOWN, true) .setValue(UP, true) diff --git a/src/main/java/vazkii/quark/content/building/block/LeafCarpetBlock.java b/src/main/java/vazkii/quark/content/building/block/LeafCarpetBlock.java index 12f11d7fbe..46bbdc0e3f 100644 --- a/src/main/java/vazkii/quark/content/building/block/LeafCarpetBlock.java +++ b/src/main/java/vazkii/quark/content/building/block/LeafCarpetBlock.java @@ -20,9 +20,9 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.jetbrains.annotations.Nullable; import vazkii.quark.base.block.QuarkBlock; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; import vazkii.zeta.registry.IZetaBlockColorProvider; +import vazkii.zeta.registry.RenderLayerRegistry; public class LeafCarpetBlock extends QuarkBlock implements IZetaBlockColorProvider { @@ -40,7 +40,7 @@ public LeafCarpetBlock(String name, Block base, ZetaModule module) { baseState = base.defaultBlockState(); - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT_MIPPED); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT_MIPPED); } public BlockState getBaseState() { diff --git a/src/main/java/vazkii/quark/content/building/block/RopeBlock.java b/src/main/java/vazkii/quark/content/building/block/RopeBlock.java index d9bc259490..57a5446d88 100755 --- a/src/main/java/vazkii/quark/content/building/block/RopeBlock.java +++ b/src/main/java/vazkii/quark/content/building/block/RopeBlock.java @@ -35,11 +35,11 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.fluids.FluidUtil; import vazkii.quark.base.block.QuarkBlock; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; import vazkii.quark.content.automation.module.PistonsMoveTileEntitiesModule; import vazkii.quark.content.building.module.RopeModule; import vazkii.zeta.registry.IZetaBlockItemProvider; +import vazkii.zeta.registry.RenderLayerRegistry; import javax.annotation.Nonnull; @@ -53,7 +53,7 @@ public RopeBlock(String regname, ZetaModule module, CreativeModeTab creativeTab, super(regname, module, creativeTab, properties); registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false)); - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); } @Override diff --git a/src/main/java/vazkii/quark/content/building/block/VariantLadderBlock.java b/src/main/java/vazkii/quark/content/building/block/VariantLadderBlock.java index 5df3d27759..0ff4818033 100644 --- a/src/main/java/vazkii/quark/content/building/block/VariantLadderBlock.java +++ b/src/main/java/vazkii/quark/content/building/block/VariantLadderBlock.java @@ -13,8 +13,8 @@ import vazkii.quark.base.Quark; import vazkii.quark.base.block.IQuarkBlock; import vazkii.quark.base.handler.CreativeTabHandler; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.registry.RenderLayerRegistry; import javax.annotation.Nonnull; import java.util.function.BooleanSupplier; @@ -33,7 +33,7 @@ public VariantLadderBlock(String type, ZetaModule module, Block.Properties props CreativeTabHandler.addTab(this, CreativeModeTab.TAB_DECORATIONS); this.module = module; - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); this.flammable = flammable; } diff --git a/src/main/java/vazkii/quark/content/building/block/WoodPostBlock.java b/src/main/java/vazkii/quark/content/building/block/WoodPostBlock.java index 9adda5e704..854b0f8588 100644 --- a/src/main/java/vazkii/quark/content/building/block/WoodPostBlock.java +++ b/src/main/java/vazkii/quark/content/building/block/WoodPostBlock.java @@ -26,8 +26,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import vazkii.quark.base.block.IQuarkBlock; import vazkii.quark.base.block.QuarkBlock; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.registry.RenderLayerRegistry; public class WoodPostBlock extends QuarkBlock implements SimpleWaterloggedBlock { @@ -57,7 +57,7 @@ public WoodPostBlock(ZetaModule module, Block parent, String prefix, boolean net state = state.setValue(prop, false); registerDefaultState(state); - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); } @Nonnull diff --git a/src/main/java/vazkii/quark/content/building/module/GoldBarsModule.java b/src/main/java/vazkii/quark/content/building/module/GoldBarsModule.java index d28205d607..72ffbb7941 100644 --- a/src/main/java/vazkii/quark/content/building/module/GoldBarsModule.java +++ b/src/main/java/vazkii/quark/content/building/module/GoldBarsModule.java @@ -7,7 +7,6 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.structure.BuiltinStructures; import vazkii.quark.base.block.QuarkPaneBlock; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.quark.base.handler.StructureBlockReplacementHandler; import vazkii.quark.base.handler.StructureBlockReplacementHandler.StructureHolder; import vazkii.quark.base.module.LoadModule; @@ -16,6 +15,7 @@ import vazkii.zeta.event.ZConfigChanged; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.registry.RenderLayerRegistry; @LoadModule(category = "building") public class GoldBarsModule extends ZetaModule { @@ -28,7 +28,7 @@ public class GoldBarsModule extends ZetaModule { @LoadEvent public final void register(ZRegister event) { - gold_bars = new QuarkPaneBlock("gold_bars", this, Properties.copy(Blocks.IRON_BARS), RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + gold_bars = new QuarkPaneBlock("gold_bars", this, Properties.copy(Blocks.IRON_BARS), RenderLayerRegistry.Layer.CUTOUT); StructureBlockReplacementHandler.addReplacement(GoldBarsModule::getGenerationBarBlockState); } diff --git a/src/main/java/vazkii/quark/content/world/block/ChorusVegetationBlock.java b/src/main/java/vazkii/quark/content/world/block/ChorusVegetationBlock.java index a31d28e2e3..e43f50ffe9 100644 --- a/src/main/java/vazkii/quark/content/world/block/ChorusVegetationBlock.java +++ b/src/main/java/vazkii/quark/content/world/block/ChorusVegetationBlock.java @@ -33,9 +33,9 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.common.IForgeShearable; import vazkii.quark.base.block.QuarkBlock; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; import vazkii.quark.content.world.module.ChorusVegetationModule; +import vazkii.zeta.registry.RenderLayerRegistry; public class ChorusVegetationBlock extends QuarkBlock implements BonemealableBlock, IForgeShearable { @@ -53,7 +53,7 @@ public ChorusVegetationBlock(String regname, ZetaModule module, boolean simple) .randomTicks()); this.simple = simple; - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); } @Override diff --git a/src/main/java/vazkii/quark/content/world/block/CorundumClusterBlock.java b/src/main/java/vazkii/quark/content/world/block/CorundumClusterBlock.java index 6839b67826..1649e769e9 100644 --- a/src/main/java/vazkii/quark/content/world/block/CorundumClusterBlock.java +++ b/src/main/java/vazkii/quark/content/world/block/CorundumClusterBlock.java @@ -26,7 +26,7 @@ import net.minecraft.world.phys.shapes.VoxelShape; import vazkii.quark.base.block.IQuarkBlock; import vazkii.quark.base.block.QuarkBlock; -import vazkii.quark.base.handler.RenderLayerHandler; +import vazkii.zeta.registry.RenderLayerRegistry; public class CorundumClusterBlock extends QuarkBlock implements SimpleWaterloggedBlock { @@ -61,7 +61,7 @@ public CorundumClusterBlock(CorundumBlock base) { this.base = base; base.cluster = this; - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + base.getModule().zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); registerDefaultState(defaultBlockState().setValue(FACING, Direction.DOWN).setValue(WATERLOGGED, false)); } diff --git a/src/main/java/vazkii/quark/content/world/block/GlowShroomRingBlock.java b/src/main/java/vazkii/quark/content/world/block/GlowShroomRingBlock.java index 9586b61db7..7f8ddbe425 100644 --- a/src/main/java/vazkii/quark/content/world/block/GlowShroomRingBlock.java +++ b/src/main/java/vazkii/quark/content/world/block/GlowShroomRingBlock.java @@ -24,8 +24,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import vazkii.quark.base.block.QuarkBlock; import vazkii.quark.base.handler.CreativeTabHandler; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.registry.RenderLayerRegistry; import javax.annotation.Nonnull; import java.util.Map; @@ -45,7 +45,7 @@ public GlowShroomRingBlock(ZetaModule module) { .instabreak() .sound(SoundType.FUNGUS)); CreativeTabHandler.addTab(this, CreativeModeTab.TAB_DECORATIONS); - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); registerDefaultState(stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, false)); } diff --git a/src/main/java/vazkii/quark/content/world/block/MonsterBoxBlock.java b/src/main/java/vazkii/quark/content/world/block/MonsterBoxBlock.java index 11e99e0ac7..90e3ed5bd3 100644 --- a/src/main/java/vazkii/quark/content/world/block/MonsterBoxBlock.java +++ b/src/main/java/vazkii/quark/content/world/block/MonsterBoxBlock.java @@ -13,10 +13,10 @@ import net.minecraft.world.level.material.Material; import net.minecraft.world.level.pathfinder.PathComputationType; import vazkii.quark.base.block.QuarkBlock; -import vazkii.quark.base.handler.RenderLayerHandler; import vazkii.zeta.module.ZetaModule; import vazkii.quark.content.world.block.be.MonsterBoxBlockEntity; import vazkii.quark.content.world.module.MonsterBoxModule; +import vazkii.zeta.registry.RenderLayerRegistry; import javax.annotation.Nonnull; @@ -29,7 +29,7 @@ public MonsterBoxBlock(ZetaModule module) { .sound(SoundType.METAL) .noOcclusion()); - RenderLayerHandler.setRenderType(this, RenderLayerHandler.RenderTypeSkeleton.CUTOUT); + module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT); } @Override diff --git a/src/main/java/vazkii/zeta/Zeta.java b/src/main/java/vazkii/zeta/Zeta.java index f213a1a04a..89325848ba 100644 --- a/src/main/java/vazkii/zeta/Zeta.java +++ b/src/main/java/vazkii/zeta/Zeta.java @@ -34,6 +34,7 @@ import vazkii.zeta.network.ZetaNetworkHandler; import vazkii.zeta.registry.CraftingExtensionsRegistry; import vazkii.zeta.registry.DyeablesRegistry; +import vazkii.zeta.registry.RenderLayerRegistry; import vazkii.zeta.registry.ZetaRegistry; import vazkii.zeta.util.ZetaSide; @@ -53,6 +54,7 @@ public Zeta(String modid, Logger log, ZetaSide side) { this.modules = createModuleManager(); this.registry = createRegistry(); + this.renderLayerRegistry = createRenderLayerRegistry(); this.dyeables = createDyeablesRegistry(); this.craftingExtensions = createCraftingExtensionsRegistry(); this.brewingRegistry = createBrewingRegistry(); @@ -67,6 +69,7 @@ public Zeta(String modid, Logger log, ZetaSide side) { public final ZetaModuleManager modules; public final ZetaRegistry registry; + public final RenderLayerRegistry renderLayerRegistry; public final DyeablesRegistry dyeables; public final CraftingExtensionsRegistry craftingExtensions; public final BrewingRegistry brewingRegistry; @@ -100,6 +103,9 @@ public ZetaModuleManager createModuleManager() { return new ZetaModuleManager(this); } public abstract ZetaRegistry createRegistry(); + public RenderLayerRegistry createRenderLayerRegistry() { + return new RenderLayerRegistry(); + } public abstract CraftingExtensionsRegistry createCraftingExtensionsRegistry(); public DyeablesRegistry createDyeablesRegistry() { return new DyeablesRegistry(this); diff --git a/src/main/java/vazkii/zeta/event/ZRegister.java b/src/main/java/vazkii/zeta/event/ZRegister.java index 1ba8eda079..ec8743ed55 100644 --- a/src/main/java/vazkii/zeta/event/ZRegister.java +++ b/src/main/java/vazkii/zeta/event/ZRegister.java @@ -4,6 +4,7 @@ import vazkii.zeta.Zeta; import vazkii.zeta.event.bus.IZetaLoadEvent; import vazkii.zeta.registry.CraftingExtensionsRegistry; +import vazkii.zeta.registry.RenderLayerRegistry; import vazkii.zeta.registry.ZetaRegistry; @SuppressWarnings("ClassCanBeRecord") @@ -26,5 +27,9 @@ public BrewingRegistry getBrewingRegistry() { return zeta.brewingRegistry; } + public RenderLayerRegistry getRenderLayerRegistry() { + return zeta.renderLayerRegistry; + } + public static class Post implements IZetaLoadEvent { } } diff --git a/src/main/java/vazkii/zeta/registry/RenderLayerRegistry.java b/src/main/java/vazkii/zeta/registry/RenderLayerRegistry.java new file mode 100644 index 0000000000..10f0539081 --- /dev/null +++ b/src/main/java/vazkii/zeta/registry/RenderLayerRegistry.java @@ -0,0 +1,78 @@ +package vazkii.zeta.registry; + +import java.util.EnumMap; +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.world.level.block.Block; +import vazkii.zeta.client.event.ZClientSetup; +import vazkii.zeta.event.bus.LoadEvent; + +/** + * note this is NOT client-side code, for ease of registering stuff in constructors + */ +public class RenderLayerRegistry { + + protected final Map mapping = new HashMap<>(); + protected final Map inheritances = new HashMap<>(); + + public enum Layer { + SOLID, + CUTOUT, + CUTOUT_MIPPED, + TRANSLUCENT, + } + + public void put(Block block, Layer layer) { + mapping.put(block, layer); + } + + public void mock(Block block, Block inheritFrom) { + inheritances.put(block, inheritFrom); + } + + /** + * but this *is* client-side code :blush: + */ + public static class Client { + + protected final RenderLayerRegistry reg; + protected final Map resolvedTypes = new EnumMap<>(Layer.class); + + public Client(RenderLayerRegistry reg) { + this.reg = reg; + + resolvedTypes.put(Layer.SOLID, RenderType.solid()); + resolvedTypes.put(Layer.CUTOUT, RenderType.cutout()); + resolvedTypes.put(Layer.CUTOUT_MIPPED, RenderType.cutoutMipped()); + resolvedTypes.put(Layer.TRANSLUCENT, RenderType.translucent()); + } + + @LoadEvent + public void register(ZClientSetup event) { + //Note: only handles one layer of inheritances + for(Block b : reg.inheritances.keySet()) { + Block inheritFrom = reg.inheritances.get(b); + Layer layer = reg.mapping.get(inheritFrom); + + if(layer != null) + reg.mapping.put(b, layer); + } + + reg.mapping.forEach(this::doSetRenderLayer); + + reg.inheritances.clear(); + reg.mapping.clear(); + } + + //Forge has some weirdo extension, they want you to use json or something. + //Doing it from java is easier and more akin to how it happens on Fabric. + @SuppressWarnings("removal") + protected void doSetRenderLayer(Block block, Layer layer) { + ItemBlockRenderTypes.setRenderLayer(block, resolvedTypes.get(layer)); + } + + } +}