Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-08 01:00:15 +01:00
Add set cooldown register in ItemRewriter
Dieser Commit ist enthalten in:
Ursprung
42efec6e2b
Commit
a68eac7cd2
@ -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
|
// Only sent to the client
|
||||||
public PacketHandler itemArrayHandler(Type<Item[]> type) {
|
public PacketHandler itemArrayHandler(Type<Item[]> type) {
|
||||||
return wrapper -> {
|
return wrapper -> {
|
||||||
@ -108,4 +120,10 @@ public class ItemRewriter {
|
|||||||
|
|
||||||
void rewrite(Item item);
|
void rewrite(Item item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ItemIdRewriteFunction {
|
||||||
|
|
||||||
|
int rewrite(int itemId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren