Compare commits

..
Author SHA1 Message Date
MeAlam1 4a7c88f48b Cleanup 2026-12-04 18:14:49 +01:00
MeAlam1 02e0c1df2e Removed Arch + Bunch of other Gradle Stuff 2026-12-04 18:08:07 +01:00
37 changed files with 694 additions and 1117 deletions

No files matched your search

+6 -18
View File
@@ -2,24 +2,6 @@
## [1.8.5 (MONTH xth, 2026)](#1-8-5)
### Additions
- You can now drag to select multiple Pokémon inside the PC menu.
### Pokémon Added
#### Generation 4
#### Generation 5
#### Generation 6
#### Generation 7
#### Generation 8
#### Generation 9
### Model updates for the following Pokémon
### Animation updates for the following Pokémon
- Added the `healersSetSpawn` gamerule. When enabled, using a healing machine will set your spawnpoint.
- A Pokémon holding a Power item now gains 1 point in the corresponding riding stat every two minutes while being ridden. The interval is configurable, and can be disabled with `-1`.
- Added sounds to Play rough, Gigaton Hammer and Pyro Ball
@@ -52,6 +34,12 @@
### Developer
- Fixed JsonArray to MoValue conversion not working properly.
- Removed Architectury from the build. `common` now compiles against vanilla Minecraft through NeoForge ModDevGradle, `fabric` uses Fabric Loom and `neoforge` uses ModDevGradle.
- The `com.cobblemon:mod` (common) Maven artifact is now published in Mojang mappings instead of intermediary, and no longer contains `architectury.common.json`. The Fabric and NeoForge artifacts are unchanged.
- The NeoForge access transformer is now generated from `cobblemon-common.accesswidener` at build time, so the access widener remains the single source for both loaders.
- Updated the build to Gradle 9.9.3 and Fabric Loom 1.17.
- Replaced the Shadow plugin with `com.gradleup.shadow` 9.6.1 and the license header plugin with `net.neoforged.licenser` 0.7.5 for Gradle 9 compatibility.
- Parchment versions now live in `gradle/libs.versions.toml`.
### Molang & Datapacks
- `q.is_standing_on_blocks` now properly checks for non-full blocks like slabs, Mud or Soul Sand.
+2 -2
View File
@@ -4,9 +4,9 @@ An open-source Pokémon mod for Minecraft Java Edition, written in Kotlin for Fa
## Getting started
To set up the development workspace, first clone the project and open the build.gradle with Intellij. Make sure that you clone it to a folder that has no spaces in its path (for example, C:/Development/Cobblemon Stuff/cobblemon/ is bad) since Architectury Plugin seems to dislike it.
To set up the development workspace, first clone the project and open the build.gradle.kts with Intellij. The project is a plain multi-loader Gradle build: `common` (vanilla Minecraft via NeoForge ModDevGradle), `fabric` (Fabric Loom) and `neoforge` (ModDevGradle).
After it takes ages to load, you should hopefully have runnable configurations of the project in the top right, such as Minecraft Client (:fabric). If not, try running `./gradlew genEclipseRuns`.
After it takes ages to load, you should hopefully have runnable configurations of the project in the top right, such as Minecraft Client (:fabric). You can also run `./gradlew :fabric:runClient` or `./gradlew :neoforge:runClient`.
Troubleshooting:
- Try running `./gradlew --refresh-dependencies`
+90 -74
View File
@@ -1,8 +1,4 @@
import utilities.isSnapshot
import utilities.version
import utilities.gitBranch
import utilities.gitCommit
import utilities.*
/*
*
@@ -15,103 +11,123 @@ import utilities.gitCommit
*/
plugins {
id("cobblemon.base-conventions")
id("cobblemon.publish-conventions")
id("cobblemon.base-conventions")
id("cobblemon.publish-conventions")
id("net.neoforged.moddev")
id("net.kyori.blossom")
id("org.jetbrains.gradle.plugin.idea-ext")
id("net.kyori.blossom")
id("org.jetbrains.gradle.plugin.idea-ext")
}
architectury {
common("neoforge", "fabric")
val generateAccessTransformer by tasks.registering(AccessWidenerToTransformer::class) {
description = "AW to AT"
accessWidener = file(ACCESS_WIDENER)
accessTransformer = layout.buildDirectory.file("generated/accesstransformer/accesstransformer.cfg")
}
neoForge {
enable {
neoFormVersion = libs.versions.neoform.get()
isDisableRecompilation = true
}
parchment {
minecraftVersion = libs.versions.parchment.minecraft.get()
mappingsVersion = libs.versions.parchment.mappings.get()
}
accessTransformers.from(generateAccessTransformer.flatMap { it.accessTransformer })
interfaceInjectionData.from(file("interfaces.json"))
addModdingDependenciesTo(sourceSets.test.get())
}
repositories {
maven(url = "${rootProject.projectDir}/deps")
maven(url = "https://api.modrinth.com/maven")
maven(url = "https://maven.neoforged.net/releases")
maven(url = "https://maven.gegy.dev")
mavenLocal()
maven(url = "${rootProject.projectDir}/deps")
maven(url = "https://api.modrinth.com/maven")
maven(url = "https://maven.neoforged.net/releases")
maven(url = "https://maven.gegy.dev")
maven(url = "https://maven.fabricmc.net/")
mavenLocal()
}
dependencies {
implementation(libs.bundles.kotlin)
modImplementation(libs.fabric.loader)
modApi(libs.molang)
implementation(libs.bundles.kotlin)
compileOnly(libs.fabric.loader)
compileOnly(libs.bundles.common.compileOnly)
api(libs.molang)
// Integrations
compileOnlyApi(libs.jei.api)
modCompileOnly(libs.bundles.common.integrations.compileOnly) {
isTransitive = false
}
// LambDynamicLights is handled differently because we need the Mojang-mappings version of it.
modCompileOnly(libs.lambDynamicLights) {
capabilities {
requireCapability("dev.lambdaurora.lambdynamiclights:api-mojmap")
}
}
// Flywheel has no common dep so just pick one and don't use any platform specific code in common
// modCompileOnly(libs.flywheelFabric)
// Integrations
compileOnlyApi(libs.jei.api)
compileOnly(libs.bundles.common.integrations.compileOnly) {
isTransitive = false
}
// LambDynamicLights is handled differently because we need the Mojang-mappings version of it.
compileOnly(libs.lambDynamicLights) {
capabilities {
requireCapability("dev.lambdaurora.lambdynamiclights:api-mojmap")
}
}
// Flywheel has no common dep so just pick one and don't use any platform specific code in common
// modCompileOnly(libs.flywheelFabric)
// Showdown
modCompileOnly(libs.graal.core)
// Showdown
compileOnly(libs.graal.core)
// Data Storage
modCompileOnly(libs.bundles.mongo)
// Data Storage
compileOnly(libs.bundles.mongo)
// Unit Testing
testImplementation(libs.bundles.unitTesting)
// Unit Testing
testImplementation(libs.bundles.unitTesting)
testRuntimeOnly(libs.junit.platform.launcher)
}
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
setEvents(listOf("failed"))
setExceptionFormat("full")
}
useJUnitPlatform()
testLogging {
setEvents(listOf("failed"))
setExceptionFormat("full")
}
}
// Git info lives in its own output dir (not processResources) so a new commit only rewrites this one file.
val writeGitInfo by tasks.registering(WriteProperties::class) {
destinationFile = layout.buildDirectory.file("generated/gitInfo/cobblemon-git.properties")
property("commit", gitCommit())
property("branch", gitBranch())
description = ""
destinationFile = layout.buildDirectory.file("generated/gitInfo/cobblemon-git.properties")
property("commit", gitCommit())
property("branch", gitBranch())
}
sourceSets.main { output.dir(mapOf("builtBy" to writeGitInfo), layout.buildDirectory.dir("generated/gitInfo")) }
tasks.processResources {
exclude("data/**/README.md")
exclude("data/**/README.md")
}
sourceSets {
main {
blossom {
kotlinSources {
fun generateLicenseHeader() : String {
val builder = StringBuilder()
builder.append("/*\n")
rootProject.file("HEADER").forEachLine {
if(it.isEmpty()) {
builder.append(" *").append("\n")
} else {
builder.append(" * ").append(it).append("\n")
}
}
main {
blossom {
kotlinSources {
fun generateLicenseHeader(): String {
val builder = StringBuilder()
builder.append("/*\n")
rootProject.file("HEADER").forEachLine {
if (it.isEmpty()) {
builder.append(" *").append("\n")
} else {
builder.append(" * ").append(it).append("\n")
}
}
return builder.append(" */").append("\n").toString()
}
return builder.append(" */").append("\n").toString()
}
property("license", generateLicenseHeader())
property("modid", "cobblemon")
property("version", project.version())
property("isSnapshot", if(rootProject.isSnapshot()) "true" else "false")
System.getProperty("buildNumber")?.let { property("buildNumber", it) }
}
}
}
property("license", generateLicenseHeader())
property("modid", "cobblemon")
property("version", project.version())
property("isSnapshot", if (rootProject.isSnapshot()) "true" else "false")
System.getProperty("buildNumber")?.let { property("buildNumber", it) }
}
}
}
}
// The platform jars are built from :common:jar, so the remapped common jars are only needed by `publish`
tasks.assemble {
setDependsOn(dependsOn.filterNot { (it as? TaskProvider<*>)?.name in setOf("remapJar", "remapSourcesJar") })
publishing.publications.named<MavenPublication>(project.name) {
artifact(tasks.jar)
artifact(tasks.named("sourcesJar"))
}
+3
View File
@@ -0,0 +1,3 @@
{
"net/minecraft/client/model/geom/ModelPart": ["com/cobblemon/mod/common/client/render/models/blockbench/pose/Bone"]
}
@@ -566,7 +566,6 @@ object CobblemonNetwork {
list.add(PacketRegisterInfo(SwapPartyPokemonPacket.ID, SwapPartyPokemonPacket::decode, SwapPartyPokemonHandler))
list.add(PacketRegisterInfo(MovePCPokemonPacket.ID, MovePCPokemonPacket::decode, MovePCPokemonHandler))
list.add(PacketRegisterInfo(MovePCPokemonBatchPacket.ID, MovePCPokemonBatchPacket::decode, MovePCPokemonBatchHandler))
list.add(PacketRegisterInfo(MovePartyPokemonPacket.ID, MovePartyPokemonPacket::decode, MovePartyPokemonHandler))
list.add(PacketRegisterInfo(SwapPCPartyPokemonPacket.ID, SwapPCPartyPokemonPacket::decode, SwapPCPartyPokemonHandler))
@@ -27,10 +27,8 @@ import com.cobblemon.mod.common.net.messages.client.storage.RemoveClientPokemonP
import com.cobblemon.mod.common.net.messages.client.storage.SwapClientPokemonPacket
import com.cobblemon.mod.common.net.messages.client.storage.pc.InitializePCPacket
import com.cobblemon.mod.common.net.messages.client.storage.pc.MoveClientPCPokemonPacket
import com.cobblemon.mod.common.net.messages.client.storage.pc.SetPCBoxPacket
import com.cobblemon.mod.common.net.messages.client.storage.pc.SetPCPokemonPacket
import com.cobblemon.mod.common.net.messages.client.storage.pc.wallpaper.UnlockPCBoxWallpaperPacket
import com.cobblemon.mod.common.net.messages.server.storage.pc.MovePCPokemonBatchPacket
import com.cobblemon.mod.common.pokemon.Pokemon
import com.cobblemon.mod.common.util.DataKeys
import com.cobblemon.mod.common.util.asTranslated
@@ -68,12 +66,6 @@ open class PCStore(
) : PokemonStore<PCPosition>() {
constructor(uuid: UUID): this(uuid, lang("your_pc"))
data class PCPokemonMove(
val pokemonID: UUID,
val oldPosition: PCPosition,
val newPosition: PCPosition
)
val boxes = mutableListOf<PCBox>()
protected var lockedSize = false
val backupStore = BottomlessStore(UUID(0L, 0L))
@@ -278,43 +270,6 @@ open class PCStore(
}
}
fun validateMoves(moves: List<PCPokemonMove>): Boolean {
if (moves.isEmpty() || moves.size > MovePCPokemonBatchPacket.MAX_MOVES) return false
if (moves.map { it.oldPosition }.toSet().size != moves.size ||
moves.map { it.newPosition }.toSet().size != moves.size ||
moves.map { it.pokemonID }.toSet().size != moves.size
) return false
if (moves.any { (_, source, target) -> !isValidPosition(source) || !isValidPosition(target) }) return false
val sourcePositions = moves.mapTo(mutableSetOf()) { it.oldPosition }
val pokemonMoves = moves.map { move ->
val pokemon = get(move.oldPosition)?.takeIf { it.uuid == move.pokemonID } ?: return false
move to pokemon
}
return !pokemonMoves.any { (move, _) -> get(move.newPosition) != null && move.newPosition !in sourcePositions }
}
fun moveBatch(moves: List<PCPokemonMove>): Boolean {
if (!validateMoves(moves)) return false
val pokemonMoves = moves.map { move ->
val pokemon = get(move.oldPosition)?.takeIf { it.uuid == move.pokemonID } ?: return false
move to pokemon
}
pokemonMoves.forEach { (move, _) -> setAtPosition(move.oldPosition, null) }
pokemonMoves.forEach { (move, pokemon) -> setAtPosition(move.newPosition, pokemon) }
val affectedBoxes = pokemonMoves
.flatMap { (move, _) -> listOf(move.oldPosition.box, move.newPosition.box) }
.distinct()
.map { boxes[it] }
affectedBoxes.forEach { sendPacketToObservers(SetPCBoxPacket(it)) }
pcChangeObservable.emit(Unit)
return true
}
override fun loadPositionFromNBT(nbt: CompoundTag): StoreCoordinates<PCPosition> {
return StoreCoordinates(this, PCPosition(nbt.getShort(DataKeys.STORE_BOX).toInt(), nbt.getByte(DataKeys.STORE_SLOT).toInt()))
}
@@ -111,7 +111,6 @@ object CobblemonClient {
val battleOverlay: BattleOverlay by lazy { BattleOverlay() }
val pokedexUsageContext: PokedexUsageContext by lazy { PokedexUsageContext() }
val rideControlsOverlay: RideControlsOverlay by lazy { RideControlsOverlay() }
var pcHealthToggle: Boolean = false
fun onLogin() {
clientPlayerData = ClientGeneralPlayerData()
@@ -29,7 +29,7 @@ class BoxStorageSlot(
val grabbedSlot = parent.grabbedSlot
return if (grabbedSlot == null) {
getPokemon().let { it == null || !parent.isInMultiSelection(it, position) }
true
} else {
grabbedSlot.getPokemon() != getPokemon()
}
@@ -50,8 +50,6 @@ import net.minecraft.network.chat.Component
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,
@@ -100,8 +98,6 @@ class PCGUI(
private val buttonWallpaperResource = cobblemonResource("textures/gui/pc/pc_button_set_wallpaper.png")
private val buttonInfoArrow = cobblemonResource("textures/gui/pc/info_arrow.png")
private val buttonHealthToggleResource = cobblemonResource("textures/gui/pc/pc_button_toggle_health.png")
private val topSpacerResource = cobblemonResource("textures/gui/pc/pc_spacer_top.png")
private val bottomSpacerResource = cobblemonResource("textures/gui/pc/pc_spacer_bottom.png")
private val rightSpacerResource = cobblemonResource("textures/gui/pc/pc_spacer_right.png")
@@ -133,55 +129,6 @@ class PCGUI(
var selectPointerOffsetIncrement = false
var displayOptions = false
private var dragStartX: Int? = null
private var dragStartY: Int? = null
private var dragEndX: Int? = null
private var dragEndY: Int? = null
private var selectionDragActive = false
data class SelectionArea(val left: Int, val top: Int, val right: Int, val bottom: Int)
private data class BoxGridBounds(val left: Int, val top: Int, val right: Int, val bottom: Int) {
fun contains(x: Int, y: Int) = x in left..< right && y >= top && y < bottom
}
private fun getBoxGridBounds(): BoxGridBounds {
val left = storageWidget.x
val top = storageWidget.y
return BoxGridBounds(
left,
top,
left + StorageWidget.SCREEN_WIDTH,
top + StorageWidget.SCREEN_HEIGHT
)
}
fun getSelectionArea(): SelectionArea? {
if (!selectionDragActive) return null
val startX = dragStartX ?: return null
val startY = dragStartY ?: return null
val endX = dragEndX ?: return null
val endY = dragEndY ?: return null
val bounds = getBoxGridBounds()
if (!bounds.contains(startX, startY)) return null
val columns = 6
val rows = 5
val slotPitch = StorageSlot.SIZE + StorageWidget.BOX_SLOT_PADDING
val gridLeft = bounds.left + StorageWidget.BOX_SLOT_START_OFFSET_X
val gridTop = bounds.top + StorageWidget.BOX_SLOT_START_OFFSET_Y + if (displayOptions) 5 else 0
val startColumn = ((startX - gridLeft) / slotPitch).coerceIn(0, columns - 1)
val endColumn = (((endX.coerceIn(bounds.left, bounds.right - 1)) - gridLeft) / slotPitch).coerceIn(0, columns - 1)
val startRow = ((startY - gridTop) / slotPitch).coerceIn(0, rows - 1)
val endRow = (((endY.coerceIn(bounds.top, bounds.bottom - 1)) - gridTop) / slotPitch).coerceIn(0, rows - 1)
return SelectionArea(
gridLeft + minOf(startColumn, endColumn) * slotPitch, // left
gridTop + minOf(startRow, endRow) * slotPitch, // top
gridLeft + (maxOf(startColumn, endColumn) * slotPitch) + StorageSlot.SIZE, // right
gridTop + (maxOf(startRow, endRow) * slotPitch) + StorageSlot.SIZE // bottom
)
}
override fun renderBlurredBackground(delta: Float) {}
override fun renderMenuBackground(context: GuiGraphics) {}
@@ -272,6 +219,7 @@ class PCGUI(
storageWidget.setupStorageSlots()
for (button in optionButtons) {
button.visible = displayOptions
button.highlighted = false
}
}.also { it.highlighted = displayOptions }
)
@@ -302,28 +250,12 @@ class PCGUI(
configuration.showParty = isVisible
wallpaperWidget.visible = !isVisible
(it as IconButton).highlighted = !isVisible
if (unseenWallpapers.isNotEmpty()) MarkPCBoxWallpapersSeenPacket(unseenWallpapers).sendToServer()
if (!unseenWallpapers.isEmpty()) MarkPCBoxWallpapersSeenPacket(unseenWallpapers).sendToServer()
}.also {
it.visible = displayOptions
optionButtons.add(it)
})
val healthButton = this.addRenderableWidget(IconButton(
pX = x + 230,
pY = y + 31,
buttonWidth = 20,
buttonHeight = 20,
resource = buttonHealthToggleResource,
label = "toggle_health_bars",
) {
CobblemonClient.pcHealthToggle = !CobblemonClient.pcHealthToggle
(it as IconButton).highlighted = CobblemonClient.pcHealthToggle
}.also {
it.visible = displayOptions
optionButtons.add(it)
})
healthButton.highlighted = CobblemonClient.pcHealthToggle
PokemonSortMode.entries.forEachIndexed { index, sortType ->
val typeName = sortType.name.lowercase()
this.addRenderableWidget(IconButton(
@@ -383,20 +315,6 @@ class PCGUI(
super.init()
}
private fun renderSelectionBox(context: GuiGraphics, area: SelectionArea) {
context.pose().pushPose()
context.pose().translate(0.0, 0.0, 1500.0)
val borderColor = FastColor.ARGB32.color(255, 205, 212, 255)
val bgColor = FastColor.ARGB32.color(75, 133, 183, 230)
val thickness = 1
context.fill(area.left, area.top, area.right, area.bottom, bgColor)
context.fill(area.left, area.top, area.right, area.top + thickness, borderColor)
context.fill(area.left, area.bottom - thickness, area.right, area.bottom, borderColor)
context.fill(area.left, area.top, area.left + thickness, area.bottom, borderColor)
context.fill(area.right - thickness, area.top, area.right, area.bottom, borderColor)
context.pose().popPose()
}
override fun render(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
val matrices = context.pose()
renderBackground(context, mouseX, mouseY, delta)
@@ -537,20 +455,6 @@ class PCGUI(
shadow = true
)
// var dexNo = pokemon.species.nationalPokedexNumber.toString()
// while (dexNo.length < 4) {
// dexNo = "0$dexNo"
// }
// drawScaledText(
// context = context,
// font = CobblemonResources.DEFAULT_LARGE,
// text = Component.literal(dexNo).bold(),
// x = x + 38,
// y = y + 1.5,
// shadow = true,
// scale = 0.85f
// )
drawScaledText(
context = context,
font = CobblemonResources.DEFAULT_LARGE,
@@ -781,14 +685,12 @@ class PCGUI(
scale = SCALE
)
if (optionButtons.isNotEmpty() && displayOptions) {
if (!optionButtons.isEmpty() && displayOptions) {
for (button in optionButtons) button.showAlt = hasShiftDown()
}
super.render(context, mouseX, mouseY, delta)
getSelectionArea()?.let { renderSelectionBox(context, it) }
// Item Tooltip
if (pokemon != null) {
val displayedItem = if (showCosmeticItem) pokemon.cosmeticItem else pokemon.heldItemNoCopy()
@@ -810,20 +712,6 @@ class PCGUI(
}
override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean {
storageWidget.clearPendingStorageSlotClick()
selectionDragActive = false
val clickX = mouseX.toInt()
val clickY = mouseY.toInt()
if (storageWidget.multiSelection == null && button == 0 &&
getBoxGridBounds().contains(clickX, clickY) &&
storageWidget.pastureWidget == null) {
dragStartX = clickX
dragStartY = clickY
} else {
dragStartX = null
dragStartY = null
}
// Trigger child component function as they will need to check the entire screen click area
if (::boxNameWidget.isInitialized) boxNameWidget.mouseClicked(mouseX, mouseY, button)
return super.mouseClicked(mouseX, mouseY, button)
@@ -852,43 +740,9 @@ class PCGUI(
storageWidget.pastureWidget?.let { pasture ->
if (pasture.pastureScrollList.isHovered) pasture.pastureScrollList.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)
}
if (button == 0 && storageWidget.pastureWidget == null) {
val startX = dragStartX
val startY = dragStartY
if (startX != null && startY != null) {
val offsetX = mouseX - startX
val offsetY = mouseY - startY
if (offsetX * offsetX + offsetY * offsetY >= 25.0) {
selectionDragActive = true
storageWidget.clearPendingStorageSlotClick()
dragEndX = mouseX.toInt()
dragEndY = mouseY.toInt()
}
}
}
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)
}
override fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean {
val handled = super.mouseReleased(mouseX, mouseY, button)
if (button == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
if (selectionDragActive) {
dragEndX = mouseX.toInt()
dragEndY = mouseY.toInt()
storageWidget.updateSelection()
storageWidget.clearPendingStorageSlotClick()
} else {
storageWidget.completePendingStorageSlotClick(mouseX, mouseY)
}
}
dragStartX = null
dragStartY = null
dragEndX = null
dragEndY = null
selectionDragActive = false
return handled
}
override fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
val boxNameFocused = this::boxNameWidget.isInitialized && boxNameWidget.isFocused
val filterFocused = this::filterWidget.isInitialized && filterWidget.isFocused
@@ -1,37 +0,0 @@
package com.cobblemon.mod.common.client.gui.pc
import com.cobblemon.mod.common.pokemon.Pokemon
data class PCMultiSelection(
private val grid: MutableList<MutableList<Pokemon?>> = mutableListOf(),
val sourceBox: Int = 0,
val sourceColumn: Int = 0,
val sourceRow: Int = 0
) {
fun getHorizontalSize(): Int = grid.firstOrNull()?.size ?: 0
fun getVerticalSize(): Int = grid.size
constructor(horizontalSize: Int, verticalSize: Int, sourceBox: Int, sourceColumn: Int, sourceRow: Int) : this(
MutableList(verticalSize) { MutableList<Pokemon?>(horizontalSize) { null } },
sourceBox,
sourceColumn,
sourceRow
)
fun getPokemon(x: Int, y: Int): Pokemon? {
return grid[y][x]
}
fun setPokemon(x: Int, y: Int, pokemon: Pokemon?) {
grid[y][x] = pokemon
}
fun pokemonEntries(): List<Triple<Int, Int, Pokemon>> {
return grid.flatMapIndexed { y, row ->
row.mapIndexedNotNull { x, pokemon -> pokemon?.let { Triple(x, y, it) } }
}
}
fun getPokemonCount(): Int = pokemonEntries().size
}
@@ -45,13 +45,11 @@ class ReleaseButton(
vOffset = if (isHovered(mouseX.toDouble(), mouseY.toDouble())) HEIGHT else 0,
textureHeight = HEIGHT * 2
)
val pokemonCount = parent.multiSelection?.getPokemonCount() ?: 0
drawScaledText(
context = context,
font = CobblemonResources.DEFAULT_LARGE,
text = if (pokemonCount > 1)
{ lang("ui.pc.release_all").bold() } else { lang("ui.pc.release").bold() },
text = lang("ui.pc.release").bold(),
x = x + (WIDTH / 2),
y = y + 3.5,
centered = true,
@@ -10,11 +10,10 @@ package com.cobblemon.mod.common.client.gui.pc
import com.cobblemon.mod.common.Cobblemon
import com.cobblemon.mod.common.api.gui.blitk
import com.cobblemon.mod.common.client.CobblemonClient
import com.cobblemon.mod.common.client.gui.CobblemonRenderable
import com.cobblemon.mod.common.client.gui.PokemonGUIAnimationStyle
import com.cobblemon.mod.common.client.gui.drawProfilePokemon
import com.cobblemon.mod.common.client.gui.pasture.PasturePCGUIConfiguration
import com.cobblemon.mod.common.client.gui.PokemonGUIAnimationStyle
import com.cobblemon.mod.common.client.render.drawScaledText
import com.cobblemon.mod.common.client.render.models.blockbench.FloatingState
import com.cobblemon.mod.common.client.render.renderScaledGuiItemIcon
@@ -23,19 +22,13 @@ import com.cobblemon.mod.common.pokemon.Pokemon
import com.cobblemon.mod.common.util.cobblemonResource
import com.cobblemon.mod.common.util.lang
import com.cobblemon.mod.common.util.math.fromEulerXYZDegrees
import juuxel.adorn.util.Colors
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.components.Button
import net.minecraft.client.renderer.RenderType
import net.minecraft.client.sounds.SoundManager
import net.minecraft.network.chat.Component
import net.minecraft.util.Mth
import org.joml.Quaternionf
import org.joml.Vector3f
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.roundToInt
open class StorageSlot(
x: Int, y: Int,
@@ -61,17 +54,9 @@ open class StorageSlot(
}
override fun renderWidget(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
val selectionArea = parent.pcGui.getSelectionArea()
if (selectionArea != null && parent.getSelectedPokemon(selectionArea).contains(this)) {
val highlightColor = 0x40FFFFFF
context.fill(x + 1, y, x + (SIZE - 1), y + SIZE, highlightColor)
context.fill(x, y + 1, x + 1, y + (SIZE - 1), highlightColor)
context.fill(x + SIZE - 1, y + 1, x + SIZE, y + (SIZE - 1), highlightColor)
}
if (shouldRender()) {
renderSlot(context, x, y, delta)
}
}
fun renderSlot(context: GuiGraphics, posX: Int, posY: Int, partialTicks: Float) {
@@ -145,23 +130,6 @@ open class StorageSlot(
matrixStack = matrices
)
}
// Pokemon health
// Taken from vanilla durability rendering
val currentHealth = pokemon.currentHealth
val maxHealth = pokemon.maxHealth.toFloat()
if (currentHealth < maxHealth && CobblemonClient.pcHealthToggle) {
val damageValue = maxHealth - currentHealth
val f = max(0.0f, (maxHealth - (maxHealth - currentHealth)) / maxHealth)
val color = Mth.hsvToRgb(f / 3.0f, 1.0f, 1.0f)
val totalWidth = 12
val width = (totalWidth - damageValue * totalWidth / pokemon.maxHealth.toFloat()).roundToInt();
val k = posX + 1
val l = posY + 6
val bgColor = if (this is PartyStorageSlot) Colors.BLACK else 0xFF3E3E3E.toInt()
context.fill(RenderType.guiOverlay(), k, l, k + totalWidth, l + 1, bgColor)
context.fill(RenderType.guiOverlay(), k, l, k + width, l + 1, color or bgColor)
}
matrices.popPose()
}
@@ -11,9 +11,9 @@ package com.cobblemon.mod.common.client.gui.pc
import com.cobblemon.mod.common.CobblemonNetwork
import com.cobblemon.mod.common.CobblemonSounds
import com.cobblemon.mod.common.api.gui.blitk
import com.cobblemon.mod.common.api.storage.StorePosition
import com.cobblemon.mod.common.api.storage.party.PartyPosition
import com.cobblemon.mod.common.api.storage.pc.PCPosition
import com.cobblemon.mod.common.api.storage.pc.PCStore
import com.cobblemon.mod.common.api.text.bold
import com.cobblemon.mod.common.client.CobblemonClient
import com.cobblemon.mod.common.client.CobblemonResources
@@ -39,8 +39,8 @@ import net.minecraft.client.gui.components.Button
import net.minecraft.client.gui.screens.Screen
import net.minecraft.client.resources.sounds.SimpleSoundInstance
import net.minecraft.network.chat.Component
import net.minecraft.resources.ResourceLocation
import net.minecraft.sounds.SoundEvent
import java.util.UUID
class StorageWidget(
pX: Int, pY: Int,
@@ -77,15 +77,9 @@ class StorageWidget(
var displayConfirmRelease = false
var screenLoaded = false
var selectedPosition: PartyPosition? = null
var selectedPosition: StorePosition? = null
var grabbedSlot: GrabbedStorageSlot? = null
var multiSelection: PCMultiSelection? = null
private val multiGrabbedSlots = mutableMapOf<UUID, GrabbedStorageSlot>()
private var pendingStorageSlotClick: Button? = null
private var movePending = false
private var movePendingSince = 0L
var box = 0
set(value) {
field =
@@ -119,24 +113,19 @@ class StorageWidget(
subKey = "ui.generic.yes",
onPress = {
if (canDeleteSelected() && displayConfirmRelease) {
val selection = multiSelection
if (selection != null) {
selection.pokemonEntries().forEach { (column, row, pokemon) ->
val position = PCPosition(
selection.sourceBox,
(selection.sourceRow + row) * 6 + selection.sourceColumn + column
)
CobblemonNetwork.sendToServer(ReleasePCPokemonPacket(pokemon.uuid, position))
}
} else {
val position = selectedPosition ?: return@ReleaseConfirmButton
val pokemon = getSelectedPokemon() ?: return@ReleaseConfirmButton
val position = selectedPosition ?: return@ReleaseConfirmButton
val pokemon = getSelectedPokemon() ?: return@ReleaseConfirmButton
CobblemonNetwork.sendToServer(ReleasePartyPokemonPacket(pokemon.uuid, position))
val packet = when (position) {
is PartyPosition -> ReleasePartyPokemonPacket(pokemon.uuid, position)
is PCPosition -> ReleasePCPokemonPacket(pokemon.uuid, position)
else -> return@ReleaseConfirmButton
}
CobblemonNetwork.sendToServer(packet)
playSound(CobblemonSounds.PC_RELEASE)
resetSelected()
displayConfirmRelease = false
}
}
)
@@ -160,8 +149,9 @@ class StorageWidget(
}
fun canDeleteSelected(): Boolean {
multiSelection?.let { return it.pokemonEntries().isNotEmpty() }
return party.filterNotNull().size > 1 && selectedPosition != null && grabbedSlot != null
return !(selectedPosition is PartyPosition && party.filterNotNull().size <= 1)
&& selectedPosition != null
&& grabbedSlot != null
}
fun setupStorageSlots() {
@@ -180,7 +170,7 @@ class StorageWidget(
parent = this,
pc = pc,
position = PCPosition(box, index),
onPress = { pendingStorageSlotClick = it }
onPress = { this.onStorageSlotClicked(it) }
).also { widget ->
this.addWidget(widget)
this.boxSlots.add(widget)
@@ -210,7 +200,7 @@ class StorageWidget(
parent = this,
party = party,
position = PartyPosition(partyIndex),
onPress = { pendingStorageSlotClick = it }
onPress = { this.onStorageSlotClicked(it) }
).also { widget ->
this.addWidget(widget)
this.partySlots.add(widget)
@@ -220,118 +210,14 @@ class StorageWidget(
private fun getSelectedPokemon(): Pokemon? {
val selectedPosition = this.selectedPosition ?: return null
return party.get(selectedPosition)
}
fun getSelectedPokemon(area: PCGUI.SelectionArea): List<BoxStorageSlot> {
return boxSlots.filter { slot ->
slot.x < area.right && slot.x + StorageSlot.SIZE > area.left &&
slot.y < area.bottom && slot.y + StorageSlot.SIZE > area.top &&
slot.getPokemon()?.let(pcGui.search::passes) == true
return when (selectedPosition) {
is PCPosition -> pc.get(selectedPosition)
is PartyPosition -> party.get(selectedPosition)
else -> null
}
}
fun clearPendingStorageSlotClick() {
pendingStorageSlotClick = null
}
fun completePendingStorageSlotClick(mouseX: Double, mouseY: Double) {
val button = pendingStorageSlotClick ?: return
pendingStorageSlotClick = null
if (button.isMouseOver(mouseX, mouseY)) {
onStorageSlotClicked(button)
}
}
fun updateSelection() {
val area = pcGui.getSelectionArea()
if (area == null) {
multiSelection = null
return
}
selectedPosition = null
grabbedSlot = null
pcGui.setPreviewPokemon(null)
val selectedSlots = getSelectedPokemon(area)
if (selectedSlots.isEmpty()) {
multiSelection = null
return
}
val minColumn = selectedSlots.minOf { it.position.slot % 6 }
val maxColumn = selectedSlots.maxOf { it.position.slot % 6 }
val minRow = selectedSlots.minOf { it.position.slot / 6 }
val maxRow = selectedSlots.maxOf { it.position.slot / 6 }
val selection = PCMultiSelection(maxColumn - minColumn + 1, maxRow - minRow + 1, box, minColumn, minRow)
selectedSlots.forEach { slot ->
val pokemon = slot.getPokemon() ?: return@forEach
val slotIndex = slot.position.slot
val column = slotIndex % 6
val row = slotIndex / 6
if (column in minColumn..maxColumn && row in minRow..maxRow) {
selection.setPokemon(column - minColumn, row - minRow, pokemon)
}
}
playSound(CobblemonSounds.PC_GRAB)
multiSelection = selection
}
private fun moveMultiSelectionTo(destination: PCPosition): Boolean {
val selection = multiSelection ?: return false
val width = selection.getHorizontalSize()
val height = selection.getVerticalSize()
val destinationColumn = destination.slot % 6
val destinationRow = destination.slot / 6
if (destinationColumn + width > 6 || destinationRow + height > 5) return false
val moves = mutableListOf<PCStore.PCPokemonMove>()
val selectedSources = mutableSetOf<PCPosition>()
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)
moves.add(PCStore.PCPokemonMove(pokemon.uuid, source, target))
}
}
if (moves.isEmpty()) return false
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) ?: return@repeat
if (target in selectedSources) return@repeat
val displacedSource = PCPosition(
selection.sourceBox,
(selection.sourceRow + row) * 6 + selection.sourceColumn + column
)
if (pc.get(displacedSource) != null && displacedSource !in selectedSources) return false
moves.add(PCStore.PCPokemonMove(displacedPokemon.uuid, target, displacedSource))
}
}
if (moves.map { it.newPosition }.toSet().size != moves.size) return false
MovePCPokemonBatchPacket(moves).sendToServer()
return true
}
fun isInMultiSelection(pokemon: Pokemon, position: PCPosition): Boolean {
val selection = multiSelection ?: return false
return selection.sourceBox == position.box && selection.pokemonEntries().any { it.third == pokemon }
}
override fun renderWidget(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
updatePendingMove()
val matrices = context.pose()
// Party Label
if (pcGui.configuration.showParty) {
@@ -354,14 +240,11 @@ class StorageWidget(
shadow = true
)
val pokemonCount = multiSelection?.getPokemonCount() ?: 0
if (canDeleteSelected() && displayConfirmRelease) {
drawScaledText(
context = context,
font = CobblemonResources.DEFAULT_LARGE,
text = if (pokemonCount > 1)
{ lang("ui.pc.release_all").bold() } else { lang("ui.pc.release").bold() },
text = lang("ui.pc.release").bold(),
x = x + 223,
y = y + 119,
centered = true
@@ -425,7 +308,6 @@ class StorageWidget(
slot.render(context, mouseX, mouseY, delta)
val pokemon = slot.getPokemon()
if (grabbedSlot == null && slot.isHovered(mouseX, mouseY)
&& multiSelection == null
&& pokemon != null && pokemon != pcGui.previewPokemon
) {
pcGui.setPreviewPokemon(pokemon, pcGui.isPreviewInParty ?: false)
@@ -442,7 +324,6 @@ class StorageWidget(
slot.render(context, mouseX, mouseY, delta)
val pokemon = slot.getPokemon()
if (grabbedSlot == null && slot.isHovered(mouseX, mouseY)
&& multiSelection == null
&& pokemon != null && pokemon != pcGui.previewPokemon
) {
pcGui.setPreviewPokemon(pokemon, pcGui.isPreviewInParty ?: true)
@@ -454,32 +335,10 @@ class StorageWidget(
pastureWidget?.render(context, mouseX, mouseY, delta)
matrices.pushPose()
matrices.translate(0.0, 0.0, 1000.0)
renderSelectedPokemon(context, mouseX, mouseY, delta)
grabbedSlot?.render(context, mouseX, mouseY, delta)
matrices.popPose()
}
private fun renderSelectedPokemon(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
if (movePending) return
val selection = multiSelection
if (selection == null) {
grabbedSlot?.render(context, mouseX, mouseY, delta)
return
}
val slotOffset = StorageSlot.SIZE + BOX_SLOT_PADDING
selection.pokemonEntries().forEach { (column, row, pokemon) ->
val grabbed = multiGrabbedSlots.getOrPut(pokemon.uuid) {
GrabbedStorageSlot(0, 0, this, pokemon)
}
grabbed.render(
context,
mouseX + column * slotOffset,
mouseY + row * slotOffset,
delta
)
}
}
override fun mouseClicked(pMouseX: Double, pMouseY: Double, pButton: Int): Boolean {
if (displayConfirmRelease) {
if (releaseYesButton.isHovered(pMouseX, pMouseY)) releaseYesButton.mouseClicked(pMouseX, pMouseY, pButton)
@@ -512,55 +371,23 @@ class StorageWidget(
else -> return
}
val clickedPokemon = when (clickedPosition) {
is PCPosition -> pc.get(clickedPosition)
is PartyPosition -> party.get(clickedPosition)
else -> null
}
multiSelection?.let { selection ->
when (clickedPosition) {
is PCPosition -> {
if (clickedPosition.box == selection.sourceBox &&
clickedPosition.slot == selection.sourceRow * 6 + selection.sourceColumn
) {
resetSelected()
} else if (moveMultiSelectionTo(clickedPosition)) {
playSound(CobblemonSounds.PC_DROP)
movePending = true
}
}
is PartyPosition -> {
val selectedPokemon = selection.pokemonEntries().singleOrNull() ?: return
val (column, row, pokemon) = selectedPokemon
val source = PCPosition(
selection.sourceBox,
(selection.sourceRow + row) * 6 + selection.sourceColumn + column
)
if (pc.get(source) !== pokemon) return
val packet = clickedPokemon?.let {
SwapPCPartyPokemonPacket(it.uuid, clickedPosition, pokemon.uuid, source)
} ?: MovePCPokemonToPartyPacket(pokemon.uuid, source, clickedPosition)
packet.sendToServer()
playSound(CobblemonSounds.PC_DROP)
movePending = true
}
else -> Unit
}
return
}
// Reset release confirmation
displayConfirmRelease = false
// Clicking on itself, so unselect position
if (selectedPosition == clickedPosition) {
if (this.selectedPosition != null && this.selectedPosition == clickedPosition) {
if (grabbedSlot != null) playSound(CobblemonSounds.PC_DROP)
resetSelected()
return
}
// Check for selecting a Pokémon
val clickedPokemon = when(button) {
is BoxStorageSlot -> pc.get(clickedPosition as PCPosition)
is PartyStorageSlot -> party.get(clickedPosition as PartyPosition)
else -> null
}
val selectOverride = pcGui.configuration.selectOverride
if (selectOverride != null) {
selectOverride(pcGui, clickedPosition, clickedPokemon)
@@ -593,47 +420,59 @@ class StorageWidget(
}
}
if (clickedPosition is PCPosition) {
val column = clickedPosition.slot % 6
val row = clickedPosition.slot / 6
multiSelection = PCMultiSelection(1, 1, clickedPosition.box, column, row).also {
it.setPokemon(0, 0, clickedPokemon)
}
playSound(CobblemonSounds.PC_GRAB)
return
} else if (clickedPosition is PartyPosition) {
this.selectedPosition = clickedPosition
this.pcGui.setPreviewPokemon(clickedPokemon, pcGui.isPreviewInParty ?: false)
grabbedSlot = GrabbedStorageSlot(
x = button.x,
y = button.y,
parent = this,
pokemon = clickedPokemon
)
playSound(CobblemonSounds.PC_GRAB)
}
this.selectedPosition = clickedPosition
this.pcGui.setPreviewPokemon(clickedPokemon, pcGui.isPreviewInParty ?: false)
grabbedSlot = GrabbedStorageSlot(
x = button.x,
y = button.y,
parent = this,
pokemon = clickedPokemon
)
playSound(CobblemonSounds.PC_GRAB)
}
} else {
val sourcePosition = selectedPosition ?: return
val selectedPokemon = party.get(sourcePosition) ?: return
// Handle movement within the Box
val selectedPokemon = when(this.selectedPosition) {
is PCPosition -> pc.get(this.selectedPosition as PCPosition)
is PartyPosition -> party.get(this.selectedPosition as PartyPosition)
else -> null
} ?: return
// Box to Box
if (this.selectedPosition is PCPosition && clickedPosition is PCPosition) {
val packet = clickedPokemon?.let { SwapPCPokemonPacket(it.uuid, clickedPosition, selectedPokemon.uuid, this.selectedPosition as PCPosition) }
?: MovePCPokemonPacket(selectedPokemon.uuid, selectedPosition as PCPosition, clickedPosition)
packet.sendToServer()
playSound(CobblemonSounds.PC_DROP)
resetSelected()
}
// Box to Party
else if (this.selectedPosition is PCPosition && clickedPosition is PartyPosition) {
val packet = clickedPokemon?.let { SwapPCPartyPokemonPacket(clickedPokemon.uuid, clickedPosition, selectedPokemon.uuid, this.selectedPosition as PCPosition) }
?: MovePCPokemonToPartyPacket(selectedPokemon.uuid, this.selectedPosition as PCPosition, clickedPosition)
packet.sendToServer()
playSound(CobblemonSounds.PC_DROP)
resetSelected()
}
// Party to Box
if (clickedPosition is PCPosition) {
else if (this.selectedPosition is PartyPosition && clickedPosition is PCPosition) {
if (ServerSettings.preventCompletePartyDeposit && this.party.filterNotNull().size == 1 && clickedPokemon == null) {
return
}
val packet = clickedPokemon?.let { SwapPCPartyPokemonPacket(selectedPokemon.uuid, sourcePosition, clickedPokemon.uuid, clickedPosition) }
?: MovePartyPokemonToPCPacket(selectedPokemon.uuid, sourcePosition, clickedPosition)
val packet = clickedPokemon?.let { SwapPCPartyPokemonPacket(selectedPokemon.uuid, this.selectedPosition as PartyPosition, clickedPokemon.uuid, clickedPosition) }
?: MovePartyPokemonToPCPacket(selectedPokemon.uuid, this.selectedPosition as PartyPosition, clickedPosition)
packet.sendToServer()
playSound(CobblemonSounds.PC_DROP)
movePending = true
resetSelected()
}
// Party to Party
else if (clickedPosition is PartyPosition) {
val packet = clickedPokemon?.let { SwapPartyPokemonPacket(it.uuid, clickedPosition, selectedPokemon.uuid, sourcePosition) }
?: MovePartyPokemonPacket(selectedPokemon.uuid, sourcePosition, clickedPosition)
else if (this.selectedPosition is PartyPosition && clickedPosition is PartyPosition) {
val packet = clickedPokemon?.let { SwapPartyPokemonPacket(it.uuid, clickedPosition, selectedPokemon.uuid, this.selectedPosition as PartyPosition) }
?: MovePartyPokemonPacket(selectedPokemon.uuid, selectedPosition as PartyPosition, clickedPosition)
packet.sendToServer()
playSound(CobblemonSounds.PC_DROP)
movePending = true
resetSelected()
}
}
}
@@ -641,37 +480,6 @@ class StorageWidget(
fun resetSelected() {
selectedPosition = null
grabbedSlot = null
multiSelection = null
multiGrabbedSlots.clear()
displayConfirmRelease = false
pcGui.setPreviewPokemon(null)
}
// annoyingly complex solution, but server/client desync causes flashing when moving pokemon. this should fix it
// if you can think of a simpler solution, feel free to implement it
private fun updatePendingMove() {
if (!movePending) return
val selection = multiSelection
if (selection != null) {
val updated = selection.pokemonEntries().any { (column, row, pokemon) ->
val source = PCPosition(selection.sourceBox, (selection.sourceRow + row) * 6 + selection.sourceColumn + column)
pc.get(source)?.uuid != pokemon.uuid
}
if (updated) {
movePending = false
resetSelected()
}
return
}
val source = selectedPosition
val pokemon = grabbedSlot?.getPokemon()
if (source != null && pokemon != null) {
if (party.get(source)?.uuid != pokemon.uuid) {
movePending = false
resetSelected()
}
}
}
}
@@ -1,48 +0,0 @@
/*
* 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://www.mozilla.org/MPL/2.0/.
*/
package com.cobblemon.mod.common.net.messages.server.storage.pc
import com.cobblemon.mod.common.api.net.NetworkPacket
import com.cobblemon.mod.common.api.storage.pc.PCStore
import com.cobblemon.mod.common.util.cobblemonResource
import com.cobblemon.mod.common.util.readPCPosition
import com.cobblemon.mod.common.util.writePCPosition
import net.minecraft.network.RegistryFriendlyByteBuf
class MovePCPokemonBatchPacket(val moves: List<PCStore.PCPokemonMove>) : NetworkPacket<MovePCPokemonBatchPacket> {
override val id = ID
override fun encode(buffer: RegistryFriendlyByteBuf) {
buffer.writeVarInt(moves.size)
moves.forEach { move ->
buffer.writeUUID(move.pokemonID)
buffer.writePCPosition(move.oldPosition)
buffer.writePCPosition(move.newPosition)
}
}
companion object {
val ID = cobblemonResource("move_pc_pokemon_batch")
const val MAX_MOVES = 60
fun decode(buffer: RegistryFriendlyByteBuf): MovePCPokemonBatchPacket {
val size = buffer.readVarInt()
require(size in 1..MAX_MOVES) { "Invalid batch PC move size: $size" }
return MovePCPokemonBatchPacket(
List(size) {
PCStore.PCPokemonMove(
pokemonID = buffer.readUUID(),
oldPosition = buffer.readPCPosition(),
newPosition = buffer.readPCPosition()
)
}
)
}
}
}
@@ -1,24 +0,0 @@
/*
* 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://www.mozilla.org/MPL/2.0/.
*/
package com.cobblemon.mod.common.net.serverhandling.storage.pc
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
import com.cobblemon.mod.common.api.storage.pc.PCStore
import com.cobblemon.mod.common.api.storage.pc.link.PCLinkManager
import com.cobblemon.mod.common.net.messages.client.storage.pc.ClosePCPacket
import com.cobblemon.mod.common.net.messages.server.storage.pc.MovePCPokemonBatchPacket
import net.minecraft.server.MinecraftServer
import net.minecraft.server.level.ServerPlayer
object MovePCPokemonBatchHandler : ServerNetworkPacketHandler<MovePCPokemonBatchPacket> {
override fun handle(packet: MovePCPokemonBatchPacket, server: MinecraftServer, player: ServerPlayer) {
val pc = PCLinkManager.getPC(player) ?: return run { ClosePCPacket(null).sendToPlayer(player) }
pc.moveBatch(packet.moves.map { PCStore.PCPokemonMove(it.pokemonID, it.oldPosition, it.newPosition) })
}
}
@@ -1,6 +0,0 @@
{
"accessWidener": "cobblemon-common.accesswidener",
"injected_interfaces": {
"net/minecraft/class_630": ["com/cobblemon/mod/common/client/render/models/blockbench/pose/Bone"]
}
}
@@ -1299,7 +1299,6 @@
"cobblemon.ui.pc.filter.tooltip": "Format: pikachu shiny held_item lvl=1...",
"cobblemon.ui.pc.options": "Options",
"cobblemon.ui.pc.release": "Release",
"cobblemon.ui.pc.release_all": "Release All",
"cobblemon.ui.sort.name": "Sort by name",
"cobblemon.ui.sort.level": "Sort by level",
"cobblemon.ui.sort.pokedex_number": "Sort by Pokédex number",
Binary file not shown.

Before

Width:  |  Height:  |  Size: 548 B

+130 -97
View File
@@ -8,139 +8,172 @@
*
*/
import utilities.ACCESS_WIDENER
import utilities.DEV_CLIENT_ARGS
import utilities.copyJarToRootLibs
configurations.all {
resolutionStrategy {
force(libs.fabric.loader)
}
resolutionStrategy {
force(libs.fabric.loader)
}
}
plugins {
id("cobblemon.platform-conventions")
id("cobblemon.publish-conventions")
id("cobblemon.platform-conventions")
id("cobblemon.publish-conventions")
id("fabric-loom")
}
architectury {
platformSetupLoomIde()
fabric()
loom {
accessWidenerPath.set(project(":common").file(ACCESS_WIDENER))
mixin.useLegacyMixinAp.set(false)
runConfigs.configureEach { isIdeConfigGenerated = true }
runConfigs.named("client") {
runDir = "runClient"
// vmArg("-Dmixin.debug=true")
programArgs(DEV_CLIENT_ARGS)
}
runConfigs.named("server") {
runDir = "runServer"
}
mods.maybeCreate("main").apply {
sourceSet(sourceSets.main.get())
sourceSet("main", project(":common"))
}
}
val generatedResources = file("src/generated/resources")
sourceSets.main {
resources {
srcDir(generatedResources)
}
resources {
srcDir(generatedResources)
}
}
repositories {
maven(url = "${rootProject.projectDir}/deps")
mavenLocal()
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven(url = "https://api.modrinth.com/maven")
maven(url = "https://maven.terraformersmc.com/releases/")
maven(url = "${rootProject.projectDir}/deps")
mavenLocal()
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven(url = "https://api.modrinth.com/maven")
maven(url = "https://maven.terraformersmc.com/releases/")
}
dependencies {
implementation(project(":common", configuration = "namedElements")) {
isTransitive = false
}
bundle(project(path = ":common", configuration = "transformProductionFabric")) {
isTransitive = false
}
modLocalRuntime(libs.fabric.debugutils)
modImplementation(libs.fabric.loader)
modApi(libs.fabric.api)
modApi(libs.bundles.fabric)
minecraft("net.minecraft:minecraft:${rootProject.property("mc_version")}")
mappings(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${libs.versions.parchment.minecraft.get()}:${libs.versions.parchment.mappings.get()}@zip")
})
modLocalRuntime(libs.fabric.debugutils)
modImplementation(libs.fabric.loader)
modApi(libs.fabric.api)
modApi(libs.bundles.fabric)
modCompileOnly(libs.bundles.common.integrations.compileOnly) {
isTransitive = false
}
modCompileOnly(libs.bundles.common.integrations.compileOnly) {
isTransitive = false
}
modImplementation(libs.bundles.fabric.integrations.implementation)
modRuntimeOnly(libs.bundles.fabric.integrations.runtimeOnly)
modRuntimeOnly(libs.bundles.mongo)
modImplementation(libs.bundles.fabric.integrations.implementation)
modRuntimeOnly(libs.bundles.fabric.integrations.runtimeOnly)
modRuntimeOnly(libs.bundles.mongo)
// modImplementation(libs.flywheelFabric)
// include(libs.flywheelFabric)
listOf(
libs.fabric.kotlin,
libs.bundles.graal,
libs.bundles.mongo
).forEach {
include(it)
}
listOf(
libs.fabric.kotlin,
libs.bundles.graal,
libs.bundles.mongo
).forEach {
include(it)
}
// Added to make graal available in dev
modRuntimeOnly(libs.bundles.graal)
modRuntimeOnly(libs.bundles.graal)
include(libs.fabric.kotlin)
include(libs.fabric.kotlin)
listOf(
libs.molang
).forEach {
bundle(it)
runtimeOnly(it)
}
listOf(
libs.molang
).forEach {
bundle(it)
runtimeOnly(it)
}
minecraftServerLibraries(libs.icu4j)
minecraftServerLibraries(libs.icu4j)
// fabric version of AppleSkin api is broken, so we modCompileOnly the mod
modCompileOnly(libs.appleskin.api.fabric) {
exclude(module = "modmenu")
}
// fabric version of AppleSkin api is broken, so we modCompileOnly the mod
modCompileOnly(libs.appleskin.api.fabric) {
exclude(module = "modmenu")
}
}
publishing {
publications.named<MavenPublication>(project.name) {
pom.withXml {
val root = asNode()
val depsNode = (root["dependencies"] as? groovy.util.NodeList)
?.firstOrNull() as? groovy.util.Node
?: root.appendNode("dependencies")
publications.named<MavenPublication>(project.name) {
artifact(tasks.remapJar)
artifact(tasks.remapSourcesJar)
configurations.getByName("include").allDependencies
.filterIsInstance<ExternalModuleDependency>()
.forEach { dep ->
depsNode.appendNode("dependency").apply {
appendNode("groupId", dep.group)
appendNode("artifactId", dep.name)
appendNode("version", dep.version)
appendNode("scope", "compile")
}
}
}
}
@Suppress("UnstableApiUsage")
loom.disableDeprecatedPomGeneration(this)
pom.withXml {
val root = asNode()
val depsNode = (root["dependencies"] as? groovy.util.NodeList)
?.firstOrNull() as? groovy.util.Node
?: root.appendNode("dependencies")
configurations.getByName("include").allDependencies
.filterIsInstance<ExternalModuleDependency>()
.forEach { dep ->
depsNode.appendNode("dependency").apply {
appendNode("groupId", dep.group)
appendNode("artifactId", dep.name)
appendNode("version", dep.version)
appendNode("scope", "compile")
}
}
}
}
}
tasks {
// The AW file is needed in :fabric project resources when the game is run.
val copyAccessWidener by registering(Copy::class) {
from(loom.accessWidenerPath)
into(generatedResources)
dependsOn(checkLicenseMain)
}
val copyAccessWidener by registering(Copy::class) {
description = ""
from(loom.accessWidenerPath)
into(generatedResources)
dependsOn(checkLicenseMain)
}
processResources {
dependsOn(copyAccessWidener)
inputs.property("version", rootProject.version)
inputs.property("fabric_loader_version", libs.fabric.loader.get().version)
inputs.property("fabric_api_version", libs.fabric.api.get().version)
inputs.property("minecraft_version", rootProject.property("mc_version").toString())
inputs.property("java_version", rootProject.property("java_version").toString())
processResources {
dependsOn(copyAccessWidener)
inputs.property("version", rootProject.version)
inputs.property("fabric_loader_version", libs.versions.fabric.loader.get())
inputs.property("fabric_api_version", libs.versions.fabric.api.get())
inputs.property("minecraft_version", rootProject.property("mc_version").toString())
inputs.property("java_version", rootProject.property("java_version").toString())
filesMatching("fabric.mod.json") {
expand(
"version" to rootProject.version,
"fabric_loader_version" to libs.fabric.loader.get().version,
"fabric_api_version" to libs.fabric.api.get().version,
"minecraft_version" to rootProject.property("mc_version").toString(),
"java_version" to rootProject.property("java_version").toString()
)
}
}
filesMatching("fabric.mod.json") {
expand(
"version" to rootProject.version,
"fabric_loader_version" to libs.versions.fabric.loader.get(),
"fabric_api_version" to libs.versions.fabric.api.get(),
"minecraft_version" to rootProject.property("mc_version").toString(),
"java_version" to rootProject.property("java_version").toString()
)
}
}
sourcesJar {
dependsOn(copyAccessWidener)
}
sourcesJar {
dependsOn(copyAccessWidener)
}
remapJar {
dependsOn(shadowJar)
inputFile.set(shadowJar.flatMap { it.archiveFile })
archiveBaseName.set("Cobblemon-${project.name}")
archiveVersion.set("${rootProject.version}")
}
}
copyJarToRootLibs(tasks.remapJar)
-1
View File
@@ -9,7 +9,6 @@ group=com.cobblemon.mod
# API
mc_version = 1.21.1
parchment_version = 2024.07.28@zip
# Used in mod files
java_version = 21
+2 -3
View File
@@ -4,9 +4,8 @@ plugins {
repositories {
gradlePluginPortal()
maven("https://maven.architectury.dev/")
maven("https://maven.fabricmc.net/")
maven("https://maven.minecraftforge.net/")
maven("https://maven.neoforged.net/releases/")
maven("https://maven.terraformersmc.com/releases/")
}
@@ -16,7 +15,7 @@ dependencies {
implementation(libs.licenser)
implementation(libs.shadow)
implementation(libs.loom)
implementation(libs.architectury)
implementation(libs.neoforge.moddev)
implementation(libs.blossom)
implementation(libs.ideaExt)
+1 -2
View File
@@ -4,9 +4,8 @@ pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
maven("https://maven.architectury.dev/")
maven("https://maven.fabricmc.net/")
maven("https://maven.minecraftforge.net/")
maven("https://maven.neoforged.net/releases/")
maven("https://repo.papermc.io/repository/maven-public/")
}
}
@@ -10,16 +10,13 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import utilities.ACCESS_WIDENER
plugins {
id("java")
id("java-library")
id("java")
id("java-library")
id("org.cadixdev.licenser")
id("dev.architectury.loom")
id("architectury-plugin")
kotlin("jvm")
id("net.neoforged.licenser")
kotlin("jvm")
}
group = rootProject.group
@@ -27,68 +24,46 @@ version = rootProject.version
description = rootProject.description
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
repositories {
mavenCentral()
//JEI
maven("https://maven.blamejared.com/")
maven("https://maven.parchmentmc.org")
mavenCentral()
//JEI
maven("https://maven.blamejared.com/")
maven("https://maven.parchmentmc.org")
// AppleSkin
maven("https://maven.ryanliptak.com/")
// AppleSkin
maven("https://maven.ryanliptak.com/")
}
license {
header(rootProject.file("HEADER"))
include("**/*.kt", "**/*.java")
}
architectury {
minecraft = project.property("mc_version").toString()
compileOnly()
}
loom {
silentMojangMappingsLicense()
accessWidenerPath.set(project(":common").file(ACCESS_WIDENER))
}
dependencies {
minecraft("net.minecraft:minecraft:${rootProject.property("mc_version")}")
mappings(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-1.21:${rootProject.property("parchment_version")}")
})
header(rootProject.file("HEADER"))
include("**/*.kt", "**/*.java")
}
tasks {
withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(21)
options.compilerArgs.add("-Xlint:-processing,-classfile,-serial")
}
withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(21)
options.compilerArgs.add("-Xlint:-processing,-classfile,-serial")
}
withType<KotlinCompile> {
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
}
withType<KotlinCompile> {
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
}
withType<Jar> {
from(rootProject.file("LICENSE"))
}
withType<Jar> {
from(rootProject.file("LICENSE"))
}
// Dev/intermediate jars only feed remapJar, which writes the compressed release jar.
// Deflating ~250MB of already-compressed assets at every stage is wasted time.
named<Jar>("jar") {
entryCompression = ZipEntryCompression.STORED
}
named<Jar>("jar") {
entryCompression = ZipEntryCompression.STORED
}
// Assets/data are ~250MB and already ship in the main jar; copying and remapping them
// into sources jars cost minutes per build.
withType<Jar>().named { it == "sourcesJar" }.configureEach {
exclude("assets/**", "data/**")
}
withType<Jar>().named { it == "sourcesJar" }.configureEach {
exclude("assets/**", "data/**")
}
}
@@ -2,73 +2,42 @@ import utilities.VersionType
import utilities.writeVersion
plugins {
id("cobblemon.base-conventions")
id("com.github.johnrengelman.shadow")
id("cobblemon.base-conventions")
id("com.gradleup.shadow")
}
writeVersion(type = VersionType.FULL)
evaluationDependsOn(":common")
val commonMain: SourceSet = project(":common").sourceSets.main.get()
val bundle: Configuration by configurations.creating {
isCanBeConsumed = false
isCanBeResolved = true
isCanBeConsumed = false
isCanBeResolved = true
}
loom {
val clientConfig = runConfigs.getByName("client")
clientConfig.runDir = "runClient"
// clientConfig.vmArg("-Dmixin.debug=true")
clientConfig.programArg("--username=AshKetchum")
//This is AshKetchum's UUID so you get an Ash Ketchum skin
clientConfig.programArg("--uuid=93e4e551-589a-41cb-ab2d-435266c8e035")
val serverConfig = runConfigs.getByName("server")
serverConfig.runDir = "runServer"
// Forge established the "main" name convention we're using here. Since NeoForged already defines it we must use
// `maybeCreate`
mods.maybeCreate("main")
// This configurations ensures that the code and resources in :common are available to the platform-specific builds
// in specifically the development mode. This code does nothing for the final packed jar since that one uses shadow
// bundling / jar-in-jar magic to make sure the platform-specific jar has all relevant files available.
mods.named("main") {
sourceSet(project.sourceSets.main.get())
sourceSet(project(":common").sourceSets.main.get())
}
dependencies {
"compileOnly"(project(":common"))
"runtimeOnly"(files(commonMain.output))
}
tasks {
jar {
archiveBaseName.set("Cobblemon-${project.name}")
archiveClassifier.set("dev-slim")
from(commonMain.output)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
jar {
archiveBaseName.set("Cobblemon-${project.name}")
archiveClassifier.set("dev-slim")
}
shadowJar {
archiveClassifier.set("dev-shadow")
entryCompression = ZipEntryCompression.STORED
archiveBaseName.set("Cobblemon-${project.name}")
configurations = listOf(bundle)
mergeServiceFiles()
relocate ("com.oracle", "com.cobblemon.mod.relocations.oracle")
}
remapJar {
dependsOn(shadowJar)
inputFile.set(shadowJar.flatMap { it.archiveFile })
archiveBaseName.set("Cobblemon-${project.name}")
archiveVersion.set("${rootProject.version}")
}
val copyJar by registering(CopyFile::class) {
val productionJar = tasks.remapJar.flatMap { it.archiveFile }
fileToCopy = productionJar
destination = productionJar.flatMap {
rootProject.layout.buildDirectory.file("libs/${it.asFile.name}")
}
}
assemble {
dependsOn(copyJar)
}
shadowJar {
archiveClassifier.set("dev-shadow")
entryCompression = ZipEntryCompression.STORED
archiveBaseName.set("Cobblemon-${project.name}")
from(commonMain.output)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
configurations.set(listOf(bundle))
mergeServiceFiles()
relocate("com.oracle", "com.cobblemon.mod.relocations.oracle")
}
}
@@ -1,61 +1,54 @@
import utilities.VersionType
import utilities.isSnapshot
import utilities.gitCommit
import utilities.isSnapshot
import utilities.writeVersion
plugins {
id("java")
id("java-library")
id("maven-publish")
id("dev.architectury.loom")
id("java")
id("java-library")
id("maven-publish")
}
java {
withSourcesJar()
withJavadocJar()
withSourcesJar()
withJavadocJar()
}
publishing {
repositories {
maven("https://maven.impactdev.net/repository/development/") {
name = "ImpactDev-Public"
credentials {
username = System.getenv("COBBLEMON_MAVEN_USER")
password = System.getenv("COBBLEMON_MAVEN_PASSWORD")
}
}
repositories {
maven("https://maven.impactdev.net/repository/development/") {
name = "ImpactDev-Public"
credentials {
username = System.getenv("COBBLEMON_MAVEN_USER")
password = System.getenv("COBBLEMON_MAVEN_PASSWORD")
}
}
maven {
val snapshot = project.isSnapshot()
maven {
val snapshot = project.isSnapshot()
val releases = uri("https://artefacts.cobblemon.com/releases")
val snapshots = uri("https://artefacts.cobblemon.com/snapshots")
val releases = uri("https://artefacts.cobblemon.com/releases")
val snapshots = uri("https://artefacts.cobblemon.com/snapshots")
url = if (snapshot) snapshots else releases
name = "Reposilite.${if (snapshot) "Snapshots" else "Releases"}"
credentials {
username = System.getenv("COBBLEMON_REPOSILITE_USERNAME")
password = System.getenv("COBBLEMON_REPOSILITE_PASSWORD")
}
}
}
url = if (snapshot) snapshots else releases
name = "Reposilite.${if (snapshot) "Snapshots" else "Releases"}"
credentials {
username = System.getenv("COBBLEMON_REPOSILITE_USERNAME")
password = System.getenv("COBBLEMON_REPOSILITE_PASSWORD")
}
}
}
publications {
create<MavenPublication>(project.name) {
artifact(tasks.remapJar)
artifact(tasks.remapSourcesJar)
@Suppress("UnstableApiUsage")
loom.disableDeprecatedPomGeneration(this)
groupId = "com.cobblemon"
artifactId = project.findProperty("maven.artifactId")?.toString() ?: project.name
version = project.writeVersion(VersionType.PUBLISHING)
pom {
properties = mapOf(
"gitCommit" to project.gitCommit()
)
}
}
}
publications {
create<MavenPublication>(project.name) {
groupId = "com.cobblemon"
artifactId = project.findProperty("maven.artifactId")?.toString() ?: project.name
version = project.writeVersion(VersionType.PUBLISHING)
pom {
properties = mapOf(
"gitCommit" to project.gitCommit()
)
}
}
}
}
@@ -0,0 +1,51 @@
package utilities
import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.*
/**
* Converts a named-namespace access widener into a NeoForge access transformer, so the AW stays the single source of
* truth for both loaders.
*/
@CacheableTask
abstract class AccessWidenerToTransformer : DefaultTask() {
@get:InputFile
@get:PathSensitive(PathSensitivity.NONE)
abstract val accessWidener: RegularFileProperty
@get:OutputFile
abstract val accessTransformer: RegularFileProperty
@TaskAction
fun convert() {
val lines = convert(accessWidener.get().asFile.readLines())
accessTransformer.get().asFile.apply { parentFile.mkdirs() }.writeText(lines.joinToString("\n", postfix = "\n"))
}
companion object {
fun convert(awLines: List<String>): List<String> {
val entries = LinkedHashMap<String, Boolean>()
for (raw in awLines.drop(1)) {
val parts = raw.substringBefore('#').trim().split(Regex("\\s+")).filter { it.isNotEmpty() }
if (parts.isEmpty()) continue
val access = parts[0].removePrefix("transitive-")
val owner = parts[2].replace('/', '.')
val target = when (parts[1]) {
"class" -> owner
"method" -> "$owner ${parts[3]}${parts[4]}"
"field" -> "$owner ${parts[3]}"
else -> error("Unknown access widener target '${parts[1]}' in: $raw")
}
entries[target] = when (access) {
"accessible" -> entries[target] ?: false
"extendable" -> true
else -> error("Unsupported access widener access '$access' in: $raw")
}
}
return entries.map { (target, extendable) ->
"${if (extendable) "public-f" else "public"} $target"
}
}
}
}
@@ -0,0 +1,5 @@
package utilities
const val ACCESS_WIDENER = "src/main/resources/cobblemon-common.accesswidener"
val DEV_CLIENT_ARGS = listOf("--username=AshKetchum", "--uuid=93e4e551-589a-41cb-ab2d-435266c8e035")
@@ -1,21 +1,36 @@
package utilities
import org.gradle.api.DefaultTask
import org.gradle.api.Project
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.bundling.AbstractArchiveTask
import org.gradle.work.DisableCachingByDefault
@DisableCachingByDefault(because = "Not worth caching")
abstract class CopyFile : DefaultTask() {
@get:InputFile
abstract val fileToCopy: RegularFileProperty
@get:InputFile
abstract val fileToCopy: RegularFileProperty
@get:OutputFile
abstract val destination: RegularFileProperty
@get:OutputFile
abstract val destination: RegularFileProperty
@TaskAction
fun copyFile() {
destination.get().asFile.parentFile.mkdirs()
fileToCopy.get().asFile.copyTo(destination.get().asFile, overwrite = true)
}
}
@TaskAction
fun copyFile() {
destination.get().asFile.parentFile.mkdirs()
fileToCopy.get().asFile.copyTo(destination.get().asFile, overwrite = true)
}
}
/** Copies the release jar into the root project's build/libs as part of `assemble`. */
fun Project.copyJarToRootLibs(productionJarTask: TaskProvider<out AbstractArchiveTask>) {
val copyJar = tasks.register("copyJar", CopyFile::class.java) {
val productionJar = productionJarTask.flatMap { it.archiveFile }
fileToCopy.set(productionJar)
destination.set(productionJar.flatMap { rootProject.layout.buildDirectory.file("libs/${it.asFile.name}") })
}
tasks.named("assemble") { dependsOn(copyJar) }
}
@@ -1,3 +0,0 @@
package utilities
const val ACCESS_WIDENER = "src/main/resources/cobblemon-common.accesswidener"
+18 -11
View File
@@ -3,17 +3,21 @@
kotlin = "2.2.20"
# Plugins
licenser = "0.6.1"
shadow = "8.1.1"
licenser = "0.7.5"
shadow = "9.6.1"
blossom = "2.1.0"
idea-ext = "1.1.7"
# Minecraft Development
loom = "1.11-SNAPSHOT"
architectury-plugin = "3.4-SNAPSHOT"
moddev = "1.0.11"
loom = "1.17-SNAPSHOT"
moddev = "2.0.149"
neoform = "1.21.1-20240808.144430"
parchment-minecraft = "1.21.1"
parchment-mappings = "2024.11.17"
# Common
sponge-mixin = "0.16.3+mixin.0.8.7"
mixinextras = "0.5.5"
molang = "1.1.21"
jei-api = "19.22.1.316"
appleskin-api = "mc1.21-3.0.5"
@@ -52,13 +56,12 @@ classgraph = "4.8.179"
[libraries]
# General Buildscript Plugins
kotlin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
loom = { group = "dev.architectury", name = "architectury-loom", version.ref = "loom" }
loom = { group = "net.fabricmc", name = "fabric-loom", version.ref = "loom" }
neoforge-moddev = { group = "net.neoforged", name = "moddev-gradle", version.ref = "moddev" }
architectury = { group = "architectury-plugin", name = "architectury-plugin.gradle.plugin", version.ref = "architectury-plugin" }
shadow = { group = "com.github.johnrengelman", name = "shadow", version.ref = "shadow" }
shadow = { group = "com.gradleup.shadow", name = "shadow-gradle-plugin", version.ref = "shadow" }
blossom = { group = "net.kyori", name = "blossom", version.ref = "blossom" }
ideaExt = { group = "org.jetbrains.gradle.plugin.idea-ext", name = "org.jetbrains.gradle.plugin.idea-ext.gradle.plugin", version.ref = "idea-ext"}
licenser = { group = "gradle.plugin.org.cadixdev.gradle", name = "licenser", version.ref = "licenser" }
licenser = { group = "net.neoforged.licenser", name = "net.neoforged.licenser.gradle.plugin", version.ref = "licenser" }
# Kotlin
kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlin" }
@@ -66,6 +69,8 @@ kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", vers
# Common
jei-api = { group = "mezz.jei", name = "jei-1.21.1-common-api", version.ref = "jei-api"}
sponge-mixin = { group = "net.fabricmc", name = "sponge-mixin", version.ref = "sponge-mixin" }
mixinextras-common = { group = "io.github.llamalad7", name = "mixinextras-common", version.ref = "mixinextras" }
molang = { group = "local.com.bedrockk", name = "molang", version.ref = "molang" }
# Graal
@@ -101,13 +106,15 @@ mongo-driver-core = { group = "org.mongodb", name = "mongodb-driver-core", versi
mongo-driver-sync = { group = "org.mongodb", name = "mongodb-driver-sync", version.ref = "mongo" }
# Testing
junit-fabric = { group = "net.fabricmc", name = "fabric-loader-junit", version.ref = "fabric-loader" }
junit-jupiter = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junit" }
junit-platform-launcher = { group = "org.junit.platform", name = "junit-platform-launcher" }
junit-params = { group = "org.junit.jupiter", name = "junit-jupiter-params", version.ref = "junit" }
mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockito" }
mock-kotlin = { group = "io.mockk", name = "mockk", version.ref = "mockk" }
classgraph = { group = "io.github.classgraph", name = "classgraph", version.ref = "classgraph" }
[bundles]
common-compileOnly = [ "sponge-mixin", "mixinextras-common" ]
kotlin = [ "kotlin-stdlib", "kotlin-reflect" ]
fabric = [ "fabric-kotlin", "fabric-permissions" ]
common-integrations-compileOnly = [ "adorn-fabric", "jei-api" ]
@@ -115,6 +122,6 @@ fabric-integrations-implementation = [ "mod-menu" ]
fabric-integrations-runtimeOnly = [ "jei-fabric", "c2me-fabric" ]
neoforge-integrations-runtimeOnly = [ "jei-neoforge", "c2me-neoforge" ]
mongo = [ "mongo-driver-core", "mongo-driver-sync" ]
unitTesting = [ "junit-fabric", "junit-params", "mockito-core", "mock-kotlin", "classgraph" ]
unitTesting = [ "junit-jupiter", "junit-params", "mockito-core", "mock-kotlin", "classgraph" ]
graal = [ "graal-core", "graal-sdk", "graal-regex", "graal-truffle", "icu4j" ]
Binary file not shown.
+3 -1
View File
@@ -1,7 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.9.3-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+9 -10
View File
@@ -1,7 +1,7 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,10 +15,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
# gradlew start up script for POSIX generated by Gradle.
#
# Important for running:
#
@@ -27,7 +29,7 @@
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
# ksh gradlew
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -112,7 +114,6 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -170,7 +171,6 @@ fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
@@ -203,15 +203,14 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
Vendored
+54 -34
View File
@@ -13,16 +13,45 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem gradlew startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Set local scope for the variables, and ensure extensions are enabled
setlocal EnableExtensions
@rem Catch executions from older scripts and ensure they exit cleanly.
@rem This can be removed once we can be reasonably confident that few people
@rem will be migrating directly to this new wrapper.
goto afterSafetyNet
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto exitWithErrorLevel
:afterSafetyNet
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@@ -43,13 +72,14 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
1>&2 echo.
1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
1>&2 echo.
1>&2 echo Please set the JAVA_HOME variable in your environment to match the
1>&2 echo location of your Java installation.
goto fail
"%COMSPEC%" /c exit 1
goto exitWithErrorLevel
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
@@ -57,36 +87,26 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
1>&2 echo.
1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
1>&2 echo.
1>&2 echo Please set the JAVA_HOME variable in your environment to match the
1>&2 echo location of your Java installation.
goto fail
"%COMSPEC%" /c exit 1
goto exitWithErrorLevel
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
@rem Execute gradlew
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
@rem which allows us to clear the local environment before executing the java command
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel & goto exitWithErrorLevel
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@rem This label must not be changed. We rely on old scripts being able to jump to this point.
:exitWithErrorLevel
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
"%COMSPEC%" /c exit %ERRORLEVEL%
+122 -78
View File
@@ -8,111 +8,155 @@
*
*/
import utilities.ACCESS_WIDENER
import utilities.AccessWidenerToTransformer
import utilities.DEV_CLIENT_ARGS
import utilities.copyJarToRootLibs
plugins {
id("cobblemon.platform-conventions")
id("cobblemon.publish-conventions")
id("cobblemon.platform-conventions")
id("cobblemon.publish-conventions")
id("net.neoforged.moddev")
}
architectury {
platformSetupLoomIde()
neoForge()
val generateAccessTransformer by tasks.registering(AccessWidenerToTransformer::class) {
description = "AW to AT"
accessWidener = project(":common").file(ACCESS_WIDENER)
accessTransformer = layout.buildDirectory.file("generated/accesstransformer/META-INF/accesstransformer.cfg")
}
loom {
neoForge {
val localRuntime: Configuration by configurations.creating
configurations.runtimeClasspath { extendsFrom(localRuntime) }
}
neoForge {
enable {
version = libs.versions.neoforge.get()
isDisableRecompilation = true
}
parchment {
minecraftVersion = libs.versions.parchment.minecraft.get()
mappingsVersion = libs.versions.parchment.mappings.get()
}
accessTransformers.from(generateAccessTransformer.flatMap { it.accessTransformer })
runs {
create("client") {
client()
gameDirectory = file("runClient")
// jvmArgument("-Dmixin.debug=true")
programArguments.addAll(DEV_CLIENT_ARGS)
}
create("server") {
server()
gameDirectory = file("runServer")
}
}
mods {
create("cobblemon") {
sourceSet(sourceSets.main.get())
sourceSet(project(":common").sourceSets.main.get())
}
}
}
repositories {
maven(url = "${rootProject.projectDir}/deps")
maven(url = "https://thedarkcolour.github.io/KotlinForForge/")
maven(url = "https://api.modrinth.com/maven")
maven(url = "https://maven.neoforged.net/releases")
mavenLocal()
maven(url = "${rootProject.projectDir}/deps")
maven(url = "https://thedarkcolour.github.io/KotlinForForge/")
maven(url = "https://api.modrinth.com/maven")
maven(url = "https://maven.neoforged.net/releases")
mavenLocal()
}
dependencies {
neoForge(libs.neoforge.api)
//shadowCommon group: 'commons-io', name: 'commons-io', version: '2.6'
//modImplementation(libs.flywheelForge)
//include(libs.flywheelForge)
modLocalRuntime(libs.neoforge.debugutils)
modRuntimeOnly(libs.bundles.neoforge.integrations.runtimeOnly)
modRuntimeOnly(libs.bundles.mongo)
forgeRuntimeLibrary(libs.bundles.mongo)
//shadowCommon group: 'commons-io', name: 'commons-io', version: '2.6'
//modImplementation(libs.flywheelForge)
//include(libs.flywheelForge)
localRuntime(libs.neoforge.debugutils)
runtimeOnly(libs.bundles.neoforge.integrations.runtimeOnly)
runtimeOnly(libs.bundles.mongo)
"additionalRuntimeClasspath"(libs.bundles.mongo)
implementation(libs.neo.kotlin.forge)
implementation(libs.neo.kotlin.forge)
implementation(project(":common", configuration = "namedElements")) {
isTransitive = false
}
bundle(project(path = ":common", configuration = "transformProductionNeoForge")) {
isTransitive = false
}
testImplementation(project(":common", configuration = "namedElements"))
testImplementation(project(":common"))
listOf(
libs.bundles.mongo
).forEach {
include(it)
}
modRuntimeOnly(libs.bundles.graal)
forgeRuntimeLibrary(libs.bundles.graal)
jarJar(libs.bundles.mongo)
runtimeOnly(libs.bundles.graal)
listOf(
libs.bundles.graal,
libs.molang
).forEach {
forgeRuntimeLibrary(it)
bundle(it)
}
listOf(
libs.bundles.graal,
libs.molang
).forEach {
"additionalRuntimeClasspath"(it)
bundle(it)
}
// AppleSkin stores api under `api` classifier in their coordinates
// Because of that, we cannot just add it to integrations bundle
modCompileOnly(variantOf(libs.appleskin.api.neoforge) { classifier("api") })
// AppleSkin stores api under `api` classifier in their coordinates
// Because of that, we cannot just add it to integrations bundle
compileOnly(variantOf(libs.appleskin.api.neoforge) { classifier("api") })
}
tasks {
shadowJar {
exclude("architectury-common.accessWidener")
exclude("architectury.common.json")
jar {
destinationDirectory = layout.buildDirectory.dir("devlibs")
}
relocate ("org.graalvm", "com.cobblemon.mod.relocations.graalvm")
relocate ("com.ibm.icu", "com.cobblemon.mod.relocations.ibm.icu")
}
shadowJar {
from(generateAccessTransformer.flatMap { it.accessTransformer }) {
into("META-INF")
}
processResources {
inputs.property("version", rootProject.version)
inputs.property("minecraft_version", rootProject.property("mc_version").toString())
inputs.property("java_version", rootProject.property("java_version").toString())
relocate("org.graalvm", "com.cobblemon.mod.relocations.graalvm")
relocate("com.ibm.icu", "com.cobblemon.mod.relocations.ibm.icu")
}
filesMatching("META-INF/neoforge.mods.toml") {
expand(
"version" to rootProject.version,
"minecraft_version" to rootProject.property("mc_version").toString(),
"java_version" to rootProject.property("java_version").toString()
)
}
}
processResources {
inputs.property("version", rootProject.version)
inputs.property("minecraft_version", rootProject.property("mc_version").toString())
inputs.property("java_version", rootProject.property("java_version").toString())
filesMatching("META-INF/neoforge.mods.toml") {
expand(
"version" to rootProject.version,
"minecraft_version" to rootProject.property("mc_version").toString(),
"java_version" to rootProject.property("java_version").toString()
)
}
}
register<Jar>("productionJar") {
description = ""
archiveBaseName.set("Cobblemon-${project.name}")
archiveVersion.set("${rootProject.version}")
from(shadowJar.flatMap { it.archiveFile }.map { zipTree(it) })
from(jarJar)
manifest.from(shadowJar.get().manifest)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
exclude("cobblemon-common.accesswidener", "**/module-info.class")
includeEmptyDirs = false
}
assemble {
dependsOn("productionJar")
}
sourcesJar {
val depSources = project(":common").tasks.sourcesJar
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn(depSources)
from(depSources.get().archiveFile.map { zipTree(it) })
}
}
tasks {
sourcesJar {
val depSources = project(":common").tasks.sourcesJar
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn(depSources)
from(depSources.get().archiveFile.map { zipTree(it) }) {
exclude("architectury.accessWidener")
}
}
}
//Stole from architect discord, replaces loom.forge.convertAccessWideners
tasks.remapJar {
atAccessWideners.add("cobblemon-common.accesswidener")
publishing {
publications.named<MavenPublication>(project.name) {
artifact(tasks.named("productionJar"))
artifact(tasks.sourcesJar)
}
}
copyJarToRootLibs(tasks.named<Jar>("productionJar"))
//jar {
// classifier("dev")
-1
View File
@@ -1 +0,0 @@
loom.platform = neoforge
+1 -2
View File
@@ -6,8 +6,7 @@ pluginManagement {
mavenCentral()
maven("https://maven.fabricmc.net/")
maven("https://maven.architectury.dev/")
maven("https://maven.minecraftforge.net/")
maven("https://maven.neoforged.net/releases/")
}
includeBuild("gradle/build-logic")