From fb28750f71fc14f8486e991ae20b662d310d87fe Mon Sep 17 00:00:00 2001 From: Rafa <32463720+Rafacasari@users.noreply.github.com> Date: Tue, 25 Jun 2024 03:12:13 -0300 Subject: [PATCH] 1.0.25 (Public Test) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added Collection GUI! Added new icons for evolution requirements Added missing translations Added new item tooltip for Cobbledex Item Planned: General code optimization Implement server-side options to choose gameplay style (Disable Pokémon info without seeing/catching it before, etc.) Add missing things on Collection GUI --- .../com/rafacasari/mod/cobbledex/Cobbledex.kt | 6 + .../client/gui/CobbledexCollectionGUI.kt | 214 +++++++++++++++--- .../mod/cobbledex/client/gui/CobbledexGUI.kt | 23 +- .../cobbledex/client/widget/ModelWidget.kt | 77 +++++++ .../mod/cobbledex/items/CobbledexItem.kt | 91 +++++--- .../SerializableEvolutionRequirement.kt | 4 +- .../template/SerializablePokemonEvolution.kt | 6 +- .../assets/cobbledex/lang/en_us.json | 7 +- .../gui/collection/type_spacer_unknown.png | Bin 0 -> 230 bytes .../textures/gui/icons/friendship.png | Bin 257 -> 421 bytes .../cobbledex/textures/gui/icons/level_up.png | Bin 286 -> 394 bytes .../cobbledex/textures/gui/icons/trade.png | Bin 0 -> 502 bytes gradle.properties | 2 +- 13 files changed, 354 insertions(+), 76 deletions(-) create mode 100644 common/src/main/kotlin/com/rafacasari/mod/cobbledex/client/widget/ModelWidget.kt create mode 100644 common/src/main/resources/assets/cobbledex/textures/gui/collection/type_spacer_unknown.png create mode 100644 common/src/main/resources/assets/cobbledex/textures/gui/icons/trade.png diff --git a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/Cobbledex.kt b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/Cobbledex.kt index 4d6d849..2aa9880 100644 --- a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/Cobbledex.kt +++ b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/Cobbledex.kt @@ -11,6 +11,7 @@ import com.cobblemon.mod.common.platform.events.PlatformEvents import com.cobblemon.mod.common.platform.events.ServerPlayerEvent import com.cobblemon.mod.common.pokemon.FormData import com.rafacasari.mod.cobbledex.client.gui.CobbledexCollectionGUI +import com.rafacasari.mod.cobbledex.client.gui.CobbledexGUI import net.minecraft.entity.player.PlayerEntity import net.minecraft.item.ItemStack import net.minecraft.util.ActionResult @@ -81,6 +82,11 @@ object Cobbledex { CobbledexCollectionGUI.discoveredList = null } + PlatformEvents.CLIENT_PLAYER_LOGIN.subscribe { + CobbledexGUI.onServerJoin() + CobbledexCollectionGUI.needReload = true + } + PlatformEvents.SERVER_PLAYER_LOGIN.subscribe { login: ServerPlayerEvent.Login -> val playerData = CobblemonPlayerData.get(login.player) diff --git a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/client/gui/CobbledexCollectionGUI.kt b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/client/gui/CobbledexCollectionGUI.kt index f6b8a11..81c1ff6 100644 --- a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/client/gui/CobbledexCollectionGUI.kt +++ b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/client/gui/CobbledexCollectionGUI.kt @@ -1,14 +1,23 @@ package com.rafacasari.mod.cobbledex.client.gui +import com.cobblemon.mod.common.CobblemonSounds import com.cobblemon.mod.common.api.gui.blitk import com.cobblemon.mod.common.api.pokemon.PokemonSpecies import com.cobblemon.mod.common.api.text.bold import com.cobblemon.mod.common.api.text.text import com.cobblemon.mod.common.client.CobblemonResources +import com.cobblemon.mod.common.client.gui.ExitButton +import com.cobblemon.mod.common.client.gui.TypeIcon import com.cobblemon.mod.common.client.gui.drawProfilePokemon import com.cobblemon.mod.common.client.render.drawScaledText +import com.cobblemon.mod.common.pokemon.RenderablePokemon +import com.cobblemon.mod.common.pokemon.Species import com.cobblemon.mod.common.util.math.fromEulerXYZDegrees +import com.rafacasari.mod.cobbledex.client.gui.CobbledexGUI.Companion.SCALE +import com.rafacasari.mod.cobbledex.client.gui.CobbledexGUI.Companion.TYPE_SPACER +import com.rafacasari.mod.cobbledex.client.gui.CobbledexGUI.Companion.TYPE_SPACER_DOUBLE import com.rafacasari.mod.cobbledex.client.widget.ImageButton +import com.rafacasari.mod.cobbledex.client.widget.SilhouetteModelWidget import com.rafacasari.mod.cobbledex.utils.CobblemonUtils.drawBlackSilhouettePokemon import com.rafacasari.mod.cobbledex.utils.cobbledexResource import com.rafacasari.mod.cobbledex.utils.cobbledexTextTranslation @@ -32,12 +41,18 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) { const val LINES_SIZE = 6 const val COLUMN_SIZE = 11 - const val AREA_WIDTH = 259f - const val AREA_HEIGHT = 145f + private const val AREA_WIDTH = 259f + private const val AREA_HEIGHT = 145f + private const val PADDING = 0.5 + + val ENTRY_SIZE = minOf(AREA_WIDTH / (COLUMN_SIZE + PADDING), AREA_HEIGHT / (LINES_SIZE + PADDING)) + val X_PADDING = (AREA_WIDTH - ENTRY_SIZE * COLUMN_SIZE) / (COLUMN_SIZE - 1) + val Y_PADDING = (AREA_HEIGHT - ENTRY_SIZE * LINES_SIZE) / (LINES_SIZE - 1) private val MAIN_BACKGROUND: Identifier = cobbledexResource("textures/gui/collection/collection_base.png") private val PORTRAIT_BACKGROUND: Identifier = cobbledexResource("textures/gui/collection/portrait_background.png") private val ENTRY_BACKGROUND: Identifier = cobbledexResource("textures/gui/collection/entry_background.png") + private val TYPE_SPACER_UNKNOWN: Identifier = cobbledexResource("textures/gui/collection/type_spacer_unknown.png") private val DOUBLE_LEFT_ARROW: Identifier = cobbledexResource("textures/gui/collection/double_left_arrow.png") private val DOUBLE_RIGHT_ARROW: Identifier = cobbledexResource("textures/gui/collection/double_right_arrow.png") @@ -45,6 +60,8 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) { private val RIGHT_ARROW: Identifier = cobbledexResource("textures/gui/collection/right_arrow.png") fun show() { + playSound(CobblemonSounds.PC_ON) + val instance = CobbledexCollectionGUI() MinecraftClient.getInstance().setScreen(instance) } @@ -56,18 +73,38 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) { private var currentPage = 1 private var maxPages = 1 - val implementedSpecies by lazy { - return@lazy PokemonSpecies.implemented.toSortedSet(compareBy { - it.nationalPokedexNumber - }).toList() - } + internal var needReload = true + private var implementedSpeciesInternal: List? = null + + var lastHoveredEntry: Species? = null + val implementedSpecies: List + get() { + if (needReload) + { + currentPage = 1 + lastHoveredEntry = null + implementedSpeciesInternal = PokemonSpecies.implemented.toSortedSet(compareBy { + it.nationalPokedexNumber + }).toList() + + needReload = false + } + + return implementedSpeciesInternal ?: listOf() + } } + + private var modelWidget: SilhouetteModelWidget? = null + private var typeWidget: TypeIcon? = null + override fun init() { val x = (width - CobbledexGUI.BASE_WIDTH) / 2 val y = (height - CobbledexGUI.BASE_HEIGHT) / 2 + this.addDrawableChild(ExitButton(pX = x + 313, pY = y + 175) { this.close() }) + addDrawableChild(ImageButton(DOUBLE_LEFT_ARROW, 14, 11, x + 131, y + 175) { currentPage = 1 }) @@ -91,6 +128,8 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) { val totalItems = (COLUMN_SIZE * LINES_SIZE) // Get total items maxPages = (implementedSpecies.size + totalItems - 1) / totalItems + + loadSpecies(lastHoveredEntry, if (lastHoveredEntry != null) discoveredList?.contains(lastHoveredEntry!!.nationalPokedexNumber) == true else false) } override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { @@ -109,6 +148,8 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) { height = PORTRAIT_SIZE ) + modelWidget?.render(context, mouseX, mouseY, delta) + blitk( matrixStack = matrices, texture = MAIN_BACKGROUND, @@ -139,12 +180,44 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) { scale = 1.5F ) - val padding = 0.5 - val minWidth = AREA_WIDTH / (COLUMN_SIZE + padding) - val minHeight = AREA_HEIGHT / (LINES_SIZE + padding) - val minSize = minOf(minWidth, minHeight) - val horizontalPadding = (AREA_WIDTH - minSize * COLUMN_SIZE) / (COLUMN_SIZE - 1) - val verticalPadding = (AREA_HEIGHT - minSize * LINES_SIZE) / (LINES_SIZE - 1) + lastHoveredEntry?.let { hoveredEntry -> + val isDiscovered = discoveredList?.contains(hoveredEntry.nationalPokedexNumber) == true + drawScaledText( + context = context, + font = CobblemonResources.DEFAULT_LARGE, + text = if (isDiscovered) hoveredEntry.translatedName.bold() else "???".text().bold(), + x = x + 13, + y = y + 28.3F, + shadow = false + ) + + if (isDiscovered) { + blitk( + matrixStack = matrices, + texture = if (hoveredEntry.secondaryType == null) TYPE_SPACER else TYPE_SPACER_DOUBLE, + x = (x + 5.5 + 3) / SCALE, + y = (y + 100 + 14) / SCALE, + width = 134, + height = 24, + scale = SCALE + ) + + typeWidget?.render(context) + } + else + blitk( + matrixStack = matrices, + texture = TYPE_SPACER_UNKNOWN, + x = (x + 5.5 + 3) / SCALE, + y = (y + 100 + 14) / SCALE, + width = 134, + height = 24, + scale = SCALE + ) + + + } + var currentIndex = 1 val linesSize = LINES_SIZE - 1 @@ -152,8 +225,8 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) { for (currentY: Int in 0..linesSize) { for (currentX in 0..columnsSize) { val currentPokemonIndex = COLUMN_SIZE * LINES_SIZE * (currentPage - 1) + (currentIndex - 1) - val entryX = x + (83.5F + (minSize * currentX) + (horizontalPadding * currentX)) - val entryY = y + (24.5F + (minSize * currentY) + (verticalPadding * currentY)) + val entryX = x + (83.5F + (ENTRY_SIZE * currentX) + (X_PADDING * currentX)) + val entryY = y + (24.5F + (ENTRY_SIZE * currentY) + (Y_PADDING * currentY)) val species = if(implementedSpecies.size > currentPokemonIndex) implementedSpecies[currentPokemonIndex] else null @@ -163,25 +236,25 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) { matrixStack = matrices, texture = ENTRY_BACKGROUND, x = entryX, y = entryY, - width = minSize, - height = minSize + width = ENTRY_SIZE, + height = ENTRY_SIZE ) context.enableScissor( entryX.toInt(), entryY.toInt(), - entryX.toInt() + minSize.toInt(), - entryY.toInt() + minSize.toInt() + entryX.toInt() + ENTRY_SIZE.toInt(), + entryY.toInt() + ENTRY_SIZE.toInt() ) matrices.push() - matrices.translate(entryX + (minSize / 2.0), entryY, 0.0) + matrices.translate(entryX + (ENTRY_SIZE / 2.0), entryY, 0.0) val rotation = Quaternionf().fromEulerXYZDegrees(Vector3f(10f, 35f, 0F)) - - if (discoveredList?.contains(species.nationalPokedexNumber) == true) { + val isDiscovered = discoveredList?.contains(species.nationalPokedexNumber) == true + if (isDiscovered) { drawProfilePokemon( species = species.resourceIdentifier, aspects = species.standardForm.aspects.toSet(), @@ -189,7 +262,7 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) { rotation = rotation, state = null, partialTicks = delta, - scale = (minSize / 2).toFloat() + scale = (ENTRY_SIZE / 2).toFloat() ) } else { @@ -198,7 +271,7 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) { aspects = species.standardForm.aspects.toSet(), matrixStack = matrices, rotation = rotation, - scale = (minSize / 2).toFloat() + scale = (ENTRY_SIZE / 2).toFloat() ) } matrices.pop() @@ -207,15 +280,19 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) { drawScaledText( context = context, - font = CobblemonResources.DEFAULT_LARGE, - text = "#${species.nationalPokedexNumber}".text().bold(), - x = entryX + 1.5f, - y = entryY + 0.5f, + text = "${species.nationalPokedexNumber}".text(), + x = entryX + 1.5, + y = entryY + 1.5, shadow = false, - centered = false, - scale = 0.5F, opacity = 0.5f + scale = SCALE, opacity = 0.3 ) + + if (lastHoveredEntry != species && mouseX.toDouble() in entryX .. (entryX + ENTRY_SIZE) && mouseY.toDouble() in entryY .. (entryY + ENTRY_SIZE)) { + lastHoveredEntry = species + loadSpecies(species, isDiscovered) + } + } currentIndex++ @@ -225,4 +302,81 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) { super.render(context, mouseX, mouseY, delta) } + + override fun shouldPause() = false + + override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean { + val entry = getMouseEntry(mouseX, mouseY) + if (entry != -1) + { + val species = if(implementedSpecies.size > entry) implementedSpecies[entry] else null + if (species != null) { + close() + playSound(CobblemonSounds.PC_CLICK) + CobbledexGUI.openCobbledexScreen(species.standardForm, setOf(), true) + return true + } + } + + return super.mouseClicked(mouseX, mouseY, button) + } + + private fun getMouseEntry(mouseX: Double, mouseY: Double): Int { + val x = (width - CobbledexGUI.BASE_WIDTH) / 2 + val y = (height - CobbledexGUI.BASE_HEIGHT) / 2 + + var currentIndex = 1 + val linesSize = LINES_SIZE - 1 + val columnsSize = COLUMN_SIZE - 1 + for (currentY: Int in 0..linesSize) { + for (currentX in 0..columnsSize) { + val currentPokemonIndex = COLUMN_SIZE * LINES_SIZE * (currentPage - 1) + (currentIndex - 1) + val entryX = x + (83.5F + (ENTRY_SIZE * currentX) + (X_PADDING * currentX)) + val entryY = y + (24.5F + (ENTRY_SIZE * currentY) + (Y_PADDING * currentY)) + + if (mouseX in entryX .. (entryX + ENTRY_SIZE) && mouseY in entryY .. (entryY + ENTRY_SIZE)) + return currentPokemonIndex + + currentIndex++ + } + } + + + return -1 + } + + fun loadSpecies(species: Species?, isDiscovered: Boolean = false) + { + val x = (width - CobbledexGUI.BASE_WIDTH) / 2 + val y = (height - CobbledexGUI.BASE_HEIGHT) / 2 + + if(species != null) { + modelWidget = SilhouetteModelWidget( + pX = x + 13, + pY = y + 41, + pWidth = CobbledexGUI.PORTRAIT_SIZE, + pHeight = CobbledexGUI.PORTRAIT_SIZE, + pokemon = RenderablePokemon(species, setOf()), + baseScale = 1.8F, + rotationY = 345F, + offsetY = -10.0, + isDiscovered = isDiscovered + ) + + typeWidget = TypeIcon( + x = x + 39 + 3, + y = y + 97 + 14, + type = species.primaryType, + secondaryType = species.secondaryType, + doubleCenteredOffset = 14f / 2, + secondaryOffset = 14f, + small = false, + centeredX = true + ) + } else { + modelWidget = null + typeWidget = null + } + } + } \ No newline at end of file diff --git a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/client/gui/CobbledexGUI.kt b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/client/gui/CobbledexGUI.kt index 857974c..4f80255 100644 --- a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/client/gui/CobbledexGUI.kt +++ b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/client/gui/CobbledexGUI.kt @@ -56,14 +56,14 @@ class CobbledexGUI(var selectedPokemon: FormData?, var selectedAspects: Set? = null) { - playSound(CobblemonSounds.PC_ON) + fun openCobbledexScreen(pokemon: FormData? = null, aspects: Set? = null, skipSound: Boolean = false) { + if (!skipSound) playSound(CobblemonSounds.PC_ON) Instance = CobbledexGUI(pokemon, aspects) MinecraftClient.getInstance().setScreen(Instance) @@ -88,6 +88,10 @@ class CobbledexGUI(var selectedPokemon: FormData?, var selectedAspects: Set? = null var lastLoadedPreEvolutions: List>>? = null //var lastLoadedForms: List>>? = null + + internal fun onServerJoin() { + previewPokemon = null + } } @@ -280,8 +284,7 @@ class CobbledexGUI(var selectedPokemon: FormData?, var selectedAspects: Set drawScaledText( context = context, @@ -337,10 +340,10 @@ class CobbledexGUI(var selectedPokemon: FormData?, var selectedAspects: Set= x && pMouseY >= y && pMouseX < x + width && pMouseY < y + height + renderPKM(context, partialTicks) + } + + private fun renderPKM(context: DrawContext, partialTicks: Float) { + val matrices = context.matrices + matrices.push() + + context.enableScissor( + x, + y, + x + width, + y + height + ) + + matrices.translate(x + width * 0.5, y.toDouble() + offsetY, 0.0) + matrices.scale(baseScale, baseScale, baseScale) + matrices.push() + + if (isDiscovered) + drawProfilePokemon( + renderablePokemon = pokemon, + matrixStack = matrices, + rotation = Quaternionf().fromEulerXYZDegrees(rotVec), + state = state, + partialTicks = partialTicks + ) + else + drawBlackSilhouettePokemon( + species = pokemon.species.resourceIdentifier, + aspects = pokemon.aspects, + matrixStack = matrices, + rotation = Quaternionf().fromEulerXYZDegrees(rotVec) + ) + + matrices.pop() + context.disableScissor() + + matrices.pop() + } + + override fun onClick(pMouseX: Double, pMouseY: Double) { + } +} \ No newline at end of file diff --git a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/items/CobbledexItem.kt b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/items/CobbledexItem.kt index 12610e8..f021d4c 100644 --- a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/items/CobbledexItem.kt +++ b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/items/CobbledexItem.kt @@ -3,11 +3,9 @@ package com.rafacasari.mod.cobbledex.items import com.cobblemon.mod.common.api.pokemon.PokemonSpecies import com.cobblemon.mod.common.api.text.text import com.cobblemon.mod.common.entity.pokemon.PokemonEntity -import net.minecraft.entity.LivingEntity +import com.cobblemon.mod.common.util.isLookingAt import net.minecraft.entity.player.PlayerEntity - import net.minecraft.item.* - import net.minecraft.client.item.TooltipContext import net.minecraft.text.Text import net.minecraft.util.* @@ -17,6 +15,11 @@ import com.rafacasari.mod.cobbledex.Cobbledex import com.rafacasari.mod.cobbledex.client.gui.CobbledexCollectionGUI import com.rafacasari.mod.cobbledex.client.gui.CobbledexGUI import com.rafacasari.mod.cobbledex.utils.cobbledexTextTranslation +import net.minecraft.client.gui.screen.Screen +import net.minecraft.server.network.ServerPlayerEntity +import net.minecraft.text.MutableText +import net.minecraft.text.TextContent +import net.minecraft.util.math.Box class CobbledexItem(settings: Settings) : Item(settings) { @@ -28,45 +31,71 @@ class CobbledexItem(settings: Settings) : Item(settings) { } } - override fun useOnEntity( - itemStack: ItemStack?, player: PlayerEntity?, target: LivingEntity?, hand: Hand?): ActionResult { - - if (player == null || target == null || player.world == null) { - return ActionResult.FAIL - } - - if (target !is PokemonEntity) { - if (player.world.isClient) - player.sendMessage(Text.translatable(CobbledexConstants.invalid_entity)) - - return ActionResult.FAIL - } + private val totalPokemonCount: Int + get() = PokemonSpecies.implemented.size - if (player.world.isClient) { - CobbledexGUI.openCobbledexScreen(target.pokemon.form, target.aspects) - return ActionResult.PASS - } - return Cobbledex.registerPlayerDiscovery(player, target.pokemon.form) - } + override fun appendTooltip(stack: ItemStack, world: World?, tooltip: MutableList, context: TooltipContext) + { + val percentage = "%.2f%%".format((totalPokemonDiscovered.toDouble() / totalPokemonCount) * 100) + val translation = cobbledexTextTranslation("tooltip_description.discovered", totalPokemonDiscovered.toString().text().formatted(Formatting.GREEN), totalPokemonCount.toString(), percentage) + tooltip.add(translation) - private val totalPokemonCount: Int - get() = PokemonSpecies.implemented.size + tooltip.add(MutableText.of(TextContent.EMPTY)) + if (Screen.hasShiftDown()) { + tooltip.add(cobbledexTextTranslation("tooltip_description.instructions1")) + tooltip.add(cobbledexTextTranslation("tooltip_description.instructions2")) + tooltip.add(cobbledexTextTranslation("tooltip_description.instructions3")) + tooltip.add(cobbledexTextTranslation("tooltip_description.instructions4")) + } else { + tooltip.add(cobbledexTextTranslation("tooltip_description.press_shift").formatted(Formatting.GREEN)) + } - override fun appendTooltip(stack: ItemStack?, world: World?, tooltip: MutableList?, context: TooltipContext?) - { - val translation = cobbledexTextTranslation("tooltip_description.discovered", totalPokemonDiscovered.toString().text().formatted(Formatting.GREEN), totalPokemonCount.toString()) - tooltip?.add(translation) super.appendTooltip(stack, world, tooltip, context) } - override fun use(world: World?, user: PlayerEntity?, hand: Hand?): TypedActionResult { + override fun use(world: World, user: PlayerEntity, hand: Hand): TypedActionResult { + val itemStack = user.getStackInHand(hand) + + if (world.isClient && user.isSneaking) { + CobbledexCollectionGUI.show() + return TypedActionResult.pass(itemStack) + } + + if (!user.isSneaking) { + // Better entity detection from official Pokédex + val entity = user.world + .getOtherEntities(user, Box.of(user.pos, 16.0, 16.0, 16.0)) + .filter { user.isLookingAt(it, stepDistance = 0.1F) } + .minByOrNull { it.distanceTo(user) } + + if (entity != null) { + if (entity !is PokemonEntity) { + if (world.isClient) + user.sendMessage(Text.translatable(CobbledexConstants.invalid_entity)) + + return TypedActionResult.fail(itemStack) + } + + val target = entity.pokemon + if (world.isClient && CobbledexCollectionGUI.discoveredList?.contains(target.species.nationalPokedexNumber) == true) { + CobbledexGUI.openCobbledexScreen(target.form, target.aspects) + return TypedActionResult.success(itemStack, false) + } + + if (user is ServerPlayerEntity) { + Cobbledex.registerPlayerDiscovery(user, target.form) + return TypedActionResult.success(itemStack) + } + } else if(world.isClient) { + if (CobbledexGUI.previewPokemon != null) + CobbledexGUI.openCobbledexScreen() + else CobbledexCollectionGUI.show() + } - if (user != null && world != null && world.isClient && user.isSneaking) { - CobbledexGUI.openCobbledexScreen() } return super.use(world, user, hand) diff --git a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/network/template/SerializableEvolutionRequirement.kt b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/network/template/SerializableEvolutionRequirement.kt index 0721b47..e73b1e4 100644 --- a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/network/template/SerializableEvolutionRequirement.kt +++ b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/network/template/SerializableEvolutionRequirement.kt @@ -63,7 +63,7 @@ class SerializableEvolutionRequirement(): IEncodable { EvolutionRequirementType.FRIENDSHIP -> { val translation = Text.translatable("cobbledex.evolution.friendship", value.toString().text().bold()) - longTextDisplay.addIcon(HEART_ICON, translation, 18, 16, xOffset = -3f, scale = 0.5f, breakLine = false) + longTextDisplay.addIcon(HEART_ICON, translation, 16, 16, xOffset = -3.5f, yOffset = -2.5f, scale = 0.65f, breakLine = false) } EvolutionRequirementType.ANY_REQUIREMENT -> { @@ -105,7 +105,7 @@ class SerializableEvolutionRequirement(): IEncodable { intRange?.let { //longTextDisplay.addText(Text.translatable("cobbledex.evolution.level", it.first.toString().text().bold()), false) val translation = Text.translatable("cobbledex.evolution.level", it.first.toString().text().bold()) - longTextDisplay.addIcon(LEVEL_ICON, translation, 18, 16, xOffset = -3f, scale = 0.5f, breakLine = false) + longTextDisplay.addIcon(LEVEL_ICON, translation, 16, 16, xOffset = -3.5f, yOffset = -2.5f, scale = 0.65f, breakLine = false) } } diff --git a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/network/template/SerializablePokemonEvolution.kt b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/network/template/SerializablePokemonEvolution.kt index 023060c..307016a 100644 --- a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/network/template/SerializablePokemonEvolution.kt +++ b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/network/template/SerializablePokemonEvolution.kt @@ -22,6 +22,7 @@ import com.rafacasari.mod.cobbledex.utils.PacketUtils.readNullableString import com.rafacasari.mod.cobbledex.utils.PacketUtils.writeNullableIdentifier import com.rafacasari.mod.cobbledex.utils.PacketUtils.writeNullableString import com.rafacasari.mod.cobbledex.utils.bold +import com.rafacasari.mod.cobbledex.utils.cobbledexResource import com.rafacasari.mod.cobbledex.utils.logInfo import com.rafacasari.mod.cobbledex.utils.logWarn import net.minecraft.block.Block @@ -82,7 +83,8 @@ class SerializablePokemonEvolution() : IEncodable { Text.translatable("cobbledex.evolution.trade_specific", speciesName.text().bold(), itemStack.name.bold()) } ?: Text.translatable("cobbledex.evolution.trade_any", itemStack.name.bold()) - longTextDisplay.addItemEntry(itemStack, translation, false, disableTooltip = false) + longTextDisplay.addIcon(TRADE_ICON, translation, 16, 16, xOffset = -3.5f, yOffset = -2.5f, scale = 0.65f, breakLine = false) + //longTextDisplay.addItemEntry(itemStack, translation, false, disableTooltip = false) } Unknown -> { @@ -185,6 +187,8 @@ class SerializablePokemonEvolution() : IEncodable { } companion object { + val TRADE_ICON = cobbledexResource("textures/gui/icons/trade.png") + fun decode(reader: PacketByteBuf) : SerializablePokemonEvolution { val evolution = SerializablePokemonEvolution() diff --git a/common/src/main/resources/assets/cobbledex/lang/en_us.json b/common/src/main/resources/assets/cobbledex/lang/en_us.json index ada01b8..2b3f5f9 100644 --- a/common/src/main/resources/assets/cobbledex/lang/en_us.json +++ b/common/src/main/resources/assets/cobbledex/lang/en_us.json @@ -24,7 +24,12 @@ "cobbledex.texts.new_pokemon_discovered": "You've discovered a new Pokémon: %s", "cobbledex.texts.click_to_open_cobbledex": "Click to open in Cobbledex", - "cobbledex.texts.tooltip_description.discovered": "Discovered: %s/%s", + "cobbledex.texts.tooltip_description.discovered": "Discovered: %s/%s (%s)", + "cobbledex.texts.tooltip_description.press_shift": "Hold for instructions", + "cobbledex.texts.tooltip_description.instructions1": "§a§lRight-Click§r a Pokémon to mark as seen", + "cobbledex.texts.tooltip_description.instructions2": "§a§lRight-Click§r a Pokémon to open §lInformation GUI§r", + "cobbledex.texts.tooltip_description.instructions3": "§a§lRight-Click§r on air to open §llast viewed Pokémon§r", + "cobbledex.texts.tooltip_description.instructions4": "§a§lShift + Right-Click§r to open §lCollection GUI§r", "cobbledex.texts.drops.item": "%s | %s%% | %sx", "cobbledex.texts.weather.clear": "Clear", "cobbledex.texts.weather.raining": "Raining", diff --git a/common/src/main/resources/assets/cobbledex/textures/gui/collection/type_spacer_unknown.png b/common/src/main/resources/assets/cobbledex/textures/gui/collection/type_spacer_unknown.png new file mode 100644 index 0000000000000000000000000000000000000000..0dbf1cd059811d042ea46c135a11244f604b553b GIT binary patch literal 230 zcmeAS@N?(olHy`uVBq!ia0vp^EkG>6!3HF)AB4^aQk(@Ik;M!Q+`=Ht$S`Y;1W<5> zr;B4qM&sKX2RWM^7+eCwFEt*$(QLZJCVK;W_r|ufS1&5a2^oCcJKLb*m(H%G*KV~` z=50Hc*m1FV)~URd@3VLB>p%YOZubs-M*$W`jr4trKa%$;S}1WeDS*+2-=`&ZzuUDv zt8D&#UGFz@fQo>qAh@zTPsVt*xt}|3x_Jio$!|>2&nR4fpC$oWWWbkzL Kb6Mw<&;$Va8CA{z literal 0 HcmV?d00001 diff --git a/common/src/main/resources/assets/cobbledex/textures/gui/icons/friendship.png b/common/src/main/resources/assets/cobbledex/textures/gui/icons/friendship.png index cd1c51d48998f3f5a6ae881e359bfc890d0286d4..8c960be10edd0c7aca0b4720fe1c0118d5bd6b15 100644 GIT binary patch literal 421 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WChBZdb&7I9VLN{N5gaFh`(4`olx@7Pd^WXMg$=B|L;rEU@<9*ZA{&o%0@cvxIAhSNCYw z?>m^qu`5yG-?{X7NvHSn?A(iXmh($ literal 257 zcmeAS@N?(olHy`uVBq!ia0vp^LO?9Q!3HFy+4N(86lZ})WHAGSo-znCRxGtI0}5{T zba4!^=v{l+k?)X#KM7wDwy`h_a9i~{-Ca^No~oslE}Lpjx4u??(?PnxYgn) zkn-wR_>M5Q?zN?YW+%TLS!l~_aJ%tn-@eMV?`HQ+*IsG!-kia!G$LZgW{hi6O zYT}1AYs41)5uf!ofOp5{AW2;@>oDg$7L^90U4_^8sLx-WuOQ*!;2Zn@#942~nMoPO zV#=BsqTY&@Cz5Aw|Jpo7p}#gaWr8V(gX?P*rVnhfY`IG}MkX=?ozLLu>gTe~DWM4f DsU~0a diff --git a/common/src/main/resources/assets/cobbledex/textures/gui/icons/level_up.png b/common/src/main/resources/assets/cobbledex/textures/gui/icons/level_up.png index d0bcbad534621e3cb257b91dc3c66966c9a17746..aca2c6070d4ce61e52da38665e0df7bc339378b4 100644 GIT binary patch literal 394 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WChAedAc};SokL|(41iR>8Cx1^UfuVM{kP%bFcsV-~P$r|Nj-tLS|Sf+}$U= z=HhczmgXA@hAT|C5?U@5Fa%}He0k`@WAzXQE{hwI5`F&n4}aKlNz|2JcnTZy%cj%_ z(`E(_9u@W=W>F^Q9gL42*8bNROI iFx2=`BRtc5eHpZXYz`m>flI-YL6oPfpUXO@geCwP8I^1R literal 286 zcmeAS@N?(olHy`uVBq!ia0vp^LO?9Q!3HFy+4N(86lZ})WHAGSo-znCRxGtI0}5X7 zba4!^=v{lok*nE2fc1j>#IoyKMV4Nlc<<=t3Q7NquI9E4N|#c18;1Re&A9TyMfXed zgd;Q46&ziK7#2)vnxXTa>yd|!!CwVSKb9xI6q>Cq8<<>#=IMMnp?c))W#8sv4so^v zjAsQVo91v@PS8EmW;Vezr=?6u@64@>aV}lVw(eDS_7Y6hjgQu&X%Q~loCIGGvZaV+~ diff --git a/common/src/main/resources/assets/cobbledex/textures/gui/icons/trade.png b/common/src/main/resources/assets/cobbledex/textures/gui/icons/trade.png new file mode 100644 index 0000000000000000000000000000000000000000..5c5b93d0d1b40ab42991c48fd6d5ebb78d36f01e GIT binary patch literal 502 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WChB#dAc};SokNWG&IdLI`)5|Pumyu^oNf$4)i{>XV#w(cbZ{(I+I}OreFU< zcT`CDuvAJom~`+@b7glpyT^4N56?k|<^>I!L2Jnla3fw=hsB8H40~1Q z#o(~V|DSC2mN+-Z=J1C{H;dUgH9gsci-p?`Er@74>%Y#pDVD*Ah3m+46~jF?)m@E= zPeolKB2KLMzrXm^ng7qj*EeSh$m=xn=`^;jz4ViR*+K@nStn-s+3f7J6-!uW*>}PG z1H)C#3oDXtwBGH!AtY@fb&z3&q|E*WQ`%S`c;yJpUNFn?<8Py4xkD489cpGa3Qk!O zbi?&vC(jf=7Ks^>cXqN!Jo{6_Tf(SO%Ph=lQP{wsvGITqU(lb&UO5Hg4JIAZvkmw3 zFz#Yt+s9ydfpwqJtpC5S>mKvS*?G`VpfsUDb)o`uOee4D7ROl&w>hx{Fs3CXConMV qKD_p8$zjbHU<~o4MtG+A`Z8z%*&IL&0+)g(gD6i|KbLh*2~7YfrNNW{ literal 0 HcmV?d00001 diff --git a/gradle.properties b/gradle.properties index 08da637..5025f76 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ mod_id=cobbledex generated_file_name_addon=-1.20.1 archives_base_name=cobbledex-1.20.1 -mod_version=1.0.24 +mod_version=1.0.25 mod_description=A mod to track your progress on Cobblemon. Fabric and Forge compatible. mod_icon=assets/cobbledex/icon.png repository=https://github.com/rafacasari/cobbledex