mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-11-27 02:28:53 -05:00
Compare commits
213
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1da7f76656 | ||
|
|
3e5733ceaf | ||
|
|
af29c99b03 | ||
|
|
60d596a24f | ||
|
|
4003456e5c | ||
|
|
1d21a52d28 | ||
|
|
2d49c62f85 | ||
|
|
da18b082a6 | ||
|
|
f8a16e5081 | ||
|
|
cad39d8802 | ||
|
|
00905b8c32 | ||
|
|
79b3cb8611 | ||
|
|
797e908621 | ||
|
|
3df3c395de | ||
|
|
89bba8a67a | ||
|
|
6d6e13be83 | ||
|
|
899bec77b6 | ||
|
|
6dd8325772 | ||
|
|
79faadef59 | ||
|
|
d9ca7b483d | ||
|
|
708f7fc1b8 | ||
|
|
621db85845 | ||
|
|
b09066c580 | ||
|
|
7c45f28827 | ||
|
|
9c1b2cae22 | ||
|
|
16b2f81bd4 | ||
|
|
6e0c005587 | ||
|
|
db0fb8e287 | ||
|
|
dae36a67d1 | ||
|
|
6f99862288 | ||
|
|
0377747e1e | ||
|
|
154b653c57 | ||
|
|
04489bc969 | ||
|
|
25499b3e7a | ||
|
|
bb6bda54dc | ||
|
|
9f3dbdc2d8 | ||
|
|
932148338c | ||
|
|
309f674853 | ||
|
|
dc705c7720 | ||
|
|
9bfc577444 | ||
|
|
3ca6d350fe | ||
|
|
2997ce8457 | ||
|
|
ff279d8310 | ||
|
|
cdb8ee0d8e | ||
|
|
e7d86a382c | ||
|
|
eb911df830 | ||
|
|
1c30acc53c | ||
|
|
2a0e8f6d47 | ||
|
|
e6bd8ec529 | ||
|
|
911a95e873 | ||
|
|
447cfc2ae5 | ||
|
|
8dfeb0d260 | ||
|
|
caa7b19833 | ||
|
|
64dd8ae193 | ||
|
|
156ee6f290 | ||
|
|
fe433d1417 | ||
|
|
0dc662d295 | ||
|
|
081e370bfd | ||
|
|
3ef0567287 | ||
|
|
3cad9e5481 | ||
|
|
dc8b7908be | ||
|
|
85085a1eca | ||
|
|
bff59dee6e | ||
|
|
bb5828531a | ||
|
|
cd08e98c28 | ||
|
|
bf7d40c9b5 | ||
|
|
5abb3d7f97 | ||
|
|
975ad8186a | ||
|
|
26b6419f04 | ||
|
|
331f7ca425 | ||
|
|
f445c05333 | ||
|
|
71c9ac0ff0 | ||
|
|
1404cc0ab5 | ||
|
|
a62485fc1f | ||
|
|
044f3080ff | ||
|
|
28b0cab906 | ||
|
|
82f34d651c | ||
|
|
6ca908a91d | ||
|
|
0948b8da9a | ||
|
|
22e04a53b3 | ||
|
|
df3217b41b | ||
|
|
9ff15a1913 | ||
|
|
89e43945a3 | ||
|
|
bd8dcddf35 | ||
|
|
dd372f3160 | ||
|
|
c56aab28d4 | ||
|
|
ca58801794 | ||
|
|
38fa5e2628 | ||
|
|
fae1ae7124 | ||
|
|
3ec5f76c73 | ||
|
|
5bb8aaba55 | ||
|
|
23ba41e981 | ||
|
|
29b049452b | ||
|
|
0b0f665804 | ||
|
|
3cdf28ffdd | ||
|
|
5d53fba2ce | ||
|
|
c6fb18ea51 | ||
|
|
2d851cb134 | ||
|
|
f685be0aab | ||
|
|
14cc851562 | ||
|
|
7223d1fd68 | ||
|
|
6ab5ad52ec | ||
|
|
079b2ae766 | ||
|
|
34eea827e7 | ||
|
|
06c6ee5a9c | ||
|
|
54748c20ea | ||
|
|
75f52e4cf4 | ||
|
|
55446dd4b1 | ||
|
|
02e63b6fc8 | ||
|
|
3aebcf66ec | ||
|
|
49a5f716b7 | ||
|
|
8b825d558f | ||
|
|
9a7f97f11f | ||
|
|
95b8d62e4a | ||
|
|
0bd7b4dab3 | ||
|
|
8cbada0cf5 | ||
|
|
f0784fec2d | ||
|
|
cfe0c5e0a5 | ||
|
|
0bc5bb5caa | ||
|
|
3330941a2c | ||
|
|
79ea082d7e | ||
|
|
3d78929ff0 | ||
|
|
5d94b03f7a | ||
|
|
587305eb52 | ||
|
|
e363ce5e0e | ||
|
|
e49b704200 | ||
|
|
ec8b35860c | ||
|
|
74c49bf2da | ||
|
|
c03e7d9ed3 | ||
|
|
f25a676bd5 | ||
|
|
a9906762a0 | ||
|
|
7b5b88eca2 | ||
|
|
291682ba52 | ||
|
|
546d403b45 | ||
|
|
2652e53e0c | ||
|
|
b423fb1c46 | ||
|
|
8ae26a268a | ||
|
|
39b522abcc | ||
|
|
9bcfcef4fd | ||
|
|
60ac2d8058 | ||
|
|
9366d28141 | ||
|
|
75b48196b7 | ||
|
|
c9f40e32a1 | ||
|
|
d642b8dd07 | ||
|
|
549a11116e | ||
|
|
b5468a4a4f | ||
|
|
c5d278ccb7 | ||
|
|
bf5e15de45 | ||
|
|
f4af417267 | ||
|
|
69c04acaeb | ||
|
|
83a6bb188f | ||
|
|
494a8b5e91 | ||
|
|
c8021f2f08 | ||
|
|
8cdf3af047 | ||
|
|
c90a24e1ab | ||
|
|
83e3cfc34e | ||
|
|
133dd4e5b7 | ||
|
|
a8cca14b86 | ||
|
|
9b0f356fa4 | ||
|
|
f2b0a102b6 | ||
|
|
a7d01b230a | ||
|
|
2a7db4b9b8 | ||
|
|
77e5f2501d | ||
|
|
e6513717bd | ||
|
|
0e0c98f693 | ||
|
|
528bfa4e22 | ||
|
|
83c87779d7 | ||
|
|
dc33235144 | ||
|
|
935c658c5f | ||
|
|
0426f4fbf9 | ||
|
|
75bc03fdcb | ||
|
|
f65cb9538c | ||
|
|
46e771a062 | ||
|
|
4c0095844b | ||
|
|
10a2ef27d6 | ||
|
|
309ff3da13 | ||
|
|
3af91e2a74 | ||
|
|
2e027e3db7 | ||
|
|
fc40fb02c0 | ||
|
|
2c1c0299f9 | ||
|
|
3c7637515c | ||
|
|
08cbbaf68c | ||
|
|
6e911acf01 | ||
|
|
f6d82a1b28 | ||
|
|
702126aeab | ||
|
|
df566e8fcb | ||
|
|
c83e0f33b5 | ||
|
|
f279f936b6 | ||
|
|
f8e20bafd9 | ||
|
|
a5211ca7ff | ||
|
|
0a5abdb331 | ||
|
|
4ed7413dd2 | ||
|
|
40b66c24fc | ||
|
|
2f7bedf001 | ||
|
|
44c31a9ddb | ||
|
|
20a35de3d8 | ||
|
|
cfc8a15db1 | ||
|
|
d5ba22a86c | ||
|
|
a38505f1c5 | ||
|
|
3cf1ba1fb3 | ||
|
|
9f5d595827 | ||
|
|
75673f0204 | ||
|
|
b43a7571ff | ||
|
|
b071dc04d3 | ||
|
|
12f9ff1647 | ||
|
|
3256a302df | ||
|
|
edbe447477 | ||
|
|
2f43910368 | ||
|
|
c2e87e4cfa | ||
|
|
e40d2ee806 | ||
|
|
ba74e7603b | ||
|
|
19c3fe6dc4 | ||
|
|
d0778dd124 |
No files matched your search
@@ -45,6 +45,3 @@ common/.fabric
|
||||
# MacOS
|
||||
.DS_Store
|
||||
/common/config/*
|
||||
|
||||
# Temp Files
|
||||
/temp/
|
||||
+129
-42
@@ -1,60 +1,147 @@
|
||||
# Changelog
|
||||
## [1.8.1 (MONTH Xth, 2026)](#1-8-1)
|
||||
## [1.8.2 (MONTH xth, 2026)](#1-8-2)
|
||||
|
||||
### Additions
|
||||
|
||||
### New rideable Pokémon
|
||||
|
||||
### Pokémon Added
|
||||
|
||||
### Model updates for the following Pokémon
|
||||
|
||||
### Animation updates for the following Pokémon
|
||||
|
||||
### Changes
|
||||
- The following items can now be placed on the ground as blocks:
|
||||
- King's Rock, Galarica Cuff, Unremarkable Teacup, Masterpiece Teacup, Chipped Pot, Cracked Pot, Sachet, Metal Powder, Quick Powder, Bright Powder, Icy Rock, Heat Rock, Smooth Rock, Damp Rock, Destiny Knot, Luminous Moss, Never-Melt Ice, Wide Lens, Scope Lens, and Zoom Lens.
|
||||
- Iron Ball, Metal Coat, Throat Spray, HP Up, Protein, Iron, Carbos, Calcium, Zinc, PP Up, PP Max, Upgrade, Dubious Disc, and Loaded Dice.
|
||||
- The following items can now be placed on various surfaces:
|
||||
- Galarica Wreath, Magnet, Flame Orb, Life Orb, Toxic Orb, Light Ball, and Smoke Ball.
|
||||
- The following items can now be placed as blocks and have additional functionality:
|
||||
- Ring Target, Metronome, and Eject Button.
|
||||
- The following items can now be worn by Players and Pokémon:
|
||||
- Galarica Wreath, Cleanse Tag, Spell Tag, Sharp Beak, Covert Cloak, Shell Helmet, and Never-Melt Ice.
|
||||
- Wearable items can now be equipped by a player by holding it and right-clicking (or rebound use/interact)
|
||||
- Wearable items that can be placed down are exempt from this behaviour.
|
||||
- New Cosmetic Item for Pikachu: Paper
|
||||
|
||||
### Fixes
|
||||
- Fixed the `stat_compare` and `stat_equal` evolution requirements crashing the game when given `special_attack` or `special_defence`, and made them treat any non-permanent stat as a failed requirement instead of crashing.
|
||||
- Fixed the Beast Ball not applying its 0.1× penalty to Pokémon that are not Ultra Beasts.
|
||||
- Fixed the Moon Ball reading the world's total elapsed time instead of the time of day, so its bonus applied during the day instead.
|
||||
- Fixed the Love Ball never awarding its 2.5× opposite gender bonus, and matching species by display name instead of identifier.
|
||||
- Fixed the Timer Ball being weaker than a regular Poké Ball on early turns and only reaching 4× on turn 14 instead of turn 10.
|
||||
- Fixed the Luxury Ball only doubling Friendship gains of 1, leaving level up and berry gains unaffected.
|
||||
- Fixed NPCs getting their own TM progress file.
|
||||
- Fixed the TM Machine refusing move selections that the `unlockAllMoveDexMovesByDefault` config had made visible, leaving the move slot blank and the craft button unresponsive.
|
||||
- Fixed Rufflet, Braviary, and Hisuian Braviary flooding logs with errors about missing sound events.
|
||||
- Fixed Pokémon property typos in Pangoro and Dedenne herd spawn files.
|
||||
- Fixed form typo in Rockruff dusk spawn entry.
|
||||
- Fixed a potential world gen stall with the Type Gem clusters.
|
||||
- Fixed Rowap and Jacoba berries not correctly altering Pokémon sizes when used as bait
|
||||
- Fixed Ampharos' eyes not emitting particles
|
||||
- Fixed Alolan Raticate's cry not playing
|
||||
- Fixed unintentional watermelon cosmetic for Hisuian Electrode.
|
||||
- Fixed Blastoise having an unintentional passenger seat
|
||||
- Fixed odd NeoForge crash due to a dependency being outdated. It will now flag the dependency for being outdated correctly.
|
||||
- Fixed form typo in Rockruff-Dusk spawn, preventing it from being able to spawn.
|
||||
- Fixed a potential world gen stall caused by Type Gem clusters.
|
||||
- Fixed Rowap and Jacoba berries not correctly altering Pokémon sizes when used as bait.
|
||||
- Fixed Ampharos' eyes not emitting particles.
|
||||
- Fixed Alolan Raticate's cry not playing.
|
||||
- Fixed odd NeoForge crash due to a dependency being outdated. It will now correctly flag the dependency for being outdated.
|
||||
- Fixed several incorrect light-based spawning conditions for ghosts and bugs.
|
||||
- Removed unused, placeholder habitat pools.
|
||||
- Fixed Mantyke, Mantine, and Quaxly getting stuck in a recoil 'expression' during battles due to a having an expression mistakenly assigned as a recoil animation.
|
||||
- Fixed Pokémon on shoulders not animating if they are visibly holding a held item.
|
||||
- Fixed Mantyke, Mantine, and Quaxly getting stuck in a recoil 'expression' during battles due to a having an expression mistakenly assigned as a recoil animation.
|
||||
- Fixed #updateMovesOnFormChange not properly initializing a form-swapped Pokemon's non-form_change moves.
|
||||
### TEST
|
||||
### Pokémon Added
|
||||
#### Generation 4
|
||||
- Snover
|
||||
- Abomasnow
|
||||
- Burmy
|
||||
- Wormadam
|
||||
- Mothim
|
||||
|
||||
#### Generation 5
|
||||
- Tympole
|
||||
- Palpitoad
|
||||
- Seismitoad
|
||||
|
||||
#### Generation 6
|
||||
- Helioptile
|
||||
- Heliolisk
|
||||
|
||||
#### Generation 7
|
||||
- Grubbin
|
||||
- Charjabug
|
||||
- Vikavolt
|
||||
- Minior
|
||||
|
||||
#### Generation 8
|
||||
- Eternatus
|
||||
|
||||
#### Generation 9
|
||||
- Greavard
|
||||
- Houndstone
|
||||
|
||||
### Model updates for the following Pokémon
|
||||
- Sudowoodo
|
||||
- Spheal
|
||||
- Cacnea
|
||||
- Cacturne
|
||||
- Binacle
|
||||
- Barbaracle
|
||||
- Glimmet
|
||||
- Glimmora
|
||||
- Deerling
|
||||
- Sawsbuck (All forms)
|
||||
- Absol
|
||||
- Poliwag
|
||||
- Politoed
|
||||
- Ekans
|
||||
- Oddish
|
||||
- Gloom
|
||||
- Vileplume
|
||||
- Bellossom
|
||||
- Shroomish
|
||||
- Chespin
|
||||
- Quilladin
|
||||
- Chesnaught
|
||||
- Fennekin
|
||||
- Braixen
|
||||
- Delphox
|
||||
- Froakie
|
||||
- Frogadier
|
||||
- Greninja
|
||||
- Shinx
|
||||
- Luxio
|
||||
- Luxray
|
||||
- Slakoth
|
||||
- Riolu
|
||||
- Lucario
|
||||
|
||||
### Animation updates for the following Pokémon
|
||||
- Treecko (New Shoulder Mount!)
|
||||
- Bonsly (New Shoulder Mount!)
|
||||
- Sudowoodo
|
||||
- Cacnea
|
||||
- Cacturne
|
||||
- Ekans
|
||||
- Arbok
|
||||
- Oddish
|
||||
- Gloom
|
||||
- Vileplume
|
||||
- Bellossom
|
||||
- Pichu
|
||||
- Pikachu
|
||||
- Raichu (+ Alolan)
|
||||
- Greninja
|
||||
- Slakoth
|
||||
|
||||
### Changes
|
||||
- Updated various recipes to display in Recipe Groups within the Recipe Book
|
||||
- Updated most recipes to display more logically/consistently within the Recipe Book's categories
|
||||
- Make ride rotations less jittery in multiplayer.
|
||||
- Made regional and Vivillon split-evo locations now mutually exclusive
|
||||
- Vivillon's patterns are now viewable as forms with form names and unique Pokedex entries displayed.
|
||||
|
||||
### Fixes
|
||||
- Correctly grants "They're Minerals!" advancement when planting a type gem
|
||||
- Type Gem Blocks now have advancements to give you the recipe in the recipe book (the data for the advancements were inside the recipes somehow??)
|
||||
- Some other recipes without advancements have also been corrected
|
||||
- Corrected the TM Recipes for Charge Beam and Payday
|
||||
- Type Gem blocks now properly generate clusters off of the block.
|
||||
- Starter Screen Categories will no longer stop rendering if they are bigger than the viewport, and you are not viewing top or bottom edges
|
||||
- Random Starter option now properly handled in height calculation, so now it won't run off into other categories or be un-accessible due to scroll limits if it causes a new row
|
||||
- Mochi and Feathers no longer drop glass bottles on use
|
||||
- Fixed a rare set of concurrency bugs related to reloading packs on NeoForge; fixes a ModernFix issue
|
||||
- Removed unnecessary conditions for Mimikyu's standing pose. Hopefully fixes the rare instance of it using its shoulder animations during battle in multiplayer scenarios.
|
||||
- Fixed Rockruff line not blinking
|
||||
- Fixed Flygon sometimes using its running animation instead of walking
|
||||
- Fixed Bramblin always sleeping outside of battle
|
||||
- Fixed Dragonair using its battle idle as a normal idle
|
||||
- Fixed Lycanroc's head movement
|
||||
- Added head movement to Archaludon
|
||||
- Fixed Duraludon line not having their sleep animations
|
||||
- Fixed Duraludon line not having any sleep animations
|
||||
- Fixed Diglett line not having their faint animations
|
||||
- Fixed Kingambit moving its legs while walking
|
||||
|
||||
- Fixed Alolan Diglett's cry not playing
|
||||
- Fixed shiny alpha Snorlax using the non-shiny texture
|
||||
- Various Structure fixes
|
||||
|
||||
### Developer
|
||||
|
||||
### Molang & Datapacks
|
||||
- A new `negate` variant for evolution requirements has been added, which will negate (invert) the provided inner condition.
|
||||
- Added Molang functions for individual Pokédex ids, wherein a subdex is passed in as a string to `dex_caught_count` etc.
|
||||
|
||||
### Particles
|
||||
|
||||
#### New Move Animations
|
||||
|
||||
### Localization
|
||||
- Updated translations for:
|
||||
@@ -1,9 +0,0 @@
|
||||
- Some kind of particle effect for them? they're meant to have glowing eyes, so maybe some red particles on the eye locator
|
||||
--- global posers? stacked posers?
|
||||
--- red texture seems to be what some people wanted.
|
||||
|
||||
/- shoulder mounts part of it
|
||||
- omni boost
|
||||
- roar when player comes within reach, adjust levels
|
||||
|
||||
- Riding settings to control what the min scale is for a pokemon to be ridable.
|
||||
@@ -0,0 +1,41 @@
|
||||
# Changelog
|
||||
## [1.8.1 (September 13th, 2026)](#1-8-1)
|
||||
|
||||
### Animation updates for the following Pokémon
|
||||
- Flapple, Appletun, Dipplin, Hydrapple (placeholder animations only).
|
||||
|
||||
### Fixes
|
||||
- Fixed a potential world generation stall caused by Type Gem clusters.
|
||||
- Fixed Pokémon on shoulders not animating if they are visibly holding a held item.
|
||||
- Fixed NPCs getting their own TM progress file.
|
||||
- Fixed odd NeoForge crash due to a dependency being outdated. It will now correctly flag the dependency for being outdated.
|
||||
- Fixed the TM Machine refusing move selections that the `unlockAllMoveDexMovesByDefault` config had made visible, leaving the move slot blank and the craft button unresponsive.
|
||||
- Fixed the Beast Ball not applying its 0.1× penalty to Pokémon that are not Ultra Beasts.
|
||||
- Fixed the Moon Ball reading the world's total elapsed time instead of the time of day, so its bonus applied during the day instead.
|
||||
- Fixed the Love Ball never awarding its 2.5× opposite gender bonus, and matching species by display name instead of identifier.
|
||||
- Fixed the Timer Ball being weaker than a regular Poké Ball on early turns and only reaching 4× on turn 14 instead of turn 10.
|
||||
- Fixed the Luxury Ball only doubling Friendship gains of 1, leaving level up and berry gains unaffected.
|
||||
- Fixed Rufflet, Braviary, and Hisuian Braviary flooding logs with errors about missing sound events.
|
||||
- Fixed Pokémon property typos in Pangoro and Dedenne herd spawn files.
|
||||
- Fixed unintentional watermelon cosmetic for Hisuian Electrode.
|
||||
- Fixed Blastoise having an unintentional passenger seat.
|
||||
- Fixed form typo in Rockruff-Dusk spawn, preventing it from being able to spawn.
|
||||
- Fixed the `stat_compare` and `stat_equal` evolution requirements crashing the game when given `special_attack` or `special_defence`, and made them treat any non-permanent stat as a failed requirement instead of crashing.
|
||||
- Fixed Rowap and Jacoba berries not correctly altering Pokémon sizes when used as bait.
|
||||
- Fixed Ampharos' eyes not emitting particles.
|
||||
- Fixed Alolan Raticate's cry not playing.
|
||||
- Fixed several incorrect light-based spawning conditions for ghosts and bugs.
|
||||
- Removed unused, placeholder habitat pools.
|
||||
- Fixed Mantyke, Mantine, and Quaxly getting stuck in a recoil 'expression' during battles due to having an expression assigned as a recoil animation.
|
||||
- Fixed Lucario's aura particles not emitting.
|
||||
- Fixed Lycanroc's head movement.
|
||||
- Added head movement to Archaludon.
|
||||
- Fixed Duraludon line not having their sleep animations.
|
||||
- Fixed Diglett line not having their faint animations.
|
||||
- Fixed Kingambit moving its legs while walking.
|
||||
|
||||
### Localization
|
||||
- Updated translations for:
|
||||
- Brazilian Portuguese
|
||||
- Simplified Chinese
|
||||
- Japanese
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
package com.cobblemon.mod.common
|
||||
|
||||
import com.cobblemon.mod.common.battles.TeamPreviewManager
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonBuildDetails.smallCommitHash
|
||||
import com.cobblemon.mod.common.api.Priority
|
||||
import com.cobblemon.mod.common.api.SeasonResolver
|
||||
@@ -256,7 +254,6 @@ object Cobblemon {
|
||||
}
|
||||
PlatformEvents.SERVER_PLAYER_LOGOUT.subscribe {
|
||||
PCLinkManager.removeLink(it.player.uuid)
|
||||
TeamPreviewManager.remove(it.player)
|
||||
BattleRegistry.onPlayerDisconnect(it.player)
|
||||
storage.onPlayerDisconnect(it.player)
|
||||
playerDataManager.onPlayerDisconnect(it.player)
|
||||
@@ -453,7 +450,6 @@ object Cobblemon {
|
||||
}
|
||||
|
||||
PlatformEvents.SERVER_STOPPED.subscribe {
|
||||
TeamPreviewManager.clear()
|
||||
storage.unregisterAll(it.server.registryAccess())
|
||||
playerDataManager.saveAllStores()
|
||||
playerDataManager.saveExecutor.shutdown()
|
||||
|
||||
@@ -16,6 +16,8 @@ import com.cobblemon.mod.common.block.MintBlock.MintType
|
||||
import com.cobblemon.mod.common.block.campfirepot.CampfireBlock
|
||||
import com.cobblemon.mod.common.block.campfirepot.CampfirePotBlock
|
||||
import com.cobblemon.mod.common.block.chest.GildedChestBlock
|
||||
import com.cobblemon.mod.common.block.decor.ActivatableDecorationBlock
|
||||
import com.cobblemon.mod.common.block.decor.RingTargetBlock
|
||||
import com.cobblemon.mod.common.block.general.BaleBlock
|
||||
import com.cobblemon.mod.common.block.general.HorizontalRotationCarpetBlock
|
||||
import com.cobblemon.mod.common.block.general.HorizontalRotationalBlock
|
||||
@@ -620,6 +622,88 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
@JvmField
|
||||
val WEAKNESS_POLICY = create("weakness_policy", WallAttachedDirectionalShapeBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_PAPER_LARGE_SOUNDS).mapColor(MapColor.NONE).noOcclusion().noCollission(), 14, 12, 1))
|
||||
|
||||
@JvmField
|
||||
val RING_TARGET = create("ring_target", RingTargetBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOD).mapColor(MapColor.NONE).noOcclusion().strength(0.125f)))
|
||||
@JvmField
|
||||
val MAGNET = create("magnet", MagnetBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.NONE).noOcclusion().strength(0.075f)))
|
||||
@JvmField
|
||||
val GALARICA_WREATH = create("galarica_wreath", GalaricaWreathBlock(BlockBehaviour.Properties.of().sound(SoundType.AZALEA_LEAVES).mapColor(MapColor.NONE).noOcclusion().noCollission()))
|
||||
|
||||
@JvmField
|
||||
val FLAME_ORB = create("flame_orb", OrbBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion().lightLevel{15}))
|
||||
@JvmField
|
||||
val TOXIC_ORB = create("toxic_orb", OrbBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion()))
|
||||
@JvmField
|
||||
val LIFE_ORB = create("life_orb", OrbBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion().lightLevel{7}))
|
||||
@JvmField
|
||||
val LIGHT_BALL = create("light_ball", OrbBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion().lightLevel{13}))
|
||||
@JvmField
|
||||
val SMOKE_BALL = create("smoke_ball", OrbBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion()))
|
||||
|
||||
@JvmField
|
||||
val KINGS_ROCK = create("kings_rock", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.CENTERED_6x))
|
||||
|
||||
@JvmField
|
||||
val GALARICA_CUFF = create("galarica_cuff", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.AZALEA_LEAVES).mapColor(MapColor.NONE).noCollission().noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.FLATTENED_10x4))
|
||||
@JvmField
|
||||
val UNREMARKABLE_TEACUP = create("unremarkable_teacup", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.DECORATED_POT).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.TEACUP))
|
||||
@JvmField
|
||||
val MASTERPIECE_TEACUP = create("masterpiece_teacup", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.DECORATED_POT).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.TEACUP))
|
||||
@JvmField
|
||||
val CHIPPED_POT = create("chipped_pot", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.DECORATED_POT).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.TEAPOT))
|
||||
@JvmField
|
||||
val CRACKED_POT = create("cracked_pot", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.DECORATED_POT).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.TEAPOT))
|
||||
|
||||
@JvmField
|
||||
val SACHET = create("sachet", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOL).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.POUCH))
|
||||
@JvmField
|
||||
val METAL_POWDER = create("metal_powder", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOL).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.POUCH))
|
||||
@JvmField
|
||||
val QUICK_POWDER = create("quick_powder", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOL).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.POUCH))
|
||||
@JvmField
|
||||
val BRIGHT_POWDER = create("bright_powder", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOL).mapColor(MapColor.NONE).noOcclusion().lightLevel{3}, DecorativeItemBlock.DecorativeItemBlockType.POUCH))
|
||||
|
||||
@JvmField
|
||||
val NEVER_MELT_ICE = create("never_melt_ice", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion().friction(0.989F), DecorativeItemBlock.DecorativeItemBlockType.NEVERMELT))
|
||||
@JvmField
|
||||
val SCOPE_LENS = create("scope_lens", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.COPPER).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.SCOPE))
|
||||
@JvmField
|
||||
val WIDE_LENS = create("wide_lens", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.COPPER).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.WIDE))
|
||||
@JvmField
|
||||
val ZOOM_LENS = create("zoom_lens", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.COPPER).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.ZOOM))
|
||||
|
||||
@JvmField
|
||||
val ICY_ROCK = create("icy_rock", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.DEEPSLATE).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.FLATTENED_8x4))
|
||||
@JvmField
|
||||
val HEAT_ROCK = create("heat_rock", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.DEEPSLATE).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.FLATTENED_8x4))
|
||||
@JvmField
|
||||
val SMOOTH_ROCK = create("smooth_rock", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.DEEPSLATE).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.FLATTENED_8x4))
|
||||
@JvmField
|
||||
val DAMP_ROCK = create("damp_rock", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.DEEPSLATE).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.FLATTENED_8x6))
|
||||
@JvmField
|
||||
val DESTINY_KNOT = create("destiny_knot", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOL).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.KNOT))
|
||||
@JvmField
|
||||
val LUMINOUS_MOSS = create("luminous_moss", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.MOSS).mapColor(MapColor.NONE).noOcclusion().lightLevel{5}, DecorativeItemBlock.DecorativeItemBlockType.CENTERED_8x))
|
||||
|
||||
@JvmField
|
||||
val METRONOME = create("metronome", ActivatableDecorationBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.NONE).pushReaction(PushReaction.DESTROY).noOcclusion(), ActivatableDecorationBlock.ActivatableDecorationBlockType.METRONOME))
|
||||
@JvmField
|
||||
val EJECT_BUTTON = create("eject_button", EjectButtonBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.NONE).pushReaction(PushReaction.DESTROY).noOcclusion().strength(0.125f), 40))
|
||||
|
||||
@JvmField
|
||||
val LOADED_DICE = create("loaded_dice", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.DICE))
|
||||
@JvmField
|
||||
val IRON_BALL = create("iron_ball", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.IRON_BALL))
|
||||
@JvmField
|
||||
val METAL_COAT = create("metal_coat", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.METAL_COAT))
|
||||
@JvmField
|
||||
val UPGRADE = create("upgrade", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.UPGRADE))
|
||||
@JvmField
|
||||
val DUBIOUS_DISC = create("dubious_disc", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.UPGRADE))
|
||||
|
||||
@JvmField
|
||||
val THROAT_SPRAY = create("throat_spray", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.THROAT_SPRAY))
|
||||
|
||||
@JvmField
|
||||
val FULL_HEAL = create("full_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
|
||||
@JvmField
|
||||
@@ -670,6 +754,23 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
@JvmField
|
||||
val X_SPEED = create("x_${Stats.SPEED.identifier.path}", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.BATTLE_ITEM))
|
||||
|
||||
@JvmField
|
||||
val HP_UP = create("hp_up", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
@JvmField
|
||||
val PROTEIN = create("protein", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
@JvmField
|
||||
val IRON = create("iron", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
@JvmField
|
||||
val CARBOS = create("carbos", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
@JvmField
|
||||
val CALCIUM = create("calcium", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
@JvmField
|
||||
val ZINC = create("zinc", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
@JvmField
|
||||
val PP_UP = create("pp_up", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
@JvmField
|
||||
val PP_MAX = create("pp_max", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
|
||||
@JvmField
|
||||
val MONITOR = create("monitor", MonitorBlock(BlockBehaviour.Properties.of().mapColor(MapColor.METAL).sound(SoundType.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().strength(5.0F, 6.0F).lightLevel { if (it.getValue(MonitorBlock.SCREEN) != MonitorBlock.MonitorScreen.OFF) 13 else 0 }))
|
||||
@JvmField
|
||||
@@ -685,6 +786,7 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
@JvmField
|
||||
val PC = create("pc", PCBlock(BlockBehaviour.Properties.of().mapColor(MapColor.METAL).sound(SoundType.METAL).pushReaction(PushReaction.BLOCK).strength(2F).noOcclusion().lightLevel { if ((it.getValue(PCBlock.ON) as Boolean) && (it.getValue(PCBlock.PART) == PCBlock.PCPart.TOP)) 13 else 0 }))
|
||||
|
||||
@JvmField
|
||||
val TM_MACHINE = create(
|
||||
"tm_machine",
|
||||
TMMachineBlock(
|
||||
@@ -713,7 +815,7 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
|
||||
@JvmField
|
||||
val PASTURE = create("pasture", PastureBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BROWN).sound(SoundType.WOOD).strength(2F).noOcclusion().pushReaction(PushReaction.BLOCK).lightLevel { if ((it.getValue(PastureBlock.ON) as Boolean) && (it.getValue(PastureBlock.PART) == PastureBlock.PasturePart.TOP)) 13 else 0 }))
|
||||
|
||||
@JvmField
|
||||
val RED_MINT = create("red_mint", MintBlock(MintType.RED, BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED).noCollission().randomTicks().instabreak().sound(CobblemonSounds.MINT_SOUNDS).pushReaction(PushReaction.DESTROY)))
|
||||
@JvmField
|
||||
val BLUE_MINT = create("blue_mint", MintBlock(MintType.BLUE, BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLUE).noCollission().randomTicks().instabreak().sound(CobblemonSounds.MINT_SOUNDS).pushReaction(PushReaction.DESTROY)))
|
||||
|
||||
@@ -472,9 +472,9 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
// Evolution items
|
||||
@JvmField val LINK_CABLE = create("link_cable", LinkCableItem())
|
||||
@JvmField val DRAGON_SCALE = noSettingsItem("dragon_scale")
|
||||
@JvmField val METAL_COAT = noSettingsItem("metal_coat")
|
||||
@JvmField val UPGRADE = noSettingsItem("upgrade")
|
||||
@JvmField val DUBIOUS_DISC = noSettingsItem("dubious_disc")
|
||||
@JvmField val METAL_COAT = itemNameBlockItem("metal_coat", CobblemonBlocks.METAL_COAT)
|
||||
@JvmField val UPGRADE = itemNameBlockItem("upgrade", CobblemonBlocks.UPGRADE)
|
||||
@JvmField val DUBIOUS_DISC = itemNameBlockItem("dubious_disc", CobblemonBlocks.DUBIOUS_DISC)
|
||||
@JvmField val DEEP_SEA_SCALE = noSettingsItem("deep_sea_scale")
|
||||
@JvmField val DEEP_SEA_TOOTH = noSettingsItem("deep_sea_tooth")
|
||||
@JvmField val ELECTIRIZER = noSettingsItem("electirizer")
|
||||
@@ -483,7 +483,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField val PROTECTOR = noSettingsItem("protector")
|
||||
@JvmField val REAPER_CLOTH = noSettingsItem("reaper_cloth")
|
||||
@JvmField val PRISM_SCALE = noSettingsItem("prism_scale")
|
||||
@JvmField val SACHET = noSettingsItem("sachet")
|
||||
@JvmField val SACHET = itemNameBlockItem("sachet", CobblemonBlocks.SACHET)
|
||||
@JvmField val WHIPPED_DREAM = create("whipped_dream", foodItem(8, 0.3f))
|
||||
@JvmField val STRAWBERRY_SWEET = create("strawberry_sweet", foodItem(6, 0.125f))
|
||||
@JvmField val LOVE_SWEET = create("love_sweet", foodItem(6, 0.125f))
|
||||
@@ -492,22 +492,20 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField val FLOWER_SWEET = create("flower_sweet", foodItem(6, 0.125f))
|
||||
@JvmField val STAR_SWEET = create("star_sweet", foodItem(6, 0.125f))
|
||||
@JvmField val RIBBON_SWEET = create("ribbon_sweet", foodItem(6, 0.125f))
|
||||
@JvmField val CHIPPED_POT = noSettingsItem("chipped_pot")
|
||||
@JvmField val CRACKED_POT = noSettingsItem("cracked_pot")
|
||||
@JvmField val MASTERPIECE_TEACUP = noSettingsItem("masterpiece_teacup")
|
||||
@JvmField val UNREMARKABLE_TEACUP = noSettingsItem("unremarkable_teacup")
|
||||
@JvmField val CHIPPED_POT = itemNameBlockItem("chipped_pot", CobblemonBlocks.CHIPPED_POT)
|
||||
@JvmField val CRACKED_POT = itemNameBlockItem("cracked_pot", CobblemonBlocks.CRACKED_POT)
|
||||
@JvmField val MASTERPIECE_TEACUP = itemNameBlockItem("masterpiece_teacup", CobblemonBlocks.MASTERPIECE_TEACUP)
|
||||
@JvmField val UNREMARKABLE_TEACUP = itemNameBlockItem("unremarkable_teacup", CobblemonBlocks.UNREMARKABLE_TEACUP)
|
||||
@JvmField val SWEET_APPLE = compostableItem("sweet_apple", foodItem(4, 0.3f), 0.65f)
|
||||
@JvmField val TART_APPLE = compostableItem("tart_apple", foodItem(4, 0.3f), 0.65f)
|
||||
@JvmField val SYRUPY_APPLE = compostableItem("syrupy_apple", foodItem(4, 0.3f), 0.65f)
|
||||
@JvmField val GALARICA_CUFF = noSettingsItem("galarica_cuff")
|
||||
@JvmField val GALARICA_WREATH = noSettingsItem("galarica_wreath")
|
||||
@JvmField val GALARICA_CUFF = itemNameBlockItem("galarica_cuff", CobblemonBlocks.GALARICA_CUFF)
|
||||
@JvmField val BLACK_AUGURITE = noSettingsItem("black_augurite")
|
||||
@JvmField val PEAT_BLOCK = noSettingsItem("peat_block")
|
||||
@JvmField val RAZOR_CLAW = noSettingsItem("razor_claw")
|
||||
@JvmField val RAZOR_FANG = noSettingsItem("razor_fang")
|
||||
@JvmField val AUSPICIOUS_ARMOR = heldItem("auspicious_armor")
|
||||
@JvmField val MALICIOUS_ARMOR = heldItem("malicious_armor")
|
||||
@JvmField val SHELL_HELMET = heldItem("shell_helmet")
|
||||
@JvmField val METAL_ALLOY = noSettingsItem("metal_alloy")
|
||||
@JvmField val SCROLL_OF_DARKNESS = noSettingsItem("scroll_of_darkness")
|
||||
@JvmField val SCROLL_OF_WATERS = noSettingsItem("scroll_of_waters")
|
||||
@@ -651,17 +649,17 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val EXPERIENCE_CANDY_XL = candyItem("exp_candy_xl") { _, _ -> CandyItem.DEFAULT_XL_CANDY_YIELD }
|
||||
@JvmField
|
||||
val CALCIUM = create("calcium", VitaminItem(Stats.SPECIAL_ATTACK))
|
||||
val CALCIUM = create("calcium", VitaminItem(Stats.SPECIAL_ATTACK, CobblemonBlocks.CALCIUM))
|
||||
@JvmField
|
||||
val CARBOS = create("carbos", VitaminItem(Stats.SPEED))
|
||||
val CARBOS = create("carbos", VitaminItem(Stats.SPEED, CobblemonBlocks.CARBOS))
|
||||
@JvmField
|
||||
val HP_UP = create("hp_up", VitaminItem(Stats.HP))
|
||||
val HP_UP = create("hp_up", VitaminItem(Stats.HP, CobblemonBlocks.HP_UP))
|
||||
@JvmField
|
||||
val IRON = create("iron", VitaminItem(Stats.DEFENCE))
|
||||
val IRON = create("iron", VitaminItem(Stats.DEFENCE, CobblemonBlocks.IRON))
|
||||
@JvmField
|
||||
val PROTEIN = create("protein", VitaminItem(Stats.ATTACK))
|
||||
val PROTEIN = create("protein", VitaminItem(Stats.ATTACK, CobblemonBlocks.PROTEIN))
|
||||
@JvmField
|
||||
val ZINC = create("zinc", VitaminItem(Stats.SPECIAL_DEFENCE))
|
||||
val ZINC = create("zinc", VitaminItem(Stats.SPECIAL_DEFENCE, CobblemonBlocks.ZINC))
|
||||
@JvmField
|
||||
val HEALTH_MOCHI = create("health_mochi", MochiItem(Stats.HP))
|
||||
@JvmField
|
||||
@@ -743,9 +741,9 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val MAX_REVIVE = create("max_revive", ReviveItem(max = true))
|
||||
@JvmField
|
||||
val PP_UP = create("pp_up", PPUpItem(1))
|
||||
val PP_UP = create("pp_up", PPUpItem(1, CobblemonBlocks.PP_UP))
|
||||
@JvmField
|
||||
val PP_MAX = create("pp_max", PPUpItem(3))
|
||||
val PP_MAX = create("pp_max", PPUpItem(3, CobblemonBlocks.PP_MAX))
|
||||
|
||||
@JvmField
|
||||
val RED_MINT_SEEDS = mintSeed("red", MintType.RED.getCropBlock())
|
||||
@@ -922,11 +920,18 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField val CHOICE_SPECS = wearableItem("choice_specs")
|
||||
@JvmField val EXP_SHARE = wearableItem("exp_share")
|
||||
@JvmField val FOCUS_BAND = wearableItem("focus_band")
|
||||
@JvmField val KINGS_ROCK = wearableItem("kings_rock")
|
||||
@JvmField val KINGS_ROCK = wearableBlockItem("kings_rock", CobblemonBlocks.KINGS_ROCK)
|
||||
@JvmField val NEVER_MELT_ICE = wearableBlockItem("never_melt_ice", CobblemonBlocks.NEVER_MELT_ICE)
|
||||
@JvmField val MUSCLE_BAND = wearableItem("muscle_band")
|
||||
@JvmField val ROCKY_HELMET = wearableItem("rocky_helmet")
|
||||
@JvmField val SAFETY_GOGGLES = wearableItem("safety_goggles")
|
||||
@JvmField val WISE_GLASSES = wearableItem("wise_glasses")
|
||||
@JvmField val SHARP_BEAK = wearableItem("sharp_beak")
|
||||
@JvmField val COVERT_CLOAK = wearableItem("covert_cloak")
|
||||
@JvmField val SHELL_HELMET = wearableItem("shell_helmet")
|
||||
@JvmField val GALARICA_WREATH = wearableBlockItem("galarica_wreath", CobblemonBlocks.GALARICA_WREATH)
|
||||
@JvmField val CLEANSE_TAG = wearableBlockItem("cleanse_tag", CobblemonBlocks.CLEANSE_TAG)
|
||||
@JvmField val SPELL_TAG = wearableBlockItem("spell_tag", CobblemonBlocks.SPELL_TAG)
|
||||
|
||||
// Held Items
|
||||
@JvmField
|
||||
@@ -954,17 +959,13 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val CHOICE_SCARF = heldItem("choice_scarf")
|
||||
@JvmField
|
||||
val CLEANSE_TAG = itemNameBlockItem("cleanse_tag", CobblemonBlocks.CLEANSE_TAG)
|
||||
@JvmField
|
||||
val CLEAR_AMULET = heldItem("clear_amulet")
|
||||
@JvmField
|
||||
val COVERT_CLOAK = heldItem("covert_cloak")
|
||||
@JvmField
|
||||
val DESTINY_KNOT = heldItem("destiny_knot")
|
||||
val DESTINY_KNOT = itemNameBlockItem("destiny_knot", CobblemonBlocks.DESTINY_KNOT)
|
||||
@JvmField
|
||||
val DRAGON_FANG = heldItem("dragon_fang")
|
||||
@JvmField
|
||||
val EJECT_BUTTON = heldItem("eject_button")
|
||||
val EJECT_BUTTON = itemNameBlockItem("eject_button", CobblemonBlocks.EJECT_BUTTON)
|
||||
@JvmField
|
||||
val EJECT_PACK = heldItem("eject_pack")
|
||||
@JvmField
|
||||
@@ -978,7 +979,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val FAIRY_FEATHER = heldItem("fairy_feather")
|
||||
@JvmField
|
||||
val FLAME_ORB = heldItem("flame_orb")
|
||||
val FLAME_ORB = itemNameBlockItem("flame_orb", CobblemonBlocks.FLAME_ORB)
|
||||
@JvmField
|
||||
val FLOAT_STONE = heldItem("float_stone")
|
||||
@JvmField
|
||||
@@ -992,34 +993,32 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val HEAVY_DUTY_BOOTS = heldItem("heavy_duty_boots")
|
||||
@JvmField
|
||||
val IRON_BALL = heldItem("iron_ball")
|
||||
val IRON_BALL = itemNameBlockItem("iron_ball", CobblemonBlocks.IRON_BALL)
|
||||
@JvmField
|
||||
val LAGGING_TAIL = heldItem("lagging_tail")
|
||||
@JvmField
|
||||
val LEFTOVERS = compostableHeldItem("leftovers", null, 0.50f)
|
||||
@JvmField
|
||||
val LIFE_ORB = heldItem("life_orb")
|
||||
val LIFE_ORB = itemNameBlockItem("life_orb", CobblemonBlocks.LIFE_ORB)
|
||||
@JvmField
|
||||
val LIGHT_BALL = heldItem("light_ball")
|
||||
val LIGHT_BALL = itemNameBlockItem("light_ball", CobblemonBlocks.LIGHT_BALL)
|
||||
@JvmField
|
||||
val LIGHT_CLAY = heldItem("light_clay")
|
||||
@JvmField
|
||||
val LOADED_DICE = heldItem("loaded_dice")
|
||||
val LOADED_DICE = itemNameBlockItem("loaded_dice", CobblemonBlocks.LOADED_DICE)
|
||||
@JvmField
|
||||
val LUCKY_EGG = heldItem("lucky_egg")
|
||||
@JvmField
|
||||
val LUMINOUS_MOSS = heldItem("luminous_moss")
|
||||
val LUMINOUS_MOSS = itemNameBlockItem("luminous_moss", CobblemonBlocks.LUMINOUS_MOSS)
|
||||
@JvmField
|
||||
val MAGNET = heldItem("magnet")
|
||||
val MAGNET = itemNameBlockItem("magnet", CobblemonBlocks.MAGNET)
|
||||
@JvmField
|
||||
val METRONOME = heldItem("metronome")
|
||||
val METRONOME = itemNameBlockItem("metronome", CobblemonBlocks.METRONOME)
|
||||
@JvmField
|
||||
val MIRACLE_SEED = heldItem("miracle_seed")
|
||||
@JvmField
|
||||
val MYSTIC_WATER = heldItem("mystic_water")
|
||||
@JvmField
|
||||
val NEVER_MELT_ICE = heldItem("never_melt_ice")
|
||||
@JvmField
|
||||
val POISON_BARB = heldItem("poison_barb")
|
||||
@JvmField
|
||||
val POWER_ANKLET = heldItem("power_anklet")
|
||||
@@ -1044,13 +1043,11 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val RED_CARD = heldItem("red_card")
|
||||
@JvmField
|
||||
val RING_TARGET = heldItem("ring_target")
|
||||
val RING_TARGET = itemNameBlockItem("ring_target", CobblemonBlocks.RING_TARGET)
|
||||
@JvmField
|
||||
val ROOM_SERVICE = heldItem("room_service")
|
||||
@JvmField
|
||||
val SCOPE_LENS = heldItem("scope_lens")
|
||||
@JvmField
|
||||
val SHARP_BEAK = heldItem("sharp_beak")
|
||||
val SCOPE_LENS = itemNameBlockItem("scope_lens", CobblemonBlocks.SCOPE_LENS)
|
||||
@JvmField
|
||||
val SHED_SHELL = heldItem("shed_shell")
|
||||
@JvmField
|
||||
@@ -1062,9 +1059,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val SOFT_SAND = heldItem("soft_sand")
|
||||
@JvmField
|
||||
val SPELL_TAG = itemNameBlockItem("spell_tag", CobblemonBlocks.SPELL_TAG)
|
||||
@JvmField
|
||||
val SMOKE_BALL = heldItem("smoke_ball")
|
||||
val SMOKE_BALL = itemNameBlockItem("smoke_ball", CobblemonBlocks.SMOKE_BALL)
|
||||
@JvmField
|
||||
val SOOTHE_BELL = heldItem("soothe_bell")
|
||||
@JvmField
|
||||
@@ -1072,9 +1067,9 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val TERRAIN_EXTENDER = heldItem("terrain_extender")
|
||||
@JvmField
|
||||
val THROAT_SPRAY = heldItem("throat_spray")
|
||||
val THROAT_SPRAY = itemNameBlockItem("throat_spray", CobblemonBlocks.THROAT_SPRAY)
|
||||
@JvmField
|
||||
val TOXIC_ORB = heldItem("toxic_orb")
|
||||
val TOXIC_ORB = itemNameBlockItem("toxic_orb", CobblemonBlocks.TOXIC_ORB)
|
||||
@JvmField
|
||||
val TWISTED_SPOON = heldItem("twisted_spoon")
|
||||
@JvmField
|
||||
@@ -1082,9 +1077,9 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val WEAKNESS_POLICY = itemNameBlockItem("weakness_policy", CobblemonBlocks.WEAKNESS_POLICY)
|
||||
@JvmField
|
||||
val WIDE_LENS = heldItem("wide_lens")
|
||||
val WIDE_LENS = itemNameBlockItem("wide_lens", CobblemonBlocks.WIDE_LENS)
|
||||
@JvmField
|
||||
val ZOOM_LENS = heldItem("zoom_lens")
|
||||
val ZOOM_LENS = itemNameBlockItem("zoom_lens", CobblemonBlocks.ZOOM_LENS)
|
||||
@JvmField
|
||||
val MENTAL_HERB = compostableHeldItem("mental_herb", null, 0.85F)
|
||||
@JvmField
|
||||
@@ -1096,19 +1091,19 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val WHITE_HERB = compostableHeldItem("white_herb", null, 0.85F)
|
||||
@JvmField
|
||||
val BRIGHT_POWDER = heldItem("bright_powder")
|
||||
val BRIGHT_POWDER = itemNameBlockItem("bright_powder", CobblemonBlocks.BRIGHT_POWDER)
|
||||
@JvmField
|
||||
val METAL_POWDER = heldItem("metal_powder")
|
||||
val METAL_POWDER = itemNameBlockItem("metal_powder", CobblemonBlocks.METAL_POWDER)
|
||||
@JvmField
|
||||
val QUICK_POWDER = heldItem("quick_powder")
|
||||
val QUICK_POWDER = itemNameBlockItem("quick_powder", CobblemonBlocks.QUICK_POWDER)
|
||||
@JvmField
|
||||
val DAMP_ROCK = heldItem("damp_rock")
|
||||
val DAMP_ROCK = itemNameBlockItem("damp_rock", CobblemonBlocks.DAMP_ROCK)
|
||||
@JvmField
|
||||
val HEAT_ROCK = heldItem("heat_rock")
|
||||
val HEAT_ROCK = itemNameBlockItem("heat_rock", CobblemonBlocks.HEAT_ROCK)
|
||||
@JvmField
|
||||
val SMOOTH_ROCK = heldItem("smooth_rock")
|
||||
val SMOOTH_ROCK = itemNameBlockItem("smooth_rock", CobblemonBlocks.SMOOTH_ROCK)
|
||||
@JvmField
|
||||
val ICY_ROCK = heldItem("icy_rock")
|
||||
val ICY_ROCK = itemNameBlockItem("icy_rock", CobblemonBlocks.ICY_ROCK)
|
||||
|
||||
// Mulch
|
||||
@JvmField
|
||||
@@ -1599,7 +1594,16 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
|
||||
private fun wearableItem(name: String, heldItemRemappedName: String? = null): CobblemonItem = create(
|
||||
name,
|
||||
WearableItem(name).also {
|
||||
WearableHatItem(name).also {
|
||||
wearables.add(it)
|
||||
if (heldItemRemappedName != null) {
|
||||
CobblemonHeldItemManager.registerRemap(it, heldItemRemappedName)
|
||||
}
|
||||
}
|
||||
)
|
||||
private fun wearableBlockItem(name: String, block: Block, heldItemRemappedName: String? = null): WearableBlockItem = create(
|
||||
name,
|
||||
WearableBlockItem(name, block).also {
|
||||
wearables.add(it)
|
||||
if (heldItemRemappedName != null) {
|
||||
CobblemonHeldItemManager.registerRemap(it, heldItemRemappedName)
|
||||
|
||||
@@ -8,34 +8,6 @@
|
||||
|
||||
package com.cobblemon.mod.common
|
||||
|
||||
import com.cobblemon.mod.common.net.serverhandling.battle.TeamPreviewSelectPokemonHandler
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.server.battle.TeamPreviewSelectPokemonPacket
|
||||
|
||||
import com.cobblemon.mod.common.client.net.battle.CloseTeamPreviewHandler
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.CloseTeamPreviewPacket
|
||||
|
||||
import com.cobblemon.mod.common.client.net.battle.TeamPreviewHandler
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.TeamPreviewPacket
|
||||
|
||||
import com.cobblemon.mod.common.client.net.battle.BattleTimerHandler
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleTimerPacket
|
||||
|
||||
import com.cobblemon.mod.common.client.net.battle.BattleInformationHandler
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleInformationPacket
|
||||
|
||||
import com.cobblemon.mod.common.client.net.battle.BattleActorTeamHandler
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleActorTeamPacket
|
||||
|
||||
import com.cobblemon.mod.common.client.net.battle.BattleActorInformationHandler
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleActorInformationPacket
|
||||
|
||||
import com.cobblemon.mod.common.api.net.NetworkPacket
|
||||
import com.cobblemon.mod.common.client.net.OpenBehaviourEditorHandler
|
||||
import com.cobblemon.mod.common.client.net.PlayerInteractOptionsHandler
|
||||
@@ -414,12 +386,6 @@ object CobblemonNetwork {
|
||||
// Battle packets
|
||||
list.add(PacketRegisterInfo(BattleEndPacket.ID, BattleEndPacket::decode, BattleEndHandler))
|
||||
list.add(PacketRegisterInfo(BattleInitializePacket.ID, BattleInitializePacket::decode, BattleInitializeHandler))
|
||||
list.add(PacketRegisterInfo(BattleActorInformationPacket.ID, BattleActorInformationPacket::decode, BattleActorInformationHandler))
|
||||
list.add(PacketRegisterInfo(BattleActorTeamPacket.ID, BattleActorTeamPacket::decode, BattleActorTeamHandler))
|
||||
list.add(PacketRegisterInfo(BattleInformationPacket.ID, BattleInformationPacket::decode, BattleInformationHandler))
|
||||
list.add(PacketRegisterInfo(BattleTimerPacket.ID, BattleTimerPacket::decode, BattleTimerHandler))
|
||||
list.add(PacketRegisterInfo(TeamPreviewPacket.ID, TeamPreviewPacket::decode, TeamPreviewHandler))
|
||||
list.add(PacketRegisterInfo(CloseTeamPreviewPacket.ID, CloseTeamPreviewPacket::decode, CloseTeamPreviewHandler))
|
||||
list.add(PacketRegisterInfo(BattleQueueRequestPacket.ID, BattleQueueRequestPacket::decode, BattleQueueRequestHandler))
|
||||
list.add(PacketRegisterInfo(BattleFaintPacket.ID, BattleFaintPacket::decode, BattleFaintHandler))
|
||||
list.add(PacketRegisterInfo(BattleMakeChoicePacket.ID, BattleMakeChoicePacket::decode, BattleMakeChoiceHandler))
|
||||
@@ -607,7 +573,6 @@ object CobblemonNetwork {
|
||||
|
||||
// Battle packets
|
||||
list.add(PacketRegisterInfo(BattleSelectActionsPacket.ID, BattleSelectActionsPacket::decode, BattleSelectActionsHandler))
|
||||
list.add(PacketRegisterInfo(TeamPreviewSelectPokemonPacket.ID, TeamPreviewSelectPokemonPacket::decode, TeamPreviewSelectPokemonHandler))
|
||||
list.add(PacketRegisterInfo(SpectateBattlePacket.ID, SpectateBattlePacket::decode, SpectateBattleHandler))
|
||||
list.add(PacketRegisterInfo(RemoveSpectatorPacket.ID, RemoveSpectatorPacket::decode, RemoveSpectatorHandler))
|
||||
|
||||
|
||||
@@ -8,16 +8,6 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.battles.model
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.FieldEffect
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleInformationPacket
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleInformationDTO
|
||||
|
||||
import com.cobblemon.mod.common.api.battles.interpreter.BattleContext
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonNetwork.sendPacket
|
||||
|
||||
import com.bedrockk.molang.runtime.MoLangRuntime
|
||||
import com.bedrockk.molang.runtime.struct.QueryStruct
|
||||
import com.bedrockk.molang.runtime.value.DoubleValue
|
||||
@@ -257,38 +247,6 @@ open class PokemonBattle(
|
||||
}
|
||||
}
|
||||
this.turn = newTurnNumber
|
||||
notifyAllOfUpdates()
|
||||
}
|
||||
|
||||
fun notifyAllOfUpdates() {
|
||||
val uuids = this.actors.flatMap { it.getPlayerUUIDs() } + this.spectators
|
||||
notifyOfUpdates(uuids)
|
||||
}
|
||||
|
||||
fun notifyOfUpdates(uuids: List<UUID>) {
|
||||
val weather = this.contextManager.get(BattleContext.Type.WEATHER)?.firstOrNull()
|
||||
val terrain = this.contextManager.get(BattleContext.Type.TERRAIN)?.firstOrNull()
|
||||
val room = this.contextManager.get(BattleContext.Type.ROOM)?.firstOrNull()
|
||||
val side1SidedEffects = getSidedFieldEffects(side1)
|
||||
val side2SidedEffects = getSidedFieldEffects(side2)
|
||||
val updatePacket = BattleInformationPacket(this.battleId, BattleInformationDTO(
|
||||
turn = turn,
|
||||
weather = weather?.let { FieldEffect(it.id, it.turn, it.origin?.entity?.id) },
|
||||
terrain = terrain?.let { FieldEffect(it.id, it.turn, it.origin?.entity?.id) },
|
||||
room = room?.let { FieldEffect(it.id, it.turn, it.origin?.entity?.id) },
|
||||
side1SidedEffects = side1SidedEffects,
|
||||
side2SidedEffects = side2SidedEffects,
|
||||
))
|
||||
uuids.mapNotNull { it.getPlayer() }.forEach {
|
||||
it.sendPacket(updatePacket)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getSidedFieldEffects(side: BattleSide): List<FieldEffect> {
|
||||
val hazards = side.contextManager.get(BattleContext.Type.HAZARD)?.map { FieldEffect(it.id, it.turn, it.origin?.entity?.id) } ?: emptyList()
|
||||
val screens = side.contextManager.get(BattleContext.Type.SCREEN)?.map { FieldEffect(it.id, it.turn, it.origin?.entity?.id) } ?: emptyList()
|
||||
val tailwind = side.contextManager.get(BattleContext.Type.TAILWIND)?.firstOrNull()?.let { FieldEffect(it.id, it.turn, it.origin?.entity?.id) }
|
||||
return hazards + screens + listOfNotNull(tailwind)
|
||||
}
|
||||
|
||||
fun end() {
|
||||
@@ -496,7 +454,6 @@ open class PokemonBattle(
|
||||
}
|
||||
|
||||
fun tick() {
|
||||
if (!ended) actors.filterIsInstance<PlayerBattleActor>().forEach { it.timer?.tick() }
|
||||
try {
|
||||
while (dispatchResult.canProceed()) {
|
||||
val dispatch = dispatches.poll() ?: break
|
||||
|
||||
-18
@@ -8,10 +8,6 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.battles.model.actor
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleTimerPacket
|
||||
|
||||
import com.cobblemon.mod.common.battles.actor.PlayerBattleActor
|
||||
|
||||
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMoLangValue
|
||||
import com.cobblemon.mod.common.api.net.NetworkPacket
|
||||
@@ -52,20 +48,6 @@ abstract class BattleActor(
|
||||
var responses = mutableListOf<ShowdownActionResponse>()
|
||||
val expectingPassActions = mutableListOf<ShowdownActionResponse>()
|
||||
var mustChoose = false
|
||||
set(value) {
|
||||
if (field == value) return
|
||||
field = value
|
||||
if (this is PlayerBattleActor) {
|
||||
timer?.let {
|
||||
if (value) {
|
||||
it.startSelection()
|
||||
sendUpdate(BattleTimerPacket(it.mustChooseBy()))
|
||||
} else {
|
||||
it.endSelection()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var itemsUsed = mutableListOf<BagItem>()
|
||||
/** For when battles start, it's the number of Pokémon that are still in the process of being sent out (animation wise) */
|
||||
|
||||
+5
@@ -55,6 +55,11 @@ object GeneralMoLangFunctions {
|
||||
struct.map.remove(variable)
|
||||
DoubleValue.ONE
|
||||
}
|
||||
functions["delete_variables"] = { params ->
|
||||
val struct = params.get<VariableStruct>(0)
|
||||
struct.map.clear()
|
||||
DoubleValue.ONE
|
||||
}
|
||||
functions["get_variable"] = { params ->
|
||||
val struct = params.get<VariableStruct>(0)
|
||||
val variable = params.getString(1)
|
||||
|
||||
+22
@@ -16,6 +16,7 @@ import com.cobblemon.mod.common.api.molang.ObjectValue
|
||||
import com.cobblemon.mod.common.api.pokedex.AbstractPokedexManager
|
||||
import com.cobblemon.mod.common.api.pokedex.CaughtCount
|
||||
import com.cobblemon.mod.common.api.pokedex.CaughtPercent
|
||||
import com.cobblemon.mod.common.api.pokedex.Dexes
|
||||
import com.cobblemon.mod.common.api.pokedex.PokedexEntryProgress
|
||||
import com.cobblemon.mod.common.api.pokedex.PokedexManager
|
||||
import com.cobblemon.mod.common.api.pokedex.SeenCount
|
||||
@@ -74,6 +75,27 @@ object PokedexMoLangFunctions : AbstractMoLangFunctionHolder<AbstractPokedexMana
|
||||
functions["caught_percent"] = { DoubleValue(pokedex.getGlobalCalculatedValue(CaughtPercent)) }
|
||||
functions["seen_percent"] = { DoubleValue(pokedex.getGlobalCalculatedValue(SeenPercent)) }
|
||||
|
||||
functions["dex_caught_count"] = { params ->
|
||||
val dexId = params.getString(0).asIdentifierDefaultingNamespace()
|
||||
if (Dexes.dexEntryMap.containsKey(dexId)) DoubleValue(pokedex.getDexCalculatedValue(dexId, CaughtCount))
|
||||
else DoubleValue.ZERO
|
||||
}
|
||||
functions["dex_seen_count"] = { params ->
|
||||
val dexId = params.getString(0).asIdentifierDefaultingNamespace()
|
||||
if (Dexes.dexEntryMap.containsKey(dexId)) DoubleValue(pokedex.getDexCalculatedValue(dexId, SeenCount))
|
||||
else DoubleValue.ZERO
|
||||
}
|
||||
functions["dex_caught_percent"] = { params ->
|
||||
val dexId = params.getString(0).asIdentifierDefaultingNamespace()
|
||||
if (Dexes.dexEntryMap.containsKey(dexId)) DoubleValue(pokedex.getDexCalculatedValue(dexId, CaughtPercent).toDouble())
|
||||
else DoubleValue.ZERO
|
||||
}
|
||||
functions["dex_seen_percent"] = { params ->
|
||||
val dexId = params.getString(0).asIdentifierDefaultingNamespace()
|
||||
if (Dexes.dexEntryMap.containsKey(dexId)) DoubleValue(pokedex.getDexCalculatedValue(dexId, SeenPercent).toDouble())
|
||||
else DoubleValue.ZERO
|
||||
}
|
||||
|
||||
when (pokedex) {
|
||||
is PokedexManager -> {
|
||||
functions["player_id"] = { StringValue(pokedex.uuid.toString()) }
|
||||
|
||||
+23
-7
@@ -8,8 +8,10 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.orientation
|
||||
|
||||
import com.cobblemon.mod.common.util.math.QuatSpring
|
||||
import com.cobblemon.mod.common.util.math.geometry.toDegrees
|
||||
import com.cobblemon.mod.common.util.math.geometry.toRadians
|
||||
import com.cobblemon.mod.common.util.math.simpleSpringDamperQuat
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.util.Mth
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
@@ -26,6 +28,8 @@ open class OrientationController(val entity: LivingEntity) {
|
||||
val FORWARDS: Vector3f = Vector3f(0.0f, 0.0f, -1.0f)
|
||||
val UP: Vector3f = Vector3f(0.0f, 1.0f, 0.0f)
|
||||
val LEFT: Vector3f = Vector3f(-1.0f, 0.0f, 0.0f)
|
||||
private const val TICK_DT = 1f / 20f // Minecraft server tick rate
|
||||
private const val RENDER_SMOOTH_HALFLIFE = 0.1f // seconds to close ~half the gap
|
||||
}
|
||||
|
||||
open var active: Boolean = false
|
||||
@@ -33,6 +37,8 @@ open class OrientationController(val entity: LivingEntity) {
|
||||
var orientation: Matrix3f? = null
|
||||
private set
|
||||
|
||||
private val renderSpring = QuatSpring()
|
||||
|
||||
private var renderOrientationO: Matrix3f? = null
|
||||
private var renderOrientation: Matrix3f? = null
|
||||
|
||||
@@ -54,6 +60,8 @@ open class OrientationController(val entity: LivingEntity) {
|
||||
orientation = null
|
||||
renderOrientationO = null
|
||||
renderOrientation = null
|
||||
renderSpring.quat.identity()
|
||||
renderSpring.angVel.set(0f, 0f, 0f)
|
||||
active = false
|
||||
}
|
||||
|
||||
@@ -77,18 +85,26 @@ open class OrientationController(val entity: LivingEntity) {
|
||||
return oldQuat
|
||||
}
|
||||
|
||||
/** Every tick move the current render orientation towards the last known true orientation **/
|
||||
fun tick() {
|
||||
if (!active || orientation == null) return
|
||||
renderOrientationO = renderOrientation
|
||||
val current = orientation
|
||||
val renderMatrix = this.renderOrientation ?: current
|
||||
val renderQuat = Quaternionf().setFromUnnormalized(renderMatrix)
|
||||
val targetQuat = Quaternionf().setFromUnnormalized(current)
|
||||
val dampingFactor = 0.66f // Smooth interpolation to reduce jitter of orientations recieved from the server.
|
||||
renderQuat.slerp(targetQuat, dampingFactor)
|
||||
val current = orientation!!
|
||||
val targetQuat = Quaternionf().setFromUnnormalized(current)
|
||||
|
||||
if (renderOrientation == null) {
|
||||
// First tick: snap the spring to the target instead of easing in from identity
|
||||
renderSpring.quat.set(targetQuat)
|
||||
renderSpring.angVel.set(0f, 0f, 0f)
|
||||
}
|
||||
|
||||
// Use a "quat spring" to smoothly move the render orientation towards the goal orientation.
|
||||
// It takes into account the orientations angular velocities and should be much more resilient
|
||||
// to sharp changes in goal orientation or late/missed packets.
|
||||
simpleSpringDamperQuat(renderSpring, targetQuat, 0.15f, TICK_DT)
|
||||
|
||||
val newRenderOrientation = Matrix3f()
|
||||
renderQuat.get(newRenderOrientation)
|
||||
renderSpring.quat.get(newRenderOrientation)
|
||||
renderOrientation = newRenderOrientation
|
||||
}
|
||||
|
||||
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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.riding.util
|
||||
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.phys.AABB
|
||||
import kotlin.math.floor
|
||||
|
||||
/**
|
||||
* Walks every block position inside [searchBox] and turns each solid block into one
|
||||
* full-cube [FieldPrimitive].
|
||||
*
|
||||
* @author Jackson
|
||||
* @since July 27th, 2026
|
||||
*/
|
||||
|
||||
fun collectPrimitivesFromBlocks(
|
||||
level: BlockGetter,
|
||||
searchBox: AABB,
|
||||
shape: PrimitiveShape,
|
||||
includeFluids: Boolean = false
|
||||
): List<FieldPrimitive> {
|
||||
val primitives = mutableListOf<FieldPrimitive>()
|
||||
|
||||
val minX = floor(searchBox.minX).toInt()
|
||||
val maxX = floor(searchBox.maxX).toInt()
|
||||
val minY = floor(searchBox.minY).toInt()
|
||||
val maxY = floor(searchBox.maxY).toInt()
|
||||
val minZ = floor(searchBox.minZ).toInt()
|
||||
val maxZ = floor(searchBox.maxZ).toInt()
|
||||
|
||||
val pos = BlockPos.MutableBlockPos()
|
||||
for (x in minX..maxX) {
|
||||
for (y in minY..maxY) {
|
||||
for (z in minZ..maxZ) {
|
||||
pos.set(x, y, z)
|
||||
val state = level.getBlockState(pos)
|
||||
|
||||
val isSolid = !state.getCollisionShape(level, pos).isEmpty
|
||||
val isFluid = includeFluids && !state.fluidState.isEmpty
|
||||
if (!isSolid && !isFluid) continue
|
||||
|
||||
primitives.add(
|
||||
FieldPrimitive(
|
||||
shape = shape,
|
||||
centerX = x + 0.5f, centerY = y + 0.5f, centerZ = z + 0.5f,
|
||||
halfWidth = 0.5f, halfHeight = 0.5f, halfDepth = 0.5f
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return primitives
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* 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.riding.util
|
||||
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.sqrt
|
||||
|
||||
/**
|
||||
* Helpful Functions when working with signed distance fields/functions.
|
||||
* https://iquilezles.org/articles/distfunctions/
|
||||
*
|
||||
* @author Jackson
|
||||
* @since July 27th, 2026
|
||||
*/
|
||||
|
||||
/** Which distance formula a primitive uses. */
|
||||
enum class PrimitiveShape {
|
||||
BOX,
|
||||
ROUNDED_BOX,
|
||||
ELLIPSOID
|
||||
}
|
||||
|
||||
/** Tunable constants for the field. */
|
||||
data class DistanceFieldTuning(
|
||||
val smoothingRange: Float = 0.5f,
|
||||
val roundingRadius: Float = 0.08f
|
||||
)
|
||||
|
||||
/** A single shape in the field - a center position, half-extents, and which formula to use. */
|
||||
data class FieldPrimitive(
|
||||
val shape: PrimitiveShape,
|
||||
val centerX: Float, val centerY: Float, val centerZ: Float,
|
||||
val halfWidth: Float, val halfHeight: Float, val halfDepth: Float
|
||||
)
|
||||
|
||||
/** Fast approximate 1/sqrt(x) - the Quake III trick, cheaper than a real sqrt + divide. */
|
||||
fun fastInverseSqrt(value: Float): Float {
|
||||
var x = value
|
||||
val halfX = 0.5f * x
|
||||
var bits = java.lang.Float.floatToIntBits(x)
|
||||
bits = 0x5f3759df - (bits shr 1)
|
||||
x = java.lang.Float.intBitsToFloat(bits)
|
||||
x *= (1.5f - halfX * x * x)
|
||||
return x
|
||||
}
|
||||
|
||||
/** Exact distance from a point to an axis-aligned box. Inputs are relative to the box's own center. */
|
||||
fun boxDistance(relX: Float, relY: Float, relZ: Float, halfWidth: Float, halfHeight: Float, halfDepth: Float): Float {
|
||||
val qx = abs(relX) - halfWidth
|
||||
val qy = abs(relY) - halfHeight
|
||||
val qz = abs(relZ) - halfDepth
|
||||
val ox = max(qx, 0f)
|
||||
val oy = max(qy, 0f)
|
||||
val oz = max(qz, 0f)
|
||||
val outside = sqrt(ox * ox + oy * oy + oz * oz)
|
||||
val inside = min(max(qx, max(qy, qz)), 0f)
|
||||
return outside + inside
|
||||
}
|
||||
|
||||
/** Same as boxDistance but with rounded corners/edges https://iquilezles.org/articles/distfunctions/ */
|
||||
fun roundedBoxDistance(relX: Float, relY: Float, relZ: Float, halfWidth: Float, halfHeight: Float, halfDepth: Float, roundingRadius: Float): Float =
|
||||
boxDistance(relX, relY, relZ, halfWidth - roundingRadius, halfHeight - roundingRadius, halfDepth - roundingRadius) - roundingRadius
|
||||
|
||||
/** Approximate (lower-bound) distance to an ellipsoid https://iquilezles.org/articles/ellipsoids/. */
|
||||
fun ellipsoidDistance(relX: Float, relY: Float, relZ: Float, halfWidth: Float, halfHeight: Float, halfDepth: Float): Float {
|
||||
val px = relX / halfWidth
|
||||
val py = relY / halfHeight
|
||||
val pz = relZ / halfDepth
|
||||
val inverseMagnitude = fastInverseSqrt(px * px + py * py + pz * pz)
|
||||
val trueDistance = sqrt(relX * relX + relY * relY + relZ * relZ)
|
||||
return trueDistance * (1.0f - inverseMagnitude)
|
||||
}
|
||||
|
||||
/** Distance from a point to one primitive, dispatched by its shape. */
|
||||
fun distanceToPrimitive(primitive: FieldPrimitive, sampleX: Float, sampleY: Float, sampleZ: Float, tuning: DistanceFieldTuning): Float {
|
||||
val relX = sampleX - primitive.centerX
|
||||
val relY = sampleY - primitive.centerY
|
||||
val relZ = sampleZ - primitive.centerZ
|
||||
return when (primitive.shape) {
|
||||
PrimitiveShape.BOX -> boxDistance(relX, relY, relZ, primitive.halfWidth, primitive.halfHeight, primitive.halfDepth)
|
||||
PrimitiveShape.ROUNDED_BOX -> roundedBoxDistance(relX, relY, relZ, primitive.halfWidth, primitive.halfHeight, primitive.halfDepth, tuning.roundingRadius)
|
||||
PrimitiveShape.ELLIPSOID -> ellipsoidDistance(relX, relY, relZ, primitive.halfWidth, primitive.halfHeight, primitive.halfDepth)
|
||||
}
|
||||
}
|
||||
|
||||
///** Normalized quadratic smooth-min https://iquilezles.org/articles/smin/ */
|
||||
//fun smoothMinimum(a: Float, b: Float, smoothingRange: Float): Float {
|
||||
// if (smoothingRange <= 0.001f) return min(a, b)
|
||||
// val k = smoothingRange * 4.0f
|
||||
// val h = (0.5f + 0.5f * (b - a) / k).coerceIn(0f, 1f)
|
||||
// return b + (a - b) * h - k * h * (1f - h)
|
||||
//}
|
||||
//
|
||||
///** Folds every primitive's distance together into one field value at a point. */
|
||||
//fun sampleField(primitives: List<FieldPrimitive>, sampleX: Float, sampleY: Float, sampleZ: Float, tuning: DistanceFieldTuning): Float {
|
||||
// var result = Float.POSITIVE_INFINITY
|
||||
// for (primitive in primitives) {
|
||||
// val distance = distanceToPrimitive(primitive, sampleX, sampleY, sampleZ, tuning)
|
||||
// result = if (result == Float.POSITIVE_INFINITY) distance else smoothMinimum(result, distance, tuning.smoothingRange)
|
||||
// }
|
||||
// return result
|
||||
//}
|
||||
|
||||
/** Normalized quadratic smooth-min https://iquilezles.org/articles/smin/ */
|
||||
fun smoothMinimum(a: Float, b: Float, smoothingRange: Float): Float {
|
||||
if (smoothingRange <= 0.001f) return min(a, b)
|
||||
val k = smoothingRange * 4.0f
|
||||
val h = (0.5f + 0.5f * (b - a) / k).coerceIn(0f, 1f)
|
||||
return b + (a - b) * h - k * h * (1f - h)
|
||||
}
|
||||
|
||||
/** Folds nearby primitive distances together into one field value at a point. */
|
||||
fun sampleField(primitives: List<FieldPrimitive>, sampleX: Float, sampleY: Float, sampleZ: Float, tuning: DistanceFieldTuning): Float {
|
||||
if (primitives.isEmpty()) return Float.POSITIVE_INFINITY
|
||||
|
||||
val distances = FloatArray(primitives.size) { distanceToPrimitive(primitives[it], sampleX, sampleY, sampleZ, tuning) }
|
||||
val minDistance = distances.min()
|
||||
|
||||
if (tuning.smoothingRange <= 0.001f) return minDistance
|
||||
|
||||
// Anything more than a few blend-widths past the closest primitive is cut - its
|
||||
// contribution would be negligible in a correct blend anyway, but left in, it still
|
||||
// drags the chained result down the more of them there are.
|
||||
val cutoff = tuning.smoothingRange * 3f
|
||||
|
||||
var result = Float.POSITIVE_INFINITY
|
||||
for (distance in distances) {
|
||||
if (distance - minDistance > cutoff) continue
|
||||
result = if (result == Float.POSITIVE_INFINITY) distance else smoothMinimum(result, distance, tuning.smoothingRange)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/** Finite-difference gradient of the field at a point - points away from the surface, magnitude ~1 for a clean field. */
|
||||
fun estimateGradient(primitives: List<FieldPrimitive>, point: Vec3, tuning: DistanceFieldTuning, epsilon: Float = 0.05f): Vec3 {
|
||||
val px = point.x.toFloat()
|
||||
val py = point.y.toFloat()
|
||||
val pz = point.z.toFloat()
|
||||
|
||||
val dx = sampleField(primitives, px + epsilon, py, pz, tuning) - sampleField(primitives, px - epsilon, py, pz, tuning)
|
||||
val dy = sampleField(primitives, px, py + epsilon, pz, tuning) - sampleField(primitives, px, py - epsilon, pz, tuning)
|
||||
val dz = sampleField(primitives, px, py, pz + epsilon, tuning) - sampleField(primitives, px, py, pz - epsilon, tuning)
|
||||
|
||||
val gradient = Vec3(dx.toDouble(), dy.toDouble(), dz.toDouble())
|
||||
return if (gradient.lengthSqr() > 1e-8) gradient.normalize() else Vec3(0.0, 1.0, 0.0)
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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.riding.util
|
||||
|
||||
import net.minecraft.core.particles.DustParticleOptions
|
||||
import net.minecraft.server.level.ServerLevel
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.phys.AABB
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import org.joml.Vector3f
|
||||
|
||||
/** One shell to draw - a target field value, a color, a particle size. */
|
||||
data class DistanceFieldLayer(
|
||||
val isoValue: Float,
|
||||
val color: Vector3f,
|
||||
val particleSize: Float = 1.0f
|
||||
)
|
||||
|
||||
/**
|
||||
* Marches a grid of vertical columns through the field around [center] and spawns a
|
||||
* particle everywhere it crosses one of [layers]' target values. Server-side only.
|
||||
*/
|
||||
fun visualizeDistanceField(
|
||||
referenceEntity: Entity,
|
||||
center: Vec3,
|
||||
layers: List<DistanceFieldLayer>,
|
||||
shape: PrimitiveShape = PrimitiveShape.BOX,
|
||||
horizontalRadius: Double = 4.0,
|
||||
verticalRange: Double = 4.0,
|
||||
sampleSpacing: Double = 0.5,
|
||||
marchStep: Double = 0.1,
|
||||
tuning: DistanceFieldTuning = DistanceFieldTuning()
|
||||
) {
|
||||
val level = referenceEntity.level()
|
||||
if (level !is ServerLevel) return
|
||||
|
||||
val searchBox = AABB(
|
||||
center.x - horizontalRadius, center.y - verticalRange, center.z - horizontalRadius,
|
||||
center.x + horizontalRadius, center.y, center.z + horizontalRadius
|
||||
)
|
||||
|
||||
val primitives = collectPrimitivesFromBlocks(level, searchBox, shape, includeFluids = true)
|
||||
if (primitives.isEmpty()) return
|
||||
|
||||
var x = -horizontalRadius
|
||||
while (x <= horizontalRadius) {
|
||||
var z = -horizontalRadius
|
||||
while (z <= horizontalRadius) {
|
||||
marchColumn(level, primitives, center, x, z, verticalRange, marchStep, layers, tuning)
|
||||
z += sampleSpacing
|
||||
}
|
||||
x += sampleSpacing
|
||||
}
|
||||
}
|
||||
|
||||
private fun marchColumn(
|
||||
level: ServerLevel,
|
||||
primitives: List<FieldPrimitive>,
|
||||
center: Vec3,
|
||||
offsetX: Double,
|
||||
offsetZ: Double,
|
||||
verticalRange: Double,
|
||||
marchStep: Double,
|
||||
layers: List<DistanceFieldLayer>,
|
||||
tuning: DistanceFieldTuning
|
||||
) {
|
||||
val previousValue = FloatArray(layers.size) { Float.NaN }
|
||||
|
||||
var y = verticalRange
|
||||
while (y >= -verticalRange) {
|
||||
val worldX = (center.x + offsetX).toFloat()
|
||||
val worldY = (center.y + y).toFloat()
|
||||
val worldZ = (center.z + offsetZ).toFloat()
|
||||
val fieldValue = sampleField(primitives, worldX, worldY, worldZ, tuning)
|
||||
|
||||
for (layerIndex in layers.indices) {
|
||||
val layer = layers[layerIndex]
|
||||
val previous = previousValue[layerIndex]
|
||||
|
||||
if (!previous.isNaN() && crossedTarget(previous, fieldValue, layer.isoValue)) {
|
||||
val t = (layer.isoValue - previous) / (fieldValue - previous)
|
||||
val crossingY = (y + marchStep) - marchStep * t
|
||||
spawnLayerParticle(level, center.add(offsetX, crossingY, offsetZ), layer)
|
||||
}
|
||||
|
||||
previousValue[layerIndex] = fieldValue
|
||||
}
|
||||
|
||||
y -= marchStep
|
||||
}
|
||||
}
|
||||
|
||||
private fun crossedTarget(previous: Float, current: Float, target: Float): Boolean =
|
||||
(previous - target) * (current - target) < 0f
|
||||
|
||||
private fun spawnLayerParticle(level: ServerLevel, pos: Vec3, layer: DistanceFieldLayer) {
|
||||
val particle = DustParticleOptions(layer.color, layer.particleSize)
|
||||
level.sendParticles(particle, pos.x, pos.y, pos.z, 1, 0.0, 0.0, 0.0, 0.0)
|
||||
}
|
||||
@@ -129,12 +129,7 @@ class ParticleEvent(
|
||||
onDespawn = {},
|
||||
getParticleColor = storm.getParticleColor,
|
||||
targetPos = storm.targetPos,
|
||||
runtime = MoLangRuntime().setup().also { runtime ->
|
||||
// Weather sub-emitters share the parent's lifetime condition.
|
||||
storm.runtime.environment.query.functions["is_weather_active"]?.let {
|
||||
runtime.environment.query.addFunction("is_weather_active", it)
|
||||
}
|
||||
},
|
||||
runtime = MoLangRuntime().setup(),
|
||||
entity = storm.entity
|
||||
)
|
||||
//The reason this doesn't use the newStorms runtime is that the parent storm can add queries AFTER
|
||||
@@ -216,4 +211,4 @@ class EventSoundEffect(
|
||||
).apply(instance, ::EventSoundEffect)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,11 +28,7 @@ data class BattleFormat(
|
||||
var ruleSet: Set<String> = setOf(),
|
||||
val gen: Int = 9,
|
||||
var adjustLevel: Int = -1, // Stop gap rule before a more general system for rules enforced by Cobblemon is implemented.
|
||||
val isOpenTeamSheet: Boolean = false,
|
||||
) {
|
||||
val hasTeamPreview: Boolean
|
||||
get() = ruleSet.any { it.equals(BattleRules.TEAM_PREVIEW, ignoreCase = true) || it.equals("teampreview", ignoreCase = true) }
|
||||
|
||||
companion object {
|
||||
fun setBattleRules(
|
||||
battleFormat: BattleFormat,
|
||||
@@ -125,4 +121,4 @@ data class BattleFormat(
|
||||
}
|
||||
""".trimIndent().replace("\n", "")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,16 +211,7 @@ object ShowdownInterpreter {
|
||||
}
|
||||
|
||||
// Broadcasts a generic lang to notify players of ability activations (effects are broadcasted separately)
|
||||
@JvmOverloads
|
||||
fun broadcastAbility(battle: PokemonBattle, effect: Effect, pokemon: BattlePokemon, revealedAbility: Effect = effect) {
|
||||
// Direct -ability messages omit the ability: prefix. A copied ability can also differ
|
||||
// from the effect announced in chat (for example, Trace).
|
||||
if (revealedAbility.type == Effect.Type.ABILITY || revealedAbility.type == Effect.Type.PURE) {
|
||||
battle.dispatchGo {
|
||||
pokemon.revealedAbility = revealedAbility.id
|
||||
pokemon.sendUpdate()
|
||||
}
|
||||
}
|
||||
fun broadcastAbility(battle: PokemonBattle, effect: Effect, pokemon: BattlePokemon) {
|
||||
battle.dispatchWaiting(0.5F) {
|
||||
val lang = battleLang("ability.generic", pokemon.getName(), effect.typelessData).yellow()
|
||||
battle.broadcastChatMessage(lang)
|
||||
@@ -330,4 +321,4 @@ object ShowdownInterpreter {
|
||||
fun registerSideInstructionParser(id: String, callback: (PokemonBattle, BattleActor, InstructionSet, BattleMessage) -> InterpreterInstruction) {
|
||||
sideInstructionParser[id] = callback
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,151 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.battles
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonNetwork.sendPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.CloseTeamPreviewPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.TeamPreviewPacket
|
||||
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||
import com.cobblemon.mod.common.util.getPlayer
|
||||
import com.cobblemon.mod.common.util.party
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
import java.util.UUID
|
||||
|
||||
object TeamPreviewManager {
|
||||
private val previews = mutableListOf<TeamPreview>()
|
||||
val TEAM_PREVIEW_TIME_SECONDS = 60
|
||||
|
||||
fun tick() {
|
||||
val expired = previews.filter { Duration.between(it.started, Instant.now()).seconds >= TEAM_PREVIEW_TIME_SECONDS }
|
||||
expired.forEach { cancel(it) }
|
||||
|
||||
val ready = previews.filter {
|
||||
hasEligibleSelections(it.sideA) && hasEligibleSelections(it.sideB)
|
||||
}
|
||||
ready.forEach { start(it) }
|
||||
}
|
||||
|
||||
fun add(sideA: TeamPreviewSide, sideB: TeamPreviewSide, openTeamSheet: Boolean, onStart: (TeamPreview) -> Unit, onCancel: (TeamPreview) -> Unit) {
|
||||
require(sideA.uuid != sideB.uuid) { "A team preview requires two distinct participants" }
|
||||
require(listOf(sideA, sideB).all { it.neededSelections in 1..it.party.count { pokemon -> pokemon != null } }) {
|
||||
"Each side must be able to fill its requested selection"
|
||||
}
|
||||
if (previews.any { it.sideA.uuid == sideA.uuid || it.sideB.uuid == sideA.uuid || it.sideA.uuid == sideB.uuid || it.sideB.uuid == sideB.uuid }) return
|
||||
val now = Instant.now()
|
||||
previews.add(TeamPreview(sideA, sideB, now, onStart, onCancel))
|
||||
if (sideA.isPlayer) {
|
||||
sideA.uuid.getPlayer()?.sendPacket(
|
||||
TeamPreviewPacket(
|
||||
sideA.neededSelections,
|
||||
sideA.party,
|
||||
sideB.party,
|
||||
openTeamSheet,
|
||||
now.plusSeconds(TEAM_PREVIEW_TIME_SECONDS.toLong()),
|
||||
sideB.name
|
||||
)
|
||||
)
|
||||
}
|
||||
if (sideB.isPlayer) {
|
||||
sideB.uuid.getPlayer()?.sendPacket(
|
||||
TeamPreviewPacket(
|
||||
sideB.neededSelections,
|
||||
sideB.party,
|
||||
sideA.party,
|
||||
openTeamSheet,
|
||||
now.plusSeconds(TEAM_PREVIEW_TIME_SECONDS.toLong()),
|
||||
sideA.name
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
previews.toList().forEach { cancel(it) }
|
||||
}
|
||||
|
||||
fun remove(player: ServerPlayer) {
|
||||
val preview = previews.firstOrNull { it.sideA.isPlayer && it.sideA.uuid == player.uuid || it.sideB.isPlayer && it.sideB.uuid == player.uuid } ?: return
|
||||
cancel(preview)
|
||||
}
|
||||
|
||||
fun cancel(preview: TeamPreview) {
|
||||
if (!previews.remove(preview)) return
|
||||
if (preview.sideA.isPlayer) {
|
||||
preview.sideA.uuid.getPlayer()?.sendPacket(CloseTeamPreviewPacket())
|
||||
}
|
||||
if (preview.sideB.isPlayer) {
|
||||
preview.sideB.uuid.getPlayer()?.sendPacket(CloseTeamPreviewPacket())
|
||||
}
|
||||
preview.onCancel(preview)
|
||||
}
|
||||
|
||||
fun start(preview: TeamPreview) {
|
||||
if (!previews.remove(preview)) return
|
||||
if (preview.sideA.isPlayer) {
|
||||
preview.sideA.uuid.getPlayer()?.sendPacket(CloseTeamPreviewPacket())
|
||||
}
|
||||
if (preview.sideB.isPlayer) {
|
||||
preview.sideB.uuid.getPlayer()?.sendPacket(CloseTeamPreviewPacket())
|
||||
}
|
||||
preview.onStart(preview)
|
||||
}
|
||||
|
||||
fun changeSelections(uuid: UUID, selections: Set<Int>) {
|
||||
val preview = previews.firstOrNull { it.sideA.uuid == uuid || it.sideB.uuid == uuid } ?: return
|
||||
val isSideA = preview.sideA.uuid == uuid
|
||||
val side = if (isSideA) preview.sideA else preview.sideB
|
||||
if (!side.isPlayer || !isValidSelection(side.party, selections, side.neededSelections, requireComplete = false)) return
|
||||
previews.remove(preview)
|
||||
if (isSideA) {
|
||||
previews.add(
|
||||
preview.copy(
|
||||
sideA = preview.sideA.copy(selections = selections.toSet()),
|
||||
)
|
||||
)
|
||||
}
|
||||
else {
|
||||
previews.add(
|
||||
preview.copy(
|
||||
sideB = preview.sideB.copy(selections = selections.toSet()),
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun hasEligibleSelections(side: TeamPreviewSide): Boolean =
|
||||
isValidSelection(side.party, side.selections, side.neededSelections)
|
||||
|
||||
internal fun isValidSelection(party: List<*>, selections: Set<Int>, needed: Int, requireComplete: Boolean = true): Boolean {
|
||||
if (needed < 1 || selections.size > needed || (requireComplete && selections.size != needed)) return false
|
||||
return selections.all { it in party.indices && party[it] != null }
|
||||
}
|
||||
}
|
||||
|
||||
data class TeamPreview(
|
||||
val sideA: TeamPreviewSide,
|
||||
val sideB: TeamPreviewSide,
|
||||
val started: Instant,
|
||||
val onStart: (TeamPreview) -> Unit,
|
||||
val onCancel: (TeamPreview) -> Unit
|
||||
)
|
||||
|
||||
data class TeamPreviewSide(
|
||||
val uuid: UUID,
|
||||
val name: Component,
|
||||
val isPlayer: Boolean,
|
||||
val party: List<Pokemon?>,
|
||||
val selections: Set<Int>,
|
||||
val neededSelections: Int
|
||||
) {
|
||||
constructor(player: ServerPlayer, neededSelections: Int): this(player.uuid, player.name, true, player.party().toGappyList(), emptySet(), neededSelections)
|
||||
constructor(pokemon: Pokemon, name: Component? = null): this(pokemon.uuid, name ?: pokemon.getDisplayName(), false, listOf(null, null, pokemon, null, null, null, null), setOf(2), 1)
|
||||
}
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
package com.cobblemon.mod.common.battles.actor
|
||||
|
||||
import com.cobblemon.mod.common.battles.timers.PlayerBattleTimer
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.CobblemonNetwork
|
||||
import com.cobblemon.mod.common.api.battles.model.actor.ActorType
|
||||
@@ -35,8 +33,6 @@ class PlayerBattleActor(
|
||||
pokemonList: List<BattlePokemon>,
|
||||
) : BattleActor(uuid, pokemonList.toMutableList()), EntityBackedBattleActor<ServerPlayer> {
|
||||
|
||||
var timer: PlayerBattleTimer? = null
|
||||
|
||||
override val initialPos: Vec3?
|
||||
override val entity: ServerPlayer?
|
||||
get() = this.uuid.getPlayer()
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ class AbilityInstruction(val instructionSet: InstructionSet, val message: Battle
|
||||
val optionalPokemon = message.battlePokemonFromOptional(battle)
|
||||
|
||||
// If there is an optional effect causing the activation, broadcast that instead of the standard effect
|
||||
ShowdownInterpreter.broadcastAbility(battle, optionalEffect ?: effect, pokemon, revealedAbility = effect)
|
||||
ShowdownInterpreter.broadcastAbility(battle, optionalEffect ?: effect, pokemon)
|
||||
|
||||
battle.dispatch {
|
||||
val pokemonName = pokemon.getName()
|
||||
@@ -63,4 +63,4 @@ class AbilityInstruction(val instructionSet: InstructionSet, val message: Battle
|
||||
else return@dispatch GO
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-4
@@ -83,10 +83,6 @@ class BoostInstruction(battle: PokemonBattle, val message: BattleMessage, val is
|
||||
}
|
||||
battle.broadcastChatMessage(lang)
|
||||
|
||||
val changedStat = Stats.getStat(statKey)
|
||||
val delta = if (isBoost) stages else -stages
|
||||
pokemon.statChanges[changedStat] = ((pokemon.statChanges[changedStat] ?: 0) + delta).coerceIn(-6, 6)
|
||||
pokemon.sendUpdate()
|
||||
val boostBucket = if (isBoost) BattleContext.Type.BOOST else BattleContext.Type.UNBOOST
|
||||
val context = ShowdownInterpreter.getContextFromAction(message, boostBucket, battle)
|
||||
// TODO: replace with context that tracks detailed information such as # of stages
|
||||
|
||||
-2
@@ -26,8 +26,6 @@ class ClearAllBoostInstruction(val message: BattleMessage): InterpreterInstructi
|
||||
override fun invoke(battle: PokemonBattle) {
|
||||
battle.dispatchWaiting(1.5F) {
|
||||
battle.activePokemon.forEach {
|
||||
it.battlePokemon?.statChanges?.clear()
|
||||
it.battlePokemon?.sendUpdate()
|
||||
it.battlePokemon?.contextManager?.clear(BattleContext.Type.BOOST, BattleContext.Type.UNBOOST)
|
||||
}
|
||||
battle.broadcastChatMessage(battleLang("clearallboost"))
|
||||
|
||||
-2
@@ -30,8 +30,6 @@ class ClearBoostInstruction(val message: BattleMessage): InterpreterInstruction
|
||||
val pokemonName = battlePokemon.getName()
|
||||
val lang = battleLang("clearboost", pokemonName)
|
||||
battle.broadcastChatMessage(lang)
|
||||
battlePokemon.statChanges.clear()
|
||||
battlePokemon.sendUpdate()
|
||||
battlePokemon.contextManager.clear(BattleContext.Type.BOOST, BattleContext.Type.UNBOOST)
|
||||
battle.minorBattleActions[battlePokemon.uuid] = message
|
||||
}
|
||||
|
||||
-2
@@ -36,8 +36,6 @@ class ClearNegativeBoostInstruction(val message: BattleMessage): InterpreterInst
|
||||
battle.broadcastChatMessage(lang)
|
||||
}
|
||||
|
||||
battlePokemon.statChanges.entries.removeIf { it.value < 0 }
|
||||
battlePokemon.sendUpdate()
|
||||
battlePokemon.contextManager.clear(BattleContext.Type.UNBOOST)
|
||||
battle.minorBattleActions[battlePokemon.uuid] = message
|
||||
}
|
||||
|
||||
-4
@@ -32,10 +32,6 @@ class CopyBoostInstruction(val message: BattleMessage): InterpreterInstruction {
|
||||
val lang = battleLang("copyboost.generic", pokemonName, targetPokemonName)
|
||||
battle.broadcastChatMessage(lang)
|
||||
|
||||
val changes = targetPokemon.statChanges.toMap()
|
||||
pokemon.statChanges.clear()
|
||||
pokemon.statChanges.putAll(changes)
|
||||
pokemon.sendUpdate()
|
||||
pokemon.contextManager.copy(targetPokemon.contextManager, BattleContext.Type.BOOST, BattleContext.Type.UNBOOST)
|
||||
battle.minorBattleActions[pokemon.uuid] = message
|
||||
}
|
||||
|
||||
+1
-8
@@ -155,13 +155,6 @@ class DamageInstruction(
|
||||
|
||||
val newHealthRatio: Float
|
||||
val remainingHealth = newHealth.split("/")[0].toInt()
|
||||
val previousHealth = battlePokemon.effectedPokemon.currentHealth
|
||||
val damageDealt = (previousHealth - remainingHealth).coerceAtLeast(0)
|
||||
val maxHp = battlePokemon.effectedPokemon.maxHealth
|
||||
if (damageDealt > 0 && maxHp > 0) {
|
||||
val percent = Math.round(damageDealt.toFloat() / maxHp * 100F).coerceAtLeast(1)
|
||||
battle.broadcastChatMessage(battleLang("damage_dealt", battlePokemon.getName(), "$percent%"))
|
||||
}
|
||||
|
||||
if (effect != null) {
|
||||
val lang = when (effect.id) {
|
||||
@@ -229,4 +222,4 @@ class DamageInstruction(
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
-2
@@ -35,8 +35,6 @@ class EndItemInstruction(val message: BattleMessage): InterpreterInstruction {
|
||||
val battlePokemon = message.battlePokemon(0, battle) ?: return@dispatchWaiting
|
||||
val itemEffect = message.effectAt(1) ?: return@dispatchWaiting
|
||||
battlePokemon.heldItemManager.handleEndInstruction(battlePokemon, battle, message)
|
||||
battlePokemon.revealedHeldItem = net.minecraft.world.item.ItemStack.EMPTY
|
||||
battlePokemon.sendUpdate()
|
||||
battle.minorBattleActions[battlePokemon.uuid] = message
|
||||
battlePokemon.contextManager.remove(itemEffect.id, BattleContext.Type.ITEM)
|
||||
if (message.hasOptionalArgument("eat")) {
|
||||
|
||||
+1
-10
@@ -8,8 +8,6 @@
|
||||
|
||||
package com.cobblemon.mod.common.battles.interpreter.instructions
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleActorTeamPacket
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.api.battles.interpreter.BattleMessage
|
||||
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
|
||||
@@ -60,11 +58,6 @@ class InitializeInstruction(val instructionSet: InstructionSet, val message: Bat
|
||||
|
||||
battle.actors.forEach { actor ->
|
||||
actor.sendUpdate(BattleSetTeamPokemonPacket(actor.pokemonList.map { it.effectedPokemon }))
|
||||
battle.actors.forEach { viewer ->
|
||||
viewer.sendUpdate(BattleActorTeamPacket(actor.uuid, actor.pokemonList.map {
|
||||
it.toBattleDTO(ally = viewer == actor)
|
||||
}))
|
||||
}
|
||||
val req = actor.request ?: return@forEach
|
||||
actor.sendUpdate(BattleQueueRequestPacket(req))
|
||||
}
|
||||
@@ -75,10 +68,8 @@ class InitializeInstruction(val instructionSet: InstructionSet, val message: Bat
|
||||
|
||||
battle.dispatchGo {
|
||||
battle.started = true
|
||||
battle.activePokemon.mapNotNull { it.battlePokemon }.forEach { it.sendUpdate() }
|
||||
battle.notifyAllOfUpdates()
|
||||
battle.side1.playCries()
|
||||
afterOnServer(seconds = 1.0F) { battle.side2.playCries() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-2
@@ -28,8 +28,6 @@ class InvertBoostInstruction(val message: BattleMessage): InterpreterInstruction
|
||||
override fun invoke(battle: PokemonBattle) {
|
||||
battle.dispatchWaiting {
|
||||
val pokemon = message.battlePokemon(0, battle) ?: return@dispatchWaiting
|
||||
pokemon.statChanges.replaceAll { _, value -> -value }
|
||||
pokemon.sendUpdate()
|
||||
val name = pokemon.getName()
|
||||
battle.broadcastChatMessage(battleLang("invertboost", name))
|
||||
|
||||
|
||||
-2
@@ -34,8 +34,6 @@ class ItemInstruction(val message: BattleMessage): InterpreterInstruction {
|
||||
battle.dispatchWaiting(1.5F) {
|
||||
val battlePokemon = message.battlePokemon(0, battle) ?: return@dispatchWaiting
|
||||
battlePokemon.heldItemManager.handleStartInstruction(battlePokemon, battle, message)
|
||||
battlePokemon.revealedHeldItem = battlePokemon.effectedPokemon.heldItem.copy()
|
||||
battlePokemon.sendUpdate()
|
||||
battle.minorBattleActions[battlePokemon.uuid] = message
|
||||
battlePokemon.contextManager.add(ShowdownInterpreter.getContextFromAction(message, BattleContext.Type.ITEM, battle))
|
||||
}
|
||||
|
||||
-10
@@ -8,8 +8,6 @@
|
||||
|
||||
package com.cobblemon.mod.common.battles.interpreter.instructions
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.MoveDTO
|
||||
|
||||
import com.bedrockk.molang.runtime.MoLangRuntime
|
||||
import com.bedrockk.molang.runtime.value.DoubleValue
|
||||
import com.bedrockk.molang.runtime.value.StringValue
|
||||
@@ -76,14 +74,6 @@ class MoveInstruction(
|
||||
battle.dispatch { UntilDispatch { instructionSet.getMostRecentInstruction<MoveInstruction>(this)?.future?.isDone != false } }
|
||||
|
||||
battle.dispatch {
|
||||
val knownMove = userPokemon.revealedMoves.firstOrNull { it?.move == move.displayName }
|
||||
if (knownMove != null) {
|
||||
knownMove.timesUsed++
|
||||
} else {
|
||||
val slot = userPokemon.revealedMoves.indexOfFirst { it == null }
|
||||
if (slot >= 0) userPokemon.revealedMoves[slot] = MoveDTO(move.displayName, 1)
|
||||
}
|
||||
userPokemon.sendUpdate()
|
||||
val pokemonName = userPokemon.getName()
|
||||
ShowdownInterpreter.lastCauser[battle.battleId] = message
|
||||
// For Spread targets the message data only gives the pnx strings. So we can't know what pokemon are actually targeted until the previous messages have been interpreted
|
||||
|
||||
+1
-8
@@ -19,13 +19,6 @@ import com.cobblemon.mod.common.battles.dispatch.InterpreterInstruction
|
||||
*/
|
||||
object PostUpdateInstruction : InterpreterInstruction {
|
||||
override fun invoke(battle: PokemonBattle) {
|
||||
battle.dispatchGo {
|
||||
battle.actors.forEach { it.postUpdate() }
|
||||
battle.notifyAllOfUpdates()
|
||||
val viewers = battle.actors.flatMap { it.getPlayerUUIDs() } + battle.spectators
|
||||
battle.actors.forEach { actor ->
|
||||
actor.pokemonList.forEach { it.updateBattleActorInformation(viewers) }
|
||||
}
|
||||
}
|
||||
battle.dispatchGo { battle.actors.forEach { it.postUpdate() } }
|
||||
}
|
||||
}
|
||||
-8
@@ -8,8 +8,6 @@
|
||||
|
||||
package com.cobblemon.mod.common.battles.interpreter.instructions
|
||||
|
||||
import com.cobblemon.mod.common.api.pokemon.stats.Stats
|
||||
|
||||
import com.cobblemon.mod.common.api.battles.interpreter.BattleContext
|
||||
import com.cobblemon.mod.common.api.battles.interpreter.BattleMessage
|
||||
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
|
||||
@@ -29,12 +27,6 @@ class SetBoostInstruction(val message: BattleMessage): InterpreterInstruction {
|
||||
override fun invoke(battle: PokemonBattle) {
|
||||
battle.dispatchWaiting(1.5F) {
|
||||
val pokemon = message.battlePokemon(0, battle) ?: return@dispatchWaiting
|
||||
val stat = message.argumentAt(1)?.let { Stats.getStat(it) }
|
||||
val amount = message.argumentAt(2)?.toIntOrNull()
|
||||
if (stat != null && amount != null) {
|
||||
pokemon.statChanges[stat] = amount.coerceIn(-6, 6)
|
||||
pokemon.sendUpdate()
|
||||
}
|
||||
val pokemonName = pokemon.getName()
|
||||
val effectID = message.effect()?.id ?: return@dispatchWaiting
|
||||
val lang = battleLang("setboost.$effectID", pokemonName)
|
||||
|
||||
-11
@@ -8,8 +8,6 @@
|
||||
|
||||
package com.cobblemon.mod.common.battles.interpreter.instructions
|
||||
|
||||
import com.cobblemon.mod.common.api.pokemon.stats.Stats
|
||||
|
||||
import com.cobblemon.mod.common.api.battles.interpreter.BattleContext
|
||||
import com.cobblemon.mod.common.api.battles.interpreter.BattleMessage
|
||||
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
|
||||
@@ -31,15 +29,6 @@ class SwapBoostInstruction(val message: BattleMessage): InterpreterInstruction {
|
||||
val pokemonName = pokemon.getName()
|
||||
val targetPokemon = message.battlePokemon(1, battle) ?: return@dispatchWaiting
|
||||
val targetPokemonName = targetPokemon.getName()
|
||||
val stats = message.argumentAt(2)?.split(',')?.map { Stats.getStat(it.trim()) }
|
||||
?: (pokemon.statChanges.keys + targetPokemon.statChanges.keys).toList()
|
||||
stats.forEach { stat ->
|
||||
val previous = pokemon.statChanges[stat] ?: 0
|
||||
pokemon.statChanges[stat] = targetPokemon.statChanges[stat] ?: 0
|
||||
targetPokemon.statChanges[stat] = previous
|
||||
}
|
||||
pokemon.sendUpdate()
|
||||
targetPokemon.sendUpdate()
|
||||
val effectID = message.effect()?.id ?: return@dispatchWaiting
|
||||
val lang = when (effectID) {
|
||||
"guardswap", "powerswap", "heartswap" -> battleLang("swapboost.$effectID", pokemonName)
|
||||
|
||||
+1
-11
@@ -129,14 +129,6 @@ class SwitchInstruction(val instructionSet: InstructionSet, val battleActor: Bat
|
||||
|
||||
activePokemon.battlePokemon?.let { oldPokemon ->
|
||||
if (publicMessage.effect()?.id == "batonpass") oldPokemon.contextManager.swap(pokemon.contextManager, BattleContext.Type.BOOST, BattleContext.Type.UNBOOST)
|
||||
pokemon.statChanges.clear()
|
||||
if (publicMessage.effect()?.id == "batonpass") pokemon.statChanges.putAll(oldPokemon.statChanges)
|
||||
oldPokemon.statChanges.clear()
|
||||
if (oldPokemon.transformed != null) {
|
||||
oldPokemon.revealedMoves.indices.forEach { oldPokemon.revealedMoves[it] = null }
|
||||
oldPokemon.revealedAbility = null
|
||||
}
|
||||
oldPokemon.transformed = null
|
||||
oldPokemon.contextManager.clear(BattleContext.Type.VOLATILE, BattleContext.Type.BOOST, BattleContext.Type.UNBOOST)
|
||||
battle.majorBattleActions[oldPokemon.uuid] = publicMessage
|
||||
|
||||
@@ -223,8 +215,6 @@ class SwitchInstruction(val instructionSet: InstructionSet, val battleActor: Bat
|
||||
}
|
||||
|
||||
private fun broadcastSwitch(battle: PokemonBattle, actor: BattleActor, newPokemon: BattlePokemon, illusion: BattlePokemon?) {
|
||||
// The active slot and its illusion are now set, so reveal the identity that entered battle.
|
||||
newPokemon.sendUpdate()
|
||||
val publicPokemon = (illusion ?: newPokemon).effectedPokemon
|
||||
val publicLang = publicPokemon.nickname?.let { nickname ->
|
||||
battleLang("switch.other.nickname", actor.getName(), nickname, publicPokemon.species.translatedName)
|
||||
@@ -239,4 +229,4 @@ class SwitchInstruction(val instructionSet: InstructionSet, val battleActor: Bat
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
-2
@@ -30,8 +30,6 @@ class TerastallizeInstruction(val message: BattleMessage): InterpreterInstructio
|
||||
val battlePokemon = message.battlePokemon(0, battle) ?: return
|
||||
val type = message.effectAt(1)?.let { TeraTypes.get(it.id) } ?: return
|
||||
battle.dispatchWaiting {
|
||||
battlePokemon.terastallized = type
|
||||
battlePokemon.sendUpdate()
|
||||
val pokemonName = battlePokemon.getName()
|
||||
battle.broadcastChatMessage(battleLang("terastallize", pokemonName, type.displayName).yellow())
|
||||
CobblemonEvents.TERASTALLIZATION.post(TerastallizationEvent(battle, battlePokemon, type))
|
||||
|
||||
+1
-11
@@ -46,16 +46,6 @@ class TransformInstruction(val battle: PokemonBattle, val message: BattleMessage
|
||||
}
|
||||
|
||||
battle.dispatchWaiting {
|
||||
pokemon.transformed = targetPokemon
|
||||
pokemon.statChanges.clear()
|
||||
pokemon.statChanges.putAll(targetPokemon.statChanges)
|
||||
for (index in pokemon.revealedMoves.indices) {
|
||||
pokemon.revealedMoves[index] = targetPokemon.moveSet.get(index)?.let {
|
||||
com.cobblemon.mod.common.net.messages.client.battle.MoveDTO(it.displayName, 0)
|
||||
}
|
||||
}
|
||||
pokemon.revealedAbility = targetPokemon.effectedPokemon.ability.name
|
||||
pokemon.sendUpdate()
|
||||
val mock = pokemon.entity?.effects?.mockEffect?.mock
|
||||
val pokemonName = pokemon.getName()
|
||||
val targetPokemonName = targetPokemon.getName()
|
||||
@@ -73,4 +63,4 @@ class TransformInstruction(val battle: PokemonBattle, val message: BattleMessage
|
||||
battle.minorBattleActions[pokemon.uuid] = message
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,24 +8,6 @@
|
||||
|
||||
package com.cobblemon.mod.common.battles.pokemon
|
||||
|
||||
import net.minecraft.world.item.ItemStack
|
||||
|
||||
import com.cobblemon.mod.common.util.getPlayer
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.MoveDTO
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattlePokemonDTO
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleActorInformationPacket
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleInitializePacket
|
||||
|
||||
import com.cobblemon.mod.common.api.types.tera.TeraType
|
||||
|
||||
import com.cobblemon.mod.common.api.pokemon.stats.Stats
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonNetwork.sendPacket
|
||||
|
||||
import com.bedrockk.molang.runtime.struct.QueryStruct
|
||||
import com.bedrockk.molang.runtime.value.DoubleValue
|
||||
import com.bedrockk.molang.runtime.value.StringValue
|
||||
@@ -138,13 +120,6 @@ open class BattlePokemon(
|
||||
|
||||
val contextManager = ContextManager()
|
||||
|
||||
var revealed = false
|
||||
var revealedAbility: String? = null
|
||||
val revealedMoves: MutableList<MoveDTO?> = mutableListOf(null, null, null, null)
|
||||
var revealedHeldItem: ItemStack? = null
|
||||
var transformed: BattlePokemon? = null
|
||||
var terastallized: TeraType? = null
|
||||
|
||||
open fun getName(): MutableComponent {
|
||||
val displayPokemon = getIllusion()?.effectedPokemon ?: effectedPokemon
|
||||
return if (actor is PokemonBattleActor || actor is MultiPokemonBattleActor) {
|
||||
@@ -154,72 +129,8 @@ open class BattlePokemon(
|
||||
}
|
||||
}
|
||||
|
||||
fun toBattleDTO(ally: Boolean, forceReveal: Boolean = false): BattlePokemonDTO {
|
||||
val moves = (transformed?.effectedPokemon ?: effectedPokemon).moveSet.getMovesWithNulls().map { move ->
|
||||
move?.let { MoveDTO(it.displayName, revealedMoves.firstOrNull { known -> known?.move == it.displayName }?.timesUsed ?: 0) }
|
||||
}
|
||||
|
||||
val boostMultipliers = statChanges.entries.mapNotNull { (stat, stage) ->
|
||||
val standardStat = stat as? Stats ?: return@mapNotNull null
|
||||
val base = if (standardStat == Stats.ACCURACY || standardStat == Stats.EVASION) 3.0 else 2.0
|
||||
val clamped = stage.coerceIn(-6, 6)
|
||||
standardStat to if (clamped >= 0) (base + clamped) / base else base / (base - clamped)
|
||||
}.toMap().filterValues { it != 1.0 }
|
||||
|
||||
val format = if (::actor.isInitialized && actor.isInitialized()) actor.battle.format else null
|
||||
val isTeamSheet = format?.isOpenTeamSheet == true
|
||||
if (ally || isTeamSheet) {
|
||||
val allyDto = BattleInitializePacket.ActiveBattlePokemonDTO.fromPokemon(this, ally, getIllusion())
|
||||
return BattlePokemonDTO(
|
||||
this.effectedPokemon.uuid,
|
||||
this.effectedPokemon.isFainted(),
|
||||
(transformed?.effectedPokemon ?: effectedPokemon).ability.name,
|
||||
moves,
|
||||
this.effectedPokemon.heldItem,
|
||||
boostMultipliers,
|
||||
if (ally) effectedPokemon.speed else null,
|
||||
terastallized = terastallized,
|
||||
allyDto
|
||||
)
|
||||
}
|
||||
else {
|
||||
// Team Preview reveals identities, while moves, abilities and items still require discovery.
|
||||
val nonAllyDto = if (forceReveal || revealed || format?.hasTeamPreview == true) {
|
||||
BattleInitializePacket.ActiveBattlePokemonDTO.fromPokemon(this, false, getIllusion())
|
||||
} else null
|
||||
return BattlePokemonDTO(
|
||||
this.effectedPokemon.uuid,
|
||||
this.effectedPokemon.isFainted(),
|
||||
revealedAbility,
|
||||
revealedMoves,
|
||||
revealedHeldItem,
|
||||
boostMultipliers,
|
||||
speed = null,
|
||||
terastallized = terastallized,
|
||||
nonAllyDto
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun updateBattleActorInformation(uuids: List<UUID>) {
|
||||
uuids.forEach {
|
||||
if (actor.uuid == it) {
|
||||
it.getPlayer()?.sendPacket(
|
||||
BattleActorInformationPacket(actor.uuid, toBattleDTO(true))
|
||||
)
|
||||
}
|
||||
else {
|
||||
it.getPlayer()?.sendPacket(
|
||||
BattleActorInformationPacket(actor.uuid, toBattleDTO(false))
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun sendUpdate() {
|
||||
actor.sendUpdate(BattleUpdateTeamPokemonPacket(effectedPokemon))
|
||||
revealed = revealed || isSentOut()
|
||||
updateBattleActorInformation(actor.battle.actors.flatMap { it.getPlayerUUIDs() } + actor.battle.spectators)
|
||||
}
|
||||
|
||||
fun isSentOut() = actor.battle.activePokemon.any { it.battlePokemon == this }
|
||||
@@ -230,7 +141,5 @@ open class BattlePokemon(
|
||||
!isSentOut() && !willBeSwitchedIn && health > 0
|
||||
}
|
||||
|
||||
fun getIllusion(): BattlePokemon? = if (::actor.isInitialized) {
|
||||
actor.activePokemon.find { it.battlePokemon == this }?.illusion
|
||||
} else null
|
||||
}
|
||||
fun getIllusion(): BattlePokemon? = this.actor.activePokemon.find { it.battlePokemon == this }?.illusion
|
||||
}
|
||||
@@ -1,28 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.battles.timers
|
||||
|
||||
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
|
||||
import com.cobblemon.mod.common.battles.ForfeitActionResponse
|
||||
import com.cobblemon.mod.common.battles.actor.PlayerBattleActor
|
||||
import java.time.Instant
|
||||
|
||||
interface PlayerBattleTimer {
|
||||
val actor: PlayerBattleActor
|
||||
val battle: PokemonBattle
|
||||
|
||||
fun startSelection()
|
||||
fun endSelection()
|
||||
fun tick()
|
||||
fun mustChooseBy(): Instant
|
||||
|
||||
fun timeout() {
|
||||
actor.setActionResponses(listOf(ForfeitActionResponse()))
|
||||
}
|
||||
}
|
||||
@@ -1,45 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.battles.timers
|
||||
|
||||
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
|
||||
import com.cobblemon.mod.common.battles.actor.PlayerBattleActor
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
|
||||
class ShowdownTimer(override val battle: PokemonBattle, override val actor: PlayerBattleActor): PlayerBattleTimer {
|
||||
private lateinit var turnStart: Instant
|
||||
private var secondsRemaining = 210
|
||||
private var hasSelected = true
|
||||
|
||||
override fun tick() {
|
||||
if (hasSelected || !::turnStart.isInitialized || battle.ended) return
|
||||
val secondsSinceStart = Duration.between(turnStart, Instant.now()).seconds
|
||||
if (secondsRemaining - secondsSinceStart <= 0) {
|
||||
hasSelected = true
|
||||
timeout()
|
||||
}
|
||||
}
|
||||
|
||||
override fun startSelection() {
|
||||
turnStart = Instant.now()
|
||||
hasSelected = false
|
||||
}
|
||||
|
||||
override fun endSelection() {
|
||||
if (hasSelected || !::turnStart.isInitialized) return
|
||||
hasSelected = true
|
||||
val secondsSinceStart = Duration.between(turnStart, Instant.now()).seconds.toInt()
|
||||
secondsRemaining = secondsRemaining - secondsSinceStart + 10
|
||||
}
|
||||
|
||||
override fun mustChooseBy(): Instant {
|
||||
return turnStart.plusSeconds(secondsRemaining.toLong())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* 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.block.decor
|
||||
|
||||
import com.cobblemon.mod.common.util.rotateShape
|
||||
import com.mojang.serialization.MapCodec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.util.StringRepresentable
|
||||
import net.minecraft.world.InteractionResult
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.item.context.BlockPlaceContext
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.LevelAccessor
|
||||
import net.minecraft.world.level.block.*
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty
|
||||
import net.minecraft.world.level.gameevent.GameEvent
|
||||
import net.minecraft.world.level.material.FluidState
|
||||
import net.minecraft.world.level.material.Fluids
|
||||
import net.minecraft.world.phys.BlockHitResult
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.Shapes
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
|
||||
class ActivatableDecorationBlock(settings: Properties, val type: ActivatableDecorationBlockType) : HorizontalDirectionalBlock(settings), SimpleWaterloggedBlock {
|
||||
enum class ActivatableDecorationBlockType: StringRepresentable {
|
||||
//For basic use, also ignore camelcase errors, it's just dumb
|
||||
CENTERED_8x,
|
||||
//For specific items
|
||||
METRONOME;
|
||||
|
||||
override fun getSerializedName(): String = this.name.lowercase()
|
||||
|
||||
companion object {
|
||||
val CODEC = StringRepresentable.fromEnum(::values)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val CODEC: MapCodec<ActivatableDecorationBlock> = RecordCodecBuilder.mapCodec { it.group(
|
||||
propertiesCodec(),
|
||||
ActivatableDecorationBlockType.CODEC.fieldOf("type").forGetter(ActivatableDecorationBlock::type)
|
||||
).apply(it, ::ActivatableDecorationBlock) }
|
||||
val ACTIVE = BooleanProperty.create("active")
|
||||
|
||||
val CENTERED_8x = Shapes.box(0.25, 0.0, 0.25, 0.75, 0.5, 0.75)
|
||||
val METRONOME_HITBOX = Shapes.box(0.25, 0.0, 0.375, 0.75, 0.8125, 0.75)
|
||||
|
||||
fun getShape(type: ActivatableDecorationBlockType): VoxelShape {
|
||||
return when (type) {
|
||||
ActivatableDecorationBlockType.METRONOME -> METRONOME_HITBOX
|
||||
else -> CENTERED_8x
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
registerDefaultState(stateDefinition.any()
|
||||
.setValue(HORIZONTAL_FACING, Direction.NORTH)
|
||||
.setValue(ACTIVE, false)
|
||||
.setValue(WATERLOGGED, false)
|
||||
)
|
||||
}
|
||||
|
||||
override fun codec(): MapCodec<ActivatableDecorationBlock> = CODEC
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
builder.add(HORIZONTAL_FACING, ACTIVE, WATERLOGGED)
|
||||
}
|
||||
|
||||
override fun getFluidState(blockState: BlockState): FluidState? = if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState)
|
||||
|
||||
override fun updateShape(state: BlockState, direction: Direction, neighborState: BlockState, world: LevelAccessor, pos: BlockPos, neighborPos: BlockPos): BlockState {
|
||||
if (state.getValue(WATERLOGGED)) {
|
||||
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
|
||||
}
|
||||
return if (state.getValue(HORIZONTAL_FACING).opposite == direction && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
|
||||
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
|
||||
}
|
||||
|
||||
override fun getCollisionShape(state: BlockState, level: BlockGetter, pos: BlockPos, context: CollisionContext): VoxelShape {
|
||||
val direction = state.getValue(HORIZONTAL_FACING)
|
||||
return rotateShape(Direction.NORTH, direction, getShape(type))
|
||||
}
|
||||
|
||||
override fun getShape(state: BlockState, level: BlockGetter, pos: BlockPos, context: CollisionContext): VoxelShape {
|
||||
return getCollisionShape(state, level, pos, context).singleEncompassing()
|
||||
}
|
||||
|
||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
||||
val fluidState = context.level.getFluidState(context.clickedPos)
|
||||
return super.getStateForPlacement(context)?.setValue(HORIZONTAL_FACING, context.horizontalDirection.opposite)?.setValue(WATERLOGGED, fluidState.type === Fluids.WATER)
|
||||
}
|
||||
|
||||
override fun useWithoutItem(
|
||||
state: BlockState,
|
||||
level: Level,
|
||||
pos: BlockPos,
|
||||
player: Player,
|
||||
hitResult: BlockHitResult
|
||||
): InteractionResult {
|
||||
if (level.isClientSide) {
|
||||
level.setBlockAndUpdate(pos, state.cycle(ACTIVE))
|
||||
return InteractionResult.SUCCESS
|
||||
} else {
|
||||
this.push(state, level, pos, null as Player?)
|
||||
return InteractionResult.CONSUME
|
||||
}
|
||||
}
|
||||
|
||||
fun push(state: BlockState, level: Level, pos: BlockPos?, player: Player?) {
|
||||
var state = state
|
||||
state = state.cycle(ACTIVE)
|
||||
level.setBlock(pos!!, state, 3)
|
||||
level.gameEvent(player, if (state.getValue(ACTIVE)) GameEvent.BLOCK_ACTIVATE else GameEvent.BLOCK_DEACTIVATE, pos)
|
||||
}
|
||||
|
||||
override fun hasAnalogOutputSignal(state: BlockState): Boolean {
|
||||
return true
|
||||
}
|
||||
//TODO: Replace this forced 4 with a value that can be set by the block, only relevant when more blocks of this class are added.
|
||||
override fun getAnalogOutputSignal(state: BlockState, level: Level, pos: BlockPos): Int {
|
||||
return if (level.getBlockState(pos).getValue(ACTIVE) as Boolean) 4 else 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* 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.block
|
||||
|
||||
import com.cobblemon.mod.common.util.rotateShape
|
||||
import com.mojang.serialization.MapCodec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.util.StringRepresentable
|
||||
import net.minecraft.world.item.context.BlockPlaceContext
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.LevelAccessor
|
||||
import net.minecraft.world.level.block.Block
|
||||
import net.minecraft.world.level.block.Blocks
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
|
||||
import net.minecraft.world.level.material.FluidState
|
||||
import net.minecraft.world.level.material.Fluids
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.Shapes
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
|
||||
class DecorativeItemBlock(settings: Properties, val type: DecorativeItemBlockType): HorizontalDirectionalBlock(settings), SimpleWaterloggedBlock {
|
||||
|
||||
enum class DecorativeItemBlockType: StringRepresentable {
|
||||
//For basic use, also ignore camelcase errors, it's just dumb
|
||||
CENTERED_8x,
|
||||
CENTERED_6x,
|
||||
FLATTENED_8x6,
|
||||
FLATTENED_8x4,
|
||||
FLATTENED_10x4,
|
||||
//For specific items
|
||||
TEACUP,
|
||||
TEAPOT,
|
||||
KNOT,
|
||||
POUCH,
|
||||
NEVERMELT,
|
||||
SCOPE,
|
||||
WIDE,
|
||||
ZOOM;
|
||||
|
||||
override fun getSerializedName(): String = this.name.lowercase()
|
||||
|
||||
companion object {
|
||||
val CODEC = StringRepresentable.fromEnum(::values)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val CODEC: MapCodec<DecorativeItemBlock> = RecordCodecBuilder.mapCodec { it.group(
|
||||
propertiesCodec(),
|
||||
DecorativeItemBlockType.CODEC.fieldOf("type").forGetter(DecorativeItemBlock::type)
|
||||
).apply(it, ::DecorativeItemBlock) }
|
||||
|
||||
val CENTERED_8x = Shapes.box(0.25, 0.0, 0.25, 0.75, 0.5, 0.75)
|
||||
val CENTERED_6x = Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.375, 0.6875)
|
||||
val FLAT6_HITBOX = Shapes.box(0.25, 0.0, 0.25, 0.75, 0.375, 0.75)
|
||||
val FLAT4_HITBOX = Shapes.box(0.25, 0.0, 0.25, 0.75, 0.25, 0.75)
|
||||
val SMOOSHED4_HITBOX = Shapes.box(0.1875, 0.0, 0.1875, 0.8125, 0.25, 0.8125)
|
||||
val TEACUP_HITBOX = Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.25, 0.6875)
|
||||
val TEAPOT_HITBOX = Shapes.box(0.1875, 0.0, 0.1875, 0.8125, 0.625, 0.8125)
|
||||
val KNOT_HITBOX = Shapes.box(0.375, 0.0, 0.375, 0.75, 0.375, 0.75)
|
||||
val POUCH_HITBOX = Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.3125, 0.6875)
|
||||
val NEVERMELT_HITBOX = Shapes.box(0.25, 0.0, 0.3125, 0.6875, 0.25, 0.75)
|
||||
val SCOPE_HITBOX = Shapes.box(0.625, 0.0, 0.4375, 0.9375, 0.125, 0.75)
|
||||
val WIDE_HITBOX = Shapes.box(0.625, 0.0, 0.125, 0.9375, 0.0625, 0.625)
|
||||
val ZOOM_HITBOX = Shapes.box(0.125, 0.0, 0.1875, 0.375, 0.1875, 0.5)
|
||||
|
||||
fun getShape(type: DecorativeItemBlockType): VoxelShape {
|
||||
return when (type) {
|
||||
DecorativeItemBlockType.TEAPOT -> TEAPOT_HITBOX
|
||||
DecorativeItemBlockType.TEACUP -> TEACUP_HITBOX
|
||||
DecorativeItemBlockType.KNOT -> KNOT_HITBOX
|
||||
DecorativeItemBlockType.POUCH -> POUCH_HITBOX
|
||||
DecorativeItemBlockType.NEVERMELT -> NEVERMELT_HITBOX
|
||||
DecorativeItemBlockType.SCOPE -> SCOPE_HITBOX
|
||||
DecorativeItemBlockType.WIDE -> WIDE_HITBOX
|
||||
DecorativeItemBlockType.ZOOM -> ZOOM_HITBOX
|
||||
DecorativeItemBlockType.FLATTENED_10x4 -> SMOOSHED4_HITBOX
|
||||
DecorativeItemBlockType.FLATTENED_8x4 -> FLAT4_HITBOX
|
||||
DecorativeItemBlockType.FLATTENED_8x6 -> FLAT6_HITBOX
|
||||
DecorativeItemBlockType.CENTERED_6x -> CENTERED_6x
|
||||
else -> CENTERED_8x
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
registerDefaultState(stateDefinition.any()
|
||||
.setValue(HORIZONTAL_FACING, Direction.NORTH)
|
||||
.setValue(WATERLOGGED, false))
|
||||
}
|
||||
|
||||
override fun codec(): MapCodec<DecorativeItemBlock> = CODEC
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
builder.add(HORIZONTAL_FACING, WATERLOGGED)
|
||||
}
|
||||
|
||||
override fun getFluidState(blockState: BlockState): FluidState? = if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState)
|
||||
|
||||
override fun updateShape(state: BlockState, direction: Direction, neighborState: BlockState, world: LevelAccessor, pos: BlockPos, neighborPos: BlockPos): BlockState {
|
||||
if (state.getValue(WATERLOGGED)) {
|
||||
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
|
||||
}
|
||||
return if (state.getValue(HORIZONTAL_FACING).opposite == direction && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
|
||||
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
|
||||
}
|
||||
|
||||
override fun getShape(state: BlockState, level: BlockGetter, pos: BlockPos, context: CollisionContext): VoxelShape {
|
||||
val direction = state.getValue(HORIZONTAL_FACING)
|
||||
return rotateShape(Direction.NORTH, direction, getShape(type))
|
||||
}
|
||||
|
||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
||||
val fluidState = context.level.getFluidState(context.clickedPos)
|
||||
return super.getStateForPlacement(context)?.setValue(HORIZONTAL_FACING, context.horizontalDirection.opposite)?.setValue(WATERLOGGED, fluidState.type === Fluids.WATER)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* 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.block
|
||||
|
||||
import com.cobblemon.mod.common.util.rotateShape
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.world.item.context.BlockPlaceContext
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.LevelAccessor
|
||||
import net.minecraft.world.level.LevelReader
|
||||
import net.minecraft.world.level.block.Block
|
||||
import net.minecraft.world.level.block.Blocks
|
||||
import net.minecraft.world.level.block.ButtonBlock
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.AttachFace
|
||||
import net.minecraft.world.level.block.state.properties.BlockSetType
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
|
||||
import net.minecraft.world.level.material.FluidState
|
||||
import net.minecraft.world.level.material.Fluids
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.Shapes
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
|
||||
class EjectButtonBlock(properties: Properties, ticksToStayPressed: Int) : ButtonBlock(BlockSetType.IRON, ticksToStayPressed, properties), SimpleWaterloggedBlock {
|
||||
companion object {
|
||||
val FLOOR_UNPOWERED = Shapes.or(
|
||||
Shapes.box(0.125, 0.0, 0.125, 0.875, 0.1875, 0.875),
|
||||
Shapes.box(0.375, 0.1875, 0.375, 0.625, 0.3125, 0.625) )
|
||||
val FLOOR_POWERED = Shapes.or(
|
||||
Shapes.box(0.125, 0.0, 0.125, 0.875, 0.1875, 0.875),
|
||||
Shapes.box(0.375, 0.1875, 0.375, 0.625, 0.25, 0.625) )
|
||||
val FLOOR_PANEL = Shapes.box(0.125, 0.0, 0.125, 0.875, 0.1875, 0.875)
|
||||
val CEILING_UNPOWERED = Shapes.or(
|
||||
Shapes.box(0.125, 0.8125, 0.125, 0.875, 1.0, 0.875),
|
||||
Shapes.box(0.375, 0.6875, 0.375, 0.625, 0.8125, 0.625) )
|
||||
val CEILING_POWERED = Shapes.or(
|
||||
Shapes.box(0.125, 0.8125, 0.125, 0.875, 1.0, 0.875),
|
||||
Shapes.box(0.375, 0.75, 0.375, 0.625, 0.8125, 0.625) )
|
||||
val CEILING_PANEL = Shapes.box(0.125, 0.8125, 0.125, 0.875, 1.0, 0.875)
|
||||
val WALL_UNPOWERED = Shapes.or(
|
||||
Shapes.box(0.125, 0.125, 0.8125, 0.875, 0.875, 1.0),
|
||||
Shapes.box(0.375, 0.375, 0.6875, 0.625, 0.625, 0.8125) )
|
||||
val WALL_POWERED = Shapes.or(
|
||||
Shapes.box(0.125, 0.125, 0.8125, 0.875, 0.875, 1.0),
|
||||
Shapes.box(0.375, 0.375, 0.75, 0.625, 0.625, 0.8125) )
|
||||
val WALL_PANEL = Shapes.box(0.125, 0.125, 0.8125, 0.875, 0.875, 1.0)
|
||||
}
|
||||
|
||||
init {
|
||||
registerDefaultState(stateDefinition.any()
|
||||
.setValue(FACING, Direction.NORTH)
|
||||
.setValue(FACE, AttachFace.WALL)
|
||||
.setValue(POWERED, false)
|
||||
.setValue(WATERLOGGED, false)
|
||||
)
|
||||
}
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
builder.add(FACING, FACE, POWERED, WATERLOGGED)
|
||||
}
|
||||
|
||||
override fun getFluidState(blockState: BlockState): FluidState? {
|
||||
return if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState);
|
||||
}
|
||||
|
||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
||||
val fluidState = context.level.getFluidState(context.clickedPos)
|
||||
for (direction in context.nearestLookingDirections) {
|
||||
val blockState: BlockState
|
||||
if (direction.getAxis() === Direction.Axis.Y) {
|
||||
blockState = (defaultBlockState()
|
||||
.setValue(FACE, if (direction == Direction.UP) AttachFace.CEILING else AttachFace.FLOOR) as BlockState)
|
||||
.setValue(FACING, context.horizontalDirection.opposite)
|
||||
.setValue(WATERLOGGED, fluidState.type === Fluids.WATER
|
||||
) as BlockState
|
||||
} else {
|
||||
blockState = (defaultBlockState()
|
||||
.setValue(FACE, AttachFace.WALL) as BlockState)
|
||||
.setValue(FACING, direction.opposite)
|
||||
.setValue(WATERLOGGED, fluidState.type === Fluids.WATER
|
||||
) as BlockState
|
||||
}
|
||||
if (blockState.canSurvive(context.getLevel(), context.getClickedPos())) {
|
||||
return blockState
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getShape(state: BlockState, blockGetter: BlockGetter, pos: BlockPos, collisionContext: CollisionContext): VoxelShape {
|
||||
val direction = state.getValue(FACING)
|
||||
return when (state.getValue(FACE)) {
|
||||
AttachFace.FLOOR -> if (state.getValue(POWERED)) {FLOOR_POWERED} else {FLOOR_UNPOWERED}
|
||||
AttachFace.WALL ->
|
||||
when (direction) {
|
||||
Direction.NORTH, Direction.UP, Direction.DOWN -> if (state.getValue(POWERED)) {WALL_POWERED} else {WALL_UNPOWERED}
|
||||
else -> rotateShape(Direction.NORTH, direction, if (state.getValue(POWERED)) {WALL_POWERED} else {WALL_UNPOWERED})
|
||||
}
|
||||
AttachFace.CEILING -> if (state.getValue(POWERED)) {CEILING_POWERED} else {CEILING_UNPOWERED}
|
||||
}
|
||||
}
|
||||
override fun getCollisionShape(state: BlockState, level: BlockGetter, pos: BlockPos, context: CollisionContext): VoxelShape {
|
||||
val direction = state.getValue(FACING)
|
||||
return when (state.getValue(FACE)) {
|
||||
AttachFace.FLOOR -> FLOOR_PANEL
|
||||
AttachFace.WALL -> when (direction) {
|
||||
Direction.NORTH, Direction.UP, Direction.DOWN -> WALL_PANEL
|
||||
else -> rotateShape(Direction.NORTH, direction, WALL_PANEL)
|
||||
}
|
||||
AttachFace.CEILING -> CEILING_PANEL
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateShape(state: BlockState, direction: Direction, neighborState: BlockState, world: LevelAccessor, pos: BlockPos, neighborPos: BlockPos): BlockState {
|
||||
if (state.getValue(WATERLOGGED)) {
|
||||
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
|
||||
}
|
||||
return if (getConnectedDirection(state).opposite == direction && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
|
||||
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
|
||||
}
|
||||
|
||||
override fun canSurvive(state: BlockState, level: LevelReader, pos: BlockPos): Boolean {
|
||||
return if (state.getValue(FACE) != AttachFace.WALL) {
|
||||
val direction = getConnectedDirection(state)
|
||||
canSupportCenter(level, pos.relative(direction.opposite), direction)
|
||||
} else {
|
||||
level.getBlockState(pos.relative(state.getValue(FACING).opposite)).isSolid
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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.block
|
||||
|
||||
import com.cobblemon.mod.common.util.rotateShape
|
||||
import com.mojang.serialization.MapCodec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.properties.AttachFace
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.Shapes
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
|
||||
class GalaricaWreathBlock(properties: Properties) : SixFaceRotationalBlock(properties) {
|
||||
companion object {
|
||||
val CODEC: MapCodec<GalaricaWreathBlock> = RecordCodecBuilder.mapCodec {
|
||||
it.group(propertiesCodec()).apply(it, ::GalaricaWreathBlock)
|
||||
}
|
||||
|
||||
val FLOOR_NORTH = Shapes.box(0.125, 0.0, 0.125, 0.875, 0.25, 0.875)
|
||||
val WALL_NORTH = Shapes.box(0.125, 0.125, 0.75, 0.875, 0.875, 1.0)
|
||||
val CEILING_NORTH = Shapes.box(0.125, 0.125, 0.375, 0.875, 0.625, 0.5625)
|
||||
}
|
||||
|
||||
init {
|
||||
registerDefaultState(stateDefinition.any()
|
||||
.setValue(FACING, Direction.NORTH)
|
||||
.setValue(FACE, AttachFace.WALL)
|
||||
.setValue(WATERLOGGED, false)
|
||||
)
|
||||
}
|
||||
|
||||
override fun codec(): MapCodec<GalaricaWreathBlock> = CODEC
|
||||
|
||||
override fun getShape(state: BlockState, blockGetter: BlockGetter, pos: BlockPos, collisionContext: CollisionContext): VoxelShape {
|
||||
val direction = state.getValue(FACING)
|
||||
return when (state.getValue(FACE)) {
|
||||
AttachFace.FLOOR ->
|
||||
if (direction.axis === Direction.Axis.X) {
|
||||
rotateShape(Direction.NORTH, Direction.WEST, FLOOR_NORTH)
|
||||
} else FLOOR_NORTH
|
||||
AttachFace.WALL ->
|
||||
when (direction) {
|
||||
Direction.NORTH, Direction.UP, Direction.DOWN -> WALL_NORTH
|
||||
else -> rotateShape(Direction.NORTH, direction, WALL_NORTH)
|
||||
}
|
||||
AttachFace.CEILING ->
|
||||
if (direction.axis === Direction.Axis.X) {
|
||||
rotateShape(Direction.NORTH, Direction.WEST, CEILING_NORTH)
|
||||
} else CEILING_NORTH
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.block
|
||||
|
||||
import com.cobblemon.mod.common.util.rotateShape
|
||||
import com.mojang.serialization.MapCodec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.LevelReader
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.properties.AttachFace
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.Shapes
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
|
||||
class MagnetBlock(properties: Properties) : SixFaceRotationalBlock(properties) {
|
||||
companion object {
|
||||
val CODEC: MapCodec<MagnetBlock> = RecordCodecBuilder.mapCodec {
|
||||
it.group(propertiesCodec()).apply(it, ::MagnetBlock)
|
||||
}
|
||||
|
||||
val FLOOR_NORTH = Shapes.box(0.25, 0.0, 0.25, 0.75, 0.1875, 0.75)
|
||||
val WALL_NORTH = Shapes.box(0.25, 0.25, 0.8125, 0.75, 0.75, 1.0)
|
||||
val CEILING_NORTH = Shapes.box(0.25, 0.8125, 0.25, 0.75, 1.0, 0.75)
|
||||
}
|
||||
|
||||
init {
|
||||
registerDefaultState(stateDefinition.any()
|
||||
.setValue(FACING, Direction.NORTH)
|
||||
.setValue(FACE, AttachFace.WALL)
|
||||
.setValue(WATERLOGGED, false)
|
||||
)
|
||||
}
|
||||
|
||||
override fun codec(): MapCodec<MagnetBlock> = CODEC
|
||||
|
||||
override fun getShape(state: BlockState, blockGetter: BlockGetter, pos: BlockPos, collisionContext: CollisionContext): VoxelShape {
|
||||
val direction = state.getValue(FACING)
|
||||
return when (state.getValue(FACE)) {
|
||||
AttachFace.FLOOR ->
|
||||
if (direction.axis === Direction.Axis.X) {
|
||||
rotateShape(Direction.NORTH, Direction.WEST, FLOOR_NORTH)
|
||||
} else FLOOR_NORTH
|
||||
AttachFace.WALL ->
|
||||
when (direction) {
|
||||
Direction.NORTH, Direction.UP, Direction.DOWN -> WALL_NORTH
|
||||
else -> rotateShape(Direction.NORTH, direction, WALL_NORTH)
|
||||
}
|
||||
AttachFace.CEILING ->
|
||||
if (direction.axis === Direction.Axis.X) {
|
||||
rotateShape(Direction.NORTH, Direction.WEST, CEILING_NORTH)
|
||||
} else CEILING_NORTH
|
||||
}
|
||||
}
|
||||
|
||||
override fun canSurvive(state: BlockState, level: LevelReader, pos: BlockPos): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.block
|
||||
|
||||
import com.cobblemon.mod.common.util.rotateShape
|
||||
import com.mojang.serialization.MapCodec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.LevelReader
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.properties.AttachFace
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.Shapes
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
|
||||
class OrbBlock(properties: Properties) : SixFaceRotationalBlock(properties) {
|
||||
companion object {
|
||||
val CODEC: MapCodec<OrbBlock> = RecordCodecBuilder.mapCodec {
|
||||
it.group(propertiesCodec()).apply(it, ::OrbBlock)
|
||||
}
|
||||
|
||||
val FLOOR_NORTH = Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.375, 0.6875)
|
||||
val WALL_NORTH = Shapes.box(0.3125, 0.3125, 0.625, 0.6875, 0.6875, 1.0)
|
||||
val CEILING_NORTH = Shapes.box(0.3125, 0.625, 0.375, 0.6875, 1.0, 0.6875)
|
||||
}
|
||||
|
||||
init {
|
||||
registerDefaultState(stateDefinition.any()
|
||||
.setValue(FACING, Direction.NORTH)
|
||||
.setValue(FACE, AttachFace.WALL)
|
||||
.setValue(WATERLOGGED, false)
|
||||
)
|
||||
}
|
||||
|
||||
override fun codec(): MapCodec<OrbBlock> = CODEC
|
||||
|
||||
override fun getShape(state: BlockState, blockGetter: BlockGetter, pos: BlockPos, collisionContext: CollisionContext): VoxelShape {
|
||||
val direction = state.getValue(FACING)
|
||||
return when (state.getValue(FACE)) {
|
||||
AttachFace.FLOOR ->
|
||||
if (direction.axis === Direction.Axis.X) {
|
||||
rotateShape(Direction.NORTH, Direction.WEST, FLOOR_NORTH)
|
||||
} else FLOOR_NORTH
|
||||
AttachFace.WALL ->
|
||||
when (direction) {
|
||||
Direction.NORTH, Direction.UP, Direction.DOWN -> WALL_NORTH
|
||||
else -> rotateShape(Direction.NORTH, direction, WALL_NORTH)
|
||||
}
|
||||
AttachFace.CEILING ->
|
||||
if (direction.axis === Direction.Axis.X) {
|
||||
rotateShape(Direction.NORTH, Direction.WEST, CEILING_NORTH)
|
||||
} else CEILING_NORTH
|
||||
}
|
||||
}
|
||||
|
||||
override fun canSurvive(state: BlockState, level: LevelReader, pos: BlockPos): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -13,25 +13,15 @@ import com.mojang.serialization.MapCodec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.world.item.context.BlockPlaceContext
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.LevelAccessor
|
||||
import net.minecraft.world.level.LevelReader
|
||||
import net.minecraft.world.level.block.Block
|
||||
import net.minecraft.world.level.block.Blocks
|
||||
import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.AttachFace
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
|
||||
import net.minecraft.world.level.material.FluidState
|
||||
import net.minecraft.world.level.material.Fluids
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.Shapes
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
|
||||
class PlaqueBlock(properties : Properties) : FaceAttachedHorizontalDirectionalBlock(properties), SimpleWaterloggedBlock {
|
||||
class PlaqueBlock(properties : Properties) : SixFaceRotationalBlock(properties) {
|
||||
companion object {
|
||||
val CODEC: MapCodec<PlaqueBlock> = RecordCodecBuilder.mapCodec {
|
||||
it.group(propertiesCodec()).apply(it, ::PlaqueBlock)
|
||||
@@ -54,40 +44,6 @@ class PlaqueBlock(properties : Properties) : FaceAttachedHorizontalDirectionalBl
|
||||
)
|
||||
}
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
builder.add(FACING, FACE, WATERLOGGED)
|
||||
}
|
||||
|
||||
override fun getFluidState(blockState: BlockState): FluidState? {
|
||||
return if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState);
|
||||
}
|
||||
|
||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
||||
val fluidState = context.level.getFluidState(context.clickedPos)
|
||||
for (direction in context.nearestLookingDirections) {
|
||||
val blockState: BlockState
|
||||
if (direction.getAxis() === Direction.Axis.Y) {
|
||||
blockState = (defaultBlockState()
|
||||
.setValue(FACE, if (direction == Direction.UP) AttachFace.CEILING else AttachFace.FLOOR) as BlockState)
|
||||
.setValue(FACING, context.horizontalDirection.opposite)
|
||||
.setValue(WATERLOGGED, fluidState.type === Fluids.WATER
|
||||
) as BlockState
|
||||
} else {
|
||||
blockState = (defaultBlockState()
|
||||
.setValue(FACE, AttachFace.WALL) as BlockState)
|
||||
.setValue(FACING, direction.opposite)
|
||||
.setValue(WATERLOGGED, fluidState.type === Fluids.WATER
|
||||
) as BlockState
|
||||
|
||||
}
|
||||
|
||||
if (blockState.canSurvive(context.getLevel(), context.getClickedPos())) {
|
||||
return blockState
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun codec(): MapCodec<PlaqueBlock> = CODEC
|
||||
|
||||
override fun getShape(state: BlockState, blockGetter: BlockGetter, pos: BlockPos, collisionContext: CollisionContext): VoxelShape {
|
||||
@@ -108,21 +64,4 @@ class PlaqueBlock(properties : Properties) : FaceAttachedHorizontalDirectionalBl
|
||||
} else CEILING_NORTH
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateShape(state: BlockState, direction: Direction, neighborState: BlockState, world: LevelAccessor, pos: BlockPos, neighborPos: BlockPos): BlockState {
|
||||
if (state.getValue(WATERLOGGED)) {
|
||||
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
|
||||
}
|
||||
return if (getConnectedDirection(state).opposite == direction && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
|
||||
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
|
||||
}
|
||||
|
||||
override fun canSurvive(state: BlockState, level: LevelReader, pos: BlockPos): Boolean {
|
||||
return if (state.getValue(FACE) == AttachFace.CEILING) {
|
||||
val direction = getConnectedDirection(state)
|
||||
canSupportCenter(level, pos.relative(direction.opposite), direction)
|
||||
} else {
|
||||
super.canSurvive(state, level, pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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.block.decor
|
||||
|
||||
import com.mojang.serialization.MapCodec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.world.item.context.BlockPlaceContext
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.LevelAccessor
|
||||
import net.minecraft.world.level.LevelReader
|
||||
import net.minecraft.world.level.block.*
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock.FACING
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
|
||||
import net.minecraft.world.level.block.state.properties.Property
|
||||
import net.minecraft.world.level.material.FluidState
|
||||
import net.minecraft.world.level.material.Fluids
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.Shapes
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
|
||||
class RingTargetBlock(settings: Properties) : TargetBlock(settings), SimpleWaterloggedBlock {
|
||||
init {
|
||||
registerDefaultState(stateDefinition.any()
|
||||
.setValue(FACING, Direction.NORTH)
|
||||
.setValue(WATERLOGGED, false)
|
||||
.setValue(OUTPUT_POWER, 0))
|
||||
}
|
||||
|
||||
override fun getStateForPlacement(ctx: BlockPlaceContext): BlockState? {
|
||||
var blockState = defaultBlockState()
|
||||
.setValue(WATERLOGGED, ctx.level.getFluidState(ctx.clickedPos).type == Fluids.WATER)
|
||||
val worldView = ctx.level
|
||||
val blockPos = ctx.clickedPos
|
||||
ctx.nearestLookingDirections.forEach { direction ->
|
||||
if (direction.axis.isHorizontal) {
|
||||
blockState = blockState.setValue(FACING, direction.opposite) as BlockState
|
||||
if (blockState.canSurvive(worldView, blockPos)) {
|
||||
return blockState
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getFluidState(blockState: BlockState): FluidState? {
|
||||
return if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState)
|
||||
}
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
builder.add(FACING)
|
||||
builder.add(WATERLOGGED)
|
||||
builder.add(*arrayOf<Property<*>>(OUTPUT_POWER))
|
||||
}
|
||||
|
||||
override fun getShape(
|
||||
state: BlockState,
|
||||
blockGetter: BlockGetter,
|
||||
pos: BlockPos,
|
||||
collisionContext: CollisionContext
|
||||
): VoxelShape {
|
||||
return when (state.getValue(FACING)) {
|
||||
Direction.SOUTH -> FULL_PLANE_SOUTH
|
||||
Direction.WEST -> FULL_PLANE_WEST
|
||||
Direction.EAST -> FULL_PLANE_EAST
|
||||
else -> FULL_PLANE_NORTH
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateShape(
|
||||
state: BlockState,
|
||||
direction: Direction,
|
||||
neighborState: BlockState,
|
||||
world: LevelAccessor,
|
||||
pos: BlockPos,
|
||||
neighborPos: BlockPos
|
||||
): BlockState {
|
||||
if (state.getValue(WATERLOGGED)) {
|
||||
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
|
||||
}
|
||||
return if (direction.opposite == state.getValue(FACING) && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
|
||||
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
|
||||
}
|
||||
|
||||
override fun rotate(state: BlockState, rotation: Rotation): BlockState {
|
||||
return state.setValue(FACING, rotation.rotate(state.getValue(FACING)))
|
||||
}
|
||||
|
||||
override fun canSurvive(state: BlockState, level: LevelReader, pos: BlockPos): Boolean {
|
||||
return level.getBlockState(pos.relative(state.getValue(FACING).opposite)).isSolid
|
||||
}
|
||||
|
||||
companion object {
|
||||
val CODEC: MapCodec<RingTargetBlock> = RecordCodecBuilder.mapCodec {
|
||||
it.group(
|
||||
propertiesCodec()
|
||||
).apply(it, ::RingTargetBlock) }
|
||||
|
||||
val OUTPUT_POWER = BlockStateProperties.POWER;
|
||||
|
||||
val FULL_PLANE_NORTH = Shapes.box(0.0, 0.0, 0.925, 1.0, 1.0, 1.0)
|
||||
val FULL_PLANE_WEST = Shapes.box(0.925, 0.0, 0.0, 1.0, 1.0, 1.0)
|
||||
val FULL_PLANE_SOUTH = Shapes.box(0.0, 0.0, 0.0, 1.0, 1.0, 0.075)
|
||||
val FULL_PLANE_EAST = Shapes.box(0.0, 0.0, 0.0, 0.075, 1.0, 1.0)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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.block
|
||||
|
||||
import com.mojang.serialization.MapCodec
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.world.item.context.BlockPlaceContext
|
||||
import net.minecraft.world.level.LevelAccessor
|
||||
import net.minecraft.world.level.LevelReader
|
||||
import net.minecraft.world.level.block.Block
|
||||
import net.minecraft.world.level.block.Blocks
|
||||
import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.AttachFace
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
|
||||
import net.minecraft.world.level.material.FluidState
|
||||
import net.minecraft.world.level.material.Fluids
|
||||
|
||||
open class SixFaceRotationalBlock(properties : Properties) : FaceAttachedHorizontalDirectionalBlock(properties), SimpleWaterloggedBlock {
|
||||
companion object {
|
||||
val CODEC = simpleCodec(::SixFaceRotationalBlock)
|
||||
}
|
||||
|
||||
override fun codec(): MapCodec<out SixFaceRotationalBlock> = CODEC
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
builder.add(FACING, FACE, WATERLOGGED)
|
||||
}
|
||||
|
||||
override fun getFluidState(blockState: BlockState): FluidState? {
|
||||
return if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState);
|
||||
}
|
||||
|
||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
||||
val fluidState = context.level.getFluidState(context.clickedPos)
|
||||
for (direction in context.nearestLookingDirections) {
|
||||
val blockState: BlockState
|
||||
if (direction.getAxis() === Direction.Axis.Y) {
|
||||
blockState = (defaultBlockState()
|
||||
.setValue(FACE, if (direction == Direction.UP) AttachFace.CEILING else AttachFace.FLOOR) as BlockState)
|
||||
.setValue(FACING, context.horizontalDirection.opposite)
|
||||
.setValue(WATERLOGGED, fluidState.type === Fluids.WATER
|
||||
) as BlockState
|
||||
} else {
|
||||
blockState = (defaultBlockState()
|
||||
.setValue(FACE, AttachFace.WALL) as BlockState)
|
||||
.setValue(FACING, direction.opposite)
|
||||
.setValue(WATERLOGGED, fluidState.type === Fluids.WATER
|
||||
) as BlockState
|
||||
|
||||
}
|
||||
|
||||
if (blockState.canSurvive(context.getLevel(), context.getClickedPos())) {
|
||||
return blockState
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun updateShape(state: BlockState, direction: Direction, neighborState: BlockState, world: LevelAccessor, pos: BlockPos, neighborPos: BlockPos): BlockState {
|
||||
if (state.getValue(WATERLOGGED)) {
|
||||
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
|
||||
}
|
||||
return if (getConnectedDirection(state).opposite == direction && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
|
||||
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
|
||||
}
|
||||
|
||||
override fun canSurvive(state: BlockState, level: LevelReader, pos: BlockPos): Boolean {
|
||||
return if (state.getValue(FACE) == AttachFace.CEILING) {
|
||||
val direction = getConnectedDirection(state)
|
||||
canSupportCenter(level, pos.relative(direction.opposite), direction)
|
||||
} else if (state.getValue(FACE) == AttachFace.WALL) {
|
||||
level.getBlockState(pos.relative(state.getValue(FACING).opposite)).isSolid
|
||||
} else {
|
||||
super.canSurvive(state, level, pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,13 @@ class StackableItemBlock(settings: Properties, val type: StackableItemBlockType)
|
||||
ETHER,
|
||||
MAX_POTION,
|
||||
POTION,
|
||||
STATUS_RESTORE;
|
||||
STATUS_RESTORE,
|
||||
VITAMIN,
|
||||
METAL_COAT,
|
||||
IRON_BALL,
|
||||
THROAT_SPRAY,
|
||||
UPGRADE,
|
||||
DICE;
|
||||
|
||||
override fun getSerializedName(): String = this.name.lowercase()
|
||||
|
||||
@@ -57,98 +63,78 @@ class StackableItemBlock(settings: Properties, val type: StackableItemBlockType)
|
||||
StackableItemBlockType.CODEC.fieldOf("type").forGetter(StackableItemBlock::type)
|
||||
).apply(it, ::StackableItemBlock) }
|
||||
|
||||
val northShapeMap: Map<StackableItemBlockType, List<VoxelShape>> = mapOf(
|
||||
StackableItemBlockType.BATTLE_ITEM to listOf(
|
||||
Shapes.box(0.34375, 0.0, 0.34375, 0.65625, 0.4375, 0.65625),
|
||||
Shapes.or(
|
||||
Shapes.box(0.09375, 0.0, 0.34375, 0.40625, 0.4375, 0.65625),
|
||||
Shapes.box(0.59375, 0.0, 0.40625, 0.90625, 0.4375, 0.71875)
|
||||
val northShapeMap: Map<StackableItemBlockType, List<VoxelShape>>
|
||||
get() = mapOf(
|
||||
StackableItemBlockType.BATTLE_ITEM to listOf(
|
||||
Shapes.box(0.34375, 0.0, 0.34375, 0.65625, 0.4375, 0.65625),
|
||||
Shapes.box(0.09375, 0.0, 0.34375, 0.90625, 0.4375, 0.71875),
|
||||
Shapes.box(0.09375, 0.0, 0.09375, 0.90625, 0.4375, 0.90625),
|
||||
Shapes.box(0.09375, 0.0, 0.09375, 0.96875, 0.4375, 0.90625)
|
||||
),
|
||||
Shapes.or(
|
||||
Shapes.box(0.59375, 0.0, 0.59375, 0.90625, 0.4375, 0.90625),
|
||||
Shapes.box(0.09375, 0.0, 0.53125, 0.40625, 0.4375, 0.84375),
|
||||
Shapes.box(0.34375, 0.0, 0.09375, 0.65625, 0.4375, 0.40625)
|
||||
StackableItemBlockType.ETHER to listOf(
|
||||
Shapes.box(0.375, 0.0, 0.3125, 0.625, 0.5, 0.6875),
|
||||
Shapes.box(0.125, 0.0, 0.3125, 0.875, 0.5, 0.75),
|
||||
Shapes.box(0.125, 0.0, 0.125, 0.875, 0.5, 1.0),
|
||||
Shapes.box(0.125, 0.0, 0.0625, 0.9375, 0.5, 1.0)
|
||||
),
|
||||
Shapes.or(
|
||||
Shapes.box(0.09375, 0.0, 0.09375, 0.40625, 0.4375, 0.40625),
|
||||
Shapes.box(0.59375, 0.0, 0.15625, 0.90625, 0.4375, 0.46875),
|
||||
Shapes.box(0.65625, 0.0, 0.59375, 0.96875, 0.4375, 0.90625),
|
||||
Shapes.box(0.15625, 0.0, 0.53125, 0.46875, 0.4375, 0.84375)
|
||||
)
|
||||
),
|
||||
StackableItemBlockType.ETHER to listOf(
|
||||
Shapes.box(0.375, 0.0, 0.3125, 0.625, 0.5, 0.6875),
|
||||
Shapes.or(
|
||||
Shapes.box(0.625, 0.0, 0.375, 0.875, 0.5, 0.75),
|
||||
Shapes.box(0.125, 0.0, 0.3125, 0.375, 0.5, 0.6875)
|
||||
StackableItemBlockType.MAX_POTION to listOf(
|
||||
Shapes.box(0.34375, 0.0, 0.3125, 0.65625, 0.5, 0.6875),
|
||||
Shapes.box(0.09375, 0.0, 0.3125, 0.90625, 0.5, 0.75),
|
||||
Shapes.box(0.09375, 0.0, 0.0625, 0.90625, 0.5, 1.0),
|
||||
Shapes.box(0.09375, 0.0, 0.0625, 0.96875, 0.5, 1.0)
|
||||
),
|
||||
Shapes.or(
|
||||
Shapes.box(0.375, 0.0, 0.125, 0.625, 0.5, 0.5),
|
||||
Shapes.box(0.125, 0.0, 0.5625, 0.375, 0.5, 0.9375),
|
||||
Shapes.box(0.625, 0.0, 0.625, 0.875, 0.5, 1.0)
|
||||
StackableItemBlockType.POTION to listOf(
|
||||
Shapes.box(0.375, 0.0, 0.3125, 0.625, 0.5625, 0.75),
|
||||
Shapes.box(0.125, 0.0, 0.3125, 0.875, 0.5625, 0.8125),
|
||||
Shapes.box(0.125, 0.0, 0.0625, 0.875, 0.5625, 1.0),
|
||||
Shapes.box(0.125, 0.0, 0.0, 0.9375, 0.5625, 1.0)
|
||||
),
|
||||
Shapes.or(
|
||||
Shapes.box(0.125, 0.0, 0.0625, 0.375, 0.5, 0.4375),
|
||||
Shapes.box(0.625, 0.0, 0.125, 0.875, 0.5, 0.5),
|
||||
Shapes.box(0.6875, 0.0, 0.625, 0.9375, 0.5, 1.0),
|
||||
Shapes.box(0.1875, 0.0, 0.5625, 0.4375, 0.5, 0.9375)
|
||||
)
|
||||
),
|
||||
StackableItemBlockType.MAX_POTION to listOf(
|
||||
Shapes.box(0.34375, 0.0, 0.3125, 0.65625, 0.5, 0.6875),
|
||||
Shapes.or(
|
||||
Shapes.box(0.09375, 0.0, 0.3125, 0.40625, 0.5, 0.6875),
|
||||
Shapes.box(0.59375, 0.0, 0.375, 0.90625, 0.5, 0.75)
|
||||
StackableItemBlockType.STATUS_RESTORE to listOf(
|
||||
Shapes.box(0.375, 0.0, 0.3125, 0.625, 0.4375, 0.6875),
|
||||
Shapes.box(0.125, 0.0, 0.3125, 0.875, 0.4375, 0.75),
|
||||
Shapes.box(0.125, 0.0, 0.0625, 0.875, 0.4375, 0.9375),
|
||||
Shapes.box(0.125, 0.0, 0.0, 0.9375, 0.4375, 0.9375)
|
||||
),
|
||||
Shapes.or(
|
||||
Shapes.box(0.34375, 0.0, 0.0625, 0.65625, 0.5, 0.4375),
|
||||
Shapes.box(0.09375, 0.0, 0.5625, 0.40625, 0.5, 0.9375),
|
||||
Shapes.box(0.59375, 0.0, 0.625, 0.90625, 0.5, 1.0)
|
||||
StackableItemBlockType.METAL_COAT to listOf(
|
||||
Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.375, 0.6875),
|
||||
Shapes.box(0.125, 0.0, 0.125, 0.875, 0.375, 0.875),
|
||||
Shapes.box(0.125, 0.0, 0.0625, 0.9375, 0.375, 0.875),
|
||||
Shapes.box(0.0625, 0.0, 0.0625, 0.9375, 0.375, 0.9375)
|
||||
),
|
||||
Shapes.or(
|
||||
Shapes.box(0.09375, 0.0, 0.0625, 0.40625, 0.5, 0.4375),
|
||||
Shapes.box(0.15625, 0.0, 0.5625, 0.46875, 0.5, 0.9375),
|
||||
Shapes.box(0.65625, 0.0, 0.625, 0.96875, 0.5, 1.0),
|
||||
Shapes.box(0.59375, 0.0, 0.125, 0.90625, 0.5, 0.5)
|
||||
).singleEncompassing()
|
||||
),
|
||||
StackableItemBlockType.POTION to listOf(
|
||||
Shapes.box(0.375, 0.0, 0.3125, 0.625, 0.5625, 0.75),
|
||||
Shapes.or(
|
||||
Shapes.box(0.125, 0.0, 0.3125, 0.375, 0.5625, 0.75),
|
||||
Shapes.box(0.625, 0.0, 0.375, 0.875, 0.5625, 0.8125)
|
||||
StackableItemBlockType.VITAMIN to listOf(
|
||||
Shapes.box(0.375, 0.0, 0.375, 0.625, 0.4375, 0.625),
|
||||
Shapes.box(0.1875, 0.0, 0.3125, 0.8125, 0.4375, 0.6875),
|
||||
Shapes.box(0.1875, 0.0, 0.1875, 0.8125, 0.4375, 0.8125),
|
||||
Shapes.box(0.125, 0.0, 0.125, 0.875, 0.4375, 0.875)
|
||||
),
|
||||
Shapes.or(
|
||||
Shapes.box(0.375, 0.0, 0.0625, 0.625, 0.5625, 0.5),
|
||||
Shapes.box(0.625, 0.0, 0.5625, 0.875, 0.5625, 1.0),
|
||||
Shapes.box(0.125, 0.0, 0.5, 0.375, 0.5625, 0.9375)
|
||||
StackableItemBlockType.IRON_BALL to listOf(
|
||||
Shapes.box(0.25, 0.0, 0.25, 0.75, 0.4375, 0.75),
|
||||
Shapes.box(0.0, 0.0, 0.1875, 1.0, 0.4375, 0.8125),
|
||||
Shapes.box(0.0, 0.0, 0.0, 1.0, 0.4375, 1.0),
|
||||
Shapes.or(
|
||||
Shapes.box(0.0, 0.0, 0.0, 1.0, 0.4375, 1.0),
|
||||
Shapes.box(0.25, 0.4375, 0.3125, 0.6875, 0.875, 0.75)
|
||||
)
|
||||
),
|
||||
Shapes.or(
|
||||
Shapes.box(0.125, 0.0, 0.0, 0.375, 0.5625, 0.4375),
|
||||
Shapes.box(0.625, 0.0, 0.0625, 0.875, 0.5625, 0.5),
|
||||
Shapes.box(0.6875, 0.0, 0.5625, 0.9375, 0.5625, 1.0),
|
||||
Shapes.box(0.1875, 0.0, 0.5, 0.4375, 0.5625, 0.9375)
|
||||
)
|
||||
),
|
||||
StackableItemBlockType.STATUS_RESTORE to listOf(
|
||||
Shapes.box(0.375, 0.0, 0.3125, 0.625, 0.4375, 0.6875),
|
||||
Shapes.or(
|
||||
Shapes.box(0.125, 0.0, 0.3125, 0.375, 0.4375, 0.75),
|
||||
Shapes.box(0.625, 0.0, 0.375, 0.875, 0.4375, 0.75)
|
||||
StackableItemBlockType.THROAT_SPRAY to listOf(
|
||||
Shapes.box(0.375, 0.0, 0.1875, 0.625, 0.5625, 0.75),
|
||||
Shapes.box(0.125, 0.0, 0.1875, 0.875, 0.5625, 0.8125),
|
||||
Shapes.box(0.125, 0.0, 0.0, 0.875, 0.5625, 1.0),
|
||||
Shapes.box(0.075, 0.0, 0.0, 0.9375, 0.5625, 1.0)
|
||||
),
|
||||
Shapes.or(
|
||||
Shapes.box(0.125, 0.0, 0.5, 0.375, 0.4375, 0.875),
|
||||
Shapes.box(0.625, 0.0, 0.5625, 0.875, 0.4375, 0.9375),
|
||||
Shapes.box(0.375, 0.0, 0.0625, 0.625, 0.4375, 0.4375)
|
||||
StackableItemBlockType.UPGRADE to listOf(
|
||||
Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.125, 0.6875),
|
||||
Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.25, 0.6875),
|
||||
Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.375, 0.6875),
|
||||
Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.5, 0.6875)
|
||||
),
|
||||
Shapes.or(
|
||||
Shapes.box(0.1875, 0.0, 0.5, 0.4375, 0.4375, 0.875),
|
||||
Shapes.box(0.125, 0.0, 0.0, 0.375, 0.4375, 0.375),
|
||||
Shapes.box(0.625, 0.0, 0.0625, 0.875, 0.4375, 0.4375),
|
||||
Shapes.box(0.6875, 0.0, 0.5625, 0.9375, 0.4375, 0.9375)
|
||||
StackableItemBlockType.DICE to listOf(
|
||||
Shapes.box(0.125, 0.0, 0.6875, 0.3125, 0.1875, 0.875),
|
||||
Shapes.box(0.125, 0.0, 0.625, 0.5625, 0.1875, 0.875),
|
||||
Shapes.box(0.125, 0.0, 0.4375, 0.5625, 0.1875, 0.875),
|
||||
Shapes.box(0.125, 0.0, 0.4375, 0.5625, 0.375, 0.875)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
fun getShape(type: StackableItemBlockType, count: Int): VoxelShape = northShapeMap[type]?.let { list -> list[(count - 1).coerceIn(0, list.lastIndex)] } ?: Shapes.block()
|
||||
fun getMaxAmount(type: StackableItemBlockType): Int = min(northShapeMap[type]?.size ?: 1 , MAX_AMOUNT)
|
||||
@@ -184,7 +170,7 @@ class StackableItemBlock(settings: Properties, val type: StackableItemBlockType)
|
||||
}
|
||||
|
||||
override fun getShape(state: BlockState, level: BlockGetter, pos: BlockPos, context: CollisionContext): VoxelShape {
|
||||
return getCollisionShape(state, level, pos, context).singleEncompassing()
|
||||
return getCollisionShape(state, level, pos, context)
|
||||
}
|
||||
|
||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
package com.cobblemon.mod.common.client
|
||||
|
||||
import com.cobblemon.mod.common.client.battle.ClientBattleInformationRepository
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon.LOGGER
|
||||
import com.cobblemon.mod.common.CobblemonBlockEntities
|
||||
import com.cobblemon.mod.common.CobblemonBlocks
|
||||
@@ -24,6 +22,7 @@ import com.cobblemon.mod.common.api.storage.player.client.ClientPokedexManager
|
||||
import com.cobblemon.mod.common.api.storage.player.client.ClientTMMoveManager
|
||||
import com.cobblemon.mod.common.api.tags.CobblemonItemTags
|
||||
import com.cobblemon.mod.common.block.entity.TintBlockEntity
|
||||
import com.cobblemon.mod.common.block.sign.CobblemonSignBlock
|
||||
import com.cobblemon.mod.common.client.battle.ClientBattle
|
||||
import com.cobblemon.mod.common.client.gui.PartyOverlay
|
||||
import com.cobblemon.mod.common.client.gui.PartyOverlayDataControl
|
||||
@@ -126,7 +125,6 @@ object CobblemonClient {
|
||||
storage.onLogout()
|
||||
battle = null
|
||||
battleOverlay.onLogout()
|
||||
ClientBattleInformationRepository.clear()
|
||||
ClientTaskTracker.clear()
|
||||
checkedStarterScreen = false
|
||||
overlay.resetAttachedToast()
|
||||
@@ -241,6 +239,12 @@ object CobblemonClient {
|
||||
CobblemonBlocks.POKE_CAKE
|
||||
)
|
||||
|
||||
this.implementation.registerBlockRenderType(
|
||||
RenderType.translucent(),
|
||||
CobblemonBlocks.UPGRADE,
|
||||
CobblemonBlocks.DUBIOUS_DISC
|
||||
)
|
||||
|
||||
this.implementation.registerBlockRenderType(
|
||||
RenderType.cutout(),
|
||||
CobblemonBlocks.GILDED_CHEST,
|
||||
@@ -386,7 +390,31 @@ object CobblemonClient {
|
||||
CobblemonBlocks.X_SP_ATK,
|
||||
CobblemonBlocks.X_SP_DEF,
|
||||
CobblemonBlocks.X_SPEED,
|
||||
CobblemonBlocks.TM_MACHINE
|
||||
CobblemonBlocks.TM_MACHINE,
|
||||
|
||||
CobblemonBlocks.GALARICA_CUFF,
|
||||
CobblemonBlocks.GALARICA_WREATH,
|
||||
CobblemonBlocks.CHIPPED_POT,
|
||||
CobblemonBlocks.CRACKED_POT,
|
||||
CobblemonBlocks.UNREMARKABLE_TEACUP,
|
||||
CobblemonBlocks.MASTERPIECE_TEACUP,
|
||||
CobblemonBlocks.LUMINOUS_MOSS,
|
||||
CobblemonBlocks.ICY_ROCK,
|
||||
CobblemonBlocks.HEAT_ROCK,
|
||||
CobblemonBlocks.SMOOTH_ROCK,
|
||||
CobblemonBlocks.DAMP_ROCK,
|
||||
CobblemonBlocks.DESTINY_KNOT,
|
||||
CobblemonBlocks.METRONOME,
|
||||
CobblemonBlocks.KINGS_ROCK,
|
||||
CobblemonBlocks.FLAME_ORB,
|
||||
CobblemonBlocks.LIFE_ORB,
|
||||
CobblemonBlocks.TOXIC_ORB,
|
||||
CobblemonBlocks.LIGHT_BALL,
|
||||
CobblemonBlocks.SMOKE_BALL,
|
||||
CobblemonBlocks.NEVER_MELT_ICE,
|
||||
CobblemonBlocks.WIDE_LENS,
|
||||
CobblemonBlocks.ZOOM_LENS,
|
||||
CobblemonBlocks.SCOPE_LENS
|
||||
)
|
||||
|
||||
this.createBoatModelLayers()
|
||||
@@ -486,7 +514,6 @@ object CobblemonClient {
|
||||
}
|
||||
|
||||
fun endBattle() {
|
||||
ClientBattleInformationRepository.clear()
|
||||
battle = null
|
||||
battleOverlay.lastKnownBattle = null
|
||||
BattleMusicController.endMusic()
|
||||
|
||||
@@ -84,7 +84,6 @@ class ClientBattle(
|
||||
pendingActionRequests.map { it.response!! }
|
||||
)
|
||||
)
|
||||
ClientBattleInformationRepository.mustChooseBy = null
|
||||
mustChoose = false
|
||||
}
|
||||
}
|
||||
|
||||
-28
@@ -1,28 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.battle
|
||||
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleInformationDTO
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattlePokemonDTO
|
||||
import java.time.Instant
|
||||
import java.util.UUID
|
||||
|
||||
object ClientBattleInformationRepository {
|
||||
val actors = mutableMapOf<UUID, MutableList<BattlePokemonDTO>>()
|
||||
val battles = mutableMapOf<UUID, BattleInformationDTO>()
|
||||
val actorActualSides = mutableMapOf<UUID, Int>()
|
||||
var mustChooseBy: Instant? = null
|
||||
|
||||
fun clear() {
|
||||
actors.clear()
|
||||
battles.clear()
|
||||
actorActualSides.clear()
|
||||
mustChooseBy = null
|
||||
}
|
||||
}
|
||||
+1
-17
@@ -9,7 +9,6 @@
|
||||
package com.cobblemon.mod.common.client.battle
|
||||
|
||||
import net.minecraft.util.FormattedCharSequence
|
||||
import net.minecraft.network.chat.Component
|
||||
|
||||
/**
|
||||
* A wrapper around the client battle message information. This is essentially an appending list of all
|
||||
@@ -22,21 +21,6 @@ import net.minecraft.network.chat.Component
|
||||
class ClientBattleMessageQueue {
|
||||
var listeners = mutableListOf<(FormattedCharSequence) -> Unit>()
|
||||
private val messages = mutableListOf<FormattedCharSequence>()
|
||||
private val components = mutableListOf<Component>()
|
||||
private val componentListeners = mutableListOf<(Component) -> Unit>()
|
||||
|
||||
fun addComponents(messages: Iterable<Component>) {
|
||||
messages.forEach { message ->
|
||||
components.add(message)
|
||||
componentListeners.toList().forEach { it(message) }
|
||||
}
|
||||
}
|
||||
|
||||
fun subscribeComponents(listener: (Component) -> Unit): () -> Unit {
|
||||
componentListeners.add(listener)
|
||||
components.forEach(listener)
|
||||
return { componentListeners.remove(listener) }
|
||||
}
|
||||
|
||||
fun add(messages: Iterable<FormattedCharSequence>) {
|
||||
this.messages.addAll(messages)
|
||||
@@ -47,4 +31,4 @@ class ClientBattleMessageQueue {
|
||||
this.listeners.add(listener)
|
||||
messages.forEach(listener)
|
||||
}
|
||||
}
|
||||
}
|
||||
-120
@@ -1,120 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.battle
|
||||
|
||||
import com.cobblemon.mod.common.api.types.ElementalType
|
||||
import com.cobblemon.mod.common.api.types.ElementalTypes
|
||||
|
||||
object MoveEffectivenessCalculator {
|
||||
|
||||
fun getMoveEffectiveness(attack: ElementalType, defenderType1: ElementalType, defenderType2: ElementalType?): Effectiveness {
|
||||
val type1Effectiveness = getEffectiveness(attack, defenderType1)
|
||||
val type2Effectiveness = if (defenderType2 == null) 1f else getEffectiveness(attack, defenderType2)
|
||||
val typeEffectiveness = type1Effectiveness * type2Effectiveness
|
||||
|
||||
return when {
|
||||
typeEffectiveness == 0f -> Effectiveness.IMMUNE
|
||||
typeEffectiveness == 0.25f -> Effectiveness.MOSTLY_INEFFECTIVE
|
||||
typeEffectiveness == 0.5f -> Effectiveness.NOT_VERY_EFFECTIVE
|
||||
typeEffectiveness == 1f -> Effectiveness.EFFECTIVE
|
||||
typeEffectiveness == 2f -> Effectiveness.SUPER_EFFECTIVE
|
||||
typeEffectiveness == 4f -> Effectiveness.EXTREMELY_EFFECTIVE
|
||||
else -> Effectiveness.IMMUNE
|
||||
}
|
||||
}
|
||||
|
||||
fun getEffectiveness(attack: ElementalType, defender: ElementalType): Float {
|
||||
if (isImmune(attack, defender)) return 0f
|
||||
if (isSuperEffective(attack, defender)) return 2f
|
||||
if (isNotVeryEffective(attack, defender)) return 0.5f
|
||||
return 1f
|
||||
}
|
||||
|
||||
fun isImmune(attack: ElementalType, defender: ElementalType): Boolean {
|
||||
when (attack) {
|
||||
ElementalTypes.NORMAL -> return defender == ElementalTypes.GHOST
|
||||
ElementalTypes.FIRE -> return false
|
||||
ElementalTypes.WATER -> return false
|
||||
ElementalTypes.GRASS -> return false
|
||||
ElementalTypes.ELECTRIC -> return defender == ElementalTypes.GROUND
|
||||
ElementalTypes.ICE -> return false
|
||||
ElementalTypes.FIGHTING -> return defender == ElementalTypes.GHOST
|
||||
ElementalTypes.POISON -> return defender == ElementalTypes.STEEL
|
||||
ElementalTypes.GROUND -> return defender == ElementalTypes.FLYING
|
||||
ElementalTypes.FLYING -> return false
|
||||
ElementalTypes.PSYCHIC -> return defender == ElementalTypes.DARK
|
||||
ElementalTypes.BUG -> return false
|
||||
ElementalTypes.ROCK -> return false
|
||||
ElementalTypes.GHOST -> return defender == ElementalTypes.NORMAL
|
||||
ElementalTypes.DRAGON -> return defender == ElementalTypes.FAIRY
|
||||
ElementalTypes.DARK -> return false
|
||||
ElementalTypes.STEEL -> return false
|
||||
ElementalTypes.FAIRY -> return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun isSuperEffective(attack: ElementalType, defender: ElementalType): Boolean {
|
||||
when (attack) {
|
||||
ElementalTypes.NORMAL -> return false
|
||||
ElementalTypes.FIRE -> return defender in listOf(ElementalTypes.GRASS, ElementalTypes.ICE, ElementalTypes.BUG, ElementalTypes.STEEL)
|
||||
ElementalTypes.WATER -> return defender in listOf(ElementalTypes.FIRE, ElementalTypes.GROUND, ElementalTypes.ROCK)
|
||||
ElementalTypes.GRASS -> return defender in listOf(ElementalTypes.WATER, ElementalTypes.GROUND, ElementalTypes.ROCK)
|
||||
ElementalTypes.ELECTRIC -> return defender in listOf(ElementalTypes.WATER, ElementalTypes.FLYING)
|
||||
ElementalTypes.ICE -> return defender in listOf(ElementalTypes.GRASS, ElementalTypes.GROUND, ElementalTypes.FLYING, ElementalTypes.DRAGON)
|
||||
ElementalTypes.FIGHTING -> return defender in listOf(ElementalTypes.NORMAL, ElementalTypes.ICE, ElementalTypes.ROCK, ElementalTypes.DARK, ElementalTypes.STEEL)
|
||||
ElementalTypes.POISON -> return defender in listOf(ElementalTypes.GRASS, ElementalTypes.FAIRY)
|
||||
ElementalTypes.GROUND -> return defender in listOf(ElementalTypes.FIRE, ElementalTypes.ELECTRIC, ElementalTypes.POISON, ElementalTypes.ROCK, ElementalTypes.STEEL)
|
||||
ElementalTypes.FLYING -> return defender in listOf(ElementalTypes.GRASS, ElementalTypes.FIGHTING, ElementalTypes.BUG)
|
||||
ElementalTypes.PSYCHIC -> return defender in listOf(ElementalTypes.FIGHTING, ElementalTypes.POISON)
|
||||
ElementalTypes.BUG -> return defender in listOf(ElementalTypes.GRASS, ElementalTypes.PSYCHIC, ElementalTypes.DARK)
|
||||
ElementalTypes.ROCK -> return defender in listOf(ElementalTypes.FIRE, ElementalTypes.ICE, ElementalTypes.FLYING, ElementalTypes.BUG)
|
||||
ElementalTypes.GHOST -> return defender in listOf(ElementalTypes.PSYCHIC, ElementalTypes.GHOST)
|
||||
ElementalTypes.DRAGON -> return defender in listOf(ElementalTypes.DRAGON)
|
||||
ElementalTypes.DARK -> return defender in listOf(ElementalTypes.PSYCHIC, ElementalTypes.GHOST)
|
||||
ElementalTypes.STEEL -> return defender in listOf(ElementalTypes.ICE, ElementalTypes.ROCK, ElementalTypes.FAIRY)
|
||||
ElementalTypes.FAIRY -> return defender in listOf(ElementalTypes.FIGHTING, ElementalTypes.DRAGON, ElementalTypes.DARK)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun isNotVeryEffective(attack: ElementalType, defender: ElementalType): Boolean {
|
||||
when (attack) {
|
||||
ElementalTypes.NORMAL -> return defender in listOf(ElementalTypes.ROCK, ElementalTypes.STEEL)
|
||||
ElementalTypes.FIRE -> return defender in listOf(ElementalTypes.FIRE, ElementalTypes.WATER, ElementalTypes.ROCK, ElementalTypes.DRAGON)
|
||||
ElementalTypes.WATER -> return defender in listOf(ElementalTypes.WATER, ElementalTypes.GRASS, ElementalTypes.DRAGON)
|
||||
ElementalTypes.GRASS -> return defender in listOf(ElementalTypes.FIRE, ElementalTypes.GRASS, ElementalTypes.POISON, ElementalTypes.FLYING, ElementalTypes.BUG, ElementalTypes.DRAGON, ElementalTypes.STEEL)
|
||||
ElementalTypes.ELECTRIC -> return defender in listOf(ElementalTypes.GRASS, ElementalTypes.ELECTRIC, ElementalTypes.DRAGON)
|
||||
ElementalTypes.ICE -> return defender in listOf(ElementalTypes.FIRE, ElementalTypes.WATER, ElementalTypes.ICE, ElementalTypes.STEEL)
|
||||
ElementalTypes.FIGHTING -> return defender in listOf(ElementalTypes.POISON, ElementalTypes.FLYING, ElementalTypes.PSYCHIC, ElementalTypes.BUG, ElementalTypes.FAIRY)
|
||||
ElementalTypes.POISON -> return defender in listOf(ElementalTypes.POISON, ElementalTypes.GROUND, ElementalTypes.ROCK, ElementalTypes.GHOST)
|
||||
ElementalTypes.GROUND -> return defender in listOf(ElementalTypes.GRASS, ElementalTypes.BUG)
|
||||
ElementalTypes.FLYING -> return defender in listOf(ElementalTypes.ELECTRIC, ElementalTypes.ROCK, ElementalTypes.STEEL)
|
||||
ElementalTypes.PSYCHIC -> return defender in listOf(ElementalTypes.PSYCHIC, ElementalTypes.STEEL)
|
||||
ElementalTypes.BUG -> return defender in listOf(ElementalTypes.FIRE, ElementalTypes.FIGHTING, ElementalTypes.POISON, ElementalTypes.FLYING, ElementalTypes.GHOST, ElementalTypes.STEEL, ElementalTypes.FAIRY)
|
||||
ElementalTypes.ROCK -> return defender in listOf(ElementalTypes.FIGHTING, ElementalTypes.GROUND, ElementalTypes.STEEL)
|
||||
ElementalTypes.GHOST -> return defender in listOf(ElementalTypes.DARK)
|
||||
ElementalTypes.DRAGON -> return defender in listOf(ElementalTypes.STEEL)
|
||||
ElementalTypes.DARK -> return defender in listOf(ElementalTypes.FIGHTING, ElementalTypes.DARK, ElementalTypes.FAIRY)
|
||||
ElementalTypes.STEEL -> return defender in listOf(ElementalTypes.FIRE, ElementalTypes.WATER, ElementalTypes.ELECTRIC, ElementalTypes.STEEL)
|
||||
ElementalTypes.FAIRY -> return defender in listOf(ElementalTypes.FIRE, ElementalTypes.POISON, ElementalTypes.STEEL)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum class Effectiveness {
|
||||
EXTREMELY_EFFECTIVE,
|
||||
SUPER_EFFECTIVE,
|
||||
EFFECTIVE,
|
||||
NOT_VERY_EFFECTIVE,
|
||||
MOSTLY_INEFFECTIVE,
|
||||
IMMUNE
|
||||
}
|
||||
-42
@@ -1,42 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.battle.preview
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonNetwork
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattlePokemonDTO
|
||||
import com.cobblemon.mod.common.net.messages.server.battle.TeamPreviewSelectPokemonPacket
|
||||
import net.minecraft.network.chat.Component
|
||||
import java.time.Instant
|
||||
|
||||
class ClientBattleTeamPreview(
|
||||
val selections: Int,
|
||||
val team: List<BattlePokemonDTO?>,
|
||||
val opponent: List<BattlePokemonDTO?>,
|
||||
val mustPickBy: Instant,
|
||||
val opponentName: Component
|
||||
) {
|
||||
val selection = mutableListOf<BattlePokemonDTO>()
|
||||
|
||||
fun select(pokemon: BattlePokemonDTO) {
|
||||
if (pokemon !in team || pokemon in selection || selection.size >= selections) return
|
||||
selection.add(pokemon)
|
||||
sendChangePacket()
|
||||
}
|
||||
|
||||
fun unselect(pokemon: BattlePokemonDTO) {
|
||||
selection.remove(pokemon)
|
||||
sendChangePacket()
|
||||
}
|
||||
|
||||
private fun sendChangePacket() {
|
||||
val indexes = selection.map { team.indexOf(it) }
|
||||
if (indexes.any { it == -1 }) return
|
||||
CobblemonNetwork.sendToServer(TeamPreviewSelectPokemonPacket(indexes.toSet()))
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -71,7 +71,7 @@ open class VariableObjectSelectionList(x: Int, y: Int, width: Int, height: Int):
|
||||
var stackHeight = -scrollAmount.toInt()
|
||||
guiGraphics.enableScissor(x, y, x + width, y + height)
|
||||
children.forEachIndexed { index, entry ->
|
||||
if (stackHeight in 1..<height || stackHeight + entry.height in 1..<height) {
|
||||
if (stackHeight < height && stackHeight + entry.height > 0) {
|
||||
entry.render(guiGraphics, index, x, y + stackHeight, mouseX, mouseY, partialTick)
|
||||
}
|
||||
stackHeight += entry.height
|
||||
|
||||
@@ -20,12 +20,10 @@ import com.cobblemon.mod.common.client.gui.battle.subscreen.BattleGeneralActionS
|
||||
import com.cobblemon.mod.common.client.gui.battle.subscreen.BattleSwitchPokemonSelection
|
||||
import com.cobblemon.mod.common.client.gui.battle.subscreen.ForfeitConfirmationSelection
|
||||
import com.cobblemon.mod.common.client.gui.battle.widgets.BattleMessagePane
|
||||
import com.cobblemon.mod.common.client.gui.battle.widgets.BattleOptionTile
|
||||
import com.cobblemon.mod.common.client.keybind.boundKey
|
||||
import com.cobblemon.mod.common.client.keybind.keybinds.PartySendBinding
|
||||
import com.cobblemon.mod.common.client.render.drawScaledText
|
||||
import com.cobblemon.mod.common.net.messages.server.battle.RemoveSpectatorPacket
|
||||
import com.cobblemon.mod.common.util.asTranslated
|
||||
import com.cobblemon.mod.common.util.battleLang
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.client.Minecraft
|
||||
@@ -46,16 +44,15 @@ class BattleGUI : Screen(battleLang("gui.title")), CobblemonRenderable {
|
||||
val forfeitResource = cobblemonResource("textures/gui/battle/battle_menu_forfeit.png")
|
||||
}
|
||||
|
||||
lateinit var messagePane: BattleMessagePane
|
||||
private lateinit var messagePane: BattleMessagePane
|
||||
var opacity = 0F
|
||||
val actor = CobblemonClient.battle?.side1?.actors?.find { it.uuid == Minecraft.getInstance().player?.uuid }
|
||||
val specBackButton = BattleBackButton(OPTION_ROOT_X - 3F, Minecraft.getInstance().window.guiScaledHeight - 22F)
|
||||
val specBackButton = BattleBackButton(12f, Minecraft.getInstance().window.guiScaledHeight - 32f)
|
||||
|
||||
var queuedActions = mutableListOf<() -> Unit>()
|
||||
|
||||
override fun init() {
|
||||
super.init()
|
||||
if (this::messagePane.isInitialized) messagePane.dispose()
|
||||
messagePane = BattleMessagePane(CobblemonClient.battle!!.messages)
|
||||
messagePane.opacity = CobblemonClient.battleOverlay.opacityRatio.toFloat().coerceAtLeast(0.3F)
|
||||
addRenderableWidget(messagePane)
|
||||
@@ -124,17 +121,16 @@ class BattleGUI : Screen(battleLang("gui.title")), CobblemonRenderable {
|
||||
}
|
||||
|
||||
val currentSelection = getCurrentActionSelection()
|
||||
if (currentSelection == null || currentSelection is BattleGeneralActionSelection) {
|
||||
if (currentSelection == null || currentSelection is BattleGeneralActionSelection ) {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = battleLang("ui.hide_label", PartySendBinding.boundKey().displayName),
|
||||
x = Minecraft.getInstance().window.guiScaledWidth / 2,
|
||||
y = Minecraft.getInstance().window.guiScaledHeight / 5,
|
||||
y = (Minecraft.getInstance().window.guiScaledHeight / 5),
|
||||
opacity = 0.75F * opacity,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
if (currentSelection is ForfeitConfirmationSelection) {
|
||||
} else if (currentSelection is ForfeitConfirmationSelection) {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = battleLang("ui.forfeit_confirmation", PartySendBinding.boundKey().displayName),
|
||||
@@ -148,11 +144,6 @@ class BattleGUI : Screen(battleLang("gui.title")), CobblemonRenderable {
|
||||
|
||||
queuedActions.forEach { it() }
|
||||
queuedActions.clear()
|
||||
CobblemonClient.battleOverlay.mouseX = mouseX
|
||||
CobblemonClient.battleOverlay.mouseY = mouseY
|
||||
// The benched-team portrait columns + active hover panels are queued during the HUD pass and drawn
|
||||
// here, last, so they sit above the switch-menu underlay, our own widgets and the chat.
|
||||
CobblemonClient.battleOverlay.renderDeferredColumns(context)
|
||||
}
|
||||
|
||||
override fun renderBackground(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
|
||||
@@ -160,6 +151,8 @@ class BattleGUI : Screen(battleLang("gui.title")), CobblemonRenderable {
|
||||
}
|
||||
|
||||
fun deriveRootActionSelection(actor: ClientBattleActor, request: SingleActionRequest): BattleActionSelection? {
|
||||
|
||||
|
||||
return if (request.forceSwitch) {
|
||||
BattleSwitchPokemonSelection(this, request)
|
||||
} else {
|
||||
@@ -182,23 +175,11 @@ class BattleGUI : Screen(battleLang("gui.title")), CobblemonRenderable {
|
||||
CobblemonClient.battle?.minimised = true
|
||||
}
|
||||
|
||||
override fun removed() {
|
||||
if (this::messagePane.isInitialized) messagePane.dispose()
|
||||
super.removed()
|
||||
}
|
||||
|
||||
override fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean {
|
||||
if (CobblemonClient.battleOverlay.columnMouseDragged(mouseX, mouseY)) return true
|
||||
if (this::messagePane.isInitialized && messagePane.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)) return true
|
||||
if (this::messagePane.isInitialized) messagePane.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)
|
||||
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)
|
||||
}
|
||||
|
||||
override fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean {
|
||||
if (this::messagePane.isInitialized) messagePane.mouseReleased(mouseX, mouseY, button)
|
||||
if (CobblemonClient.battleOverlay.columnMouseReleased()) return true
|
||||
return super.mouseReleased(mouseX, mouseY, button)
|
||||
}
|
||||
|
||||
override fun charTyped(chr: Char, modifiers: Int): Boolean {
|
||||
if (chr.toString().equals(PartySendBinding.boundKey().displayName.string, ignoreCase = true) && CobblemonClient.battleOverlay.opacity == BattleOverlay.MAX_OPACITY && PartySendBinding.canAction()) {
|
||||
return minimizeBattle()
|
||||
@@ -207,18 +188,14 @@ class BattleGUI : Screen(battleLang("gui.title")), CobblemonRenderable {
|
||||
}
|
||||
|
||||
override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean {
|
||||
// Grab a benched-team portrait column to drag it (left-click). Consumes the click if one was hit.
|
||||
if (button == 0 && CobblemonClient.battleOverlay.columnMouseClicked(mouseX, mouseY)) return true
|
||||
if (button == PartySendBinding.boundKey().value && CobblemonClient.battleOverlay.opacity == BattleOverlay.MAX_OPACITY && PartySendBinding.canAction()) {
|
||||
return minimizeBattle()
|
||||
}
|
||||
|
||||
val battle = CobblemonClient.battle
|
||||
if (battle?.spectating == true) {
|
||||
if (specBackButton.isHovered(mouseX, mouseY)) {
|
||||
RemoveSpectatorPacket(battle.battleId).sendToServer()
|
||||
CobblemonClient.endBattle()
|
||||
}
|
||||
if (battle?.spectating == true && specBackButton.isHovered(mouseX, mouseY)) {
|
||||
RemoveSpectatorPacket(battle.battleId).sendToServer()
|
||||
CobblemonClient.endBattle()
|
||||
}
|
||||
return super.mouseClicked(mouseX, mouseY, button)
|
||||
}
|
||||
@@ -229,4 +206,4 @@ class BattleGUI : Screen(battleLang("gui.title")), CobblemonRenderable {
|
||||
PartySendBinding.actioned()
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
+77
-1671
File diff suppressed because it is too large.
Load diff
-682
@@ -1,682 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.gui.battle
|
||||
|
||||
import com.cobblemon.mod.common.api.abilities.Abilities
|
||||
import com.cobblemon.mod.common.api.moves.Moves
|
||||
import com.cobblemon.mod.common.api.gui.blitk
|
||||
import com.cobblemon.mod.common.api.pokemon.stats.Stats
|
||||
import com.cobblemon.mod.common.api.text.bold
|
||||
import com.cobblemon.mod.common.api.text.green
|
||||
import com.cobblemon.mod.common.api.text.red
|
||||
import com.cobblemon.mod.common.api.text.text
|
||||
import com.cobblemon.mod.common.client.battle.ClientBattlePokemon
|
||||
import com.cobblemon.mod.common.client.gui.TypeIcon
|
||||
import com.cobblemon.mod.common.client.render.drawScaledText
|
||||
import com.cobblemon.mod.common.client.render.drawScaledTextJustifiedRight
|
||||
import com.cobblemon.mod.common.client.render.getDepletableRedGreen
|
||||
import com.cobblemon.mod.common.pokemon.FormData
|
||||
import com.cobblemon.mod.common.pokemon.Species
|
||||
import com.cobblemon.mod.common.util.asTranslated
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattlePokemonDTO
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.MutableComponent
|
||||
import net.minecraft.network.chat.TextColor
|
||||
import net.minecraft.network.chat.contents.TranslatableContents
|
||||
import java.text.DecimalFormat
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.floor
|
||||
|
||||
/**
|
||||
* The "Info" style expanded stat panel for a single battle Pokémon (form, buffs/debuffs, ability,
|
||||
* moves, speed/speed-tier, types, held item). It renders to the *side* of a tile, with a connector
|
||||
* pointing back at it, and expands inwards (towards the screen centre) on both sides.
|
||||
*
|
||||
* Shared by the team Info screen (the team Info screen)
|
||||
* and the on-field benched-team portrait column ([BattleOverlay.drawPartyColumn]) so the two stay identical.
|
||||
*
|
||||
* Knowledge gating is inherited from [dto]: the team owner gets full data while opponents only carry
|
||||
* what has been revealed, so unrevealed ability/moves show "?" and speed falls back to a tier range.
|
||||
*/
|
||||
object BattlePokemonInfoPanel {
|
||||
private val expandedPokemonInfo = cobblemonResource("textures/gui/battle/expanded_pokemon_info_center.png")
|
||||
// Variant for non-active Pokémon: the left (Buffs/Debuffs) column is cleared for a Current HP gauge.
|
||||
private val expandedPokemonInfoInactive = cobblemonResource("textures/gui/battle/expanded_pokemon_info_center_inactive.png")
|
||||
// Same battle health-bar texture the active Pokémon's tile uses, for the Current HP gauge.
|
||||
private val healthBar = cobblemonResource("textures/gui/battle/health_bar.png")
|
||||
private val hoverGap = cobblemonResource("textures/gui/battle/hover_gap.png")
|
||||
private val hoverGapReversed = cobblemonResource("textures/gui/battle/hover_gap_reversed.png")
|
||||
|
||||
private val multiplierFormat = DecimalFormat("0.##")
|
||||
|
||||
// Boost value slots span x=46..65; leave one pixel of padding at the battle text scale.
|
||||
internal const val BOOST_VALUE_CENTER_X = 55.5
|
||||
internal const val BOOST_VALUE_MAX_WIDTH = 36 // 18 GUI pixels at BattleOverlay.SCALE.
|
||||
|
||||
fun renderUnknownTile(context: GuiGraphics, x: Float, y: Float, reversed: Boolean, scale: Float = 1F, opacity: Number = 1F) {
|
||||
val matrices = context.pose()
|
||||
val insetX = if (reversed) 8 else 5
|
||||
matrices.pushPose()
|
||||
matrices.translate(x.toDouble(), y.toDouble(), 0.0)
|
||||
matrices.scale(scale, scale, scale)
|
||||
blitk(
|
||||
matrixStack = matrices,
|
||||
texture = BattleOverlay.battleInfoUnderlay,
|
||||
x = insetX,
|
||||
y = 4,
|
||||
width = 28,
|
||||
height = 28,
|
||||
alpha = opacity
|
||||
)
|
||||
// Draw the complete 8x10 asset at twice its size, centred in the portrait window.
|
||||
blitk(
|
||||
matrixStack = matrices,
|
||||
texture = BattleOverlay.questionMarkIcon,
|
||||
x = (insetX + 6) / 2F,
|
||||
y = 4,
|
||||
width = 8,
|
||||
height = 10,
|
||||
scale = 2F,
|
||||
alpha = opacity
|
||||
)
|
||||
blitk(
|
||||
matrixStack = matrices,
|
||||
texture = if (reversed) BattleOverlay.partyColumnTileReversed else BattleOverlay.partyColumnTile,
|
||||
x = 0,
|
||||
y = 0,
|
||||
width = 41,
|
||||
height = 39,
|
||||
alpha = opacity
|
||||
)
|
||||
matrices.popPose()
|
||||
}
|
||||
|
||||
fun render(
|
||||
context: GuiGraphics,
|
||||
tileX: Float,
|
||||
tileY: Float,
|
||||
tileWidth: Float,
|
||||
reversed: Boolean,
|
||||
pokemon: ClientBattlePokemon,
|
||||
dto: BattlePokemonDTO,
|
||||
showGap: Boolean = true,
|
||||
showBuffs: Boolean = true
|
||||
) {
|
||||
context.pose().pushPose()
|
||||
context.pose().translate(0.0, 0.0, 300.0)
|
||||
// Panel sits just beside the tile (inwards) with the connector bridging the gap.
|
||||
val startX = if (reversed) tileX - 136 else tileX + tileWidth - 1
|
||||
val startY = tileY
|
||||
val species = pokemon.species
|
||||
val form = species.getForm(pokemon.state.currentAspects)
|
||||
|
||||
// The connector is only shown for the Info screen tiles, not the on-field draggable column.
|
||||
if (showGap) {
|
||||
val gap = if (reversed) hoverGapReversed else hoverGap
|
||||
val xOffset = if (reversed) 136 else -7
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = gap,
|
||||
x = startX + xOffset,
|
||||
y = startY,
|
||||
height = 36,
|
||||
width = 8,
|
||||
textureHeight = 36,
|
||||
textureWidth = 8,
|
||||
)
|
||||
}
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = if (showBuffs) expandedPokemonInfo else expandedPokemonInfoInactive,
|
||||
x = startX,
|
||||
y = startY,
|
||||
height = 112,
|
||||
width = 137,
|
||||
textureHeight = 112,
|
||||
textureWidth = 137,
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "deltaclient.ui.battle.label.pokemon_form".asTranslated().bold(),
|
||||
x = startX + 36,
|
||||
y = startY + 6.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getFormText(species, form),
|
||||
x = startX + 36,
|
||||
y = startY + 13.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
if (showBuffs) {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "deltaclient.ui.battle.label.buffs".asTranslated().bold(),
|
||||
x = startX + 36,
|
||||
y = startY + 23.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.attack.name".asTranslated().statColored(Stats.ATTACK),
|
||||
x = startX + 10,
|
||||
y = startY + 31.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs[Stats.ATTACK]?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getBoostText(Stats.ATTACK, it),
|
||||
x = startX + BOOST_VALUE_CENTER_X,
|
||||
y = startY + 31.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
maxCharacterWidth = BOOST_VALUE_MAX_WIDTH,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.defence.name".asTranslated().statColored(Stats.DEFENCE),
|
||||
x = startX + 10,
|
||||
y = startY + 39.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs[Stats.DEFENCE]?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getBoostText(Stats.DEFENCE, it),
|
||||
x = startX + BOOST_VALUE_CENTER_X,
|
||||
y = startY + 39.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
maxCharacterWidth = BOOST_VALUE_MAX_WIDTH,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "deltaclient.ui.battle.stats.special_attack".asTranslated().statColored(Stats.SPECIAL_ATTACK),
|
||||
x = startX + 10,
|
||||
y = startY + 47.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs[Stats.SPECIAL_ATTACK]?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getBoostText(Stats.SPECIAL_ATTACK, it),
|
||||
x = startX + BOOST_VALUE_CENTER_X,
|
||||
y = startY + 47.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
maxCharacterWidth = BOOST_VALUE_MAX_WIDTH,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "deltaclient.ui.battle.stats.special_defence".asTranslated().statColored(Stats.SPECIAL_DEFENCE),
|
||||
x = startX + 10,
|
||||
y = startY + 55.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs[Stats.SPECIAL_DEFENCE]?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getBoostText(Stats.SPECIAL_DEFENCE, it),
|
||||
x = startX + BOOST_VALUE_CENTER_X,
|
||||
y = startY + 55.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
maxCharacterWidth = BOOST_VALUE_MAX_WIDTH,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.speed.name".asTranslated().statColored(Stats.SPEED),
|
||||
x = startX + 10,
|
||||
y = startY + 63.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs[Stats.SPEED]?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getBoostText(Stats.SPEED, it),
|
||||
x = startX + BOOST_VALUE_CENTER_X,
|
||||
y = startY + 63.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
maxCharacterWidth = BOOST_VALUE_MAX_WIDTH,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.accuracy.name".asTranslated(),
|
||||
x = startX + 10,
|
||||
y = startY + 71.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs[Stats.ACCURACY]?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getBoostText(Stats.ACCURACY, it),
|
||||
x = startX + BOOST_VALUE_CENTER_X,
|
||||
y = startY + 71.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
maxCharacterWidth = BOOST_VALUE_MAX_WIDTH,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.evasion.name".asTranslated(),
|
||||
x = startX + 10,
|
||||
y = startY + 79.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs[Stats.EVASION]?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getBoostText(Stats.EVASION, it),
|
||||
x = startX + BOOST_VALUE_CENTER_X,
|
||||
y = startY + 79.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
maxCharacterWidth = BOOST_VALUE_MAX_WIDTH,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// Non-active Pokémon have no stat stages; the inactive panel asset already clears the
|
||||
// Buffs/Debuffs column, so we just draw a "Current HP" gauge on that clean area.
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "deltaclient.ui.battle.label.current_hp".asTranslated().bold(),
|
||||
x = startX + 36,
|
||||
y = startY + 23.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
// Owner sees flat HP (hp/maxHp); opponents carry a 0..1 ratio.
|
||||
val hpRatio = (if (pokemon.isHpFlat) pokemon.hpValue / pokemon.maxHp.toInt() else pokemon.hpValue)
|
||||
.coerceIn(0f, 1f)
|
||||
val (hpRed, hpGreen) = getDepletableRedGreen(hpRatio)
|
||||
|
||||
// Same battle health-bar texture + tint the active Pokémon uses, sized to fill the asset's
|
||||
// bar slot beneath the "Current HP" label (slot ≈ x8..64, y30..36).
|
||||
val barX = startX + 8
|
||||
val barW = hpRatio * 57f
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = healthBar,
|
||||
x = barX,
|
||||
y = startY + 30,
|
||||
width = barW,
|
||||
height = 6,
|
||||
textureWidth = 99,
|
||||
textureHeight = 6,
|
||||
red = hpRed * 0.8f,
|
||||
green = hpGreen * 0.8f,
|
||||
blue = 0.27f
|
||||
)
|
||||
// The texture's right end is angled, so a left-clipped fill has a border on every side except
|
||||
// the right. Re-draw the texture's square left-edge column (texel 0) at the fill's right edge
|
||||
// to close the border into a full rectangle.
|
||||
if (barW >= 1f) {
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = healthBar,
|
||||
x = barX + barW - 1f,
|
||||
y = startY + 30,
|
||||
width = 1f,
|
||||
height = 6,
|
||||
textureWidth = 99,
|
||||
textureHeight = 6,
|
||||
red = hpRed * 0.8f,
|
||||
green = hpGreen * 0.8f,
|
||||
blue = 0.27f
|
||||
)
|
||||
}
|
||||
|
||||
// Percentage centred inside the bar — and exact values for your own Pokémon — exactly like
|
||||
// the active Pokémon's health bar does in battle.
|
||||
val hpText = if (pokemon.isHpFlat) {
|
||||
"${pokemon.hpValue.toInt()}/${pokemon.maxHp.toInt()} (${ceil(hpRatio * 100).toInt()}%)"
|
||||
} else {
|
||||
"${ceil(hpRatio * 100).toInt()}%"
|
||||
}
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = hpText.text(),
|
||||
x = startX + 36,
|
||||
y = startY + 31.0,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "deltaclient.ui.battle.label.ability".asTranslated().bold(),
|
||||
x = startX + 100,
|
||||
y = startY + 6.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
val ability = dto.ability?.let { Abilities.get(it) }
|
||||
val abilityName = ability?.displayName?.asTranslated() ?: "?".text()
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = abilityName,
|
||||
x = startX + 100,
|
||||
y = startY + 13.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "deltaclient.ui.battle.label.moves".asTranslated().bold(),
|
||||
x = startX + 100,
|
||||
y = startY + 23.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
if (dto.moves.size != 4) {
|
||||
for (i in 0 until 4) {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "?".text(),
|
||||
x = startX + 100,
|
||||
y = startY + 31.5 + i * 8,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
val questionMarkText = "?".text()
|
||||
dto.moves.forEachIndexed { index, moveDTO ->
|
||||
val move = moveDTO?.move ?: questionMarkText
|
||||
val moveColor = moveDTO?.move?.let { typeColorFor(it) }
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = move.string.text().let { t -> if (moveColor != null) t.colored(moveColor) else t },
|
||||
x = if (move == questionMarkText) startX + 100 else startX + 74,
|
||||
y = startY + 31.5 + index * 8,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = move == questionMarkText
|
||||
)
|
||||
|
||||
if (moveDTO != null) {
|
||||
drawScaledTextJustifiedRight(
|
||||
context = context,
|
||||
text = moveDTO.timesUsed.toString().text(),
|
||||
x = startX + 127.5,
|
||||
y = startY + 31.5 + index * 8,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val dtoSpeed = dto.speed
|
||||
if (dtoSpeed != null) {
|
||||
val speedBoost = dto.buffs[Stats.SPEED] ?: 1.0
|
||||
val speedAfterBoost = (dtoSpeed * speedBoost).toInt()
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.speed.name".asTranslated(),
|
||||
x = startX + 100,
|
||||
y = startY + 65.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = speedAfterBoost.toString().text(),
|
||||
x = startX + 100,
|
||||
y = startY + 72.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
else {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "deltaclient.ui.battle.label.speed_tier".asTranslated(),
|
||||
x = startX + 100,
|
||||
y = startY + 65.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
val speedBoost = dto.buffs[Stats.SPEED] ?: 1.0
|
||||
val speedTier = getSpeedRange(form, pokemon.level, speedBoost)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = speedTier,
|
||||
x = startX + 100,
|
||||
y = startY + 72.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "deltaclient.ui.battle.label.held_item".asTranslated(),
|
||||
x = startX + 40,
|
||||
y = startY + 99.5,
|
||||
scale = BattleOverlay.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
TypeIcon(
|
||||
x = startX + 100.5,
|
||||
y = startY + 88,
|
||||
type = form.primaryType,
|
||||
secondaryType = form.secondaryType,
|
||||
small = false,
|
||||
centeredX = true
|
||||
).render(context)
|
||||
|
||||
if (form.secondaryType != null) {
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = cobblemonResource("textures/gui/battle/type_spacer_double.png"),
|
||||
x = (startX + 69.0) / 0.45,
|
||||
y = (startY + 91.5) / 0.45,
|
||||
height = 24,
|
||||
width = 140,
|
||||
textureHeight = 24,
|
||||
textureWidth = 140,
|
||||
scale = 0.45f
|
||||
)
|
||||
}
|
||||
else {
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = cobblemonResource("textures/gui/summary/type_spacer.png"),
|
||||
x = (startX + 70.5) / 0.45,
|
||||
y = (startY + 91.5) / 0.45,
|
||||
height = 24,
|
||||
width = 132,
|
||||
textureHeight = 24,
|
||||
textureWidth = 132,
|
||||
scale = 0.45f
|
||||
)
|
||||
}
|
||||
|
||||
val heldItem = dto.heldItem
|
||||
if (heldItem != null && !heldItem.isEmpty()) {
|
||||
context.pose().pushPose()
|
||||
context.pose().scale(0.95F, 0.95F, 0.95F)
|
||||
val itemX = (startX + 4) / 0.95
|
||||
val itemY = (startY + 91) / 0.95
|
||||
context.renderItem(heldItem, itemX.toInt(), itemY.toInt())
|
||||
context.pose().popPose()
|
||||
}
|
||||
else {
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = BattleOverlay.questionMarkIcon,
|
||||
x = startX + 6,
|
||||
y = startY + 92.5,
|
||||
height = 11,
|
||||
width = 10,
|
||||
)
|
||||
}
|
||||
context.pose().popPose()
|
||||
}
|
||||
|
||||
private fun getSpeedRange(form: FormData, level: Int, speedBoost: Double): MutableComponent {
|
||||
val base = form.baseStats[Stats.SPEED] ?: 0
|
||||
val maxIV = 31
|
||||
val maxEV = 252
|
||||
val minNatureMod = 0.9
|
||||
val maxNatureMod = 1.1
|
||||
|
||||
val minSpeed = getStat(base, level, 0, 0, minNatureMod) * speedBoost
|
||||
val maxSpeed = getStat(base, level, maxIV, maxEV, maxNatureMod) * speedBoost
|
||||
return "deltaclient.ui.battle.speed_tier".asTranslated(minSpeed.toInt(), maxSpeed.toInt())
|
||||
}
|
||||
|
||||
private fun getStat(base: Int, level: Int, iv: Int, ev: Int, natureMod: Double): Int {
|
||||
return floor((floor(((2.0 * base + iv + floor(ev / 4.0)) * level) / 100) + 5) * natureMod).toInt()
|
||||
}
|
||||
|
||||
internal fun getBoostText(stat: Stats, multiplier: Double): MutableComponent {
|
||||
val stage = stageFromMultiplier(stat, multiplier)
|
||||
val sign = if (stage > 0) "+" else ""
|
||||
val str = "$sign$stage (${multiplierFormat.format(multiplier)}x)"
|
||||
return when {
|
||||
multiplier > 1.0 -> str.green()
|
||||
multiplier < 1.0 -> str.red()
|
||||
else -> str.text()
|
||||
}
|
||||
}
|
||||
|
||||
// Converts a stat-boost multiplier back to its stage. Accuracy/Evasion use a /3 base, others /2.
|
||||
private fun stageFromMultiplier(stat: Stats, multiplier: Double): Int {
|
||||
val base = if (stat == Stats.ACCURACY || stat == Stats.EVASION) 3.0 else 2.0
|
||||
return if (multiplier >= 1.0) Math.round(multiplier * base - base).toInt()
|
||||
else Math.round(base - base / multiplier).toInt()
|
||||
}
|
||||
|
||||
// The type colour for a move from its "cobblemon.move.<name>" display name, or null if unknown.
|
||||
internal fun typeColorFor(move: Component): Int? {
|
||||
val key = (move.contents as? TranslatableContents)?.key ?: return null
|
||||
if (!key.startsWith("cobblemon.move.")) return null
|
||||
val type = Moves.getByName(key.removePrefix("cobblemon.move."))?.elementalType?.name ?: return null
|
||||
return typeColor(type)
|
||||
}
|
||||
|
||||
private fun typeColor(type: String): Int = when (type.lowercase()) {
|
||||
"bug" -> 0xA8B820
|
||||
"dark" -> 0x705848
|
||||
"dragon" -> 0x7038F8
|
||||
"electric" -> 0xF8D030
|
||||
"fairy" -> 0xEE99AC
|
||||
"fighting" -> 0xC03028
|
||||
"fire" -> 0xF08030
|
||||
"flying" -> 0xA890F0
|
||||
"ghost" -> 0x705898
|
||||
"grass" -> 0x78C850
|
||||
"ground" -> 0xE0C068
|
||||
"ice" -> 0x98D8D8
|
||||
"normal" -> 0xA8A878
|
||||
"poison" -> 0xA040A0
|
||||
"psychic" -> 0xF85888
|
||||
"rock" -> 0xB8A038
|
||||
"steel" -> 0xB8B8D0
|
||||
"water" -> 0x6890F0
|
||||
else -> 0xFFFFFF
|
||||
}
|
||||
|
||||
private fun getFormText(species: Species, form: FormData): MutableComponent {
|
||||
val speciesName = species.name
|
||||
val formName = form.name
|
||||
return if (formName == "Normal") speciesName.text() else "$speciesName-$formName".text()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal fun MutableComponent.colored(rgb: Int): MutableComponent = this.withStyle { it.withColor(TextColor.fromRgb(rgb)) }
|
||||
|
||||
// Buffs/Debuffs stat names are all white. (Per-stat colours can be re-enabled by returning them here.)
|
||||
internal fun statColor(stat: Stats): Int? = null
|
||||
|
||||
internal fun MutableComponent.statColored(stat: Stats): MutableComponent {
|
||||
val rgb = statColor(stat) ?: return this
|
||||
return this.colored(rgb)
|
||||
}
|
||||
-32
@@ -1,32 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.gui.battle.preview
|
||||
|
||||
import com.cobblemon.mod.common.client.battle.preview.ClientBattleTeamPreview
|
||||
import com.cobblemon.mod.common.client.gui.CobblemonRenderable
|
||||
import com.cobblemon.mod.common.util.battleLang
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
|
||||
class TeamPreviewGUI(val preview: ClientBattleTeamPreview) : Screen(battleLang("gui.team_preview")), CobblemonRenderable {
|
||||
private lateinit var widget: TeamPreviewWidget
|
||||
|
||||
override fun init() {
|
||||
super.init()
|
||||
widget = addRenderableWidget(TeamPreviewWidget(preview))
|
||||
}
|
||||
|
||||
override fun render(guiGraphics: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) {
|
||||
super.render(guiGraphics, mouseX, mouseY, partialTick)
|
||||
}
|
||||
|
||||
override fun shouldCloseOnEsc() = false
|
||||
|
||||
override fun isPauseScreen() = false
|
||||
}
|
||||
-973
@@ -1,973 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.gui.battle.preview
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.CobblemonSounds
|
||||
import com.cobblemon.mod.common.api.abilities.Abilities
|
||||
import com.cobblemon.mod.common.api.gui.ParentWidget
|
||||
import com.cobblemon.mod.common.api.gui.blitk
|
||||
import com.cobblemon.mod.common.api.gui.renderSprite
|
||||
import com.cobblemon.mod.common.api.pokemon.stats.Stats
|
||||
import com.cobblemon.mod.common.api.text.bold
|
||||
import com.cobblemon.mod.common.api.text.font
|
||||
import com.cobblemon.mod.common.api.text.green
|
||||
import com.cobblemon.mod.common.api.text.red
|
||||
import com.cobblemon.mod.common.api.text.text
|
||||
import com.cobblemon.mod.common.api.text.yellow
|
||||
import com.cobblemon.mod.common.client.CobblemonResources
|
||||
import com.cobblemon.mod.common.client.battle.ClientBattleInformationRepository
|
||||
import com.cobblemon.mod.common.client.battle.ClientBattlePokemon
|
||||
import com.cobblemon.mod.common.client.battle.preview.ClientBattleTeamPreview
|
||||
import com.cobblemon.mod.common.client.gui.TypeIcon
|
||||
import com.cobblemon.mod.common.client.gui.battle.BattleOverlay
|
||||
import com.cobblemon.mod.common.client.gui.battle.BattleOverlay.Companion.PORTRAIT_DIAMETER
|
||||
import com.cobblemon.mod.common.client.gui.battle.BattleOverlay.Companion.SCALE
|
||||
import com.cobblemon.mod.common.client.gui.battle.BattleOverlay.Companion.questionMarkIcon
|
||||
import com.cobblemon.mod.common.client.render.SpriteType
|
||||
import com.cobblemon.mod.common.client.render.drawScaledText
|
||||
import com.cobblemon.mod.common.client.render.drawScaledTextJustifiedRight
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.FloatingState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.VaryingModelRepository
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattlePokemonDTO
|
||||
import com.cobblemon.mod.common.pokemon.FormData
|
||||
import com.cobblemon.mod.common.pokemon.Species
|
||||
import com.cobblemon.mod.common.util.asTranslated
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import com.cobblemon.mod.common.util.toHex
|
||||
import com.mojang.blaze3d.platform.InputConstants
|
||||
import com.mojang.blaze3d.platform.Lighting
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import com.mojang.math.Axis
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.gui.narration.NarratableEntry
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput
|
||||
import net.minecraft.client.renderer.LightTexture
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance
|
||||
import net.minecraft.client.sounds.SoundManager
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.MutableComponent
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import org.joml.Quaternionf
|
||||
import org.joml.Vector3f
|
||||
import java.math.RoundingMode
|
||||
import java.text.DecimalFormat
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.floor
|
||||
import kotlin.math.max
|
||||
|
||||
class TeamPreviewWidget(val preview: ClientBattleTeamPreview) : ParentWidget(
|
||||
pX = 0,
|
||||
pY = if (Minecraft.getInstance().window.guiScaledHeight > 304) (Minecraft.getInstance().window.guiScaledHeight / 2) - (BACKGROUND_HEIGHT / 2)
|
||||
else Minecraft.getInstance().window.guiScaledHeight - (BACKGROUND_HEIGHT + 78),
|
||||
pWidth = Minecraft.getInstance().window.guiScaledWidth,
|
||||
pHeight = Minecraft.getInstance().window.guiScaledHeight,
|
||||
"cobblemon.battle.ui.team_info".asTranslated()
|
||||
) {
|
||||
companion object {
|
||||
const val SLOT_HORIZONTAL_SPACING = 4F
|
||||
const val SLOT_VERTICAL_SPACING = 2F
|
||||
|
||||
const val BACKGROUND_HEIGHT = 148
|
||||
val underlayTexture = cobblemonResource("textures/gui/battle/selection_underlay.png")
|
||||
val title = cobblemonResource("textures/gui/battle/team_preview_title.png")
|
||||
val checkmark = cobblemonResource("textures/gui/battle/checkmark.png")
|
||||
var visible = false
|
||||
}
|
||||
|
||||
val teamTiles = mutableListOf<PokemonTile>()
|
||||
val opponentTiles = mutableListOf<PokemonTile>()
|
||||
|
||||
init {
|
||||
addTiles()
|
||||
}
|
||||
|
||||
fun addTiles() {
|
||||
preview.team.forEachIndexed { index, pokemon ->
|
||||
if (pokemon == null) return@forEachIndexed
|
||||
val (slotX, slotY) = getSlotPosition(index, 1)
|
||||
teamTiles.add(PokemonTile(slotX, slotY, pokemon, this, false))
|
||||
}
|
||||
preview.opponent.forEachIndexed { index, pokemon ->
|
||||
if (pokemon == null) return@forEachIndexed
|
||||
val (slotX, slotY) = getSlotPosition(index, 2)
|
||||
opponentTiles.add(PokemonTile(slotX, slotY, pokemon, this, true))
|
||||
}
|
||||
}
|
||||
|
||||
fun getSlotPosition(index: Int, side: Int): Pair<Float, Float> {
|
||||
val startX = if (side == 1) 10 else width - 10 - (41 + SLOT_HORIZONTAL_SPACING) * 2
|
||||
val startY = y + 15
|
||||
val row = index / 2
|
||||
val column = index % 2
|
||||
val slotX = startX.toFloat() + column * (SLOT_HORIZONTAL_SPACING + 41)
|
||||
val slotY = startY.toFloat() + row * (SLOT_VERTICAL_SPACING + 39)
|
||||
return Pair(slotX, slotY)
|
||||
}
|
||||
|
||||
private fun getHoveredTile(team: Boolean, mouseX: Int, mouseY: Int): Int {
|
||||
val tiles = if (team) teamTiles else opponentTiles
|
||||
return tiles.indexOfFirst { it.isHovered(mouseX.toDouble(), mouseY.toDouble()) }
|
||||
}
|
||||
|
||||
override fun renderWidget(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
|
||||
val matrixStack = context.pose()
|
||||
val mc = Minecraft.getInstance()
|
||||
blitk(
|
||||
matrixStack = matrixStack,
|
||||
texture = underlayTexture,
|
||||
x = x,
|
||||
y = y,
|
||||
width = width,
|
||||
height = BACKGROUND_HEIGHT
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = matrixStack,
|
||||
texture = title,
|
||||
x = (mc.window.guiScaledWidth / 2) - (103 / 2),
|
||||
y = 4,
|
||||
width = 103,
|
||||
height = 22
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.team_preview.title".asTranslated().bold(),
|
||||
x = (mc.window.guiScaledWidth / 2),
|
||||
y = 6,
|
||||
scale = 0.75f,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
val totalSecondsRemaining = Duration.between(Instant.now(), preview.mustPickBy).seconds
|
||||
val minutesRemaining = max(0, totalSecondsRemaining / 60)
|
||||
val secondsRemaining = max(0, totalSecondsRemaining % 60)
|
||||
val secondsRemainingStr = String.format("%02d", secondsRemaining)
|
||||
val timer = "$minutesRemaining:$secondsRemainingStr"
|
||||
val text = when {
|
||||
totalSecondsRemaining <= 15 -> timer.text().red().bold()
|
||||
totalSecondsRemaining <= 30 -> timer.text().yellow().bold()
|
||||
else -> timer.text().bold()
|
||||
}
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = text,
|
||||
x = (mc.window.guiScaledWidth / 2) + 2,
|
||||
y = 15,
|
||||
scale = 0.75f,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
|
||||
val ellipsis = ".".repeat(3 - (secondsRemaining % 3).toInt())
|
||||
if (preview.selection.size == preview.selections) {
|
||||
blitk(
|
||||
matrixStack = matrixStack,
|
||||
texture = checkmark,
|
||||
x = (mc.window.guiScaledWidth / 2) - 39,
|
||||
y = 24,
|
||||
width = 8,
|
||||
height = 6
|
||||
)
|
||||
val offset = when (ellipsis.length) {
|
||||
1 -> 0.5
|
||||
2 -> 1.0
|
||||
else -> 2.0
|
||||
}
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.team_preview.waiting".asTranslated(ellipsis).bold(),
|
||||
x = (mc.window.guiScaledWidth / 2) + 2.0 + offset,
|
||||
y = 26,
|
||||
scale = 0.5f,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
blitk(
|
||||
matrixStack = matrixStack,
|
||||
texture = cobblemonResource("textures/gui/battle/name_plate.png"),
|
||||
x = 10,
|
||||
y = y - 8,
|
||||
width = 128,
|
||||
height = 8
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = mc.player!!.name.string.text(),
|
||||
y = y - 8 + 2,
|
||||
x = x + 14 + 10,
|
||||
scale = SCALE,
|
||||
shadow = true
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = matrixStack,
|
||||
texture = cobblemonResource("textures/gui/battle/nameplate_reversed.png"),
|
||||
x = mc.window.guiScaledWidth - 14 - 128,
|
||||
y = y - 8,
|
||||
width = 128,
|
||||
height = 8
|
||||
)
|
||||
|
||||
drawScaledTextJustifiedRight(
|
||||
context = context,
|
||||
text = preview.opponentName.string.text(),
|
||||
y = y - 8 + 2,
|
||||
x = mc.window.guiScaledWidth - 14 - 12,
|
||||
scale = SCALE,
|
||||
shadow = true
|
||||
)
|
||||
|
||||
teamTiles.forEachIndexed { index, tile ->
|
||||
val hoveredTile = getHoveredTile(true, mouseX, mouseY)
|
||||
if (shouldHide(hoveredTile, index, false)) return@forEachIndexed
|
||||
tile.render(context, mouseX.toDouble(), mouseY.toDouble(), delta)
|
||||
}
|
||||
opponentTiles.forEachIndexed { index, tile ->
|
||||
val hoveredTile = getHoveredTile(false, mouseX, mouseY)
|
||||
if (shouldHide(hoveredTile, index, true)) return@forEachIndexed
|
||||
tile.render(context, mouseX.toDouble(), mouseY.toDouble(), delta)
|
||||
}
|
||||
}
|
||||
|
||||
private fun shouldHide(hoveredTile: Int, currentTile: Int, reversed: Boolean): Boolean {
|
||||
if (hoveredTile != -1) {
|
||||
val hoveredRow = hoveredTile / 2
|
||||
val hoveredColumn = hoveredTile % 2
|
||||
val currentRow = currentTile / 2
|
||||
val currentColumn = currentTile % 2
|
||||
if (!reversed && hoveredColumn < currentColumn && hoveredRow <= currentRow) return true
|
||||
if (reversed && hoveredColumn > currentColumn && hoveredRow <= currentRow) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun mouseClicked(pMouseX: Double, pMouseY: Double, pButton: Int): Boolean {
|
||||
val tile = teamTiles.firstOrNull { it.isHovered(pMouseX, pMouseY) }
|
||||
if (tile != null && tile.pokemonDto in preview.team) {
|
||||
if (pButton == InputConstants.MOUSE_BUTTON_LEFT) {
|
||||
if (tile.pokemonDto !in preview.selection && preview.selection.size < preview.selections) {
|
||||
preview.select(tile.pokemonDto)
|
||||
}
|
||||
}
|
||||
else if (pButton == InputConstants.MOUSE_BUTTON_RIGHT) {
|
||||
if (tile.pokemonDto in preview.selection) {
|
||||
preview.unselect(tile.pokemonDto)
|
||||
}
|
||||
}
|
||||
}
|
||||
playDownSound(Minecraft.getInstance().soundManager)
|
||||
return super.mouseClicked(pMouseX, pMouseY, pButton)
|
||||
}
|
||||
|
||||
override fun defaultButtonNarrationText(builder: NarrationElementOutput) {
|
||||
}
|
||||
|
||||
override fun playDownSound(soundManager: SoundManager) {
|
||||
soundManager.play(SimpleSoundInstance.forUI(CobblemonSounds.GUI_CLICK, 1.0F))
|
||||
}
|
||||
|
||||
override fun narrationPriority() = NarratableEntry.NarrationPriority.HOVERED
|
||||
|
||||
class PokemonTile(
|
||||
val x: Float,
|
||||
val y: Float,
|
||||
val pokemonDto: BattlePokemonDTO,
|
||||
val widget: TeamPreviewWidget,
|
||||
val reversed: Boolean
|
||||
) {
|
||||
companion object {
|
||||
const val SELECT_WIDTH = 41
|
||||
const val SELECT_HEIGHT = 39
|
||||
const val SCALE = 0.5F
|
||||
val expandedPokemonInfo = cobblemonResource("textures/gui/battle/expanded_pokemon_info_center.png")
|
||||
|
||||
val pokemonTile = cobblemonResource("textures/gui/battle/pokemon_tile.png")
|
||||
val pokemonTileReversed = cobblemonResource("textures/gui/battle/pokemon_tile_reversed.png")
|
||||
val pokemonTileDisabled = cobblemonResource("textures/gui/battle/pokemon_tile_disabled.png")
|
||||
val pokemonTileDisabledReversed = cobblemonResource("textures/gui/battle/pokemon_tile_disabled_reversed.png")
|
||||
val pokemonTileSelected = cobblemonResource("textures/gui/battle/pokemon_tile_selected.png")
|
||||
val pokemonTileSelectedReversed = cobblemonResource("textures/gui/battle/pokemon_tile_selected_reversed.png")
|
||||
|
||||
val hoverGapSelected = cobblemonResource("textures/gui/battle/hover_gap_selected.png")
|
||||
val hoverGap = cobblemonResource("textures/gui/battle/hover_gap.png")
|
||||
val hoverGapReversed = cobblemonResource("textures/gui/battle/hover_gap_reversed.png")
|
||||
|
||||
private val decimalFormat = DecimalFormat("0.00").also {
|
||||
it.roundingMode = RoundingMode.CEILING
|
||||
}
|
||||
}
|
||||
|
||||
val state = FloatingState()
|
||||
|
||||
fun isHovered(mouseX: Double, mouseY: Double) = mouseX in x..(x + SELECT_WIDTH) && mouseY in (y..(y + SELECT_HEIGHT))
|
||||
|
||||
fun render(context: GuiGraphics, mouseX: Double, mouseY: Double, deltaTicks: Float) {
|
||||
val pokemon = pokemonDto.activeBattlePokemonDTO ?: return
|
||||
val battlePokemon = ClientBattlePokemon(
|
||||
uuid = pokemon.uuid,
|
||||
properties = pokemon.properties,
|
||||
aspects = pokemon.aspects,
|
||||
displayName = pokemon.displayName,
|
||||
hpValue = pokemon.hpValue,
|
||||
maxHp = pokemon.maxHp,
|
||||
isHpFlat = pokemon.isFlatHp,
|
||||
status = pokemon.status,
|
||||
statChanges = pokemon.statChanges,
|
||||
)
|
||||
state.currentAspects = pokemon.aspects
|
||||
val matrixStack = context.pose()
|
||||
val isFainted = pokemonDto.fainted
|
||||
val isSelected = pokemonDto in widget.preview.selection
|
||||
|
||||
blitk(
|
||||
matrixStack = matrixStack,
|
||||
texture = cobblemonResource("textures/gui/battle/battle_info_underlay.png"),
|
||||
x = x + 5 + (if (reversed) 3 else 0),
|
||||
y = y + 4,
|
||||
width = 28,
|
||||
height = 28
|
||||
)
|
||||
val speciesToDisplay = battlePokemon.species
|
||||
val stateToDisplay = battlePokemon.state
|
||||
context.enableScissor(
|
||||
(x + 5 + (if (reversed) 3 else 0)).toInt(),
|
||||
(y + 5).toInt(),
|
||||
(x + 5 + 28 + (if (reversed) 3 else 0)).toInt(),
|
||||
(y + 5 + 28).toInt(),
|
||||
)
|
||||
matrixStack.pushPose()
|
||||
matrixStack.translate(
|
||||
x + (if (reversed) 3 else 0) + 5 + 28 / 2.0,
|
||||
y.toDouble() + 5 - 5.0,
|
||||
0.0
|
||||
)
|
||||
drawCustomPosablePortrait(
|
||||
identifier = speciesToDisplay.resourceIdentifier,
|
||||
matrixStack = matrixStack,
|
||||
scale = 18f,
|
||||
contextScale = speciesToDisplay.getForm(stateToDisplay.currentAspects).baseScale,
|
||||
reversed = reversed,
|
||||
doQuirks = false,
|
||||
state = stateToDisplay,
|
||||
partialTicks = if (Cobblemon.config.animateBattleTiles) deltaTicks else 0F
|
||||
)
|
||||
matrixStack.popPose()
|
||||
context.disableScissor()
|
||||
|
||||
val tile = if (reversed) pokemonTileReversed else pokemonTile
|
||||
val disabled = if (reversed) pokemonTileDisabledReversed else pokemonTileDisabled
|
||||
val selected = if (reversed) pokemonTileSelectedReversed else pokemonTileSelected
|
||||
if (isFainted) {
|
||||
blitk(
|
||||
matrixStack = matrixStack,
|
||||
texture = disabled,
|
||||
x = x,
|
||||
y = y,
|
||||
width = 41,
|
||||
height = 39
|
||||
)
|
||||
}
|
||||
else if (isSelected) {
|
||||
blitk(
|
||||
matrixStack = matrixStack,
|
||||
texture = selected,
|
||||
x = x,
|
||||
y = y,
|
||||
width = 41,
|
||||
height = 39
|
||||
)
|
||||
|
||||
val selectionIndex = widget.preview.selection.indexOf(pokemonDto)
|
||||
if (selectionIndex != -1) {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
font = CobblemonResources.DEFAULT_LARGE,
|
||||
text = "${selectionIndex + 1}".text().bold(),
|
||||
x = x + 34,
|
||||
y = y + 29,
|
||||
scale = 1.25f,
|
||||
opacity = 1f,
|
||||
shadow = true
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
blitk(
|
||||
matrixStack = matrixStack,
|
||||
texture = tile,
|
||||
x = x,
|
||||
y = y,
|
||||
width = 41,
|
||||
height = 39
|
||||
)
|
||||
}
|
||||
|
||||
if (isHovered(mouseX, mouseY)) {
|
||||
renderExpandedInfo(context, isSelected, reversed, battlePokemon, pokemonDto)
|
||||
}
|
||||
}
|
||||
|
||||
private fun renderExpandedInfo(context: GuiGraphics, selected: Boolean, reversed: Boolean, pokemon: ClientBattlePokemon, dto: BattlePokemonDTO) {
|
||||
context.pose().pushPose()
|
||||
context.pose().translate(0.0, 0.0, 300.0)
|
||||
val startX = if (reversed) x - 136 else x + 40
|
||||
val startY = y
|
||||
val species = pokemon.species
|
||||
val form = species.getForm(pokemon.state.currentAspects)
|
||||
val expandedInfoTexture = expandedPokemonInfo
|
||||
|
||||
if (selected) {
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = hoverGapSelected,
|
||||
x = startX - 3,
|
||||
y = startY,
|
||||
height = 30,
|
||||
width = 4,
|
||||
textureHeight = 30,
|
||||
textureWidth = 4,
|
||||
)
|
||||
}
|
||||
else {
|
||||
val gap = if (reversed) hoverGapReversed else hoverGap
|
||||
val xOffset = if (reversed) 136 else -7
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = gap,
|
||||
x = startX + xOffset,
|
||||
y = startY,
|
||||
height = 36,
|
||||
width = 8,
|
||||
textureHeight = 36,
|
||||
textureWidth = 8,
|
||||
)
|
||||
}
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = expandedInfoTexture,
|
||||
x = startX,
|
||||
y = startY,
|
||||
height = 112,
|
||||
width = 137,
|
||||
textureHeight = 112,
|
||||
textureWidth = 137,
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.label.pokemon_form".asTranslated().bold(),
|
||||
x = startX + 36,
|
||||
y = startY + 6.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getFormText(species, form),
|
||||
x = startX + 36,
|
||||
y = startY + 13.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.label.buffs".asTranslated().bold(),
|
||||
x = startX + 36,
|
||||
y = startY + 23.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.attack.name".asTranslated(),
|
||||
x = startX + 10,
|
||||
y = startY + 31.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs.get(Stats.ATTACK)?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getMultiplierText(it),
|
||||
x = startX + 50,
|
||||
y = startY + 31.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.defence.name".asTranslated(),
|
||||
x = startX + 10,
|
||||
y = startY + 39.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs.get(Stats.DEFENCE)?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getMultiplierText(it),
|
||||
x = startX + 50,
|
||||
y = startY + 39.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.stats.special_attack".asTranslated(),
|
||||
x = startX + 10,
|
||||
y = startY + 47.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs.get(Stats.SPECIAL_ATTACK)?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getMultiplierText(it),
|
||||
x = startX + 50,
|
||||
y = startY + 47.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.stats.special_defence".asTranslated(),
|
||||
x = startX + 10,
|
||||
y = startY + 55.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs.get(Stats.SPECIAL_DEFENCE)?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getMultiplierText(it),
|
||||
x = startX + 50,
|
||||
y = startY + 55.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.speed.name".asTranslated(),
|
||||
x = startX + 10,
|
||||
y = startY + 63.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs.get(Stats.SPEED)?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getMultiplierText(it),
|
||||
x = startX + 50,
|
||||
y = startY + 63.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.accuracy.name".asTranslated(),
|
||||
x = startX + 10,
|
||||
y = startY + 71.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs.get(Stats.ACCURACY)?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getMultiplierText(it),
|
||||
x = startX + 50,
|
||||
y = startY + 71.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.evasion.name".asTranslated(),
|
||||
x = startX + 10,
|
||||
y = startY + 79.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto?.buffs?.get(Stats.EVASION)?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getMultiplierText(it),
|
||||
x = startX + 50,
|
||||
y = startY + 79.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.label.ability".asTranslated().bold(),
|
||||
x = startX + 100,
|
||||
y = startY + 6.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
val ability = dto.ability?.let { Abilities.get(it) }
|
||||
val abilityName = ability?.displayName?.asTranslated() ?: "?".text()
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = abilityName,
|
||||
x = startX + 100,
|
||||
y = startY + 13.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.label.moves".asTranslated().bold(),
|
||||
x = startX + 100,
|
||||
y = startY + 23.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
if (dto.moves.size != 4) {
|
||||
for (i in 0 until 4) {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "?".text(),
|
||||
x = startX + 100,
|
||||
y = startY + 31.5 + i * 8,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
val questionMarkText = "?".text()
|
||||
dto.moves.forEachIndexed { index, moveDTO ->
|
||||
val move = moveDTO?.move ?: questionMarkText
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = move.string.text(),
|
||||
x = if (move == questionMarkText) startX + 100 else startX + 74,
|
||||
y = startY + 31.5 + index * 8,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = move == questionMarkText
|
||||
)
|
||||
|
||||
if (moveDTO != null) {
|
||||
drawScaledTextJustifiedRight(
|
||||
context = context,
|
||||
text = moveDTO.timesUsed.toString().text(),
|
||||
x = startX + 127.5,
|
||||
y = startY + 31.5 + index * 8,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dto.speed != null) {
|
||||
val speed = dto.speed
|
||||
val speedBoost = dto.buffs.get(Stats.SPEED) ?: 1.0
|
||||
val speedAfterBoost = (speed * speedBoost).toInt()
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.speed.name".asTranslated(),
|
||||
x = startX + 100,
|
||||
y = startY + 65.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = speedAfterBoost.toString().text(),
|
||||
x = startX + 100,
|
||||
y = startY + 72.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
else {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.label.speed_tier".asTranslated(),
|
||||
x = startX + 100,
|
||||
y = startY + 65.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
val speedBoost = dto.buffs.get(Stats.SPEED) ?: 1.0
|
||||
val speedTier = getSpeedRange(form, pokemon.level, speedBoost)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = speedTier,
|
||||
x = startX + 100,
|
||||
y = startY + 72.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.label.held_item".asTranslated(),
|
||||
x = startX + 40,
|
||||
y = startY + 99.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
TypeIcon(
|
||||
x = startX + 100.5,
|
||||
y = startY + 88,
|
||||
type = form.primaryType,
|
||||
secondaryType = form.secondaryType,
|
||||
small = false,
|
||||
centeredX = true
|
||||
).render(context)
|
||||
|
||||
if (form.secondaryType != null) {
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = cobblemonResource("textures/gui/battle/type_spacer_double.png"),
|
||||
x = (startX + 69.0) / 0.45,
|
||||
y = (startY + 91.5) / 0.45,
|
||||
height = 24,
|
||||
width = 140,
|
||||
textureHeight = 24,
|
||||
textureWidth = 140,
|
||||
scale = 0.45f
|
||||
)
|
||||
}
|
||||
else {
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = cobblemonResource("textures/gui/summary/type_spacer.png"),
|
||||
x = (startX + 70.5) / 0.45,
|
||||
y = (startY + 91.5) / 0.45,
|
||||
height = 24,
|
||||
width = 132,
|
||||
textureHeight = 24,
|
||||
textureWidth = 132,
|
||||
scale = 0.45f
|
||||
)
|
||||
}
|
||||
|
||||
val heldItem = dto.heldItem
|
||||
if (heldItem != null && !heldItem.isEmpty()) {
|
||||
context.pose().pushPose()
|
||||
context.pose().scale(0.95F, 0.95F, 0.95F)
|
||||
val itemX = (startX + 4) / 0.95
|
||||
val itemY = (startY + 91) / 0.95
|
||||
context.renderItem(heldItem, itemX.toInt(), itemY.toInt())
|
||||
context.pose().popPose()
|
||||
}
|
||||
else {
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = questionMarkIcon,
|
||||
x = startX + 6,
|
||||
y = startY + 92.5,
|
||||
height = 11,
|
||||
width = 10,
|
||||
)
|
||||
}
|
||||
context.pose().popPose()
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun drawCustomPosablePortrait(
|
||||
identifier: ResourceLocation,
|
||||
matrixStack: PoseStack,
|
||||
scale: Float = 13F,
|
||||
contextScale: Float = 1F,
|
||||
reversed: Boolean = false,
|
||||
state: PosableState,
|
||||
partialTicks: Float,
|
||||
limbSwing: Float = 0F,
|
||||
limbSwingAmount: Float = 0F,
|
||||
ageInTicks: Float = 0F,
|
||||
headYaw: Float = 0F,
|
||||
headPitch: Float = 0F,
|
||||
r: Float = 1F,
|
||||
g: Float = 1F,
|
||||
b: Float = 1F,
|
||||
a: Float = 1F,
|
||||
doQuirks: Boolean = true
|
||||
) {
|
||||
RenderSystem.applyModelViewMatrix()
|
||||
matrixStack.pushPose()
|
||||
matrixStack.translate(0.0, PORTRAIT_DIAMETER.toDouble() + 2.0, 0.0)
|
||||
matrixStack.scale(scale, scale, -scale)
|
||||
matrixStack.translate(0.0, -PORTRAIT_DIAMETER / 18.0, 0.0)
|
||||
|
||||
val sprite = VaryingModelRepository.getSprite(identifier, state, SpriteType.PORTRAIT);
|
||||
|
||||
if (sprite == null) {
|
||||
val model = VaryingModelRepository.getPoser(identifier, state)
|
||||
state.currentModel = model
|
||||
val texture = VaryingModelRepository.getTexture(identifier, state)
|
||||
|
||||
val context = RenderContext()
|
||||
model.context = context
|
||||
VaryingModelRepository.getTextureNoSubstitute(identifier, state).let { context.put(RenderContext.TEXTURE, it) }
|
||||
context.put(RenderContext.SCALE, contextScale)
|
||||
context.put(RenderContext.SPECIES, identifier)
|
||||
context.put(RenderContext.ASPECTS, state.currentAspects)
|
||||
context.put(RenderContext.POSABLE_STATE, state)
|
||||
context.put(RenderContext.DO_QUIRKS, doQuirks)
|
||||
|
||||
val renderType = RenderType.entityCutout(texture)
|
||||
|
||||
val quaternion1 = Axis.YP.rotationDegrees(-32F * if (reversed) -1F else 1F)
|
||||
val quaternion2 = Axis.XP.rotationDegrees(5F)
|
||||
|
||||
val originalPose = state.currentPose
|
||||
state.setPoseToFirstSuitable(PoseType.PORTRAIT)
|
||||
state.updatePartialTicks(partialTicks)
|
||||
model.applyAnimations(null, state, limbSwing, limbSwingAmount, ageInTicks, headYaw, headPitch)
|
||||
originalPose?.let { state.setPose(it) }
|
||||
|
||||
matrixStack.translate(
|
||||
model.portraitTranslation.x * if (reversed) -1F else 1F,
|
||||
model.portraitTranslation.y + 1.5 * model.portraitScale,
|
||||
model.portraitTranslation.z - 4
|
||||
)
|
||||
matrixStack.scale(model.portraitScale, model.portraitScale, 1 / model.portraitScale)
|
||||
matrixStack.mulPose(quaternion1)
|
||||
matrixStack.mulPose(quaternion2)
|
||||
|
||||
val light1 = Vector3f(0.2F, 1.0F, -1.0F)
|
||||
val light2 = Vector3f(0.1F, 0.0F, 8.0F)
|
||||
RenderSystem.setShaderLights(light1, light2)
|
||||
quaternion1.conjugate()
|
||||
|
||||
val immediate = Minecraft.getInstance().renderBuffers().bufferSource()
|
||||
val buffer = immediate.getBuffer(renderType)
|
||||
val packedLight = LightTexture.pack(11, 7)
|
||||
|
||||
val colour = toHex(r, g, b, a)
|
||||
model.withLayerContext(immediate, state, VaryingModelRepository.getLayers(identifier, state)) {
|
||||
model.render(context, matrixStack, buffer, packedLight, OverlayTexture.NO_OVERLAY, colour)
|
||||
immediate.endBatch()
|
||||
}
|
||||
|
||||
model.setDefault()
|
||||
|
||||
Lighting.setupFor3DItems()
|
||||
} else {
|
||||
renderSprite(matrixStack, sprite)
|
||||
}
|
||||
|
||||
matrixStack.popPose()
|
||||
}
|
||||
|
||||
private fun getSpeedRange(form: FormData, level: Int, speedBoost: Double): MutableComponent {
|
||||
val base = form.baseStats[Stats.SPEED] ?: 0
|
||||
val maxIV = 31
|
||||
val maxEV = 252
|
||||
val minNatureMod = 0.9
|
||||
val maxNatureMod = 1.1
|
||||
|
||||
val minSpeed = getStat(base, level, 0, 0, minNatureMod) * speedBoost
|
||||
val maxSpeed = getStat(base, level, maxIV, maxEV, maxNatureMod) * speedBoost
|
||||
return "cobblemon.battle.ui.speed_tier".asTranslated(minSpeed.toInt(), maxSpeed.toInt())
|
||||
}
|
||||
|
||||
private fun getStat(base: Int, level: Int, iv: Int, ev: Int, natureMod: Double): Int {
|
||||
return floor((floor(((2.0 * base + iv + floor(ev / 4.0)) * level) / 100) + 5) * natureMod).toInt()
|
||||
}
|
||||
|
||||
private fun getMultiplierText(multiplier: Double): MutableComponent {
|
||||
val rounded = decimalFormat.format(multiplier)
|
||||
val str = "x$rounded"
|
||||
return when {
|
||||
multiplier > 1.0 -> str.green()
|
||||
multiplier < 1.0 -> str.red()
|
||||
else -> str.text()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getFormText(species: Species, form: FormData): MutableComponent {
|
||||
val speciesName = species.name
|
||||
val formName = form.name
|
||||
return if (formName == "Normal") speciesName.text() else "$speciesName-$formName".text()
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-9
@@ -8,8 +8,6 @@
|
||||
|
||||
package com.cobblemon.mod.common.client.gui.battle.subscreen
|
||||
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonSounds
|
||||
import com.cobblemon.mod.common.api.battles.model.actor.ActorType
|
||||
import com.cobblemon.mod.common.battles.FleeAttemptActionResponse
|
||||
@@ -76,12 +74,6 @@ class BattleGeneralActionSelection(
|
||||
battleGUI.changeActionSelection(ForfeitConfirmationSelection(battleGUI, request))
|
||||
playDownSound(Minecraft.getInstance().soundManager)
|
||||
}
|
||||
if (battle.side2.actors.all { it.type == ActorType.PLAYER }) {
|
||||
addOption(rank++, battleLang("ui.team_info.button"), cobblemonResource("textures/gui/battle/team_info.png")) {
|
||||
battleGUI.changeActionSelection(BattleTeamInfoSelection(battleGUI, request))
|
||||
playDownSound(Minecraft.getInstance().soundManager)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,4 +121,4 @@ class BattleGeneralActionSelection(
|
||||
}
|
||||
|
||||
override fun narrationPriority() = NarratableEntry.NarrationPriority.NONE
|
||||
}
|
||||
}
|
||||
+7
-294
@@ -10,41 +10,27 @@ package com.cobblemon.mod.common.client.gui.battle.subscreen
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonSounds
|
||||
import com.cobblemon.mod.common.api.gui.blitk
|
||||
import com.cobblemon.mod.common.api.moves.MoveTemplate
|
||||
import com.cobblemon.mod.common.api.moves.Moves
|
||||
import com.cobblemon.mod.common.api.moves.categories.DamageCategories
|
||||
import com.cobblemon.mod.common.api.text.bold
|
||||
import com.cobblemon.mod.common.api.text.gold
|
||||
import com.cobblemon.mod.common.api.text.red
|
||||
import com.cobblemon.mod.common.api.text.text
|
||||
import com.cobblemon.mod.common.battles.*
|
||||
import com.cobblemon.mod.common.client.CobblemonClient
|
||||
import com.cobblemon.mod.common.client.CobblemonResources
|
||||
import com.cobblemon.mod.common.client.battle.Effectiveness
|
||||
import com.cobblemon.mod.common.client.battle.MoveEffectivenessCalculator
|
||||
import com.cobblemon.mod.common.client.battle.SingleActionRequest
|
||||
import com.cobblemon.mod.common.client.gui.MoveCategoryIcon
|
||||
import com.cobblemon.mod.common.client.gui.TypeIcon
|
||||
import com.cobblemon.mod.common.client.gui.battle.BattleGUI
|
||||
import com.cobblemon.mod.common.client.gui.summary.widgets.screens.moves.MovesWidget
|
||||
import com.cobblemon.mod.common.client.render.drawScaledText
|
||||
import com.cobblemon.mod.common.client.render.drawScaledTextJustifiedRight
|
||||
import com.cobblemon.mod.common.util.asTranslated
|
||||
import com.cobblemon.mod.common.util.battleLang
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import com.cobblemon.mod.common.util.lang
|
||||
import com.cobblemon.mod.common.util.math.toRGB
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance
|
||||
import net.minecraft.client.sounds.SoundManager
|
||||
import net.minecraft.locale.Language
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.MutableComponent
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.util.Mth.floor
|
||||
import java.math.RoundingMode
|
||||
import java.text.DecimalFormat
|
||||
|
||||
class BattleMoveSelection(
|
||||
battleGUI: BattleGUI,
|
||||
@@ -65,21 +51,7 @@ class BattleMoveSelection(
|
||||
const val MOVE_HORIZONTAL_SPACING = 13F
|
||||
|
||||
val moveTexture = cobblemonResource("textures/gui/battle/battle_move.png")
|
||||
val moveOverlayTexture = cobblemonResource("textures/gui/battle/move_outline.png")
|
||||
val moveTooltipIcon = cobblemonResource("textures/gui/battle/move_tooltip_icon.png")
|
||||
val moveTooltip = cobblemonResource("textures/gui/battle/move_tooltip.png")
|
||||
val moveTooltipForStatus = cobblemonResource("textures/gui/battle/move_tooltip_status.png")
|
||||
|
||||
val effectiveIcon = cobblemonResource("textures/gui/battle/effective_icon.png")
|
||||
val extremelyEffectiveIcon = cobblemonResource("textures/gui/battle/extremely_effective_icon.png")
|
||||
val immuneIcon = cobblemonResource("textures/gui/battle/immune_icon.png")
|
||||
val mostlyIneffectiveIcon = cobblemonResource("textures/gui/battle/mostly_ineffective_icon.png")
|
||||
val superEffectiveIcon = cobblemonResource("textures/gui/battle/super_effective_icon.png")
|
||||
val notVeryEffectiveIcon = cobblemonResource("textures/gui/battle/not_very_effective_icon.png")
|
||||
|
||||
private val decimalFormat = DecimalFormat("#.##").also {
|
||||
it.roundingMode = RoundingMode.CEILING
|
||||
}
|
||||
val moveOverlayTexture = cobblemonResource("textures/gui/battle/battle_move_overlay.png")
|
||||
}
|
||||
|
||||
val moveSet = request.moveSet!!
|
||||
@@ -102,7 +74,7 @@ class BattleMoveSelection(
|
||||
BattleGimmickButton.create(gimmick, this, backButton.x + xOff, backButton.y)
|
||||
}
|
||||
|
||||
val shiftButton = BattleShiftButton(x + 22.5F, Minecraft.getInstance().window.guiScaledHeight - 22F)
|
||||
val shiftButton = BattleShiftButton(x + 22.5F, Minecraft.getInstance().window.guiScaledHeight - 22F )
|
||||
|
||||
open class MoveTile(
|
||||
val moveSelection: BattleMoveSelection,
|
||||
@@ -166,7 +138,7 @@ class BattleMoveSelection(
|
||||
|
||||
// Move Category
|
||||
MoveCategoryIcon(
|
||||
x = x + 41,
|
||||
x = x + 48,
|
||||
y = y + 14.5,
|
||||
category = moveTemplate.damageCategory,
|
||||
opacity = moveSelection.opacity
|
||||
@@ -196,265 +168,14 @@ class BattleMoveSelection(
|
||||
context = context,
|
||||
font = CobblemonResources.DEFAULT_LARGE,
|
||||
text = movePPText,
|
||||
x = x + 67,
|
||||
x = x + 75,
|
||||
y = y + 14,
|
||||
opacity = moveSelection.opacity,
|
||||
centered = true
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = moveTooltipIcon,
|
||||
x = x + 82,
|
||||
y = y + 14,
|
||||
width = 9,
|
||||
height = 9,
|
||||
textureHeight = 18,
|
||||
textureWidth = 9,
|
||||
alpha = moveSelection.opacity,
|
||||
vOffset = if (isTooltipHovered(mouseX.toDouble(), mouseY.toDouble())) 9 else 0
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
font = CobblemonResources.DEFAULT_LARGE,
|
||||
text = "i".text().bold(),
|
||||
x = x + 87.375,
|
||||
y = y + 14,
|
||||
opacity = moveSelection.opacity,
|
||||
centered = true
|
||||
)
|
||||
|
||||
if (isTooltipHovered(mouseX.toDouble(), mouseY.toDouble())) {
|
||||
renderTooltip(context)
|
||||
}
|
||||
}
|
||||
|
||||
fun renderTooltip(context: GuiGraphics) {
|
||||
val tooltipY = Minecraft.getInstance().window.guiScaledHeight - 84 - 59 - 4
|
||||
val tooltipX = 20
|
||||
|
||||
val move = moveTemplate
|
||||
|
||||
val effectiveness = getMoveEffectiveness(move)
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = if (effectiveness == null) moveTooltipForStatus else moveTooltip,
|
||||
x = tooltipX,
|
||||
y = tooltipY,
|
||||
width = 195,
|
||||
height = 56,
|
||||
alpha = moveSelection.opacity
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = lang("ui.power"),
|
||||
x = tooltipX + 18,
|
||||
y = tooltipY + 11,
|
||||
opacity = moveSelection.opacity,
|
||||
centered = false,
|
||||
scale = 0.65f
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = MovesWidget.movesPowerIconResource,
|
||||
x = (tooltipX + 8.5) / 0.66f,
|
||||
y = (tooltipY + 9.5) / 0.66f,
|
||||
width = 10,
|
||||
height = 10,
|
||||
alpha = moveSelection.opacity,
|
||||
scale = 0.66f
|
||||
)
|
||||
|
||||
val powerStr = if (move.power <= 0) "—" else move.power.toInt().toString()
|
||||
|
||||
drawScaledTextJustifiedRight(
|
||||
context = context,
|
||||
text = powerStr.text(),
|
||||
x = tooltipX + 73,
|
||||
y = tooltipY + 11,
|
||||
opacity = moveSelection.opacity,
|
||||
scale = 0.65f
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = MovesWidget.movesAccuracyIconResource,
|
||||
x = (tooltipX + 8.5) / 0.66f,
|
||||
y = (tooltipY + 26) / 0.66f,
|
||||
width = 10,
|
||||
height = 10,
|
||||
alpha = moveSelection.opacity,
|
||||
scale = 0.66f
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = lang("ui.accuracy"),
|
||||
x = tooltipX + 18,
|
||||
y = tooltipY + 27,
|
||||
opacity = moveSelection.opacity,
|
||||
centered = false,
|
||||
scale = 0.65f
|
||||
)
|
||||
|
||||
val accuracyStr = format(move.accuracy).text()
|
||||
|
||||
drawScaledTextJustifiedRight(
|
||||
context = context,
|
||||
text = accuracyStr,
|
||||
x = tooltipX + 73,
|
||||
y = tooltipY + 27,
|
||||
opacity = moveSelection.opacity,
|
||||
scale = 0.65f
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = MovesWidget.movesEffectIconResource,
|
||||
x = (tooltipX + 8.5) / 0.66f,
|
||||
y = (tooltipY + 42.5) / 0.66f,
|
||||
width = 10,
|
||||
height = 10,
|
||||
alpha = moveSelection.opacity,
|
||||
scale = 0.66f
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = lang("ui.effect"),
|
||||
x = tooltipX + 18,
|
||||
y = tooltipY + 43.5,
|
||||
opacity = moveSelection.opacity,
|
||||
centered = false,
|
||||
scale = 0.65f
|
||||
)
|
||||
|
||||
val moveEffect = format(move.effectChances.firstOrNull() ?: 0.0).text()
|
||||
|
||||
drawScaledTextJustifiedRight(
|
||||
context = context,
|
||||
text = moveEffect,
|
||||
x = tooltipX + 73,
|
||||
y = tooltipY + 43.5,
|
||||
opacity = moveSelection.opacity,
|
||||
scale = 0.65f
|
||||
)
|
||||
|
||||
val moveDescription = move.description
|
||||
val lines = Minecraft.getInstance().font.splitter.splitLines(moveDescription, 200, moveDescription.style)
|
||||
val orderedLines = Language.getInstance().getVisualOrder(lines)
|
||||
val maxLines = if (effectiveness == null) 6 else 4
|
||||
orderedLines.take(maxLines).forEachIndexed { index, line ->
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = line,
|
||||
x = tooltipX + 85,
|
||||
y = tooltipY + 11 + (6 * index),
|
||||
opacity = moveSelection.opacity,
|
||||
scaleX = 0.5f,
|
||||
scaleY = 0.5f,
|
||||
centered = false
|
||||
)
|
||||
}
|
||||
|
||||
if (effectiveness == null) return
|
||||
val effectivenessText = getEffectivenessText(effectiveness)
|
||||
val effectivenessIcon = getEffectivenessIcon(effectiveness)
|
||||
val effectivenessValue = getEffectivenessValue(effectiveness)
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = effectivenessIcon,
|
||||
x = (tooltipX + 84) / 0.5f,
|
||||
y = (tooltipY + 43) / 0.5f,
|
||||
width = 12,
|
||||
height = 12,
|
||||
alpha = moveSelection.opacity,
|
||||
scale = 0.5f
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = effectivenessText,
|
||||
x = tooltipX + 94,
|
||||
y = tooltipY + 43.5,
|
||||
opacity = moveSelection.opacity,
|
||||
centered = false,
|
||||
scale = 0.65f
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = effectivenessValue,
|
||||
x = tooltipX + 168,
|
||||
y = tooltipY + 43.5,
|
||||
opacity = moveSelection.opacity,
|
||||
centered = false,
|
||||
scale = 0.65f
|
||||
)
|
||||
}
|
||||
|
||||
private fun getEffectivenessValue(effectiveness: Effectiveness): MutableComponent {
|
||||
return when (effectiveness) {
|
||||
Effectiveness.IMMUNE -> "0.00x".text()
|
||||
Effectiveness.MOSTLY_INEFFECTIVE -> "0.25x".text()
|
||||
Effectiveness.NOT_VERY_EFFECTIVE -> "0.50x".text()
|
||||
Effectiveness.EFFECTIVE -> "1.00x".text()
|
||||
Effectiveness.SUPER_EFFECTIVE -> "2.00x".text()
|
||||
Effectiveness.EXTREMELY_EFFECTIVE -> "4.00x".text()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getEffectivenessIcon(effectiveness: Effectiveness): ResourceLocation {
|
||||
return when (effectiveness) {
|
||||
Effectiveness.IMMUNE -> immuneIcon
|
||||
Effectiveness.MOSTLY_INEFFECTIVE -> mostlyIneffectiveIcon
|
||||
Effectiveness.NOT_VERY_EFFECTIVE -> notVeryEffectiveIcon
|
||||
Effectiveness.EFFECTIVE -> effectiveIcon
|
||||
Effectiveness.SUPER_EFFECTIVE -> superEffectiveIcon
|
||||
Effectiveness.EXTREMELY_EFFECTIVE -> extremelyEffectiveIcon
|
||||
}
|
||||
}
|
||||
|
||||
private fun getEffectivenessText(effectiveness: Effectiveness): MutableComponent {
|
||||
return when (effectiveness) {
|
||||
Effectiveness.IMMUNE -> "cobblemon.battle.ui.effectiveness.has_no_effect".asTranslated()
|
||||
Effectiveness.MOSTLY_INEFFECTIVE -> "cobblemon.battle.ui.effectiveness.mostly_ineffective".asTranslated()
|
||||
Effectiveness.NOT_VERY_EFFECTIVE -> "cobblemon.battle.ui.effectiveness.not_very_effective".asTranslated()
|
||||
Effectiveness.EFFECTIVE -> "cobblemon.battle.ui.effectiveness.effective".asTranslated()
|
||||
Effectiveness.SUPER_EFFECTIVE -> "cobblemon.battle.ui.effectiveness.super_effective".asTranslated()
|
||||
Effectiveness.EXTREMELY_EFFECTIVE -> "cobblemon.battle.ui.effectiveness.extremely_effective".asTranslated()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getMoveEffectiveness(move: MoveTemplate): Effectiveness? {
|
||||
val battle = CobblemonClient.battle ?: return null
|
||||
val opponents = battle.side2.activeClientBattlePokemon.toList()
|
||||
if (opponents.size != 1) return null
|
||||
val opponent = battle.side2.activeClientBattlePokemon.first().battlePokemon ?: return null
|
||||
|
||||
val aspects: Set<String> = opponent.state.currentAspects
|
||||
val opponentForm = opponent.species.getForm(aspects)
|
||||
if (move.damageCategory == DamageCategories.STATUS) return null
|
||||
return MoveEffectivenessCalculator.getMoveEffectiveness(move.elementalType, opponentForm.primaryType, opponentForm.secondaryType)
|
||||
}
|
||||
|
||||
fun format(input: Double): String {
|
||||
if (input <= 0) return "—"
|
||||
return "${decimalFormat.format(input)}%"
|
||||
}
|
||||
|
||||
fun isHovered(mouseX: Double, mouseY: Double): Boolean {
|
||||
return !isTooltipHovered(mouseX, mouseY) && mouseX >= x && mouseX <= x + MOVE_WIDTH && mouseY >= y && mouseY <= y + MOVE_HEIGHT
|
||||
}
|
||||
|
||||
fun isTooltipHovered(mouseX: Double, mouseY: Double): Boolean {
|
||||
return mouseX >= x + 82 && mouseX <= x + MOVE_WIDTH && mouseY >= y + 14 && mouseY <= y + MOVE_HEIGHT
|
||||
}
|
||||
fun isHovered(mouseX: Double, mouseY: Double) = mouseX >= x && mouseX <= x + MOVE_WIDTH && mouseY >= y && mouseY <= y + MOVE_HEIGHT
|
||||
|
||||
fun onClick() {
|
||||
if (!selectable) return
|
||||
@@ -483,15 +204,7 @@ class BattleMoveSelection(
|
||||
if(request.activePokemon.getFormat().battleType.pokemonPerSide == 1) {
|
||||
move.onClick()
|
||||
} else {
|
||||
battleGUI.changeActionSelection(
|
||||
BattleTargetSelection(
|
||||
battleGUI,
|
||||
request,
|
||||
move.move,
|
||||
move.response.gimmickID,
|
||||
move.move.gimmickMove
|
||||
)
|
||||
)
|
||||
battleGUI.changeActionSelection(BattleTargetSelection(battleGUI, request, move.move, move.response.gimmickID, move.move.gimmickMove))
|
||||
playDownSound(Minecraft.getInstance().soundManager)
|
||||
}
|
||||
return true
|
||||
@@ -511,4 +224,4 @@ class BattleMoveSelection(
|
||||
override fun playDownSound(soundManager: SoundManager) {
|
||||
soundManager.play(SimpleSoundInstance.forUI(CobblemonSounds.GUI_CLICK, 1.0F))
|
||||
}
|
||||
}
|
||||
}
|
||||
-880
@@ -1,880 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.gui.battle.subscreen
|
||||
|
||||
import com.cobblemon.mod.common.client.battle.SingleActionRequest
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.CobblemonSounds
|
||||
import com.cobblemon.mod.common.api.abilities.Abilities
|
||||
import com.cobblemon.mod.common.api.gui.blitk
|
||||
import com.cobblemon.mod.common.api.gui.renderSprite
|
||||
import com.cobblemon.mod.common.api.pokemon.stats.Stats
|
||||
import com.cobblemon.mod.common.api.text.bold
|
||||
import com.cobblemon.mod.common.api.text.font
|
||||
import com.cobblemon.mod.common.api.text.green
|
||||
import com.cobblemon.mod.common.api.text.red
|
||||
import com.cobblemon.mod.common.api.text.text
|
||||
import com.cobblemon.mod.common.client.CobblemonClient
|
||||
import com.cobblemon.mod.common.client.CobblemonResources
|
||||
import com.cobblemon.mod.common.client.battle.ClientBattleActor
|
||||
import com.cobblemon.mod.common.client.battle.ClientBattleInformationRepository
|
||||
import com.cobblemon.mod.common.client.battle.ClientBattlePokemon
|
||||
import com.cobblemon.mod.common.client.gui.TypeIcon
|
||||
import com.cobblemon.mod.common.client.gui.battle.BattleGUI
|
||||
import com.cobblemon.mod.common.client.gui.drawProfilePokemon
|
||||
import com.cobblemon.mod.common.client.render.drawScaledText
|
||||
import com.cobblemon.mod.common.client.render.drawScaledTextJustifiedRight
|
||||
import com.cobblemon.mod.common.client.render.getDepletableRedGreen
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.FloatingState
|
||||
import com.cobblemon.mod.common.client.render.renderScaledGuiItemIcon
|
||||
import com.cobblemon.mod.common.pokemon.FormData
|
||||
import com.cobblemon.mod.common.pokemon.Gender
|
||||
import com.cobblemon.mod.common.pokemon.Species
|
||||
import com.cobblemon.mod.common.util.asTranslated
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import com.cobblemon.mod.common.util.lang
|
||||
import com.cobblemon.mod.common.util.math.fromEulerXYZDegrees
|
||||
import com.cobblemon.mod.common.client.gui.battle.BattleOverlay
|
||||
import com.cobblemon.mod.common.client.gui.battle.BattlePokemonInfoPanel
|
||||
import com.cobblemon.mod.common.client.gui.battle.BattleOverlay.Companion.PORTRAIT_DIAMETER
|
||||
import com.cobblemon.mod.common.client.gui.battle.BattleOverlay.Companion.questionMarkIcon
|
||||
import com.cobblemon.mod.common.client.gui.battle.preview.TeamPreviewWidget
|
||||
import com.cobblemon.mod.common.client.render.SpriteType
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.VaryingModelRepository
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattlePokemonDTO
|
||||
import com.cobblemon.mod.common.util.toHex
|
||||
import com.mojang.blaze3d.platform.Lighting
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import com.mojang.math.Axis
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.gui.narration.NarratableEntry
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput
|
||||
import net.minecraft.client.renderer.LightTexture
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance
|
||||
import net.minecraft.client.sounds.SoundManager
|
||||
import net.minecraft.network.chat.MutableComponent
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import org.joml.Quaternionf
|
||||
import org.joml.Vector3f
|
||||
import java.math.RoundingMode
|
||||
import java.text.DecimalFormat
|
||||
import kotlin.collections.get
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.floor
|
||||
|
||||
class BattleTeamInfoSelection(
|
||||
battleGUI: BattleGUI,
|
||||
request: SingleActionRequest
|
||||
) : BattleActionSelection(
|
||||
battleGUI,
|
||||
request,
|
||||
x = 0,
|
||||
y = if (Minecraft.getInstance().window.guiScaledHeight > 304) (Minecraft.getInstance().window.guiScaledHeight / 2) - (BACKGROUND_HEIGHT / 2)
|
||||
else Minecraft.getInstance().window.guiScaledHeight - (BACKGROUND_HEIGHT + 78),
|
||||
width = Minecraft.getInstance().window.guiScaledWidth,
|
||||
height = Minecraft.getInstance().window.guiScaledHeight,
|
||||
"cobblemon.battle.ui.team_info".asTranslated()
|
||||
) {
|
||||
companion object {
|
||||
const val SLOT_HORIZONTAL_SPACING = 4F
|
||||
const val SLOT_VERTICAL_SPACING = 2F
|
||||
|
||||
const val BACKGROUND_HEIGHT = 148
|
||||
val underlayTexture = cobblemonResource("textures/gui/battle/selection_underlay.png")
|
||||
val title = cobblemonResource("textures/gui/battle/turn_counter.png")
|
||||
var visible = false
|
||||
}
|
||||
|
||||
val teamTiles = mutableListOf<PokemonTile>()
|
||||
val opponentTiles = mutableListOf<PokemonTile>()
|
||||
val backButton = BattleBackButton(x + 9F, Minecraft.getInstance().window.guiScaledHeight - 22F)
|
||||
|
||||
init {
|
||||
addTiles()
|
||||
}
|
||||
|
||||
fun addTiles() {
|
||||
val battle = CobblemonClient.battle ?: return
|
||||
|
||||
val actors = mutableListOf<ClientBattleActor>()
|
||||
battle.sides.forEach { side ->
|
||||
side.actors.forEach { actors.add(it) }
|
||||
}
|
||||
|
||||
if (actors.size != 2) return
|
||||
val displayOrder = if (actors.last().uuid == Minecraft.getInstance().player?.uuid) actors.reversed() else actors
|
||||
val actorToPokemon = displayOrder.map { it to ClientBattleInformationRepository.actors[it.uuid] }
|
||||
actorToPokemon.first().second?.forEachIndexed { index, pokemon ->
|
||||
val (slotX, slotY) = getSlotPosition(index, 1)
|
||||
teamTiles.add(PokemonTile(slotX, slotY, pokemon, this, false, actorToPokemon.first().first))
|
||||
}
|
||||
actorToPokemon.last().second?.forEachIndexed { index, pokemon ->
|
||||
val (slotX, slotY) = getSlotPosition(index, 2)
|
||||
opponentTiles.add(PokemonTile(slotX, slotY, pokemon, this, true, actorToPokemon.last().first))
|
||||
}
|
||||
}
|
||||
|
||||
fun getSlotPosition(index: Int, side: Int): Pair<Float, Float> {
|
||||
val startX = if (side == 1) 10 else width - 10 - (41 + TeamPreviewWidget.Companion.SLOT_HORIZONTAL_SPACING) * 2
|
||||
val startY = y + 15
|
||||
val row = index / 2
|
||||
val column = index % 2
|
||||
val slotX = startX.toFloat() + column * (SLOT_HORIZONTAL_SPACING + 41)
|
||||
val slotY = startY.toFloat() + row * (SLOT_VERTICAL_SPACING + 39)
|
||||
return Pair(slotX, slotY)
|
||||
}
|
||||
|
||||
private fun getHoveredTile(team: Boolean, mouseX: Int, mouseY: Int): Int {
|
||||
val tiles = if (team) teamTiles else opponentTiles
|
||||
return tiles.indexOfFirst { it.pokemonDto.activeBattlePokemonDTO != null && it.isHovered(mouseX.toDouble(), mouseY.toDouble()) }
|
||||
}
|
||||
|
||||
override fun renderWidget(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
|
||||
if (opacity <= 0.05F) return
|
||||
|
||||
val matrixStack = context.pose()
|
||||
val mc = Minecraft.getInstance()
|
||||
|
||||
blitk(
|
||||
matrixStack = matrixStack,
|
||||
texture = underlayTexture,
|
||||
x = x,
|
||||
y = y,
|
||||
width = width,
|
||||
height = BACKGROUND_HEIGHT
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = matrixStack,
|
||||
texture = title,
|
||||
x = (mc.window.guiScaledWidth / 2) - (103 / 2),
|
||||
y = 4,
|
||||
width = 103,
|
||||
height = 22
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.team_info.title".asTranslated().bold(),
|
||||
x = (mc.window.guiScaledWidth / 2),
|
||||
y = 6,
|
||||
scale = 0.75f,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
teamTiles.forEachIndexed { index, tile ->
|
||||
val hoveredTile = getHoveredTile(true, mouseX, mouseY)
|
||||
if (shouldHide(hoveredTile, index, false)) return@forEachIndexed
|
||||
tile.render(context, mouseX.toDouble(), mouseY.toDouble(), delta)
|
||||
}
|
||||
opponentTiles.forEachIndexed { index, tile ->
|
||||
val hoveredTile = getHoveredTile(false, mouseX, mouseY)
|
||||
if (shouldHide(hoveredTile, index, true)) return@forEachIndexed
|
||||
tile.render(context, mouseX.toDouble(), mouseY.toDouble(), delta)
|
||||
}
|
||||
backButton.render(context, mouseX, mouseY, delta)
|
||||
}
|
||||
|
||||
private fun shouldHide(hoveredTile: Int, currentTile: Int, reversed: Boolean): Boolean {
|
||||
if (hoveredTile != -1) {
|
||||
val hoveredRow = hoveredTile / 2
|
||||
val hoveredColumn = hoveredTile % 2
|
||||
val currentRow = currentTile / 2
|
||||
val currentColumn = currentTile % 2
|
||||
if (!reversed && hoveredColumn < currentColumn && hoveredRow <= currentRow) return true
|
||||
if (reversed && hoveredColumn > currentColumn && hoveredRow <= currentRow) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun mousePrimaryClicked(mouseX: Double, mouseY: Double): Boolean {
|
||||
if (backButton.isHovered(mouseX, mouseY)) {
|
||||
battleGUI.changeActionSelection(null)
|
||||
playDownSound(Minecraft.getInstance().soundManager)
|
||||
Companion.visible = false
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun defaultButtonNarrationText(builder: NarrationElementOutput) {
|
||||
}
|
||||
|
||||
override fun playDownSound(soundManager: SoundManager) {
|
||||
soundManager.play(SimpleSoundInstance.forUI(CobblemonSounds.GUI_CLICK, 1.0F))
|
||||
}
|
||||
|
||||
override fun narrationPriority() = NarratableEntry.NarrationPriority.HOVERED
|
||||
|
||||
class PokemonTile(
|
||||
val x: Float,
|
||||
val y: Float,
|
||||
private val initialPokemonDto: BattlePokemonDTO,
|
||||
val widget: BattleTeamInfoSelection,
|
||||
val reversed: Boolean,
|
||||
val actor: ClientBattleActor
|
||||
) {
|
||||
companion object {
|
||||
const val SELECT_WIDTH = 41
|
||||
const val SELECT_HEIGHT = 39
|
||||
const val SCALE = 0.5F
|
||||
val expandedPokemonInfo = cobblemonResource("textures/gui/battle/expanded_pokemon_info_center.png")
|
||||
|
||||
val pokemonTile = cobblemonResource("textures/gui/battle/pokemon_tile.png")
|
||||
val pokemonTileReversed = cobblemonResource("textures/gui/battle/pokemon_tile_reversed.png")
|
||||
val pokemonTileDisabled = cobblemonResource("textures/gui/battle/pokemon_tile_disabled.png")
|
||||
val pokemonTileDisabledReversed = cobblemonResource("textures/gui/battle/pokemon_tile_disabled_reversed.png")
|
||||
val pokemonTileSelected = cobblemonResource("textures/gui/battle/pokemon_tile_selected.png")
|
||||
val pokemonTileSelectedReversed = cobblemonResource("textures/gui/battle/pokemon_tile_selected_reversed.png")
|
||||
|
||||
val hoverGapSelected = cobblemonResource("textures/gui/battle/hover_gap_selected.png")
|
||||
val hoverGap = cobblemonResource("textures/gui/battle/hover_gap.png")
|
||||
val hoverGapReversed = cobblemonResource("textures/gui/battle/hover_gap_reversed.png")
|
||||
|
||||
private val decimalFormat = DecimalFormat("0.00").also {
|
||||
it.roundingMode = RoundingMode.CEILING
|
||||
}
|
||||
}
|
||||
|
||||
val state = FloatingState()
|
||||
|
||||
val pokemonDto: BattlePokemonDTO
|
||||
get() = ClientBattleInformationRepository.actors[actor.uuid]?.firstOrNull { it.uuid == initialPokemonDto.uuid } ?: initialPokemonDto
|
||||
|
||||
fun isHovered(mouseX: Double, mouseY: Double) = mouseX in x..(x + SELECT_WIDTH) && mouseY in (y..(y + SELECT_HEIGHT))
|
||||
|
||||
fun render(context: GuiGraphics, mouseX: Double, mouseY: Double, deltaTicks: Float) {
|
||||
val pokemon = pokemonDto.activeBattlePokemonDTO
|
||||
if (pokemon == null) {
|
||||
BattlePokemonInfoPanel.renderUnknownTile(context, x, y, reversed)
|
||||
return
|
||||
}
|
||||
val battlePokemon = ClientBattlePokemon(
|
||||
uuid = pokemon.uuid,
|
||||
properties = pokemon.properties,
|
||||
aspects = pokemon.aspects,
|
||||
displayName = pokemon.displayName,
|
||||
hpValue = pokemon.hpValue,
|
||||
maxHp = pokemon.maxHp,
|
||||
isHpFlat = pokemon.isFlatHp,
|
||||
status = pokemon.status,
|
||||
statChanges = pokemon.statChanges,
|
||||
)
|
||||
state.currentAspects = pokemon.aspects
|
||||
val matrixStack = context.pose()
|
||||
val isFainted = pokemonDto.fainted
|
||||
|
||||
blitk(
|
||||
matrixStack = matrixStack,
|
||||
texture = cobblemonResource("textures/gui/battle/battle_info_underlay.png"),
|
||||
x = x + 5 + (if (reversed) 3 else 0),
|
||||
y = y + 4,
|
||||
width = 28,
|
||||
height = 28
|
||||
)
|
||||
val speciesToDisplay = battlePokemon.species
|
||||
val stateToDisplay = battlePokemon.state
|
||||
context.enableScissor(
|
||||
(x + 5 + (if (reversed) 3 else 0)).toInt(),
|
||||
(y + 5).toInt(),
|
||||
(x + 5 + 28 + (if (reversed) 3 else 0)).toInt(),
|
||||
(y + 5 + 28).toInt(),
|
||||
)
|
||||
matrixStack.pushPose()
|
||||
matrixStack.translate(
|
||||
x + (if (reversed) 3 else 0) + 5 + 28 / 2.0,
|
||||
y.toDouble() + 5 - 5.0,
|
||||
0.0
|
||||
)
|
||||
drawCustomPosablePortrait(
|
||||
identifier = speciesToDisplay.resourceIdentifier,
|
||||
matrixStack = matrixStack,
|
||||
scale = 18f,
|
||||
contextScale = speciesToDisplay.getForm(stateToDisplay.currentAspects).baseScale,
|
||||
reversed = reversed,
|
||||
doQuirks = false,
|
||||
state = stateToDisplay,
|
||||
partialTicks = if (Cobblemon.config.animateBattleTiles) deltaTicks else 0F
|
||||
)
|
||||
matrixStack.popPose()
|
||||
context.disableScissor()
|
||||
|
||||
val tile = if (reversed) pokemonTileReversed else pokemonTile
|
||||
val disabled = if (reversed) pokemonTileDisabledReversed else pokemonTileDisabled
|
||||
val selected = if (reversed) pokemonTileSelectedReversed else pokemonTileSelected
|
||||
if (isFainted) {
|
||||
blitk(
|
||||
matrixStack = matrixStack,
|
||||
texture = disabled,
|
||||
x = x,
|
||||
y = y,
|
||||
width = 41,
|
||||
height = 39
|
||||
)
|
||||
}
|
||||
else {
|
||||
blitk(
|
||||
matrixStack = matrixStack,
|
||||
texture = tile,
|
||||
x = x,
|
||||
y = y,
|
||||
width = 41,
|
||||
height = 39
|
||||
)
|
||||
}
|
||||
|
||||
if (isHovered(mouseX, mouseY)) {
|
||||
renderExpandedInfo(context, reversed, battlePokemon, pokemonDto)
|
||||
}
|
||||
}
|
||||
|
||||
private fun renderExpandedInfo(context: GuiGraphics, reversed: Boolean, pokemon: ClientBattlePokemon, dto: BattlePokemonDTO) {
|
||||
context.pose().pushPose()
|
||||
context.pose().translate(0.0, 0.0, 300.0)
|
||||
val startX = if (reversed) x - 136 else x + 40
|
||||
val startY = y
|
||||
val species = pokemon.species
|
||||
val form = species.getForm(pokemon.state.currentAspects)
|
||||
val expandedInfoTexture = expandedPokemonInfo
|
||||
|
||||
val gap = if (reversed) hoverGapReversed else hoverGap
|
||||
val xOffset = if (reversed) 136 else -7
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = gap,
|
||||
x = startX + xOffset,
|
||||
y = startY,
|
||||
height = 36,
|
||||
width = 8,
|
||||
textureHeight = 36,
|
||||
textureWidth = 8,
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = expandedInfoTexture,
|
||||
x = startX,
|
||||
y = startY,
|
||||
height = 112,
|
||||
width = 137,
|
||||
textureHeight = 112,
|
||||
textureWidth = 137,
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.label.pokemon_form".asTranslated().bold(),
|
||||
x = startX + 36,
|
||||
y = startY + 6.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = getFormText(species, form),
|
||||
x = startX + 36,
|
||||
y = startY + 13.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.label.buffs".asTranslated().bold(),
|
||||
x = startX + 36,
|
||||
y = startY + 23.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.attack.name".asTranslated(),
|
||||
x = startX + 10,
|
||||
y = startY + 31.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs.get(Stats.ATTACK)?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = BattlePokemonInfoPanel.getBoostText(Stats.ATTACK, it),
|
||||
x = startX + BattlePokemonInfoPanel.BOOST_VALUE_CENTER_X,
|
||||
y = startY + 31.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
maxCharacterWidth = BattlePokemonInfoPanel.BOOST_VALUE_MAX_WIDTH,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.defence.name".asTranslated(),
|
||||
x = startX + 10,
|
||||
y = startY + 39.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs.get(Stats.DEFENCE)?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = BattlePokemonInfoPanel.getBoostText(Stats.DEFENCE, it),
|
||||
x = startX + BattlePokemonInfoPanel.BOOST_VALUE_CENTER_X,
|
||||
y = startY + 39.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
maxCharacterWidth = BattlePokemonInfoPanel.BOOST_VALUE_MAX_WIDTH,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.stats.special_attack".asTranslated(),
|
||||
x = startX + 10,
|
||||
y = startY + 47.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs.get(Stats.SPECIAL_ATTACK)?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = BattlePokemonInfoPanel.getBoostText(Stats.SPECIAL_ATTACK, it),
|
||||
x = startX + BattlePokemonInfoPanel.BOOST_VALUE_CENTER_X,
|
||||
y = startY + 47.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
maxCharacterWidth = BattlePokemonInfoPanel.BOOST_VALUE_MAX_WIDTH,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.stats.special_defence".asTranslated(),
|
||||
x = startX + 10,
|
||||
y = startY + 55.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs.get(Stats.SPECIAL_DEFENCE)?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = BattlePokemonInfoPanel.getBoostText(Stats.SPECIAL_DEFENCE, it),
|
||||
x = startX + BattlePokemonInfoPanel.BOOST_VALUE_CENTER_X,
|
||||
y = startY + 55.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
maxCharacterWidth = BattlePokemonInfoPanel.BOOST_VALUE_MAX_WIDTH,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.speed.name".asTranslated(),
|
||||
x = startX + 10,
|
||||
y = startY + 63.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs.get(Stats.SPEED)?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = BattlePokemonInfoPanel.getBoostText(Stats.SPEED, it),
|
||||
x = startX + BattlePokemonInfoPanel.BOOST_VALUE_CENTER_X,
|
||||
y = startY + 63.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
maxCharacterWidth = BattlePokemonInfoPanel.BOOST_VALUE_MAX_WIDTH,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.accuracy.name".asTranslated(),
|
||||
x = startX + 10,
|
||||
y = startY + 71.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto.buffs.get(Stats.ACCURACY)?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = BattlePokemonInfoPanel.getBoostText(Stats.ACCURACY, it),
|
||||
x = startX + BattlePokemonInfoPanel.BOOST_VALUE_CENTER_X,
|
||||
y = startY + 71.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
maxCharacterWidth = BattlePokemonInfoPanel.BOOST_VALUE_MAX_WIDTH,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.evasion.name".asTranslated(),
|
||||
x = startX + 10,
|
||||
y = startY + 79.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = false
|
||||
)
|
||||
|
||||
dto?.buffs?.get(Stats.EVASION)?.let {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = BattlePokemonInfoPanel.getBoostText(Stats.EVASION, it),
|
||||
x = startX + BattlePokemonInfoPanel.BOOST_VALUE_CENTER_X,
|
||||
y = startY + 79.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
maxCharacterWidth = BattlePokemonInfoPanel.BOOST_VALUE_MAX_WIDTH,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.label.ability".asTranslated().bold(),
|
||||
x = startX + 100,
|
||||
y = startY + 6.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
val ability = dto.ability?.let { Abilities.get(it) }
|
||||
val abilityName = ability?.displayName?.asTranslated() ?: "?".text()
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = abilityName,
|
||||
x = startX + 100,
|
||||
y = startY + 13.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.label.moves".asTranslated().bold(),
|
||||
x = startX + 100,
|
||||
y = startY + 23.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
if (dto.moves.size != 4) {
|
||||
for (i in 0 until 4) {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "?".text(),
|
||||
x = startX + 100,
|
||||
y = startY + 31.5 + i * 8,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
val questionMarkText = "?".text()
|
||||
dto.moves.forEachIndexed { index, moveDTO ->
|
||||
val move = moveDTO?.move ?: questionMarkText
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = move.string.text(),
|
||||
x = if (move == questionMarkText) startX + 100 else startX + 74,
|
||||
y = startY + 31.5 + index * 8,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = move == questionMarkText
|
||||
)
|
||||
|
||||
if (moveDTO != null) {
|
||||
drawScaledTextJustifiedRight(
|
||||
context = context,
|
||||
text = moveDTO.timesUsed.toString().text(),
|
||||
x = startX + 127.5,
|
||||
y = startY + 31.5 + index * 8,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dto.speed != null) {
|
||||
val speed = dto.speed
|
||||
val speedBoost = dto.buffs.get(Stats.SPEED) ?: 1.0
|
||||
val speedAfterBoost = (speed * speedBoost).toInt()
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.stat.speed.name".asTranslated(),
|
||||
x = startX + 100,
|
||||
y = startY + 65.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = speedAfterBoost.toString().text(),
|
||||
x = startX + 100,
|
||||
y = startY + 72.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
else {
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.label.speed_tier".asTranslated(),
|
||||
x = startX + 100,
|
||||
y = startY + 65.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
val speedBoost = dto.buffs.get(Stats.SPEED) ?: 1.0
|
||||
val speedTier = getSpeedRange(form, pokemon.level, speedBoost)
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = speedTier,
|
||||
x = startX + 100,
|
||||
y = startY + 72.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
}
|
||||
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = "cobblemon.battle.ui.label.held_item".asTranslated(),
|
||||
x = startX + 40,
|
||||
y = startY + 99.5,
|
||||
scale = BattleOverlay.Companion.SCALE,
|
||||
shadow = true,
|
||||
centered = true
|
||||
)
|
||||
|
||||
TypeIcon(
|
||||
x = startX + 100.5,
|
||||
y = startY + 88,
|
||||
type = form.primaryType,
|
||||
secondaryType = form.secondaryType,
|
||||
small = false,
|
||||
centeredX = true
|
||||
).render(context)
|
||||
|
||||
if (form.secondaryType != null) {
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = cobblemonResource("textures/gui/battle/type_spacer_double.png"),
|
||||
x = (startX + 69.0) / 0.45,
|
||||
y = (startY + 91.5) / 0.45,
|
||||
height = 24,
|
||||
width = 140,
|
||||
textureHeight = 24,
|
||||
textureWidth = 140,
|
||||
scale = 0.45f
|
||||
)
|
||||
}
|
||||
else {
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = cobblemonResource("textures/gui/summary/type_spacer.png"),
|
||||
x = (startX + 70.5) / 0.45,
|
||||
y = (startY + 91.5) / 0.45,
|
||||
height = 24,
|
||||
width = 132,
|
||||
textureHeight = 24,
|
||||
textureWidth = 132,
|
||||
scale = 0.45f
|
||||
)
|
||||
}
|
||||
|
||||
val heldItem = dto.heldItem
|
||||
if (heldItem != null && !heldItem.isEmpty()) {
|
||||
context.pose().pushPose()
|
||||
context.pose().scale(0.95F, 0.95F, 0.95F)
|
||||
val itemX = (startX + 4) / 0.95
|
||||
val itemY = (startY + 91) / 0.95
|
||||
context.renderItem(heldItem, itemX.toInt(), itemY.toInt())
|
||||
context.pose().popPose()
|
||||
}
|
||||
else {
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = questionMarkIcon,
|
||||
x = startX + 6,
|
||||
y = startY + 92.5,
|
||||
height = 11,
|
||||
width = 10,
|
||||
)
|
||||
}
|
||||
context.pose().popPose()
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun drawCustomPosablePortrait(
|
||||
identifier: ResourceLocation,
|
||||
matrixStack: PoseStack,
|
||||
scale: Float = 13F,
|
||||
contextScale: Float = 1F,
|
||||
reversed: Boolean = false,
|
||||
state: PosableState,
|
||||
partialTicks: Float,
|
||||
limbSwing: Float = 0F,
|
||||
limbSwingAmount: Float = 0F,
|
||||
ageInTicks: Float = 0F,
|
||||
headYaw: Float = 0F,
|
||||
headPitch: Float = 0F,
|
||||
r: Float = 1F,
|
||||
g: Float = 1F,
|
||||
b: Float = 1F,
|
||||
a: Float = 1F,
|
||||
doQuirks: Boolean = true
|
||||
) {
|
||||
RenderSystem.applyModelViewMatrix()
|
||||
matrixStack.pushPose()
|
||||
matrixStack.translate(0.0, PORTRAIT_DIAMETER.toDouble() + 2.0, 0.0)
|
||||
matrixStack.scale(scale, scale, -scale)
|
||||
matrixStack.translate(0.0, -PORTRAIT_DIAMETER / 18.0, 0.0)
|
||||
|
||||
val sprite = VaryingModelRepository.getSprite(identifier, state, SpriteType.PORTRAIT);
|
||||
|
||||
if (sprite == null) {
|
||||
val model = VaryingModelRepository.getPoser(identifier, state)
|
||||
state.currentModel = model
|
||||
val texture = VaryingModelRepository.getTexture(identifier, state)
|
||||
|
||||
val context = RenderContext()
|
||||
model.context = context
|
||||
VaryingModelRepository.getTextureNoSubstitute(identifier, state).let { context.put(RenderContext.TEXTURE, it) }
|
||||
context.put(RenderContext.SCALE, contextScale)
|
||||
context.put(RenderContext.SPECIES, identifier)
|
||||
context.put(RenderContext.ASPECTS, state.currentAspects)
|
||||
context.put(RenderContext.POSABLE_STATE, state)
|
||||
context.put(RenderContext.DO_QUIRKS, doQuirks)
|
||||
|
||||
val renderType = RenderType.entityCutout(texture)
|
||||
|
||||
val quaternion1 = Axis.YP.rotationDegrees(-32F * if (reversed) -1F else 1F)
|
||||
val quaternion2 = Axis.XP.rotationDegrees(5F)
|
||||
|
||||
val originalPose = state.currentPose
|
||||
state.setPoseToFirstSuitable(PoseType.PORTRAIT)
|
||||
state.updatePartialTicks(partialTicks)
|
||||
model.applyAnimations(null, state, limbSwing, limbSwingAmount, ageInTicks, headYaw, headPitch)
|
||||
originalPose?.let { state.setPose(it) }
|
||||
|
||||
matrixStack.translate(
|
||||
model.portraitTranslation.x * if (reversed) -1F else 1F,
|
||||
model.portraitTranslation.y + 1.5 * model.portraitScale,
|
||||
model.portraitTranslation.z - 4
|
||||
)
|
||||
matrixStack.scale(model.portraitScale, model.portraitScale, 1 / model.portraitScale)
|
||||
matrixStack.mulPose(quaternion1)
|
||||
matrixStack.mulPose(quaternion2)
|
||||
|
||||
val light1 = Vector3f(0.2F, 1.0F, -1.0F)
|
||||
val light2 = Vector3f(0.1F, 0.0F, 8.0F)
|
||||
RenderSystem.setShaderLights(light1, light2)
|
||||
quaternion1.conjugate()
|
||||
|
||||
val immediate = Minecraft.getInstance().renderBuffers().bufferSource()
|
||||
val buffer = immediate.getBuffer(renderType)
|
||||
val packedLight = LightTexture.pack(11, 7)
|
||||
|
||||
val colour = toHex(r, g, b, a)
|
||||
model.withLayerContext(immediate, state, VaryingModelRepository.getLayers(identifier, state)) {
|
||||
model.render(context, matrixStack, buffer, packedLight, OverlayTexture.NO_OVERLAY, colour)
|
||||
immediate.endBatch()
|
||||
}
|
||||
|
||||
model.setDefault()
|
||||
|
||||
Lighting.setupFor3DItems()
|
||||
} else {
|
||||
renderSprite(matrixStack, sprite)
|
||||
}
|
||||
|
||||
matrixStack.popPose()
|
||||
}
|
||||
|
||||
private fun getSpeedRange(form: FormData, level: Int, speedBoost: Double): MutableComponent {
|
||||
val base = form.baseStats[Stats.SPEED] ?: 0
|
||||
val maxIV = 31
|
||||
val maxEV = 252
|
||||
val minNatureMod = 0.9
|
||||
val maxNatureMod = 1.1
|
||||
|
||||
val minSpeed = getStat(base, level, 0, 0, minNatureMod) * speedBoost
|
||||
val maxSpeed = getStat(base, level, maxIV, maxEV, maxNatureMod) * speedBoost
|
||||
return "cobblemon.battle.ui.speed_tier".asTranslated(minSpeed.toInt(), maxSpeed.toInt())
|
||||
}
|
||||
|
||||
private fun getStat(base: Int, level: Int, iv: Int, ev: Int, natureMod: Double): Int {
|
||||
return floor((floor(((2.0 * base + iv + floor(ev / 4.0)) * level) / 100) + 5) * natureMod).toInt()
|
||||
}
|
||||
|
||||
private fun getMultiplierText(multiplier: Double): MutableComponent {
|
||||
val rounded = decimalFormat.format(multiplier)
|
||||
val str = "x$rounded"
|
||||
return when {
|
||||
multiplier > 1.0 -> str.green()
|
||||
multiplier < 1.0 -> str.red()
|
||||
else -> str.text()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getFormText(species: Species, form: FormData): MutableComponent {
|
||||
val speciesName = species.name
|
||||
val formName = form.name
|
||||
return if (formName == "Normal") speciesName.text() else "$speciesName-$formName".text()
|
||||
}
|
||||
}
|
||||
}
|
||||
+46
-325
@@ -10,7 +10,6 @@ package com.cobblemon.mod.common.client.gui.battle.widgets
|
||||
|
||||
import com.cobblemon.mod.common.api.gui.blitk
|
||||
import com.cobblemon.mod.common.api.text.text
|
||||
import com.cobblemon.mod.common.client.CobblemonResources
|
||||
import com.cobblemon.mod.common.client.battle.ClientBattleMessageQueue
|
||||
import com.cobblemon.mod.common.client.gui.CobblemonRenderable
|
||||
import com.cobblemon.mod.common.client.render.drawScaledText
|
||||
@@ -18,15 +17,7 @@ import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.gui.components.ObjectSelectionList
|
||||
import net.minecraft.locale.Language
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.Style
|
||||
import net.minecraft.network.chat.TextColor
|
||||
import net.minecraft.network.chat.contents.TranslatableContents
|
||||
import net.minecraft.util.FormattedCharSequence
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.round
|
||||
|
||||
/**
|
||||
* Pane for seeing and interacting with battle messages.
|
||||
@@ -45,80 +36,29 @@ class BattleMessagePane(
|
||||
), CobblemonRenderable {
|
||||
var opacity = 1F
|
||||
private var scrolling = false
|
||||
private var resizing = false
|
||||
private var movingBox = false
|
||||
// Offset from the mouse to the box's top-left when a move-drag begins, so the box tracks the cursor
|
||||
// exactly (positioning absolutely avoids the GUI-scale mismatch that accumulating deltas causes).
|
||||
private var dragOffsetX = 0.0
|
||||
private var dragOffsetY = 0.0
|
||||
|
||||
val appropriateX: Int
|
||||
get() = minecraft.window.guiScaledWidth - (FRAME_WIDTH + 12)
|
||||
val appropriateY: Int
|
||||
get() = minecraft.window.guiScaledHeight - (30 + (if (expanded) FRAME_EXPANDED_HEIGHT else FRAME_HEIGHT))
|
||||
|
||||
val battleMessages = mutableListOf<Component>()
|
||||
private val unsubscribe: () -> Unit
|
||||
|
||||
fun dispose() = unsubscribe()
|
||||
|
||||
init {
|
||||
correctSize()
|
||||
//setRenderBackground(false)
|
||||
|
||||
scrollAmount = maxScroll.toDouble()
|
||||
unsubscribe = messageQueue.subscribeComponents {
|
||||
battleMessages.add(it)
|
||||
correctBattleText()
|
||||
}
|
||||
}
|
||||
|
||||
private fun correctBattleText() {
|
||||
val isFullyScrolled = maxScroll - scrollAmount < 10
|
||||
clearEntries()
|
||||
val textRenderer = Minecraft.getInstance().font
|
||||
for (message in battleMessages) {
|
||||
// Turn announcements ("It is now turn N") render as a centered "Turn N" divider header.
|
||||
val contents = message.contents
|
||||
if (contents is TranslatableContents && contents.key == "cobblemon.battle.turn") {
|
||||
val turnNum = contents.args.firstOrNull()?.toString() ?: ""
|
||||
addEntry(BattleMessageLine(this, null, Component.translatable("deltaclient.ui.battle.turn", turnNum).string))
|
||||
continue
|
||||
}
|
||||
// Tint certain message categories by their translation key: weather/field/screen → teal,
|
||||
// stat changes → purple, damage → blue. Other messages keep their existing styling.
|
||||
var style = message.style.withBold(true).withFont(CobblemonResources.DEFAULT_LARGE)
|
||||
val color = messageColor((contents as? TranslatableContents)?.key)
|
||||
if (color != null) style = style.withColor(TextColor.fromRgb(color))
|
||||
val line = message.copy().setStyle(style)
|
||||
val wrappedLines = textRenderer.splitter.splitLines(line, battleLogWidth - 27, line.style)
|
||||
val lines = Language.getInstance().getVisualOrder(wrappedLines)
|
||||
for (finalLine in lines) {
|
||||
addEntry(BattleMessageLine(this, finalLine))
|
||||
messageQueue.subscribe {
|
||||
val fullyScrolledDown = maxScroll - scrollAmount < 10
|
||||
addEntry(BattleMessageLine(this, it))
|
||||
if (fullyScrolledDown) {
|
||||
scrollAmount = maxScroll.toDouble()
|
||||
}
|
||||
}
|
||||
if (isFullyScrolled) {
|
||||
scrollAmount = maxScroll.toDouble()
|
||||
}
|
||||
}
|
||||
|
||||
/** Colour for a battle message based on its translation key, or null to keep its existing styling. */
|
||||
private fun messageColor(key: String?): Int? = when {
|
||||
key == null -> null
|
||||
key == "cobblemon.battle.damage_dealt" -> 0x4298ED // damage % → blue
|
||||
key.startsWith("cobblemon.battle.weather.") -> 0x42EDAF // weather → teal
|
||||
key.startsWith("cobblemon.battle.fieldstart.") -> 0x42EDAF // terrains, rooms, gravity, etc.
|
||||
key.startsWith("cobblemon.battle.fieldend.") -> 0x42EDAF
|
||||
key.startsWith("cobblemon.battle.fieldactivate.") -> 0x42EDAF
|
||||
key.startsWith("cobblemon.battle.sidestart.") -> 0x42EDAF // Reflect, Light Screen, etc.
|
||||
key.startsWith("cobblemon.battle.sideend.") -> 0x42EDAF
|
||||
key.startsWith("cobblemon.battle.boost.") -> 0x8C42ED // stat rose → purple
|
||||
key.startsWith("cobblemon.battle.unboost.") -> 0x8C42ED // stat fell → purple
|
||||
else -> null
|
||||
}
|
||||
|
||||
private fun correctSize() {
|
||||
setRectangle(battleLogWidth - 11, battleLogHeight - 13, battleLogX.toInt(), battleLogY.toInt() + 8)
|
||||
val textBoxHeight = if (expanded) TEXT_BOX_HEIGHT * 2 else TEXT_BOX_HEIGHT
|
||||
setRectangle(TEXT_BOX_WIDTH, textBoxHeight, appropriateY + 6, appropriateY + 6)
|
||||
this.x = appropriateX
|
||||
}
|
||||
|
||||
companion object {
|
||||
@@ -131,52 +71,10 @@ class BattleMessagePane(
|
||||
const val TEXT_BOX_HEIGHT = 46
|
||||
const val EXPAND_TOGGLE_SIZE = 5
|
||||
|
||||
private val battleMessagePaneFrameResource = cobblemonResource("textures/gui/battle/battle_log.png")
|
||||
private val battleMessagePaneFrameExpandedResource = cobblemonResource("textures/gui/battle/battle_log_expanded.png")
|
||||
private val battleMessageHighlight = cobblemonResource("textures/gui/battle/battle_log_row_selected_color.png")
|
||||
|
||||
val topTexture = cobblemonResource("textures/gui/battle/log/top.png")
|
||||
val bottomTexture = cobblemonResource("textures/gui/battle/log/bottom.png")
|
||||
val leftTexture = cobblemonResource("textures/gui/battle/log/left.png")
|
||||
val rightTexture = cobblemonResource("textures/gui/battle/log/right.png")
|
||||
val topLeftTexture = cobblemonResource("textures/gui/battle/log/top_left.png")
|
||||
val topRightTexture = cobblemonResource("textures/gui/battle/log/top_right.png")
|
||||
val bottomLeftTexture = cobblemonResource("textures/gui/battle/log/bottom_left.png")
|
||||
val bottomRightTexture = cobblemonResource("textures/gui/battle/log/bottom_right.png")
|
||||
val centerTexture = cobblemonResource("textures/gui/battle/log/center.png")
|
||||
|
||||
private var expanded = false
|
||||
|
||||
var battleLogWidth: Int = 153
|
||||
set(value) {
|
||||
val max = Minecraft.getInstance().window.guiScaledWidth - 20
|
||||
if (battleLogX + value <= max) {
|
||||
field = value
|
||||
}
|
||||
}
|
||||
|
||||
var battleLogHeight: Int = 46
|
||||
set(value) {
|
||||
val max = Minecraft.getInstance().window.guiScaledHeight - 20
|
||||
if (battleLogY + value <= max) {
|
||||
field = value
|
||||
}
|
||||
}
|
||||
|
||||
var battleLogX: Double = defaultLogX
|
||||
get() {
|
||||
val max = Minecraft.getInstance().window.guiScaledWidth - battleLogWidth
|
||||
return max(min(field, max.toDouble() - 20), 4.0)
|
||||
}
|
||||
|
||||
var battleLogY: Double = defaultLogY
|
||||
get() {
|
||||
val max = Minecraft.getInstance().window.guiScaledHeight - battleLogHeight
|
||||
return max(min(field, max.toDouble() - 20), 4.0)
|
||||
}
|
||||
|
||||
val defaultLogX: Double
|
||||
get() = Minecraft.getInstance().window.guiScaledWidth - 181.0
|
||||
val defaultLogY: Double
|
||||
get() = Minecraft.getInstance().window.guiScaledHeight - 85.0
|
||||
}
|
||||
|
||||
override fun addEntry(entry: BattleMessageLine): Int {
|
||||
@@ -184,7 +82,7 @@ class BattleMessagePane(
|
||||
}
|
||||
|
||||
override fun getRowLeft(): Int {
|
||||
return x + 10
|
||||
return super.getRowLeft() + 4
|
||||
}
|
||||
|
||||
override fun renderSelection(guiGraphics: GuiGraphics, top: Int, width: Int, height: Int, outerColor: Int, innerColor: Int) {
|
||||
@@ -204,7 +102,7 @@ class BattleMessagePane(
|
||||
x = x + 6,
|
||||
y = top - 2,
|
||||
height = 1,
|
||||
width = battleLogWidth - 18,
|
||||
width = LINE_WIDTH,
|
||||
alpha = opacity
|
||||
)
|
||||
|
||||
@@ -214,14 +112,14 @@ class BattleMessagePane(
|
||||
x = x + 6,
|
||||
y = top + 7,
|
||||
height = 1,
|
||||
width = battleLogWidth - 18,
|
||||
width = LINE_WIDTH,
|
||||
alpha = opacity
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = guiGraphics.pose(),
|
||||
texture = battleMessageHighlight,
|
||||
x = x + 6 + battleLogWidth - 19,
|
||||
x = x + 6 + LINE_WIDTH - 1,
|
||||
y = top - 2,
|
||||
height = 10,
|
||||
width = 1,
|
||||
@@ -230,198 +128,62 @@ class BattleMessagePane(
|
||||
}
|
||||
|
||||
override fun getRowWidth(): Int {
|
||||
return battleLogWidth - 16
|
||||
return LINE_WIDTH
|
||||
}
|
||||
|
||||
override fun getScrollbarPosition(): Int {
|
||||
return this.x + battleLogWidth - 16
|
||||
return this.x + 154
|
||||
}
|
||||
|
||||
override fun renderWidget(context: GuiGraphics, mouseX: Int, mouseY: Int, partialTicks: Float) {
|
||||
correctSize()
|
||||
|
||||
val isFullyScrolled = opacity != 1f || maxScroll - scrollAmount < 2
|
||||
if (isFullyScrolled) { scrollAmount = maxScroll.toDouble() }
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = topLeftTexture,
|
||||
x = battleLogX,
|
||||
y = battleLogY,
|
||||
height = 8,
|
||||
width = 7,
|
||||
textureHeight = 8,
|
||||
textureWidth = 7,
|
||||
alpha = opacity
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = topRightTexture,
|
||||
x = battleLogX + battleLogWidth - 13,
|
||||
y = battleLogY,
|
||||
height = 8,
|
||||
width = 13,
|
||||
textureHeight = 8,
|
||||
textureWidth = 13,
|
||||
alpha = opacity
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = bottomLeftTexture,
|
||||
x = battleLogX,
|
||||
y = battleLogY + battleLogHeight - 5,
|
||||
height = 5,
|
||||
width = 7,
|
||||
textureHeight = 5,
|
||||
textureWidth = 7,
|
||||
alpha = opacity
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = bottomRightTexture,
|
||||
x = battleLogX + battleLogWidth - 13,
|
||||
y = battleLogY + battleLogHeight - 10,
|
||||
height = 10,
|
||||
width = 13,
|
||||
textureHeight = 10,
|
||||
textureWidth = 13,
|
||||
alpha = opacity
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = topTexture,
|
||||
x = battleLogX + 7,
|
||||
y = battleLogY,
|
||||
height = 7,
|
||||
width = battleLogWidth - 7 - 13,
|
||||
textureHeight = 7,
|
||||
textureWidth = 1,
|
||||
alpha = opacity
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = bottomTexture,
|
||||
x = battleLogX + 7,
|
||||
y = battleLogY + battleLogHeight - 4,
|
||||
height = 4,
|
||||
width = battleLogWidth - 7 - 12,
|
||||
textureHeight = 4,
|
||||
textureWidth = 1,
|
||||
alpha = opacity
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = leftTexture,
|
||||
x = battleLogX,
|
||||
y = battleLogY + 8,
|
||||
height = battleLogHeight - 8 - 5,
|
||||
width = 7,
|
||||
textureHeight = 1,
|
||||
textureWidth = 7,
|
||||
alpha = opacity
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = rightTexture,
|
||||
x = battleLogX + battleLogWidth - 13,
|
||||
y = battleLogY + 8,
|
||||
height = battleLogHeight - 18,
|
||||
width = 13,
|
||||
textureHeight = 1,
|
||||
textureWidth = 13,
|
||||
alpha = opacity
|
||||
)
|
||||
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = centerTexture,
|
||||
x = battleLogX + 7,
|
||||
y = battleLogY + 7,
|
||||
height = battleLogHeight - 11,
|
||||
width = battleLogWidth - 20,
|
||||
textureHeight = battleLogHeight - 11,
|
||||
textureWidth = battleLogWidth - 20,
|
||||
texture = if (expanded) battleMessagePaneFrameExpandedResource else battleMessagePaneFrameResource,
|
||||
x = this.x,
|
||||
y = appropriateY,
|
||||
height = if (expanded) FRAME_EXPANDED_HEIGHT else FRAME_HEIGHT,
|
||||
width = FRAME_WIDTH,
|
||||
alpha = opacity
|
||||
)
|
||||
|
||||
val textBoxHeight = if (expanded) TEXT_BOX_HEIGHT * 2 else TEXT_BOX_HEIGHT
|
||||
context.enableScissor(
|
||||
x + 5,
|
||||
round(battleLogY + 6).toInt(),
|
||||
x + 6 + battleLogWidth,
|
||||
round(battleLogY + 6 + battleLogHeight).toInt()
|
||||
this.x + 5,
|
||||
appropriateY + 6,
|
||||
this.x + 5 + width,
|
||||
appropriateY + 6 + textBoxHeight
|
||||
)
|
||||
super.renderWidget(context, mouseX, mouseY, partialTicks)
|
||||
context.disableScissor()
|
||||
}
|
||||
|
||||
override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean {
|
||||
if (button != 0) return false
|
||||
// Intentionally NOT calling super.mouseClicked — that selects the clicked log line, which we no
|
||||
// longer want. Instead the press grabs the scrollbar, the bottom-right resize handle, or (anywhere
|
||||
// else on the box) moves the whole box.
|
||||
updateScrollingState(mouseX, mouseY)
|
||||
if (scrolling) return true
|
||||
if (isOnResizeHandle(mouseX, mouseY)) {
|
||||
resizing = true
|
||||
return true
|
||||
val toggleOffsetY = if (expanded) 92 else 46
|
||||
if (mouseX > (this.x + 160) && mouseX < (this.x + 160 + EXPAND_TOGGLE_SIZE) && mouseY > (appropriateY + toggleOffsetY) && mouseY < (appropriateY + toggleOffsetY + EXPAND_TOGGLE_SIZE)) {
|
||||
expanded = !expanded
|
||||
}
|
||||
if (isWithinBox(mouseX, mouseY)) {
|
||||
movingBox = true
|
||||
dragOffsetX = mouseX - battleLogX
|
||||
dragOffsetY = mouseY - battleLogY
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean {
|
||||
scrolling = false
|
||||
resizing = false
|
||||
movingBox = false
|
||||
return super.mouseReleased(mouseX, mouseY, button)
|
||||
updateScrollingState(mouseX, mouseY)
|
||||
if (scrolling) {
|
||||
focused = getEntryAtPosition(mouseX, mouseY)
|
||||
isDragging = true
|
||||
}
|
||||
|
||||
return super.mouseClicked(mouseX, mouseY, button)
|
||||
}
|
||||
|
||||
override fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean {
|
||||
if (scrolling) {
|
||||
when {
|
||||
mouseY < this.y -> scrollAmount = 0.0
|
||||
mouseY > bottom -> scrollAmount = maxScroll.toDouble()
|
||||
else -> scrollAmount += deltaY
|
||||
if (mouseY < this.y) {
|
||||
scrollAmount = 0.0
|
||||
} else if (mouseY > bottom) {
|
||||
scrollAmount = maxScroll.toDouble()
|
||||
} else {
|
||||
scrollAmount += deltaY
|
||||
}
|
||||
return true
|
||||
}
|
||||
if (resizing) {
|
||||
battleLogHeight = max(mouseY.toInt() + 7 - y, TEXT_BOX_HEIGHT)
|
||||
battleLogWidth = max(mouseX.toInt() - x, TEXT_BOX_WIDTH)
|
||||
correctSize()
|
||||
correctBattleText()
|
||||
return true
|
||||
}
|
||||
if (movingBox) {
|
||||
battleLogX = mouseX - dragOffsetX
|
||||
battleLogY = mouseY - dragOffsetY
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/** The whole message box (frame included) — grab it anywhere here to move it. */
|
||||
private fun isWithinBox(mouseX: Double, mouseY: Double): Boolean {
|
||||
return mouseX >= battleLogX && mouseX <= battleLogX + battleLogWidth &&
|
||||
mouseY >= battleLogY && mouseY <= battleLogY + battleLogHeight
|
||||
}
|
||||
|
||||
/** The resize handle in the bottom-right corner (drag to expand); takes priority over moving. */
|
||||
private fun isOnResizeHandle(mouseX: Double, mouseY: Double): Boolean {
|
||||
return mouseX >= battleLogX + battleLogWidth - 13 && mouseX <= battleLogX + battleLogWidth &&
|
||||
mouseY >= battleLogY + battleLogHeight - 10 && mouseY <= battleLogY + battleLogHeight
|
||||
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)
|
||||
}
|
||||
|
||||
private fun updateScrollingState(mouseX: Double, mouseY: Double) {
|
||||
@@ -431,7 +193,7 @@ class BattleMessagePane(
|
||||
&& mouseY < bottom
|
||||
}
|
||||
|
||||
class BattleMessageLine(val pane: BattleMessagePane, val line: FormattedCharSequence?, val headerText: String? = null) : Entry<BattleMessageLine>() {
|
||||
class BattleMessageLine(val pane: BattleMessagePane, val line: FormattedCharSequence) : Entry<BattleMessageLine>() {
|
||||
override fun getNarration() = "".text()
|
||||
override fun render(
|
||||
context: GuiGraphics,
|
||||
@@ -445,54 +207,13 @@ class BattleMessagePane(
|
||||
isHovered: Boolean,
|
||||
partialTicks: Float
|
||||
) {
|
||||
if (headerText != null) {
|
||||
// "Turn N" centered on the divider's true midpoint, with an equal-length line each side.
|
||||
val comp = headerText.text().setStyle(Style.EMPTY.withBold(true).withFont(CobblemonResources.DEFAULT_LARGE))
|
||||
val textWidth = Minecraft.getInstance().font.width(comp)
|
||||
val dividerLeft = rowLeft - 3
|
||||
val dividerRight = rowLeft + rowWidth - 7
|
||||
val centerX = (dividerLeft + dividerRight) / 2
|
||||
val lineY = rowTop + 2
|
||||
val leftEnd = centerX - textWidth / 2 - 3
|
||||
val rightStart = centerX + textWidth / 2 + 3
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = CobblemonResources.WHITE,
|
||||
x = dividerLeft,
|
||||
y = lineY,
|
||||
width = (leftEnd - dividerLeft).coerceAtLeast(0),
|
||||
height = 1,
|
||||
alpha = pane.opacity * 0.6f
|
||||
)
|
||||
blitk(
|
||||
matrixStack = context.pose(),
|
||||
texture = CobblemonResources.WHITE,
|
||||
x = rightStart,
|
||||
y = lineY,
|
||||
width = (dividerRight - rightStart).coerceAtLeast(0),
|
||||
height = 1,
|
||||
alpha = pane.opacity * 0.6f
|
||||
)
|
||||
drawScaledText(
|
||||
context = context,
|
||||
text = comp,
|
||||
x = centerX - textWidth / 2,
|
||||
y = rowTop - 2,
|
||||
opacity = pane.opacity
|
||||
)
|
||||
return
|
||||
}
|
||||
drawScaledText(
|
||||
context,
|
||||
line ?: return,
|
||||
line,
|
||||
rowLeft,
|
||||
rowTop - 2,
|
||||
opacity = pane.opacity
|
||||
)
|
||||
}
|
||||
|
||||
override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean {
|
||||
return super.mouseClicked(mouseX, mouseY, button)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-6
@@ -8,12 +8,10 @@
|
||||
|
||||
package com.cobblemon.mod.common.client.gui.startselection.widgets
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.CobblemonSounds
|
||||
import com.cobblemon.mod.common.api.gui.blitk
|
||||
import com.cobblemon.mod.common.api.text.bold
|
||||
import com.cobblemon.mod.common.client.gui.CobblemonRenderable
|
||||
import com.cobblemon.mod.common.client.gui.PokemonGUIAnimationStyle
|
||||
import com.cobblemon.mod.common.client.gui.VariableObjectSelectionList
|
||||
import com.cobblemon.mod.common.client.gui.drawProfilePokemon
|
||||
import com.cobblemon.mod.common.client.gui.startselection.StarterSelectionScreen
|
||||
@@ -29,12 +27,11 @@ import org.joml.Quaternionf
|
||||
import org.joml.Vector3f
|
||||
|
||||
class CategoryList(
|
||||
private val paneWidth: Int,
|
||||
private val paneHeight: Int,
|
||||
paneWidth: Int,
|
||||
paneHeight: Int,
|
||||
private val categories: List<RenderableStarterCategory>,
|
||||
val listX: Int,
|
||||
val listY: Int,
|
||||
private val minecraft: Minecraft = Minecraft.getInstance(),
|
||||
private val starterSelectionScreen: StarterSelectionScreen
|
||||
) : VariableObjectSelectionList(
|
||||
listX,
|
||||
@@ -70,7 +67,8 @@ class CategoryList(
|
||||
}
|
||||
|
||||
private fun createEntries() = categories.map { category ->
|
||||
val rows = (category.pokemon.size - 1) / 3 + 1
|
||||
val pokemonCount = category.pokemon.size - if (category.randomStarter) 0 else 1
|
||||
val rows = pokemonCount / 3 + 1
|
||||
val height = CONTAINER_BUTTON_SIZE * rows + BUTTON_SEPERATION * (rows + 1) + HEADER_HEIGHT + 3
|
||||
Category(category, height)
|
||||
}
|
||||
|
||||
-25
@@ -1,25 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.net.battle
|
||||
|
||||
import com.cobblemon.mod.common.api.net.ClientNetworkPacketHandler
|
||||
import com.cobblemon.mod.common.client.battle.ClientBattleInformationRepository
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleActorInformationPacket
|
||||
import net.minecraft.client.Minecraft
|
||||
|
||||
object BattleActorInformationHandler : ClientNetworkPacketHandler<BattleActorInformationPacket> {
|
||||
override fun handle(packet: BattleActorInformationPacket, client: Minecraft) {
|
||||
val pokemon = ClientBattleInformationRepository.actors[packet.actor]
|
||||
if (pokemon == null) return
|
||||
val previous = pokemon.find { it.uuid == packet.update.uuid }
|
||||
if (previous == null) return
|
||||
pokemon.add(pokemon.indexOf(previous), packet.update)
|
||||
pokemon.remove(previous)
|
||||
}
|
||||
}
|
||||
-20
@@ -1,20 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.net.battle
|
||||
|
||||
import com.cobblemon.mod.common.api.net.ClientNetworkPacketHandler
|
||||
import com.cobblemon.mod.common.client.battle.ClientBattleInformationRepository
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleActorTeamPacket
|
||||
import net.minecraft.client.Minecraft
|
||||
|
||||
object BattleActorTeamHandler : ClientNetworkPacketHandler<BattleActorTeamPacket> {
|
||||
override fun handle(packet: BattleActorTeamPacket, client: Minecraft) {
|
||||
ClientBattleInformationRepository.actors[packet.actor] = packet.team.toMutableList()
|
||||
}
|
||||
}
|
||||
-73
@@ -1,73 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.net.battle
|
||||
|
||||
import com.bedrockk.molang.runtime.MoLangRuntime
|
||||
import com.bedrockk.molang.runtime.value.DoubleValue
|
||||
import com.cobblemon.mod.common.api.net.ClientNetworkPacketHandler
|
||||
import com.cobblemon.mod.common.client.CobblemonClient
|
||||
import com.cobblemon.mod.common.client.battle.ClientBattleInformationRepository
|
||||
import com.cobblemon.mod.common.client.particle.BedrockParticleOptionsRepository
|
||||
import com.cobblemon.mod.common.client.particle.ParticleStorm
|
||||
import com.cobblemon.mod.common.client.render.MatrixWrapper
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleInformationPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.FieldEffect
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import com.mojang.authlib.minecraft.client.MinecraftClient
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
|
||||
object BattleInformationHandler : ClientNetworkPacketHandler<BattleInformationPacket> {
|
||||
override fun handle(packet: BattleInformationPacket, client: Minecraft) {
|
||||
val currentWeather: FieldEffect? = getCurrentWeather()
|
||||
ClientBattleInformationRepository.battles[packet.battle] = packet.informationDTO
|
||||
val newWeather: FieldEffect? = packet.informationDTO.weather
|
||||
if (newWeather != null && currentWeather?.id != newWeather.id) {
|
||||
client.executeIfPossible { playWeatherParticle(newWeather, client) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCurrentWeather(): FieldEffect? {
|
||||
val currentBattleId = CobblemonClient.battle?.battleId ?: return null
|
||||
val currentBattleInfo = ClientBattleInformationRepository.battles[currentBattleId] ?: return null
|
||||
return currentBattleInfo.weather
|
||||
}
|
||||
|
||||
private fun playWeatherParticle(weather: FieldEffect, client: Minecraft) {
|
||||
if (weather.sourceEntityId == null) return
|
||||
val source = client.level?.getEntity(weather.sourceEntityId) ?: return
|
||||
val particle = getParticleForWeather(weather) ?: return
|
||||
val wrapper = MatrixWrapper()
|
||||
val matrix = PoseStack()
|
||||
wrapper.updateMatrix(matrix.last().pose())
|
||||
wrapper.updatePosition(source.position())
|
||||
val world = Minecraft.getInstance().level ?: return
|
||||
val effect = BedrockParticleOptionsRepository.getEffect(particle) ?: return
|
||||
val runtime = MoLangRuntime()
|
||||
runtime.environment.query.addFunction("is_weather_active") { DoubleValue(getCurrentWeather()?.id == weather.id) }
|
||||
ParticleStorm(
|
||||
effect,
|
||||
wrapper,
|
||||
wrapper,
|
||||
world,
|
||||
runtime = runtime
|
||||
).spawn()
|
||||
}
|
||||
|
||||
fun getParticleForWeather(weather: FieldEffect): ResourceLocation? {
|
||||
return when (weather.id) {
|
||||
"hail" -> cobblemonResource("battle_hail")
|
||||
"snow" -> cobblemonResource("battle_snow")
|
||||
"raindance" -> cobblemonResource("battle_rain")
|
||||
"sandstorm" -> cobblemonResource("battle_sandstorm")
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
-5
@@ -8,8 +8,6 @@
|
||||
|
||||
package com.cobblemon.mod.common.client.net.battle
|
||||
|
||||
import com.cobblemon.mod.common.client.battle.ClientBattleInformationRepository
|
||||
|
||||
import com.cobblemon.mod.common.api.net.ClientNetworkPacketHandler
|
||||
import com.cobblemon.mod.common.client.CobblemonClient
|
||||
import com.cobblemon.mod.common.client.battle.ActiveClientBattlePokemon
|
||||
@@ -22,9 +20,6 @@ import net.minecraft.client.Minecraft
|
||||
|
||||
object BattleInitializeHandler : ClientNetworkPacketHandler<BattleInitializePacket> {
|
||||
override fun handle(packet: BattleInitializePacket, client: Minecraft) {
|
||||
ClientBattleInformationRepository.clear()
|
||||
packet.side1.actors.forEach { ClientBattleInformationRepository.actorActualSides[it.uuid] = 1 }
|
||||
packet.side2.actors.forEach { ClientBattleInformationRepository.actorActualSides[it.uuid] = 2 }
|
||||
val playerUUID = Minecraft.getInstance().player?.uuid
|
||||
CobblemonClient.battle = ClientBattle(
|
||||
packet.battleId,
|
||||
|
||||
+1
-2
@@ -21,7 +21,6 @@ import net.minecraft.locale.Language
|
||||
object BattleMessageHandler : ClientNetworkPacketHandler<BattleMessagePacket> {
|
||||
override fun handle(packet: BattleMessagePacket, client: Minecraft) {
|
||||
val battle = CobblemonClient.battle ?: return
|
||||
battle.messages.addComponents(packet.messages)
|
||||
val textRenderer = Minecraft.getInstance().font
|
||||
for (message in packet.messages) {
|
||||
val line = message.copy().bold().font(CobblemonResources.DEFAULT_LARGE)
|
||||
@@ -29,4 +28,4 @@ object BattleMessageHandler : ClientNetworkPacketHandler<BattleMessagePacket> {
|
||||
battle.messages.add(lines)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-20
@@ -1,20 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.net.battle
|
||||
|
||||
import com.cobblemon.mod.common.api.net.ClientNetworkPacketHandler
|
||||
import com.cobblemon.mod.common.client.battle.ClientBattleInformationRepository
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleTimerPacket
|
||||
import net.minecraft.client.Minecraft
|
||||
|
||||
object BattleTimerHandler : ClientNetworkPacketHandler<BattleTimerPacket> {
|
||||
override fun handle(packet: BattleTimerPacket, client: Minecraft) {
|
||||
ClientBattleInformationRepository.mustChooseBy = packet.mustChooseBy
|
||||
}
|
||||
}
|
||||
-22
@@ -1,22 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.net.battle
|
||||
|
||||
import com.cobblemon.mod.common.api.net.ClientNetworkPacketHandler
|
||||
import com.cobblemon.mod.common.client.gui.battle.preview.TeamPreviewGUI
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.CloseTeamPreviewPacket
|
||||
import net.minecraft.client.Minecraft
|
||||
|
||||
object CloseTeamPreviewHandler : ClientNetworkPacketHandler<CloseTeamPreviewPacket> {
|
||||
override fun handle(packet: CloseTeamPreviewPacket, client: Minecraft) {
|
||||
if (client.screen is TeamPreviewGUI) {
|
||||
client.screen!!.onClose()
|
||||
}
|
||||
}
|
||||
}
|
||||
-27
@@ -1,27 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.net.battle
|
||||
|
||||
import com.cobblemon.mod.common.api.net.ClientNetworkPacketHandler
|
||||
import com.cobblemon.mod.common.client.battle.preview.ClientBattleTeamPreview
|
||||
import com.cobblemon.mod.common.client.gui.battle.preview.TeamPreviewGUI
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.TeamPreviewPacket
|
||||
import net.minecraft.client.Minecraft
|
||||
|
||||
object TeamPreviewHandler : ClientNetworkPacketHandler<TeamPreviewPacket> {
|
||||
override fun handle(packet: TeamPreviewPacket, client: Minecraft) {
|
||||
Minecraft.getInstance().setScreen(TeamPreviewGUI(ClientBattleTeamPreview(
|
||||
packet.selections,
|
||||
packet.team,
|
||||
packet.opponent,
|
||||
packet.mustPickBy,
|
||||
packet.opponentName
|
||||
)))
|
||||
}
|
||||
}
|
||||
-104
@@ -1,104 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen1
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.WaveAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.WaveSegment
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.CryProvider
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.ModelPartTransformation.Companion.X_AXIS
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.ModelPartTransformation.Companion.Y_AXIS
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.wavefunction.sineFunction
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.MOVING_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.STATIONARY_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.UI_POSES
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class EkansModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame {
|
||||
|
||||
override val rootPart = root.registerChildWithAllChildren("ekans")
|
||||
private val body = getPart("body")
|
||||
override val head = getPart("head")
|
||||
private val tail = getPart("tail")
|
||||
private val tail2 = getPart("tail2")
|
||||
private val tail3 = getPart("tail3")
|
||||
private val tail4 = getPart("tail4")
|
||||
private val tail5 = getPart("tail5")
|
||||
private val tail6 = getPart("tail6")
|
||||
|
||||
val tailSegment = WaveSegment(modelPart = tail, length = 9F)
|
||||
val tail2Segment = WaveSegment(modelPart = tail2, length = 9F)
|
||||
val tail3Segment = WaveSegment(modelPart = tail3, length = 9F)
|
||||
val tail4Segment = WaveSegment(modelPart = tail4, length = 9F)
|
||||
val tail5Segment = WaveSegment(modelPart = tail5, length = 10F)
|
||||
val tail6Segment = WaveSegment(modelPart = tail6, length = 10F)
|
||||
|
||||
override var portraitScale = 1.7F
|
||||
override var portraitTranslation = Vec3(-0.3, -0.45, 0.0)
|
||||
|
||||
override var profileScale = 0.7F
|
||||
override var profileTranslation = Vec3(-0.05, 0.6, 0.0)
|
||||
|
||||
lateinit var sleep: Pose
|
||||
|
||||
override val cryAnimation = CryProvider { bedrockStateful("ekans", "cry") }
|
||||
|
||||
override fun registerPoses() {
|
||||
sleep = registerPose(
|
||||
poseType = PoseType.SLEEP,
|
||||
animations = arrayOf(bedrock("ekans", "sleep"))
|
||||
)
|
||||
val blink = quirk { bedrockStateful("ekans", "blink") }
|
||||
registerPose(
|
||||
poseName = "normal",
|
||||
poseTypes = STATIONARY_POSES + MOVING_POSES,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("ekans", "ground_idle"),
|
||||
WaveAnimation(
|
||||
waveFunction = sineFunction(
|
||||
period = 8F,
|
||||
amplitude = 0.8F
|
||||
),
|
||||
basedOnLimbSwing = true,
|
||||
oscillationsScalar = 5F,
|
||||
head = head,
|
||||
rotationAxis = Y_AXIS,
|
||||
motionAxis = X_AXIS,
|
||||
moveHead = false,
|
||||
headLength = 16F,
|
||||
segments = arrayOf(
|
||||
tailSegment,
|
||||
tail2Segment,
|
||||
tail3Segment,
|
||||
tail4Segment,
|
||||
tail5Segment,
|
||||
tail6Segment
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
registerPose(
|
||||
poseName = "portrait",
|
||||
poseTypes = UI_POSES,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(bedrock("ekans", "summary_idle"))
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
override fun getFaintAnimation(state: PosableState) = bedrockStateful("ekans", "faint")
|
||||
}
|
||||
-63
@@ -1,63 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen1
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.CryProvider
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.MOVING_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.STATIONARY_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.UI_POSES
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class GloomModel(root: ModelPart) : PokemonPosableModel(root) {
|
||||
override val rootPart = root.registerChildWithAllChildren("gloom")
|
||||
|
||||
override var portraitScale = 1.8F
|
||||
override var portraitTranslation = Vec3(-0.0, -1.0, 0.0)
|
||||
|
||||
override var profileScale = 1.05F
|
||||
override var profileTranslation = Vec3(0.0, 0.19, 0.0)
|
||||
|
||||
lateinit var sleep: Pose
|
||||
lateinit var standing: Pose
|
||||
lateinit var walk: Pose
|
||||
|
||||
override val cryAnimation = CryProvider { bedrockStateful("gloom", "cry") }
|
||||
|
||||
override fun registerPoses() {
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = STATIONARY_POSES + UI_POSES,
|
||||
transformTicks = 10,
|
||||
animations = arrayOf(
|
||||
bedrock("gloom", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
sleep = registerPose(
|
||||
poseType = PoseType.SLEEP,
|
||||
animations = arrayOf(bedrock("gloom", "sleep"))
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = MOVING_POSES,
|
||||
transformTicks = 10,
|
||||
animations = arrayOf(
|
||||
bedrock("gloom", "ground_walk")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getFaintAnimation(state: PosableState) = bedrockStateful("gloom", "faint")
|
||||
}
|
||||
-66
@@ -1,66 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen1
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.CryProvider
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.MOVING_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.STATIONARY_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.UI_POSES
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class OddishModel(root: ModelPart) : PokemonPosableModel(root) {
|
||||
override val rootPart = root.registerChildWithAllChildren("oddish")
|
||||
|
||||
override var portraitScale = 2.0F
|
||||
override var portraitTranslation = Vec3(-0.0, -1.0, 0.0)
|
||||
|
||||
override var profileScale = 0.85F
|
||||
override var profileTranslation = Vec3(0.0, 0.5, 0.0)
|
||||
|
||||
lateinit var sleep: Pose
|
||||
lateinit var standing: Pose
|
||||
lateinit var walk: Pose
|
||||
|
||||
override val cryAnimation = CryProvider { bedrockStateful("oddish", "cry") }
|
||||
|
||||
override fun registerPoses() {
|
||||
val blink = quirk { bedrockStateful("oddish", "blink")}
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = STATIONARY_POSES + UI_POSES,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
bedrock("oddish", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
sleep = registerPose(
|
||||
poseType = PoseType.SLEEP,
|
||||
animations = arrayOf(bedrock("oddish", "sleep"))
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = MOVING_POSES,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
bedrock("oddish", "ground_walk")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getFaintAnimation(state: PosableState) = bedrockStateful("oddish", "faint")
|
||||
}
|
||||
-75
@@ -1,75 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen1
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.CryProvider
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.STANDING_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.UI_POSES
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class PoliwagModel(root: ModelPart) : PokemonPosableModel(root) {
|
||||
override val rootPart = root.registerChildWithAllChildren("poliwag")
|
||||
|
||||
override var portraitScale = 1.8F
|
||||
override var portraitTranslation = Vec3(0.0, -0.7, 0.0)
|
||||
|
||||
override var profileScale = 0.9F
|
||||
override var profileTranslation = Vec3(0.0, 0.38, 0.0)
|
||||
|
||||
lateinit var sleep: Pose
|
||||
lateinit var standing: Pose
|
||||
lateinit var float: Pose
|
||||
lateinit var swim: Pose
|
||||
|
||||
override val cryAnimation = CryProvider { bedrockStateful("poliwag", "cry") }
|
||||
|
||||
override fun registerPoses() {
|
||||
val blink = quirk { bedrockStateful("poliwag", "blink")}
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = STANDING_POSES + UI_POSES,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
bedrock("poliwag", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
sleep = registerPose(
|
||||
poseType = PoseType.SLEEP,
|
||||
animations = arrayOf(bedrock("poliwag", "sleep"))
|
||||
)
|
||||
|
||||
float = registerPose(
|
||||
poseName = "float",
|
||||
poseType = PoseType.FLOAT,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
bedrock("poliwag", "water_idle")
|
||||
)
|
||||
)
|
||||
|
||||
swim = registerPose(
|
||||
poseName = "swim",
|
||||
poseType = PoseType.SWIM,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
bedrock("poliwag", "water_swim")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// override fun getFaintAnimation(
|
||||
// ) = if (state.isPosedIn(standing, walk)) bedrockStateful("poliwag", "faint") else null
|
||||
// pokemonEntity: PokemonEntity,
|
||||
// state: PosableState<PokemonEntity>
|
||||
}
|
||||
-66
@@ -1,66 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen1
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.CryProvider
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.MOVING_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.STATIONARY_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.UI_POSES
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class VileplumeModel(root: ModelPart) : PokemonPosableModel(root) {
|
||||
override val rootPart = root.registerChildWithAllChildren("vileplume")
|
||||
|
||||
override var portraitScale = 1.8F
|
||||
override var portraitTranslation = Vec3(-0.35, -0.8, 0.0)
|
||||
|
||||
override var profileScale = 0.8F
|
||||
override var profileTranslation = Vec3(0.0, 0.53, 0.0)
|
||||
|
||||
lateinit var sleep: Pose
|
||||
lateinit var standing: Pose
|
||||
lateinit var walk: Pose
|
||||
|
||||
override val cryAnimation = CryProvider { bedrockStateful("vileplume", "cry") }
|
||||
|
||||
override fun registerPoses() {
|
||||
val blink = quirk { bedrockStateful("vileplume", "blink")}
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = STATIONARY_POSES + UI_POSES,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
bedrock("vileplume", "idle")
|
||||
)
|
||||
)
|
||||
|
||||
sleep = registerPose(
|
||||
poseType = PoseType.SLEEP,
|
||||
animations = arrayOf(bedrock("vileplume", "sleep"))
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = MOVING_POSES,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
bedrock("vileplume", "ground_walk")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getFaintAnimation(state: PosableState) = bedrockStateful("vileplume", "faint")
|
||||
}
|
||||
-95
@@ -1,95 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen2
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.createTransformation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.ModelPartTransformation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.MOVING_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.SHOULDER_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.STATIONARY_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.UI_POSES
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class BellossomModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame {
|
||||
override val rootPart = root.registerChildWithAllChildren("bellossom")
|
||||
override val head = getPart("head")
|
||||
|
||||
override var portraitScale = 1.8F
|
||||
override var portraitTranslation = Vec3(0.0, -0.2, 0.0)
|
||||
|
||||
override var profileScale = 1.0F
|
||||
override var profileTranslation = Vec3(0.0, 0.21, 0.0)
|
||||
|
||||
lateinit var standing: Pose
|
||||
lateinit var walk: Pose
|
||||
lateinit var shoulderLeft: Pose
|
||||
lateinit var shoulderRight: Pose
|
||||
|
||||
val shoulderOffset = 5
|
||||
|
||||
override fun registerPoses() {
|
||||
val blink = quirk { bedrockStateful("bellossom", "blink") }
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = STATIONARY_POSES + UI_POSES,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
bedrock("bellossom", "ground_idle"),
|
||||
singleBoneLook()
|
||||
)
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = MOVING_POSES,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
bedrock("bellossom", "ground_idle"),
|
||||
bedrock("bellossom", "ground_walk"),
|
||||
singleBoneLook()
|
||||
)
|
||||
)
|
||||
|
||||
shoulderLeft = registerPose(
|
||||
poseType = PoseType.SHOULDER_LEFT,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("bellossom", "ground_idle")
|
||||
),
|
||||
transformedParts = arrayOf(
|
||||
rootPart.createTransformation().addPosition(ModelPartTransformation.X_AXIS, shoulderOffset)
|
||||
)
|
||||
)
|
||||
|
||||
shoulderRight = registerPose(
|
||||
poseType = PoseType.SHOULDER_RIGHT,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("bellossom", "ground_idle")
|
||||
),
|
||||
transformedParts = arrayOf(
|
||||
rootPart.createTransformation().addPosition(ModelPartTransformation.X_AXIS, -shoulderOffset)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// override fun getFaintAnimation(
|
||||
// pokemonEntity: PokemonEntity,
|
||||
// state: PosableState<PokemonEntity>
|
||||
// ) = if (state.isPosedIn(standing, walk)) bedrockStateful("bellossom", "faint") else null
|
||||
}
|
||||
-80
@@ -1,80 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen2
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BipedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.UI_POSES
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class PolitoedModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame, BipedFrame {
|
||||
override val rootPart = root.registerChildWithAllChildren("politoed")
|
||||
override val head = getPart("head")
|
||||
|
||||
override val leftLeg = getPart("leftleg")
|
||||
override val rightLeg = getPart("rightleg")
|
||||
|
||||
override var portraitScale = 2.4F
|
||||
override var portraitTranslation = Vec3(-0.04, -0.55, 0.0)
|
||||
|
||||
override var profileScale = 1.1F
|
||||
override var profileTranslation = Vec3(0.0, 0.1, 0.0)
|
||||
|
||||
lateinit var standing: Pose
|
||||
lateinit var walking: Pose
|
||||
lateinit var float: Pose
|
||||
lateinit var swim: Pose
|
||||
|
||||
override fun registerPoses() {
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = UI_POSES + PoseType.STAND,
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("politoed", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
walking = registerPose(
|
||||
poseName = "walking",
|
||||
poseType = PoseType.WALK,
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("politoed", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
float = registerPose(
|
||||
poseName = "float",
|
||||
poseTypes = setOf(PoseType.FLOAT, PoseType.HOVER),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("politoed", "water_idle")
|
||||
)
|
||||
)
|
||||
|
||||
swim = registerPose(
|
||||
poseName = "swim",
|
||||
poseTypes = setOf(PoseType.SWIM, PoseType.FLY),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("politoed", "water_swim")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// override fun getFaintAnimation(
|
||||
// pokemonEntity: PokemonEntity,
|
||||
// state: PosableState<PokemonEntity>
|
||||
// ) = if (state.isPosedIn(standing, walk)) bedrockStateful("politoed", "faint") else null
|
||||
}
|
||||
-72
@@ -1,72 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen2
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.BimanualSwingAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.BipedWalkAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BimanualFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BipedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.MOVING_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.STATIONARY_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.UI_POSES
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class SudowoodoModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame, BipedFrame, BimanualFrame {
|
||||
override val rootPart = root.registerChildWithAllChildren("sudowoodo")
|
||||
override val head = getPart("head")
|
||||
|
||||
override val leftArm = getPart("arm_left")
|
||||
override val rightArm = getPart("arm_right")
|
||||
override val leftLeg = getPart("leg_left")
|
||||
override val rightLeg = getPart("leg_right")
|
||||
|
||||
override var portraitScale = 1.9F
|
||||
override var portraitTranslation = Vec3(-0.7, 1.6, 0.0)
|
||||
|
||||
override var profileScale = 0.5F
|
||||
override var profileTranslation = Vec3(-0.1, 0.95, 0.0)
|
||||
|
||||
lateinit var standing: Pose
|
||||
lateinit var walk: Pose
|
||||
|
||||
override fun registerPoses() {
|
||||
val blink = quirk { bedrockStateful("sudowoodo", "blink") }
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = STATIONARY_POSES + UI_POSES,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(yawMultiplier = 0F),
|
||||
bedrock("sudowoodo", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = MOVING_POSES,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(yawMultiplier = 0F),
|
||||
bedrock("sudowoodo", "ground_idle"),
|
||||
BipedWalkAnimation(this, periodMultiplier = 0.6F, amplitudeMultiplier = 0.9F),
|
||||
BimanualSwingAnimation(this, swingPeriodMultiplier = 0.6F, amplitudeMultiplier = 0.9F)
|
||||
//bedrock("sudowoodo", "ground_walk")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// override fun getFaintAnimation(
|
||||
// pokemonEntity: PokemonEntity,
|
||||
// state: PosableState<PokemonEntity>
|
||||
// ) = if (state.isPosedIn(standing, walk)) bedrockStateful("sudowoodo", "faint") else null
|
||||
}
|
||||
-91
@@ -1,91 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen3
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BipedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.CryProvider
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.MOVING_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.STATIONARY_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.UI_POSES
|
||||
import com.cobblemon.mod.common.util.isBattling
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class ShroomishModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame, BipedFrame {
|
||||
override val rootPart = root.registerChildWithAllChildren("shroomish")
|
||||
override val head = getPart("torso")
|
||||
|
||||
override val leftLeg = getPart("foot_left")
|
||||
override val rightLeg = getPart("foot_right")
|
||||
|
||||
override var portraitScale = 2.0F
|
||||
override var portraitTranslation = Vec3(-0.1, -1.2, 0.0)
|
||||
|
||||
override var profileScale = 1.0F
|
||||
override var profileTranslation = Vec3(0.0, 0.3, 0.0)
|
||||
|
||||
lateinit var standing: Pose
|
||||
lateinit var battling: Pose
|
||||
lateinit var sleeping: Pose
|
||||
lateinit var walk: Pose
|
||||
|
||||
override val cryAnimation = CryProvider { bedrockStateful("shroomish", "cry") }
|
||||
|
||||
override fun registerPoses() {
|
||||
val blink = quirk { bedrockStateful("shroomish", "blink") }
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = STATIONARY_POSES + UI_POSES,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { !it.isBattling },
|
||||
animations = arrayOf(
|
||||
singleBoneLook(pitchMultiplier = 0.5F),
|
||||
bedrock("shroomish", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = MOVING_POSES,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(pitchMultiplier = 0.5F),
|
||||
bedrock("shroomish", "ground_walk")
|
||||
)
|
||||
)
|
||||
|
||||
battling = registerPose(
|
||||
poseName = "battlestanding",
|
||||
poseTypes = STATIONARY_POSES,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { it.isBattling },
|
||||
animations = arrayOf(
|
||||
singleBoneLook(pitchMultiplier = 0.5F),
|
||||
bedrock("shroomish", "battle_idle")
|
||||
)
|
||||
)
|
||||
|
||||
sleeping = registerPose(
|
||||
poseName = "sleeping",
|
||||
poseType = PoseType.SLEEP,
|
||||
transformTicks = 10,
|
||||
animations = arrayOf(
|
||||
bedrock("shroomish", "sleep")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getFaintAnimation(state: PosableState) = if (state.isPosedIn(standing, walk, battling, sleeping)) bedrockStateful("shroomish", "faint") else null
|
||||
}
|
||||
-102
@@ -1,102 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen4
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BipedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.MOVING_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.STATIONARY_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.UI_POSES
|
||||
import com.cobblemon.mod.common.util.isBattling
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class BonslyModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame, BipedFrame {
|
||||
override val rootPart = root.registerChildWithAllChildren("bonsly")
|
||||
override val head = getPart("torso")
|
||||
|
||||
override val leftLeg = getPart("leg_left")
|
||||
override val rightLeg = getPart("leg_right")
|
||||
|
||||
override var portraitScale = 2.2F
|
||||
override var portraitTranslation = Vec3(-0.2, -0.8, 0.0)
|
||||
|
||||
override var profileScale = 0.72F
|
||||
override var profileTranslation = Vec3(0.0, 0.65, 0.0)
|
||||
|
||||
lateinit var standing: Pose
|
||||
lateinit var walk: Pose
|
||||
lateinit var battleidle: Pose
|
||||
lateinit var sleep: Pose
|
||||
lateinit var battlesleep: Pose
|
||||
|
||||
override fun registerPoses() {
|
||||
val blink = quirk { bedrockStateful("bonsly", "blink") }
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = STATIONARY_POSES + UI_POSES,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { !it.isBattling },
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("bonsly", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = MOVING_POSES,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("bonsly", "ground_walk")
|
||||
)
|
||||
)
|
||||
|
||||
sleep = registerPose(
|
||||
poseName = "sleep",
|
||||
poseType = PoseType.SLEEP,
|
||||
condition = { !it.isBattling },
|
||||
animations = arrayOf(
|
||||
bedrock("bonsly", "sleep_pot")
|
||||
)
|
||||
)
|
||||
|
||||
battlesleep = registerPose(
|
||||
poseName = "battlesleep",
|
||||
poseType = PoseType.SLEEP,
|
||||
condition = { it.isBattling },
|
||||
animations = arrayOf(
|
||||
bedrock("bonsly", "sleep")
|
||||
)
|
||||
)
|
||||
|
||||
battleidle = registerPose(
|
||||
poseName = "battle_idle",
|
||||
poseTypes = PoseType.STATIONARY_POSES,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { it.isBattling },
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("bonsly", "battle_idle")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// override fun getFaintAnimation(
|
||||
// pokemonEntity: PokemonEntity,
|
||||
// state: PosableState<PokemonEntity>
|
||||
// ) = if (state.isPosedIn(standing, walk))
|
||||
// bedrockStateful("bonsly", "faint")
|
||||
// else null
|
||||
}
|
||||
-72
@@ -1,72 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen4
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.QuadrupedWalkAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.QuadrupedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class LuxioModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame, QuadrupedFrame {
|
||||
override val rootPart = root.registerChildWithAllChildren("luxio")
|
||||
override val head = getPart("head")
|
||||
|
||||
override val foreLeftLeg = getPart("front_leg_left")
|
||||
override val foreRightLeg = getPart("front_leg_right")
|
||||
override val hindLeftLeg = getPart("back_leg_left")
|
||||
override val hindRightLeg = getPart("back_leg_right")
|
||||
|
||||
override var portraitScale = 1.8F
|
||||
override var portraitTranslation = Vec3(-0.6, -0.25, 0.0)
|
||||
|
||||
override var profileScale = 0.7F
|
||||
override var profileTranslation = Vec3(0.0, 0.7, 0.0)
|
||||
|
||||
lateinit var standing: Pose
|
||||
lateinit var walk: Pose
|
||||
lateinit var sleep: Pose
|
||||
|
||||
override fun registerPoses() {
|
||||
// val blink = quirk { bedrockStateful("luxio", "blink") }
|
||||
sleep = registerPose(
|
||||
poseType = PoseType.SLEEP,
|
||||
animations = arrayOf(bedrock("luxio", "sleep"))
|
||||
)
|
||||
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = PoseType.UI_POSES + PoseType.STATIONARY_POSES,
|
||||
// quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("luxio", "idle")
|
||||
)
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = PoseType.MOVING_POSES,
|
||||
// quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
QuadrupedWalkAnimation(this, periodMultiplier = 1.1F),
|
||||
singleBoneLook(),
|
||||
bedrock("luxio", "idle")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// override fun getFaintAnimation(
|
||||
// pokemonEntity: PokemonEntity,
|
||||
// state: PosableState<PokemonEntity>
|
||||
// ) = if (state.isPosedIn(standing, walk)) bedrockStateful("luxio", "faint") else null
|
||||
}
|
||||
-67
@@ -1,67 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen4
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.QuadrupedWalkAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.QuadrupedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class LuxrayModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame, QuadrupedFrame {
|
||||
override val rootPart = root.registerChildWithAllChildren("luxray")
|
||||
override val head = getPart("head")
|
||||
|
||||
override val foreLeftLeg = getPart("front_leg_left")
|
||||
override val foreRightLeg = getPart("front_leg_right")
|
||||
override val hindLeftLeg = getPart("back_leg_left")
|
||||
override val hindRightLeg = getPart("back_leg_right")
|
||||
|
||||
override var portraitScale = 1.8F
|
||||
override var portraitTranslation = Vec3(-0.9, 0.6, 0.0)
|
||||
|
||||
override var profileScale = 0.66F
|
||||
override var profileTranslation = Vec3(0.0, 0.7, 0.0)
|
||||
|
||||
lateinit var standing: Pose
|
||||
lateinit var walk: Pose
|
||||
|
||||
override fun registerPoses() {
|
||||
// val blink = quirk { bedrockStateful("luxray", "blink") }
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = PoseType.UI_POSES + PoseType.STATIONARY_POSES,
|
||||
// quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("luxray", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = PoseType.MOVING_POSES,
|
||||
// quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
QuadrupedWalkAnimation(this, periodMultiplier = 1.1F),
|
||||
bedrock("luxray", "ground_idle"),
|
||||
singleBoneLook()
|
||||
// bedrock("luxray", "idle")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// override fun getFaintAnimation(
|
||||
// pokemonEntity: PokemonEntity,
|
||||
// state: PosableState<PokemonEntity>
|
||||
// ) = if (state.isPosedIn(standing, walk)) bedrockStateful("luxray", "faint") else null
|
||||
}
|
||||
-66
@@ -1,66 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen4
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.QuadrupedWalkAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.QuadrupedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class ShinxModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame, QuadrupedFrame {
|
||||
override val rootPart = root.registerChildWithAllChildren("shinx")
|
||||
override val head = getPart("head")
|
||||
|
||||
override val foreLeftLeg = getPart("leg_left")
|
||||
override val foreRightLeg = getPart("leg_right")
|
||||
override val hindLeftLeg = getPart("back_leg_left")
|
||||
override val hindRightLeg = getPart("back_leg_right")
|
||||
|
||||
override var portraitScale = 1.8F
|
||||
override var portraitTranslation = Vec3(-0.6, -0.25, 0.0)
|
||||
|
||||
override var profileScale = 0.66F
|
||||
override var profileTranslation = Vec3(0.0, 0.7, 0.0)
|
||||
|
||||
lateinit var standing: Pose
|
||||
lateinit var walk: Pose
|
||||
|
||||
override fun registerPoses() {
|
||||
// val blink = quirk { bedrockStateful("shinx", "blink") }
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = PoseType.UI_POSES + PoseType.STATIONARY_POSES,
|
||||
// quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("shinx", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = PoseType.MOVING_POSES,
|
||||
// quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
QuadrupedWalkAnimation(this, periodMultiplier = 1.1F),
|
||||
singleBoneLook(),
|
||||
bedrock("shinx", "ground_idle")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// override fun getFaintAnimation(
|
||||
// pokemonEntity: PokemonEntity,
|
||||
// state: PosableState<PokemonEntity>
|
||||
// ) = if (state.isPosedIn(standing, walk)) bedrockStateful("shinx", "faint") else null
|
||||
}
|
||||
-63
@@ -1,63 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen5
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.QuadrupedWalkAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.QuadrupedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class DeerlingModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame, QuadrupedFrame {
|
||||
override val rootPart = root.registerChildWithAllChildren("deerling")
|
||||
override val head = getPart("head")
|
||||
|
||||
override var portraitScale = 3.5F
|
||||
override var portraitTranslation = Vec3(-0.55, -1.1, 0.0)
|
||||
|
||||
override var profileScale = 1.0F
|
||||
override var profileTranslation = Vec3(0.0, 0.25, 0.0)
|
||||
|
||||
override val foreLeftLeg= getPart("leg_front_left")
|
||||
override val foreRightLeg = getPart("leg_front_right")
|
||||
override val hindLeftLeg = getPart("leg_back_left")
|
||||
override val hindRightLeg = getPart("leg_back_right")
|
||||
|
||||
lateinit var standing: Pose
|
||||
lateinit var walk: Pose
|
||||
|
||||
override fun registerPoses() {
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = PoseType.STATIONARY_POSES + PoseType.UI_POSES,
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
// bedrock("deerling", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = PoseType.MOVING_POSES,
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
QuadrupedWalkAnimation(this, periodMultiplier = 0.8F, amplitudeMultiplier = 0.8F)
|
||||
// bedrock("deerling", "ground_walk")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// override fun getFaintAnimation(
|
||||
// pokemonEntity: PokemonEntity,
|
||||
// state: PosableState<PokemonEntity>
|
||||
// ) = if (state.isPosedIn(standing, walk)) bedrockStateful("deerling", "faint") else null
|
||||
}
|
||||
-63
@@ -1,63 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen5
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.QuadrupedWalkAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.QuadrupedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class SawsbuckModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame, QuadrupedFrame {
|
||||
override val rootPart = root.registerChildWithAllChildren("sawsbuck")
|
||||
override val head = getPart("head")
|
||||
|
||||
override var portraitScale = 2.0F
|
||||
override var portraitTranslation = Vec3(-0.5, 1.1, 0.0)
|
||||
|
||||
override var profileScale = 0.65F
|
||||
override var profileTranslation = Vec3(0.0, 0.75, 0.0)
|
||||
|
||||
override val foreLeftLeg= getPart("leg_front_left")
|
||||
override val foreRightLeg = getPart("leg_front_right")
|
||||
override val hindLeftLeg = getPart("leg_back_left")
|
||||
override val hindRightLeg = getPart("leg_back_right")
|
||||
|
||||
lateinit var standing: Pose
|
||||
lateinit var walk: Pose
|
||||
|
||||
override fun registerPoses() {
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = PoseType.STATIONARY_POSES + PoseType.UI_POSES,
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
// bedrock("sawsbuck", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = PoseType.MOVING_POSES,
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
QuadrupedWalkAnimation(this, periodMultiplier = 0.9F, amplitudeMultiplier = 0.9F)
|
||||
// bedrock("sawsbuck", "ground_walk")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// override fun getFaintAnimation(
|
||||
// pokemonEntity: PokemonEntity,
|
||||
// state: PosableState<PokemonEntity>
|
||||
// ) = if (state.isPosedIn(standing, walk)) bedrockStateful("sawsbuck", "faint") else null
|
||||
}
|
||||
-70
@@ -1,70 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen6
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.BimanualSwingAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.BipedWalkAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BimanualFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BipedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.CryProvider
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.MOVING_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.STATIONARY_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.UI_POSES
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class ChesnaughtModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame, BipedFrame, BimanualFrame {
|
||||
override val rootPart = root.registerChildWithAllChildren("chesnaught")
|
||||
override val head = getPart("head")
|
||||
override val rightArm = getPart("arm_right")
|
||||
override val leftArm = getPart("arm_left")
|
||||
override val leftLeg = getPart("leg_left")
|
||||
override val rightLeg = getPart("leg_right")
|
||||
|
||||
override var portraitScale = 2.2F
|
||||
override var portraitTranslation = Vec3(-1.0, 1.65, 0.0)
|
||||
|
||||
override var profileScale = 0.6F
|
||||
override var profileTranslation = Vec3(0.0, 0.85, 0.0)
|
||||
|
||||
|
||||
lateinit var standing: Pose
|
||||
lateinit var walk: Pose
|
||||
|
||||
override val cryAnimation = CryProvider { bedrockStateful("chesnaught", "cry") }
|
||||
|
||||
override fun registerPoses() {
|
||||
val blink = quirk { bedrockStateful("chesnaught", "blink")}
|
||||
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = STATIONARY_POSES + UI_POSES,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("chesnaught", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = MOVING_POSES,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
BimanualSwingAnimation(this),
|
||||
BipedWalkAnimation(this),
|
||||
bedrock("chesnaught", "ground_idle")
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
-70
@@ -1,70 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen6
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BimanualFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BipedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.CryProvider
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class ChespinModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame, BipedFrame, BimanualFrame {
|
||||
override val rootPart = root.registerChildWithAllChildren("chespin")
|
||||
override val head = getPart("head")
|
||||
override val rightArm = getPart("arm_right")
|
||||
override val leftArm = getPart("arm_left")
|
||||
override val leftLeg = getPart("leg_left")
|
||||
override val rightLeg = getPart("leg_right")
|
||||
|
||||
override var portraitScale = 2.03F
|
||||
override var portraitTranslation = Vec3(-0.12, -0.44, 0.0)
|
||||
|
||||
override var profileScale = 0.77F
|
||||
override var profileTranslation = Vec3(0.0, 0.6, 0.0)
|
||||
|
||||
lateinit var standing: Pose
|
||||
lateinit var walk: Pose
|
||||
lateinit var sleep: Pose
|
||||
|
||||
override val cryAnimation = CryProvider { bedrockStateful("chespin", "cry") }
|
||||
|
||||
override fun registerPoses() {
|
||||
val blink = quirk { bedrockStateful("chespin", "blink")}
|
||||
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = PoseType.STATIONARY_POSES + PoseType.UI_POSES,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("chespin", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = PoseType.MOVING_POSES,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("chespin", "ground_walk")
|
||||
)
|
||||
)
|
||||
|
||||
sleep = registerPose(
|
||||
poseType = PoseType.SLEEP,
|
||||
transformTicks = 10,
|
||||
animations = arrayOf(bedrock("chespin", "sleep"))
|
||||
)
|
||||
}
|
||||
}
|
||||
-118
@@ -1,118 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen6
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BimanualFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BipedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.CryProvider
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.util.isBattling
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class FroakieModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame, BipedFrame, BimanualFrame {
|
||||
override val rootPart = root.registerChildWithAllChildren("froakie")
|
||||
override val head = getPart("head")
|
||||
override val rightArm = getPart("arm_right")
|
||||
override val leftArm = getPart("arm_left")
|
||||
override val rightLeg = getPart("leg_right")
|
||||
override val leftLeg = getPart("leg_left")
|
||||
|
||||
override var portraitScale = 1.86F
|
||||
override var portraitTranslation = Vec3(-0.25, -0.51, 0.0)
|
||||
|
||||
override var profileScale = 0.75F
|
||||
override var profileTranslation = Vec3(0.0, 0.56, 0.0)
|
||||
|
||||
lateinit var sleep: Pose
|
||||
lateinit var standing: Pose
|
||||
lateinit var float: Pose
|
||||
lateinit var swim: Pose
|
||||
lateinit var walk: Pose
|
||||
lateinit var battleidle: Pose
|
||||
|
||||
override val cryAnimation = CryProvider { bedrockStateful("froakie", "cry") }
|
||||
|
||||
override fun registerPoses() {
|
||||
val blink = quirk { bedrockStateful("froakie", "blink")}
|
||||
sleep = registerPose(
|
||||
poseType = PoseType.SLEEP,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(bedrock("froakie", "sleep"))
|
||||
)
|
||||
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = PoseType.UI_POSES + PoseType.STATIONARY_POSES - PoseType.FLOAT,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { !it.isBattling },
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("froakie", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseType = PoseType.WALK,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { !it.isBattling },
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("froakie", "ground_walk")
|
||||
)
|
||||
)
|
||||
|
||||
float = registerPose(
|
||||
poseName = "swim_idle",
|
||||
poseTypes = setOf(PoseType.FLOAT, PoseType.HOVER),
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { !it.isBattling },
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("froakie", "water_idle")
|
||||
)
|
||||
)
|
||||
|
||||
swim = registerPose(
|
||||
poseName = "swim",
|
||||
poseTypes = setOf(PoseType.SWIM, PoseType.FLY),
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { !it.isBattling },
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("froakie", "water_swim")
|
||||
)
|
||||
)
|
||||
|
||||
battleidle = registerPose(
|
||||
poseName = "battle_idle",
|
||||
poseTypes = PoseType.STATIONARY_POSES,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { it.isBattling },
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("froakie", "battle_idle")
|
||||
)
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
override fun getFaintAnimation(state: PosableState) = if (state.isPosedIn(standing, walk, battleidle, swim, float, sleep)) bedrockStateful("froakie", "faint") else null
|
||||
}
|
||||
-118
@@ -1,118 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen6
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BimanualFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BipedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.CryProvider
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.util.isBattling
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class FrogadierModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame, BipedFrame, BimanualFrame {
|
||||
override val rootPart = root.registerChildWithAllChildren("frogadier")
|
||||
override val head = getPart("head")
|
||||
override val rightArm = getPart("arm_right")
|
||||
override val leftArm = getPart("arm_left")
|
||||
override val rightLeg = getPart("leg_right")
|
||||
override val leftLeg = getPart("leg_left")
|
||||
|
||||
override var portraitScale = 1.9F
|
||||
override var portraitTranslation = Vec3(-0.1, 1.4, 0.0)
|
||||
|
||||
override var profileScale = 0.7F
|
||||
override var profileTranslation = Vec3(0.0, 0.7, 0.0)
|
||||
|
||||
lateinit var sleep: Pose
|
||||
lateinit var standing: Pose
|
||||
lateinit var float: Pose
|
||||
lateinit var swim: Pose
|
||||
lateinit var walk: Pose
|
||||
lateinit var battleidle: Pose
|
||||
|
||||
override val cryAnimation = CryProvider { bedrockStateful("frogadier", "cry") }
|
||||
|
||||
override fun registerPoses() {
|
||||
val blink = quirk { bedrockStateful("frogadier", "blink")}
|
||||
sleep = registerPose(
|
||||
poseType = PoseType.SLEEP,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(bedrock("frogadier", "sleep"))
|
||||
)
|
||||
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = PoseType.UI_POSES + PoseType.STATIONARY_POSES - PoseType.FLOAT,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { !it.isBattling },
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("frogadier", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseType = PoseType.WALK,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { !it.isBattling },
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("frogadier", "ground_walk")
|
||||
)
|
||||
)
|
||||
|
||||
float = registerPose(
|
||||
poseName = "swim_idle",
|
||||
poseTypes = setOf(PoseType.FLOAT, PoseType.HOVER),
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { !it.isBattling },
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("frogadier", "water_idle")
|
||||
)
|
||||
)
|
||||
|
||||
swim = registerPose(
|
||||
poseName = "swim",
|
||||
poseTypes = setOf(PoseType.SWIM, PoseType.FLY),
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { !it.isBattling },
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("frogadier", "water_swim")
|
||||
)
|
||||
)
|
||||
|
||||
battleidle = registerPose(
|
||||
poseName = "battle_idle",
|
||||
poseTypes = PoseType.STATIONARY_POSES,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { it.isBattling },
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("frogadier", "battle_idle")
|
||||
)
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
override fun getFaintAnimation(state: PosableState) = if (state.isPosedIn(standing, walk, battleidle, swim, float, sleep)) bedrockStateful("frogadier", "faint") else null
|
||||
}
|
||||
-142
@@ -1,142 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen6
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.createTransformation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BimanualFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BipedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.CryProvider
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.util.isBattling
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class GreninjaModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame, BipedFrame, BimanualFrame {
|
||||
override val rootPart = root.registerChildWithAllChildren("greninja")
|
||||
override val head = getPart("head")
|
||||
override val rightArm = getPart("arm_right")
|
||||
override val leftArm = getPart("arm_left")
|
||||
override val rightLeg = getPart("leg_right")
|
||||
override val leftLeg = getPart("leg_left")
|
||||
val shurikenright = getPart("hand_shuriken_right")
|
||||
val shurikenleft = getPart("hand_shuriken_left")
|
||||
|
||||
override var portraitScale = 2.2F
|
||||
override var portraitTranslation = Vec3(-0.1, 1.34, 0.0)
|
||||
|
||||
override var profileScale = 0.7F
|
||||
override var profileTranslation = Vec3(0.0, 0.7, 0.0)
|
||||
|
||||
lateinit var sleep: Pose
|
||||
lateinit var standing: Pose
|
||||
lateinit var float: Pose
|
||||
lateinit var swim: Pose
|
||||
lateinit var walk: Pose
|
||||
lateinit var battleidle: Pose
|
||||
|
||||
override val cryAnimation = CryProvider { bedrockStateful("greninja", "cry") }
|
||||
|
||||
override fun registerPoses() {
|
||||
val blink = quirk { bedrockStateful("greninja", "blink")}
|
||||
sleep = registerPose(
|
||||
poseType = PoseType.SLEEP,
|
||||
transformTicks = 10,
|
||||
transformedParts = arrayOf(
|
||||
shurikenleft.createTransformation().withVisibility(visibility = false),
|
||||
shurikenright.createTransformation().withVisibility(visibility = false)
|
||||
),
|
||||
animations = arrayOf(bedrock("greninja", "sleep"))
|
||||
)
|
||||
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = PoseType.UI_POSES + PoseType.STATIONARY_POSES - PoseType.FLOAT,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { !it.isBattling },
|
||||
transformedParts = arrayOf(
|
||||
shurikenleft.createTransformation().withVisibility(visibility = false),
|
||||
shurikenright.createTransformation().withVisibility(visibility = false)
|
||||
),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("greninja", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseType = PoseType.WALK,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
transformedParts = arrayOf(
|
||||
shurikenleft.createTransformation().withVisibility(visibility = false),
|
||||
shurikenright.createTransformation().withVisibility(visibility = false)
|
||||
),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("greninja", "ground_walk")
|
||||
)
|
||||
)
|
||||
|
||||
float = registerPose(
|
||||
poseName = "swim_idle",
|
||||
poseTypes = setOf(PoseType.FLOAT, PoseType.HOVER),
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { !it.isBattling },
|
||||
transformedParts = arrayOf(
|
||||
shurikenleft.createTransformation().withVisibility(visibility = false),
|
||||
shurikenright.createTransformation().withVisibility(visibility = false)
|
||||
),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("greninja", "water_idle")
|
||||
)
|
||||
)
|
||||
|
||||
swim = registerPose(
|
||||
poseName = "swim",
|
||||
poseTypes = setOf(PoseType.SWIM, PoseType.FLY),
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { !it.isBattling },
|
||||
transformedParts = arrayOf(
|
||||
shurikenleft.createTransformation().withVisibility(visibility = false),
|
||||
shurikenright.createTransformation().withVisibility(visibility = false)
|
||||
),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("greninja", "water_swim")
|
||||
)
|
||||
)
|
||||
|
||||
battleidle = registerPose(
|
||||
poseName = "battle_idle",
|
||||
poseTypes = PoseType.STATIONARY_POSES,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
condition = { it.isBattling },
|
||||
transformedParts = arrayOf(
|
||||
shurikenleft.createTransformation().withVisibility(visibility = false),
|
||||
shurikenright.createTransformation().withVisibility(visibility = false)
|
||||
),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("greninja", "battle_idle")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getFaintAnimation(state: PosableState) = if (state.isPosedIn(standing, walk, battleidle, swim, float, sleep)) bedrockStateful("greninja", "faint") else null
|
||||
}
|
||||
-73
@@ -1,73 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen6
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BimanualFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BipedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.CryProvider
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.MOVING_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.STATIONARY_POSES
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.UI_POSES
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class QuilladinModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame, BipedFrame, BimanualFrame {
|
||||
override val rootPart = root.registerChildWithAllChildren("quilladin")
|
||||
override val head = getPart("torso")
|
||||
override val rightArm = getPart("arm_right")
|
||||
override val leftArm = getPart("arm_left")
|
||||
override val leftLeg = getPart("leg_left")
|
||||
override val rightLeg = getPart("leg_right")
|
||||
|
||||
override var portraitScale = 2F
|
||||
override var portraitTranslation = Vec3(-0.3, 0.1, 0.0)
|
||||
|
||||
override var profileScale = 0.7F
|
||||
override var profileTranslation = Vec3(0.0, 0.7, 0.0)
|
||||
|
||||
lateinit var standing: Pose
|
||||
lateinit var walk: Pose
|
||||
lateinit var sleep: Pose
|
||||
|
||||
override val cryAnimation = CryProvider { bedrockStateful("quilladin", "cry") }
|
||||
|
||||
override fun registerPoses() {
|
||||
val blink = quirk { bedrockStateful("quilladin", "blink")}
|
||||
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = STATIONARY_POSES + UI_POSES,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("quilladin", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = MOVING_POSES,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
singleBoneLook(),
|
||||
bedrock("quilladin", "ground_walk")
|
||||
)
|
||||
)
|
||||
|
||||
sleep = registerPose(
|
||||
poseType = PoseType.SLEEP,
|
||||
transformTicks = 10,
|
||||
animations = arrayOf(bedrock("quilladin", "sleep"))
|
||||
)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -29,7 +29,7 @@ class VivillonModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame, B
|
||||
override var portraitTranslation = Vec3(-0.3, 0.2, 0.0)
|
||||
|
||||
override var profileScale = 0.7F
|
||||
override var profileTranslation = Vec3(0.1, 0.8, 0.0)
|
||||
override var profileTranslation = Vec3(0.0, 0.8, 0.0)
|
||||
|
||||
lateinit var standing: Pose
|
||||
lateinit var walk: Pose
|
||||
|
||||
-90
@@ -1,90 +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://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen9
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.createTransformation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.CryProvider
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.ModelPartTransformation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class GlimmetModel (root: ModelPart) : PokemonPosableModel(root) {
|
||||
override val rootPart = root.registerChildWithAllChildren("glimmet")
|
||||
|
||||
override var portraitScale = 2.0F
|
||||
override var portraitTranslation = Vec3(-0.5, 1.3, 0.0)
|
||||
|
||||
override var profileScale = 0.7F
|
||||
override var profileTranslation = Vec3(0.0, 0.8, 0.0)
|
||||
|
||||
lateinit var standing: Pose
|
||||
lateinit var walk: Pose
|
||||
lateinit var sleep: Pose
|
||||
lateinit var shoulderLeft: Pose
|
||||
lateinit var shoulderRight: Pose
|
||||
|
||||
val shoulderOffset = 8
|
||||
|
||||
override val cryAnimation = CryProvider { bedrockStateful("glimmet", "cry") }
|
||||
|
||||
override fun registerPoses() {
|
||||
val blink = quirk { bedrockStateful("glimmet", "blink") }
|
||||
sleep = registerPose(
|
||||
poseType = PoseType.SLEEP,
|
||||
animations = arrayOf(bedrock("glimmet", "sleep"))
|
||||
)
|
||||
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = PoseType.STATIONARY_POSES + PoseType.UI_POSES,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
bedrock("glimmet", "ground_idle")
|
||||
)
|
||||
)
|
||||
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = PoseType.MOVING_POSES,
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
bedrock("glimmet", "ground_walk")
|
||||
)
|
||||
)
|
||||
|
||||
shoulderLeft = registerPose(
|
||||
poseType = PoseType.SHOULDER_LEFT,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
bedrock("glimmet", "ground_idle")
|
||||
),
|
||||
transformedParts = arrayOf(
|
||||
rootPart.createTransformation().addPosition(ModelPartTransformation.X_AXIS, shoulderOffset)
|
||||
)
|
||||
)
|
||||
|
||||
shoulderRight = registerPose(
|
||||
poseType = PoseType.SHOULDER_RIGHT,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
bedrock("glimmet", "ground_idle")
|
||||
),
|
||||
transformedParts = arrayOf(
|
||||
rootPart.createTransformation().addPosition(ModelPartTransformation.X_AXIS, -shoulderOffset)
|
||||
)
|
||||
)
|
||||
}
|
||||
override fun getFaintAnimation(state: PosableState) = if (state.isPosedIn(standing, walk)) bedrockStateful("glimmet", "faint") else null
|
||||
}
|
||||
Loaded 100 of 2080 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user