Search in sources :

Example 1 with PartTextures

use of net.silentchaos512.gear.client.model.PartTextures in project Silent-Gear by SilentChaos512.

the class GearModel method getTextures.

@SuppressWarnings("OverlyComplexMethod")
@Override
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
    Set<Material> ret = new HashSet<>();
    ret.add(new Material(InventoryMenu.BLOCK_ATLAS, SilentGear.getId("item/error")));
    // Generic built-in textures
    for (PartTextures tex : PartTextures.getTextures(this.gearType)) {
        int animationFrames = tex.isAnimated() ? item.getAnimationFrames() : 1;
        for (int i = 0; i < animationFrames; ++i) {
            MaterialLayer layer = new MaterialLayer(tex, Color.VALUE_WHITE);
            ret.add(getTexture(layer, i, false));
            ret.add(getTexture(layer, 0, true));
        }
    }
    // Custom textures
    for (IMaterialDisplay materialDisplay : GearDisplayManager.getMaterials()) {
        for (PartType partType : PartType.getValues()) {
            if (item.hasTexturesFor(partType)) {
                for (MaterialLayer layer : materialDisplay.getLayerList(gearType, partType, LazyMaterialInstance.of(materialDisplay.getMaterialId()))) {
                    int animationFrames = layer.isAnimated() ? item.getAnimationFrames() : 1;
                    ret.addAll(this.getTexturesForAllFrames(layer, animationFrames, false));
                    ret.addAll(this.getTexturesForAllFrames(layer, 1, true));
                }
            }
        }
    }
    for (IPartDisplay partDisplay : GearDisplayManager.getParts()) {
        for (MaterialLayer layer : partDisplay.getLayers(gearType, FakePartData.of(PartType.NONE))) {
            int animationFrames = layer.isAnimated() ? item.getAnimationFrames() : 1;
            ret.addAll(this.getTexturesForAllFrames(layer, animationFrames, false));
            ret.addAll(this.getTexturesForAllFrames(layer, animationFrames, true));
        }
    }
    if (GearModelOverrideList.isDebugLoggingEnabled()) {
        SilentGear.LOGGER.info("Textures for gear model '{}' ({})", getTexturePath(false), this.gearType.getName());
        for (Material mat : ret) {
            SilentGear.LOGGER.info("- {}", mat.texture());
        }
    }
    return ret;
}
Also used : PartType(net.silentchaos512.gear.api.part.PartType) PartTextures(net.silentchaos512.gear.client.model.PartTextures) IMaterialDisplay(net.silentchaos512.gear.api.material.IMaterialDisplay) IPartDisplay(net.silentchaos512.gear.api.part.IPartDisplay) MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer) IMaterial(net.silentchaos512.gear.api.material.IMaterial)

Example 2 with PartTextures

use of net.silentchaos512.gear.client.model.PartTextures in project Silent-Gear by SilentChaos512.

the class MaterialBuilder method displayTip.

public MaterialBuilder displayTip(PartTextures texture, int color) {
    display(PartType.TIP, GearType.ALL, new MaterialLayer(texture, color));
    display(PartType.TIP, GearType.PART, new MaterialLayer(SilentGear.getId("tip_base"), Color.VALUE_WHITE), new MaterialLayer(SilentGear.getId("tip"), color), new MaterialLayer(SilentGear.getId("tip_shine"), Color.VALUE_WHITE));
    return this;
}
Also used : MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer)

Example 3 with PartTextures

use of net.silentchaos512.gear.client.model.PartTextures in project Silent-Gear by SilentChaos512.

the class CompoundPartModel method getTextures.

@Override
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
    Set<Material> ret = new HashSet<>();
    if (this.gearType == GearType.SHIELD) {
        // Unobtainable part items, no need for textures
        return ret;
    }
    // Generic built-in textures
    for (PartTextures tex : PartTextures.getTextures(this.gearType)) {
        ret.add(getTexture(tex.getTexture()));
    }
    // Custom textures
    for (IMaterialDisplay materialDisplay : GearDisplayManager.getMaterials()) {
        for (MaterialLayer layer : materialDisplay.getLayerList(this.gearType, this.partType, LazyMaterialInstance.of(materialDisplay.getMaterialId()))) {
            ret.add(getTexture(layer));
        }
    }
    for (ResourceLocation texture : this.extraLayers) {
        ret.add(getTexture(new StaticLayer(texture)));
    }
    ret.add(getTexture(new StaticLayer(PART_MARKER_TEXTURE)));
    ret.add(new Material(InventoryMenu.BLOCK_ATLAS, SilentGear.getId("item/error")));
    if (CompoundPartModelOverrideList.isDebugLoggingEnabled()) {
        SilentGear.LOGGER.info("Textures for compound part model '{}'", PartGearKey.of(this.gearType, this.partType));
        for (Material mat : ret) {
            SilentGear.LOGGER.info("- {}", mat.texture());
        }
    }
    return ret;
}
Also used : PartTextures(net.silentchaos512.gear.client.model.PartTextures) IMaterialDisplay(net.silentchaos512.gear.api.material.IMaterialDisplay) MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer) ResourceLocation(net.minecraft.resources.ResourceLocation) ModResourceLocation(net.silentchaos512.gear.util.ModResourceLocation) IMaterial(net.silentchaos512.gear.api.material.IMaterial) StaticLayer(net.silentchaos512.gear.api.material.StaticLayer)

Aggregations

MaterialLayer (net.silentchaos512.gear.api.material.MaterialLayer)3 IMaterial (net.silentchaos512.gear.api.material.IMaterial)2 IMaterialDisplay (net.silentchaos512.gear.api.material.IMaterialDisplay)2 PartTextures (net.silentchaos512.gear.client.model.PartTextures)2 ResourceLocation (net.minecraft.resources.ResourceLocation)1 StaticLayer (net.silentchaos512.gear.api.material.StaticLayer)1 IPartDisplay (net.silentchaos512.gear.api.part.IPartDisplay)1 PartType (net.silentchaos512.gear.api.part.PartType)1 ModResourceLocation (net.silentchaos512.gear.util.ModResourceLocation)1