mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-10-31 22:38:52 -04:00
Compare commits
483
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fa0544c28 | ||
|
|
e2445db9c4 | ||
|
|
9610332de5 | ||
|
|
0c08a3c271 | ||
|
|
7aafc377db | ||
|
|
91fad06986 | ||
|
|
6865654f37 | ||
|
|
17b3345abe | ||
|
|
9c037dbad2 | ||
|
|
8afbe3a3a7 | ||
|
|
916147ee0d | ||
|
|
ad83d0e4a1 | ||
|
|
7c164fc4c8 | ||
|
|
2ccda57c66 | ||
|
|
846acaef88 | ||
|
|
5fa12ff1c5 | ||
|
|
2b3db32243 | ||
|
|
5a993f3d88 | ||
|
|
4b54405017 | ||
|
|
3824531735 | ||
|
|
63a30dcfd0 | ||
|
|
9cc63b59e6 | ||
|
|
cb17c29be5 | ||
|
|
fd16d59ea2 | ||
|
|
373c383097 | ||
|
|
00c095ba8d | ||
|
|
e8236b55a4 | ||
|
|
2ea07899ea | ||
|
|
d0ce03cd5e | ||
|
|
8ae0c409a3 | ||
|
|
2782cb5f34 | ||
|
|
2f10707211 | ||
|
|
f40a9d762a | ||
|
|
17587f97e5 | ||
|
|
5230820657 | ||
|
|
61c55e136f | ||
|
|
22cced74f5 | ||
|
|
3cd2dec8e0 | ||
|
|
cea930893a | ||
|
|
8662364ca8 | ||
|
|
1fd079b1b4 | ||
|
|
244876a26c | ||
|
|
e7790f530f | ||
|
|
04a9ab0e67 | ||
|
|
3f338d27c3 | ||
|
|
5da3dfb451 | ||
|
|
fd329e00cd | ||
|
|
6da47a8b2c | ||
|
|
860c73fac9 | ||
|
|
e26fdd4bdd | ||
|
|
8e642f71b8 | ||
|
|
2d6c7f5148 | ||
|
|
7a761003c5 | ||
|
|
f9fa9dcf24 | ||
|
|
dfc4873ce3 | ||
|
|
f17884b4e1 | ||
|
|
65bd00033c | ||
|
|
f82fa2b4e6 | ||
|
|
c40b456948 | ||
|
|
7e74e85315 | ||
|
|
21fd4d7cbf | ||
|
|
908bff9892 | ||
|
|
966acecf6d | ||
|
|
fa14f70bbb | ||
|
|
2cd09af4d0 | ||
|
|
610ea0f30c | ||
|
|
a9c92d72d0 | ||
|
|
25cc5f526b | ||
|
|
3cb4f938f1 | ||
|
|
388e03e261 | ||
|
|
346559f292 | ||
|
|
331b282fcf | ||
|
|
a876666bc7 | ||
|
|
7f97eeafed | ||
|
|
51f5a1f5a8 | ||
|
|
1829f7d48a | ||
|
|
bcc3c885d7 | ||
|
|
e2a6dbc709 | ||
|
|
b32ca4af5d | ||
|
|
a2e728905e | ||
|
|
7c0535b8bd | ||
|
|
ead232be6f | ||
|
|
feaba85ba0 | ||
|
|
6a8822ca76 | ||
|
|
4f15ac0cbc | ||
|
|
8fc6d93be4 | ||
|
|
97f8dc562a | ||
|
|
35a0d8a80d | ||
|
|
6616cd1d4c | ||
|
|
f9635cf03f | ||
|
|
49db87737f | ||
|
|
a414213255 | ||
|
|
59a8c21429 | ||
|
|
b67fda7a37 | ||
|
|
4392a61ab5 | ||
|
|
a9d96818ec | ||
|
|
6b285e48e9 | ||
|
|
c0270d3ef0 | ||
|
|
82a1eb2a55 | ||
|
|
a528ea952a | ||
|
|
592b40cd12 | ||
|
|
532ef09acd | ||
|
|
9e05cfa385 | ||
|
|
f0f7bb96ad | ||
|
|
ecfb6c60c3 | ||
|
|
36f13f5b77 | ||
|
|
141a88ba13 | ||
|
|
5be436f25c | ||
|
|
2ddc265b0f | ||
|
|
fc269e853c | ||
|
|
df44486eee | ||
|
|
d7881a327a | ||
|
|
6ff719d2ec | ||
|
|
088fd65159 | ||
|
|
3a2d4028a5 | ||
|
|
a6a9dce811 | ||
|
|
55f0a392e9 | ||
|
|
52af8ceb99 | ||
|
|
14a5060100 | ||
|
|
9d33586b44 | ||
|
|
d4f328157e | ||
|
|
c4331043f7 | ||
|
|
9945d8a069 | ||
|
|
2595d6ee91 | ||
|
|
f16e024bbe | ||
|
|
87a5522acc | ||
|
|
2c812cdc3c | ||
|
|
fb3b2a9452 | ||
|
|
f6e910038e | ||
|
|
5c7d96897d | ||
|
|
dff934b308 | ||
|
|
862d892c84 | ||
|
|
9246e1e8ee | ||
|
|
0de555610a | ||
|
|
0715cb465f | ||
|
|
2e251972aa | ||
|
|
7a1f96e31e | ||
|
|
d405b099b3 | ||
|
|
74322e2f48 | ||
|
|
40a37fedd2 | ||
|
|
3bc6c50d79 | ||
|
|
1ef9f44a1b | ||
|
|
f1ed339d9d | ||
|
|
f07930ef16 | ||
|
|
2e213e0472 | ||
|
|
c6d18cda44 | ||
|
|
263b86e833 | ||
|
|
953560051d | ||
|
|
bf3904a214 | ||
|
|
1708eb9b3e | ||
|
|
0dee18dbfd | ||
|
|
eeb4000b71 | ||
|
|
2fbf3100c5 | ||
|
|
7ee7aaab76 | ||
|
|
3dd4f515dd | ||
|
|
f24310d043 | ||
|
|
61bfe02322 | ||
|
|
7cbcb30aff | ||
|
|
6fc8fa5b60 | ||
|
|
7763a6d3e7 | ||
|
|
1288469172 | ||
|
|
86cf79bff9 | ||
|
|
765e9f2cc3 | ||
|
|
ffda34742c | ||
|
|
c2385edbe7 | ||
|
|
961ad0f4bd | ||
|
|
8851594347 | ||
|
|
3c1ad2bea6 | ||
|
|
e1960792d7 | ||
|
|
23b9f933c7 | ||
|
|
9662699bcb | ||
|
|
32b2d2023b | ||
|
|
c64612859c | ||
|
|
6c97c4c238 | ||
|
|
8c6f7335a5 | ||
|
|
6535d43964 | ||
|
|
234d1dad44 | ||
|
|
da247e9902 | ||
|
|
c747d089ca | ||
|
|
8c881ab85a | ||
|
|
0655d63dc5 | ||
|
|
81ba5ef615 | ||
|
|
8354c3838a | ||
|
|
80db305aba | ||
|
|
802bf10c6e | ||
|
|
42f442233a | ||
|
|
addd063406 | ||
|
|
bae01e7143 | ||
|
|
ec43a78ae4 | ||
|
|
fd0e2fa43f | ||
|
|
60e0314f29 | ||
|
|
5f868630e0 | ||
|
|
762a53923c | ||
|
|
1cf03d4a0d | ||
|
|
48f7be485f | ||
|
|
89364a9fd0 | ||
|
|
b93adae945 | ||
|
|
9f1ed344d8 | ||
|
|
2c256eefde | ||
|
|
b075fce83f | ||
|
|
f2ed332c4c | ||
|
|
e8f083d8bf | ||
|
|
43d965f2a1 | ||
|
|
1684a341a1 | ||
|
|
b4e1bf794d | ||
|
|
c85ad7d60c | ||
|
|
e61e92a5d4 | ||
|
|
a245e9661c | ||
|
|
059152b34c | ||
|
|
76260fb998 | ||
|
|
e4a698b04b | ||
|
|
0d35157fcf | ||
|
|
302388d0a6 | ||
|
|
3aa45d83b6 | ||
|
|
ab957f82e1 | ||
|
|
fef82ae6bf | ||
|
|
8b979c1944 | ||
|
|
4bbbaacacf | ||
|
|
eda8e15509 | ||
|
|
d53a71c188 | ||
|
|
d2f02b0d06 | ||
|
|
5c0bb194b6 | ||
|
|
e41562f5ad | ||
|
|
69ea1ac3bf | ||
|
|
7c15f0f924 | ||
|
|
6165e5e871 | ||
|
|
dd8f59e0d0 | ||
|
|
87611795e9 | ||
|
|
d2fe9b1132 | ||
|
|
e95759a710 | ||
|
|
7284f8d35d | ||
|
|
334dd1206e | ||
|
|
e7caab0ae0 | ||
|
|
47f02f6e50 | ||
|
|
3367b0c39c | ||
|
|
0e43d7730c | ||
|
|
b5604686f2 | ||
|
|
e030dbfbf5 | ||
|
|
2eb6062b9c | ||
|
|
96647a9398 | ||
|
|
33cfbf7d1c | ||
|
|
9e2c0ab0db | ||
|
|
1bc953f3f3 | ||
|
|
d089eab60f | ||
|
|
09da392c36 | ||
|
|
d18cab39a9 | ||
|
|
4492666f5a | ||
|
|
6ddf048984 | ||
|
|
6a0985958b | ||
|
|
308c5e6d32 | ||
|
|
bd83cc143b | ||
|
|
c9e6cb1022 | ||
|
|
74c75b7faa | ||
|
|
45819a17f6 | ||
|
|
e3f84248b8 | ||
|
|
0ff518194f | ||
|
|
634a1ad6fc | ||
|
|
41217ebdcc | ||
|
|
f396b63a34 | ||
|
|
a021ec1337 | ||
|
|
b03f95b7da | ||
|
|
d8cee44661 | ||
|
|
5dd2287441 | ||
|
|
1eb6af14c2 | ||
|
|
61b73972d4 | ||
|
|
f8bcf8c291 | ||
|
|
543d408e63 | ||
|
|
2cdc781e93 | ||
|
|
8dc0a7f72d | ||
|
|
8b5231d6f0 | ||
|
|
665c4cc26c | ||
|
|
253cfd55d8 | ||
|
|
7c860d8f91 | ||
|
|
006e86f3c3 | ||
|
|
e75d0c564f | ||
|
|
1e97143a6a | ||
|
|
91dec859e8 | ||
|
|
85f08c9d28 | ||
|
|
d465f465c8 | ||
|
|
a87bd35fd6 | ||
|
|
0c32da0ce1 | ||
|
|
2bdb110c92 | ||
|
|
d21f3747fc | ||
|
|
fb303fcd97 | ||
|
|
7b4e63001b | ||
|
|
31b185b96c | ||
|
|
034a51b904 | ||
|
|
9e1c491d9c | ||
|
|
f695a99705 | ||
|
|
a8567f9190 | ||
|
|
7d455b2dac | ||
|
|
1dffbd1b37 | ||
|
|
332e25fa76 | ||
|
|
f080fb5639 | ||
|
|
769a1862e4 | ||
|
|
127c5e7a8b | ||
|
|
58fba24f01 | ||
|
|
f49265ae52 | ||
|
|
d1a71373c0 | ||
|
|
77def6de43 | ||
|
|
973c6bb05f | ||
|
|
5b83e49669 | ||
|
|
e01bc2eeab | ||
|
|
f6f3070b8e | ||
|
|
0f2301e668 | ||
|
|
80ce5bab58 | ||
|
|
8fb678b0f8 | ||
|
|
c0a77aca23 | ||
|
|
e4c0eab8e2 | ||
|
|
b9ff46e1b2 | ||
|
|
45a998d3d7 | ||
|
|
a108d85531 | ||
|
|
0fae45f811 | ||
|
|
88717d598d | ||
|
|
33123b4a33 | ||
|
|
001864e20c | ||
|
|
0c9fe19da3 | ||
|
|
74e0915ec8 | ||
|
|
39cd5e9726 | ||
|
|
28ebd1dec1 | ||
|
|
94bbc0e574 | ||
|
|
876be2afcf | ||
|
|
d693f452bc | ||
|
|
034e7d315c | ||
|
|
fb785b4204 | ||
|
|
ac807ce25b | ||
|
|
c065f0f8fd | ||
|
|
a1e94b8200 | ||
|
|
9c7d286dd8 | ||
|
|
69d8e4fab9 | ||
|
|
b788fe3984 | ||
|
|
cfd90fac04 | ||
|
|
1cf2359195 | ||
|
|
6868d7f26c | ||
|
|
3e58229a89 | ||
|
|
d76f1524bd | ||
|
|
58b5eb155d | ||
|
|
fd9caa537b | ||
|
|
5262972a8d | ||
|
|
011a095314 | ||
|
|
3520c50541 | ||
|
|
3eccac861f | ||
|
|
7a85b0b690 | ||
|
|
ff3aa5d782 | ||
|
|
8b4552a532 | ||
|
|
41673ba90f | ||
|
|
18f9942dc6 | ||
|
|
875fe46d21 | ||
|
|
66c6f9bdd1 | ||
|
|
9e6dec8605 | ||
|
|
1fe223c772 | ||
|
|
d89ccc110e | ||
|
|
72c337195a | ||
|
|
b72af84c8c | ||
|
|
a5ee270b8b | ||
|
|
c08ef4247d | ||
|
|
9424bafabb | ||
|
|
a96ecfcdf2 | ||
|
|
b1d11e8c22 | ||
|
|
c1fb1379a9 | ||
|
|
5a220e0ef0 | ||
|
|
b379fc62b1 | ||
|
|
d442e4e956 | ||
|
|
bb22c22db9 | ||
|
|
09bc174401 | ||
|
|
e109a1d59f | ||
|
|
3b97a0c847 | ||
|
|
28a2ec3fc0 | ||
|
|
72bba7fdfd | ||
|
|
a258e48582 | ||
|
|
21a15686b2 | ||
|
|
5da7183ae3 | ||
|
|
d847972bb1 | ||
|
|
5e88e73e3f | ||
|
|
87e8fcd7f7 | ||
|
|
b34f8a045d | ||
|
|
e9086ec2bd | ||
|
|
866db464c4 | ||
|
|
4f79b9f8a7 | ||
|
|
d1b651a876 | ||
|
|
b30a67651e | ||
|
|
a1398e9495 | ||
|
|
ca319764f0 | ||
|
|
ac03c68f41 | ||
|
|
0eb4b43b49 | ||
|
|
b49376dba5 | ||
|
|
81f6e7b786 | ||
|
|
574ee1ae4a | ||
|
|
07a83f54a2 | ||
|
|
6f3b530d7b | ||
|
|
4b86dc1e58 | ||
|
|
bb141aee50 | ||
|
|
acb473c01f | ||
|
|
a8dc3f40a4 | ||
|
|
b55f11628d | ||
|
|
150c03d4f5 | ||
|
|
1c092588f4 | ||
|
|
683473c34c | ||
|
|
c7dee1bd53 | ||
|
|
d83a1086d3 | ||
|
|
b34ca3d42b | ||
|
|
3a1389d719 | ||
|
|
e608dc84ae | ||
|
|
c987a5ba19 | ||
|
|
3dbcc2d28c | ||
|
|
d65090ce10 | ||
|
|
206ec25a99 | ||
|
|
ccd376c055 | ||
|
|
b8e95bd210 | ||
|
|
b14465f2a1 | ||
|
|
6214fb1b97 | ||
|
|
a65cee3e24 | ||
|
|
1a0135c1fd | ||
|
|
23dab6546f | ||
|
|
2a60048f7e | ||
|
|
b4787b8db8 | ||
|
|
eefc125f24 | ||
|
|
f95f17d0c6 | ||
|
|
ba7e98e95c | ||
|
|
cdcc071ce0 | ||
|
|
02067929a2 | ||
|
|
0bc3e8465b | ||
|
|
0ebf5712b9 | ||
|
|
4020e28da9 | ||
|
|
dbc074bfde | ||
|
|
17cdedf65f | ||
|
|
f96766505b | ||
|
|
fe96642be4 | ||
|
|
701af6cd8f | ||
|
|
5515fbfeda | ||
|
|
41a0dce7fc | ||
|
|
3b122b7bcc | ||
|
|
2b3500dfc3 | ||
|
|
e921253a57 | ||
|
|
da45797022 | ||
|
|
fc1f68711d | ||
|
|
da9c1f440c | ||
|
|
ae10ca9541 | ||
|
|
80d2f76dfc | ||
|
|
ebf3c9b82f | ||
|
|
af57ac45a2 | ||
|
|
1c25ae69a5 | ||
|
|
7f464f2e3e | ||
|
|
d8e209e4a2 | ||
|
|
41a87d0c8a | ||
|
|
45faed038f | ||
|
|
30a78f978d | ||
|
|
d8c1d50aa5 | ||
|
|
eb7bf65e02 | ||
|
|
c7d3164ff4 | ||
|
|
e6da43be6d | ||
|
|
f52345036d | ||
|
|
bd99ff2bfd | ||
|
|
19510ca8ba | ||
|
|
0ece90bcf1 | ||
|
|
c2894b4bf1 | ||
|
|
8c3958cdf0 | ||
|
|
92cb847755 | ||
|
|
fc4fed42b5 | ||
|
|
ea332515c4 | ||
|
|
49965d6856 | ||
|
|
6e7694d650 | ||
|
|
a301779a42 | ||
|
|
440a07d1de | ||
|
|
fc7951cbcd | ||
|
|
44b58ab9a0 | ||
|
|
d24a6fa75c | ||
|
|
fca867a8b8 | ||
|
|
9514c48eaa | ||
|
|
d029b4380a | ||
|
|
4c29c9726b | ||
|
|
af9fff9793 | ||
|
|
a8d84c4a28 | ||
|
|
5215388e33 | ||
|
|
93c7685ef7 | ||
|
|
5c395a1987 | ||
|
|
755d367760 | ||
|
|
3b26d24958 | ||
|
|
27afe40892 | ||
|
|
fcd4dccdad | ||
|
|
35e206a5d6 | ||
|
|
b51d007341 | ||
|
|
a85fd79818 |
No files matched your search
@@ -0,0 +1,30 @@
|
||||
<!-- 1. START HERE: (Before filling all this out, please quickly go to the list of all issues: (https://gitlab.com/cable-mc/cobblemon/-/issues/?sort=created_date&state=all) and do a quick search to see if your issue has already been reported. If it has, please add a comment to the existing issue instead of creating a new one.)-->
|
||||
<!-- 2. If the issue was not already reported, please fill out the following template. -->
|
||||
<!-- 3. If you do not know something, don't worry! Just fill out as much as you can to make sure the issue can get fixed asap. -->
|
||||
|
||||
## Summary
|
||||
(Please summarize the bug encountered concisely)
|
||||
|
||||
## Steps to reproduce
|
||||
(How one can reproduce the issue - this is very important)
|
||||
|
||||
## What is the current bug behavior?
|
||||
(What actually happens)
|
||||
|
||||
## What is the expected correct behavior?
|
||||
(What you should see instead)
|
||||
|
||||
## Cobblemon Version and Mod Loader
|
||||
(Are you using Forge or Fabric? And what version of Cobblemon are you using?)
|
||||
|
||||
## Mods used besides Cobblemon
|
||||
(Did you have any other mods installed besides Cobblemon? If so, please list them here)
|
||||
|
||||
## Relevant logs, screenshots and/or videos
|
||||
(Paste any relevant logs - use code blocks (```) at the start and end to format console output, logs, and code, as
|
||||
it's very hard to read otherwise. Or just put a link here)
|
||||
|
||||
## Additional Information
|
||||
(If you can, link to the line of code that might be responsible for the problem, or any other info that might be useful)
|
||||
|
||||
/label ~bug
|
||||
@@ -0,0 +1,31 @@
|
||||
<!-- 1. START HERE: (Before filling all this out, please quickly go to the list of all issues: (https://gitlab.com/cable-mc/cobblemon/-/issues/?sort=created_date&state=all) and do a quick search to see if your feature was already requested. If it is, please add a comment to the existing issue instead of creating a new one.)-->
|
||||
<!-- 2. If the feature request was not already reported, please fill out the following template. -->
|
||||
<!-- 3. If you do not know something, don't worry! Just fill out as much as you can. -->
|
||||
<!-- 4. The more info you provide here, the greater the chance of it being considered by the Design team. -->
|
||||
|
||||
## Summary
|
||||
(Please summarize your feature request concisely)
|
||||
|
||||
## What are the projected benefits of this feature?
|
||||
- (List)
|
||||
- (benefits)
|
||||
- (here)
|
||||
|
||||
## What could speak against this feature?
|
||||
- (List)
|
||||
- (possible)
|
||||
- (cons)
|
||||
|
||||
## Why do you think the benefits outweigh the cons?
|
||||
(Explain why you think the benefits outweigh the cons)
|
||||
|
||||
## Mods involved besides Cobblemon
|
||||
(Does your suggestion require any other mods besides Cobblemon? If so, please list them here)
|
||||
|
||||
## Sketches, screenshots and/or videos
|
||||
(Feel free to add any sketches, screenshots or videos that might help the Design team understand your suggestion)
|
||||
|
||||
## Additional Information
|
||||
(Is there anything else you would like to add?)
|
||||
|
||||
/label ~feature ~suggestion ~needs-design
|
||||
+159
-60
@@ -1,68 +1,133 @@
|
||||
# Changelog
|
||||
## [1.4.1](#1-4-1)
|
||||
## [1.5.0](#1-5-0)
|
||||
### Additions
|
||||
- Added over (number here) ruin structures, where you can find Pokémon-themed Armor Trims and Pottery Sherds, Tumblestones, and more.
|
||||
- Added (number here) fossil structures, where you can brush Suspicious Sand/Gravel for Fossils.
|
||||
- Added the Data Monitor, Fossil Compartment, and Restoration Tube. Placed in the correct formation, you can use these to create a Restoration Machine where you can bring fossils back to life.
|
||||
- Added 3 variants of Tumblestones, which can be planted near Lava or Magma to grow harvestable Tumblestone Clusters.
|
||||
- Added Tumblestone Blocks, a storage block crafted from 9 Tumblestones.
|
||||
- Added Ancient Poké Balls, which are aesthetic variants crafted from Tumblestones.
|
||||
- Added the Ancient Feather, Wing, and Jet Balls, which fly further than regular Poké Balls.
|
||||
- Added the Ancient Heavy, Leaden, and Gigaton Balls, which are heavier and don't fly as far as regular Poké Balls. These will recieve more functionality in a future update.
|
||||
- Added Original Trainer functionality. To edit the OT through commands, you must specify originaltrainertype=<Player/NPC>, and originaltrainer=<Username or UUID/NPC Name>
|
||||
|
||||
### Changes
|
||||
- Slightly lowered the volume of all cries
|
||||
- Updated Pokeball animations and model.
|
||||
- Turtwig can now be put on shoulder.
|
||||
- Updated Zubat line model, texture, and animations.
|
||||
- Added animations for Hitmontop, Tyrogue, and Mightyena.
|
||||
- Tweaked animations for Dusknoir, Ratatta, Bewear, Exeggutor, and Alolan Exeggutor.
|
||||
- Sized Kantonian Exeggutor down. Still big but not TOO BIG.
|
||||
- Tweaked cries for Pikachu, Raichu and Alolan Raichu.
|
||||
- Pasture blocks will now also connect their bottom left and right sides to walls, iron bars, glass panes and any other modded block that follows the same connection rules.
|
||||
- The config option `consumeHeldItems` has been removed, please see the Datapack & Resourcepack Creators for instructions on the updated method.
|
||||
- Using Potions, Status Heals, Ethers, and Antidotes will now return a glass bottle
|
||||
- Using a Remedy, Fine Remedy, or Superb Remedy will no longer lower friendship with a Pokémon
|
||||
- The Healing Machine now has a more difficult recipe, placing it later game.
|
||||
- Heal Powder can now be composted with a 75% chance of adding a layer
|
||||
- Mental, Power, White, and Mirror Herbs can now be composted with a 100% chance of adding a layer.
|
||||
- Added emissive to Hoothoot.
|
||||
- Mining Evolution Stone Ores with a Fortune pickaxe will now increase the amount of items recieved
|
||||
- Black Augurite can now be used to craft stone axes and obsidian.
|
||||
- Using Experience Candies brings up the Party Pokémon Select screen when not targeting a Pokémon.
|
||||
- Added tab completion for statuses to commands
|
||||
|
||||
### Additions
|
||||
- Added battle spectating, can disable in config
|
||||
- Cobblemon now has compatibility with [Adorn](https://modrinth.com/mod/adorn) allowing you to craft Apricorn wood furniture.
|
||||
- Berries can now be used in recipes from [Farmer's Delight](https://modrinth.com/mod/farmers-delight) and [Farmer's Delight (Fabric)](https://modrinth.com/mod/farmers-delight-fabric), as well as any other mods using the same berry tags.
|
||||
- The nature of cobblemon will now be displayed italicized when a mint has been applied. Hovering over the nature will display the mint that was applied. This is the intended behaviour, because the original nature and taste of the Cobblemon does not change when a mint is applied.
|
||||
- Giving Pokémon items now plays a sound
|
||||
- A boat, sign and hanging sign is now craftable with Apricorn wood. The recipes are the same shape as Minecraft's equivalent with Apricorn planks as replacements.
|
||||
- Added the Cleanse Tag held item.
|
||||
- Added the Inferno, Void, and Forsaken patterns for Vivillon. These can be obtained by evolving a Spewpa in the Nether, End, or Deep Dark respectively.
|
||||
- Added the Litwick line.
|
||||
- Bees can now be fed using Pep-Up Flowers.
|
||||
- Mooshtank can now be milked with a bowl for Mushroom Stew.
|
||||
- Added cries to Beldum, Metang and Metagross.
|
||||
- Pokémon now transition more smoothly between different poses.
|
||||
- Added more held items to the held item tag, and Metal Coat to the held item tab.
|
||||
- Added all ores to the modloader ore tags, and added tags for each ore type to the mod (both blocks and items).
|
||||
- Changed the Destiny Knot to be crafted with a Ghast Tear, rather than a diamond.
|
||||
- You can now punch grown apricorns to harvest them.
|
||||
|
||||
### Fixes
|
||||
- Fixed various stone related blocks not being valid for Big Roots to spread on the Fabric version.
|
||||
- Re-added the recipe for the Iron Vitamin.
|
||||
- Cleaned up empty evolutions declaration in species files (no, I'm not listing all 169 by name).
|
||||
- Fixed Exeggcute not being able to evolve.
|
||||
- Fixed Cubone not being able to evolve into Alolan Marowak.
|
||||
- Fixed Squawkabilly forms not being recognized.
|
||||
|
||||
### Developer
|
||||
- Significantly changed the way properties in PokemonEntity work. This could break some plugins (albeit in a quick-fix way).
|
||||
- Rebuilt the scheduling API to more clearly force side choices and allow more local temporal frames of reference for tasks.
|
||||
- Added dialogue API.
|
||||
- Opened up the ItemDropEntry class to allow for it to be extended.
|
||||
|
||||
### Datapack & Resourcepack Creators
|
||||
- The maximum amount of fossils that can fit in the Fossil Compartment can be adjusted in the config.
|
||||
- Custom fossils can be defined using a list of items and the resulting Pokémon. An example of `aerodactyl.json`:
|
||||
```JSON
|
||||
{
|
||||
"result": "aerodactyl",
|
||||
"fossils": [
|
||||
"cobblemon:old_amber_fossil"
|
||||
]
|
||||
}
|
||||
```
|
||||
- Fetus models can be defined in `bedrock/fossils`.
|
||||
- Fetus textures can be defined in `textures/fossils`.
|
||||
- Fuel for the Restoration Machine is registered inside the `natural_materials` folder. To register more fuels, create a JSON file containing an array of objects. Each object supports the following fields:
|
||||
- `content`: Integer containing the amount of fuel to add.
|
||||
- `item` OR `tag`: Identifier of the item or item tag to be inserted.
|
||||
- `returnItem`: Identifier of an item to return to the player after consumption.
|
||||
- Added 3 new item tags: `ancient_poke_balls`, `fossils`, and `tumblestones`.
|
||||
- Added a spawn rules system to modify general spawning behaviour, see the [wiki](https://wiki.cobblemon.com/index.php/Spawn_Rules) for more information.
|
||||
- Fixed an issue with transformed parts in posers causing whacky positional issues.
|
||||
- Fixed Poké Balls freezing in an open state if you look away when it's meant to close.
|
||||
- Added dialogue datapack folder and /opendialogue command.
|
||||
|
||||
## [1.4.1 (December 23rd, 2023)](#1-4-1)
|
||||
|
||||
### Additions
|
||||
- Added battle spectating. Press R on a player in a battle and you can spectate and bully them for their tactics.
|
||||
- Added the Litwick and Drifloon lines.
|
||||
- Cobblemon now has compatibility with [Adorn](https://modrinth.com/mod/adorn), allowing you to craft Apricorn wood furniture.
|
||||
- Berries can now be used in recipes from [Farmer's Delight](https://modrinth.com/mod/farmers-delight) and [Farmer's Delight (Fabric)](https://modrinth.com/mod/farmers-delight-fabric), as well as any other mods using the same berry tags.
|
||||
- Boats, signs and hanging signs are now craftable with Apricorn wood.
|
||||
- Added the Fairy Feather, Iron Ball, Cleanse Tag, Flame Orb, Life Orb, Smoke Ball, and Toxic Orb held items.
|
||||
- Added the Inferno, Void, and Forsaken patterns for Vivillon. These can be obtained by evolving a Spewpa in the Nether, End, or Deep Dark respectively.
|
||||
- Bees can now be fed using Pep-Up Flowers.
|
||||
- Mooshtank can now be milked with a bowl for Mushroom Stew.
|
||||
- Updated Showdown version to use generation 9 battle data.
|
||||
- Added cries to Beldum, Metang and Metagross.
|
||||
- Added a /bedrockparticle command to run Snowstorm-format particle effects.
|
||||
- Added data for Dipplin, Fezandipiti, Munkidori, Ogerpon, Okidogi, Poltchageist and Sinistcha.
|
||||
|
||||
### Changes
|
||||
- Using Potions, Status Heals, Ethers, and Antidotes will now return a glass bottle
|
||||
- Using a Remedy, Fine Remedy, or Superb Remedy will no longer lower friendship with a Pokémon.
|
||||
- The Healing Machine now has a [much more difficult recipe](https://wiki.cobblemon.com/index.php/Healing_Machine), placing it later game.
|
||||
- Made the EXP. Share recipe cheaper.
|
||||
- Turtwig can now be put on your shoulder.
|
||||
- Updated Zubat line model, texture, and animations.
|
||||
- Updated Geodude line models and textures.
|
||||
- Added animations for Hitmontop, Tyrogue, and Mightyena.
|
||||
- Tweaked animations for Dusknoir, Ratatta, Bewear, Exeggutor, and Alolan Exeggutor.
|
||||
- Sized Kantonian Exeggutor down. Still big, but not TOO big.
|
||||
- Tweaked cries for Pikachu, Raichu and Alolan Raichu.
|
||||
- Fixed Swimming behaviors for Wimpod line, Oshawott line, Quaxly line, and Clodsire
|
||||
- Changed the way level scaling works in spawning. By default, anything with a spawn range of up to 5 either side of the party highest level and everything else will spawn per its specified ranges.
|
||||
- The nature of Pokémon will now be displayed italicized when a mint has been applied. Hovering over the nature will display the mint that was applied.
|
||||
- Slightly lowered the volume of all cries.
|
||||
- Giving Pokémon items now plays a sound
|
||||
- Updated the Poké Ball model and animations.
|
||||
- Pasture blocks will now also connect their bottom left and right sides to walls, iron bars, glass panes, and any other modded block that follows the same connection rules.
|
||||
- The config option `consumeHeldItems` has been removed, please see the Datapack & Resourcepack Creators section for instructions on the updated method.
|
||||
- Heal Powder can now be composted with a 75% chance of adding a layer
|
||||
- Mental, Power, White, and Mirror Herbs can now be composted with a 100% chance of adding a layer.
|
||||
- Added glowing eyes to Hoothoot and Noctowl.
|
||||
- Mining Evolution Stone Ores with a Fortune pickaxe will now increase the amount of items received.
|
||||
- Black Augurite can now be used to craft stone axes and obsidian.
|
||||
- Using Experience Candies brings up the Party Pokémon Select screen when not targeting a Pokémon.
|
||||
- Added tab completion for statuses to commands.
|
||||
- Remedies can now be cooked in a Smoker and on a Campfire.
|
||||
- Vertically flipped the Destiny Knot recipe.
|
||||
|
||||
### Fixes
|
||||
- Fixed Raticate, Onix, Unfezant, Bergmite, Avalugg, Boltund and Revavroom cries not playing.
|
||||
- Fixed Alolan Ratticate animations causing a crash.
|
||||
- Fixed Quaxwell not doing its cry.
|
||||
- Fixed Shroomish not using its idle.
|
||||
- Fixed how Weight and Height is calculated for Pokémon, fixing the damage from moves like Low Kick.
|
||||
- Fixed a staggering number of battle messages.
|
||||
- Fixed various stone related blocks not being valid for Big Roots to spread onto on the Fabric version.
|
||||
- Updated the registration of compostable items to improve compatibility with Fabric forks such as Quilt. Please note this does not mean we officially support Quilt, this change was only done since it was possible by correcting the registration to use the new intended way in the Fabric API.
|
||||
- Fixed Dispensers being unable to shear grown Apricorns.
|
||||
- Fixed Bowl not being given back to player after using Berry Juice
|
||||
- Added context for -fail and -block handlers for battle text and added 16 related battle texts for them
|
||||
- Fixed Battle text for Disable, Laser Focus, Foresight, Fire Spin, Telekinesis, Curse, Recharge and Encore
|
||||
- Fixed missing text for snowy weather in battles
|
||||
- Fixed missing text for attempting to catch an uncatchable Pokémon
|
||||
- Fixed Moonphases for Clefairy line
|
||||
- Fixed issue where Potions, Super Potions, and Hyper Potions did not work during battle
|
||||
- Fixed the compatibility patch with the Forge version of [Carry On](https://modrinth.com/mod/carry-on) due to a bug on the mod, the Fabric version was unchanged and is still compatible.
|
||||
- Added the ability to place Berries on modded Farmland blocks.
|
||||
- Shouldered Pokémon now hop off when selected in team and r is pressed. This also is in effect in battles leading to shouldered Pokémon jumping of the shoulder of the trainer when it is their turn.
|
||||
- Shouldered Pokémon now hop off when selected in team and R is pressed. This also is in effect in battles leading to shouldered Pokémon jumping of the shoulder of the trainer when it is their turn.
|
||||
- Made more items compostable and changed the process for making items compostable.
|
||||
- Added the ability for Hoppers to fill Brewing Stands with Medicinal Brews and Potions.
|
||||
- Apricorn blocks are now flammable.
|
||||
- Apricorn blocks are now flammable. Probably should have started that way, but we got there.
|
||||
- The default pose for Pokémon being passengers is now "standing".
|
||||
- Fixed issue where some IVs were changing every player relog.
|
||||
- Fixed cursed battle message
|
||||
- Fixed mistakes in pokemon spawning JSONs
|
||||
- Fixed issue where some IVs were changing every time a player logged back in.
|
||||
- Fixed advancement crash from bad datapack evolution data.
|
||||
- Fixed global influences being applied to TickingSpawners twice.
|
||||
- Reverted the default SpawningSelector back to FlatContextWeightedSelector. This fixes multiple weight related issues, including weights with SpawningInfluences.
|
||||
- Apricorn Planting advancement should work again.
|
||||
- Advancement "Patterned Wings" should now allow High Plains and Icy Snow Vivillon to register.
|
||||
- Advancement "Vivillonaire" should now allow High Plains and Icy Snow Vivillon to register.
|
||||
- Fixed the last battle critical hits evolution requirement not working.
|
||||
- Fixed the damage taken evolution requirement not saving progress.
|
||||
- Fixed the defeated Pokémon evolution requirement not saving progress.
|
||||
@@ -70,20 +135,54 @@
|
||||
- Fixed an exploit that could convert a single piece of Blaze Powder into an extra Medicinal Brew on the Forge version.
|
||||
- Fixed an issue where health percentages would show incorrectly after healing
|
||||
- Fixed the move Revival Blessing not allowing you to select from fainted party members.
|
||||
- Fixed villagers not being able to pick up and plant mint seeds, vivichoke seeds, and revival herbs.
|
||||
- Fixed Exeggcute faint.
|
||||
- Fixed Raticate, Onix, Unfezant, Bergmite, Avalugg, Boltund and Revavroom cries not playing.
|
||||
- Fixed Alolan Ratticate animations causing a crash.
|
||||
- Fixed Quaxwell not doing its cry.
|
||||
- Fixed Shroomish not using its idle.
|
||||
- Fixed various spawn configuration issues across the board.
|
||||
- Fixed a possible visual duplication of sent out Pokémon.
|
||||
- Fixed battle text for Trace, Receiver, and Power of Alchemy.
|
||||
- Fixed tooltips being appended too late in items.
|
||||
- Fixed battles ending background music when battle music is not present.
|
||||
- Fixed battles ending background music, instead of pausing, when battle music is played.
|
||||
- Fixed a bunch of regionals to actually be obtainable, namely the unmodelled ones
|
||||
- Fixed battle text for moves that were missing.
|
||||
- Fixed a formatting error that affected Pokémon nicknames when the storage type is JSON.
|
||||
- Fixed a crash that could occur on some servers relating to chunk loading and teleporting.
|
||||
- Fixed an issue with Inkay's evolution requirement.
|
||||
- Fixed conflicting evolution requirements that would cause the Ocean, River, Sun, and Tundra variants of Vivillon to be unobtainable through evolution.
|
||||
- Fixed the Modern variant of Vivillon not being obtainable through evolution.
|
||||
- Fixed Pokémon pathing through berry bushes, harming themselves in the process.
|
||||
|
||||
### Developer
|
||||
- Fixed the `SpawnEvent` not respecting usage of `Cancelable#cancel`.
|
||||
- Added the `EvolutionTestedEvent`, this allows listening and overriding the final result of evolution requirement tests.
|
||||
- Rebuilt the scheduling API to more clearly force side choices and allow more local temporal frames of reference for tasks.
|
||||
- Added utility script that can be used to generate all Spawn JSONS for all pokemon from the spawning spreadsheet in 1 click ([cobblemon_spawn_csv_to_json.py](utilityscripts%2Fcobblemon_spawn_csv_to_json.py)).
|
||||
- The `HeldItemManager` has a new method `shouldConsumeItem`, this will return false by default to prevent breaking changes, see the documentation and update your implementations as needed.
|
||||
- Added and implemented minSkyLight and maxSkyLight as config options for SpawnConditions
|
||||
- Player specific battle themes can now be assigned to `PlayerData#battleTheme`.
|
||||
- Changed design of `BattleStartedPreEvent`. Will now expose the `PokemonBattle`.
|
||||
|
||||
### Datapack & Resourcepack Creators
|
||||
- Added 3 new item tags: `cobblemon:held/consumed_in_npc_battle`, `cobblemon:held/consumed_in_pvp_battle` & `cobblemon:held/consumed_in_wild_battle` these will determine which items get consumed in the implied battle types by Cobblemon, keep in mind the controller for this behaviour can be overriden by 3rd party.
|
||||
- Unique wild encounter themes can now be associated with a specific species (or form) by assigning a SoundEvent identifier to the `battleTheme` field in the species' data configuration.
|
||||
- Added a `structure` evolution condition, used to check if a Pokémon is in a given structure.
|
||||
|
||||
### Localization
|
||||
- Updated translations for:
|
||||
- French and Canadian French
|
||||
- Simplified and Traditional Chinese
|
||||
- Spanish and Mexican Spanish
|
||||
- Pirate English
|
||||
- German
|
||||
- Thai
|
||||
- Portuguese and Brazilian Portuguese
|
||||
- Polish
|
||||
- Italian
|
||||
- Dutch
|
||||
- Ukrainian
|
||||
- Russian
|
||||
|
||||
Thank you so much to all of our community translators that bring the mod to the rest of the world!
|
||||
|
||||
## [1.4.0 - The Friends and Farms Update (October 13th, 2023)](#1-4-0)
|
||||
### Additions
|
||||
@@ -872,20 +971,20 @@
|
||||
- Fixed spawning in several biome tag categories.
|
||||
- Fixed resource pack support for Pokémon models and textures.
|
||||
- **Model Fixes**
|
||||
- Fixed Paras and Nidoqueen looking very weird.
|
||||
- Fixed Hitmonchan asserting dominance with a T-pose as well as Grimer and Muk pointing their hands to the sky.
|
||||
- Fixed specific Pokémon suddenly pausing their animation after staying still for a long time.
|
||||
- Fixed Mankey's feet being buried in the ground.
|
||||
- Updated the Substitute model and updated its shiny texture to be better for the red-green colorblind.
|
||||
- Improved Horsea, Seadra, and Kingdra animations, especially on land.
|
||||
- Fixed Paras and Nidoqueen looking very weird.
|
||||
- Fixed Hitmonchan asserting dominance with a T-pose as well as Grimer and Muk pointing their hands to the sky.
|
||||
- Fixed specific Pokémon suddenly pausing their animation after staying still for a long time.
|
||||
- Fixed Mankey's feet being buried in the ground.
|
||||
- Updated the Substitute model and updated its shiny texture to be better for the red-green colorblind.
|
||||
- Improved Horsea, Seadra, and Kingdra animations, especially on land.
|
||||
- **Battle Fixes**
|
||||
- Fixed an issue with battles where Pokémon had a different max HP causing some desync issues with the health bars.
|
||||
- Fixed Magnitude battle messages.
|
||||
- Moves that are disabled or out of PP now show transparently in the battle GUI instead of being hidden completely.
|
||||
- Statuses like sleep and frozen no longer last forever if it was carried over from a previous battle.
|
||||
- Fixed an issue with battles where Pokémon had a different max HP causing some desync issues with the health bars.
|
||||
- Fixed Magnitude battle messages.
|
||||
- Moves that are disabled or out of PP now show transparently in the battle GUI instead of being hidden completely.
|
||||
- Statuses like sleep and frozen no longer last forever if it was carried over from a previous battle.
|
||||
|
||||
### Localization
|
||||
- Added species, ability, and move translations for `ko_ko`, `jp_jp`, `fr_fr`, `es_es`, `it_it`, and `zh_cn`.
|
||||
|
||||
## [1.0.0 (November 12th, 2022)](#1-0-0)
|
||||
- Initial release.
|
||||
- Initial release.
|
||||
-3
@@ -8,12 +8,9 @@
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pose;
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PoseableEntityModel;
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.duck;
|
||||
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface SoundManagerDuck {
|
||||
|
||||
void pauseSounds(@Nullable Identifier id, @Nullable SoundCategory category);
|
||||
|
||||
void resumeSounds(@Nullable Identifier id, @Nullable SoundCategory category);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.duck;
|
||||
|
||||
import net.minecraft.client.sound.SoundInstance;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface SoundSystemDuck {
|
||||
|
||||
void pauseSounds(@Nullable Identifier id, @Nullable SoundCategory category);
|
||||
|
||||
void resumeSounds(@Nullable Identifier id, @Nullable SoundCategory category);
|
||||
|
||||
Collection<SoundInstance> getSounds(@Nullable SoundCategory category);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.mixin;
|
||||
|
||||
import net.minecraft.entity.passive.VillagerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.village.VillagerProfession;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import com.cobblemon.mod.common.villager.VillagerGatherableItems;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Mixin(VillagerEntity.class)
|
||||
public abstract class EntityVillagerMixin {
|
||||
|
||||
@Inject(method = "canGather", at = @At(value = "RETURN"), cancellable = true)
|
||||
private void cobblemon$canGather(ItemStack stack, CallbackInfoReturnable<Boolean> ci) {
|
||||
final VillagerEntity villager = (VillagerEntity) (Object) this;
|
||||
if(ci.getReturnValue() == false && Objects.equals(villager.getVillagerData().getProfession(), VillagerProfession.FARMER) && villager.getInventory().canInsert(stack)) {
|
||||
if(VillagerGatherableItems.INSTANCE.getVillagerGatherableItems().contains(stack.getItem()))
|
||||
ci.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,20 +8,36 @@
|
||||
|
||||
package com.cobblemon.mod.common.mixin;
|
||||
|
||||
import com.cobblemon.mod.common.api.scheduling.ScheduledTaskTracker;
|
||||
import com.cobblemon.mod.common.api.scheduling.ClientTaskTracker;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public class GameRendererMixin {
|
||||
@Unique
|
||||
long lastTime = -1;
|
||||
|
||||
@Inject(
|
||||
method = "render",
|
||||
at = @At(value = "TAIL")
|
||||
)
|
||||
public void render(float tickDelta, long startTime, boolean tick, CallbackInfo ci) {
|
||||
ScheduledTaskTracker.INSTANCE.update();
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
long newTime = System.currentTimeMillis();
|
||||
// Don't play scheduled animations when the game is paused
|
||||
if (client.isPaused()) {
|
||||
lastTime = newTime;
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastTime != -1) {
|
||||
ClientTaskTracker.INSTANCE.update((newTime - lastTime) / 1000F);
|
||||
}
|
||||
lastTime = newTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.mixin;
|
||||
|
||||
import com.cobblemon.mod.common.client.CobblemonBakingOverrides;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.render.model.UnbakedModel;
|
||||
import net.minecraft.client.render.model.json.JsonUnbakedModel;
|
||||
import net.minecraft.client.util.ModelIdentifier;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionPoint;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.points.BeforeStringInvoke;
|
||||
|
||||
@Mixin(ModelLoader.class)
|
||||
public abstract class ModelLoaderMixin {
|
||||
|
||||
@Shadow protected abstract void addModel(ModelIdentifier modelId);
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
private Map<Identifier, UnbakedModel> unbakedModels;
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
private static Logger LOGGER;
|
||||
|
||||
@Inject(
|
||||
method = "<init>",
|
||||
at = @At("TAIL")
|
||||
)
|
||||
public void init(BlockColors blockColors,
|
||||
Profiler profiler,
|
||||
Map jsonUnbakedModels,
|
||||
Map blockStates,
|
||||
CallbackInfo ci) {
|
||||
CobblemonBakingOverrides.INSTANCE.getModels().forEach(bakingOverride -> {
|
||||
try {
|
||||
this.unbakedModels.put(bakingOverride.getModelIdentifier(), this.loadModelFromJson(bakingOverride.getModelLocation()));
|
||||
this.addModel(bakingOverride.getModelIdentifier());
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Error loading a Cobblemon BakedModel:", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Shadow
|
||||
private JsonUnbakedModel loadModelFromJson(Identifier id) throws IOException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -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.mixin;
|
||||
|
||||
import com.cobblemon.mod.common.client.sound.battle.BattleMusicController;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.sound.MusicTracker;
|
||||
import net.minecraft.client.sound.SoundInstance;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MusicTracker.class)
|
||||
public class MusicTrackerMixin {
|
||||
|
||||
@Shadow @Final
|
||||
private MinecraftClient client;
|
||||
|
||||
@Shadow @Nullable
|
||||
private SoundInstance current;
|
||||
|
||||
/** Freezes the tracker while a BattleMusicInstance is in progress. Current SoundInstance being tracked will be paused by BattleMusicHandler. */
|
||||
@Inject(method = "tick()V", at = @At("HEAD"), cancellable = true)
|
||||
public void tick(CallbackInfo cb) {
|
||||
if (this.client.getSoundManager().isPlaying(BattleMusicController.INSTANCE.getMusic())) cb.cancel();
|
||||
}
|
||||
}
|
||||
@@ -8,36 +8,77 @@
|
||||
|
||||
package com.cobblemon.mod.common.mixin;
|
||||
|
||||
import com.cobblemon.mod.common.access.SoundManagerDuck;
|
||||
import net.minecraft.client.sound.SoundInstance;
|
||||
import net.minecraft.client.sound.SoundManager;
|
||||
import com.cobblemon.mod.common.client.sound.battle.BattleMusicController;
|
||||
import com.cobblemon.mod.common.duck.SoundManagerDuck;
|
||||
import com.cobblemon.mod.common.duck.SoundSystemDuck;
|
||||
import net.minecraft.client.sound.*;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(SoundManager.class)
|
||||
public class SoundManagerMixin implements SoundManagerDuck {
|
||||
public abstract class SoundManagerMixin implements SoundManagerDuck {
|
||||
|
||||
private boolean[] blockedCategories = new boolean[SoundCategory.values().length];
|
||||
@Shadow
|
||||
public abstract boolean isPlaying(SoundInstance sound);
|
||||
|
||||
@Override
|
||||
public void toggleCategories(SoundCategory... categories) {
|
||||
for (SoundCategory category : categories) {
|
||||
int index = category.ordinal();
|
||||
boolean blocked = blockedCategories[index];
|
||||
blockedCategories[index] = !blocked;
|
||||
}
|
||||
@Shadow @Final
|
||||
private SoundSystem soundSystem;
|
||||
|
||||
// Never-ending ambient loops are a special exception (they are only initiated once) and should always be paused if filtered.
|
||||
private boolean isAmbientLoop(SoundInstance sound) {
|
||||
return sound instanceof BiomeEffectSoundPlayer.MusicLoop || sound instanceof AmbientSoundLoops.Underwater;
|
||||
}
|
||||
|
||||
private boolean filterCondition(SoundInstance sound) {
|
||||
return !isAmbientLoop(sound) &&
|
||||
this.isPlaying(BattleMusicController.INSTANCE.getMusic()) &&
|
||||
BattleMusicController.INSTANCE.getFilteredCategories().contains(sound.getCategory());
|
||||
}
|
||||
|
||||
private boolean ambientLoopCondition(SoundInstance sound) {
|
||||
return isAmbientLoop(sound) &&
|
||||
this.isPlaying(BattleMusicController.INSTANCE.getMusic()) &&
|
||||
BattleMusicController.INSTANCE.getFilteredCategories().contains(sound.getCategory());
|
||||
}
|
||||
|
||||
/** Pauses the queried SoundInstance(s). If id is null, will pause all sounds belonging to the SoundCategory. */
|
||||
@Override
|
||||
public void pauseSounds(@Nullable Identifier id, @Nullable SoundCategory category) {
|
||||
((SoundSystemDuck)soundSystem).pauseSounds(id, category);
|
||||
}
|
||||
|
||||
/** Resumes the queried SoundInstance(s). If id is null, will resume all sounds belonging to the SoundCategory. */
|
||||
@Override
|
||||
public void resumeSounds(@Nullable Identifier id, @Nullable SoundCategory category) {
|
||||
((SoundSystemDuck)soundSystem).resumeSounds(id, category);
|
||||
}
|
||||
|
||||
/** Blocks filtered sounds from being played while a BattleMusicInstance is in progress. */
|
||||
@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V", at = @At("HEAD"), cancellable = true)
|
||||
public void play(SoundInstance sound, CallbackInfo cb) {
|
||||
if (blockedCategories[sound.getCategory().ordinal()]) cb.cancel();
|
||||
public void playStart(SoundInstance sound, CallbackInfo cb) {
|
||||
if (filterCondition(sound)) cb.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;I)V", at = @At("HEAD"), cancellable = true)
|
||||
public void play(SoundInstance sound, int delay, CallbackInfo cb) {
|
||||
if (blockedCategories[sound.getCategory().ordinal()]) cb.cancel();
|
||||
public void playStart(SoundInstance sound, int delay, CallbackInfo cb) {
|
||||
if (filterCondition(sound)) cb.cancel();
|
||||
}
|
||||
|
||||
/** Pauses ambient loops while a BattleMusicInstance is in progress. */
|
||||
@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V", at = @At("TAIL"))
|
||||
public void playEnd(SoundInstance sound, CallbackInfo cb) {
|
||||
if (ambientLoopCondition(sound)) this.pauseSounds(sound.getId(), SoundCategory.AMBIENT);
|
||||
}
|
||||
|
||||
@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;I)V", at = @At("TAIL"))
|
||||
public void playEnd(SoundInstance sound, int delay, CallbackInfo cb) {
|
||||
if (ambientLoopCondition(sound)) this.pauseSounds(sound.getId(), SoundCategory.AMBIENT);
|
||||
}
|
||||
}
|
||||
@@ -8,31 +8,102 @@
|
||||
|
||||
package com.cobblemon.mod.common.mixin;
|
||||
|
||||
import com.cobblemon.mod.common.client.sound.battle.BattleMusicController;
|
||||
import com.cobblemon.mod.common.duck.SoundSystemDuck;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.client.sound.SoundInstance;
|
||||
import net.minecraft.client.sound.SoundSystem;
|
||||
import net.minecraft.client.sound.*;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(SoundSystem.class)
|
||||
public abstract class SoundSystemMixin {
|
||||
public abstract class SoundSystemMixin implements SoundSystemDuck {
|
||||
|
||||
@Shadow
|
||||
private boolean started;
|
||||
|
||||
@Shadow
|
||||
private Multimap<SoundCategory, SoundInstance> sounds;
|
||||
|
||||
@Shadow @Final
|
||||
private Map<SoundInstance, Channel.SourceManager> sources;
|
||||
|
||||
@Shadow
|
||||
protected abstract void stop(SoundInstance sound);
|
||||
|
||||
@Shadow
|
||||
public abstract boolean isPlaying(SoundInstance sound);
|
||||
|
||||
/** Resumes the Source belonging to the queried SoundInstance. */
|
||||
private void resume(SoundInstance sound) {
|
||||
Channel.SourceManager sourceManager = this.sources.get(sound);
|
||||
if (this.started && sourceManager != null) sourceManager.run(Source::resume);
|
||||
}
|
||||
|
||||
/** Pauses the Source belonging to the queried SoundInstance. */
|
||||
private void pause(SoundInstance sound) {
|
||||
Channel.SourceManager sourceManager = this.sources.get(sound);
|
||||
if (this.started && sourceManager != null) sourceManager.run(Source::pause);
|
||||
}
|
||||
|
||||
/** Resumes the SoundInstance(s) queried by id and/or category. */
|
||||
@Override
|
||||
public void resumeSounds(@Nullable Identifier id, @Nullable SoundCategory category) {
|
||||
if (category != null) {
|
||||
this.sounds.get(category).forEach((sound) -> {
|
||||
if (id == null || sound.getId().equals(id)) resume(sound);
|
||||
});
|
||||
} else if (id == null) {
|
||||
this.sources.keySet().forEach(this::resume);
|
||||
} else {
|
||||
this.sources.keySet().forEach(sound -> {
|
||||
if (sound.getId().equals(id)) resume(sound);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** Pauses the SoundInstances queried by id and/or category. */
|
||||
@Override
|
||||
public void pauseSounds(@Nullable Identifier id, @Nullable SoundCategory category) {
|
||||
if (category != null) {
|
||||
this.sounds.get(category).forEach((sound) -> {
|
||||
if (id == null || sound.getId().equals(id)) pause(sound);
|
||||
});
|
||||
} else if (id == null) {
|
||||
this.sources.keySet().forEach(this::pause);
|
||||
} else {
|
||||
this.sources.keySet().forEach(sound -> {
|
||||
if (sound.getId().equals(id)) pause(sound);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** Allows stopping all SoundInstances that belong to a queried category. */
|
||||
@Inject(method = "stopSounds(Lnet/minecraft/util/Identifier;Lnet/minecraft/sound/SoundCategory;)V", at = @At("HEAD"), cancellable = true)
|
||||
public void stopSounds(@Nullable Identifier id, @Nullable SoundCategory category, CallbackInfo cb) {
|
||||
if (id == null && category != null) {
|
||||
sounds.get(category).forEach(this::stop);
|
||||
this.sounds.get(category).forEach(this::stop);
|
||||
cb.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/** Different behavior for resuming SoundInstances while a BattleMusicInstance is being played. We do not want to resume filtered sounds. */
|
||||
@Inject(method = "resumeAll()V", at = @At("HEAD"), cancellable = true)
|
||||
public void resumeAll(CallbackInfo cb) {
|
||||
if (this.isPlaying(BattleMusicController.INSTANCE.getMusic())) {
|
||||
this.sounds.values().forEach(sound -> {
|
||||
if (sound == BattleMusicController.INSTANCE.getMusic() || !BattleMusicController.INSTANCE.getFilteredCategories().contains(sound.getCategory())) {
|
||||
resume(sound);
|
||||
}
|
||||
});
|
||||
cb.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.mixin.accessor;
|
||||
|
||||
import net.minecraft.client.sound.MusicTracker;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(MusicTracker.class)
|
||||
public interface MusicTrackerAccessor {
|
||||
@Accessor("timeUntilNextSong")
|
||||
int timeUntilNextSong();
|
||||
|
||||
@Accessor("timeUntilNextSong")
|
||||
void setTimeUntilNextSong(int timeUntilNextSong);
|
||||
}
|
||||
@@ -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
|
||||
|
||||
import net.minecraft.client.MinecraftClient
|
||||
import net.minecraft.client.render.model.BakedModel
|
||||
import net.minecraft.client.util.ModelIdentifier
|
||||
import net.minecraft.util.Identifier
|
||||
|
||||
/**
|
||||
* Contains information for forcing a model to be baked
|
||||
*
|
||||
* @param modelLocation The location of the model
|
||||
* @param modelIdentifier The identifier that the BakedModel will be registered to
|
||||
*/
|
||||
data class BakingOverride(
|
||||
val modelLocation: Identifier,
|
||||
val modelIdentifier: ModelIdentifier
|
||||
) {
|
||||
fun getModel(): BakedModel {
|
||||
return MinecraftClient.getInstance().bakedModelManager.getModel(modelIdentifier)
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,8 @@ import com.cobblemon.mod.common.api.pokemon.stats.EvCalculator
|
||||
import com.cobblemon.mod.common.api.pokemon.stats.Generation8EvCalculator
|
||||
import com.cobblemon.mod.common.api.pokemon.stats.StatProvider
|
||||
import com.cobblemon.mod.common.api.properties.CustomPokemonProperty
|
||||
import com.cobblemon.mod.common.api.scheduling.ScheduledTaskTracker
|
||||
import com.cobblemon.mod.common.api.scheduling.ServerRealTimeTaskTracker
|
||||
import com.cobblemon.mod.common.api.scheduling.ServerTaskTracker
|
||||
import com.cobblemon.mod.common.api.spawning.BestSpawner
|
||||
import com.cobblemon.mod.common.api.spawning.CobblemonSpawningProspector
|
||||
import com.cobblemon.mod.common.api.spawning.context.AreaContextResolver
|
||||
@@ -54,6 +55,7 @@ import com.cobblemon.mod.common.api.storage.adapter.flatfile.FileStoreAdapter
|
||||
import com.cobblemon.mod.common.api.storage.adapter.flatfile.JSONStoreAdapter
|
||||
import com.cobblemon.mod.common.api.storage.adapter.flatfile.NBTStoreAdapter
|
||||
import com.cobblemon.mod.common.api.storage.factory.FileBackedPokemonStoreFactory
|
||||
import com.cobblemon.mod.common.api.storage.molang.NbtMoLangDataStoreFactory
|
||||
import com.cobblemon.mod.common.api.storage.pc.PCStore
|
||||
import com.cobblemon.mod.common.api.storage.pc.link.PCLinkManager
|
||||
import com.cobblemon.mod.common.api.storage.player.PlayerDataStoreManager
|
||||
@@ -67,6 +69,7 @@ import com.cobblemon.mod.common.battles.BattleSide
|
||||
import com.cobblemon.mod.common.battles.ShowdownThread
|
||||
import com.cobblemon.mod.common.battles.actor.PokemonBattleActor
|
||||
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
|
||||
import com.cobblemon.mod.common.command.argument.DialogueArgumentType
|
||||
import com.cobblemon.mod.common.command.argument.MoveArgumentType
|
||||
import com.cobblemon.mod.common.command.argument.PartySlotArgumentType
|
||||
import com.cobblemon.mod.common.command.argument.PokemonArgumentType
|
||||
@@ -153,6 +156,7 @@ object Cobblemon {
|
||||
val bestSpawner = BestSpawner
|
||||
val battleRegistry = BattleRegistry
|
||||
var storage = PokemonStoreManager()
|
||||
var molangData = NbtMoLangDataStoreFactory
|
||||
lateinit var playerData: PlayerDataStoreManager
|
||||
lateinit var starterConfig: StarterConfig
|
||||
val dataProvider: DataProvider = CobblemonDataProvider
|
||||
@@ -260,9 +264,15 @@ object Cobblemon {
|
||||
|
||||
ifDedicatedServer {
|
||||
isDedicatedServer = true
|
||||
PlatformEvents.SERVER_TICK_POST.subscribe { ScheduledTaskTracker.update() }
|
||||
}
|
||||
|
||||
PlatformEvents.SERVER_TICK_POST.subscribe {
|
||||
ServerTaskTracker.update(1/20F)
|
||||
ServerRealTimeTaskTracker.update()
|
||||
}
|
||||
PlatformEvents.SERVER_TICK_PRE.subscribe {
|
||||
ServerRealTimeTaskTracker.update()
|
||||
}
|
||||
PlatformEvents.SERVER_STARTING.subscribe { event ->
|
||||
val server = event.server
|
||||
playerData = PlayerDataStoreManager().also { it.setup(server) }
|
||||
@@ -371,8 +381,9 @@ object Cobblemon {
|
||||
battleRegistry.startBattle(
|
||||
BattleFormat.GEN_9_SINGLES,
|
||||
BattleSide(PokemonBattleActor(UUID.randomUUID(), BattlePokemon(Pokemon().initialize()), -1F)),
|
||||
BattleSide(PokemonBattleActor(UUID.randomUUID(), BattlePokemon(Pokemon().initialize()), -1F))
|
||||
).apply { mute = true }
|
||||
BattleSide(PokemonBattleActor(UUID.randomUUID(), BattlePokemon(Pokemon().initialize()), -1F)),
|
||||
true
|
||||
).ifSuccessful { it.mute = true }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -477,6 +488,7 @@ object Cobblemon {
|
||||
this.implementation.registerCommandArgument(cobblemonResource("move"), MoveArgumentType::class, ConstantArgumentSerializer.of(MoveArgumentType::move))
|
||||
this.implementation.registerCommandArgument(cobblemonResource("party_slot"), PartySlotArgumentType::class, ConstantArgumentSerializer.of(PartySlotArgumentType::partySlot))
|
||||
this.implementation.registerCommandArgument(cobblemonResource("pokemon_store"), PokemonStoreArgumentType::class, ConstantArgumentSerializer.of(PokemonStoreArgumentType::pokemonStore))
|
||||
this.implementation.registerCommandArgument(cobblemonResource("dialogue"), DialogueArgumentType::class, ConstantArgumentSerializer.of(DialogueArgumentType::dialogue))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common
|
||||
|
||||
import net.minecraft.entity.ai.brain.Activity
|
||||
|
||||
object CobblemonActivities {
|
||||
val activities = mutableListOf<Activity>()
|
||||
val BATTLING_ACTIVITY = Activity("pokemon_battling")
|
||||
|
||||
fun register(activity: Activity): Activity {
|
||||
activities.add(activity)
|
||||
return activity
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,14 @@
|
||||
|
||||
package com.cobblemon.mod.common
|
||||
|
||||
import com.cobblemon.mod.common.block.entity.BerryBlockEntity
|
||||
import com.cobblemon.mod.common.block.entity.HealingMachineBlockEntity
|
||||
import com.cobblemon.mod.common.block.entity.PCBlockEntity
|
||||
import com.cobblemon.mod.common.block.entity.PokemonPastureBlockEntity
|
||||
import com.cobblemon.mod.common.block.entity.fossil.FossilCompartmentBlockEntity
|
||||
import com.cobblemon.mod.common.block.entity.fossil.FossilMultiblockEntity
|
||||
import com.cobblemon.mod.common.block.entity.fossil.FossilTubeBlockEntity
|
||||
import com.cobblemon.mod.common.block.multiblock.FossilMultiblockBuilder
|
||||
import com.cobblemon.mod.common.block.entity.*
|
||||
import com.cobblemon.mod.common.platform.PlatformRegistry
|
||||
import net.minecraft.block.entity.BlockEntityType
|
||||
@@ -23,9 +31,13 @@ object CobblemonBlockEntities : PlatformRegistry<Registry<BlockEntityType<*>>, R
|
||||
|
||||
@JvmField
|
||||
val HEALING_MACHINE: BlockEntityType<HealingMachineBlockEntity> = this.create("healing_machine", BlockEntityType.Builder.create(::HealingMachineBlockEntity, CobblemonBlocks.HEALING_MACHINE).build(null))
|
||||
|
||||
@JvmField
|
||||
val PC: BlockEntityType<PCBlockEntity> = this.create("pc", BlockEntityType.Builder.create(::PCBlockEntity, CobblemonBlocks.PC).build(null))
|
||||
|
||||
@JvmField
|
||||
val BERRY = this.create("berry", BlockEntityType.Builder.create(::BerryBlockEntity, *CobblemonBlocks.berries().values.toTypedArray()).build(null))
|
||||
|
||||
@JvmField
|
||||
val PASTURE: BlockEntityType<PokemonPastureBlockEntity> = this.create("pasture", BlockEntityType.Builder.create(::PokemonPastureBlockEntity, CobblemonBlocks.PASTURE).build(null))
|
||||
@JvmField
|
||||
@@ -33,4 +45,24 @@ object CobblemonBlockEntities : PlatformRegistry<Registry<BlockEntityType<*>>, R
|
||||
@JvmField
|
||||
val HANGING_SIGN: BlockEntityType<CobblemonHangingSignBlockEntity> = this.create("hanging_sign", BlockEntityType.Builder.create(::CobblemonHangingSignBlockEntity, CobblemonBlocks.APRICORN_HANGING_SIGN, CobblemonBlocks.APRICORN_WALL_HANGING_SIGN).build(null))
|
||||
|
||||
}
|
||||
@JvmField
|
||||
val FOSSIL_MULTIBLOCK: BlockEntityType<FossilMultiblockEntity> = this.create("fossil_multiblock",
|
||||
BlockEntityType.Builder.create({ pos, state -> FossilMultiblockEntity(pos, state, FossilMultiblockBuilder(pos)) },
|
||||
CobblemonBlocks.FOSSIL_MONITOR
|
||||
).build(null)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val FOSSIL_TUBE: BlockEntityType<FossilTubeBlockEntity> = this.create("fossil_tube",
|
||||
BlockEntityType.Builder.create({ pos, state -> FossilTubeBlockEntity(pos, state, FossilMultiblockBuilder(pos)) },
|
||||
CobblemonBlocks.FOSSIL_TUBE
|
||||
).build(null)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val FOSSIL_COMPARTMENT: BlockEntityType<FossilCompartmentBlockEntity> = this.create("fossil_compartment",
|
||||
BlockEntityType.Builder.create({ pos, state -> FossilCompartmentBlockEntity(pos, state, FossilMultiblockBuilder(pos)) },
|
||||
CobblemonBlocks.FOSSIL_COMPARTMENT
|
||||
).build(null)
|
||||
)
|
||||
}
|
||||
@@ -11,6 +11,9 @@ package com.cobblemon.mod.common
|
||||
import com.cobblemon.mod.common.api.apricorn.Apricorn
|
||||
import com.cobblemon.mod.common.block.*
|
||||
import com.cobblemon.mod.common.block.MintBlock.MintType
|
||||
import com.cobblemon.mod.common.block.fossilmachine.FossilCompartmentBlock
|
||||
import com.cobblemon.mod.common.block.fossilmachine.FossilMonitorBlock
|
||||
import com.cobblemon.mod.common.block.fossilmachine.FossilTubeBlock
|
||||
import com.cobblemon.mod.common.mixin.invoker.DoorBlockInvoker
|
||||
import com.cobblemon.mod.common.mixin.invoker.PressurePlateBlockInvoker
|
||||
import com.cobblemon.mod.common.mixin.invoker.StairsBlockInvoker
|
||||
@@ -153,6 +156,52 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, RegistryKey<Registry<
|
||||
@JvmField
|
||||
val REVIVAL_HERB = this.create("revival_herb", RevivalHerbBlock(AbstractBlock.Settings.create().pistonBehavior(PistonBehavior.DESTROY).mapColor(MapColor.DARK_GREEN).burnable().noCollision().breakInstantly().sounds(BlockSoundGroup.CROP)))
|
||||
|
||||
@JvmField
|
||||
val TUMBLESTONE_CLUSTER = tumblestoneBlock("tumblestone_cluster", TumblestoneBlock.STAGE_3, 7, 3, null)
|
||||
@JvmField
|
||||
val LARGE_BUDDING_TUMBLESTONE = tumblestoneBlock("large_budding_tumblestone", TumblestoneBlock.STAGE_2, 5, 3, TUMBLESTONE_CLUSTER)
|
||||
@JvmField
|
||||
val MEDIUM_BUDDING_TUMBLESTONE = tumblestoneBlock("medium_budding_tumblestone", TumblestoneBlock.STAGE_1, 4, 3, LARGE_BUDDING_TUMBLESTONE)
|
||||
@JvmField
|
||||
val SMALL_BUDDING_TUMBLESTONE = tumblestoneBlock("small_budding_tumblestone", TumblestoneBlock.STAGE_0, 3, 4, MEDIUM_BUDDING_TUMBLESTONE)
|
||||
|
||||
@JvmField
|
||||
val SKY_TUMBLESTONE_CLUSTER = tumblestoneBlock("sky_tumblestone_cluster", TumblestoneBlock.STAGE_3, 7, 3, null)
|
||||
@JvmField
|
||||
val LARGE_BUDDING_SKY_TUMBLESTONE = tumblestoneBlock("large_budding_sky_tumblestone", TumblestoneBlock.STAGE_2, 5, 3, SKY_TUMBLESTONE_CLUSTER)
|
||||
@JvmField
|
||||
val MEDIUM_BUDDING_SKY_TUMBLESTONE = tumblestoneBlock("medium_budding_sky_tumblestone", TumblestoneBlock.STAGE_1, 4, 3, LARGE_BUDDING_SKY_TUMBLESTONE)
|
||||
@JvmField
|
||||
val SMALL_BUDDING_SKY_TUMBLESTONE = tumblestoneBlock("small_budding_sky_tumblestone", TumblestoneBlock.STAGE_0, 3, 4, MEDIUM_BUDDING_SKY_TUMBLESTONE)
|
||||
|
||||
@JvmField
|
||||
val BLACK_TUMBLESTONE_CLUSTER = tumblestoneBlock("black_tumblestone_cluster", TumblestoneBlock.STAGE_3, 7, 3, null)
|
||||
@JvmField
|
||||
val LARGE_BUDDING_BLACK_TUMBLESTONE = tumblestoneBlock("large_budding_black_tumblestone", TumblestoneBlock.STAGE_2, 5, 3, BLACK_TUMBLESTONE_CLUSTER)
|
||||
@JvmField
|
||||
val MEDIUM_BUDDING_BLACK_TUMBLESTONE = tumblestoneBlock("medium_budding_black_tumblestone", TumblestoneBlock.STAGE_1, 4, 3, LARGE_BUDDING_BLACK_TUMBLESTONE)
|
||||
@JvmField
|
||||
val SMALL_BUDDING_BLACK_TUMBLESTONE = tumblestoneBlock("small_budding_black_tumblestone", TumblestoneBlock.STAGE_0, 3, 4, MEDIUM_BUDDING_BLACK_TUMBLESTONE)
|
||||
|
||||
@JvmField
|
||||
val TUMBLESTONE_BLOCK = this.create("tumblestone_block", Block(AbstractBlock.Settings.create()
|
||||
.mapColor(MapColor.TERRACOTTA_ORANGE)
|
||||
.strength(1.0F)
|
||||
.sounds(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS)
|
||||
))
|
||||
@JvmField
|
||||
val SKY_TUMBLESTONE_BLOCK = this.create("sky_tumblestone_block", Block(AbstractBlock.Settings.create()
|
||||
.mapColor(MapColor.LIGHT_BLUE)
|
||||
.strength(1.0F)
|
||||
.sounds(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS)
|
||||
))
|
||||
@JvmField
|
||||
val BLACK_TUMBLESTONE_BLOCK = this.create("black_tumblestone_block", Block(AbstractBlock.Settings.create()
|
||||
.mapColor(MapColor.TERRACOTTA_BLACK)
|
||||
.strength(1.0F)
|
||||
.sounds(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS)
|
||||
))
|
||||
|
||||
@JvmField
|
||||
val BLACK_APRICORN = apricornBlock("black_apricorn", Apricorn.BLACK)
|
||||
@JvmField
|
||||
@@ -168,6 +217,42 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, RegistryKey<Registry<
|
||||
@JvmField
|
||||
val YELLOW_APRICORN = apricornBlock("yellow_apricorn", Apricorn.YELLOW)
|
||||
|
||||
@JvmField
|
||||
val FOSSIL_MONITOR = create(
|
||||
"fossil_monitor",
|
||||
FossilMonitorBlock(
|
||||
AbstractBlock.Settings.create()
|
||||
.mapColor(MapColor.IRON_GRAY)
|
||||
.sounds(BlockSoundGroup.METAL)
|
||||
.pistonBehavior(PistonBehavior.BLOCK)
|
||||
.strength(2f)
|
||||
.luminance { if (it.get(FossilMonitorBlock.PROGRESS) > 0) 15 else 0 }
|
||||
)
|
||||
)
|
||||
@JvmField
|
||||
val FOSSIL_COMPARTMENT = create(
|
||||
"fossil_compartment",
|
||||
FossilCompartmentBlock(
|
||||
AbstractBlock.Settings.create()
|
||||
.mapColor(MapColor.IRON_GRAY)
|
||||
.sounds(BlockSoundGroup.METAL)
|
||||
.pistonBehavior(PistonBehavior.BLOCK)
|
||||
.strength(2f)
|
||||
.nonOpaque()
|
||||
)
|
||||
)
|
||||
@JvmField
|
||||
val FOSSIL_TUBE = create(
|
||||
"fossil_tube",
|
||||
FossilTubeBlock(
|
||||
AbstractBlock.Settings.create()
|
||||
.mapColor(MapColor.IRON_GRAY)
|
||||
.sounds(BlockSoundGroup.METAL)
|
||||
.pistonBehavior(PistonBehavior.BLOCK)
|
||||
.strength(2f)
|
||||
.nonOpaque()
|
||||
)
|
||||
)
|
||||
@JvmField
|
||||
val HEALING_MACHINE = create(
|
||||
"healing_machine",
|
||||
@@ -243,6 +328,15 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, RegistryKey<Registry<
|
||||
|
||||
private fun apricornBlock(name: String, apricorn: Apricorn): ApricornBlock = this.create(name, ApricornBlock(AbstractBlock.Settings.create().mapColor(apricorn.mapColor()).ticksRandomly().strength(Blocks.OAK_LOG.hardness, Blocks.OAK_LOG.blastResistance).sounds(BlockSoundGroup.WOOD).nonOpaque(), apricorn))
|
||||
|
||||
private fun tumblestoneBlock(name: String, stage: Int, height: Int, xzOffset: Int, nextStage: Block?) : Block {
|
||||
return this.create(name, TumblestoneBlock(AbstractBlock.Settings.create()
|
||||
.pistonBehavior(PistonBehavior.DESTROY)
|
||||
.nonOpaque()
|
||||
.strength(1.5F)
|
||||
.sounds(CobblemonSounds.TUMBLESTONE_SOUNDS),
|
||||
stage, height, xzOffset, nextStage))
|
||||
}
|
||||
|
||||
private val berries = mutableMapOf<Identifier, BerryBlock>()
|
||||
|
||||
val AGUAV_BERRY = this.berryBlock("aguav")
|
||||
|
||||
@@ -46,5 +46,8 @@ object CobblemonCommands {
|
||||
ClearPartyCommand.register(dispatcher)
|
||||
ClearPCCommand.register(dispatcher)
|
||||
PokemonRestartCommand.register(dispatcher)
|
||||
RandomBattleCommand.register(dispatcher)
|
||||
BedrockParticleCommand.register(dispatcher)
|
||||
OpenDialogueCommand.register(dispatcher)
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import com.cobblemon.mod.common.item.berry.PortionHealingBerryItem
|
||||
import com.cobblemon.mod.common.item.berry.StatusCuringBerryItem
|
||||
import com.cobblemon.mod.common.item.berry.VolatileCuringBerryItem
|
||||
import com.cobblemon.mod.common.item.interactive.*
|
||||
import com.cobblemon.mod.common.item.interactive.PotionItem
|
||||
import com.cobblemon.mod.common.platform.PlatformRegistry
|
||||
import com.cobblemon.mod.common.pokeball.PokeBall
|
||||
import com.cobblemon.mod.common.pokemon.helditem.CobblemonHeldItemManager
|
||||
@@ -37,7 +36,13 @@ import net.minecraft.block.Block
|
||||
import net.minecraft.entity.LivingEntity
|
||||
import net.minecraft.entity.effect.StatusEffectInstance
|
||||
import net.minecraft.entity.effect.StatusEffects
|
||||
import net.minecraft.item.*
|
||||
import net.minecraft.item.BlockItem
|
||||
import net.minecraft.item.FoodComponent
|
||||
import net.minecraft.item.HangingSignItem
|
||||
import net.minecraft.item.Item
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.item.SignItem
|
||||
import net.minecraft.item.StewItem
|
||||
import net.minecraft.registry.Registries
|
||||
import net.minecraft.registry.Registry
|
||||
import net.minecraft.registry.RegistryKey
|
||||
@@ -116,6 +121,38 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, RegistryKey<Registry<It
|
||||
val MASTER_BALL = pokeBallItem(PokeBalls.MASTER_BALL)
|
||||
@JvmField
|
||||
val CHERISH_BALL = pokeBallItem(PokeBalls.CHERISH_BALL)
|
||||
@JvmField
|
||||
val ANCIENT_POKE_BALL = pokeBallItem(PokeBalls.ANCIENT_POKE_BALL)
|
||||
@JvmField
|
||||
val ANCIENT_CITRINE_BALL = pokeBallItem(PokeBalls.ANCIENT_CITRINE_BALL)
|
||||
@JvmField
|
||||
val ANCIENT_VERDANT_BALL = pokeBallItem(PokeBalls.ANCIENT_VERDANT_BALL)
|
||||
@JvmField
|
||||
val ANCIENT_AZURE_BALL = pokeBallItem(PokeBalls.ANCIENT_AZURE_BALL)
|
||||
@JvmField
|
||||
val ANCIENT_ROSEATE_BALL = pokeBallItem(PokeBalls.ANCIENT_ROSEATE_BALL)
|
||||
@JvmField
|
||||
val ANCIENT_SLATE_BALL = pokeBallItem(PokeBalls.ANCIENT_SLATE_BALL)
|
||||
@JvmField
|
||||
val ANCIENT_IVORY_BALL = pokeBallItem(PokeBalls.ANCIENT_IVORY_BALL)
|
||||
@JvmField
|
||||
val ANCIENT_GREAT_BALL = pokeBallItem(PokeBalls.ANCIENT_GREAT_BALL)
|
||||
@JvmField
|
||||
val ANCIENT_ULTRA_BALL = pokeBallItem(PokeBalls.ANCIENT_ULTRA_BALL)
|
||||
@JvmField
|
||||
val ANCIENT_FEATHER_BALL = pokeBallItem(PokeBalls.ANCIENT_FEATHER_BALL)
|
||||
@JvmField
|
||||
val ANCIENT_WING_BALL = pokeBallItem(PokeBalls.ANCIENT_WING_BALL)
|
||||
@JvmField
|
||||
val ANCIENT_JET_BALL = pokeBallItem(PokeBalls.ANCIENT_JET_BALL)
|
||||
@JvmField
|
||||
val ANCIENT_HEAVY_BALL = pokeBallItem(PokeBalls.ANCIENT_HEAVY_BALL)
|
||||
@JvmField
|
||||
val ANCIENT_LEADEN_BALL = pokeBallItem(PokeBalls.ANCIENT_LEADEN_BALL)
|
||||
@JvmField
|
||||
val ANCIENT_GIGATON_BALL = pokeBallItem(PokeBalls.ANCIENT_GIGATON_BALL)
|
||||
@JvmField
|
||||
val ANCIENT_ORIGIN_BALL = pokeBallItem(PokeBalls.ANCIENT_ORIGIN_BALL)
|
||||
|
||||
@JvmField
|
||||
val VIVICHOKE = compostableItem("vivichoke")
|
||||
@@ -191,6 +228,12 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, RegistryKey<Registry<It
|
||||
@JvmField
|
||||
val APRICORN_HANGING_SIGN = this.create("apricorn_hanging_sign", HangingSignItem(CobblemonBlocks.APRICORN_HANGING_SIGN, CobblemonBlocks.APRICORN_WALL_HANGING_SIGN, Item.Settings().maxCount(16)))
|
||||
|
||||
@JvmField
|
||||
val FOSSIL_TUBE = blockItem("fossil_tube", CobblemonBlocks.FOSSIL_TUBE)
|
||||
@JvmField
|
||||
val FOSSIL_COMPARTMENT = blockItem("fossil_compartment", CobblemonBlocks.FOSSIL_COMPARTMENT)
|
||||
@JvmField
|
||||
val FOSSIL_MONITOR = blockItem("fossil_monitor", CobblemonBlocks.FOSSIL_MONITOR)
|
||||
@JvmField
|
||||
val HEALING_MACHINE = blockItem("healing_machine", CobblemonBlocks.HEALING_MACHINE)
|
||||
@JvmField
|
||||
@@ -553,16 +596,28 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, RegistryKey<Registry<It
|
||||
|
||||
// Held Items
|
||||
@JvmField
|
||||
val ABILITY_SHIELD = heldItem("ability_shield")
|
||||
@JvmField
|
||||
val ABSORB_BULB = heldItem("absorb_bulb")
|
||||
@JvmField
|
||||
val AIR_BALLOON = heldItem("air_balloon")
|
||||
@JvmField
|
||||
val ASSAULT_VEST = heldItem("assault_vest")
|
||||
@JvmField
|
||||
val BIG_ROOT = blockItem("big_root", CobblemonBlocks.BIG_ROOT)
|
||||
@JvmField
|
||||
val BINDING_BAND = heldItem("binding_band")
|
||||
@JvmField
|
||||
val BLACK_BELT = heldItem("black_belt")
|
||||
@JvmField
|
||||
val BLACK_GLASSES = heldItem("black_glasses")
|
||||
@JvmField
|
||||
val BLACK_SLUDGE = heldItem("black_sludge")
|
||||
@JvmField
|
||||
val BLUNDER_POLICY = heldItem("blunder_policy")
|
||||
@JvmField
|
||||
val CELL_BATTERY = heldItem("cell_battery")
|
||||
@JvmField
|
||||
val CHARCOAL = heldItem("charcoal_stick", remappedName = "charcoal")
|
||||
@JvmField
|
||||
val CHOICE_BAND = heldItem("choice_band")
|
||||
@@ -573,26 +628,64 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, RegistryKey<Registry<It
|
||||
@JvmField
|
||||
val CLEANSE_TAG = heldItem("cleanse_tag")
|
||||
@JvmField
|
||||
val CLEAR_AMULET = heldItem("clear_amulet")
|
||||
@JvmField
|
||||
val COVERT_CLOAK = heldItem("covert_cloak")
|
||||
@JvmField
|
||||
val DESTINY_KNOT = heldItem("destiny_knot")
|
||||
@JvmField
|
||||
val DRAGON_FANG = heldItem("dragon_fang")
|
||||
@JvmField
|
||||
val EJECT_BUTTON = heldItem("eject_button")
|
||||
@JvmField
|
||||
val EJECT_PACK = heldItem("eject_pack")
|
||||
@JvmField
|
||||
val EVERSTONE = heldItem("everstone")
|
||||
@JvmField
|
||||
val EVIOLITE = heldItem("eviolite")
|
||||
@JvmField
|
||||
val EXP_SHARE = heldItem("exp_share")
|
||||
@JvmField
|
||||
val EXPERT_BELT = heldItem("expert_belt")
|
||||
@JvmField
|
||||
val FAIRY_FEATHER = heldItem("fairy_feather")
|
||||
@JvmField
|
||||
val FLAME_ORB = heldItem("flame_orb")
|
||||
@JvmField
|
||||
val FLOAT_STONE = heldItem("float_stone")
|
||||
@JvmField
|
||||
val FOCUS_BAND = heldItem("focus_band")
|
||||
@JvmField
|
||||
val FOCUS_SASH = heldItem("focus_sash")
|
||||
@JvmField
|
||||
val GRIP_CLAW = heldItem("grip_claw")
|
||||
@JvmField
|
||||
val HARD_STONE = heldItem("hard_stone")
|
||||
@JvmField
|
||||
val HEAVY_DUTY_BOOTS = heldItem("heavy_duty_boots")
|
||||
@JvmField
|
||||
val IRON_BALL = heldItem("iron_ball")
|
||||
@JvmField
|
||||
val LAGGING_TAIL = heldItem("lagging_tail")
|
||||
@JvmField
|
||||
val LEFTOVERS = heldItem("leftovers")
|
||||
@JvmField
|
||||
val LIFE_ORB = heldItem("life_orb")
|
||||
@JvmField
|
||||
val LIGHT_BALL = heldItem("light_ball")
|
||||
@JvmField
|
||||
val LIGHT_CLAY = heldItem("light_clay")
|
||||
@JvmField
|
||||
val LOADED_DICE = heldItem("loaded_dice")
|
||||
@JvmField
|
||||
val LUCKY_EGG = heldItem("lucky_egg")
|
||||
@JvmField
|
||||
val LUMINOUS_MOSS = heldItem("luminous_moss")
|
||||
@JvmField
|
||||
val MAGNET = heldItem("magnet")
|
||||
@JvmField
|
||||
val METRONOME = heldItem("metronome")
|
||||
@JvmField
|
||||
val MIRACLE_SEED = heldItem("miracle_seed")
|
||||
@JvmField
|
||||
val MUSCLE_BAND = heldItem("muscle_band")
|
||||
@@ -603,14 +696,42 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, RegistryKey<Registry<It
|
||||
@JvmField
|
||||
val POISON_BARB = heldItem("poison_barb")
|
||||
@JvmField
|
||||
val POWER_ANKLET = heldItem("power_anklet")
|
||||
@JvmField
|
||||
val POWER_BAND = heldItem("power_band")
|
||||
@JvmField
|
||||
val POWER_BELT = heldItem("power_belt")
|
||||
@JvmField
|
||||
val POWER_BRACER = heldItem("power_bracer")
|
||||
@JvmField
|
||||
val POWER_LENS = heldItem("power_lens")
|
||||
@JvmField
|
||||
val POWER_WEIGHT = heldItem("power_weight")
|
||||
@JvmField
|
||||
val PROTECTIVE_PADS = heldItem("protective_pads")
|
||||
@JvmField
|
||||
val PUNCHING_GLOVE = heldItem("punching_glove")
|
||||
@JvmField
|
||||
val QUICK_CLAW = heldItem("quick_claw")
|
||||
@JvmField
|
||||
val RED_CARD = heldItem("red_card")
|
||||
@JvmField
|
||||
val RING_TARGET = heldItem("ring_target")
|
||||
@JvmField
|
||||
val ROCKY_HELMET = heldItem("rocky_helmet")
|
||||
@JvmField
|
||||
val ROOM_SERVICE = heldItem("room_service")
|
||||
@JvmField
|
||||
val SAFETY_GOGGLES = heldItem("safety_goggles")
|
||||
@JvmField
|
||||
val SCOPE_LENS = heldItem("scope_lens")
|
||||
@JvmField
|
||||
val SHARP_BEAK = heldItem("sharp_beak")
|
||||
@JvmField
|
||||
val SHED_SHELL = heldItem("shed_shell")
|
||||
@JvmField
|
||||
val SHELL_BELL = heldItem("shell_bell")
|
||||
@JvmField
|
||||
val SILK_SCARF = heldItem("silk_scarf")
|
||||
@JvmField
|
||||
val SILVER_POWDER = heldItem("silver_powder")
|
||||
@@ -619,10 +740,28 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, RegistryKey<Registry<It
|
||||
@JvmField
|
||||
val SPELL_TAG = heldItem("spell_tag")
|
||||
@JvmField
|
||||
val SMOKE_BALL = heldItem("smoke_ball")
|
||||
@JvmField
|
||||
val STICKY_BARB = heldItem("sticky_barb")
|
||||
@JvmField
|
||||
val TERRAIN_EXTENDER = heldItem("terrain_extender")
|
||||
@JvmField
|
||||
val THROAT_SPRAY = heldItem("throat_spray")
|
||||
@JvmField
|
||||
val TOXIC_ORB = heldItem("toxic_orb")
|
||||
@JvmField
|
||||
val TWISTED_SPOON = heldItem("twisted_spoon")
|
||||
@JvmField
|
||||
val UTILITY_UMBRELLA = heldItem("utility_umbrella")
|
||||
@JvmField
|
||||
val WEAKNESS_POLICY = heldItem("weakness_policy")
|
||||
@JvmField
|
||||
val WIDE_LENS = heldItem("wide_lens")
|
||||
@JvmField
|
||||
val WISE_GLASSES = heldItem("wise_glasses")
|
||||
@JvmField
|
||||
val ZOOM_LENS = heldItem("zoom_lens")
|
||||
@JvmField
|
||||
val MENTAL_HERB = compostableHeldItem("mental_herb", null, 1F)
|
||||
@JvmField
|
||||
val MIRROR_HERB = compostableHeldItem("mirror_herb", null, 1F)
|
||||
@@ -637,21 +776,13 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, RegistryKey<Registry<It
|
||||
@JvmField
|
||||
val QUICK_POWDER = heldItem("quick_powder")
|
||||
@JvmField
|
||||
val DESTINY_KNOT = heldItem("destiny_knot")
|
||||
val DAMP_ROCK = heldItem("damp_rock")
|
||||
@JvmField
|
||||
val EVERSTONE = heldItem("everstone")
|
||||
val HEAT_ROCK = heldItem("heat_rock")
|
||||
@JvmField
|
||||
val POWER_ANKLET = heldItem("power_anklet")
|
||||
val SMOOTH_ROCK = heldItem("smooth_rock")
|
||||
@JvmField
|
||||
val POWER_BAND = heldItem("power_band")
|
||||
@JvmField
|
||||
val POWER_BELT = heldItem("power_belt")
|
||||
@JvmField
|
||||
val POWER_BRACER = heldItem("power_bracer")
|
||||
@JvmField
|
||||
val POWER_LENS = heldItem("power_lens")
|
||||
@JvmField
|
||||
val POWER_WEIGHT = heldItem("power_weight")
|
||||
val ICY_ROCK = heldItem("icy_rock")
|
||||
|
||||
// Mulch
|
||||
@JvmField
|
||||
@@ -673,6 +804,90 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, RegistryKey<Registry<It
|
||||
@JvmField
|
||||
val SURPRISE_MULCH = mulchItem("surprise_mulch", MulchVariant.SURPRISE)
|
||||
|
||||
// Archaeology
|
||||
@JvmField
|
||||
val ARMOR_FOSSIL = noSettingsItem("armor_fossil")
|
||||
@JvmField
|
||||
val BIRD_FOSSIL = noSettingsItem("bird_fossil")
|
||||
@JvmField
|
||||
val CLAW_FOSSIL = noSettingsItem("claw_fossil")
|
||||
@JvmField
|
||||
val COVER_FOSSIL = noSettingsItem("cover_fossil")
|
||||
@JvmField
|
||||
val DINO_FOSSIL = noSettingsItem("dino_fossil")
|
||||
@JvmField
|
||||
val DOME_FOSSIL = noSettingsItem("dome_fossil")
|
||||
@JvmField
|
||||
val DRAKE_FOSSIL = noSettingsItem("drake_fossil")
|
||||
@JvmField
|
||||
val FISH_FOSSIL = noSettingsItem("fish_fossil")
|
||||
@JvmField
|
||||
val HELIX_FOSSIL = noSettingsItem("helix_fossil")
|
||||
@JvmField
|
||||
val JAW_FOSSIL = noSettingsItem("jaw_fossil")
|
||||
@JvmField
|
||||
val OLD_AMBER_FOSSIL = noSettingsItem("old_amber_fossil")
|
||||
@JvmField
|
||||
val PLUME_FOSSIL = noSettingsItem("plume_fossil")
|
||||
@JvmField
|
||||
val ROOT_FOSSIL = noSettingsItem("root_fossil")
|
||||
@JvmField
|
||||
val SAIL_FOSSIL = noSettingsItem("sail_fossil")
|
||||
@JvmField
|
||||
val SKULL_FOSSIL = noSettingsItem("skull_fossil")
|
||||
|
||||
@JvmField
|
||||
val BYGONE_SHERD = noSettingsItem("bygone_sherd")
|
||||
@JvmField
|
||||
val CAPTURE_SHERD = noSettingsItem("capture_sherd")
|
||||
@JvmField
|
||||
val DOME_SHERD = noSettingsItem("dome_sherd")
|
||||
@JvmField
|
||||
val HELIX_SHERD = noSettingsItem("helix_sherd")
|
||||
@JvmField
|
||||
val NOSTALGIC_SHERD = noSettingsItem("nostalgic_sherd")
|
||||
|
||||
@JvmField
|
||||
val TUMBLESTONE = this.create("tumblestone", TumblestoneItem(Item.Settings(), CobblemonBlocks.SMALL_BUDDING_TUMBLESTONE))
|
||||
@JvmField
|
||||
val BLACK_TUMBLESTONE = this.create("black_tumblestone", TumblestoneItem(Item.Settings(), CobblemonBlocks.SMALL_BUDDING_BLACK_TUMBLESTONE))
|
||||
@JvmField
|
||||
val SKY_TUMBLESTONE = this.create("sky_tumblestone", TumblestoneItem(Item.Settings(), CobblemonBlocks.SMALL_BUDDING_SKY_TUMBLESTONE))
|
||||
|
||||
@JvmField
|
||||
val SMALL_BUDDING_TUMBLESTONE = blockItem("small_budding_tumblestone", CobblemonBlocks.SMALL_BUDDING_TUMBLESTONE)
|
||||
@JvmField
|
||||
val MEDIUM_BUDDING_TUMBLESTONE = blockItem("medium_budding_tumblestone", CobblemonBlocks.MEDIUM_BUDDING_TUMBLESTONE)
|
||||
@JvmField
|
||||
val LARGE_BUDDING_TUMBLESTONE = blockItem("large_budding_tumblestone", CobblemonBlocks.LARGE_BUDDING_TUMBLESTONE)
|
||||
@JvmField
|
||||
val TUMBLESTONE_CLUSTER = blockItem("tumblestone_cluster", CobblemonBlocks.TUMBLESTONE_CLUSTER)
|
||||
|
||||
@JvmField
|
||||
val SMALL_BUDDING_SKY_TUMBLESTONE = blockItem("small_budding_sky_tumblestone", CobblemonBlocks.SMALL_BUDDING_SKY_TUMBLESTONE)
|
||||
@JvmField
|
||||
val MEDIUM_BUDDING_SKY_TUMBLESTONE = blockItem("medium_budding_sky_tumblestone", CobblemonBlocks.MEDIUM_BUDDING_SKY_TUMBLESTONE)
|
||||
@JvmField
|
||||
val LARGE_BUDDING_SKY_TUMBLESTONE = blockItem("large_budding_sky_tumblestone", CobblemonBlocks.LARGE_BUDDING_SKY_TUMBLESTONE)
|
||||
@JvmField
|
||||
val SKY_TUMBLESTONE_CLUSTER = blockItem("sky_tumblestone_cluster", CobblemonBlocks.SKY_TUMBLESTONE_CLUSTER)
|
||||
|
||||
@JvmField
|
||||
val SMALL_BUDDING_BLACK_TUMBLESTONE = blockItem("small_budding_black_tumblestone", CobblemonBlocks.SMALL_BUDDING_BLACK_TUMBLESTONE)
|
||||
@JvmField
|
||||
val MEDIUM_BUDDING_BLACK_TUMBLESTONE = blockItem("medium_budding_black_tumblestone", CobblemonBlocks.MEDIUM_BUDDING_BLACK_TUMBLESTONE)
|
||||
@JvmField
|
||||
val LARGE_BUDDING_BLACK_TUMBLESTONE = blockItem("large_budding_black_tumblestone", CobblemonBlocks.LARGE_BUDDING_BLACK_TUMBLESTONE)
|
||||
@JvmField
|
||||
val BLACK_TUMBLESTONE_CLUSTER = blockItem("black_tumblestone_cluster", CobblemonBlocks.BLACK_TUMBLESTONE_CLUSTER)
|
||||
|
||||
@JvmField
|
||||
val TUMBLESTONE_BLOCK = blockItem("tumblestone_block", CobblemonBlocks.TUMBLESTONE_BLOCK)
|
||||
@JvmField
|
||||
val SKY_TUMBLESTONE_BLOCK = blockItem("sky_tumblestone_block", CobblemonBlocks.SKY_TUMBLESTONE_BLOCK)
|
||||
@JvmField
|
||||
val BLACK_TUMBLESTONE_BLOCK = blockItem("black_tumblestone_block", CobblemonBlocks.BLACK_TUMBLESTONE_BLOCK)
|
||||
|
||||
// Misc
|
||||
@JvmField
|
||||
val POKEMON_MODEL = this.create("pokemon_model", PokemonItem())
|
||||
|
||||
@@ -37,6 +37,8 @@ import com.cobblemon.mod.common.client.net.callback.party.OpenPartyCallbackHandl
|
||||
import com.cobblemon.mod.common.client.net.callback.partymove.OpenPartyMoveCallbackHandler
|
||||
import com.cobblemon.mod.common.client.net.data.DataRegistrySyncPacketHandler
|
||||
import com.cobblemon.mod.common.client.net.data.UnlockReloadPacketHandler
|
||||
import com.cobblemon.mod.common.client.net.dialogue.DialogueClosedHandler
|
||||
import com.cobblemon.mod.common.client.net.dialogue.DialogueOpenedHandler
|
||||
import com.cobblemon.mod.common.client.net.effect.SpawnSnowstormParticleHandler
|
||||
import com.cobblemon.mod.common.client.net.gui.InteractPokemonUIPacketHandler
|
||||
import com.cobblemon.mod.common.client.net.gui.SummaryUIPacketHandler
|
||||
@@ -81,7 +83,11 @@ import com.cobblemon.mod.common.net.messages.client.data.MovesRegistrySyncPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.data.PropertiesCompletionRegistrySyncPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.data.SpeciesRegistrySyncPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.data.UnlockReloadPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.dialogue.DialogueClosedPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.dialogue.DialogueOpenedPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.effect.SpawnSnowstormParticlePacket
|
||||
import com.cobblemon.mod.common.net.messages.client.fossil.FossilRegistrySyncPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.fossil.NaturalMaterialRegistrySyncPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.pasture.ClosePasturePacket
|
||||
import com.cobblemon.mod.common.net.messages.client.pasture.OpenPasturePacket
|
||||
import com.cobblemon.mod.common.net.messages.client.pasture.PokemonPasturedPacket
|
||||
@@ -129,6 +135,8 @@ import com.cobblemon.mod.common.net.messages.server.callback.party.PartyPokemonS
|
||||
import com.cobblemon.mod.common.net.messages.server.callback.party.PartySelectCancelledPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.callback.partymove.PartyMoveSelectCancelledPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.callback.partymove.PartyPokemonMoveSelectedPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.dialogue.EscapeDialoguePacket
|
||||
import com.cobblemon.mod.common.net.messages.server.dialogue.InputToDialoguePacket
|
||||
import com.cobblemon.mod.common.net.messages.server.pasture.PasturePokemonPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.pasture.UnpastureAllPokemonPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.pasture.UnpasturePokemonPacket
|
||||
@@ -162,6 +170,8 @@ import com.cobblemon.mod.common.net.serverhandling.callback.party.PartyPokemonSe
|
||||
import com.cobblemon.mod.common.net.serverhandling.callback.party.PartySelectCancelledHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.callback.partymove.PartyMoveSelectCancelledHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.callback.partymove.PartyPokemonMoveSelectedHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.dialogue.EscapeDialogueHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.dialogue.InputToDialogueHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.evolution.AcceptEvolutionHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.pasture.PasturePokemonHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.pasture.UnpastureAllPokemonHandler
|
||||
@@ -233,6 +243,7 @@ object CobblemonNetwork : NetworkManager {
|
||||
this.createClientBound(PokemonStateUpdatePacket.ID, PokemonStateUpdatePacket::decode, PokemonUpdatePacketHandler())
|
||||
this.createClientBound(TetheringUpdatePacket.ID, TetheringUpdatePacket::decode, PokemonUpdatePacketHandler())
|
||||
this.createClientBound(TradeableUpdatePacket.ID, TradeableUpdatePacket::decode, PokemonUpdatePacketHandler())
|
||||
this.createClientBound(OriginalTrainerUpdatePacket.ID, OriginalTrainerUpdatePacket::decode, PokemonUpdatePacketHandler())
|
||||
|
||||
// Evolution start
|
||||
this.createClientBound(AddEvolutionPacket.ID, AddEvolutionPacket::decode, PokemonUpdatePacketHandler())
|
||||
@@ -298,6 +309,8 @@ object CobblemonNetwork : NetworkManager {
|
||||
this.createClientBound(PropertiesCompletionRegistrySyncPacket.ID, PropertiesCompletionRegistrySyncPacket::decode, DataRegistrySyncPacketHandler())
|
||||
this.createClientBound(UnlockReloadPacket.ID, UnlockReloadPacket::decode, UnlockReloadPacketHandler)
|
||||
this.createClientBound(BerryRegistrySyncPacket.ID, BerryRegistrySyncPacket::decode, DataRegistrySyncPacketHandler())
|
||||
this.createClientBound(NaturalMaterialRegistrySyncPacket.ID, NaturalMaterialRegistrySyncPacket::decode, DataRegistrySyncPacketHandler())
|
||||
this.createClientBound(FossilRegistrySyncPacket.ID, FossilRegistrySyncPacket::decode, DataRegistrySyncPacketHandler())
|
||||
|
||||
// Effects
|
||||
this.createClientBound(SpawnSnowstormParticlePacket.ID, SpawnSnowstormParticlePacket::decode, SpawnSnowstormParticleHandler)
|
||||
@@ -334,6 +347,10 @@ object CobblemonNetwork : NetworkManager {
|
||||
|
||||
// Party move select packets
|
||||
this.createClientBound(OpenPartyMoveCallbackPacket.ID, OpenPartyMoveCallbackPacket::decode, OpenPartyMoveCallbackHandler)
|
||||
|
||||
// Dialogue packets
|
||||
this.createClientBound(DialogueClosedPacket.ID, DialogueClosedPacket::decode, DialogueClosedHandler)
|
||||
this.createClientBound(DialogueOpenedPacket.ID, DialogueOpenedPacket::decode, DialogueOpenedHandler)
|
||||
}
|
||||
|
||||
override fun registerServerBound() {
|
||||
@@ -399,6 +416,10 @@ object CobblemonNetwork : NetworkManager {
|
||||
// Party move select packets
|
||||
this.createServerBound(PartyPokemonMoveSelectedPacket.ID, PartyPokemonMoveSelectedPacket::decode, PartyPokemonMoveSelectedHandler)
|
||||
this.createServerBound(PartyMoveSelectCancelledPacket.ID, PartyMoveSelectCancelledPacket::decode, PartyMoveSelectCancelledHandler)
|
||||
|
||||
// Dialogue packets
|
||||
this.createServerBound(EscapeDialoguePacket.ID, EscapeDialoguePacket::decode, EscapeDialogueHandler)
|
||||
this.createServerBound(InputToDialoguePacket.ID, InputToDialoguePacket::decode, InputToDialogueHandler)
|
||||
}
|
||||
|
||||
private inline fun <reified T : NetworkPacket<T>> createClientBound(identifier: Identifier, noinline decoder: (PacketByteBuf) -> T, handler: ClientNetworkPacketHandler<T>) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.registry.Registries
|
||||
import net.minecraft.registry.Registry
|
||||
import net.minecraft.registry.RegistryKey
|
||||
import net.minecraft.registry.RegistryKeys
|
||||
import net.minecraft.sound.BlockSoundGroup
|
||||
import net.minecraft.sound.SoundEvent
|
||||
|
||||
object CobblemonSounds : PlatformRegistry<Registry<SoundEvent>, RegistryKey<Registry<SoundEvent>>, SoundEvent>() {
|
||||
@@ -88,6 +89,57 @@ object CobblemonSounds : PlatformRegistry<Registry<SoundEvent>, RegistryKey<Regi
|
||||
@JvmField
|
||||
val MULCH_REMOVE = this.create("mulch.remove")
|
||||
|
||||
@JvmField
|
||||
val FOSSIL_MACHINE_ACTIVATE = this.create("fossilmachine.activate")
|
||||
@JvmField
|
||||
val FOSSIL_MACHINE_ACTIVE_LOOP = this.create("fossilmachine.active_loop")
|
||||
@JvmField
|
||||
val FOSSIL_MACHINE_ASSEMBLE = this.create("fossilmachine.assemble")
|
||||
@JvmField
|
||||
val FOSSIL_MACHINE_DNA_FULL = this.create("fossilmachine.dna_full")
|
||||
@JvmField
|
||||
val FOSSIL_MACHINE_FINISHED = this.create("fossilmachine.finished")
|
||||
@JvmField
|
||||
val FOSSIL_MACHINE_INSERT_DNA = this.create("fossilmachine.insert_dna")
|
||||
@JvmField
|
||||
val FOSSIL_MACHINE_INSERT_DNA_SMALL = this.create("fossilmachine.insert_dna_small")
|
||||
@JvmField
|
||||
val FOSSIL_MACHINE_INSERT_FOSSIL = this.create("fossilmachine.insert_fossil")
|
||||
@JvmField
|
||||
val FOSSIL_MACHINE_RETRIEVE_FOSSIL = this.create("fossilmachine.retrieve_fossil")
|
||||
@JvmField
|
||||
val FOSSIL_MACHINE_RETRIEVE_POKEMON = this.create("fossilmachine.retrieve_pokemon")
|
||||
@JvmField
|
||||
val FOSSIL_MACHINE_UNPROTECTED = this.create("fossilmachine.unprotected")
|
||||
|
||||
@JvmField
|
||||
val TUMBLESTONE_BREAK = this.create("tumblestone.break")
|
||||
@JvmField
|
||||
val TUMBLESTONE_BLOCK_BREAK = this.create("tumblestone.block_break")
|
||||
@JvmField
|
||||
val TUMBLESTONE_HIT = this.create("tumblestone.hit")
|
||||
@JvmField
|
||||
val TUMBLESTONE_PLACE = this.create("tumblestone.place")
|
||||
@JvmField
|
||||
val TUMBLESTONE_STEP = this.create("tumblestone.step")
|
||||
|
||||
@JvmField
|
||||
val TUMBLESTONE_SOUNDS = BlockSoundGroup(1f, 1f,
|
||||
TUMBLESTONE_BREAK,
|
||||
TUMBLESTONE_STEP,
|
||||
TUMBLESTONE_PLACE,
|
||||
TUMBLESTONE_HIT,
|
||||
TUMBLESTONE_STEP
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val TUMBLESTONE_BLOCK_SOUNDS = BlockSoundGroup(1f, 1f,
|
||||
TUMBLESTONE_BLOCK_BREAK,
|
||||
TUMBLESTONE_STEP,
|
||||
TUMBLESTONE_PLACE,
|
||||
TUMBLESTONE_HIT,
|
||||
TUMBLESTONE_STEP
|
||||
)
|
||||
|
||||
private fun create(name: String): SoundEvent = this.create(name, SoundEvent.of(cobblemonResource(name)))
|
||||
}
|
||||
@@ -99,6 +99,13 @@ object CobblemonCriteria {
|
||||
)
|
||||
)
|
||||
|
||||
val RESURRECT_POKEMON = this.create(
|
||||
SimpleCriterionTrigger(
|
||||
cobblemonResource("resurrect_pokemon"),
|
||||
PickStarterCriterionCondition::class.java
|
||||
)
|
||||
)
|
||||
|
||||
val TRADE_POKEMON = this.create(
|
||||
SimpleCriterionTrigger(
|
||||
cobblemonResource("trade_pokemon"),
|
||||
|
||||
@@ -46,9 +46,9 @@ import com.cobblemon.mod.common.util.battleLang
|
||||
import com.cobblemon.mod.common.util.getPlayer
|
||||
import java.io.File
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.ConcurrentLinkedQueue
|
||||
import net.minecraft.server.network.ServerPlayerEntity
|
||||
import net.minecraft.text.Text
|
||||
import java.util.concurrent.ConcurrentLinkedDeque
|
||||
|
||||
/**
|
||||
* Individual battle instance
|
||||
@@ -69,6 +69,7 @@ open class PokemonBattle(
|
||||
side1.battle = this
|
||||
side2.battle = this
|
||||
this.actors.forEach { actor ->
|
||||
actor.battle = this
|
||||
actor.pokemonList.forEach { battlePokemon ->
|
||||
battlePokemon.effectedPokemon.evolutionProxy.current().progress()
|
||||
.filterIsInstance<LastBattleCriticalHitsEvolutionProgress>()
|
||||
@@ -95,6 +96,7 @@ open class PokemonBattle(
|
||||
val chatLog = mutableListOf<Text>()
|
||||
var started = false
|
||||
var ended = false
|
||||
var simulation = false
|
||||
// TEMP battle showcase stuff
|
||||
var announcingRules = false
|
||||
var turn: Int = 1
|
||||
@@ -102,7 +104,7 @@ open class PokemonBattle(
|
||||
|
||||
|
||||
var dispatchResult = GO
|
||||
val dispatches = ConcurrentLinkedQueue<BattleDispatch>()
|
||||
val dispatches = ConcurrentLinkedDeque<BattleDispatch>()
|
||||
val afterDispatches = mutableListOf<() -> Unit>()
|
||||
|
||||
val captureActions = mutableListOf<BattleCaptureAction>()
|
||||
@@ -204,7 +206,8 @@ open class PokemonBattle(
|
||||
|
||||
fun end() {
|
||||
ended = true
|
||||
this.actors.forEach { actor ->
|
||||
// award XP if it is not a simulation battle
|
||||
if (simulation == false) this.actors.forEach { actor ->
|
||||
val faintedPokemons = actor.pokemonList.filter { it.health <= 0 }
|
||||
actor.getSide().getOppositeSide().actors.forEach { opponent ->
|
||||
val opponentNonFaintedPokemons = opponent.pokemonList.filter { it.health > 0 }
|
||||
@@ -252,7 +255,6 @@ open class PokemonBattle(
|
||||
}
|
||||
}
|
||||
sendUpdate(BattleEndPacket())
|
||||
sendUpdate(BattleMusicPacket(null))
|
||||
BattleRegistry.closeBattle(this)
|
||||
}
|
||||
|
||||
@@ -319,6 +321,12 @@ open class PokemonBattle(
|
||||
|
||||
fun dispatch(dispatcher: () -> DispatchResult) {
|
||||
dispatches.add(BattleDispatch { dispatcher() })
|
||||
|
||||
}
|
||||
|
||||
fun dispatchToFront(dispatcher: () -> DispatchResult) {
|
||||
dispatches.addFirst(BattleDispatch { dispatcher() })
|
||||
|
||||
}
|
||||
|
||||
fun dispatchGo(dispatcher: () -> Unit) {
|
||||
@@ -350,6 +358,10 @@ open class PokemonBattle(
|
||||
dispatches.add(dispatcher)
|
||||
}
|
||||
|
||||
fun dispatchToFront(dispatcher: BattleDispatch) {
|
||||
dispatches.addFirst(dispatcher)
|
||||
}
|
||||
|
||||
fun doWhenClear(action: () -> Unit) {
|
||||
afterDispatches.add(action)
|
||||
}
|
||||
|
||||
+2
-1
@@ -12,6 +12,7 @@ import com.cobblemon.mod.common.Cobblemon.LOGGER
|
||||
import com.cobblemon.mod.common.api.battles.model.ai.BattleAI
|
||||
import com.cobblemon.mod.common.api.net.NetworkPacket
|
||||
import com.cobblemon.mod.common.battles.PassActionResponse
|
||||
import com.cobblemon.mod.common.battles.ai.StrongBattleAI
|
||||
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
|
||||
import com.cobblemon.mod.common.exception.IllegalActionChoiceException
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleMakeChoicePacket
|
||||
@@ -20,7 +21,7 @@ import java.util.UUID
|
||||
abstract class AIBattleActor(
|
||||
gameId: UUID,
|
||||
pokemonList: List<BattlePokemon>,
|
||||
val battleAI: BattleAI
|
||||
val battleAI: BattleAI = StrongBattleAI(0)
|
||||
) : BattleActor(gameId, pokemonList.toMutableList()) {
|
||||
override fun sendUpdate(packet: NetworkPacket<*>) {
|
||||
super.sendUpdate(packet)
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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.dialogue
|
||||
|
||||
import com.bedrockk.molang.runtime.MoLangRuntime
|
||||
import com.bedrockk.molang.runtime.struct.MoStruct
|
||||
import com.bedrockk.molang.runtime.struct.QueryStruct
|
||||
import com.bedrockk.molang.runtime.value.DoubleValue
|
||||
import com.bedrockk.molang.runtime.value.MoValue
|
||||
import com.bedrockk.molang.runtime.value.StringValue
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.CobblemonNetwork.sendPacket
|
||||
import com.cobblemon.mod.common.api.dialogue.input.ActiveInput
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.addFunctions
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.addStandardFunctions
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMoLangValue
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.getQueryStruct
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.setup
|
||||
import com.cobblemon.mod.common.api.scheduling.ServerRealTimeTaskTracker
|
||||
import com.cobblemon.mod.common.net.messages.client.dialogue.DialogueOpenedPacket
|
||||
import java.util.UUID
|
||||
import net.minecraft.server.network.ServerPlayerEntity
|
||||
|
||||
/**
|
||||
* An active instance of [Dialogue]. Bound to a player. These all need to be created through DialogueManager
|
||||
* or things will go to shit.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since December 27th, 2023
|
||||
*/
|
||||
class ActiveDialogue(var playerEntity: ServerPlayerEntity, var dialogueReference: Dialogue) {
|
||||
val dialogueId = UUID.randomUUID()
|
||||
val runtime = MoLangRuntime().setup()
|
||||
var currentPage = dialogueReference.pages[0]
|
||||
val playerStruct = playerEntity.asMoLangValue()
|
||||
var activeInput = ActiveInput(this, currentPage.input)
|
||||
|
||||
init {
|
||||
runtime.environment.getQueryStruct().addFunctions(
|
||||
mapOf(
|
||||
"dialogue" to java.util.function.Function { _ -> toMoLangStruct() },
|
||||
"player" to java.util.function.Function { _ -> playerStruct }
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
val currentPageIndex
|
||||
get() = dialogueReference.pages.indexOf(currentPage)
|
||||
|
||||
fun setPage(value: MoValue) {
|
||||
val page = if (value is StringValue) {
|
||||
dialogueReference.pages.find { it.id == value.value }
|
||||
?: return Cobblemon.LOGGER.error("Dialogue requested page ${value.value} but it doesn't exist")
|
||||
} else {
|
||||
val pageNum = value.asDouble().toInt()
|
||||
if (pageNum < 0 || pageNum >= dialogueReference.pages.size) {
|
||||
return Cobblemon.LOGGER.error("Dialogue requested page $pageNum but it doesn't exist")
|
||||
} else {
|
||||
dialogueReference.pages[pageNum]
|
||||
}
|
||||
}
|
||||
setPage(page)
|
||||
}
|
||||
|
||||
fun isActive() = DialogueManager.activeDialogues[playerEntity.uuid] == this
|
||||
|
||||
fun incrementPage() {
|
||||
setPage(currentPageIndex + 1)
|
||||
}
|
||||
|
||||
fun setPage(page: DialoguePage) {
|
||||
currentPage = page
|
||||
activeInput = ActiveInput(this, currentPage.input)
|
||||
val deadline = currentPage.input.timeout?.duration
|
||||
val inputId = activeInput.inputId
|
||||
if (deadline != null && deadline > 0) {
|
||||
ServerRealTimeTaskTracker.after(seconds = deadline) {
|
||||
if (inputId == activeInput.inputId && isActive()) {
|
||||
activeInput.dialogueInput.timeout?.action?.invoke(this, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
playerEntity.sendPacket(DialogueOpenedPacket(this, false))
|
||||
}
|
||||
|
||||
fun setPage(index: Int) {
|
||||
if (index == dialogueReference.pages.size) {
|
||||
return close()
|
||||
}
|
||||
|
||||
if (index < 0 || index > dialogueReference.pages.size) {
|
||||
return Cobblemon.LOGGER.error("Dialogue requested page $index but it doesn't exist")
|
||||
}
|
||||
|
||||
setPage(dialogueReference.pages[index])
|
||||
}
|
||||
|
||||
fun toMoLangStruct(): MoStruct {
|
||||
return QueryStruct(
|
||||
hashMapOf(
|
||||
"current_page" to java.util.function.Function { _ -> currentPage.toMoLangStruct(this) },
|
||||
"current_page_number" to java.util.function.Function { _ -> DoubleValue(currentPageIndex) },
|
||||
"next_page" to java.util.function.Function { _ -> incrementPage() },
|
||||
"set_page" to java.util.function.Function { args -> setPage(args[0]) },
|
||||
"close" to java.util.function.Function { _ -> close() },
|
||||
"input" to java.util.function.Function { params -> activeInput.handle(if (params.params.size > 0) params.get<MoValue>(0).asString() else "") },
|
||||
)
|
||||
).addStandardFunctions()
|
||||
}
|
||||
|
||||
fun close() {
|
||||
DialogueManager.stopDialogue(playerEntity)
|
||||
}
|
||||
|
||||
fun escape() {
|
||||
val action = currentPage.escapeAction ?: dialogueReference.escapeAction
|
||||
action(this, null)
|
||||
}
|
||||
}
|
||||
@@ -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.api.dialogue
|
||||
|
||||
import com.cobblemon.mod.common.api.molang.ExpressionLike
|
||||
|
||||
/**
|
||||
* A dialogue that could be sent to players.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since December 27th, 2023
|
||||
*/
|
||||
class Dialogue(
|
||||
val pages: List<DialoguePage> = mutableListOf(),
|
||||
val escapeAction: DialogueAction = FunctionDialogueAction { dialogue, _ -> dialogue.close() },
|
||||
val speakers: Map<String, DialogueSpeaker> = emptyMap()
|
||||
) {
|
||||
companion object {
|
||||
fun of(
|
||||
pages: Iterable<DialoguePage>,
|
||||
escapeAction: ExpressionLike,
|
||||
speakers: Map<String, DialogueSpeaker>
|
||||
): Dialogue {
|
||||
return Dialogue(
|
||||
pages = pages.toList(),
|
||||
escapeAction = ExpressionLikeDialogueAction(escapeAction),
|
||||
speakers = speakers
|
||||
)
|
||||
}
|
||||
|
||||
fun of(
|
||||
pages: Iterable<DialoguePage>,
|
||||
escapeAction: (ActiveDialogue) -> Unit,
|
||||
speakers: Map<String, DialogueSpeaker>
|
||||
): Dialogue {
|
||||
val dialogue = Dialogue(
|
||||
pages = pages.toList(),
|
||||
escapeAction = FunctionDialogueAction { activeDialogue, _ -> escapeAction(activeDialogue) },
|
||||
speakers = speakers
|
||||
)
|
||||
return dialogue
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.dialogue
|
||||
|
||||
import com.bedrockk.molang.runtime.value.StringValue
|
||||
import com.cobblemon.mod.common.api.molang.ExpressionLike
|
||||
import com.cobblemon.mod.common.util.resolve
|
||||
|
||||
/**
|
||||
* Something that can happen in the context of an [ActiveDialogue]. The input field is nullable because I'm reusing
|
||||
* this for dialogue input timeouts which don't have an input. It'll be fine.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since December 29th, 2023
|
||||
*/
|
||||
interface DialogueAction {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
val types = mutableMapOf<String, Class<out DialogueAction>>()
|
||||
}
|
||||
|
||||
operator fun invoke(dialogue: ActiveDialogue, input: String? = null)
|
||||
}
|
||||
|
||||
class FunctionDialogueAction(val consumer: (ActiveDialogue, String?) -> Unit) : DialogueAction {
|
||||
override fun invoke(dialogue: ActiveDialogue, input: String?) {
|
||||
consumer(dialogue, input)
|
||||
}
|
||||
}
|
||||
|
||||
class ExpressionLikeDialogueAction(val expression: ExpressionLike) : DialogueAction {
|
||||
override fun invoke(dialogue: ActiveDialogue, input: String?) {
|
||||
if (input != null) {
|
||||
dialogue.runtime.environment.setSimpleVariable("selected_option", StringValue(input))
|
||||
}
|
||||
dialogue.runtime.resolve(expression)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.dialogue
|
||||
|
||||
import com.cobblemon.mod.common.api.molang.ExpressionLike
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import java.util.UUID
|
||||
import net.minecraft.util.Identifier
|
||||
|
||||
/**
|
||||
* Something that produces a dialogue's renderable face. This is sealed because the client has very particular handling for this.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since January 1st, 2024
|
||||
*/
|
||||
sealed interface DialogueFaceProvider {
|
||||
companion object {
|
||||
val types = mutableMapOf(
|
||||
"player" to PlayerDialogueFaceProvider::class.java,
|
||||
"standard" to ArtificialDialogueFaceProvider::class.java,
|
||||
"expression" to ExpressionLikeDialogueFaceProvider::class.java
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class ArtificialDialogueFaceProvider(
|
||||
val modelType: String = "",
|
||||
val identifier: Identifier = cobblemonResource("bulbasaur"),
|
||||
val aspects: Set<String> = setOf()
|
||||
) : DialogueFaceProvider
|
||||
|
||||
class ReferenceDialogueFaceProvider(
|
||||
val entityId: Int
|
||||
): DialogueFaceProvider
|
||||
|
||||
class PlayerDialogueFaceProvider(val playerId: UUID) : DialogueFaceProvider
|
||||
|
||||
class ExpressionLikeDialogueFaceProvider(
|
||||
val providerExpression: ExpressionLike
|
||||
): DialogueFaceProvider
|
||||
@@ -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.api.dialogue
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonNetwork.sendPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.dialogue.DialogueClosedPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.dialogue.DialogueOpenedPacket
|
||||
import com.cobblemon.mod.common.util.activeDialogue
|
||||
import java.util.UUID
|
||||
import net.minecraft.server.network.ServerPlayerEntity
|
||||
|
||||
/**
|
||||
* Manages the active dialogues for players. Map is indexed by player UUID.
|
||||
* You really need to make sure any dialogues you start with a player go through this otherwise
|
||||
* the player won't be able to close the dialogue.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since December 27th, 2023
|
||||
*/
|
||||
object DialogueManager {
|
||||
val activeDialogues = mutableMapOf<UUID, ActiveDialogue>()
|
||||
|
||||
fun startDialogue(playerEntity: ServerPlayerEntity, dialogue: Dialogue) {
|
||||
val activeDialogue = ActiveDialogue(playerEntity, dialogue)
|
||||
activeDialogues[playerEntity.uuid] = activeDialogue
|
||||
val packet = DialogueOpenedPacket(activeDialogue, includeFaces = true)
|
||||
playerEntity.sendPacket(packet)
|
||||
}
|
||||
|
||||
fun stopDialogue(playerEntity: ServerPlayerEntity) {
|
||||
val activeDialogue = playerEntity.activeDialogue ?: return
|
||||
DialogueClosedPacket(activeDialogue.dialogueId).sendToPlayer(playerEntity)
|
||||
activeDialogues.remove(activeDialogue.dialogueId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.dialogue
|
||||
|
||||
import com.bedrockk.molang.Expression
|
||||
import com.bedrockk.molang.runtime.struct.MoStruct
|
||||
import com.bedrockk.molang.runtime.struct.QueryStruct
|
||||
import com.bedrockk.molang.runtime.value.MoValue
|
||||
import com.bedrockk.molang.runtime.value.StringValue
|
||||
import com.cobblemon.mod.common.api.dialogue.input.DialogueInput
|
||||
import com.cobblemon.mod.common.api.dialogue.input.DialogueNoInput
|
||||
import com.google.gson.JsonArray
|
||||
import net.minecraft.text.MutableText
|
||||
|
||||
/**
|
||||
* A page of a dialogue. This has lines of text and also some kind of input expected from the player.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since December 27th, 2023
|
||||
*/
|
||||
class DialoguePage(
|
||||
var id: String = "",
|
||||
var speaker: String? = null,
|
||||
var lines: MutableList<DialogueText> = mutableListOf(),
|
||||
var input: DialogueInput = DialogueNoInput(),
|
||||
var clientActions: MutableList<Expression> = mutableListOf(),
|
||||
var escapeAction: DialogueAction? = null,
|
||||
) {
|
||||
companion object {
|
||||
@JvmOverloads
|
||||
fun of(
|
||||
/** The ID is optional, but if you want to be able to jump to this page from other pages then you probably want to set this. */
|
||||
id: String = "",
|
||||
speaker: String? = null,
|
||||
lines: Iterable<MutableText>,
|
||||
input: DialogueInput = DialogueNoInput(),
|
||||
clientActions: Iterable<Expression> = emptyList(),
|
||||
/** The thing to do when the player presses ESC while on this page. If null, falls back to the same property on [Dialogue]. */
|
||||
escapeAction: ((ActiveDialogue) -> Unit)? = null,
|
||||
): DialoguePage {
|
||||
return DialoguePage(
|
||||
id = id,
|
||||
speaker = speaker,
|
||||
lines = lines.map { WrappedDialogueText(it) }.toMutableList(),
|
||||
input = input,
|
||||
clientActions = clientActions.toMutableList(),
|
||||
escapeAction = escapeAction?.let { func -> FunctionDialogueAction { activeDialogue, _ -> func(activeDialogue) } }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun toMoLangStruct(activeDialogue: ActiveDialogue): MoStruct {
|
||||
return QueryStruct(
|
||||
hashMapOf(
|
||||
"id" to java.util.function.Function { _ -> StringValue(id) },
|
||||
"input" to java.util.function.Function { _ -> activeDialogue.activeInput.struct },
|
||||
"lines" to java.util.function.Function { _ ->
|
||||
val array = JsonArray()
|
||||
lines.forEach { array.add(it(activeDialogue).string) }
|
||||
MoValue.of(array)
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.dialogue
|
||||
|
||||
import com.cobblemon.mod.common.api.molang.ExpressionLike
|
||||
import com.cobblemon.mod.common.util.asExpressionLike
|
||||
import com.cobblemon.mod.common.util.resolveBoolean
|
||||
|
||||
/**
|
||||
* A predicate loaded for a particular dialogue. Tests arbitrary conditions about the dialogue context.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since December 29th, 2023
|
||||
*/
|
||||
interface DialoguePredicate {
|
||||
companion object {
|
||||
val types = mutableMapOf<String, Class<out DialoguePredicate>>()
|
||||
}
|
||||
|
||||
operator fun invoke(dialogue: ActiveDialogue): Boolean
|
||||
}
|
||||
|
||||
class ExpressionLikeDialoguePredicate(val expression: ExpressionLike = "true".asExpressionLike()) : DialoguePredicate {
|
||||
override fun invoke(dialogue: ActiveDialogue) = dialogue.runtime.resolveBoolean(expression)
|
||||
}
|
||||
|
||||
class FunctionDialoguePredicate(val predicate: (ActiveDialogue) -> Boolean = { true }) : DialoguePredicate {
|
||||
override fun invoke(dialogue: ActiveDialogue) = predicate(dialogue)
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.dialogue
|
||||
|
||||
import com.cobblemon.mod.common.api.text.text
|
||||
import net.minecraft.text.MutableText
|
||||
|
||||
/**
|
||||
* A kind of speaker in a dialogue. They include a name and a face, each optional.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since January 1st, 2024
|
||||
*/
|
||||
class DialogueSpeaker(
|
||||
val name: DialogueText? = null,
|
||||
val face: DialogueFaceProvider? = null
|
||||
) {
|
||||
fun of(name: MutableText = "".text(), face: DialogueFaceProvider? = null) = DialogueSpeaker(WrappedDialogueText(name), face)
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.dialogue
|
||||
|
||||
import com.cobblemon.mod.common.api.molang.ExpressionLike
|
||||
import com.cobblemon.mod.common.api.text.text
|
||||
import com.cobblemon.mod.common.util.asExpressionLike
|
||||
import com.cobblemon.mod.common.util.resolveString
|
||||
import net.minecraft.text.MutableText
|
||||
|
||||
/**
|
||||
* Some kind of text-resolving property. This is to hide where sometimes we want literals,
|
||||
* sometimes we want the text to come from a function, and sometimes we want it to be the
|
||||
* product of a MoLang script.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since December 29th, 2023
|
||||
*/
|
||||
interface DialogueText {
|
||||
companion object {
|
||||
val types = mutableMapOf<String, Class<out DialogueText>>(
|
||||
"expression" to ExpressionLikeDialogueText::class.java,
|
||||
)
|
||||
}
|
||||
|
||||
operator fun invoke(activeDialogue: ActiveDialogue): MutableText
|
||||
}
|
||||
|
||||
class FunctionDialogueText(val function: (ActiveDialogue) -> MutableText = { "".text() }) : DialogueText {
|
||||
override fun invoke(activeDialogue: ActiveDialogue) = function(activeDialogue)
|
||||
}
|
||||
|
||||
class WrappedDialogueText(val text: MutableText = "".text()) : DialogueText {
|
||||
override fun invoke(activeDialogue: ActiveDialogue) = text.copy()
|
||||
}
|
||||
|
||||
class ExpressionLikeDialogueText(val expression: ExpressionLike = "''".asExpressionLike()) : DialogueText {
|
||||
override fun invoke(activeDialogue: ActiveDialogue): MutableText {
|
||||
return activeDialogue.runtime.resolveString(expression).text()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.dialogue
|
||||
|
||||
import com.bedrockk.molang.Expression
|
||||
import com.cobblemon.mod.common.api.data.JsonDataRegistry
|
||||
import com.cobblemon.mod.common.api.dialogue.input.DialogueInput
|
||||
import com.cobblemon.mod.common.api.molang.ExpressionLike
|
||||
import com.cobblemon.mod.common.api.reactive.SimpleObservable
|
||||
import com.cobblemon.mod.common.util.adapters.DialogueActionAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.DialogueFaceProviderAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.DialogueInputAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.DialoguePredicateAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.DialogueTextAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.ExpressionAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.ExpressionLikeAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.IdentifierAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.TextAdapter
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import net.minecraft.resource.ResourceType
|
||||
import net.minecraft.server.network.ServerPlayerEntity
|
||||
import net.minecraft.text.MutableText
|
||||
import net.minecraft.text.Text
|
||||
import net.minecraft.util.Identifier
|
||||
|
||||
/**
|
||||
* Registry for dialogue data.
|
||||
*
|
||||
* @see Dialogue
|
||||
* @since December 29th, 2023
|
||||
* @author Hiroku
|
||||
*/
|
||||
object Dialogues : JsonDataRegistry<Dialogue> {
|
||||
override val id = cobblemonResource("dialogues")
|
||||
override val type = ResourceType.SERVER_DATA
|
||||
override val observable = SimpleObservable<Dialogues>()
|
||||
|
||||
val dialogues = mutableMapOf<Identifier, Dialogue>()
|
||||
/** If you need custom adapters registered, subscribe to this and register them. */
|
||||
val gsonObservable: SimpleObservable<GsonBuilder> = SimpleObservable()
|
||||
|
||||
override fun sync(player: ServerPlayerEntity) {}
|
||||
|
||||
override val gson = GsonBuilder()
|
||||
.registerTypeAdapter(DialogueAction::class.java, DialogueActionAdapter)
|
||||
.registerTypeAdapter(DialoguePredicate::class.java, DialoguePredicateAdapter)
|
||||
.registerTypeAdapter(DialogueInput::class.java, DialogueInputAdapter)
|
||||
.registerTypeAdapter(DialogueFaceProvider::class.java, DialogueFaceProviderAdapter)
|
||||
.registerTypeAdapter(DialogueText::class.java, DialogueTextAdapter)
|
||||
.registerTypeAdapter(Expression::class.java, ExpressionAdapter)
|
||||
.registerTypeAdapter(ExpressionLike::class.java, ExpressionLikeAdapter)
|
||||
.registerTypeAdapter(MutableText::class.java, TextAdapter)
|
||||
.registerTypeAdapter(Identifier::class.java, IdentifierAdapter)
|
||||
.also { gsonObservable.emit(it) }
|
||||
.create()
|
||||
|
||||
override val typeToken = TypeToken.get(Dialogue::class.java)
|
||||
override val resourcePath = "dialogues"
|
||||
|
||||
override fun reload(data: Map<Identifier, Dialogue>) {
|
||||
dialogues.putAll(data)
|
||||
observable.emit(this)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.dialogue.input
|
||||
|
||||
import com.bedrockk.molang.runtime.value.DoubleValue
|
||||
import com.bedrockk.molang.runtime.value.MoValue
|
||||
import com.cobblemon.mod.common.api.dialogue.ActiveDialogue
|
||||
import com.cobblemon.mod.common.util.server
|
||||
import java.util.UUID
|
||||
|
||||
/**
|
||||
* An active input waiting for the player as part of an [ActiveDialogue]. The purpose of this is to
|
||||
* maintain some data integrity and track how long it's taken to choose an action.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since December 27th, 2023
|
||||
*/
|
||||
class ActiveInput(
|
||||
val activeDialogue: ActiveDialogue,
|
||||
val dialogueInput: DialogueInput
|
||||
) {
|
||||
val inputId = UUID.randomUUID()
|
||||
val startTime = server()!!.overworld.time
|
||||
|
||||
val struct = toMoLangStruct()
|
||||
|
||||
fun handle(input: String) {
|
||||
val secondsToChoose = (server()!!.overworld.time - startTime) / 20F
|
||||
activeDialogue.runtime.environment.setSimpleVariable("seconds_taken_to_input", DoubleValue(secondsToChoose))
|
||||
dialogueInput.handle(this, input)
|
||||
}
|
||||
|
||||
fun toMoLangStruct(): MoValue {
|
||||
return dialogueInput.toMoLangStruct(this)
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.dialogue.input
|
||||
|
||||
import com.bedrockk.molang.runtime.struct.QueryStruct
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.api.dialogue.DialogueAction
|
||||
import com.cobblemon.mod.common.api.dialogue.FunctionDialogueAction
|
||||
|
||||
/**
|
||||
* Input that has no input but has an action that will run after a delay.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since December 27th, 2023
|
||||
*/
|
||||
class DialogueAutoContinueInput : DialogueInput {
|
||||
val delay = 5F
|
||||
/** Whether the player can click to move on in a hurry or if they must wait. */
|
||||
var allowSkip = true
|
||||
var showTimer = false
|
||||
val action: DialogueAction = FunctionDialogueAction { dialogue, _ -> dialogue.incrementPage() }
|
||||
|
||||
override var timeout: DialogueTimeout?
|
||||
get() = DialogueTimeout(duration = delay, showTimer = showTimer, action)
|
||||
set(_) {}
|
||||
|
||||
override fun toMoLangStruct(activeInput: ActiveInput) = QueryStruct(hashMapOf())
|
||||
|
||||
|
||||
override fun handle(activeInput: ActiveInput, value: String) {
|
||||
if (!allowSkip) {
|
||||
return Cobblemon.LOGGER.warn("A no-skip dialogue received input from ${activeInput.activeDialogue.playerEntity.gameProfile.name}, is this person a hacker or something")
|
||||
}
|
||||
|
||||
action.invoke(activeInput.activeDialogue)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.dialogue.input
|
||||
|
||||
import com.bedrockk.molang.runtime.struct.MoStruct
|
||||
import com.cobblemon.mod.common.api.dialogue.DialoguePage
|
||||
|
||||
/**
|
||||
* A type of input to [DialoguePage]s. This is sealed because the client needs to know about it. Sorry.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since December 27th, 2023
|
||||
*/
|
||||
sealed interface DialogueInput {
|
||||
var timeout: DialogueTimeout?
|
||||
fun toMoLangStruct(activeInput: ActiveInput): MoStruct
|
||||
fun handle(activeInput: ActiveInput, value: String)
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.api.dialogue.input
|
||||
|
||||
import com.bedrockk.molang.runtime.struct.VariableStruct
|
||||
import com.cobblemon.mod.common.api.dialogue.DialogueAction
|
||||
import com.cobblemon.mod.common.api.dialogue.FunctionDialogueAction
|
||||
|
||||
/**
|
||||
* An input type that's really just waiting for the player to click or something.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since December 27th, 2023
|
||||
|
||||
*/
|
||||
class DialogueNoInput(
|
||||
var action: DialogueAction = FunctionDialogueAction { dialogue, _ -> dialogue.incrementPage() }
|
||||
) : DialogueInput {
|
||||
override var timeout: DialogueTimeout?
|
||||
get() = null
|
||||
set(_) {}
|
||||
|
||||
override fun toMoLangStruct(activeInput: ActiveInput) = VariableStruct()
|
||||
override fun handle(activeInput: ActiveInput, value: String) {
|
||||
action(activeInput.activeDialogue)
|
||||
}
|
||||
}
|
||||
@@ -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.api.dialogue.input
|
||||
|
||||
import com.cobblemon.mod.common.api.dialogue.DialogueAction
|
||||
import com.cobblemon.mod.common.api.dialogue.DialoguePredicate
|
||||
import com.cobblemon.mod.common.api.dialogue.DialogueText
|
||||
import com.cobblemon.mod.common.api.dialogue.FunctionDialogueAction
|
||||
import com.cobblemon.mod.common.api.dialogue.FunctionDialoguePredicate
|
||||
import com.cobblemon.mod.common.api.dialogue.WrappedDialogueText
|
||||
|
||||
/**
|
||||
* A choosable option as part of a [DialogueOptionSetInput].
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since December 27th, 2023
|
||||
*/
|
||||
class DialogueOption(
|
||||
var text: DialogueText = WrappedDialogueText(),
|
||||
/** The value is a unique identifier so the client can tell the server what they selected. Don't forget this. */
|
||||
var value: String = "",
|
||||
/** The action to run when they click it. */
|
||||
var action: DialogueAction = FunctionDialogueAction { _, _ -> },
|
||||
val isVisible: DialoguePredicate = FunctionDialoguePredicate(),
|
||||
val isSelectable: DialoguePredicate = FunctionDialoguePredicate()
|
||||
)
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.dialogue.input
|
||||
|
||||
import com.bedrockk.molang.runtime.struct.QueryStruct
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.api.dialogue.ActiveDialogue
|
||||
|
||||
/**
|
||||
* A type of [DialogueInput] that has the player choose from a list of options.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since December 27th, 2023
|
||||
*/
|
||||
class DialogueOptionSetInput(
|
||||
var options: MutableList<DialogueOption>,
|
||||
override var timeout: DialogueTimeout? = null,
|
||||
/** Whether the buttons should be stacked vertically. */
|
||||
var vertical: Boolean = false,
|
||||
) : DialogueInput {
|
||||
|
||||
// JSON uses this. Basically so that the main constructor can force people to specify options
|
||||
constructor() : this(mutableListOf(), null, false)
|
||||
|
||||
fun getVisibleOptions(activeDialogue: ActiveDialogue) = options.filter { it.isVisible(activeDialogue) }
|
||||
override fun toMoLangStruct(activeInput: ActiveInput) = QueryStruct(hashMapOf())
|
||||
override fun handle(activeInput: ActiveInput, value: String) {
|
||||
val option = options.firstOrNull { it.value == value }
|
||||
if (option != null) {
|
||||
if (!option.isSelectable(activeInput.activeDialogue)) {
|
||||
Cobblemon.LOGGER.warn("Dialogue option $value is not selectable but ${activeInput.activeDialogue.playerEntity.gameProfile.name} selected it anyway")
|
||||
activeInput.activeDialogue.close()
|
||||
} else if (!option.isVisible(activeInput.activeDialogue)) {
|
||||
Cobblemon.LOGGER.warn("Dialogue option $value is not visible but ${activeInput.activeDialogue.playerEntity.gameProfile.name} selected it anyway")
|
||||
activeInput.activeDialogue.close()
|
||||
}
|
||||
|
||||
option.action(activeInput.activeDialogue, value)
|
||||
} else {
|
||||
Cobblemon.LOGGER.warn("No option with value $value found in dialogue option set")
|
||||
}
|
||||
}
|
||||
}
|
||||
+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.api.dialogue.input
|
||||
|
||||
import com.bedrockk.molang.runtime.struct.QueryStruct
|
||||
import com.cobblemon.mod.common.api.dialogue.DialogueAction
|
||||
import com.cobblemon.mod.common.api.dialogue.FunctionDialogueAction
|
||||
|
||||
/**
|
||||
* A text input for dialogues where the player can enter free text.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since December 27th, 2023
|
||||
*/
|
||||
class DialogueTextInput : DialogueInput {
|
||||
override var timeout: DialogueTimeout? = null
|
||||
val action: DialogueAction = FunctionDialogueAction { dialogue, _ -> dialogue.setPage(dialogue.currentPageIndex + 1) }
|
||||
override fun toMoLangStruct(activeInput: ActiveInput) = QueryStruct(hashMapOf())
|
||||
|
||||
override fun handle(activeInput: ActiveInput, value: String) {
|
||||
action.invoke(activeInput.activeDialogue, value)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.dialogue.input
|
||||
|
||||
import com.cobblemon.mod.common.api.dialogue.DialogueAction
|
||||
import com.cobblemon.mod.common.api.dialogue.FunctionDialogueAction
|
||||
|
||||
/**
|
||||
* A deadline for dialogue input. This is used to have something occur if the player spends
|
||||
* too long on one page of dialogue.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since December 27th, 2023
|
||||
*/
|
||||
class DialogueTimeout(
|
||||
var duration: Float = 10F,
|
||||
var showTimer: Boolean = true,
|
||||
var action: DialogueAction = FunctionDialogueAction { dialogue, _ -> dialogue.close() }
|
||||
)
|
||||
@@ -31,14 +31,14 @@ import net.minecraft.util.math.Vec3d
|
||||
* @author Hiroku
|
||||
* @since July 24th, 2022
|
||||
*/
|
||||
class ItemDropEntry : DropEntry {
|
||||
open class ItemDropEntry : DropEntry {
|
||||
override val percentage = 100F
|
||||
override val quantity = 1
|
||||
val quantityRange: IntRange? = null
|
||||
open val quantityRange: IntRange? = null
|
||||
override val maxSelectableTimes = 1
|
||||
val dropMethod: ItemDropMethod? = null
|
||||
val item = Identifier("minecraft:fish")
|
||||
val nbt: NbtCompound? = null
|
||||
open val dropMethod: ItemDropMethod? = null
|
||||
open val item = Identifier("minecraft:fish")
|
||||
open val nbt: NbtCompound? = null
|
||||
|
||||
override fun drop(entity: LivingEntity?, world: ServerWorld, pos: Vec3d, player: ServerPlayerEntity?) {
|
||||
val item = world.registryManager.get(RegistryKeys.ITEM).get(item) ?: return LOGGER.error("Unable to load drop item: $item")
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
package com.cobblemon.mod.common.api.entity
|
||||
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.entity.data.TrackedData
|
||||
|
||||
/**
|
||||
* Represents a delegation of a portion of an entity's logic to a particular side.
|
||||
@@ -16,4 +17,5 @@ import net.minecraft.entity.Entity
|
||||
interface EntitySideDelegate<T : Entity> {
|
||||
fun initialize(entity: T) {}
|
||||
fun tick(entity: T) {}
|
||||
fun onTrackedDataSet(data: TrackedData<*>) {}
|
||||
}
|
||||
+5
-16
@@ -9,26 +9,19 @@
|
||||
package com.cobblemon.mod.common.api.events.battles
|
||||
|
||||
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
|
||||
import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
|
||||
import com.cobblemon.mod.common.api.events.Cancelable
|
||||
import com.cobblemon.mod.common.battles.BattleFormat
|
||||
import net.minecraft.text.MutableText
|
||||
|
||||
/**
|
||||
* Event fired before a [PokemonBattle] is started. Canceling this event prevents the battle from being
|
||||
* created and launched.
|
||||
*
|
||||
* @property reason The text used to inform the participants why the battle was canceled. Keep null for a default error.
|
||||
*
|
||||
* @author Segfault Guy
|
||||
* @since March 26th 2023
|
||||
*/
|
||||
data class BattleStartedPreEvent (
|
||||
|
||||
val participants: Collection<BattleActor>,
|
||||
val format: BattleFormat,
|
||||
val isPvP: Boolean,
|
||||
val isPvN: Boolean,
|
||||
val isPvW: Boolean
|
||||
|
||||
) : Cancelable()
|
||||
data class BattleStartedPreEvent (override val battle: PokemonBattle, var reason: MutableText? = null) : BattleEvent, Cancelable()
|
||||
|
||||
/**
|
||||
* Event fired after a [PokemonBattle] starts.
|
||||
@@ -36,8 +29,4 @@ data class BattleStartedPreEvent (
|
||||
* @author Segfault Guy
|
||||
* @since March 26th 2023
|
||||
*/
|
||||
data class BattleStartedPostEvent (
|
||||
|
||||
override val battle: PokemonBattle
|
||||
|
||||
) : BattleEvent
|
||||
data class BattleStartedPostEvent (override val battle: PokemonBattle) : BattleEvent
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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.fossil
|
||||
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonProperties
|
||||
import com.cobblemon.mod.common.pokemon.evolution.predicate.NbtItemPredicate
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.registry.Registries
|
||||
import net.minecraft.text.MutableText
|
||||
import net.minecraft.text.Text
|
||||
import net.minecraft.util.Identifier
|
||||
import net.minecraft.util.StringIdentifiable
|
||||
|
||||
class Fossil(
|
||||
identifier: Identifier,
|
||||
val result: PokemonProperties,
|
||||
val fossils: List<NbtItemPredicate>
|
||||
): StringIdentifiable {
|
||||
|
||||
@Transient
|
||||
var identifier: Identifier = identifier
|
||||
internal set
|
||||
|
||||
override fun asString(): String {
|
||||
return identifier.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the fossil.
|
||||
* @return The name of the fossil.
|
||||
*/
|
||||
fun getName(): MutableText = Text.translatable("${identifier.namespace}.fossil.${identifier.path}.name")
|
||||
|
||||
/**
|
||||
* Whether the fossil ingredients match this fossil.
|
||||
* @param ingredients The ingredients to check.
|
||||
* @return True if the ingredients match, false otherwise.
|
||||
*/
|
||||
fun matchesIngredients(ingredients: List<ItemStack>): Boolean {
|
||||
if (this.fossils.size != ingredients.size) {
|
||||
return false
|
||||
}
|
||||
|
||||
return this.fossils.all { fossil ->
|
||||
ingredients.any { fossil.item.fits(it.item, Registries.ITEM) && fossil.nbt.test(it) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the fossil ingredients match a subset of this fossil.
|
||||
* @param ingredients The ingredients to check.
|
||||
* @return True if the ingredients are a subset, false otherwise.
|
||||
*/
|
||||
fun matchesIngredientsSubSet(ingredients: List<ItemStack>): Boolean {
|
||||
if (this.fossils.size < ingredients.size) {
|
||||
return false
|
||||
}
|
||||
|
||||
return ingredients.all { ingredient ->
|
||||
ingredients.count { item -> ingredient.itemMatches(item.registryEntry) } <=
|
||||
this.fossils.count { fossil -> fossil.item.fits(ingredient.item, Registries.ITEM) && fossil.nbt.test(ingredient) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the [ItemStack] is an ingredient for this fossil.
|
||||
* @param itemStack The [ItemStack] to check.
|
||||
* @return True if the [ItemStack] is an ingredient, false otherwise.
|
||||
*/
|
||||
fun isIngredient(itemStack: ItemStack): Boolean {
|
||||
return this.fossils.any { it.item.fits(itemStack.item, Registries.ITEM) && it.nbt.test(itemStack) }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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.fossil
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.api.conditional.RegistryLikeCondition
|
||||
import com.cobblemon.mod.common.api.data.JsonDataRegistry
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonProperties
|
||||
import com.cobblemon.mod.common.api.reactive.SimpleObservable
|
||||
import com.cobblemon.mod.common.net.messages.client.fossil.FossilRegistrySyncPacket
|
||||
import com.cobblemon.mod.common.pokemon.evolution.adapters.NbtItemPredicateAdapter
|
||||
import com.cobblemon.mod.common.pokemon.evolution.predicate.NbtItemPredicate
|
||||
import com.cobblemon.mod.common.util.adapters.IdentifierAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.ItemLikeConditionAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.pokemonPropertiesShortAdapter
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import net.minecraft.item.Item
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.resource.ResourceType
|
||||
import net.minecraft.server.network.ServerPlayerEntity
|
||||
import net.minecraft.util.Identifier
|
||||
|
||||
object Fossils: JsonDataRegistry<Fossil> {
|
||||
|
||||
override val id: Identifier = cobblemonResource("fossils")
|
||||
override val type: ResourceType = ResourceType.SERVER_DATA
|
||||
override val observable = SimpleObservable<Fossils>()
|
||||
|
||||
override val gson = GsonBuilder()
|
||||
.disableHtmlEscaping()
|
||||
.setPrettyPrinting()
|
||||
.registerTypeAdapter(Identifier::class.java, IdentifierAdapter)
|
||||
.registerTypeAdapter(PokemonProperties::class.java, pokemonPropertiesShortAdapter)
|
||||
.registerTypeAdapter(TypeToken.getParameterized(RegistryLikeCondition::class.java, Item::class.java).type, ItemLikeConditionAdapter)
|
||||
.registerTypeAdapter(NbtItemPredicate::class.java, NbtItemPredicateAdapter)
|
||||
.create()
|
||||
|
||||
override val typeToken: TypeToken<Fossil> = TypeToken.get(Fossil::class.java)
|
||||
override val resourcePath: String = "fossils"
|
||||
|
||||
private val fossils = hashMapOf<Identifier, Fossil>()
|
||||
|
||||
override fun reload(data: Map<Identifier, Fossil>) {
|
||||
this.fossils.clear()
|
||||
data.forEach { (identifier, fossil) ->
|
||||
try {
|
||||
fossil.identifier = identifier
|
||||
this.fossils[identifier] = fossil
|
||||
} catch (e: Exception) {
|
||||
Cobblemon.LOGGER.error("Skipped loading the {} fossil", identifier, e)
|
||||
}
|
||||
}
|
||||
Cobblemon.LOGGER.info("Loaded {} fossils", this.fossils.size)
|
||||
this.observable.emit(this)
|
||||
}
|
||||
|
||||
override fun sync(player: ServerPlayerEntity) {
|
||||
FossilRegistrySyncPacket(this.all()).sendToPlayer(player)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all loaded [Fossil]s.
|
||||
*/
|
||||
fun all() = this.fossils.values.toList()
|
||||
|
||||
/**
|
||||
* Gets a [Fossil] by its [Identifier].
|
||||
* @param identifier The identifier of the fossil.
|
||||
* @return The [Fossil] if loaded, otherwise null.
|
||||
*/
|
||||
fun getByIdentifier(identifier: Identifier): Fossil? = this.fossils[identifier]
|
||||
|
||||
/**
|
||||
* Looks for a [Fossil] that matches a [ItemStack].
|
||||
* @param fossilStacks The fossil [ItemStack]'s.
|
||||
* @return The [Fossil] if found, otherwise null.
|
||||
*/
|
||||
fun getFossilByItemStacks(fossilStacks: List<ItemStack>): Fossil? {
|
||||
return this.all().firstOrNull { it.matchesIngredients(fossilStacks) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for a [Fossil] that is a superset of [ItemStack].
|
||||
* @param fossilStacks The fossil [ItemStack]'s.
|
||||
* @return The [Fossil] if found to be a superset, otherwise null.
|
||||
*/
|
||||
fun getSubFossilByItemStacks(fossilStacks: List<ItemStack>): Fossil? {
|
||||
return this.all().firstOrNull { it.matchesIngredientsSubSet(fossilStacks) }
|
||||
}
|
||||
/**
|
||||
* Checks if a [ItemStack] is a fossil ingredient.
|
||||
* @param itemStack The ingredient [ItemStack].
|
||||
* @return true if it's a fossil ingredient, otherwise false.
|
||||
*/
|
||||
fun isFossilIngredient(itemStack: ItemStack): Boolean {
|
||||
return this.all().any { it.isIngredient(itemStack) }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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.fossil
|
||||
|
||||
import com.cobblemon.mod.common.registry.ItemTagCondition
|
||||
import net.minecraft.util.Identifier
|
||||
|
||||
data class NaturalMaterial(
|
||||
val content: Int = 0,
|
||||
val item: Identifier?,
|
||||
val tag: ItemTagCondition? = null,
|
||||
val returnItem: Identifier? = null
|
||||
)
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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.fossil
|
||||
|
||||
import com.cobblemon.mod.common.api.data.JsonDataRegistry
|
||||
import com.cobblemon.mod.common.api.reactive.SimpleObservable
|
||||
import com.cobblemon.mod.common.net.messages.client.fossil.NaturalMaterialRegistrySyncPacket
|
||||
import com.cobblemon.mod.common.registry.ItemTagCondition
|
||||
import com.cobblemon.mod.common.util.adapters.IdentifierAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.ItemLikeConditionAdapter
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.registry.Registries
|
||||
import net.minecraft.resource.ResourceType
|
||||
import net.minecraft.server.network.ServerPlayerEntity
|
||||
import net.minecraft.util.Identifier
|
||||
|
||||
object NaturalMaterials : JsonDataRegistry<List<NaturalMaterial>>{
|
||||
override val id = cobblemonResource("natural_materials")
|
||||
override val type = ResourceType.SERVER_DATA
|
||||
override val observable = SimpleObservable<NaturalMaterials>()
|
||||
override val typeToken: TypeToken<List<NaturalMaterial>> =
|
||||
TypeToken.getParameterized(List::class.java, NaturalMaterial::class.java) as TypeToken<List<NaturalMaterial>>
|
||||
override val resourcePath = "natural_materials"
|
||||
override val gson: Gson = GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.registerTypeAdapter(Identifier::class.java, IdentifierAdapter)
|
||||
.registerTypeAdapter(ItemTagCondition::class.java, ItemLikeConditionAdapter)
|
||||
.create()
|
||||
|
||||
private val itemMap = mutableMapOf<Identifier, NaturalMaterial>()
|
||||
private val tagMap = mutableMapOf<ItemTagCondition, NaturalMaterial>()
|
||||
override fun sync(player: ServerPlayerEntity) {
|
||||
NaturalMaterialRegistrySyncPacket(this.itemMap.values.toList() + this.tagMap.values.toList()).sendToPlayer(player)
|
||||
}
|
||||
|
||||
override fun reload(data: Map<Identifier, List<NaturalMaterial>>) {
|
||||
data.forEach { entry ->
|
||||
entry.value.forEach {
|
||||
itemMap.remove(it.item)
|
||||
if (it.item != null) {
|
||||
itemMap[it.item] = it
|
||||
}
|
||||
if (it.tag != null) {
|
||||
tagMap[it.tag] = it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun isNaturalMaterial(item: ItemStack): Boolean {
|
||||
val itemId = Registries.ITEM.getId(item.item)
|
||||
return itemId in itemMap.keys || tagMap.keys.any {
|
||||
it.fits(item.item, Registries.ITEM)
|
||||
}
|
||||
}
|
||||
|
||||
fun getContent(item: ItemStack): Int? {
|
||||
val itemId = Registries.ITEM.getId(item.item)
|
||||
if (itemId in itemMap.keys) {
|
||||
return itemMap[itemId]?.content
|
||||
}
|
||||
val tag = tagMap.keys.firstOrNull { it.fits(item.item, Registries.ITEM) }
|
||||
if (tag != null) {
|
||||
return tagMap[tag]?.content
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun getReturnItem(item: ItemStack): Identifier? {
|
||||
val itemId = Registries.ITEM.getId(item.item)
|
||||
if (itemId in itemMap.keys) {
|
||||
return itemMap[itemId]?.returnItem
|
||||
}
|
||||
val tag = tagMap.keys.firstOrNull { it.fits(item.item, Registries.ITEM) }
|
||||
if (tag != null) {
|
||||
return tagMap[tag]?.returnItem
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -196,6 +196,8 @@ fun drawPortraitPokemon(
|
||||
val context = RenderContext()
|
||||
PokemonModelRepository.getTextureNoSubstitute(species.resourceIdentifier, aspects, 0f).let { it -> context.put(RenderContext.TEXTURE, it) }
|
||||
context.put(RenderContext.SCALE, species.getForm(aspects).baseScale)
|
||||
context.put(RenderContext.SPECIES, species.resourceIdentifier)
|
||||
context.put(RenderContext.ASPECTS, aspects)
|
||||
|
||||
val renderType = model.getLayer(texture)
|
||||
|
||||
@@ -206,10 +208,12 @@ fun drawPortraitPokemon(
|
||||
if (state == null) {
|
||||
model.setupAnimStateless(setOf(PoseType.PORTRAIT, PoseType.PROFILE))
|
||||
} else {
|
||||
val originalPose = state.currentPose
|
||||
model.getPose(PoseType.PORTRAIT)?.let { state.setPose(it.poseName) }
|
||||
state.timeEnteredPose = 0F
|
||||
state.updatePartialTicks(partialTicks)
|
||||
model.setupAnimStateful(null, state, 0F, 0F, 0F, 0F, 0F)
|
||||
originalPose?.let { state.setPose(it) }
|
||||
}
|
||||
|
||||
matrixStack.push()
|
||||
|
||||
@@ -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.api.molang
|
||||
|
||||
import com.bedrockk.molang.runtime.MoLangRuntime
|
||||
import com.bedrockk.molang.runtime.value.MoValue
|
||||
|
||||
/**
|
||||
* An object that can be given a [MoLangRuntime] to produce a single [MoValue]. This abstracts
|
||||
* the use of simple and complex [Expression]s as MoLang can be a single line or multiple.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since October 22nd, 2023
|
||||
*/
|
||||
interface ExpressionLike {
|
||||
/** Produces a [MoValue] for a [MoLangRuntime] to supply an environment. */
|
||||
fun resolve(runtime: MoLangRuntime): MoValue
|
||||
|
||||
fun resolveDouble(runtime: MoLangRuntime) = resolve(runtime).asDouble()
|
||||
fun resolveFloat(runtime: MoLangRuntime) = resolveDouble(runtime).toFloat()
|
||||
fun resolveString(runtime: MoLangRuntime) = resolve(runtime).asString()
|
||||
fun resolveInt(runtime: MoLangRuntime) = resolveDouble(runtime).toInt()
|
||||
fun resolveBoolean(runtime: MoLangRuntime) = resolveDouble(runtime) == 1.0
|
||||
fun resolveObject(runtime: MoLangRuntime) = resolve(runtime) as ObjectValue<*>
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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.molang
|
||||
|
||||
import com.bedrockk.molang.Expression
|
||||
import com.bedrockk.molang.runtime.MoLangRuntime
|
||||
import com.cobblemon.mod.common.util.resolve
|
||||
|
||||
/**
|
||||
* An [ExpressionLike] that produces MoValues by evaluating a series of [Expression]s.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since October 22nd, 2023
|
||||
*/
|
||||
class ListExpression(val exprs: List<Expression>): ExpressionLike {
|
||||
override fun resolve(runtime: MoLangRuntime) = exprs.resolve(runtime)
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* 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.molang
|
||||
|
||||
import com.bedrockk.molang.runtime.MoLangEnvironment
|
||||
import com.bedrockk.molang.runtime.MoLangRuntime
|
||||
import com.bedrockk.molang.runtime.MoParams
|
||||
import com.bedrockk.molang.runtime.struct.ArrayStruct
|
||||
import com.bedrockk.molang.runtime.struct.QueryStruct
|
||||
import com.bedrockk.molang.runtime.struct.VariableStruct
|
||||
import com.bedrockk.molang.runtime.value.DoubleValue
|
||||
import com.bedrockk.molang.runtime.value.MoValue
|
||||
import com.bedrockk.molang.runtime.value.StringValue
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.api.dialogue.PlayerDialogueFaceProvider
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMoLangValue
|
||||
import com.cobblemon.mod.common.util.isInt
|
||||
import com.cobblemon.mod.common.util.itemRegistry
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.nbt.NbtCompound
|
||||
import net.minecraft.nbt.NbtDouble
|
||||
import net.minecraft.nbt.NbtElement
|
||||
import net.minecraft.nbt.NbtList
|
||||
import net.minecraft.nbt.NbtString
|
||||
import net.minecraft.registry.Registry
|
||||
import net.minecraft.registry.RegistryKey
|
||||
import net.minecraft.registry.RegistryKeys
|
||||
import net.minecraft.registry.entry.RegistryEntry
|
||||
import net.minecraft.registry.tag.TagKey
|
||||
import net.minecraft.server.network.ServerPlayerEntity
|
||||
import net.minecraft.util.Identifier
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.world.biome.Biome
|
||||
import net.minecraft.world.dimension.DimensionType
|
||||
|
||||
/**
|
||||
* Holds a bunch of useful MoLang trickery that can be used or extended in API
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since October 2nd, 2023
|
||||
*/
|
||||
object MoLangFunctions {
|
||||
val generalFunctions = hashMapOf<String, java.util.function.Function<MoParams, Any>>(
|
||||
"is_int" to java.util.function.Function { params -> DoubleValue(params.get<MoValue>(0).asString().isInt()) },
|
||||
"is_number" to java.util.function.Function { params -> DoubleValue(params.get<MoValue>(0).asString().toDoubleOrNull() != null) },
|
||||
"to_number" to java.util.function.Function { params -> DoubleValue(params.get<MoValue>(0).asString().toDoubleOrNull() ?: 0.0) },
|
||||
"to_int" to java.util.function.Function { params -> DoubleValue(params.get<MoValue>(0).asString().toIntOrNull() ?: 0) },
|
||||
"to_string" to java.util.function.Function { params -> StringValue(params.get<MoValue>(0).asString()) }
|
||||
)
|
||||
val biomeFunctions = hashMapOf<String, java.util.function.Function<MoParams, Any>>()
|
||||
val worldFunctions = hashMapOf<String, java.util.function.Function<MoParams, Any>>()
|
||||
val dimensionTypeFunctions = hashMapOf<String, java.util.function.Function<MoParams, Any>>()
|
||||
val blockFunctions = hashMapOf<String, java.util.function.Function<MoParams, Any>>()
|
||||
val playerFunctions = mutableListOf<(ServerPlayerEntity) -> HashMap<String, java.util.function.Function<MoParams, Any>>>(
|
||||
{ player ->
|
||||
hashMapOf(
|
||||
"username" to java.util.function.Function { _ -> StringValue(player.gameProfile.name) },
|
||||
"uuid" to java.util.function.Function { _ -> StringValue(player.gameProfile.id.toString()) },
|
||||
"data" to java.util.function.Function { _ -> return@Function Cobblemon.molangData.load(player.uuid) },
|
||||
"save_data" to java.util.function.Function { _ -> Cobblemon.molangData.save(player.uuid) },
|
||||
"main_held_item" to java.util.function.Function { _ -> player.world.itemRegistry.getEntry(player.mainHandStack.item).asMoLangValue(RegistryKeys.ITEM) },
|
||||
"off_held_item" to java.util.function.Function { _ -> player.world.itemRegistry.getEntry(player.offHandStack.item).asMoLangValue(RegistryKeys.ITEM) },
|
||||
"face" to java.util.function.Function { _ -> ObjectValue(PlayerDialogueFaceProvider(player.uuid)) }
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
fun RegistryEntry<Biome>.asBiomeMoLangValue() = asMoLangValue(RegistryKeys.BIOME).addFunctions(biomeFunctions)
|
||||
fun RegistryEntry<World>.asWorldMoLangValue() = asMoLangValue(RegistryKeys.WORLD).addFunctions(worldFunctions)
|
||||
fun RegistryEntry<Block>.asBlockMoLangValue() = asMoLangValue(RegistryKeys.BLOCK).addFunctions(blockFunctions)
|
||||
fun RegistryEntry<DimensionType>.asDimensionTypeMoLangValue() = asMoLangValue(RegistryKeys.DIMENSION_TYPE).addFunctions(dimensionTypeFunctions)
|
||||
fun ServerPlayerEntity.asMoLangValue(): ObjectValue<ServerPlayerEntity> {
|
||||
val value = ObjectValue(
|
||||
obj = this,
|
||||
stringify = { it.entityName }
|
||||
)
|
||||
value.addFunctions(playerFunctions.flatMap { it(this).entries.map { it.key to it.value } }.toMap())
|
||||
return value
|
||||
}
|
||||
|
||||
fun <T> RegistryEntry<T>.asMoLangValue(key: RegistryKey<Registry<T>>): ObjectValue<RegistryEntry<T>> {
|
||||
val value = ObjectValue(
|
||||
obj = this,
|
||||
stringify = { it.key.get().value.toString() }
|
||||
)
|
||||
value.functions.put("is_in") {
|
||||
val tag = TagKey.of(key, Identifier(it.getString(0).replace("#", "")))
|
||||
return@put DoubleValue(if (value.obj.isIn(tag)) 1.0 else 0.0)
|
||||
}
|
||||
value.functions.put("is_of") {
|
||||
val identifier = Identifier(it.getString(0))
|
||||
return@put DoubleValue(if (value.obj.matchesId(identifier)) 1.0 else 0.0)
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
fun QueryStruct.addStandardFunctions(): QueryStruct {
|
||||
functions.putAll(generalFunctions)
|
||||
return this
|
||||
}
|
||||
|
||||
fun <T : QueryStruct> T.addFunctions(functions: Map<String, java.util.function.Function<MoParams, Any>>): T {
|
||||
this.functions.putAll(functions)
|
||||
return this
|
||||
}
|
||||
|
||||
fun MoLangEnvironment.getQueryStruct(name: String = "query") = structs.getOrPut(name) { QueryStruct(hashMapOf()) } as QueryStruct
|
||||
|
||||
fun MoLangRuntime.setup(): MoLangRuntime {
|
||||
environment.getQueryStruct().addStandardFunctions()
|
||||
return this
|
||||
}
|
||||
|
||||
fun writeMoValueToNBT(value: MoValue): NbtElement? {
|
||||
return when (value) {
|
||||
is DoubleValue -> NbtDouble.of(value.value)
|
||||
is StringValue -> NbtString.of(value.value)
|
||||
is ArrayStruct -> {
|
||||
val list = value.map.values
|
||||
val nbtList = NbtList()
|
||||
list.mapNotNull(::writeMoValueToNBT).forEach(nbtList::add)
|
||||
nbtList
|
||||
}
|
||||
is VariableStruct -> {
|
||||
val nbt = NbtCompound()
|
||||
value.map.forEach { (key, value) ->
|
||||
val element = writeMoValueToNBT(value) ?: return@forEach
|
||||
nbt.put(key, element)
|
||||
}
|
||||
nbt
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
fun readMoValueFromNBT(nbt: NbtElement): MoValue {
|
||||
return when (nbt) {
|
||||
is NbtDouble -> DoubleValue(nbt.doubleValue())
|
||||
is NbtString -> StringValue(nbt.asString())
|
||||
is NbtList -> {
|
||||
val array = ArrayStruct(hashMapOf())
|
||||
var index = 0
|
||||
nbt.forEach { element ->
|
||||
val value = readMoValueFromNBT(element)
|
||||
array.setDirectly("$index", value)
|
||||
index++
|
||||
}
|
||||
array
|
||||
}
|
||||
is NbtCompound -> {
|
||||
val variable = VariableStruct(hashMapOf())
|
||||
nbt.keys.toList().forEach { key ->
|
||||
val value = readMoValueFromNBT(nbt[key]!!)
|
||||
variable.map[key] = value
|
||||
}
|
||||
variable
|
||||
}
|
||||
else -> null
|
||||
} ?: throw IllegalArgumentException("Invalid NBT element type: ${nbt.type}")
|
||||
}
|
||||
}
|
||||
@@ -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.api.molang
|
||||
|
||||
import com.bedrockk.molang.runtime.struct.QueryStruct
|
||||
import com.bedrockk.molang.runtime.value.MoValue
|
||||
|
||||
/**
|
||||
* A [MoValue] that just wraps around some other object value. It's for good and valid reasons.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since October 2nd, 2023
|
||||
*/
|
||||
class ObjectValue<T>(
|
||||
var obj: T,
|
||||
val stringify: (T) -> String = { it.toString() },
|
||||
val doublify: (T) -> Double = { throw NotImplementedError("Doublify not implemented for this object value, are you doing weird molang") }
|
||||
) : QueryStruct(hashMapOf()) {
|
||||
override fun value() = this
|
||||
override fun asDouble() = doublify(obj)
|
||||
override fun asString() = stringify(obj)
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.molang
|
||||
|
||||
import com.bedrockk.molang.Expression
|
||||
import com.bedrockk.molang.runtime.MoLangRuntime
|
||||
import com.cobblemon.mod.common.util.resolve
|
||||
|
||||
/**
|
||||
* A simple implementation of [ExpressionLike] that is just a single [Expression]. This
|
||||
* is as opposed to [ListExpression]s.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since October 22nd, 2023
|
||||
*/
|
||||
class SingleExpression(val expr: Expression) : ExpressionLike {
|
||||
override fun resolve(runtime: MoLangRuntime) = runtime.resolve(expr)
|
||||
}
|
||||
@@ -13,7 +13,9 @@ import com.cobblemon.mod.common.api.moves.categories.DamageCategory
|
||||
import com.cobblemon.mod.common.api.types.ElementalType
|
||||
import com.cobblemon.mod.common.api.types.ElementalTypes
|
||||
import com.cobblemon.mod.common.battles.MoveTarget
|
||||
import com.cobblemon.mod.common.battles.runner.ShowdownService
|
||||
import com.cobblemon.mod.common.util.lang
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import net.minecraft.text.MutableText
|
||||
|
||||
@@ -45,7 +47,8 @@ open class MoveTemplate(
|
||||
val pp: Int,
|
||||
val priority: Int,
|
||||
val critRatio: Double,
|
||||
val effectChances: Array<Double>
|
||||
val effectChances: Array<Double>,
|
||||
val flags: Set<String>
|
||||
) {
|
||||
|
||||
val displayName: MutableText
|
||||
@@ -65,7 +68,8 @@ open class MoveTemplate(
|
||||
pp = 5,
|
||||
priority = 0,
|
||||
critRatio = 0.0,
|
||||
effectChances = emptyArray()
|
||||
effectChances = emptyArray(),
|
||||
flags = emptySet()
|
||||
)
|
||||
|
||||
companion object {
|
||||
@@ -92,4 +96,9 @@ open class MoveTemplate(
|
||||
template = this
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this move's showdown data as a [JsonObject]
|
||||
*/
|
||||
fun showdownJson() = ShowdownService.service.getMoves()[num].asJsonObject
|
||||
}
|
||||
@@ -72,7 +72,22 @@ object Moves : DataRegistry {
|
||||
effectChances += secondaryMember.get("chance").asDouble
|
||||
}
|
||||
}
|
||||
val move = MoveTemplate(id, num, elementalType, damageCategory, power, target, accuracy, pp, priority, critRatio, effectChances.toTypedArray())
|
||||
val flags = mutableSetOf<String>()
|
||||
jsMove["flags"].asJsonObject.asMap().forEach { flags.add(it.key) }
|
||||
val move = MoveTemplate(
|
||||
id,
|
||||
num,
|
||||
elementalType,
|
||||
damageCategory,
|
||||
power,
|
||||
target,
|
||||
accuracy,
|
||||
pp,
|
||||
priority,
|
||||
critRatio,
|
||||
effectChances.toTypedArray(),
|
||||
flags
|
||||
)
|
||||
this.register(move)
|
||||
} catch (e: Exception) {
|
||||
Cobblemon.LOGGER.error("Caught exception trying to resolve the move '{}'", id, e)
|
||||
|
||||
+5
-5
@@ -6,10 +6,10 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.access;
|
||||
package com.cobblemon.mod.common.api.moves.tags
|
||||
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import com.cobblemon.mod.common.api.moves.MoveTemplate
|
||||
|
||||
public interface SoundManagerDuck {
|
||||
void toggleCategories(SoundCategory... categories);
|
||||
}
|
||||
class MoveTag(
|
||||
val moves: List<MoveTemplate>
|
||||
)
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.moves.tags
|
||||
|
||||
import com.cobblemon.mod.common.api.moves.Moves
|
||||
|
||||
object MoveTags {
|
||||
|
||||
private val moves = Moves.all()
|
||||
|
||||
val PRIORITY_ZERO = MoveTag(moves.filter { it.priority == 0 })
|
||||
|
||||
/* Showdown flags */
|
||||
val PROTECT = MoveTag(moves.filter { it.flags.contains("protect") })
|
||||
val CONTACT = MoveTag(moves.filter { it.flags.contains("contact") })
|
||||
val DISTANCE = MoveTag(moves.filter { it.flags.contains("distance") })
|
||||
val ALLY_ANIM = MoveTag(moves.filter { it.flags.contains("allyanim") })
|
||||
val FAIL_ENCORE = MoveTag(moves.filter { it.flags.contains("failencore") })
|
||||
val FAIL_COPYCAT = MoveTag(moves.filter { it.flags.contains("failcopycat") })
|
||||
val REFLECTABLE = MoveTag(moves.filter { it.flags.contains("reflectable") })
|
||||
val BITE = MoveTag(moves.filter { it.flags.contains("bite") })
|
||||
val NON_SKY = MoveTag(moves.filter { it.flags.contains("nonsky") })
|
||||
val GRAVITY = MoveTag(moves.filter { it.flags.contains("gravity") })
|
||||
val POWDER = MoveTag(moves.filter { it.flags.contains("powder") })
|
||||
val PLEDGE_COMBO = MoveTag(moves.filter { it.flags.contains("pledgecombo") })
|
||||
val MIRROR = MoveTag(moves.filter { it.flags.contains("mirror") })
|
||||
val SNATCH = MoveTag(moves.filter { it.flags.contains("snatch") })
|
||||
val SLICING = MoveTag(moves.filter { it.flags.contains("slicing") })
|
||||
val WIND = MoveTag(moves.filter { it.flags.contains("wind") })
|
||||
val NO_SLEEP_TALK = MoveTag(moves.filter { it.flags.contains("nosleeptalk") })
|
||||
val FAIL_INSTRUCT = MoveTag(moves.filter { it.flags.contains("failinstruct") })
|
||||
val PULSE = MoveTag(moves.filter { it.flags.contains("pulse") })
|
||||
val RECHARGE = MoveTag(moves.filter { it.flags.contains("recharge") })
|
||||
val SOUND = MoveTag(moves.filter { it.flags.contains("sound") })
|
||||
val PUNCH = MoveTag(moves.filter { it.flags.contains("punch") })
|
||||
val FUTURE_MOVE = MoveTag(moves.filter { it.flags.contains("futuremove") })
|
||||
val MUST_PRESSURE = MoveTag(moves.filter { it.flags.contains("mustpressure") })
|
||||
val HEAL = MoveTag(moves.filter { it.flags.contains("heal") })
|
||||
val BULLET = MoveTag(moves.filter { it.flags.contains("bullet") })
|
||||
val BYPASS_SUB = MoveTag(moves.filter { it.flags.contains("bypasssub") })
|
||||
val DANCE = MoveTag(moves.filter { it.flags.contains("dance") })
|
||||
val NO_ASSIST = MoveTag(moves.filter { it.flags.contains("noassist") })
|
||||
val FAIL_MIMIC = MoveTag(moves.filter { it.flags.contains("failmimic") })
|
||||
val FAIL_ME_FIRST = MoveTag(moves.filter { it.flags.contains("failmefirst") })
|
||||
val CANT_USE_TWICE = MoveTag(moves.filter { it.flags.contains("cantusetwice") })
|
||||
val CHARGE = MoveTag(moves.filter { it.flags.contains("charge") })
|
||||
val DEFROST = MoveTag(moves.filter { it.flags.contains("defrost") })
|
||||
val NO_PARENTAL_BOND = MoveTag(moves.filter { it.flags.contains("noparentalbond") })
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.multiblock
|
||||
|
||||
import com.cobblemon.mod.common.block.entity.fossil.FossilMultiblockEntity
|
||||
import net.minecraft.block.*
|
||||
import net.minecraft.block.entity.BlockEntity
|
||||
import net.minecraft.entity.LivingEntity
|
||||
import net.minecraft.entity.player.PlayerEntity
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.server.world.ServerWorld
|
||||
import net.minecraft.util.ActionResult
|
||||
import net.minecraft.util.Hand
|
||||
import net.minecraft.util.hit.BlockHitResult
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.World
|
||||
|
||||
/**
|
||||
* A block that can be part of a [MultiblockStructure]
|
||||
*/
|
||||
abstract class MultiblockBlock(properties: Settings) : BlockWithEntity(properties) {
|
||||
|
||||
override fun onPlaced(
|
||||
world: World,
|
||||
pos: BlockPos,
|
||||
state: BlockState,
|
||||
placer: LivingEntity?,
|
||||
itemStack: ItemStack?
|
||||
) {
|
||||
if (world is ServerWorld) {
|
||||
val multiblockEntity = world.getBlockEntity(pos) as MultiblockEntity
|
||||
multiblockEntity.multiblockBuilder?.validate(world)
|
||||
}
|
||||
super.onPlaced(world, pos, state, placer, itemStack)
|
||||
}
|
||||
|
||||
override fun onUse(
|
||||
state: BlockState,
|
||||
world: World,
|
||||
pos: BlockPos,
|
||||
player: PlayerEntity,
|
||||
hand: Hand,
|
||||
hit: BlockHitResult
|
||||
): ActionResult {
|
||||
if(hand == Hand.OFF_HAND) {
|
||||
return ActionResult.SUCCESS
|
||||
}
|
||||
val entity = world.getBlockEntity(pos) as MultiblockEntity
|
||||
if (entity.multiblockStructure != null) {
|
||||
return entity.multiblockStructure!!.onUse(state, world, pos, player, hand, hit)
|
||||
}
|
||||
return super.onUse(state, world, pos, player, hand, hit)
|
||||
}
|
||||
|
||||
override fun onBreak(world: World, pos: BlockPos, state: BlockState, player: PlayerEntity?) {
|
||||
super.onBreak(world, pos, state, player)
|
||||
if (!world.isClient) {
|
||||
val entity = world.getBlockEntity(pos)
|
||||
if (entity is MultiblockEntity && entity.multiblockStructure != null) {
|
||||
entity.multiblockStructure!!.onBreak(world, pos, state, player)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun createBlockEntity(pos: BlockPos, state: BlockState): BlockEntity? {
|
||||
return createMultiBlockEntity(pos, state)
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun getRenderType(state: BlockState?): BlockRenderType {
|
||||
return BlockRenderType.MODEL
|
||||
}
|
||||
|
||||
abstract fun createMultiBlockEntity(pos: BlockPos, state: BlockState): FossilMultiblockEntity
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.multiblock
|
||||
|
||||
import com.cobblemon.mod.common.api.multiblock.MultiblockStructure
|
||||
import com.cobblemon.mod.common.api.multiblock.builder.MultiblockStructureBuilder
|
||||
import com.cobblemon.mod.common.util.DataKeys
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.block.entity.BlockEntity
|
||||
import net.minecraft.block.entity.BlockEntityType
|
||||
import net.minecraft.nbt.NbtCompound
|
||||
import net.minecraft.nbt.NbtHelper
|
||||
import net.minecraft.network.listener.ClientPlayPacketListener
|
||||
import net.minecraft.network.packet.Packet
|
||||
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket
|
||||
import net.minecraft.util.math.BlockPos
|
||||
|
||||
/**
|
||||
* Multiblock entities are kind of complicated. Basically every multiblock entity should have a MultiBlockStructureBuilder
|
||||
* that is checked when this block entity is created. The multiblock entity also contains a reference to a MultiblockStructure
|
||||
* which is shared between all MultiblockEntities in the structure. Finally, every Multiblock contains the location of the
|
||||
* block that controls this blockentities associated structure
|
||||
*/
|
||||
abstract class MultiblockEntity(
|
||||
type: BlockEntityType<*>,
|
||||
pos: BlockPos,
|
||||
state: BlockState,
|
||||
var multiblockBuilder: MultiblockStructureBuilder?
|
||||
) : BlockEntity(type, pos, state) {
|
||||
|
||||
abstract var multiblockStructure: MultiblockStructure?
|
||||
abstract var masterBlockPos: BlockPos?
|
||||
|
||||
override fun toUpdatePacket(): Packet<ClientPlayPacketListener>? {
|
||||
return BlockEntityUpdateS2CPacket.create(this)
|
||||
}
|
||||
|
||||
override fun toInitialChunkDataNbt(): NbtCompound {
|
||||
val result = NbtCompound()
|
||||
writeNbt(result)
|
||||
return result
|
||||
}
|
||||
|
||||
override fun writeNbt(nbt: NbtCompound) {
|
||||
super.writeNbt(nbt)
|
||||
//Used for checking build conditions in multiblocks (Dont count a block if it has the FORMED flag)
|
||||
nbt.putBoolean(DataKeys.FORMED, masterBlockPos != null)
|
||||
if (multiblockStructure != null && multiblockStructure!!.controllerBlockPos == pos) {
|
||||
nbt.put(DataKeys.MULTIBLOCK_STORAGE, multiblockStructure!!.writeToNbt())
|
||||
}
|
||||
else if (masterBlockPos != null) {
|
||||
nbt.put(DataKeys.CONTROLLER_BLOCK, NbtHelper.fromBlockPos(masterBlockPos))
|
||||
}
|
||||
}
|
||||
|
||||
abstract override fun readNbt(nbt: NbtCompound)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.multiblock
|
||||
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.entity.player.PlayerEntity
|
||||
import net.minecraft.nbt.NbtCompound
|
||||
import net.minecraft.server.world.ServerWorld
|
||||
import net.minecraft.util.ActionResult
|
||||
import net.minecraft.util.Hand
|
||||
import net.minecraft.util.hit.BlockHitResult
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.random.Random
|
||||
import net.minecraft.world.World
|
||||
|
||||
interface MultiblockStructure {
|
||||
val controllerBlockPos: BlockPos
|
||||
|
||||
fun onUse(
|
||||
blockState: BlockState,
|
||||
world: World,
|
||||
blockPos: BlockPos,
|
||||
player: PlayerEntity,
|
||||
interactionHand: Hand,
|
||||
blockHitResult: BlockHitResult
|
||||
): ActionResult
|
||||
|
||||
fun onBreak(world: World, pos: BlockPos, state: BlockState, player: PlayerEntity?)
|
||||
|
||||
fun tick(world: World)
|
||||
|
||||
fun syncToClient(world: World)
|
||||
|
||||
fun markDirty(world: World)
|
||||
fun writeToNbt(): NbtCompound
|
||||
fun getComparatorOutput(state: BlockState, world: World?, pos: BlockPos?): Int {
|
||||
return 0
|
||||
}
|
||||
fun onTriggerEvent(state: BlockState?, world: ServerWorld?, pos: BlockPos?, random: Random?)
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.multiblock.builder
|
||||
|
||||
import com.cobblemon.mod.common.api.multiblock.condition.MultiblockCondition
|
||||
import net.minecraft.server.world.ServerWorld
|
||||
import net.minecraft.util.math.Box
|
||||
import net.minecraft.util.shape.VoxelShape
|
||||
|
||||
/**
|
||||
* Represents an area that has a potential to form a MultiBlockStructure
|
||||
* @property boundingBox The box that each condition checks in
|
||||
* @property conditions The [MultiblockCondition]s that must be met for the multiblock to form. All must be true.
|
||||
*
|
||||
* @author Apion
|
||||
* @since August 24, 2023
|
||||
*/
|
||||
interface MultiblockStructureBuilder {
|
||||
val boundingBox: VoxelShape
|
||||
val conditions: List<MultiblockCondition>
|
||||
|
||||
fun validate(world: ServerWorld): Boolean {
|
||||
conditions.forEach {
|
||||
if (!it.test(world, boundingBox)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
form(world)
|
||||
return true
|
||||
}
|
||||
|
||||
fun form(world: ServerWorld)
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.multiblock.condition
|
||||
|
||||
import net.minecraft.server.world.ServerWorld
|
||||
import net.minecraft.util.math.Box
|
||||
import net.minecraft.util.shape.VoxelShape
|
||||
|
||||
class AndCondition(val conditionOne: MultiblockCondition, val conditionTwo: MultiblockCondition) :
|
||||
MultiblockCondition {
|
||||
override fun test(world: ServerWorld, box: VoxelShape): Boolean {
|
||||
return conditionOne.test(world, box) and conditionTwo.test(world, box)
|
||||
}
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.multiblock.condition
|
||||
|
||||
import com.cobblemon.mod.common.util.blockPositionsAsList
|
||||
import net.minecraft.predicate.BlockPredicate
|
||||
import net.minecraft.server.world.ServerWorld
|
||||
import net.minecraft.util.math.Direction
|
||||
import net.minecraft.util.shape.VoxelShape
|
||||
|
||||
/**
|
||||
* Checks that a block adjacent to another block matches a predicate. Basically we find a block that
|
||||
* matched relToBlock, then we look in each direction to see if there is an adjacent block that matches
|
||||
* target block.
|
||||
*
|
||||
* @param relToBlock The [BlockPredicate] for the main block. The block that matches this predicate is the block whose adjacent blocks we check
|
||||
* @param targetBlock The [BlockPredicate] that is checked for blocks adjacent to relToBlock
|
||||
* @param directionsToCheck The [Direction]s that we check from the target relToBlock
|
||||
*
|
||||
* @author Apion
|
||||
* @since August 24th, 2023
|
||||
*/
|
||||
class BlockRelativeCondition(
|
||||
val relToBlock: BlockPredicate,
|
||||
val targetBlock: BlockPredicate,
|
||||
val directionsToCheck: Array<Direction> = Direction.values()
|
||||
) : MultiblockCondition {
|
||||
override fun test(world: ServerWorld, box: VoxelShape): Boolean {
|
||||
val relToBlockBlockPositions = box.blockPositionsAsList().filter { relToBlock.test(world, it) }
|
||||
relToBlockBlockPositions.forEach { pos ->
|
||||
directionsToCheck.forEach {
|
||||
if (targetBlock.test(world, pos.offset(it))) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.multiblock.condition
|
||||
|
||||
import net.minecraft.server.world.ServerWorld
|
||||
import net.minecraft.util.math.Box
|
||||
import net.minecraft.util.shape.VoxelShape
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
interface MultiblockCondition {
|
||||
fun test(world: ServerWorld, box: VoxelShape): Boolean
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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.multiblock.condition
|
||||
|
||||
import net.minecraft.server.world.ServerWorld
|
||||
import net.minecraft.util.math.Box
|
||||
import net.minecraft.util.shape.VoxelShape
|
||||
|
||||
class OrCondition(
|
||||
val conditionOne: MultiblockCondition,
|
||||
val conditionTwo: MultiblockCondition
|
||||
) : MultiblockCondition {
|
||||
override fun test(world: ServerWorld, box: VoxelShape): Boolean {
|
||||
return conditionOne.test(world, box) or conditionTwo.test(world, box)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,11 +27,14 @@ object CobblemonPermissions {
|
||||
val HEAL_POKEMON_SELF = this.create("$HEAL_POKEMON_BASE.self", PermissionLevel.CHEAT_COMMANDS_AND_COMMAND_BLOCKS)
|
||||
val HEAL_POKEMON_OTHER = this.create("$HEAL_POKEMON_BASE.other", PermissionLevel.CHEAT_COMMANDS_AND_COMMAND_BLOCKS)
|
||||
|
||||
|
||||
private const val LEVEL_UP_BASE = "${COMMAND_PREFIX}levelup"
|
||||
val LEVEL_UP_SELF = this.create("$LEVEL_UP_BASE.self", PermissionLevel.CHEAT_COMMANDS_AND_COMMAND_BLOCKS)
|
||||
val LEVEL_UP_OTHER = this.create("$LEVEL_UP_BASE.other", PermissionLevel.CHEAT_COMMANDS_AND_COMMAND_BLOCKS)
|
||||
|
||||
val OPEN_STARTER_SCREEN = this.create("${COMMAND_PREFIX}openstarterscreen", PermissionLevel.CHEAT_COMMANDS_AND_COMMAND_BLOCKS)
|
||||
val BEDROCK_PARTICLE = this.create("${COMMAND_PREFIX}bedrockparticle", PermissionLevel.CHEAT_COMMANDS_AND_COMMAND_BLOCKS)
|
||||
val OPEN_DIALOGUE = this.create("${COMMAND_PREFIX}opendialogue", PermissionLevel.CHEAT_COMMANDS_AND_COMMAND_BLOCKS)
|
||||
|
||||
private const val POKEMON_EDIT_BASE = "${COMMAND_PREFIX}pokemonedit"
|
||||
val POKEMON_EDIT_SELF = this.create("$POKEMON_EDIT_BASE.self", PermissionLevel.CHEAT_COMMANDS_AND_COMMAND_BLOCKS)
|
||||
@@ -67,6 +70,9 @@ object CobblemonPermissions {
|
||||
val CLEAR_PARTY = this.create("${COMMAND_PREFIX}clearparty", PermissionLevel.CHEAT_COMMANDS_AND_COMMAND_BLOCKS)
|
||||
val CLEAR_PC = this.create("${COMMAND_PREFIX}clearpc", PermissionLevel.CHEAT_COMMANDS_AND_COMMAND_BLOCKS)
|
||||
|
||||
// Test for starting a random battle with AI Player
|
||||
val RANDOM_BATTLE = this.create("${COMMAND_PREFIX}randombattle", PermissionLevel.CHEAT_COMMANDS_AND_COMMAND_BLOCKS)
|
||||
|
||||
fun all(): Iterable<Permission> = this.permissions
|
||||
|
||||
private fun create(node: String, level: PermissionLevel): Permission {
|
||||
|
||||
@@ -121,6 +121,38 @@ object PokeBalls : JsonDataRegistry<PokeBall> {
|
||||
get() = this.byName("dream_ball")
|
||||
val BEAST_BALL
|
||||
get() = this.byName("beast_ball")
|
||||
val ANCIENT_POKE_BALL
|
||||
get() = this.byName("ancient_poke_ball")
|
||||
val ANCIENT_CITRINE_BALL
|
||||
get() = this.byName("ancient_citrine_ball")
|
||||
val ANCIENT_VERDANT_BALL
|
||||
get() = this.byName("ancient_verdant_ball")
|
||||
val ANCIENT_AZURE_BALL
|
||||
get() = this.byName("ancient_azure_ball")
|
||||
val ANCIENT_ROSEATE_BALL
|
||||
get() = this.byName("ancient_roseate_ball")
|
||||
val ANCIENT_SLATE_BALL
|
||||
get() = this.byName("ancient_slate_ball")
|
||||
val ANCIENT_IVORY_BALL
|
||||
get() = this.byName("ancient_ivory_ball")
|
||||
val ANCIENT_GREAT_BALL
|
||||
get() = this.byName("ancient_great_ball")
|
||||
val ANCIENT_ULTRA_BALL
|
||||
get() = this.byName("ancient_ultra_ball")
|
||||
val ANCIENT_HEAVY_BALL
|
||||
get() = this.byName("ancient_heavy_ball")
|
||||
val ANCIENT_LEADEN_BALL
|
||||
get() = this.byName("ancient_leaden_ball")
|
||||
val ANCIENT_GIGATON_BALL
|
||||
get() = this.byName("ancient_gigaton_ball")
|
||||
val ANCIENT_FEATHER_BALL
|
||||
get() = this.byName("ancient_feather_ball")
|
||||
val ANCIENT_WING_BALL
|
||||
get() = this.byName("ancient_wing_ball")
|
||||
val ANCIENT_JET_BALL
|
||||
get() = this.byName("ancient_jet_ball")
|
||||
val ANCIENT_ORIGIN_BALL
|
||||
get() = this.byName("ancient_origin_ball")
|
||||
|
||||
init {
|
||||
createDefault("poke_ball")
|
||||
@@ -157,6 +189,22 @@ object PokeBalls : JsonDataRegistry<PokeBall> {
|
||||
createDefault("park_ball", CatchRateModifiers.PARK)
|
||||
createDefault("dream_ball", CatchRateModifiers.statusBoosting(4F, Statuses.SLEEP))
|
||||
createDefault("beast_ball", LabelModifier(5F, true, CobblemonPokemonLabels.ULTRA_BEAST)/*, LabelModifier(0.1F, false, CobblemonPokemonLabels.ULTRA_BEAST))*/)
|
||||
createDefault("ancient_poke_ball", ancient = true)
|
||||
createDefault("ancient_citrine_ball", ancient = true)
|
||||
createDefault("ancient_verdant_ball", ancient = true)
|
||||
createDefault("ancient_azure_ball", ancient = true)
|
||||
createDefault("ancient_roseate_ball", ancient = true)
|
||||
createDefault("ancient_slate_ball", ancient = true)
|
||||
createDefault("ancient_ivory_ball", ancient = true)
|
||||
createDefault("ancient_great_ball", MultiplierModifier(1.5F), ancient = true)
|
||||
createDefault("ancient_ultra_ball", MultiplierModifier(2F), ancient = true)
|
||||
createDefault("ancient_heavy_ball", throwPower = 0.75f, ancient = true)
|
||||
createDefault("ancient_leaden_ball", throwPower = 0.75f, ancient = true)
|
||||
createDefault("ancient_gigaton_ball", throwPower = 0.75f, ancient = true)
|
||||
createDefault("ancient_feather_ball", throwPower = 2.5f, ancient = true)
|
||||
createDefault("ancient_wing_ball", throwPower = 2.5f, ancient = true)
|
||||
createDefault("ancient_jet_ball", throwPower = 2.5f, ancient = true)
|
||||
createDefault("ancient_origin_ball", ancient = true)
|
||||
// Luxury ball effect
|
||||
CobblemonEvents.FRIENDSHIP_UPDATED.subscribe(priority = Priority.LOWEST) { event ->
|
||||
var increment = (event.newFriendship - event.pokemon.friendship).toFloat()
|
||||
@@ -191,11 +239,13 @@ object PokeBalls : JsonDataRegistry<PokeBall> {
|
||||
effects: List<CaptureEffect> = emptyList(),
|
||||
waterDragValue: Float = 0.8F,
|
||||
model2d: Identifier = cobblemonResource(name),
|
||||
model3d: Identifier = cobblemonResource("${name}_model")
|
||||
model3d: Identifier = cobblemonResource("${name}_model"),
|
||||
throwPower: Float = 1.25f,
|
||||
ancient: Boolean = false
|
||||
): PokeBall {
|
||||
val identifier = cobblemonResource(name)
|
||||
//val finalModifiers = if (appendUltraBeastPenalty) modifiers + listOf(LabelModifier(0.1F, true, CobblemonPokemonLabels.ULTRA_BEAST)) else modifiers
|
||||
val pokeball = PokeBall(identifier, modifier, effects, waterDragValue, model2d, model3d)
|
||||
val pokeball = PokeBall(identifier, modifier, effects, waterDragValue, model2d, model3d, throwPower, ancient)
|
||||
this.defaults[identifier] = pokeball
|
||||
return pokeball
|
||||
}
|
||||
|
||||
@@ -8,8 +8,12 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.pokemon
|
||||
|
||||
import com.bedrockk.molang.runtime.struct.VariableStruct
|
||||
import com.bedrockk.molang.runtime.value.DoubleValue
|
||||
import com.bedrockk.molang.runtime.value.StringValue
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.api.abilities.Abilities
|
||||
import com.cobblemon.mod.common.api.moves.Moves
|
||||
import com.cobblemon.mod.common.api.pokeball.PokeBalls
|
||||
import com.cobblemon.mod.common.api.pokemon.aspect.AspectProvider
|
||||
import com.cobblemon.mod.common.api.pokemon.stats.Stats
|
||||
@@ -17,16 +21,9 @@ import com.cobblemon.mod.common.api.pokemon.status.Statuses
|
||||
import com.cobblemon.mod.common.api.properties.CustomPokemonProperty
|
||||
import com.cobblemon.mod.common.api.types.ElementalTypes
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.pokemon.EVs
|
||||
import com.cobblemon.mod.common.pokemon.Gender
|
||||
import com.cobblemon.mod.common.pokemon.IVs
|
||||
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||
import com.cobblemon.mod.common.pokemon.RenderablePokemon
|
||||
import com.cobblemon.mod.common.pokemon.*
|
||||
import com.cobblemon.mod.common.pokemon.status.PersistentStatus
|
||||
import com.cobblemon.mod.common.util.DataKeys
|
||||
import com.cobblemon.mod.common.util.asIdentifierDefaultingNamespace
|
||||
import com.cobblemon.mod.common.util.isInt
|
||||
import com.cobblemon.mod.common.util.splitMap
|
||||
import com.cobblemon.mod.common.util.*
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonObject
|
||||
import kotlin.random.Random
|
||||
@@ -39,6 +36,7 @@ import net.minecraft.text.Text
|
||||
import net.minecraft.util.Identifier
|
||||
import net.minecraft.util.InvalidIdentifierException
|
||||
import net.minecraft.world.World
|
||||
import java.util.UUID
|
||||
|
||||
/**
|
||||
* A grouping of typical, selectable properties for a Pokémon. This is serializable
|
||||
@@ -95,6 +93,12 @@ open class PokemonProperties {
|
||||
props.dmaxLevel = parseIntProperty(keyPairs, listOf("dmax_level", "dmax"))?.coerceIn(0, Cobblemon.config.maxDynamaxLevel)
|
||||
props.gmaxFactor = parseBooleanProperty(keyPairs, listOf("gmax_factor", "gmax"))
|
||||
props.tradeable = parseBooleanProperty(keyPairs, listOf("tradeable", "tradable"))
|
||||
props.move1 = parseStringOfRegistry(keyPairs, listOf("move1", "m1")) { Moves.getByName(it)?.name }
|
||||
props.move2 = parseStringOfRegistry(keyPairs, listOf("move2", "m2")) { Moves.getByName(it)?.name }
|
||||
props.move3 = parseStringOfRegistry(keyPairs, listOf("move3", "m3")) { Moves.getByName(it)?.name }
|
||||
props.move4 = parseStringOfRegistry(keyPairs, listOf("move4", "m4")) { Moves.getByName(it)?.name }
|
||||
props.originalTrainerType = OriginalTrainerType.values().toList().parsePropertyOfCollection(keyPairs, listOf("originaltrainertype", "ottype"), labelsOptional = true) { it.name.lowercase() }
|
||||
props.originalTrainer = parsePlayerProperty(keyPairs, listOf("originaltrainer", "ot"))
|
||||
|
||||
val maybeIVs = IVs()
|
||||
val maybeEVs = EVs()
|
||||
@@ -213,6 +217,21 @@ open class PokemonProperties {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try and parse a Player reference, either as a Username (3 <= length <= 16) or a UUID (length == 36)
|
||||
*/
|
||||
private fun parsePlayerProperty(keyPairs: MutableList<Pair<String, String?>>, labels: Iterable<String>): String? {
|
||||
val matchingKeyPair = getMatchedKeyPair(keyPairs, labels) ?: return null
|
||||
keyPairs.remove(matchingKeyPair)
|
||||
|
||||
if (matchingKeyPair.second == null)
|
||||
return null
|
||||
|
||||
val string = matchingKeyPair.second!!
|
||||
|
||||
return if (string.length in 3..16 || (string.length == 36 && isUuid(string)) ) string else null
|
||||
}
|
||||
|
||||
private fun <T> Iterable<T>.parsePropertyOfCollection(
|
||||
keyPairs: MutableList<Pair<String, String?>>,
|
||||
labels: Iterable<String>,
|
||||
@@ -260,6 +279,13 @@ open class PokemonProperties {
|
||||
var dmaxLevel: Int? = null
|
||||
var gmaxFactor: Boolean? = null
|
||||
var tradeable: Boolean? = null
|
||||
var move1: String? = null
|
||||
var move2: String? = null
|
||||
var move3: String? = null
|
||||
var move4: String? = null
|
||||
var originalTrainerType: OriginalTrainerType? = null
|
||||
var originalTrainer: String? = null // Original Trainer by Username or UUID
|
||||
|
||||
|
||||
var ivs: IVs? = null
|
||||
var evs: EVs? = null
|
||||
@@ -313,6 +339,32 @@ open class PokemonProperties {
|
||||
dmaxLevel?.let { pokemon.dmaxLevel = it }
|
||||
gmaxFactor?.let { pokemon.gmaxFactor = it }
|
||||
tradeable?.let { pokemon.tradeable = it }
|
||||
move1?.let { pokemon.setMove(it, 0) }
|
||||
move2?.let { pokemon.setMove(it, 1) }
|
||||
move3?.let { pokemon.setMove(it, 2) }
|
||||
move4?.let { pokemon.setMove(it, 3) }
|
||||
// If it has been explicitly set to NONE, clear the stored information, including the originalTrainer property
|
||||
originalTrainerType?.let {
|
||||
if (it == OriginalTrainerType.NONE) {
|
||||
pokemon.removeOriginalTrainer()
|
||||
originalTrainer = null
|
||||
}
|
||||
}
|
||||
originalTrainer?.let { ot ->
|
||||
val type = originalTrainerType ?: pokemon.originalTrainerType
|
||||
when (type) {
|
||||
OriginalTrainerType.PLAYER -> {
|
||||
when (ot.length) {
|
||||
in 3..16 -> server()?.userCache?.findByName(ot)?.get()?.id // OT is a Username
|
||||
36 -> UUID.fromString(ot) // OT is a UUID
|
||||
else -> null // OT is invalid
|
||||
}?.let { uuid -> pokemon.setOriginalTrainer(uuid) }
|
||||
}
|
||||
OriginalTrainerType.NPC -> pokemon.setOriginalTrainer(ot)
|
||||
else -> {}
|
||||
}
|
||||
pokemon.refreshOriginalTrainer()
|
||||
}
|
||||
pokemon.updateAspects()
|
||||
}
|
||||
|
||||
@@ -353,6 +405,32 @@ open class PokemonProperties {
|
||||
dmaxLevel?.let { pokemonEntity.pokemon.dmaxLevel = it }
|
||||
gmaxFactor?.let { pokemonEntity.pokemon.gmaxFactor = it }
|
||||
tradeable?.let { pokemonEntity.pokemon.tradeable = it }
|
||||
move1?.let { pokemonEntity.pokemon.setMove(it, 0) }
|
||||
move2?.let { pokemonEntity.pokemon.setMove(it, 1) }
|
||||
move3?.let { pokemonEntity.pokemon.setMove(it, 2) }
|
||||
move4?.let { pokemonEntity.pokemon.setMove(it, 3) }
|
||||
// If it has been explicitly set to NONE, clear the stored information, including the originalTrainer property
|
||||
originalTrainerType?.let {
|
||||
if (it == OriginalTrainerType.NONE) {
|
||||
pokemonEntity.pokemon.removeOriginalTrainer()
|
||||
originalTrainer = null
|
||||
}
|
||||
}
|
||||
originalTrainer?.let { ot ->
|
||||
val type = originalTrainerType ?: pokemonEntity.pokemon.originalTrainerType
|
||||
when (type) {
|
||||
OriginalTrainerType.PLAYER -> {
|
||||
when (ot.length) {
|
||||
in 3..16 -> server()?.userCache?.findByName(ot)?.get()?.id // OT is a Username
|
||||
36 -> UUID.fromString(ot) // OT is a UUID
|
||||
else -> null // OT is invalid
|
||||
}?.let { uuid -> pokemonEntity.pokemon.setOriginalTrainer(uuid) }
|
||||
}
|
||||
OriginalTrainerType.NPC -> pokemonEntity.pokemon.setOriginalTrainer(ot)
|
||||
else -> {}
|
||||
}
|
||||
pokemonEntity.pokemon.refreshOriginalTrainer()
|
||||
}
|
||||
pokemonEntity.pokemon.updateAspects()
|
||||
}
|
||||
|
||||
@@ -391,6 +469,12 @@ open class PokemonProperties {
|
||||
dmaxLevel?.takeIf { it != pokemon.dmaxLevel }?.let { return false }
|
||||
gmaxFactor?.takeIf { it != pokemon.gmaxFactor }?.let { return false }
|
||||
tradeable?.takeIf { it != pokemon.tradeable }?.let { return false }
|
||||
move1?.takeIf { move -> pokemon.moveSet.getMoves().none { it.name == move } }?.let { return false }
|
||||
move2?.takeIf { move -> pokemon.moveSet.getMoves().none { it.name == move } }?.let { return false }
|
||||
move3?.takeIf { move -> pokemon.moveSet.getMoves().none { it.name == move } }?.let { return false }
|
||||
move4?.takeIf { move -> pokemon.moveSet.getMoves().none { it.name == move } }?.let { return false }
|
||||
originalTrainer?.takeIf { it != pokemon.originalTrainer }?.let{ return false }
|
||||
originalTrainerType?.takeIf { it != pokemon.originalTrainerType }?.let{ return false }
|
||||
return customProperties.none { !it.matches(pokemon) }
|
||||
}
|
||||
|
||||
@@ -427,6 +511,12 @@ open class PokemonProperties {
|
||||
dmaxLevel?.takeIf { it != pokemonEntity.pokemon.dmaxLevel }?.let { return false }
|
||||
gmaxFactor?.takeIf { it != pokemonEntity.pokemon.gmaxFactor }?.let { return false }
|
||||
tradeable?.takeIf { it != pokemonEntity.pokemon.tradeable }?.let { return false }
|
||||
move1?.takeIf { move -> pokemonEntity.pokemon.moveSet.getMoves().none { it.name == move } }?.let { return false }
|
||||
move2?.takeIf { move -> pokemonEntity.pokemon.moveSet.getMoves().none { it.name == move } }?.let { return false }
|
||||
move3?.takeIf { move -> pokemonEntity.pokemon.moveSet.getMoves().none { it.name == move } }?.let { return false }
|
||||
move4?.takeIf { move -> pokemonEntity.pokemon.moveSet.getMoves().none { it.name == move } }?.let { return false }
|
||||
originalTrainer?.takeIf { it != pokemonEntity.pokemon.originalTrainer }?.let{ return false }
|
||||
originalTrainerType?.takeIf { it != pokemonEntity.pokemon.originalTrainerType }?.let{ return false }
|
||||
return customProperties.none { !it.matches(pokemonEntity) }
|
||||
}
|
||||
|
||||
@@ -471,13 +561,20 @@ open class PokemonProperties {
|
||||
dmaxLevel?.takeIf { it != properties.dmaxLevel }?.let { return false }
|
||||
gmaxFactor?.takeIf { it != properties.gmaxFactor }?.let { return false }
|
||||
tradeable?.takeIf { it != properties.tradeable }?.let { return false }
|
||||
move1?.takeIf { it != properties.move1 }?.let { return false }
|
||||
move2?.takeIf { it != properties.move2 }?.let { return false }
|
||||
move3?.takeIf { it != properties.move3 }?.let { return false }
|
||||
move4?.takeIf { it != properties.move4 }?.let { return false }
|
||||
originalTrainer?.takeIf { it != properties.originalTrainer }?.let{ return false }
|
||||
originalTrainerType?.takeIf { it != properties.originalTrainerType }?.let{ return false }
|
||||
return true
|
||||
}
|
||||
|
||||
fun create(): Pokemon {
|
||||
val pokemon = Pokemon()
|
||||
apply(pokemon)
|
||||
pokemon.initialize()
|
||||
if (move1 == null) //if there is not a move1 or later specific moves stated then initialize
|
||||
pokemon.initialize()
|
||||
roll(pokemon)
|
||||
return pokemon
|
||||
}
|
||||
@@ -518,6 +615,8 @@ open class PokemonProperties {
|
||||
dmaxLevel?.let { nbt.putInt(DataKeys.POKEMON_DMAX_LEVEL, it) }
|
||||
gmaxFactor?.let { nbt.putBoolean(DataKeys.POKEMON_GMAX_FACTOR, it) }
|
||||
tradeable?.let { nbt.putBoolean(DataKeys.POKEMON_TRADEABLE, it) }
|
||||
originalTrainerType?.let { nbt.putInt(DataKeys.POKEMON_ORIGINAL_TRAINER_TYPE, it.ordinal) }
|
||||
originalTrainer?.let { nbt.putString(DataKeys.POKEMON_ORIGINAL_TRAINER, it) }
|
||||
val custom = NbtList()
|
||||
customProperties.map { NbtString.of(it.asString()) }.forEach { custom.add(it) }
|
||||
nbt.put(DataKeys.POKEMON_PROPERTIES_CUSTOM, custom)
|
||||
@@ -543,6 +642,8 @@ open class PokemonProperties {
|
||||
dmaxLevel = if (tag.contains(DataKeys.POKEMON_DMAX_LEVEL)) tag.getInt(DataKeys.POKEMON_DMAX_LEVEL) else null
|
||||
gmaxFactor = if (tag.contains(DataKeys.POKEMON_GMAX_FACTOR)) tag.getBoolean(DataKeys.POKEMON_GMAX_FACTOR) else null
|
||||
tradeable = if (tag.contains(DataKeys.POKEMON_TRADEABLE)) tag.getBoolean(DataKeys.POKEMON_TRADEABLE) else null
|
||||
originalTrainerType = if (tag.contains(DataKeys.POKEMON_ORIGINAL_TRAINER_TYPE)) OriginalTrainerType.valueOf(tag.getString(DataKeys.POKEMON_ORIGINAL_TRAINER_TYPE)) else null
|
||||
originalTrainer = if (tag.contains(DataKeys.POKEMON_ORIGINAL_TRAINER)) tag.getString(DataKeys.POKEMON_ORIGINAL_TRAINER) else null
|
||||
val custom = tag.getList(DataKeys.POKEMON_PROPERTIES_CUSTOM, NbtElement.STRING_TYPE.toInt())
|
||||
// This is kinda gross
|
||||
custom.forEach { customProperties.addAll(parse(it.asString()).customProperties) }
|
||||
@@ -570,6 +671,8 @@ open class PokemonProperties {
|
||||
dmaxLevel?.let { json.addProperty(DataKeys.POKEMON_DMAX_LEVEL, it) }
|
||||
gmaxFactor?.let { json.addProperty(DataKeys.POKEMON_GMAX_FACTOR, it) }
|
||||
tradeable?.let { json.addProperty(DataKeys.POKEMON_TRADEABLE, it) }
|
||||
originalTrainerType?.let { json.addProperty(DataKeys.POKEMON_ORIGINAL_TRAINER_TYPE, it.name) }
|
||||
originalTrainer?.let { json.addProperty(DataKeys.POKEMON_ORIGINAL_TRAINER, it) }
|
||||
val custom = JsonArray()
|
||||
customProperties.map { it.asString() }.forEach { custom.add(it) }
|
||||
json.add(DataKeys.POKEMON_PROPERTIES_CUSTOM, custom)
|
||||
@@ -596,6 +699,8 @@ open class PokemonProperties {
|
||||
dmaxLevel = json.get(DataKeys.POKEMON_DMAX_LEVEL)?.asInt
|
||||
gmaxFactor = json.get(DataKeys.POKEMON_GMAX_FACTOR)?.asBoolean
|
||||
tradeable = json.get(DataKeys.POKEMON_TRADEABLE)?.asBoolean
|
||||
originalTrainerType = json.get(DataKeys.POKEMON_ORIGINAL_TRAINER_TYPE)?.asString?.let { OriginalTrainerType.valueOf(it) }
|
||||
originalTrainer = json.get(DataKeys.POKEMON_ORIGINAL_TRAINER)?.asString
|
||||
val custom = json.get(DataKeys.POKEMON_PROPERTIES_CUSTOM)?.asJsonArray
|
||||
// This is still kinda gross
|
||||
custom?.forEach { customProperties.addAll(parse(it.asString).customProperties) }
|
||||
@@ -626,10 +731,23 @@ open class PokemonProperties {
|
||||
dmaxLevel?.let { pieces.add("dmax_level=$it") }
|
||||
gmaxFactor?.let { pieces.add("gmax_factor=$it") }
|
||||
tradeable?.let { pieces.add("tradeable=$it") }
|
||||
originalTrainerType?.let { pieces.add("originaltrainertype=${it.name}") }
|
||||
originalTrainer?.let { pieces.add("originaltrainer=$it") }
|
||||
customProperties.forEach { pieces.add(it.asString()) }
|
||||
return pieces.joinToString(separator)
|
||||
}
|
||||
|
||||
fun asStruct(): VariableStruct {
|
||||
val struct = VariableStruct()
|
||||
species?.let { struct.setDirectly("species", StringValue(it)) }
|
||||
level?.let { struct.setDirectly("level", DoubleValue(it)) }
|
||||
shiny?.let { struct.setDirectly("shiny", DoubleValue(it)) }
|
||||
// add more of the optional properties to the struct as doubles or strings
|
||||
gender?.let { struct.setDirectly("gender", StringValue(it.name)) }
|
||||
friendship?.let { struct.setDirectly("friendship", DoubleValue(it)) }
|
||||
return struct
|
||||
}
|
||||
|
||||
fun updateAspects() {
|
||||
val aspects = mutableSetOf<String>()
|
||||
AspectProvider.providers.forEach { aspects.addAll(it.provide(this)) }
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.cobblemon.mod.common.api.pokemon.stats.Stats
|
||||
import com.cobblemon.mod.common.api.reactive.SimpleObservable
|
||||
import com.cobblemon.mod.common.api.spawning.TimeRange
|
||||
import com.cobblemon.mod.common.api.types.ElementalType
|
||||
import com.cobblemon.mod.common.api.types.ElementalTypes
|
||||
import com.cobblemon.mod.common.api.types.adapters.ElementalTypeAdapter
|
||||
import com.cobblemon.mod.common.net.messages.client.data.SpeciesRegistrySyncPacket
|
||||
import com.cobblemon.mod.common.pokemon.FormData
|
||||
@@ -61,6 +62,7 @@ import net.minecraft.server.network.ServerPlayerEntity
|
||||
import net.minecraft.util.Identifier
|
||||
import net.minecraft.util.math.Box
|
||||
import net.minecraft.world.biome.Biome
|
||||
import net.minecraft.world.gen.structure.Structure
|
||||
|
||||
object PokemonSpecies : JsonDataRegistry<Species> {
|
||||
|
||||
@@ -93,6 +95,7 @@ object PokemonSpecies : JsonDataRegistry<Species> {
|
||||
.registerTypeAdapter(TypeToken.getParameterized(RegistryLikeCondition::class.java, Biome::class.java).type, BiomeLikeConditionAdapter)
|
||||
.registerTypeAdapter(TypeToken.getParameterized(RegistryLikeCondition::class.java, Block::class.java).type, BlockLikeConditionAdapter)
|
||||
.registerTypeAdapter(TypeToken.getParameterized(RegistryLikeCondition::class.java, Item::class.java).type, ItemLikeConditionAdapter)
|
||||
.registerTypeAdapter(TypeToken.getParameterized(RegistryLikeCondition::class.java, Structure::class.java).type, StructureLikeConditionAdapter)
|
||||
.registerTypeAdapter(EggGroup::class.java, EggGroupAdapter)
|
||||
.registerTypeAdapter(StatusEffect::class.java, RegistryElementAdapter<StatusEffect> { Registries.STATUS_EFFECT })
|
||||
.registerTypeAdapter(NbtItemPredicate::class.java, NbtItemPredicateAdapter)
|
||||
@@ -169,6 +172,9 @@ object PokemonSpecies : JsonDataRegistry<Species> {
|
||||
*/
|
||||
fun random(): Species = this.implemented.random()
|
||||
|
||||
// overloaded function to give random pokemon species of a certain type
|
||||
fun random(type: ElementalType): Species = this.implemented.filter { it.primaryType == type || it.secondaryType == type }.random()
|
||||
|
||||
override fun reload(data: Map<Identifier, Species>) {
|
||||
this.speciesByIdentifier.clear()
|
||||
this.implemented.clear()
|
||||
@@ -236,8 +242,8 @@ object PokemonSpecies : JsonDataRegistry<Species> {
|
||||
"spd" to (form?.baseStats?.get(Stats.SPECIAL_DEFENCE) ?: species.baseStats[Stats.SPECIAL_DEFENCE] ?: 1),
|
||||
"spe" to (form?.baseStats?.get(Stats.SPEED) ?: species.baseStats[Stats.SPEED] ?: 1)
|
||||
)
|
||||
val heightm = form?.height ?: species.height
|
||||
val weightkg = form?.weight ?: species.weight
|
||||
val heightm = (form?.height ?: species.height) / 10
|
||||
val weightkg = (form?.weight ?: species.weight) / 10
|
||||
// This is ugly, but we already have it hardcoded in the mod anyway
|
||||
val maxHP = if (species.showdownId() == "shedinja") 1 else null
|
||||
val canGigantamax: String? = if (form?.gigantamaxMove != null) form.gigantamaxMove.name else null
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.pokemon.effect
|
||||
|
||||
import com.cobblemon.mod.common.api.scheduling.after
|
||||
import com.cobblemon.mod.common.api.scheduling.ServerTaskTracker
|
||||
import com.cobblemon.mod.common.platform.events.PlatformEvents
|
||||
import com.cobblemon.mod.common.pokemon.activestate.ShoulderedState
|
||||
import com.cobblemon.mod.common.pokemon.effects.LightSourceEffect
|
||||
@@ -51,7 +51,7 @@ object ShoulderEffectRegistry {
|
||||
fun onEffectEnd(player: ServerPlayerEntity) {
|
||||
// Do this next tick so the client syncs correctly.
|
||||
// While it is a ticks worth of downtime it's still 1/20th of a second, doubt they'll notice.
|
||||
after(1, serverThread = true) { this.refreshEffects(player) }
|
||||
ServerTaskTracker.momentarily { this.refreshEffects(player) }
|
||||
}
|
||||
|
||||
private fun refreshEffects(player: ServerPlayerEntity) {
|
||||
|
||||
-21
@@ -8,7 +8,6 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.reactive
|
||||
|
||||
import com.cobblemon.mod.common.api.scheduling.taskBuilder
|
||||
class ObservableSubscription<T>(
|
||||
private val observable: Observable<T>,
|
||||
private val handler: (T) -> Unit
|
||||
@@ -19,24 +18,4 @@ class ObservableSubscription<T>(
|
||||
observable.unsubscribe(this)
|
||||
alive = false
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules a task for every [checkInterval] seconds which checks the given [condition], and if it is
|
||||
* true it unsubscribes this [ObservableSubscription]. This exists predominantly for performance reasons,
|
||||
* as releasing subscriptions when they are no longer necessary should be done as soon as possible to allow
|
||||
* objects to be released.
|
||||
*/
|
||||
fun unsubscribeWhen(checkInterval: Float = 5F, condition: () -> Boolean): ObservableSubscription<T> {
|
||||
// Maybe there should just be 1 task that has a list of the conditions and observables to check, I dunno what's better - Hiro
|
||||
taskBuilder()
|
||||
.interval(checkInterval)
|
||||
.execute {
|
||||
if (!alive || condition()) {
|
||||
unsubscribe()
|
||||
it.expire()
|
||||
}
|
||||
}
|
||||
.build()
|
||||
return this
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.scheduling
|
||||
|
||||
/**
|
||||
* An interface for which an implementation must provide a [SchedulingTracker] so that the standard scheduling
|
||||
* functions can be executed.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since November 5th, 2023
|
||||
*/
|
||||
interface Schedulable {
|
||||
val schedulingTracker: SchedulingTracker
|
||||
|
||||
fun momentarily(action: () -> Unit): ScheduledTask = after(action = action)
|
||||
fun after(seconds: Float = 0F, action: () -> Unit): ScheduledTask {
|
||||
return schedulingTracker.addTask(
|
||||
ScheduledTask(
|
||||
action = { action() },
|
||||
delaySeconds = seconds
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun lerp(seconds: Float = 0F, action: (Float) -> Unit): ScheduledTask {
|
||||
var passed = 0F
|
||||
if (seconds == 0F) {
|
||||
action(1F)
|
||||
return ScheduledTask.BLANK
|
||||
}
|
||||
action(passed / seconds)
|
||||
return if (passed / seconds != 1F) {
|
||||
taskBuilder().tracker(schedulingTracker).interval(0F).iterations(-1).execute { task ->
|
||||
passed = task.secondsPassed
|
||||
if (passed > seconds) {
|
||||
passed = seconds
|
||||
}
|
||||
val ratio = passed / seconds
|
||||
action(ratio)
|
||||
if (passed >= seconds) {
|
||||
task.expire()
|
||||
}
|
||||
}.build()
|
||||
} else {
|
||||
ScheduledTask.BLANK
|
||||
}
|
||||
}
|
||||
|
||||
fun taskBuilder(): ScheduledTask.Builder = ScheduledTask.Builder().tracker(schedulingTracker)
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.scheduling
|
||||
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import kotlin.math.max
|
||||
|
||||
/**
|
||||
@@ -29,6 +30,11 @@ class ScheduledTask(
|
||||
/** The number of times this task should iterate. */
|
||||
val iterations: Int = 1
|
||||
) {
|
||||
companion object {
|
||||
val BLANK = ScheduledTask({}, delaySeconds = 0F)
|
||||
}
|
||||
val future = CompletableFuture<Unit>()
|
||||
var secondsPassed = 0F
|
||||
var currentIteration: Int = 0
|
||||
private set
|
||||
var secondsRemaining: Float = 0F
|
||||
@@ -38,13 +44,8 @@ class ScheduledTask(
|
||||
var paused = false
|
||||
set(value) {
|
||||
field = value
|
||||
if (!value) {
|
||||
lastExecutedTime = System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
|
||||
var lastExecutedTime = System.currentTimeMillis()
|
||||
|
||||
init {
|
||||
if (delaySeconds > 0) {
|
||||
secondsRemaining = delaySeconds
|
||||
@@ -55,13 +56,10 @@ class ScheduledTask(
|
||||
return identifier?.let { "Task-$it" } ?: super.toString()
|
||||
}
|
||||
|
||||
fun update() {
|
||||
val now = System.currentTimeMillis()
|
||||
val passed = now - lastExecutedTime
|
||||
lastExecutedTime = now
|
||||
|
||||
fun update(deltaSeconds: Float) {
|
||||
if (!expired && !paused) {
|
||||
secondsRemaining = max(0F, secondsRemaining - passed / 1000F)
|
||||
secondsPassed += deltaSeconds
|
||||
secondsRemaining = max(0F, secondsRemaining - deltaSeconds)
|
||||
if (secondsRemaining == 0F) {
|
||||
action(this)
|
||||
currentIteration++
|
||||
@@ -76,6 +74,7 @@ class ScheduledTask(
|
||||
|
||||
fun expire() {
|
||||
this.expired = true
|
||||
future.complete(Unit)
|
||||
}
|
||||
|
||||
class Builder {
|
||||
@@ -91,7 +90,9 @@ class ScheduledTask(
|
||||
private var iterations: Int = 1
|
||||
|
||||
private var identifier: String? = null
|
||||
|
||||
|
||||
private var tracker: SchedulingTracker? = null
|
||||
|
||||
fun identifier(identifier: String): Builder {
|
||||
this.identifier = identifier
|
||||
return this
|
||||
@@ -156,6 +157,11 @@ class ScheduledTask(
|
||||
return iterations(-1)
|
||||
}
|
||||
|
||||
fun tracker(schedulingTracker: SchedulingTracker): Builder {
|
||||
this.tracker = schedulingTracker
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the task using the properties of the task builder.
|
||||
* This will add the task to [TaskTickListener].
|
||||
@@ -172,7 +178,7 @@ class ScheduledTask(
|
||||
intervalSeconds = interval,
|
||||
iterations = iterations
|
||||
)
|
||||
ScheduledTaskTracker.addTask(task)
|
||||
(tracker ?: ServerTaskTracker).addTask(task)
|
||||
return task
|
||||
}
|
||||
}
|
||||
|
||||
+20
-15
@@ -8,23 +8,28 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.scheduling
|
||||
|
||||
object ScheduledTaskTracker {
|
||||
private val tasks = mutableListOf<ScheduledTask>()
|
||||
|
||||
fun clear() {
|
||||
tasks.clear()
|
||||
}
|
||||
/**
|
||||
* More precise than the [ServerTaskTracker], still runs on the server, and uses epoch time deltas for
|
||||
* the scheduling delta so that it is working by real time and not by ticks. This is useful for some
|
||||
* applications but is generally not what you want.
|
||||
*/
|
||||
object ServerRealTimeTaskTracker : Schedulable, SchedulingTracker() {
|
||||
override val schedulingTracker = this
|
||||
var lastTicked = System.currentTimeMillis()
|
||||
|
||||
fun update() {
|
||||
for (task in tasks.toList()) {
|
||||
task.update()
|
||||
if (task.expired) {
|
||||
tasks.remove(task)
|
||||
}
|
||||
}
|
||||
val now = System.currentTimeMillis()
|
||||
val delta = now - lastTicked
|
||||
lastTicked = now
|
||||
update(delta / 1000F)
|
||||
}
|
||||
}
|
||||
|
||||
fun addTask(task: ScheduledTask) {
|
||||
tasks.add(task)
|
||||
}
|
||||
|
||||
object ServerTaskTracker: Schedulable, SchedulingTracker() {
|
||||
override val schedulingTracker = this
|
||||
}
|
||||
|
||||
object ClientTaskTracker : Schedulable, SchedulingTracker() {
|
||||
override val schedulingTracker = this
|
||||
}
|
||||
+15
-33
@@ -8,45 +8,27 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.scheduling
|
||||
|
||||
import com.cobblemon.mod.common.util.runOnServer
|
||||
|
||||
@Deprecated("Use afterOnServer or afterOnClient; ambiguous side is not good for your health")
|
||||
@JvmOverloads
|
||||
fun after(ticks: Int = 0, seconds: Float = 0F, serverThread: Boolean = false, action: () -> Unit) {
|
||||
ScheduledTaskTracker.addTask(
|
||||
ScheduledTask(
|
||||
action = { if (serverThread) runOnServer(action) else action() },
|
||||
delaySeconds = ticks / 20F + seconds
|
||||
)
|
||||
)
|
||||
val scheduler = if (serverThread) ServerTaskTracker else ClientTaskTracker
|
||||
scheduler.after(seconds = seconds + ticks / 20F, action)
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as [after] but the task is made to run on the main thread. This is for when the task
|
||||
* Delayed task is created to run on the main thread. This is for when the task
|
||||
* being completed after the delay does things like entity removal or other thread-unsafe actions.
|
||||
*/
|
||||
fun afterOnMain(ticks: Int = 0, seconds: Float = 0F, action: () -> Unit) = after(ticks, seconds, true, action)
|
||||
@JvmOverloads
|
||||
fun afterOnServer(ticks: Int = 0, seconds: Float = 0F, action: () -> Unit) = ServerTaskTracker.after(seconds + ticks / 20F, action)
|
||||
@JvmOverloads
|
||||
fun afterOnClient(ticks: Int = 0, seconds: Float, action: () -> Unit) = ClientTaskTracker.after(seconds + ticks / 20F, action)
|
||||
|
||||
@Deprecated("Use lerpOnServer or lerpOnClient, side-ambiguity causes problems now")
|
||||
fun lerp(seconds: Float = 0F, serverThread: Boolean = false, action: (Float) -> Unit) = (if (serverThread) ServerTaskTracker else ClientTaskTracker).lerp(seconds, action = action)
|
||||
|
||||
fun lerp(seconds: Float = 0F, serverThread: Boolean = false, action: (Float) -> Unit) {
|
||||
val startedTime = System.currentTimeMillis()
|
||||
var passed = 0F
|
||||
if (seconds == 0F) {
|
||||
if (serverThread) runOnServer { action(1F) } else action(1F)
|
||||
return
|
||||
}
|
||||
action(passed / seconds)
|
||||
if (passed / seconds != 1F) {
|
||||
taskBuilder().interval(0F).iterations(-1).execute { task ->
|
||||
passed = (System.currentTimeMillis() - startedTime)/1000F
|
||||
if (passed > seconds) {
|
||||
passed = seconds
|
||||
}
|
||||
val ratio = passed / seconds
|
||||
if (serverThread) runOnServer { action(ratio) } else action(ratio)
|
||||
if (passed >= seconds) {
|
||||
task.expire()
|
||||
}
|
||||
}.build()
|
||||
}
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun lerpOnServer(seconds: Float = 0F, action: (Float) -> Unit) = ServerTaskTracker.lerp(seconds = seconds, action = action)
|
||||
@JvmOverloads
|
||||
fun lerpOnClient(seconds: Float = 0F, action: (Float) -> Unit) = ClientTaskTracker.lerp(seconds = seconds, action = action)
|
||||
fun taskBuilder() = ScheduledTask.Builder()
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.scheduling
|
||||
|
||||
/**
|
||||
* A data block for scheduled tasks. This is to neatly contain the data for an
|
||||
* implementation of [Schedulable].
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since November 5th, 2023
|
||||
*/
|
||||
open class SchedulingTracker {
|
||||
private val tasks = mutableListOf<ScheduledTask>()
|
||||
|
||||
fun clear() {
|
||||
tasks.clear()
|
||||
}
|
||||
|
||||
fun update(deltaSeconds: Float) {
|
||||
for (task in tasks.toList()) {
|
||||
task.update(deltaSeconds)
|
||||
if (task.expired) {
|
||||
tasks.remove(task)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun addTask(task: ScheduledTask): ScheduledTask {
|
||||
tasks.add(task)
|
||||
return task
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -20,6 +20,7 @@ import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.Box
|
||||
import net.minecraft.util.math.ChunkSectionPos.getSectionCoord
|
||||
import net.minecraft.util.math.Vec3d
|
||||
import net.minecraft.world.LightType
|
||||
import net.minecraft.world.chunk.Chunk
|
||||
import net.minecraft.world.chunk.ChunkStatus
|
||||
|
||||
@@ -69,7 +70,7 @@ object CobblemonSpawningProspector : SpawningProspector {
|
||||
.map { it.pos }
|
||||
|
||||
val defaultState = Blocks.STONE.defaultState
|
||||
val defaultBlockData = WorldSlice.BlockData(defaultState, 0)
|
||||
val defaultBlockData = WorldSlice.BlockData(defaultState, 0, 0)
|
||||
|
||||
val blocks = Array(area.length) { Array(height) { Array(area.width) { defaultBlockData } } }
|
||||
val skyLevel = Array(area.length) { Array(area.width) { world.topY } }
|
||||
@@ -77,6 +78,7 @@ object CobblemonSpawningProspector : SpawningProspector {
|
||||
|
||||
val chunks = mutableMapOf<Pair<Int, Int>, Chunk?>()
|
||||
val yRange = (baseY until baseY + height).reversed()
|
||||
val lightingProvider = world.lightingProvider
|
||||
for (x in area.baseX until area.baseX + area.length) {
|
||||
for (z in area.baseZ until area.baseZ + area.width) {
|
||||
val query = chunks.computeIfAbsent(Pair(getSectionCoord(x), getSectionCoord(z))) {
|
||||
@@ -85,16 +87,16 @@ object CobblemonSpawningProspector : SpawningProspector {
|
||||
|
||||
var canSeeSky = world.isSkyVisibleAllowingSea(pos.set(x, yRange.first, z))
|
||||
for (y in yRange) {
|
||||
val skyLight = lightingProvider.get(LightType.SKY).getLightLevel(pos.set(x, y, z))
|
||||
val state = query.getBlockState(pos.set(x, y, z))
|
||||
blocks[x - area.baseX][y - baseY][z - area.baseZ] = WorldSlice.BlockData(
|
||||
state = state,
|
||||
light = world.getLightLevel(pos)
|
||||
light = world.getLightLevel(pos),
|
||||
skyLight = skyLight
|
||||
)
|
||||
|
||||
if (canSeeSky) {
|
||||
skyLevel[x - area.baseX][z - area.baseZ] = y
|
||||
}
|
||||
|
||||
if (state.fluidState.isEmpty && !state.isIn(CobblemonBlockTags.SEES_SKY)) {
|
||||
canSeeSky = false
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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.spawning
|
||||
|
||||
import com.bedrockk.molang.Expression
|
||||
import com.cobblemon.mod.common.api.data.JsonDataRegistry
|
||||
import com.cobblemon.mod.common.api.reactive.SimpleObservable
|
||||
import com.cobblemon.mod.common.api.spawning.condition.SpawningCondition
|
||||
import com.cobblemon.mod.common.api.spawning.influence.SpawningInfluence
|
||||
import com.cobblemon.mod.common.api.spawning.rules.SpawnRule
|
||||
import com.cobblemon.mod.common.api.spawning.rules.component.FilterRuleComponent
|
||||
import com.cobblemon.mod.common.api.spawning.rules.component.LocationRuleCalculator
|
||||
import com.cobblemon.mod.common.api.spawning.rules.component.SpawnRuleComponent
|
||||
import com.cobblemon.mod.common.api.spawning.rules.component.WeightTweakRuleComponent
|
||||
import com.cobblemon.mod.common.api.spawning.rules.selector.ConditionalSpawningContextSelector
|
||||
import com.cobblemon.mod.common.api.spawning.rules.selector.ExpressionSpawnDetailSelector
|
||||
import com.cobblemon.mod.common.api.spawning.rules.selector.ExpressionSpawningContextSelector
|
||||
import com.cobblemon.mod.common.api.spawning.rules.selector.SpawnDetailSelector
|
||||
import com.cobblemon.mod.common.api.spawning.rules.selector.SpawningContextSelector
|
||||
import com.cobblemon.mod.common.util.adapters.ExpressionAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.SpawnDetailSelectorAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.SpawnRuleComponentAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.SpawningConditionAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.SpawningContextSelectorAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.TextAdapter
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import net.minecraft.resource.ResourceType
|
||||
import net.minecraft.server.network.ServerPlayerEntity
|
||||
import net.minecraft.text.Text
|
||||
import net.minecraft.util.Identifier
|
||||
|
||||
/**
|
||||
* All of the [SpawnRule]s that will be applied as global [SpawningInfluence]s.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since September 30th, 2023
|
||||
*/
|
||||
object CobblemonSpawnRules : JsonDataRegistry<SpawnRule> {
|
||||
override val gson = GsonBuilder()
|
||||
.registerTypeAdapter(SpawnRuleComponent::class.java, SpawnRuleComponentAdapter)
|
||||
.registerTypeAdapter(SpawnDetailSelector::class.java, SpawnDetailSelectorAdapter)
|
||||
.registerTypeAdapter(SpawningContextSelector::class.java, SpawningContextSelectorAdapter)
|
||||
.registerTypeAdapter(SpawningCondition::class.java, SpawningConditionAdapter)
|
||||
.registerTypeAdapter(Expression::class.java, ExpressionAdapter)
|
||||
.registerTypeAdapter(Text::class.java, TextAdapter)
|
||||
.create()
|
||||
|
||||
override val typeToken = TypeToken.get(SpawnRule::class.java)
|
||||
override val resourcePath = "spawn_rules"
|
||||
|
||||
init {
|
||||
SpawnRuleComponent.register<WeightTweakRuleComponent>("weight")
|
||||
SpawnRuleComponent.register<FilterRuleComponent>("filter")
|
||||
SpawnRuleComponent.register<LocationRuleCalculator>("location")
|
||||
|
||||
SpawnDetailSelector.register<ExpressionSpawnDetailSelector>("expression")
|
||||
|
||||
SpawningContextSelector.register<ExpressionSpawningContextSelector>("expression")
|
||||
SpawningContextSelector.register<ConditionalSpawningContextSelector>("conditional")
|
||||
}
|
||||
|
||||
val rules = mutableMapOf<Identifier, SpawnRule>()
|
||||
|
||||
override fun reload(data: Map<Identifier, SpawnRule>) {
|
||||
rules.clear()
|
||||
rules.putAll(data)
|
||||
data.forEach { (id, value) -> value.id = id }
|
||||
observable.emit(this)
|
||||
}
|
||||
|
||||
override val id: Identifier = cobblemonResource("spawn_rules")
|
||||
override val type: ResourceType = ResourceType.SERVER_DATA
|
||||
override val observable = SimpleObservable<CobblemonSpawnRules>()
|
||||
|
||||
override fun sync(player: ServerPlayerEntity) {}
|
||||
}
|
||||
@@ -44,7 +44,8 @@ class WorldSlice(
|
||||
) {
|
||||
class BlockData(
|
||||
val state: BlockState,
|
||||
val light: Int
|
||||
val light: Int,
|
||||
val skyLight: Int
|
||||
)
|
||||
|
||||
val length = blocks.size
|
||||
@@ -83,6 +84,15 @@ class WorldSlice(
|
||||
}
|
||||
fun getLight(position: BlockPos, elseLight: Int = 0) = getLight(position.x, position.y, position.z, elseLight)
|
||||
|
||||
fun getSkyLight(x: Int, y: Int, z: Int, elseLight: Int = 0): Int {
|
||||
return if (!isInBounds(x, y, z)) {
|
||||
elseLight
|
||||
} else {
|
||||
getBlockData(x, y, z).skyLight
|
||||
}
|
||||
}
|
||||
fun getSkyLight(position: BlockPos, elseLight: Int = 0) = getSkyLight(position.x, position.y, position.z, elseLight)
|
||||
|
||||
fun skySpaceAbove(x: Int, y: Int, z: Int): Int {
|
||||
return if (!isInBounds(x, y, z) || skyLevel[x - baseX][z - baseZ] > y) {
|
||||
0
|
||||
|
||||
+1
-1
@@ -55,5 +55,5 @@ interface AppendageCondition {
|
||||
|
||||
fun getAppendages(spawningCondition: SpawningCondition<*>) = appendages.filter { it.spawningConditionFits(spawningCondition) }.map { it.clazz }
|
||||
}
|
||||
fun fits(ctx: SpawningContext, detail: SpawnDetail): Boolean
|
||||
fun fits(ctx: SpawningContext): Boolean
|
||||
}
|
||||
+2
-2
@@ -26,8 +26,8 @@ abstract class AreaTypeSpawningCondition<T : AreaSpawningContext> : SpawningCond
|
||||
var maxHeight: Int? = null
|
||||
var neededNearbyBlocks: MutableList<RegistryLikeCondition<Block>>? = null
|
||||
|
||||
override fun fits(ctx: T, detail: SpawnDetail): Boolean {
|
||||
if (!super.fits(ctx, detail)) {
|
||||
override fun fits(ctx: T): Boolean {
|
||||
if (!super.fits(ctx)) {
|
||||
return false
|
||||
} else if (minHeight != null && ctx.height < minHeight!!) {
|
||||
return false
|
||||
|
||||
+3
-3
@@ -30,11 +30,11 @@ class CompositeSpawningCondition {
|
||||
var conditions = mutableListOf<SpawningCondition<*>>()
|
||||
var anticonditions = mutableListOf<SpawningCondition<*>>()
|
||||
|
||||
fun satisfiedBy(ctx: SpawningContext, detail: SpawnDetail): Boolean {
|
||||
return if (conditions.isNotEmpty() && conditions.none { it.isSatisfiedBy(ctx, detail) }) {
|
||||
fun satisfiedBy(ctx: SpawningContext): Boolean {
|
||||
return if (conditions.isNotEmpty() && conditions.none { it.isSatisfiedBy(ctx) }) {
|
||||
false
|
||||
} else {
|
||||
!(anticonditions.isNotEmpty() && anticonditions.any { it.isSatisfiedBy(ctx, detail) })
|
||||
!(anticonditions.isNotEmpty() && anticonditions.any { it.isSatisfiedBy(ctx) })
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -24,8 +24,8 @@ import net.minecraft.block.Block
|
||||
abstract class GroundedTypeSpawningCondition<T : GroundedSpawningContext> : AreaTypeSpawningCondition<T>() {
|
||||
var neededBaseBlocks: MutableList<RegistryLikeCondition<Block>>? = null
|
||||
|
||||
override fun fits(ctx: T, detail: SpawnDetail): Boolean {
|
||||
return if (!super.fits(ctx, detail)) {
|
||||
override fun fits(ctx: T): Boolean {
|
||||
return if (!super.fits(ctx)) {
|
||||
false
|
||||
} else if (minHeight != null && ctx.height < minHeight!!) {
|
||||
return false
|
||||
|
||||
+10
-16
@@ -11,8 +11,6 @@ package com.cobblemon.mod.common.api.spawning.condition
|
||||
import com.cobblemon.mod.common.api.conditional.RegistryLikeCondition
|
||||
import com.cobblemon.mod.common.api.spawning.MoonPhaseRange
|
||||
import com.cobblemon.mod.common.api.spawning.TimeRange
|
||||
import com.cobblemon.mod.common.api.spawning.condition.ListCheckMode.ALL
|
||||
import com.cobblemon.mod.common.api.spawning.condition.ListCheckMode.ANY
|
||||
import com.cobblemon.mod.common.api.spawning.context.SpawningContext
|
||||
import com.cobblemon.mod.common.api.spawning.detail.SpawnDetail
|
||||
import com.cobblemon.mod.common.util.Merger
|
||||
@@ -52,11 +50,11 @@ abstract class SpawningCondition<T : SpawningContext> {
|
||||
var maxZ: Float? = null
|
||||
var minLight: Int? = null
|
||||
var maxLight: Int? = null
|
||||
var minSkyLight: Int? = null
|
||||
var maxSkyLight: Int? = null
|
||||
var isRaining: Boolean? = null
|
||||
var isThundering: Boolean? = null
|
||||
var timeRange: TimeRange? = null
|
||||
var labels: MutableList<String>? = null
|
||||
var labelMode = ANY
|
||||
var structures: MutableList<Either<Identifier, TagKey<Structure>>>? = null
|
||||
|
||||
@Transient
|
||||
@@ -65,15 +63,15 @@ abstract class SpawningCondition<T : SpawningContext> {
|
||||
abstract fun contextClass(): Class<out T>
|
||||
fun contextMatches(ctx: SpawningContext) = contextClass().isAssignableFrom(ctx::class.java)
|
||||
|
||||
fun isSatisfiedBy(ctx: SpawningContext, detail: SpawnDetail): Boolean {
|
||||
fun isSatisfiedBy(ctx: SpawningContext): Boolean {
|
||||
return if (contextMatches(ctx)) {
|
||||
fits(ctx as T, detail)
|
||||
fits(ctx as T)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun fits(ctx: T, detail: SpawnDetail): Boolean {
|
||||
protected open fun fits(ctx: T): Boolean {
|
||||
if (ctx.position.x < minX.orMin() || ctx.position.x > maxX.orMax()) {
|
||||
return false
|
||||
} else if (ctx.position.y < minY.orMin() || ctx.position.y > maxY.orMax()) {
|
||||
@@ -88,6 +86,8 @@ abstract class SpawningCondition<T : SpawningContext> {
|
||||
return false
|
||||
} else if (ctx.light > maxLight.orMax() || ctx.light < minLight.orMin()) {
|
||||
return false
|
||||
} else if (ctx.skyLight > maxSkyLight.orMax() || ctx.skyLight < minSkyLight.orMin()) {
|
||||
return false
|
||||
} else if (timeRange != null && !timeRange!!.contains((ctx.world.timeOfDay % 24000).toInt())) {
|
||||
return false
|
||||
} else if (canSeeSky != null && canSeeSky != ctx.canSeeSky) {
|
||||
@@ -96,14 +96,7 @@ abstract class SpawningCondition<T : SpawningContext> {
|
||||
return false
|
||||
} else if (isThundering != null && ctx.world.isThundering != isThundering!!) {
|
||||
return false
|
||||
} else if (labels != null && labels!!.isNotEmpty() &&
|
||||
(
|
||||
(labelMode == ANY && labels!!.none { it in detail.labels }) ||
|
||||
(labelMode == ALL && labels!!.any { it !in detail.labels })
|
||||
)
|
||||
) {
|
||||
return false
|
||||
} else if (appendages.any { !it.fits(ctx, detail) }) {
|
||||
} else if (appendages.any { !it.fits(ctx) }) {
|
||||
return false
|
||||
} else if (structures != null && structures!!.isNotEmpty() &&
|
||||
structures!!.let { structures ->
|
||||
@@ -123,7 +116,6 @@ abstract class SpawningCondition<T : SpawningContext> {
|
||||
open fun copyFrom(other: SpawningCondition<*>, merger: Merger) {
|
||||
dimensions = merger.merge(dimensions, other.dimensions)?.toMutableList()
|
||||
biomes = merger.merge(biomes, other.biomes)?.toMutableSet()
|
||||
labels = merger.merge(labels, other.labels)?.toMutableList()
|
||||
moonPhase = merger.mergeSingle(moonPhase, other.moonPhase)
|
||||
canSeeSky = merger.mergeSingle(canSeeSky, other.canSeeSky)
|
||||
minX = merger.mergeSingle(minX, other.minX)
|
||||
@@ -134,6 +126,8 @@ abstract class SpawningCondition<T : SpawningContext> {
|
||||
maxZ = merger.mergeSingle(maxZ, other.maxZ)
|
||||
minLight = merger.mergeSingle(minLight, other.minLight)
|
||||
maxLight = merger.mergeSingle(maxLight, other.maxLight)
|
||||
minSkyLight = merger.mergeSingle(minSkyLight, other.minSkyLight)
|
||||
maxSkyLight = merger.mergeSingle(maxSkyLight, other.maxSkyLight)
|
||||
timeRange = merger.mergeSingle(timeRange, other.timeRange)
|
||||
structures = merger.merge(structures, other.structures)?.toMutableList()
|
||||
}
|
||||
|
||||
+2
-2
@@ -27,8 +27,8 @@ abstract class SubmergedTypeSpawningCondition<T : SubmergedSpawningContext> : Ar
|
||||
var fluidIsSource: Boolean? = null
|
||||
var fluid: RegistryLikeCondition<Fluid>? = null
|
||||
|
||||
override fun fits(ctx: T, detail: SpawnDetail): Boolean {
|
||||
return if (!super.fits(ctx, detail)) {
|
||||
override fun fits(ctx: T): Boolean {
|
||||
return if (!super.fits(ctx)) {
|
||||
false
|
||||
} else if (minHeight != null && ctx.height < minHeight!!) {
|
||||
return false
|
||||
|
||||
+2
-2
@@ -26,8 +26,8 @@ abstract class SurfaceTypeSpawningCondition<T : SurfaceSpawningContext> : AreaTy
|
||||
var maxDepth: Int? = null
|
||||
var fluid: RegistryLikeCondition<Fluid>? = null
|
||||
|
||||
override fun fits(ctx: T, detail: SpawnDetail): Boolean {
|
||||
return if (!super.fits(ctx, detail)) {
|
||||
override fun fits(ctx: T): Boolean {
|
||||
return if (!super.fits(ctx)) {
|
||||
false
|
||||
} else if (minDepth != null && ctx.depth < minDepth!!) {
|
||||
false
|
||||
|
||||
+2
-1
@@ -49,7 +49,8 @@ interface AreaContextResolver {
|
||||
pos.set(x, y, z)
|
||||
val vec = pos.toVec3d()
|
||||
if (slice.nearbyEntityPositions.none { it.isInRange(vec, config.minimumDistanceBetweenEntities) && it != slice.cause.entity }) {
|
||||
val fittedContextCalculator = contextCalculators.firstOrNull { it.fits(input) }
|
||||
val fittedContextCalculator = contextCalculators
|
||||
.firstOrNull { calc -> calc.fits(input) && input.spawner.influences.none { !it.isAllowedPosition(input.world, input.position, calc) } }
|
||||
if (fittedContextCalculator != null) {
|
||||
val context = fittedContextCalculator.calculate(input)
|
||||
if (context != null) {
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ open class AreaSpawningContext(
|
||||
override val world: ServerWorld,
|
||||
override val position: BlockPos,
|
||||
override val light: Int,
|
||||
override val skyLight: Int,
|
||||
override val canSeeSky: Boolean,
|
||||
override val influences: MutableList<SpawningInfluence>,
|
||||
/** Space above. */
|
||||
|
||||
+10
-5
@@ -27,12 +27,13 @@ abstract class FlooredSpawningContext(
|
||||
world: ServerWorld,
|
||||
position: BlockPos,
|
||||
light: Int,
|
||||
skyLight: Int,
|
||||
canSeeSky: Boolean,
|
||||
influences: MutableList<SpawningInfluence>,
|
||||
height: Int,
|
||||
nearbyBlocks: List<BlockState>,
|
||||
slice: WorldSlice
|
||||
) : AreaSpawningContext(cause, world, position, light, canSeeSky, influences, height, nearbyBlocks, slice) {
|
||||
) : AreaSpawningContext(cause, world, position, light, skyLight, canSeeSky, influences, height, nearbyBlocks, slice) {
|
||||
/** The block that the spawning is occurring on. */
|
||||
val baseBlock = slice.getBlockState(position.x, position.y, position.z)
|
||||
}
|
||||
@@ -48,12 +49,13 @@ open class GroundedSpawningContext(
|
||||
world: ServerWorld,
|
||||
position: BlockPos,
|
||||
light: Int,
|
||||
skyLight: Int,
|
||||
canSeeSky: Boolean,
|
||||
influences: MutableList<SpawningInfluence>,
|
||||
height: Int,
|
||||
nearbyBlocks: List<BlockState>,
|
||||
slice: WorldSlice
|
||||
) : FlooredSpawningContext(cause, world, position, light, canSeeSky, influences, height, nearbyBlocks, slice)
|
||||
) : FlooredSpawningContext(cause, world, position, light, skyLight, canSeeSky, influences, height, nearbyBlocks, slice)
|
||||
|
||||
/**
|
||||
* A spawning context that occurs at the bottom of a body of water.
|
||||
@@ -66,12 +68,13 @@ open class SeafloorSpawningContext(
|
||||
world: ServerWorld,
|
||||
position: BlockPos,
|
||||
light: Int,
|
||||
skyLight: Int,
|
||||
canSeeSky: Boolean,
|
||||
influences: MutableList<SpawningInfluence>,
|
||||
height: Int,
|
||||
nearbyBlocks: List<BlockState>,
|
||||
slice: WorldSlice
|
||||
) : FlooredSpawningContext(cause, world, position, light, canSeeSky, influences, height, nearbyBlocks, slice) {
|
||||
) : FlooredSpawningContext(cause, world, position, light, skyLight, canSeeSky, influences, height, nearbyBlocks, slice) {
|
||||
override fun isSafeSpace(world: ServerWorld, pos: BlockPos, state: BlockState) = state.fluidState.isIn(FluidTags.WATER)
|
||||
}
|
||||
|
||||
@@ -86,12 +89,13 @@ open class LavafloorSpawningContext(
|
||||
world: ServerWorld,
|
||||
position: BlockPos,
|
||||
light: Int,
|
||||
skyLight: Int,
|
||||
canSeeSky: Boolean,
|
||||
influences: MutableList<SpawningInfluence>,
|
||||
height: Int,
|
||||
nearbyBlocks: List<BlockState>,
|
||||
slice: WorldSlice
|
||||
) : FlooredSpawningContext(cause, world, position, light, canSeeSky, influences, height, nearbyBlocks, slice) {
|
||||
) : FlooredSpawningContext(cause, world, position, light, skyLight, canSeeSky, influences, height, nearbyBlocks, slice) {
|
||||
override fun isSafeSpace(world: ServerWorld, pos: BlockPos, state: BlockState) = state.fluidState.isIn(FluidTags.LAVA)
|
||||
}
|
||||
|
||||
@@ -100,10 +104,11 @@ open class SurfaceSpawningContext(
|
||||
world: ServerWorld,
|
||||
position: BlockPos,
|
||||
light: Int,
|
||||
skyLight: Int,
|
||||
canSeeSky: Boolean,
|
||||
influences: MutableList<SpawningInfluence>,
|
||||
height: Int,
|
||||
val depth: Int,
|
||||
nearbyBlocks: List<BlockState>,
|
||||
slice: WorldSlice
|
||||
) : FlooredSpawningContext(cause, world, position, light, canSeeSky, influences, height, nearbyBlocks, slice)
|
||||
) : FlooredSpawningContext(cause, world, position, light, skyLight, canSeeSky, influences, height, nearbyBlocks, slice)
|
||||
+25
@@ -8,6 +8,9 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.spawning.context
|
||||
|
||||
import com.bedrockk.molang.runtime.struct.VariableStruct
|
||||
import com.bedrockk.molang.runtime.value.DoubleValue
|
||||
import com.cobblemon.mod.common.api.molang.ObjectValue
|
||||
import com.cobblemon.mod.common.api.spawning.SpawnCause
|
||||
import com.cobblemon.mod.common.api.spawning.condition.BasicSpawningCondition
|
||||
import com.cobblemon.mod.common.api.spawning.detail.SpawnDetail
|
||||
@@ -61,6 +64,8 @@ abstract class SpawningContext {
|
||||
abstract val position: BlockPos
|
||||
/** The light level at this location. */
|
||||
abstract val light: Int
|
||||
/** The sky light level at this location. (15 - The distance to the nearest block that would be illuminated by the sun */
|
||||
abstract val skyLight: Int
|
||||
/** Whether or not the sky is visible at this location. */
|
||||
abstract val canSeeSky: Boolean
|
||||
/** A list of [SpawningInfluence]s that apply due to this specific context. */
|
||||
@@ -80,6 +85,9 @@ abstract class SpawningContext {
|
||||
val biomeName: Identifier
|
||||
get() = this.biomeRegistry.getId(biome)!!
|
||||
|
||||
private val struct = VariableStruct()
|
||||
private var structCompiled = false
|
||||
|
||||
class StructureChunkCache {
|
||||
val missingTags = mutableSetOf<TagKey<Structure>>()
|
||||
val foundTags = mutableSetOf<TagKey<Structure>>()
|
||||
@@ -159,4 +167,21 @@ abstract class SpawningContext {
|
||||
}
|
||||
return weight
|
||||
}
|
||||
|
||||
fun getOrSetupStruct(): VariableStruct {
|
||||
if (structCompiled) {
|
||||
return struct
|
||||
}
|
||||
|
||||
struct.setDirectly("light", DoubleValue(light.toDouble()))
|
||||
struct.setDirectly("x", DoubleValue(position.x.toDouble()))
|
||||
struct.setDirectly("y", DoubleValue(position.y.toDouble()))
|
||||
struct.setDirectly("z", DoubleValue(position.z.toDouble()))
|
||||
struct.setDirectly("moon_phase", DoubleValue(moonPhase.toDouble()))
|
||||
struct.setDirectly("world", ObjectValue(world.registryManager.get(RegistryKeys.WORLD).getEntry(world)))
|
||||
struct.setDirectly("biome", ObjectValue(biomeRegistry.getEntry(biome)))
|
||||
|
||||
structCompiled = true
|
||||
return struct
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -26,13 +26,14 @@ open class SubmergedSpawningContext(
|
||||
world: ServerWorld,
|
||||
position: BlockPos,
|
||||
light: Int,
|
||||
skyLight: Int,
|
||||
canSeeSky: Boolean,
|
||||
influences: MutableList<SpawningInfluence>,
|
||||
height: Int,
|
||||
val depth: Int,
|
||||
nearbyBlocks: List<BlockState>,
|
||||
slice: WorldSlice
|
||||
) : AreaSpawningContext(cause, world, position, light, canSeeSky, influences, height, nearbyBlocks, slice) {
|
||||
) : AreaSpawningContext(cause, world, position, light, skyLight, canSeeSky, influences, height, nearbyBlocks, slice) {
|
||||
val fluid = slice.getBlockState(position.x, position.y, position.z).fluidState
|
||||
|
||||
override fun isSafeSpace(world: ServerWorld, pos: BlockPos, state: BlockState) = state.fluidState.fluid == fluid.fluid
|
||||
|
||||
+2
@@ -45,6 +45,8 @@ interface AreaSpawningContextCalculator<O : AreaSpawningContext> : SpawningConte
|
||||
= input.slice.horizontalSpace(input.position.x + offsetX, input.position.y + offsetY, input.position.z + offsetZ, condition, maximum)
|
||||
fun getLight(input: AreaSpawningInput, elseLight: Int = 0): Int
|
||||
= input.slice.getLight(input.position.x, input.position.y + 1, input.position.z, elseLight)
|
||||
fun getSkyLight(input: AreaSpawningInput, elseLight: Int = 0): Int
|
||||
= input.slice.getSkyLight(input.position.x, input.position.y + 1, input.position.z, elseLight)
|
||||
fun getCanSeeSky(input: AreaSpawningInput): Boolean = input.slice.canSeeSky(input.position.x, input.position.y + 1, input.position.z)
|
||||
fun getSkySpaceAbove(input: AreaSpawningInput): Int = input.slice.skySpaceAbove(input.position.x, input.position.y, input.position.z)
|
||||
fun getNearbyBlocks(
|
||||
|
||||
+8
@@ -50,6 +50,7 @@ interface FlooredSpawningContextCalculator<T : FlooredSpawningContext> : AreaSpa
|
||||
*/
|
||||
object GroundedSpawningContextCalculator : FlooredSpawningContextCalculator<GroundedSpawningContext> {
|
||||
// TODO expand base condition
|
||||
override val name = "grounded"
|
||||
override val baseCondition: (BlockState) -> Boolean = isSolidCondition
|
||||
override val surroundingCondition: (BlockState) -> Boolean = isAirCondition
|
||||
|
||||
@@ -59,6 +60,7 @@ object GroundedSpawningContextCalculator : FlooredSpawningContextCalculator<Grou
|
||||
world = input.world,
|
||||
position = input.position.toImmutable(),
|
||||
light = getLight(input),
|
||||
skyLight = getSkyLight(input),
|
||||
canSeeSky = getCanSeeSky(input),
|
||||
influences = input.spawner.copyInfluences(),
|
||||
height = getHeight(input, surroundingCondition, config.maxVerticalSpace, offsetY = 1),
|
||||
@@ -76,6 +78,7 @@ object GroundedSpawningContextCalculator : FlooredSpawningContextCalculator<Grou
|
||||
* @since February 7th, 2022
|
||||
*/
|
||||
object SeafloorSpawningContextCalculator : FlooredSpawningContextCalculator<SeafloorSpawningContext> {
|
||||
override val name = "seafloor"
|
||||
override val baseCondition: (BlockState) -> Boolean = isSolidCondition
|
||||
override val surroundingCondition: (BlockState) -> Boolean = isWaterCondition
|
||||
|
||||
@@ -85,6 +88,7 @@ object SeafloorSpawningContextCalculator : FlooredSpawningContextCalculator<Seaf
|
||||
world = input.world,
|
||||
position = input.position.toImmutable(),
|
||||
light = getLight(input),
|
||||
skyLight = getSkyLight(input),
|
||||
canSeeSky = getCanSeeSky(input),
|
||||
influences = input.spawner.copyInfluences(),
|
||||
height = getHeight(input, surroundingCondition, config.maxVerticalSpace, offsetY = 1),
|
||||
@@ -102,6 +106,7 @@ object SeafloorSpawningContextCalculator : FlooredSpawningContextCalculator<Seaf
|
||||
* @since February 7th, 2022
|
||||
*/
|
||||
object LavafloorSpawningContextCalculator : FlooredSpawningContextCalculator<LavafloorSpawningContext> {
|
||||
override val name = "lavafloor"
|
||||
override val baseCondition: (BlockState) -> Boolean = isSolidCondition
|
||||
override val surroundingCondition: (BlockState) -> Boolean = isLavaCondition
|
||||
|
||||
@@ -111,6 +116,7 @@ object LavafloorSpawningContextCalculator : FlooredSpawningContextCalculator<Lav
|
||||
world = input.world,
|
||||
position = input.position.toImmutable(),
|
||||
light = getLight(input),
|
||||
skyLight = getSkyLight(input),
|
||||
canSeeSky = getCanSeeSky(input),
|
||||
influences = input.spawner.copyInfluences(),
|
||||
height = getHeight(input, surroundingCondition, config.maxVerticalSpace, offsetY = 1),
|
||||
@@ -129,6 +135,7 @@ object LavafloorSpawningContextCalculator : FlooredSpawningContextCalculator<Lav
|
||||
* @since December 15th, 2022
|
||||
*/
|
||||
object SurfaceSpawningContextCalculator : FlooredSpawningContextCalculator<SurfaceSpawningContext> {
|
||||
override val name = "surface"
|
||||
override val baseCondition: (BlockState) -> Boolean = { !it.fluidState.isEmpty }
|
||||
override val surroundingCondition: (BlockState) -> Boolean = isAirCondition
|
||||
|
||||
@@ -138,6 +145,7 @@ object SurfaceSpawningContextCalculator : FlooredSpawningContextCalculator<Surfa
|
||||
world = input.world,
|
||||
position = input.position.toImmutable(),
|
||||
light = getLight(input),
|
||||
skyLight = getSkyLight(input),
|
||||
canSeeSky = getCanSeeSky(input),
|
||||
influences = input.spawner.copyInfluences(),
|
||||
height = getHeight(input, surroundingCondition, config.maxVerticalSpace / 2, offsetY = 1),
|
||||
|
||||
+2
@@ -48,6 +48,8 @@ interface SpawningContextCalculator<I : SpawningContextInput, O : SpawningContex
|
||||
}
|
||||
}
|
||||
|
||||
val name: String
|
||||
|
||||
/** Tries creating a [SpawningContext] from the given input. Returning null should be a last resort. */
|
||||
fun calculate(input: I): O?
|
||||
}
|
||||
|
||||
+2
@@ -23,6 +23,7 @@ import net.minecraft.util.math.MathHelper.ceil
|
||||
* @since February 7th, 2022
|
||||
*/
|
||||
object SubmergedSpawningContextCalculator : AreaSpawningContextCalculator<SubmergedSpawningContext> {
|
||||
override val name = "submerged"
|
||||
val fluidConditions = mutableListOf(
|
||||
isWaterCondition,
|
||||
isLavaCondition
|
||||
@@ -45,6 +46,7 @@ object SubmergedSpawningContextCalculator : AreaSpawningContextCalculator<Submer
|
||||
world = input.world,
|
||||
position = input.position.toImmutable(),
|
||||
light = getLight(input),
|
||||
skyLight = getSkyLight(input),
|
||||
canSeeSky = getCanSeeSky(input),
|
||||
influences = input.spawner.copyInfluences(),
|
||||
height = getHeight(input, fluidCondition, ceil(config.maxVerticalSpace / 2F)),
|
||||
|
||||
+4
-1
@@ -8,8 +8,8 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.spawning.detail
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon.LOGGER
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.Cobblemon.LOGGER
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonProperties
|
||||
import com.cobblemon.mod.common.api.spawning.context.SpawningContext
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
@@ -50,6 +50,9 @@ class PokemonSpawnAction(
|
||||
entity.pokemon.swapHeldItem(heldItem)
|
||||
}
|
||||
entity.drops = detail.drops
|
||||
// Useful debug code in situations where you want to find spawns
|
||||
// val fireworkRocketEntity = FireworkRocketEntity(ctx.world, ctx.position.x.toDouble(), ctx.position.y.toDouble() + 2, ctx.position.z.toDouble(), ItemStack(Items.FIREWORK_ROCKET))
|
||||
// ctx.world.spawnEntity(fireworkRocketEntity)
|
||||
return entity
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -69,7 +69,7 @@ class PokemonSpawnDetail : SpawnDetail() {
|
||||
}
|
||||
|
||||
override fun autoLabel() {
|
||||
super.autoLabel()
|
||||
val pokemonStruct = pokemon.asStruct()
|
||||
if (pokemon.species != null) {
|
||||
val species = PokemonSpecies.getByIdentifier(pokemon.species!!.asIdentifierDefaultingNamespace())
|
||||
if (species != null) {
|
||||
@@ -87,6 +87,9 @@ class PokemonSpawnDetail : SpawnDetail() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct.setDirectly("pokemon", pokemonStruct)
|
||||
super.autoLabel()
|
||||
}
|
||||
|
||||
fun getDerivedLevelRange() = levelRange.let { levelRange ->
|
||||
|
||||
Loaded 100 of 2314 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user