Search in sources :

Example 61 with PartType

use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.

the class GearModelOverrideList method getPartsInRenderOrder.

private static PartDataList getPartsInRenderOrder(ItemStack stack) {
    PartDataList unsorted = GearData.getConstructionParts(stack);
    PartDataList ret = PartDataList.of();
    ICoreItem item = (ICoreItem) stack.getItem();
    for (PartType partType : item.getRenderParts()) {
        ret.addAll(unsorted.getPartsOfType(partType));
    }
    for (PartData part : unsorted) {
        if (!ret.contains(part)) {
            ret.add(part);
        }
    }
    return ret;
}
Also used : PartDataList(net.silentchaos512.gear.api.part.PartDataList) PartType(net.silentchaos512.gear.api.part.PartType) PartData(net.silentchaos512.gear.gear.part.PartData) ICoreItem(net.silentchaos512.gear.api.item.ICoreItem)

Example 62 with PartType

use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.

the class TooltipHandler method getMaterialStatLines.

private static void getMaterialStatLines(ItemTooltipEvent event, PartType partType, MaterialInstance material) {
    TextListBuilder builder = new TextListBuilder();
    for (ItemStat stat : ItemStats.allStatsOrdered()) {
        if (stat.isVisible()) {
            getMaterialStatModLines(event, partType, material, builder, stat);
        }
    }
    event.getToolTip().addAll(builder.build());
}
Also used : TextListBuilder(net.silentchaos512.gear.client.util.TextListBuilder) ItemStat(net.silentchaos512.gear.api.stats.ItemStat)

Example 63 with PartType

use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.

the class TooltipHandler method getMaterialStatModLines.

private static void getMaterialStatModLines(ItemTooltipEvent event, PartType partType, MaterialInstance material, TextListBuilder builder, ItemStat stat) {
    Collection<StatInstance> modsAll = material.getStatModifiers(partType, StatGearKey.of(stat, GearType.ALL));
    Optional<MutableComponent> head = getStatTooltipLine(event, partType, stat, modsAll);
    builder.add(head.orElseGet(() -> TextUtil.withColor(stat.getDisplayName(), stat.getNameColor())));
    builder.indent();
    int subCount = 0;
    List<StatGearKey> keysForStat = material.get().getStatKeys(material, partType).stream().filter(key -> key.getStat().equals(stat)).collect(Collectors.toList());
    for (StatGearKey key : keysForStat) {
        if (key.getGearType() != GearType.ALL) {
            ItemStat stat1 = ItemStats.get(key.getStat());
            if (stat1 != null) {
                Collection<StatInstance> mods = material.getStatModifiers(partType, key);
                Optional<MutableComponent> line = getSubStatTooltipLine(event, partType, stat1, key.getGearType(), mods);
                if (line.isPresent()) {
                    builder.add(line.get());
                    ++subCount;
                }
            }
        }
    }
    if (subCount == 0 && !head.isPresent()) {
        builder.removeLast();
    }
    builder.unindent();
}
Also used : GraderTileEntity(net.silentchaos512.gear.block.grader.GraderTileEntity) java.util(java.util) ChargerTileEntity(net.silentchaos512.gear.block.charger.ChargerTileEntity) MaterialInstance(net.silentchaos512.gear.gear.material.MaterialInstance) StatModifierMap(net.silentchaos512.gear.api.stats.StatModifierMap) IMaterialModifier(net.silentchaos512.gear.api.material.modifier.IMaterialModifier) MutableComponent(net.minecraft.network.chat.MutableComponent) PartData(net.silentchaos512.gear.gear.part.PartData) I18n(net.minecraft.client.resources.language.I18n) AbstractGearPart(net.silentchaos512.gear.gear.part.AbstractGearPart) Config(net.silentchaos512.gear.config.Config) ChatFormatting(net.minecraft.ChatFormatting) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) IMaterialCategory(net.silentchaos512.gear.api.material.IMaterialCategory) StatInstance(net.silentchaos512.gear.api.stats.StatInstance) KeyTracker(net.silentchaos512.gear.client.KeyTracker) ItemStat(net.silentchaos512.gear.api.stats.ItemStat) TextUtil(net.silentchaos512.gear.util.TextUtil) ItemStats(net.silentchaos512.gear.api.stats.ItemStats) Component(net.minecraft.network.chat.Component) StatGearKey(net.silentchaos512.gear.api.util.StatGearKey) ModTags(net.silentchaos512.gear.init.ModTags) Collectors(java.util.stream.Collectors) PartType(net.silentchaos512.gear.api.part.PartType) GearType(net.silentchaos512.gear.api.item.GearType) TextComponent(net.minecraft.network.chat.TextComponent) Color(net.silentchaos512.utils.Color) ItemTooltipEvent(net.minecraftforge.event.entity.player.ItemTooltipEvent) TraitInstance(net.silentchaos512.gear.api.traits.TraitInstance) ItemStack(net.minecraft.world.item.ItemStack) ClientTicks(net.silentchaos512.lib.event.ClientTicks) TagUtils(net.silentchaos512.lib.util.TagUtils) TextListBuilder(net.silentchaos512.gear.client.util.TextListBuilder) CompoundPartItem(net.silentchaos512.gear.item.CompoundPartItem) MutableComponent(net.minecraft.network.chat.MutableComponent) StatInstance(net.silentchaos512.gear.api.stats.StatInstance) ItemStat(net.silentchaos512.gear.api.stats.ItemStat) StatGearKey(net.silentchaos512.gear.api.util.StatGearKey)

Example 64 with PartType

use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.

the class TooltipHandler method getSubStatTooltipLine.

private static Optional<MutableComponent> getSubStatTooltipLine(ItemTooltipEvent event, PartType partType, ItemStat stat, GearType gearType, Collection<StatInstance> modifiers) {
    if (!modifiers.isEmpty()) {
        StatInstance inst = stat.computeForDisplay(0, gearType, modifiers);
        if (inst.shouldList(partType, stat, event.getFlags().isAdvanced())) {
            boolean isZero = inst.getValue() == 0;
            Color color = isZero ? MC_DARK_GRAY : Color.WHITE;
            MutableComponent nameStr = TextUtil.withColor(gearType.getDisplayName().copy(), color);
            int decimalPlaces = stat.isDisplayAsInt() && inst.getOp() != StatInstance.Operation.MUL1 && inst.getOp() != StatInstance.Operation.MUL2 ? 0 : 2;
            MutableComponent statListText = TextUtil.withColor(StatModifierMap.formatText(modifiers, stat, decimalPlaces), color);
            // Harvest level hints
            MutableComponent textWithAdditions = stat == ItemStats.HARVEST_LEVEL && modifiers.size() == 1 ? harvestLevelWithHint(statListText, inst.getValue()) : statListText;
            return Optional.of(new TranslatableComponent("stat.silentgear.displayFormat", nameStr, textWithAdditions));
        }
    }
    return Optional.empty();
}
Also used : MutableComponent(net.minecraft.network.chat.MutableComponent) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) Color(net.silentchaos512.utils.Color) StatInstance(net.silentchaos512.gear.api.stats.StatInstance)

Example 65 with PartType

use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.

the class MaterialDisplay method getMostSpecificKey.

private PartGearKey getMostSpecificKey(GearType gearType, PartType partType) {
    PartGearKey key = PartGearKey.of(gearType, partType);
    if (map.containsKey(key)) {
        return key;
    }
    PartGearKey parent = key.getParent();
    while (parent != null) {
        if (map.containsKey(parent)) {
            return parent;
        }
        parent = parent.getParent();
    }
    // No match
    return key;
}
Also used : PartGearKey(net.silentchaos512.gear.api.util.PartGearKey)

Aggregations

PartType (net.silentchaos512.gear.api.part.PartType)37 ItemStack (net.minecraft.world.item.ItemStack)14 PartData (net.silentchaos512.gear.gear.part.PartData)14 StatInstance (net.silentchaos512.gear.api.stats.StatInstance)13 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)10 ICoreItem (net.silentchaos512.gear.api.item.ICoreItem)10 TextComponent (net.minecraft.network.chat.TextComponent)9 ResourceLocation (net.minecraft.resources.ResourceLocation)9 GearType (net.silentchaos512.gear.api.item.GearType)9 PartDataList (net.silentchaos512.gear.api.part.PartDataList)9 ItemStat (net.silentchaos512.gear.api.stats.ItemStat)9 Component (net.minecraft.network.chat.Component)8 IMaterialInstance (net.silentchaos512.gear.api.material.IMaterialInstance)8 IPartData (net.silentchaos512.gear.api.part.IPartData)8 MaterialInstance (net.silentchaos512.gear.gear.material.MaterialInstance)8 TraitInstance (net.silentchaos512.gear.api.traits.TraitInstance)7 StatGearKey (net.silentchaos512.gear.api.util.StatGearKey)7 ArrayList (java.util.ArrayList)5 Collectors (java.util.stream.Collectors)5 MutableComponent (net.minecraft.network.chat.MutableComponent)5