1.20.1 Sign doesnt show Text
nyancat-hu opened this issue · 4 comments
Make sure you're doing the following
- [✔ ] You're using the latest build for your server version
- [✔ ] This isn't an issue caused by another plugin
- [✔ ] You've checked for duplicate issues
- [✔ ] You didn't use
/reload
Describe the question
I want to open a sign GUI for a player with a given text without other players seeing the required sign.
Minecraft Verison 1.20.1
Papermc Server
My Code
`Location location = player.getLocation();
BlockPosition blockPosition = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
PacketContainer blockChangePacket = protocolManager.createPacket(PacketType.Play.Server.BLOCK_CHANGE);
blockChangePacket.getBlockPositionModifier().write(0, blockPosition);
blockChangePacket.getBlockData().write(0, WrappedBlockData.createData(Material.OAK_SIGN));
PacketContainer signUpdatePacket = protocolManager.createPacket(PacketType.Play.Server.TILE_ENTITY_DATA);
signUpdatePacket.getBlockPositionModifier().write(0, blockPosition);
NbtCompound compound = NbtFactory.ofCompound("");
compound.put("Text1", NbtFactory.of("String", "{\"text\":\"test1\"}"));
compound.put("Text2", NbtFactory.of("String", "{\"text\":\"test2\"}"));
compound.put("Text3", NbtFactory.of("String", "{\"text\":\"test3\"}"));
compound.put("Text4", NbtFactory.of("String", "{\"text\":\"test4\"}"));
compound.put("Color", NbtFactory.of("String", "black"));
compound.put("GlowingText", NbtFactory.of("Byte", (byte) 0));
signUpdatePacket.getNbtModifier().write(0, compound);
PacketContainer openSignEditorPacket = protocolManager.createPacket(PacketType.Play.Server.OPEN_SIGN_EDITOR);
openSignEditorPacket.getBlockPositionModifier().write(0, blockPosition);
try {
protocolManager.sendServerPacket(player, blockChangePacket);
protocolManager.sendServerPacket(player, signUpdatePacket);
protocolManager.sendServerPacket(player, openSignEditorPacket);
} catch ([Exception](http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+exception) e) {
e.printStackTrace();
}`
No error message, just no text on the opened Sign. I think i have something wrong with the NBT data
I searched online and found that the 1.20 sign NBT has changed to the following
{back_text:{color:"black",has_glowing_text:0b,messages:['{"text":""}','{"text":""}','{"text":""}','{"text":""}']},front_text:{color:"black",has_glowing_text:0b,messages:['{"text":""}','{"text":""}','{"text":""}','{"text":""}']},is_waxed:0b}
So,the problem now is, how to get the right nbt data into that packet.
Can someone give me an example? Thank you!
API method(s) used
Look at the code above
Expected behavior
Players can see the information on the sign . Minecraft 1.20.1
Code
Look at the code above
Additional context
I tried using it, but my sign still didn't show any messages on 1.20.1. Can you give me some help?
Had the same problem and this works great: https://github.com/Rapha149/SignGUI/tree/main
I didn't have any issues except with the .setLine() function but that can be overlooked my simply using .setLines(). This is my code with that implementation which works:
SignGUI gui = SignGUI.builder() .setLines("text1", "text2", "text3", null) .setType(Material.OAK_SIGN) .setHandler((player, result) -> { String[] linesWithoutColor = result.getLinesWithoutColor(); return List.of(//Actions on sign close); }) .build(); gui.open(p);
If you have different code try this first otherwise send your code and any errors you may have
I didn't have any issues except with the .setLine() function but that can be overlooked my simply using .setLines(). This is my code with that implementation which works:
SignGUI gui = SignGUI.builder() .setLines("text1", "text2", "text3", null) .setType(Material.OAK_SIGN) .setHandler((player, result) -> { String[] linesWithoutColor = result.getLinesWithoutColor(); return List.of(//Actions on sign close); }) .build(); gui.open(p);
If you have different code try this first otherwise send your code and any errors you may have
Thank you. Now my Sign can display messages, and I have debugged it in Wrapper_ 1_ 20__ A few lines of code have been added to R1 to solve the problem with setline()