Changed models loading (Done)
This commit is contained in:
parent
831faeb306
commit
5da634fc73
63 changed files with 490 additions and 729 deletions
|
@ -12,23 +12,23 @@ import ru.betterend.BetterEnd;
|
|||
|
||||
import static net.minecraft.client.resources.model.ModelBakery.MISSING_MODEL_LOCATION;
|
||||
|
||||
public interface BlockModelProvider extends ModelProvider {
|
||||
public interface BlockModelProvider extends ItemModelProvider {
|
||||
default @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
Optional<String> pattern = Patterns.createBlockSimple(resourceLocation.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
default UnbakedModel getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||
"block/" + resourceLocation.getPath());
|
||||
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
|
||||
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);
|
||||
}
|
||||
|
||||
default void registerBlockModel(ResourceLocation stateId, ResourceLocation modelId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
if (!modelCache.containsKey(modelId)) {
|
||||
UnbakedModel model = getBlockModel(stateId, blockState);
|
||||
BlockModel model = getBlockModel(stateId, blockState);
|
||||
if (model != null) {
|
||||
model.name = modelId.toString();
|
||||
modelCache.put(modelId, model);
|
||||
} else {
|
||||
BetterEnd.LOGGER.warning("Error loading model: {}", modelId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue