use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class ICoreArmor method supportsPart.
@Override
default boolean supportsPart(ItemStack gear, PartData part) {
PartType type = part.getType();
boolean supported = ICoreItem.super.supportsPart(gear, part);
return (type == PartType.MAIN && supported) || type == PartType.TIP || type == PartType.LINING || supported;
}
use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class TooltipHandler method getPartStatLines.
private static void getPartStatLines(ItemTooltipEvent event, ItemStack stack, PartData part) {
GearType gearType = getPartGearType(part);
TextListBuilder builder = new TextListBuilder();
List<ItemStat> relevantStats = new ArrayList<>(part.getGearType().getRelevantStats());
if (part.getGearType().isArmor() && relevantStats.contains(ItemStats.DURABILITY)) {
int index = relevantStats.indexOf(ItemStats.DURABILITY);
relevantStats.remove(ItemStats.DURABILITY);
relevantStats.add(index, ItemStats.ARMOR_DURABILITY);
}
for (ItemStat stat : relevantStats) {
Collection<StatInstance> modifiers = new ArrayList<>();
for (StatInstance mod : part.getStatModifiers(StatGearKey.of(stat, gearType), ItemStack.EMPTY)) {
if (mod.getOp() == StatInstance.Operation.AVG) {
float computed = stat.compute(Collections.singleton(mod));
modifiers.add(StatInstance.of(computed, StatInstance.Operation.AVG, mod.getKey()));
} else {
modifiers.add(mod);
}
}
getStatTooltipLine(event, part.getType(), stat, modifiers).ifPresent(builder::add);
}
event.getToolTip().addAll(builder.build());
}
use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class TooltipHandler method onPartTooltip.
private static void onPartTooltip(ItemTooltipEvent event, ItemStack stack, PartData part) {
if (event.getFlags().isAdvanced() && KeyTracker.isControlDown()) {
event.getToolTip().add(new TextComponent("* Part ID: " + part.getId()).withStyle(ChatFormatting.DARK_GRAY));
event.getToolTip().add(new TextComponent("* Part data pack: " + part.get().getPackName()).withStyle(ChatFormatting.DARK_GRAY));
}
if (!Config.Client.showPartTooltips.get()) {
return;
}
// Type, tier
event.getToolTip().add(TextUtil.withColor(part.getType().getDisplayName(part.getTier()), Color.AQUAMARINE));
// Traits
List<TraitInstance> traits = new ArrayList<>();
for (TraitInstance traitInstance : part.getTraits()) {
if (traitInstance.getTrait().showInTooltip(event.getFlags())) {
traits.add(traitInstance);
}
}
int numTraits = traits.size();
int traitIndex = getTraitDisplayIndex(numTraits);
int i = 0;
for (TraitInstance inst : traits) {
if (traitIndex < 0 || traitIndex == i) {
inst.addInformation(event.getToolTip(), event.getFlags());
}
++i;
}
// Stats
if (KeyTracker.isControlDown()) {
event.getToolTip().add(new TranslatableComponent("misc.silentgear.tooltip.stats").withStyle(ChatFormatting.GOLD).append(new TextComponent(" (Silent Gear)").withStyle(ChatFormatting.RESET).withStyle(ChatFormatting.ITALIC)));
getPartStatLines(event, stack, part);
} else {
event.getToolTip().add(new TranslatableComponent("misc.silentgear.tooltip.ctrlForStats").withStyle(ChatFormatting.GOLD));
}
// Gear type blacklist?
if (part.get() instanceof AbstractGearPart) {
List<GearType> blacklist = ((AbstractGearPart) part.get()).getBlacklistedGearTypes();
if (!blacklist.isEmpty()) {
int index = (ClientTicks.ticksInGame() / 20) % blacklist.size();
GearType gearType = blacklist.get(index);
Component blacklistedType = gearType.getDisplayName();
event.getToolTip().add(new TranslatableComponent("misc.silentgear.tooltip.blacklist", blacklistedType).withStyle(ChatFormatting.RED));
}
}
}
use of net.silentchaos512.gear.gear.part.PartData 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);
}
use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class GearModelOverrideList method addColorBlendedLayers.
private static void addColorBlendedLayers(List<MaterialLayer> list, PartData part, ItemStack stack, List<MaterialLayer> layers) {
for (int i = 0; i < layers.size(); i++) {
MaterialLayer layer = layers.get(i);
if ((layer.getColor() & 0xFFFFFF) < 0xFFFFFF) {
int blendedColor = part.getColor(stack, i, 0);
MaterialLayer coloredLayer = layer.withColor(blendedColor);
list.add(coloredLayer);
if (isDebugLoggingEnabled()) {
debugLogLayer(coloredLayer, Color.format(blendedColor));
}
} else {
list.add(layer);
if (isDebugLoggingEnabled()) {
debugLogLayer(layer, "colorless");
}
}
}
}
Aggregations