fix block place sounds in 1.14.2

This commit is contained in:
Gerrygames 2019-06-07 15:04:16 +02:00
parent b1cef12f46
commit 7ae66a27e4
2 changed files with 16 additions and 7 deletions

View File

@ -6,7 +6,7 @@
<groupId>de.gerrygames</groupId>
<artifactId>viarewind-legacy-support</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>jar</packaging>
<properties>
@ -42,7 +42,7 @@
<dependency>
<groupId>us.myles</groupId>
<artifactId>viaversion</artifactId>
<version>1.3.0</version>
<version>2.1.1</version>
<scope>provided</scope>
</dependency>
@ -67,5 +67,4 @@
</resource>
</resources>
</build>
</project>

View File

@ -101,16 +101,26 @@ public class SoundListener implements Listener {
Object nmsBlock = getBlock.invoke(blockData);
Method getStepSound;
try {
getStepSound = nmsBlock.getClass().getMethod("getStepSound");
getStepSound = nmsBlock.getClass().getMethod("getStepSound", blockData.getClass());
} catch (NoSuchMethodException ex) {
getStepSound = nmsBlock.getClass().getMethod("w");
try {
getStepSound = nmsBlock.getClass().getMethod("getStepSound");
} catch (NoSuchMethodError ex2) {
getStepSound = nmsBlock.getClass().getMethod("w");
}
}
Object soundType;
if (getStepSound.getParameterCount() == 0) {
soundType = getStepSound.invoke(nmsBlock);
} else {
soundType = getStepSound.invoke(nmsBlock, blockData);
}
Object soundType = getStepSound.invoke(nmsBlock);
Object soundEffect = soundType.getClass().getMethod("e").invoke(soundType);
float volume = (float) soundType.getClass().getMethod("a").invoke(soundType);
float pitch = (float) soundType.getClass().getMethod("b").invoke(soundType);
Object soundCategory = Enum.class.getMethod("valueOf", Class.class, String.class).invoke(null, NMSReflection.getNMSClass("SoundCategory"), "BLOCKS");
Object soundCategory = Enum.valueOf(NMSReflection.getNMSClass("SoundCategory"), "BLOCKS");
volume = (volume + 1.0f) / 2.0f;
pitch *= 0.8;