for (Block block : ForgeRegistries.BLOCKS.getValues()) {
BlockState state = block.defaultBlockState();
Predicate<RenderType> predicate = getLayerCheck(state, Minecraft.getInstance().getModelManager().getBlockModelShaper().getBlockModel(state));
if (predicate != null) {
blockRenderChecks.put(block.delegate, getExistingRenderCheck(block));
ItemBlockRenderTypes.setRenderLayer(block, predicate);
}
}
the problem is that it only considers the default block state's model.
for example, the redstone ore's default block state is LIT:false .
if I only set the LIT:true model and need it to use layer/rendertype cutout
the Predicate produce function will just return null as the LIT:false model is not any instance below
the layer/rendertype setting in LIT:false model is ignored
so , just use block.getStateDefinition().getPossibleStates() and Predicate#or to consider all models' setting
the problem is that if a block has many states, this may become a performance issue.
though forge add canRenderInLayer to replace getRenderLayer to allow one block to have multi rendertypes
current implementation just convert parameter from blockstae -> state
the map which stores the information is also Map<IRegistryDelegate<Block>, Predicate<RenderType>>
though we can just cache solid, cutout_mipped, cutout, translucent, tripwire
but it is not good for rendertype usage like https://github.com/MinecraftForge/MinecraftForge/pull/8331
Yeah, the potential performance hit of this on blocks that might not even utilize it is too much to accept. Fortunately forge is including this feature itself in 1.19, so it's probably best to just leave it alone.
the origin logic for setting render type is this
the problem is that it only considers the default block state's model.
for example, the redstone ore's default block state is
LIT:false
.if I only set the
LIT:true
model and need it to use layer/rendertype cutoutthe Predicate produce function will just return null as the
LIT:false
model is not any instance belowthe layer/rendertype setting in
LIT:false
model is ignoredso , just use
block.getStateDefinition().getPossibleStates()
andPredicate#or
to consider all models' settingthe problem is that if a block has many states, this may become a performance issue.
though forge add
canRenderInLayer
to replacegetRenderLayer
to allow one block to have multi rendertypescurrent implementation just convert parameter from blockstae -> state
the map which stores the information is also
Map<IRegistryDelegate<Block>, Predicate<RenderType>>
though we can just cachesolid, cutout_mipped, cutout, translucent, tripwire
but it is not good for rendertype usage like https://github.com/MinecraftForge/MinecraftForge/pull/8331