mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-12-03 21:48:53 -05:00
Compare commits
300
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7468902b43 | ||
|
|
da9da12630 | ||
|
|
da76b2fb94 | ||
|
|
87d8197dd0 | ||
|
|
2ed6f89d09 | ||
|
|
5947468cd9 | ||
|
|
7ba1507ac8 | ||
|
|
9fdffdc392 | ||
|
|
6a01fe3863 | ||
|
|
9b5a153e3f | ||
|
|
67f906dec2 | ||
|
|
0570afbe05 | ||
|
|
dfba2d27ab | ||
|
|
9c7cd4b616 | ||
|
|
9fe0e9c87e | ||
|
|
bd0e5a44bd | ||
|
|
229ec4176b | ||
|
|
323413efdc | ||
|
|
a309cc2522 | ||
|
|
cb782a2aa1 | ||
|
|
2c58dcb8ef | ||
|
|
d91cd4322c | ||
|
|
e48e492392 | ||
|
|
1f93994eba | ||
|
|
5210121b3d | ||
|
|
7fa3bf24d1 | ||
|
|
1128d7edf3 | ||
|
|
eef50a7237 | ||
|
|
f4140a097d | ||
|
|
b79dbcca80 | ||
|
|
5ac12a897a | ||
|
|
ae5f7c83f2 | ||
|
|
f14de9ab58 | ||
|
|
8a1c846c2c | ||
|
|
459e7d3490 | ||
|
|
5a9be8944f | ||
|
|
3bb941b087 | ||
|
|
384b496d76 | ||
|
|
fe940caafc | ||
|
|
c9d148ec9c | ||
|
|
e611bf4a77 | ||
|
|
8093822140 | ||
|
|
f695ec15f9 | ||
|
|
1f6c791ce6 | ||
|
|
570805fdf1 | ||
|
|
ddecb08bc7 | ||
|
|
a1b930a21f | ||
|
|
7728ff3892 | ||
|
|
4d7cfcdf61 | ||
|
|
e56dd6ef64 | ||
|
|
236b98fa78 | ||
|
|
ac61e0d4d0 | ||
|
|
d8956fd66f | ||
|
|
ffe005511d | ||
|
|
1e634a20b8 | ||
|
|
50a5a78dd4 | ||
|
|
76c2654399 | ||
|
|
f9f4745e93 | ||
|
|
c700674289 | ||
|
|
c4f0032eee | ||
|
|
d92986016b | ||
|
|
ab57e01242 | ||
|
|
0da1c740a4 | ||
|
|
a7979aa80c | ||
|
|
397d3c618d | ||
|
|
29f6feab6c | ||
|
|
ea5d3ae40f | ||
|
|
59804a4e08 | ||
|
|
072c67acad | ||
|
|
60bbe221de | ||
|
|
5f06dc214b | ||
|
|
a6607e585b | ||
|
|
20584f4507 | ||
|
|
9660f1f724 | ||
|
|
c8cbace800 | ||
|
|
a616a24923 | ||
|
|
12035dd589 | ||
|
|
9627b80b01 | ||
|
|
4e9cecc854 | ||
|
|
9d4b19b185 | ||
|
|
aee96d06aa | ||
|
|
23e3c585f7 | ||
|
|
c22a88079f | ||
|
|
2225402082 | ||
|
|
9197207431 | ||
|
|
47c7f7079c | ||
|
|
eb0c1dddfd | ||
|
|
e3dbfe6ff8 | ||
|
|
fac207f36b | ||
|
|
379e794848 | ||
|
|
9081a4b131 | ||
|
|
dc6d75b8ee | ||
|
|
bb297a4448 | ||
|
|
a93922c438 | ||
|
|
f7d21c80d7 | ||
|
|
9248d26fd4 | ||
|
|
b5ac54cd16 | ||
|
|
dc703e67f7 | ||
|
|
0930721865 | ||
|
|
644ff1772e | ||
|
|
3c7e0bebb6 | ||
|
|
0c0eea3876 | ||
|
|
5535140bb7 | ||
|
|
f9dd1448e5 | ||
|
|
ecf5d57ad2 | ||
|
|
8663888abc | ||
|
|
f452cd9a05 | ||
|
|
4fe9cd7fd6 | ||
|
|
9b0ca1c16b | ||
|
|
052ff59f57 | ||
|
|
40e5ef1c46 | ||
|
|
5025977d23 | ||
|
|
922006afe7 | ||
|
|
46cc7cb04d | ||
|
|
fa3e3bbb1b | ||
|
|
afbdcce337 | ||
|
|
2c1d11ed11 | ||
|
|
b88adf0479 | ||
|
|
b1066671f5 | ||
|
|
387e85d4ad | ||
|
|
77ab58d823 | ||
|
|
1a9e736d8b | ||
|
|
f680682f61 | ||
|
|
4d93d1244d | ||
|
|
6a7d5d2133 | ||
|
|
98397cd1da | ||
|
|
fc5a610394 | ||
|
|
504df5d998 | ||
|
|
3b4d3ebf50 | ||
|
|
aa39c1906e | ||
|
|
2e460e2ca2 | ||
|
|
a07ff7f442 | ||
|
|
5374569ea1 | ||
|
|
af9c1196bf | ||
|
|
def975c03f | ||
|
|
09d5543469 | ||
|
|
49e4dd0298 | ||
|
|
c8e408c50a | ||
|
|
e8a0467643 | ||
|
|
2dd0b66b83 | ||
|
|
68374017e1 | ||
|
|
120520f51d | ||
|
|
e8dea9773a | ||
|
|
7b31e6bcc4 | ||
|
|
c6ffca639f | ||
|
|
c491a1f7ca | ||
|
|
0b333b743d | ||
|
|
e67567e8dc | ||
|
|
23a42a29b3 | ||
|
|
95e79865e5 | ||
|
|
0e2860cd90 | ||
|
|
3259bf032c | ||
|
|
116205cdf1 | ||
|
|
43277d18dc | ||
|
|
86153419ee | ||
|
|
2b4d9c451c | ||
|
|
7f0e2fa9d8 | ||
|
|
e165095bd5 | ||
|
|
b8708d6e10 | ||
|
|
ef536390ca | ||
|
|
28befab173 | ||
|
|
c142439d5b | ||
|
|
1ca7335654 | ||
|
|
9197d9cdcd | ||
|
|
f75813e64d | ||
|
|
1f617c76a4 | ||
|
|
ebf573aa7a | ||
|
|
75363da470 | ||
|
|
cce4b932cc | ||
|
|
0973e1ced0 | ||
|
|
e7b5c84024 | ||
|
|
4001cc2a89 | ||
|
|
6e57d77d10 | ||
|
|
2206d96a6e | ||
|
|
33f05858f1 | ||
|
|
a4f204a5a3 | ||
|
|
31b6be2164 | ||
|
|
0dbf73067b | ||
|
|
775703e1f5 | ||
|
|
bcdfef4886 | ||
|
|
a19adb463b | ||
|
|
5004edbbb6 | ||
|
|
d8bdd6329a | ||
|
|
82d56637a0 | ||
|
|
7232a43816 | ||
|
|
098eb7d14b | ||
|
|
835b70ed48 | ||
|
|
9d828a86fb | ||
|
|
910551ee70 | ||
|
|
9beee548d4 | ||
|
|
bacc482bf0 | ||
|
|
edb3f906f8 | ||
|
|
4171bf341b | ||
|
|
6f3894f27b | ||
|
|
bbc9a5e62e | ||
|
|
94765da04a | ||
|
|
8caa82f123 | ||
|
|
8e1fcc6f14 | ||
|
|
131ef31492 | ||
|
|
b6b067b1d3 | ||
|
|
546f10eca7 | ||
|
|
fb4aaed220 | ||
|
|
c5e1b37ead | ||
|
|
2be9d303ea | ||
|
|
99ac6d213a | ||
|
|
6f4aae8b7d | ||
|
|
01e5e74e64 | ||
|
|
b6565a5dee | ||
|
|
61d53f3052 | ||
|
|
2e88d971f7 | ||
|
|
bfc1c66097 | ||
|
|
13d9f84d8d | ||
|
|
148eb130d9 | ||
|
|
eb07b0e03f | ||
|
|
1b8d416962 | ||
|
|
3030b544b5 | ||
|
|
b890d662f6 | ||
|
|
2a9bbc1d68 | ||
|
|
735817869a | ||
|
|
488e6dcf7a | ||
|
|
a0f32ea444 | ||
|
|
b426df7271 | ||
|
|
1543e06a06 | ||
|
|
d7b4ccb1e5 | ||
|
|
dedd449329 | ||
|
|
38c589658f | ||
|
|
182e06205d | ||
|
|
4c391645fe | ||
|
|
79bf50004a | ||
|
|
2f961bd7bf | ||
|
|
b72244a986 | ||
|
|
6710f25190 | ||
|
|
4089e5d7a9 | ||
|
|
0a49b5b17b | ||
|
|
34c40de429 | ||
|
|
6d02144401 | ||
|
|
561687ce0f | ||
|
|
20973c6724 | ||
|
|
bf10a4dcef | ||
|
|
565987a780 | ||
|
|
4f9a6c8e98 | ||
|
|
3a3e92d441 | ||
|
|
bc0dc809f9 | ||
|
|
92310847aa | ||
|
|
5bdc59830c | ||
|
|
17f524d3da | ||
|
|
4d0de2bb45 | ||
|
|
b3b8f56bb8 | ||
|
|
f036b83693 | ||
|
|
73fb31c2fc | ||
|
|
381787f39d | ||
|
|
2cb942a24b | ||
|
|
c79cb5731e | ||
|
|
4760bb15a4 | ||
|
|
aac881f23c | ||
|
|
da19c51566 | ||
|
|
396ab13164 | ||
|
|
37dd354155 | ||
|
|
acb1ebda19 | ||
|
|
5dddc05626 | ||
|
|
99890671bd | ||
|
|
9451ac5f46 | ||
|
|
a8e4e21ba1 | ||
|
|
f555ba3703 | ||
|
|
37677b3730 | ||
|
|
2a298b2268 | ||
|
|
ad3f94fb80 | ||
|
|
719660798e | ||
|
|
8d973a09e1 | ||
|
|
3579a86cde | ||
|
|
ba96a6a205 | ||
|
|
f07d2a9a9a | ||
|
|
2469067fd4 | ||
|
|
c10c91d86a | ||
|
|
d5fd2e9a07 | ||
|
|
45cc0ba579 | ||
|
|
1880a0a24e | ||
|
|
5f3a0b96cc | ||
|
|
7ab1610700 | ||
|
|
daad9f6c00 | ||
|
|
2b234b740e | ||
|
|
39e3983020 | ||
|
|
9d58cdb21c | ||
|
|
f05e35e792 | ||
|
|
a333e68620 | ||
|
|
2c2791ec69 | ||
|
|
635b09d82f | ||
|
|
46c3ff9db4 | ||
|
|
8bfc95c23a | ||
|
|
99d05b6ef7 | ||
|
|
1c0a14c819 | ||
|
|
fe5cd58801 | ||
|
|
c3bd007f5a | ||
|
|
dba24e104e | ||
|
|
35815e371b | ||
|
|
d0f8ae0565 | ||
|
|
b2e21969ca | ||
|
|
ea57c233a3 | ||
|
|
0d39b47f22 | ||
|
|
9f3a279b03 |
No files matched your search
+23
-32
@@ -1,46 +1,37 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
## [1.8.3 (MONTH xth, 2026)](#1-8-3)
|
## [1.9.0 (MONTH xth, 2026)](#1-9-0)
|
||||||
|
|
||||||
### Additions
|
### Additions
|
||||||
|
- Trainer bags and packs got added
|
||||||
### Pokémon Added
|
- You can craft and equip those to store additional items
|
||||||
#### Generation 4
|
|
||||||
|
|
||||||
#### Generation 5
|
|
||||||
|
|
||||||
#### Generation 6
|
|
||||||
|
|
||||||
#### Generation 7
|
|
||||||
|
|
||||||
#### Generation 8
|
|
||||||
|
|
||||||
#### Generation 9
|
|
||||||
|
|
||||||
### Model updates for the following Pokémon
|
|
||||||
|
|
||||||
### Animation updates for the following Pokémon
|
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
- Trading has been overhauled to allow offering multiple Pokémon, up to the entire party, in a single trade
|
||||||
|
- Selected Pokémon are now highlighted in both parties with new party slot assets
|
||||||
|
- Hovering an offered Pokémon now shows its summary, and clicking the active Pokémon no longer exits the summary view
|
||||||
|
- The trade animation now moves the offered Pokémon towards the Poké Ball
|
||||||
|
- Parties are compacted after a trade so no empty slots are left between Pokémon
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
- Fixed datapacks with item interaction evolutions that don't specify an item crashing the world on load.
|
|
||||||
- Fixed the Pokédex evolution tree crashing when a datapack's dex entry is missing an evolution's form.
|
|
||||||
- Fixed the Pokédex evolution tree crashing with a stack overflow on evolutions that loop back on themselves.
|
|
||||||
- Fixed the Pokédex evolution tree crashing when looking at a dex that is not part of the "National Dex" aggregate.
|
|
||||||
- Fixed evolution trees not building properly when a pokemon has several pokedex entries for different regions.
|
|
||||||
- Fixed form-changing evolutions sometimes resolving to the source form in the Pokédex evolution tree.
|
|
||||||
- Broken datapack evolutions are now logged and skipped in the Pokédex evolution tree instead of crashing.
|
|
||||||
- Fixed friendship booster items not being recognised as such
|
|
||||||
- Fixed conflicts with other mods that would make use of recipe books in certain ways (Farmer's Delight Cooking Pot)
|
|
||||||
- Fixed Pokémon battles stalling when a sidemod cancels the `THROWN_POKEBALL_HIT` hit event
|
|
||||||
- Fixed choice feature tab completion in `spawnpokemon/pokegive/pokeedit` commands
|
|
||||||
|
|
||||||
### Developer
|
### Developer
|
||||||
- Bumped NeoForge to `21.1.195` to get access to MixinExtras `0.5` and the expressions annotation
|
- Trade network packets (`TradeUpdatedPacket`, `UpdateTradeOfferPacket`, and `TradeCompletedPacket`) now receive an array of Pokémon instead of a single Pokémon to execute trades
|
||||||
|
- `TradeEvent.Pre` and `TradeEvent.Post` now expose every Pokémon each participant receives (`tradeParticipant1Pokemon` and `tradeParticipant2Pokemon` are now lists), and their Molang context includes `trade_participant_1_pokemon_list` and `trade_participant_2_pokemon_list`
|
||||||
|
|
||||||
### Molang & Datapacks
|
### Molang & Datapacks
|
||||||
- Fixed `q.pokemon.nature` returning class instance instead of proper string value (`cobblemon:adamant`)
|
- `bag_categories` got added which control what kind of tabs and capabilities the Trainerbags have
|
||||||
- Fixed `q.entity.is_looking_at` result being always `1` for whatever entity passed as target
|
```json
|
||||||
|
{
|
||||||
|
"order": 1,
|
||||||
|
"icon": "cobblemon:textures/item/medicine/potion.png",
|
||||||
|
"whiteListTag": "cobblemon:bag/whitelist_consumables",
|
||||||
|
"blackListTag": "cobblemon:bag/blacklist_consumables",
|
||||||
|
"maxCount": 512
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- Bunch of default tags as white/blacklist got added to control what can be inserted the corresponding bag categories
|
||||||
|
|
||||||
|
### Particles
|
||||||
|
|
||||||
### Localization
|
### Localization
|
||||||
- Updated translations for:
|
- Updated translations for:
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
# Changelog
|
||||||
|
## [1.8.3 (October 25th, 2026)](#1-8-3)
|
||||||
|
|
||||||
|
### Additions
|
||||||
|
- Added compatability with AppleSkin.
|
||||||
|
|
||||||
|
### New Rideable Pokémon
|
||||||
|
- Vikavolt
|
||||||
|
- Fearow
|
||||||
|
|
||||||
|
### Particles
|
||||||
|
## New Move Animations
|
||||||
|
- Water Shuriken
|
||||||
|
|
||||||
|
### Cries added/updated for the following Pokémon
|
||||||
|
- Hoppip
|
||||||
|
- Skiploom
|
||||||
|
- Jumpluff
|
||||||
|
- Houndour
|
||||||
|
- Houndoom
|
||||||
|
- Wurmple
|
||||||
|
- Silcoon
|
||||||
|
- Beautifly
|
||||||
|
- Cascoon
|
||||||
|
- Dustox
|
||||||
|
- Surskit
|
||||||
|
- Masquerain
|
||||||
|
- Torkoal
|
||||||
|
- Starly
|
||||||
|
- Staravia
|
||||||
|
- Staraptor
|
||||||
|
- Combee
|
||||||
|
- Vespiquen
|
||||||
|
- Dusknoir
|
||||||
|
- Helioptile
|
||||||
|
- Heliolisk
|
||||||
|
- Grubbin
|
||||||
|
- Charjabug
|
||||||
|
- Vikavolt
|
||||||
|
- Applin (updated)
|
||||||
|
- Flapple (updated)
|
||||||
|
- Appletun
|
||||||
|
- Runerigus
|
||||||
|
- Dipplin
|
||||||
|
|
||||||
|
### Animation updates for the following Pokémon
|
||||||
|
- Vikavolt
|
||||||
|
- Magby
|
||||||
|
- Magmar
|
||||||
|
- Ninetales (+ Alolan)
|
||||||
|
- Spearow
|
||||||
|
- Fearow
|
||||||
|
- Squawkabilly
|
||||||
|
- Mudkip
|
||||||
|
- Marshtomp
|
||||||
|
- Swampert
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
- Changed the Misc icon in the Campfire Pot Recipe Book to Health Candy.
|
||||||
|
- Moved EXP Candies from the Medicine recipe book category to the Misc category.
|
||||||
|
- Removed Dynamic Lights data from the Magmarizer item for consistency with the block.
|
||||||
|
- Added `doPokemonPredation` game rule, which controls aggressiveness of Pokémon with the `hate_entity` brain task defined.
|
||||||
|
- Added `predation_chance` server config value, which controls the possibility of attacking the hated entity found in `hate_entity` brain tasks.
|
||||||
|
- Prehistoric Eroded Pillar generates slightly more frequently.
|
||||||
|
- Togekiss was changed from a jet-style mount to bird-style.
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- Fixed datapacks with item interaction evolutions that don't specify an item crashing the world on load.
|
||||||
|
- Fixed the Pokédex evolution tree crashing when a datapack's dex entry is missing an evolution's form.
|
||||||
|
- Fixed the Pokédex evolution tree crashing with a stack overflow on evolutions that loop back on themselves.
|
||||||
|
- Fixed the Pokédex evolution tree crashing when looking at a dex that is not part of the "National Dex" aggregate.
|
||||||
|
- Fixed some display names in the Pokédex evolution tree having unintended font colours.
|
||||||
|
- Fixed evolution trees not building properly when a Pokémon has several Pokédex entries for different regions.
|
||||||
|
- Fixed form-changing evolutions sometimes resolving to the source form in the Pokédex evolution tree.
|
||||||
|
- Broken datapack evolutions are now logged and skipped in the Pokédex evolution tree instead of crashing.
|
||||||
|
- Fixed the `alpha` property having no tab completion in commands such as `/pokespawn`, `/pokegive` and `/pokeedit`, and added the missing `dmax_level`, `gmax_factor` and `tradable` aliases to tab completion.
|
||||||
|
- Fixed friendship booster items not being recognised as such.
|
||||||
|
- Fixed conflicts with other mods that would make use of recipe books in certain ways (Farmer's Delight Cooking Pot).
|
||||||
|
- Fixed Pokémon battles stalling when a sidemod cancels the `THROWN_POKEBALL_HIT` hit event.
|
||||||
|
- Fixed choice feature tab completion in `spawnpokemon/pokegive/pokeedit` commands.
|
||||||
|
- Fixed MoLang that's targeting players intermittedly failing when they have died, requiring them to relog.
|
||||||
|
- Fixed a NeoForge bug where none of the Cobblemon plants/berries could be placed into pots.
|
||||||
|
- Fixed party overlay not hiding when the player opens the Pokédex scanner.
|
||||||
|
- Fixed `hate_entity` task focusing on its own entity, therefore enabling deadly warfare between Zangoose and Seviper.
|
||||||
|
- Prehistoric Frozen Pond, Prehistoric Frozen Spike, and Prehistoric Lush Den now actually generate (oops).
|
||||||
|
- Fixed Frogadier floating in its `battle_idle` animation.
|
||||||
|
- Fixed absence or incorrect mergers in spawning conditions, causing the max height/depth of conditions to use the min value instead.
|
||||||
|
- Added stricter riding checks on server side to prevent possible packet forgery when a player tries to ride Pokémon.
|
||||||
|
- Fixed Pokémon cries and animation sounds played from GUIs, such as the starter selection screen and the Pokédex, being tied to the Master volume slider instead of Friendly Creatures.
|
||||||
|
- Fixed Archeops T-posing during its `air_cry` animation.
|
||||||
|
|
||||||
|
### Developer
|
||||||
|
- Bumped NeoForge to `21.1.195` to get access to MixinExtras `0.5` and the expressions annotation.
|
||||||
|
- New Platform Event `PLAYER_RESPAWN` which is fired when a player respawns (either through death or returning from the end).
|
||||||
|
- Platform Events `SERVER_PLAYER_TICK_PRE` and `SERVER_PLAYER_TICK_POST` no longer fire when the player is dead.
|
||||||
|
- It is now tied much closer to the actual entity rather than the player or their connection.
|
||||||
|
|
||||||
|
### Molang & Datapacks
|
||||||
|
- Fixed `q.pokemon.nature` returning class instance instead of proper string value (`cobblemon:adamant`).
|
||||||
|
- Fixed `q.entity.is_looking_at` result being always `1` for whatever entity passed as the target parameter.
|
||||||
|
- Added hate chance optional parameter to `hate_entity` task. `1.0` will make an entity always attack the target.
|
||||||
|
|
||||||
|
### Localization
|
||||||
|
- Updated translations for:
|
||||||
|
- Russian
|
||||||
|
- Japanese
|
||||||
|
- Brazilian Portuguese
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# Changelog
|
||||||
|
## [1.8.4 (October 27th, 2026)](#1-8-4)
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
- The Froakie line now blinks. The world will never be the same.
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- Fixed heaps of spawns not working. This was caused by us missing something before release. RIP.
|
||||||
|
- Fixed a crash caused by Fearow blinking while you're riding one. Makes sense to me.
|
||||||
|
- Fixed Minior's "Shields Down" ability being very broken.
|
||||||
|
- Fixed Dusclops using Squirtle's cry sound (lol).
|
||||||
|
- Fixed blank Cooking Pot recipe book entries and missing tabs on Fabric.
|
||||||
|
- Fixed a hitbox issue with placeable Orb held items attached to a ceiling.
|
||||||
|
- Fixed something sneaky. I'll tell you about it later.
|
||||||
|
|
||||||
|
### Molang & Datapacks
|
||||||
|
- Added `q.target_fainted` function to move action effects that checks if any opponents fainted from the move.
|
||||||
|
|
||||||
|
### Particles
|
||||||
|
- Updated Water Shuriken effect to be timed better when the opponent faints.
|
||||||
|
|
||||||
|
### Localization
|
||||||
|
- Updated translations for:
|
||||||
|
- Korean
|
||||||
|
- Simplified Chinese
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* 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.bag;
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.item.bag.CobblemonBagContainer;
|
||||||
|
|
||||||
|
public interface BagEntity {
|
||||||
|
CobblemonBagContainer cobblemon$getBagContainer();
|
||||||
|
void cobblemon$setBagContainer(CobblemonBagContainer bagContainer);
|
||||||
|
}
|
||||||
@@ -23,6 +23,8 @@ import com.cobblemon.mod.common.api.tags.CobblemonItemTags;
|
|||||||
import com.cobblemon.mod.common.duck.PlayerDuck;
|
import com.cobblemon.mod.common.duck.PlayerDuck;
|
||||||
import com.cobblemon.mod.common.duck.RidePassenger;
|
import com.cobblemon.mod.common.duck.RidePassenger;
|
||||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||||
|
import com.cobblemon.mod.common.bag.BagEntity;
|
||||||
|
import com.cobblemon.mod.common.item.bag.CobblemonBagContainer;
|
||||||
import com.cobblemon.mod.common.pokedex.scanner.PokedexEntityData;
|
import com.cobblemon.mod.common.pokedex.scanner.PokedexEntityData;
|
||||||
import com.cobblemon.mod.common.pokedex.scanner.ScannableEntity;
|
import com.cobblemon.mod.common.pokedex.scanner.ScannableEntity;
|
||||||
import com.cobblemon.mod.common.pokemon.FormData;
|
import com.cobblemon.mod.common.pokemon.FormData;
|
||||||
@@ -56,6 +58,7 @@ import net.minecraft.world.item.ItemStack;
|
|||||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
@@ -73,7 +76,7 @@ import java.util.*;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Mixin(Player.class)
|
@Mixin(Player.class)
|
||||||
public abstract class PlayerMixin extends LivingEntity implements ScannableEntity, OrientationControllable, PlayerDuck, RidePassenger {
|
public abstract class PlayerMixin extends LivingEntity implements ScannableEntity, OrientationControllable, PlayerDuck, RidePassenger, BagEntity {
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private Vector3f cobblemon$driverInput;
|
private Vector3f cobblemon$driverInput;
|
||||||
@@ -107,6 +110,8 @@ public abstract class PlayerMixin extends LivingEntity implements ScannableEntit
|
|||||||
|
|
||||||
@Unique private Vec3 cobblemon$rideEyePos = Vec3.ZERO;
|
@Unique private Vec3 cobblemon$rideEyePos = Vec3.ZERO;
|
||||||
|
|
||||||
|
@Unique private CobblemonBagContainer cobblemon$cobblemonBagContainer = new CobblemonBagContainer();
|
||||||
|
|
||||||
protected PlayerMixin(EntityType<? extends LivingEntity> p_20966_, Level p_20967_) {
|
protected PlayerMixin(EntityType<? extends LivingEntity> p_20966_, Level p_20967_) {
|
||||||
super(p_20966_, p_20967_);
|
super(p_20966_, p_20967_);
|
||||||
}
|
}
|
||||||
@@ -404,4 +409,37 @@ public abstract class PlayerMixin extends LivingEntity implements ScannableEntit
|
|||||||
original.call(target, strength, x, z);
|
original.call(target, strength, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override @NotNull
|
||||||
|
public CobblemonBagContainer cobblemon$getBagContainer() { return cobblemon$cobblemonBagContainer; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cobblemon$setBagContainer(CobblemonBagContainer bagContainer) { cobblemon$cobblemonBagContainer = bagContainer; }
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "readAdditionalSaveData(Lnet/minecraft/nbt/CompoundTag;)V",
|
||||||
|
at = @At("TAIL")
|
||||||
|
)
|
||||||
|
private void cobblemon$readAdditionalSaveData(CompoundTag compound, CallbackInfo ci) {
|
||||||
|
if (compound.contains("CobblemonBagData", 9)) {
|
||||||
|
this.cobblemon$cobblemonBagContainer.fromTag(compound.getList("CobblemonBagData", 10), this.registryAccess());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "addAdditionalSaveData(Lnet/minecraft/nbt/CompoundTag;)V",
|
||||||
|
at = @At("TAIL")
|
||||||
|
)
|
||||||
|
private void cobblemon$addAdditionalSaveData(CompoundTag compound, CallbackInfo ci) {
|
||||||
|
compound.put("CobblemonBagData", this.cobblemon$cobblemonBagContainer.createTag(this.registryAccess()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "dropEquipment()V",
|
||||||
|
at = @At("TAIL")
|
||||||
|
)
|
||||||
|
private void cobblemon$dropCobblemonBag(CallbackInfo ci) {
|
||||||
|
if (level().getGameRules().getBoolean(CobblemonGameRules.BAG_DROP_ITEMS)) {
|
||||||
|
this.cobblemon$cobblemonBagContainer.dropAll((Player)(Object)this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -15,17 +15,23 @@ import com.cobblemon.mod.common.api.riding.RidingStyle;
|
|||||||
import com.cobblemon.mod.common.api.spawning.spawner.PlayerSpawner;
|
import com.cobblemon.mod.common.api.spawning.spawner.PlayerSpawner;
|
||||||
import com.cobblemon.mod.common.api.spawning.spawner.PlayerSpawnerFactory;
|
import com.cobblemon.mod.common.api.spawning.spawner.PlayerSpawnerFactory;
|
||||||
import com.cobblemon.mod.common.api.stats.CobblemonStats;
|
import com.cobblemon.mod.common.api.stats.CobblemonStats;
|
||||||
|
import com.cobblemon.mod.common.block.HealingMachineBlock;
|
||||||
import com.cobblemon.mod.common.duck.ServerLevelDuck;
|
import com.cobblemon.mod.common.duck.ServerLevelDuck;
|
||||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||||
|
import com.cobblemon.mod.common.bag.BagEntity;
|
||||||
import com.cobblemon.mod.common.world.gamerules.CobblemonGameRules;
|
import com.cobblemon.mod.common.world.gamerules.CobblemonGameRules;
|
||||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||||
import com.llamalad7.mixinextras.sugar.Local;
|
import com.llamalad7.mixinextras.sugar.Local;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -33,6 +39,9 @@ import org.spongepowered.asm.mixin.Unique;
|
|||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Mixin(ServerPlayer.class)
|
@Mixin(ServerPlayer.class)
|
||||||
public abstract class ServerPlayerMixin implements PlayerSpawnerAccessor {
|
public abstract class ServerPlayerMixin implements PlayerSpawnerAccessor {
|
||||||
@@ -142,4 +151,25 @@ public abstract class ServerPlayerMixin implements PlayerSpawnerAccessor {
|
|||||||
((ServerLevelDuck) this.serverLevel()).cobblemon$getLevelResourceLocation()
|
((ServerLevelDuck) this.serverLevel()).cobblemon$getLevelResourceLocation()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "findRespawnAndUseSpawnBlock(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;FZZ)Ljava/util/Optional;",
|
||||||
|
at = @At(value = "HEAD"),
|
||||||
|
cancellable = true
|
||||||
|
)
|
||||||
|
private static void cobblemon$useHealthStationAsRespawn(ServerLevel level, BlockPos pos, float angle, boolean forced, boolean keepInventory, CallbackInfoReturnable<Optional<ServerPlayer.RespawnPosAngle>> cir) {
|
||||||
|
BlockState state = level.getBlockState(pos);
|
||||||
|
Block block = state.getBlock();
|
||||||
|
if (block instanceof HealingMachineBlock && HealingMachineBlock.Companion.canSetSpawn(level)) {
|
||||||
|
cir.setReturnValue(HealingMachineBlock.Companion.findStandUpPosition(EntityType.PLAYER, level, pos).map((vec3) -> ServerPlayer.RespawnPosAngle.of(vec3, pos)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "restoreFrom",
|
||||||
|
at = @At("TAIL")
|
||||||
|
)
|
||||||
|
private void cobblemon$restoreCobblemonBag(ServerPlayer that, boolean keepEverything, CallbackInfo ci) {
|
||||||
|
((BagEntity)(Object)this).cobblemon$setBagContainer(((BagEntity)that).cobblemon$getBagContainer());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -69,7 +69,7 @@ public abstract class ClientRecipeBookMixin {
|
|||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lcom/google/common/collect/ImmutableMap;copyOf(Ljava/util/Map;)Lcom/google/common/collect/ImmutableMap;"
|
target = "Lcom/google/common/collect/ImmutableMap;copyOf(Ljava/util/Map;)Lcom/google/common/collect/ImmutableMap;"
|
||||||
))
|
))
|
||||||
private void addCustomAggregateCategories(Iterable<RecipeHolder<?>> recipes, RegistryAccess registryAccess, CallbackInfo ci, @Local(name = "map2") Map<RecipeBookCategories, List<RecipeCollection>> map2) {
|
private void addCustomAggregateCategories(Iterable<RecipeHolder<?>> recipes, RegistryAccess registryAccess, CallbackInfo ci, @Local(ordinal = 1) Map<RecipeBookCategories, List<RecipeCollection>> map2) {
|
||||||
CobblemonRecipeCategories.Companion.getCustomAggregateCategories().forEach((recipeBookCategories, list) -> map2.put(recipeBookCategories, (List) list.stream().flatMap((recipeBookCategoriesx) -> ((List) map2.getOrDefault(recipeBookCategoriesx, ImmutableList.of())).stream()).collect(ImmutableList.toImmutableList())));
|
CobblemonRecipeCategories.Companion.getCustomAggregateCategories().forEach((recipeBookCategories, list) -> map2.put(recipeBookCategories, (List) list.stream().flatMap((recipeBookCategoriesx) -> ((List) map2.getOrDefault(recipeBookCategoriesx, ImmutableList.of())).stream()).collect(ImmutableList.toImmutableList())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -20,14 +20,14 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||||||
|
|
||||||
@Mixin(RecipeBookComponent.class)
|
@Mixin(RecipeBookComponent.class)
|
||||||
public class RecipeBookComponentMixin {
|
public class RecipeBookComponentMixin {
|
||||||
@Definition(id = "recipeBookCategories", local = @Local(name = "recipeBookCategories"))
|
@Definition(id = "recipeBookCategories", local = @Local(type = RecipeBookCategories.class))
|
||||||
@Definition(id = "FURNACE_SEARCH", field = "Lnet/minecraft/client/RecipeBookCategories;FURNACE_SEARCH:Lnet/minecraft/client/RecipeBookCategories;")
|
@Definition(id = "FURNACE_SEARCH", field = "Lnet/minecraft/client/RecipeBookCategories;FURNACE_SEARCH:Lnet/minecraft/client/RecipeBookCategories;")
|
||||||
@Expression("recipeBookCategories != FURNACE_SEARCH")
|
@Expression("recipeBookCategories != FURNACE_SEARCH")
|
||||||
@ModifyExpressionValue(
|
@ModifyExpressionValue(
|
||||||
method = "updateTabs",
|
method = "updateTabs",
|
||||||
at = @At(value = "MIXINEXTRAS:EXPRESSION")
|
at = @At(value = "MIXINEXTRAS:EXPRESSION")
|
||||||
)
|
)
|
||||||
private boolean notCookingPotSearch(boolean original, @Local(name = "recipeBookCategories") RecipeBookCategories recipeBookCategories) {
|
private boolean notCookingPotSearch(boolean original, @Local RecipeBookCategories recipeBookCategories) {
|
||||||
return original && recipeBookCategories != CobblemonRecipeCategories.COOKING_POT_SEARCH.toVanillaCategory();
|
return original && recipeBookCategories != CobblemonRecipeCategories.COOKING_POT_SEARCH.toVanillaCategory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,6 +260,9 @@ object Cobblemon {
|
|||||||
RequestManager.onLogoff(it.player)
|
RequestManager.onLogoff(it.player)
|
||||||
serverPlayerStructs.remove(it.player.uuid)
|
serverPlayerStructs.remove(it.player.uuid)
|
||||||
}
|
}
|
||||||
|
PlatformEvents.PLAYER_RESPAWN.subscribe {
|
||||||
|
serverPlayerStructs.remove(it.player.uuid)
|
||||||
|
}
|
||||||
PlatformEvents.PLAYER_DEATH.subscribe {
|
PlatformEvents.PLAYER_DEATH.subscribe {
|
||||||
PCLinkManager.removeLink(it.player.uuid)
|
PCLinkManager.removeLink(it.player.uuid)
|
||||||
battleRegistry.getBattleByParticipatingPlayer(it.player)?.stop()
|
battleRegistry.getBattleByParticipatingPlayer(it.player)?.stop()
|
||||||
|
|||||||
@@ -845,54 +845,35 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
|||||||
@JvmField
|
@JvmField
|
||||||
val PEP_UP_FLOWER = this.create("pep_up_flower", FlowerBlock(MobEffects.LEVITATION, 10F, BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).noCollission().instabreak().sound(SoundType.GRASS).offsetType(BlockBehaviour.OffsetType.XZ).pushReaction(PushReaction.DESTROY)))
|
val PEP_UP_FLOWER = this.create("pep_up_flower", FlowerBlock(MobEffects.LEVITATION, 10F, BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).noCollission().instabreak().sound(SoundType.GRASS).offsetType(BlockBehaviour.OffsetType.XZ).pushReaction(PushReaction.DESTROY)))
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_PEP_UP_FLOWER = this.create("potted_pep_up_flower", BlocksInvoker.createFlowerPotBlock(PEP_UP_FLOWER))
|
|
||||||
@JvmField
|
|
||||||
val HEARTY_GRAINS = this.create("hearty_grains", HeartyGrainsBlock(BlockBehaviour.Properties.of().pushReaction(PushReaction.DESTROY).ignitedByLava().mapColor(MapColor.PLANT).noCollission().randomTicks().instabreak()))
|
val HEARTY_GRAINS = this.create("hearty_grains", HeartyGrainsBlock(BlockBehaviour.Properties.of().pushReaction(PushReaction.DESTROY).ignitedByLava().mapColor(MapColor.PLANT).noCollission().randomTicks().instabreak()))
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val GALARICA_NUT_BUSH = this.create("galarica_nut_bush", NutBushBlock(BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).randomTicks().noCollission().sound(SoundType.SWEET_BERRY_BUSH).pushReaction(PushReaction.DESTROY)))
|
val GALARICA_NUT_BUSH = this.create("galarica_nut_bush", NutBushBlock(BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).randomTicks().noCollission().sound(SoundType.SWEET_BERRY_BUSH).pushReaction(PushReaction.DESTROY)))
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val POTTED_RED_APRICORN_SAPLING = this.create("potted_red_apricorn_sapling", BlocksInvoker.createFlowerPotBlock(RED_APRICORN_SAPLING))
|
|
||||||
@JvmField
|
|
||||||
val POTTED_YELLOW_APRICORN_SAPLING = this.create("potted_yellow_apricorn_sapling", BlocksInvoker.createFlowerPotBlock(YELLOW_APRICORN_SAPLING))
|
|
||||||
@JvmField
|
|
||||||
val POTTED_GREEN_APRICORN_SAPLING = this.create("potted_green_apricorn_sapling", BlocksInvoker.createFlowerPotBlock(GREEN_APRICORN_SAPLING))
|
|
||||||
@JvmField
|
|
||||||
val POTTED_BLUE_APRICORN_SAPLING = this.create("potted_blue_apricorn_sapling", BlocksInvoker.createFlowerPotBlock(BLUE_APRICORN_SAPLING))
|
|
||||||
@JvmField
|
|
||||||
val POTTED_PINK_APRICORN_SAPLING = this.create("potted_pink_apricorn_sapling", BlocksInvoker.createFlowerPotBlock(PINK_APRICORN_SAPLING))
|
|
||||||
@JvmField
|
|
||||||
val POTTED_BLACK_APRICORN_SAPLING = this.create("potted_black_apricorn_sapling", BlocksInvoker.createFlowerPotBlock(BLACK_APRICORN_SAPLING))
|
|
||||||
@JvmField
|
|
||||||
val POTTED_WHITE_APRICORN_SAPLING = this.create("potted_white_apricorn_sapling", BlocksInvoker.createFlowerPotBlock(WHITE_APRICORN_SAPLING))
|
|
||||||
@JvmField
|
|
||||||
val POTTED_SACCHARINE_SAPLING = this.create("potted_saccharine_sapling", BlocksInvoker.createFlowerPotBlock(SACCHARINE_SAPLING))
|
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val RED_MINT_LEAF_LITTER = this.mintLitter("red_mint_leaf_litter", MapColor.COLOR_RED)
|
val RED_MINT_LEAF_LITTER = this.mintLitter("red_mint_leaf_litter", MapColor.COLOR_RED)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_RED_MINT = this.pottedPlant("potted_red_mint", RED_MINT_LEAF_LITTER)
|
val POTTED_RED_MINT = this.flowerPot("potted_red_mint", RED_MINT_LEAF_LITTER)
|
||||||
@JvmField
|
@JvmField
|
||||||
val BLUE_MINT_LEAF_LITTER = this.mintLitter("blue_mint_leaf_litter", MapColor.COLOR_BLUE)
|
val BLUE_MINT_LEAF_LITTER = this.mintLitter("blue_mint_leaf_litter", MapColor.COLOR_BLUE)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_BLUE_MINT = this.pottedPlant("potted_blue_mint", BLUE_MINT_LEAF_LITTER)
|
val POTTED_BLUE_MINT = this.flowerPot("potted_blue_mint", BLUE_MINT_LEAF_LITTER)
|
||||||
@JvmField
|
@JvmField
|
||||||
val CYAN_MINT_LEAF_LITTER = this.mintLitter("cyan_mint_leaf_litter", MapColor.COLOR_CYAN)
|
val CYAN_MINT_LEAF_LITTER = this.mintLitter("cyan_mint_leaf_litter", MapColor.COLOR_CYAN)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_CYAN_MINT = this.pottedPlant("potted_cyan_mint", CYAN_MINT_LEAF_LITTER)
|
val POTTED_CYAN_MINT = this.flowerPot("potted_cyan_mint", CYAN_MINT_LEAF_LITTER)
|
||||||
@JvmField
|
@JvmField
|
||||||
val PINK_MINT_LEAF_LITTER = this.mintLitter("pink_mint_leaf_litter", MapColor.COLOR_PINK)
|
val PINK_MINT_LEAF_LITTER = this.mintLitter("pink_mint_leaf_litter", MapColor.COLOR_PINK)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_PINK_MINT = this.pottedPlant("potted_pink_mint", PINK_MINT_LEAF_LITTER)
|
val POTTED_PINK_MINT = this.flowerPot("potted_pink_mint", PINK_MINT_LEAF_LITTER)
|
||||||
@JvmField
|
@JvmField
|
||||||
val GREEN_MINT_LEAF_LITTER = this.mintLitter("green_mint_leaf_litter", MapColor.COLOR_GREEN)
|
val GREEN_MINT_LEAF_LITTER = this.mintLitter("green_mint_leaf_litter", MapColor.COLOR_GREEN)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_GREEN_MINT = this.pottedPlant("potted_green_mint", GREEN_MINT_LEAF_LITTER)
|
val POTTED_GREEN_MINT = this.flowerPot("potted_green_mint", GREEN_MINT_LEAF_LITTER)
|
||||||
@JvmField
|
@JvmField
|
||||||
val WHITE_MINT_LEAF_LITTER = this.mintLitter("white_mint_leaf_litter", MapColor.SNOW)
|
val WHITE_MINT_LEAF_LITTER = this.mintLitter("white_mint_leaf_litter", MapColor.SNOW)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_WHITE_MINT = this.pottedPlant("potted_white_mint", WHITE_MINT_LEAF_LITTER)
|
val POTTED_WHITE_MINT = this.flowerPot("potted_white_mint", WHITE_MINT_LEAF_LITTER)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val LOBAILA = this.create("lobaila", LobailaFlowerBlock(BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).noCollission().instabreak().sound(SoundType.GRASS).offsetType(BlockBehaviour.OffsetType.XZ).ignitedByLava().pushReaction(PushReaction.DESTROY)))
|
val LOBAILA = this.create("lobaila", LobailaFlowerBlock(BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).noCollission().instabreak().sound(SoundType.GRASS).offsetType(BlockBehaviour.OffsetType.XZ).ignitedByLava().pushReaction(PushReaction.DESTROY)))
|
||||||
@@ -1104,145 +1085,163 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
|||||||
//val BINDING_SOIL = this.create("binding_soil", BindingSoilBlock(BlockBehaviour.Properties.of()))
|
//val BINDING_SOIL = this.create("binding_soil", BindingSoilBlock(BlockBehaviour.Properties.of()))
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_AGUAV_BERRY = this.create("potted_aguav_berry", BlocksInvoker.createFlowerPotBlock(AGUAV_BERRY))
|
val POTTED_AGUAV_BERRY = this.flowerPot("potted_aguav_berry", AGUAV_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_APICOT_BERRY = this.create("potted_apicot_berry", BlocksInvoker.createFlowerPotBlock(APICOT_BERRY))
|
val POTTED_APICOT_BERRY = this.flowerPot("potted_apicot_berry", APICOT_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_ASPEAR_BERRY = this.create("potted_aspear_berry", BlocksInvoker.createFlowerPotBlock(ASPEAR_BERRY))
|
val POTTED_ASPEAR_BERRY = this.flowerPot("potted_aspear_berry", ASPEAR_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_BABIRI_BERRY = this.create("potted_babiri_berry", BlocksInvoker.createFlowerPotBlock(BABIRI_BERRY))
|
val POTTED_BABIRI_BERRY = this.flowerPot("potted_babiri_berry", BABIRI_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_BELUE_BERRY = this.create("potted_belue_berry", BlocksInvoker.createFlowerPotBlock(BELUE_BERRY))
|
val POTTED_BELUE_BERRY = this.flowerPot("potted_belue_berry", BELUE_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_BLUK_BERRY = this.create("potted_bluk_berry", BlocksInvoker.createFlowerPotBlock(BLUK_BERRY))
|
val POTTED_BLUK_BERRY = this.flowerPot("potted_bluk_berry", BLUK_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_CHARTI_BERRY = this.create("potted_charti_berry", BlocksInvoker.createFlowerPotBlock(CHARTI_BERRY))
|
val POTTED_CHARTI_BERRY = this.flowerPot("potted_charti_berry", CHARTI_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_CHERI_BERRY = this.create("potted_cheri_berry", BlocksInvoker.createFlowerPotBlock(CHERI_BERRY))
|
val POTTED_CHERI_BERRY = this.flowerPot("potted_cheri_berry", CHERI_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_CHESTO_BERRY = this.create("potted_chesto_berry", BlocksInvoker.createFlowerPotBlock(CHESTO_BERRY))
|
val POTTED_CHESTO_BERRY = this.flowerPot("potted_chesto_berry", CHESTO_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_CHILAN_BERRY = this.create("potted_chilan_berry", BlocksInvoker.createFlowerPotBlock(CHILAN_BERRY))
|
val POTTED_CHILAN_BERRY = this.flowerPot("potted_chilan_berry", CHILAN_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_CHOPLE_BERRY = this.create("potted_chople_berry", BlocksInvoker.createFlowerPotBlock(CHOPLE_BERRY))
|
val POTTED_CHOPLE_BERRY = this.flowerPot("potted_chople_berry", CHOPLE_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_COBA_BERRY = this.create("potted_coba_berry", BlocksInvoker.createFlowerPotBlock(COBA_BERRY))
|
val POTTED_COBA_BERRY = this.flowerPot("potted_coba_berry", COBA_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_COLBUR_BERRY = this.create("potted_colbur_berry", BlocksInvoker.createFlowerPotBlock(COLBUR_BERRY))
|
val POTTED_COLBUR_BERRY = this.flowerPot("potted_colbur_berry", COLBUR_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_CORNN_BERRY = this.create("potted_cornn_berry", BlocksInvoker.createFlowerPotBlock(CORNN_BERRY))
|
val POTTED_CORNN_BERRY = this.flowerPot("potted_cornn_berry", CORNN_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_CUSTAP_BERRY = this.create("potted_custap_berry", BlocksInvoker.createFlowerPotBlock(CUSTAP_BERRY))
|
val POTTED_CUSTAP_BERRY = this.flowerPot("potted_custap_berry", CUSTAP_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_DURIN_BERRY = this.create("potted_durin_berry", BlocksInvoker.createFlowerPotBlock(DURIN_BERRY))
|
val POTTED_DURIN_BERRY = this.flowerPot("potted_durin_berry", DURIN_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_EGGANT_BERRY = this.create("potted_eggant_berry", BlocksInvoker.createFlowerPotBlock(EGGANT_BERRY))
|
val POTTED_EGGANT_BERRY = this.flowerPot("potted_eggant_berry", EGGANT_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_ENIGMA_BERRY = this.create("potted_enigma_berry", BlocksInvoker.createFlowerPotBlock(ENIGMA_BERRY))
|
val POTTED_ENIGMA_BERRY = this.flowerPot("potted_enigma_berry", ENIGMA_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_FIGY_BERRY = this.create("potted_figy_berry", BlocksInvoker.createFlowerPotBlock(FIGY_BERRY))
|
val POTTED_FIGY_BERRY = this.flowerPot("potted_figy_berry", FIGY_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_GANLON_BERRY = this.create("potted_ganlon_berry", BlocksInvoker.createFlowerPotBlock(GANLON_BERRY))
|
val POTTED_GANLON_BERRY = this.flowerPot("potted_ganlon_berry", GANLON_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_GREPA_BERRY = this.create("potted_grepa_berry", BlocksInvoker.createFlowerPotBlock(GREPA_BERRY))
|
val POTTED_GREPA_BERRY = this.flowerPot("potted_grepa_berry", GREPA_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_HABAN_BERRY = this.create("potted_haban_berry", BlocksInvoker.createFlowerPotBlock(HABAN_BERRY))
|
val POTTED_HABAN_BERRY = this.flowerPot("potted_haban_berry", HABAN_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_HONDEW_BERRY = this.create("potted_hondew_berry", BlocksInvoker.createFlowerPotBlock(HONDEW_BERRY))
|
val POTTED_HONDEW_BERRY = this.flowerPot("potted_hondew_berry", HONDEW_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_HOPO_BERRY = this.create("potted_hopo_berry", BlocksInvoker.createFlowerPotBlock(HOPO_BERRY))
|
val POTTED_HOPO_BERRY = this.flowerPot("potted_hopo_berry", HOPO_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_IAPAPA_BERRY = this.create("potted_iapapa_berry", BlocksInvoker.createFlowerPotBlock(IAPAPA_BERRY))
|
val POTTED_IAPAPA_BERRY = this.flowerPot("potted_iapapa_berry", IAPAPA_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_JABOCA_BERRY = this.create("potted_jaboca_berry", BlocksInvoker.createFlowerPotBlock(JABOCA_BERRY))
|
val POTTED_JABOCA_BERRY = this.flowerPot("potted_jaboca_berry", JABOCA_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_KASIB_BERRY = this.create("potted_kasib_berry", BlocksInvoker.createFlowerPotBlock(KASIB_BERRY))
|
val POTTED_KASIB_BERRY = this.flowerPot("potted_kasib_berry", KASIB_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_KEBIA_BERRY = this.create("potted_kebia_berry", BlocksInvoker.createFlowerPotBlock(KEBIA_BERRY))
|
val POTTED_KEBIA_BERRY = this.flowerPot("potted_kebia_berry", KEBIA_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_KEE_BERRY = this.create("potted_kee_berry", BlocksInvoker.createFlowerPotBlock(KEE_BERRY))
|
val POTTED_KEE_BERRY = this.flowerPot("potted_kee_berry", KEE_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_KELPSY_BERRY = this.create("potted_kelpsy_berry", BlocksInvoker.createFlowerPotBlock(KELPSY_BERRY))
|
val POTTED_KELPSY_BERRY = this.flowerPot("potted_kelpsy_berry", KELPSY_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_LANSAT_BERRY = this.create("potted_lansat_berry", BlocksInvoker.createFlowerPotBlock(LANSAT_BERRY))
|
val POTTED_LANSAT_BERRY = this.flowerPot("potted_lansat_berry", LANSAT_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_LEPPA_BERRY = this.create("potted_leppa_berry", BlocksInvoker.createFlowerPotBlock(LEPPA_BERRY))
|
val POTTED_LEPPA_BERRY = this.flowerPot("potted_leppa_berry", LEPPA_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_LIECHI_BERRY = this.create("potted_liechi_berry", BlocksInvoker.createFlowerPotBlock(LIECHI_BERRY))
|
val POTTED_LIECHI_BERRY = this.flowerPot("potted_liechi_berry", LIECHI_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_LUM_BERRY = this.create("potted_lum_berry", BlocksInvoker.createFlowerPotBlock(LUM_BERRY))
|
val POTTED_LUM_BERRY = this.flowerPot("potted_lum_berry", LUM_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_MAGO_BERRY = this.create("potted_mago_berry", BlocksInvoker.createFlowerPotBlock(MAGO_BERRY))
|
val POTTED_MAGO_BERRY = this.flowerPot("potted_mago_berry", MAGO_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_MAGOST_BERRY = this.create("potted_magost_berry", BlocksInvoker.createFlowerPotBlock(MAGOST_BERRY))
|
val POTTED_MAGOST_BERRY = this.flowerPot("potted_magost_berry", MAGOST_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_MARANGA_BERRY = this.create("potted_maranga_berry", BlocksInvoker.createFlowerPotBlock(MARANGA_BERRY))
|
val POTTED_MARANGA_BERRY = this.flowerPot("potted_maranga_berry", MARANGA_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_MICLE_BERRY = this.create("potted_micle_berry", BlocksInvoker.createFlowerPotBlock(MICLE_BERRY))
|
val POTTED_MICLE_BERRY = this.flowerPot("potted_micle_berry", MICLE_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_NANAB_BERRY = this.create("potted_nanab_berry", BlocksInvoker.createFlowerPotBlock(NANAB_BERRY))
|
val POTTED_NANAB_BERRY = this.flowerPot("potted_nanab_berry", NANAB_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_NOMEL_BERRY = this.create("potted_nomel_berry", BlocksInvoker.createFlowerPotBlock(NOMEL_BERRY))
|
val POTTED_NOMEL_BERRY = this.flowerPot("potted_nomel_berry", NOMEL_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_OCCA_BERRY = this.create("potted_occa_berry", BlocksInvoker.createFlowerPotBlock(OCCA_BERRY))
|
val POTTED_OCCA_BERRY = this.flowerPot("potted_occa_berry", OCCA_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_ORAN_BERRY = this.create("potted_oran_berry", BlocksInvoker.createFlowerPotBlock(ORAN_BERRY))
|
val POTTED_ORAN_BERRY = this.flowerPot("potted_oran_berry", ORAN_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_PAMTRE_BERRY = this.create("potted_pamtre_berry", BlocksInvoker.createFlowerPotBlock(PAMTRE_BERRY))
|
val POTTED_PAMTRE_BERRY = this.flowerPot("potted_pamtre_berry", PAMTRE_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_PASSHO_BERRY = this.create("potted_passho_berry", BlocksInvoker.createFlowerPotBlock(PASSHO_BERRY))
|
val POTTED_PASSHO_BERRY = this.flowerPot("potted_passho_berry", PASSHO_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_PAYAPA_BERRY = this.create("potted_payapa_berry", BlocksInvoker.createFlowerPotBlock(PAYAPA_BERRY))
|
val POTTED_PAYAPA_BERRY = this.flowerPot("potted_payapa_berry", PAYAPA_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_PECHA_BERRY = this.create("potted_pecha_berry", BlocksInvoker.createFlowerPotBlock(PECHA_BERRY))
|
val POTTED_PECHA_BERRY = this.flowerPot("potted_pecha_berry", PECHA_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_PERSIM_BERRY = this.create("potted_persim_berry", BlocksInvoker.createFlowerPotBlock(PERSIM_BERRY))
|
val POTTED_PERSIM_BERRY = this.flowerPot("potted_persim_berry", PERSIM_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_PETAYA_BERRY = this.create("potted_petaya_berry", BlocksInvoker.createFlowerPotBlock(PETAYA_BERRY))
|
val POTTED_PETAYA_BERRY = this.flowerPot("potted_petaya_berry", PETAYA_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_PINAP_BERRY = this.create("potted_pinap_berry", BlocksInvoker.createFlowerPotBlock(PINAP_BERRY))
|
val POTTED_PINAP_BERRY = this.flowerPot("potted_pinap_berry", PINAP_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_POMEG_BERRY = this.create("potted_pomeg_berry", BlocksInvoker.createFlowerPotBlock(POMEG_BERRY))
|
val POTTED_POMEG_BERRY = this.flowerPot("potted_pomeg_berry", POMEG_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_QUALOT_BERRY = this.create("potted_qualot_berry", BlocksInvoker.createFlowerPotBlock(QUALOT_BERRY))
|
val POTTED_QUALOT_BERRY = this.flowerPot("potted_qualot_berry", QUALOT_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_RABUTA_BERRY = this.create("potted_rabuta_berry", BlocksInvoker.createFlowerPotBlock(RABUTA_BERRY))
|
val POTTED_RABUTA_BERRY = this.flowerPot("potted_rabuta_berry", RABUTA_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_RAWST_BERRY = this.create("potted_rawst_berry", BlocksInvoker.createFlowerPotBlock(RAWST_BERRY))
|
val POTTED_RAWST_BERRY = this.flowerPot("potted_rawst_berry", RAWST_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_RAZZ_BERRY = this.create("potted_razz_berry", BlocksInvoker.createFlowerPotBlock(RAZZ_BERRY))
|
val POTTED_RAZZ_BERRY = this.flowerPot("potted_razz_berry", RAZZ_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_RINDO_BERRY = this.create("potted_rindo_berry", BlocksInvoker.createFlowerPotBlock(RINDO_BERRY))
|
val POTTED_RINDO_BERRY = this.flowerPot("potted_rindo_berry", RINDO_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_ROSELI_BERRY = this.create("potted_roseli_berry", BlocksInvoker.createFlowerPotBlock(ROSELI_BERRY))
|
val POTTED_ROSELI_BERRY = this.flowerPot("potted_roseli_berry", ROSELI_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_ROWAP_BERRY = this.create("potted_rowap_berry", BlocksInvoker.createFlowerPotBlock(ROWAP_BERRY))
|
val POTTED_ROWAP_BERRY = this.flowerPot("potted_rowap_berry", ROWAP_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_SALAC_BERRY = this.create("potted_salac_berry", BlocksInvoker.createFlowerPotBlock(SALAC_BERRY))
|
val POTTED_SALAC_BERRY = this.flowerPot("potted_salac_berry", SALAC_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_SHUCA_BERRY = this.create("potted_shuca_berry", BlocksInvoker.createFlowerPotBlock(SHUCA_BERRY))
|
val POTTED_SHUCA_BERRY = this.flowerPot("potted_shuca_berry", SHUCA_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_SITRUS_BERRY = this.create("potted_sitrus_berry", BlocksInvoker.createFlowerPotBlock(SITRUS_BERRY))
|
val POTTED_SITRUS_BERRY = this.flowerPot("potted_sitrus_berry", SITRUS_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_SPELON_BERRY = this.create("potted_spelon_berry", BlocksInvoker.createFlowerPotBlock(SPELON_BERRY))
|
val POTTED_SPELON_BERRY = this.flowerPot("potted_spelon_berry", SPELON_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_STARF_BERRY = this.create("potted_starf_berry", BlocksInvoker.createFlowerPotBlock(STARF_BERRY))
|
val POTTED_STARF_BERRY = this.flowerPot("potted_starf_berry", STARF_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_TAMATO_BERRY = this.create("potted_tamato_berry", BlocksInvoker.createFlowerPotBlock(TAMATO_BERRY))
|
val POTTED_TAMATO_BERRY = this.flowerPot("potted_tamato_berry", TAMATO_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_TANGA_BERRY = this.create("potted_tanga_berry", BlocksInvoker.createFlowerPotBlock(TANGA_BERRY))
|
val POTTED_TANGA_BERRY = this.flowerPot("potted_tanga_berry", TANGA_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_TOUGA_BERRY = this.create("potted_touga_berry", BlocksInvoker.createFlowerPotBlock(TOUGA_BERRY))
|
val POTTED_TOUGA_BERRY = this.flowerPot("potted_touga_berry", TOUGA_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_WACAN_BERRY = this.create("potted_wacan_berry", BlocksInvoker.createFlowerPotBlock(WACAN_BERRY))
|
val POTTED_WACAN_BERRY = this.flowerPot("potted_wacan_berry", WACAN_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_WATMEL_BERRY = this.create("potted_watmel_berry", BlocksInvoker.createFlowerPotBlock(WATMEL_BERRY))
|
val POTTED_WATMEL_BERRY = this.flowerPot("potted_watmel_berry", WATMEL_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_WEPEAR_BERRY = this.create("potted_wepear_berry", BlocksInvoker.createFlowerPotBlock(WEPEAR_BERRY))
|
val POTTED_WEPEAR_BERRY = this.flowerPot("potted_wepear_berry", WEPEAR_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_WIKI_BERRY = this.create("potted_wiki_berry", BlocksInvoker.createFlowerPotBlock(WIKI_BERRY))
|
val POTTED_WIKI_BERRY = this.flowerPot("potted_wiki_berry", WIKI_BERRY)
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_YACHE_BERRY = this.create("potted_yache_berry", BlocksInvoker.createFlowerPotBlock(YACHE_BERRY))
|
val POTTED_YACHE_BERRY = this.flowerPot("potted_yache_berry", YACHE_BERRY)
|
||||||
|
@JvmField
|
||||||
|
val POTTED_PEP_UP_FLOWER = this.flowerPot("potted_pep_up_flower", PEP_UP_FLOWER)
|
||||||
|
@JvmField
|
||||||
|
val POTTED_RED_APRICORN_SAPLING = this.flowerPot("potted_red_apricorn_sapling", RED_APRICORN_SAPLING)
|
||||||
|
@JvmField
|
||||||
|
val POTTED_YELLOW_APRICORN_SAPLING = this.flowerPot("potted_yellow_apricorn_sapling", YELLOW_APRICORN_SAPLING)
|
||||||
|
@JvmField
|
||||||
|
val POTTED_GREEN_APRICORN_SAPLING = this.flowerPot("potted_green_apricorn_sapling", GREEN_APRICORN_SAPLING)
|
||||||
|
@JvmField
|
||||||
|
val POTTED_BLUE_APRICORN_SAPLING = this.flowerPot("potted_blue_apricorn_sapling", BLUE_APRICORN_SAPLING)
|
||||||
|
@JvmField
|
||||||
|
val POTTED_PINK_APRICORN_SAPLING = this.flowerPot("potted_pink_apricorn_sapling", PINK_APRICORN_SAPLING)
|
||||||
|
@JvmField
|
||||||
|
val POTTED_BLACK_APRICORN_SAPLING = this.flowerPot("potted_black_apricorn_sapling", BLACK_APRICORN_SAPLING)
|
||||||
|
@JvmField
|
||||||
|
val POTTED_WHITE_APRICORN_SAPLING = this.flowerPot("potted_white_apricorn_sapling", WHITE_APRICORN_SAPLING)
|
||||||
|
@JvmField
|
||||||
|
val POTTED_SACCHARINE_SAPLING = this.flowerPot("potted_saccharine_sapling", SACCHARINE_SAPLING)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
/**
|
/**
|
||||||
@@ -1346,7 +1345,16 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
|||||||
|
|
||||||
fun typeGemClusters() = typeGemClusters.toMap()
|
fun typeGemClusters() = typeGemClusters.toMap()
|
||||||
|
|
||||||
private fun pottedPlant(name: String, flower: Block) = this.create(name, BlocksInvoker.createFlowerPotBlock(flower))
|
private fun flowerPot(name: String, flower: Block) = this.create(
|
||||||
|
name,
|
||||||
|
FlowerPotBlock(
|
||||||
|
flower,
|
||||||
|
BlockBehaviour.Properties.of()
|
||||||
|
.instabreak()
|
||||||
|
.noOcclusion()
|
||||||
|
.pushReaction(PushReaction.DESTROY)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
private fun mintLitter(name: String, color: MapColor) = this.create(
|
private fun mintLitter(name: String, color: MapColor) = this.create(
|
||||||
name,
|
name,
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.cobblemon.mod.common.client.pokedex.PokedexType
|
|||||||
import com.cobblemon.mod.common.entity.boat.CobblemonBoatType
|
import com.cobblemon.mod.common.entity.boat.CobblemonBoatType
|
||||||
import com.cobblemon.mod.common.item.*
|
import com.cobblemon.mod.common.item.*
|
||||||
import com.cobblemon.mod.common.item.armor.CobblemonArmorTrims
|
import com.cobblemon.mod.common.item.armor.CobblemonArmorTrims
|
||||||
|
import com.cobblemon.mod.common.item.bag.CobblemonBagItem
|
||||||
import com.cobblemon.mod.common.item.battle.DireHitItem
|
import com.cobblemon.mod.common.item.battle.DireHitItem
|
||||||
import com.cobblemon.mod.common.item.battle.GuardSpecItem
|
import com.cobblemon.mod.common.item.battle.GuardSpecItem
|
||||||
import com.cobblemon.mod.common.item.battle.XStatItem
|
import com.cobblemon.mod.common.item.battle.XStatItem
|
||||||
@@ -1577,6 +1578,12 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
@JvmField
|
@JvmField
|
||||||
val LUCIBELL = compostableBlockItem("lucibell", CobblemonBlocks.LUCIBELL, 0.85f)
|
val LUCIBELL = compostableBlockItem("lucibell", CobblemonBlocks.LUCIBELL, 0.85f)
|
||||||
|
|
||||||
|
//Bags
|
||||||
|
@JvmField
|
||||||
|
val TRAINER_BAG = this.create("trainer_bag", CobblemonBagItem())
|
||||||
|
@JvmField
|
||||||
|
val TRAINER_PACK = this.create("trainer_pack", CobblemonBagItem())
|
||||||
|
|
||||||
private fun blockItem(name: String, block: Block, rarity: Rarity = Rarity.COMMON): BlockItem = this.create(name, BlockItem(block, Item.Properties().rarity(rarity)))
|
private fun blockItem(name: String, block: Block, rarity: Rarity = Rarity.COMMON): BlockItem = this.create(name, BlockItem(block, Item.Properties().rarity(rarity)))
|
||||||
|
|
||||||
private fun itemNameBlockItem(name: String, block: Block, rarity: Rarity = Rarity.COMMON): ItemNameBlockItem = this.create(name, ItemNameBlockItem(block, Item.Properties().rarity(rarity)))
|
private fun itemNameBlockItem(name: String, block: Block, rarity: Rarity = Rarity.COMMON): ItemNameBlockItem = this.create(name, ItemNameBlockItem(block, Item.Properties().rarity(rarity)))
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ package com.cobblemon.mod.common
|
|||||||
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.block.campfirepot.CookingPotMenu
|
import com.cobblemon.mod.common.block.campfirepot.CookingPotMenu
|
||||||
|
import com.cobblemon.mod.common.item.bag.CobblemonBagMenu
|
||||||
import com.cobblemon.mod.common.block.tmmachine.TMMachineMenu
|
import com.cobblemon.mod.common.block.tmmachine.TMMachineMenu
|
||||||
import com.cobblemon.mod.common.platform.PlatformRegistry
|
import com.cobblemon.mod.common.platform.PlatformRegistry
|
||||||
import net.minecraft.core.Registry
|
import net.minecraft.core.Registry
|
||||||
@@ -20,8 +21,9 @@ import net.minecraft.world.inventory.MenuType
|
|||||||
|
|
||||||
object CobblemonMenuType : PlatformRegistry<Registry<MenuType<*>>, ResourceKey<Registry<MenuType<*>>>, MenuType<*>>() {
|
object CobblemonMenuType : PlatformRegistry<Registry<MenuType<*>>, ResourceKey<Registry<MenuType<*>>>, MenuType<*>>() {
|
||||||
|
|
||||||
val COOKING_POT = MenuType.register("cooking_pot_menu", ::CookingPotMenu)
|
val COOKING_POT = MenuType.register("cooking_pot", ::CookingPotMenu)
|
||||||
val TM_MACHINE = MenuType.register("tm_machine_menu", ::TMMachineMenu)
|
val TM_MACHINE = MenuType.register("tm_machine_menu", ::TMMachineMenu)
|
||||||
|
val COBBLEMON_BAG = MenuType.register("cobblemon_bag", ::CobblemonBagMenu)
|
||||||
|
|
||||||
override val registry: Registry<MenuType<*>>
|
override val registry: Registry<MenuType<*>>
|
||||||
get() = BuiltInRegistries.MENU
|
get() = BuiltInRegistries.MENU
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import com.cobblemon.mod.common.client.net.OpenBehaviourEditorHandler
|
|||||||
import com.cobblemon.mod.common.client.net.PlayerInteractOptionsHandler
|
import com.cobblemon.mod.common.client.net.PlayerInteractOptionsHandler
|
||||||
import com.cobblemon.mod.common.client.net.SetClientPlayerDataHandler
|
import com.cobblemon.mod.common.client.net.SetClientPlayerDataHandler
|
||||||
import com.cobblemon.mod.common.client.net.animation.PlayPosableAnimationHandler
|
import com.cobblemon.mod.common.client.net.animation.PlayPosableAnimationHandler
|
||||||
|
import com.cobblemon.mod.common.client.net.bag.UpdateBagMenuDataHandler
|
||||||
|
import com.cobblemon.mod.common.client.net.bag.UseItemOnPokemonFromBagHandler
|
||||||
import com.cobblemon.mod.common.client.net.battle.*
|
import com.cobblemon.mod.common.client.net.battle.*
|
||||||
import com.cobblemon.mod.common.client.net.callback.move.OpenMoveCallbackHandler
|
import com.cobblemon.mod.common.client.net.callback.move.OpenMoveCallbackHandler
|
||||||
import com.cobblemon.mod.common.client.net.callback.party.OpenPartyCallbackHandler
|
import com.cobblemon.mod.common.client.net.callback.party.OpenPartyCallbackHandler
|
||||||
@@ -76,6 +78,8 @@ import com.cobblemon.mod.common.net.messages.client.OpenBehaviourEditorPacket
|
|||||||
import com.cobblemon.mod.common.net.messages.client.PlayerInteractOptionsPacket
|
import com.cobblemon.mod.common.net.messages.client.PlayerInteractOptionsPacket
|
||||||
import com.cobblemon.mod.common.net.messages.client.SetClientPlayerDataPacket
|
import com.cobblemon.mod.common.net.messages.client.SetClientPlayerDataPacket
|
||||||
import com.cobblemon.mod.common.net.messages.client.animation.PlayPosableAnimationPacket
|
import com.cobblemon.mod.common.net.messages.client.animation.PlayPosableAnimationPacket
|
||||||
|
import com.cobblemon.mod.common.net.messages.client.bag.UpdateBagMenuDataPacket
|
||||||
|
import com.cobblemon.mod.common.net.messages.client.bag.UseItemOnPokemonFromBagPacket
|
||||||
import com.cobblemon.mod.common.net.messages.client.battle.*
|
import com.cobblemon.mod.common.net.messages.client.battle.*
|
||||||
import com.cobblemon.mod.common.net.messages.client.callback.OpenMoveCallbackPacket
|
import com.cobblemon.mod.common.net.messages.client.callback.OpenMoveCallbackPacket
|
||||||
import com.cobblemon.mod.common.net.messages.client.callback.OpenPartyCallbackPacket
|
import com.cobblemon.mod.common.net.messages.client.callback.OpenPartyCallbackPacket
|
||||||
@@ -444,6 +448,7 @@ object CobblemonNetwork {
|
|||||||
list.add(PacketRegisterInfo(BehaviourSyncPacket.ID, BehaviourSyncPacket::decode, DataRegistrySyncPacketHandler()))
|
list.add(PacketRegisterInfo(BehaviourSyncPacket.ID, BehaviourSyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||||
list.add(PacketRegisterInfo(MarkRegistrySyncPacket.ID, MarkRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
list.add(PacketRegisterInfo(MarkRegistrySyncPacket.ID, MarkRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||||
list.add(PacketRegisterInfo(RideSettingsSyncPacket.ID, RideSettingsSyncPacket::decode, RideSettingsSyncHandler))
|
list.add(PacketRegisterInfo(RideSettingsSyncPacket.ID, RideSettingsSyncPacket::decode, RideSettingsSyncHandler))
|
||||||
|
list.add(PacketRegisterInfo(BagCategoriesSyncPacket.ID, BagCategoriesSyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||||
list.add(PacketRegisterInfo(TechnicalMachineRegistrySyncPacket.ID, TechnicalMachineRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
list.add(PacketRegisterInfo(TechnicalMachineRegistrySyncPacket.ID, TechnicalMachineRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||||
|
|
||||||
// Effects
|
// Effects
|
||||||
@@ -640,6 +645,10 @@ object CobblemonNetwork {
|
|||||||
list.add(PacketRegisterInfo(SetActiveTMPacket.ID, SetActiveTMPacket::decode, SetActiveTMPacketHandler))
|
list.add(PacketRegisterInfo(SetActiveTMPacket.ID, SetActiveTMPacket::decode, SetActiveTMPacketHandler))
|
||||||
list.add(PacketRegisterInfo(SetTMMachineContainerDataPacket.ID, SetTMMachineContainerDataPacket::decode, SetTMMachineContainerDataPacketHandler))
|
list.add(PacketRegisterInfo(SetTMMachineContainerDataPacket.ID, SetTMMachineContainerDataPacket::decode, SetTMMachineContainerDataPacketHandler))
|
||||||
|
|
||||||
|
// Bag
|
||||||
|
list.add(PacketRegisterInfo(UpdateBagMenuDataPacket.ID, UpdateBagMenuDataPacket::decode, UpdateBagMenuDataHandler))
|
||||||
|
list.add(PacketRegisterInfo(UseItemOnPokemonFromBagPacket.ID, UseItemOnPokemonFromBagPacket::decode, UseItemOnPokemonFromBagHandler))
|
||||||
|
|
||||||
// Behaviour Packets
|
// Behaviour Packets
|
||||||
list.add(PacketRegisterInfo(SetEntityBehaviourPacket.ID, SetEntityBehaviourPacket::decode, SetEntityBehaviourHandler))
|
list.add(PacketRegisterInfo(SetEntityBehaviourPacket.ID, SetEntityBehaviourPacket::decode, SetEntityBehaviourHandler))
|
||||||
list.add(PacketRegisterInfo(DamageOnCollisionPacket.ID, DamageOnCollisionPacket::decode, DamageOnCollisionPacketHandler))
|
list.add(PacketRegisterInfo(DamageOnCollisionPacket.ID, DamageOnCollisionPacket::decode, DamageOnCollisionPacketHandler))
|
||||||
@@ -647,7 +656,7 @@ object CobblemonNetwork {
|
|||||||
// Habitat blocks
|
// Habitat blocks
|
||||||
list.add(PacketRegisterInfo(SaveHabitatBlockSettingsPacket.ID, SaveHabitatBlockSettingsPacket::decode, SaveHabitatBlockSettingsHandler))
|
list.add(PacketRegisterInfo(SaveHabitatBlockSettingsPacket.ID, SaveHabitatBlockSettingsPacket::decode, SaveHabitatBlockSettingsHandler))
|
||||||
|
|
||||||
// Debug / cheats
|
// Debug
|
||||||
list.add(PacketRegisterInfo(RequestOpenRidingStatsDebugGUIPacket.ID, RequestOpenRidingStatsDebugGUIPacket::decode, RequestOpenRidingStatsDebugGUIHandler))
|
list.add(PacketRegisterInfo(RequestOpenRidingStatsDebugGUIPacket.ID, RequestOpenRidingStatsDebugGUIPacket::decode, RequestOpenRidingStatsDebugGUIHandler))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -321,6 +321,19 @@ object CobblemonSounds : PlatformRegistry<Registry<SoundEvent>, ResourceKey<Regi
|
|||||||
@JvmField
|
@JvmField
|
||||||
val MEDICINAL_LEEK_PLACE = this.create("block.medicinal_leek.plant")
|
val MEDICINAL_LEEK_PLACE = this.create("block.medicinal_leek.plant")
|
||||||
|
|
||||||
|
@JvmField
|
||||||
|
val ITEM_BAG_OPEN = this.create("item.bag.open")
|
||||||
|
@JvmField
|
||||||
|
val ITEM_BAG_CLOSE = this.create("item.bag.close")
|
||||||
|
@JvmField
|
||||||
|
val ITEM_BAG_CLICK = this.create("item.bag.click")
|
||||||
|
@JvmField
|
||||||
|
val ITEM_BAG_ITEM_IN = this.create("item.bag.item_in")
|
||||||
|
@JvmField
|
||||||
|
val ITEM_BAG_ITEM_OUT = this.create("item.bag.item_out")
|
||||||
|
@JvmField
|
||||||
|
val ITEM_BAG_EQUIP = this.create("item.bag.equip")
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val GILDED_CHEST_OPEN = this.create("block.gilded_chest.open")
|
val GILDED_CHEST_OPEN = this.create("block.gilded_chest.open")
|
||||||
@JvmField
|
@JvmField
|
||||||
|
|||||||
+31
-7
@@ -9,6 +9,7 @@
|
|||||||
package com.cobblemon.mod.common.api.ai.config.task
|
package com.cobblemon.mod.common.api.ai.config.task
|
||||||
|
|
||||||
import com.bedrockk.molang.Expression
|
import com.bedrockk.molang.Expression
|
||||||
|
import com.cobblemon.mod.common.Cobblemon
|
||||||
import com.cobblemon.mod.common.api.ai.BehaviourConfigurationContext
|
import com.cobblemon.mod.common.api.ai.BehaviourConfigurationContext
|
||||||
import com.cobblemon.mod.common.api.ai.ExpressionOrEntityVariable
|
import com.cobblemon.mod.common.api.ai.ExpressionOrEntityVariable
|
||||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMostSpecificMoLangValue
|
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMostSpecificMoLangValue
|
||||||
@@ -17,6 +18,7 @@ import com.cobblemon.mod.common.util.asExpression
|
|||||||
import com.cobblemon.mod.common.util.mainThreadRuntime
|
import com.cobblemon.mod.common.util.mainThreadRuntime
|
||||||
import com.cobblemon.mod.common.util.resolveBoolean
|
import com.cobblemon.mod.common.util.resolveBoolean
|
||||||
import com.cobblemon.mod.common.util.withQueryValue
|
import com.cobblemon.mod.common.util.withQueryValue
|
||||||
|
import com.cobblemon.mod.common.world.gamerules.CobblemonGameRules
|
||||||
import com.mojang.datafixers.util.Either
|
import com.mojang.datafixers.util.Either
|
||||||
import net.minecraft.world.entity.LivingEntity
|
import net.minecraft.world.entity.LivingEntity
|
||||||
import net.minecraft.world.entity.ai.behavior.BehaviorControl
|
import net.minecraft.world.entity.ai.behavior.BehaviorControl
|
||||||
@@ -34,6 +36,8 @@ import net.minecraft.world.entity.ai.sensing.SensorType
|
|||||||
class HateEntityTaskConfig : SingleTaskConfig {
|
class HateEntityTaskConfig : SingleTaskConfig {
|
||||||
val entityCondition: Expression = "true".asExpression()
|
val entityCondition: Expression = "true".asExpression()
|
||||||
val range: ExpressionOrEntityVariable = Either.left("24".asExpression())
|
val range: ExpressionOrEntityVariable = Either.left("24".asExpression())
|
||||||
|
val chance: Float = Cobblemon.config.predationChance
|
||||||
|
private val coercedChance = chance.coerceIn(0f, 1f)
|
||||||
|
|
||||||
override fun getVariables(entity: LivingEntity, behaviourConfigurationContext: BehaviourConfigurationContext) = emptyList<MoLangConfigVariable>()
|
override fun getVariables(entity: LivingEntity, behaviourConfigurationContext: BehaviourConfigurationContext) = emptyList<MoLangConfigVariable>()
|
||||||
override fun createTask(
|
override fun createTask(
|
||||||
@@ -43,24 +47,44 @@ class HateEntityTaskConfig : SingleTaskConfig {
|
|||||||
val range = range.resolveFloat(behaviourConfigurationContext.runtime)
|
val range = range.resolveFloat(behaviourConfigurationContext.runtime)
|
||||||
behaviourConfigurationContext.addMemories(
|
behaviourConfigurationContext.addMemories(
|
||||||
MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES,
|
MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES,
|
||||||
MemoryModuleType.ANGRY_AT
|
MemoryModuleType.ANGRY_AT,
|
||||||
|
MemoryModuleType.ATTACK_TARGET
|
||||||
)
|
)
|
||||||
behaviourConfigurationContext.addSensors(SensorType.NEAREST_LIVING_ENTITIES)
|
behaviourConfigurationContext.addSensors(SensorType.NEAREST_LIVING_ENTITIES)
|
||||||
return BehaviorBuilder.create { instance ->
|
return BehaviorBuilder.create { instance ->
|
||||||
instance.group(
|
instance.group(
|
||||||
instance.present(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES),
|
instance.present(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES),
|
||||||
instance.registered(MemoryModuleType.ANGRY_AT)
|
instance.registered(MemoryModuleType.ANGRY_AT),
|
||||||
).apply(instance) { entities, angryAt ->
|
instance.registered(MemoryModuleType.ATTACK_TARGET),
|
||||||
|
).apply(instance) { entities, angryAt, attackTarget ->
|
||||||
Trigger { world, entity, _ ->
|
Trigger { world, entity, _ ->
|
||||||
val target = instance.get(entities).findClosest {
|
// bail if gamerule is disabled
|
||||||
mainThreadRuntime.withQueryValue("entity", entity.asMostSpecificMoLangValue())
|
if (!world.gameRules.getBoolean(CobblemonGameRules.DO_POKEMON_PREDATION)) return@Trigger false
|
||||||
|
val target = instance.get(entities).findClosest { hated ->
|
||||||
|
mainThreadRuntime.withQueryValue("entity", hated.asMostSpecificMoLangValue())
|
||||||
return@findClosest mainThreadRuntime.resolveBoolean(entityCondition)
|
return@findClosest mainThreadRuntime.resolveBoolean(entityCondition)
|
||||||
}.orElse(null)
|
}.orElse(null)
|
||||||
|
|
||||||
|
var shouldTrigger = false
|
||||||
if (target != null && target.distanceTo(entity) <= range) {
|
if (target != null && target.distanceTo(entity) <= range) {
|
||||||
angryAt.set(target.uuid)
|
shouldTrigger = when {
|
||||||
|
// set always attacking if activity chance is equal to 1.0
|
||||||
|
coercedChance == 1f -> {
|
||||||
|
angryAt.set(target.uuid)
|
||||||
|
attackTarget.set(target)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
// roll the dice in other way
|
||||||
|
coercedChance != 1f && world.random.nextFloat() < coercedChance -> {
|
||||||
|
angryAt.set(target.uuid)
|
||||||
|
attackTarget.set(target)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
// fallback to peaceful behavior in unattended cases
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return@Trigger true
|
return@Trigger shouldTrigger
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* 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.bag
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.Cobblemon
|
||||||
|
import com.cobblemon.mod.common.api.data.JsonDataRegistry
|
||||||
|
import com.cobblemon.mod.common.api.reactive.SimpleObservable
|
||||||
|
import com.cobblemon.mod.common.net.messages.client.data.BagCategoriesSyncPacket
|
||||||
|
import com.cobblemon.mod.common.util.adapters.IdentifierAdapter
|
||||||
|
import com.cobblemon.mod.common.util.adapters.TagKeyAdapter
|
||||||
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
|
import com.google.gson.GsonBuilder
|
||||||
|
import com.google.gson.reflect.TypeToken
|
||||||
|
import net.minecraft.core.registries.Registries
|
||||||
|
import net.minecraft.resources.ResourceLocation
|
||||||
|
import net.minecraft.server.level.ServerPlayer
|
||||||
|
import net.minecraft.server.packs.PackType
|
||||||
|
import net.minecraft.tags.TagKey
|
||||||
|
import net.minecraft.world.item.Item
|
||||||
|
|
||||||
|
object BagCategories: JsonDataRegistry<BagCategory> {
|
||||||
|
|
||||||
|
override val id: ResourceLocation = cobblemonResource("bag_categories")
|
||||||
|
override val type: PackType = PackType.SERVER_DATA
|
||||||
|
override val observable = SimpleObservable<BagCategories>()
|
||||||
|
|
||||||
|
override val gson = GsonBuilder()
|
||||||
|
.disableHtmlEscaping()
|
||||||
|
.setPrettyPrinting()
|
||||||
|
.registerTypeAdapter(ResourceLocation::class.java, IdentifierAdapter)
|
||||||
|
.registerTypeAdapter(TypeToken.getParameterized(TagKey::class.java, Item::class.java).type, TagKeyAdapter(Registries.ITEM))
|
||||||
|
.create()
|
||||||
|
|
||||||
|
override val typeToken: TypeToken<BagCategory> = TypeToken.get(BagCategory::class.java)
|
||||||
|
override val resourcePath = "bag_categories"
|
||||||
|
|
||||||
|
private val bagCategories = hashMapOf<ResourceLocation, BagCategory>()
|
||||||
|
|
||||||
|
override fun reload(data: Map<ResourceLocation, BagCategory>) {
|
||||||
|
bagCategories.clear()
|
||||||
|
data.forEach { identifier, category ->
|
||||||
|
try {
|
||||||
|
category.identifier = identifier
|
||||||
|
bagCategories[identifier] = category
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Cobblemon.LOGGER.error("Skipped loading the {} category", identifier, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Cobblemon.LOGGER.info("Loaded {} bag categories", bagCategories.size)
|
||||||
|
this.observable.emit(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun sync(player: ServerPlayer) {
|
||||||
|
BagCategoriesSyncPacket(bagCategories.values.toList())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getOrderedCategoriesList(): List<BagCategory> {
|
||||||
|
return bagCategories.values.toList().sortedBy { it.order }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* 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.bag
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.util.readIdentifier
|
||||||
|
import com.cobblemon.mod.common.util.writeIdentifier
|
||||||
|
import net.minecraft.core.registries.Registries
|
||||||
|
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||||
|
import net.minecraft.network.chat.Component
|
||||||
|
import net.minecraft.network.chat.MutableComponent
|
||||||
|
import net.minecraft.resources.ResourceLocation
|
||||||
|
import net.minecraft.tags.TagKey
|
||||||
|
import net.minecraft.util.StringRepresentable
|
||||||
|
import net.minecraft.world.item.Item
|
||||||
|
import net.minecraft.world.item.ItemStack
|
||||||
|
|
||||||
|
class BagCategory(
|
||||||
|
identifier: ResourceLocation,
|
||||||
|
val order: Int,
|
||||||
|
val icon: ResourceLocation,
|
||||||
|
val whiteListTag: TagKey<Item>,
|
||||||
|
val blackListTag: TagKey<Item>,
|
||||||
|
val maxCount: Int,
|
||||||
|
val defaultSort: ResourceLocation?,
|
||||||
|
val sortMethods: List<ResourceLocation>?
|
||||||
|
): StringRepresentable {
|
||||||
|
@Transient
|
||||||
|
var identifier: ResourceLocation = identifier
|
||||||
|
internal set
|
||||||
|
|
||||||
|
override fun getSerializedName(): String = identifier.toString()
|
||||||
|
|
||||||
|
fun getName(): MutableComponent = Component.translatable("${identifier.namespace}.bag_category.${identifier.path}")
|
||||||
|
|
||||||
|
fun itemIsValid(itemStack: ItemStack): Boolean {
|
||||||
|
if (itemStack.`is`(blackListTag)) return false
|
||||||
|
if (itemStack.`is`(whiteListTag)) return true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getAllSortMethods(): List<ResourceLocation> {
|
||||||
|
val returnList = mutableListOf<ResourceLocation>()
|
||||||
|
returnList.add(defaultSort ?: BagSortComparators.DEFAULT_SORT)
|
||||||
|
sortMethods?.let { returnList.addAll(it) }
|
||||||
|
return returnList
|
||||||
|
}
|
||||||
|
|
||||||
|
fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||||
|
buffer.writeIdentifier(identifier)
|
||||||
|
buffer.writeInt(order)
|
||||||
|
buffer.writeIdentifier(icon)
|
||||||
|
buffer.writeIdentifier(whiteListTag.location)
|
||||||
|
buffer.writeIdentifier(blackListTag.location)
|
||||||
|
buffer.writeInt(maxCount)
|
||||||
|
buffer.writeIdentifier(defaultSort ?: BagSortComparators.DEFAULT_SORT)
|
||||||
|
val sortMethods = sortMethods.orEmpty()
|
||||||
|
buffer.writeInt(sortMethods.size)
|
||||||
|
buffer.writeCollection(sortMethods) { buf, method -> buf.writeIdentifier(method) }
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
internal fun decode(buffer: RegistryFriendlyByteBuf): BagCategory {
|
||||||
|
return BagCategory(
|
||||||
|
buffer.readIdentifier(),
|
||||||
|
buffer.readInt(),
|
||||||
|
buffer.readIdentifier(),
|
||||||
|
TagKey.create(Registries.ITEM, buffer.readIdentifier()),
|
||||||
|
TagKey.create(Registries.ITEM, buffer.readIdentifier()),
|
||||||
|
buffer.readInt(),
|
||||||
|
buffer.readIdentifier(),
|
||||||
|
buffer.readList { it.readIdentifier() }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package com.cobblemon.mod.common.api.bag
|
||||||
|
|
||||||
|
import net.minecraft.resources.ResourceLocation
|
||||||
|
import net.minecraft.world.item.ItemStack
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event to register code-based functions to define sorting order
|
||||||
|
* Function compares 2 itemStacks, returns 0 if they are equal, less than 0
|
||||||
|
*/
|
||||||
|
class BagSortComparatorRegistryEvent {
|
||||||
|
val comparators = mutableMapOf<ResourceLocation, Comparator<ItemStack>>()
|
||||||
|
|
||||||
|
fun registerFunction(id: ResourceLocation, comparator: Comparator<ItemStack>) {
|
||||||
|
comparators[id] = comparator
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.cobblemon.mod.common.api.bag
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.api.events.CobblemonEvents
|
||||||
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
|
import net.minecraft.resources.ResourceLocation
|
||||||
|
import net.minecraft.world.item.CreativeModeTabs
|
||||||
|
import net.minecraft.world.item.Item
|
||||||
|
import net.minecraft.world.item.ItemStack
|
||||||
|
|
||||||
|
object BagSortComparators {
|
||||||
|
private val SORT_METHODS = mutableMapOf<ResourceLocation, Comparator<ItemStack>>()
|
||||||
|
|
||||||
|
val INPUT_ORDER = cobblemonResource("input_order")
|
||||||
|
val ALPHABETICAL = cobblemonResource("alphabetical")
|
||||||
|
val CREATIVE_MENU = cobblemonResource("creative_menu")
|
||||||
|
|
||||||
|
val DEFAULT_SORT = CREATIVE_MENU
|
||||||
|
|
||||||
|
fun registerComparator(type: ResourceLocation, comparator: Comparator<ItemStack>) {
|
||||||
|
SORT_METHODS[type] = comparator
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getComparator(type: ResourceLocation): Comparator<ItemStack>? {
|
||||||
|
return SORT_METHODS[type]
|
||||||
|
}
|
||||||
|
|
||||||
|
private val creativeItemOrder: Map<Item, Int> by lazy {
|
||||||
|
buildMap {
|
||||||
|
CreativeModeTabs.searchTab().displayItems.forEachIndexed { index, stack ->
|
||||||
|
getOrPut(stack.item) { index }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setupComparators() {
|
||||||
|
registerComparator(ALPHABETICAL, compareBy { it.displayName.toString() })
|
||||||
|
registerComparator(CREATIVE_MENU, compareBy { creativeItemOrder[it.item] ?: Int.MAX_VALUE })
|
||||||
|
registerComparator(INPUT_ORDER, compareBy { null })
|
||||||
|
CobblemonEvents.BAG_SORTING_REGISTRATION.post(BagSortComparatorRegistryEvent()) { event ->
|
||||||
|
event.comparators.forEach { (type, comparator) -> registerComparator(type, comparator) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -239,6 +239,10 @@ open class PokemonBattle(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun writeShowdownAction(vararg messages: String) {
|
fun writeShowdownAction(vararg messages: String) {
|
||||||
|
if (messages.any { it.contains("\n") || it.contains("\r") }) {
|
||||||
|
LOGGER.warn("Refusing to forward Showdown action with an embedded line break for battle {}: {}", battleId, messages.joinToString(" | "))
|
||||||
|
return
|
||||||
|
}
|
||||||
log(messages.joinToString("\n"))
|
log(messages.joinToString("\n"))
|
||||||
ShowdownService.service.send(battleId, messages.toList().toTypedArray())
|
ShowdownService.service.send(battleId, messages.toList().toTypedArray())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.api.events
|
package com.cobblemon.mod.common.api.events
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.api.bag.BagSortComparatorRegistryEvent
|
||||||
import com.cobblemon.mod.common.api.events.battles.BattleFaintedEvent
|
import com.cobblemon.mod.common.api.events.battles.BattleFaintedEvent
|
||||||
import com.cobblemon.mod.common.api.events.battles.BattleFledEvent
|
import com.cobblemon.mod.common.api.events.battles.BattleFledEvent
|
||||||
import com.cobblemon.mod.common.api.events.battles.BattleFleeAttemptEvent
|
import com.cobblemon.mod.common.api.events.battles.BattleFleeAttemptEvent
|
||||||
@@ -393,4 +394,8 @@ object CobblemonEvents {
|
|||||||
val HABITAT_SETTINGS_SAVED_PRE = CancelableObservable<SaveHabitatBlockSettingsEvent.Pre>()
|
val HABITAT_SETTINGS_SAVED_PRE = CancelableObservable<SaveHabitatBlockSettingsEvent.Pre>()
|
||||||
@JvmField
|
@JvmField
|
||||||
val HABITAT_SETTINGS_SAVED_POST = EventObservable<SaveHabitatBlockSettingsEvent.Post>()
|
val HABITAT_SETTINGS_SAVED_POST = EventObservable<SaveHabitatBlockSettingsEvent.Post>()
|
||||||
|
|
||||||
|
// Bag
|
||||||
|
@JvmField
|
||||||
|
val BAG_SORTING_REGISTRATION = EventObservable<BagSortComparatorRegistryEvent>()
|
||||||
}
|
}
|
||||||
@@ -9,12 +9,14 @@
|
|||||||
package com.cobblemon.mod.common.api.events.pokemon
|
package com.cobblemon.mod.common.api.events.pokemon
|
||||||
|
|
||||||
import com.bedrockk.molang.runtime.value.DoubleValue
|
import com.bedrockk.molang.runtime.value.DoubleValue
|
||||||
|
import com.bedrockk.molang.runtime.value.MoValue
|
||||||
import com.cobblemon.mod.common.api.events.Cancelable
|
import com.cobblemon.mod.common.api.events.Cancelable
|
||||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMoLangValue
|
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMoLangValue
|
||||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.moLangFunctionMap
|
import com.cobblemon.mod.common.api.molang.MoLangFunctions.moLangFunctionMap
|
||||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||||
import com.cobblemon.mod.common.pokemon.Pokemon
|
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||||
import com.cobblemon.mod.common.trade.TradeParticipant
|
import com.cobblemon.mod.common.trade.TradeParticipant
|
||||||
|
import com.cobblemon.mod.common.util.asArrayValue
|
||||||
import com.cobblemon.mod.common.util.getPlayer
|
import com.cobblemon.mod.common.util.getPlayer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,9 +33,9 @@ interface TradeEvent {
|
|||||||
val tradeParticipant1: TradeParticipant
|
val tradeParticipant1: TradeParticipant
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The [Pokemon] being traded by the first participant.
|
* All the [Pokemon] the first participant receives in the trade.
|
||||||
*/
|
*/
|
||||||
val tradeParticipant1Pokemon: Pokemon
|
val tradeParticipant1Pokemon: List<Pokemon>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The second [TradeParticipant].
|
* The second [TradeParticipant].
|
||||||
@@ -41,9 +43,19 @@ interface TradeEvent {
|
|||||||
val tradeParticipant2: TradeParticipant
|
val tradeParticipant2: TradeParticipant
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The [Pokemon] being traded by the second participant.
|
* All the [Pokemon] the second participant receives in the trade.
|
||||||
*/
|
*/
|
||||||
val tradeParticipant2Pokemon: Pokemon
|
val tradeParticipant2Pokemon: List<Pokemon>
|
||||||
|
|
||||||
|
fun createContext(): MutableMap<String, MoValue> = mutableMapOf(
|
||||||
|
"trade_participant_1" to (tradeParticipant1.uuid.getPlayer()?.asMoLangValue() ?: DoubleValue.ZERO),
|
||||||
|
"trade_participant_2" to (tradeParticipant2.uuid.getPlayer()?.asMoLangValue() ?: DoubleValue.ZERO),
|
||||||
|
// Kept for backwards compatibility, this is the first Pokémon of each side.
|
||||||
|
"trade_participant_1_pokemon" to tradeParticipant1Pokemon.first().struct,
|
||||||
|
"trade_participant_2_pokemon" to tradeParticipant2Pokemon.first().struct,
|
||||||
|
"trade_participant_1_pokemon_list" to tradeParticipant1Pokemon.asArrayValue { it.struct },
|
||||||
|
"trade_participant_2_pokemon_list" to tradeParticipant2Pokemon.asArrayValue { it.struct }
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event fired when a trade is about to happen. Cancelling this event prevents the trade from occurring.
|
* Event fired when a trade is about to happen. Cancelling this event prevents the trade from occurring.
|
||||||
@@ -53,16 +65,11 @@ interface TradeEvent {
|
|||||||
*/
|
*/
|
||||||
data class Pre(
|
data class Pre(
|
||||||
override val tradeParticipant1: TradeParticipant,
|
override val tradeParticipant1: TradeParticipant,
|
||||||
override val tradeParticipant1Pokemon: Pokemon,
|
override val tradeParticipant1Pokemon: List<Pokemon>,
|
||||||
override val tradeParticipant2: TradeParticipant,
|
override val tradeParticipant2: TradeParticipant,
|
||||||
override val tradeParticipant2Pokemon: Pokemon
|
override val tradeParticipant2Pokemon: List<Pokemon>
|
||||||
) : TradeEvent, Cancelable() {
|
) : TradeEvent, Cancelable() {
|
||||||
val context = mutableMapOf(
|
val context = createContext()
|
||||||
"trade_participant_1" to (tradeParticipant1.uuid.getPlayer()?.asMoLangValue() ?: DoubleValue.ZERO),
|
|
||||||
"trade_participant_2" to (tradeParticipant2.uuid.getPlayer()?.asMoLangValue() ?: DoubleValue.ZERO),
|
|
||||||
"trade_participant_1_pokemon" to tradeParticipant1Pokemon.struct,
|
|
||||||
"trade_participant_2_pokemon" to tradeParticipant2Pokemon.struct
|
|
||||||
)
|
|
||||||
|
|
||||||
val functions = moLangFunctionMap(
|
val functions = moLangFunctionMap(
|
||||||
cancelFunc
|
cancelFunc
|
||||||
@@ -77,15 +84,10 @@ interface TradeEvent {
|
|||||||
*/
|
*/
|
||||||
data class Post(
|
data class Post(
|
||||||
override val tradeParticipant1: TradeParticipant,
|
override val tradeParticipant1: TradeParticipant,
|
||||||
override val tradeParticipant1Pokemon: Pokemon,
|
override val tradeParticipant1Pokemon: List<Pokemon>,
|
||||||
override val tradeParticipant2: TradeParticipant,
|
override val tradeParticipant2: TradeParticipant,
|
||||||
override val tradeParticipant2Pokemon: Pokemon
|
override val tradeParticipant2Pokemon: List<Pokemon>
|
||||||
) : TradeEvent {
|
) : TradeEvent {
|
||||||
val context = mutableMapOf(
|
val context = createContext()
|
||||||
"trade_participant_1" to (tradeParticipant1.uuid.getPlayer()?.asMoLangValue() ?: DoubleValue.ZERO),
|
|
||||||
"trade_participant_2" to (tradeParticipant2.uuid.getPlayer()?.asMoLangValue() ?: DoubleValue.ZERO),
|
|
||||||
"trade_participant_1_pokemon" to tradeParticipant1Pokemon.struct,
|
|
||||||
"trade_participant_2_pokemon" to tradeParticipant2Pokemon.struct
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+6
-6
@@ -88,7 +88,7 @@ fun getToolTipHeaderIcon(tradeEvolution: TradeEvolution): CobblemonDexEvolutionR
|
|||||||
lang("ui.pokedex.evolution.trade.tooltip.with_any_species")
|
lang("ui.pokedex.evolution.trade.tooltip.with_any_species")
|
||||||
} else {
|
} else {
|
||||||
PokemonSpecies.getByIdentifier(species.asIdentifierDefaultingNamespace())
|
PokemonSpecies.getByIdentifier(species.asIdentifierDefaultingNamespace())
|
||||||
?.let { lang("ui.pokedex.evolution.trade.tooltip.with_species", it.translatedName.green()) }
|
?.let { lang("ui.pokedex.evolution.trade.tooltip.with_species", it.translatedName.plainCopy().green()) }
|
||||||
?: lang("ui.pokedex.evolution.trade.tooltip.with_any_species")
|
?: lang("ui.pokedex.evolution.trade.tooltip.with_any_species")
|
||||||
}
|
}
|
||||||
return CobblemonDexEvolutionRequirementDisplay(CobblemonItems.LINK_CABLE, tooltip)
|
return CobblemonDexEvolutionRequirementDisplay(CobblemonItems.LINK_CABLE, tooltip)
|
||||||
@@ -282,7 +282,7 @@ fun buildLevelRequirement(levelRequirement: LevelRequirement): DexEvolutionRequi
|
|||||||
|
|
||||||
fun buildMoonPhaseRequirement(moonPhaseRequirement: MoonPhaseRequirement): DexEvolutionRequirementDisplay {
|
fun buildMoonPhaseRequirement(moonPhaseRequirement: MoonPhaseRequirement): DexEvolutionRequirementDisplay {
|
||||||
val icon = Items.CLOCK
|
val icon = Items.CLOCK
|
||||||
val moonPhaseComponent = moonPhaseRequirement.moonPhase.displayName().green()
|
val moonPhaseComponent = moonPhaseRequirement.moonPhase.displayName().plainCopy().green()
|
||||||
val tooltip = lang("ui.pokedex.requirement.moon_phase.tooltip", moonPhaseComponent)
|
val tooltip = lang("ui.pokedex.requirement.moon_phase.tooltip", moonPhaseComponent)
|
||||||
|
|
||||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||||
@@ -290,7 +290,7 @@ fun buildMoonPhaseRequirement(moonPhaseRequirement: MoonPhaseRequirement): DexEv
|
|||||||
|
|
||||||
fun buildMoveSetRequirement(moveSetRequirement: MoveSetRequirement): DexEvolutionRequirementDisplay {
|
fun buildMoveSetRequirement(moveSetRequirement: MoveSetRequirement): DexEvolutionRequirementDisplay {
|
||||||
val icon = CobblemonItems.TECHNICAL_MACHINE
|
val icon = CobblemonItems.TECHNICAL_MACHINE
|
||||||
val tooltip = lang("ui.pokedex.requirement.has_move.tooltip", moveSetRequirement.move.displayName.green())
|
val tooltip = lang("ui.pokedex.requirement.has_move.tooltip", moveSetRequirement.move.displayName.plainCopy().green())
|
||||||
|
|
||||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||||
}
|
}
|
||||||
@@ -319,7 +319,7 @@ fun buildMoveTypeRequirement(moveTypeRequirement: MoveTypeRequirement): DexEvolu
|
|||||||
else -> CobblemonItems.NORMAL_GEM
|
else -> CobblemonItems.NORMAL_GEM
|
||||||
}
|
}
|
||||||
|
|
||||||
val tooltip = lang("ui.pokedex.requirement.has_move_type.tooltip", moveTypeRequirement.type.displayName.green())
|
val tooltip = lang("ui.pokedex.requirement.has_move_type.tooltip", moveTypeRequirement.type.displayName.plainCopy().green())
|
||||||
|
|
||||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||||
}
|
}
|
||||||
@@ -437,7 +437,7 @@ fun buildStructureRequirement(structureRequirement: StructureRequirement, negate
|
|||||||
|
|
||||||
fun buildTimeRangeRequirement(timeRangeRequirement: TimeRangeRequirement): DexEvolutionRequirementDisplay? {
|
fun buildTimeRangeRequirement(timeRangeRequirement: TimeRangeRequirement): DexEvolutionRequirementDisplay? {
|
||||||
val icon = Items.CLOCK
|
val icon = Items.CLOCK
|
||||||
val timeRangeComponent = timeRangeRequirement.range.displayName() ?: return null
|
val timeRangeComponent = timeRangeRequirement.range.displayName()?.plainCopy() ?: return null
|
||||||
val tooltip = lang("ui.pokedex.requirement.time_range.tooltip", timeRangeComponent.green())
|
val tooltip = lang("ui.pokedex.requirement.time_range.tooltip", timeRangeComponent.green())
|
||||||
|
|
||||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||||
@@ -445,7 +445,7 @@ fun buildTimeRangeRequirement(timeRangeRequirement: TimeRangeRequirement): DexEv
|
|||||||
|
|
||||||
fun buildUseMoveRequirement(useMoveRequirement: UseMoveRequirement): DexEvolutionRequirementDisplay {
|
fun buildUseMoveRequirement(useMoveRequirement: UseMoveRequirement): DexEvolutionRequirementDisplay {
|
||||||
val icon = CobblemonItems.CHOICE_BAND
|
val icon = CobblemonItems.CHOICE_BAND
|
||||||
val tooltip = lang("ui.pokedex.requirement.use_move.tooltip", useMoveRequirement.move.displayName.green())
|
val tooltip = lang("ui.pokedex.requirement.use_move.tooltip", useMoveRequirement.move.displayName.plainCopy().green())
|
||||||
|
|
||||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -42,8 +42,8 @@ abstract class AreaTypeSpawningCondition<T : AreaSpawnablePosition> : SpawningCo
|
|||||||
override fun copyFrom(other: SpawningCondition<*>, merger: Merger) {
|
override fun copyFrom(other: SpawningCondition<*>, merger: Merger) {
|
||||||
super.copyFrom(other, merger)
|
super.copyFrom(other, merger)
|
||||||
if (other is AreaTypeSpawningCondition) {
|
if (other is AreaTypeSpawningCondition) {
|
||||||
merger.mergeSingle(minHeight, other.minHeight)
|
minHeight = merger.mergeSingle(minHeight, other.minHeight)
|
||||||
merger.mergeSingle(maxHeight, other.maxHeight)
|
maxHeight = merger.mergeSingle(maxHeight, other.maxHeight)
|
||||||
neededNearbyBlocks = merger.merge(neededNearbyBlocks, other.neededNearbyBlocks)?.toMutableList()
|
neededNearbyBlocks = merger.merge(neededNearbyBlocks, other.neededNearbyBlocks)?.toMutableList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ abstract class SubmergedTypeSpawningCondition<T : SubmergedSpawnablePosition> :
|
|||||||
super.copyFrom(other, merger)
|
super.copyFrom(other, merger)
|
||||||
if (other is SubmergedTypeSpawningCondition) {
|
if (other is SubmergedTypeSpawningCondition) {
|
||||||
minDepth = merger.mergeSingle(minDepth, other.minDepth)
|
minDepth = merger.mergeSingle(minDepth, other.minDepth)
|
||||||
maxDepth = merger.mergeSingle(minDepth, other.minDepth)
|
maxDepth = merger.mergeSingle(maxDepth, other.maxDepth)
|
||||||
fluidIsSource = merger.mergeSingle(fluidIsSource, other.fluidIsSource)
|
fluidIsSource = merger.mergeSingle(fluidIsSource, other.fluidIsSource)
|
||||||
fluid = merger.mergeSingle(fluid, other.fluid)
|
fluid = merger.mergeSingle(fluid, other.fluid)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ abstract class SurfaceTypeSpawningCondition<T : SurfaceSpawnablePosition> : Area
|
|||||||
super.copyFrom(other, merger)
|
super.copyFrom(other, merger)
|
||||||
if (other is SurfaceTypeSpawningCondition) {
|
if (other is SurfaceTypeSpawningCondition) {
|
||||||
minDepth = merger.mergeSingle(minDepth, other.minDepth)
|
minDepth = merger.mergeSingle(minDepth, other.minDepth)
|
||||||
maxDepth = merger.mergeSingle(minDepth, other.minDepth)
|
maxDepth = merger.mergeSingle(maxDepth, other.maxDepth)
|
||||||
fluid = merger.mergeSingle(fluid, other.fluid)
|
fluid = merger.mergeSingle(fluid, other.fluid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,7 +198,17 @@ interface Spawner {
|
|||||||
val mid = chunk.getBlockState(startPos)
|
val mid = chunk.getBlockState(startPos)
|
||||||
val above = chunk.getBlockState(abovePos)
|
val above = chunk.getBlockState(abovePos)
|
||||||
|
|
||||||
return above.isPathfindable(PathComputationType.AIR) && mid.isAir
|
// Above must be non-solid
|
||||||
|
if (!above.isPathfindable(PathComputationType.AIR)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Position must be non-air
|
||||||
|
if (mid.isAir) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun constrainArea(area: SpawningZoneInput): SpawningZoneInput? {
|
fun constrainArea(area: SpawningZoneInput): SpawningZoneInput? {
|
||||||
|
|||||||
@@ -140,6 +140,20 @@ object CobblemonItemTags {
|
|||||||
@JvmField val WEARABLE_HAT_ITEMS = create("held/visibility/hat")
|
@JvmField val WEARABLE_HAT_ITEMS = create("held/visibility/hat")
|
||||||
@JvmField val HIDDEN_ITEMS = create("held/visibility/hidden")
|
@JvmField val HIDDEN_ITEMS = create("held/visibility/hidden")
|
||||||
|
|
||||||
|
//Bag Categories Tags
|
||||||
|
@JvmField val BAG_WHITELIST_POKE_BALLS = create("bag/whitelist_poke_balls")
|
||||||
|
@JvmField val BAG_BLACKLIST_POKE_BALLS = create("bag/blacklist_poke_balls")
|
||||||
|
@JvmField val BAG_WHITELIST_CONSUMABLES = create("bag/whitelist_consumables")
|
||||||
|
@JvmField val BAG_BLACKLIST_CONSUMABLES = create("bag/blacklist_consumables")
|
||||||
|
@JvmField val BAG_WHITELIST_BERRIES = create("bag/whitelist_berries")
|
||||||
|
@JvmField val BAG_BLACKLIST_BERRIES = create("bag/blacklist_berries")
|
||||||
|
@JvmField val BAG_WHITELIST_HELD_EVO = create("bag/whitelist_held_evo")
|
||||||
|
@JvmField val BAG_BLACKLIST_HELD_EVO = create("bag/blacklist_held_evo")
|
||||||
|
@JvmField val BAG_WHITELIST_CURRENCY = create("bag/whitelist_currency")
|
||||||
|
@JvmField val BAG_BLACKLIST_CURRENCY = create("bag/blacklist_currency")
|
||||||
|
@JvmField val BAG_WHITELIST_TMS = create("bag/whitelist_tms")
|
||||||
|
@JvmField val BAG_BLACKLIST_TMS = create("bag/blacklist_tms")
|
||||||
|
|
||||||
//Empty Tag
|
//Empty Tag
|
||||||
@JvmField val EMPTY = create("empty")
|
@JvmField val EMPTY = create("empty")
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,9 @@ abstract class ShowdownActionResponse(val type: ShowdownActionResponseType) {
|
|||||||
|
|
||||||
data class MoveActionResponse(var moveName: String, var targetPnx: String? = null, var gimmickID: String? = null): ShowdownActionResponse(ShowdownActionResponseType.MOVE) {
|
data class MoveActionResponse(var moveName: String, var targetPnx: String? = null, var gimmickID: String? = null): ShowdownActionResponse(ShowdownActionResponseType.MOVE) {
|
||||||
override fun isValid(activeBattlePokemon: ActiveBattlePokemon, showdownMoveSet: ShowdownMoveset?, forceSwitch: Boolean): Boolean {
|
override fun isValid(activeBattlePokemon: ActiveBattlePokemon, showdownMoveSet: ShowdownMoveset?, forceSwitch: Boolean): Boolean {
|
||||||
|
// Ensure that the gimmick ID the player is sending is valid
|
||||||
|
gimmickID?.let { if (it !in VALID_GIMMICK_IDS) return false }
|
||||||
|
|
||||||
if (forceSwitch || showdownMoveSet == null) {
|
if (forceSwitch || showdownMoveSet == null) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -168,6 +171,10 @@ data class MoveActionResponse(var moveName: String, var targetPnx: String? = nul
|
|||||||
gimmickID = buffer.readNullable { buffer.readString() }
|
gimmickID = buffer.readNullable { buffer.readString() }
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val VALID_GIMMICK_IDS = ShowdownMoveset.Gimmick.entries.map { it.id }.toSet()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class HealItemActionResponse(var item: String) : ShowdownActionResponse(ShowdownActionResponseType.FORCE_PASS) {
|
data class HealItemActionResponse(var item: String) : ShowdownActionResponse(ShowdownActionResponseType.FORCE_PASS) {
|
||||||
@@ -183,7 +190,8 @@ data class HealItemActionResponse(var item: String) : ShowdownActionResponse(Sho
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun isValid(activeBattlePokemon: ActiveBattlePokemon, showdownMoveSet: ShowdownMoveset?, forceSwitch: Boolean): Boolean {
|
override fun isValid(activeBattlePokemon: ActiveBattlePokemon, showdownMoveSet: ShowdownMoveset?, forceSwitch: Boolean): Boolean {
|
||||||
return !forceSwitch
|
// Previously checked for !forceSwitch, excepts in the case of a forceSwitch, this couldn't legally be sent anyway.
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toShowdownString(activeBattlePokemon: ActiveBattlePokemon, showdownMoveSet: ShowdownMoveset?): String {
|
override fun toShowdownString(activeBattlePokemon: ActiveBattlePokemon, showdownMoveSet: ShowdownMoveset?): String {
|
||||||
|
|||||||
+11
-2
@@ -37,7 +37,6 @@ import com.cobblemon.mod.common.util.asIdentifierDefaultingNamespace
|
|||||||
import com.cobblemon.mod.common.util.battleLang
|
import com.cobblemon.mod.common.util.battleLang
|
||||||
import com.cobblemon.mod.common.util.cobblemonResource
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
import java.util.concurrent.CompletableFuture
|
import java.util.concurrent.CompletableFuture
|
||||||
import net.minecraft.world.entity.LivingEntity
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format: |move|POKEMON|MOVE|TARGET
|
* Format: |move|POKEMON|MOVE|TARGET
|
||||||
@@ -77,7 +76,7 @@ class MoveInstruction(
|
|||||||
val pokemonName = userPokemon.getName()
|
val pokemonName = userPokemon.getName()
|
||||||
ShowdownInterpreter.lastCauser[battle.battleId] = message
|
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
|
// 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
|
||||||
val spreadTargetPokemon = spreadTargets.map { battle.activePokemon.firstOrNull() { poke -> poke.getPNX() == it }?.battlePokemon }
|
val spreadTargetPokemon = spreadTargets.map { battle.activePokemon.firstOrNull { poke -> poke.getPNX() == it }?.battlePokemon }
|
||||||
|
|
||||||
val targetPokemonEntity = targetPokemon?.entity
|
val targetPokemonEntity = targetPokemon?.entity
|
||||||
if (targetPokemonEntity != null) {
|
if (targetPokemonEntity != null) {
|
||||||
@@ -137,10 +136,20 @@ class MoveInstruction(
|
|||||||
|
|
||||||
val subsequentInstructions = instructionSet.findInstructionsCausedBy(this)
|
val subsequentInstructions = instructionSet.findInstructionsCausedBy(this)
|
||||||
val missedTargets = subsequentInstructions.filterIsInstance<MissInstruction>().mapNotNull { it.target }
|
val missedTargets = subsequentInstructions.filterIsInstance<MissInstruction>().mapNotNull { it.target }
|
||||||
|
val faintedTargets = subsequentInstructions.filterIsInstance<FaintInstruction>().map { it.faintingPokemon }
|
||||||
val failed = subsequentInstructions.any { it is FailInstruction }
|
val failed = subsequentInstructions.any { it is FailInstruction }
|
||||||
val failedTargets = subsequentInstructions.filterIsInstance<FailInstruction>().mapNotNull { it.target }
|
val failedTargets = subsequentInstructions.filterIsInstance<FailInstruction>().mapNotNull { it.target }
|
||||||
val hitCountInstruction = subsequentInstructions.filterIsInstance<HitCountInstruction>().firstOrNull()
|
val hitCountInstruction = subsequentInstructions.filterIsInstance<HitCountInstruction>().firstOrNull()
|
||||||
|
|
||||||
|
runtime.environment.query.addFunction("target_fainted") { params ->
|
||||||
|
if (params.params.size == 0) {
|
||||||
|
return@addFunction DoubleValue(faintedTargets.isNotEmpty())
|
||||||
|
} else {
|
||||||
|
val entityUUID = params.getString(0)
|
||||||
|
return@addFunction DoubleValue(faintedTargets.any { it.entity?.stringUUID == entityUUID })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
runtime.environment.query.addFunction("missed") { params ->
|
runtime.environment.query.addFunction("missed") { params ->
|
||||||
if (params.params.size == 0) {
|
if (params.params.size == 0) {
|
||||||
return@addFunction DoubleValue(missedTargets.isNotEmpty())
|
return@addFunction DoubleValue(missedTargets.isNotEmpty())
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import net.minecraft.network.chat.Component
|
|||||||
import net.minecraft.server.level.ServerPlayer
|
import net.minecraft.server.level.ServerPlayer
|
||||||
import net.minecraft.util.RandomSource
|
import net.minecraft.util.RandomSource
|
||||||
import net.minecraft.world.InteractionResult
|
import net.minecraft.world.InteractionResult
|
||||||
|
import net.minecraft.world.entity.EntityType
|
||||||
import net.minecraft.world.entity.LivingEntity
|
import net.minecraft.world.entity.LivingEntity
|
||||||
import net.minecraft.world.entity.player.Player
|
import net.minecraft.world.entity.player.Player
|
||||||
import net.minecraft.world.item.Item
|
import net.minecraft.world.item.Item
|
||||||
@@ -31,13 +32,9 @@ import net.minecraft.world.item.ItemStack
|
|||||||
import net.minecraft.world.item.TooltipFlag
|
import net.minecraft.world.item.TooltipFlag
|
||||||
import net.minecraft.world.item.context.BlockPlaceContext
|
import net.minecraft.world.item.context.BlockPlaceContext
|
||||||
import net.minecraft.world.level.BlockGetter
|
import net.minecraft.world.level.BlockGetter
|
||||||
|
import net.minecraft.world.level.CollisionGetter
|
||||||
import net.minecraft.world.level.Level
|
import net.minecraft.world.level.Level
|
||||||
import net.minecraft.world.level.block.BaseEntityBlock
|
import net.minecraft.world.level.block.*
|
||||||
import net.minecraft.world.level.block.Block
|
|
||||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock
|
|
||||||
import net.minecraft.world.level.block.Mirror
|
|
||||||
import net.minecraft.world.level.block.RenderShape
|
|
||||||
import net.minecraft.world.level.block.Rotation
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity
|
import net.minecraft.world.level.block.entity.BlockEntity
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityTicker
|
import net.minecraft.world.level.block.entity.BlockEntityTicker
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
import net.minecraft.world.level.block.entity.BlockEntityType
|
||||||
@@ -48,9 +45,11 @@ import net.minecraft.world.level.block.state.properties.IntegerProperty
|
|||||||
import net.minecraft.world.level.block.state.properties.Property
|
import net.minecraft.world.level.block.state.properties.Property
|
||||||
import net.minecraft.world.level.pathfinder.PathComputationType
|
import net.minecraft.world.level.pathfinder.PathComputationType
|
||||||
import net.minecraft.world.phys.BlockHitResult
|
import net.minecraft.world.phys.BlockHitResult
|
||||||
|
import net.minecraft.world.phys.Vec3
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext
|
import net.minecraft.world.phys.shapes.CollisionContext
|
||||||
import net.minecraft.world.phys.shapes.Shapes
|
import net.minecraft.world.phys.shapes.Shapes
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape
|
import net.minecraft.world.phys.shapes.VoxelShape
|
||||||
|
import java.util.Optional
|
||||||
|
|
||||||
@Suppress("DEPRECATED", "OVERRIDE_DEPRECATION")
|
@Suppress("DEPRECATED", "OVERRIDE_DEPRECATION")
|
||||||
class HealingMachineBlock(settings: Properties) : BaseEntityBlock(settings) {
|
class HealingMachineBlock(settings: Properties) : BaseEntityBlock(settings) {
|
||||||
@@ -79,6 +78,14 @@ class HealingMachineBlock(settings: Properties) : BaseEntityBlock(settings) {
|
|||||||
const val MAX_CHARGE_LEVEL = 5
|
const val MAX_CHARGE_LEVEL = 5
|
||||||
val CHARGE_LEVEL: IntegerProperty = IntegerProperty.create("charge", 0, MAX_CHARGE_LEVEL + 1)
|
val CHARGE_LEVEL: IntegerProperty = IntegerProperty.create("charge", 0, MAX_CHARGE_LEVEL + 1)
|
||||||
val NATURAL: BooleanProperty = BooleanProperty.create("natural")
|
val NATURAL: BooleanProperty = BooleanProperty.create("natural")
|
||||||
|
|
||||||
|
fun canSetSpawn(level: Level): Boolean {
|
||||||
|
return level.gameRules.getBoolean(CobblemonGameRules.HEALER_SET_SPAWN)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun findStandUpPosition(entityType: EntityType<*>, level: CollisionGetter, pos: BlockPos): Optional<Vec3> {
|
||||||
|
return RespawnAnchorBlock.findStandUpPosition(entityType, level, pos) // Exists if we ever want to make something more custom, but anchor block logic should suffice
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -158,7 +165,12 @@ class HealingMachineBlock(settings: Properties) : BaseEntityBlock(settings) {
|
|||||||
}
|
}
|
||||||
val party = serverPlayerEntity.party()
|
val party = serverPlayerEntity.party()
|
||||||
val pc = serverPlayerEntity.pc()
|
val pc = serverPlayerEntity.pc()
|
||||||
val healPC = player.level().gameRules.getBoolean(CobblemonGameRules.HEALERS_HEAL_PC);
|
val healPC = player.level().gameRules.getBoolean(CobblemonGameRules.HEALERS_HEAL_PC)
|
||||||
|
|
||||||
|
// Do spawnpoint stuff
|
||||||
|
if (canSetSpawn(world)) {
|
||||||
|
player.setRespawnPosition(world.dimension(), blockPos, player.yRot, false, true)
|
||||||
|
}
|
||||||
|
|
||||||
if (party.none() && (!healPC || pc.none())) {
|
if (party.none() && (!healPC || pc.none())) {
|
||||||
player.sendSystemMessage(lang("healingmachine.nopokemon").red(), true)
|
player.sendSystemMessage(lang("healingmachine.nopokemon").red(), true)
|
||||||
@@ -183,6 +195,7 @@ class HealingMachineBlock(settings: Properties) : BaseEntityBlock(settings) {
|
|||||||
player.sendSystemMessage(lang("healingmachine.notenoughcharge", "${((neededCharge/party.count())*100f).toInt()}%").red(), true)
|
player.sendSystemMessage(lang("healingmachine.notenoughcharge", "${((neededCharge/party.count())*100f).toInt()}%").red(), true)
|
||||||
}
|
}
|
||||||
party.forEach { it.tryRecallWithAnimation() }
|
party.forEach { it.tryRecallWithAnimation() }
|
||||||
|
|
||||||
return InteractionResult.CONSUME
|
return InteractionResult.CONSUME
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class OrbBlock(properties: Properties) : SixFaceRotationalBlock(properties) {
|
|||||||
|
|
||||||
val FLOOR_NORTH = Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.375, 0.6875)
|
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 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)
|
val CEILING_NORTH = Shapes.box(0.3125, 0.625, 0.3125, 0.6875, 1.0, 0.6875)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -160,8 +160,8 @@ class TypeGemClusterBlock(
|
|||||||
&& state.getValue(STAGE) == 3) return false
|
&& state.getValue(STAGE) == 3) return false
|
||||||
|
|
||||||
val supportPos = pos.relative(state.getValue(FACING).opposite)
|
val supportPos = pos.relative(state.getValue(FACING).opposite)
|
||||||
val supportBlock = level.getBlockState(supportPos).block
|
val supportState = level.getBlockState(supportPos)
|
||||||
return CobblemonBlocks.typeGemBlocks().containsValue(supportBlock) || (supportBlock == CobblemonBlocks.TYPE_GEM_CORE) // Cannot grow if not on any gem blocks
|
return supportState.`is`(CobblemonBlockTags.TYPE_GEM_BLOCKS) || supportState.block == CobblemonBlocks.TYPE_GEM_CORE // Cannot grow if not on any gem blocks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -51,10 +51,20 @@ class TypeGemCoreBlock(properties: Properties) : Block(properties) {
|
|||||||
ResourceLocation.parse("cobblemon:dragon_gem_block") to CobblemonBlocks.TYPE_GEM_CLUSTER_DRAGON,
|
ResourceLocation.parse("cobblemon:dragon_gem_block") to CobblemonBlocks.TYPE_GEM_CLUSTER_DRAGON,
|
||||||
ResourceLocation.parse("cobblemon:dark_gem_block") to CobblemonBlocks.TYPE_GEM_CLUSTER_DARK,
|
ResourceLocation.parse("cobblemon:dark_gem_block") to CobblemonBlocks.TYPE_GEM_CLUSTER_DARK,
|
||||||
ResourceLocation.parse("cobblemon:steel_gem_block") to CobblemonBlocks.TYPE_GEM_CLUSTER_STEEL,
|
ResourceLocation.parse("cobblemon:steel_gem_block") to CobblemonBlocks.TYPE_GEM_CLUSTER_STEEL,
|
||||||
ResourceLocation.parse("cobblemon:fairy_gem_block") to CobblemonBlocks.TYPE_GEM_CLUSTER_FAIRY
|
ResourceLocation.parse("cobblemon:fairy_gem_block") to CobblemonBlocks.TYPE_GEM_CLUSTER_FAIRY,
|
||||||
|
ResourceLocation.parse("minecraft:amethyst_block") to Blocks.SMALL_AMETHYST_BUD
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val AMETHYST_STAGES = listOf(
|
||||||
|
Blocks.SMALL_AMETHYST_BUD,
|
||||||
|
Blocks.MEDIUM_AMETHYST_BUD,
|
||||||
|
Blocks.LARGE_AMETHYST_BUD,
|
||||||
|
Blocks.AMETHYST_CLUSTER
|
||||||
|
)
|
||||||
|
|
||||||
|
private fun isAmethystStage(block: Block) = block in AMETHYST_STAGES
|
||||||
|
|
||||||
fun getConnectedGemBlocks(level: BlockGetter, pos: BlockPos): List<Pair<BlockState, BlockPos>> {
|
fun getConnectedGemBlocks(level: BlockGetter, pos: BlockPos): List<Pair<BlockState, BlockPos>> {
|
||||||
val connectedGems = mutableListOf<Pair<BlockState, BlockPos>>()
|
val connectedGems = mutableListOf<Pair<BlockState, BlockPos>>()
|
||||||
val visited = mutableSetOf<BlockPos>()
|
val visited = mutableSetOf<BlockPos>()
|
||||||
@@ -85,12 +95,16 @@ class TypeGemCoreBlock(properties: Properties) : Block(properties) {
|
|||||||
Direction.entries.forEach {
|
Direction.entries.forEach {
|
||||||
if (random.nextFloat() < Cobblemon.config.typeGemGrowthChance) {
|
if (random.nextFloat() < Cobblemon.config.typeGemGrowthChance) {
|
||||||
val faceState = level.getBlockState(pos.relative(it))
|
val faceState = level.getBlockState(pos.relative(it))
|
||||||
val randomGrowthType = decideClusterGrowthType(level, pos)
|
var newState = BLOCK_TO_CLUSTER[BuiltInRegistries.BLOCK.getKey(state.block)]?.defaultBlockState()
|
||||||
val newState = BLOCK_TO_CLUSTER[BuiltInRegistries.BLOCK.getKey(state.block)]?.defaultBlockState()
|
|
||||||
?.setValue(DirectionalBlock.FACING, it)
|
?.setValue(DirectionalBlock.FACING, it)
|
||||||
?.setValue(GROWTH_TYPE, randomGrowthType)
|
|
||||||
?: return
|
?: return
|
||||||
|
|
||||||
|
if (newState.hasProperty(GROWTH_TYPE)) {
|
||||||
|
newState = newState.setValue(GROWTH_TYPE, decideClusterGrowthType(level, pos))
|
||||||
|
} else if (getConnectedGemBlocks(level, pos).size > Cobblemon.config.typeGemMaxConnected) {
|
||||||
|
return@forEach
|
||||||
|
}
|
||||||
|
|
||||||
if (faceState.`is`(Blocks.AIR)) {
|
if (faceState.`is`(Blocks.AIR)) {
|
||||||
level.setBlock(pos.relative(it), newState, 3)
|
level.setBlock(pos.relative(it), newState, 3)
|
||||||
}
|
}
|
||||||
@@ -132,7 +146,7 @@ class TypeGemCoreBlock(properties: Properties) : Block(properties) {
|
|||||||
if (!visited.add(clusterPos)) continue
|
if (!visited.add(clusterPos)) continue
|
||||||
|
|
||||||
val clusterState = level.getBlockState(clusterPos)
|
val clusterState = level.getBlockState(clusterPos)
|
||||||
if (clusterState.block == expectedCluster) {
|
if (clusterState.block == expectedCluster && clusterState.hasProperty(GROWTH_TYPE)) {
|
||||||
clusters += clusterState to clusterPos
|
clusters += clusterState to clusterPos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,13 +192,41 @@ class TypeGemCoreBlock(properties: Properties) : Block(properties) {
|
|||||||
Direction.entries.forEach { direction ->
|
Direction.entries.forEach { direction ->
|
||||||
val relativePos = pos.relative(direction)
|
val relativePos = pos.relative(direction)
|
||||||
val relativeState = level.getBlockState(relativePos)
|
val relativeState = level.getBlockState(relativePos)
|
||||||
val clusterBlock = relativeState.block as? TypeGemClusterBlock ?: return@forEach
|
val matchesFace = relativeState.hasProperty(DirectionalBlock.FACING)
|
||||||
|
&& relativeState.getValue(DirectionalBlock.FACING) == direction
|
||||||
if ((relativeState.getValue(DirectionalBlock.FACING) == direction &&
|
if (!(forceGrow || (matchesFace && random.nextFloat() < Cobblemon.config.typeGemGrowthChance))) {
|
||||||
random.nextFloat() < Cobblemon.config.typeGemGrowthChance) || forceGrow
|
return@forEach
|
||||||
) {
|
|
||||||
clusterBlock.advanceGrowth(relativeState, level, relativePos, random)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val block = relativeState.block
|
||||||
|
if (block is TypeGemClusterBlock) {
|
||||||
|
block.advanceGrowth(relativeState, level, relativePos, random)
|
||||||
|
} else if (isAmethystStage(block)) {
|
||||||
|
advanceAmethyst(relativeState, level, relativePos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun advanceAmethyst(state: BlockState, level: LevelAccessor, pos: BlockPos) {
|
||||||
|
val facing = state.getValue(DirectionalBlock.FACING)
|
||||||
|
val supportState = level.getBlockState(pos.relative(facing.opposite))
|
||||||
|
if (!supportState.`is`(CobblemonBlockTags.TYPE_GEM_BLOCKS) && supportState.block != CobblemonBlocks.TYPE_GEM_CORE) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.block != Blocks.AMETHYST_CLUSTER) {
|
||||||
|
val nextStage = AMETHYST_STAGES[AMETHYST_STAGES.indexOf(state.block) + 1]
|
||||||
|
level.setBlock(pos, nextStage.defaultBlockState().setValue(DirectionalBlock.FACING, facing), 3)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fully grown clusters mature into amethyst blocks unless boxed in, mirroring stunted type gems
|
||||||
|
val boxedIn = Direction.entries.any { direction ->
|
||||||
|
direction != facing.opposite
|
||||||
|
&& level.getBlockState(pos.relative(direction)).`is`(CobblemonBlockTags.TYPE_GEM_BLOCKS)
|
||||||
|
}
|
||||||
|
if (!boxedIn) {
|
||||||
|
level.setBlock(pos, Blocks.AMETHYST_BLOCK.defaultBlockState(), 3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,13 @@
|
|||||||
package com.cobblemon.mod.common.client
|
package com.cobblemon.mod.common.client
|
||||||
|
|
||||||
import com.cobblemon.mod.common.BakingOverride
|
import com.cobblemon.mod.common.BakingOverride
|
||||||
|
import com.cobblemon.mod.common.CobblemonItems
|
||||||
|
import com.cobblemon.mod.common.item.bag.CobblemonBagItem
|
||||||
import com.cobblemon.mod.common.util.cobblemonModel
|
import com.cobblemon.mod.common.util.cobblemonModel
|
||||||
import com.cobblemon.mod.common.util.cobblemonResource
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
import net.minecraft.client.resources.model.ModelResourceLocation
|
import net.minecraft.client.resources.model.ModelResourceLocation
|
||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.resources.ResourceLocation
|
||||||
|
import net.minecraft.world.item.Item
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The purpose of this class is to hold models that we want baked, but aren't associated with
|
* The purpose of this class is to hold models that we want baked, but aren't associated with
|
||||||
@@ -103,9 +106,33 @@ object CobblemonBakingOverrides {
|
|||||||
cobblemonModel("surprise_mulch", "none")
|
cobblemonModel("surprise_mulch", "none")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Bag
|
||||||
|
val bagModels = mutableMapOf<CobblemonBagItem, BakingOverride>()
|
||||||
|
val TRAINER_PACK = registerBagOverride(
|
||||||
|
CobblemonItems.TRAINER_PACK,
|
||||||
|
cobblemonResource("item/bag/trainer_pack"),
|
||||||
|
cobblemonModel("trainer_pack", "none")
|
||||||
|
)
|
||||||
|
val TRAINER_BAG = registerBagOverride(
|
||||||
|
CobblemonItems.TRAINER_BAG,
|
||||||
|
cobblemonResource("item/bag/trainer_bag"),
|
||||||
|
cobblemonModel("trainer_bag", "none")
|
||||||
|
)
|
||||||
|
/*val BAG_PENNY = registerBagOverride(
|
||||||
|
CobblemonItems.TRAINER_PACK,
|
||||||
|
cobblemonResource("item/bag/bag_penny"),
|
||||||
|
cobblemonModel("bag_penny", "penny")
|
||||||
|
)*/
|
||||||
|
|
||||||
fun registerOverride(modelLocation: ResourceLocation, modelIdentifier: ModelResourceLocation): BakingOverride {
|
fun registerOverride(modelLocation: ResourceLocation, modelIdentifier: ModelResourceLocation): BakingOverride {
|
||||||
val result = BakingOverride(modelLocation, modelIdentifier)
|
val result = BakingOverride(modelLocation, modelIdentifier)
|
||||||
models.add(result)
|
models.add(result)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun registerBagOverride(associatedItem: CobblemonBagItem, modelLocation: ResourceLocation, modelIdentifier: ModelResourceLocation): BakingOverride {
|
||||||
|
val result = registerOverride(modelLocation, modelIdentifier)
|
||||||
|
bagModels[associatedItem] = result
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -27,6 +27,7 @@ import com.cobblemon.mod.common.client.battle.ClientBattle
|
|||||||
import com.cobblemon.mod.common.client.gui.PartyOverlay
|
import com.cobblemon.mod.common.client.gui.PartyOverlay
|
||||||
import com.cobblemon.mod.common.client.gui.PartyOverlayDataControl
|
import com.cobblemon.mod.common.client.gui.PartyOverlayDataControl
|
||||||
import com.cobblemon.mod.common.client.gui.RideControlsOverlay
|
import com.cobblemon.mod.common.client.gui.RideControlsOverlay
|
||||||
|
import com.cobblemon.mod.common.client.gui.bag.CobblemonBagScreen
|
||||||
import com.cobblemon.mod.common.client.gui.battle.BattleOverlay
|
import com.cobblemon.mod.common.client.gui.battle.BattleOverlay
|
||||||
import com.cobblemon.mod.common.client.gui.cookingpot.CookingPotScreen
|
import com.cobblemon.mod.common.client.gui.cookingpot.CookingPotScreen
|
||||||
import com.cobblemon.mod.common.client.gui.party.PartyTutorialToasts
|
import com.cobblemon.mod.common.client.gui.party.PartyTutorialToasts
|
||||||
@@ -46,6 +47,7 @@ import com.cobblemon.mod.common.client.render.generic.GenericBedrockRenderer
|
|||||||
import com.cobblemon.mod.common.client.render.item.CobblemonBuiltinItemRendererRegistry
|
import com.cobblemon.mod.common.client.render.item.CobblemonBuiltinItemRendererRegistry
|
||||||
import com.cobblemon.mod.common.client.render.item.PokemonItemRenderer
|
import com.cobblemon.mod.common.client.render.item.PokemonItemRenderer
|
||||||
import com.cobblemon.mod.common.client.render.layer.PlayerRecallBallRenderer
|
import com.cobblemon.mod.common.client.render.layer.PlayerRecallBallRenderer
|
||||||
|
import com.cobblemon.mod.common.client.render.layer.CobblemonBagRenderer
|
||||||
import com.cobblemon.mod.common.client.render.layer.PokemonOnShoulderRenderer
|
import com.cobblemon.mod.common.client.render.layer.PokemonOnShoulderRenderer
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.bedrock.animation.BedrockAnimationRepository
|
import com.cobblemon.mod.common.client.render.models.blockbench.bedrock.animation.BedrockAnimationRepository
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.BerryModelRepository
|
import com.cobblemon.mod.common.client.render.models.blockbench.repository.BerryModelRepository
|
||||||
@@ -391,7 +393,7 @@ object CobblemonClient {
|
|||||||
CobblemonBlocks.X_SP_ATK,
|
CobblemonBlocks.X_SP_ATK,
|
||||||
CobblemonBlocks.X_SP_DEF,
|
CobblemonBlocks.X_SP_DEF,
|
||||||
CobblemonBlocks.X_SPEED,
|
CobblemonBlocks.X_SPEED,
|
||||||
CobblemonBlocks.TM_MACHINE,
|
CobblemonBlocks.TM_MACHINE,
|
||||||
|
|
||||||
CobblemonBlocks.GALARICA_CUFF,
|
CobblemonBlocks.GALARICA_CUFF,
|
||||||
CobblemonBlocks.GALARICA_WREATH,
|
CobblemonBlocks.GALARICA_WREATH,
|
||||||
@@ -419,7 +421,7 @@ object CobblemonClient {
|
|||||||
CobblemonBlocks.MOOMOO_MILK,
|
CobblemonBlocks.MOOMOO_MILK,
|
||||||
CobblemonBlocks.MEDICINAL_BREW,
|
CobblemonBlocks.MEDICINAL_BREW,
|
||||||
CobblemonBlocks.TERRAIN_EXTENDER,
|
CobblemonBlocks.TERRAIN_EXTENDER,
|
||||||
|
|
||||||
CobblemonBlocks.RED_MINT_LEAF_LITTER,
|
CobblemonBlocks.RED_MINT_LEAF_LITTER,
|
||||||
CobblemonBlocks.POTTED_RED_MINT,
|
CobblemonBlocks.POTTED_RED_MINT,
|
||||||
CobblemonBlocks.BLUE_MINT_LEAF_LITTER,
|
CobblemonBlocks.BLUE_MINT_LEAF_LITTER,
|
||||||
@@ -539,14 +541,17 @@ object CobblemonClient {
|
|||||||
skinMap?.get(PlayerSkin.Model.WIDE) as LivingEntityRenderer<Player, PlayerModel<Player>>
|
skinMap?.get(PlayerSkin.Model.WIDE) as LivingEntityRenderer<Player, PlayerModel<Player>>
|
||||||
renderer?.addLayer(PokemonOnShoulderRenderer(renderer))
|
renderer?.addLayer(PokemonOnShoulderRenderer(renderer))
|
||||||
renderer?.addLayer(PlayerRecallBallRenderer(renderer))
|
renderer?.addLayer(PlayerRecallBallRenderer(renderer))
|
||||||
|
renderer?.addLayer(CobblemonBagRenderer(renderer))
|
||||||
renderer = skinMap[PlayerSkin.Model.SLIM] as LivingEntityRenderer<Player, PlayerModel<Player>>?
|
renderer = skinMap[PlayerSkin.Model.SLIM] as LivingEntityRenderer<Player, PlayerModel<Player>>?
|
||||||
renderer?.addLayer(PokemonOnShoulderRenderer(renderer))
|
renderer?.addLayer(PokemonOnShoulderRenderer(renderer))
|
||||||
renderer?.addLayer(PlayerRecallBallRenderer(renderer))
|
renderer?.addLayer(PlayerRecallBallRenderer(renderer))
|
||||||
|
renderer?.addLayer(CobblemonBagRenderer(renderer))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun registerMenuScreens() {
|
private fun registerMenuScreens() {
|
||||||
MenuScreens.register(CobblemonMenuType.COOKING_POT, ::CookingPotScreen)
|
MenuScreens.register(CobblemonMenuType.COOKING_POT, ::CookingPotScreen)
|
||||||
MenuScreens.register(CobblemonMenuType.TM_MACHINE, ::TMMachineScreen)
|
MenuScreens.register(CobblemonMenuType.TM_MACHINE, ::TMMachineScreen)
|
||||||
|
MenuScreens.register(CobblemonMenuType.COBBLEMON_BAG, ::CobblemonBagScreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun registerBlockEntityRenderers() {
|
private fun registerBlockEntityRenderers() {
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ class PartyOverlay : Gui(Minecraft.getInstance()) {
|
|||||||
if (HidePartyBinding.shouldHide) {
|
if (HidePartyBinding.shouldHide) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -558,4 +559,4 @@ class PartyOverlay : Gui(Minecraft.getInstance()) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* 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.bag
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.api.bag.BagCategories
|
||||||
|
import com.cobblemon.mod.common.api.gui.blitk
|
||||||
|
import com.cobblemon.mod.common.client.CobblemonResources
|
||||||
|
import com.cobblemon.mod.common.client.gui.CobblemonRenderable
|
||||||
|
import com.cobblemon.mod.common.client.render.getDepletableRedGreen
|
||||||
|
import com.cobblemon.mod.common.util.asTranslated
|
||||||
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
|
import com.cobblemon.mod.common.util.lang
|
||||||
|
import net.minecraft.client.Minecraft
|
||||||
|
import net.minecraft.client.gui.GuiGraphics
|
||||||
|
import net.minecraft.client.gui.components.Button
|
||||||
|
import net.minecraft.client.sounds.SoundManager
|
||||||
|
import net.minecraft.network.chat.Component
|
||||||
|
import net.minecraft.resources.ResourceLocation
|
||||||
|
|
||||||
|
class BagCategoryButton(
|
||||||
|
x: Int,
|
||||||
|
y: Int,
|
||||||
|
val parent: CobblemonBagScreen,
|
||||||
|
val category: Int,
|
||||||
|
val action: OnPress
|
||||||
|
): Button(x, y, WIDTH, HEIGHT, Component.empty(), action, DEFAULT_NARRATION), CobblemonRenderable {
|
||||||
|
companion object {
|
||||||
|
private const val WIDTH = 32
|
||||||
|
private const val HEIGHT = 31
|
||||||
|
|
||||||
|
private val CATEGORY_SLOT = cobblemonResource("textures/gui/bag/bag_tab.png")
|
||||||
|
private val VOLUME_BAR = cobblemonResource("textures/gui/bag/bag_tab_volume_bar.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun renderWidget(context: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) {
|
||||||
|
val orderedCategories = BagCategories.getOrderedCategoriesList()
|
||||||
|
|
||||||
|
blitk(
|
||||||
|
matrixStack = context.pose(),
|
||||||
|
texture = CATEGORY_SLOT,
|
||||||
|
x = x, y = y,
|
||||||
|
width = WIDTH, height = HEIGHT,
|
||||||
|
textureHeight = 64,
|
||||||
|
vOffset = if (parent.menu.currentlySelectedCategory == category) 32 else 0
|
||||||
|
)
|
||||||
|
|
||||||
|
blitk(
|
||||||
|
matrixStack = context.pose(),
|
||||||
|
texture = if (category == -1) ResourceLocation("minecraft", "textures/item/bundle.png") else orderedCategories[category].icon,
|
||||||
|
x = x + 8, y = y + 9,
|
||||||
|
width = 16, height = 16
|
||||||
|
)
|
||||||
|
|
||||||
|
//The Bar
|
||||||
|
if (category != -1) {
|
||||||
|
blitk(
|
||||||
|
matrixStack = context.pose(),
|
||||||
|
texture = VOLUME_BAR,
|
||||||
|
x = x + 8, y = y + 25,
|
||||||
|
width = 16, height = 3
|
||||||
|
)
|
||||||
|
|
||||||
|
val itemRatio = (parent.menu.categoryItemCounts[category].toFloat() / orderedCategories[category].maxCount).coerceIn(0F, 1F)
|
||||||
|
val barWidth = itemRatio * 14
|
||||||
|
val (red, green) = getDepletableRedGreen(1 - itemRatio)
|
||||||
|
|
||||||
|
blitk(
|
||||||
|
matrixStack = context.pose(),
|
||||||
|
texture = CobblemonResources.WHITE,
|
||||||
|
x = x + 9, y = y + 26,
|
||||||
|
width = barWidth, height = 1,
|
||||||
|
red = red * 0.8F, green = green * 0.8F, blue = 0.27F
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHovered) {
|
||||||
|
context.renderTooltip(Minecraft.getInstance().font, if (category == -1) lang("bag_categories.all_items") else orderedCategories[category].getName(), mouseX, mouseY)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun playDownSound(handler: SoundManager) {}
|
||||||
|
}
|
||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* 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.bag
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.CobblemonSounds
|
||||||
|
import com.cobblemon.mod.common.api.gui.blitk
|
||||||
|
import com.cobblemon.mod.common.client.gui.CobblemonRenderable
|
||||||
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
|
import net.minecraft.client.gui.GuiGraphics
|
||||||
|
import net.minecraft.client.gui.components.Button
|
||||||
|
import net.minecraft.client.sounds.SoundManager
|
||||||
|
import net.minecraft.network.chat.Component
|
||||||
|
|
||||||
|
class BagCategoryPageButton(
|
||||||
|
x: Int,
|
||||||
|
y: Int,
|
||||||
|
val parent: CobblemonBagScreen,
|
||||||
|
val leftButton: Boolean,
|
||||||
|
val action: OnPress
|
||||||
|
): Button(x, y, WIDTH, HEIGHT, Component.empty(), action, DEFAULT_NARRATION), CobblemonRenderable {
|
||||||
|
companion object {
|
||||||
|
private const val WIDTH = 12
|
||||||
|
private const val HEIGHT = 10
|
||||||
|
|
||||||
|
private val LEFT_BUTTON = cobblemonResource("textures/gui/bag/button_left.png")
|
||||||
|
private val RIGHT_BUTTON = cobblemonResource("textures/gui/bag/button_right.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
var enabled = true
|
||||||
|
|
||||||
|
override fun renderWidget(context: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) {
|
||||||
|
blitk(
|
||||||
|
matrixStack = context.pose(),
|
||||||
|
texture = if (leftButton) LEFT_BUTTON else RIGHT_BUTTON,
|
||||||
|
x = x / 0.5F, y = y / 0.5F,
|
||||||
|
width = WIDTH * 2, height = HEIGHT * 2,
|
||||||
|
textureHeight = 40,
|
||||||
|
vOffset = if (enabled) 20 else 0,
|
||||||
|
scale = 0.5f
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun playDownSound(handler: SoundManager) {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* 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.bag
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.api.bag.BagCategories
|
||||||
|
import com.cobblemon.mod.common.api.gui.blitk
|
||||||
|
import com.cobblemon.mod.common.client.gui.CobblemonRenderable
|
||||||
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
|
import com.cobblemon.mod.common.util.lang
|
||||||
|
import net.minecraft.client.Minecraft
|
||||||
|
import net.minecraft.client.gui.GuiGraphics
|
||||||
|
import net.minecraft.client.gui.components.Button
|
||||||
|
import net.minecraft.client.sounds.SoundManager
|
||||||
|
import net.minecraft.network.chat.Component
|
||||||
|
|
||||||
|
class BagCycleSortButton(
|
||||||
|
x: Int,
|
||||||
|
y: Int,
|
||||||
|
val parent: CobblemonBagScreen,
|
||||||
|
val action: OnPress
|
||||||
|
): Button(x, y, WIDTH, HEIGHT, Component.empty(), action, DEFAULT_NARRATION), CobblemonRenderable {
|
||||||
|
companion object {
|
||||||
|
private const val WIDTH = 12
|
||||||
|
private const val HEIGHT = 10
|
||||||
|
|
||||||
|
private val LEFT_BUTTON = cobblemonResource("textures/gui/bag/button_left.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
var enabled = false
|
||||||
|
|
||||||
|
override fun renderWidget(context: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) {
|
||||||
|
if (!enabled) return
|
||||||
|
blitk(
|
||||||
|
matrixStack = context.pose(),
|
||||||
|
texture = LEFT_BUTTON,
|
||||||
|
x = x / 0.5F, y = y / 0.5F,
|
||||||
|
width = WIDTH * 2, height = HEIGHT * 2,
|
||||||
|
textureHeight = 40,
|
||||||
|
vOffset = if (enabled) 20 else 0,
|
||||||
|
scale = 0.5f
|
||||||
|
)
|
||||||
|
|
||||||
|
if (isHovered) {
|
||||||
|
val currentCategory = BagCategories.getOrderedCategoriesList().getOrNull(parent.menu.currentlySelectedCategory)
|
||||||
|
val currentSort = currentCategory?.getAllSortMethods()[parent.menu.currentlySelectedSort]
|
||||||
|
currentSort?.let {
|
||||||
|
val lang = lang("bag.sort.${it.path}")
|
||||||
|
context.renderTooltip(Minecraft.getInstance().font, lang, mouseX, mouseY)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun playDownSound(handler: SoundManager) {}
|
||||||
|
}
|
||||||
+58
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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.bag
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.api.gui.blitk
|
||||||
|
import com.cobblemon.mod.common.client.gui.CobblemonRenderable
|
||||||
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
|
import com.cobblemon.mod.common.util.lang
|
||||||
|
import net.minecraft.client.Minecraft
|
||||||
|
import net.minecraft.client.gui.GuiGraphics
|
||||||
|
import net.minecraft.client.gui.components.Button
|
||||||
|
import net.minecraft.client.sounds.SoundManager
|
||||||
|
import net.minecraft.network.chat.Component
|
||||||
|
|
||||||
|
class BagSortAscendingButton(
|
||||||
|
x: Int,
|
||||||
|
y: Int,
|
||||||
|
val parent: CobblemonBagScreen,
|
||||||
|
val action: OnPress
|
||||||
|
): Button(x, y, WIDTH, HEIGHT, Component.empty(), action, DEFAULT_NARRATION), CobblemonRenderable {
|
||||||
|
companion object {
|
||||||
|
private const val WIDTH = 12
|
||||||
|
private const val HEIGHT = 10
|
||||||
|
|
||||||
|
private val LEFT_BUTTON = cobblemonResource("textures/gui/bag/button_left.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
var enabled = false
|
||||||
|
|
||||||
|
override fun renderWidget(context: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) {
|
||||||
|
if (!enabled) return
|
||||||
|
blitk(
|
||||||
|
matrixStack = context.pose(),
|
||||||
|
texture = LEFT_BUTTON,
|
||||||
|
x = x / 0.5F, y = y / 0.5F,
|
||||||
|
width = WIDTH * 2, height = HEIGHT * 2,
|
||||||
|
textureHeight = 40,
|
||||||
|
vOffset = if (enabled) 20 else 0,
|
||||||
|
scale = 0.5f
|
||||||
|
)
|
||||||
|
|
||||||
|
if (isHovered) {
|
||||||
|
if (parent.menu.ascending) {
|
||||||
|
context.renderTooltip(Minecraft.getInstance().font, lang("bag.sort.ascending"), mouseX, mouseY)
|
||||||
|
} else {
|
||||||
|
context.renderTooltip(Minecraft.getInstance().font, lang("bag.sort.descending"), mouseX, mouseY)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun playDownSound(handler: SoundManager) {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,461 @@
|
|||||||
|
/*
|
||||||
|
* 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.bag
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.CobblemonNetwork.sendToServer
|
||||||
|
import com.cobblemon.mod.common.CobblemonSounds
|
||||||
|
import com.cobblemon.mod.common.api.bag.BagCategories
|
||||||
|
import com.cobblemon.mod.common.api.gui.blitk
|
||||||
|
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.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.item.bag.CobblemonBagMenu
|
||||||
|
import com.cobblemon.mod.common.item.battle.BagItem
|
||||||
|
import com.cobblemon.mod.common.net.messages.client.bag.UpdateBagMenuDataPacket
|
||||||
|
import com.cobblemon.mod.common.net.messages.client.bag.UseItemOnPokemonFromBagPacket
|
||||||
|
import com.cobblemon.mod.common.pokemon.Gender
|
||||||
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
|
import com.cobblemon.mod.common.util.lang
|
||||||
|
import com.cobblemon.mod.common.util.math.fromEulerXYZDegrees
|
||||||
|
import juuxel.adorn.util.Colors
|
||||||
|
import net.fabricmc.api.EnvType
|
||||||
|
import net.fabricmc.api.Environment
|
||||||
|
import net.minecraft.client.Minecraft
|
||||||
|
import net.minecraft.client.gui.GuiGraphics
|
||||||
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
|
||||||
|
import net.minecraft.client.resources.sounds.SimpleSoundInstance
|
||||||
|
import net.minecraft.network.chat.Component
|
||||||
|
import net.minecraft.sounds.SoundEvent
|
||||||
|
import net.minecraft.world.entity.player.Inventory
|
||||||
|
import net.minecraft.world.inventory.ClickType
|
||||||
|
import net.minecraft.world.inventory.Slot
|
||||||
|
import org.joml.Quaternionf
|
||||||
|
import org.joml.Vector3f
|
||||||
|
import kotlin.math.min
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
class CobblemonBagScreen(
|
||||||
|
menu: CobblemonBagMenu,
|
||||||
|
playerInventory: Inventory,
|
||||||
|
title: Component
|
||||||
|
): AbstractContainerScreen<CobblemonBagMenu>(
|
||||||
|
menu,
|
||||||
|
playerInventory,
|
||||||
|
Component.translatable("cobblemon.container.bag")
|
||||||
|
) {
|
||||||
|
companion object {
|
||||||
|
private const val BACKGROUND_HEIGHT = 197
|
||||||
|
private const val BACKGROUND_WIDTH = 184
|
||||||
|
|
||||||
|
private val BACKGROUND = cobblemonResource("textures/gui/bag/bag_base.png")
|
||||||
|
private val SCROLL_TRACK = cobblemonResource("textures/gui/bag/scrollbar_track.png")
|
||||||
|
private val SCROLL_SLIDE = cobblemonResource("textures/gui/bag/scrollbar_slide.png")
|
||||||
|
private val PARTY_SLOT_BASE = cobblemonResource("textures/gui/bag/party_slot_base.png")
|
||||||
|
private val PARTY_SLOT_COLLAPSED = cobblemonResource("textures/gui/bag/party_slot_collapsed.png")
|
||||||
|
private val PARTY_SLOT = cobblemonResource("textures/gui/bag/party_slot.png")
|
||||||
|
private val PARTY_SLOT_FAINTED = cobblemonResource("textures/gui/bag/party_slot_fainted.png")
|
||||||
|
private val GENDER_ICON_MALE = cobblemonResource("textures/gui/party/party_gender_male.png")
|
||||||
|
private val GENDER_ICON_FEMALE = cobblemonResource("textures/gui/party/party_gender_female.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
val categoriesWidgets = mutableListOf<BagCategoryButton>()
|
||||||
|
lateinit var allItemsCategoryWidget: BagCategoryButton
|
||||||
|
lateinit var leftCategoryPageButton: BagCategoryPageButton
|
||||||
|
lateinit var rightCategoryPageButton: BagCategoryPageButton
|
||||||
|
lateinit var cycleCategorySortButton: BagCycleSortButton
|
||||||
|
lateinit var ascendingButton: BagSortAscendingButton
|
||||||
|
var currentCategoryPage = 0
|
||||||
|
var lastCategory = menu.currentlySelectedCategory
|
||||||
|
var lastScroll = menu.scroll
|
||||||
|
var scrolling = false
|
||||||
|
|
||||||
|
init {
|
||||||
|
this.imageWidth = BACKGROUND_WIDTH + 69
|
||||||
|
this.imageHeight = BACKGROUND_HEIGHT + 27
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
super.init()
|
||||||
|
this.leftPos -= 34
|
||||||
|
|
||||||
|
for (i in 0..3) {
|
||||||
|
if (i < BagCategories.getOrderedCategoriesList().size) {
|
||||||
|
categoriesWidgets.add(
|
||||||
|
BagCategoryButton(leftPos + 76 + i * 33, topPos, this, i) {
|
||||||
|
if (menu.currentlySelectedCategory != i) {
|
||||||
|
menu.changeCategory(i)
|
||||||
|
updateSortButtonState(false)
|
||||||
|
playSound(CobblemonSounds.ITEM_BAG_CLICK)
|
||||||
|
}
|
||||||
|
}.also { addRenderableWidget(it) }
|
||||||
|
)
|
||||||
|
} else break
|
||||||
|
}
|
||||||
|
|
||||||
|
allItemsCategoryWidget = BagCategoryButton(leftPos + 214, topPos, this, -1) {
|
||||||
|
if (menu.currentlySelectedCategory != -1) {
|
||||||
|
menu.changeCategory(-1)
|
||||||
|
updateSortButtonState(false)
|
||||||
|
playSound(CobblemonSounds.ITEM_BAG_CLICK)
|
||||||
|
}
|
||||||
|
}.also { addRenderableWidget(it) }
|
||||||
|
|
||||||
|
leftCategoryPageButton = BagCategoryPageButton(leftPos + 218, topPos + 32, this, true) {
|
||||||
|
if (leftCategoryPageButton.enabled) {
|
||||||
|
cycleCategoryPage(false)
|
||||||
|
playSound(CobblemonSounds.ITEM_BAG_CLICK)
|
||||||
|
}
|
||||||
|
}.also { addRenderableWidget(it) }
|
||||||
|
leftCategoryPageButton.enabled = false
|
||||||
|
rightCategoryPageButton = BagCategoryPageButton(leftPos + 229, topPos + 32, this, false) {
|
||||||
|
if (rightCategoryPageButton.enabled) {
|
||||||
|
cycleCategoryPage(true)
|
||||||
|
playSound(CobblemonSounds.ITEM_BAG_CLICK)
|
||||||
|
}
|
||||||
|
}.also { addRenderableWidget(it) }
|
||||||
|
cycleCategorySortButton = BagCycleSortButton(
|
||||||
|
leftPos + 200, topPos + 32, this
|
||||||
|
) {
|
||||||
|
updateSortButtonState(true)
|
||||||
|
}.also { addRenderableWidget(it) }
|
||||||
|
ascendingButton = BagSortAscendingButton(
|
||||||
|
leftPos + 180, topPos + 32, this
|
||||||
|
) {
|
||||||
|
if (ascendingButton.enabled) {
|
||||||
|
playSound(CobblemonSounds.ITEM_BAG_CLICK)
|
||||||
|
menu.ascending = !menu.ascending
|
||||||
|
menu.setupSlotsBasedOnContent()
|
||||||
|
}
|
||||||
|
}.also { addRenderableWidget(it) }
|
||||||
|
|
||||||
|
playSound(CobblemonSounds.ITEM_BAG_OPEN)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun renderBg(context: GuiGraphics, partialTick: Float, mouseX: Int, mouseY: Int) {}
|
||||||
|
override fun renderBackground(guiGraphics: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) {}
|
||||||
|
|
||||||
|
override fun renderLabels(guiGraphics: GuiGraphics, mouseX: Int, mouseY: Int) {}
|
||||||
|
|
||||||
|
override fun render(context: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) {
|
||||||
|
renderTransparentBackground(context)
|
||||||
|
|
||||||
|
val matrices = context.pose()
|
||||||
|
|
||||||
|
// Background
|
||||||
|
blitk(
|
||||||
|
matrixStack = matrices,
|
||||||
|
texture = BACKGROUND,
|
||||||
|
x = leftPos + 69, y = topPos + 27,
|
||||||
|
width = BACKGROUND_WIDTH, height = BACKGROUND_HEIGHT
|
||||||
|
)
|
||||||
|
|
||||||
|
//Scroll
|
||||||
|
val scrollYOffset = if (menu.maxScroll == 0) {
|
||||||
|
if (menu.scroll == 0) 0 else 53
|
||||||
|
} else ((min(menu.scroll, menu.maxScroll).toFloat() / menu.maxScroll) * 53).toInt()
|
||||||
|
val trackHeight = 71 - scrollYOffset - 13
|
||||||
|
|
||||||
|
if (trackHeight > 0) {
|
||||||
|
blitk(
|
||||||
|
matrixStack = matrices,
|
||||||
|
texture = SCROLL_TRACK,
|
||||||
|
x = leftPos + 230, y = topPos + 49 + (71 - trackHeight),
|
||||||
|
width = 9, height = trackHeight,
|
||||||
|
textureHeight = 71,
|
||||||
|
vOffset = 71 - trackHeight
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
blitk(
|
||||||
|
matrixStack = matrices,
|
||||||
|
texture = SCROLL_SLIDE,
|
||||||
|
x = leftPos + 230, y = topPos + 49 + scrollYOffset,
|
||||||
|
width = 9, height = 17
|
||||||
|
)
|
||||||
|
|
||||||
|
// Pokemon
|
||||||
|
val party = CobblemonClient.storage.party
|
||||||
|
for (i in 0..5) {
|
||||||
|
val pokemon = party.get(i)
|
||||||
|
val slotYPosition = topPos + i * 33 + 27
|
||||||
|
|
||||||
|
if (pokemon != null) {
|
||||||
|
blitk(
|
||||||
|
matrixStack = matrices,
|
||||||
|
texture = PARTY_SLOT_BASE,
|
||||||
|
x = leftPos, y = slotYPosition,
|
||||||
|
width = 67, height = 31
|
||||||
|
)
|
||||||
|
|
||||||
|
val slotWidth = 32
|
||||||
|
val slotLeft = leftPos + 11
|
||||||
|
blitk(
|
||||||
|
matrixStack = matrices,
|
||||||
|
texture = if (pokemon.isFainted()) PARTY_SLOT_FAINTED else PARTY_SLOT,
|
||||||
|
x = slotLeft, y = slotYPosition,
|
||||||
|
width = slotWidth, height = 26,
|
||||||
|
textureHeight = 52,
|
||||||
|
vOffset = if (!menu.carried.isEmpty && menu.carried.item is BagItem && partySlotHovered(i, mouseX, mouseY)) 26 else 0
|
||||||
|
)
|
||||||
|
|
||||||
|
val expForThisLevel = pokemon.experience - pokemon.experienceGroup.getExperience(pokemon.level)
|
||||||
|
val expToNextLevel = pokemon.experienceGroup.getExperience(pokemon.level + 1) - pokemon.experienceGroup.getExperience(pokemon.level)
|
||||||
|
val expRatio = expForThisLevel.toFloat() / expToNextLevel
|
||||||
|
|
||||||
|
val expBarHeight = expRatio * 20
|
||||||
|
|
||||||
|
if (expBarHeight > 0) {
|
||||||
|
blitk(
|
||||||
|
matrixStack = matrices,
|
||||||
|
texture = CobblemonResources.WHITE,
|
||||||
|
x = leftPos + 6, y = slotYPosition + 24 - expBarHeight,
|
||||||
|
width = 1, height = expBarHeight,
|
||||||
|
red = 0.2, green = 0.65, blue = 0.84
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val hpRatio = pokemon.currentHealth.toFloat() / pokemon.maxHealth
|
||||||
|
val hpBarHeight = hpRatio * 20
|
||||||
|
val (red, green) = getDepletableRedGreen(hpRatio)
|
||||||
|
|
||||||
|
if (hpBarHeight > 0) {
|
||||||
|
blitk(
|
||||||
|
matrixStack = matrices,
|
||||||
|
texture = CobblemonResources.WHITE,
|
||||||
|
x = leftPos + 8, y = slotYPosition + 24 - hpBarHeight,
|
||||||
|
width = 2, height = hpBarHeight,
|
||||||
|
red = red * 0.8F, green = green * 0.8F, blue = 0.27F
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ball Icon
|
||||||
|
val ballIcon = cobblemonResource("textures/gui/ball/" + pokemon.caughtBall.name.path + ".png")
|
||||||
|
blitk(
|
||||||
|
matrixStack = matrices,
|
||||||
|
texture = ballIcon,
|
||||||
|
x = (leftPos + 3.5F) / 0.5F, y = (slotYPosition + 23) / 0.5F,
|
||||||
|
width = 18, height = 22,
|
||||||
|
textureHeight = 44,
|
||||||
|
scale = 0.5F
|
||||||
|
)
|
||||||
|
|
||||||
|
//Gender
|
||||||
|
if (pokemon.gender != Gender.GENDERLESS) {
|
||||||
|
blitk(
|
||||||
|
matrixStack = matrices,
|
||||||
|
texture = if (pokemon.gender == Gender.MALE) GENDER_ICON_MALE else GENDER_ICON_FEMALE,
|
||||||
|
x = (leftPos + 62) / 0.5F, y = (slotYPosition + 26) / 0.5F,
|
||||||
|
width = 5, height = 7,
|
||||||
|
scale = 0.5F
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
//Status
|
||||||
|
val status = pokemon.status?.status
|
||||||
|
if (!pokemon.isFainted() && status != null) {
|
||||||
|
blitk(
|
||||||
|
matrixStack = matrices,
|
||||||
|
texture = cobblemonResource("textures/gui/bag/status_${status.showdownName}.png"),
|
||||||
|
x = leftPos + 1, y = slotYPosition + 9,
|
||||||
|
width = 4, height = 14
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
matrices.pushPose()
|
||||||
|
matrices.translate(slotLeft + ((slotWidth - 8) / 2.0), slotYPosition.toDouble() - 6, 0.0)
|
||||||
|
matrices.scale(3.5F, 3.5F, 1F)
|
||||||
|
|
||||||
|
val state = FloatingState()
|
||||||
|
state.currentAspects = pokemon.aspects
|
||||||
|
drawProfilePokemon(
|
||||||
|
species = pokemon.species.resourceIdentifier,
|
||||||
|
matrixStack = matrices,
|
||||||
|
rotation = Quaternionf().fromEulerXYZDegrees(Vector3f(13F, 35F, 0F)),
|
||||||
|
state = state,
|
||||||
|
scale = 4.5F,
|
||||||
|
partialTicks = 0F
|
||||||
|
)
|
||||||
|
matrices.popPose()
|
||||||
|
|
||||||
|
matrices.pushPose()
|
||||||
|
matrices.translate(0.0, 0.0, 100.0)
|
||||||
|
// Level and Name and Gender
|
||||||
|
drawScaledText(
|
||||||
|
context = context,
|
||||||
|
text = pokemon.getDisplayName(),
|
||||||
|
x = leftPos + 14, y = slotYPosition + 26,
|
||||||
|
scale = 0.5F
|
||||||
|
)
|
||||||
|
|
||||||
|
drawScaledTextJustifiedRight(
|
||||||
|
context = context,
|
||||||
|
text = lang("ui.lv"),
|
||||||
|
x = leftPos + 40, y = slotYPosition + 14,
|
||||||
|
shadow = true,
|
||||||
|
scale = 0.5F
|
||||||
|
)
|
||||||
|
|
||||||
|
drawScaledTextJustifiedRight(
|
||||||
|
context = context,
|
||||||
|
text = pokemon.level.toString().text(),
|
||||||
|
x = leftPos + 40, y = slotYPosition + 19,
|
||||||
|
shadow = true,
|
||||||
|
scale = 0.5F
|
||||||
|
)
|
||||||
|
matrices.popPose()
|
||||||
|
} else {
|
||||||
|
blitk(
|
||||||
|
matrixStack = matrices,
|
||||||
|
texture = PARTY_SLOT_COLLAPSED,
|
||||||
|
x = leftPos + 64, y = slotYPosition,
|
||||||
|
width = 5, height = 31
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Titles
|
||||||
|
context.drawString(font, title, leftPos + 80, topPos + 33, Colors.WHITE, false)
|
||||||
|
context.drawString(font, playerInventoryTitle, leftPos + 80, topPos + 129, 4210752, false)
|
||||||
|
|
||||||
|
super.render(context, mouseX, mouseY, partialTick)
|
||||||
|
renderTooltip(context, mouseX, mouseY)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun partySlotHovered(index: Int, mouseX: Int, mouseY: Int): Boolean {
|
||||||
|
val left = leftPos + 11
|
||||||
|
val top = topPos + index * 33 + 27
|
||||||
|
return mouseX in left..(left + 32) && mouseY in top..(top + 26)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun cycleCategoryPage(next: Boolean) {
|
||||||
|
val orderedCategories = BagCategories.getOrderedCategoriesList()
|
||||||
|
currentCategoryPage = (currentCategoryPage + if (next) 1 else -1).coerceIn(0, (orderedCategories.size - 1) / 4)
|
||||||
|
categoriesWidgets.forEach {
|
||||||
|
removeWidget(it)
|
||||||
|
}
|
||||||
|
categoriesWidgets.clear()
|
||||||
|
for (i in 0..3) {
|
||||||
|
val adjustedIndex = i + 4 * currentCategoryPage
|
||||||
|
if (adjustedIndex < orderedCategories.size) {
|
||||||
|
categoriesWidgets.add(
|
||||||
|
BagCategoryButton(leftPos + 76 + i * 33, topPos, this, adjustedIndex) {
|
||||||
|
playSound(CobblemonSounds.ITEM_BAG_CLICK)
|
||||||
|
menu.changeCategory(adjustedIndex)
|
||||||
|
updateSortButtonState(false)
|
||||||
|
}.also { addRenderableWidget(it) }
|
||||||
|
)
|
||||||
|
} else break
|
||||||
|
}
|
||||||
|
leftCategoryPageButton.enabled = currentCategoryPage > 0
|
||||||
|
rightCategoryPageButton.enabled = currentCategoryPage < (orderedCategories.size - 1) / 4
|
||||||
|
updateSortButtonState(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Updates the state of [cycleCategorySortButton]. If cycle = true, will cycle to the next sort type. */
|
||||||
|
private fun updateSortButtonState(cycle: Boolean) {
|
||||||
|
val currentCategory = BagCategories.getOrderedCategoriesList().getOrNull(menu.currentlySelectedCategory)
|
||||||
|
if (menu.currentlySelectedCategory == -1) {
|
||||||
|
cycleCategorySortButton.enabled = false
|
||||||
|
ascendingButton.enabled = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
cycleCategorySortButton.enabled = currentCategory != null && currentCategory.getAllSortMethods().size > 1
|
||||||
|
ascendingButton.enabled = currentCategory != null && currentCategory.getAllSortMethods().size > 1
|
||||||
|
|
||||||
|
if (cycle && cycleCategorySortButton.enabled) {
|
||||||
|
val currentCategory = BagCategories.getOrderedCategoriesList().getOrNull(menu.currentlySelectedCategory) ?: return
|
||||||
|
|
||||||
|
playSound(CobblemonSounds.ITEM_BAG_CLICK)
|
||||||
|
if (menu.currentlySelectedSort == currentCategory.getAllSortMethods().size-1) {
|
||||||
|
menu.currentlySelectedSort = 0
|
||||||
|
} else { menu.currentlySelectedSort++ }
|
||||||
|
menu.setupSlotsBasedOnContent()
|
||||||
|
sendToServer(UpdateBagMenuDataPacket(menu.currentlySelectedCategory, menu.scroll, menu.currentlySelectedSort))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateScrollValue(mouseY: Double) {
|
||||||
|
val adjustedMouseY = mouseY - topPos - 49.0
|
||||||
|
if (adjustedMouseY < 0) {
|
||||||
|
menu.scroll = 0
|
||||||
|
} else if (adjustedMouseY > 71) {
|
||||||
|
menu.scroll = menu.maxScroll
|
||||||
|
} else {
|
||||||
|
menu.scroll = ((adjustedMouseY / 71.0) * (menu.maxScroll)).roundToInt()
|
||||||
|
}
|
||||||
|
menu.setupSlotsBasedOnContent()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun slotClicked(slot: Slot?, slotId: Int, mouseButton: Int, type: ClickType) {
|
||||||
|
if (slotId in CobblemonBagMenu.BAG_SLOTS && (lastCategory != menu.currentlySelectedCategory || lastScroll != menu.scroll)) {
|
||||||
|
lastCategory = menu.currentlySelectedCategory
|
||||||
|
lastScroll = menu.scroll
|
||||||
|
sendToServer(UpdateBagMenuDataPacket(menu.currentlySelectedCategory, menu.scroll, menu.currentlySelectedSort)) // Synchronize this data
|
||||||
|
}
|
||||||
|
super.slotClicked(slot, slotId, mouseButton, type)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollX: Double, scrollY: Double): Boolean {
|
||||||
|
if (scrollY < 0 && menu.scroll < menu.maxScroll) {
|
||||||
|
menu.scroll += 1
|
||||||
|
} else if (scrollY > 0 && menu.scroll > 0) {
|
||||||
|
menu.scroll -= 1
|
||||||
|
}
|
||||||
|
menu.setupSlotsBasedOnContent()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean {
|
||||||
|
if (mouseX in (leftPos + 229.0)..(leftPos + 240.0) && mouseY in (topPos + 49.0)..(topPos + 120.0)) {
|
||||||
|
scrolling = true
|
||||||
|
updateScrollValue(mouseY)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
val party = CobblemonClient.storage.party
|
||||||
|
if (!menu.carried.isEmpty && menu.carried.item is BagItem) {
|
||||||
|
for (i in 0..5) {
|
||||||
|
if (party.get(i) != null && partySlotHovered(i, mouseX.toInt(), mouseY.toInt())) {
|
||||||
|
playSound(CobblemonSounds.GUI_CLICK)
|
||||||
|
sendToServer(UseItemOnPokemonFromBagPacket(i))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.mouseClicked(mouseX, mouseY, button)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean {
|
||||||
|
scrolling = false
|
||||||
|
return super.mouseReleased(mouseX, mouseY, button)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, dragX: Double, dragY: Double): Boolean {
|
||||||
|
if (scrolling) {
|
||||||
|
updateScrollValue(mouseY)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return super.mouseDragged(mouseX, mouseY, button, dragX, dragY)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun playSound(soundEvent: SoundEvent) {
|
||||||
|
Minecraft.getInstance().soundManager.play(SimpleSoundInstance.forUI(soundEvent, 1.0F))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onClose() {
|
||||||
|
Minecraft.getInstance().soundManager.play(SimpleSoundInstance.forUI(CobblemonSounds.ITEM_BAG_CLOSE, 1.0F))
|
||||||
|
super.onClose()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,9 +28,9 @@ import org.joml.Vector3f
|
|||||||
|
|
||||||
open class PartySlot(
|
open class PartySlot(
|
||||||
x: Int, y: Int,
|
x: Int, y: Int,
|
||||||
private val pokemon: TradeStartedPacket.TradeablePokemon?,
|
val pokemon: TradeStartedPacket.TradeablePokemon?,
|
||||||
private val parent: TradeGUI,
|
private val parent: TradeGUI,
|
||||||
private val isOpposing: Boolean = false,
|
val isOpposing: Boolean = false,
|
||||||
onPress: OnPress
|
onPress: OnPress
|
||||||
) : Button(x, y, SIZE, SIZE, Component.literal("PartySlot"), onPress, DEFAULT_NARRATION), CobblemonRenderable {
|
) : Button(x, y, SIZE, SIZE, Component.literal("PartySlot"), onPress, DEFAULT_NARRATION), CobblemonRenderable {
|
||||||
val state = FloatingState()
|
val state = FloatingState()
|
||||||
@@ -42,6 +42,8 @@ open class PartySlot(
|
|||||||
private val genderIconFemale = cobblemonResource("textures/gui/pc/gender_icon_female.png")
|
private val genderIconFemale = cobblemonResource("textures/gui/pc/gender_icon_female.png")
|
||||||
private val selectPointerResource = cobblemonResource("textures/gui/pc/pc_pointer.png")
|
private val selectPointerResource = cobblemonResource("textures/gui/pc/pc_pointer.png")
|
||||||
private val untradeableResource = cobblemonResource("textures/gui/trade/trade_slot_icon_locked.png")
|
private val untradeableResource = cobblemonResource("textures/gui/trade/trade_slot_icon_locked.png")
|
||||||
|
private val tradePartySlotSelectedResource = cobblemonResource("textures/gui/trade/trade_party_slot_selected.png")
|
||||||
|
private val tradePartySlotSelectedOpposingResource = cobblemonResource("textures/gui/trade/trade_party_slot_selected_opposing.png")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun playDownSound(soundManager: SoundManager) {
|
override fun playDownSound(soundManager: SoundManager) {
|
||||||
@@ -60,6 +62,17 @@ open class PartySlot(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasSelected()) {
|
||||||
|
blitk(
|
||||||
|
matrixStack = matrices,
|
||||||
|
texture = if (isOpposing) tradePartySlotSelectedOpposingResource else tradePartySlotSelectedResource,
|
||||||
|
x = x - 2,
|
||||||
|
y = y - 2,
|
||||||
|
width = 29,
|
||||||
|
height = 29
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (pokemon != null) {
|
if (pokemon != null) {
|
||||||
// context.enableScissor(x - 2, y + 2, x + SIZE + 4, y + SIZE + 4)
|
// context.enableScissor(x - 2, y + 2, x + SIZE + 4, y + SIZE + 4)
|
||||||
// Render Pokémon
|
// Render Pokémon
|
||||||
@@ -118,7 +131,16 @@ open class PartySlot(
|
|||||||
}
|
}
|
||||||
|
|
||||||
matrices.popPose()
|
matrices.popPose()
|
||||||
if (hasSelected()) {
|
|
||||||
|
val isViewed = if (isOpposing) {
|
||||||
|
parent.opposingOfferedPokemon?.uuid == pokemon.pokemonId
|
||||||
|
} else {
|
||||||
|
parent.offeredPokemon?.uuid == pokemon.pokemonId
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isViewed && pokemon.tradeable) {
|
||||||
|
matrices.pushPose()
|
||||||
|
matrices.translate(0.0, 0.0, 200.0)
|
||||||
blitk(
|
blitk(
|
||||||
matrixStack = matrices,
|
matrixStack = matrices,
|
||||||
texture = selectPointerResource,
|
texture = selectPointerResource,
|
||||||
@@ -128,6 +150,7 @@ open class PartySlot(
|
|||||||
height = 8,
|
height = 8,
|
||||||
scale = TradeGUI.SCALE
|
scale = TradeGUI.SCALE
|
||||||
)
|
)
|
||||||
|
matrices.popPose()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Held Item
|
// Held Item
|
||||||
@@ -145,8 +168,9 @@ open class PartySlot(
|
|||||||
}
|
}
|
||||||
|
|
||||||
open fun hasSelected(): Boolean {
|
open fun hasSelected(): Boolean {
|
||||||
val offeredPokemon = if (isOpposing) parent.trade.oppositeOffer.get() else parent.trade.myOffer.get()
|
if (pokemon == null) return false
|
||||||
return pokemon?.pokemonId == offeredPokemon?.uuid && pokemon != null
|
val offeredPokemons = if (isOpposing) parent.trade.oppositeOffer.get() else parent.trade.myOffer.get()
|
||||||
|
return offeredPokemons.any { it.uuid == pokemon.pokemonId }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isHovered(mouseX: Int, mouseY: Int) = pokemon?.tradeable != false && mouseX.toFloat() in (x.toFloat()..(x.toFloat() + SIZE)) && mouseY.toFloat() in (y.toFloat()..(y.toFloat() + SIZE))
|
fun isHovered(mouseX: Int, mouseY: Int) = pokemon?.tradeable != false && mouseX.toFloat() in (x.toFloat()..(x.toFloat() + SIZE)) && mouseY.toFloat() in (y.toFloat()..(y.toFloat() + SIZE))
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import com.cobblemon.mod.common.client.gui.summary.widgets.common.reformatNature
|
|||||||
import com.cobblemon.mod.common.client.render.drawScaledText
|
import com.cobblemon.mod.common.client.render.drawScaledText
|
||||||
import com.cobblemon.mod.common.client.render.drawScaledTextJustifiedRight
|
import com.cobblemon.mod.common.client.render.drawScaledTextJustifiedRight
|
||||||
import com.cobblemon.mod.common.client.trade.ClientTrade
|
import com.cobblemon.mod.common.client.trade.ClientTrade
|
||||||
|
import com.cobblemon.mod.common.net.messages.client.trade.TradeStartedPacket
|
||||||
import com.cobblemon.mod.common.net.messages.client.trade.TradeStartedPacket.TradeablePokemon
|
import com.cobblemon.mod.common.net.messages.client.trade.TradeStartedPacket.TradeablePokemon
|
||||||
import com.cobblemon.mod.common.net.messages.server.trade.*
|
import com.cobblemon.mod.common.net.messages.server.trade.*
|
||||||
import com.cobblemon.mod.common.pokemon.Gender
|
import com.cobblemon.mod.common.pokemon.Gender
|
||||||
@@ -98,15 +99,23 @@ class TradeGUI(
|
|||||||
private val tradeAnimationArrowsResource = cobblemonResource("textures/gui/trade/trade_animation_arrows.png")
|
private val tradeAnimationArrowsResource = cobblemonResource("textures/gui/trade/trade_animation_arrows.png")
|
||||||
}
|
}
|
||||||
|
|
||||||
private var offeredPokemonModel: ModelWidget? = null
|
private var offeredPokemonModels: MutableList<ModelWidget> = mutableListOf()
|
||||||
private var opposingOfferedPokemonModel: ModelWidget? = null
|
private var opposingOfferedPokemonModels: MutableList<ModelWidget> = mutableListOf()
|
||||||
|
|
||||||
private lateinit var offeredPokemonMarkings: MarkingsWidget
|
private lateinit var offeredPokemonMarkings: MarkingsWidget
|
||||||
private lateinit var opposingOfferedPokemonMarkings: MarkingsWidget
|
private lateinit var opposingOfferedPokemonMarkings: MarkingsWidget
|
||||||
|
|
||||||
|
var selectedPartyIndices = mutableListOf<Int>()
|
||||||
|
var offeredPokemons: MutableList<Pokemon> = mutableListOf()
|
||||||
|
var opposingPokemons: MutableList<Pokemon> = mutableListOf()
|
||||||
|
|
||||||
|
// For backwards compatibility where single is referenced in rendering text info
|
||||||
var offeredPokemon: Pokemon? = null
|
var offeredPokemon: Pokemon? = null
|
||||||
var opposingOfferedPokemon: Pokemon? = null
|
var opposingOfferedPokemon: Pokemon? = null
|
||||||
|
|
||||||
|
var myGridMode = true
|
||||||
|
var opposingGridMode = true
|
||||||
|
|
||||||
var ticksElapsed = 0
|
var ticksElapsed = 0
|
||||||
var protectiveTicks = 0
|
var protectiveTicks = 0
|
||||||
var selectPointerOffsetY = 0
|
var selectPointerOffsetY = 0
|
||||||
@@ -125,30 +134,67 @@ class TradeGUI(
|
|||||||
}
|
}
|
||||||
|
|
||||||
trade.completedEmitter.subscribe {
|
trade.completedEmitter.subscribe {
|
||||||
val (pokemonId1, pokemonId2) = it
|
val (pokemonIds1, pokemonIds2) = it
|
||||||
val myTradedPokemon = party.find { it?.pokemonId == pokemonId1 }
|
val myTradedPokemons = pokemonIds1.mapNotNull { id -> party.find { it?.pokemonId == id } }
|
||||||
val theirTradedPokemon = traderParty.find { it?.pokemonId == pokemonId2 }
|
val theirTradedPokemons = pokemonIds2.mapNotNull { id -> traderParty.find { it?.pokemonId == id } }
|
||||||
if (myTradedPokemon == null || theirTradedPokemon == null) {
|
if (myTradedPokemons.isEmpty() || theirTradedPokemons.isEmpty()) {
|
||||||
CobblemonNetwork.sendToServer(CancelTradePacket())
|
CobblemonNetwork.sendToServer(CancelTradePacket())
|
||||||
return@subscribe onClose()
|
return@subscribe onClose()
|
||||||
}
|
}
|
||||||
val tradedSlot = party.indexOf(myTradedPokemon)
|
|
||||||
val opposingTradedSlot = traderParty.indexOf(theirTradedPokemon)
|
myTradedPokemons.forEach { pk ->
|
||||||
party[tradedSlot] = theirTradedPokemon
|
val idx = party.indexOf(pk)
|
||||||
traderParty[opposingTradedSlot] = myTradedPokemon
|
if (idx != -1) party[idx] = null
|
||||||
|
}
|
||||||
|
theirTradedPokemons.forEach { pk ->
|
||||||
|
val idx = traderParty.indexOf(pk)
|
||||||
|
if (idx != -1) traderParty[idx] = null
|
||||||
|
}
|
||||||
|
|
||||||
|
val newSelectedIndices = mutableListOf<Int>()
|
||||||
|
theirTradedPokemons.forEach { pk ->
|
||||||
|
val emptyIdx = party.indexOf(null)
|
||||||
|
if (emptyIdx != -1) {
|
||||||
|
party[emptyIdx] = pk
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myTradedPokemons.forEach { pk ->
|
||||||
|
val emptyIdx = traderParty.indexOf(null)
|
||||||
|
if (emptyIdx != -1) traderParty[emptyIdx] = pk
|
||||||
|
}
|
||||||
|
|
||||||
|
val compactUI = { list: MutableList<TradeStartedPacket.TradeablePokemon?> ->
|
||||||
|
val nonNulls = list.filterNotNull()
|
||||||
|
list.clear()
|
||||||
|
list.addAll(nonNulls)
|
||||||
|
while (list.size < 6) list.add(null)
|
||||||
|
}
|
||||||
|
compactUI(party)
|
||||||
|
compactUI(traderParty)
|
||||||
|
|
||||||
|
theirTradedPokemons.forEach { pk ->
|
||||||
|
val idx = party.indexOf(pk)
|
||||||
|
if (idx != -1) newSelectedIndices.add(idx)
|
||||||
|
}
|
||||||
|
|
||||||
trade.oppositeAcceptedMyOffer.set(false)
|
trade.oppositeAcceptedMyOffer.set(false)
|
||||||
CobblemonNetwork.sendToServer(UpdateTradeOfferPacket(Pair(theirTradedPokemon.pokemonId, PartyPosition(tradedSlot))))
|
selectedPartyIndices.clear()
|
||||||
|
selectedPartyIndices.addAll(newSelectedIndices)
|
||||||
|
|
||||||
|
val newOffers = selectedPartyIndices.mapNotNull { idx ->
|
||||||
|
party[idx]?.let { it.pokemonId to PartyPosition(idx) }
|
||||||
|
}
|
||||||
|
CobblemonNetwork.sendToServer(UpdateTradeOfferPacket(newOffers))
|
||||||
|
|
||||||
rebuildWidgets()
|
rebuildWidgets()
|
||||||
}
|
}
|
||||||
|
|
||||||
trade.oppositeOffer.subscribe { newOffer: Pokemon? ->
|
trade.oppositeOffer.subscribe { newOffer: List<Pokemon> ->
|
||||||
setOfferedPokemon(pokemon = newOffer, isOpposing = true)
|
setOfferedPokemon(pokemonList = newOffer, isOpposing = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
trade.myOffer.subscribe { myOffer: Pokemon? ->
|
trade.myOffer.subscribe { myOffer: List<Pokemon> ->
|
||||||
setOfferedPokemon(pokemon = myOffer)
|
setOfferedPokemon(pokemonList = myOffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
trade.oppositeAcceptedMyOffer.subscribe {
|
trade.oppositeAcceptedMyOffer.subscribe {
|
||||||
@@ -216,9 +262,16 @@ class TradeGUI(
|
|||||||
pokemon = pokemon,
|
pokemon = pokemon,
|
||||||
parent = this,
|
parent = this,
|
||||||
onPress = {
|
onPress = {
|
||||||
if (!trade.acceptedOppositeOffer && !tradeProcessing) {
|
if (!trade.acceptedOppositeOffer && !tradeProcessing && pokemon != null) {
|
||||||
val pk = if (offeredPokemon?.uuid == pokemon?.pokemonId) null else pokemon
|
if (selectedPartyIndices.contains(partyIndex)) {
|
||||||
CobblemonNetwork.sendToServer(UpdateTradeOfferPacket(pk?.let { it.pokemonId to PartyPosition(partyIndex) }))
|
selectedPartyIndices.remove(partyIndex)
|
||||||
|
} else if (selectedPartyIndices.size < 6) {
|
||||||
|
selectedPartyIndices.add(partyIndex)
|
||||||
|
}
|
||||||
|
val newOffers = selectedPartyIndices.mapNotNull { idx ->
|
||||||
|
party[idx]?.let { it.pokemonId to PartyPosition(idx) }
|
||||||
|
}
|
||||||
|
CobblemonNetwork.sendToServer(UpdateTradeOfferPacket(newOffers))
|
||||||
playSound(CobblemonSounds.GUI_CLICK)
|
playSound(CobblemonSounds.GUI_CLICK)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -250,8 +303,8 @@ class TradeGUI(
|
|||||||
).also { widget -> addRenderableWidget(widget) }
|
).also { widget -> addRenderableWidget(widget) }
|
||||||
}
|
}
|
||||||
|
|
||||||
setOfferedPokemon(pokemon = offeredPokemon, isOpposing = false)
|
setOfferedPokemon(pokemonList = offeredPokemons.toList(), isOpposing = false)
|
||||||
setOfferedPokemon(pokemon = opposingOfferedPokemon, isOpposing = true)
|
setOfferedPokemon(pokemonList = opposingPokemons.toList(), isOpposing = true)
|
||||||
|
|
||||||
offeredPokemonMarkings = MarkingsWidget(x + 74.5, y + 21, offeredPokemon, false)
|
offeredPokemonMarkings = MarkingsWidget(x + 74.5, y + 21, offeredPokemon, false)
|
||||||
opposingOfferedPokemonMarkings = MarkingsWidget(x + 177.5, y + 21, opposingOfferedPokemon, false)
|
opposingOfferedPokemonMarkings = MarkingsWidget(x + 177.5, y + 21, opposingOfferedPokemon, false)
|
||||||
@@ -284,7 +337,7 @@ class TradeGUI(
|
|||||||
if (tradeAnimationProgress > REVERSE_ANIMATION_TICK)
|
if (tradeAnimationProgress > REVERSE_ANIMATION_TICK)
|
||||||
(REVERSE_ANIMATION_TICK + TRADE_ANIMATION_FRAMES - tradeAnimationProgress)
|
(REVERSE_ANIMATION_TICK + TRADE_ANIMATION_FRAMES - tradeAnimationProgress)
|
||||||
else (tradeAnimationProgress - MODEL_SCALE_BUFFER_FRAMES)
|
else (tradeAnimationProgress - MODEL_SCALE_BUFFER_FRAMES)
|
||||||
) * TRADE_ANIMATION_HEIGHT
|
) * TRADE_ANIMATION_HEIGHT
|
||||||
blitk(
|
blitk(
|
||||||
matrixStack = matrices,
|
matrixStack = matrices,
|
||||||
texture = tradeAnimationResource,
|
texture = tradeAnimationResource,
|
||||||
@@ -313,20 +366,56 @@ class TradeGUI(
|
|||||||
// Render Model Portraits
|
// Render Model Portraits
|
||||||
var scale = PORTRAIT_SCALE
|
var scale = PORTRAIT_SCALE
|
||||||
var scaleOffsetY = PORTRAIT_MODEL_OFFSET_Y
|
var scaleOffsetY = PORTRAIT_MODEL_OFFSET_Y
|
||||||
|
var isShrinking = false
|
||||||
if (tradeProcessing) {
|
if (tradeProcessing) {
|
||||||
val scaleInterval = if (tradeAnimationProgress > REVERSE_ANIMATION_TICK) (MAX_TRADE_PROGRESS - tradeAnimationProgress) else tradeAnimationProgress
|
val scaleInterval = if (tradeAnimationProgress > REVERSE_ANIMATION_TICK) (MAX_TRADE_PROGRESS - tradeAnimationProgress) else tradeAnimationProgress
|
||||||
scale = (PORTRAIT_SCALE - (scaleInterval * PORTRAIT_SCALE_MULTIPLIER)).coerceIn(0F, PORTRAIT_SCALE)
|
scale = (PORTRAIT_SCALE - (scaleInterval * PORTRAIT_SCALE_MULTIPLIER)).coerceIn(0F, PORTRAIT_SCALE)
|
||||||
scaleOffsetY = (45.0 - (45.0 / PORTRAIT_SCALE) * scale) + PORTRAIT_MODEL_OFFSET_Y
|
scaleOffsetY = (45.0 - (45.0 / PORTRAIT_SCALE) * scale) + PORTRAIT_MODEL_OFFSET_Y
|
||||||
|
isShrinking = true
|
||||||
}
|
}
|
||||||
|
val shrinkPercentage = if (isShrinking) 1.0F - (scale / PORTRAIT_SCALE) else 0.0F
|
||||||
|
val myCenterXDest = x + 70 + (PORTRAIT_SIZE / 2.0)
|
||||||
|
val myCenterYDest = y + 30 + (PORTRAIT_SIZE / 2.0)
|
||||||
|
val opCenterXDest = x + 145 + (PORTRAIT_SIZE / 2.0)
|
||||||
|
val opCenterYDest = y + 30 + (PORTRAIT_SIZE / 2.0)
|
||||||
|
|
||||||
if (scale > 0F) {
|
if (scale > 0F) {
|
||||||
context.enableScissor(backgroundX, backgroundY, backgroundX + BASE_BACKGROUND_WIDTH, backgroundY + BASE_BACKGROUND_HEIGHT)
|
context.enableScissor(backgroundX, backgroundY, backgroundX + BASE_BACKGROUND_WIDTH, backgroundY + BASE_BACKGROUND_HEIGHT)
|
||||||
offeredPokemonModel?.baseScale = scale
|
|
||||||
offeredPokemonModel?.offsetY = scaleOffsetY
|
|
||||||
offeredPokemonModel?.render(context, mouseX, mouseY, delta)
|
|
||||||
|
|
||||||
opposingOfferedPokemonModel?.baseScale = scale
|
offeredPokemonModels.forEachIndexed { i, model ->
|
||||||
opposingOfferedPokemonModel?.offsetY = scaleOffsetY
|
val posAndScale = getModelPositionAndScale(i, offeredPokemons.size, x + 70, y + 30)
|
||||||
opposingOfferedPokemonModel?.render(context, mouseX, mouseY, delta)
|
val originalScale = posAndScale.second
|
||||||
|
model.baseScale = if (isShrinking) (originalScale / PORTRAIT_SCALE) * scale else originalScale
|
||||||
|
model.offsetY = if (isShrinking) scaleOffsetY else PORTRAIT_MODEL_OFFSET_Y
|
||||||
|
|
||||||
|
val startCenterX = posAndScale.first.first + (PORTRAIT_SIZE / 2.0)
|
||||||
|
val startCenterY = posAndScale.first.second + (PORTRAIT_SIZE / 2.0)
|
||||||
|
|
||||||
|
context.pose().pushPose()
|
||||||
|
context.pose().translate((myCenterXDest - startCenterX) * shrinkPercentage, (myCenterYDest - startCenterY) * shrinkPercentage, 0.0)
|
||||||
|
|
||||||
|
model.render(context, mouseX, mouseY, delta)
|
||||||
|
|
||||||
|
context.pose().popPose()
|
||||||
|
}
|
||||||
|
|
||||||
|
opposingOfferedPokemonModels.forEachIndexed { i, model ->
|
||||||
|
val posAndScale = getModelPositionAndScale(i, opposingPokemons.size, x + 145, y + 30)
|
||||||
|
val originalScale = posAndScale.second
|
||||||
|
model.baseScale = if (isShrinking) (originalScale / PORTRAIT_SCALE) * scale else originalScale
|
||||||
|
model.offsetY = if (isShrinking) scaleOffsetY else PORTRAIT_MODEL_OFFSET_Y
|
||||||
|
|
||||||
|
val startCenterX = posAndScale.first.first + (PORTRAIT_SIZE / 2.0)
|
||||||
|
val startCenterY = posAndScale.first.second + (PORTRAIT_SIZE / 2.0)
|
||||||
|
|
||||||
|
context.pose().pushPose()
|
||||||
|
context.pose().translate((opCenterXDest - startCenterX) * shrinkPercentage, (opCenterYDest - startCenterY) * shrinkPercentage, 0.0)
|
||||||
|
|
||||||
|
model.render(context, mouseX, mouseY, delta)
|
||||||
|
|
||||||
|
context.pose().popPose()
|
||||||
|
}
|
||||||
|
|
||||||
context.disableScissor()
|
context.disableScissor()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,8 +430,46 @@ class TradeGUI(
|
|||||||
|
|
||||||
renderInfoLabels(context, x, y)
|
renderInfoLabels(context, x, y)
|
||||||
|
|
||||||
renderPokemonInfo(offeredPokemon, false, context, x, y, mouseX, mouseY)
|
children().filterIsInstance<PartySlot>().forEach { slot ->
|
||||||
renderPokemonInfo(opposingOfferedPokemon, true, context, x, y, mouseX, mouseY)
|
if (slot.isHovered(mouseX, mouseY)) {
|
||||||
|
val hoveredId = slot.pokemon?.pokemonId
|
||||||
|
if (slot.isOpposing && slot.hasSelected()) {
|
||||||
|
opposingPokemons.find { it.uuid == hoveredId }?.let { opposingOfferedPokemon = it }
|
||||||
|
} else if (!slot.isOpposing) {
|
||||||
|
val matchingModel = offeredPokemons.find { it.uuid == hoveredId }
|
||||||
|
if (matchingModel != null) {
|
||||||
|
offeredPokemon = matchingModel
|
||||||
|
} else {
|
||||||
|
val realPokemon = com.cobblemon.mod.common.client.CobblemonClient.storage.party.find { it?.uuid == hoveredId }
|
||||||
|
if (realPokemon != null) {
|
||||||
|
offeredPokemon = realPokemon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val currentOffered = offeredPokemon
|
||||||
|
if (currentOffered != null) {
|
||||||
|
renderPokemonInfo(currentOffered, false, context, x, y, mouseX, mouseY)
|
||||||
|
if (::offeredPokemonMarkings.isInitialized) {
|
||||||
|
offeredPokemonMarkings.visible = true
|
||||||
|
if (offeredPokemonMarkings.pokemon != currentOffered) offeredPokemonMarkings.setActivePokemon(currentOffered)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (::offeredPokemonMarkings.isInitialized) offeredPokemonMarkings.visible = false
|
||||||
|
}
|
||||||
|
|
||||||
|
val currentOpposing = opposingOfferedPokemon
|
||||||
|
if (currentOpposing != null) {
|
||||||
|
renderPokemonInfo(currentOpposing, true, context, x, y, mouseX, mouseY)
|
||||||
|
if (::opposingOfferedPokemonMarkings.isInitialized) {
|
||||||
|
opposingOfferedPokemonMarkings.visible = true
|
||||||
|
if (opposingOfferedPokemonMarkings.pokemon != currentOpposing) opposingOfferedPokemonMarkings.setActivePokemon(currentOpposing)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (::opposingOfferedPokemonMarkings.isInitialized) opposingOfferedPokemonMarkings.visible = false
|
||||||
|
}
|
||||||
|
|
||||||
if (trade.acceptedOppositeOffer) {
|
if (trade.acceptedOppositeOffer) {
|
||||||
blitk(
|
blitk(
|
||||||
@@ -431,19 +558,25 @@ class TradeGUI(
|
|||||||
|
|
||||||
super.render(context, mouseX, mouseY, delta)
|
super.render(context, mouseX, mouseY, delta)
|
||||||
|
|
||||||
// Item Tooltip
|
val ttOffered = offeredPokemon
|
||||||
if (offeredPokemon != null && !offeredPokemon!!.heldItemNoCopy().isEmpty) {
|
if (ttOffered != null) {
|
||||||
val itemX = x + 50
|
// Item Tooltip
|
||||||
val itemY = y + 125
|
if (!ttOffered.heldItemNoCopy().isEmpty) {
|
||||||
val itemHovered = mouseX.toFloat() in (itemX.toFloat()..(itemX.toFloat() + 16)) && mouseY.toFloat() in (itemY.toFloat()..(itemY.toFloat() + 16))
|
val itemX = x + 50
|
||||||
if (itemHovered) context.renderTooltip(Minecraft.getInstance().font, offeredPokemon!!.heldItemNoCopy(), mouseX, mouseY)
|
val itemY = y + 125
|
||||||
|
val itemHovered = mouseX.toFloat() in (itemX.toFloat()..(itemX.toFloat() + 16)) && mouseY.toFloat() in (itemY.toFloat()..(itemY.toFloat() + 16))
|
||||||
|
if (itemHovered) context.renderTooltip(Minecraft.getInstance().font, ttOffered.heldItemNoCopy(), mouseX, mouseY)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opposingOfferedPokemon != null && !opposingOfferedPokemon!!.heldItemNoCopy().isEmpty) {
|
val ttOpposing = opposingOfferedPokemon
|
||||||
val itemX = x + 227
|
if (ttOpposing != null) {
|
||||||
val itemY = y + 125
|
if (!ttOpposing.heldItemNoCopy().isEmpty) {
|
||||||
val itemHovered = mouseX.toFloat() in (itemX.toFloat()..(itemX.toFloat() + 16)) && mouseY.toFloat() in (itemY.toFloat()..(itemY.toFloat() + 16))
|
val itemX = x + 227
|
||||||
if (itemHovered) context.renderTooltip(Minecraft.getInstance().font, opposingOfferedPokemon!!.heldItemNoCopy(), mouseX, mouseY)
|
val itemY = y + 125
|
||||||
|
val itemHovered = mouseX.toFloat() in (itemX.toFloat()..(itemX.toFloat() + 16)) && mouseY.toFloat() in (itemY.toFloat()..(itemY.toFloat() + 16))
|
||||||
|
if (itemHovered) context.renderTooltip(Minecraft.getInstance().font, ttOpposing.heldItemNoCopy(), mouseX, mouseY)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,11 +613,13 @@ class TradeGUI(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tradeAnimationProgress == (MAX_TRADE_PROGRESS + CRY_BUFFER)) {
|
if (tradeAnimationProgress == (MAX_TRADE_PROGRESS + CRY_BUFFER)) {
|
||||||
if (offeredPokemonModel !== null && opposingOfferedPokemonModel !== null) {
|
offeredPokemonModels.forEach {
|
||||||
offeredPokemonModel!!.state.activeAnimations.clear()
|
it.state.activeAnimations.clear()
|
||||||
offeredPokemonModel!!.state.addFirstAnimation(setOf("cry"))
|
it.state.addFirstAnimation(setOf("cry"))
|
||||||
opposingOfferedPokemonModel!!.state.activeAnimations.clear()
|
}
|
||||||
opposingOfferedPokemonModel!!.state.addFirstAnimation(setOf("cry"))
|
opposingOfferedPokemonModels.forEach {
|
||||||
|
it.state.activeAnimations.clear()
|
||||||
|
it.state.addFirstAnimation(setOf("cry"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,41 +650,140 @@ class TradeGUI(
|
|||||||
|
|
||||||
override fun renderMenuBackground(context: GuiGraphics) {}
|
override fun renderMenuBackground(context: GuiGraphics) {}
|
||||||
|
|
||||||
private fun setOfferedPokemon(pokemon: Pokemon?, isOpposing: Boolean = false) {
|
private fun setOfferedPokemon(pokemonList: List<Pokemon>, isOpposing: Boolean = false) {
|
||||||
protectiveTicks = 20
|
protectiveTicks = 20
|
||||||
|
if (isOpposing) {
|
||||||
|
val wasEmpty = opposingPokemons.isEmpty()
|
||||||
|
val currentViewedUuid = if (opposingGridMode) null else opposingOfferedPokemon?.uuid
|
||||||
|
opposingPokemons.clear()
|
||||||
|
opposingPokemons.addAll(pokemonList)
|
||||||
|
|
||||||
|
val matchingPokemon = opposingPokemons.find { it.uuid == currentViewedUuid }
|
||||||
|
|
||||||
|
if (matchingPokemon != null) {
|
||||||
|
opposingOfferedPokemon = matchingPokemon
|
||||||
|
if (::opposingOfferedPokemonMarkings.isInitialized) opposingOfferedPokemonMarkings.setActivePokemon(opposingOfferedPokemon)
|
||||||
|
} else {
|
||||||
|
opposingOfferedPokemon = opposingPokemons.lastOrNull()
|
||||||
|
if (::opposingOfferedPokemonMarkings.isInitialized) opposingOfferedPokemonMarkings.setActivePokemon(opposingOfferedPokemon)
|
||||||
|
if (wasEmpty && opposingOfferedPokemon != null) {
|
||||||
|
opposingGridMode = false
|
||||||
|
} else if (!opposingGridMode) {
|
||||||
|
opposingGridMode = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trade.acceptedOppositeOffer = false
|
||||||
|
} else {
|
||||||
|
val wasEmpty = offeredPokemons.isEmpty()
|
||||||
|
val currentViewedUuid = if (myGridMode) null else offeredPokemon?.uuid
|
||||||
|
offeredPokemons.clear()
|
||||||
|
offeredPokemons.addAll(pokemonList)
|
||||||
|
|
||||||
|
val matchingPokemon = offeredPokemons.find { it.uuid == currentViewedUuid }
|
||||||
|
|
||||||
|
if (matchingPokemon != null) {
|
||||||
|
offeredPokemon = matchingPokemon
|
||||||
|
if (::offeredPokemonMarkings.isInitialized) offeredPokemonMarkings.setActivePokemon(offeredPokemon)
|
||||||
|
} else {
|
||||||
|
offeredPokemon = offeredPokemons.lastOrNull()
|
||||||
|
if (::offeredPokemonMarkings.isInitialized) offeredPokemonMarkings.setActivePokemon(offeredPokemon)
|
||||||
|
if (wasEmpty && offeredPokemon != null) {
|
||||||
|
myGridMode = false
|
||||||
|
} else if (!myGridMode) {
|
||||||
|
myGridMode = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rebuildSelectedModels(isOpposing)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun rebuildSelectedModels(isOpposing: Boolean) {
|
||||||
val x = (width - BASE_WIDTH) / 2
|
val x = (width - BASE_WIDTH) / 2
|
||||||
val y = (height - BASE_HEIGHT) / 2
|
val y = (height - BASE_HEIGHT) / 2
|
||||||
|
|
||||||
if (isOpposing) {
|
if (isOpposing) {
|
||||||
opposingOfferedPokemon = pokemon
|
opposingOfferedPokemonModels.clear()
|
||||||
opposingOfferedPokemonModel = if (pokemon != null) ModelWidget(
|
val total = opposingPokemons.size
|
||||||
pX = x + 145,
|
opposingPokemons.forEachIndexed { i, pk ->
|
||||||
pY = y + 30,
|
val (pos, currentScale) = getModelPositionAndScale(i, total, x + 145, y + 30)
|
||||||
pWidth = PORTRAIT_SIZE,
|
opposingOfferedPokemonModels.add(ModelWidget(
|
||||||
pHeight = PORTRAIT_SIZE,
|
pX = pos.first, pY = pos.second,
|
||||||
pokemon = pokemon.asRenderablePokemon(),
|
pWidth = PORTRAIT_SIZE, pHeight = PORTRAIT_SIZE,
|
||||||
baseScale = PORTRAIT_SCALE,
|
pokemon = pk.asRenderablePokemon(),
|
||||||
rotationY = 35F,
|
baseScale = currentScale,
|
||||||
offsetY = PORTRAIT_MODEL_OFFSET_Y
|
rotationY = 35F,
|
||||||
) else null
|
offsetY = PORTRAIT_MODEL_OFFSET_Y
|
||||||
if (::opposingOfferedPokemonMarkings.isInitialized) opposingOfferedPokemonMarkings.setActivePokemon(opposingOfferedPokemon)
|
))
|
||||||
trade.acceptedOppositeOffer = false
|
}
|
||||||
} else {
|
} else {
|
||||||
offeredPokemon = pokemon
|
offeredPokemonModels.clear()
|
||||||
offeredPokemonModel = if (pokemon != null) ModelWidget(
|
val total = offeredPokemons.size
|
||||||
pX = x + 70,
|
offeredPokemons.forEachIndexed { i, pk ->
|
||||||
pY = y + 30,
|
val (pos, currentScale) = getModelPositionAndScale(i, total, x + 70, y + 30)
|
||||||
pWidth = PORTRAIT_SIZE,
|
offeredPokemonModels.add(ModelWidget(
|
||||||
pHeight = PORTRAIT_SIZE,
|
pX = pos.first, pY = pos.second,
|
||||||
pokemon = pokemon.asRenderablePokemon(),
|
pWidth = PORTRAIT_SIZE, pHeight = PORTRAIT_SIZE,
|
||||||
baseScale = PORTRAIT_SCALE,
|
pokemon = pk.asRenderablePokemon(),
|
||||||
rotationY = 325F,
|
baseScale = currentScale,
|
||||||
offsetY = PORTRAIT_MODEL_OFFSET_Y
|
rotationY = 325F,
|
||||||
) else null
|
offsetY = PORTRAIT_MODEL_OFFSET_Y
|
||||||
if (::offeredPokemonMarkings.isInitialized) offeredPokemonMarkings.setActivePokemon(offeredPokemon)
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getModelPositionAndScale(index: Int, total: Int, baseX: Int, baseY: Int): Pair<Pair<Int, Int>, Float> {
|
||||||
|
val scale = when (total) {
|
||||||
|
1 -> PORTRAIT_SCALE
|
||||||
|
2 -> PORTRAIT_SCALE * 0.75f
|
||||||
|
3 -> PORTRAIT_SCALE * 0.65f
|
||||||
|
4 -> PORTRAIT_SCALE * 0.55f
|
||||||
|
else -> PORTRAIT_SCALE * 0.5f
|
||||||
|
}
|
||||||
|
|
||||||
|
if (total <= 1) {
|
||||||
|
return Pair(Pair(baseX, baseY), scale)
|
||||||
|
}
|
||||||
|
|
||||||
|
val rowLength1 = when (total) {
|
||||||
|
2, 3, 4 -> 2
|
||||||
|
else -> 3
|
||||||
|
}
|
||||||
|
val rowLength2 = total - rowLength1
|
||||||
|
|
||||||
|
val isBottomRow = index >= rowLength1
|
||||||
|
val row = if (isBottomRow) 1 else 0
|
||||||
|
val col = if (isBottomRow) index - rowLength1 else index
|
||||||
|
val currentRowLength = if (isBottomRow) rowLength2 else rowLength1
|
||||||
|
|
||||||
|
val colSpacing = when (total) {
|
||||||
|
2 -> 35
|
||||||
|
3 -> 30
|
||||||
|
4 -> 25
|
||||||
|
else -> 23
|
||||||
|
}
|
||||||
|
val rowSpacing = when (total) {
|
||||||
|
2, 3 -> 30
|
||||||
|
4 -> 28
|
||||||
|
else -> 25
|
||||||
|
}
|
||||||
|
|
||||||
|
val totalWidth = (currentRowLength - 1) * colSpacing
|
||||||
|
val startX = baseX - (totalWidth / 2)
|
||||||
|
|
||||||
|
val totalHeight = if (rowLength2 > 0) rowSpacing else 0
|
||||||
|
var startY = baseY + 12 - (totalHeight / 2)
|
||||||
|
|
||||||
|
if (total >= 4) {
|
||||||
|
startY += 8
|
||||||
|
}
|
||||||
|
|
||||||
|
val posX = startX + (col * colSpacing)
|
||||||
|
val posY = startY + (row * rowSpacing)
|
||||||
|
|
||||||
|
return Pair(Pair(posX, posY), scale)
|
||||||
|
}
|
||||||
|
|
||||||
private fun playSound(soundEvent: SoundEvent): SoundInstance {
|
private fun playSound(soundEvent: SoundEvent): SoundInstance {
|
||||||
val soundInstance = SimpleSoundInstance.forUI(soundEvent, 1.0F)
|
val soundInstance = SimpleSoundInstance.forUI(soundEvent, 1.0F)
|
||||||
Minecraft.getInstance().soundManager.play(soundInstance)
|
Minecraft.getInstance().soundManager.play(soundInstance)
|
||||||
@@ -557,10 +791,10 @@ class TradeGUI(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun cancelTradeSound() {
|
private fun cancelTradeSound() {
|
||||||
if (tradeSoundInstance !== null) Minecraft.getInstance().soundManager.stop(tradeSoundInstance)
|
if (tradeSoundInstance != null) Minecraft.getInstance().soundManager.stop(tradeSoundInstance!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderPokemonInfo(pokemon: Pokemon?, isOpposing: Boolean, context: GuiGraphics, x: Int, y: Int, mouseX: Int, mouseY: Int) {
|
public fun renderPokemonInfo(pokemon: Pokemon?, isOpposing: Boolean, context: GuiGraphics, x: Int, y: Int, mouseX: Int, mouseY: Int) {
|
||||||
if (pokemon != null) {
|
if (pokemon != null) {
|
||||||
val matrices = context.pose()
|
val matrices = context.pose()
|
||||||
// Level
|
// Level
|
||||||
@@ -1047,4 +1281,4 @@ class TradeGUI(
|
|||||||
scale = SCALE
|
scale = SCALE
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* 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.bag
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.Cobblemon
|
||||||
|
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
|
||||||
|
import com.cobblemon.mod.common.item.bag.CobblemonBagMenu
|
||||||
|
import com.cobblemon.mod.common.net.messages.client.bag.UpdateBagMenuDataPacket
|
||||||
|
import net.minecraft.server.MinecraftServer
|
||||||
|
import net.minecraft.server.level.ServerPlayer
|
||||||
|
|
||||||
|
object UpdateBagMenuDataHandler : ServerNetworkPacketHandler<UpdateBagMenuDataPacket> {
|
||||||
|
override fun handle(packet: UpdateBagMenuDataPacket, server: MinecraftServer, player: ServerPlayer) {
|
||||||
|
if (player.containerMenu !is CobblemonBagMenu) {
|
||||||
|
Cobblemon.LOGGER.debug("Player {} interacted with invalid menu {}", player, player.containerMenu)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val menu = player.containerMenu as? CobblemonBagMenu ?: return
|
||||||
|
menu.currentlySelectedCategory = packet.categoryId
|
||||||
|
menu.scroll = packet.scroll
|
||||||
|
menu.currentlySelectedSort = packet.sort
|
||||||
|
menu.setupSlotsBasedOnContent()
|
||||||
|
}
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* 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.bag
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.Cobblemon
|
||||||
|
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
|
||||||
|
import com.cobblemon.mod.common.item.bag.CobblemonBagMenu
|
||||||
|
import com.cobblemon.mod.common.net.messages.client.bag.UseItemOnPokemonFromBagPacket
|
||||||
|
import net.minecraft.server.MinecraftServer
|
||||||
|
import net.minecraft.server.level.ServerPlayer
|
||||||
|
|
||||||
|
object UseItemOnPokemonFromBagHandler: ServerNetworkPacketHandler<UseItemOnPokemonFromBagPacket> {
|
||||||
|
override fun handle(packet: UseItemOnPokemonFromBagPacket, server: MinecraftServer, player: ServerPlayer) {
|
||||||
|
if (player.containerMenu !is CobblemonBagMenu) {
|
||||||
|
Cobblemon.LOGGER.debug("Player {} interacted with invalid menu {}", player, player.containerMenu)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val menu = player.containerMenu as? CobblemonBagMenu ?: return
|
||||||
|
menu.useHeldItemOnPokemon(packet.partySlot)
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -15,9 +15,9 @@ import net.minecraft.client.Minecraft
|
|||||||
|
|
||||||
object TradeAcceptanceChangedHandler : ClientNetworkPacketHandler<TradeAcceptanceChangedPacket> {
|
object TradeAcceptanceChangedHandler : ClientNetworkPacketHandler<TradeAcceptanceChangedPacket> {
|
||||||
override fun handle(packet: TradeAcceptanceChangedPacket, client: Minecraft) {
|
override fun handle(packet: TradeAcceptanceChangedPacket, client: Minecraft) {
|
||||||
if (CobblemonClient.trade?.myOffer?.get()?.uuid == packet.pokemonId) {
|
if (CobblemonClient.trade?.myOffer?.get()?.any { it.uuid == packet.pokemonId } == true) {
|
||||||
CobblemonClient.trade!!.oppositeAcceptedMyOffer.set(packet.accepted)
|
CobblemonClient.trade!!.oppositeAcceptedMyOffer.set(packet.accepted)
|
||||||
} else if (CobblemonClient.trade?.oppositeOffer?.get()?.uuid == packet.pokemonId) {
|
} else if (CobblemonClient.trade?.oppositeOffer?.get()?.any { it.uuid == packet.pokemonId } == true) {
|
||||||
CobblemonClient.trade!!.acceptedOppositeOffer = packet.accepted
|
CobblemonClient.trade!!.acceptedOppositeOffer = packet.accepted
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -16,6 +16,6 @@ import net.minecraft.client.Minecraft
|
|||||||
object TradeCompletedHandler : ClientNetworkPacketHandler<TradeCompletedPacket> {
|
object TradeCompletedHandler : ClientNetworkPacketHandler<TradeCompletedPacket> {
|
||||||
override fun handle(packet: TradeCompletedPacket, client: Minecraft) {
|
override fun handle(packet: TradeCompletedPacket, client: Minecraft) {
|
||||||
val trade = CobblemonClient.trade ?: return
|
val trade = CobblemonClient.trade ?: return
|
||||||
trade.completedEmitter.emit(packet.pokemonId1 to packet.pokemonId2)
|
trade.completedEmitter.emit(packet.pokemonIds1 to packet.pokemonIds2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -20,7 +20,7 @@ import net.minecraft.client.Minecraft
|
|||||||
|
|
||||||
object TradeStartedHandler : ClientNetworkPacketHandler<TradeStartedPacket> {
|
object TradeStartedHandler : ClientNetworkPacketHandler<TradeStartedPacket> {
|
||||||
override fun handle(packet: TradeStartedPacket, client: Minecraft) {
|
override fun handle(packet: TradeStartedPacket, client: Minecraft) {
|
||||||
Cobblemon.LOGGER.error("handle trade start from: " + packet.traderId)
|
Cobblemon.LOGGER.info("Trade started with {}", packet.traderId)
|
||||||
val trade = ClientTrade()
|
val trade = ClientTrade()
|
||||||
CobblemonClient.trade = trade
|
CobblemonClient.trade = trade
|
||||||
Minecraft.getInstance().setScreen(
|
Minecraft.getInstance().setScreen(
|
||||||
|
|||||||
+2
-2
@@ -18,9 +18,9 @@ object TradeUpdatedHandler : ClientNetworkPacketHandler<TradeUpdatedPacket> {
|
|||||||
val trade = CobblemonClient.trade ?: return
|
val trade = CobblemonClient.trade ?: return
|
||||||
|
|
||||||
if (packet.playerId == Minecraft.getInstance().player?.uuid) {
|
if (packet.playerId == Minecraft.getInstance().player?.uuid) {
|
||||||
trade.myOffer.set(packet.pokemon)
|
trade.myOffer.set(packet.pokemons)
|
||||||
} else {
|
} else {
|
||||||
trade.oppositeOffer.set(packet.pokemon)
|
trade.oppositeOffer.set(packet.pokemons)
|
||||||
}
|
}
|
||||||
trade.oppositeAcceptedMyOffer.set(false)
|
trade.oppositeAcceptedMyOffer.set(false)
|
||||||
trade.acceptedOppositeOffer = false
|
trade.acceptedOppositeOffer = false
|
||||||
|
|||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* 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.layer
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.client.CobblemonBakingOverrides
|
||||||
|
import com.cobblemon.mod.common.item.bag.CobblemonBagItem
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
|
import com.mojang.math.Axis
|
||||||
|
import net.minecraft.client.Minecraft
|
||||||
|
import net.minecraft.client.model.PlayerModel
|
||||||
|
import net.minecraft.client.renderer.MultiBufferSource
|
||||||
|
import net.minecraft.client.renderer.entity.RenderLayerParent
|
||||||
|
import net.minecraft.client.renderer.entity.layers.RenderLayer
|
||||||
|
import net.minecraft.client.renderer.texture.OverlayTexture
|
||||||
|
import net.minecraft.world.entity.EquipmentSlot
|
||||||
|
import net.minecraft.world.entity.player.Player
|
||||||
|
import net.minecraft.world.item.ItemDisplayContext
|
||||||
|
|
||||||
|
class CobblemonBagRenderer<T : Player>(renderLayerParent: RenderLayerParent<T, PlayerModel<T>>): RenderLayer<T, PlayerModel<T>>(renderLayerParent) {
|
||||||
|
override fun render(
|
||||||
|
poseStack: PoseStack,
|
||||||
|
bufferSource: MultiBufferSource,
|
||||||
|
packedLight: Int,
|
||||||
|
player: T,
|
||||||
|
limbSwing: Float,
|
||||||
|
limbSwingAmount: Float,
|
||||||
|
partialTick: Float,
|
||||||
|
ageInTicks: Float,
|
||||||
|
netHeadYaw: Float,
|
||||||
|
headPitch: Float
|
||||||
|
) {
|
||||||
|
val bagItem = player.getItemBySlot(EquipmentSlot.CHEST)
|
||||||
|
if (bagItem.item !is CobblemonBagItem) return
|
||||||
|
val model = CobblemonBakingOverrides.bagModels[bagItem.item]?.getModel() ?: return
|
||||||
|
|
||||||
|
player.level().profiler.push("cobblemon_bag_render")
|
||||||
|
poseStack.pushPose()
|
||||||
|
|
||||||
|
parentModel.body.translateAndRotate(poseStack)
|
||||||
|
|
||||||
|
poseStack.rotateAround(Axis.ZP.rotationDegrees(180F), 0F, 1F, 0F)
|
||||||
|
poseStack.translate(0.0, 1.0, 0.0)
|
||||||
|
|
||||||
|
Minecraft.getInstance().itemRenderer.render(
|
||||||
|
bagItem,
|
||||||
|
ItemDisplayContext.FIXED,
|
||||||
|
false,
|
||||||
|
poseStack,
|
||||||
|
bufferSource,
|
||||||
|
packedLight,
|
||||||
|
OverlayTexture.NO_OVERLAY,
|
||||||
|
model
|
||||||
|
)
|
||||||
|
|
||||||
|
poseStack.popPose()
|
||||||
|
player.level().profiler.pop()
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -34,6 +34,7 @@ import com.cobblemon.mod.common.client.render.models.blockbench.bedrock.animatio
|
|||||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.quirk.ModelQuirk
|
import com.cobblemon.mod.common.client.render.models.blockbench.quirk.ModelQuirk
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.quirk.QuirkData
|
import com.cobblemon.mod.common.client.render.models.blockbench.quirk.QuirkData
|
||||||
|
import com.cobblemon.mod.common.client.sound.instances.UIEntitySoundInstance
|
||||||
import com.cobblemon.mod.common.entity.PosableEntity
|
import com.cobblemon.mod.common.entity.PosableEntity
|
||||||
import com.cobblemon.mod.common.entity.PoseType
|
import com.cobblemon.mod.common.entity.PoseType
|
||||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||||
@@ -44,7 +45,6 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException
|
|||||||
import java.util.concurrent.ConcurrentLinkedQueue
|
import java.util.concurrent.ConcurrentLinkedQueue
|
||||||
import net.minecraft.client.Minecraft
|
import net.minecraft.client.Minecraft
|
||||||
import net.minecraft.client.multiplayer.ClientLevel
|
import net.minecraft.client.multiplayer.ClientLevel
|
||||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance
|
|
||||||
import net.minecraft.commands.arguments.item.ItemParser
|
import net.minecraft.commands.arguments.item.ItemParser
|
||||||
import net.minecraft.sounds.SoundEvent
|
import net.minecraft.sounds.SoundEvent
|
||||||
import net.minecraft.world.entity.Entity
|
import net.minecraft.world.entity.Entity
|
||||||
@@ -289,7 +289,7 @@ abstract class PosableState : Schedulable {
|
|||||||
entity.level().playLocalSound(entity, soundEvent, entity.soundSource, volume, pitch)
|
entity.level().playLocalSound(entity, soundEvent, entity.soundSource, volume, pitch)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Minecraft.getInstance().soundManager.play(SimpleSoundInstance.forUI(soundEvent, volume, pitch))
|
Minecraft.getInstance().soundManager.play(UIEntitySoundInstance(soundEvent, volume, pitch))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -19,6 +19,7 @@ import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
|
|||||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Bone
|
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Bone
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext
|
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext
|
||||||
import com.cobblemon.mod.common.client.sound.instances.AlphaCrySoundInstance
|
import com.cobblemon.mod.common.client.sound.instances.AlphaCrySoundInstance
|
||||||
|
import com.cobblemon.mod.common.client.sound.instances.UIEntitySoundInstance
|
||||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||||
import com.cobblemon.mod.common.util.effectiveName
|
import com.cobblemon.mod.common.util.effectiveName
|
||||||
import com.cobblemon.mod.common.util.genericRuntime
|
import com.cobblemon.mod.common.util.genericRuntime
|
||||||
@@ -31,7 +32,6 @@ import net.minecraft.client.Minecraft
|
|||||||
import net.minecraft.client.model.geom.ModelPart
|
import net.minecraft.client.model.geom.ModelPart
|
||||||
import net.minecraft.client.multiplayer.ClientLevel
|
import net.minecraft.client.multiplayer.ClientLevel
|
||||||
import net.minecraft.client.resources.sounds.EntityBoundSoundInstance
|
import net.minecraft.client.resources.sounds.EntityBoundSoundInstance
|
||||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance
|
|
||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.resources.ResourceLocation
|
||||||
import net.minecraft.sounds.SoundEvent
|
import net.minecraft.sounds.SoundEvent
|
||||||
import net.minecraft.world.entity.Entity
|
import net.minecraft.world.entity.Entity
|
||||||
@@ -121,7 +121,7 @@ class BedrockSoundKeyframe(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Minecraft.getInstance().soundManager.play(SimpleSoundInstance.forUI(soundEvent, 1F, 1F))
|
Minecraft.getInstance().soundManager.play(UIEntitySoundInstance(soundEvent))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -29,8 +29,8 @@ class FarfetchdGalarianModel(root: ModelPart) : PokemonPosableModel(root), Heade
|
|||||||
override var portraitScale = 2.6F
|
override var portraitScale = 2.6F
|
||||||
override var portraitTranslation = Vec3(-0.2, -1.0, 0.0)
|
override var portraitTranslation = Vec3(-0.2, -1.0, 0.0)
|
||||||
|
|
||||||
override var profileScale = 1.1F
|
override var profileScale = 0.93F
|
||||||
override var profileTranslation = Vec3(-0.1, 0.1, 0.0)
|
override var profileTranslation = Vec3(-0.1, 0.36, 0.0)
|
||||||
|
|
||||||
lateinit var standing: Pose
|
lateinit var standing: Pose
|
||||||
lateinit var walk: Pose
|
lateinit var walk: Pose
|
||||||
|
|||||||
+2
-2
@@ -28,8 +28,8 @@ class FarfetchdModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame,
|
|||||||
override var portraitScale = 2.6F
|
override var portraitScale = 2.6F
|
||||||
override var portraitTranslation = Vec3(-0.2, -1.0, 0.0)
|
override var portraitTranslation = Vec3(-0.2, -1.0, 0.0)
|
||||||
|
|
||||||
override var profileScale = 1.1F
|
override var profileScale = 0.93F
|
||||||
override var profileTranslation = Vec3(-0.1, 0.1, 0.0)
|
override var profileTranslation = Vec3(-0.1, 0.36, 0.0)
|
||||||
|
|
||||||
lateinit var standing: Pose
|
lateinit var standing: Pose
|
||||||
lateinit var walk: Pose
|
lateinit var walk: Pose
|
||||||
|
|||||||
+2
-2
@@ -23,8 +23,8 @@ class KabutoModel(root: ModelPart) : PokemonPosableModel(root) {
|
|||||||
override var portraitScale = 3.3F
|
override var portraitScale = 3.3F
|
||||||
override var portraitTranslation = Vec3(0.0, -3.3, 0.0)
|
override var portraitTranslation = Vec3(0.0, -3.3, 0.0)
|
||||||
|
|
||||||
override var profileScale = 1.6F
|
override var profileScale = 1.25F
|
||||||
override var profileTranslation = Vec3(0.0, -0.6, 0.0)
|
override var profileTranslation = Vec3(0.0, -0.17, 0.0)
|
||||||
|
|
||||||
lateinit var standing: CobblemonPose
|
lateinit var standing: CobblemonPose
|
||||||
lateinit var walk: CobblemonPose
|
lateinit var walk: CobblemonPose
|
||||||
|
|||||||
+2
-2
@@ -21,8 +21,8 @@ class HoothootModel (root: ModelPart) : PokemonPosableModel(root) {
|
|||||||
|
|
||||||
override var portraitScale = 2.2F
|
override var portraitScale = 2.2F
|
||||||
override var portraitTranslation = Vec3(-0.25, -0.9, 0.0)
|
override var portraitTranslation = Vec3(-0.25, -0.9, 0.0)
|
||||||
override var profileScale = 1.0F
|
override var profileScale = 0.82F
|
||||||
override var profileTranslation = Vec3(0.0, 0.3, 0.0)
|
override var profileTranslation = Vec3(0.0, 0.53, 0.0)
|
||||||
|
|
||||||
lateinit var standing: Pose
|
lateinit var standing: Pose
|
||||||
lateinit var walk: Pose
|
lateinit var walk: Pose
|
||||||
|
|||||||
+2
-2
@@ -29,8 +29,8 @@ class WooperModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame {
|
|||||||
override var portraitScale = 2.0F
|
override var portraitScale = 2.0F
|
||||||
override var portraitTranslation = Vec3(-0.15, -0.65, 0.0)
|
override var portraitTranslation = Vec3(-0.15, -0.65, 0.0)
|
||||||
|
|
||||||
override var profileScale = 0.9F
|
override var profileScale = 0.75F
|
||||||
override var profileTranslation = Vec3(0.0, 0.4, 0.0)
|
override var profileTranslation = Vec3(0.0, 0.6, 0.0)
|
||||||
|
|
||||||
lateinit var shoulderLeft: Pose
|
lateinit var shoulderLeft: Pose
|
||||||
lateinit var shoulderRight: Pose
|
lateinit var shoulderRight: Pose
|
||||||
|
|||||||
+2
-2
@@ -29,8 +29,8 @@ class WooperPaldeanModel(root: ModelPart) : PokemonPosableModel(root), HeadedFra
|
|||||||
override var portraitScale = 2.0F
|
override var portraitScale = 2.0F
|
||||||
override var portraitTranslation = Vec3(-0.15, -0.65, 0.0)
|
override var portraitTranslation = Vec3(-0.15, -0.65, 0.0)
|
||||||
|
|
||||||
override var profileScale = 0.9F
|
override var profileScale = 0.75F
|
||||||
override var profileTranslation = Vec3(0.0, 0.4, 0.0)
|
override var profileTranslation = Vec3(0.0, 0.6, 0.0)
|
||||||
|
|
||||||
lateinit var shoulderLeft: Pose
|
lateinit var shoulderLeft: Pose
|
||||||
lateinit var shoulderRight: Pose
|
lateinit var shoulderRight: Pose
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ class DusclopsModel (root: ModelPart) : PokemonPosableModel(root) {
|
|||||||
lateinit var battleidle: Pose
|
lateinit var battleidle: Pose
|
||||||
|
|
||||||
override fun registerPoses() {
|
override fun registerPoses() {
|
||||||
animations["cry"] = "q.bedrock_stateful('squirtle', 'cry')".asExpressionLike()
|
animations["cry"] = "q.bedrock_stateful('dusclops', 'cry')".asExpressionLike()
|
||||||
|
|
||||||
val blink = quirk { bedrockStateful("dusclops", "blink") }
|
val blink = quirk { bedrockStateful("dusclops", "blink") }
|
||||||
|
|
||||||
|
|||||||
+3
@@ -12,6 +12,7 @@ import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonP
|
|||||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
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
|
||||||
|
import com.cobblemon.mod.common.util.asExpressionLike
|
||||||
import net.minecraft.client.model.geom.ModelPart
|
import net.minecraft.client.model.geom.ModelPart
|
||||||
import net.minecraft.world.phys.Vec3
|
import net.minecraft.world.phys.Vec3
|
||||||
|
|
||||||
@@ -28,6 +29,8 @@ class MasquerainModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame
|
|||||||
lateinit var walk: Pose
|
lateinit var walk: Pose
|
||||||
lateinit var standing: Pose
|
lateinit var standing: Pose
|
||||||
override fun registerPoses() {
|
override fun registerPoses() {
|
||||||
|
animations["cry"] = "q.bedrock_stateful('masquerain', 'cry')".asExpressionLike()
|
||||||
|
|
||||||
val blink = quirk { bedrockStateful("masquerain", "blink") }
|
val blink = quirk { bedrockStateful("masquerain", "blink") }
|
||||||
standing = registerPose(
|
standing = registerPose(
|
||||||
poseName = "standing",
|
poseName = "standing",
|
||||||
|
|||||||
+3
@@ -14,6 +14,7 @@ import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonP
|
|||||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.ModelPartTransformation
|
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.client.render.models.blockbench.pose.Pose
|
||||||
import com.cobblemon.mod.common.entity.PoseType
|
import com.cobblemon.mod.common.entity.PoseType
|
||||||
|
import com.cobblemon.mod.common.util.asExpressionLike
|
||||||
import com.cobblemon.mod.common.util.isInWater
|
import com.cobblemon.mod.common.util.isInWater
|
||||||
import net.minecraft.client.model.geom.ModelPart
|
import net.minecraft.client.model.geom.ModelPart
|
||||||
import net.minecraft.world.phys.Vec3
|
import net.minecraft.world.phys.Vec3
|
||||||
@@ -36,6 +37,8 @@ class SurskitModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame {
|
|||||||
val wateroffset = -8
|
val wateroffset = -8
|
||||||
|
|
||||||
override fun registerPoses() {
|
override fun registerPoses() {
|
||||||
|
animations["cry"] = "q.bedrock_stateful('surskit', 'cry')".asExpressionLike()
|
||||||
|
|
||||||
val blink = quirk { bedrockStateful("surskit", "blink") }
|
val blink = quirk { bedrockStateful("surskit", "blink") }
|
||||||
standing = registerPose(
|
standing = registerPose(
|
||||||
poseName = "standing",
|
poseName = "standing",
|
||||||
|
|||||||
+3
@@ -14,6 +14,7 @@ import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonP
|
|||||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.ModelPartTransformation
|
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.client.render.models.blockbench.pose.Pose
|
||||||
import com.cobblemon.mod.common.entity.PoseType
|
import com.cobblemon.mod.common.entity.PoseType
|
||||||
|
import com.cobblemon.mod.common.util.asExpressionLike
|
||||||
import net.minecraft.client.model.geom.ModelPart
|
import net.minecraft.client.model.geom.ModelPart
|
||||||
import net.minecraft.world.phys.Vec3
|
import net.minecraft.world.phys.Vec3
|
||||||
|
|
||||||
@@ -36,6 +37,8 @@ class CombeeModel (root: ModelPart) : PokemonPosableModel(root) {
|
|||||||
val shoulderZOffset = 8
|
val shoulderZOffset = 8
|
||||||
|
|
||||||
override fun registerPoses() {
|
override fun registerPoses() {
|
||||||
|
animations["cry"] = "q.bedrock_stateful('combee', 'cry')".asExpressionLike()
|
||||||
|
|
||||||
val blink1 = quirk { bedrockStateful("combee", "blink_right") }
|
val blink1 = quirk { bedrockStateful("combee", "blink_right") }
|
||||||
val blink2 = quirk { bedrockStateful("combee", "blink_gender") }
|
val blink2 = quirk { bedrockStateful("combee", "blink_gender") }
|
||||||
val blink3 = quirk { bedrockStateful("combee", "blink_left") }
|
val blink3 = quirk { bedrockStateful("combee", "blink_left") }
|
||||||
|
|||||||
+3
@@ -12,6 +12,7 @@ import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonP
|
|||||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
|
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
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
|
||||||
|
import com.cobblemon.mod.common.util.asExpressionLike
|
||||||
import net.minecraft.client.model.geom.ModelPart
|
import net.minecraft.client.model.geom.ModelPart
|
||||||
import net.minecraft.world.phys.Vec3
|
import net.minecraft.world.phys.Vec3
|
||||||
|
|
||||||
@@ -30,6 +31,8 @@ class VespiquenModel (root: ModelPart) : PokemonPosableModel(root) {
|
|||||||
lateinit var standing: Pose
|
lateinit var standing: Pose
|
||||||
|
|
||||||
override fun registerPoses() {
|
override fun registerPoses() {
|
||||||
|
animations["cry"] = "q.bedrock_stateful('vespiquen', 'cry')".asExpressionLike()
|
||||||
|
|
||||||
val blink1 = quirk { bedrockStateful("vespiquen", "blink") }
|
val blink1 = quirk { bedrockStateful("vespiquen", "blink") }
|
||||||
val wingsleep = quirk { bedrockStateful("vespiquen", "sleep_flap") }
|
val wingsleep = quirk { bedrockStateful("vespiquen", "sleep_flap") }
|
||||||
|
|
||||||
|
|||||||
-62
@@ -1,62 +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.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 SerperiorModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame {
|
|
||||||
override val rootPart = root.registerChildWithAllChildren("serperior")
|
|
||||||
override val head = getPart("head_ai")
|
|
||||||
|
|
||||||
override var portraitScale = 2.5F
|
|
||||||
override var portraitTranslation = Vec3(-0.3, 1.25, 0.0)
|
|
||||||
|
|
||||||
override var profileScale = 0.6F
|
|
||||||
override var profileTranslation = Vec3(0.0, 0.8, 0.0)
|
|
||||||
|
|
||||||
lateinit var standing: Pose
|
|
||||||
lateinit var walk: Pose
|
|
||||||
lateinit var sleep: Pose
|
|
||||||
|
|
||||||
override val cryAnimation = CryProvider { bedrockStateful("serperior", "cry") }
|
|
||||||
|
|
||||||
override fun registerPoses() {
|
|
||||||
val blink = quirk { bedrockStateful("serperior", "blink") }
|
|
||||||
sleep = registerPose(
|
|
||||||
poseType = PoseType.SLEEP,
|
|
||||||
animations = arrayOf(bedrock("serperior", "sleep"))
|
|
||||||
)
|
|
||||||
|
|
||||||
standing = registerPose(
|
|
||||||
poseName = "standing",
|
|
||||||
poseTypes = PoseType.STATIONARY_POSES + PoseType.UI_POSES,
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
animations = arrayOf(
|
|
||||||
singleBoneLook(),
|
|
||||||
bedrock("serperior", "ground_idle")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
walk = registerPose(
|
|
||||||
poseName = "walk",
|
|
||||||
poseTypes = PoseType.MOVING_POSES,
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
animations = arrayOf(
|
|
||||||
singleBoneLook(),
|
|
||||||
bedrock("serperior", "ground_walk")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-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.gen5
|
|
||||||
|
|
||||||
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 ServineModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame, BipedFrame, BimanualFrame {
|
|
||||||
override val rootPart = root.registerChildWithAllChildren("servine")
|
|
||||||
override val head = getPart("head_ai")
|
|
||||||
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 = 2.6F
|
|
||||||
override var portraitTranslation = Vec3(-0.15, 0.75, 0.0)
|
|
||||||
override var profileScale = 0.8F
|
|
||||||
override var profileTranslation = Vec3(0.0, 0.55, 0.0)
|
|
||||||
|
|
||||||
lateinit var sleep: Pose
|
|
||||||
lateinit var standing: Pose
|
|
||||||
lateinit var walk: Pose
|
|
||||||
|
|
||||||
override val cryAnimation = CryProvider { bedrockStateful("servine", "cry") }
|
|
||||||
|
|
||||||
override fun registerPoses() {
|
|
||||||
val blink = quirk { bedrockStateful("servine", "blink") }
|
|
||||||
sleep = registerPose(
|
|
||||||
poseType = PoseType.SLEEP,
|
|
||||||
transformTicks = 10,
|
|
||||||
animations = arrayOf(bedrock("servine", "sleep"))
|
|
||||||
)
|
|
||||||
|
|
||||||
standing = registerPose(
|
|
||||||
poseName = "standing",
|
|
||||||
poseTypes = PoseType.STATIONARY_POSES + PoseType.UI_POSES,
|
|
||||||
transformTicks = 10,
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
animations = arrayOf(
|
|
||||||
singleBoneLook(),
|
|
||||||
bedrock("servine", "ground_idle")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
walk = registerPose(
|
|
||||||
poseName = "walking",
|
|
||||||
poseTypes = PoseType.MOVING_POSES,
|
|
||||||
transformTicks = 10,
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
animations = arrayOf(
|
|
||||||
singleBoneLook(),
|
|
||||||
bedrock("servine", "ground_walk")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-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.gen5
|
|
||||||
|
|
||||||
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 SnivyModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame, BipedFrame, BimanualFrame {
|
|
||||||
override val rootPart = root.registerChildWithAllChildren("snivy")
|
|
||||||
override val head = getPart("head_ai")
|
|
||||||
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 = 2.0F
|
|
||||||
override var portraitTranslation = Vec3(-0.15, 0.32, 0.0)
|
|
||||||
override var profileScale = 0.8F
|
|
||||||
override var profileTranslation = Vec3(0.0, 0.55, 0.0)
|
|
||||||
|
|
||||||
lateinit var sleep: Pose
|
|
||||||
lateinit var standing: Pose
|
|
||||||
lateinit var walk: Pose
|
|
||||||
|
|
||||||
override val cryAnimation = CryProvider { bedrockStateful("snivy", "cry") }
|
|
||||||
|
|
||||||
override fun registerPoses() {
|
|
||||||
val blink = quirk { bedrockStateful("snivy", "blink") }
|
|
||||||
sleep = registerPose(
|
|
||||||
poseType = PoseType.SLEEP,
|
|
||||||
transformTicks = 10,
|
|
||||||
animations = arrayOf(bedrock("snivy", "sleep"))
|
|
||||||
)
|
|
||||||
|
|
||||||
standing = registerPose(
|
|
||||||
poseName = "standing",
|
|
||||||
poseTypes = PoseType.STATIONARY_POSES + PoseType.UI_POSES,
|
|
||||||
transformTicks = 10,
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
animations = arrayOf(
|
|
||||||
singleBoneLook(),
|
|
||||||
bedrock("snivy", "ground_idle")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
walk = registerPose(
|
|
||||||
poseName = "walking",
|
|
||||||
poseTypes = PoseType.MOVING_POSES,
|
|
||||||
transformTicks = 10,
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
animations = arrayOf(
|
|
||||||
singleBoneLook(),
|
|
||||||
bedrock("snivy", "ground_walk")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -23,7 +23,7 @@ class CarbinkModel (root: ModelPart) : PokemonPosableModel(root) {
|
|||||||
override var portraitScale = 1.8F
|
override var portraitScale = 1.8F
|
||||||
override var portraitTranslation = Vec3(0.0, 0.2, 0.0)
|
override var portraitTranslation = Vec3(0.0, 0.2, 0.0)
|
||||||
|
|
||||||
override var profileScale = 0.85F
|
override var profileScale = 0.68F
|
||||||
override var profileTranslation = Vec3(0.0, 0.7, 0.0)
|
override var profileTranslation = Vec3(0.0, 0.7, 0.0)
|
||||||
|
|
||||||
lateinit var standing: CobblemonPose
|
lateinit var standing: CobblemonPose
|
||||||
|
|||||||
-85
@@ -1,85 +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.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 GourgeistModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame {
|
|
||||||
override val rootPart = root.registerChildWithAllChildren("gourgeist")
|
|
||||||
override val head = getPart("head")
|
|
||||||
|
|
||||||
override var portraitScale = 4.0F
|
|
||||||
override var portraitTranslation = Vec3(-0.1, 0.6, 0.0)
|
|
||||||
|
|
||||||
override var profileScale = 0.8F
|
|
||||||
override var profileTranslation = Vec3(0.0, 0.55, 0.0)
|
|
||||||
|
|
||||||
lateinit var standing: Pose
|
|
||||||
lateinit var walk: Pose
|
|
||||||
lateinit var hovering: Pose
|
|
||||||
lateinit var fly: Pose
|
|
||||||
lateinit var sleep: Pose
|
|
||||||
|
|
||||||
override val cryAnimation = CryProvider { bedrockStateful("gourgeist", "cry") }
|
|
||||||
|
|
||||||
override fun registerPoses() {
|
|
||||||
val blink = quirk { bedrockStateful("gourgeist", "blink") }
|
|
||||||
standing = registerPose(
|
|
||||||
poseName = "standing",
|
|
||||||
poseTypes = PoseType.UI_POSES + PoseType.STAND,
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
animations = arrayOf(
|
|
||||||
singleBoneLook(),
|
|
||||||
bedrock("gourgeist", "ground_idle")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
walk = registerPose(
|
|
||||||
poseName = "walk",
|
|
||||||
poseType = PoseType.WALK,
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
animations = arrayOf(
|
|
||||||
bedrock("gourgeist", "ground_walk")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
hovering = registerPose(
|
|
||||||
poseName = "hovering",
|
|
||||||
poseType = PoseType.HOVER,
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
animations = arrayOf(
|
|
||||||
bedrock("gourgeist", "air_idle")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
fly = registerPose(
|
|
||||||
poseName = "fly",
|
|
||||||
poseType = PoseType.FLY,
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
animations = arrayOf(
|
|
||||||
bedrock("gourgeist", "air_fly")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
sleep = registerPose(
|
|
||||||
poseName = "sleep",
|
|
||||||
poseType = PoseType.SLEEP,
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
animations = arrayOf(
|
|
||||||
bedrock("gourgeist", "sleep")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-77
@@ -1,77 +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.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.CobblemonPose
|
|
||||||
import com.cobblemon.mod.common.entity.PoseType
|
|
||||||
import net.minecraft.client.model.geom.ModelPart
|
|
||||||
import net.minecraft.world.phys.Vec3
|
|
||||||
|
|
||||||
class PumpkabooModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame {
|
|
||||||
override val rootPart = root.registerChildWithAllChildren("pumpkaboo")
|
|
||||||
override val head = getPart("head")
|
|
||||||
|
|
||||||
override var portraitScale = 3.5F
|
|
||||||
override var portraitTranslation = Vec3(0.0, -1.5, 0.0)
|
|
||||||
|
|
||||||
override var profileScale = 1.0F
|
|
||||||
override var profileTranslation = Vec3(0.0, 0.25, 0.0)
|
|
||||||
|
|
||||||
lateinit var standing: CobblemonPose
|
|
||||||
lateinit var walk: CobblemonPose
|
|
||||||
lateinit var battleidle: CobblemonPose
|
|
||||||
lateinit var sleep: CobblemonPose
|
|
||||||
|
|
||||||
override val cryAnimation = CryProvider { bedrockStateful("pumpkaboo", "cry") }
|
|
||||||
|
|
||||||
override fun registerPoses() {
|
|
||||||
val blink = quirk { bedrockStateful("pumpkaboo", "blink") }
|
|
||||||
val quirk = quirk { bedrockStateful("pumpkaboo", "quirk_idle") }
|
|
||||||
|
|
||||||
sleep = registerPose(
|
|
||||||
poseName = "sleep",
|
|
||||||
poseType = PoseType.SLEEP,
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
animations = arrayOf(
|
|
||||||
bedrock("pumpkaboo", "sleep")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
standing = registerPose(
|
|
||||||
poseName = "standing",
|
|
||||||
poseTypes = PoseType.STATIONARY_POSES + PoseType.UI_POSES,
|
|
||||||
quirks = arrayOf(blink, quirk),
|
|
||||||
animations = arrayOf(
|
|
||||||
singleBoneLook(),
|
|
||||||
bedrock("pumpkaboo", "ground_idle")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
walk = registerPose(
|
|
||||||
poseName = "walk",
|
|
||||||
poseTypes = PoseType.MOVING_POSES,
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
animations = arrayOf(
|
|
||||||
bedrock("pumpkaboo", "ground_walk")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
battleidle = registerPose(
|
|
||||||
poseName = "battleidle",
|
|
||||||
poseTypes = PoseType.STATIONARY_POSES,
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
animations = arrayOf(
|
|
||||||
bedrock("pumpkaboo", "battle_idle")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+2
-2
@@ -26,8 +26,8 @@ class ScatterbugModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame
|
|||||||
override var portraitScale = 2.6F
|
override var portraitScale = 2.6F
|
||||||
override var portraitTranslation = Vec3(-0.2, -1.9, 0.0)
|
override var portraitTranslation = Vec3(-0.2, -1.9, 0.0)
|
||||||
|
|
||||||
override var profileScale = 1.2F
|
override var profileScale = 0.98F
|
||||||
override var profileTranslation = Vec3(0.0, 0.05, 0.0)
|
override var profileTranslation = Vec3(0.0, 0.28, 0.0)
|
||||||
|
|
||||||
lateinit var standing: CobblemonPose
|
lateinit var standing: CobblemonPose
|
||||||
lateinit var walk: CobblemonPose
|
lateinit var walk: CobblemonPose
|
||||||
|
|||||||
+2
-2
@@ -36,8 +36,8 @@ class CharcadetModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame,
|
|||||||
override var portraitScale = 1.7F
|
override var portraitScale = 1.7F
|
||||||
override var portraitTranslation = Vec3(-0.15, 0.08, 0.0)
|
override var portraitTranslation = Vec3(-0.15, 0.08, 0.0)
|
||||||
|
|
||||||
override var profileScale = 0.8F
|
override var profileScale = 0.58F
|
||||||
override var profileTranslation = Vec3(0.0, 0.6, 0.0)
|
override var profileTranslation = Vec3(0.0, 0.91, 0.0)
|
||||||
|
|
||||||
lateinit var standing: CobblemonPose
|
lateinit var standing: CobblemonPose
|
||||||
lateinit var walking: CobblemonPose
|
lateinit var walking: CobblemonPose
|
||||||
|
|||||||
+2
-2
@@ -35,8 +35,8 @@ class QuaquavalModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame,
|
|||||||
override var portraitScale = 2.3F
|
override var portraitScale = 2.3F
|
||||||
override var portraitTranslation = Vec3(-0.42, 3.7, 0.0)
|
override var portraitTranslation = Vec3(-0.42, 3.7, 0.0)
|
||||||
|
|
||||||
override var profileScale = 0.32F
|
override var profileScale = 0.36F
|
||||||
override var profileTranslation = Vec3(0.0, 1.24, 0.0)
|
override var profileTranslation = Vec3(0.0, 1.19, 0.0)
|
||||||
|
|
||||||
lateinit var standing: CobblemonPose
|
lateinit var standing: CobblemonPose
|
||||||
lateinit var standing2: CobblemonPose
|
lateinit var standing2: CobblemonPose
|
||||||
|
|||||||
-208
@@ -1,208 +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.animation.WingFlapIdleAnimation
|
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.createTransformation
|
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BiWingedFrame
|
|
||||||
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.ModelPartTransformation
|
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.wavefunction.parabolaFunction
|
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.wavefunction.sineFunction
|
|
||||||
import com.cobblemon.mod.common.entity.PoseType
|
|
||||||
import com.cobblemon.mod.common.util.math.geometry.toRadians
|
|
||||||
import net.minecraft.client.model.geom.ModelPart
|
|
||||||
import net.minecraft.world.phys.Vec3
|
|
||||||
|
|
||||||
class SquawkabillyModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame, BipedFrame, BiWingedFrame {
|
|
||||||
override val rootPart = root.registerChildWithAllChildren("squawkabilly")
|
|
||||||
override val head = getPart("head")
|
|
||||||
override val leftWing = getPart("wing_left")
|
|
||||||
override val rightWing = getPart("wing_right")
|
|
||||||
override val leftLeg = getPart("leg_left")
|
|
||||||
override val rightLeg = getPart("leg_right")
|
|
||||||
private val tail = getPart("tail")
|
|
||||||
|
|
||||||
override var portraitScale = 2.0F
|
|
||||||
override var portraitTranslation = Vec3(-0.2, -0.2, 0.0)
|
|
||||||
|
|
||||||
override var profileScale = 0.85F
|
|
||||||
override var profileTranslation = Vec3(0.0, 0.51, 0.0)
|
|
||||||
|
|
||||||
lateinit var standing: Pose
|
|
||||||
lateinit var walk: Pose
|
|
||||||
lateinit var hovering: Pose
|
|
||||||
lateinit var flying: Pose
|
|
||||||
lateinit var shoulderLeft: Pose
|
|
||||||
lateinit var shoulderRight: Pose
|
|
||||||
|
|
||||||
override val cryAnimation = CryProvider { bedrockStateful("squawkabilly", "cry") }
|
|
||||||
|
|
||||||
val shoulderOffsetX = -1.0
|
|
||||||
val shoulderOffsetY = 0
|
|
||||||
override fun registerPoses() {
|
|
||||||
val blink = quirk { bedrockStateful("squawkabilly", "blink") }
|
|
||||||
|
|
||||||
standing = registerPose(
|
|
||||||
poseName = "standing",
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
poseTypes = PoseType.UI_POSES + PoseType.STAND,
|
|
||||||
transformTicks = 10,
|
|
||||||
animations = arrayOf(
|
|
||||||
singleBoneLook(),
|
|
||||||
bedrock("squawkabilly", "ground_idle")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
walk = registerPose(
|
|
||||||
poseName = "walk",
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
poseType = PoseType.WALK,
|
|
||||||
transformTicks = 10,
|
|
||||||
animations = arrayOf(
|
|
||||||
singleBoneLook(),
|
|
||||||
bedrock("squawkabilly", "ground_idle"),
|
|
||||||
rootPart.translation(
|
|
||||||
function = parabolaFunction(
|
|
||||||
peak = -4F,
|
|
||||||
period = 0.4F
|
|
||||||
),
|
|
||||||
timeVariable = { state, _, _ -> state.animationSeconds },
|
|
||||||
axis = ModelPartTransformation.Y_AXIS
|
|
||||||
),
|
|
||||||
head.translation(
|
|
||||||
function = sineFunction(
|
|
||||||
amplitude = (-20F).toRadians(),
|
|
||||||
period = 1F,
|
|
||||||
verticalShift = (-10F).toRadians()
|
|
||||||
),
|
|
||||||
axis = ModelPartTransformation.X_AXIS,
|
|
||||||
timeVariable = { state, _, _ -> state.animationSeconds }
|
|
||||||
),
|
|
||||||
leftLeg.rotation(
|
|
||||||
function = parabolaFunction(
|
|
||||||
tightness = -20F,
|
|
||||||
phaseShift = 0F,
|
|
||||||
verticalShift = (30F).toRadians()
|
|
||||||
),
|
|
||||||
axis = ModelPartTransformation.X_AXIS,
|
|
||||||
timeVariable = { _, _, ageInTicks -> ageInTicks / 20 },
|
|
||||||
),
|
|
||||||
rightLeg.rotation(
|
|
||||||
function = parabolaFunction(
|
|
||||||
tightness = -20F,
|
|
||||||
phaseShift = 0F,
|
|
||||||
verticalShift = (30F).toRadians()
|
|
||||||
),
|
|
||||||
axis = ModelPartTransformation.X_AXIS,
|
|
||||||
timeVariable = { _, _, ageInTicks -> ageInTicks / 20 },
|
|
||||||
),
|
|
||||||
tail.rotation(
|
|
||||||
function = sineFunction(
|
|
||||||
amplitude = (-5F).toRadians(),
|
|
||||||
period = 1F
|
|
||||||
),
|
|
||||||
axis = ModelPartTransformation.X_AXIS,
|
|
||||||
timeVariable = { _, _, ageInTicks -> ageInTicks / 20 },
|
|
||||||
),
|
|
||||||
wingFlap(
|
|
||||||
flapFunction = sineFunction(
|
|
||||||
amplitude = (-5F).toRadians(),
|
|
||||||
period = 0.4F,
|
|
||||||
phaseShift = 0.00F,
|
|
||||||
verticalShift = (-20F).toRadians()
|
|
||||||
),
|
|
||||||
timeVariable = { state, _, _ -> state.animationSeconds },
|
|
||||||
axis = ModelPartTransformation.Z_AXIS
|
|
||||||
),
|
|
||||||
rightWing.translation(
|
|
||||||
function = parabolaFunction(
|
|
||||||
tightness = -10F,
|
|
||||||
phaseShift = 30F,
|
|
||||||
verticalShift = (25F).toRadians()
|
|
||||||
),
|
|
||||||
axis = ModelPartTransformation.Y_AXIS,
|
|
||||||
timeVariable = { _, _, ageInTicks -> ageInTicks / 20 },
|
|
||||||
),
|
|
||||||
leftWing.translation(
|
|
||||||
function = parabolaFunction(
|
|
||||||
tightness = -10F,
|
|
||||||
phaseShift = 30F,
|
|
||||||
verticalShift = (25F).toRadians()
|
|
||||||
),
|
|
||||||
axis = ModelPartTransformation.Y_AXIS,
|
|
||||||
timeVariable = { _, _, ageInTicks -> ageInTicks / 20 },
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
hovering = registerPose(
|
|
||||||
poseName = "hovering",
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
poseTypes = setOf(PoseType.FLOAT, PoseType.HOVER),
|
|
||||||
transformTicks = 10,
|
|
||||||
animations = arrayOf(
|
|
||||||
singleBoneLook(),
|
|
||||||
WingFlapIdleAnimation(this,
|
|
||||||
flapFunction = sineFunction(verticalShift = -10F.toRadians(), period = 0.9F, amplitude = 0.9F),
|
|
||||||
timeVariable = { state, _, _ -> state.animationSeconds },
|
|
||||||
axis = ModelPartTransformation.Z_AXIS
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
flying = registerPose(
|
|
||||||
poseName = "flying",
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
poseTypes = setOf(PoseType.FLY, PoseType.SWIM),
|
|
||||||
transformTicks = 10,
|
|
||||||
animations = arrayOf(
|
|
||||||
singleBoneLook(),
|
|
||||||
WingFlapIdleAnimation(this,
|
|
||||||
flapFunction = sineFunction(verticalShift = -14F.toRadians(), period = 0.9F, amplitude = 0.9F),
|
|
||||||
timeVariable = { state, _, _ -> state.animationSeconds },
|
|
||||||
axis = ModelPartTransformation.Z_AXIS
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
shoulderLeft = registerPose(
|
|
||||||
poseType = PoseType.SHOULDER_LEFT,
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
animations = arrayOf(
|
|
||||||
singleBoneLook(),
|
|
||||||
bedrock("squawkabilly", "ground_idle")
|
|
||||||
),
|
|
||||||
transformedParts = arrayOf(
|
|
||||||
rootPart.createTransformation().addPosition(shoulderOffsetX, shoulderOffsetY, 0.0)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
shoulderRight = registerPose(
|
|
||||||
poseType = PoseType.SHOULDER_RIGHT,
|
|
||||||
quirks = arrayOf(blink),
|
|
||||||
animations = arrayOf(
|
|
||||||
singleBoneLook(),
|
|
||||||
bedrock("squawkabilly", "ground_idle")
|
|
||||||
),
|
|
||||||
transformedParts = arrayOf(
|
|
||||||
rootPart.createTransformation().addPosition(-shoulderOffsetX, shoulderOffsetY, 0.0)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
|
||||||
// override fun getFaintAnimation(
|
|
||||||
// pokemonEntity: PokemonEntity,
|
|
||||||
// state: PosableState<PokemonEntity>
|
|
||||||
// ) = if (state.isNotPosedIn(sleep)) bedrockStateful("squawkabilly", "faint") else null
|
|
||||||
}
|
|
||||||
-6
@@ -322,8 +322,6 @@ object VaryingModelRepository {
|
|||||||
inbuilt("loudred", :: LoudredModel)
|
inbuilt("loudred", :: LoudredModel)
|
||||||
inbuilt("exploud", :: ExploudModel)
|
inbuilt("exploud", :: ExploudModel)
|
||||||
inbuilt("cryogonal", :: CryogonalModel)
|
inbuilt("cryogonal", :: CryogonalModel)
|
||||||
inbuilt("pumpkaboo", :: PumpkabooModel)
|
|
||||||
inbuilt("gourgeist", :: GourgeistModel)
|
|
||||||
inbuilt("eiscue", :: EiscueModel)
|
inbuilt("eiscue", :: EiscueModel)
|
||||||
inbuilt("wooloo", :: WoolooModel)
|
inbuilt("wooloo", :: WoolooModel)
|
||||||
inbuilt("dubwool", :: DubwoolModel)
|
inbuilt("dubwool", :: DubwoolModel)
|
||||||
@@ -340,9 +338,6 @@ object VaryingModelRepository {
|
|||||||
inbuilt("thwackey", ::ThwackeyModel)
|
inbuilt("thwackey", ::ThwackeyModel)
|
||||||
inbuilt("rillaboom", ::RillaboomModel)
|
inbuilt("rillaboom", ::RillaboomModel)
|
||||||
inbuilt("samurott", ::SamurottModel)
|
inbuilt("samurott", ::SamurottModel)
|
||||||
inbuilt("snivy", ::SnivyModel)
|
|
||||||
inbuilt("servine", ::ServineModel)
|
|
||||||
inbuilt("serperior", ::SerperiorModel)
|
|
||||||
inbuilt("slugma", ::SlugmaModel)
|
inbuilt("slugma", ::SlugmaModel)
|
||||||
inbuilt("magcargo", ::MagcargoModel)
|
inbuilt("magcargo", ::MagcargoModel)
|
||||||
inbuilt("slugma_shiny", ::SlugmaShinyModel)
|
inbuilt("slugma_shiny", ::SlugmaShinyModel)
|
||||||
@@ -402,7 +397,6 @@ object VaryingModelRepository {
|
|||||||
inbuilt("bunnelby", ::BunnelbyModel)
|
inbuilt("bunnelby", ::BunnelbyModel)
|
||||||
inbuilt("arrokuda", ::ArrokudaModel)
|
inbuilt("arrokuda", ::ArrokudaModel)
|
||||||
inbuilt("barraskewda", ::BarraskewdaModel)
|
inbuilt("barraskewda", ::BarraskewdaModel)
|
||||||
inbuilt("squawkabilly", ::SquawkabillyModel)
|
|
||||||
inbuilt("ponyta_galarian", ::PonytaGalarianModel)
|
inbuilt("ponyta_galarian", ::PonytaGalarianModel)
|
||||||
inbuilt("rapidash_galarian", ::RapidashGalarianModel)
|
inbuilt("rapidash_galarian", ::RapidashGalarianModel)
|
||||||
inbuilt("volbeat", ::VolbeatModel)
|
inbuilt("volbeat", ::VolbeatModel)
|
||||||
|
|||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 Cobblemon Contributors
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.cobblemon.mod.common.client.sound.instances
|
||||||
|
|
||||||
|
import net.minecraft.client.resources.sounds.SimpleSoundInstance
|
||||||
|
import net.minecraft.client.resources.sounds.SoundInstance
|
||||||
|
import net.minecraft.sounds.SoundEvent
|
||||||
|
import net.minecraft.sounds.SoundSource
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plays a sound for a Pokémon rendered in a GUI, where there is no entity to take the sound source from.
|
||||||
|
* Unlike [SimpleSoundInstance.forUI] this uses [SoundSource.NEUTRAL] so the Friendly Creatures slider applies.
|
||||||
|
*/
|
||||||
|
class UIEntitySoundInstance(sound: SoundEvent, volume: Float = 1F, pitch: Float = 1F) :
|
||||||
|
SimpleSoundInstance(sound.location, SoundSource.NEUTRAL, volume, pitch, SoundInstance.createUnseededRandom(),
|
||||||
|
false, 0, SoundInstance.Attenuation.NONE, 0.0, 0.0, 0.0, true)
|
||||||
@@ -14,12 +14,12 @@ import com.cobblemon.mod.common.pokemon.Pokemon
|
|||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
class ClientTrade {
|
class ClientTrade {
|
||||||
var myOffer = SettableObservable<Pokemon?>(null)
|
var myOffer = SettableObservable<List<Pokemon>>(emptyList())
|
||||||
var oppositeOffer = SettableObservable<Pokemon?>(null)
|
var oppositeOffer = SettableObservable<List<Pokemon>>(emptyList())
|
||||||
var tradeProcessing = SettableObservable(Pair(false, false))
|
var tradeProcessing = SettableObservable(Pair(false, false))
|
||||||
var oppositeAcceptedMyOffer = SettableObservable(false)
|
var oppositeAcceptedMyOffer = SettableObservable(false)
|
||||||
var acceptedOppositeOffer = false
|
var acceptedOppositeOffer = false
|
||||||
|
|
||||||
var completedEmitter = SimpleObservable<Pair<UUID, UUID>>()
|
var completedEmitter = SimpleObservable<Pair<List<UUID>, List<UUID>>>()
|
||||||
var cancelEmitter = SimpleObservable<Unit>()
|
var cancelEmitter = SimpleObservable<Unit>()
|
||||||
}
|
}
|
||||||
@@ -164,6 +164,9 @@ class CobblemonConfig {
|
|||||||
@CobblemonConfigField(Category.Pokemon, lang = "experience_multiplier", SERVER)
|
@CobblemonConfigField(Category.Pokemon, lang = "experience_multiplier", SERVER)
|
||||||
var experienceMultiplier = 2F
|
var experienceMultiplier = 2F
|
||||||
|
|
||||||
|
@CobblemonConfigField(Category.Pokemon, lang = "predation_chance", SERVER)
|
||||||
|
var predationChance = 0.05F
|
||||||
|
|
||||||
@CobblemonConfigField(Category.Spawning, lang = "pokemon_per_chunk", SERVER)
|
@CobblemonConfigField(Category.Spawning, lang = "pokemon_per_chunk", SERVER)
|
||||||
var pokemonPerChunk = 1F
|
var pokemonPerChunk = 1F
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ package com.cobblemon.mod.common.data
|
|||||||
import com.cobblemon.mod.common.*
|
import com.cobblemon.mod.common.*
|
||||||
import com.cobblemon.mod.common.Cobblemon.LOGGER
|
import com.cobblemon.mod.common.Cobblemon.LOGGER
|
||||||
import com.cobblemon.mod.common.api.abilities.Abilities
|
import com.cobblemon.mod.common.api.abilities.Abilities
|
||||||
|
import com.cobblemon.mod.common.api.bag.BagCategories
|
||||||
|
import com.cobblemon.mod.common.api.bag.BagSortComparators
|
||||||
import com.cobblemon.mod.common.api.berry.Berries
|
import com.cobblemon.mod.common.api.berry.Berries
|
||||||
import com.cobblemon.mod.common.api.cooking.Seasonings
|
import com.cobblemon.mod.common.api.cooking.Seasonings
|
||||||
import com.cobblemon.mod.common.api.data.DataProvider
|
import com.cobblemon.mod.common.api.data.DataProvider
|
||||||
@@ -120,7 +122,9 @@ object CobblemonDataProvider : DataProvider {
|
|||||||
this.register(SpawnBaitEffects, reloadable = false)
|
this.register(SpawnBaitEffects, reloadable = false)
|
||||||
this.register(CobblemonRideSettings, reloadable = true)
|
this.register(CobblemonRideSettings, reloadable = true)
|
||||||
this.register(TechnicalMachines, reloadable = false)
|
this.register(TechnicalMachines, reloadable = false)
|
||||||
|
this.register(BagCategories, reloadable = false)
|
||||||
SpawnBait.Effects.setupEffects()
|
SpawnBait.Effects.setupEffects()
|
||||||
|
BagSortComparators.setupComparators()
|
||||||
|
|
||||||
PlatformEvents.SERVER_PLAYER_LOGOUT.subscribe {
|
PlatformEvents.SERVER_PLAYER_LOGOUT.subscribe {
|
||||||
synchronizedPlayerIds.remove(it.player.uuid)
|
synchronizedPlayerIds.remove(it.player.uuid)
|
||||||
|
|||||||
-1
@@ -160,5 +160,4 @@ class CobblemonChestBoatEntity(entityType: EntityType<CobblemonChestBoatEntity>,
|
|||||||
private const val INVENTORY_SLOTS = 27
|
private const val INVENTORY_SLOTS = 27
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1294,16 +1294,7 @@ open class PokemonEntity(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun showInteractionWheel(player: ServerPlayer, itemStack: ItemStack) {
|
private fun showInteractionWheel(player: ServerPlayer, itemStack: ItemStack) {
|
||||||
val canRide = ifRidingAvailableSupply(false) { behaviour, settings, state ->
|
val canRide = isRideableFor(player)
|
||||||
if (platform != PlatformType.NONE) return@ifRidingAvailableSupply false
|
|
||||||
if (tethering != null) return@ifRidingAvailableSupply false;
|
|
||||||
if (seats.isEmpty()) return@ifRidingAvailableSupply false;
|
|
||||||
if ((owner as? ServerPlayer)?.isInBattle() == true) return@ifRidingAvailableSupply false;
|
|
||||||
if (this.owner != player && this.passengers.isEmpty()) return@ifRidingAvailableSupply false;
|
|
||||||
if(pokemon.effectiveScale < Cobblemon.config.minimumRidingScale) return@ifRidingAvailableSupply false;
|
|
||||||
if(beamMode == 3) return@ifRidingAvailableSupply false;
|
|
||||||
return@ifRidingAvailableSupply behaviour.isActive(settings, state, this);
|
|
||||||
}
|
|
||||||
if (pokemon.getOwnerPlayer() == player) {
|
if (pokemon.getOwnerPlayer() == player) {
|
||||||
val cosmeticItemDefinition = CobblemonCosmeticItems.findValidCosmeticForPokemonAndItem(
|
val cosmeticItemDefinition = CobblemonCosmeticItems.findValidCosmeticForPokemonAndItem(
|
||||||
player.level().registryAccess(),
|
player.level().registryAccess(),
|
||||||
@@ -1325,6 +1316,18 @@ open class PokemonEntity(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isRideableFor(player: ServerPlayer): Boolean = ifRidingAvailableSupply(false) canRide@{ behaviour, settings, state ->
|
||||||
|
if (!player.canInteractWithEntity(this, player.entityInteractionRange())) return@canRide false
|
||||||
|
if (platform != PlatformType.NONE) return@canRide false
|
||||||
|
if (tethering != null) return@canRide false
|
||||||
|
if (seats.isEmpty()) return@canRide false
|
||||||
|
if ((owner as? ServerPlayer)?.isInBattle() == true) return@canRide false
|
||||||
|
if (this.owner != player && this.passengers.isEmpty()) return@canRide false
|
||||||
|
if (pokemon.effectiveScale < Cobblemon.config.minimumRidingScale) return@canRide false
|
||||||
|
if (beamMode == 3) return@canRide false
|
||||||
|
return@canRide behaviour.isActive(settings, state, this)
|
||||||
|
}
|
||||||
|
|
||||||
override fun getDimensions(pose: Pose): EntityDimensions {
|
override fun getDimensions(pose: Pose): EntityDimensions {
|
||||||
val scale = effects.mockEffect?.scale ?: (form.baseScale * pokemon.effectiveScale)
|
val scale = effects.mockEffect?.scale ?: (form.baseScale * pokemon.effectiveScale)
|
||||||
var result = this.exposedForm.hitbox.scale(scale)
|
var result = this.exposedForm.hitbox.scale(scale)
|
||||||
@@ -1606,9 +1609,8 @@ open class PokemonEntity(
|
|||||||
|| stack.`is`(CobblemonItemTags.WHITELISTED_ITEMS_TO_HOLD)
|
|| stack.`is`(CobblemonItemTags.WHITELISTED_ITEMS_TO_HOLD)
|
||||||
|
|
||||||
fun tryRidingPokemon(player: ServerPlayer): Boolean {
|
fun tryRidingPokemon(player: ServerPlayer): Boolean {
|
||||||
if (pokemon.effectiveScale < Cobblemon.config.minimumRidingScale) {
|
if (!isRideableFor(player)) return false
|
||||||
return false
|
|
||||||
}
|
|
||||||
val event = RidePokemonEvent.Pre(player, this)
|
val event = RidePokemonEvent.Pre(player, this)
|
||||||
CobblemonEvents.RIDE_EVENT_PRE.post(event)
|
CobblemonEvents.RIDE_EVENT_PRE.post(event)
|
||||||
if (!event.isCanceled) {
|
if (!event.isCanceled) {
|
||||||
@@ -2742,4 +2744,9 @@ open class PokemonEntity(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun hasRider() = this.passengers.any { it is LivingEntity }
|
fun hasRider() = this.passengers.any { it is LivingEntity }
|
||||||
}
|
|
||||||
|
override fun playStepSound(pos: BlockPos, state: BlockState) {
|
||||||
|
if (this.pokemon.species.silenceStepSounds) return
|
||||||
|
super.playStepSound(pos, state)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,6 +31,7 @@ import net.minecraft.world.item.BlockItem
|
|||||||
import com.cobblemon.mod.common.platform.events.ServerPlayerEvent
|
import com.cobblemon.mod.common.platform.events.ServerPlayerEvent
|
||||||
import com.cobblemon.mod.common.api.storage.player.PlayerInstancedDataStoreTypes
|
import com.cobblemon.mod.common.api.storage.player.PlayerInstancedDataStoreTypes
|
||||||
import com.cobblemon.mod.common.item.GemItem
|
import com.cobblemon.mod.common.item.GemItem
|
||||||
|
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||||
import com.cobblemon.mod.common.platform.events.PlatformEvents
|
import com.cobblemon.mod.common.platform.events.PlatformEvents
|
||||||
import com.cobblemon.mod.common.util.effectiveName
|
import com.cobblemon.mod.common.util.effectiveName
|
||||||
import com.cobblemon.mod.common.util.getPlayer
|
import com.cobblemon.mod.common.util.getPlayer
|
||||||
@@ -164,26 +165,21 @@ object AdvancementHandler : EventHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onTradeCompleted(event : TradeEvent.Post) {
|
fun onTradeCompleted(event : TradeEvent.Post) {
|
||||||
val player1 = event.tradeParticipant1Pokemon.getOwnerPlayer()
|
onTradeCompleted(event.tradeParticipant1Pokemon, event.tradeParticipant2Pokemon)
|
||||||
val player2 = event.tradeParticipant2Pokemon.getOwnerPlayer()
|
onTradeCompleted(event.tradeParticipant2Pokemon, event.tradeParticipant1Pokemon)
|
||||||
if (player1 != null) {
|
}
|
||||||
CobblemonCriteria.TRADE_POKEMON.trigger(player1, TradePokemonContext(event.tradeParticipant1Pokemon, event.tradeParticipant2Pokemon))
|
|
||||||
val playerData = Cobblemon.playerDataManager.getGenericData(player1)
|
private fun onTradeCompleted(received: List<Pokemon>, traded: List<Pokemon>) {
|
||||||
val advancementData = playerData.advancementData
|
val player = received.firstOrNull()?.getOwnerPlayer() ?: return
|
||||||
advancementData.updateTotalTradedCount()
|
received.forEach { receivedPokemon ->
|
||||||
advancementData.updateAspectsCollected(player1, event.tradeParticipant2Pokemon)
|
traded.forEach { tradedPokemon -> CobblemonCriteria.TRADE_POKEMON.trigger(player, TradePokemonContext(tradedPokemon, receivedPokemon)) }
|
||||||
CobblemonCriteria.COLLECT_ASPECT.trigger(player1, advancementData.aspectsCollected)
|
|
||||||
Cobblemon.playerDataManager.saveSingle(playerData, PlayerInstancedDataStoreTypes.GENERAL)
|
|
||||||
}
|
|
||||||
if (player2 != null) {
|
|
||||||
CobblemonCriteria.TRADE_POKEMON.trigger(player2, TradePokemonContext(event.tradeParticipant2Pokemon, event.tradeParticipant1Pokemon))
|
|
||||||
val playerData = Cobblemon.playerDataManager.getGenericData(player2)
|
|
||||||
val advancementData = playerData.advancementData
|
|
||||||
advancementData.updateTotalTradedCount()
|
|
||||||
advancementData.updateAspectsCollected(player2, event.tradeParticipant1Pokemon)
|
|
||||||
CobblemonCriteria.COLLECT_ASPECT.trigger(player2, advancementData.aspectsCollected)
|
|
||||||
Cobblemon.playerDataManager.saveSingle(playerData, PlayerInstancedDataStoreTypes.GENERAL)
|
|
||||||
}
|
}
|
||||||
|
val playerData = Cobblemon.playerDataManager.getGenericData(player)
|
||||||
|
val advancementData = playerData.advancementData
|
||||||
|
advancementData.updateTotalTradedCount()
|
||||||
|
received.forEach { advancementData.updateAspectsCollected(player, it) }
|
||||||
|
CobblemonCriteria.COLLECT_ASPECT.trigger(player, advancementData.aspectsCollected)
|
||||||
|
Cobblemon.playerDataManager.saveSingle(playerData, PlayerInstancedDataStoreTypes.GENERAL)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -110,8 +110,8 @@ object StatHandler : EventHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onTradeCompleted(event : TradeEvent.Post) {
|
fun onTradeCompleted(event : TradeEvent.Post) {
|
||||||
event.tradeParticipant1Pokemon.getOwnerPlayer()?.awardStat(getStat(Cobblemon.statistics.TRADED))
|
event.tradeParticipant1Pokemon.firstOrNull()?.getOwnerPlayer()?.awardStat(getStat(Cobblemon.statistics.TRADED))
|
||||||
event.tradeParticipant2Pokemon.getOwnerPlayer()?.awardStat(getStat(Cobblemon.statistics.TRADED))
|
event.tradeParticipant2Pokemon.firstOrNull()?.getOwnerPlayer()?.awardStat(getStat(Cobblemon.statistics.TRADED))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onFossilRevived(event : FossilRevivedEvent) {
|
fun onFossilRevived(event : FossilRevivedEvent) {
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* 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.item.bag
|
||||||
|
|
||||||
|
import net.minecraft.core.HolderLookup
|
||||||
|
import net.minecraft.nbt.CompoundTag
|
||||||
|
import net.minecraft.nbt.ListTag
|
||||||
|
import net.minecraft.world.Container
|
||||||
|
import net.minecraft.world.ContainerHelper
|
||||||
|
import net.minecraft.world.entity.player.Player
|
||||||
|
import net.minecraft.world.item.ItemStack
|
||||||
|
import kotlin.math.min
|
||||||
|
|
||||||
|
class CobblemonBagContainer: Container {
|
||||||
|
val items: MutableList<ItemStack> = mutableListOf()
|
||||||
|
|
||||||
|
override fun getContainerSize(): Int {
|
||||||
|
return items.size
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItem(slot: Int): ItemStack {
|
||||||
|
if (slot >= items.size) return ItemStack.EMPTY
|
||||||
|
return items[slot]
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isEmpty(): Boolean {
|
||||||
|
return items.isEmpty()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun removeItem(slot: Int, amount: Int): ItemStack {
|
||||||
|
if (slot >= items.size) return ItemStack.EMPTY
|
||||||
|
val itemStack = items[slot].split(amount)
|
||||||
|
if (items[slot].isEmpty) {
|
||||||
|
items.removeAt(slot)
|
||||||
|
}
|
||||||
|
return itemStack
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun removeItemNoUpdate(slot: Int): ItemStack { return ItemStack.EMPTY }
|
||||||
|
|
||||||
|
override fun clearContent() {
|
||||||
|
items.clear()
|
||||||
|
setChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setChanged() {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setItem(slot: Int, stack: ItemStack) {} // Obsolete
|
||||||
|
|
||||||
|
override fun stillValid(player: Player): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getMaxStackSize(): Int {
|
||||||
|
return 99999
|
||||||
|
}
|
||||||
|
|
||||||
|
fun fromTag(tag: ListTag, levelRegistry: HolderLookup.Provider) {
|
||||||
|
items.clear()
|
||||||
|
|
||||||
|
tag.forEach {
|
||||||
|
val compoundTag = it as CompoundTag
|
||||||
|
val count = compoundTag.getInt("count")
|
||||||
|
compoundTag.putInt("count", 1)
|
||||||
|
val item = ItemStack.parse(levelRegistry, it)
|
||||||
|
item.ifPresent { theItem ->
|
||||||
|
theItem.count = count
|
||||||
|
items.add(theItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun createTag(levelRegistry: HolderLookup.Provider): ListTag {
|
||||||
|
val tag = ListTag()
|
||||||
|
|
||||||
|
items.forEach {
|
||||||
|
val fakeItem = it.copyWithCount(1)
|
||||||
|
val compoundTag = fakeItem.save(levelRegistry) as CompoundTag
|
||||||
|
compoundTag.putInt("count", it.count) // ItemStack does not save count above 99 for some reason, so we save it ourselves
|
||||||
|
tag.add(compoundTag)
|
||||||
|
}
|
||||||
|
|
||||||
|
return tag
|
||||||
|
}
|
||||||
|
|
||||||
|
fun dropAll(player: Player) {
|
||||||
|
items.forEach {
|
||||||
|
player.drop(it, true, false)
|
||||||
|
}
|
||||||
|
items.clear()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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.item.bag
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.CobblemonSounds
|
||||||
|
import com.cobblemon.mod.common.item.CobblemonItem
|
||||||
|
import com.cobblemon.mod.common.bag.BagEntity
|
||||||
|
import net.minecraft.client.Minecraft
|
||||||
|
import net.minecraft.client.resources.sounds.SimpleSoundInstance
|
||||||
|
import net.minecraft.core.Holder
|
||||||
|
import net.minecraft.network.chat.Component
|
||||||
|
import net.minecraft.sounds.SoundEvent
|
||||||
|
import net.minecraft.world.InteractionHand
|
||||||
|
import net.minecraft.world.InteractionResultHolder
|
||||||
|
import net.minecraft.world.MenuProvider
|
||||||
|
import net.minecraft.world.entity.EquipmentSlot
|
||||||
|
import net.minecraft.world.entity.player.Inventory
|
||||||
|
import net.minecraft.world.entity.player.Player
|
||||||
|
import net.minecraft.world.inventory.AbstractContainerMenu
|
||||||
|
import net.minecraft.world.item.Equipable
|
||||||
|
import net.minecraft.world.item.ItemStack
|
||||||
|
import net.minecraft.world.level.Level
|
||||||
|
|
||||||
|
class CobblemonBagItem: CobblemonItem(Properties().stacksTo(1)), MenuProvider, Equipable {
|
||||||
|
override fun use(level: Level, player: Player, usedHand: InteractionHand): InteractionResultHolder<ItemStack?> {
|
||||||
|
val itemStack = player.getItemInHand(usedHand)
|
||||||
|
player.openMenu(this)
|
||||||
|
return InteractionResultHolder.success(itemStack)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createMenu(i: Int, inventory: Inventory, player: Player): AbstractContainerMenu {
|
||||||
|
val bagEntity = (player as? BagEntity)
|
||||||
|
val container = bagEntity?.`cobblemon$getBagContainer`() ?: CobblemonBagContainer()
|
||||||
|
|
||||||
|
return CobblemonBagMenu(i, inventory, container)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getDisplayName(): Component? {
|
||||||
|
return Component.translatable("cobblemon.container.bag")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getEquipmentSlot(): EquipmentSlot = EquipmentSlot.CHEST
|
||||||
|
|
||||||
|
override fun getEquipSound(): Holder<SoundEvent?>? {
|
||||||
|
Minecraft.getInstance().soundManager.play(SimpleSoundInstance.forUI(CobblemonSounds.ITEM_BAG_EQUIP, 1.0F))
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,458 @@
|
|||||||
|
/*
|
||||||
|
* 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.item.bag
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.Cobblemon
|
||||||
|
import com.cobblemon.mod.common.CobblemonMenuType
|
||||||
|
import com.cobblemon.mod.common.CobblemonSounds
|
||||||
|
import com.cobblemon.mod.common.advancement.CobblemonCriteria
|
||||||
|
import com.cobblemon.mod.common.advancement.criterion.PokemonInteractContext
|
||||||
|
import com.cobblemon.mod.common.api.bag.BagCategories
|
||||||
|
import com.cobblemon.mod.common.api.bag.BagCategory
|
||||||
|
import com.cobblemon.mod.common.api.bag.BagSortComparators
|
||||||
|
import com.cobblemon.mod.common.api.item.PokemonSelectingItem
|
||||||
|
import com.cobblemon.mod.common.api.storage.party.PartyStore
|
||||||
|
import com.cobblemon.mod.common.api.tags.CobblemonItemTags
|
||||||
|
import com.cobblemon.mod.common.client.CobblemonClient
|
||||||
|
import com.cobblemon.mod.common.util.isInBattle
|
||||||
|
import net.minecraft.CrashReport
|
||||||
|
import net.minecraft.ReportedException
|
||||||
|
import net.minecraft.client.Minecraft
|
||||||
|
import net.minecraft.client.resources.sounds.SimpleSoundInstance
|
||||||
|
import net.minecraft.core.NonNullList
|
||||||
|
import net.minecraft.core.registries.BuiltInRegistries
|
||||||
|
import net.minecraft.server.level.ServerPlayer
|
||||||
|
import net.minecraft.sounds.SoundEvent
|
||||||
|
import net.minecraft.world.InteractionResult
|
||||||
|
import net.minecraft.world.SimpleContainer
|
||||||
|
import net.minecraft.world.entity.player.Inventory
|
||||||
|
import net.minecraft.world.entity.player.Player
|
||||||
|
import net.minecraft.world.inventory.AbstractContainerMenu
|
||||||
|
import net.minecraft.world.inventory.ClickAction
|
||||||
|
import net.minecraft.world.inventory.ClickType
|
||||||
|
import net.minecraft.world.inventory.Slot
|
||||||
|
import net.minecraft.world.item.ItemStack
|
||||||
|
import kotlin.math.ceil
|
||||||
|
import kotlin.math.max
|
||||||
|
import kotlin.math.min
|
||||||
|
|
||||||
|
class CobblemonBagMenu: AbstractContainerMenu {
|
||||||
|
companion object {
|
||||||
|
val BAG_SLOTS = 0..31
|
||||||
|
private val PARTY_SLOTS = 32..37
|
||||||
|
private val INVENTORY_SLOTS = 38..64
|
||||||
|
private val HOTBAR_SLOTS = 65..73
|
||||||
|
}
|
||||||
|
|
||||||
|
private val playerInventory: Inventory
|
||||||
|
private val bagContainer: CobblemonBagContainer
|
||||||
|
private val partyContainer: SimpleContainer
|
||||||
|
|
||||||
|
private var serverParty: PartyStore? = null
|
||||||
|
var currentlySelectedCategory = -1
|
||||||
|
var scroll = 0
|
||||||
|
var maxScroll = 0
|
||||||
|
var categoryItemCounts = mutableListOf<Int>()
|
||||||
|
var currentlySelectedSort = 0
|
||||||
|
var ascending = true
|
||||||
|
|
||||||
|
constructor(containerId: Int, playerInventory: Inventory): super(CobblemonMenuType.COBBLEMON_BAG, containerId) {
|
||||||
|
this.playerInventory = playerInventory
|
||||||
|
this.bagContainer = CobblemonBagContainer()
|
||||||
|
this.partyContainer = SimpleContainer(6)
|
||||||
|
for (i in 0..<BagCategories.getOrderedCategoriesList().size) { //Pre-init so Screen does not crash
|
||||||
|
categoryItemCounts.add(0)
|
||||||
|
}
|
||||||
|
initializeSlots(playerInventory)
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(containerId: Int, playerInventory: Inventory, bagContainer: CobblemonBagContainer): super(CobblemonMenuType.COBBLEMON_BAG, containerId) {
|
||||||
|
this.playerInventory = playerInventory
|
||||||
|
this.bagContainer = bagContainer
|
||||||
|
this.partyContainer = SimpleContainer(6)
|
||||||
|
this.serverParty = Cobblemon.storage.getParty(playerInventory.player as ServerPlayer)
|
||||||
|
initializeSlots(playerInventory)
|
||||||
|
setupSlotsBasedOnContent()
|
||||||
|
calculateCategoriesItemCounts()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun sort(items: MutableList<ItemStack>, category: BagCategory?): List<ItemStack> {
|
||||||
|
if (category == null) return items
|
||||||
|
|
||||||
|
val sortMethod = category.getAllSortMethods().getOrNull(currentlySelectedSort)
|
||||||
|
?: category.defaultSort
|
||||||
|
?: BagSortComparators.DEFAULT_SORT
|
||||||
|
val comparator = BagSortComparators.getComparator(sortMethod)
|
||||||
|
?: BagSortComparators.getComparator(category.defaultSort ?: BagSortComparators.DEFAULT_SORT)
|
||||||
|
?: return items
|
||||||
|
|
||||||
|
return if (ascending) {
|
||||||
|
items.sortedWith(comparator)
|
||||||
|
} else {
|
||||||
|
items.sortedWith(comparator).asReversed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initializeSlots(playerInventory: Inventory) {
|
||||||
|
for ((index, _) in BAG_SLOTS.withIndex()) {
|
||||||
|
val i = index / 8
|
||||||
|
val j = index % 8
|
||||||
|
addSlot(CobblemonBagSlot(bagContainer, -1, 81 + j * 18, 50 + i * 18))
|
||||||
|
}
|
||||||
|
|
||||||
|
for ((index, _) in PARTY_SLOTS.withIndex()) {
|
||||||
|
val xPos = 46
|
||||||
|
val yPos = 32 + 33 * index
|
||||||
|
if (serverParty != null) {
|
||||||
|
addSlot(CobblemonBagPartySlot(partyContainer, index,
|
||||||
|
{ serverParty?.get(index) != null },
|
||||||
|
{ serverParty?.get(index)?.heldItem() ?: ItemStack.EMPTY },
|
||||||
|
xPos, yPos))
|
||||||
|
} else {
|
||||||
|
addSlot(CobblemonBagPartySlot(partyContainer, index,
|
||||||
|
{ CobblemonClient.storage.party.get(index) != null },
|
||||||
|
{ CobblemonClient.storage.party.get(index)?.heldItem() ?: ItemStack.EMPTY },
|
||||||
|
xPos, yPos))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ((index, _) in INVENTORY_SLOTS.withIndex()) {
|
||||||
|
val i = index / 9
|
||||||
|
val j = index % 9
|
||||||
|
addSlot(Slot(playerInventory, 9 + index, 81 + j * 18, 142 + i * 18))
|
||||||
|
}
|
||||||
|
|
||||||
|
for ((index, _) in HOTBAR_SLOTS.withIndex()) {
|
||||||
|
addSlot(Slot(playerInventory, index, 81 + index * 18, 200))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setupSlotsBasedOnContent() {
|
||||||
|
BAG_SLOTS.forEach {
|
||||||
|
(getSlot(it) as CobblemonBagSlot).let {
|
||||||
|
it.simulatedSlot = -1
|
||||||
|
it.slotOverflowValue = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val items = bagContainer.items
|
||||||
|
val indexByStack = mutableMapOf<ItemStack, Int>()
|
||||||
|
items.forEachIndexed { i, stack -> indexByStack[stack] = i }
|
||||||
|
val orderedCategories = BagCategories.getOrderedCategoriesList()
|
||||||
|
val category = if (currentlySelectedCategory == -1) null else orderedCategories[currentlySelectedCategory]
|
||||||
|
val sortedItems = sort(items, category)
|
||||||
|
var slotId = BAG_SLOTS.first - 8 * scroll
|
||||||
|
|
||||||
|
sortedItems.forEach { itemStack ->
|
||||||
|
val index = indexByStack[itemStack] ?: return@forEach
|
||||||
|
if (category == null || category.itemIsValid(itemStack)) {
|
||||||
|
val stackCount = ceil(itemStack.count.toFloat() / itemStack.maxStackSize).toInt()
|
||||||
|
for (i in 0..<stackCount) {
|
||||||
|
if (slotId in BAG_SLOTS) {
|
||||||
|
val slot = getSlot(slotId) as CobblemonBagSlot
|
||||||
|
slot.simulatedSlot = index
|
||||||
|
slot.slotOverflowValue = i
|
||||||
|
}
|
||||||
|
slotId += 1
|
||||||
|
if (slotId > BAG_SLOTS.last) return@forEach
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateMaxScroll()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun calculateCategoriesItemCounts() {
|
||||||
|
val orderedCategories = BagCategories.getOrderedCategoriesList()
|
||||||
|
categoryItemCounts.clear()
|
||||||
|
for (i in 0..<orderedCategories.size) {
|
||||||
|
categoryItemCounts.add(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
bagContainer.items.forEach { itemStack ->
|
||||||
|
for (i in 0..<orderedCategories.size) {
|
||||||
|
val category = orderedCategories[i]
|
||||||
|
if (category.itemIsValid(itemStack)) {
|
||||||
|
categoryItemCounts[i] += itemStack.count
|
||||||
|
return@forEach
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun changeCategory(categoryId: Int) {
|
||||||
|
currentlySelectedCategory = categoryId
|
||||||
|
currentlySelectedSort = 0
|
||||||
|
scroll = 0
|
||||||
|
setupSlotsBasedOnContent()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateMaxScroll() {
|
||||||
|
var itemCount = 0
|
||||||
|
bagContainer.items.forEach { itemStack ->
|
||||||
|
if (currentlySelectedCategory == -1 || BagCategories.getOrderedCategoriesList()[currentlySelectedCategory].itemIsValid(itemStack)) {
|
||||||
|
itemCount += ceil(itemStack.count.toFloat() / itemStack.maxStackSize).toInt()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val rowsWithItems = (itemCount - 1) / 8 + 1
|
||||||
|
maxScroll = max(rowsWithItems - 3, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun stillValid(player: Player): Boolean {
|
||||||
|
return true //Add some extra logic like checking for maybe bag item existance
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun sendAllDataToRemote() { //We want to send more info than just the slots
|
||||||
|
val items = NonNullList.create<ItemStack>()
|
||||||
|
for (i in PARTY_SLOTS.first..HOTBAR_SLOTS.last) {
|
||||||
|
this.remoteSlots[i] = this.slots[i].item.copy()
|
||||||
|
items.add(this.remoteSlots[i].copy())
|
||||||
|
}
|
||||||
|
|
||||||
|
this.remoteCarried = this.carried.copy()
|
||||||
|
|
||||||
|
bagContainer.items.forEach {
|
||||||
|
items.add(it.copy())
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.synchronizer != null) {
|
||||||
|
this.synchronizer!!.sendInitialData(this, items, this.remoteCarried, this.remoteDataSlots.toIntArray())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun initializeContents(stateId: Int, items: List<ItemStack>, carried: ItemStack) {
|
||||||
|
bagContainer.items.clear()
|
||||||
|
items.forEachIndexed { index, stack ->
|
||||||
|
val adjustedIndex = index + PARTY_SLOTS.first
|
||||||
|
if (adjustedIndex in PARTY_SLOTS.first..HOTBAR_SLOTS.last) {
|
||||||
|
this.slots[adjustedIndex].set(stack)
|
||||||
|
} else {
|
||||||
|
bagContainer.items.add(stack)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.carried = carried
|
||||||
|
this.stateId = stateId
|
||||||
|
setupSlotsBasedOnContent()
|
||||||
|
calculateCategoriesItemCounts()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun clicked(slotId: Int, button: Int, clickType: ClickType, player: Player) {
|
||||||
|
if (slotId in BAG_SLOTS) {
|
||||||
|
try {
|
||||||
|
doBagClick(slotId, button, clickType, player)
|
||||||
|
} catch (exception: Exception) {
|
||||||
|
val crashReport = CrashReport.forThrowable(exception, "Container click")
|
||||||
|
val crashReportCategory = crashReport.addCategory("Click info")
|
||||||
|
crashReportCategory.setDetail("Menu Type") {
|
||||||
|
if (this.menuType != null) BuiltInRegistries.MENU.getKey(this.menuType!!)
|
||||||
|
.toString() else "<no type>"
|
||||||
|
}
|
||||||
|
crashReportCategory.setDetail("Menu Class") { this.javaClass.getCanonicalName() }
|
||||||
|
crashReportCategory.setDetail("Slot Count", this.slots.size)
|
||||||
|
crashReportCategory.setDetail("Slot", slotId)
|
||||||
|
crashReportCategory.setDetail("Button", button)
|
||||||
|
crashReportCategory.setDetail("Type", clickType)
|
||||||
|
throw ReportedException(crashReport)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
} else if (slotId in PARTY_SLOTS) {
|
||||||
|
onPartySlotClick(slotId, button, clickType, player)
|
||||||
|
}
|
||||||
|
super.clicked(slotId, button, clickType, player)
|
||||||
|
}
|
||||||
|
|
||||||
|
// We handle the bag slots completely differently than normal slots, but a lot of default logic is cut
|
||||||
|
private fun doBagClick(slotId: Int, button: Int, clickType: ClickType, player: Player) {
|
||||||
|
val slot = (getSlot(slotId) as? CobblemonBagSlot) ?: return
|
||||||
|
val slotItem = slot.item
|
||||||
|
|
||||||
|
if (clickType == ClickType.PICKUP && (button == 0 || button == 1)) {
|
||||||
|
val primaryButton = if (button == 0) ClickAction.PRIMARY else ClickAction.SECONDARY
|
||||||
|
val carriedStack = carried
|
||||||
|
|
||||||
|
if (carriedStack.isEmpty) {
|
||||||
|
if (!slotItem.isEmpty) {
|
||||||
|
val pickupCount = if (primaryButton == ClickAction.PRIMARY) slotItem.count else (slotItem.count + 1) / 2
|
||||||
|
|
||||||
|
val removedItemStack = slot.remove(pickupCount)
|
||||||
|
if (!removedItemStack.isEmpty) {
|
||||||
|
carried = removedItemStack
|
||||||
|
slot.onTake(player, removedItemStack)
|
||||||
|
getAndReduceCategoryCount(removedItemStack)
|
||||||
|
}
|
||||||
|
|
||||||
|
playSound(CobblemonSounds.ITEM_BAG_ITEM_OUT)
|
||||||
|
setupSlotsBasedOnContent()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val (categoryId, allowedTransfer) = calculateInsertCount(carriedStack)
|
||||||
|
if (allowedTransfer <= 0) return
|
||||||
|
|
||||||
|
val transferCount = if (primaryButton == ClickAction.PRIMARY) min(carriedStack.count, allowedTransfer) else 1
|
||||||
|
|
||||||
|
bagContainer.items.forEachIndexed { index, slotStack ->
|
||||||
|
if (ItemStack.isSameItemSameComponents(carriedStack, slotStack) && !tryItemClickBehaviourOverride(player, primaryButton, CobblemonBagSlot(bagContainer, index, 0, 0), slotStack, carriedStack)
|
||||||
|
) { // Provide a slot with index equal to the item, as there is not really any 'real' slots
|
||||||
|
slotStack.grow(transferCount)
|
||||||
|
carriedStack.shrink(transferCount)
|
||||||
|
categoryItemCounts[categoryId] += transferCount
|
||||||
|
playSound(CobblemonSounds.ITEM_BAG_ITEM_IN)
|
||||||
|
setupSlotsBasedOnContent()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val transferItem = carriedStack.split(transferCount)
|
||||||
|
bagContainer.items.add(transferItem)
|
||||||
|
categoryItemCounts[categoryId] += transferCount
|
||||||
|
playSound(CobblemonSounds.ITEM_BAG_ITEM_IN)
|
||||||
|
setupSlotsBasedOnContent()
|
||||||
|
}
|
||||||
|
} else if (clickType == ClickType.QUICK_MOVE && (button == 0 || button == 1)) {
|
||||||
|
quickMoveStackFromBag(player, slot)
|
||||||
|
} else if (clickType == ClickType.CLONE && player.hasInfiniteMaterials() && carried.isEmpty && !slotItem.isEmpty) {
|
||||||
|
carried = slotItem.copyWithCount(slotItem.maxStackSize)
|
||||||
|
} else if (clickType == ClickType.THROW && carried.isEmpty && !slotItem.isEmpty) {
|
||||||
|
val throwCount = if (button == 0) 1 else min(slotItem.count, slotItem.maxStackSize)
|
||||||
|
val bagSize = bagContainer.items.size
|
||||||
|
val removedItemStack = slot.remove(throwCount)
|
||||||
|
player.drop(removedItemStack, true)
|
||||||
|
playSound(CobblemonSounds.ITEM_BAG_ITEM_OUT)
|
||||||
|
getAndReduceCategoryCount(removedItemStack)
|
||||||
|
|
||||||
|
if (bagSize != bagContainer.items.size) {
|
||||||
|
setupSlotsBasedOnContent()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Handle party slot clicked
|
||||||
|
private fun onPartySlotClick(slotId: Int, button: Int, clickType: ClickType, player: Player) {
|
||||||
|
val slotItem = getSlot(slotId).item
|
||||||
|
if (clickType == ClickType.CLONE && player.hasInfiniteMaterials() && carried.isEmpty && !slotItem.isEmpty) {
|
||||||
|
carried = slotItem.copyWithCount(slotItem.maxStackSize)
|
||||||
|
} else if (clickType != ClickType.PICKUP) return
|
||||||
|
|
||||||
|
if (serverParty == null) return // Client does nothing
|
||||||
|
|
||||||
|
if (!carried.isEmpty && (isBlacklisted(carried) || !isWhitelisted(carried))) return //Blacklisted and Whitelisted checks
|
||||||
|
|
||||||
|
val index = slotId - PARTY_SLOTS.first
|
||||||
|
val pokemon = serverParty?.get(index) ?: return
|
||||||
|
|
||||||
|
val heldItem = pokemon.heldItem()
|
||||||
|
|
||||||
|
if (carried.isEmpty || carried.count <= 1) { // Can Swap/Pickup
|
||||||
|
val returned = pokemon.swapHeldItem(carried, aiCanDrop = false)
|
||||||
|
carried = returned
|
||||||
|
broadcastChanges()
|
||||||
|
} else if (heldItem.isEmpty) { // Can Placedown
|
||||||
|
pokemon.swapHeldItem(carried, aiCanDrop = false)
|
||||||
|
broadcastChanges()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Handled only by server
|
||||||
|
fun useHeldItemOnPokemon(partySlot: Int) {
|
||||||
|
if (carried.isEmpty) return
|
||||||
|
|
||||||
|
val pokemon = serverParty?.get(partySlot) ?: return
|
||||||
|
val item = carried.item as? PokemonSelectingItem ?: return
|
||||||
|
val player = playerInventory.player as? ServerPlayer ?: return
|
||||||
|
|
||||||
|
if (player.isInBattle()) return
|
||||||
|
|
||||||
|
val interaction = item.applyToPokemon(player, carried, pokemon)
|
||||||
|
if (interaction?.result == InteractionResult.SUCCESS) {
|
||||||
|
CobblemonCriteria.POKEMON_INTERACT.trigger(player, PokemonInteractContext(pokemon.species.resourceIdentifier, BuiltInRegistries.ITEM.getKey(carried.item)))
|
||||||
|
broadcastChanges()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isBlacklisted(stack: ItemStack): Boolean =
|
||||||
|
BuiltInRegistries.ITEM.getTagOrEmpty(CobblemonItemTags.BLACKLISTED_ITEMS_TO_HOLD).any()
|
||||||
|
&& stack.`is`(CobblemonItemTags.BLACKLISTED_ITEMS_TO_HOLD)
|
||||||
|
|
||||||
|
private fun isWhitelisted(stack: ItemStack): Boolean =
|
||||||
|
BuiltInRegistries.ITEM.getTagOrEmpty(CobblemonItemTags.WHITELISTED_ITEMS_TO_HOLD).none()
|
||||||
|
|| stack.`is`(CobblemonItemTags.WHITELISTED_ITEMS_TO_HOLD)
|
||||||
|
|
||||||
|
override fun quickMoveStack(player: Player, index: Int): ItemStack { // This will only be called by base inventory
|
||||||
|
if (index < 0 || index >= slots.size) return ItemStack.EMPTY
|
||||||
|
val slot = slots[index]
|
||||||
|
val itemStack = slot.item
|
||||||
|
|
||||||
|
val (categoryId, allowedTransfer) = calculateInsertCount(itemStack)
|
||||||
|
if (allowedTransfer <= 0) return ItemStack.EMPTY
|
||||||
|
|
||||||
|
val transferCount = min(itemStack.count, allowedTransfer)
|
||||||
|
|
||||||
|
if (slot.hasItem()) {
|
||||||
|
bagContainer.items.forEach { slotStack ->
|
||||||
|
if (ItemStack.isSameItemSameComponents(slotStack, itemStack)) {
|
||||||
|
slotStack.grow(transferCount)
|
||||||
|
itemStack.shrink(transferCount)
|
||||||
|
categoryItemCounts[categoryId] += transferCount
|
||||||
|
playSound(CobblemonSounds.ITEM_BAG_ITEM_IN)
|
||||||
|
setupSlotsBasedOnContent()
|
||||||
|
return ItemStack.EMPTY
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bagContainer.items.add(itemStack.split(transferCount))
|
||||||
|
categoryItemCounts[categoryId] += transferCount
|
||||||
|
playSound(CobblemonSounds.ITEM_BAG_ITEM_IN)
|
||||||
|
setupSlotsBasedOnContent()
|
||||||
|
}
|
||||||
|
return ItemStack.EMPTY
|
||||||
|
}
|
||||||
|
|
||||||
|
fun quickMoveStackFromBag(player: Player, slot: CobblemonBagSlot) { //Called by bag items
|
||||||
|
val transferStack = slot.item
|
||||||
|
val startingCount = transferStack.count
|
||||||
|
|
||||||
|
if (moveItemStackTo(transferStack, INVENTORY_SLOTS.first, HOTBAR_SLOTS.last + 1, false)) {
|
||||||
|
val itemsMoved = startingCount - transferStack.count
|
||||||
|
getAndReduceCategoryCount(slot.remove(itemsMoved))
|
||||||
|
playSound(CobblemonSounds.ITEM_BAG_ITEM_OUT)
|
||||||
|
setupSlotsBasedOnContent()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun calculateInsertCount(stack: ItemStack): Pair<Int, Int> {
|
||||||
|
if (stack.isEmpty) return -1 to 0
|
||||||
|
|
||||||
|
BagCategories.getOrderedCategoriesList().forEachIndexed { index, category ->
|
||||||
|
if (category.itemIsValid(stack)) {
|
||||||
|
val maxAllowed = max(category.maxCount - categoryItemCounts[index], 0)
|
||||||
|
return index to min(stack.count, maxAllowed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1 to 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getAndReduceCategoryCount(stack: ItemStack) {
|
||||||
|
if (stack.isEmpty) return
|
||||||
|
|
||||||
|
BagCategories.getOrderedCategoriesList().forEachIndexed { index, category ->
|
||||||
|
if (category.itemIsValid(stack)) {
|
||||||
|
categoryItemCounts[index] -= stack.count
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun canTakeItemForPickAll(stack: ItemStack, slot: Slot): Boolean {
|
||||||
|
return slot.index !in BAG_SLOTS
|
||||||
|
}
|
||||||
|
|
||||||
|
fun playSound(soundEvent: SoundEvent) {
|
||||||
|
Minecraft.getInstance().soundManager.play(SimpleSoundInstance.forUI(soundEvent, 1.0F))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* 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.item.bag
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||||
|
import net.minecraft.world.SimpleContainer
|
||||||
|
import net.minecraft.world.entity.player.Player
|
||||||
|
import net.minecraft.world.inventory.Slot
|
||||||
|
import net.minecraft.world.item.ItemStack
|
||||||
|
|
||||||
|
class CobblemonBagPartySlot(
|
||||||
|
container: SimpleContainer,
|
||||||
|
index: Int,
|
||||||
|
val activeGetter: () -> Boolean,
|
||||||
|
val itemGetter: () -> ItemStack,
|
||||||
|
x: Int,
|
||||||
|
y: Int
|
||||||
|
): Slot(container, index, x, y) {
|
||||||
|
override fun getMaxStackSize(): Int = 1
|
||||||
|
|
||||||
|
override fun mayPlace(stack: ItemStack): Boolean = false
|
||||||
|
override fun mayPickup(player: Player): Boolean = false
|
||||||
|
|
||||||
|
override fun getItem(): ItemStack {
|
||||||
|
return itemGetter.invoke()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isActive(): Boolean {
|
||||||
|
return activeGetter.invoke()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* 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.item.bag
|
||||||
|
|
||||||
|
import net.minecraft.world.entity.player.Player
|
||||||
|
import net.minecraft.world.inventory.Slot
|
||||||
|
import net.minecraft.world.item.ItemStack
|
||||||
|
import java.util.Optional
|
||||||
|
import kotlin.math.min
|
||||||
|
|
||||||
|
class CobblemonBagSlot(
|
||||||
|
container: CobblemonBagContainer,
|
||||||
|
var simulatedSlot: Int, //Cant override base slot variable so it is forever -1
|
||||||
|
x: Int,
|
||||||
|
y: Int
|
||||||
|
): Slot(container, 0, x, y) {
|
||||||
|
var slotOverflowValue = 0
|
||||||
|
|
||||||
|
override fun set(stack: ItemStack) {}
|
||||||
|
|
||||||
|
override fun getItem(): ItemStack {
|
||||||
|
if (simulatedSlot == -1) return ItemStack.EMPTY
|
||||||
|
val itemStack = container.getItem(simulatedSlot)
|
||||||
|
val count = min(itemStack.count - itemStack.maxStackSize * slotOverflowValue, itemStack.maxStackSize)
|
||||||
|
return itemStack.copyWithCount(count)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun remove(amount: Int): ItemStack {
|
||||||
|
if (simulatedSlot == -1) return ItemStack.EMPTY
|
||||||
|
return container.removeItem(simulatedSlot, amount)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mayPlace(stack: ItemStack): Boolean = false
|
||||||
|
override fun mayPickup(player: Player): Boolean = false
|
||||||
|
}
|
||||||
@@ -945,6 +945,8 @@ object CobblemonItemGroups {
|
|||||||
CobblemonItems.pokeBalls.forEach(entries::accept)
|
CobblemonItems.pokeBalls.forEach(entries::accept)
|
||||||
CobblemonItems.pokeRods.forEach(entries::accept)
|
CobblemonItems.pokeRods.forEach(entries::accept)
|
||||||
CobblemonItems.pokedexes.forEach(entries::accept)
|
CobblemonItems.pokedexes.forEach(entries::accept)
|
||||||
|
entries.accept(CobblemonItems.TRAINER_PACK)
|
||||||
|
entries.accept(CobblemonItems.TRAINER_BAG)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun blocksInjections(injector: Injector) {
|
private fun blocksInjections(injector: Injector) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
package com.cobblemon.mod.common.item.interactive
|
package com.cobblemon.mod.common.item.interactive
|
||||||
|
|
||||||
import com.cobblemon.mod.common.CobblemonItemComponents
|
import com.cobblemon.mod.common.CobblemonItemComponents
|
||||||
|
import com.cobblemon.mod.common.item.components.FoodComponent
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
import net.minecraft.sounds.SoundEvent
|
import net.minecraft.sounds.SoundEvent
|
||||||
import net.minecraft.sounds.SoundEvents
|
import net.minecraft.sounds.SoundEvents
|
||||||
@@ -23,10 +24,15 @@ import net.minecraft.world.level.Level
|
|||||||
class PonigiriItem : Item(
|
class PonigiriItem : Item(
|
||||||
Properties().stacksTo(64)
|
Properties().stacksTo(64)
|
||||||
.food(FoodProperties.Builder()
|
.food(FoodProperties.Builder()
|
||||||
.nutrition(2)
|
.nutrition(NUTRITION)
|
||||||
.saturationModifier(0.55f)
|
.saturationModifier(SATURATION_MODIFIER)
|
||||||
.build())
|
.build())
|
||||||
) {
|
) {
|
||||||
|
companion object {
|
||||||
|
const val NUTRITION = 2
|
||||||
|
const val SATURATION_MODIFIER = 0.55f
|
||||||
|
}
|
||||||
|
|
||||||
override fun getName(stack: ItemStack): Component {
|
override fun getName(stack: ItemStack): Component {
|
||||||
|
|
||||||
val ingredients = stack.get(CobblemonItemComponents.INGREDIENT)
|
val ingredients = stack.get(CobblemonItemComponents.INGREDIENT)
|
||||||
@@ -59,4 +65,9 @@ class PonigiriItem : Item(
|
|||||||
override fun getEatingSound(): SoundEvent {
|
override fun getEatingSound(): SoundEvent {
|
||||||
return SoundEvents.GENERIC_EAT
|
return SoundEvents.GENERIC_EAT
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
fun getFoodValues(stack: ItemStack): Pair<Int, Float> {
|
||||||
|
val (hunger, saturation) = stack.getOrDefault(CobblemonItemComponents.FOOD, FoodComponent(NUTRITION, SATURATION_MODIFIER))
|
||||||
|
return hunger to saturation
|
||||||
|
}
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* 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.net.messages.client.bag
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.api.net.NetworkPacket
|
||||||
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
|
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||||
|
|
||||||
|
class UpdateBagMenuDataPacket(val categoryId: Int, val scroll: Int, val sort: Int): NetworkPacket<UpdateBagMenuDataPacket> {
|
||||||
|
companion object {
|
||||||
|
val ID = cobblemonResource("update_bag_menu_data")
|
||||||
|
fun decode(buffer: RegistryFriendlyByteBuf): UpdateBagMenuDataPacket {
|
||||||
|
return UpdateBagMenuDataPacket(buffer.readInt(), buffer.readInt(), buffer.readInt())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override val id = ID
|
||||||
|
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||||
|
buffer.writeInt(categoryId)
|
||||||
|
buffer.writeInt(scroll)
|
||||||
|
buffer.writeInt(sort)
|
||||||
|
}
|
||||||
|
}
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* 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.net.messages.client.bag
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.api.net.NetworkPacket
|
||||||
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
|
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||||
|
|
||||||
|
class UseItemOnPokemonFromBagPacket(val partySlot: Int): NetworkPacket<UseItemOnPokemonFromBagPacket> {
|
||||||
|
companion object {
|
||||||
|
val ID = cobblemonResource("use_item_on_pokemon_from_bag")
|
||||||
|
fun decode(buffer: RegistryFriendlyByteBuf): UseItemOnPokemonFromBagPacket {
|
||||||
|
return UseItemOnPokemonFromBagPacket(buffer.readInt())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
override val id = ID
|
||||||
|
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||||
|
buffer.writeInt(partySlot)
|
||||||
|
}
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* 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.net.messages.client.data
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.api.bag.BagCategories
|
||||||
|
import com.cobblemon.mod.common.api.bag.BagCategory
|
||||||
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
|
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||||
|
|
||||||
|
class BagCategoriesSyncPacket(categories: List<BagCategory>): DataRegistrySyncPacket<BagCategory, BagCategoriesSyncPacket>(categories) {
|
||||||
|
companion object {
|
||||||
|
val ID = cobblemonResource("bag_categories")
|
||||||
|
fun decode(buffer: RegistryFriendlyByteBuf) = BagCategoriesSyncPacket(emptyList()).apply { decodeBuffer(buffer) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override val id = ID
|
||||||
|
override fun encodeEntry(buffer: RegistryFriendlyByteBuf, entry: BagCategory) {
|
||||||
|
entry.encode(buffer)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun decodeEntry(buffer: RegistryFriendlyByteBuf): BagCategory = BagCategory.decode(buffer)
|
||||||
|
|
||||||
|
override fun synchronizeDecoded(entries: Collection<BagCategory>) {
|
||||||
|
BagCategories.reload(entries.associateBy { it.identifier })
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-4
@@ -23,16 +23,19 @@ import java.util.UUID
|
|||||||
* @author Hiroku
|
* @author Hiroku
|
||||||
* @since March 5th, 2023
|
* @since March 5th, 2023
|
||||||
*/
|
*/
|
||||||
class TradeCompletedPacket(val pokemonId1: UUID, val pokemonId2: UUID) : NetworkPacket<TradeCompletedPacket> {
|
class TradeCompletedPacket(val pokemonIds1: List<UUID>, val pokemonIds2: List<UUID>) : NetworkPacket<TradeCompletedPacket> {
|
||||||
companion object {
|
companion object {
|
||||||
val ID = cobblemonResource("trade_completed")
|
val ID = cobblemonResource("trade_completed")
|
||||||
fun decode(buffer: RegistryFriendlyByteBuf) = TradeCompletedPacket(buffer.readUUID(), buffer.readUUID())
|
fun decode(buffer: RegistryFriendlyByteBuf) = TradeCompletedPacket(
|
||||||
|
buffer.readList { it.readUUID() },
|
||||||
|
buffer.readList { it.readUUID() }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val id = ID
|
override val id = ID
|
||||||
|
|
||||||
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||||
buffer.writeUUID(pokemonId1)
|
buffer.writeCollection(pokemonIds1) { buf, id -> buf.writeUUID(id) }
|
||||||
buffer.writeUUID(pokemonId2)
|
buffer.writeCollection(pokemonIds2) { buf, id -> buf.writeUUID(id) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+6
-7
@@ -12,10 +12,6 @@ import com.cobblemon.mod.common.api.net.NetworkPacket
|
|||||||
import com.cobblemon.mod.common.api.net.UnsplittablePacket
|
import com.cobblemon.mod.common.api.net.UnsplittablePacket
|
||||||
import com.cobblemon.mod.common.pokemon.Pokemon
|
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||||
import com.cobblemon.mod.common.util.cobblemonResource
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
import com.cobblemon.mod.common.util.readNullable
|
|
||||||
import com.cobblemon.mod.common.util.readUUID
|
|
||||||
import com.cobblemon.mod.common.util.writeNullable
|
|
||||||
import com.cobblemon.mod.common.util.writeUUID
|
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
@@ -27,15 +23,18 @@ import java.util.UUID
|
|||||||
* @author Hiroku
|
* @author Hiroku
|
||||||
* @since March 5th, 2023
|
* @since March 5th, 2023
|
||||||
*/
|
*/
|
||||||
class TradeUpdatedPacket(val playerId: UUID, val pokemon: Pokemon?) : NetworkPacket<TradeUpdatedPacket>, UnsplittablePacket {
|
class TradeUpdatedPacket(val playerId: UUID, val pokemons: List<Pokemon>) : NetworkPacket<TradeUpdatedPacket>, UnsplittablePacket {
|
||||||
companion object {
|
companion object {
|
||||||
val ID = cobblemonResource("trade_updated")
|
val ID = cobblemonResource("trade_updated")
|
||||||
fun decode(buffer: RegistryFriendlyByteBuf) = TradeUpdatedPacket(buffer.readUUID(), buffer.readNullable { Pokemon.S2C_CODEC.decode(buffer) })
|
fun decode(buffer: RegistryFriendlyByteBuf) = TradeUpdatedPacket(
|
||||||
|
buffer.readUUID(),
|
||||||
|
buffer.readList { Pokemon.S2C_CODEC.decode(it as RegistryFriendlyByteBuf) }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val id = ID
|
override val id = ID
|
||||||
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||||
buffer.writeUUID(playerId)
|
buffer.writeUUID(playerId)
|
||||||
buffer.writeNullable(pokemon) { _, pokemon -> Pokemon.S2C_CODEC.encode(buffer, pokemon) }
|
buffer.writeCollection(pokemons) { buf, pokemon -> Pokemon.S2C_CODEC.encode(buf as RegistryFriendlyByteBuf, pokemon) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-5
@@ -11,26 +11,30 @@ package com.cobblemon.mod.common.net.messages.server.trade
|
|||||||
import com.cobblemon.mod.common.api.net.NetworkPacket
|
import com.cobblemon.mod.common.api.net.NetworkPacket
|
||||||
import com.cobblemon.mod.common.api.storage.party.PartyPosition
|
import com.cobblemon.mod.common.api.storage.party.PartyPosition
|
||||||
import com.cobblemon.mod.common.util.cobblemonResource
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
|
import com.cobblemon.mod.common.util.readList
|
||||||
import com.cobblemon.mod.common.util.readNullable
|
import com.cobblemon.mod.common.util.readNullable
|
||||||
import com.cobblemon.mod.common.util.readPartyPosition
|
import com.cobblemon.mod.common.util.readPartyPosition
|
||||||
import com.cobblemon.mod.common.util.readUUID
|
import com.cobblemon.mod.common.util.readUUID
|
||||||
|
import com.cobblemon.mod.common.util.writeCollection
|
||||||
import com.cobblemon.mod.common.util.writeNullable
|
import com.cobblemon.mod.common.util.writeNullable
|
||||||
import com.cobblemon.mod.common.util.writePartyPosition
|
import com.cobblemon.mod.common.util.writePartyPosition
|
||||||
import com.cobblemon.mod.common.util.writeUUID
|
import com.cobblemon.mod.common.util.writeUUID
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
class UpdateTradeOfferPacket(val newOffer: Pair<UUID, PartyPosition>?): NetworkPacket<UpdateTradeOfferPacket> {
|
class UpdateTradeOfferPacket(val newOffers: List<Pair<UUID, PartyPosition>>): NetworkPacket<UpdateTradeOfferPacket> {
|
||||||
companion object {
|
companion object {
|
||||||
val ID = cobblemonResource("update_trade_offer")
|
val ID = cobblemonResource("update_trade_offer")
|
||||||
fun decode(buffer: RegistryFriendlyByteBuf) = UpdateTradeOfferPacket(buffer.readNullable { buffer.readUUID() to buffer.readPartyPosition() })
|
fun decode(buffer: RegistryFriendlyByteBuf) = UpdateTradeOfferPacket(
|
||||||
|
buffer.readList { it.readUUID() to it.readPartyPosition() }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val id = ID
|
override val id = ID
|
||||||
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||||
buffer.writeNullable(newOffer) { buffer, (pokemonId, partyPosition) ->
|
buffer.writeCollection(newOffers) { buf, (pokemonId, partyPosition) ->
|
||||||
buffer.writeUUID(pokemonId)
|
buf.writeUUID(pokemonId)
|
||||||
buffer.writePartyPosition(partyPosition)
|
buf.writePartyPosition(partyPosition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+24
@@ -8,9 +8,12 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.net.serverhandling.battle
|
package com.cobblemon.mod.common.net.serverhandling.battle
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.Cobblemon
|
||||||
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
|
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
|
||||||
import com.cobblemon.mod.common.api.text.red
|
import com.cobblemon.mod.common.api.text.red
|
||||||
import com.cobblemon.mod.common.battles.BattleRegistry
|
import com.cobblemon.mod.common.battles.BattleRegistry
|
||||||
|
import com.cobblemon.mod.common.battles.HealItemActionResponse
|
||||||
|
import com.cobblemon.mod.common.battles.MoveActionResponse
|
||||||
import com.cobblemon.mod.common.exception.IllegalActionChoiceException
|
import com.cobblemon.mod.common.exception.IllegalActionChoiceException
|
||||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleMakeChoicePacket
|
import com.cobblemon.mod.common.net.messages.client.battle.BattleMakeChoicePacket
|
||||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleQueueRequestPacket
|
import com.cobblemon.mod.common.net.messages.client.battle.BattleQueueRequestPacket
|
||||||
@@ -25,6 +28,27 @@ object BattleSelectActionsHandler : ServerNetworkPacketHandler<BattleSelectActio
|
|||||||
if (!actor.mustChoose) {
|
if (!actor.mustChoose) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Battle command injection attempt detection
|
||||||
|
packet.showdownActionResponses.asSequence()
|
||||||
|
.flatMap {
|
||||||
|
when (it) {
|
||||||
|
is MoveActionResponse -> sequenceOf(it.moveName, it.targetPnx, it.gimmickID)
|
||||||
|
is HealItemActionResponse -> sequenceOf(it.item)
|
||||||
|
else -> emptySequence()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.filterNotNull()
|
||||||
|
.firstOrNull { field -> field.any(Char::isISOControl) }
|
||||||
|
?.let {
|
||||||
|
// Escapes control chars as \uXXXX to prevent forging logs.
|
||||||
|
val printable = it.replace(Regex("\\p{Cc}")) { "\\u%04x".format(it.value[0].code) }
|
||||||
|
Cobblemon.LOGGER.warn("Blocked battle command injection from ${player.name.string}: $printable")
|
||||||
|
actor.sendUpdate(BattleQueueRequestPacket(actor.request!!))
|
||||||
|
actor.sendUpdate(BattleMakeChoicePacket())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
actor.setActionResponses(packet.showdownActionResponses)
|
actor.setActionResponses(packet.showdownActionResponses)
|
||||||
} catch (e: IllegalActionChoiceException) {
|
} catch (e: IllegalActionChoiceException) {
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ object ChangeTradeAcceptanceHandler : ServerNetworkPacketHandler<ChangeTradeAcce
|
|||||||
override fun handle(packet: ChangeTradeAcceptancePacket, server: MinecraftServer, player: ServerPlayer) {
|
override fun handle(packet: ChangeTradeAcceptancePacket, server: MinecraftServer, player: ServerPlayer) {
|
||||||
val trade = TradeManager.getActiveTrade(player.uuid) ?: return player.sendPacket(TradeCancelledPacket())
|
val trade = TradeManager.getActiveTrade(player.uuid) ?: return player.sendPacket(TradeCancelledPacket())
|
||||||
val tradeParticipant = trade.getTradeParticipant(player.uuid)
|
val tradeParticipant = trade.getTradeParticipant(player.uuid)
|
||||||
if (trade.getOpposingOffer(tradeParticipant).pokemon?.uuid == packet.pokemonOfferId) {
|
if (trade.getOpposingOffer(tradeParticipant).pokemon.any { it.uuid == packet.pokemonOfferId }) {
|
||||||
trade.updateAcceptance(tradeParticipant, packet.newAcceptance)
|
trade.updateAcceptance(tradeParticipant, packet.newAcceptance)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ object PerformTradeHandler : ServerNetworkPacketHandler<PerformTradePacket> {
|
|||||||
override fun handle(packet: PerformTradePacket, server: MinecraftServer, player: ServerPlayer) {
|
override fun handle(packet: PerformTradePacket, server: MinecraftServer, player: ServerPlayer) {
|
||||||
val trade = TradeManager.getActiveTrade(player.uuid) ?: return player.sendPacket(TradeCancelledPacket())
|
val trade = TradeManager.getActiveTrade(player.uuid) ?: return player.sendPacket(TradeCancelledPacket())
|
||||||
val tradeParticipant = trade.getTradeParticipant(player.uuid)
|
val tradeParticipant = trade.getTradeParticipant(player.uuid)
|
||||||
if (trade.getOpposingOffer(tradeParticipant).pokemon?.uuid == packet.pokemonOfferId) {
|
if (trade.getOpposingOffer(tradeParticipant).pokemon.any { it.uuid == packet.pokemonOfferId }) {
|
||||||
trade.performTrade(tradeParticipant)
|
trade.performTrade(tradeParticipant)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-12
@@ -12,6 +12,7 @@ import com.cobblemon.mod.common.CobblemonNetwork.sendPacket
|
|||||||
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
|
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
|
||||||
import com.cobblemon.mod.common.net.messages.server.trade.CancelTradePacket
|
import com.cobblemon.mod.common.net.messages.server.trade.CancelTradePacket
|
||||||
import com.cobblemon.mod.common.net.messages.server.trade.UpdateTradeOfferPacket
|
import com.cobblemon.mod.common.net.messages.server.trade.UpdateTradeOfferPacket
|
||||||
|
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||||
import com.cobblemon.mod.common.trade.TradeManager
|
import com.cobblemon.mod.common.trade.TradeManager
|
||||||
import com.cobblemon.mod.common.util.party
|
import com.cobblemon.mod.common.util.party
|
||||||
import net.minecraft.server.MinecraftServer
|
import net.minecraft.server.MinecraftServer
|
||||||
@@ -21,20 +22,16 @@ object UpdateTradeOfferHandler : ServerNetworkPacketHandler<UpdateTradeOfferPack
|
|||||||
override fun handle(packet: UpdateTradeOfferPacket, server: MinecraftServer, player: ServerPlayer) {
|
override fun handle(packet: UpdateTradeOfferPacket, server: MinecraftServer, player: ServerPlayer) {
|
||||||
val trade = TradeManager.getActiveTrade(player.uuid) ?: return player.sendPacket(CancelTradePacket())
|
val trade = TradeManager.getActiveTrade(player.uuid) ?: return player.sendPacket(CancelTradePacket())
|
||||||
val tradeParticipant = trade.getTradeParticipant(player.uuid)
|
val tradeParticipant = trade.getTradeParticipant(player.uuid)
|
||||||
val newOffer = packet.newOffer
|
val newOffers = packet.newOffers
|
||||||
if (newOffer == null) {
|
|
||||||
trade.updateOffer(tradeParticipant, null)
|
val validPokemons = mutableListOf<Pokemon>()
|
||||||
} else {
|
val party = player.party()
|
||||||
val (pokemonId, partyPosition) = newOffer
|
for ((pokemonId, partyPosition) in newOffers) {
|
||||||
val party = player.party()
|
|
||||||
val pokemon = party[partyPosition]
|
val pokemon = party[partyPosition]
|
||||||
if (pokemon == null || pokemon.uuid != pokemonId) {
|
if (pokemon != null && pokemon.uuid == pokemonId && pokemon.tradeable) {
|
||||||
return
|
validPokemons.add(pokemon)
|
||||||
} else if (!pokemon.tradeable) {
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
trade.updateOffer(tradeParticipant, pokemon)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
trade.updateOffer(tradeParticipant, validPokemons)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loaded 100 of 1263 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user