This commit is contained in:
Chipmunk 2023-04-30 21:18:49 -04:00
parent 5552542461
commit 09c1357e1c

View file

@ -128,23 +128,25 @@ public class ChatPlugin extends SessionAdapter {
if (command.length() > maxLength) { if (command.length() > maxLength) {
String tagString; String tagString;
boolean inspect; boolean interpret;
CompoundTag itemTag = new CompoundTag("");
if (message instanceof TextComponent && message.style().isEmpty() && (message.children() == null || message.children().size() == 0)) { if (message instanceof TextComponent && message.style().isEmpty() && (message.children() == null || message.children().size() == 0)) {
tagString = ((TextComponent) message).content(); tagString = ((TextComponent) message).content();
inspect = false; interpret = false;
} else { } else {
tagString = raw; tagString = raw;
inspect = true; interpret = true;
} }
if (tagString.getBytes(StandardCharsets.UTF_8).length > 65535) return; if (tagString.getBytes(StandardCharsets.UTF_8).length > 65535) return;
CompoundTag itemTag = new CompoundTag("");
itemTag.put(new StringTag("m", tagString));
final Session session = client.session(); final Session session = client.session();
session.send(new ServerboundSetCreativeModeSlotPacket(26, new ItemStack(1 /* stone */, 1, itemTag))); session.send(new ServerboundSetCreativeModeSlotPacket(26, new ItemStack(1 /* stone */, 1, itemTag)));
client.core().run("minecraft:tellraw " + targets + " {\"nbt\":\"SelectedItem.tag.m\",\"entity\":\"" + uuid.toString() + "\",\"inspect\":" + inspect + "}"); // TODO: Use GSON instead of concatenating strings, and hardcode less of this (it shouldn't matter here but yes) client.core().run("minecraft:tellraw " + targets + " {\"nbt\":\"Inventory[0].tag.m\",\"entity\":\"" + uuid.toString() + "\",\"interpret\":" + interpret + "}"); // TODO: Use GSON instead of concatenating strings, and hardcode less of this (it shouldn't matter here but yes)
return; return;
} }