Skip to content

Commit 22e823e

Browse files
authored
Directly override handle click event in 1.21.6->1.21.5 (#1233)
1 parent bd3877b commit 22e823e

1 file changed

Lines changed: 11 additions & 18 deletions

File tree

common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_6to1_21_5/rewriter/ComponentRewriter1_21_6.java

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,25 @@ public ComponentRewriter1_21_6(final BackwardsProtocol<ClientboundPacket1_21_6,
3131
}
3232

3333
@Override
34-
protected void processCompoundTag(final UserConnection connection, final CompoundTag tag) {
35-
super.processCompoundTag(connection, tag);
36-
37-
final CompoundTag clickEvent = tag.getCompoundTag("click_event");
38-
if (clickEvent == null) {
39-
return;
40-
}
41-
42-
final String action = clickEvent.getString("action");
34+
protected void handleClickEvent(final UserConnection connection, final CompoundTag clickEventTag) {
35+
final String action = clickEventTag.getString("action");
4336

4437
// Make them run a command generated by us executing the actual logic
4538
if ("show_dialog".equals(action)) {
4639
final ClickEvents clickEvents = connection.get(ClickEvents.class);
47-
final String command = clickEvents.storeClickEvent(clickEvent.copy());
40+
final String command = clickEvents.storeClickEvent(clickEventTag.copy());
4841

49-
clickEvent.putString("action", "run_command");
50-
clickEvent.putString("command", command);
51-
clickEvent.remove("dialog");
42+
clickEventTag.putString("action", "run_command");
43+
clickEventTag.putString("command", command);
44+
clickEventTag.remove("dialog");
5245
} else if ("custom".equals(action)) {
5346
final ClickEvents clickEvents = connection.get(ClickEvents.class);
54-
final String command = clickEvents.storeClickEvent(clickEvent.copy());
47+
final String command = clickEvents.storeClickEvent(clickEventTag.copy());
5548

56-
clickEvent.putString("action", "run_command");
57-
clickEvent.putString("command", command);
58-
clickEvent.remove("id");
59-
clickEvent.remove("payload");
49+
clickEventTag.putString("action", "run_command");
50+
clickEventTag.putString("command", command);
51+
clickEventTag.remove("id");
52+
clickEventTag.remove("payload");
6053
}
6154
}
6255
}

0 commit comments

Comments
 (0)