Compare commits

...

3 Commits

Author SHA1 Message Date
wtlgo 9250d8ebab
Merge 2dda90b158 into dcf741a2ba 2024-04-23 16:36:24 +01:00
EnZaXD dcf741a2ba
Fix sound mapping lookup in 1.8->1.9 (#3801) 2024-04-23 10:46:40 +02:00
wtlgo 2dda90b158
Update ViaManagerImpl.java 2024-04-07 02:55:57 +03:00
3 changed files with 19 additions and 15 deletions

View File

@ -329,7 +329,11 @@ public class ViaManagerImpl implements ViaManager {
* @param runnable runnable to be executed
*/
public void addEnableListener(Runnable runnable) {
enableListeners.add(runnable);
if (enableListeners != null) {
enableListeners.add(runnable);
} else {
runnable.run();
}
}
@Override

View File

@ -46,6 +46,7 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.sounds.SoundEffect;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.ClientChunks;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
import com.viaversion.viaversion.util.ComponentUtil;
import com.viaversion.viaversion.util.Key;
import java.util.ArrayList;
import java.util.Optional;
@ -98,7 +99,7 @@ public class WorldPackets {
// Everything else gets written through
handler(wrapper -> {
String name = wrapper.get(Type.STRING, 0);
String name = Key.stripMinecraftNamespace(wrapper.get(Type.STRING, 0));
SoundEffect effect = SoundEffect.getByName(name);
int catid = 0;
@ -109,7 +110,7 @@ public class WorldPackets {
}
wrapper.set(Type.STRING, 0, newname);
wrapper.write(Type.VAR_INT, catid); // Write Category ID
if (effect != null && effect.isBreaksound()) {
if (effect != null && effect.isBreakSound()) {
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
int x = wrapper.passthrough(Type.INT); //Position X
int y = wrapper.passthrough(Type.INT); //Position Y

View File

@ -273,7 +273,7 @@ public enum SoundEffect {
private final String name;
private final String newName;
private final SoundCategory category;
private final boolean breaksound;
private final boolean breakSound;
private static final Map<String, SoundEffect> effects;
@ -284,22 +284,21 @@ public enum SoundEffect {
}
}
SoundEffect(String name, String newname, SoundCategory cat) {
this.category = cat;
this.newName = newname;
SoundEffect(String name, String newName, SoundCategory category) {
this.category = category;
this.newName = newName;
this.name = name;
this.breaksound = name.startsWith("dig.");
this.breakSound = name.startsWith("dig.");
}
SoundEffect(String name, String newname, SoundCategory cat, boolean shouldIgnore) {
this.category = cat;
this.newName = newname;
SoundEffect(String name, String newName, SoundCategory category, boolean shouldIgnore) {
this.category = category;
this.newName = newName;
this.name = name;
this.breaksound = name.startsWith("dig.") || shouldIgnore;
this.breakSound = name.startsWith("dig.") || shouldIgnore;
}
public static SoundEffect getByName(String name) {
name = name.toLowerCase(Locale.ROOT);
return effects.get(name);
}
@ -315,7 +314,7 @@ public enum SoundEffect {
return category;
}
public boolean isBreaksound() {
return breaksound;
public boolean isBreakSound() {
return breakSound;
}
}