Skip to content

Commit

Permalink
Forgot to push this, it should be in the builds for 2.0.0 already
Browse files Browse the repository at this point in the history
  • Loading branch information
Micalobia committed Mar 18, 2021
1 parent 9f4d26e commit 39dc8c4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
24 changes: 23 additions & 1 deletion src/main/java/dev/micalobia/full_slabs/FullSlabsClient.java
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());
}


}
9 changes: 0 additions & 9 deletions src/main/java/dev/micalobia/full_slabs/util/LinkedSlabs.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@ public static boolean contains(Block... slabs) {
return true;
}

@Environment(EnvType.CLIENT)
public static void correctRenderLayers() {
BlockRenderLayerMap map = BlockRenderLayerMap.INSTANCE;
for(SlabBlock slab : vertical.keySet()) {
RenderLayer layer = RenderLayers.getBlockLayer(slab.getDefaultState());
map.putBlock(vertical(slab), layer);
}
}

@NotNull
public static SlabBlock horizontal(Block slab) {
if(!contains(slab))
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"depends": {
"fabricloader": ">=0.7.4",
"fabric": "*",
"minecraft": "1.16.x"
"minecraft": "1.16.x",
"micalibria": ">=1.0.2"
}
}

0 comments on commit 39dc8c4

Please sign in to comment.