use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class CompoundPartItem method appendHoverText.
@Override
public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
PartData part = PartData.from(stack);
if (part != null && Config.Client.showPartTooltips.get()) {
float synergy = SynergyUtils.getSynergy(this.partType, getMaterials(stack), part.getTraits());
tooltip.add(SynergyUtils.getDisplayText(synergy));
TextListBuilder matsBuilder = new TextListBuilder();
getMaterials(stack).forEach(material -> {
int nameColor = material.getNameColor(part.getType(), this.getGearType());
matsBuilder.add(TextUtil.withColor(material.getDisplayNameWithModifiers(part.getType(), ItemStack.EMPTY), nameColor));
});
tooltip.addAll(matsBuilder.build());
}
}
use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class PartData method of.
public static PartData of(IGearPart part) {
ResourceLocation name = part.getId();
if (CACHE_UNGRADED_PARTS.containsKey(name)) {
return CACHE_UNGRADED_PARTS.get(name);
}
PartData inst = new PartData(part);
CACHE_UNGRADED_PARTS.put(name, inst);
return inst;
}
use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class StatsCommand method runInfo.
private static int runInfo(CommandContext<CommandSourceStack> context, ServerPlayer player) {
ItemStack stack = player.getMainHandItem();
if (!GearHelper.isGear(stack)) {
context.getSource().sendFailure(TextUtil.translate("command", "invalidItemType", stack.getHoverName()));
return 0;
}
context.getSource().sendSuccess(TextUtil.translate("command", "stats.info.header", player.getName(), stack.getHoverName()).withStyle(ChatFormatting.BOLD), true);
ICoreItem item = (ICoreItem) stack.getItem();
PartDataList parts = GearData.getConstructionParts(stack);
StatModifierMap stats = GearData.getStatModifiers(stack, item, parts);
for (ItemStat stat : ItemStats.allStatsOrderedExcluding((item).getExcludedStats(stack))) {
StatGearKey key = StatGearKey.of(stat, item.getGearType());
Collection<StatInstance> mods = stats.get(key);
if (!mods.isEmpty()) {
Component name = TextUtil.withColor(stat.getDisplayName(), stat.getNameColor());
Component modsText = StatModifierMap.formatText(mods, stat, 5, true);
float statValue = stat.compute(0f, true, item.getGearType(), mods);
Component valueText = TextUtil.withColor(StatInstance.of(statValue, StatInstance.Operation.AVG, key).getFormattedText(stat, 5, false), ChatFormatting.YELLOW);
context.getSource().sendSuccess(TextUtil.translate("command", "stats.info.format", name, modsText, valueText), true);
for (PartData part : parts) {
Collection<StatInstance> partMods = part.getStatModifiers(key, stack);
if (!partMods.isEmpty()) {
Component partName = part.getDisplayName(stack);
Component partModsText = StatModifierMap.formatText(partMods, stat, 5, true);
context.getSource().sendSuccess(TextUtil.translate("command", "stats.info.formatPart", partName, partModsText), true);
}
}
}
}
return 1;
}
use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class TraitsCommand method getPartsWithTrait.
private static String getPartsWithTrait(ITrait trait) {
StringBuilder str = new StringBuilder();
boolean foundAny = false;
for (IGearPart part : PartManager.getValues()) {
PartData partData = PartData.of(part);
for (TraitInstance inst : partData.getTraits()) {
if (inst.getTrait().equals(trait) && part.isVisible()) {
if (foundAny) {
str.append(", ");
}
foundAny = true;
str.append("**").append(partData.getDisplayName(ItemStack.EMPTY).getString()).append("**");
}
}
}
return str.toString();
}
use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class ModKitRemovePartRecipe method getRemainingItems.
@Override
public NonNullList<ItemStack> getRemainingItems(CraftingContainer inv) {
NonNullList<ItemStack> list = NonNullList.withSize(inv.getContainerSize(), ItemStack.EMPTY);
ItemStack gear = StackList.from(inv).uniqueOfType(ICoreItem.class);
ItemStack modKit = StackList.from(inv).uniqueOfType(ModKitItem.class);
PartType type = ModKitItem.getSelectedType(modKit);
PartData part = GearData.getPartOfType(gear, type);
for (int i = 0; i < list.size(); ++i) {
ItemStack stack = inv.getItem(i);
if (stack.getItem() instanceof ICoreItem) {
list.set(i, part != null ? part.getItem() : ItemStack.EMPTY);
} else if (stack.hasContainerItem()) {
list.set(i, stack.getContainerItem());
}
}
return list;
}
Aggregations