Search in sources :

Example 11 with IGearPart

use of net.silentchaos512.gear.api.part.IGearPart in project Silent-Gear by SilentChaos512.

the class PartsCommand method runDump.

private static int runDump(CommandContext<CommandSourceStack> context) {
    String fileName = "part_export.tsv";
    String dirPath = "output/silentgear";
    File output = new File(dirPath, fileName);
    File directory = output.getParentFile();
    if (!directory.exists() && !directory.mkdirs()) {
        context.getSource().sendFailure(new TextComponent("Could not create directory: " + output.getParent()));
        return 0;
    }
    try (Writer writer = new OutputStreamWriter(new FileOutputStream(output), StandardCharsets.UTF_8)) {
        StringBuilder builder = new StringBuilder("Name\tID\tType\tTier\t");
        ItemStats.allStatsOrdered().forEach(s -> builder.append(s.getDisplayName().getString()).append("\t"));
        builder.append("Traits");
        writer.write(builder.toString());
        for (IGearPart part : PartManager.getValues()) {
            writer.write(partToTsvLine(part) + "\n");
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        context.getSource().sendSuccess(new TextComponent("Wrote to " + output.getAbsolutePath()), true);
    }
    return 1;
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) IGearPart(net.silentchaos512.gear.api.part.IGearPart)

Aggregations

IGearPart (net.silentchaos512.gear.api.part.IGearPart)8 ResourceLocation (net.minecraft.resources.ResourceLocation)5 TextComponent (net.minecraft.network.chat.TextComponent)2 ItemStack (net.minecraft.world.item.ItemStack)2 PartData (net.silentchaos512.gear.gear.part.PartData)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 JsonObject (com.google.gson.JsonObject)1 JsonParseException (com.google.gson.JsonParseException)1 IOException (java.io.IOException)1 Nullable (javax.annotation.Nullable)1 CompoundTag (net.minecraft.nbt.CompoundTag)1 ListTag (net.minecraft.nbt.ListTag)1 Component (net.minecraft.network.chat.Component)1 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)1 Resource (net.minecraft.server.packs.resources.Resource)1 ICoreItem (net.silentchaos512.gear.api.item.ICoreItem)1 IPartData (net.silentchaos512.gear.api.part.IPartData)1 IPartSerializer (net.silentchaos512.gear.api.part.IPartSerializer)1 PartType (net.silentchaos512.gear.api.part.PartType)1