Search in sources :

Example 1 with IMaterialCategory

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

the class CraftedMaterial method getCategories.

@Override
public Collection<IMaterialCategory> getCategories(IMaterialInstance material) {
    Collection<IMaterialCategory> set = super.getCategories(material);
    IMaterialInstance base = getBaseMaterial(material);
    set.addAll(base.getCategories());
    return set;
}
Also used : IMaterialCategory(net.silentchaos512.gear.api.material.IMaterialCategory) IMaterialInstance(net.silentchaos512.gear.api.material.IMaterialInstance)

Example 2 with IMaterialCategory

use of net.silentchaos512.gear.api.material.IMaterialCategory 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 3 with IMaterialCategory

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

the class PartMaterialIngredient method getJeiHint.

@Override
public Optional<Component> getJeiHint() {
    MutableComponent text;
    if (!this.categories.isEmpty()) {
        MutableComponent cats = new TextComponent(categories.stream().map(IMaterialCategory::getName).collect(Collectors.joining(", ")));
        text = TextUtil.withColor(cats, Color.INDIANRED);
    } else {
        MutableComponent any = new TextComponent("any");
        text = TextUtil.withColor(any, Color.LIGHTGREEN);
    }
    PartGearKey key = PartGearKey.of(this.gearType, this.partType);
    text.append(TextUtil.misc("spaceBrackets", key.toString()).withStyle(ChatFormatting.GRAY));
    return Optional.of(TextUtil.translate("jei", "materialType", text));
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) PartGearKey(net.silentchaos512.gear.api.util.PartGearKey) IMaterialCategory(net.silentchaos512.gear.api.material.IMaterialCategory) MutableComponent(net.minecraft.network.chat.MutableComponent)

Example 4 with IMaterialCategory

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

the class CompoundingRecipe method makeExample.

public static CompoundingRecipe makeExample(CompounderInfo<?> info, int count, CompoundingRecipe recipe) {
    IMaterialCategory[] cats = info.getCategories().toArray(new IMaterialCategory[0]);
    for (int i = 0; i < count; ++i) {
        recipe.ingredients.add(PartMaterialIngredient.of(PartType.MAIN, GearType.ALL, cats));
    }
    recipe.result = new ItemStack(info.getOutputItem(), count);
    return recipe;
}
Also used : IMaterialCategory(net.silentchaos512.gear.api.material.IMaterialCategory) ItemStack(net.minecraft.world.item.ItemStack)

Example 5 with IMaterialCategory

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

the class MaterialBuilder method serialize.

@SuppressWarnings({ "OverlyComplexMethod", "OverlyLongMethod" })
public JsonObject serialize() {
    validate();
    JsonObject json = new JsonObject();
    json.addProperty("type", this.serializer.getName().toString());
    json.addProperty("simple", this.simple);
    if (this.parent != null) {
        json.addProperty("parent", this.parent.toString());
    }
    if (!this.loadConditions.isEmpty()) {
        JsonArray array = new JsonArray();
        for (ICondition condition : this.loadConditions) {
            array.add(CraftingHelper.serialize(condition));
        }
        json.add("conditions", array);
    }
    JsonObject availability = new JsonObject();
    if (this.tier >= 0) {
        availability.addProperty("tier", this.tier);
        if (!this.categories.isEmpty()) {
            JsonArray array = new JsonArray();
            for (IMaterialCategory category : this.categories) {
                array.add(category.getName());
            }
            availability.add("categories", array);
        }
        availability.addProperty("visible", this.visible);
        JsonArray array = new JsonArray();
        for (String gearType : this.gearBlacklist) {
            array.add(gearType);
        }
        availability.add("gear_blacklist", array);
        availability.addProperty("can_salvage", this.canSalvage);
    }
    if (!availability.entrySet().isEmpty()) {
        json.add("availability", availability);
    }
    JsonObject craftingItems = new JsonObject();
    if (this.ingredient != Ingredient.EMPTY) {
        craftingItems.add("main", this.ingredient.toJson());
    }
    if (!this.partSubstitutes.isEmpty()) {
        JsonObject subs = new JsonObject();
        this.partSubstitutes.forEach((type, ing) -> subs.add(SilentGear.shortenId(type.getName()), ing.toJson()));
        craftingItems.add("subs", subs);
    }
    json.add("crafting_items", craftingItems);
    if (this.name != null) {
        json.add("name", Component.Serializer.toJsonTree(this.name));
    }
    if (this.namePrefix != null) {
        json.add("name_prefix", Component.Serializer.toJsonTree(this.namePrefix));
    }
    if (!this.stats.isEmpty()) {
        JsonObject statsJson = new JsonObject();
        this.stats.forEach((partType, map) -> statsJson.add(SilentGear.shortenId(partType.getName()), map.serialize()));
        json.add("stats", statsJson);
    }
    if (!this.traits.isEmpty()) {
        JsonObject traitsJson = new JsonObject();
        this.traits.forEach((partType, list) -> {
            JsonArray array = new JsonArray();
            list.forEach(t -> array.add(t.serialize()));
            traitsJson.add(SilentGear.shortenId(partType.getName()), array);
        });
        json.add("traits", traitsJson);
    }
    json.add("model", serializeModel());
    return json;
}
Also used : JsonArray(com.google.gson.JsonArray) IMaterialCategory(net.silentchaos512.gear.api.material.IMaterialCategory) JsonObject(com.google.gson.JsonObject) ICondition(net.minecraftforge.common.crafting.conditions.ICondition)

Aggregations

IMaterialCategory (net.silentchaos512.gear.api.material.IMaterialCategory)5 TextComponent (net.minecraft.network.chat.TextComponent)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 MutableComponent (net.minecraft.network.chat.MutableComponent)1 ItemStack (net.minecraft.world.item.ItemStack)1 ICondition (net.minecraftforge.common.crafting.conditions.ICondition)1 IMaterialInstance (net.silentchaos512.gear.api.material.IMaterialInstance)1 PartType (net.silentchaos512.gear.api.part.PartType)1 TraitInstance (net.silentchaos512.gear.api.traits.TraitInstance)1 PartGearKey (net.silentchaos512.gear.api.util.PartGearKey)1