Search in sources :

Example 6 with PartData

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

the class ICoreArmor method supportsPart.

@Override
default boolean supportsPart(ItemStack gear, PartData part) {
    PartType type = part.getType();
    boolean supported = ICoreItem.super.supportsPart(gear, part);
    return (type == PartType.MAIN && supported) || type == PartType.TIP || type == PartType.LINING || supported;
}
Also used : PartType(net.silentchaos512.gear.api.part.PartType)

Example 7 with PartData

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

the class TooltipHandler method getPartStatLines.

private static void getPartStatLines(ItemTooltipEvent event, ItemStack stack, PartData part) {
    GearType gearType = getPartGearType(part);
    TextListBuilder builder = new TextListBuilder();
    List<ItemStat> relevantStats = new ArrayList<>(part.getGearType().getRelevantStats());
    if (part.getGearType().isArmor() && relevantStats.contains(ItemStats.DURABILITY)) {
        int index = relevantStats.indexOf(ItemStats.DURABILITY);
        relevantStats.remove(ItemStats.DURABILITY);
        relevantStats.add(index, ItemStats.ARMOR_DURABILITY);
    }
    for (ItemStat stat : relevantStats) {
        Collection<StatInstance> modifiers = new ArrayList<>();
        for (StatInstance mod : part.getStatModifiers(StatGearKey.of(stat, gearType), ItemStack.EMPTY)) {
            if (mod.getOp() == StatInstance.Operation.AVG) {
                float computed = stat.compute(Collections.singleton(mod));
                modifiers.add(StatInstance.of(computed, StatInstance.Operation.AVG, mod.getKey()));
            } else {
                modifiers.add(mod);
            }
        }
        getStatTooltipLine(event, part.getType(), stat, modifiers).ifPresent(builder::add);
    }
    event.getToolTip().addAll(builder.build());
}
Also used : TextListBuilder(net.silentchaos512.gear.client.util.TextListBuilder) GearType(net.silentchaos512.gear.api.item.GearType) StatInstance(net.silentchaos512.gear.api.stats.StatInstance) ItemStat(net.silentchaos512.gear.api.stats.ItemStat)

Example 8 with PartData

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

the class TooltipHandler method onPartTooltip.

private static void onPartTooltip(ItemTooltipEvent event, ItemStack stack, PartData part) {
    if (event.getFlags().isAdvanced() && KeyTracker.isControlDown()) {
        event.getToolTip().add(new TextComponent("* Part ID: " + part.getId()).withStyle(ChatFormatting.DARK_GRAY));
        event.getToolTip().add(new TextComponent("* Part data pack: " + part.get().getPackName()).withStyle(ChatFormatting.DARK_GRAY));
    }
    if (!Config.Client.showPartTooltips.get()) {
        return;
    }
    // Type, tier
    event.getToolTip().add(TextUtil.withColor(part.getType().getDisplayName(part.getTier()), Color.AQUAMARINE));
    // Traits
    List<TraitInstance> traits = new ArrayList<>();
    for (TraitInstance traitInstance : part.getTraits()) {
        if (traitInstance.getTrait().showInTooltip(event.getFlags())) {
            traits.add(traitInstance);
        }
    }
    int numTraits = traits.size();
    int traitIndex = getTraitDisplayIndex(numTraits);
    int i = 0;
    for (TraitInstance inst : traits) {
        if (traitIndex < 0 || traitIndex == i) {
            inst.addInformation(event.getToolTip(), event.getFlags());
        }
        ++i;
    }
    // Stats
    if (KeyTracker.isControlDown()) {
        event.getToolTip().add(new TranslatableComponent("misc.silentgear.tooltip.stats").withStyle(ChatFormatting.GOLD).append(new TextComponent(" (Silent Gear)").withStyle(ChatFormatting.RESET).withStyle(ChatFormatting.ITALIC)));
        getPartStatLines(event, stack, part);
    } else {
        event.getToolTip().add(new TranslatableComponent("misc.silentgear.tooltip.ctrlForStats").withStyle(ChatFormatting.GOLD));
    }
    // Gear type blacklist?
    if (part.get() instanceof AbstractGearPart) {
        List<GearType> blacklist = ((AbstractGearPart) part.get()).getBlacklistedGearTypes();
        if (!blacklist.isEmpty()) {
            int index = (ClientTicks.ticksInGame() / 20) % blacklist.size();
            GearType gearType = blacklist.get(index);
            Component blacklistedType = gearType.getDisplayName();
            event.getToolTip().add(new TranslatableComponent("misc.silentgear.tooltip.blacklist", blacklistedType).withStyle(ChatFormatting.RED));
        }
    }
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) AbstractGearPart(net.silentchaos512.gear.gear.part.AbstractGearPart) GearType(net.silentchaos512.gear.api.item.GearType) TraitInstance(net.silentchaos512.gear.api.traits.TraitInstance) MutableComponent(net.minecraft.network.chat.MutableComponent) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) Component(net.minecraft.network.chat.Component) TextComponent(net.minecraft.network.chat.TextComponent)

Example 9 with PartData

use of net.silentchaos512.gear.gear.part.PartData 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)

Example 10 with PartData

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

the class GearModelOverrideList method addColorBlendedLayers.

private static void addColorBlendedLayers(List<MaterialLayer> list, PartData part, ItemStack stack, List<MaterialLayer> layers) {
    for (int i = 0; i < layers.size(); i++) {
        MaterialLayer layer = layers.get(i);
        if ((layer.getColor() & 0xFFFFFF) < 0xFFFFFF) {
            int blendedColor = part.getColor(stack, i, 0);
            MaterialLayer coloredLayer = layer.withColor(blendedColor);
            list.add(coloredLayer);
            if (isDebugLoggingEnabled()) {
                debugLogLayer(coloredLayer, Color.format(blendedColor));
            }
        } else {
            list.add(layer);
            if (isDebugLoggingEnabled()) {
                debugLogLayer(layer, "colorless");
            }
        }
    }
}
Also used : MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer)

Aggregations

PartData (net.silentchaos512.gear.gear.part.PartData)36 ItemStack (net.minecraft.world.item.ItemStack)16 IPartData (net.silentchaos512.gear.api.part.IPartData)14 PartDataList (net.silentchaos512.gear.api.part.PartDataList)13 ICoreItem (net.silentchaos512.gear.api.item.ICoreItem)12 PartType (net.silentchaos512.gear.api.part.PartType)9 GearType (net.silentchaos512.gear.api.item.GearType)8 MaterialInstance (net.silentchaos512.gear.gear.material.MaterialInstance)8 IMaterialInstance (net.silentchaos512.gear.api.material.IMaterialInstance)6 MaterialLayer (net.silentchaos512.gear.api.material.MaterialLayer)6 ArrayList (java.util.ArrayList)5 Component (net.minecraft.network.chat.Component)5 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)5 TextComponent (net.minecraft.network.chat.TextComponent)4 ItemStat (net.silentchaos512.gear.api.stats.ItemStat)4 StatInstance (net.silentchaos512.gear.api.stats.StatInstance)4 TraitInstance (net.silentchaos512.gear.api.traits.TraitInstance)4 Nullable (javax.annotation.Nullable)3 CompoundTag (net.minecraft.nbt.CompoundTag)3 MutableComponent (net.minecraft.network.chat.MutableComponent)3