Search in sources :

Example 6 with IGearPart

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

the class SyncGearCraftingItemsPacket method handle.

public void handle(Supplier<NetworkEvent.Context> context) {
    SilentGear.LOGGER.debug("Correcting part crafting items");
    this.craftingItems.forEach((id, ingredient) -> {
        IGearPart part = PartManager.get(id);
        if (part instanceof AbstractGearPart) {
            ((AbstractGearPart) part).updateCraftingItems(ingredient);
        }
    });
    context.get().setPacketHandled(true);
}
Also used : AbstractGearPart(net.silentchaos512.gear.gear.part.AbstractGearPart) IGearPart(net.silentchaos512.gear.api.part.IGearPart)

Example 7 with IGearPart

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

the class GearBlueprintItem method appendSupportedTypesText.

private void appendSupportedTypesText(Collection<Component> list) {
    if (KeyTracker.isDisplayStatsDown()) {
        Optional<ICoreItem> itemOptional = this.gearType.getItem();
        if (itemOptional.isPresent()) {
            TextListBuilder builder = new TextListBuilder();
            ICoreItem item = itemOptional.get();
            ItemStack gear = new ItemStack(item);
            for (PartType type : PartType.getValues()) {
                if (type != PartType.MAIN) {
                    List<IGearPart> partsOfType = PartManager.getPartsOfType(type);
                    if (!partsOfType.isEmpty() && item.supportsPart(gear, PartData.of(partsOfType.get(0)))) {
                        builder.add(type.getDisplayName(0));
                    }
                }
            }
            List<Component> lines = builder.build();
            if (!lines.isEmpty()) {
                list.add(TextUtil.withColor(TextUtil.misc("supportedPartTypes"), Color.GOLD));
                list.addAll(lines);
            }
        }
    } else {
        list.add(TextUtil.withColor(TextUtil.misc("supportedPartTypes"), Color.GOLD).append(" ").append(TextUtil.withColor(TextUtil.keyBinding(KeyTracker.DISPLAY_STATS), ChatFormatting.GRAY)));
    }
}
Also used : TextListBuilder(net.silentchaos512.gear.client.util.TextListBuilder) PartType(net.silentchaos512.gear.api.part.PartType) IGearPart(net.silentchaos512.gear.api.part.IGearPart) ICoreItem(net.silentchaos512.gear.api.item.ICoreItem) ItemStack(net.minecraft.world.item.ItemStack) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) Component(net.minecraft.network.chat.Component) TextComponent(net.minecraft.network.chat.TextComponent)

Example 8 with IGearPart

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

the class PartData method of.

public static PartData of(IGearPart part) {
    ResourceLocation name = part.getId();
    if (CACHE_UNGRADED_PARTS.containsKey(name)) {
        return CACHE_UNGRADED_PARTS.get(name);
    }
    PartData inst = new PartData(part);
    CACHE_UNGRADED_PARTS.put(name, inst);
    return inst;
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) IPartData(net.silentchaos512.gear.api.part.IPartData)

Example 9 with IGearPart

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

the class TraitsCommand method getPartsWithTrait.

private static String getPartsWithTrait(ITrait trait) {
    StringBuilder str = new StringBuilder();
    boolean foundAny = false;
    for (IGearPart part : PartManager.getValues()) {
        PartData partData = PartData.of(part);
        for (TraitInstance inst : partData.getTraits()) {
            if (inst.getTrait().equals(trait) && part.isVisible()) {
                if (foundAny) {
                    str.append(", ");
                }
                foundAny = true;
                str.append("**").append(partData.getDisplayName(ItemStack.EMPTY).getString()).append("**");
            }
        }
    }
    return str.toString();
}
Also used : IGearPart(net.silentchaos512.gear.api.part.IGearPart) TraitInstance(net.silentchaos512.gear.api.traits.TraitInstance) PartData(net.silentchaos512.gear.gear.part.PartData)

Example 10 with IGearPart

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

the class PartsCommand method partToTsvLine.

private static String partToTsvLine(IGearPart part) {
    StringBuilder builder = new StringBuilder();
    PartData partData = PartData.of(part);
    appendTsv(builder, part.getDisplayName(partData, ItemStack.EMPTY).getString());
    appendTsv(builder, part.getId().toString());
    appendTsv(builder, part.getType().getName());
    appendTsv(builder, partData.getTier());
    // Stats
    for (ItemStat stat : ItemStats.allStatsOrdered()) {
        Collection<StatInstance> statModifiers = partData.getStatModifiers(StatGearKey.of(stat, GearType.ALL), ItemStack.EMPTY);
        appendTsv(builder, FORMAT_CODES.matcher(StatModifierMap.formatText(statModifiers, stat, 5).getString()).replaceAll(""));
    }
    // Traits
    appendTsv(builder, partData.getTraits().stream().map(t -> t.getTrait().getDisplayName(t.getLevel()).getString()).collect(Collectors.joining(", ")));
    return builder.toString();
}
Also used : PartData(net.silentchaos512.gear.gear.part.PartData) StatInstance(net.silentchaos512.gear.api.stats.StatInstance) ItemStat(net.silentchaos512.gear.api.stats.ItemStat)

Aggregations

IGearPart (net.silentchaos512.gear.api.part.IGearPart)8 ResourceLocation (net.minecraft.resources.ResourceLocation)5 TextComponent (net.minecraft.network.chat.TextComponent)2 ItemStack (net.minecraft.world.item.ItemStack)2 PartData (net.silentchaos512.gear.gear.part.PartData)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 JsonObject (com.google.gson.JsonObject)1 JsonParseException (com.google.gson.JsonParseException)1 IOException (java.io.IOException)1 Nullable (javax.annotation.Nullable)1 CompoundTag (net.minecraft.nbt.CompoundTag)1 ListTag (net.minecraft.nbt.ListTag)1 Component (net.minecraft.network.chat.Component)1 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)1 Resource (net.minecraft.server.packs.resources.Resource)1 ICoreItem (net.silentchaos512.gear.api.item.ICoreItem)1 IPartData (net.silentchaos512.gear.api.part.IPartData)1 IPartSerializer (net.silentchaos512.gear.api.part.IPartSerializer)1 PartType (net.silentchaos512.gear.api.part.PartType)1