Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sign colors #1407

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions patches/server/0227-Signs-allow-color-codes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,21 @@ index 83541ef2f3c27e13ebf244b056d2f40e1c60e96a..7b962da50664abedc676e931a422e678
this.connection.send(new ClientboundOpenSignEditorPacket(sign.getBlockPos(), front));
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
index 38cde466714e5663cd416b6afd5d2558e139ec09..46b599539afee09a043de993006d025a8a104ff3 100644
index 38cde466714e5663cd416b6afd5d2558e139ec09..a4142961a3eb82f827b89b2b14e84b1fdbf8b3ed 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
@@ -202,16 +202,31 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
@@ -11,9 +11,7 @@ import javax.annotation.Nullable;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.BlockPos;
-import net.minecraft.nbt.CompoundTag;
-import net.minecraft.nbt.NbtOps;
-import net.minecraft.nbt.Tag;
+import net.minecraft.nbt.*;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.ComponentUtils;
@@ -202,16 +200,31 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
return this.setText((SignText) textChanger.apply(signtext), front);
}

Expand Down Expand Up @@ -54,7 +65,7 @@ index 38cde466714e5663cd416b6afd5d2558e139ec09..46b599539afee09a043de993006d025a
}
}

@@ -351,6 +366,23 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
@@ -351,6 +364,28 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
return ClientboundBlockEntityDataPacket.create(this);
}

Expand All @@ -63,12 +74,17 @@ index 38cde466714e5663cd416b6afd5d2558e139ec09..46b599539afee09a043de993006d025a
+ final CompoundTag nbt = new CompoundTag();
+ this.saveAdditional(nbt);
+ final Component[] lines = front ? frontText.getMessages(filtered) : backText.getMessages(filtered);
+ final String side = front ? "front_text" : "back_text";
+ for (int i = 0; i < 4; i++) {
+ final var component = io.papermc.paper.adventure.PaperAdventure.asAdventure(lines[i]);
+ final String line = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacyAmpersand().serialize(component);
+ final var text = net.kyori.adventure.text.Component.text(line);
+ final String json = net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().serialize(text);
+ nbt.putString("Text" + (i + 1), json);
+ if (!nbt.contains(side)) nbt.put(side, new CompoundTag());
+ final CompoundTag sideNbt = nbt.getCompound(side);
+ if (!sideNbt.contains("messages")) sideNbt.put("messages", new ListTag());
+ final ListTag messagesNbt = sideNbt.getList("messages", Tag.TAG_STRING);
+ messagesNbt.set(i, StringTag.valueOf(json));
+ }
+ nbt.putString("PurpurEditor", "true");
+ return ClientboundBlockEntityDataPacket.create(this, entity -> nbt);
Expand Down