use of net.silentchaos512.gear.api.util.PartGearKey in project Silent-Gear by SilentChaos512.
the class CompoundPart method getTraits.
@Override
public Collection<TraitInstance> getTraits(IPartData part, PartGearKey partKey, ItemStack gear) {
List<TraitInstance> ret = new ArrayList<>(super.getTraits(part, partKey, gear));
List<IMaterialInstance> materials = getMaterials(part);
for (TraitInstance inst : TraitHelper.getTraits(materials, partKey, gear)) {
if (inst.conditionsMatch(partKey, gear, materials)) {
ret.add(inst);
}
}
return ret;
}
use of net.silentchaos512.gear.api.util.PartGearKey in project Silent-Gear by SilentChaos512.
the class PartDisplay method deserialize.
public static PartDisplay deserialize(ResourceLocation modelId, JsonObject json) {
PartDisplay ret = new PartDisplay();
// noinspection OverlyLongLambda
json.entrySet().forEach(entry -> {
PartGearKey key = PartGearKey.read(entry.getKey());
JsonElement value = entry.getValue();
ret.partType = key.getPartType();
ret.map.put(key, MaterialLayerList.deserialize(key, value, MaterialLayerList.DEFAULT));
});
return ret;
}
use of net.silentchaos512.gear.api.util.PartGearKey in project Silent-Gear by SilentChaos512.
the class PartDisplay method getMostSpecificKey.
private PartGearKey getMostSpecificKey(GearType gearType) {
PartGearKey key = PartGearKey.of(gearType, this.partType);
if (map.containsKey(key)) {
return key;
}
PartGearKey parent = key.getParent();
while (parent != null) {
if (map.containsKey(parent)) {
return parent;
}
parent = parent.getParent();
}
// No match
return key;
}
use of net.silentchaos512.gear.api.util.PartGearKey in project Silent-Gear by SilentChaos512.
the class MaterialDisplay method fromNetwork.
public static MaterialDisplay fromNetwork(ResourceLocation materialId, FriendlyByteBuf buf) {
Map<PartGearKey, MaterialLayerList> map = new LinkedHashMap<>();
int count = buf.readVarInt();
for (int i = 0; i < count; ++i) {
PartGearKey key = PartGearKey.fromNetwork(buf);
MaterialLayerList layerList = MaterialLayerList.read(buf);
map.put(key, layerList);
}
return of(materialId, map);
}
use of net.silentchaos512.gear.api.util.PartGearKey in project Silent-Gear by SilentChaos512.
the class PartGearKey method fromNetwork.
public static PartGearKey fromNetwork(FriendlyByteBuf buf) {
GearType gearType = GearType.get(buf.readUtf());
PartType partType = Objects.requireNonNull(PartType.get(buf.readResourceLocation()));
return of(gearType, partType);
}
Aggregations