use of net.silentchaos512.gear.api.util.PartGearKey in project Silent-Gear by SilentChaos512.
the class CraftedMaterial method getTraits.
@Override
public Collection<TraitInstance> getTraits(IMaterialInstance material, PartGearKey partKey, ItemStack gear) {
Collection<TraitInstance> ret = super.getTraits(material, partKey, gear);
IMaterialInstance base = getBaseMaterial(material);
ret.addAll(base.getTraits(partKey, gear));
return ret;
}
use of net.silentchaos512.gear.api.util.PartGearKey in project Silent-Gear by SilentChaos512.
the class MaterialRatioTraitCondition method matches.
@Override
public boolean matches(ITrait trait, PartGearKey key, ItemStack gear, List<? extends IGearComponentInstance<?>> components) {
int count = 0;
for (IGearComponentInstance<?> comp : components) {
Collection<TraitInstance> traits = comp.getTraits(key, gear);
for (TraitInstance inst : traits) {
if (inst.getTrait() == trait) {
++count;
break;
}
}
}
float ratio = (float) count / components.size();
return ratio >= this.requiredRatio;
}
use of net.silentchaos512.gear.api.util.PartGearKey in project Silent-Gear by SilentChaos512.
the class MaterialDisplay method deserialize.
public static MaterialDisplay deserialize(ResourceLocation modelId, JsonObject json) {
MaterialDisplay ret = new MaterialDisplay(modelId);
json.entrySet().forEach(entry -> {
PartGearKey key = PartGearKey.read(entry.getKey());
JsonElement value = entry.getValue();
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 MaterialDisplay method getMostSpecificKey.
private PartGearKey getMostSpecificKey(GearType gearType, PartType partType) {
PartGearKey key = PartGearKey.of(gearType, 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 of.
public static MaterialDisplay of(ResourceLocation id, Map<PartGearKey, MaterialLayerList> display) {
MaterialDisplay model = new MaterialDisplay(id);
model.map.putAll(display);
return model;
}
Aggregations