use of net.silentchaos512.gear.api.item.GearType in project Silent-Gear by SilentChaos512.
the class MaterialBuilder method stat.
public MaterialBuilder stat(PartType partType, IItemStat stat, GearType gearType, float value, StatInstance.Operation operation) {
StatGearKey key = StatGearKey.of(stat, gearType);
StatInstance mod = StatInstance.of(value, operation, key);
StatModifierMap map = stats.computeIfAbsent(partType, pt -> new StatModifierMap());
map.put(stat, gearType, mod);
return this;
}
use of net.silentchaos512.gear.api.item.GearType in project Silent-Gear by SilentChaos512.
the class UpgradeSmithingRecipe method applyUpgrade.
@Override
protected ItemStack applyUpgrade(ItemStack gear, ItemStack upgradeItem) {
PartData part = PartData.from(upgradeItem);
if (part != null) {
GearType gearType = GearHelper.getType(gear);
if (gearType.isGear() && part.get().canAddToGear(gear, part) && !GearData.hasPart(gear, part.get())) {
ItemStack result = gear.copy();
GearData.addPart(result, part);
GearData.recalculateStats(result, ForgeHooks.getCraftingPlayer());
return result;
}
}
return ItemStack.EMPTY;
}
use of net.silentchaos512.gear.api.item.GearType in project Silent-Gear by SilentChaos512.
the class ShapelessGearRecipe method matches.
@Override
public boolean matches(CraftingContainer inv, Level worldIn) {
if (!this.getBaseRecipe().matches(inv, worldIn))
return false;
GearType gearType = item.getGearType();
Collection<PartData> parts = getParts(inv);
if (parts.isEmpty())
return false;
for (PartData part : parts) {
if (!part.isCraftingAllowed(gearType, inv)) {
return false;
}
}
return true;
}
use of net.silentchaos512.gear.api.item.GearType in project Silent-Gear by SilentChaos512.
the class ItemStat method computeForDisplay.
public StatInstance computeForDisplay(float baseValue, GearType gearType, Collection<StatInstance> modifiers) {
if (modifiers.isEmpty()) {
return StatInstance.of(baseValue, Operation.AVG, StatInstance.DEFAULT_KEY);
}
int add = 1;
for (StatInstance inst : modifiers) {
Operation op = inst.getOp();
if (op == Operation.AVG || op == Operation.ADD || op == Operation.MAX) {
add = 0;
break;
}
}
float value = compute(baseValue + add, false, gearType, modifiers) - add;
Operation op = modifiers.iterator().next().getOp();
return StatInstance.of(value, op, StatInstance.DEFAULT_KEY);
}
use of net.silentchaos512.gear.api.item.GearType 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;
}
Aggregations