Search in sources :

Example 6 with MaterialInstance

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

the class TooltipHandler method addJeiSearchTerms.

private static void addJeiSearchTerms(ItemTooltipEvent event, MaterialInstance material) {
    // Add search terms to allow advanced filtering in JEI (requires the
    // `SearchAdvancedTooltips` JEI config to be set)
    StringBuilder b = new StringBuilder();
    for (IMaterialCategory category : material.getCategories()) {
        b.append(category.getName()).append(" ");
    }
    Collection<String> traits = new HashSet<>();
    for (PartType partType : material.getPartTypes()) {
        b.append(partType.getDisplayName(0).getString()).append(" ");
        for (TraitInstance trait : material.getTraits(partType)) {
            traits.add(trait.getTrait().getDisplayName(0).getString());
        }
    }
    for (String str : traits) {
        b.append(str).append(" ");
    }
    event.getToolTip().add(new TextComponent(b.toString().toLowerCase(Locale.ROOT)).withStyle(ChatFormatting.DARK_GRAY).withStyle(ChatFormatting.ITALIC));
}
Also used : PartType(net.silentchaos512.gear.api.part.PartType) TextComponent(net.minecraft.network.chat.TextComponent) IMaterialCategory(net.silentchaos512.gear.api.material.IMaterialCategory) TraitInstance(net.silentchaos512.gear.api.traits.TraitInstance)

Example 7 with MaterialInstance

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

the class TooltipHandler method getMaterialTraitLines.

private static void getMaterialTraitLines(ItemTooltipEvent event, PartType partType, MaterialInstance material) {
    Collection<TraitInstance> traits = material.getTraits(partType);
    if (traits.isEmpty())
        return;
    MutableComponent header = TextUtil.misc("tooltip.traits").withStyle(ChatFormatting.GOLD);
    if (!KeyTracker.isDisplayTraitsDown()) {
        MutableComponent keyHint = TextUtil.withColor(TextUtil.keyBinding(KeyTracker.DISPLAY_TRAITS), Color.AQUAMARINE);
        header.append(" ").append(keyHint);
    }
    event.getToolTip().add(header);
    TextListBuilder builder = new TextListBuilder();
    for (TraitInstance trait : traits) {
        builder.add(trait.getDisplayName());
        // Trait description and conditions
        if (event.getFlags().isAdvanced() || KeyTracker.isDisplayTraitsDown()) {
            builder.indent();
            builder.add(trait.getTrait().getDescription(trait.getLevel()).withStyle(ChatFormatting.DARK_GRAY));
            if (!trait.getConditions().isEmpty()) {
                builder.add(TextUtil.withColor(trait.getConditionsText(), ChatFormatting.DARK_GRAY));
            }
            builder.unindent();
        }
    }
    event.getToolTip().addAll(builder.build());
}
Also used : TextListBuilder(net.silentchaos512.gear.client.util.TextListBuilder) MutableComponent(net.minecraft.network.chat.MutableComponent) TraitInstance(net.silentchaos512.gear.api.traits.TraitInstance)

Example 8 with MaterialInstance

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

the class TooltipHandler method onMaterialTooltip.

private static void onMaterialTooltip(ItemTooltipEvent event, ItemStack stack, MaterialInstance material) {
    boolean keyHeld = KeyTracker.isDisplayStatsDown();
    if (event.getFlags().isAdvanced()) {
        event.getToolTip().add(new TextComponent("Material ID: " + material.getId()).withStyle(ChatFormatting.DARK_GRAY));
        event.getToolTip().add(new TextComponent("Material data pack: " + material.get().getPackName()).withStyle(ChatFormatting.DARK_GRAY));
    }
    if (!Config.Client.showMaterialTooltips.get()) {
        return;
    }
    if (keyHeld) {
        event.getToolTip().add(TextUtil.withColor(TextUtil.misc("tooltip.material"), Color.GOLD));
    } else {
        event.getToolTip().add(TextUtil.withColor(TextUtil.misc("tooltip.material"), Color.GOLD).append(new TextComponent(" ").append(TextUtil.withColor(TextUtil.keyBinding(KeyTracker.DISPLAY_STATS), ChatFormatting.GRAY))));
    }
    if (event.getFlags().isAdvanced()) {
        event.getToolTip().add(new TextComponent("Material ID: " + material.getId()).withStyle(ChatFormatting.DARK_GRAY));
        event.getToolTip().add(new TextComponent("Material data pack: " + material.get().getPackName()).withStyle(ChatFormatting.DARK_GRAY));
    }
    if (keyHeld) {
        getMaterialModifierLines(event, material);
        getMaterialCategoriesLine(material).ifPresent(t -> event.getToolTip().add(t));
        List<PartType> partTypes = new ArrayList<>(material.getPartTypes());
        if (!partTypes.isEmpty()) {
            int index = KeyTracker.getMaterialCycleIndex(partTypes.size());
            PartType partType = partTypes.get(index);
            event.getToolTip().add(buildPartTypeHeader(partTypes, partType));
            event.getToolTip().add(TextUtil.withColor(TextUtil.misc("tier", material.getTier(partType)), Color.DEEPSKYBLUE));
            getMaterialTraitLines(event, partType, material);
            event.getToolTip().add(new TranslatableComponent("misc.silentgear.tooltip.stats").withStyle(ChatFormatting.GOLD));
            getMaterialStatLines(event, partType, material);
        }
    } else {
        getMaterialModifierLines(event, material);
        if (event.getFlags().isAdvanced()) {
            addJeiSearchTerms(event, material);
        }
    }
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) PartType(net.silentchaos512.gear.api.part.PartType) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent)

Example 9 with MaterialInstance

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

the class GearDisplayManager method getMaterials.

public static Collection<IMaterialDisplay> getMaterials() {
    synchronized (MATERIALS) {
        Collection<IMaterialDisplay> ret = new ArrayList<>();
        for (IMaterial material : MaterialManager.getValues()) {
            MaterialInstance mat = MaterialInstance.of(material);
            ret.add(mat.getDisplayProperties());
        }
        ret.addAll(MATERIALS.values());
        return ret;
    }
}
Also used : IMaterial(net.silentchaos512.gear.api.material.IMaterial) IMaterialDisplay(net.silentchaos512.gear.api.material.IMaterialDisplay) MaterialInstance(net.silentchaos512.gear.gear.material.MaterialInstance) IMaterialInstance(net.silentchaos512.gear.api.material.IMaterialInstance)

Example 10 with MaterialInstance

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

the class GearModelOverrideList method addWithBlendedColor.

private static void addWithBlendedColor(List<MaterialLayer> list, PartData part, MaterialInstance material, ItemStack stack) {
    IMaterialDisplay model = material.getDisplayProperties();
    GearType gearType = GearHelper.getType(stack);
    List<MaterialLayer> layers = model.getLayerList(gearType, part, material).getLayers();
    addColorBlendedLayers(list, part, stack, layers);
}
Also used : GearType(net.silentchaos512.gear.api.item.GearType) IMaterialDisplay(net.silentchaos512.gear.api.material.IMaterialDisplay) MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer)

Aggregations

MaterialInstance (net.silentchaos512.gear.gear.material.MaterialInstance)25 ItemStack (net.minecraft.world.item.ItemStack)12 IMaterial (net.silentchaos512.gear.api.material.IMaterial)10 IMaterialInstance (net.silentchaos512.gear.api.material.IMaterialInstance)10 PartType (net.silentchaos512.gear.api.part.PartType)9 MaterialLayer (net.silentchaos512.gear.api.material.MaterialLayer)8 PartData (net.silentchaos512.gear.gear.part.PartData)8 Component (net.minecraft.network.chat.Component)7 IMaterialDisplay (net.silentchaos512.gear.api.material.IMaterialDisplay)7 TextComponent (net.minecraft.network.chat.TextComponent)6 ResourceLocation (net.minecraft.resources.ResourceLocation)6 TraitInstance (net.silentchaos512.gear.api.traits.TraitInstance)6 Collectors (java.util.stream.Collectors)5 Nullable (javax.annotation.Nullable)5 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)5 GearType (net.silentchaos512.gear.api.item.GearType)5 ItemStat (net.silentchaos512.gear.api.stats.ItemStat)5 LazyMaterialInstance (net.silentchaos512.gear.gear.material.LazyMaterialInstance)5 java.util (java.util)4 ArrayList (java.util.ArrayList)4