fix set cooldown

This commit is contained in:
creeper123123321 2018-11-10 08:41:22 -02:00
parent d84c4365c9
commit 408bd49120
No known key found for this signature in database
GPG Key ID: 0AC57D54786721D1
2 changed files with 55 additions and 1 deletions

View File

@ -90,6 +90,22 @@ 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

@ -223,7 +223,45 @@ public class Protocol1_13To1_12_2 extends Protocol {
// InventoryPackets 0x14 -> 0x15
// InventoryPackets 0x15 -> 0x16
// InventoryPackets 0x16 -> 0x17
registerOutgoing(State.PLAY, 0x17, 0x18);
// Set cooldown
registerOutgoing(State.PLAY, 0x17, 0x18, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int item = wrapper.read(Type.VAR_INT);
int ticks = wrapper.read(Type.VAR_INT);
wrapper.cancel();
if (item == 383) { // Spawn egg
for (int i = 0; i < 44; i++) {
Integer newItem = MappingData.oldToNewItems.get(item << 16 | i);
if (newItem != null) {
PacketWrapper packet = wrapper.create(0x18);
packet.write(Type.VAR_INT, newItem);
packet.write(Type.VAR_INT, ticks);
packet.send(Protocol1_13To1_12_2.class);
} else {
break;
}
}
} else {
for (int i = 0; i < 16; i++) {
Integer newItem = MappingData.oldToNewItems.get(item << 4 | i);
if (newItem != null) {
PacketWrapper packet = wrapper.create(0x18);
packet.write(Type.VAR_INT, newItem);
packet.write(Type.VAR_INT, ticks);
packet.send(Protocol1_13To1_12_2.class);
} else {
break;
}
}
}
}
});
}
});
// WorldPackets 0x18 -> 0x19
registerOutgoing(State.PLAY, 0x1A, 0x1B);
registerOutgoing(State.PLAY, 0x1B, 0x1C);