mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-12-24 17:37:39 +01:00
Merge pull request #1650 from KennyTV/abstraction
Handle items in cooldown packet
This commit is contained in:
commit
7513b0499d
@ -93,22 +93,6 @@ public class Protocol1_13_1To1_13 extends Protocol {
|
||||
}
|
||||
});
|
||||
|
||||
// Set cooldown
|
||||
registerOutgoing(State.PLAY, 0x18, 0x18, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Item
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.set(Type.VAR_INT, 0,
|
||||
InventoryPackets.getNewItemId(wrapper.get(Type.VAR_INT, 0))
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Boss bar
|
||||
registerOutgoing(State.PLAY, 0x0C, 0x0C, new PacketRemapper() {
|
||||
@Override
|
||||
|
@ -14,6 +14,9 @@ public class InventoryPackets {
|
||||
public static void register(Protocol protocol) {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
|
||||
|
||||
// Set cooldown
|
||||
itemRewriter.registerSetCooldown(0x18, 0x18, InventoryPackets::getNewItemId);
|
||||
|
||||
// Set slot packet
|
||||
itemRewriter.registerSetSlot(Type.FLAT_ITEM, 0x17, 0x17);
|
||||
|
||||
|
@ -137,5 +137,4 @@ public class InventoryPackets {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -339,9 +339,11 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// InventoryPackets 0x14 -> 0x15
|
||||
// InventoryPackets 0x15 -> 0x16
|
||||
// InventoryPackets 0x16 -> 0x17
|
||||
|
||||
// Set cooldown
|
||||
registerOutgoing(State.PLAY, 0x17, 0x18, new PacketRemapper() {
|
||||
@Override
|
||||
|
@ -34,8 +34,6 @@ public class Protocol1_14To1_13_2 extends Protocol {
|
||||
|
||||
registerOutgoing(State.PLAY, 0x16, 0x15);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x18, 0x17);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x1A, 0x19);
|
||||
registerOutgoing(State.PLAY, 0x1B, 0x1A);
|
||||
registerOutgoing(State.PLAY, 0x1C, 0x1B);
|
||||
|
@ -28,6 +28,9 @@ public class InventoryPackets {
|
||||
public static void register(Protocol protocol) {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
|
||||
|
||||
// Set cooldown
|
||||
itemRewriter.registerSetCooldown(0x18, 0x17, InventoryPackets::getNewItemId);
|
||||
|
||||
// Open Inventory
|
||||
protocol.registerOutgoing(State.PLAY, 0x14, -1, new PacketRemapper() {
|
||||
@Override
|
||||
|
@ -171,7 +171,6 @@ public class Protocol1_15To1_14_4 extends Protocol {
|
||||
|
||||
registerOutgoing(State.PLAY, 0x15, 0x16);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x17, 0x18);
|
||||
registerOutgoing(State.PLAY, 0x18, 0x19);
|
||||
registerOutgoing(State.PLAY, 0x19, 0x1A);
|
||||
registerOutgoing(State.PLAY, 0x1A, 0x1B);
|
||||
|
@ -16,6 +16,9 @@ public class InventoryPackets {
|
||||
public static void register(Protocol protocol) {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
|
||||
|
||||
// Set cooldown
|
||||
itemRewriter.registerSetCooldown(0x17, 0x18, InventoryPackets::getNewItemId);
|
||||
|
||||
// Window items packet
|
||||
itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x14, 0x15);
|
||||
|
||||
|
@ -14,6 +14,9 @@ public class InventoryPackets {
|
||||
public static void register(Protocol protocol) {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
|
||||
|
||||
// Set cooldown
|
||||
itemRewriter.registerSetCooldown(0x18, 0x18, InventoryPackets::getNewItemId);
|
||||
|
||||
// Window items packet
|
||||
itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x15, 0x15);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user