use of meteordevelopment.meteorclient.gui.screens.EditBookTitleAndAuthorScreen 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));
}));
}
Aggregations