use of net.silentchaos512.gear.api.part.IGearPart in project Silent-Gear by SilentChaos512.
the class SyncGearCraftingItemsPacket method handle.
public void handle(Supplier<NetworkEvent.Context> context) {
SilentGear.LOGGER.debug("Correcting part crafting items");
this.craftingItems.forEach((id, ingredient) -> {
IGearPart part = PartManager.get(id);
if (part instanceof AbstractGearPart) {
((AbstractGearPart) part).updateCraftingItems(ingredient);
}
});
context.get().setPacketHandled(true);
}
use of net.silentchaos512.gear.api.part.IGearPart in project Silent-Gear by SilentChaos512.
the class GearBlueprintItem method appendSupportedTypesText.
private void appendSupportedTypesText(Collection<Component> list) {
if (KeyTracker.isDisplayStatsDown()) {
Optional<ICoreItem> itemOptional = this.gearType.getItem();
if (itemOptional.isPresent()) {
TextListBuilder builder = new TextListBuilder();
ICoreItem item = itemOptional.get();
ItemStack gear = new ItemStack(item);
for (PartType type : PartType.getValues()) {
if (type != PartType.MAIN) {
List<IGearPart> partsOfType = PartManager.getPartsOfType(type);
if (!partsOfType.isEmpty() && item.supportsPart(gear, PartData.of(partsOfType.get(0)))) {
builder.add(type.getDisplayName(0));
}
}
}
List<Component> lines = builder.build();
if (!lines.isEmpty()) {
list.add(TextUtil.withColor(TextUtil.misc("supportedPartTypes"), Color.GOLD));
list.addAll(lines);
}
}
} else {
list.add(TextUtil.withColor(TextUtil.misc("supportedPartTypes"), Color.GOLD).append(" ").append(TextUtil.withColor(TextUtil.keyBinding(KeyTracker.DISPLAY_STATS), ChatFormatting.GRAY)));
}
}
use of net.silentchaos512.gear.api.part.IGearPart 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.api.part.IGearPart 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.api.part.IGearPart in project Silent-Gear by SilentChaos512.
the class PartsCommand method partToTsvLine.
private static String partToTsvLine(IGearPart part) {
StringBuilder builder = new StringBuilder();
PartData partData = PartData.of(part);
appendTsv(builder, part.getDisplayName(partData, ItemStack.EMPTY).getString());
appendTsv(builder, part.getId().toString());
appendTsv(builder, part.getType().getName());
appendTsv(builder, partData.getTier());
// Stats
for (ItemStat stat : ItemStats.allStatsOrdered()) {
Collection<StatInstance> statModifiers = partData.getStatModifiers(StatGearKey.of(stat, GearType.ALL), ItemStack.EMPTY);
appendTsv(builder, FORMAT_CODES.matcher(StatModifierMap.formatText(statModifiers, stat, 5).getString()).replaceAll(""));
}
// Traits
appendTsv(builder, partData.getTraits().stream().map(t -> t.getTrait().getDisplayName(t.getLevel()).getString()).collect(Collectors.joining(", ")));
return builder.toString();
}
Aggregations