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:
Ursprung
78972a5345
Commit
7abff77c51
@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren