Skip to content

Commit

Permalink
Fix 1.13->1.12 item cooldown
Browse files Browse the repository at this point in the history
Fixes #450
  • Loading branch information
kennytv committed May 29, 2022
1 parent dc9fe10 commit c2ae3df
Showing 1 changed file with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,20 @@ protected void registerPackets() {
protocol.registerClientbound(ClientboundPackets1_13.COOLDOWN, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int itemId = wrapper.read(Type.VAR_INT);
int oldId = protocol.getMappingData().getItemMappings().get(itemId);
if (oldId != -1) {
Optional<String> eggEntityId = SpawnEggRewriter.getEntityId(oldId);
if (eggEntityId.isPresent()) {
itemId = 383 << 16;
} else {
itemId = (oldId >> 4) << 16 | oldId & 0xF;
}
}
wrapper.write(Type.VAR_INT, itemId);
handler(wrapper -> {
int itemId = wrapper.read(Type.VAR_INT);
int oldId = protocol.getMappingData().getItemMappings().get(itemId);
if (oldId == -1) {
wrapper.cancel();
return;
}

if (SpawnEggRewriter.getEntityId(oldId).isPresent()) {
wrapper.write(Type.VAR_INT, 383 << 4);
return;
}

wrapper.write(Type.VAR_INT, oldId >> 4);
});
}
});
Expand Down

0 comments on commit c2ae3df

Please sign in to comment.