feat: Add composter sound muffler
This commit is contained in:
65
src/main/kotlin/features/debug/SoundVisualizer.kt
Normal file
65
src/main/kotlin/features/debug/SoundVisualizer.kt
Normal file
@@ -0,0 +1,65 @@
|
||||
package moe.nea.firmament.features.debug
|
||||
|
||||
import net.minecraft.text.Text
|
||||
import moe.nea.firmament.annotations.Subscribe
|
||||
import moe.nea.firmament.commands.thenExecute
|
||||
import moe.nea.firmament.commands.thenLiteral
|
||||
import moe.nea.firmament.events.CommandEvent
|
||||
import moe.nea.firmament.events.SoundReceiveEvent
|
||||
import moe.nea.firmament.events.WorldReadyEvent
|
||||
import moe.nea.firmament.events.WorldRenderLastEvent
|
||||
import moe.nea.firmament.util.red
|
||||
import moe.nea.firmament.util.render.RenderInWorldContext
|
||||
|
||||
object SoundVisualizer {
|
||||
|
||||
var showSounds = false
|
||||
|
||||
var sounds = mutableListOf<SoundReceiveEvent>()
|
||||
|
||||
|
||||
@Subscribe
|
||||
fun onSubCommand(event: CommandEvent.SubCommand) {
|
||||
event.subcommand("dev") {
|
||||
thenLiteral("sounds") {
|
||||
thenExecute {
|
||||
showSounds = !showSounds
|
||||
if (!showSounds) {
|
||||
sounds.clear()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onWorldSwap(event: WorldReadyEvent) {
|
||||
sounds.clear()
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onRender(event: WorldRenderLastEvent) {
|
||||
RenderInWorldContext.renderInWorld(event) {
|
||||
sounds.forEach { event ->
|
||||
withFacingThePlayer(event.position) {
|
||||
text(
|
||||
Text.literal(event.sound.value().id.toString()).also {
|
||||
if (event.cancelled)
|
||||
it.red()
|
||||
},
|
||||
verticalAlign = RenderInWorldContext.VerticalAlign.CENTER,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onSoundReceive(event: SoundReceiveEvent) {
|
||||
if (!showSounds) return
|
||||
if (sounds.size > 1000) {
|
||||
sounds.subList(0, 200).clear()
|
||||
}
|
||||
sounds.add(event)
|
||||
}
|
||||
}
|
||||
32
src/main/kotlin/features/garden/HideComposterNoises.kt
Normal file
32
src/main/kotlin/features/garden/HideComposterNoises.kt
Normal file
@@ -0,0 +1,32 @@
|
||||
package moe.nea.firmament.features.garden
|
||||
|
||||
import net.minecraft.entity.passive.WolfSoundVariants
|
||||
import net.minecraft.sound.SoundEvent
|
||||
import net.minecraft.sound.SoundEvents
|
||||
import moe.nea.firmament.annotations.Subscribe
|
||||
import moe.nea.firmament.events.SoundReceiveEvent
|
||||
import moe.nea.firmament.gui.config.ManagedConfig
|
||||
import moe.nea.firmament.util.SBData
|
||||
import moe.nea.firmament.util.SkyBlockIsland
|
||||
|
||||
object HideComposterNoises {
|
||||
object TConfig : ManagedConfig("composter", Category.GARDEN) {
|
||||
val hideComposterNoises by toggle("no-more-noises") { false }
|
||||
}
|
||||
|
||||
val composterSoundEvents: List<SoundEvent> = listOf(
|
||||
SoundEvents.BLOCK_PISTON_EXTEND,
|
||||
SoundEvents.BLOCK_WATER_AMBIENT,
|
||||
SoundEvents.ENTITY_CHICKEN_EGG,
|
||||
SoundEvents.WOLF_SOUNDS[WolfSoundVariants.Type.CLASSIC]!!.growlSound().value(),
|
||||
)
|
||||
|
||||
@Subscribe
|
||||
fun onNoise(event: SoundReceiveEvent) {
|
||||
if (!TConfig.hideComposterNoises) return
|
||||
if (SBData.skyblockLocation == SkyBlockIsland.GARDEN) {
|
||||
if (event.sound.value() in composterSoundEvents)
|
||||
event.cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@ abstract class ManagedConfig(
|
||||
CHAT,
|
||||
INVENTORY,
|
||||
MINING,
|
||||
GARDEN,
|
||||
EVENTS,
|
||||
INTEGRATIONS,
|
||||
META,
|
||||
|
||||
Reference in New Issue
Block a user