-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Forgot to push this, it should be in the builds for 2.0.0 already
- Loading branch information
Showing
3 changed files
with
25 additions
and
11 deletions.
There are no files selected for viewing
24 changes: 23 additions & 1 deletion
24
src/main/java/dev/micalobia/full_slabs/FullSlabsClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,44 @@ | ||
package dev.micalobia.full_slabs; | ||
|
||
import dev.micalobia.full_slabs.block.Blocks; | ||
import dev.micalobia.full_slabs.block.VerticalSlabBlock; | ||
import dev.micalobia.full_slabs.client.render.model.SlabModelProvider; | ||
import dev.micalobia.full_slabs.util.LinkedSlabs; | ||
import net.fabricmc.api.ClientModInitializer; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; | ||
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry; | ||
import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.client.render.RenderLayer; | ||
import net.minecraft.client.render.RenderLayers; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.registry.Registry; | ||
|
||
@Environment(EnvType.CLIENT) | ||
public class FullSlabsClient implements ClientModInitializer { | ||
private static BlockRenderLayerMap map; | ||
|
||
private static void syncRenderLayer(int i, Identifier identifier, Block block) { | ||
syncRenderLayer(block); | ||
} | ||
|
||
private static void syncRenderLayer(Block block) { | ||
if(!(block instanceof VerticalSlabBlock)) return; | ||
RenderLayer layer = RenderLayers.getBlockLayer(LinkedSlabs.horizontal(block).getDefaultState()); | ||
map.putBlock(block, RenderLayer.getTranslucent()); // TODO: Figure out why using layer doesn't work unless i'm running from intellij | ||
} | ||
|
||
public void onInitializeClient() { | ||
ModelLoadingRegistry.INSTANCE.registerVariantProvider(vm -> new SlabModelProvider()); | ||
ModelLoadingRegistry.INSTANCE.registerResourceProvider(rm -> new SlabModelProvider()); | ||
LinkedSlabs.correctRenderLayers(); | ||
map = BlockRenderLayerMap.INSTANCE; | ||
Registry.BLOCK.forEach(FullSlabsClient::syncRenderLayer); | ||
RegistryEntryAddedCallback.event(Registry.BLOCK).register(FullSlabsClient::syncRenderLayer); | ||
BlockRenderLayerMap map = BlockRenderLayerMap.INSTANCE; | ||
map.putBlock(Blocks.FULL_SLAB_BLOCK, RenderLayer.getTranslucent()); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters