Merge pull request #1650 from KennyTV/abstraction

Handle items in cooldown packet
This commit is contained in:
Myles 2020-02-08 21:24:45 +00:00 committed by GitHub
commit 7513b0499d
9 changed files with 14 additions and 20 deletions

View File

@ -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

View File

@ -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);

View File

@ -137,5 +137,4 @@ public class InventoryPackets {
}
);
}
}

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);