Search in sources :

Example 41 with NbtList

use of net.minecraft.nbt.NbtList in project meteor-client by MeteorDevelopment.

the class SoundEventListSetting method save.

@Override
public NbtCompound save(NbtCompound tag) {
    NbtList valueTag = new NbtList();
    for (SoundEvent sound : get()) {
        Identifier id = Registry.SOUND_EVENT.getId(sound);
        if (id != null)
            valueTag.add(NbtString.of(id.toString()));
    }
    tag.put("value", valueTag);
    return tag;
}
Also used : SoundEvent(net.minecraft.sound.SoundEvent) Identifier(net.minecraft.util.Identifier) NbtList(net.minecraft.nbt.NbtList)

Example 42 with NbtList

use of net.minecraft.nbt.NbtList in project meteor-client by MeteorDevelopment.

the class StatusEffectListSetting method load.

@Override
public List<StatusEffect> load(NbtCompound tag) {
    get().clear();
    NbtList valueTag = tag.getList("value", 8);
    for (NbtElement tagI : valueTag) {
        StatusEffect effect = Registry.STATUS_EFFECT.get(new Identifier(tagI.asString()));
        if (effect != null)
            get().add(effect);
    }
    return get();
}
Also used : StatusEffect(net.minecraft.entity.effect.StatusEffect) Identifier(net.minecraft.util.Identifier) NbtList(net.minecraft.nbt.NbtList) NbtElement(net.minecraft.nbt.NbtElement)

Example 43 with NbtList

use of net.minecraft.nbt.NbtList in project meteor-client by MeteorDevelopment.

the class StatusEffectListSetting method save.

@Override
public NbtCompound save(NbtCompound tag) {
    NbtList valueTag = new NbtList();
    for (StatusEffect effect : get()) {
        Identifier id = Registry.STATUS_EFFECT.getId(effect);
        if (id != null)
            valueTag.add(NbtString.of(id.toString()));
    }
    tag.put("value", valueTag);
    return tag;
}
Also used : StatusEffect(net.minecraft.entity.effect.StatusEffect) Identifier(net.minecraft.util.Identifier) NbtList(net.minecraft.nbt.NbtList)

Example 44 with NbtList

use of net.minecraft.nbt.NbtList in project meteor-client by MeteorDevelopment.

the class BookBot method writeBook.

private void writeBook(PrimitiveIterator.OfInt chars) {
    ArrayList<String> pages = new ArrayList<>();
    for (int pageI = 0; pageI < (mode.get() == Mode.File ? 100 : this.pages.get()); pageI++) {
        // Check if the stream is empty before creating a new page
        if (!chars.hasNext())
            break;
        StringBuilder page = new StringBuilder();
        for (int lineI = 0; lineI < 13; lineI++) {
            // Check if the stream is empty before creating a new line
            if (!chars.hasNext())
                break;
            double lineWidth = 0;
            StringBuilder line = new StringBuilder();
            while (true) {
                // Check if the stream is empty
                if (!chars.hasNext())
                    break;
                // Get the next character
                int nextChar = chars.nextInt();
                // Ignore newline chars when writing lines, should already be organised
                if (nextChar == '\r' || nextChar == '\n')
                    break;
                // Make sure the character will fit on the line
                double charWidth = ((TextHandlerAccessor) mc.textRenderer.getTextHandler()).getWidthRetriever().getWidth(nextChar, Style.EMPTY);
                if (lineWidth + charWidth > 114)
                    break;
                // Append it to the line
                line.appendCodePoint(nextChar);
                lineWidth += charWidth;
            }
            // Append the line to the page
            page.append(line).append('\n');
        }
        // Append page to the page list
        pages.add(page.toString());
    }
    // Get the title with count
    String title = name.get();
    if (count.get() && bookCount != 0)
        title += " #" + bookCount;
    // Write data to book
    mc.player.getMainHandStack().setSubNbt("title", NbtString.of(title));
    mc.player.getMainHandStack().setSubNbt("author", NbtString.of(mc.player.getGameProfile().getName()));
    // Write pages NBT
    NbtList pageNbt = new NbtList();
    pages.stream().map(NbtString::of).forEach(pageNbt::add);
    if (!pages.isEmpty())
        mc.player.getMainHandStack().setSubNbt("pages", pageNbt);
    // Send book update to server
    mc.player.networkHandler.sendPacket(new BookUpdateC2SPacket(mc.player.getInventory().selectedSlot, pages, Optional.of(title)));
    bookCount++;
}
Also used : BookUpdateC2SPacket(net.minecraft.network.packet.c2s.play.BookUpdateC2SPacket) ArrayList(java.util.ArrayList) NbtList(net.minecraft.nbt.NbtList) NbtString(net.minecraft.nbt.NbtString)

Example 45 with NbtList

use of net.minecraft.nbt.NbtList in project meteor-client by MeteorDevelopment.

the class Profile method toTag.

@Override
public NbtCompound toTag() {
    NbtCompound tag = new NbtCompound();
    tag.putString("name", name);
    tag.putBoolean("onLaunch", onLaunch);
    tag.putBoolean("accounts", accounts);
    tag.putBoolean("config", config);
    tag.putBoolean("friends", friends);
    tag.putBoolean("macros", macros);
    tag.putBoolean("modules", modules);
    tag.putBoolean("waypoints", waypoints);
    tag.putBoolean("hud", hud);
    loadOnJoinIps.removeIf(String::isEmpty);
    NbtList ipsTag = new NbtList();
    for (String ip : loadOnJoinIps) ipsTag.add(NbtString.of(ip));
    tag.put("loadOnJoinIps", ipsTag);
    return tag;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList) NbtString(net.minecraft.nbt.NbtString)

Aggregations

NbtList (net.minecraft.nbt.NbtList)161 NbtCompound (net.minecraft.nbt.NbtCompound)92 NbtElement (net.minecraft.nbt.NbtElement)46 Identifier (net.minecraft.util.Identifier)38 ItemStack (net.minecraft.item.ItemStack)28 NbtString (net.minecraft.nbt.NbtString)17 LiteralText (net.minecraft.text.LiteralText)12 BlockPos (net.minecraft.util.math.BlockPos)11 Block (net.minecraft.block.Block)9 IOException (java.io.IOException)8 List (java.util.List)8 Item (net.minecraft.item.Item)7 Inject (org.spongepowered.asm.mixin.injection.Inject)7 Items (net.minecraft.item.Items)6 NbtIo (net.minecraft.nbt.NbtIo)6 StatusEffect (net.minecraft.entity.effect.StatusEffect)5 Text (net.minecraft.text.Text)5 ArrayList (java.util.ArrayList)4 Comparator (java.util.Comparator)4 Blocks (net.minecraft.block.Blocks)4