diff --git a/src/main/kotlin/com/mineinabyss/blocky/assets_generation/ResourcepackGeneration.kt b/src/main/kotlin/com/mineinabyss/blocky/assets_generation/ResourcepackGeneration.kt index 55aad95..26842fa 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/assets_generation/ResourcepackGeneration.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/assets_generation/ResourcepackGeneration.kt @@ -187,12 +187,12 @@ object ResourcepackGeneration { .parent(Key.key(parent)).key(Key.key("blocky:block/${material.name.lowercase()}$suffix")) .build() - resourcePack.model(model) + model.addTo(resourcePack) } fun handleBlockState(blockType: SetBlock.BlockType, material: Material, index: Int) { blockPrefabs.find { it.block.blockType == blockType && it.block.blockId == index + 1 } ?: return - resourcePack.blockState(VanillaBlockstateFiles.vanillaBlockStateFile(blockType, material) ?: return) + VanillaBlockstateFiles.vanillaBlockStateFile(blockType, material)?.addTo(resourcePack) } CopperHelpers.BLOCKY_STAIRS.forEachIndexed { index, material -> @@ -206,6 +206,7 @@ object ResourcepackGeneration { handleBlockState(SetBlock.BlockType.SLAB, material, index) handleModel(SetBlock.BlockType.SLAB, material, index, "block/slab", "") handleModel(SetBlock.BlockType.SLAB, material, index, "block/slab_top", "_top") + handleModel(SetBlock.BlockType.SLAB, material, index, "block/cube_all", "") } CopperHelpers.BLOCKY_DOORS.forEachIndexed { index, material -> diff --git a/src/main/kotlin/com/mineinabyss/blocky/helpers/CopperHelpers.kt b/src/main/kotlin/com/mineinabyss/blocky/helpers/CopperHelpers.kt index cb4e23f..b32bd04 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/helpers/CopperHelpers.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/helpers/CopperHelpers.kt @@ -78,33 +78,15 @@ object CopperHelpers { Material.WEATHERED_COPPER_DOOR, Material.WEATHERED_COPPER_TRAPDOOR, Material.WEATHERED_COPPER_GRATE ) - val BLOCKY_SLABS: Set - get() = BLOCKY_COPPER.filter { it.name.endsWith("_SLAB") }.toSet() - - val BLOCKY_STAIRS: Set - get() = BLOCKY_COPPER.filter { it.name.endsWith("_STAIRS") }.toSet() - - val BLOCKY_DOORS: Set - get() = BLOCKY_COPPER.filter { it.name.endsWith("_DOOR") }.toSet() - - val BLOCKY_TRAPDOORS: Set - get() = BLOCKY_COPPER.filter { it.name.endsWith("_TRAPDOOR") }.toSet() - - val BLOCKY_GRATE: Set - get() = BLOCKY_COPPER.filter { it.name.endsWith("_GRATE") }.toSet() - - val COPPER_SLABS: Set - get() = VANILLA_COPPER.filter { it.name.endsWith("_SLAB") }.toSet() - - val COPPER_STAIRS: Set - get() = VANILLA_COPPER.filter { it.name.endsWith("_STAIRS") }.toSet() - - val COPPER_DOORS: Set - get() = VANILLA_COPPER.filter { it.name.endsWith("_DOOR") }.toSet() - - val COPPER_TRAPDOORS: Set - get() = VANILLA_COPPER.filter { it.name.endsWith("_TRAPDOOR") }.toSet() - - val COPPER_GRATE: Set - get() = VANILLA_COPPER.filter { it.name.endsWith("_GRATE") }.toSet() + val BLOCKY_SLABS = BLOCKY_COPPER.filter { it.name.endsWith("_SLAB") }.toSet() + val BLOCKY_STAIRS = BLOCKY_COPPER.filter { it.name.endsWith("_STAIRS") }.toSet() + val BLOCKY_DOORS = BLOCKY_COPPER.filter { it.name.endsWith("_DOOR") }.toSet() + val BLOCKY_TRAPDOORS = BLOCKY_COPPER.filter { it.name.endsWith("_TRAPDOOR") }.toSet() + val BLOCKY_GRATE = BLOCKY_COPPER.filter { it.name.endsWith("_GRATE") }.toSet() + + val COPPER_SLABS = VANILLA_COPPER.filter { it.name.endsWith("_SLAB") }.toSet() + val COPPER_STAIRS = VANILLA_COPPER.filter { it.name.endsWith("_STAIRS") }.toSet() + val COPPER_DOORS = VANILLA_COPPER.filter { it.name.endsWith("_DOOR") }.toSet() + val COPPER_TRAPDOORS = VANILLA_COPPER.filter { it.name.endsWith("_TRAPDOOR") }.toSet() + val COPPER_GRATE = VANILLA_COPPER.filter { it.name.endsWith("_GRATE") }.toSet() } diff --git a/src/main/kotlin/com/mineinabyss/blocky/listeners/BlockySoundListener.kt b/src/main/kotlin/com/mineinabyss/blocky/listeners/BlockySoundListener.kt index c60af4c..3bda1be 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/listeners/BlockySoundListener.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/listeners/BlockySoundListener.kt @@ -91,11 +91,14 @@ class BlockySoundListener : Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) fun PlayerInteractEvent.onOpenCloseDoor() { if (action != Action.RIGHT_CLICK_BLOCK || useInteractedBlock() == Event.Result.DENY) return - val block = clickedBlock?.takeIf { (it.type in CopperHelpers.BLOCKY_DOORS || it.type !in CopperHelpers.BLOCKY_TRAPDOORS) } ?: return - val type = if (block.blockData is Door) "_door_" else if (block.blockData is TrapDoor) "_trapdoor_" else return + val block = clickedBlock?.takeIf(CopperHelpers::isBlockyDoor)?.takeIf(CopperHelpers::isBlockyTrapDoor) ?: return val opening = !(block.blockData as Openable).isOpen - val suffix = if (opening) "open" else "close" - val sound = block.toGearyOrNull()?.get()?.let { if (opening) it.openSound else it.closeSound } ?: ("blocky:copper_$type$suffix") + val suffix = when (block.blockData) { + is Door -> "_door_" + is TrapDoor -> "_trapdoor_" + else -> return + }.plus(if (opening) "open" else "close") + val sound = block.toGearyOrNull()?.get()?.let { if (opening) it.openSound else it.closeSound } ?: ("blocky:copper_$suffix") block.world.playSound(block.location, sound, SoundCategory.BLOCKS, DEFAULT_HIT_VOLUME, DEFAULT_HIT_PITCH) }