diff --git a/gradle.properties b/gradle.properties index 50b3005..9f39e4c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ group=com.mineinabyss version=0.10 -idofrontVersion=0.24.16 +idofrontVersion=0.25.3 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8293a17..fc85abd 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] -gearyPaper = "0.30.10-dev.9" -guiy="0.12.1" +gearyPaper = "0.30.14" +guiy="0.12.4-dev.1" [libraries] geary-papermc = { module = "com.mineinabyss:geary-papermc", version.ref = "gearyPaper" } diff --git a/src/main/kotlin/com/mineinabyss/blocky/BlockyDatapacks.kt b/src/main/kotlin/com/mineinabyss/blocky/BlockyDatapacks.kt index f5bdf44..2d2b20e 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/BlockyDatapacks.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/BlockyDatapacks.kt @@ -19,33 +19,29 @@ object BlockyDatapacks { } private fun writeMcMeta() { - runCatching { - val packMeta = blockyDatapack.resolve("pack.mcmeta") - packMeta.writeText(buildJsonObject { - putJsonObject("pack") { - put("description", "Datapack for Blocky") - put("pack_format", 26) - } - }.toString()) - }.onFailure { it.printStackTrace() } + val packMeta = blockyDatapack.resolve("pack.mcmeta") + packMeta.writeText(buildJsonObject { + putJsonObject("pack") { + put("description", "Datapack for Blocky") + put("pack_format", 26) + } + }.toString()) } private fun generateMineableTag() { - runCatching { - val tagFile = blockyDatapack.resolve("data/minecraft/tags/block/mineable/axe.json") - tagFile.parentFile.mkdirs() - tagFile.createNewFile() - - val tagObject = buildJsonObject { - put("replace", true) - putJsonArray("values") { - BuiltInRegistries.BLOCK.tags.toList().find { it.first == BlockTags.MINEABLE_WITH_AXE }?.second?.forEach { - if (it.registeredName != "minecraft:note_block") add(it.registeredName) - } + val tagFile = blockyDatapack.resolve("data/minecraft/tags/block/mineable/axe.json") + tagFile.parentFile.mkdirs() + tagFile.createNewFile() + + val tagObject = buildJsonObject { + put("replace", true) + putJsonArray("values") { + BuiltInRegistries.BLOCK.tags.toList().find { it.first == BlockTags.MINEABLE_WITH_AXE }?.second?.forEach { + if (it.registeredName != "minecraft:note_block") add(it.registeredName) } } + } - tagFile.writeText(tagObject.toString()) - }.onFailure { it.printStackTrace() } + tagFile.writeText(tagObject.toString()) } } \ No newline at end of file diff --git a/src/main/kotlin/com/mineinabyss/blocky/menus/BlockyNavigation.kt b/src/main/kotlin/com/mineinabyss/blocky/menus/BlockyNavigation.kt index f6fe7e4..a343d19 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/menus/BlockyNavigation.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/menus/BlockyNavigation.kt @@ -12,6 +12,7 @@ import com.mineinabyss.guiy.components.Item import com.mineinabyss.guiy.components.VerticalGrid import com.mineinabyss.guiy.components.canvases.Chest import com.mineinabyss.guiy.components.lists.NavbarPosition +import com.mineinabyss.guiy.components.lists.ScrollDirection import com.mineinabyss.guiy.components.lists.Scrollable import com.mineinabyss.guiy.inventory.LocalGuiyOwner import com.mineinabyss.guiy.modifiers.Modifier @@ -46,33 +47,34 @@ fun BlockyMainMenu(player: Player) { val owner = LocalGuiyOwner.current BlockyUIScope(player).apply { nav.withScreen(setOf(player), onEmpty = owner::exit) { screen -> - var title by remember(screen) { mutableStateOf(screen.handleTitle(0)) } + val items = remember(screen) { + when (screen) { + is BlockyScreen.Block -> blockPrefabs + is BlockyScreen.Wire -> plantPrefabs + is BlockyScreen.Furniture -> furniturePrefabs + else -> return@remember emptyList() + }.sortedBy { it.prefabKey.full }.map { gearyItems.createItem(it.prefabKey) } + } + val hasMultiplePages by remember(screen) { mutableStateOf(items.size.toDouble().div(9 * 5) > 1) } + var title by remember(screen) { mutableStateOf(handleTitle(screen, 0, hasMultiplePages)) } + var line by remember(screen) { mutableStateOf(0) } + Chest(setOf(player), title, Modifier.height(screen.height), onClose = { owner.exit() }) { when (screen) { is BlockyScreen.Default -> BlockyMenu() else -> { - var line by remember(screen) { mutableStateOf(0) } - val items = remember(screen) { - when (screen) { - is BlockyScreen.Block -> blockPrefabs - is BlockyScreen.Wire -> plantPrefabs - is BlockyScreen.Furniture -> furniturePrefabs - else -> return@remember emptyList() - }.sortedBy { it.prefabKey.full }.map { gearyItems.createItem(it.prefabKey) } - } - Scrollable( - items, line, 8, 5, - nextButton = { ScrollDownButton(Modifier.at(0, 3).clickable { line++; title = screen.handleTitle(line) }) }, - previousButton = { ScrollUpButton(Modifier.at(0, 1).clickable { line--; title = screen.handleTitle(line) }) }, - NavbarPosition.START, null + items, line, ScrollDirection.VERTICAL, + nextButton = { ScrollDownButton(Modifier.at(5, 0).clickable { line++; title = handleTitle(screen, line, hasMultiplePages) }) }, + previousButton = { ScrollUpButton(Modifier.at(2, 0).clickable { line--; title = handleTitle(screen, line, hasMultiplePages) }) }, + NavbarPosition.BOTTOM, null ) { pageItems -> - VerticalGrid(Modifier.size(8, 5)) { + VerticalGrid(Modifier.size(9, 5)) { pageItems.forEach { CreativeItem(it) } } } - BackButton(Modifier.at(0, 5)) + BackButton(Modifier.at(8, 5)) } } } @@ -80,11 +82,12 @@ fun BlockyMainMenu(player: Player) { } } -private fun BlockyScreen.handleTitle(page: Int): Component { - if (this is BlockyScreen.Default) return title - return Component.textOfChildren(title, buildString { - append(":space_-26:") - if (page > 0) append(":blocky_scrolling_up::space_-18:") +private fun handleTitle(screen: BlockyScreen, page: Int, hasMultiplePages: Boolean): Component { + if (screen is BlockyScreen.Default) return screen.title + return Component.textOfChildren(screen.title, buildString { + if (!hasMultiplePages) return@buildString + if (page > 0) append(":space_-132::blocky_scrolling_up::space_36:") + else append(":space_-80:") append(":blocky_scrolling_down:") }.miniMsg()) } @@ -93,7 +96,7 @@ private fun BlockyScreen.handleTitle(page: Int): Component { fun ScrollDownButton(modifier: Modifier = Modifier) { Item(ItemStack(Material.PAPER).editItemMeta { itemName("Scroll Down".miniMsg()) - setCustomModelData(0) + setCustomModelData(1) }, modifier) } @@ -101,8 +104,7 @@ fun ScrollDownButton(modifier: Modifier = Modifier) { fun ScrollUpButton(modifier: Modifier = Modifier) { Item(ItemStack(Material.PAPER).editItemMeta { itemName("Scroll Up".miniMsg()) - isHideTooltip = true - setCustomModelData(0) + setCustomModelData(1) }, modifier) } @@ -111,7 +113,7 @@ fun BlockyUIScope.BackButton(modifier: Modifier = Modifier, onClick: () -> Unit Button(onClick = onClick, modifier = modifier) { Item(ItemStack(Material.PAPER).editItemMeta { itemName("Back".miniMsg()) - setCustomModelData(0) + setCustomModelData(1) }) } }