Search in sources :

Example 26 with PartData

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

the class UpgradeSmithingRecipe method applyUpgrade.

@Override
protected ItemStack applyUpgrade(ItemStack gear, ItemStack upgradeItem) {
    PartData part = PartData.from(upgradeItem);
    if (part != null) {
        GearType gearType = GearHelper.getType(gear);
        if (gearType.isGear() && part.get().canAddToGear(gear, part) && !GearData.hasPart(gear, part.get())) {
            ItemStack result = gear.copy();
            GearData.addPart(result, part);
            GearData.recalculateStats(result, ForgeHooks.getCraftingPlayer());
            return result;
        }
    }
    return ItemStack.EMPTY;
}
Also used : GearType(net.silentchaos512.gear.api.item.GearType) PartData(net.silentchaos512.gear.gear.part.PartData) ItemStack(net.minecraft.world.item.ItemStack)

Example 27 with PartData

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

the class ShapelessGearRecipe method matches.

@Override
public boolean matches(CraftingContainer inv, Level worldIn) {
    if (!this.getBaseRecipe().matches(inv, worldIn))
        return false;
    GearType gearType = item.getGearType();
    Collection<PartData> parts = getParts(inv);
    if (parts.isEmpty())
        return false;
    for (PartData part : parts) {
        if (!part.isCraftingAllowed(gearType, inv)) {
            return false;
        }
    }
    return true;
}
Also used : GearType(net.silentchaos512.gear.api.item.GearType) PartData(net.silentchaos512.gear.gear.part.PartData)

Example 28 with PartData

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

the class GearClientHelper method addInformation.

public static void addInformation(ItemStack stack, Level world, List<Component> tooltip, GearTooltipFlag flag) {
    if (!(stack.getItem() instanceof ICoreItem))
        return;
    ICoreItem item = (ICoreItem) stack.getItem();
    if (GearHelper.isBroken(stack)) {
        tooltip.add(Math.min(1, tooltip.size()), TextUtil.withColor(misc("broken"), Color.FIREBRICK));
    }
    if (GearData.isExampleGear(stack)) {
        tooltip.add(Math.min(1, tooltip.size()), TextUtil.withColor(misc("exampleOutput1"), Color.YELLOW));
        tooltip.add(Math.min(2, tooltip.size()), TextUtil.withColor(misc("exampleOutput2"), Color.YELLOW));
    }
    PartDataList constructionParts = GearData.getConstructionParts(stack);
    if (constructionParts.getMains().isEmpty()) {
        tooltip.add(TextUtil.withColor(misc("invalidParts"), Color.FIREBRICK));
        tooltip.add(TextUtil.withColor(misc("lockedStats"), Color.FIREBRICK));
    } else if (GearData.hasLockedStats(stack)) {
        tooltip.add(TextUtil.withColor(misc("lockedStats"), Color.YELLOW));
    }
    if (!Config.Client.vanillaStyleTooltips.get()) {
        // Let parts add information if they need to
        Collections.reverse(constructionParts);
        for (PartData data : constructionParts) {
            data.get().addInformation(data, stack, tooltip, flag);
        }
    }
    // Traits
    addTraitsInfo(stack, tooltip, flag);
    if (!Config.Client.vanillaStyleTooltips.get()) {
        // Stats
        addStatsInfo(stack, tooltip, flag, item);
    }
    // Tool construction
    if (KeyTracker.isDisplayConstructionDown() && flag.showConstruction) {
        tooltip.add(TextUtil.withColor(misc("tooltip.construction"), Color.GOLD));
        Collections.reverse(constructionParts);
        tooltipListParts(stack, tooltip, constructionParts, flag);
    } else if (flag.showConstruction) {
        tooltip.add(TextUtil.withColor(TextUtil.misc("tooltip.construction"), Color.GOLD).append(new TextComponent(" ").append(TextUtil.withColor(TextUtil.keyBinding(KeyTracker.DISPLAY_CONSTRUCTION), ChatFormatting.GRAY))));
    }
}
Also used : PartDataList(net.silentchaos512.gear.api.part.PartDataList) TextComponent(net.minecraft.network.chat.TextComponent) PartData(net.silentchaos512.gear.gear.part.PartData) ICoreItem(net.silentchaos512.gear.api.item.ICoreItem)

Example 29 with PartData

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

the class GearSalvagingRecipe method getPossibleResults.

@Override
public List<ItemStack> getPossibleResults(Container inv) {
    ItemStack input = inv.getItem(0);
    List<ItemStack> ret = new ArrayList<>();
    PartDataList parts = GearData.getConstructionParts(input);
    for (PartData part : parts) {
        ret.addAll(salvage(part));
    }
    return ret;
}
Also used : PartDataList(net.silentchaos512.gear.api.part.PartDataList) ArrayList(java.util.ArrayList) PartData(net.silentchaos512.gear.gear.part.PartData) ItemStack(net.minecraft.world.item.ItemStack)

Example 30 with PartData

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

the class CompoundPartItem method getName.

@Override
public Component getName(ItemStack stack) {
    PartData part = PartData.from(stack);
    MaterialInstance material = getPrimaryMaterial(stack);
    if (part != null && material != null) {
        TranslatableComponent nameText = new TranslatableComponent(this.getDescriptionId() + ".nameProper", material.getDisplayName(partType, ItemStack.EMPTY));
        int nameColor = Color.blend(part.getColor(ItemStack.EMPTY), Color.VALUE_WHITE, 0.25f) & 0xFFFFFF;
        return TextUtil.withColor(nameText, nameColor);
    }
    return super.getName(stack);
}
Also used : TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) PartData(net.silentchaos512.gear.gear.part.PartData) MaterialInstance(net.silentchaos512.gear.gear.material.MaterialInstance) IMaterialInstance(net.silentchaos512.gear.api.material.IMaterialInstance) LazyMaterialInstance(net.silentchaos512.gear.gear.material.LazyMaterialInstance)

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