Compare commits

...
Author SHA1 Message Date
Deltric 94978bff20 The great java annotation 2026-01-17 06:20:57 -06:00
Deltric cccc71a64b Add register method for types 2026-01-17 04:19:07 -06:00
Deltric 23ce272813 Expose PNX to FormeChangeEvent and MoLang 2026-01-17 04:02:44 -06:00
Deltric e271613257 Add methods for registering custom showdown instructions. 2026-01-17 03:57:38 -06:00
Hiroku 948ca61ef3 Merge branch 'fix-super-potion-ingredients-tag' into 'main'
Fix super potion ingredients tag

See merge request cable-mc/cobblemon!2121
2026-01-16 08:27:19 +00:00
Hiroku e60aca30ba Merge branch 'patch-2' into 'main'
Fix Syrupy Apple missing from evolution items tag

See merge request cable-mc/cobblemon!2120
2026-01-16 08:26:22 +00:00
Hiroku fb5055c39e Merge branch 'form_crash' into 'main'
Initialize FormData when updating

Closes #1916

See merge request cable-mc/cobblemon!2122
2026-01-16 08:20:23 +00:00
Paul dfb5650121 Merge remote-tracking branch 'origin/main' 2026-01-16 18:17:01 +10:00
Paul 8a0cbf28fe Fixed battles not ending fully when a switch is in progress, closes #1917 2026-01-16 18:16:11 +10:00
aeroeng15 a6b9060d57 Changelog 2026-01-15 20:54:54 -07:00
aeroeng15 8e57995e44 Make It Proper 2026-01-15 20:51:59 -07:00
aeroeng15 1d8257808c Initialize rather than set; seems to fix the issue 2026-01-15 20:42:14 -07:00
Faintful e3582ccfb4 Add changelog 2026-01-14 19:49:11 +01:00
Faintful 4c6822b1c6 Merge remote-tracking branch 'upstream/main' into fix-super-potion-ingredients-tag 2026-01-14 19:46:54 +01:00
Faintful 2e6a4c7341 Change Hondew for Aguav 2026-01-14 19:28:49 +01:00
Micky 8edb5e1013 Fix Syrupy Apple missing from evolution items tag 2026-01-14 18:25:06 +00:00
Polymeta 6fb139cbb9 Merge branch 'pokemon-interactions-fixes' into 'main'
Pokémon Interaction fixes

See merge request cable-mc/cobblemon!2117
2026-01-14 00:03:33 +00:00
lionandPolymeta c81c95142b Pokémon Interaction fixes 2026-01-14 00:03:32 +00:00
Hiroku afde822860 Edit CHANGELOG.md [skip-ci] 2026-01-12 10:50:47 +00:00
Hiroku 474c386535 Merge branch 'main' into 'main'
Fix Fresh Start Mochi EV Reset

See merge request cable-mc/cobblemon!2115
2026-01-12 10:48:40 +00:00
ToothCollector 71b9ae8dee add fix to CHANGELOG.md 2026-01-11 21:31:22 +02:00
ToothCollector b87b47d62a Merge branch 'main' of https://gitlab.com/cable-mc/cobblemon 2026-01-11 21:28:04 +02:00
Hiroku 2bb85718d7 Merge branch 'main' into 'main'
Fix Adorn compatibility

See merge request cable-mc/cobblemon!2112
2026-01-11 12:21:25 +00:00
Tate Frost ee187d7b89 Delete file + update Adorn resource pack metadata
- Delete config file that was committed in error
- Update Adorn resource pack metadata to reflect new wood type
2026-01-10 22:30:27 -06:00
Tate Frost 3532cac278 Update CHANGELOG.md 2026-01-10 22:18:01 -06:00
Hiroku 1447ab25b4 Merge branch 'CombeeWorldGenFix' into 'main'
CombeeWorldGenFix

See merge request cable-mc/cobblemon!2071
2026-01-11 02:55:56 +00:00
Hiroku 9a06ca78c6 Merge branch 'fix-mongo-driver' into 'main'
Fix MongoDB ClassNotFoundException by including drivers at runtime

See merge request cable-mc/cobblemon!2098
2026-01-11 02:47:10 +00:00
Hiroku f6ba70634b Merge branch 'double-battle-gimmicks' into 'main'
Fix double battle gimmicks not being processed

See merge request cable-mc/cobblemon!2094
2026-01-11 02:46:36 +00:00
Hiroku 148fd04a93 Merge branch 'molang-evaluate_expression' into 'main'
molang addition: exception handling for run_molang

See merge request cable-mc/cobblemon!2102
2026-01-11 02:12:07 +00:00
Hiroku 17f60623ee Merge branch 'effect-id-regex-update' into 'main'
Custom messages for datapack moves and abilities

See merge request cable-mc/cobblemon!2106
2026-01-11 02:08:42 +00:00
Hiroku c5ece27c11 Merge branch '1861-galarien_mrmime_mount' into 'main'
Fix Galarian Mr. Mime incorrectly being rideable.

Closes #1861

See merge request cable-mc/cobblemon!2107
2026-01-11 02:02:14 +00:00
Hiroku 296ccd1a76 Merge branch 'main' into 'main'
Fix pasture block incorrect hit-box when facing north and south.

See merge request cable-mc/cobblemon!2109
2026-01-11 02:01:44 +00:00
ToothCollector 82a4f71f24 fix(FreshStartMochiItem.kt): Set all Pokemon's EVs to zero with the appropriate method. 2026-01-10 17:10:15 +02:00
Tate Frost 08b58e2f78 Fix Adorn compatibility
- Fixed Apricorn block model rotation for counters/sinks/cupboards/drawers to match that of most recent version of Adorn
- Added Saccharine wood + Adorn compatibility
2026-01-07 02:04:52 -06:00
Merv 62d2b8db2d Edit CHANGELOG.md 2026-01-06 18:47:45 +00:00
Merv 3869f7ed93 Merge branch cobblemon:main into main 2026-01-05 23:09:08 +00:00
Dragonwhisper92 c9c44872d6 Updated Changelog. 2026-01-05 19:35:05 +00:00
Dragonwhisper92 cae53efedc Updated ActivateInstruction.kt to have an optional message parameter. 2026-01-05 19:14:40 +00:00
Polymeta 5fac24cee8 Merge branch 'Molang-SimpleDateFormat-Fix' into 'main'
Fixed Molang functions:

See merge request cable-mc/cobblemon!2105
2026-01-05 11:22:45 +00:00
Polymeta 1954dfec80 Merge branch '1784-riding_stats_order' into 'main'
Fix riding stat boosts to always render in the same order

Closes #1784

See merge request cable-mc/cobblemon!2108
2026-01-05 11:20:29 +00:00
Landon 2eea2b64c2 Merge branch 'bag-clause' into 'main'
Bag Clause (Preventing Item use in Battles)

See merge request cable-mc/cobblemon!1849
2026-01-05 08:12:36 +00:00
GDWR a127a93be8 Sort boosts when rendering to remove the jumping of stats between items
The sort uses the key. As `RidingStat` it sorts them by the enum value.
2026-01-04 20:27:42 +00:00
GDWR 9b32f85817 Set an empty riding definition for Galarian Mr. Mime to avoid inheriting the default definition 2026-01-04 17:28:02 +00:00
Dragonwhisper92 ec139d2677 Updated Effect.kt to use a custom REGEX entry 2026-01-04 16:46:44 +00:00
Landon Wills 4327be0cf9 Omit bag clause from getting sent to showdown 2026-01-04 02:22:32 -05:00
Landon Wills c25c832b31 Remove import 2026-01-04 01:21:20 -05:00
Landon Wills eabaabc535 Move bag clause check to bag items instead of pokemon entity 2026-01-04 01:19:26 -05:00
Dragonwhisper92 9acf97f5a0 Updated CHANGELOG.md 2026-01-04 00:18:24 +00:00
Dragonwhisper92 24fc212c76 Updated CHANGELOG.md 2026-01-04 00:15:32 +00:00
Hiroku 04f88bdd63 Merge branch 'form-change-move-sanitization-fix' into 'main'
Fix the improper sanitization of moves on mons with compounding properties

Closes #1853 and #1846

See merge request cable-mc/cobblemon!2085
2026-01-04 00:05:26 +00:00
Dragonwhisper92 a4eb58aa57 Fixed molang functions:
- date_local_time
- date_of
- date_is_after
too use the correct SimpleDateFormat of "dd/MM/yyyy"
2026-01-03 23:40:12 +00:00
Merv 6704d4e5ee Maybe fix pasture block incorrect hitbox 2026-01-03 02:05:03 +00:00
Hiroku c88087de29 Merge branch 'main' into 'main'
Small improvements to the Battle AI

See merge request cable-mc/cobblemon!2101
2026-01-02 00:38:26 +00:00
Konoha 86bb802140 adjustment: exception handling to run_molang 2026-01-01 11:44:29 -05:00
GGavino1 6b644b384d Updated CHANGELOG.md to include AI changes 2026-01-01 15:00:15 +00:00
Konoha c370af8914 feature: molang function for safe evaluation of booleans 2025-12-31 22:23:50 -05:00
GGavino1 1cd6d2bfc7 Edit StrongBattleAI.kt 2025-12-31 23:15:52 +00:00
Konoha 1edeae2a60 fix: let's actually fix 2025-12-27 09:48:49 -05:00
mkh 409f1056b9 fix: Add MongoDB driver dependency to Fabric/NeoForge build configuration and shade it into the mod jar to resolve ClassNotFoundException. 2025-12-26 17:31:46 +08:00
Landon Wills d8c470db3d Oops, forgot a file 2025-12-23 01:28:50 -05:00
Landon Wills c642c4b84b Update changelog 2025-12-23 01:22:01 -05:00
Landon Wills 0b80f7e547 Make the gimmick buttons work with the back button 2025-12-23 01:18:35 -05:00
Landon Wills d543f45607 Fix double battle gimmicks not being processed, prevent people from trying to use the same gimmick multiple times on the same turn 2025-12-23 00:43:31 -05:00
Konoha 2b4fdfd219 changelog: sanitization fix 2025-12-21 15:40:17 -05:00
Hiroku 1a3b655d3f Merge branch 'the-tiniest-of-tiny-changes' into 'main'
Edit pokemon_model.json

See merge request cable-mc/cobblemon!2091
2025-12-20 12:41:36 +00:00
dhi_holo 1f5f278970 Edit pokemon_model.json 2025-12-20 21:25:12 +10:00
Hiroku 0b4eb5239a Merge branch 'in-flight-dismounting-config' into 'main'
Add enable in-flight dismounting config

See merge request cable-mc/cobblemon!2079
2025-12-20 06:01:12 +00:00
lionandHiroku 118e8f6205 Add enable in-flight dismounting config 2025-12-20 06:01:12 +00:00
Hiroku cf126c5906 Merge branch 'molang-is-love-molang-is-life' into 'main'
Fixed the `run_script` Molang function to not fail if the environment's context is null.

See merge request cable-mc/cobblemon!2090
2025-12-20 01:59:22 +00:00
Spicy 645cf61911 Fixed the run_script Molang function to not fail if the environment's context is null. 2025-12-19 19:48:27 -06:00
Hiroku 87d5ede3dd Merge branch 'RestoreCombeeLeavesPathing' into 'main'
RestoreCombeeLeavesPathing

See merge request cable-mc/cobblemon!2046
2025-12-19 07:36:50 +00:00
Hiroku 203e5d89cd Merge branch 'label-consistency' into 'main'
Who are we if not consistent?

See merge request cable-mc/cobblemon!1985
2025-12-19 07:36:21 +00:00
Konoha ce611cc61c cleanup: fix redundancies in form change sanitization 2025-12-18 21:17:48 -05:00
JazzMcNade f6ad7ff865 Fix changelog 2025-12-17 21:08:46 -06:00
JazzMcNade d69627a9c8 Merge branch 'main' into CombeeWorldGenFix 2025-12-17 20:05:09 -06:00
JazzMcNade 54e8763470 Fixed a bug in which Combees could become stuck inside of leaves 2025-12-13 21:17:59 -06:00
JazzMcNade db34687df0 Merge branch 'main' into RestoreCombeeLeavesPathing 2025-12-13 21:11:57 -06:00
Konoha 7f008d85ff fix: form_change move updates no longer sanitize the sets of compounding property mons 2025-12-13 18:37:37 -05:00
Polymeta 06ebf51078 Merge branch 'Wii-Break-It-Wii-Fix-It' into 'main'
Boat Tags and Mint Leaves

Closes #1855

See merge request cable-mc/cobblemon!2082
2025-12-13 22:14:32 +00:00
Polymeta 39c5bcd73c Merge branch 'even-more-seasonings' into 'main'
Adding Missing Effects for Seasonings

See merge request cable-mc/cobblemon!1991
2025-12-13 22:13:24 +00:00
CeejayandPolymeta 8f5f158b60 Adding Missing Effects for Seasonings 2025-12-13 22:13:24 +00:00
dhi_holo 3bc1e35125 Update CHANGELOG.md 2025-12-13 18:42:50 +10:00
dhi_holo 460bedddae Boat Tags
Resolves #1855
2025-12-13 18:12:24 +10:00
dhi_holo 8b64c315f3 Merge branch 'main' into Wii-Break-It-Wii-Fix-It 2025-12-13 17:51:15 +10:00
dhi_holo 7c824a2b72 OVERSIGHTS 2025-12-13 17:50:57 +10:00
Paul f197ac5077 Removed a bunch of duplicates from is_held_item because it looks whack. 2025-12-12 16:24:30 +10:00
Hiroku e0be669482 Merge branch 'patch-1' into 'main'
Fix Soothe Bell not tagged as `cobblemon:held/is_held_item`

See merge request cable-mc/cobblemon!2081
2025-12-12 06:17:17 +00:00
Micky 08ea21fff4 Fix Soothe Bell not tagged as cobblemon:held/is_held_item 2025-12-10 13:27:23 +00:00
JazzMcNade 9dac604a93 Merge branch 'main' into RestoreCombeeLeavesPathing 2025-12-10 00:20:49 -06:00
JazzMcNade 8540a73885 Fix for error occurring while populating bee nests with pokemon on world gen 2025-12-04 01:38:56 -06:00
Neovitalism 25ce784a60 Hopefully fixes changelog
Idk why gitlab didn't detect that when merging main
2025-12-03 10:17:48 -06:00
Neovitalism 5358cccb62 Merge branch 'main' into label-consistency 2025-12-03 10:09:41 -06:00
JazzMcNade 698fa9dff9 Merge branch 'main' into RestoreCombeeLeavesPathing 2025-12-01 00:46:50 -06:00
JazzMcNade a8949cf1f9 changelog 2025-11-25 21:49:38 -06:00
JazzMcNade 61db6334f9 Restores Combee pathing through leaves 2025-11-25 21:37:57 -06:00
Neovitalism 46d278ca55 key \:) 2025-11-17 03:18:02 -06:00
Neovitalism 339038956d Support for deserialization from any key
...I think.
2025-11-17 03:09:21 -06:00
Neovitalism 116a93d8cc Update CHANGELOG.md 2025-11-16 04:19:32 -06:00
Neovitalism acebc35d3f Who are we if not consistent?
Before, this property was called `PokemonFlagProperty`, had the key `tag`, and checked pokémon's labels. It was also in a package by itself.

Now, it's moved down into the properties package, renamed to LabelProperty, and the key "label" was added, keeping "tag" as a secondary for those that are using it currently.
2025-11-16 04:10:45 -06:00
Konoha aee89f1c92 Preliminary Bag Clause implementation 2025-09-09 18:15:37 -04:00
373 changed files with 2494 additions and 617 deletions
+42 -2
View File
@@ -6,17 +6,35 @@
- Added the Partner Mark, which party Pokémon have a very small chance to earn as the player walks, provided they have enough friendship.
- Added trades for Saccharine Saplings, Hearty Grains, Chipped Pot, and Masterpiece Teacup to the Wandering Trader.
- Added brewing recipe for Throat Spray.
- Added new effects
- Mental Restoration: Reduces "Time Since Last Rest" statistic, which controls Insomnia, by half a minute per second per effect level
- Negative Effect Cleanse: Removes all negative effects
- Effect Cleanse: Removes all effects
- Added more seasonings for sinister tea
- Mental Herb - Mental Restoration I for 10 seconds
- White Herb - Negative Effect Cleanse
- Milk - Effect Cleanse
- Moomoo Milk - Effect Cleanse
- Added `label` as an alternate key to the `tag` property.
- Added Saccharine wood furniture for Adorn.
### Changes
- Ride sounds have been separated into stereo for passengers and mono for other players. Riding will now sound more spacious.
- Added a new config option, `Enable In-Flight Dismounting` (default: off), which lets you dismount while riding a Pokémon in the air.
- Battle AI now uses a smarter threshold for switching, reducing unnecessary switches.
- AI will always use the most damaging move when at low HP and when it is not switching, improving endgame decision-making.
- Added support for optional message variants in battle activate instructions for more context-specific battle text.
- Example: `this.add('-activate', pokemon, 'ability: example', '[msg]message1');` will parse to lang key `cobblemon.battle.activate.example.message1`
### Fixes
- Fixed an issue in the OmniPathNodeMaker/Navigation that prevented Combees from pathing into and out of Saccharine leaves.
- Fixed orientation not getting reset after crashing while flying and getting back on the Pokémon.
- Fixed Furfrou not being trimmable on NeoForge.
- Fixed shiny Pokémon not respecting the silent flag on spawn.
- Fixed honey from Saccharine Leaves being harvestable at less than the max age.
- Items given from interacting with Saccharine Leaves are placed in the active hotbar slot if possible.
- Fix all Pokémon being saved to chunks and never despawning.
- Fixed possible error on world generation when Combees are placed in naturally generated bee nests.
- Fixed PokeSnacks crashing if there was no available spawn.
- Fixed Pokémon spawn influences not being specific to regional forms
- Fixed crashing when viewing another player in spectator mode
@@ -24,15 +42,37 @@
- Fixed crashing when riding due to malformed json file, instead resetting it
- Fixed mochi items consuming two items at a time
- Fix item interaction sometimes not working properly when playing on servers.
- Fixed Soothe Bell not being properly tagged as a held item.
- Fixed Mint Leaves not being usable for filling the Resurrection Machine.
- Added Saccharine Boats and Saccharine Boat with Chests to relevant boat tags.
- Fixed the `run_script` Molang function to not fail if the environment's context is null.
- Fixed issue #1917
- Fixed the movesets of certain Pokémon being incorrectly sanitized upon reload.
- Fixed the ordering of Aprijuice's riding stat boosts to always have the same order.
- Fixed the Molang functions `date_local_time`, `date_of`, `date_is_after` to use the correct date format.
- Fixed the bottom half of pasture blocks having an incorrect hit-box when facing north or south.
- Fixed Galarian Mr. Mime incorrectly being rideable.
- Fixed gimmicks not being usable in double / triple battles
- Fixed gimmick buttons showing when already used in the same turn in double / triple battles
- Fixed Apricorn block model rotation for counters/sinks/cupboards/drawers to match that of most recent version of Adorn.
- Fixed Fresh Start Mochi EV reset not syncing health changes properly.
- Fixed requirements such as `biomeCondition` crashing the game when used to define Pokémon interactions.
- Fixed Pokémon interactions not playing sound effects when the volume was not specified.
- Fixed Pokémon interaction cooldowns taking longer than intended when the Pokémon was in the player’s party.
- Fixed Pokémon interactions occasionally crashing the game when spamming an interaction with a 0 cooldown.
- Fixed Pokémon fullness decreasing more than intended when the Pokémon was pastured.
- Fixed crashing when sending a Pokémon out after editing its form
- Fixed Super Potion recipes incorrectly using Hondew Berry instead of Aguav Berry.
### Developer
- Changed the `owner` parameter in the `OwnerQueryRequirement` interface from `ServerPlayer` to `Player`. This method is now also called on the client to verify whether a Pokémon interaction succeeded, so make sure to update your implementations to handle both server and client contexts.
- Changed the `owner` parameter in the `OwnerQueryRequirement` interface from `ServerPlayer` to `Player`. This method is now also called on the client to verify whether a Pokémon interaction succeeded, so make sure to update your implementations to handle both server and client contexts.
### Molang & Datapacks
- Ride sounds can now be set as exclusive to passengers
- Ride sounds no longer play when submerged unless specified with a new setting
- Exception handling has been added to `run_molang`, resolving some crashes caused by malformed MoLang expressions.
### Particles
### Localization
- Updated translations for:
- Updated translations for:
@@ -11,7 +11,9 @@ package com.cobblemon.mod.common.mixin;
import com.cobblemon.mod.common.CobblemonMemories;
import com.cobblemon.mod.common.api.ai.config.task.PathToBeeHiveTaskConfig;
import com.cobblemon.mod.common.api.pokemon.PokemonProperties;
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
import com.cobblemon.mod.common.world.feature.SaccharineTreeFeature;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.tags.BlockTags;
@@ -42,7 +44,21 @@ public abstract class BeeOccupantMixin {
if (cir.getReturnValue() == null) {
final BeehiveBlockEntity.Occupant occupant = (BeehiveBlockEntity.Occupant) (Object) this;
CompoundTag compoundTag = occupant.entityData().copyTag();
Entity entity = EntityType.loadEntityRecursive(compoundTag, level, (entityx) -> entityx);
String id = compoundTag.getString("id");
Entity entity = null;
if (id.equals(SaccharineTreeFeature.Companion.getPOKEMON_PLACEHOLD_ID())) {
// Special case for Pokemon stuffed into a beenest upon world gen.
// For technical reasons we cannot create them as full entities during world gen.
// So we look for this special id tag and complete the entity when it attempts to exit a hive.
if (compoundTag.contains("pokemonProperties")) {
String properties = compoundTag.getString("pokemonProperties");
PokemonProperties pokemon = PokemonProperties.Companion.parse(properties);
entity = pokemon.createEntity(level);
}
} else {
entity = EntityType.loadEntityRecursive(compoundTag, level, (entityx) -> entityx);
}
if (entity instanceof PokemonEntity pokemonEntity) {
var state = level.getBlockState(pos);
var newPos = Vec3.ZERO;
@@ -33,7 +33,7 @@ public class SimpleBlockFeatureMixin {
if (!(blockState.getBlock() instanceof HeartyGrainsBlock)) {
return;
}
if (blockState.getValue(HeartyGrainsBlock.Companion.getAGE()) <= HeartyGrainsBlock.AGE_AFTER_HARVEST) {
if (blockState.getValue(HeartyGrainsBlock.AGE) <= HeartyGrainsBlock.AGE_AFTER_HARVEST) {
return; //block is too young to be double
}
if (!worldGenLevel.isEmptyBlock(blockPos.above())) {
@@ -43,4 +43,4 @@ public class SimpleBlockFeatureMixin {
DoublePlantBlock.placeAt(worldGenLevel, blockState, blockPos, Block.UPDATE_CLIENTS);
cir.setReturnValue(true);
}
}
}
@@ -91,7 +91,7 @@ import com.cobblemon.mod.common.pokemon.feature.SlowpokeTailRegrowthSpeciesFeatu
import com.cobblemon.mod.common.pokemon.feature.TagSeasonResolver
import com.cobblemon.mod.common.pokemon.helditem.CobblemonHeldItemManager
import com.cobblemon.mod.common.pokemon.properties.*
import com.cobblemon.mod.common.pokemon.properties.tags.PokemonFlagProperty
import com.cobblemon.mod.common.pokemon.properties.LabelProperty
import com.cobblemon.mod.common.pokemon.stat.CobblemonStatProvider
import com.cobblemon.mod.common.starter.CobblemonStarterHandler
import com.cobblemon.mod.common.util.*
@@ -164,7 +164,7 @@ object Cobblemon {
val statistics: CobblemonStats = CobblemonStats
@JvmStatic
@JvmField
val builtinPacks = listOf<CobblemonPack>(
CobblemonPack(id = "adorncompatibility", name = "Adorn Compatibility", packType = PackType.CLIENT_RESOURCES, activationBehaviour = ResourcePackActivationBehaviour.ALWAYS_ENABLED, neededMods = setOf("adorn")),
CobblemonPack(id = "gyaradosjump", name = "Gyarados Jump Patterns", packType = PackType.CLIENT_RESOURCES, activationBehaviour = ResourcePackActivationBehaviour.DEFAULT_ENABLED),
@@ -201,6 +201,7 @@ object Cobblemon {
implementation.registerEntityDataSerializers()
implementation.registerCriteria()
implementation.registerEntitySubPredicates()
implementation.registerMobEffects()
DispenserBehaviorRegistry.registerDispenserBehaviors()
DropEntry.register("command", CommandDropEntry::class.java)
@@ -314,7 +315,7 @@ object Cobblemon {
CustomPokemonProperty.register(UncatchableProperty)
CustomPokemonProperty.register(BattleCloneProperty)
CustomPokemonProperty.register(PokemonFlagProperty)
CustomPokemonProperty.register(LabelProperty)
CustomPokemonProperty.register(HiddenAbilityPropertyType)
CustomPokemonProperty.register(AspectPropertyType)
CustomPokemonProperty.register(UnaspectPropertyType)
@@ -568,4 +569,4 @@ object Cobblemon {
this.implementation.registerCommandArgument(cobblemonResource("model_part"), ModelPartArgumentType::class, SingletonArgumentInfo.contextFree(ModelPartArgumentType::modelPart))
}
}
}
@@ -117,6 +117,11 @@ interface CobblemonImplementation {
fun registerEntitySubPredicates()
/**
* TODO
*/
fun registerMobEffects()
/**
* Add a feature to the current platform implementation.
@@ -0,0 +1,33 @@
/*
* 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
import com.cobblemon.mod.common.api.cooking.effects.CleanseAllEffect
import com.cobblemon.mod.common.api.cooking.effects.CleanseNegativeEffect
import com.cobblemon.mod.common.api.cooking.effects.MentalRestorationEffect
import com.cobblemon.mod.common.platform.PlatformRegistry
import net.minecraft.core.Registry
import net.minecraft.core.registries.BuiltInRegistries
import net.minecraft.core.registries.Registries
import net.minecraft.resources.ResourceKey
import net.minecraft.world.effect.MobEffect
object CobblemonMobEffects : PlatformRegistry<Registry<MobEffect>, ResourceKey<Registry<MobEffect>>, MobEffect>() {
override val registry: Registry<MobEffect> = BuiltInRegistries.MOB_EFFECT
override val resourceKey: ResourceKey<Registry<MobEffect>> = Registries.MOB_EFFECT
@JvmField
val CLEANSE_NEGATIVE = create("cleanse_negative", CleanseNegativeEffect())
@JvmField
val MENTAL_RESTORATION = create("mental_restoration", MentalRestorationEffect())
@JvmField
val CLEANSE_ALL = create("cleanse_all", CleanseAllEffect())
}
@@ -23,6 +23,7 @@ class AspectCriterion(
): SimpleCriterionCondition<MutableMap<ResourceLocation, MutableSet<String>>>(playerCtx) {
companion object {
@JvmField
val CODEC: Codec<AspectCriterion> = RecordCodecBuilder.create { it.group(
//All three of these codecs used to use Codecs.createStrictOptionalFieldCodec, that no longer exists
ContextAwarePredicate.CODEC.optionalFieldOf("player").forGetter(AspectCriterion::playerCtx),
@@ -35,4 +36,4 @@ class AspectCriterion(
val caughtAspects = context.getOrDefault(species, mutableSetOf())
return this.aspects.all { it in caughtAspects }
}
}
}
@@ -25,6 +25,7 @@ class BattleCountableCriterion(
): CountableCriterion<BattleCountableContext>(playerCtx, count) {
companion object {
@JvmField
val CODEC: Codec<BattleCountableCriterion> = RecordCodecBuilder.create { it.group(
ContextAwarePredicate.CODEC.optionalFieldOf("player").forGetter(BattleCountableCriterion::playerCtx),
Codec.STRING.listOf().optionalFieldOf("battle_types", listOf("any")).forGetter(BattleCountableCriterion::battleTypes),
@@ -25,6 +25,7 @@ class CastPokeRodCriterionCondition(
): SimpleCriterionCondition<CastPokeRodContext>(playerCtx) {
companion object {
@JvmField
val CODEC: Codec<CastPokeRodCriterionCondition> = RecordCodecBuilder.create { it.group(
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(CastPokeRodCriterionCondition::playerCtx),
Codec.STRING.optionalFieldOf("baitId", "empty_bait").forGetter(CastPokeRodCriterionCondition::baitId)
@@ -34,4 +35,4 @@ class CastPokeRodCriterionCondition(
override fun matches(player: ServerPlayer, context: CastPokeRodContext): Boolean {
return (context.baitId == this.baitId.asIdentifierDefaultingNamespace() || this.baitId == "empty_bait")
}
}
}
@@ -31,6 +31,7 @@ class CaughtPokemonCriterion(
): CountableCriterion<CountablePokemonTypeContext>(playerCtx, count) {
companion object {
@JvmField
val CODEC: Codec<CaughtPokemonCriterion> = RecordCodecBuilder.create { it.group(
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(CaughtPokemonCriterion::playerCtx),
Codec.STRING.optionalFieldOf("type", "any").forGetter(CaughtPokemonCriterion::type),
@@ -42,4 +43,4 @@ class CaughtPokemonCriterion(
override fun matches(player: ServerPlayer, context: CountablePokemonTypeContext): Boolean {
return super.matches(player, context) && (context.type == type || type == "any")// && (context.species == species || species == "any")
}
}
}
@@ -23,6 +23,7 @@ open class CountableCriterion<T : CountableContext>(
): SimpleCriterionCondition<T>(playerCtx) {
companion object {
@JvmField
val CODEC: Codec<CountableCriterion<CountableContext>> = RecordCodecBuilder.create { it.group(
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(CountableCriterion<CountableContext>::playerCtx),
Codec.INT.optionalFieldOf("count", 0).forGetter(CountableCriterion<CountableContext>::count)
@@ -26,6 +26,7 @@ class EvolvePokemonCriterion(
): CountableCriterion<EvolvePokemonContext>(playerCtx, count) {
companion object {
@JvmField
val CODEC: Codec<EvolvePokemonCriterion> = RecordCodecBuilder.create { it.group(
ContextAwarePredicate.CODEC.optionalFieldOf("player").forGetter(EvolvePokemonCriterion::playerCtx),
Codec.STRING.optionalFieldOf("species", "any").forGetter(EvolvePokemonCriterion::species),
@@ -25,6 +25,7 @@ class LevelUpCriterion(
): SimpleCriterionCondition<LevelUpContext>(playerCtx) {
companion object {
@JvmField
val CODEC: Codec<LevelUpCriterion> = RecordCodecBuilder.create { it.group(
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(LevelUpCriterion::playerCtx),
Codec.INT.optionalFieldOf("level", 0).forGetter(LevelUpCriterion::level),
@@ -42,4 +43,4 @@ class LevelUpCriterion(
return level == context.level && evolutionCheck == evolved
}
}
}
@@ -24,6 +24,7 @@ class PartyCheckCriterion(
): SimpleCriterionCondition<PlayerPartyStore>(playerCtx) {
companion object {
@JvmField
val CODEC: Codec<PartyCheckCriterion> = RecordCodecBuilder.create { it.group(
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(PartyCheckCriterion::playerCtx),
ResourceLocation.CODEC.listOf().optionalFieldOf("party", listOf()).forGetter(PartyCheckCriterion::party)
@@ -47,4 +48,4 @@ class PartyCheckCriterion(
}
return matches.containsAll(party) && matches.size == party.size
}
}
}
@@ -23,6 +23,7 @@ class PlantTumblestoneCriterion(
): SimpleCriterionCondition<PlantTumblestoneContext>(playerCtx) {
companion object {
@JvmField
val CODEC: Codec<PlantTumblestoneCriterion> = RecordCodecBuilder.create { it.group(
ContextAwarePredicate.CODEC.optionalFieldOf("player").forGetter(PlantTumblestoneCriterion::playerCtx)
).apply(it, ::PlantTumblestoneCriterion) }
@@ -24,6 +24,7 @@ class PokemonCriterion(
): SimpleCriterionCondition<Pokemon>(playerCtx) {
companion object {
@JvmField
val CODEC: Codec<PokemonCriterion> = RecordCodecBuilder.create { it.group(
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(PokemonCriterion::playerCtx),
Codec.STRING.optionalFieldOf("species", "any").forGetter(PokemonCriterion::species),
@@ -35,4 +36,4 @@ class PokemonCriterion(
var speciesCheck = (species.equals(context.species.resourceIdentifier.path) || species.equals(context.species.resourceIdentifier.toString())) || species.equals("any")
return speciesCheck && properties.matches(context)
}
}
}
@@ -25,6 +25,7 @@ class PokemonInteractCriterion(
val item: String
): SimpleCriterionCondition<PokemonInteractContext>(playerCtx) {
companion object {
@JvmField
val CODEC: Codec<PokemonInteractCriterion> = RecordCodecBuilder.create { it.group(
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(PokemonInteractCriterion::playerCtx),
Codec.STRING.optionalFieldOf("species", "any").forGetter(PokemonInteractCriterion::species),
@@ -35,4 +36,4 @@ class PokemonInteractCriterion(
override fun matches(player: ServerPlayer, context: PokemonInteractContext): Boolean {
return (context.species == this.species.asIdentifierDefaultingNamespace() || this.species == "any") && (context.item == this.item.asIdentifierDefaultingNamespace() || this.item == "any")
}
}
}
@@ -26,6 +26,7 @@ class ReelInPokemonCriterionCondition(
) : SimpleCriterionCondition<ReelInPokemonContext>(playerCtx) {
companion object {
@JvmField
val CODEC: Codec<ReelInPokemonCriterionCondition> = RecordCodecBuilder.create { it.group(
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter { it.playerCtx },
Codec.STRING.optionalFieldOf("species", "any").forGetter { it.species },
@@ -37,4 +38,4 @@ class ReelInPokemonCriterionCondition(
return (context.species == this.species.asIdentifierDefaultingNamespace() || this.species == "any")
&& (context.baitId == this.baitId.asIdentifierDefaultingNamespace() || this.baitId == "any" || this.baitId == "empty_bait")
}
}
}
@@ -28,6 +28,7 @@ class TradePokemonCriterion(
): SimpleCriterionCondition<TradePokemonContext>(playerCtx) {
companion object {
@JvmField
val CODEC: Codec<TradePokemonCriterion> = RecordCodecBuilder.create { it.group(
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(TradePokemonCriterion::playerCtx),
Codec.STRING.optionalFieldOf("traded", "any").forGetter(TradePokemonCriterion::traded),
@@ -18,7 +18,7 @@ import net.minecraft.resources.ResourceKey
object CobblemonEntitySubPredicates : PlatformRegistry<Registry<MapCodec<out EntitySubPredicate>>, ResourceKey<Registry<MapCodec<out EntitySubPredicate>>>, MapCodec<out EntitySubPredicate>>() {
@JvmStatic
@JvmField
val POKE_POBBER = this.create("poke_bobber", FishingBobberPredicate.CODEC)
override val registry: Registry<MapCodec<out EntitySubPredicate>> = BuiltInRegistries.ENTITY_SUB_PREDICATE_TYPE
@@ -24,7 +24,7 @@ class FishingBobberPredicate(val inOpenWater: Boolean) : EntitySubPredicate {
return (entity as? PokeRodFishingBobberEntity)?.inOpenWater == this.inOpenWater
}
companion object {
@JvmStatic
@JvmField
val CODEC: MapCodec<FishingBobberPredicate> = RecordCodecBuilder.mapCodec { instance ->
instance.group(
Codec.BOOL.fieldOf("in_open_water").forGetter(FishingBobberPredicate::inOpenWater)
@@ -22,7 +22,7 @@ enum class Priority : StringRepresentable {
companion object {
@JvmStatic
@JvmField
val CODEC: Codec<Priority> = StringRepresentable.fromEnum(Priority::values)
}
@@ -104,7 +104,7 @@ open class Ability internal constructor(var template: AbilityTemplate, forced: B
companion object {
@JvmStatic
@JvmField
val CODEC: Codec<Ability> = RecordCodecBuilder.create {
it.group(
AbilityTemplate.CODEC.fieldOf(DataKeys.POKEMON_ABILITY_NAME).forGetter(Ability::template),
@@ -47,7 +47,7 @@ class AbilityTemplate(
companion object {
@JvmStatic
@JvmField
val CODEC: Codec<AbilityTemplate> = CodecUtils.createByStringCodec(
Abilities::getOrDummy,
AbilityTemplate::name
@@ -29,6 +29,7 @@ interface PotentialAbility {
val type: PotentialAbilityType<*>
fun isSatisfiedBy(aspects: Set<String>): Boolean
companion object {
@JvmField
val types = mutableListOf<PotentialAbilityType<*>>()
}
}
@@ -51,5 +52,4 @@ open class CommonAbility(override val template: AbilityTemplate) : PotentialAbil
override val priority = Priority.LOWEST
override val type = CommonAbilityType
override fun isSatisfiedBy(aspects: Set<String>) = true
}
}
@@ -26,8 +26,9 @@ class AttackHostileMobsTaskConfig : SingleTaskConfig {
): BehaviorControl<in LivingEntity>? {
return AttackHostileMobsTask.create()
}
companion object {
@JvmField
val CODEC: Codec<AttackHostileMobsTaskConfig> = Codec.unit(AttackHostileMobsTaskConfig())
}
}
@@ -99,6 +99,7 @@ enum class Apricorn : StringRepresentable {
override fun getSerializedName() = this.name.lowercase()
companion object {
@JvmField
val CODEC: Codec<Apricorn> = StringRepresentable.fromValues(::values)
}
}
@@ -24,6 +24,7 @@ class AllBiomeCondition(val minGroveSize: Int, val maxGroveSize: Int) : BerrySpa
}
companion object {
@JvmField
val ID = cobblemonResource("all_biome")
}
}
}
@@ -26,6 +26,7 @@ class PreferredBiomeCondition(val minGroveSize: Int, val maxGroveSize: Int) : Be
}
companion object {
@JvmField
val ID = cobblemonResource("preferred_biome")
}
}
}
@@ -24,6 +24,7 @@ class SpecificBiomeCondition : BerrySpawnCondition {
override fun getGroveSize(random: RandomSource) = random.nextIntBetweenInclusive(minGroveSize, maxGroveSize)
companion object {
@JvmField
val ID = cobblemonResource("specific_biome")
}
}
@@ -27,6 +27,7 @@ enum class Flavour(val colour: Int): StringRepresentable {
override fun getSerializedName() = name
companion object {
@JvmField
val CODEC = StringRepresentable.fromEnum<Flavour> { Flavour.entries.toTypedArray() }
}
}
}
@@ -17,6 +17,7 @@ data class Food(
val saturation: Float = 0f,
) {
companion object {
@JvmField
val CODEC: Codec<Food> = RecordCodecBuilder.create { builder ->
builder.group(
Codec.INT.optionalFieldOf("hunger", 0).forGetter { it.hunger },
@@ -38,6 +38,7 @@ data class Seasoning(
val mobEffects: List<SerializableMobEffectInstance>? = null
) {
companion object {
@JvmField
val CODEC: Codec<Seasoning> = RecordCodecBuilder.create { builder ->
builder.group(
ITEM_REGISTRY_LIKE_CODEC.fieldOf("ingredient").forGetter { it.ingredient },
@@ -58,6 +59,7 @@ data class Seasoning(
}
}
@JvmField
val STREAM_CODEC: StreamCodec<ByteBuf, Seasoning> = ByteBufCodecs.fromCodec(CODEC)
}
}
}
@@ -31,6 +31,7 @@ data class SerializableMobEffectInstance(
}
companion object {
@JvmField
val CODEC: Codec<SerializableMobEffectInstance> = RecordCodecBuilder.create { builder ->
builder.group(
ResourceLocation.CODEC.fieldOf("effect").forGetter { it.effect },
@@ -42,4 +43,4 @@ data class SerializableMobEffectInstance(
).apply(builder, ::SerializableMobEffectInstance)
}
}
}
}
@@ -0,0 +1,22 @@
/*
* 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.api.cooking.effects
import net.minecraft.world.effect.MobEffect
import net.minecraft.world.effect.MobEffectCategory
import net.minecraft.world.entity.Entity
import net.minecraft.world.entity.LivingEntity
class CleanseAllEffect : MobEffect(MobEffectCategory.BENEFICIAL, 0xFFFFFF) {
override fun isInstantenous() = true
override fun applyInstantenousEffect(source: Entity?, indirect: Entity?, target: LivingEntity, amplifier: Int, proximity: Double) {
target.removeAllEffects()
}
override fun shouldApplyEffectTickThisTick(duration: Int, amplifier: Int) = false
}
@@ -0,0 +1,27 @@
/*
* 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.api.cooking.effects
import net.minecraft.world.effect.MobEffect
import net.minecraft.world.effect.MobEffectCategory
import net.minecraft.world.entity.Entity
import net.minecraft.world.entity.LivingEntity
class CleanseNegativeEffect : MobEffect(MobEffectCategory.BENEFICIAL, 0xFFFFFF) {
override fun isInstantenous() = true
override fun applyInstantenousEffect(source: Entity?, indirect: Entity?, target: LivingEntity, amplifier: Int, proximity: Double) {
val snapshot = target.activeEffects.toList()
for (ei in snapshot) {
if (ei.effect.value().category == MobEffectCategory.HARMFUL) {
target.removeEffect(ei.effect)
}
}
}
override fun shouldApplyEffectTickThisTick(duration: Int, amplifier: Int) = false
}
@@ -0,0 +1,33 @@
/*
* 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.api.cooking.effects
import net.minecraft.server.level.ServerPlayer
import net.minecraft.stats.Stats
import net.minecraft.world.effect.MobEffect
import net.minecraft.world.effect.MobEffectCategory
import net.minecraft.world.entity.LivingEntity
class MentalRestorationEffect : MobEffect(MobEffectCategory.BENEFICIAL, 0xAA66FF) {
override fun applyEffectTick(entity: LivingEntity, amplifier: Int): Boolean {
if (entity is ServerPlayer) {
val stats = entity.stats
val statType = Stats.CUSTOM.get(Stats.TIME_SINCE_REST)
val current = stats.getValue(statType)
val reduction = 31 * (amplifier + 1)// reduce by half a minute every second per level (30 ticks removed per tick + 1 to account for the tick passing)
val newValue = Math.max(current - reduction, 0)
stats.setValue(entity, statType, newValue)
}
return true
}
override fun shouldApplyEffectTickThisTick(duration: Int, amplifier: Int): Boolean {
return true
}
}
@@ -26,9 +26,11 @@ class Dialogue(
val initializationAction: DialogueAction = FunctionDialogueAction { _, _ -> }
) {
companion object {
@JvmField
val DEFAULT_BACKGROUND = cobblemonResource("textures/gui/dialogue/dialogue_box.png")
@JvmOverloads
@JvmStatic
fun of(
pages: Iterable<DialoguePage>,
background: ResourceLocation = DEFAULT_BACKGROUND,
@@ -44,6 +46,7 @@ class Dialogue(
}
@JvmOverloads
@JvmStatic
fun of(
pages: Iterable<DialoguePage>,
background: ResourceLocation = DEFAULT_BACKGROUND,
@@ -23,7 +23,7 @@ import com.cobblemon.mod.common.util.resolve
*/
interface DialogueAction {
companion object {
@JvmStatic
@JvmField
val types = mutableMapOf<String, Class<out DialogueAction>>()
}
@@ -23,6 +23,7 @@ sealed interface DialogueFaceProvider {
val isLeftSide: Boolean
companion object {
@JvmField
val types = mutableMapOf(
"artificial" to ArtificialDialogueFaceProvider::class.java,
"player" to PlayerDialogueFaceProvider::class.java,
@@ -58,4 +58,9 @@ object DialogueManager {
DialogueClosedPacket(activeDialogue.dialogueId).sendToPlayer(playerEntity)
activeDialogues.remove(playerEntity.uuid)
}
@JvmStatic
fun getDialogue(playerEntity: ServerPlayer): ActiveDialogue? {
return activeDialogues[playerEntity.uuid]
}
}
@@ -38,6 +38,7 @@ class DialoguePage(
) {
companion object {
@JvmOverloads
@JvmStatic
fun of(
/** The ID is optional, but if you want to be able to jump to this page from other pages then you probably want to set this. */
id: String = "",
@@ -78,4 +79,4 @@ class DialoguePage(
)
)
}
}
}
@@ -20,6 +20,7 @@ import com.cobblemon.mod.common.util.resolveBoolean
*/
interface DialoguePredicate {
companion object {
@JvmField
val types = mutableMapOf<String, Class<out DialoguePredicate>>()
}
@@ -24,6 +24,7 @@ import net.minecraft.network.chat.MutableComponent
*/
interface DialogueText {
companion object {
@JvmField
val types = mutableMapOf<String, Class<out DialogueText>>(
"expression" to ExpressionLikeDialogueText::class.java,
)
@@ -26,7 +26,10 @@ interface DropEntry {
companion object {
val entryTypes = mutableMapOf<String, Class<out DropEntry>>()
var defaultType: Class<out DropEntry>? = null
@JvmStatic
fun getByName(name: String) = entryTypes[name]
@JvmOverloads
@JvmStatic
fun <T : DropEntry> register(name: String, clazz: Class<T>, isDefault: Boolean = false) {
entryTypes[name] = clazz
if (isDefault) {
@@ -63,13 +63,16 @@ interface EntityEffect {
register(TransformEffect.ID, TransformEffect::class, ::TransformEffect)
}
@JvmStatic
fun <T : EntityEffect> register(id: String, type: KClass<T>, default: () -> T) {
effects[id] = type
defaults[id] = default
}
@JvmStatic
fun createDefault(id: String): EntityEffect? = defaults[id]?.invoke()
@JvmStatic
fun loadFromNbt(nbt: CompoundTag, registryLookup: HolderLookup.Provider): EntityEffect? {
if (nbt.contains(DataKeys.ENTITY_EFFECT_ID)) {
val id = nbt.getString(DataKeys.ENTITY_EFFECT_ID)
@@ -100,4 +103,4 @@ interface MocKEffect : PhysicalEffect {
val exposedBall: PokeBall?
get() = this.mock.pokeball?.let { PokeBalls.getPokeBall(it.asIdentifierDefaultingNamespace()) }
}
}
@@ -8,12 +8,10 @@
package com.cobblemon.mod.common.api.events.battles.instruction
import com.bedrockk.molang.runtime.value.MoValue
import com.bedrockk.molang.runtime.value.StringValue
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
import com.cobblemon.mod.common.api.battles.model.actor.ActorType
import com.cobblemon.mod.common.api.events.battles.BattleEvent
import com.cobblemon.mod.common.battles.dispatch.InterpreterInstruction
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.util.asArrayValue
@@ -25,7 +23,8 @@ import com.cobblemon.mod.common.util.asArrayValue
data class FormeChangeEvent(
override val battle: PokemonBattle,
val pokemon: BattlePokemon,
val formeName: String
val formeName: String,
val pnx: String
) : BattleEvent {
val context = mutableMapOf(
"battle" to battle.struct,
@@ -33,6 +32,7 @@ data class FormeChangeEvent(
"npcs" to battle.actors.filter { it.type == ActorType.NPC }.asArrayValue { it.struct },
"wild_pokemon" to battle.actors.filter { it.type == ActorType.WILD }.asArrayValue { it.struct },
"pokemon" to pokemon.struct,
"forme" to StringValue(formeName)
"forme" to StringValue(formeName),
"pnx" to StringValue(pnx)
)
}
}
@@ -35,6 +35,7 @@ class SpawnBait(
constructor(type: ResourceLocation, subcategory: Optional<ResourceLocation>, chance: Double, value: Double) : this(type, subcategory.orElse(null), chance, value)
companion object {
@JvmField
val CODEC = RecordCodecBuilder.create<Effect> { instance ->
instance.group(
ResourceLocation.CODEC.fieldOf("type").forGetter { it.type },
@@ -47,6 +48,7 @@ class SpawnBait(
}
companion object {
@JvmField
val CODEC = RecordCodecBuilder.create<SpawnBait> { instance ->
instance.group(
ITEM_REGISTRY_LIKE_CODEC.fieldOf("item").forGetter { it.item },
@@ -54,6 +56,7 @@ class SpawnBait(
).apply(instance, ::SpawnBait)
}
@JvmField
val STREAM_CODEC = ByteBufCodecs.fromCodec(CODEC)
}
@@ -96,6 +99,4 @@ class SpawnBait(
}
}
}
}
}
@@ -9,6 +9,7 @@
package com.cobblemon.mod.common.api.interaction
import com.cobblemon.mod.common.Cobblemon
import com.cobblemon.mod.common.api.conditional.RegistryLikeCondition
import com.cobblemon.mod.common.api.data.JsonDataRegistry
import com.cobblemon.mod.common.api.molang.ExpressionLike
import com.cobblemon.mod.common.api.pokemon.PokemonProperties
@@ -29,6 +30,11 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.server.level.ServerPlayer
import net.minecraft.server.packs.PackType
import net.minecraft.util.LowerCaseEnumTypeAdapterFactory
import net.minecraft.world.item.Item
import net.minecraft.world.level.biome.Biome
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.levelgen.structure.Structure
import net.minecraft.world.level.material.Fluid
object PokemonInteractions : JsonDataRegistry<PokemonInteractionSet> {
override val id = cobblemonResource("pokemon_interactions")
@@ -43,6 +49,11 @@ object PokemonInteractions : JsonDataRegistry<PokemonInteractionSet> {
.registerTypeAdapter(Requirement::class.java, CobblemonRequirementAdapter)
.registerTypeAdapter(InteractionEffect::class.java, InteractionEffectAdapter)
.registerTypeAdapter(ExpressionLike::class.java, ExpressionLikeAdapter)
.registerTypeAdapter(TypeToken.getParameterized(RegistryLikeCondition::class.java, Biome::class.java).type, BiomeLikeConditionAdapter)
.registerTypeAdapter(TypeToken.getParameterized(RegistryLikeCondition::class.java, Block::class.java).type, BlockLikeConditionAdapter)
.registerTypeAdapter(TypeToken.getParameterized(RegistryLikeCondition::class.java, Item::class.java).type, ItemLikeConditionAdapter)
.registerTypeAdapter(TypeToken.getParameterized(RegistryLikeCondition::class.java, Structure::class.java).type, StructureLikeConditionAdapter)
.registerTypeAdapter(TypeToken.getParameterized(RegistryLikeCondition::class.java, Fluid::class.java).type, FluidLikeConditionAdapter)
.registerTypeAdapter(IntRange::class.java, IntRangeAdapter)
.registerTypeAdapterFactory(LowerCaseEnumTypeAdapterFactory())
.setPrettyPrinting()
@@ -17,6 +17,7 @@ import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.cobblemon.mod.common.net.messages.client.sound.UnvalidatedPlaySoundS2CPacket
import com.cobblemon.mod.common.pokemon.adapters.CobblemonRequirementAdapter
import com.cobblemon.mod.common.util.*
import com.google.gson.annotations.SerializedName
import net.minecraft.core.registries.Registries
import net.minecraft.network.FriendlyByteBuf
import net.minecraft.resources.ResourceLocation
@@ -143,11 +144,12 @@ class GiveItemEffect(val item: ResourceLocation, val amount: IntRange?) : Intera
class PlaySoundEffect(
val sound: ResourceLocation,
val soundSource: SoundSource?,
val playAround: Boolean = true,
val distance: Double = 64.0,
val volume: Float = 1.0F,
val pitch: Float = 1.0F
@SerializedName("playAround") private val _playAround: Boolean?,
@SerializedName("distance") private val _distance: Double?,
@SerializedName("volume") private val _volume: Float?,
@SerializedName("pitch") private val _pitch: Float?,
) : InteractionEffect {
override fun applyEffect(
pokemon: PokemonEntity,
player: ServerPlayer
@@ -161,6 +163,7 @@ class PlaySoundEffect(
volume,
pitch
)
if (playAround) {
packet.sendToPlayersAround(pokemon.x, pokemon.y, pokemon.z, distance, pokemon.level().dimension())
} else {
@@ -168,6 +171,18 @@ class PlaySoundEffect(
}
}
val playAround: Boolean
get() = _playAround != false
val distance: Double
get() = _distance ?: 64.0
val volume: Float
get() = _volume ?: 1.0F
val pitch: Float
get() = _pitch ?: 1.0F
companion object {
val ID = "play_sound"
}
@@ -223,6 +223,7 @@ abstract class RequestManager<T : ServerPlayerActionRequest> {
companion object {
private val managers = mutableListOf<RequestManager<*>>()
@JvmStatic
fun register(manager: RequestManager<*>) = managers.add(manager)
fun onLogoff(player: ServerPlayer) = managers.forEach { it.onLogoff(player) }
@@ -59,7 +59,7 @@ interface AbilityChanger<T : PotentialAbility> {
*
* While this can be used in custom data scenarios this functions most "game-like" if the Pokémon only has 2 common abilities.
*/
@JvmStatic
@JvmField
val COMMON_ABILITY: AbilityChanger<CommonAbility> = AbilityTypeChanger(CommonAbilityType) { other -> other == CommonAbilityType }
/**
@@ -67,7 +67,7 @@ interface AbilityChanger<T : PotentialAbility> {
*
* While this can be used in custom data scenarios this functions most "game-like" if the Pokémon only has 1 hidden ability.
*/
@JvmStatic
@JvmField
val HIDDEN_ABILITY: AbilityChanger<HiddenAbility> = AbilityTypeChanger(HiddenAbilityType) { other -> other == CommonAbilityType || other == HiddenAbilityType }
}
@@ -35,10 +35,11 @@ interface ExpressionLike {
fun resolveObject(runtime: MoLangRuntime) = resolve(runtime) as ObjectValue<*>
companion object {
@JvmField
val CODEC: Codec<ExpressionLike> = Codec.STRING.xmap({
it.asExpressionLike()
}) {
it.getString()
}
}
}
}
@@ -311,7 +311,7 @@ object MoLangFunctions {
runtime.environment.variable = params.environment.variable
val args = params.params.subList(1, params.params.size)
runtime.environment.context = ContextStruct(
params.environment.context.map + args.mapIndexed { index, value -> "arg_${index + 1}" to value }.toMap()
(params.environment.context?.map ?: emptyMap()) + args.mapIndexed { index, value -> "arg_${index + 1}" to value }.toMap()
)
val script = params.getString(0).asIdentifierDefaultingNamespace()
// store the args in the
@@ -324,13 +324,24 @@ object MoLangFunctions {
runtime.environment.context = params.environment.context
val expression = params.getString(0).asExpressionLike()
val delayInSeconds = params.getDoubleOrNull(1)?.toFloat() ?: 0.0f
fun evaluate(): MoValue {
return try {
runtime.resolve(expression)
} catch (ex: Exception) {
Cobblemon.LOGGER.warn("Failed to evaluate MoLang expression${if (delayInSeconds > 0.0f) " (delayed)" else ""}: $expression", ex)
DoubleValue.ZERO
}
}
if (delayInSeconds > 0.0f) {
val tracker = if (Cobblemon.implementation.environment() == Environment.SERVER) ServerTaskTracker else ClientTaskTracker
tracker.after(delayInSeconds) {
runtime.resolve(expression)
evaluate()
}
DoubleValue.ONE
} else {
runtime.resolve(expression)
evaluate()
}
},
"system_time_millis" to java.util.function.Function { _ ->
@@ -340,19 +351,19 @@ object MoLangFunctions {
"date_local_time" to java.util.function.Function { _ ->
val time = System.currentTimeMillis()
val date = java.util.Date(time)
val formatted = java.text.SimpleDateFormat("DD/MM/YYYY").format(date)
val formatted = java.text.SimpleDateFormat("dd/MM/yyyy").format(date)
StringValue(formatted)
},
"date_of" to java.util.function.Function { params ->
val time = params.getDouble(0).toLong()
val date = java.util.Date(time)
val formatted = java.text.SimpleDateFormat("DD/MM/YYYY").format(date)
val formatted = java.text.SimpleDateFormat("dd/MM/yyyy").format(date)
StringValue(formatted)
},
"date_is_after" to java.util.function.Function { params ->
val dateA = params.getString(0)
val dateB = params.getString(1)
val format = java.text.SimpleDateFormat("DD/MM/YYYY")
val format = java.text.SimpleDateFormat("dd/MM/yyyy")
val a = format.parse(dateA)
val b = format.parse(dateB)
DoubleValue(a.after(b))
@@ -112,7 +112,7 @@ class BenchedMoves : Iterable<BenchedMove> {
}
companion object {
@JvmStatic
@JvmField
val CODEC: Codec<BenchedMoves> = Codec.list(BenchedMove.CODEC)
.xmap(
{ moveList ->
@@ -144,6 +144,7 @@ data class BenchedMove(val moveTemplate: MoveTemplate, val ppRaisedStages: Int)
}
companion object {
@JvmStatic
fun loadFromNBT(nbt: CompoundTag): BenchedMove {
val name = nbt.getString(DataKeys.POKEMON_MOVESET_MOVENAME)
return BenchedMove(
@@ -152,6 +153,7 @@ data class BenchedMove(val moveTemplate: MoveTemplate, val ppRaisedStages: Int)
)
}
@JvmStatic
fun loadFromJSON(json: JsonObject): BenchedMove {
val name = json.get(DataKeys.POKEMON_MOVESET_MOVENAME).asString
return BenchedMove(
@@ -160,6 +162,7 @@ data class BenchedMove(val moveTemplate: MoveTemplate, val ppRaisedStages: Int)
)
}
@JvmStatic
fun loadFromBuffer(buffer: RegistryFriendlyByteBuf): BenchedMove {
val name = buffer.readString()
return BenchedMove(
@@ -168,7 +171,7 @@ data class BenchedMove(val moveTemplate: MoveTemplate, val ppRaisedStages: Int)
)
}
@JvmStatic
@JvmField
val CODEC: Codec<BenchedMove> = RecordCodecBuilder.create { it.group(
MoveTemplate.BY_STRING_CODEC.fieldOf(DataKeys.POKEMON_MOVESET_MOVENAME).forGetter(BenchedMove::moveTemplate),
Codec.intRange(0, 3).fieldOf(DataKeys.POKEMON_MOVESET_RAISED_PP_STAGES).forGetter(BenchedMove::ppRaisedStages)
@@ -149,12 +149,14 @@ open class Move(
}
companion object {
@JvmStatic
fun loadFromNBT(nbt: CompoundTag): Move {
val moveName = nbt.getString(DataKeys.POKEMON_MOVESET_MOVENAME)
val template = Moves.getByNameOrDummy(moveName)
return template.create(nbt.getInt(DataKeys.POKEMON_MOVESET_MOVEPP), nbt.getInt(DataKeys.POKEMON_MOVESET_RAISED_PP_STAGES))
}
@JvmStatic
fun loadFromJSON(json: JsonObject): Move {
val moveName = json.get(DataKeys.POKEMON_MOVESET_MOVENAME).asString
val template = Moves.getByNameOrDummy(moveName)
@@ -163,6 +165,7 @@ open class Move(
return Move(template, currentPp, raisedPpStages)
}
@JvmStatic
fun loadFromBuffer(buffer: RegistryFriendlyByteBuf): Move {
val moveName = buffer.readString()
val currentPp = buffer.readSizedInt(IntSize.U_BYTE)
@@ -171,7 +174,7 @@ open class Move(
return template.create(currentPp, raisedPpStages)
}
@JvmStatic
@JvmField
val CODEC: Codec<Move> = RecordCodecBuilder.create { it.group(
MoveTemplate.BY_STRING_CODEC.fieldOf(DataKeys.POKEMON_MOVESET_MOVENAME).forGetter(Move::template),
Codec.intRange(0, Int.MAX_VALUE).fieldOf(DataKeys.POKEMON_MOVESET_MOVEPP).forGetter(Move::currentPp),
@@ -208,7 +208,7 @@ class MoveSet : Iterable<Move> {
companion object {
const val MOVE_COUNT = 4
@JvmStatic
@JvmField
val CODEC: Codec<MoveSet> = Codec.list(Move.CODEC, 0, MOVE_COUNT)
.xmap(
{ moveList ->
@@ -90,9 +90,10 @@ open class MoveTemplate(
)
companion object {
@JvmStatic
fun dummy(name: String) = Dummy(name)
@JvmStatic
@JvmField
val BY_STRING_CODEC: Codec<MoveTemplate> = CodecUtils.createByStringCodec(
Moves::getByNameOrDummy,
MoveTemplate::name
@@ -157,4 +158,4 @@ open class MoveTemplate(
}
return this.elementalType
}
}
}
@@ -32,6 +32,7 @@ class ActionEffectTimeline(
val condition: ExpressionLike = "true".asExpressionLike()
) {
companion object {
@JvmField
val NONE = ActionEffectTimeline()
}
@@ -98,4 +99,4 @@ interface EntityProvider {
// val sound: ResourceLocation? = null,
// val animation: List<AnimationWithMoments> = listOf(),
// val effects: List<ActionEffect> = listOf()
//)
//)
@@ -21,8 +21,10 @@ import java.util.concurrent.CompletableFuture
*/
interface ActionEffectKeyframe {
companion object {
@JvmField
val types = mutableMapOf<String, Class<out ActionEffectKeyframe>>()
@JvmStatic
inline fun <reified T : ActionEffectKeyframe> register(type: String) {
types[type] = T::class.java
}
@@ -31,4 +33,4 @@ interface ActionEffectKeyframe {
fun play(context: ActionEffectContext): CompletableFuture<Unit>
fun interrupt(context: ActionEffectContext) {}
fun skip(): CompletableFuture<Unit> = CompletableFuture.completedFuture(Unit)
}
}
@@ -32,4 +32,4 @@ enum class MulchVariant(val duration: Int = -1) : StringRepresentable {
companion object {
const val GROWTH_TIME_MULTIPLIER = 0.5
}
}
}
@@ -109,6 +109,7 @@ object NPCClasses : JsonDataRegistry<NPCClass> {
* @param name The path of the NPC class asset.
* @return The [NPCClass] if existing.
*/
@JvmStatic
fun getByName(name: String) = this.getByIdentifier(cobblemonResource(name))
/**
@@ -25,6 +25,7 @@ import net.minecraft.server.level.ServerPlayer
*/
interface NPCPartyProvider {
companion object {
@JvmField
val types = mutableMapOf<String, (String) -> NPCPartyProvider>(
SimplePartyProvider.TYPE to { SimplePartyProvider() },
PoolPartyProvider.TYPE to { PoolPartyProvider() },
@@ -34,6 +34,7 @@ interface NPCInteractConfiguration {
companion object {
val types = mutableMapOf<String, NPCInteractConfigurationType<out NPCInteractConfiguration>>()
@JvmStatic
fun register(type: String, displayName: MutableComponent, clazz: Class<out NPCInteractConfiguration>) {
types[type] = NPCInteractConfigurationType(displayName, clazz)
}
@@ -34,6 +34,7 @@ interface NPCVariationProvider {
"random" to RandomNPCVariationProvider::class.java
)
@JvmStatic
fun register(type: String, clazz: Class<out NPCVariationProvider>) {
types[type] = clazz
}
@@ -23,8 +23,11 @@ import kotlin.math.sign
open class OrientationController(val entity: LivingEntity) {
companion object {
@JvmField
val FORWARDS: Vector3f = Vector3f(0.0f, 0.0f, -1.0f)
@JvmField
val UP: Vector3f = Vector3f(0.0f, 1.0f, 0.0f)
@JvmField
val LEFT: Vector3f = Vector3f(-1.0f, 0.0f, 0.0f)
}
@@ -129,4 +132,4 @@ open class OrientationController(val entity: LivingEntity) {
return@updateOrientation Matrix3f().set(resultQuat)
}
}
}
@@ -25,6 +25,7 @@ enum class PermissionLevel(val numericalValue: Int) {
ALL_COMMANDS(4);
companion object {
@JvmStatic
fun byNumericValue(value: Int): PermissionLevel {
return entries.first { it.numericalValue == value }
}
@@ -23,6 +23,8 @@ data class CaptureContext(
* @param critical If the capture is a critical capture, defaults to false.
* @return The generated [CaptureContext].
*/
@JvmOverloads
@JvmStatic
fun successful(critical: Boolean = false): CaptureContext {
if (critical) {
return CaptureContext(numberOfShakes = 1, isSuccessfulCapture = true, isCriticalCapture = true)
@@ -37,6 +37,7 @@ import net.minecraft.network.RegistryFriendlyByteBuf
*/
class FormDexRecord {
companion object {
@JvmField
val CODEC: Codec<FormDexRecord> = RecordCodecBuilder.create { instance ->
instance.group(
ListCodec(Codec.STRING, 0, 3).fieldOf("genders").forGetter { it.genders.map { it.name } },
@@ -26,10 +26,11 @@ enum class PokedexEntryProgress : StringRepresentable, Comparable<PokedexEntryPr
override fun getSerializedName() = this.name
companion object {
@JvmField
val CODEC: Codec<PokedexEntryProgress> = RecordCodecBuilder.create { instance ->
instance.map ({
PokedexEntryProgress.valueOf(it)
}, PrimitiveCodec.STRING.fieldOf("name").forGetter { it.name })
}
}
}
}
@@ -70,6 +70,7 @@ class PokedexManager(
}
companion object {
@JvmField
val CODEC = RecordCodecBuilder.create<PokedexManager> { instance ->
instance.group(
PrimitiveCodec.STRING.fieldOf("uuid").forGetter { it.uuid.toString() },
@@ -33,6 +33,7 @@ import net.minecraft.resources.ResourceLocation
*/
class SpeciesDexRecord {
companion object {
@JvmField
val CODEC: Codec<SpeciesDexRecord> = RecordCodecBuilder.create { instance ->
instance.group(
ListCodec(PrimitiveCodec.STRING, 0, 512).fieldOf("aspects").forGetter { it.aspects.toList() },
@@ -76,7 +76,9 @@ class AggregatePokedexDef(
}
companion object {
@JvmField
val ID = cobblemonResource("aggregate_pokedex_def")
@JvmField
val CODEC: MapCodec<AggregatePokedexDef> = RecordCodecBuilder.mapCodec { instance ->
instance.group(
ResourceLocation.CODEC.fieldOf("id").forGetter { it.id },
@@ -34,9 +34,12 @@ abstract class PokedexDef: ClientDataSynchronizer<PokedexDef> {
abstract fun getEntries(): List<PokedexEntry>
companion object {
@JvmField
val CODEC: Codec<PokedexDef> = ResourceLocation.CODEC.dispatch("type", PokedexDef::typeId, PokedexDef::getCodecById)
@JvmField
val PACKET_CODEC: StreamCodec<ByteBuf, PokedexDef> = ResourceLocation.STREAM_CODEC.dispatch({ it.typeId }, ::getPacketCodecById)
@JvmStatic
fun getPacketCodecById(id: ResourceLocation): StreamCodec<ByteBuf, out PokedexDef> {
return when (id) {
SimplePokedexDef.ID -> SimplePokedexDef.PACKET_CODEC
@@ -45,6 +48,7 @@ abstract class PokedexDef: ClientDataSynchronizer<PokedexDef> {
}
}
@JvmStatic
fun getCodecById(id: ResourceLocation): MapCodec<out PokedexDef> {
return when (id) {
SimplePokedexDef.ID -> SimplePokedexDef.CODEC
@@ -64,7 +64,9 @@ class SimplePokedexDef(
}
companion object {
@JvmField
val ID = cobblemonResource("simple_pokedex_def")
@JvmField
val CODEC: MapCodec<SimplePokedexDef> = RecordCodecBuilder.mapCodec { instance ->
instance.group(
ResourceLocation.CODEC.fieldOf("id").forGetter { it.id },
@@ -78,6 +80,7 @@ class SimplePokedexDef(
}
}
@JvmField
val PACKET_CODEC: StreamCodec<ByteBuf, SimplePokedexDef> = StreamCodec.composite(
ResourceLocation.STREAM_CODEC, SimplePokedexDef::id,
ByteBufCodecs.INT, SimplePokedexDef::sortOrder,
@@ -82,13 +82,13 @@ import kotlin.jvm.optionals.getOrNull
open class PokemonProperties {
companion object {
@JvmStatic
@JvmField
val CODEC: Codec<PokemonProperties> = Codec.STRING.xmap(
{ parse(it) },
{ it.asString() }
)
@JvmStatic
@JvmField
val CUSTOM_PROPERTIES_CODEC: Codec<MutableList<CustomPokemonProperty>> = Codec.list(Codec.STRING)
.xmap(
{ string -> parse(string.joinToString(" ")).customProperties },
@@ -96,6 +96,7 @@ open class PokemonProperties {
)
@JvmOverloads
@JvmStatic
fun parse(string: String, delimiter: String = " ", assigner: String = "="): PokemonProperties {
val props = PokemonProperties()
props.originalString = string
@@ -22,10 +22,14 @@ import com.cobblemon.mod.common.pokemon.Pokemon
interface AspectProvider {
companion object {
val providers = mutableListOf<AspectProvider>()
@JvmStatic
fun register(provider: AspectProvider): AspectProvider {
providers.add(provider)
return provider
}
@JvmStatic
fun unregister(provider: AspectProvider) {
providers.remove(provider)
}
@@ -21,6 +21,7 @@ import com.cobblemon.mod.common.pokemon.Pokemon
*/
interface SingleConditionalAspectProvider : AspectProvider {
companion object {
@JvmStatic
fun getForFeature(name: String): SingleConditionalAspectProvider {
return object : SingleConditionalAspectProvider {
override val aspect: String = name
@@ -38,6 +38,7 @@ enum class EggGroup(val showdownID: String) {
it.showdownID.lowercase().replace(" ", "_").replace("-", "_")
}
@JvmStatic
fun fromIdentifier(identifier: String): EggGroup? {
val key = identifier.lowercase().replace(" ", "_").replace("-", "_")
return identifierMap[key]
@@ -26,9 +26,9 @@ interface PreEvolution {
val form: FormData
companion object {
@JvmOverloads
@JvmStatic
fun of(species: Species, form: FormData = species.standardForm): PreEvolution = StandardPreEvolution(species, form)
}
}
@@ -25,15 +25,15 @@ object EvolutionProgressTypes {
ResourceKey.createRegistryKey(cobblemonResource("evolution_progress")), Lifecycle.stable()
)
@JvmStatic
@JvmField
val DAMAGE_TAKEN = this.registerType(DamageTakenEvolutionProgress.ID, EvolutionProgressType(DamageTakenEvolutionProgress.CODEC))
@JvmStatic
@JvmField
val DEFEAT = this.registerType(DefeatEvolutionProgress.ID, EvolutionProgressType(DefeatEvolutionProgress.CODEC))
@JvmStatic
@JvmField
val LAST_BATTLE_CRITICAL_HITS = this.registerType(LastBattleCriticalHitsEvolutionProgress.ID, EvolutionProgressType(LastBattleCriticalHitsEvolutionProgress.CODEC))
@JvmStatic
@JvmField
val RECOIL = this.registerType(RecoilEvolutionProgress.ID, EvolutionProgressType(RecoilEvolutionProgress.CODEC))
@JvmStatic
@JvmField
val USE_MOVE = this.registerType(UseMoveEvolutionProgress.ID, EvolutionProgressType(UseMoveEvolutionProgress.CODEC))
/**
@@ -80,7 +80,9 @@ open class ChoiceSpeciesFeatureProvider(
internal constructor(): this(emptyList())
override fun get(pokemon: Pokemon) = pokemon.getFeature<StringSpeciesFeature>(keys.first())
override fun get(pokemon: Pokemon): StringSpeciesFeature? {
return pokemon.features.filterIsInstance<StringSpeciesFeature>().find { it.name in keys }
}
override fun invoke(pokemon: Pokemon): StringSpeciesFeature? {
val existing = get(pokemon)
@@ -101,15 +103,15 @@ open class ChoiceSpeciesFeatureProvider(
}
override fun invoke(nbt: CompoundTag): StringSpeciesFeature? {
return if (nbt.contains(keys.first())) {
StringSpeciesFeature(keys.first(), "").also { it.loadFromNBT(nbt) }
} else null
val key = keys.find { nbt.contains(it) }
if (key == null) return null
return StringSpeciesFeature(key, "").also { it.loadFromNBT(nbt) }
}
override fun invoke(json: JsonObject): StringSpeciesFeature? {
return if (json.has(keys.first())) {
StringSpeciesFeature(keys.first(), "").also { it.loadFromJSON(json) }
} else null
val key = keys.find { json.has(it) }
if (key == null) return null
return StringSpeciesFeature(key, "").also { it.loadFromJSON(json) }
}
override fun fromString(value: String?): StringSpeciesFeature? {
@@ -131,7 +133,7 @@ open class ChoiceSpeciesFeatureProvider(
override fun provide(properties: PokemonProperties): Set<String> {
return if (isAspect) {
val feature = properties.customProperties.filterIsInstance<StringSpeciesFeature>().find { it.name == keys.first() }
val feature = properties.customProperties.filterIsInstance<StringSpeciesFeature>().find { it.name in keys }
if (feature != null) {
setOf(getAspect(feature))
} else {
@@ -132,7 +132,9 @@ class FlagSpeciesFeatureProvider : SynchronizedSpeciesFeatureProvider<FlagSpecie
constructor(vararg keys: String) : this(keys.toList())
override fun get(pokemon: Pokemon) = pokemon.getFeature<FlagSpeciesFeature>(keys.first())
override fun get(pokemon: Pokemon): FlagSpeciesFeature? {
return pokemon.features.filterIsInstance<FlagSpeciesFeature>().find { it.name in keys }
}
override fun invoke(pokemon: Pokemon): FlagSpeciesFeature? {
return get(pokemon)
@@ -144,15 +146,15 @@ class FlagSpeciesFeatureProvider : SynchronizedSpeciesFeatureProvider<FlagSpecie
}
override fun invoke(nbt: CompoundTag): FlagSpeciesFeature? {
return if (nbt.contains(keys.first())) {
FlagSpeciesFeature(keys.first(), false).also { it.loadFromNBT(nbt) }
} else null
val key = keys.find { nbt.contains(it) }
if (key == null) return null
return FlagSpeciesFeature(key, false).also { it.loadFromNBT(nbt) }
}
override fun invoke(json: JsonObject): FlagSpeciesFeature? {
return if (json.has(keys.first())) {
FlagSpeciesFeature(keys.first(), false).also { it.loadFromJSON(json) }
} else null
val key = keys.find { json.has(it) }
if (key == null) return null
return FlagSpeciesFeature(key, false).also { it.loadFromJSON(json) }
}
override fun fromString(value: String?): FlagSpeciesFeature? {
@@ -170,16 +172,26 @@ class FlagSpeciesFeatureProvider : SynchronizedSpeciesFeatureProvider<FlagSpecie
}
override fun provide(pokemon: Pokemon): Set<String> {
return if (isAspect && pokemon.getFeature<FlagSpeciesFeature>(keys.first())?.enabled == true) {
setOf(keys.first())
return if (isAspect) {
val feature = pokemon.features.filterIsInstance<FlagSpeciesFeature>().find { it.name in keys }
if (feature != null && feature.enabled) {
setOf(keys.first())
} else {
emptySet()
}
} else {
emptySet()
}
}
override fun provide(properties: PokemonProperties): Set<String> {
return if (isAspect && properties.customProperties.filterIsInstance<FlagSpeciesFeature>().find { it.name == keys.first() }?.enabled == true) {
setOf(keys.first())
return if (isAspect) {
val feature = properties.customProperties.filterIsInstance<FlagSpeciesFeature>().find { it.name in keys }
if (feature != null && feature.enabled) {
setOf(keys.first())
} else {
emptySet()
}
} else {
emptySet()
}
@@ -142,19 +142,15 @@ class IntSpeciesFeatureProvider : SynchronizedSpeciesFeatureProvider<IntSpeciesF
}
override fun invoke(nbt: CompoundTag): IntSpeciesFeature? {
return if (nbt.contains(keys.first())) {
IntSpeciesFeature(keys.first(), nbt.getInt(keys.first()))
} else {
null
}
val key = keys.find { nbt.contains(it) }
if (key == null) return null
return IntSpeciesFeature(keys.first(), nbt.getInt(key));
}
override fun invoke(json: JsonObject): IntSpeciesFeature? {
return if (json.has(keys.first())) {
IntSpeciesFeature(keys.first(), json.get(keys.first()).asInt)
} else {
null
}
val key = keys.find { json.has(it) }
if (key == null) return null
return IntSpeciesFeature(keys.first(), json.get(key).asInt)
}
override fun get(pokemon: Pokemon) = pokemon.features.filterIsInstance<IntSpeciesFeature>().find { it.name in keys }
@@ -102,6 +102,12 @@ object SpeciesFeatures : JsonDataRegistry<SpeciesFeatureProvider<*>> {
@JvmStatic
fun register(name: String, provider: SpeciesFeatureProvider<*>) = register(name, provider, isCoded = true)
@JvmStatic
fun registerType(key: String, clazz: Class<out SpeciesFeatureProvider<*>>) {
types[key] = clazz
}
private fun registerFromAssets(identifier: ResourceLocation, provider: SpeciesFeatureProvider<*>) = register(identifier.path, provider, isCoded = false)
@JvmStatic
@@ -34,6 +34,7 @@ fun interface FriendshipMutationCalculator {
* For more information see this [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Friendship#Generation_VIII) entry.
* It will yield 3 between 0 and 99 friendship, 2 between 100 and 199 otherwise 0.
*/
@JvmField
val SWORD_AND_SHIELD_LEVEL_UP = FriendshipMutationCalculator { pokemon ->
when {
pokemon.friendship <= 99 -> 3
@@ -23,6 +23,7 @@ open class Learnset : ClientDataSynchronizer<Learnset> {
val loadMove: (JsonElement, Learnset) -> Boolean
) {
companion object {
@JvmStatic
fun parseFromPrefixIntoList(prefix: String, list: (Learnset) -> MutableList<MoveTemplate>): Interpreter {
return Interpreter { element, learnset ->
val str = element.takeIf { it.isJsonPrimitive }?.asString ?: return@Interpreter false
@@ -40,12 +41,19 @@ open class Learnset : ClientDataSynchronizer<Learnset> {
}
companion object {
@JvmField
val tmInterpreter = Interpreter.parseFromPrefixIntoList("tm") { it.tmMoves }
@JvmField
val eggInterpreter = Interpreter.parseFromPrefixIntoList("egg") { it.eggMoves }
@JvmField
val tutorInterpreter = Interpreter.parseFromPrefixIntoList("tutor") { it.tutorMoves }
@JvmField
val legacyInterpreter = Interpreter.parseFromPrefixIntoList("legacy") { it.legacyMoves }
@JvmField
val specialInterpreter = Interpreter.parseFromPrefixIntoList("special") { it.specialMoves }
@JvmField
val formChangeInterpreter = Interpreter.parseFromPrefixIntoList("form_change") { it.formChangeMoves }
@JvmField
val levelUpInterpreter = Interpreter { element, learnset ->
val str = element.takeIf { it.isJsonPrimitive }?.asString ?: return@Interpreter false
val splits = str.split(":")
@@ -68,6 +76,7 @@ open class Learnset : ClientDataSynchronizer<Learnset> {
}
@JvmField
val interpreters = mutableListOf(
tmInterpreter,
eggInterpreter,
@@ -22,7 +22,7 @@ fun interface LearnsetQuery {
fun canLearn(move: MoveTemplate, learnset: Learnset): Boolean
companion object {
@JvmField
val ANY = LearnsetQuery { move, learnset ->
learnset.levelUpMoves.values.any { it.contains(move) }
|| learnset.eggMoves.contains(move)
@@ -34,6 +34,7 @@ fun interface LearnsetQuery {
|| learnset.specialMoves.contains(move)
}
@JvmField
val LEGAL = LearnsetQuery { move, learnset ->
learnset.levelUpMoves.values.any { it.contains(move) }
|| learnset.eggMoves.contains(move)
@@ -43,22 +44,31 @@ fun interface LearnsetQuery {
|| learnset.evolutionMoves.contains(move)
}
@JvmStatic
fun level(level: Int) = LearnsetQuery { move, learnset -> learnset.getLevelUpMovesUpTo(level).contains(move) }
@JvmField
val ANY_LEVEL = LearnsetQuery { move, learnset -> learnset.levelUpMoves.values.any { it.contains(move) } }
@JvmField
val EGG_MOVE = LearnsetQuery { move, learnset -> learnset.eggMoves.contains(move) }
@JvmField
val TUTOR_MOVES = LearnsetQuery { move, learnset -> learnset.tutorMoves.contains(move) }
@JvmField
val TM_MOVE = LearnsetQuery { move, learnset -> learnset.tmMoves.contains(move) }
@JvmField
val FORM_CHANGE = LearnsetQuery { move, learnset -> learnset.formChangeMoves.contains(move) }
@JvmField
val EVOLUTION = LearnsetQuery { move, learnset -> learnset.evolutionMoves.contains(move) }
@JvmField
val LEGACY_MOVES = LearnsetQuery { move, learnset -> learnset.legacyMoves.contains(move) }
@JvmField
val SPECIAL_MOVES = LearnsetQuery { move, learnset -> learnset.specialMoves.contains(move) }
}
@@ -70,7 +70,7 @@ interface Stat {
/**
* A [Codec] for [Stat] without filtering the [Stat.Type].
*/
@JvmStatic
@JvmField
val ALL_CODEC: Codec<Stat> = CodecUtils.createByIdentifierCodec(
Cobblemon.statProvider::fromIdentifier,
Stat::identifier
@@ -79,7 +79,7 @@ interface Stat {
/**
* A [Codec] for [Stat] with the [Stat.Type.PERMANENT].
*/
@JvmStatic
@JvmField
val PERMANENT_ONLY_CODEC: Codec<Stat> = ALL_CODEC.comapFlatMap(
{ stat -> if (stat.type == Type.PERMANENT) DataResult.success(stat) else DataResult.error { "${stat.identifier} is not of type ${Type.PERMANENT}" } },
{ stat -> stat }
@@ -88,7 +88,7 @@ interface Stat {
/**
* A [Codec] for [Stat] with the [Stat.Type.BATTLE_ONLY].
*/
@JvmStatic
@JvmField
val BATTLE_ONLY_CODEC: Codec<Stat> = ALL_CODEC.comapFlatMap(
{ stat -> if (stat.type == Type.BATTLE_ONLY) DataResult.success(stat) else DataResult.error { "${stat.identifier} is not of type ${Type.BATTLE_ONLY}" } },
{ stat -> stat }
@@ -35,21 +35,25 @@ enum class Stats(override val identifier: ResourceLocation, override val display
* All the stats, an alternative to [values].
* Using [StatProvider.all] is recommended instead for maximum addon compatibility.
*/
@JvmField
val ALL: Set<Stat> = EnumSet.allOf(Stats::class.java)
/**
* All the stats with type of [Stat.Type.PERMANENT].
* Using [StatProvider.ofType] with type [Stat.Type.PERMANENT] is recommended instead for maximum addon compatibility.
*/
@JvmField
val PERMANENT: Set<Stat> = EnumSet.of(HP, ATTACK, DEFENCE, SPECIAL_ATTACK, SPECIAL_DEFENCE, SPEED)
/**
* All the stats with type of [Stat.Type.BATTLE_ONLY].
* Using [StatProvider.ofType] with type [Stat.Type.BATTLE_ONLY] is recommended instead for maximum addon compatibility.
*/
@JvmField
val BATTLE_ONLY: Set<Stat> = EnumSet.of(EVASION, ACCURACY)
/** Gets the [Stat] from the respective Showdown id. */
@JvmStatic
fun getStat(statKey: String) = when(statKey.lowercase()) {
"hp" -> HP
"atk", "attack" -> ATTACK // Hyper Cutter states the full stat name "Attack"
@@ -62,6 +66,7 @@ enum class Stats(override val identifier: ResourceLocation, override val display
}
/** Gets the severity lang key from the respective boost/unboost stage. */
@JvmStatic
fun getSeverity(stages: Int) = when(stages) {
0 -> "cap.single"
1 -> "slight"
@@ -30,7 +30,7 @@ open class Status(
/**
* A [Codec] for [Status].
*/
@JvmStatic
@JvmField
val CODEC: Codec<Status> = CodecUtils.createByIdentifierCodec(
Statuses::getStatus,
Status::name
@@ -25,17 +25,23 @@ import com.cobblemon.mod.common.util.server
interface CustomPokemonProperty {
companion object {
/** A list of all the registered [CustomPokemonPropertyType]s. */
@JvmField
val properties = mutableListOf<CustomPokemonPropertyType<*>>()
@JvmStatic
fun <T: CustomPokemonProperty> register(propertyType: CustomPokemonPropertyType<T>) {
properties.add(propertyType)
this.triggerSyncAttempt()
}
@JvmStatic
@JvmOverloads
fun <T : CustomPokemonProperty> register(name: String, needsLabel: Boolean = true, fromString: (String?) -> T?, examples: () -> Collection<String>) {
register(listOf(name), needsLabel, fromString, examples)
}
@JvmStatic
@JvmOverloads
fun <T : CustomPokemonProperty> register(aliases: Iterable<String>, needsLabel: Boolean = true, fromString: (String?) -> T?, examples: () -> Collection<String>) {
properties.add(
object : CustomPokemonPropertyType<T> {
@@ -48,6 +54,7 @@ interface CustomPokemonProperty {
this.triggerSyncAttempt()
}
@JvmStatic
fun unregister(property: CustomPokemonPropertyType<*>) {
properties.remove(property)
}
@@ -11,6 +11,7 @@ package com.cobblemon.mod.common.api.reactive
import com.cobblemon.mod.common.api.events.Cancelable
open class EventObservable<T> : SimpleObservable<T>() {
@JvmOverloads
inline fun post(vararg events: T, then: (T) -> Unit = {}) {
// Issuing generic-typed pass-throughs to varargs doesn't work
// properly unless the source is a vararg as well, complicated story.
@@ -59,10 +59,12 @@ interface Observable<T> {
companion object {
/** Creates a completed [Observable] with the given values. This [Observable] cannot receive new values. */
@JvmStatic
fun <T> just(vararg values: T): Observable<T> {
return SingularObservable<T>().also { it.emit(*values) }
}
@JvmStatic
fun <T> of(future: CompletableFuture<T>): Observable<T> {
val observable = SingularObservable<T>()
future.thenAccept { observable.emit(it) }
@@ -70,20 +72,28 @@ interface Observable<T> {
}
/** Gets a [TakeFirstTransform] */
@JvmStatic
fun <T> takeFirst(amount: Int = 1) = TakeFirstTransform<T>(amount)
/** Gets a [IgnoreFirstTransform] */
@JvmStatic
fun <T> ignoreFirst(amount: Int = 1) = IgnoreFirstTransform<T>(amount)
/** Gets a [FilterTransform] */
@JvmStatic
fun <T> filter(predicate: (T) -> Boolean) = FilterTransform(predicate)
/** Gets a [MapTransform] */
@JvmStatic
fun <T, O> map(mapping: (T) -> O) = MapTransform(mapping)
/** Gets a [EmitWhileTransform] */
@JvmStatic
fun <T> emitWhile(predicate: (T) -> Boolean) = EmitWhileTransform(predicate)
/** Gets a [StopAfterTransform] */
@JvmStatic
fun <T> stopAfter(predicate: (T) -> Boolean) = StopAfterTransform(predicate)
/** Gets a transform which will take values until the given predicate is met. */
@JvmStatic
fun <T> emitUntil(predicate: (T) -> Boolean) = EmitWhileTransform<T> { !predicate(it) }
/** Gets a transform which does not change the value but lets you access the value at this stage of the pipe. */
@JvmStatic
fun <T> tap(handler: (T) -> Unit) = map<T, T> { handler(it); return@map it }
}
}
@@ -29,7 +29,9 @@ enum class RidingStat(
JUMP(Flavour.BITTER);
companion object {
@JvmStatic
fun getByName(name: String) = RidingStat.entries.firstOrNull { it.name.equals(name, ignoreCase = true) }
@JvmStatic
fun getByFlavour(flavour: Flavour) = RidingStat.entries.firstOrNull { it.flavour == flavour }
}
@@ -72,6 +72,7 @@ class BedrockParticle(
// kill plane maybe
companion object {
@JvmField
val EXPRESSION_SET_CODEC = RecordCodecBuilder.create<ExpressionSet> { instance ->
instance.group(
EXPRESSION_CODEC.fieldOf("sizeX").forGetter { it.sizeX },
@@ -83,6 +84,7 @@ class BedrockParticle(
).apply(instance, ::ExpressionSet)
}
@JvmField
val EVENT_SET_CODEC = RecordCodecBuilder.create<EventSet> { instance ->
instance.group(
SimpleEventTrigger.CODEC.listOf().fieldOf("creationEvents").forGetter { it.creationEvents },
@@ -91,6 +93,7 @@ class BedrockParticle(
).apply(instance, ::EventSet)
}
@JvmField
val CODEC: Codec<BedrockParticle> = RecordCodecBuilder.create { instance ->
instance.group(
ResourceLocation.CODEC.fieldOf("texture").forGetter { it.texture },
@@ -36,6 +36,7 @@ class BedrockParticleOptions(
var events: MutableMap<String, ParticleEvent> = mutableMapOf()
) {
companion object {
@JvmField
val CODEC: Codec<BedrockParticleOptions> = RecordCodecBuilder.create { instance ->
instance.group(
ResourceLocation.CODEC.fieldOf("id").forGetter { it.id },
@@ -39,6 +39,7 @@ class BedrockParticleEmitter(
var loopingTravelDistanceEvents: MutableList<LoopingTravelDistanceEventTrigger> = mutableListOf()
) {
companion object {
@JvmField
val CODEC: Codec<BedrockParticleEmitter> = RecordCodecBuilder.create { instance ->
instance.group(
EXPRESSION_CODEC.listOf().fieldOf("startExpressions").forGetter { it.startExpressions },
@@ -20,6 +20,7 @@ class EmitterSpace(
var scaling: ScalingMode = ScalingMode.WORLD
) {
companion object {
@JvmField
val CODEC: Codec<EmitterSpace> = RecordCodecBuilder.create { instance ->
instance.group(
Codec.STRING.optionalFieldOfWithDefault("scaling", "world").forGetter { it.scaling.toString() }
@@ -66,6 +66,7 @@ class LinearMoLangCurve(
var nodes: List<Double> = emptyList()
) : MoLangCurve {
companion object {
@JvmField
val CODEC: Codec<LinearMoLangCurve> = RecordCodecBuilder.create { instance ->
instance.group(
PrimitiveCodec.STRING.fieldOf("type").forGetter { it.type.name },
@@ -127,6 +128,7 @@ class CatmullRomMoLangCurve(
}
companion object {
@JvmField
val CODEC: Codec<CatmullRomMoLangCurve> = RecordCodecBuilder.create { instance ->
instance.group(
PrimitiveCodec.STRING.fieldOf("type").forGetter { it.type.name },
@@ -202,6 +204,7 @@ class BezierChainMoLangCurve(
}
companion object {
@JvmField
val CODEC = RecordCodecBuilder.create<BezierChainNode> { instance ->
instance.group(
PrimitiveCodec.DOUBLE.fieldOf("value").forGetter { it.value },
@@ -230,6 +233,7 @@ class BezierChainMoLangCurve(
class BezierChainPointData(val time: Double, val value: Double, val slope: Double)
companion object {
@JvmField
val CODEC: Codec<BezierChainMoLangCurve> = RecordCodecBuilder.create { instance ->
instance.group(
PrimitiveCodec.STRING.fieldOf("type").forGetter { it.type.name },
@@ -280,6 +284,7 @@ class BezierMoLangCurve(
}
companion object {
@JvmField
val CODEC: Codec<BezierMoLangCurve> = RecordCodecBuilder.create { instance ->
instance.group(
PrimitiveCodec.STRING.fieldOf("type").forGetter { it.type.name },

Some files were not shown because too many files have changed in this diff Show More