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

Add method to get handler in sound rewriter

Dieser Commit ist enthalten in:
KennyTV 2020-11-15 12:01:01 +01:00
Ursprung 78972a5345
Commit 7abff77c51
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B

Datei anzeigen

@ -2,6 +2,7 @@ package us.myles.ViaVersion.api.rewriters;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
@ -25,16 +26,20 @@ public class SoundRewriter {
@Override
public void registerMap() {
map(Type.VAR_INT); // Sound Id
handler(wrapper -> {
int soundId = wrapper.get(Type.VAR_INT, 0);
int mappedId = idRewriter.rewrite(soundId);
if (mappedId == -1) {
wrapper.cancel();
} else if (soundId != mappedId) {
wrapper.set(Type.VAR_INT, 0, mappedId);
}
});
handler(getSoundHandler());
}
});
}
public PacketHandler getSoundHandler() {
return wrapper -> {
int soundId = wrapper.get(Type.VAR_INT, 0);
int mappedId = idRewriter.rewrite(soundId);
if (mappedId == -1) {
wrapper.cancel();
} else if (soundId != mappedId) {
wrapper.set(Type.VAR_INT, 0, mappedId);
}
};
}
}