3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-28 00:50:13 +01:00

Add set cooldown register in ItemRewriter

Dieser Commit ist enthalten in:
KennyTV 2019-11-27 12:56:20 +01:00
Ursprung 42efec6e2b
Commit a68eac7cd2

Datei anzeigen

@ -85,6 +85,18 @@ public class ItemRewriter {
});
}
public void registerSetCooldown(int oldPacketId, int newPacketId, ItemIdRewriteFunction itemIDRewriteFunction) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
int itemId = wrapper.read(Type.VAR_INT);
wrapper.write(Type.VAR_INT, itemIDRewriteFunction.rewrite(itemId));
});
}
});
}
// Only sent to the client
public PacketHandler itemArrayHandler(Type<Item[]> type) {
return wrapper -> {
@ -108,4 +120,10 @@ public class ItemRewriter {
void rewrite(Item item);
}
@FunctionalInterface
public interface ItemIdRewriteFunction {
int rewrite(int itemId);
}
}