Skip to content

Commit

Permalink
Merge pull request #112 from jpenilla/412
Browse files Browse the repository at this point in the history
Bump adventure to 4.12 and use sound seed when present
  • Loading branch information
lucko committed Nov 30, 2022
2 parents 95303b2 + a6ba429 commit 62e8edf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -12,7 +12,7 @@ plugins {
}

// Adventure version
ext.adventure = "4.11.0"
ext.adventure = "4.12.0"

group 'net.kyori'
version '4.1.3-SNAPSHOT'
Expand Down
Expand Up @@ -549,11 +549,12 @@ private Object createForEntity(final net.kyori.adventure.sound.Sound sound, fina
if (soundCategory == null) return null;
final Object nameRl = NEW_RESOURCE_LOCATION.invoke(sound.name().namespace(), sound.name().value());
final java.util.Optional<?> event = (Optional<?>) REGISTRY_GET_OPTIONAL.invoke(REGISTRY_SOUND_EVENT, nameRl);
final long seed = sound.seed().orElseGet(() -> ThreadLocalRandom.current().nextLong());
if (event.isPresent()) {
return NEW_CLIENTBOUND_ENTITY_SOUND.invoke(event.get(), soundCategory, nmsEntity, sound.volume(), sound.pitch(), ThreadLocalRandom.current().nextLong() /* TODO replace with sound seed when 4.12.X releases */);
return NEW_CLIENTBOUND_ENTITY_SOUND.invoke(event.get(), soundCategory, nmsEntity, sound.volume(), sound.pitch(), seed);
} else if (NEW_CLIENTBOUND_CUSTOM_SOUND != null && NEW_VEC3 != null) {
final Location loc = entity.getLocation();
return NEW_CLIENTBOUND_CUSTOM_SOUND.invoke(nameRl, soundCategory, NEW_VEC3.invoke(loc.getX(), loc.getY(), loc.getZ()), sound.volume(), sound.pitch(), ThreadLocalRandom.current().nextLong() /* TODO replace with sound seed when 4.12.X releases */);
return NEW_CLIENTBOUND_CUSTOM_SOUND.invoke(nameRl, soundCategory, NEW_VEC3.invoke(loc.getX(), loc.getY(), loc.getZ()), sound.volume(), sound.pitch(), seed);
}
} catch (final Throwable error) {
logError(error, "Failed to send sound tracking an entity");
Expand Down

0 comments on commit 62e8edf

Please sign in to comment.