Skip to content

Commit 1be574b

Browse files
Handle lit_furnace as furnace in 1.8->1.9 (ViaVersion#4739)
1 parent 0640e24 commit 1be574b

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

common/src/main/java/com/viaversion/viaversion/protocols/v1_8to1_9/rewriter/ItemPacketRewriter1_9.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,28 @@ public void register() {
382382
@Override
383383
public @Nullable Item handleItemToClient(final UserConnection connection, @Nullable final Item item) {
384384
if (item == null) return null;
385+
if (item.identifier() == 62) {
386+
item.setIdentifier(61);
387+
CompoundTag tag = item.tag();
388+
if (tag == null) {
389+
tag = new CompoundTag();
390+
}
391+
tag.putBoolean(nbtTagName("lit_furnace"), true);
392+
393+
CompoundTag display = tag.getCompoundTag("display");
394+
if (display == null) {
395+
tag.put("display", display = new CompoundTag());
396+
display.putBoolean(nbtTagName(), true);
397+
}
398+
399+
StringTag nameTag = display.getStringTag("Name");
400+
if (nameTag == null) {
401+
nameTag = new StringTag("1.8 Lit Furnace");
402+
display.put("Name", nameTag);
403+
display.putBoolean(nbtTagName("custom_name"), true);
404+
}
405+
item.setTag(tag);
406+
}
385407
if (item.identifier() == 383 && item.data() != 0) { // Monster Egg
386408
CompoundTag tag = item.tag();
387409
if (tag == null) {
@@ -442,6 +464,24 @@ public void register() {
442464
@Override
443465
public @Nullable Item handleItemToServer(final UserConnection connection, @Nullable final Item item) {
444466
if (item == null) return null;
467+
if (item.identifier() == 61) {
468+
CompoundTag tag = item.tag();
469+
if (tag != null && tag.remove(nbtTagName("lit_furnace")) != null) {
470+
item.setIdentifier(62);
471+
CompoundTag display = tag.getCompoundTag("display");
472+
if (display != null) {
473+
if (display.remove(nbtTagName("custom_name")) != null) {
474+
display.remove("Name");
475+
}
476+
if (display.remove(nbtTagName()) != null) {
477+
tag.remove("display");
478+
if (tag.isEmpty()) {
479+
item.setTag(null);
480+
}
481+
}
482+
}
483+
}
484+
}
445485
if (item.identifier() == 383 && item.data() == 0) { // Monster Egg
446486
CompoundTag tag = item.tag();
447487
int data = 0;

0 commit comments

Comments
 (0)