3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-08 17:20:24 +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.ClientboundPacketType;
import us.myles.ViaVersion.api.protocol.Protocol; 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.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
@ -25,7 +26,13 @@ public class SoundRewriter {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // Sound Id map(Type.VAR_INT); // Sound Id
handler(wrapper -> { handler(getSoundHandler());
}
});
}
public PacketHandler getSoundHandler() {
return wrapper -> {
int soundId = wrapper.get(Type.VAR_INT, 0); int soundId = wrapper.get(Type.VAR_INT, 0);
int mappedId = idRewriter.rewrite(soundId); int mappedId = idRewriter.rewrite(soundId);
if (mappedId == -1) { if (mappedId == -1) {
@ -33,8 +40,6 @@ public class SoundRewriter {
} else if (soundId != mappedId) { } else if (soundId != mappedId) {
wrapper.set(Type.VAR_INT, 0, mappedId); wrapper.set(Type.VAR_INT, 0, mappedId);
} }
}); };
}
});
} }
} }