3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-19 14:30:16 +01:00

Add handleMenuType function to ItemRewriter (#3953)

Dieser Commit ist enthalten in:
EnZaXD 2024-06-17 16:39:01 +02:00 committet von GitHub
Ursprung 2ab62a8f4f
Commit 3d083cf463
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194

Datei anzeigen

@ -112,20 +112,22 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
@Override @Override
public void register() { public void register() {
map(Types.VAR_INT); // Container id map(Types.VAR_INT); // Container id
handler(wrapper -> { handler(wrapper -> handleMenuType(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 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) { public void registerSetSlot(C packetType) {
protocol.registerClientbound(packetType, new PacketHandlers() { protocol.registerClientbound(packetType, new PacketHandlers() {
@Override @Override