Search in sources :

Example 21 with GearType

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

the class MaterialBuilder method stat.

public MaterialBuilder stat(PartType partType, IItemStat stat, GearType gearType, float value, StatInstance.Operation operation) {
    StatGearKey key = StatGearKey.of(stat, gearType);
    StatInstance mod = StatInstance.of(value, operation, key);
    StatModifierMap map = stats.computeIfAbsent(partType, pt -> new StatModifierMap());
    map.put(stat, gearType, mod);
    return this;
}
Also used : StatGearKey(net.silentchaos512.gear.api.util.StatGearKey)

Example 22 with GearType

use of net.silentchaos512.gear.api.item.GearType 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 23 with GearType

use of net.silentchaos512.gear.api.item.GearType 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 24 with GearType

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

the class ItemStat method computeForDisplay.

public StatInstance computeForDisplay(float baseValue, GearType gearType, Collection<StatInstance> modifiers) {
    if (modifiers.isEmpty()) {
        return StatInstance.of(baseValue, Operation.AVG, StatInstance.DEFAULT_KEY);
    }
    int add = 1;
    for (StatInstance inst : modifiers) {
        Operation op = inst.getOp();
        if (op == Operation.AVG || op == Operation.ADD || op == Operation.MAX) {
            add = 0;
            break;
        }
    }
    float value = compute(baseValue + add, false, gearType, modifiers) - add;
    Operation op = modifiers.iterator().next().getOp();
    return StatInstance.of(value, op, StatInstance.DEFAULT_KEY);
}
Also used : Operation(net.silentchaos512.gear.api.stats.StatInstance.Operation)

Example 25 with GearType

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

the class AbstractMaterial method isCraftingAllowed.

@Override
public boolean isCraftingAllowed(IMaterialInstance material, PartType partType, GearType gearType, @Nullable Container inventory) {
    if (isGearTypeBlacklisted(gearType) || !allowedInPart(material, partType)) {
        return false;
    }
    if (stats.containsKey(partType) || (getParent() != null && getParent().isCraftingAllowed(material, partType, gearType, inventory))) {
        if (partType == PartType.MAIN) {
            ItemStat stat = gearType.getDurabilityStat();
            StatGearKey key = StatGearKey.of(stat, gearType);
            return !getStatModifiers(material, partType, key).isEmpty() && getStatUnclamped(material, partType, key, ItemStack.EMPTY) > 0;
        }
        return true;
    }
    return false;
}
Also used : StatGearKey(net.silentchaos512.gear.api.util.StatGearKey)

Aggregations

GearType (net.silentchaos512.gear.api.item.GearType)25 ItemStack (net.minecraft.world.item.ItemStack)9 PartType (net.silentchaos512.gear.api.part.PartType)9 ArrayList (java.util.ArrayList)8 ResourceLocation (net.minecraft.resources.ResourceLocation)8 JsonObject (com.google.gson.JsonObject)6 StatGearKey (net.silentchaos512.gear.api.util.StatGearKey)6 MaterialInstance (net.silentchaos512.gear.gear.material.MaterialInstance)6 JsonArray (com.google.gson.JsonArray)5 List (java.util.List)5 ICoreItem (net.silentchaos512.gear.api.item.ICoreItem)5 PartGearKey (net.silentchaos512.gear.api.util.PartGearKey)5 JsonParseException (com.google.gson.JsonParseException)4 IMaterial (net.silentchaos512.gear.api.material.IMaterial)4 MaterialLayer (net.silentchaos512.gear.api.material.MaterialLayer)4 IPartData (net.silentchaos512.gear.api.part.IPartData)4 ItemStat (net.silentchaos512.gear.api.stats.ItemStat)4 StatInstance (net.silentchaos512.gear.api.stats.StatInstance)4 ITrait (net.silentchaos512.gear.api.traits.ITrait)4 TraitInstance (net.silentchaos512.gear.api.traits.TraitInstance)4