forked from mirrors/cobblemon
Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
379c690d0b | ||
|
|
e3be7b9c8c | ||
|
|
17864263b8 | ||
|
|
54d0c9aad3 | ||
|
|
38a53efc54 | ||
|
|
d7ceb91948 | ||
|
|
d7e2c02f10 | ||
|
|
5ee4e08509 | ||
|
|
c43f1392e9 | ||
|
|
f0bbe9454d | ||
|
|
d09ab2323c | ||
|
|
3083d28f85 | ||
|
|
60fb266a75 | ||
|
|
8fbce136b7 |
@@ -46,6 +46,9 @@
|
||||
- Berries can now be smelted into their respective dyes.
|
||||
- Added Syrupy Apples.
|
||||
- Added `/runmolang <molang> [<npc>|<player>|<pokemon>]` command that executes a MoLang expression with the provided options as environment variables, as well as the entity (as `q.entity`) that executed the command.
|
||||
- Added [LambDynamicLights](https://modrinth.com/mod/lambdynamiclights) support for items held by Pokémon.
|
||||
- Fixed Moon Ball moon phase logic to actually work correctly
|
||||
- Added the Moves tab to the Pokédex, allowing players to view all of the move categories a form can obtain.
|
||||
|
||||
### Pokémon Added
|
||||
|
||||
@@ -448,6 +451,7 @@
|
||||
- Added `Pokemon#hyperTrainIV()` and `IVs#setHyperTrainedIV(Stat, Int)`
|
||||
- `ElementalType` now implements `ShowdownIdentifiable` to ensure the communcation with showdown stays consistent (also in regards to TeraTypes)
|
||||
- Pokemon no longer have a change observable
|
||||
- Fixed `[SpawnPool].observable` not emitting when the spawn pool is reloaded.
|
||||
|
||||
### MoLang & Datapacks
|
||||
- The following usages for item predicates can now use item conditions like advancements do, you can learn about them in the [Minecraft wiki](https://minecraft.wiki/w/Advancement_definition#minecraft:filled_bucket)
|
||||
|
||||
@@ -109,7 +109,17 @@ open class Learnset : ClientDataSynchronizer<Learnset> {
|
||||
}
|
||||
|
||||
// We only sync level up moves atm
|
||||
override fun shouldSynchronize(other: Learnset) = other.levelUpMoves != this.levelUpMoves
|
||||
override fun shouldSynchronize(other: Learnset): Boolean {
|
||||
return when {
|
||||
other.levelUpMoves.size != this.levelUpMoves.size -> true
|
||||
other.eggMoves.size != this.eggMoves.size -> true
|
||||
other.tutorMoves.size != this.tutorMoves.size -> true
|
||||
other.tmMoves.size != this.tmMoves.size -> true
|
||||
other.evolutionMoves.size != this.evolutionMoves.size -> true
|
||||
other.formChangeMoves.size != this.formChangeMoves.size -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
override fun decode(buffer: RegistryFriendlyByteBuf) {
|
||||
this.levelUpMoves.clear()
|
||||
@@ -121,6 +131,16 @@ open class Learnset : ClientDataSynchronizer<Learnset> {
|
||||
}
|
||||
levelUpMoves[level] = moves
|
||||
}
|
||||
this.eggMoves.clear()
|
||||
this.eggMoves.addAll(readMoves(buffer))
|
||||
this.tutorMoves.clear()
|
||||
this.tutorMoves.addAll(readMoves(buffer))
|
||||
this.tmMoves.clear()
|
||||
this.tmMoves.addAll(readMoves(buffer))
|
||||
this.evolutionMoves.clear()
|
||||
this.evolutionMoves.addAll(readMoves(buffer))
|
||||
this.formChangeMoves.clear()
|
||||
this.formChangeMoves.addAll(readMoves(buffer))
|
||||
}
|
||||
|
||||
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||
@@ -132,5 +152,25 @@ open class Learnset : ClientDataSynchronizer<Learnset> {
|
||||
buffer.writeInt(move.num)
|
||||
}
|
||||
}
|
||||
writeMoves(buffer, this.eggMoves)
|
||||
writeMoves(buffer, this.tutorMoves)
|
||||
writeMoves(buffer, this.tmMoves)
|
||||
writeMoves(buffer, this.evolutionMoves)
|
||||
writeMoves(buffer, this.formChangeMoves)
|
||||
}
|
||||
|
||||
private fun writeMoves(buffer: RegistryFriendlyByteBuf, moves: Collection<MoveTemplate>) {
|
||||
buffer.writeSizedInt(IntSize.U_SHORT, moves.size)
|
||||
for (move in moves) {
|
||||
buffer.writeInt(move.num)
|
||||
}
|
||||
}
|
||||
|
||||
private fun readMoves(buffer: RegistryFriendlyByteBuf): MutableList<MoveTemplate> {
|
||||
val moves = mutableListOf<MoveTemplate>()
|
||||
repeat(times = buffer.readSizedInt(IntSize.U_SHORT)) {
|
||||
Moves.getByNumericalId(buffer.readInt())?.let(moves::add)
|
||||
}
|
||||
return moves
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@ import com.cobblemon.mod.common.client.gui.pokedex.PokedexGUIConstants.TAB_ABILI
|
||||
import com.cobblemon.mod.common.client.gui.pokedex.PokedexGUIConstants.TAB_DESCRIPTION
|
||||
import com.cobblemon.mod.common.client.gui.pokedex.PokedexGUIConstants.TAB_DROPS
|
||||
import com.cobblemon.mod.common.client.gui.pokedex.PokedexGUIConstants.TAB_ICON_SIZE
|
||||
import com.cobblemon.mod.common.client.gui.pokedex.PokedexGUIConstants.TAB_MOVES
|
||||
import com.cobblemon.mod.common.client.gui.pokedex.PokedexGUIConstants.TAB_SIZE
|
||||
import com.cobblemon.mod.common.client.gui.pokedex.PokedexGUIConstants.TAB_STATS
|
||||
import com.cobblemon.mod.common.client.gui.pokedex.widgets.*
|
||||
@@ -91,7 +92,8 @@ class PokedexGUI private constructor(
|
||||
cobblemonResource("textures/gui/pokedex/tab_abilities.png"),
|
||||
cobblemonResource("textures/gui/pokedex/tab_size.png"),
|
||||
cobblemonResource("textures/gui/pokedex/tab_stats.png"),
|
||||
cobblemonResource("textures/gui/pokedex/tab_drops.png")
|
||||
cobblemonResource("textures/gui/pokedex/tab_drops.png"),
|
||||
cobblemonResource("textures/gui/pokedex/tab_moves.png")
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -312,8 +314,7 @@ class PokedexGUI private constructor(
|
||||
blitk(
|
||||
matrixStack = matrices,
|
||||
texture = tabSelectArrow,
|
||||
x = (x + 198 + (25 * tabInfoIndex)) / SCALE,
|
||||
// (x + 191.5 + (22 * tabInfoIndex)) / SCALE for 6 tabs
|
||||
x = (x + 191.5 + (22 * tabInfoIndex)) / SCALE,
|
||||
y = (y + 177) / SCALE,
|
||||
width = 12,
|
||||
height = 6,
|
||||
@@ -467,7 +468,7 @@ class PokedexGUI private constructor(
|
||||
|
||||
for (i in tabIcons.indices) {
|
||||
tabButtons.add(ScaledButton(
|
||||
x + 197F + (i * 25F), // x + 190.5F + (i * 22F) for 6 tabs
|
||||
x + 190.5F + (i * 22F),
|
||||
y + 181.5F,
|
||||
TAB_ICON_SIZE,
|
||||
TAB_ICON_SIZE,
|
||||
@@ -489,6 +490,9 @@ class PokedexGUI private constructor(
|
||||
if (tabInfoIndex == TAB_ABILITIES && tabInfoElement is AbilitiesWidget) {
|
||||
removeWidget((tabInfoElement as AbilitiesWidget).leftButton)
|
||||
removeWidget((tabInfoElement as AbilitiesWidget).rightButton)
|
||||
} else if (tabInfoIndex == TAB_MOVES && tabInfoElement is MovesWidget) {
|
||||
removeWidget((tabInfoElement as MovesWidget).leftButton)
|
||||
removeWidget((tabInfoElement as MovesWidget).rightButton)
|
||||
}
|
||||
|
||||
tabInfoIndex = tabIndex
|
||||
@@ -513,6 +517,9 @@ class PokedexGUI private constructor(
|
||||
TAB_DROPS -> {
|
||||
tabInfoElement = DropsScrollingWidget(x + 189, y + 135)
|
||||
}
|
||||
TAB_MOVES -> {
|
||||
tabInfoElement = MovesWidget(x + 180, y + 135)
|
||||
}
|
||||
}
|
||||
val element = tabInfoElement
|
||||
if (element is Renderable && element is NarratableEntry) {
|
||||
@@ -560,9 +567,15 @@ class PokedexGUI private constructor(
|
||||
(tabInfoElement as DropsScrollingWidget).dropTable = form.drops
|
||||
(tabInfoElement as DropsScrollingWidget).setEntries()
|
||||
}
|
||||
// TAB_MOVES -> {
|
||||
// form.moves.getLevelUpMovesUpTo(100)
|
||||
// }
|
||||
TAB_MOVES -> {
|
||||
val widget = tabInfoElement as MovesWidget
|
||||
widget.learnset = form.moves
|
||||
widget.categoryIndex = 0
|
||||
widget.refreshMoves()
|
||||
widget.scrollAmount = 0.0
|
||||
addRenderableWidget(widget.leftButton)
|
||||
addRenderableWidget(widget.rightButton)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (tabInfoIndex != TAB_DESCRIPTION) displaytabInfoElement(TAB_DESCRIPTION)
|
||||
|
||||
+1
@@ -35,6 +35,7 @@ object PokedexGUIConstants {
|
||||
const val TAB_SIZE = 2
|
||||
const val TAB_STATS = 3
|
||||
const val TAB_DROPS = 4
|
||||
const val TAB_MOVES = 5
|
||||
|
||||
// RowScrollingWidget
|
||||
const val SCROLL_BASE_HEIGHT = 141
|
||||
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.gui.pokedex.widgets
|
||||
|
||||
import com.cobblemon.mod.common.api.pokemon.moves.Learnset
|
||||
import com.cobblemon.mod.common.api.text.bold
|
||||
import com.cobblemon.mod.common.client.CobblemonResources
|
||||
import com.cobblemon.mod.common.client.gui.pokedex.ScaledButton
|
||||
import com.cobblemon.mod.common.client.render.drawScaledText
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.MutableComponent
|
||||
|
||||
class MovesWidget(x: Int, y: Int): InfoTextScrollWidget(pX = x, pY = y) {
|
||||
|
||||
companion object {
|
||||
private val arrowLeft = cobblemonResource("textures/gui/pokedex/info_arrow_left.png")
|
||||
private val arrowRight = cobblemonResource("textures/gui/pokedex/info_arrow_right.png")
|
||||
}
|
||||
|
||||
val leftButton: ScaledButton = ScaledButton(
|
||||
pX + 2.5F,
|
||||
pY - 8F,
|
||||
7,
|
||||
10,
|
||||
arrowLeft,
|
||||
clickAction = { switchMoves(false) }
|
||||
)
|
||||
|
||||
val rightButton: ScaledButton = ScaledButton(
|
||||
pX + 133F,
|
||||
pY - 8F,
|
||||
7,
|
||||
10,
|
||||
arrowRight,
|
||||
clickAction = { switchMoves(true) }
|
||||
)
|
||||
|
||||
var learnset: Learnset? = null
|
||||
var categoryIndex: Int = MoveCategory.LEVEL_UP.ordinal
|
||||
private var category: MoveCategory = MoveCategory.LEVEL_UP
|
||||
|
||||
override fun renderWidget(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
font = CobblemonResources.DEFAULT_LARGE,
|
||||
text = Component.translatable("cobblemon.ui.pokedex.info.moves", this.category.title).bold(),
|
||||
x = pX + 9,
|
||||
y = pY - 10,
|
||||
shadow = true
|
||||
)
|
||||
|
||||
super.renderWidget(context, mouseX, mouseY, delta)
|
||||
}
|
||||
|
||||
private fun switchMoves(forwards: Boolean) {
|
||||
val newIndex = this.categoryIndex + (if (forwards) 1 else -1)
|
||||
this.category = when {
|
||||
newIndex < 0 -> MoveCategory.entries.last()
|
||||
newIndex >= MoveCategory.entries.size -> MoveCategory.entries.first()
|
||||
else -> MoveCategory.entries[newIndex]
|
||||
}
|
||||
this.refreshMoves()
|
||||
}
|
||||
|
||||
fun refreshMoves() {
|
||||
this.learnset?.let { this.setText(this.category.getTextFromLearnset(it)) }
|
||||
}
|
||||
|
||||
private enum class MoveCategory(
|
||||
val title: MutableComponent,
|
||||
) {
|
||||
LEVEL_UP(Component.translatable("cobblemon.ui.pokedex.info.moves.level_up")),
|
||||
EGG(Component.translatable("cobblemon.ui.pokedex.info.moves.egg")),
|
||||
TM(Component.translatable("cobblemon.ui.pokedex.info.moves.tm")),
|
||||
TUTOR(Component.translatable("cobblemon.ui.pokedex.info.moves.tutor"));
|
||||
|
||||
fun getTextFromLearnset(learnset: Learnset): List<String> {
|
||||
return when(this) {
|
||||
LEVEL_UP -> learnset.levelUpMoves.flatMap { (level, moves) ->
|
||||
moves.map { "$level - ${it.displayName.string}" }
|
||||
}
|
||||
EGG -> learnset.eggMoves.map { it.displayName.string }
|
||||
TM -> learnset.tmMoves.map { it.displayName.string }
|
||||
TUTOR -> learnset.tutorMoves.map { it.displayName.string }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -259,6 +259,8 @@ class Species : ClientDataSynchronizer<Species>, ShowdownIdentifiable {
|
||||
}
|
||||
|
||||
this.riding.encode(buffer)
|
||||
|
||||
buffer.writeCollection(this.eggGroups) { pb, eggGroup -> pb.writeInt(eggGroup.ordinal)}
|
||||
}
|
||||
|
||||
override fun decode(buffer: RegistryFriendlyByteBuf) {
|
||||
@@ -301,6 +303,8 @@ class Species : ClientDataSynchronizer<Species>, ShowdownIdentifiable {
|
||||
}
|
||||
}
|
||||
this.riding = RidingProperties.decode(buffer)
|
||||
this.eggGroups.clear()
|
||||
this.eggGroups += buffer.readList { pb -> EggGroup.entries[pb.readInt()] }
|
||||
this.initialize()
|
||||
}
|
||||
|
||||
|
||||
@@ -1244,6 +1244,11 @@
|
||||
"cobblemon.ui.pokedex.search.type.drops": "Drops",
|
||||
|
||||
"cobblemon.ui.pokedex.info.ability": "Ability: %1$s",
|
||||
"cobblemon.ui.pokedex.info.moves": "Moves: %1$s",
|
||||
"cobblemon.ui.pokedex.info.moves.level_up": "Level Up",
|
||||
"cobblemon.ui.pokedex.info.moves.egg": "Egg",
|
||||
"cobblemon.ui.pokedex.info.moves.tm": "TM",
|
||||
"cobblemon.ui.pokedex.info.moves.tutor": "Tutor",
|
||||
"cobblemon.ui.pokedex.info.entry": "Entry",
|
||||
"cobblemon.ui.pokedex.info.stats": "Base Stats",
|
||||
"cobblemon.ui.pokedex.info.drops": "Drops",
|
||||
|
||||
Reference in New Issue
Block a user