Search in sources :

Example 56 with NbtCompound

use of net.minecraft.nbt.NbtCompound in project EdenClient by HahaOO7.

the class ChestShopEntry method toTag.

public NbtCompound toTag() {
    NbtCompound tag = new NbtCompound();
    tag.putIntArray("pos", new int[] { pos.getX(), pos.getY(), pos.getZ() });
    tag.putString("owner", owner);
    tag.putString("item", item);
    tag.putInt("amount", amount);
    if (canBuy())
        tag.putInt("buyPrice", buyPrice);
    if (canSell())
        tag.putInt("sellPrice", sellPrice);
    return tag;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound)

Example 57 with NbtCompound

use of net.minecraft.nbt.NbtCompound in project EdenClient by HahaOO7.

the class PerWorldConfig method loadConfig.

private void loadConfig() {
    File file = new File(folder, worldName + ".mca");
    if (!folder.exists())
        folder.mkdirs();
    NbtCompound tag = new NbtCompound();
    try {
        tag = file.exists() ? NbtIo.readCompressed(file) : new NbtCompound();
    } catch (IOException e) {
        System.err.println("Error while loading PerWorldConfig: " + worldName);
    }
    NbtCompound finalTag = tag;
    registered.forEach((key, obj) -> load(getCompound(finalTag, key), obj));
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) IOException(java.io.IOException) File(java.io.File)

Example 58 with NbtCompound

use of net.minecraft.nbt.NbtCompound in project EdenClient by HahaOO7.

the class PerWorldConfig method saveConfig.

private void saveConfig() {
    NbtCompound tag = new NbtCompound();
    registered.forEach((key, obj) -> {
        NbtCompound compound = getCompound(tag, key);
        save(compound, obj);
    });
    File file = new File(folder, worldName + ".mca");
    if (!folder.exists())
        folder.mkdirs();
    try {
        NbtIo.writeCompressed(tag, file);
    } catch (IOException e) {
        System.err.println("Error while saving PerWorldConfig: " + worldName);
    }
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) IOException(java.io.IOException) File(java.io.File)

Example 59 with NbtCompound

use of net.minecraft.nbt.NbtCompound in project EdenClient by HahaOO7.

the class PerWorldConfig method getCompound.

private NbtCompound getCompound(NbtCompound root, String path) {
    if (path.isEmpty())
        return root;
    String[] a = path.split("\\.");
    for (String s : a) {
        NbtCompound tag = root.getCompound(s);
        root.put(s, tag);
        root = tag;
    }
    return root;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound)

Example 60 with NbtCompound

use of net.minecraft.nbt.NbtCompound in project EdenClient by HahaOO7.

the class BiStringStringMapLoader method parse.

public NbtCompound parse(String s) {
    NbtCompound tag = new NbtCompound();
    if (s.isEmpty())
        return tag;
    String[] a = s.split(";");
    for (int i = 0; i < a.length; i++) {
        String k = a[i];
        i++;
        tag.putString(k, a[i]);
    }
    return tag;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound)

Aggregations

NbtCompound (net.minecraft.nbt.NbtCompound)318 NbtList (net.minecraft.nbt.NbtList)93 ItemStack (net.minecraft.item.ItemStack)69 NbtElement (net.minecraft.nbt.NbtElement)28 IOException (java.io.IOException)25 LiteralText (net.minecraft.text.LiteralText)24 Identifier (net.minecraft.util.Identifier)24 Inject (org.spongepowered.asm.mixin.injection.Inject)21 BlockPos (net.minecraft.util.math.BlockPos)20 NbtString (net.minecraft.nbt.NbtString)16 File (java.io.File)13 HashMap (java.util.HashMap)10 List (java.util.List)9 Text (net.minecraft.text.Text)9 Vec3d (net.minecraft.util.math.Vec3d)9 Map (java.util.Map)8 Items (net.minecraft.item.Items)8 TranslatableText (net.minecraft.text.TranslatableText)8 HashSet (java.util.HashSet)7 BlockEntity (net.minecraft.block.entity.BlockEntity)7