3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-09-28 22:51:06 +02:00

Update to VV container id types

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-08-16 20:52:15 +02:00
Ursprung eb4d30ae73
Commit e36917e6c2
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
7 geänderte Dateien mit 19 neuen und 18 gelöschten Zeilen

Datei anzeigen

@ -60,7 +60,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
protocol.registerClientbound(ClientboundPackets1_9_3.CONTAINER_SET_SLOT, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE); // 0 - Window ID
map(Types.BYTE); // 0 - Window ID
map(Types.SHORT); // 1 - Slot ID
map(Types.ITEM1_8); // 2 - Slot Value
@ -118,7 +118,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
protocol.registerServerbound(ServerboundPackets1_9_3.CONTAINER_CLICK, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE); // 0 - Window ID
map(Types.BYTE); // 0 - Window ID
map(Types.SHORT); // 1 - Slot
map(Types.BYTE); // 2 - Button
map(Types.SHORT); // 3 - Action number

Datei anzeigen

@ -95,7 +95,7 @@ public class BlockItemPacketRewriter1_12 extends LegacyBlockItemRewriter<Clientb
protocol.registerServerbound(ServerboundPackets1_9_3.CONTAINER_CLICK, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE); // 0 - Window ID
map(Types.BYTE); // 0 - Window ID
map(Types.SHORT); // 1 - Slot
map(Types.BYTE); // 2 - Button
map(Types.SHORT); // 3 - Action number
@ -112,7 +112,8 @@ public class BlockItemPacketRewriter1_12 extends LegacyBlockItemRewriter<Clientb
// Apologize (may happen in some cases, maybe if inventory is full?)
PacketWrapper confirm = wrapper.create(ServerboundPackets1_12.CONTAINER_ACK);
confirm.write(Types.UNSIGNED_BYTE, wrapper.get(Types.UNSIGNED_BYTE, 0));
byte containerId = wrapper.get(Types.BYTE, 0);
confirm.write(Types.BYTE, containerId);
confirm.write(Types.SHORT, wrapper.get(Types.SHORT, 1));
confirm.write(Types.BOOLEAN, false); // Success - not used

Datei anzeigen

@ -30,7 +30,7 @@ public class ItemPacketRewriter1_13_2 {
protocol.registerClientbound(ClientboundPackets1_13.CONTAINER_SET_SLOT, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE); // 0 - Window ID
map(Types.BYTE); // 0 - Window ID
map(Types.SHORT); // 1 - Slot ID
map(Types.ITEM1_13_2, Types.ITEM1_13); // 2 - Slot Value
}
@ -117,7 +117,7 @@ public class ItemPacketRewriter1_13_2 {
protocol.registerServerbound(ServerboundPackets1_13.CONTAINER_CLICK, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE); // 0 - Window ID
map(Types.BYTE); // 0 - Window ID
map(Types.SHORT); // 1 - Slot
map(Types.BYTE); // 2 - Button
map(Types.SHORT); // 3 - Action number

Datei anzeigen

@ -270,7 +270,7 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter<Clientbou
protocol.registerClientbound(ClientboundPackets1_13.CONTAINER_SET_SLOT, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE);
map(Types.BYTE);
map(Types.SHORT);
map(Types.ITEM1_13, Types.ITEM1_8);
@ -464,7 +464,7 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter<Clientbou
protocol.registerServerbound(ServerboundPackets1_12_1.CONTAINER_CLICK, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE);
map(Types.BYTE);
map(Types.SHORT);
map(Types.BYTE);
map(Types.SHORT);

Datei anzeigen

@ -58,17 +58,17 @@ public final class Protocol1_17_1To1_17 extends BackwardsProtocol<ClientboundPac
registerClientbound(ClientboundPackets1_17_1.CONTAINER_CLOSE, wrapper -> {
short containerId = wrapper.passthrough(Types.UNSIGNED_BYTE);
wrapper.user().get(InventoryStateIds.class).removeStateId(containerId);
wrapper.user().get(InventoryStateIds.class).removeStateId((byte) containerId);
});
registerClientbound(ClientboundPackets1_17_1.CONTAINER_SET_SLOT, wrapper -> {
short containerId = wrapper.passthrough(Types.UNSIGNED_BYTE);
byte containerId = wrapper.passthrough(Types.BYTE);
int stateId = wrapper.read(Types.VAR_INT);
wrapper.user().get(InventoryStateIds.class).setStateId(containerId, stateId);
});
registerClientbound(ClientboundPackets1_17_1.CONTAINER_SET_CONTENT, wrapper -> {
short containerId = wrapper.passthrough(Types.UNSIGNED_BYTE);
int stateId = wrapper.read(Types.VAR_INT);
wrapper.user().get(InventoryStateIds.class).setStateId(containerId, stateId);
wrapper.user().get(InventoryStateIds.class).setStateId((byte) containerId, stateId);
// Length is encoded as a var int in 1.17.1
wrapper.write(Types.ITEM1_13_2_SHORT_ARRAY, wrapper.read(Types.ITEM1_13_2_ARRAY));
@ -89,10 +89,10 @@ public final class Protocol1_17_1To1_17 extends BackwardsProtocol<ClientboundPac
registerServerbound(ServerboundPackets1_17.CONTAINER_CLOSE, wrapper -> {
short containerId = wrapper.passthrough(Types.UNSIGNED_BYTE);
wrapper.user().get(InventoryStateIds.class).removeStateId(containerId);
wrapper.user().get(InventoryStateIds.class).removeStateId((byte) containerId);
});
registerServerbound(ServerboundPackets1_17.CONTAINER_CLICK, wrapper -> {
short containerId = wrapper.passthrough(Types.UNSIGNED_BYTE);
byte containerId = wrapper.passthrough(Types.BYTE);
int stateId = wrapper.user().get(InventoryStateIds.class).removeStateId(containerId);
wrapper.write(Types.VAR_INT, stateId == Integer.MAX_VALUE ? 0 : stateId);
});

Datei anzeigen

@ -29,11 +29,11 @@ public final class InventoryStateIds implements StorableObject {
ids.defaultReturnValue(Integer.MAX_VALUE);
}
public void setStateId(short containerId, int id) {
public void setStateId(byte containerId, int id) {
ids.put(containerId, id);
}
public int removeStateId(short containerId) {
public int removeStateId(byte containerId) {
return ids.remove(containerId);
}
}

Datei anzeigen

@ -91,7 +91,7 @@ public final class BlockItemPacketRewriter1_17 extends BackwardsItemRewriter<Cli
protocol.registerServerbound(ServerboundPackets1_16_2.CONTAINER_CLICK, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE);
map(Types.BYTE);
handler(wrapper -> {
short slot = wrapper.passthrough(Types.SHORT); // Slot
byte button = wrapper.passthrough(Types.BYTE); // Button
@ -139,7 +139,7 @@ public final class BlockItemPacketRewriter1_17 extends BackwardsItemRewriter<Cli
});
protocol.registerClientbound(ClientboundPackets1_17.CONTAINER_SET_SLOT, wrapper -> {
short windowId = wrapper.passthrough(Types.UNSIGNED_BYTE);
byte windowId = wrapper.passthrough(Types.BYTE);
short slot = wrapper.passthrough(Types.SHORT);
Item carried = wrapper.read(Types.ITEM1_13_2);
@ -164,7 +164,7 @@ public final class BlockItemPacketRewriter1_17 extends BackwardsItemRewriter<Cli
}
// Handle ping packet replacement
short inventoryId = wrapper.read(Types.UNSIGNED_BYTE);
byte inventoryId = wrapper.read(Types.BYTE);
short confirmationId = wrapper.read(Types.SHORT);
boolean accepted = wrapper.read(Types.BOOLEAN);
if (inventoryId == 0 && accepted && wrapper.user().get(PingRequests.class).removeId(confirmationId)) {