Search in sources :

Example 1 with CraftingItems

use of net.silentchaos512.gear.item.CraftingItems in project Silent-Gear by SilentChaos512.

the class ModItemModelProvider method registerModels.

@Override
protected void registerModels() {
    // Blocks
    Registration.BLOCKS.getEntries().stream().map(RegistryObject::get).forEach(this::blockItemModel);
    ModelFile itemGenerated = getExistingFile(new ResourceLocation("item/generated"));
    for (CraftingItems item : CraftingItems.values()) {
        builder(item, itemGenerated, "item/" + item.getName());
    }
    builder(ModItems.NETHERWOOD_CHARCOAL, itemGenerated);
    // Crafted materials
    builder(ModItems.SHEET_METAL).parent(itemGenerated).texture("layer0", "item/sheet_metal").texture("layer1", "item/sheet_metal_highlight");
    // Compound materials
    builder(ModItems.ALLOY_INGOT).parent(itemGenerated).texture("layer0", "item/alloy_ingot").texture("layer1", "item/alloy_ingot_highlight");
    builder(ModItems.HYBRID_GEM).parent(itemGenerated).texture("layer0", "item/hybrid_gem").texture("layer1", "item/hybrid_gem_highlight");
    builder(ModItems.MIXED_FABRIC, itemGenerated, "item/mixed_fabric");
    // Custom materials
    builder(ModItems.CUSTOM_INGOT).parent(itemGenerated).texture("layer0", "item/alloy_ingot").texture("layer1", "item/alloy_ingot_highlight");
    builder(ModItems.CUSTOM_GEM).parent(itemGenerated).texture("layer0", "item/hybrid_gem").texture("layer1", "item/hybrid_gem_highlight");
    builder(ModItems.BLUEPRINT_BOOK).parent(itemGenerated).texture("layer0", "item/blueprint_book_cover").texture("layer1", "item/blueprint_book_pages").texture("layer2", "item/blueprint_book_deco");
    builder(ModItems.JEWELER_TOOLS, itemGenerated, "item/jeweler_tools");
    // Blueprints and templates
    Registration.getItems(PartBlueprintItem.class).forEach(item -> {
        if (item.hasStandardModel()) {
            builder(item).parent(itemGenerated).texture("layer0", "item/" + (item.isSingleUse() ? "template" : "blueprint")).texture("layer1", "item/blueprint_" + item.getPartType().getName().getPath());
        }
    });
    Registration.getItems(GearBlueprintItem.class).forEach(item -> builder(item).parent(itemGenerated).texture("layer0", "item/" + (item.isSingleUse() ? "template" : "blueprint")).texture("layer1", "item/blueprint_" + item.getGearType().getName()));
    builder(ModItems.MOD_KIT, itemGenerated);
    // Repair kits
    builder(ModItems.VERY_CRUDE_REPAIR_KIT, itemGenerated);
    builder(ModItems.CRUDE_REPAIR_KIT, itemGenerated);
    builder(ModItems.STURDY_REPAIR_KIT, itemGenerated);
    builder(ModItems.CRIMSON_REPAIR_KIT, itemGenerated);
    builder(ModItems.AZURE_REPAIR_KIT, itemGenerated);
    // Misc
    builder(ModItems.GUIDE_BOOK, itemGenerated);
    builder(ModItems.BLUEPRINT_PACKAGE, itemGenerated);
    builder(ModItems.FLAX_SEEDS, itemGenerated);
    builder(ModItems.FLUFFY_SEEDS, itemGenerated);
    builder(ModItems.GOLDEN_NETHER_BANANA, itemGenerated);
    builder(ModItems.NETHER_BANANA, itemGenerated);
    builder(ModItems.PEBBLE, itemGenerated);
}
Also used : CraftingItems(net.silentchaos512.gear.item.CraftingItems) PartBlueprintItem(net.silentchaos512.gear.item.blueprint.PartBlueprintItem) ModelFile(net.minecraftforge.client.model.generators.ModelFile) ResourceLocation(net.minecraft.resources.ResourceLocation) GearBlueprintItem(net.silentchaos512.gear.item.blueprint.GearBlueprintItem)

Example 2 with CraftingItems

use of net.silentchaos512.gear.item.CraftingItems 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

JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 ResourceLocation (net.minecraft.resources.ResourceLocation)1 ModelFile (net.minecraftforge.client.model.generators.ModelFile)1 ICondition (net.minecraftforge.common.crafting.conditions.ICondition)1 IMaterialCategory (net.silentchaos512.gear.api.material.IMaterialCategory)1 CraftingItems (net.silentchaos512.gear.item.CraftingItems)1 GearBlueprintItem (net.silentchaos512.gear.item.blueprint.GearBlueprintItem)1 PartBlueprintItem (net.silentchaos512.gear.item.blueprint.PartBlueprintItem)1