Fixed 1.7.6 -> 1.8 open screen title translation

This commit is contained in:
RaphiMC 2024-09-09 11:33:18 +02:00
parent 7f068fc928
commit 1996e214a1
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94

View File

@ -836,11 +836,35 @@ public class Protocolr1_7_6_10Tor1_8 extends AbstractProtocol<ClientboundPackets
final String inventoryName; final String inventoryName;
switch (windowType) { switch (windowType) {
case 0 -> inventoryName = "minecraft:chest"; case 0 -> inventoryName = "minecraft:chest";
case 1 -> inventoryName = "minecraft:crafting_table"; case 1 -> {
case 2 -> inventoryName = "minecraft:furnace"; inventoryName = "minecraft:crafting_table";
case 3 -> inventoryName = "minecraft:dispenser"; title = "container.crafting";
case 4 -> inventoryName = "minecraft:enchanting_table"; useProvidedWindowTitle = false;
case 5 -> inventoryName = "minecraft:brewing_stand"; }
case 2 -> {
inventoryName = "minecraft:furnace";
if (!useProvidedWindowTitle) {
title = "container.furnace";
}
}
case 3 -> {
inventoryName = "minecraft:dispenser";
if (!useProvidedWindowTitle) {
title = "container.dispenser";
}
}
case 4 -> {
inventoryName = "minecraft:enchanting_table";
if (!useProvidedWindowTitle) {
title = "container.enchant";
}
}
case 5 -> {
inventoryName = "minecraft:brewing_stand";
if (!useProvidedWindowTitle) {
title = "container.brewing";
}
}
case 6 -> { case 6 -> {
inventoryName = "minecraft:villager"; inventoryName = "minecraft:villager";
if (!useProvidedWindowTitle || title.isEmpty()) { if (!useProvidedWindowTitle || title.isEmpty()) {
@ -848,10 +872,29 @@ public class Protocolr1_7_6_10Tor1_8 extends AbstractProtocol<ClientboundPackets
useProvidedWindowTitle = false; useProvidedWindowTitle = false;
} }
} }
case 7 -> inventoryName = "minecraft:beacon"; case 7 -> {
case 8 -> inventoryName = "minecraft:anvil"; inventoryName = "minecraft:beacon";
case 9 -> inventoryName = "minecraft:hopper"; if (!useProvidedWindowTitle) {
case 10 -> inventoryName = "minecraft:dropper"; title = "container.beacon";
}
}
case 8 -> {
inventoryName = "minecraft:anvil";
title = "container.repair";
useProvidedWindowTitle = false;
}
case 9 -> {
inventoryName = "minecraft:hopper";
if (!useProvidedWindowTitle) {
title = "container.hopper";
}
}
case 10 -> {
inventoryName = "minecraft:dropper";
if (!useProvidedWindowTitle) {
title = "container.dropper";
}
}
case 11 -> inventoryName = "EntityHorse"; case 11 -> inventoryName = "EntityHorse";
default -> throw new IllegalArgumentException("Unknown window type: " + windowType); default -> throw new IllegalArgumentException("Unknown window type: " + windowType);
} }
@ -1285,12 +1328,12 @@ public class Protocolr1_7_6_10Tor1_8 extends AbstractProtocol<ClientboundPackets
final PacketWrapper resetHandItem = PacketWrapper.create(ClientboundPackets1_8.CONTAINER_SET_SLOT, wrapper.user()); final PacketWrapper resetHandItem = PacketWrapper.create(ClientboundPackets1_8.CONTAINER_SET_SLOT, wrapper.user());
resetHandItem.write(Types.UNSIGNED_BYTE, (short) -1); // window id resetHandItem.write(Types.UNSIGNED_BYTE, (short) -1); // window id
resetHandItem.write(Types.SHORT, (short) 0); // slot resetHandItem.write(Types.SHORT, (short) 0); // slot
resetHandItem.write(Types.ITEM1_8, new DataItem(-1, (byte) 0, (short) 0, null)); resetHandItem.write(Types.ITEM1_8, null); // item
resetHandItem.send(Protocolr1_7_6_10Tor1_8.class); resetHandItem.send(Protocolr1_7_6_10Tor1_8.class);
final PacketWrapper setLapisSlot = PacketWrapper.create(ClientboundPackets1_8.CONTAINER_SET_SLOT, wrapper.user()); final PacketWrapper setLapisSlot = PacketWrapper.create(ClientboundPackets1_8.CONTAINER_SET_SLOT, wrapper.user());
setLapisSlot.write(Types.UNSIGNED_BYTE, windowId); setLapisSlot.write(Types.UNSIGNED_BYTE, windowId); // window id
setLapisSlot.write(Types.SHORT, slot); setLapisSlot.write(Types.SHORT, slot); // slot
setLapisSlot.write(Types.ITEM1_8, new DataItem(351/*lapis_lazuli*/, (byte) 3, (short) 4, null)); setLapisSlot.write(Types.ITEM1_8, new DataItem(351/*lapis_lazuli*/, (byte) 3, (short) 4, null)); // item
setLapisSlot.send(Protocolr1_7_6_10Tor1_8.class); setLapisSlot.send(Protocolr1_7_6_10Tor1_8.class);
wrapper.cancel(); wrapper.cancel();
} else if (slot > 1) { } else if (slot > 1) {