chore: code cleanup

This commit is contained in:
whatsy committed 2026-11-25 12:21:22 -05:00
1 parent 8415d65678
commit 3c19da86b9
4 files changed
+15 -17

No files matched your search

@@ -286,13 +286,10 @@ open class PCStore(
}
if (pokemonMoves.any { (_, target, _) -> get(target) != null && target !in sourcePositions }) return false
pokemonMoves.forEach { (source, _, _) -> setAtPosition(source, null) }
pokemonMoves.forEach { (_, target, pokemon) -> setAtPosition(target, pokemon) }
pokemonMoves.forEach { (_, _, pokemon) ->
pokemonMoves.forEach { (source, target, pokemon) ->
setAtPosition(source, null)
setAtPosition(target, pokemon)
sendPacketToObservers(RemoveClientPokemonPacket(this, pokemon.uuid))
}
pokemonMoves.forEach { (_, target, pokemon) ->
sendPacketToObservers(SetPCPokemonPacket(uuid, target) { pokemon })
}
pcChangeObservable.emit(Unit)
@@ -29,8 +29,7 @@ class BoxStorageSlot(
val grabbedSlot = parent.grabbedSlot
return if (grabbedSlot == null) {
val pokemon = getPokemon()
pokemon == null || !parent.isInMultiSelection(pokemon, position)
getPokemon().let { it == null || !parent.isInMultiSelection(it, position) }
} else {
grabbedSlot.getPokemon() != getPokemon()
}
@@ -51,6 +51,7 @@ import net.minecraft.sounds.SoundEvent
import kotlin.isInitialized
import net.minecraft.resources.ResourceLocation
import net.minecraft.util.FastColor
import org.lwjgl.glfw.GLFW
class PCGUI(
val pc: ClientPC,
@@ -870,7 +871,7 @@ class PCGUI(
override fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean {
val handled = super.mouseReleased(mouseX, mouseY, button)
if (button == 0) {
if (button == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
if (selectionDragActive) {
dragEndX = mouseX.toInt()
dragEndY = mouseY.toInt()
@@ -291,9 +291,10 @@ class StorageWidget(
val moves = mutableListOf<PCPokemonMove>()
val selectedSources = mutableSetOf<PCPosition>()
for (row in 0 until height) {
for (column in 0 until width) {
val pokemon = selection.getPokemon(column, row) ?: continue
repeat(height) { row ->
repeat(width) { column ->
val pokemon = selection.getPokemon(column, row) ?: return@repeat
val source = PCPosition(selection.sourceBox, (selection.sourceRow + row) * 6 + selection.sourceColumn + column)
val target = PCPosition(destination.box, (destinationRow + row) * 6 + destinationColumn + column)
selectedSources.add(source)
@@ -303,12 +304,12 @@ class StorageWidget(
if (moves.isEmpty()) return false
for (row in 0 until height) {
for (column in 0 until width) {
if (selection.getPokemon(column, row) == null) continue
repeat(height) { row ->
repeat(width) { column ->
if (selection.getPokemon(column, row) == null) return@repeat
val target = PCPosition(destination.box, (destinationRow + row) * 6 + destinationColumn + column)
val displacedPokemon = pc.get(target) ?: continue
if (target in selectedSources) continue
val displacedPokemon = pc.get(target) ?: return@repeat
if (target in selectedSources) return@repeat
val displacedSource = PCPosition(
selection.sourceBox,