Skip to content

Commit

Permalink
Support for block Material Instances RenderMethod
Browse files Browse the repository at this point in the history
  • Loading branch information
boybook committed Mar 1, 2024
1 parent 095add7 commit 8e32775
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package net.easecation.bedrockloader.loader

import net.easecation.bedrockloader.bedrock.block.component.ComponentMaterialInstances
import net.easecation.bedrockloader.block.BlockDataDriven
import net.easecation.bedrockloader.deserializer.BedrockPackContext
import net.easecation.bedrockloader.entity.EntityDataDriven
import net.fabricmc.api.EnvType
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap
import net.fabricmc.fabric.api.item.v1.FabricItemSettings
import net.fabricmc.fabric.api.`object`.builder.v1.entity.FabricDefaultAttributeRegistry
import net.fabricmc.loader.api.FabricLoader
import net.minecraft.client.render.RenderLayer
import net.minecraft.item.BlockItem
import net.minecraft.util.registry.Registry

Expand All @@ -20,6 +24,16 @@ class BedrockBehaviorPackLoader(
val block = BlockDataDriven.create(id, beh.components)
Registry.register(Registry.BLOCK, id, block)
BedrockAddonsRegistry.blocks[id] = block
if (env == EnvType.CLIENT) {
beh.components.minecraftMaterialInstances?.let { materialInstances ->
val renderMethod = materialInstances["*"]?.render_method ?: return
if (renderMethod == ComponentMaterialInstances.RenderMethod.alpha_test) {
BlockRenderLayerMap.INSTANCE.putBlock(block, RenderLayer.getCutout())
} else if (renderMethod == ComponentMaterialInstances.RenderMethod.blend) {
BlockRenderLayerMap.INSTANCE.putBlock(block, RenderLayer.getTranslucent())
}
}
}
val item = BlockItem(block, FabricItemSettings())
Registry.register(Registry.ITEM, id, item)
BedrockAddonsRegistry.items[id] = item
Expand Down

0 comments on commit 8e32775

Please sign in to comment.