use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class GearModelOverrideList method getPartsInRenderOrder.
private static PartDataList getPartsInRenderOrder(ItemStack stack) {
PartDataList unsorted = GearData.getConstructionParts(stack);
PartDataList ret = PartDataList.of();
ICoreItem item = (ICoreItem) stack.getItem();
for (PartType partType : item.getRenderParts()) {
ret.addAll(unsorted.getPartsOfType(partType));
}
for (PartData part : unsorted) {
if (!ret.contains(part)) {
ret.add(part);
}
}
return ret;
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class TooltipHandler method getMaterialStatLines.
private static void getMaterialStatLines(ItemTooltipEvent event, PartType partType, MaterialInstance material) {
TextListBuilder builder = new TextListBuilder();
for (ItemStat stat : ItemStats.allStatsOrdered()) {
if (stat.isVisible()) {
getMaterialStatModLines(event, partType, material, builder, stat);
}
}
event.getToolTip().addAll(builder.build());
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class TooltipHandler method getMaterialStatModLines.
private static void getMaterialStatModLines(ItemTooltipEvent event, PartType partType, MaterialInstance material, TextListBuilder builder, ItemStat stat) {
Collection<StatInstance> modsAll = material.getStatModifiers(partType, StatGearKey.of(stat, GearType.ALL));
Optional<MutableComponent> head = getStatTooltipLine(event, partType, stat, modsAll);
builder.add(head.orElseGet(() -> TextUtil.withColor(stat.getDisplayName(), stat.getNameColor())));
builder.indent();
int subCount = 0;
List<StatGearKey> keysForStat = material.get().getStatKeys(material, partType).stream().filter(key -> key.getStat().equals(stat)).collect(Collectors.toList());
for (StatGearKey key : keysForStat) {
if (key.getGearType() != GearType.ALL) {
ItemStat stat1 = ItemStats.get(key.getStat());
if (stat1 != null) {
Collection<StatInstance> mods = material.getStatModifiers(partType, key);
Optional<MutableComponent> line = getSubStatTooltipLine(event, partType, stat1, key.getGearType(), mods);
if (line.isPresent()) {
builder.add(line.get());
++subCount;
}
}
}
}
if (subCount == 0 && !head.isPresent()) {
builder.removeLast();
}
builder.unindent();
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class TooltipHandler method getSubStatTooltipLine.
private static Optional<MutableComponent> getSubStatTooltipLine(ItemTooltipEvent event, PartType partType, ItemStat stat, GearType gearType, Collection<StatInstance> modifiers) {
if (!modifiers.isEmpty()) {
StatInstance inst = stat.computeForDisplay(0, gearType, modifiers);
if (inst.shouldList(partType, stat, event.getFlags().isAdvanced())) {
boolean isZero = inst.getValue() == 0;
Color color = isZero ? MC_DARK_GRAY : Color.WHITE;
MutableComponent nameStr = TextUtil.withColor(gearType.getDisplayName().copy(), color);
int decimalPlaces = stat.isDisplayAsInt() && inst.getOp() != StatInstance.Operation.MUL1 && inst.getOp() != StatInstance.Operation.MUL2 ? 0 : 2;
MutableComponent statListText = TextUtil.withColor(StatModifierMap.formatText(modifiers, stat, decimalPlaces), color);
// Harvest level hints
MutableComponent textWithAdditions = stat == ItemStats.HARVEST_LEVEL && modifiers.size() == 1 ? harvestLevelWithHint(statListText, inst.getValue()) : statListText;
return Optional.of(new TranslatableComponent("stat.silentgear.displayFormat", nameStr, textWithAdditions));
}
}
return Optional.empty();
}
use of net.silentchaos512.gear.api.part.PartType 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;
}
Aggregations