Client side render fix
This commit is contained in:
parent
570e65ca47
commit
2686089835
2 changed files with 6 additions and 1 deletions
|
@ -7,6 +7,8 @@ import java.util.Optional;
|
|||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -14,17 +16,20 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import ru.bclib.BCLib;
|
||||
|
||||
public interface BlockModelProvider extends ItemModelProvider {
|
||||
@Environment(EnvType.CLIENT)
|
||||
default @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
Optional<String> pattern = PatternsHelper.createBlockSimple(resourceLocation);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
default UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createBlockSimple(modelId);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
default void registerBlockModel(ResourceLocation stateId, ResourceLocation modelId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
if (!modelCache.containsKey(modelId)) {
|
||||
BlockModel model = getBlockModel(stateId, blockState);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue