Skip to content

Commit

Permalink
Fix codec nullability & change sendSound
Browse files Browse the repository at this point in the history
  • Loading branch information
senseiwells committed Mar 1, 2025
1 parent 9c77c5b commit f38b482
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ repositories {
}

dependencies {
include(modImplementation("net.casualchampionships:arcade:0.4.0-beta.20+1.21.4")!!)
include(modImplementation("net.casualchampionships:arcade:0.4.0-beta.21+1.21.4")!!)
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,33 +285,35 @@ public object PlayerUtils {
}

@JvmStatic
public fun ServerPlayer.sendSound(sound: Sound) {
this.sendSound(sound.event, sound.source, sound.volume, sound.pitch, sound.static)
public fun ServerPlayer.sendSound(sound: Sound, position: Vec3 = this.position()) {
this.sendSound(sound.event, sound.source, position, sound.volume, sound.pitch, sound.static)
}

@JvmStatic
@JvmOverloads
public fun ServerPlayer.sendSound(
sound: SoundEvent,
source: SoundSource = SoundSource.MASTER,
position: Vec3 = this.position(),
volume: Float = 1.0F,
pitch: Float = 1.0F,
static: Boolean = true
) {
this.sendSound(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(sound), source, volume, pitch, static)
this.sendSound(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(sound), source, position, volume, pitch, static)
}

@JvmStatic
@JvmOverloads
public fun ServerPlayer.sendSound(
sound: Holder<SoundEvent>,
source: SoundSource = SoundSource.MASTER,
position: Vec3 = this.position(),
volume: Float = 1.0F,
pitch: Float = 1.0F,
static: Boolean = true
) {
val packet = if (!static) {
ClientboundSoundPacket(sound, source, this.x, this.y, this.z, volume, pitch, this.random.nextLong())
ClientboundSoundPacket(sound, source, position.x, position.y, position.z, volume, pitch, this.random.nextLong())
} else {
ClientboundSoundEntityPacket(sound, source, this, volume, pitch, this.random.nextLong())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public object ArcadeExtraCodecs {
keyCodec: Codec<K>,
valueMapCodec: MapCodec<V>,
keyName: String = "id"
): Codec<Map<K, V>>? {
): Codec<Map<K, V>> {
val entryCodec = RecordCodecBuilder.create<Pair<K, V>> { instance ->
instance.group(
keyCodec.fieldOf(keyName).forGetter { it.first },
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
java
}

val modVersion = "0.4.0-beta.20"
val modVersion = "0.4.0-beta.21"

allprojects {
apply(plugin = "org.jetbrains.kotlin.jvm")
Expand Down

0 comments on commit f38b482

Please sign in to comment.