Add handleMenuType function to ItemRewriter (#3953)

This commit is contained in:
EnZaXD 2024-06-17 16:39:01 +02:00 committed by GitHub
parent 2ab62a8f4f
commit 3d083cf463
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -112,20 +112,22 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
@Override
public void register() {
map(Types.VAR_INT); // Container id
handler(wrapper -> {
final int windowType = wrapper.read(Types.VAR_INT);
final int mappedId = protocol.getMappingData().getMenuMappings().getNewId(windowType);
if (mappedId == -1) {
wrapper.cancel();
return;
}
wrapper.write(Types.VAR_INT, mappedId);
});
handler(wrapper -> handleMenuType(wrapper));
}
});
}
public void handleMenuType(final PacketWrapper wrapper) {
final int windowType = wrapper.read(Types.VAR_INT);
final int mappedId = protocol.getMappingData().getMenuMappings().getNewId(windowType);
if (mappedId == -1) {
wrapper.cancel();
return;
}
wrapper.write(Types.VAR_INT, mappedId);
}
public void registerSetSlot(C packetType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override