Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-09-16 17:31:21 +02:00
Extend from VV soundrewriter
Dieser Commit ist enthalten in:
Ursprung
cb8cdf27a4
Commit
611dd93bb9
@ -8,16 +8,12 @@ import us.myles.ViaVersion.packets.State;
|
|||||||
|
|
||||||
import java.util.function.Function;
|
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;
|
private final Function<String, String> stringIdRewriter;
|
||||||
|
|
||||||
public SoundRewriter(BackwardsProtocol protocol, IdRewriteFunction idRewriter, Function<String, String> stringIdRewriter) {
|
public SoundRewriter(BackwardsProtocol protocol, IdRewriteFunction idRewriter, Function<String, String> stringIdRewriter) {
|
||||||
this.protocol = protocol;
|
super(protocol, idRewriter);
|
||||||
this.idRewriter = idRewriter;
|
|
||||||
this.stringIdRewriter = stringIdRewriter;
|
this.stringIdRewriter = stringIdRewriter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,23 +21,6 @@ public class SoundRewriter {
|
|||||||
this(protocol, idRewriter, null);
|
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) {
|
public void registerNamedSound(int oldId, int newId) {
|
||||||
protocol.registerOutgoing(State.PLAY, oldId, newId, new PacketRemapper() {
|
protocol.registerOutgoing(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren