Search in sources :

Example 1 with CITItem

use of shcm.shsupercm.fabric.citresewn.pack.cits.CITItem in project CITResewn by SHsuperCM.

the class ModelLoaderMixin method linkBakedCITItemModels.

@Inject(method = "upload", at = @At("RETURN"))
public void linkBakedCITItemModels(TextureManager textureManager, Profiler profiler, CallbackInfoReturnable<SpriteAtlasManager> cir) {
    if (CITResewn.INSTANCE.activeCITs == null)
        return;
    profiler.push("citresewn_linking");
    info("Linking baked models to CITItems...");
    if (CITResewn.INSTANCE.activeCITs != null) {
        for (CITItem citItem : CITResewn.INSTANCE.activeCITs.citItems.values().stream().flatMap(Collection::stream).distinct().collect(Collectors.toList())) {
            for (Map.Entry<List<ModelOverride.Condition>, JsonUnbakedModel> citModelEntry : citItem.unbakedAssets.entrySet()) {
                if (citModelEntry.getKey() == null) {
                    citItem.bakedModel = this.bakedModels.get(new ResewnItemModelIdentifier(citModelEntry.getValue().id));
                } else {
                    BakedModel bakedModel = bakedModels.get(new ResewnItemModelIdentifier(citModelEntry.getValue().id));
                    if (bakedModel == null)
                        CITResewn.logWarnLoading("Skipping sub cit: Failed loading model for \"" + citModelEntry.getValue().id + "\" in " + citItem.pack.resourcePack.getName() + " -> " + citItem.propertiesIdentifier.getPath());
                    else
                        citItem.bakedSubModels.override(citModelEntry.getKey(), bakedModel);
                }
            }
            citItem.unbakedAssets = null;
        }
    }
    profiler.pop();
}
Also used : CITItem(shcm.shsupercm.fabric.citresewn.pack.cits.CITItem) BakedModel(net.minecraft.client.render.model.BakedModel) JsonUnbakedModel(net.minecraft.client.render.model.json.JsonUnbakedModel) ModelOverride(net.minecraft.client.render.model.json.ModelOverride) ResewnItemModelIdentifier(shcm.shsupercm.fabric.citresewn.pack.ResewnItemModelIdentifier) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

BakedModel (net.minecraft.client.render.model.BakedModel)1 JsonUnbakedModel (net.minecraft.client.render.model.json.JsonUnbakedModel)1 ModelOverride (net.minecraft.client.render.model.json.ModelOverride)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1 ResewnItemModelIdentifier (shcm.shsupercm.fabric.citresewn.pack.ResewnItemModelIdentifier)1 CITItem (shcm.shsupercm.fabric.citresewn.pack.cits.CITItem)1