|
6 | 6 | import meteordevelopment.meteorclient.systems.modules.Module; |
7 | 7 | import meteordevelopment.meteorclient.utils.Utils; |
8 | 8 | import meteordevelopment.orbit.EventHandler; |
| 9 | +import net.minecraft.component.DataComponentTypes; |
| 10 | +import net.minecraft.component.type.WrittenBookContentComponent; |
9 | 11 | import net.minecraft.item.ItemStack; |
10 | 12 | import net.minecraft.item.Items; |
11 | | -import net.minecraft.nbt.NbtCompound; |
12 | | -import net.minecraft.nbt.NbtList; |
13 | | -import net.minecraft.nbt.NbtString; |
14 | 13 | import net.minecraft.network.packet.c2s.play.BookUpdateC2SPacket; |
15 | 14 | import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket; |
| 15 | +import net.minecraft.text.RawFilteredPair; |
| 16 | +import net.minecraft.text.Text; |
16 | 17 | import org.apache.commons.lang3.RandomStringUtils; |
17 | 18 | import widecat.meteorcrashaddon.CrashAddon; |
18 | 19 |
|
19 | 20 | import java.util.ArrayList; |
| 21 | +import java.util.List; |
20 | 22 | import java.util.Optional; |
21 | 23 |
|
22 | 24 | public class BookCrash extends Module { |
@@ -78,15 +80,14 @@ private void sendBadBook() { |
78 | 80 | } |
79 | 81 | slot++; |
80 | 82 | ItemStack book = new ItemStack(Items.WRITTEN_BOOK, 1); |
81 | | - NbtCompound tag = new NbtCompound(); |
82 | | - NbtList list = new NbtList(); |
| 83 | + List<RawFilteredPair<Text>> list = new ArrayList<>(); |
83 | 84 | for (int j = 0; j < 99; j++) { |
84 | | - list.add(NbtString.of("{\"text\":" + RandomStringUtils.randomAlphabetic(200) + "\"}")); |
| 85 | + list.add(RawFilteredPair.of(Text.of(RandomStringUtils.randomAlphabetic(200)))); |
85 | 86 | } |
86 | | - tag.put("author", NbtString.of(RandomStringUtils.randomAlphabetic(9000))); |
87 | | - tag.put("title", NbtString.of(RandomStringUtils.randomAlphabetic(25564))); |
88 | | - tag.put("pages", list); |
89 | | - book.setNbt(tag); |
| 87 | + WrittenBookContentComponent component = book.get(DataComponentTypes.WRITTEN_BOOK_CONTENT); |
| 88 | + WrittenBookContentComponent newComponent = new WrittenBookContentComponent(RawFilteredPair.of(RandomStringUtils.randomAlphabetic(9000)), RandomStringUtils.randomAlphabetic(25564), component.generation(), list, component.resolved()); |
| 89 | + book.set(DataComponentTypes.WRITTEN_BOOK_CONTENT, newComponent); |
| 90 | + |
90 | 91 | mc.player.networkHandler.sendPacket(new CreativeInventoryActionC2SPacket(slot, book)); |
91 | 92 | } |
92 | 93 | } |
|
0 commit comments