Search in sources :

Example 16 with IMaterialDisplay

use of net.silentchaos512.gear.api.material.IMaterialDisplay in project Silent-Gear by SilentChaos512.

the class GearModel method buildFakeModel.

private void buildFakeModel(Function<Material, TextureAtlasSprite> spriteGetter, ImmutableList.Builder<BakedQuad> builder, Transformation rotation, IMaterial material) {
    // This method will display an example tool for items with no data (ie, for advancements)
    MaterialInstance mat = MaterialInstance.of(material);
    IMaterialDisplay model = mat.getDisplayProperties();
    if (!gearType.isArmor()) {
        MaterialLayer exampleRod = model.getLayerList(this.gearType, PartType.ROD, mat).getFirstLayer();
        if (exampleRod != null) {
            builder.addAll(getQuadsForSprite(0, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, exampleRod.getTexture(gearType, 0))), rotation, exampleRod.getColor()));
        }
    }
    MaterialLayer exampleMain = model.getLayerList(this.gearType, PartType.MAIN, mat).getFirstLayer();
    if (exampleMain != null) {
        builder.addAll(getQuadsForSprite(0, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, exampleMain.getTexture(gearType, 0))), rotation, exampleMain.getColor()));
    }
    if (gearType.matches(GearType.RANGED_WEAPON)) {
        MaterialLayer exampleBowstring = model.getLayerList(this.gearType, PartType.CORD, mat).getFirstLayer();
        if (exampleBowstring != null) {
            builder.addAll(getQuadsForSprite(0, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, exampleBowstring.getTexture(gearType, 0))), rotation, exampleBowstring.getColor()));
        }
    }
}
Also used : IMaterialDisplay(net.silentchaos512.gear.api.material.IMaterialDisplay) MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer) IMaterial(net.silentchaos512.gear.api.material.IMaterial) MaterialInstance(net.silentchaos512.gear.gear.material.MaterialInstance) LazyMaterialInstance(net.silentchaos512.gear.gear.material.LazyMaterialInstance)

Aggregations

IMaterialDisplay (net.silentchaos512.gear.api.material.IMaterialDisplay)16 MaterialLayer (net.silentchaos512.gear.api.material.MaterialLayer)12 IMaterial (net.silentchaos512.gear.api.material.IMaterial)7 IMaterialInstance (net.silentchaos512.gear.api.material.IMaterialInstance)6 MaterialInstance (net.silentchaos512.gear.gear.material.MaterialInstance)5 ResourceLocation (net.minecraft.resources.ResourceLocation)3 LazyMaterialInstance (net.silentchaos512.gear.gear.material.LazyMaterialInstance)3 StaticLayer (net.silentchaos512.gear.api.material.StaticLayer)2 PartType (net.silentchaos512.gear.api.part.PartType)2 PartTextures (net.silentchaos512.gear.client.model.PartTextures)2 JsonObject (com.google.gson.JsonObject)1 JsonParseException (com.google.gson.JsonParseException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Resource (net.minecraft.server.packs.resources.Resource)1 GearType (net.silentchaos512.gear.api.item.GearType)1 IPartDisplay (net.silentchaos512.gear.api.part.IPartDisplay)1 ModResourceLocation (net.silentchaos512.gear.util.ModResourceLocation)1