use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class ModKitRemovePartRecipe method assemble.
@Override
public ItemStack assemble(CraftingContainer inv) {
StackList list = StackList.from(inv);
ItemStack gear = list.uniqueOfType(ICoreItem.class);
ItemStack modKit = list.uniqueOfType(ModKitItem.class);
if (gear.isEmpty() || modKit.isEmpty())
return ItemStack.EMPTY;
ItemStack result = gear.copy();
PartType type = ModKitItem.getSelectedType(modKit);
if (GearData.removeFirstPartOfType(result, type)) {
GearData.recalculateStats(result, ForgeHooks.getCraftingPlayer());
}
return result;
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class PartType method create.
/**
* Call during mod construction to create a new part type.
*
* @param builder Type builder
* @return The new PartType
* @throws IllegalArgumentException if a type with the same name already exists
*/
public static PartType create(Builder builder) {
if (VALUES.containsKey(builder.name))
throw new IllegalArgumentException(String.format("Already have PartType \"%s\"", builder.name));
PartType type = new PartType(builder);
VALUES.put(builder.name, type);
if (!type.alias.isEmpty()) {
VALUES.put(new ModResourceLocation(type.alias), type);
}
return type;
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class PartType method fromJson.
public static PartType fromJson(JsonObject json, String key) {
String str = GsonHelper.getAsString(json, key);
PartType type = get(new ModResourceLocation(str));
if (type == null) {
throw new JsonSyntaxException("Unknown part type: " + str);
}
return type;
}
use of net.silentchaos512.gear.api.part.PartType 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;
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class CompoundMaterial method getPartTypes.
@Override
public Set<PartType> getPartTypes(IMaterialInstance material) {
List<IMaterialInstance> subMaterials = getMaterials(material);
if (subMaterials.isEmpty()) {
return Collections.emptySet();
} else if (subMaterials.size() == 1) {
return subMaterials.get(0).getPartTypes();
}
Set<PartType> set = new LinkedHashSet<>(subMaterials.get(0).getPartTypes());
for (int i = 1; i < subMaterials.size(); ++i) {
Set<PartType> set1 = subMaterials.get(i).getPartTypes();
Set<PartType> toRemove = new HashSet<>();
for (PartType type : set) {
if (!set1.contains(type)) {
toRemove.add(type);
}
}
set.removeAll(toRemove);
}
return set;
}
Aggregations