Skip to content

Commit

Permalink
Remove RenderLayerHandler in favor of a non-static registry
Browse files Browse the repository at this point in the history
  • Loading branch information
quat1024 committed Nov 5, 2023
1 parent af360dd commit 8c9cdd4
Show file tree
Hide file tree
Showing 37 changed files with 160 additions and 166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/vazkii/quark/base/block/QuarkBushBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/vazkii/quark/base/block/QuarkDoorBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/vazkii/quark/base/block/QuarkGlassBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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) {
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/vazkii/quark/base/block/QuarkLeavesBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/vazkii/quark/base/block/QuarkPaneBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/vazkii/quark/base/block/QuarkSaplingBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/vazkii/quark/base/block/QuarkSlabBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/vazkii/quark/base/block/QuarkStairsBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/vazkii/quark/base/block/QuarkTrapdoorBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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);

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/vazkii/quark/base/block/QuarkVineBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/vazkii/quark/base/block/QuarkWallBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/main/java/vazkii/quark/base/handler/FuelHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/vazkii/quark/base/handler/QuarkSounds.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
81 changes: 0 additions & 81 deletions src/main/java/vazkii/quark/base/handler/RenderLayerHandler.java

This file was deleted.

3 changes: 2 additions & 1 deletion src/main/java/vazkii/quark/base/handler/VariantHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -55,7 +56,7 @@ public static FlowerPotBlock addFlowerPot(Block block, String name, Function<Blo
props = propertiesFunc.apply(props);

FlowerPotBlock potted = new FlowerPotBlock(() -> (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");
Expand Down
Loading

0 comments on commit 8c9cdd4

Please sign in to comment.