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 trade signs not updating with full inventories #5574

Merged
merged 1 commit into from
Nov 11, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ public interface ISign {
static class EventSign implements ISign {
private final transient SignChangeEvent event;
private final transient Block block;
private final transient Sign sign;
private transient Sign sign;

EventSign(final SignChangeEvent event) {
this.event = event;
Expand Down Expand Up @@ -543,22 +543,21 @@ public Block getBlock() {
@Override
public void updateSign() {
sign.update();
sign = (Sign) block.getState();
}
}

static class BlockSign implements ISign {
private final transient Sign sign;
private final transient Block block;

BlockSign(final Block block) {
this.block = block;
this.sign = (Sign) block.getState();
}

@Override
public final String getLine(final int index) {
final StringBuilder builder = new StringBuilder();
for (final char c : sign.getLine(index).toCharArray()) {
for (final char c : getSign().getLine(index).toCharArray()) {
if (c < 0xF700 || c > 0xF747) {
builder.append(c);
}
Expand All @@ -569,7 +568,7 @@ public final String getLine(final int index) {

@Override
public final void setLine(final int index, final String text) {
sign.setLine(index, text);
getSign().setLine(index, text);
updateSign();
}

Expand All @@ -578,9 +577,15 @@ public final Block getBlock() {
return block;
}

private Sign getSign() {
// Starting in 1.19, the block state is no longer persistent I guess? We must get it every time to prevent
// sign updates from not taking effect.
return (Sign) block.getState();
}

@Override
public final void updateSign() {
sign.update();
getSign().update();
}
}
}