Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-25 15:50:12 +01:00
Update to VV container id types
Dieser Commit ist enthalten in:
Ursprung
eb4d30ae73
Commit
e36917e6c2
@ -60,7 +60,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
|
|||||||
protocol.registerClientbound(ClientboundPackets1_9_3.CONTAINER_SET_SLOT, new PacketHandlers() {
|
protocol.registerClientbound(ClientboundPackets1_9_3.CONTAINER_SET_SLOT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.UNSIGNED_BYTE); // 0 - Window ID
|
map(Types.BYTE); // 0 - Window ID
|
||||||
map(Types.SHORT); // 1 - Slot ID
|
map(Types.SHORT); // 1 - Slot ID
|
||||||
map(Types.ITEM1_8); // 2 - Slot Value
|
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() {
|
protocol.registerServerbound(ServerboundPackets1_9_3.CONTAINER_CLICK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.UNSIGNED_BYTE); // 0 - Window ID
|
map(Types.BYTE); // 0 - Window ID
|
||||||
map(Types.SHORT); // 1 - Slot
|
map(Types.SHORT); // 1 - Slot
|
||||||
map(Types.BYTE); // 2 - Button
|
map(Types.BYTE); // 2 - Button
|
||||||
map(Types.SHORT); // 3 - Action number
|
map(Types.SHORT); // 3 - Action number
|
||||||
|
@ -95,7 +95,7 @@ public class BlockItemPacketRewriter1_12 extends LegacyBlockItemRewriter<Clientb
|
|||||||
protocol.registerServerbound(ServerboundPackets1_9_3.CONTAINER_CLICK, new PacketHandlers() {
|
protocol.registerServerbound(ServerboundPackets1_9_3.CONTAINER_CLICK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.UNSIGNED_BYTE); // 0 - Window ID
|
map(Types.BYTE); // 0 - Window ID
|
||||||
map(Types.SHORT); // 1 - Slot
|
map(Types.SHORT); // 1 - Slot
|
||||||
map(Types.BYTE); // 2 - Button
|
map(Types.BYTE); // 2 - Button
|
||||||
map(Types.SHORT); // 3 - Action number
|
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?)
|
// Apologize (may happen in some cases, maybe if inventory is full?)
|
||||||
PacketWrapper confirm = wrapper.create(ServerboundPackets1_12.CONTAINER_ACK);
|
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.SHORT, wrapper.get(Types.SHORT, 1));
|
||||||
confirm.write(Types.BOOLEAN, false); // Success - not used
|
confirm.write(Types.BOOLEAN, false); // Success - not used
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ public class ItemPacketRewriter1_13_2 {
|
|||||||
protocol.registerClientbound(ClientboundPackets1_13.CONTAINER_SET_SLOT, new PacketHandlers() {
|
protocol.registerClientbound(ClientboundPackets1_13.CONTAINER_SET_SLOT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.UNSIGNED_BYTE); // 0 - Window ID
|
map(Types.BYTE); // 0 - Window ID
|
||||||
map(Types.SHORT); // 1 - Slot ID
|
map(Types.SHORT); // 1 - Slot ID
|
||||||
map(Types.ITEM1_13_2, Types.ITEM1_13); // 2 - Slot Value
|
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() {
|
protocol.registerServerbound(ServerboundPackets1_13.CONTAINER_CLICK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.UNSIGNED_BYTE); // 0 - Window ID
|
map(Types.BYTE); // 0 - Window ID
|
||||||
map(Types.SHORT); // 1 - Slot
|
map(Types.SHORT); // 1 - Slot
|
||||||
map(Types.BYTE); // 2 - Button
|
map(Types.BYTE); // 2 - Button
|
||||||
map(Types.SHORT); // 3 - Action number
|
map(Types.SHORT); // 3 - Action number
|
||||||
|
@ -270,7 +270,7 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter<Clientbou
|
|||||||
protocol.registerClientbound(ClientboundPackets1_13.CONTAINER_SET_SLOT, new PacketHandlers() {
|
protocol.registerClientbound(ClientboundPackets1_13.CONTAINER_SET_SLOT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.UNSIGNED_BYTE);
|
map(Types.BYTE);
|
||||||
map(Types.SHORT);
|
map(Types.SHORT);
|
||||||
map(Types.ITEM1_13, Types.ITEM1_8);
|
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() {
|
protocol.registerServerbound(ServerboundPackets1_12_1.CONTAINER_CLICK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.UNSIGNED_BYTE);
|
map(Types.BYTE);
|
||||||
map(Types.SHORT);
|
map(Types.SHORT);
|
||||||
map(Types.BYTE);
|
map(Types.BYTE);
|
||||||
map(Types.SHORT);
|
map(Types.SHORT);
|
||||||
|
@ -58,17 +58,17 @@ public final class Protocol1_17_1To1_17 extends BackwardsProtocol<ClientboundPac
|
|||||||
|
|
||||||
registerClientbound(ClientboundPackets1_17_1.CONTAINER_CLOSE, wrapper -> {
|
registerClientbound(ClientboundPackets1_17_1.CONTAINER_CLOSE, wrapper -> {
|
||||||
short containerId = wrapper.passthrough(Types.UNSIGNED_BYTE);
|
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 -> {
|
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);
|
int stateId = wrapper.read(Types.VAR_INT);
|
||||||
wrapper.user().get(InventoryStateIds.class).setStateId(containerId, stateId);
|
wrapper.user().get(InventoryStateIds.class).setStateId(containerId, stateId);
|
||||||
});
|
});
|
||||||
registerClientbound(ClientboundPackets1_17_1.CONTAINER_SET_CONTENT, wrapper -> {
|
registerClientbound(ClientboundPackets1_17_1.CONTAINER_SET_CONTENT, wrapper -> {
|
||||||
short containerId = wrapper.passthrough(Types.UNSIGNED_BYTE);
|
short containerId = wrapper.passthrough(Types.UNSIGNED_BYTE);
|
||||||
int stateId = wrapper.read(Types.VAR_INT);
|
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
|
// 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));
|
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 -> {
|
registerServerbound(ServerboundPackets1_17.CONTAINER_CLOSE, wrapper -> {
|
||||||
short containerId = wrapper.passthrough(Types.UNSIGNED_BYTE);
|
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 -> {
|
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);
|
int stateId = wrapper.user().get(InventoryStateIds.class).removeStateId(containerId);
|
||||||
wrapper.write(Types.VAR_INT, stateId == Integer.MAX_VALUE ? 0 : stateId);
|
wrapper.write(Types.VAR_INT, stateId == Integer.MAX_VALUE ? 0 : stateId);
|
||||||
});
|
});
|
||||||
|
@ -29,11 +29,11 @@ public final class InventoryStateIds implements StorableObject {
|
|||||||
ids.defaultReturnValue(Integer.MAX_VALUE);
|
ids.defaultReturnValue(Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStateId(short containerId, int id) {
|
public void setStateId(byte containerId, int id) {
|
||||||
ids.put(containerId, id);
|
ids.put(containerId, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int removeStateId(short containerId) {
|
public int removeStateId(byte containerId) {
|
||||||
return ids.remove(containerId);
|
return ids.remove(containerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ public final class BlockItemPacketRewriter1_17 extends BackwardsItemRewriter<Cli
|
|||||||
protocol.registerServerbound(ServerboundPackets1_16_2.CONTAINER_CLICK, new PacketHandlers() {
|
protocol.registerServerbound(ServerboundPackets1_16_2.CONTAINER_CLICK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.UNSIGNED_BYTE);
|
map(Types.BYTE);
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
short slot = wrapper.passthrough(Types.SHORT); // Slot
|
short slot = wrapper.passthrough(Types.SHORT); // Slot
|
||||||
byte button = wrapper.passthrough(Types.BYTE); // Button
|
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 -> {
|
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);
|
short slot = wrapper.passthrough(Types.SHORT);
|
||||||
|
|
||||||
Item carried = wrapper.read(Types.ITEM1_13_2);
|
Item carried = wrapper.read(Types.ITEM1_13_2);
|
||||||
@ -164,7 +164,7 @@ public final class BlockItemPacketRewriter1_17 extends BackwardsItemRewriter<Cli
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle ping packet replacement
|
// Handle ping packet replacement
|
||||||
short inventoryId = wrapper.read(Types.UNSIGNED_BYTE);
|
byte inventoryId = wrapper.read(Types.BYTE);
|
||||||
short confirmationId = wrapper.read(Types.SHORT);
|
short confirmationId = wrapper.read(Types.SHORT);
|
||||||
boolean accepted = wrapper.read(Types.BOOLEAN);
|
boolean accepted = wrapper.read(Types.BOOLEAN);
|
||||||
if (inventoryId == 0 && accepted && wrapper.user().get(PingRequests.class).removeId(confirmationId)) {
|
if (inventoryId == 0 && accepted && wrapper.user().get(PingRequests.class).removeId(confirmationId)) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren