3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-07-28 09:58:04 +02:00

Extend from VV soundrewriter

Dieser Commit ist enthalten in:
KennyTV 2020-05-23 11:21:42 +02:00
Ursprung cb8cdf27a4
Commit 611dd93bb9
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B

Datei anzeigen

@ -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