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