Search in sources :

Example 66 with PartType

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

the class IStatModProvider method getStat.

default float getStat(D instance, PartType partType, StatGearKey key, ItemStack gear) {
    ItemStat stat = ItemStats.get(key.getStat());
    if (stat == null)
        return key.getStat().getDefaultValue();
    Collection<StatInstance> mods = getStatModifiers(instance, partType, key, gear);
    return stat.compute(mods);
}
Also used : StatInstance(net.silentchaos512.gear.api.stats.StatInstance) ItemStat(net.silentchaos512.gear.api.stats.ItemStat)

Example 67 with PartType

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

the class PartGearKey method read.

public static PartGearKey read(String key) {
    String[] parts = key.split("/");
    if (parts.length != 2) {
        throw new JsonParseException("invalid key: " + key);
    }
    PartType partType = PartType.getNonNull(Objects.requireNonNull(SilentGear.getIdWithDefaultNamespace(parts[0])));
    if (partType.isInvalid()) {
        throw new JsonParseException("Unknown part type: " + parts[0]);
    }
    GearType gearType = GearType.get(parts[1]);
    if (gearType.isInvalid()) {
        throw new JsonParseException("Unknown gear type: " + parts[1]);
    }
    return new PartGearKey(gearType, partType);
}
Also used : PartType(net.silentchaos512.gear.api.part.PartType) GearType(net.silentchaos512.gear.api.item.GearType) JsonParseException(com.google.gson.JsonParseException)

Aggregations

PartType (net.silentchaos512.gear.api.part.PartType)37 ItemStack (net.minecraft.world.item.ItemStack)14 PartData (net.silentchaos512.gear.gear.part.PartData)14 StatInstance (net.silentchaos512.gear.api.stats.StatInstance)13 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)10 ICoreItem (net.silentchaos512.gear.api.item.ICoreItem)10 TextComponent (net.minecraft.network.chat.TextComponent)9 ResourceLocation (net.minecraft.resources.ResourceLocation)9 GearType (net.silentchaos512.gear.api.item.GearType)9 PartDataList (net.silentchaos512.gear.api.part.PartDataList)9 ItemStat (net.silentchaos512.gear.api.stats.ItemStat)9 Component (net.minecraft.network.chat.Component)8 IMaterialInstance (net.silentchaos512.gear.api.material.IMaterialInstance)8 IPartData (net.silentchaos512.gear.api.part.IPartData)8 MaterialInstance (net.silentchaos512.gear.gear.material.MaterialInstance)8 TraitInstance (net.silentchaos512.gear.api.traits.TraitInstance)7 StatGearKey (net.silentchaos512.gear.api.util.StatGearKey)7 ArrayList (java.util.ArrayList)5 Collectors (java.util.stream.Collectors)5 MutableComponent (net.minecraft.network.chat.MutableComponent)5