use of net.silentchaos512.gear.gear.material.MaterialInstance in project Silent-Gear by SilentChaos512.
the class TooltipHandler method addJeiSearchTerms.
private static void addJeiSearchTerms(ItemTooltipEvent event, MaterialInstance material) {
// Add search terms to allow advanced filtering in JEI (requires the
// `SearchAdvancedTooltips` JEI config to be set)
StringBuilder b = new StringBuilder();
for (IMaterialCategory category : material.getCategories()) {
b.append(category.getName()).append(" ");
}
Collection<String> traits = new HashSet<>();
for (PartType partType : material.getPartTypes()) {
b.append(partType.getDisplayName(0).getString()).append(" ");
for (TraitInstance trait : material.getTraits(partType)) {
traits.add(trait.getTrait().getDisplayName(0).getString());
}
}
for (String str : traits) {
b.append(str).append(" ");
}
event.getToolTip().add(new TextComponent(b.toString().toLowerCase(Locale.ROOT)).withStyle(ChatFormatting.DARK_GRAY).withStyle(ChatFormatting.ITALIC));
}
use of net.silentchaos512.gear.gear.material.MaterialInstance in project Silent-Gear by SilentChaos512.
the class TooltipHandler method getMaterialTraitLines.
private static void getMaterialTraitLines(ItemTooltipEvent event, PartType partType, MaterialInstance material) {
Collection<TraitInstance> traits = material.getTraits(partType);
if (traits.isEmpty())
return;
MutableComponent header = TextUtil.misc("tooltip.traits").withStyle(ChatFormatting.GOLD);
if (!KeyTracker.isDisplayTraitsDown()) {
MutableComponent keyHint = TextUtil.withColor(TextUtil.keyBinding(KeyTracker.DISPLAY_TRAITS), Color.AQUAMARINE);
header.append(" ").append(keyHint);
}
event.getToolTip().add(header);
TextListBuilder builder = new TextListBuilder();
for (TraitInstance trait : traits) {
builder.add(trait.getDisplayName());
// Trait description and conditions
if (event.getFlags().isAdvanced() || KeyTracker.isDisplayTraitsDown()) {
builder.indent();
builder.add(trait.getTrait().getDescription(trait.getLevel()).withStyle(ChatFormatting.DARK_GRAY));
if (!trait.getConditions().isEmpty()) {
builder.add(TextUtil.withColor(trait.getConditionsText(), ChatFormatting.DARK_GRAY));
}
builder.unindent();
}
}
event.getToolTip().addAll(builder.build());
}
use of net.silentchaos512.gear.gear.material.MaterialInstance in project Silent-Gear by SilentChaos512.
the class TooltipHandler method onMaterialTooltip.
private static void onMaterialTooltip(ItemTooltipEvent event, ItemStack stack, MaterialInstance material) {
boolean keyHeld = KeyTracker.isDisplayStatsDown();
if (event.getFlags().isAdvanced()) {
event.getToolTip().add(new TextComponent("Material ID: " + material.getId()).withStyle(ChatFormatting.DARK_GRAY));
event.getToolTip().add(new TextComponent("Material data pack: " + material.get().getPackName()).withStyle(ChatFormatting.DARK_GRAY));
}
if (!Config.Client.showMaterialTooltips.get()) {
return;
}
if (keyHeld) {
event.getToolTip().add(TextUtil.withColor(TextUtil.misc("tooltip.material"), Color.GOLD));
} else {
event.getToolTip().add(TextUtil.withColor(TextUtil.misc("tooltip.material"), Color.GOLD).append(new TextComponent(" ").append(TextUtil.withColor(TextUtil.keyBinding(KeyTracker.DISPLAY_STATS), ChatFormatting.GRAY))));
}
if (event.getFlags().isAdvanced()) {
event.getToolTip().add(new TextComponent("Material ID: " + material.getId()).withStyle(ChatFormatting.DARK_GRAY));
event.getToolTip().add(new TextComponent("Material data pack: " + material.get().getPackName()).withStyle(ChatFormatting.DARK_GRAY));
}
if (keyHeld) {
getMaterialModifierLines(event, material);
getMaterialCategoriesLine(material).ifPresent(t -> event.getToolTip().add(t));
List<PartType> partTypes = new ArrayList<>(material.getPartTypes());
if (!partTypes.isEmpty()) {
int index = KeyTracker.getMaterialCycleIndex(partTypes.size());
PartType partType = partTypes.get(index);
event.getToolTip().add(buildPartTypeHeader(partTypes, partType));
event.getToolTip().add(TextUtil.withColor(TextUtil.misc("tier", material.getTier(partType)), Color.DEEPSKYBLUE));
getMaterialTraitLines(event, partType, material);
event.getToolTip().add(new TranslatableComponent("misc.silentgear.tooltip.stats").withStyle(ChatFormatting.GOLD));
getMaterialStatLines(event, partType, material);
}
} else {
getMaterialModifierLines(event, material);
if (event.getFlags().isAdvanced()) {
addJeiSearchTerms(event, material);
}
}
}
use of net.silentchaos512.gear.gear.material.MaterialInstance in project Silent-Gear by SilentChaos512.
the class GearDisplayManager method getMaterials.
public static Collection<IMaterialDisplay> getMaterials() {
synchronized (MATERIALS) {
Collection<IMaterialDisplay> ret = new ArrayList<>();
for (IMaterial material : MaterialManager.getValues()) {
MaterialInstance mat = MaterialInstance.of(material);
ret.add(mat.getDisplayProperties());
}
ret.addAll(MATERIALS.values());
return ret;
}
}
use of net.silentchaos512.gear.gear.material.MaterialInstance in project Silent-Gear by SilentChaos512.
the class GearModelOverrideList method addWithBlendedColor.
private static void addWithBlendedColor(List<MaterialLayer> list, PartData part, MaterialInstance material, ItemStack stack) {
IMaterialDisplay model = material.getDisplayProperties();
GearType gearType = GearHelper.getType(stack);
List<MaterialLayer> layers = model.getLayerList(gearType, part, material).getLayers();
addColorBlendedLayers(list, part, stack, layers);
}
Aggregations