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));
}));
}
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();
}
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();
}
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;
}
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;
}
Aggregations