mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-07 10:02:01 +01:00
Extend from VV soundrewriter
This commit is contained in:
parent
cb8cdf27a4
commit
611dd93bb9
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user