use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class GearElytraItem method supportsPart.
@Override
public boolean supportsPart(ItemStack gear, PartData part) {
PartType type = part.getType();
boolean canAdd = part.get().canAddToGear(gear, part);
boolean supported = (requiresPartOfType(part.getType()) && canAdd) || canAdd;
return (type == PartType.MAIN && supported) || type == PartType.LINING || supported;
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class SyncMaterialCraftingItemsPacket method encode.
public void encode(FriendlyByteBuf buffer) {
buffer.writeVarInt(this.craftingItems.size());
this.craftingItems.forEach((id, ingredient) -> {
buffer.writeResourceLocation(id);
ingredient.toNetwork(buffer);
});
buffer.writeVarInt(this.partSubs.size());
for (ResourceLocation id : this.partSubs.keySet()) {
Map<PartType, Ingredient> map = this.partSubs.get(id);
buffer.writeResourceLocation(id);
buffer.writeByte(map.size());
map.forEach((type, ingredient) -> {
buffer.writeResourceLocation(type.getName());
ingredient.toNetwork(buffer);
});
}
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class MaterialsCommand method makeTsvLine.
private static String makeTsvLine(MaterialInstance material, PartType partType) {
StringBuilder builder = new StringBuilder();
appendTsv(builder, material.get().getPackName());
appendTsv(builder, material.getDisplayName(partType).getString());
int tier = material.getTier(partType);
// appendTsv(builder, partType.getDisplayName(tier).getFormattedText());
appendTsv(builder, partType.getDisplayName(0).getString());
appendTsv(builder, material.getId().toString());
appendTsv(builder, getParentId(material.get()));
// Traits
appendTsv(builder, material.getTraits(partType).stream().map(t -> t.getTrait().getDisplayName(t.getLevel()).getString()).collect(Collectors.joining(", ")));
appendTsv(builder, tier);
// Stats
for (ItemStat stat : ItemStats.allStatsOrdered()) {
Collection<StatInstance> statModifiers = material.getStatModifiers(partType, StatGearKey.of(stat, GearType.ALL));
appendTsv(builder, FORMAT_CODES.matcher(StatModifierMap.formatText(statModifiers, stat, 5).getString()).replaceAll(""));
}
return builder.toString();
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class MaterialsCommand method runDumpClient.
public static void runDumpClient(boolean includeChildren) {
Player player = SilentGear.PROXY.getClientPlayer();
if (player == null) {
SilentGear.LOGGER.error("MaterialsCommand#runDumpClient: player is null?");
return;
}
String fileName = "material_export.tsv";
String dirPath = "output/silentgear";
File output = new File(dirPath, fileName);
File directory = output.getParentFile();
if (!directory.exists() && !directory.mkdirs()) {
player.sendMessage(new TextComponent("Could not create directory: " + output.getParent()), Util.NIL_UUID);
return;
}
try (Writer writer = new OutputStreamWriter(new FileOutputStream(output), StandardCharsets.UTF_8)) {
StringBuilder builder = new StringBuilder("Pack\tName\tType\tID\tParent\tTraits\tTier\t");
ItemStats.allStatsOrdered().forEach(s -> builder.append(s.getDisplayName().getString()).append("\t"));
writer.write(builder + "\n");
List<PartType> partTypes = new ArrayList<>(PartType.getValues());
partTypes.sort((o1, o2) -> Comparator.comparing(o -> ((PartType) o).getDisplayName(0).getString()).compare(o1, o2));
for (PartType partType : partTypes) {
for (IMaterial material : MaterialManager.getValues()) {
if (includeChildren || getParentId(material).isEmpty()) {
MaterialInstance inst = MaterialInstance.of(material);
if (material.allowedInPart(inst, partType)) {
writer.write(makeTsvLine(inst, partType) + "\n");
}
}
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
Component fileNameText = (new TextComponent(output.getAbsolutePath())).withStyle(ChatFormatting.UNDERLINE).withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, output.getAbsolutePath())));
player.sendMessage(new TextComponent("Wrote materials info to ").append(fileNameText), Util.NIL_UUID);
}
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class PartsCommand method runList.
private static int runList(CommandContext<CommandSourceStack> context) {
String listStr = PartManager.getValues().stream().map(part -> part.getId().toString()).collect(Collectors.joining(", "));
context.getSource().sendSuccess(new TextComponent(listStr), true);
for (PartType type : PartType.getValues()) {
int count = PartManager.getPartsOfType(type).size();
String str = String.format("%s: %d", type.getName(), count);
context.getSource().sendSuccess(new TextComponent(str), true);
}
return 1;
}
Aggregations