Search in sources :

Example 36 with NbtList

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

the class BookScreenMixin method onInit.

@Inject(method = "init", at = @At("TAIL"))
private void onInit(CallbackInfo info) {
    addDrawableChild(new ButtonWidget(4, 4, 120, 20, new LiteralText("Copy"), button -> {
        NbtList listTag = new NbtList();
        for (int i = 0; i < contents.getPageCount(); i++) listTag.add(NbtString.of(contents.getPage(i).getString()));
        NbtCompound tag = new NbtCompound();
        tag.put("pages", listTag);
        tag.putInt("currentPage", pageIndex);
        FastByteArrayOutputStream bytes = new FastByteArrayOutputStream();
        DataOutputStream out = new DataOutputStream(bytes);
        try {
            NbtIo.write(tag, out);
        } catch (IOException e) {
            e.printStackTrace();
        }
        GLFW.glfwSetClipboardString(mc.getWindow().getHandle(), Base64.getEncoder().encodeToString(bytes.array));
    }));
    // Edit title & author
    ItemStack itemStack = mc.player.getMainHandStack();
    Hand hand = Hand.MAIN_HAND;
    if (itemStack.getItem() != Items.WRITTEN_BOOK) {
        itemStack = mc.player.getOffHandStack();
        hand = Hand.OFF_HAND;
    }
    if (itemStack.getItem() != Items.WRITTEN_BOOK)
        return;
    // Fuck you Java
    ItemStack book = itemStack;
    // Honestly
    Hand hand2 = hand;
    addDrawableChild(new ButtonWidget(4, 4 + 20 + 2, 120, 20, new LiteralText("Edit title & author"), button -> {
        mc.setScreen(new EditBookTitleAndAuthorScreen(GuiThemes.get(), book, hand2));
    }));
}
Also used : NbtIo(net.minecraft.nbt.NbtIo) LiteralText(net.minecraft.text.LiteralText) EditBookTitleAndAuthorScreen(meteordevelopment.meteorclient.gui.screens.EditBookTitleAndAuthorScreen) Inject(org.spongepowered.asm.mixin.injection.Inject) NbtList(net.minecraft.nbt.NbtList) ItemStack(net.minecraft.item.ItemStack) CallbackInfo(org.spongepowered.asm.mixin.injection.callback.CallbackInfo) BookScreen(net.minecraft.client.gui.screen.ingame.BookScreen) DataOutputStream(java.io.DataOutputStream) Mixin(org.spongepowered.asm.mixin.Mixin) Hand(net.minecraft.util.Hand) At(org.spongepowered.asm.mixin.injection.At) MeteorClient.mc(meteordevelopment.meteorclient.MeteorClient.mc) GuiThemes(meteordevelopment.meteorclient.gui.GuiThemes) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) IOException(java.io.IOException) Items(net.minecraft.item.Items) GLFW(org.lwjgl.glfw.GLFW) NbtCompound(net.minecraft.nbt.NbtCompound) NbtString(net.minecraft.nbt.NbtString) Base64(java.util.Base64) Screen(net.minecraft.client.gui.screen.Screen) Shadow(org.spongepowered.asm.mixin.Shadow) Text(net.minecraft.text.Text) FastByteArrayOutputStream(it.unimi.dsi.fastutil.io.FastByteArrayOutputStream) FastByteArrayOutputStream(it.unimi.dsi.fastutil.io.FastByteArrayOutputStream) NbtCompound(net.minecraft.nbt.NbtCompound) DataOutputStream(java.io.DataOutputStream) EditBookTitleAndAuthorScreen(meteordevelopment.meteorclient.gui.screens.EditBookTitleAndAuthorScreen) NbtList(net.minecraft.nbt.NbtList) IOException(java.io.IOException) ItemStack(net.minecraft.item.ItemStack) Hand(net.minecraft.util.Hand) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) LiteralText(net.minecraft.text.LiteralText) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 37 with NbtList

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

the class StorageBlockListSetting method load.

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

Example 38 with NbtList

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

the class ParticleTypeListSetting method load.

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

Example 39 with NbtList

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

the class ParticleTypeListSetting method save.

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

Example 40 with NbtList

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

the class SettingGroup method toTag.

@Override
public NbtCompound toTag() {
    NbtCompound tag = new NbtCompound();
    tag.putString("name", name);
    tag.putBoolean("sectionExpanded", sectionExpanded);
    NbtList settingsTag = new NbtList();
    for (Setting<?> setting : this) if (setting.wasChanged())
        settingsTag.add(setting.toTag());
    tag.put("settings", settingsTag);
    return tag;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList)

Aggregations

NbtList (net.minecraft.nbt.NbtList)158 NbtCompound (net.minecraft.nbt.NbtCompound)90 NbtElement (net.minecraft.nbt.NbtElement)46 Identifier (net.minecraft.util.Identifier)38 ItemStack (net.minecraft.item.ItemStack)27 NbtString (net.minecraft.nbt.NbtString)16 LiteralText (net.minecraft.text.LiteralText)12 BlockPos (net.minecraft.util.math.BlockPos)11 Block (net.minecraft.block.Block)9 List (java.util.List)8 Item (net.minecraft.item.Item)7 Inject (org.spongepowered.asm.mixin.injection.Inject)7 IOException (java.io.IOException)6 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 Comparator (java.util.Comparator)4 Blocks (net.minecraft.block.Blocks)4 EntityType (net.minecraft.entity.EntityType)4