Skip to content

Commit

Permalink
Client side render fix
Browse files Browse the repository at this point in the history
  • Loading branch information
paulevsGitch committed Jun 20, 2021
1 parent 570e65c commit 2686089
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ yarn_mappings=6
loader_version=0.11.3

# Mod Properties
mod_version = 0.1.38
mod_version = 0.1.39
maven_group = ru.bclib
archives_base_name = bclib

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/ru/bclib/client/models/BlockModelProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,29 @@

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;
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);
Expand Down

0 comments on commit 2686089

Please sign in to comment.