Search in sources :

Example 16 with PartGearKey

use of net.silentchaos512.gear.api.util.PartGearKey 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

PartGearKey (net.silentchaos512.gear.api.util.PartGearKey)8 TraitInstance (net.silentchaos512.gear.api.traits.TraitInstance)6 JsonElement (com.google.gson.JsonElement)2 MutableComponent (net.minecraft.network.chat.MutableComponent)2 TextComponent (net.minecraft.network.chat.TextComponent)2 GearType (net.silentchaos512.gear.api.item.GearType)2 IMaterialDisplay (net.silentchaos512.gear.api.material.IMaterialDisplay)2 IMaterialInstance (net.silentchaos512.gear.api.material.IMaterialInstance)2 PartType (net.silentchaos512.gear.api.part.PartType)2 ITrait (net.silentchaos512.gear.api.traits.ITrait)2 JsonParseException (com.google.gson.JsonParseException)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Component (net.minecraft.network.chat.Component)1 GetTraitsEvent (net.silentchaos512.gear.api.event.GetTraitsEvent)1 IMaterialCategory (net.silentchaos512.gear.api.material.IMaterialCategory)1 IMaterialLayerList (net.silentchaos512.gear.api.material.IMaterialLayerList)1 MaterialLayerList (net.silentchaos512.gear.api.material.MaterialLayerList)1 PartData (net.silentchaos512.gear.gear.part.PartData)1