mirror of
https://gitlab.bixilon.de/bixilon/pixlyzer.git
synced 2025-09-29 23:21:04 -04:00
sound groups
This commit is contained in:
parent
823191c3c0
commit
196ae226b3
@ -11,6 +11,7 @@ import de.bixilon.pixlyzer.generator.generators.variants.FrogVariantGenerator
|
|||||||
object Generators {
|
object Generators {
|
||||||
val GENERATORS: List<Generator> = mutableListOf(
|
val GENERATORS: List<Generator> = mutableListOf(
|
||||||
ArgumentTypeGenerator,
|
ArgumentTypeGenerator,
|
||||||
|
SoundGroupGenerator,
|
||||||
CatVariantGenerator,
|
CatVariantGenerator,
|
||||||
FrogVariantGenerator,
|
FrogVariantGenerator,
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ object BlockGenerator : Generator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
blockData["class"] = block::class.java.realName
|
blockData["class"] = block::class.java.realName
|
||||||
|
blockData["sound_group"] = SoundGroupGenerator.getId(block.soundGroup)
|
||||||
|
|
||||||
if (block is FluidBlock) {
|
if (block is FluidBlock) {
|
||||||
(FLUID_BLOCK_FLUID_FIELD.get(block) as Fluid).let {
|
(FLUID_BLOCK_FLUID_FIELD.get(block) as Fluid).let {
|
||||||
@ -144,14 +145,6 @@ object BlockGenerator : Generator(
|
|||||||
if (state.hasSidedTransparency()) {
|
if (state.hasSidedTransparency()) {
|
||||||
stateData["has_side_transparency"] = state.hasSidedTransparency()
|
stateData["has_side_transparency"] = state.hasSidedTransparency()
|
||||||
}
|
}
|
||||||
stateData["sound_type_volume"] = state.soundGroup.volume
|
|
||||||
stateData["sound_type_pitch"] = state.soundGroup.pitch
|
|
||||||
stateData["break_sound_type"] = Registry.SOUND_EVENT.getRawId(state.soundGroup.breakSound)
|
|
||||||
stateData["step_sound_type"] = Registry.SOUND_EVENT.getRawId(state.soundGroup.stepSound)
|
|
||||||
stateData["place_sound_type"] = Registry.SOUND_EVENT.getRawId(state.soundGroup.placeSound)
|
|
||||||
stateData["hit_sound_type"] = Registry.SOUND_EVENT.getRawId(state.soundGroup.hitSound)
|
|
||||||
stateData["fall_sound_type"] = Registry.SOUND_EVENT.getRawId(state.soundGroup.fallSound)
|
|
||||||
|
|
||||||
|
|
||||||
REQUIRES_CORRECT_TOOL_FOR_DROP_FIELDS?.let {
|
REQUIRES_CORRECT_TOOL_FOR_DROP_FIELDS?.let {
|
||||||
stateData["requires_tool"] = it.getBoolean(state)
|
stateData["requires_tool"] = it.getBoolean(state)
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
package de.bixilon.pixlyzer.generator.generators
|
||||||
|
|
||||||
|
import de.bixilon.pixlyzer.generator.Generator
|
||||||
|
import de.bixilon.pixlyzer.util.ReflectionUtil.getClass
|
||||||
|
import de.bixilon.pixlyzer.util.Util.compound
|
||||||
|
import net.minecraft.sound.BlockSoundGroup
|
||||||
|
import net.minecraft.util.registry.Registry
|
||||||
|
import java.lang.reflect.Modifier
|
||||||
|
|
||||||
|
object SoundGroupGenerator : Generator(
|
||||||
|
"sound_groups",
|
||||||
|
) {
|
||||||
|
private val SOUND_GROUP_CLASS = getClass("net.minecraft.sound.BlockSoundGroup")
|
||||||
|
private var ids: MutableMap<BlockSoundGroup, Int> = mutableMapOf()
|
||||||
|
|
||||||
|
override fun generate() {
|
||||||
|
val fields = SOUND_GROUP_CLASS?.fields ?: return
|
||||||
|
for (field in fields) {
|
||||||
|
if (!Modifier.isStatic(field.modifiers)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
val data = compound()
|
||||||
|
val group = field.get(null) as BlockSoundGroup
|
||||||
|
val id = ids.size
|
||||||
|
ids[group] = id
|
||||||
|
|
||||||
|
if (group.volume != 1.0f) {
|
||||||
|
data["sound_type_volume"] = group.volume
|
||||||
|
}
|
||||||
|
if (group.volume != 1.0f) {
|
||||||
|
data["sound_type_pitch"] = group.pitch
|
||||||
|
}
|
||||||
|
data["break_sound_type"] = Registry.SOUND_EVENT.getRawId(group.breakSound)
|
||||||
|
data["step_sound_type"] = Registry.SOUND_EVENT.getRawId(group.stepSound)
|
||||||
|
data["place_sound_type"] = Registry.SOUND_EVENT.getRawId(group.placeSound)
|
||||||
|
data["hit_sound_type"] = Registry.SOUND_EVENT.getRawId(group.hitSound)
|
||||||
|
data["fall_sound_type"] = Registry.SOUND_EVENT.getRawId(group.fallSound)
|
||||||
|
|
||||||
|
this.data[id] = data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun getId(sound: BlockSoundGroup): Int {
|
||||||
|
return ids[sound]!!
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user