Extend from VV soundrewriter

This commit is contained in:
KennyTV 2020-05-23 11:21:42 +02:00
parent cb8cdf27a4
commit 611dd93bb9
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B

View File

@ -8,16 +8,12 @@ import us.myles.ViaVersion.packets.State;
import java.util.function.Function;
public class SoundRewriter {
public class SoundRewriter extends us.myles.ViaVersion.api.rewriters.SoundRewriter {
private final BackwardsProtocol protocol;
// Can't hold the mappings instance here since it's loaded later
private final IdRewriteFunction idRewriter;
private final Function<String, String> stringIdRewriter;
public SoundRewriter(BackwardsProtocol protocol, IdRewriteFunction idRewriter, Function<String, String> stringIdRewriter) {
this.protocol = protocol;
this.idRewriter = idRewriter;
super(protocol, idRewriter);
this.stringIdRewriter = stringIdRewriter;
}
@ -25,23 +21,6 @@ public class SoundRewriter {
this(protocol, idRewriter, null);
}
// The same for entity sound effect
public void registerSound(int oldId, int newId) {
protocol.registerOutgoing(State.PLAY, oldId, newId, new PacketRemapper() {
@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 && soundId != mappedId) {
wrapper.set(Type.VAR_INT, 0, mappedId);
}
});
}
});
}
public void registerNamedSound(int oldId, int newId) {
protocol.registerOutgoing(State.PLAY, oldId, newId, new PacketRemapper() {
@Override