feat: oven sounds

This commit is contained in:
whatsy committed 2026-11-24 16:41:26 -05:00
1 parent 9dcc92666e
commit d050058d69
35 files changed
+84 -42

No files matched your search

@@ -415,6 +415,14 @@ object CobblemonSounds : PlatformRegistry<Registry<SoundEvent>, ResourceKey<Regi
@JvmField
val MOWER_CUT = this.create("block.appliance.roto_mower_cut")
@JvmField
val OVEN_OPEN = this.create("block.appliance.roto_oven_open")
@JvmField
val OVEN_CLOSE = this.create("block.appliance.roto_oven_close")
@JvmField
val OVEN_EJECT = this.create("block.appliance.roto_oven_eject")
@JvmField
val OVEN_COOK = this.create("block.appliance.roto_oven_cook")
@JvmField
val WASHER_WASH = this.create("block.appliance.roto_washer_wash")
@JvmField
val FRIDGE_INPUT = this.create("block.appliance.roto_fridge_input")
@@ -9,12 +9,14 @@
package com.cobblemon.mod.common.block.appliances.oven
import com.cobblemon.mod.common.CobblemonBlockEntities
import com.cobblemon.mod.common.CobblemonSounds
import com.cobblemon.mod.common.block.appliances.WeatheringCopperAppliance
import com.cobblemon.mod.common.util.rotateShape
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.sounds.SoundSource
import net.minecraft.util.StringRepresentable
import net.minecraft.world.InteractionResult
import net.minecraft.world.entity.player.Player
@@ -118,8 +120,10 @@ open class CopperOvenBlock(settings: Properties) : BaseEntityBlock(settings), Si
if (player.isCrouching) {
if (cooking == CookingState.OPEN) {
level.setBlockAndUpdate(pos, state.setValue(COOKING, CookingState.CLOSED))
level.playSound(null, pos, CobblemonSounds.OVEN_CLOSE, SoundSource.BLOCKS)
} else {
level.setBlockAndUpdate(pos, state.setValue(COOKING, CookingState.OPEN))
level.playSound(null, pos, CobblemonSounds.OVEN_OPEN, SoundSource.BLOCKS)
}
} else {
openContainer(level, pos, player)
@@ -14,6 +14,8 @@ import com.cobblemon.mod.common.CobblemonSounds
import com.cobblemon.mod.common.api.cooking.Seasonings
import com.cobblemon.mod.common.block.appliances.oven.CopperOvenBlock.Companion.COOKING
import com.cobblemon.mod.common.block.appliances.oven.CopperOvenBlock.CookingState
import com.cobblemon.mod.common.client.sound.BlockEntitySoundTracker
import com.cobblemon.mod.common.client.sound.instances.CancellableSoundInstance
import com.cobblemon.mod.common.item.crafting.CookingPotRecipeBase
import com.cobblemon.mod.common.util.lang
import com.cobblemon.mod.common.util.playSoundServer
@@ -81,23 +83,26 @@ class CopperOvenBlockEntity(pos: BlockPos, state: BlockState) : BaseContainerBlo
const val IS_DOOR_OPEN_INDEX = 2
const val COOKING_POT_COLOR_INDEX = 3
const val DISABLED_SLOTS_INDEX = 4
val RUNNING_SOUND = CobblemonSounds.OVEN_COOK
fun clientTick(level: Level, pos: BlockPos, state: BlockState, ovenBlockEntity: CopperOvenBlockEntity) {
if (!level.isClientSide) return
val isCooking = state.getValue(CopperOvenBlock.COOKING) == CopperOvenBlock.CookingState.COOKING
// val isRunningSoundActive = BlockEntitySoundTracker.isActive(pos, campfireBlockEntity.runningSound.location)
val isCooking = state.getValue(COOKING) == CookingState.COOKING
val isRunningSoundActive = BlockEntitySoundTracker.isActive(pos, RUNNING_SOUND.location)
val containsItems = ovenBlockEntity.getSeasonings().isNotEmpty() || ovenBlockEntity.getIngredients().isNotEmpty()
// if (containsItems) {
// if (isCooking) {
//// if (!isRunningSoundActive) BlockEntitySoundTracker.play(pos, CancellableSoundInstance(campfireBlockEntity.runningSound, pos, true, 1.0f, 1.0f))
// } else {
//// BlockEntitySoundTracker.stop(pos, campfireBlockEntity.runningSound.location)
// }
// } else {
//// BlockEntitySoundTracker.stop(pos, campfireBlockEntity.runningSound.location)
// }
if (containsItems) {
if (isCooking) {
if (!isRunningSoundActive) BlockEntitySoundTracker.play(pos,
CancellableSoundInstance(RUNNING_SOUND, pos, true, 1.0f, 1.0f)
)
} else {
BlockEntitySoundTracker.stop(pos, RUNNING_SOUND.location)
}
} else {
BlockEntitySoundTracker.stop(pos, RUNNING_SOUND.location)
}
}
fun serverTick(level: Level, pos: BlockPos, state: BlockState, ovenBlockEntity: CopperOvenBlockEntity) {
@@ -128,11 +133,12 @@ class CopperOvenBlockEntity(pos: BlockPos, state: BlockState) : BaseContainerBlo
level.setBlockAndUpdate(pos, currentState)
}
} else if (powerFell) {
ovenBlockEntity.ejectDelay = EJECT_DELAY_TICKS
ovenBlockEntity.closeDelay = 0
val hasResult = !ovenBlockEntity.getItem(RESULT_SLOT).isEmpty
ovenBlockEntity.ejectDelay = if (hasResult) EJECT_DELAY_TICKS else NO_EJECT_PENDING
currentState = currentState
.setValue(COOKING, CookingState.CLOSED)
.setValue(CopperOvenBlock.EJECTING, true)
.setValue(CopperOvenBlock.EJECTING, hasResult)
level.setBlockAndUpdate(pos, currentState)
} else {
if (currentState.getValue(COOKING) == CookingState.COOKING) {
@@ -206,11 +212,6 @@ class CopperOvenBlockEntity(pos: BlockPos, state: BlockState) : BaseContainerBlo
ovenBlockEntity
)
level.playSoundServer(
position = pos.bottomCenter,
sound = CobblemonSounds.CAMPFIRE_POT_COOK,
)
hasChanged = true
}
}
@@ -218,14 +219,6 @@ class CopperOvenBlockEntity(pos: BlockPos, state: BlockState) : BaseContainerBlo
}
}
val isCookingNow = ovenBlockEntity.cookingProgress > 0
// if (isCookingBefore != isCookingNow) {
// hasChanged = true
// val newCookingState = if (isCookingNow) CopperOvenBlock.CookingState.COOKING else CopperOvenBlock.CookingState.CLOSED
// level.setBlock(pos, state.setValue(CopperOvenBlock.COOKING, newCookingState), 3)
// }
if (!powered && ovenBlockEntity.ejectDelay == 0 && ovenBlockEntity.getItem(RESULT_SLOT).isEmpty) {
ovenBlockEntity.ejectDelay = NO_EJECT_PENDING
ovenBlockEntity.setChanged()
@@ -268,7 +261,7 @@ class CopperOvenBlockEntity(pos: BlockPos, state: BlockState) : BaseContainerBlo
state: BlockState
) {
level.setBlockAndUpdate(pos, state.setValue(COOKING, CookingState.OPEN))
level.playSound(null, pos, SoundEvents.CHEST_OPEN, SoundSource.BLOCKS)
level.playSound(null, pos, CobblemonSounds.OVEN_OPEN, SoundSource.BLOCKS)
}
override fun onClose(
@@ -277,7 +270,7 @@ class CopperOvenBlockEntity(pos: BlockPos, state: BlockState) : BaseContainerBlo
state: BlockState
) {
level.setBlockAndUpdate(pos, state.setValue(COOKING, CookingState.CLOSED))
level.playSound(null, pos, SoundEvents.CHEST_CLOSE, SoundSource.BLOCKS)
level.playSound(null, pos, CobblemonSounds.OVEN_CLOSE, SoundSource.BLOCKS)
}
override fun openerCountChanged(
@@ -404,7 +397,7 @@ class CopperOvenBlockEntity(pos: BlockPos, state: BlockState) : BaseContainerBlo
container?.setChanged()
dispenseRemainders(level, pos, container, facing)
level.setBlockAndUpdate(pos, level.getBlockState(pos).setValue(CopperOvenBlock.EJECTING, true))
level.playSound(null, pos, SoundEvents.DISPENSER_DISPENSE, SoundSource.BLOCKS)
level.playSound(null, pos, CobblemonSounds.OVEN_EJECT, SoundSource.BLOCKS)
closeDelay = 10
onItemUpdate(level)
}
@@ -134,7 +134,7 @@ class CopperOvenScreen(
override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean {
val progressX = leftPos + 96
val progressY = topPos + 39
val progressY = topPos + 50
if (Cobblemon.implementation.isModInstalled("jei") &&
mouseX >= progressX && mouseX < progressX + COOK_PROGRESS_WIDTH &&
mouseY >= progressY && mouseY < progressY + COOK_PROGRESS_HEIGHT
@@ -2160,6 +2160,10 @@
"cobblemon.subtitle.block.fan.stop": "Copper Fan stops",
"cobblemon.subtitle.block.fan.blow": "Copper Fan blowing",
"cobblemon.subtitle.block.washer.wash": "Copper Washer washes",
"cobblemon.subtitle.block.oven.open": "Copper Oven opens",
"cobblemon.subtitle.block.oven.close": "Copper Oven closes",
"cobblemon.subtitle.block.oven.eject": "Copper Oven ejects items",
"cobblemon.subtitle.block.oven.cook": "Copper Oven cooks",
"cobblemon.subtitle.block.mower.cut": "Copper Mower revs",
"cobblemon.subtitle.block.fridge.input": "Copper Fridge receives item",
"cobblemon.subtitle.block.fridge.output": "Copper Fridge dispenses item",
@@ -1201,28 +1201,61 @@
"block.appliance.roto_fan_start": {
"subtitle": "cobblemon.subtitle.block.fan.start",
"sounds": [
{ "name": "cobblemon:block/appliance/roto_fan_start_1", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_fan_start_2", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_fan_start_3", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_fan_start_4", "volume": 0.7 }
{ "name": "cobblemon:block/appliance/roto_fan_start1", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_fan_start2", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_fan_start3", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_fan_start4", "volume": 0.7 }
]
},
"block.appliance.roto_fan_stop": {
"subtitle": "cobblemon.subtitle.block.fan.stop",
"sounds": [
{ "name": "cobblemon:block/appliance/roto_fan_stop_1", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_fan_stop_2", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_fan_stop_3", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_fan_stop_4", "volume": 0.7 }
{ "name": "cobblemon:block/appliance/roto_fan_stop1", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_fan_stop2", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_fan_stop3", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_fan_stop4", "volume": 0.7 }
]
},
"block.appliance.roto_oven_open": {
"subtitle": "cobblemon.subtitle.block.oven.open",
"sounds": [
{ "name": "cobblemon:block/appliance/roto_oven_open_1", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_oven_open_2", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_oven_open_3", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_oven_open_4", "volume": 0.7 }
]
},
"block.appliance.roto_oven_close": {
"subtitle": "cobblemon.subtitle.block.oven.close",
"sounds": [
{ "name": "cobblemon:block/appliance/roto_oven_close_1", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_oven_close_2", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_oven_close_3", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_oven_close_4", "volume": 0.7 }
]
},
"block.appliance.roto_oven_eject": {
"subtitle": "cobblemon.subtitle.block.oven.eject",
"sounds": [
{ "name": "cobblemon:block/appliance/roto_oven_eject_1", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_oven_eject_2", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_oven_eject_3", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_oven_eject_4", "volume": 0.7 }
]
},
"block.appliance.roto_oven_cook": {
"subtitle": "cobblemon.subtitle.block.oven.cook",
"sounds": [
{ "name": "cobblemon:block/appliance/roto_oven_cook", "volume": 0.7 }
]
},
"block.appliance.roto_washer_wash": {
"subtitle": "cobblemon.subtitle.block.washer.wash",
"sounds": [
{ "name": "cobblemon:block/appliance/roto_washer_wash_1", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_washer_wash_2", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_washer_wash_3", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_washer_wash_4", "volume": 0.7 }
{ "name": "cobblemon:block/appliance/roto_washer_wash1", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_washer_wash2", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_washer_wash3", "volume": 0.7 },
{ "name": "cobblemon:block/appliance/roto_washer_wash4", "volume": 0.7 }
]
},
"block.appliance.roto_fridge_input": {