mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-11-22 08:08:53 -05:00
Compare commits
637
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d059978f7 | ||
|
|
1a619046fa | ||
|
|
665d2ec0b1 | ||
|
|
cca53f1d19 | ||
|
|
ecf4114f68 | ||
|
|
99e0a26d7b | ||
|
|
71753df513 | ||
|
|
729f080f6e | ||
|
|
13eb57afb1 | ||
|
|
72b6cb06ff | ||
|
|
74a57eb972 | ||
|
|
7246c7f8e6 | ||
|
|
cd05f741ae | ||
|
|
00222d929d | ||
|
|
b8f4637cb3 | ||
|
|
9f572250f5 | ||
|
|
0927d6fa43 | ||
|
|
a293b3d71f | ||
|
|
162b1cc68f | ||
|
|
67f906dec2 | ||
|
|
0570afbe05 | ||
|
|
dfba2d27ab | ||
|
|
9c7cd4b616 | ||
|
|
9fe0e9c87e | ||
|
|
bd0e5a44bd | ||
|
|
229ec4176b | ||
|
|
323413efdc | ||
|
|
a309cc2522 | ||
|
|
cb782a2aa1 | ||
|
|
2c58dcb8ef | ||
|
|
d91cd4322c | ||
|
|
e48e492392 | ||
|
|
1f93994eba | ||
|
|
5210121b3d | ||
|
|
7fa3bf24d1 | ||
|
|
1128d7edf3 | ||
|
|
eef50a7237 | ||
|
|
f4140a097d | ||
|
|
b79dbcca80 | ||
|
|
5ac12a897a | ||
|
|
ae5f7c83f2 | ||
|
|
f14de9ab58 | ||
|
|
8a1c846c2c | ||
|
|
459e7d3490 | ||
|
|
5a9be8944f | ||
|
|
3bb941b087 | ||
|
|
384b496d76 | ||
|
|
4caa736e0b | ||
|
|
c3e9051918 | ||
|
|
fe940caafc | ||
|
|
c9d148ec9c | ||
|
|
e611bf4a77 | ||
|
|
8093822140 | ||
|
|
f695ec15f9 | ||
|
|
1f6c791ce6 | ||
|
|
570805fdf1 | ||
|
|
ddecb08bc7 | ||
|
|
a1b930a21f | ||
|
|
7728ff3892 | ||
|
|
0b38e063d2 | ||
|
|
4d7cfcdf61 | ||
|
|
e56dd6ef64 | ||
|
|
236b98fa78 | ||
|
|
ac61e0d4d0 | ||
|
|
d8956fd66f | ||
|
|
ffe005511d | ||
|
|
1e634a20b8 | ||
|
|
50a5a78dd4 | ||
|
|
76c2654399 | ||
|
|
f9f4745e93 | ||
|
|
c700674289 | ||
|
|
c4f0032eee | ||
|
|
d92986016b | ||
|
|
ab57e01242 | ||
|
|
0da1c740a4 | ||
|
|
a7979aa80c | ||
|
|
397d3c618d | ||
|
|
066a6b56f7 | ||
|
|
29f6feab6c | ||
|
|
ea5d3ae40f | ||
|
|
59804a4e08 | ||
|
|
072c67acad | ||
|
|
60bbe221de | ||
|
|
5f06dc214b | ||
|
|
7687833add | ||
|
|
a6607e585b | ||
|
|
20584f4507 | ||
|
|
9660f1f724 | ||
|
|
c8cbace800 | ||
|
|
a616a24923 | ||
|
|
12035dd589 | ||
|
|
9627b80b01 | ||
|
|
4e9cecc854 | ||
|
|
9d4b19b185 | ||
|
|
aee96d06aa | ||
|
|
23e3c585f7 | ||
|
|
c22a88079f | ||
|
|
2225402082 | ||
|
|
9197207431 | ||
|
|
47c7f7079c | ||
|
|
eb0c1dddfd | ||
|
|
e3dbfe6ff8 | ||
|
|
fac207f36b | ||
|
|
379e794848 | ||
|
|
9081a4b131 | ||
|
|
dc6d75b8ee | ||
|
|
bb297a4448 | ||
|
|
a93922c438 | ||
|
|
f7d21c80d7 | ||
|
|
9248d26fd4 | ||
|
|
cb9ba82fcc | ||
|
|
b5ac54cd16 | ||
|
|
dc703e67f7 | ||
|
|
0930721865 | ||
|
|
644ff1772e | ||
|
|
3c7e0bebb6 | ||
|
|
0c0eea3876 | ||
|
|
5535140bb7 | ||
|
|
f9dd1448e5 | ||
|
|
ecf5d57ad2 | ||
|
|
8663888abc | ||
|
|
f452cd9a05 | ||
|
|
4fe9cd7fd6 | ||
|
|
9b0ca1c16b | ||
|
|
052ff59f57 | ||
|
|
40e5ef1c46 | ||
|
|
5025977d23 | ||
|
|
922006afe7 | ||
|
|
46cc7cb04d | ||
|
|
fa3e3bbb1b | ||
|
|
afbdcce337 | ||
|
|
2c1d11ed11 | ||
|
|
b88adf0479 | ||
|
|
b1066671f5 | ||
|
|
387e85d4ad | ||
|
|
1fa113f5ac | ||
|
|
77ab58d823 | ||
|
|
1a9e736d8b | ||
|
|
f680682f61 | ||
|
|
4d93d1244d | ||
|
|
6a7d5d2133 | ||
|
|
98397cd1da | ||
|
|
fc5a610394 | ||
|
|
504df5d998 | ||
|
|
3b4d3ebf50 | ||
|
|
aa39c1906e | ||
|
|
2e460e2ca2 | ||
|
|
a07ff7f442 | ||
|
|
5374569ea1 | ||
|
|
af9c1196bf | ||
|
|
09d5543469 | ||
|
|
49e4dd0298 | ||
|
|
c8e408c50a | ||
|
|
e8a0467643 | ||
|
|
2dd0b66b83 | ||
|
|
68374017e1 | ||
|
|
120520f51d | ||
|
|
e8dea9773a | ||
|
|
7b31e6bcc4 | ||
|
|
c6ffca639f | ||
|
|
c491a1f7ca | ||
|
|
0b333b743d | ||
|
|
95e79865e5 | ||
|
|
0e2860cd90 | ||
|
|
3259bf032c | ||
|
|
116205cdf1 | ||
|
|
43277d18dc | ||
|
|
86153419ee | ||
|
|
2b4d9c451c | ||
|
|
7f0e2fa9d8 | ||
|
|
e165095bd5 | ||
|
|
b8708d6e10 | ||
|
|
ef536390ca | ||
|
|
28befab173 | ||
|
|
c142439d5b | ||
|
|
1ca7335654 | ||
|
|
9197d9cdcd | ||
|
|
f75813e64d | ||
|
|
1f617c76a4 | ||
|
|
ebf573aa7a | ||
|
|
75363da470 | ||
|
|
cce4b932cc | ||
|
|
0973e1ced0 | ||
|
|
e7b5c84024 | ||
|
|
4001cc2a89 | ||
|
|
6e57d77d10 | ||
|
|
2206d96a6e | ||
|
|
33f05858f1 | ||
|
|
8443b88c16 | ||
|
|
a4f204a5a3 | ||
|
|
31b6be2164 | ||
|
|
0dbf73067b | ||
|
|
775703e1f5 | ||
|
|
bcdfef4886 | ||
|
|
a19adb463b | ||
|
|
b71208299f | ||
|
|
136b5824b0 | ||
|
|
5004edbbb6 | ||
|
|
d8bdd6329a | ||
|
|
82d56637a0 | ||
|
|
7232a43816 | ||
|
|
098eb7d14b | ||
|
|
835b70ed48 | ||
|
|
9d828a86fb | ||
|
|
910551ee70 | ||
|
|
9beee548d4 | ||
|
|
bacc482bf0 | ||
|
|
edb3f906f8 | ||
|
|
4171bf341b | ||
|
|
f9189b265f | ||
|
|
6f3894f27b | ||
|
|
bbc9a5e62e | ||
|
|
94765da04a | ||
|
|
8caa82f123 | ||
|
|
8e1fcc6f14 | ||
|
|
21c4d0233d | ||
|
|
2f87d53af6 | ||
|
|
131ef31492 | ||
|
|
b6b067b1d3 | ||
|
|
546f10eca7 | ||
|
|
542839ba69 | ||
|
|
efab1bba08 | ||
|
|
8f986bc326 | ||
|
|
e155d32aaf | ||
|
|
743e0b7d66 | ||
|
|
1518d703f9 | ||
|
|
af9d851d67 | ||
|
|
20ca91f1c9 | ||
|
|
6fb3c0e49a | ||
|
|
5cb4ff5f5f | ||
|
|
d035c08a5c | ||
|
|
fda7b13f50 | ||
|
|
fb4aaed220 | ||
|
|
c5e1b37ead | ||
|
|
2be9d303ea | ||
|
|
99ac6d213a | ||
|
|
f595724971 | ||
|
|
0511ba147b | ||
|
|
760f48d850 | ||
|
|
bf296b4921 | ||
|
|
6f4aae8b7d | ||
|
|
01e5e74e64 | ||
|
|
b6565a5dee | ||
|
|
49886389cf | ||
|
|
643bf9068b | ||
|
|
53f3258246 | ||
|
|
1e9895ec84 | ||
|
|
52dacb03ae | ||
|
|
85b0f3f393 | ||
|
|
a04a91bf24 | ||
|
|
5e814f7ab5 | ||
|
|
2780f491d6 | ||
|
|
2d3ec7aff1 | ||
|
|
cb7baf2696 | ||
|
|
5cc069df78 | ||
|
|
9222476c1f | ||
|
|
f220755f99 | ||
|
|
d55bbf237c | ||
|
|
83a9d44c3a | ||
|
|
c5a802eaf6 | ||
|
|
2e27875460 | ||
|
|
cd66887faa | ||
|
|
d665c87c21 | ||
|
|
044d3102b6 | ||
|
|
c421a93b06 | ||
|
|
2865aa2272 | ||
|
|
7c4aae3e9d | ||
|
|
d9f671f2a8 | ||
|
|
69733b530b | ||
|
|
d4471c30bc | ||
|
|
185f7e03f5 | ||
|
|
a45eb0eb21 | ||
|
|
ed67142379 | ||
|
|
13169c6848 | ||
|
|
8be134ee2f | ||
|
|
8c3206a413 | ||
|
|
4d4c071b95 | ||
|
|
b82c27754f | ||
|
|
63afec184e | ||
|
|
65699f045e | ||
|
|
61d53f3052 | ||
|
|
d02441a273 | ||
|
|
f76ab784b5 | ||
|
|
a566e36754 | ||
|
|
ef1479fde6 | ||
|
|
d6c7b271e4 | ||
|
|
df9acfa0d1 | ||
|
|
9d7fc8435e | ||
|
|
ab4492ac5c | ||
|
|
cb78dc8d88 | ||
|
|
020adabe26 | ||
|
|
08aca7a274 | ||
|
|
2a9ef2b9fe | ||
|
|
90dc489547 | ||
|
|
5ec5cfbc4a | ||
|
|
1ef65449a8 | ||
|
|
c6ff1ea72e | ||
|
|
cbfa8d3e78 | ||
|
|
5098ff3cfd | ||
|
|
7c32b07d3f | ||
|
|
b2142fed1d | ||
|
|
fef21516e9 | ||
|
|
6fba0f55c1 | ||
|
|
95d43de79f | ||
|
|
0be617b8ab | ||
|
|
c02d22f449 | ||
|
|
846b645856 | ||
|
|
25d93a771c | ||
|
|
f16c782336 | ||
|
|
ed0f315e41 | ||
|
|
d20b03f4c5 | ||
|
|
a3920413ac | ||
|
|
92bccf620f | ||
|
|
15f8a9ee71 | ||
|
|
dfb9ee755e | ||
|
|
68f4117e29 | ||
|
|
f74a24a056 | ||
|
|
e5750cbba0 | ||
|
|
c6482c82cd | ||
|
|
b4c23a9132 | ||
|
|
c470894bd3 | ||
|
|
a940e32f8d | ||
|
|
b6b59eccad | ||
|
|
b520b94fae | ||
|
|
9af99d16f7 | ||
|
|
2cc17d3280 | ||
|
|
20b2bcaa5a | ||
|
|
d1ada605fd | ||
|
|
d37f73626d | ||
|
|
73a94cb02e | ||
|
|
5a48945e50 | ||
|
|
476448a2ce | ||
|
|
bcba4f7fb7 | ||
|
|
20e9608ff3 | ||
|
|
3e5733ceaf | ||
|
|
af29c99b03 | ||
|
|
60d596a24f | ||
|
|
5a84b4b4b4 | ||
|
|
3f993e0466 | ||
|
|
9e3d22ee54 | ||
|
|
e86cb1981f | ||
|
|
e94f265adb | ||
|
|
b3fc35240a | ||
|
|
d74618bddb | ||
|
|
8b54a8d459 | ||
|
|
c17104a0fd | ||
|
|
88ca3ebbf3 | ||
|
|
4003456e5c | ||
|
|
1d21a52d28 | ||
|
|
2d49c62f85 | ||
|
|
20fac724f6 | ||
|
|
0807d73646 | ||
|
|
3013302f35 | ||
|
|
879e7bef21 | ||
|
|
557623dfe2 | ||
|
|
a28d1e176d | ||
|
|
f3c52db70d | ||
|
|
525575b0ba | ||
|
|
a55efeb378 | ||
|
|
da18b082a6 | ||
|
|
7511facebc | ||
|
|
1486f5cfc2 | ||
|
|
f8a16e5081 | ||
|
|
558e2d89ff | ||
|
|
ea7b688655 | ||
|
|
fdafa3435c | ||
|
|
f17c90f6ea | ||
|
|
1dc45669bb | ||
|
|
f3658614a4 | ||
|
|
cad39d8802 | ||
|
|
422f60f587 | ||
|
|
8190ddf0e9 | ||
|
|
af281d0bde | ||
|
|
00905b8c32 | ||
|
|
79b3cb8611 | ||
|
|
797e908621 | ||
|
|
3df3c395de | ||
|
|
b2f682ebb1 | ||
|
|
754e9bc158 | ||
|
|
2df8504139 | ||
|
|
2838f97c56 | ||
|
|
68c75deeeb | ||
|
|
4221993f7d | ||
|
|
3bc2659740 | ||
|
|
89bba8a67a | ||
|
|
cbd5cdaf92 | ||
|
|
5b9d5cbb55 | ||
|
|
6d6e13be83 | ||
|
|
899bec77b6 | ||
|
|
6dd8325772 | ||
|
|
e9bffd3ad7 | ||
|
|
ff890307c2 | ||
|
|
dda9d3e790 | ||
|
|
1acc02a2ec | ||
|
|
460c472c55 | ||
|
|
69c3b6142d | ||
|
|
9a036a4c01 | ||
|
|
0fbe206893 | ||
|
|
0dd1c01874 | ||
|
|
3cea6dd175 | ||
|
|
4ef2fe74d9 | ||
|
|
2fa053f833 | ||
|
|
ea4f858919 | ||
|
|
bc4383d21b | ||
|
|
16d1ba3a68 | ||
|
|
2aa4ab4b52 | ||
|
|
113977990e | ||
|
|
d86021e2a1 | ||
|
|
79faadef59 | ||
|
|
9b6629db7f | ||
|
|
d151a1ce65 | ||
|
|
d9ca7b483d | ||
|
|
aacf9e145d | ||
|
|
708f7fc1b8 | ||
|
|
621db85845 | ||
|
|
b09066c580 | ||
|
|
30a252d8e0 | ||
|
|
72ece5f9a4 | ||
|
|
d012f39baf | ||
|
|
c57a5bf260 | ||
|
|
6b1e59a6df | ||
|
|
7c45f28827 | ||
|
|
a4bbcdff1d | ||
|
|
a5c7d2df42 | ||
|
|
544b9e3bf1 | ||
|
|
9c1b2cae22 | ||
|
|
16b2f81bd4 | ||
|
|
a616c25c8c | ||
|
|
6ce4bf5673 | ||
|
|
1b652ba99f | ||
|
|
1969af65b9 | ||
|
|
3bd3ce5688 | ||
|
|
108f0e3d88 | ||
|
|
4344c127eb | ||
|
|
881a87216b | ||
|
|
1d473b82af | ||
|
|
1f1e3186b0 | ||
|
|
66da3aaba2 | ||
|
|
718bfdf82b | ||
|
|
01588b069a | ||
|
|
a3522ab5b8 | ||
|
|
f56b202610 | ||
|
|
038a15d9dd | ||
|
|
0a601d8a36 | ||
|
|
6e0c005587 | ||
|
|
b8433b5131 | ||
|
|
77a654dc3a | ||
|
|
5955547c6f | ||
|
|
7a3a1cb8de | ||
|
|
1674cb0913 | ||
|
|
152ce4e923 | ||
|
|
3a6d024217 | ||
|
|
3b722068b0 | ||
|
|
f2fcc5ba79 | ||
|
|
db0fb8e287 | ||
|
|
11b59df386 | ||
|
|
dae36a67d1 | ||
|
|
6f99862288 | ||
|
|
0377747e1e | ||
|
|
6bc974f90f | ||
|
|
aca53de259 | ||
|
|
41bde38727 | ||
|
|
ac2b068bf3 | ||
|
|
8e8f346e52 | ||
|
|
a4b7ee3b38 | ||
|
|
b426df7271 | ||
|
|
154b653c57 | ||
|
|
1543e06a06 | ||
|
|
d7b4ccb1e5 | ||
|
|
dedd449329 | ||
|
|
38c589658f | ||
|
|
04489bc969 | ||
|
|
25499b3e7a | ||
|
|
2f961bd7bf | ||
|
|
bb6bda54dc | ||
|
|
9f3dbdc2d8 | ||
|
|
b72244a986 | ||
|
|
6710f25190 | ||
|
|
4089e5d7a9 | ||
|
|
932148338c | ||
|
|
0a49b5b17b | ||
|
|
34c40de429 | ||
|
|
6d02144401 | ||
|
|
561687ce0f | ||
|
|
e0d0c38232 | ||
|
|
20973c6724 | ||
|
|
bf10a4dcef | ||
|
|
309f674853 | ||
|
|
dc705c7720 | ||
|
|
565987a780 | ||
|
|
4f9a6c8e98 | ||
|
|
3a3e92d441 | ||
|
|
bc0dc809f9 | ||
|
|
92310847aa | ||
|
|
5bdc59830c | ||
|
|
17f524d3da | ||
|
|
4d0de2bb45 | ||
|
|
b3b8f56bb8 | ||
|
|
f036b83693 | ||
|
|
73fb31c2fc | ||
|
|
9bfc577444 | ||
|
|
381787f39d | ||
|
|
217d4cda42 | ||
|
|
08daa43aae | ||
|
|
184d889831 | ||
|
|
c6e0f431ae | ||
|
|
93daeab840 | ||
|
|
f132b297c6 | ||
|
|
905d63e098 | ||
|
|
1ea8ab7dcc | ||
|
|
a45d21b279 | ||
|
|
3ca6d350fe | ||
|
|
2997ce8457 | ||
|
|
ff279d8310 | ||
|
|
91d6fb62ba | ||
|
|
8f4a5b2015 | ||
|
|
07604c9a3b | ||
|
|
c0a524a718 | ||
|
|
efe8f34413 | ||
|
|
6bb23582c4 | ||
|
|
56ccb43997 | ||
|
|
f445c05333 | ||
|
|
a62485fc1f | ||
|
|
044f3080ff | ||
|
|
28b0cab906 | ||
|
|
82f34d651c | ||
|
|
5fbbcb5707 | ||
|
|
92b0ef84e9 | ||
|
|
dc8d18384c | ||
|
|
44c056ecd5 | ||
|
|
dcc707c20d | ||
|
|
580a24eac3 | ||
|
|
07b1b22c2c | ||
|
|
23078eccba | ||
|
|
8a82f35edf | ||
|
|
bec664c073 | ||
|
|
3e61424d8f | ||
|
|
c1606c6fc9 | ||
|
|
e0108cc99f | ||
|
|
c0de8a2591 | ||
|
|
b8733eed52 | ||
|
|
4aa30efec7 | ||
|
|
2cb942a24b | ||
|
|
c79cb5731e | ||
|
|
4760bb15a4 | ||
|
|
aac881f23c | ||
|
|
da19c51566 | ||
|
|
7930ec52fa | ||
|
|
57eb306e4f | ||
|
|
bd0511a9fb | ||
|
|
c14f3292aa | ||
|
|
37dd354155 | ||
|
|
8fb2b1cf3d | ||
|
|
5c7d1cbe10 | ||
|
|
3348bfc362 | ||
|
|
acb1ebda19 | ||
|
|
5dddc05626 | ||
|
|
99890671bd | ||
|
|
9451ac5f46 | ||
|
|
8db9252434 | ||
|
|
d9d4fe15cc | ||
|
|
8453e2d514 | ||
|
|
4d3070c0c2 | ||
|
|
15f273a9ef | ||
|
|
007c079cd6 | ||
|
|
9851b1e8ad | ||
|
|
a8e4e21ba1 | ||
|
|
f555ba3703 | ||
|
|
c65c2610cd | ||
|
|
2be08a3fcc | ||
|
|
37677b3730 | ||
|
|
2a298b2268 | ||
|
|
ad3f94fb80 | ||
|
|
719660798e | ||
|
|
8d973a09e1 | ||
|
|
3579a86cde | ||
|
|
ba96a6a205 | ||
|
|
f07d2a9a9a | ||
|
|
2469067fd4 | ||
|
|
4cdf440eee | ||
|
|
1545ee8fc2 | ||
|
|
a009fabfe4 | ||
|
|
46e4bfdd13 | ||
|
|
e24c82860d | ||
|
|
1291dee1e1 | ||
|
|
69732be09b | ||
|
|
8ce4ed7dee | ||
|
|
33d3cc0104 | ||
|
|
33b6b519ed | ||
|
|
5ec849f4e3 | ||
|
|
6f4a2d2cd5 | ||
|
|
0bca89e77d | ||
|
|
8f9f162011 | ||
|
|
ac3bea3d5e | ||
|
|
178d4f199b | ||
|
|
933819380d | ||
|
|
d68131e1b9 | ||
|
|
ffbc379c0b | ||
|
|
7053d12508 | ||
|
|
d41442200f | ||
|
|
d2564c343e | ||
|
|
d1c19e8837 | ||
|
|
0ec3bfabad | ||
|
|
43ffb04621 | ||
|
|
eeaedf76a9 | ||
|
|
120fb4829a | ||
|
|
12b93e53a7 | ||
|
|
00b17b9764 | ||
|
|
06192f809d | ||
|
|
d09eb0d3ff | ||
|
|
416321679c | ||
|
|
72c4e6e54f | ||
|
|
d3738e3424 | ||
|
|
2e183db903 | ||
|
|
fa174b88dd | ||
|
|
0b4abe6d16 | ||
|
|
759fb0ecd8 | ||
|
|
429e927c3f | ||
|
|
643aed9133 | ||
|
|
e701642de2 | ||
|
|
a3a03e3da6 | ||
|
|
5dd3d5b552 | ||
|
|
1bae246e6c | ||
|
|
c94ef10189 | ||
|
|
dfacf1f9df | ||
|
|
06c5e34f48 | ||
|
|
1ab8b35e98 | ||
|
|
261b61ee6c | ||
|
|
5abf8e1bab | ||
|
|
7c0b463637 | ||
|
|
e156ab2432 | ||
|
|
0b46a7163b | ||
|
|
21b76c008a | ||
|
|
b7e9f8248d | ||
|
|
8b21e76a36 | ||
|
|
515471185f | ||
|
|
628e8f4e5e |
No files matched your search
+14
-86
@@ -1,101 +1,29 @@
|
||||
# Changelog
|
||||
## [1.8.2 (MONTH xth, 2026)](#1-8-2)
|
||||
## [1.8.5 (MONTH xth, 2026)](#1-8-5)
|
||||
|
||||
### Additions
|
||||
- The following items can now be placed on the ground as blocks:
|
||||
- King's Rock, Galarica Cuff, Unremarkable Teacup, Masterpiece Teacup, Chipped Pot, Cracked Pot, Sachet, Metal Powder, Quick Powder, Bright Powder, Icy Rock, Heat Rock, Smooth Rock, Damp Rock, Destiny Knot, Luminous Moss, Never-Melt Ice, Wide Lens, Scope Lens, and Zoom Lens.
|
||||
- Iron Ball, Metal Coat, Throat Spray, HP Up, Protein, Iron, Carbos, Calcium, Zinc, PP Up, PP Max, Upgrade, Dubious Disc, and Loaded Dice.
|
||||
- The following items can now be placed on various surfaces:
|
||||
- Galarica Wreath, Magnet, Flame Orb, Life Orb, Toxic Orb, Light Ball, and Smoke Ball.
|
||||
- The following items can now be placed as blocks and have additional functionality:
|
||||
- Ring Target, Metronome, and Eject Button.
|
||||
- The following items can now be worn by Players and Pokémon:
|
||||
- Galarica Wreath, Cleanse Tag, Spell Tag, Sharp Beak, Covert Cloak, Shell Helmet, and Never-Melt Ice.
|
||||
- Wearable items can now be equipped by a player by holding it and right-clicking (or rebound use/interact)
|
||||
- Wearable items that can be placed down are exempt from this behaviour.
|
||||
|
||||
### Pokémon Added
|
||||
#### Generation 4
|
||||
- Snover
|
||||
- Abomasnow
|
||||
- Burmy
|
||||
- Wormadam
|
||||
- Mothim
|
||||
|
||||
#### Generation 5
|
||||
- Tympole
|
||||
- Palpitoad
|
||||
- Seismitoad
|
||||
|
||||
#### Generation 6
|
||||
- Helioptile
|
||||
- Heliolisk
|
||||
|
||||
#### Generation 7
|
||||
- Grubbin
|
||||
- Charjabug
|
||||
- Vikavolt
|
||||
|
||||
#### Generation 9
|
||||
- Greavard
|
||||
- Houndstone
|
||||
|
||||
### Model updates for the following Pokémon
|
||||
- Cacnea
|
||||
- Cacturne
|
||||
- Binacle
|
||||
- Barbaracle
|
||||
- Glimmet
|
||||
- Glimmora
|
||||
- Deerling
|
||||
- Sawsbuck (All forms)
|
||||
- Absol
|
||||
|
||||
### Animation updates for the following Pokémon
|
||||
- Cacnea
|
||||
- Cacturne
|
||||
- Added the `healersSetSpawn` gamerule. When enabled, using a healing machine will set your spawnpoint.
|
||||
- A Pokémon holding a Power item now gains 1 point in the corresponding riding stat every two minutes while being ridden. The interval is configurable, and can be disabled with `-1`.
|
||||
- Added sounds to Gigaton Hammer and Pyro Ball
|
||||
- Added stepsounds to Venusaur, Blastoise, Dewgong, Rhydon, Rhyhorn, Parasect and Mr. Mime.
|
||||
|
||||
### Changes
|
||||
- Updated various recipes to display in Recipe Groups within the Recipe Book
|
||||
- Updated most recipes to display more logically/consistently within the Recipe Book's categories
|
||||
- Make ride rotations less jittery in multiplayer.
|
||||
- Changes tm shelf discs to use textures instead of tinting and overlays to line up with item display
|
||||
- Blank TM can now be inserted into the Disc Shelf
|
||||
- Amethyst now grows from Typegem core blocks like typegems do
|
||||
- Updated the recipe category for the Create compatibility EXP Candy recipe
|
||||
- Added No Man's Lands' Honeyed Apple to the Leaves Leftovers tag
|
||||
|
||||
### Fixes
|
||||
- Correctly grants "They're Minerals!" advancement when planting a type gem
|
||||
- Type Gem Blocks now have advancements to give you the recipe in the recipe book (the data for the advancements were inside the recipes somehow??)
|
||||
- Some other recipes without advancements have also been corrected
|
||||
- Corrected the TM Recipes for Charge Beam and Payday
|
||||
- Type Gem blocks now properly generate clusters off of the block.
|
||||
- Starter Screen Categories will no longer stop rendering if they are bigger than the viewport, and you are not viewing top or bottom edges
|
||||
- Random Starter option now properly handled in height calculation, so now it won't run off into other categories or be un-accessible due to scroll limits if it causes a new row
|
||||
- Mochi and Feathers no longer drop glass bottles on use
|
||||
- Fixed a rare set of concurrency bugs related to reloading packs on NeoForge; fixes a ModernFix issue
|
||||
- Removed unnecessary conditions for Mimikyu's standing pose. Hopefully fixes the rare instance of it using its shoulder animations during battle in multiplayer scenarios.
|
||||
- Fixed Rockruff line not blinking
|
||||
- Fixed Flygon sometimes using its running animation instead of walking
|
||||
- Fixed Bramblin always sleeping outside of battle
|
||||
- Fixed Dragonair using its battle idle as a normal idle
|
||||
- Fixed Lycanroc's head movement
|
||||
- Added head movement to Archaludon
|
||||
- Fixed Duraludon line not having any sleep animations
|
||||
- Fixed Diglett line not having their faint animations
|
||||
- Fixed Kingambit moving its legs while walking
|
||||
- Various Structure fixes
|
||||
- Fixed shiny pokemon under certain circumstances forgetting taught TMs
|
||||
- Fixed Ponigiri food values for AppleSkin integration
|
||||
- Fixed errors emitted by typos in Parched Peat bog structure files
|
||||
|
||||
### Developer
|
||||
- Fixed wrong order of operations in the code flow prior to the `FOSSIL_REVIVED` event causing pokemon to appear without entity link
|
||||
- Fixed TestPartySlot command not correctly comparing the provided spec with the target Pokémon
|
||||
|
||||
### Molang & Datapacks
|
||||
- A new `negate` variant for evolution requirements has been added, which will negate (invert) the provided inner condition.
|
||||
- Added Molang functions for individual Pokédex ids, wherein a subdex is passed in as a string to `dex_caught_count` etc.
|
||||
- `q.is_standing_on_blocks` now properly checks for non-full blocks like slabs, Mud or Soul Sand
|
||||
- Added Molang functions to play footstep sounds based on the corresponding surface. These are intended to be used by Pokémon animations.
|
||||
- Pokémon can now have their Minecraft footstep sounds silenced in their poser. This doesn't affect emitting game events.
|
||||
|
||||
### Particles
|
||||
|
||||
#### New Move Animations
|
||||
|
||||
### Localization
|
||||
- Updated translations for:
|
||||
- Updated translations for:
|
||||
@@ -36,6 +36,7 @@
|
||||
- Added `cobblemon:catch_alpha_pokemon` advancement trigger and `totalAlphaCaptureCount` stat for captured Alpha Pokémon.
|
||||
|
||||
### New rideable Pokémon
|
||||
- Pidgeot
|
||||
- Crobat
|
||||
- Skarmory
|
||||
- Milotic
|
||||
@@ -106,7 +107,9 @@
|
||||
- Avalugg (Hisuian Form)
|
||||
|
||||
### Model updates for the following Pokémon
|
||||
|
||||
- Pidgey
|
||||
- Pidgeotto
|
||||
- Pidgeot
|
||||
- Sandshrew
|
||||
- Sandslash
|
||||
- Nidoking
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
# Changelog
|
||||
## [1.8.2 (October 11th, 2026)](#1-8-2)
|
||||
|
||||
### Additions
|
||||
- The following items can now be placed on the ground as blocks:
|
||||
- King's Rock, Galarica Cuff, Unremarkable Teacup, Masterpiece Teacup, Chipped Pot, Cracked Pot, Sachet, Metal Powder, Quick Powder, Bright Powder, Soft Sand, Electirizer, Magmarizer, Icy Rock, Heat Rock, Smooth Rock, Damp Rock, Destiny Knot, Luminous Moss, Never-Melt Ice, Wide Lens, Scope Lens, and Zoom Lens.
|
||||
- I wasn't finished. Iron Ball, Metal Coat, Throat Spray, Terrain Extender, Medicinal Brew, Moomoo Milk, HP Up, Protein, Iron, Carbos, Calcium, Zinc, PP Up, PP Max, Upgrade, Dubious Disc, and Loaded Dice.
|
||||
- The following items can now be placed on various surfaces:
|
||||
- Galarica Wreath, Magnet, Flame Orb, Life Orb, Toxic Orb, Light Ball, and Smoke Ball.
|
||||
- The following items can now be placed as blocks and have additional functionality:
|
||||
- Ring Target, Metronome, and Eject Button.
|
||||
- The following items can now be worn by Players and Pokémon:
|
||||
- Galarica Wreath, Cleanse Tag, Spell Tag, Sharp Beak, Covert Cloak, Shell Helmet, and Never-Melt Ice.
|
||||
- Wearable items can now be equipped by a player by holding it and right-clicking (or whatever you've rebound use/interact to).
|
||||
- Wearable items that can be placed down are exempt from this behaviour.
|
||||
- Mint Leaves can now be placed on the ground as Leaf Litter, or in Flower Pots.
|
||||
- The recall animation now renders the ball in hand with the player's arm raised.
|
||||
- Added Oricorio Flowers.
|
||||
- Added Terrain Plants, four plants grown from Electric, Grassy, Misty, and Psychic Seeds, which glow under specific environmental conditions and can be farmed for more of their seeds.
|
||||
- Berries can now be placed in Flower Pots.
|
||||
- The evolution tree for a Pokémon can now be viewed in the Pokédex, showing the Pokémon's full family line and what's needed to evolve into each stage.
|
||||
- Added custom sounds to a bunch of items that can be placed as blocks: liquid bottles, pill bottles, powders, and dice.
|
||||
- Added paper as a new cosmetic item for Pikachu.
|
||||
- Burmy changes its cloak after a battle it took part in, based on the biome.
|
||||
- Trash Cloak in the Deep Dark, Nether and End.
|
||||
- Plant Cloak in lush biomes such as forests, jungles, plains and swamps.
|
||||
- Sandy Cloak in sandy biomes, beaches and caves.
|
||||
|
||||
### Pokémon Added
|
||||
#### Generation 4
|
||||
- Snover
|
||||
- Abomasnow
|
||||
- Burmy
|
||||
- Wormadam
|
||||
- Mothim
|
||||
|
||||
#### Generation 5
|
||||
- Tympole
|
||||
- Palpitoad
|
||||
- Seismitoad
|
||||
|
||||
#### Generation 6
|
||||
- Helioptile
|
||||
- Heliolisk
|
||||
|
||||
#### Generation 7
|
||||
- Grubbin
|
||||
- Charjabug
|
||||
- Vikavolt
|
||||
- Minior
|
||||
|
||||
#### Generation 8
|
||||
- Eternatus
|
||||
|
||||
#### Generation 9
|
||||
- Greavard
|
||||
- Houndstone
|
||||
|
||||
### Model updates for the following Pokémon
|
||||
- Sudowoodo
|
||||
- Spheal
|
||||
- Cacnea
|
||||
- Cacturne
|
||||
- Binacle
|
||||
- Barbaracle
|
||||
- Glimmet
|
||||
- Glimmora
|
||||
- Deerling
|
||||
- Sawsbuck (All forms)
|
||||
- Absol
|
||||
- Poliwag
|
||||
- Politoed
|
||||
- Ekans
|
||||
- Oddish
|
||||
- Gloom
|
||||
- Vileplume
|
||||
- Bellossom
|
||||
- Shroomish
|
||||
- Chespin
|
||||
- Quilladin
|
||||
- Chesnaught
|
||||
- Fennekin
|
||||
- Braixen
|
||||
- Delphox
|
||||
- Froakie
|
||||
- Frogadier
|
||||
- Greninja
|
||||
- Shinx
|
||||
- Luxio
|
||||
- Luxray
|
||||
- Slakoth
|
||||
- Riolu
|
||||
- Lucario
|
||||
- Corsola
|
||||
- Mime Jr.
|
||||
|
||||
### Animation updates for the following Pokémon
|
||||
- Treecko (New Shoulder Mount!)
|
||||
- Bonsly (New Shoulder Mount!)
|
||||
- Sudowoodo
|
||||
- Cacnea
|
||||
- Cacturne
|
||||
- Ekans
|
||||
- Arbok
|
||||
- Oddish
|
||||
- Gloom
|
||||
- Vileplume
|
||||
- Bellossom
|
||||
- Pichu
|
||||
- Pikachu
|
||||
- Raichu (+ Alolan)
|
||||
- Greninja
|
||||
- Slakoth
|
||||
|
||||
### Changes
|
||||
- Slowed the speed of Type Gem growth, and revamped their generation to grow in a more crystal-like shape.
|
||||
- Terrain Seeds can now be planted.
|
||||
- Terrain Seeds are now consumed during PvP and NPC battles.
|
||||
- Glow Item Frames can be crafted using Bright Powder as an alternative to Glow Ink Sacs.
|
||||
- Bright Powder can be used on Signs and Hanging Signs to make text glow, as an alternative to Glow Ink Sacs.
|
||||
- Updated various recipes to display in Recipe Groups within the Recipe Book.
|
||||
- Updated most recipes to display more logically and consistently within the Recipe Book's categories.
|
||||
- Updated the following recipes
|
||||
- Never-Melt Ice, Focus Sash, Blunder Policy, Weakness Policy, Blank TM.
|
||||
- Made ride rotations less jittery in multiplayer.
|
||||
- Changes Disc Shelf TMs to use textures instead of tinting and overlays to line up with item display.
|
||||
- Blank TM can now be inserted into the Disc Shelf.
|
||||
- Added a TM creative tab.
|
||||
- Made regional and Vivillon split-evo locations mutually exclusive.
|
||||
- Vivillon's patterns are now viewable as forms with form names and unique Pokédex entries displayed.
|
||||
- Item evolutions now unlock **all** locked evolutions whose requirements are met instead of stopping after the first.
|
||||
- Exceptions being "forced" evolutions which stop after the first one.
|
||||
- Removed Mega Drain as a TM.
|
||||
- PokeSnacks (and other area spawns) will now start the vertical offset checking from the center rather than base coordinate
|
||||
- This will help PokeSnacks to work inside caves or tighter spaces better.
|
||||
|
||||
### Fixes
|
||||
- Type Gem blocks now properly generate clusters off of the block.
|
||||
- Correctly grant "They're Minerals!" advancement when planting a Type Gem.
|
||||
- Shoulder mounted Pokémon now follow player body animations, improving their positioning with custom player animations and default actions.
|
||||
- Shoulder mounted Pokémon now sit slightly higher with chest armor equipped for better alignment, with a configurable blacklist.
|
||||
- Type Gem Blocks now have advancements to give you the recipe in the recipe book (the data for the advancements were inside the recipes somehow??).
|
||||
- Some other recipes without advancements have also been corrected.
|
||||
- Corrected the TM Recipes for Charge Beam and Payday.
|
||||
- Starter Screen Categories will no longer stop rendering if they are bigger than the viewport and you are not viewing the top or bottom edges.
|
||||
- The Random Starter option no longer runs off into other categories or becomes unaccessible due to scroll limits if it causes a new row.
|
||||
- Mochi and Feathers no longer drop glass bottles on use.
|
||||
- Fixed a rare set of concurrency bugs related to reloading packs on NeoForge; fixes a ModernFix compatibility issue.
|
||||
- Removed unnecessary conditions for Mimikyu's standing pose. Hopefully fixes the rare instance of it using its shoulder animations during battle in multiplayer scenarios.
|
||||
- Fixed Rockruff line not blinking.
|
||||
- Fixed Flygon sometimes using its running animation instead of walking.
|
||||
- Fixed Bramblin always sleeping outside of battle.
|
||||
- Fixed Dragonair using its battle idle as a normal idle.
|
||||
- Fixed Lycanroc's head movement.
|
||||
- Added head movement to Archaludon.
|
||||
- Fixed Duraludon line not having any sleep animations.
|
||||
- Fixed Diglett line not having their faint animations.
|
||||
- Fixed Kingambit moving its legs while walking.
|
||||
- Fixed Alolan Diglett's cry not playing.
|
||||
- Fixed shiny alpha Snorlax using the non-shiny texture.
|
||||
- Fixed Crabominable's head breaking when looking around.
|
||||
- Fixed Shiny Dipplin and Hydrapple's textures.
|
||||
- Various structure fixes.
|
||||
- Fixed shiny Pokémon under certain circumstances forgetting taught TMs.
|
||||
- Fixed certain Pokémon sounds sometimes being doubled when played at specific times in their animations.
|
||||
- Fixed ball capture beam origin coming from behind the ball.
|
||||
- Fixed Safari Ball catch rate outside of battle.
|
||||
- Fixed alpha eye (and other) particles not respecting the client particle density setting in video options.
|
||||
- Fixed the TM Machine UI not closing when player is moving away from it.
|
||||
- Moved the config category for alpha/shiny chance config fields for fossil machine and honey log slathering to Spawning.
|
||||
- Fixed crashes for addon species with non-Cobblemon namespaces in evolution, fishing bait, and Pokédex lookups.
|
||||
- Bees will now grow Apricorns and the Galarica Nut Bush, which were in the bee growables tag but never handled, and correctly spend their nectar when they do.
|
||||
- Saccharine Leaves can now be bone mealed.
|
||||
- Fixed equipping a stack of wearable items instead of one item of a stack.
|
||||
- Fixed TM stack consumption in TM Machine screen when a player teaches a move to a Pokémon.
|
||||
- Fixed every Miltank giving mushroom stew, not only mushroom variants.
|
||||
- Medicinal Leeks can now be eaten when they aren't being planted, matching their food properties.
|
||||
- Sweeping attacks no longer set owned Pokémon on fire (e.g. with Fire Aspect) or knock them back. Friendly Fire is now off.
|
||||
- Fixed Pokémon not losing their previous form's signature moves when changing forms (e.g. Rotom keeping Overheat after leaving its Heat form).
|
||||
- Form-specific moves gained from a form change are now only granted if the Pokémon is high enough level to learn them, and no longer create duplicates in benched moves.
|
||||
- Spinda now learns Teeter Dance at level 32 instead of via TM.
|
||||
- Fixed Oricorio Pa'u form description in the Pokédex.
|
||||
- Fixed PC playing sound on close when opened via command.
|
||||
|
||||
### Developer
|
||||
- Evolution requirements can now set `pokedexIcon` and `pokedexTooltip` directly in their JSON to control how they're shown on the Pokédex's evolution tree, for example:
|
||||
```json
|
||||
{
|
||||
"variant": "attack_defence_ratio",
|
||||
"pokedexIcon": "minecraft:diamond_sword",
|
||||
"pokedexTooltip": "cobblemon.ui.pokedex.requirement.attack_defence_ratio.tooltip"
|
||||
}
|
||||
```
|
||||
- Fixed the wrong order of operations in the code flow prior to the `FOSSIL_REVIVED` event causing Pokémon to appear without the entity link.
|
||||
- Fixed TestPartySlot command not correctly comparing the provided spec with the target Pokémon.
|
||||
|
||||
### Molang & Datapacks
|
||||
- A new `negate` variant for evolution requirements has been added, which will negate (invert) the provided inner condition.
|
||||
- Added Molang functions for individual Pokédex ids, wherein a subdex is passed in as a string to `dex_caught_count` etc.
|
||||
- Added a `battle_ended` callback, backed by the new `BATTLE_ENDED` event, which fires whenever a battle ends for any reason, alongside a multitude of flags not previously covered by `BATTLE_VICTORY`.
|
||||
- Added `battle_pokemon` to battle actor structs and `has_faced_opponents` to battle Pokémon structs.
|
||||
- Added the `cobblemon:form_change/bagworm_cloak/plant_cloak`, `sandy_cloak` and `trash_cloak` biome tags, which control Burmy's cloak after battle.
|
||||
|
||||
### Localization
|
||||
- Updated translations for:
|
||||
- Brazilian Portuguese
|
||||
- Canadian French
|
||||
- Japanese
|
||||
- Korean
|
||||
- Russian
|
||||
- Ukrainian
|
||||
@@ -0,0 +1,107 @@
|
||||
# Changelog
|
||||
## [1.8.3 (October 25th, 2026)](#1-8-3)
|
||||
|
||||
### Additions
|
||||
- Added compatability with AppleSkin.
|
||||
|
||||
### New Rideable Pokémon
|
||||
- Vikavolt
|
||||
- Fearow
|
||||
|
||||
### Particles
|
||||
## New Move Animations
|
||||
- Water Shuriken
|
||||
|
||||
### Cries added/updated for the following Pokémon
|
||||
- Hoppip
|
||||
- Skiploom
|
||||
- Jumpluff
|
||||
- Houndour
|
||||
- Houndoom
|
||||
- Wurmple
|
||||
- Silcoon
|
||||
- Beautifly
|
||||
- Cascoon
|
||||
- Dustox
|
||||
- Surskit
|
||||
- Masquerain
|
||||
- Torkoal
|
||||
- Starly
|
||||
- Staravia
|
||||
- Staraptor
|
||||
- Combee
|
||||
- Vespiquen
|
||||
- Dusknoir
|
||||
- Helioptile
|
||||
- Heliolisk
|
||||
- Grubbin
|
||||
- Charjabug
|
||||
- Vikavolt
|
||||
- Applin (updated)
|
||||
- Flapple (updated)
|
||||
- Appletun
|
||||
- Runerigus
|
||||
- Dipplin
|
||||
|
||||
### Animation updates for the following Pokémon
|
||||
- Vikavolt
|
||||
- Magby
|
||||
- Magmar
|
||||
- Ninetales (+ Alolan)
|
||||
- Spearow
|
||||
- Fearow
|
||||
- Squawkabilly
|
||||
- Mudkip
|
||||
- Marshtomp
|
||||
- Swampert
|
||||
|
||||
### Changes
|
||||
- Changed the Misc icon in the Campfire Pot Recipe Book to Health Candy.
|
||||
- Moved EXP Candies from the Medicine recipe book category to the Misc category.
|
||||
- Removed Dynamic Lights data from the Magmarizer item for consistency with the block.
|
||||
- Added `doPokemonPredation` game rule, which controls aggressiveness of Pokémon with the `hate_entity` brain task defined.
|
||||
- Added `predation_chance` server config value, which controls the possibility of attacking the hated entity found in `hate_entity` brain tasks.
|
||||
- Prehistoric Eroded Pillar generates slightly more frequently.
|
||||
- Togekiss was changed from a jet-style mount to bird-style.
|
||||
|
||||
### Fixes
|
||||
- Fixed datapacks with item interaction evolutions that don't specify an item crashing the world on load.
|
||||
- Fixed the Pokédex evolution tree crashing when a datapack's dex entry is missing an evolution's form.
|
||||
- Fixed the Pokédex evolution tree crashing with a stack overflow on evolutions that loop back on themselves.
|
||||
- Fixed the Pokédex evolution tree crashing when looking at a dex that is not part of the "National Dex" aggregate.
|
||||
- Fixed some display names in the Pokédex evolution tree having unintended font colours.
|
||||
- Fixed evolution trees not building properly when a Pokémon has several Pokédex entries for different regions.
|
||||
- Fixed form-changing evolutions sometimes resolving to the source form in the Pokédex evolution tree.
|
||||
- Broken datapack evolutions are now logged and skipped in the Pokédex evolution tree instead of crashing.
|
||||
- Fixed the `alpha` property having no tab completion in commands such as `/pokespawn`, `/pokegive` and `/pokeedit`, and added the missing `dmax_level`, `gmax_factor` and `tradable` aliases to tab completion.
|
||||
- Fixed friendship booster items not being recognised as such.
|
||||
- Fixed conflicts with other mods that would make use of recipe books in certain ways (Farmer's Delight Cooking Pot).
|
||||
- Fixed Pokémon battles stalling when a sidemod cancels the `THROWN_POKEBALL_HIT` hit event.
|
||||
- Fixed choice feature tab completion in `spawnpokemon/pokegive/pokeedit` commands.
|
||||
- Fixed MoLang that's targeting players intermittedly failing when they have died, requiring them to relog.
|
||||
- Fixed a NeoForge bug where none of the Cobblemon plants/berries could be placed into pots.
|
||||
- Fixed party overlay not hiding when the player opens the Pokédex scanner.
|
||||
- Fixed `hate_entity` task focusing on its own entity, therefore enabling deadly warfare between Zangoose and Seviper.
|
||||
- Prehistoric Frozen Pond, Prehistoric Frozen Spike, and Prehistoric Lush Den now actually generate (oops).
|
||||
- Fixed Frogadier floating in its `battle_idle` animation.
|
||||
- Fixed absence or incorrect mergers in spawning conditions, causing the max height/depth of conditions to use the min value instead.
|
||||
- Added stricter riding checks on server side to prevent possible packet forgery when a player tries to ride Pokémon.
|
||||
- Fixed Pokémon cries and animation sounds played from GUIs, such as the starter selection screen and the Pokédex, being tied to the Master volume slider instead of Friendly Creatures.
|
||||
- Fixed Archeops T-posing during its `air_cry` animation.
|
||||
|
||||
### Developer
|
||||
- Bumped NeoForge to `21.1.195` to get access to MixinExtras `0.5` and the expressions annotation.
|
||||
- New Platform Event `PLAYER_RESPAWN` which is fired when a player respawns (either through death or returning from the end).
|
||||
- Platform Events `SERVER_PLAYER_TICK_PRE` and `SERVER_PLAYER_TICK_POST` no longer fire when the player is dead.
|
||||
- It is now tied much closer to the actual entity rather than the player or their connection.
|
||||
|
||||
### Molang & Datapacks
|
||||
- Fixed `q.pokemon.nature` returning class instance instead of proper string value (`cobblemon:adamant`).
|
||||
- Fixed `q.entity.is_looking_at` result being always `1` for whatever entity passed as the target parameter.
|
||||
- Added hate chance optional parameter to `hate_entity` task. `1.0` will make an entity always attack the target.
|
||||
|
||||
### Localization
|
||||
- Updated translations for:
|
||||
- Russian
|
||||
- Japanese
|
||||
- Brazilian Portuguese
|
||||
@@ -0,0 +1,25 @@
|
||||
# Changelog
|
||||
## [1.8.4 (October 27th, 2026)](#1-8-4)
|
||||
|
||||
### Changes
|
||||
- The Froakie line now blinks. The world will never be the same.
|
||||
|
||||
### Fixes
|
||||
- Fixed heaps of spawns not working. This was caused by us missing something before release. RIP.
|
||||
- Fixed a crash caused by Fearow blinking while you're riding one. Makes sense to me.
|
||||
- Fixed Minior's "Shields Down" ability being very broken.
|
||||
- Fixed Dusclops using Squirtle's cry sound (lol).
|
||||
- Fixed blank Cooking Pot recipe book entries and missing tabs on Fabric.
|
||||
- Fixed a hitbox issue with placeable Orb held items attached to a ceiling.
|
||||
- Fixed something sneaky. I'll tell you about it later.
|
||||
|
||||
### Molang & Datapacks
|
||||
- Added `q.target_fainted` function to move action effects that checks if any opponents fainted from the move.
|
||||
|
||||
### Particles
|
||||
- Updated Water Shuriken effect to be timed better when the opponent faints.
|
||||
|
||||
### Localization
|
||||
- Updated translations for:
|
||||
- Korean
|
||||
- Simplified Chinese
|
||||
@@ -8,54 +8,42 @@
|
||||
|
||||
package com.cobblemon.mod.common.mixin;
|
||||
|
||||
import com.cobblemon.mod.common.block.SaccharineLeafBlock;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.animal.Bee;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.BonemealableBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
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.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
|
||||
@Mixin(targets = "net.minecraft.world.entity.animal.Bee$BeeGrowCropGoal")
|
||||
public abstract class BeeEntityMixin {
|
||||
|
||||
@Unique
|
||||
private BlockState cobblemon$result = null;
|
||||
|
||||
@Inject(method = "tick()V", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/block/BonemealableBlock;performBonemeal(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/util/RandomSource;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)V",
|
||||
shift = At.Shift.BY,
|
||||
by = 2
|
||||
),
|
||||
locals = LocalCapture.CAPTURE_FAILHARD
|
||||
)
|
||||
private void injectCustomGrowth(CallbackInfo ci, int i, BlockPos blockPos, BlockState blockState, Block block) {
|
||||
if (block instanceof SaccharineLeafBlock) {
|
||||
|
||||
int age = blockState.getValue(SaccharineLeafBlock.Companion.getAGE());
|
||||
boolean waterlogged = blockState.getValue(BlockStateProperties.WATERLOGGED);
|
||||
|
||||
if (age < 2 && !waterlogged) {
|
||||
this.cobblemon$result = blockState.setValue(SaccharineLeafBlock.Companion.getAGE(), age + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Shadow(aliases = {"this$0", "field_20373"}) @Final private Bee bee;
|
||||
|
||||
// Grows bonemealable blocks vanilla's hardcoded checks miss, returning the state so it handles the rest.
|
||||
@ModifyVariable(method = "tick", at = @At(value = "LOAD", ordinal = 0), index = 5)
|
||||
private BlockState applyCustomBlockState(BlockState before) {
|
||||
if(this.cobblemon$result != null && before == null) {
|
||||
BlockState result = this.cobblemon$result;
|
||||
this.cobblemon$result = null;
|
||||
return result;
|
||||
private BlockState cobblemon$growBonemealableBlocks(BlockState grownState, @Local(ordinal = 0) BlockState blockState, @Local BlockPos pos) {
|
||||
if (grownState != null || blockState.is(Blocks.CAVE_VINES) || blockState.is(Blocks.CAVE_VINES_PLANT)) {
|
||||
return grownState;
|
||||
}
|
||||
|
||||
return before;
|
||||
if (!(blockState.getBlock() instanceof BonemealableBlock bonemealable)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ServerLevel level = (ServerLevel) this.bee.level();
|
||||
if (!bonemealable.isValidBonemealTarget(level, pos, blockState)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
bonemealable.performBonemeal(level, this.bee.getRandom(), pos, blockState);
|
||||
return level.getBlockState(pos);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.IntTag;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
@@ -45,4 +46,24 @@ public class ChunkStorageMixin {
|
||||
int curVersion = vanillaFixed.contains(VERSION_KEY) ? vanillaFixed.getInt(VERSION_KEY) : 0;
|
||||
return DataFixTypes.CHUNK.update(CobblemonSchemas.getDATA_FIXER(), vanillaFixed, curVersion, CobblemonSchemas.DATA_VERSION);
|
||||
}
|
||||
|
||||
// Our update on the same MC version still needs its own fixes so run them here in that case.
|
||||
@Inject(
|
||||
method = "upgradeChunkTag(Lnet/minecraft/resources/ResourceKey;Ljava/util/function/Supplier;Lnet/minecraft/nbt/CompoundTag;Ljava/util/Optional;)Lnet/minecraft/nbt/CompoundTag;",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void cobblemon$doChunkFixOnCurrentVersion(
|
||||
ResourceKey<Level> levelKey,
|
||||
Supplier<DimensionDataStorage> storage,
|
||||
CompoundTag chunkData,
|
||||
Optional<ResourceKey<MapCodec<? extends ChunkGenerator>>> chunkGeneratorKey,
|
||||
CallbackInfoReturnable<CompoundTag> cir
|
||||
) {
|
||||
if (ChunkStorage.getVersion(chunkData) != SharedConstants.getCurrentVersion().getDataVersion().getVersion()) {
|
||||
return;
|
||||
}
|
||||
int curVersion = chunkData.contains(VERSION_KEY) ? chunkData.getInt(VERSION_KEY) : 0;
|
||||
cir.setReturnValue(DataFixTypes.CHUNK.update(CobblemonSchemas.getDATA_FIXER(), chunkData, curVersion, CobblemonSchemas.DATA_VERSION));
|
||||
}
|
||||
}
|
||||
@@ -35,13 +35,16 @@ import com.cobblemon.mod.common.util.DataKeys;
|
||||
import com.cobblemon.mod.common.world.gamerules.CobblemonGameRules;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@@ -50,6 +53,7 @@ import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -371,4 +375,33 @@ public abstract class PlayerMixin extends LivingEntity implements ScannableEntit
|
||||
this.cobblemon$rideEyePos = rideEyePos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sweeping attacks apply post-attack enchantment effects (e.g. Fire Aspect) to every entity caught
|
||||
* in the sweep, even if the damage itself was blocked. Skip them for Pokémon immune to the attack.
|
||||
*/
|
||||
@WrapOperation(
|
||||
method = "attack",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/enchantment/EnchantmentHelper;doPostAttackEffects(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;)V")
|
||||
)
|
||||
private void cobblemon$skipPostAttackEffectsOnImmunePokemon(ServerLevel level, Entity target, DamageSource source, Operation<Void> original) {
|
||||
if (target instanceof PokemonEntity pokemonEntity && pokemonEntity.isInvulnerableTo(source)) {
|
||||
return;
|
||||
}
|
||||
original.call(level, target, source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sweeping attacks also knock back every entity caught in the sweep regardless of whether it took damage.
|
||||
*/
|
||||
@WrapOperation(
|
||||
method = "attack",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;knockback(DDD)V")
|
||||
)
|
||||
private void cobblemon$skipKnockbackOnImmunePokemon(LivingEntity target, double strength, double x, double z, Operation<Void> original, @Local DamageSource source) {
|
||||
if (target instanceof PokemonEntity pokemonEntity && pokemonEntity.isInvulnerableTo(source)) {
|
||||
return;
|
||||
}
|
||||
original.call(target, strength, x, z);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import com.cobblemon.mod.common.api.riding.RidingStyle;
|
||||
import com.cobblemon.mod.common.api.spawning.spawner.PlayerSpawner;
|
||||
import com.cobblemon.mod.common.api.spawning.spawner.PlayerSpawnerFactory;
|
||||
import com.cobblemon.mod.common.api.stats.CobblemonStats;
|
||||
import com.cobblemon.mod.common.block.HealingMachineBlock;
|
||||
import com.cobblemon.mod.common.duck.ServerLevelDuck;
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||
import com.cobblemon.mod.common.world.gamerules.CobblemonGameRules;
|
||||
@@ -22,10 +23,14 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -33,6 +38,9 @@ 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;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(ServerPlayer.class)
|
||||
public abstract class ServerPlayerMixin implements PlayerSpawnerAccessor {
|
||||
@@ -142,4 +150,17 @@ public abstract class ServerPlayerMixin implements PlayerSpawnerAccessor {
|
||||
((ServerLevelDuck) this.serverLevel()).cobblemon$getLevelResourceLocation()
|
||||
);
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "findRespawnAndUseSpawnBlock(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;FZZ)Ljava/util/Optional;",
|
||||
at = @At(value = "HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private static void cobblemon$useHealthStationAsRespawn(ServerLevel level, BlockPos pos, float angle, boolean forced, boolean keepInventory, CallbackInfoReturnable<Optional<ServerPlayer.RespawnPosAngle>> cir) {
|
||||
BlockState state = level.getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof HealingMachineBlock && HealingMachineBlock.Companion.canSetSpawn(level)) {
|
||||
cir.setReturnValue(HealingMachineBlock.Companion.findStandUpPosition(EntityType.PLAYER, level, pos).map((vec3) -> ServerPlayer.RespawnPosAngle.of(vec3, pos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-17
@@ -16,6 +16,7 @@ import com.cobblemon.mod.common.item.crafting.CookingPotShapelessRecipe;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.minecraft.client.ClientRecipeBook;
|
||||
import net.minecraft.client.RecipeBookCategories;
|
||||
import net.minecraft.client.gui.screens.recipebook.RecipeCollection;
|
||||
@@ -63,23 +64,12 @@ public abstract class ClientRecipeBookMixin {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "setupCollections", at = @At("RETURN"))
|
||||
private void addCustomAggregateCategories(Iterable<RecipeHolder<?>> recipes, RegistryAccess registryAccess, CallbackInfo ci) {
|
||||
Map<RecipeBookCategories, List<List<RecipeHolder<?>>>> map = categorizeAndGroupRecipes(recipes);
|
||||
Map<RecipeBookCategories, List<RecipeCollection>> map2 = Maps.newHashMap();
|
||||
ImmutableList.Builder<RecipeCollection> builder = ImmutableList.builder();
|
||||
|
||||
map.forEach((recipeBookCategories, list) -> {
|
||||
List<RecipeCollection> collections = list.stream()
|
||||
.map(listx -> new RecipeCollection(registryAccess, listx))
|
||||
.peek(builder::add)
|
||||
.collect(ImmutableList.toImmutableList());
|
||||
map2.put(recipeBookCategories, collections);
|
||||
});
|
||||
RecipeBookCategories.AGGREGATE_CATEGORIES.forEach((recipeBookCategories, list) -> map2.put(recipeBookCategories, (List) list.stream().flatMap((recipeBookCategoriesx) -> ((List) map2.getOrDefault(recipeBookCategoriesx, ImmutableList.of())).stream()).collect(ImmutableList.toImmutableList())));
|
||||
@Inject(method = "setupCollections",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lcom/google/common/collect/ImmutableMap;copyOf(Ljava/util/Map;)Lcom/google/common/collect/ImmutableMap;"
|
||||
))
|
||||
private void addCustomAggregateCategories(Iterable<RecipeHolder<?>> recipes, RegistryAccess registryAccess, CallbackInfo ci, @Local(ordinal = 1) Map<RecipeBookCategories, List<RecipeCollection>> map2) {
|
||||
CobblemonRecipeCategories.Companion.getCustomAggregateCategories().forEach((recipeBookCategories, list) -> map2.put(recipeBookCategories, (List) list.stream().flatMap((recipeBookCategoriesx) -> ((List) map2.getOrDefault(recipeBookCategoriesx, ImmutableList.of())).stream()).collect(ImmutableList.toImmutableList())));
|
||||
|
||||
this.collectionsByTab = ImmutableMap.copyOf(map2);
|
||||
this.allCollections = builder.build();
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,13 @@ package com.cobblemon.mod.common.mixin.client;
|
||||
|
||||
import com.cobblemon.mod.common.OrientationControllable;
|
||||
import com.cobblemon.mod.common.client.render.player.MountedPlayerRenderer;
|
||||
import com.cobblemon.mod.common.client.render.player.RecallArmAnimationTracker;
|
||||
import com.cobblemon.mod.common.duck.RidePassenger;
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
@@ -96,4 +98,14 @@ public class HumanoidModelMixin {
|
||||
MountedPlayerRenderer.INSTANCE.animate((HumanoidModel<AbstractClientPlayer>)(Object)this, pokemonEntity, player, netHeadYaw, headPitch, ageInTicks, limbSwing, limbSwingAmount);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "setupAnim*", at = @At("TAIL"))
|
||||
public void cobblemon$poseRecallArm(LivingEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, CallbackInfo ci) {
|
||||
if (!(entity instanceof AbstractClientPlayer) || entity.getVehicle() instanceof PokemonEntity) return;
|
||||
float raise = RecallArmAnimationTracker.INSTANCE.raiseFactor(entity.getUUID());
|
||||
if (raise <= 0f) return;
|
||||
this.rightArm.xRot = Mth.lerp(raise, this.rightArm.xRot, (float) (-Math.PI / 2.0));
|
||||
this.rightArm.yRot = Mth.lerp(raise, this.rightArm.yRot, 0f);
|
||||
this.rightArm.zRot = Mth.lerp(raise, this.rightArm.zRot, 0f);
|
||||
}
|
||||
}
|
||||
@@ -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.mixin.client;
|
||||
|
||||
import com.cobblemon.mod.common.client.render.player.RecallArmAnimationTracker;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.entity.layers.ItemInHandLayer;
|
||||
import net.minecraft.world.entity.HumanoidArm;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
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.CallbackInfo;
|
||||
|
||||
@Mixin(ItemInHandLayer.class)
|
||||
public class ItemInHandLayerMixin {
|
||||
@Inject(method = "renderArmWithItem", at = @At("HEAD"), cancellable = true)
|
||||
private void cobblemon$hideRecallHandItem(LivingEntity entity, ItemStack itemStack, ItemDisplayContext itemDisplayContext, HumanoidArm humanoidArm, PoseStack poseStack, MultiBufferSource multiBufferSource, int light, CallbackInfo ci) {
|
||||
if (humanoidArm == HumanoidArm.RIGHT && RecallArmAnimationTracker.INSTANCE.isRecalling(entity.getUUID())) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -9,6 +9,7 @@
|
||||
package com.cobblemon.mod.common.mixin.client;
|
||||
|
||||
import com.cobblemon.mod.common.OrientationControllable;
|
||||
import com.cobblemon.mod.common.client.render.player.FirstPersonRecallBallRenderer;
|
||||
import com.cobblemon.mod.common.item.PokedexItem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -31,6 +32,9 @@ public class ItemInHandRendererMixin {
|
||||
if (abstractClientPlayer.isUsingItem() && abstractClientPlayer.getUseItem().getItem() instanceof PokedexItem) {
|
||||
ci.cancel();
|
||||
}
|
||||
else if (interactionHand == InteractionHand.MAIN_HAND && FirstPersonRecallBallRenderer.INSTANCE.render(poseStack, multiBufferSource, j, f)) {
|
||||
ci.cancel();
|
||||
}
|
||||
else if (abstractClientPlayer instanceof OrientationControllable controllable && controllable.getOrientationController().isActive()) {
|
||||
|
||||
}
|
||||
|
||||
+13
-43
@@ -9,55 +9,25 @@
|
||||
package com.cobblemon.mod.common.mixin.client;
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonRecipeCategories;
|
||||
import net.minecraft.client.ClientRecipeBook;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import com.llamalad7.mixinextras.expression.Definition;
|
||||
import com.llamalad7.mixinextras.expression.Expression;
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.minecraft.client.RecipeBookCategories;
|
||||
import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent;
|
||||
import net.minecraft.client.gui.screens.recipebook.RecipeBookPage;
|
||||
import net.minecraft.client.gui.screens.recipebook.RecipeBookTabButton;
|
||||
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(RecipeBookComponent.class)
|
||||
public class RecipeBookComponentMixin {
|
||||
|
||||
@Shadow private ClientRecipeBook book;
|
||||
|
||||
@Shadow protected Minecraft minecraft;
|
||||
|
||||
@Shadow private int width;
|
||||
|
||||
@Shadow private int xOffset;
|
||||
|
||||
@Shadow private int height;
|
||||
|
||||
@Shadow @Final private RecipeBookPage recipeBookPage;
|
||||
|
||||
@Inject(method = "updateTabs", at = @At("HEAD"), cancellable = true)
|
||||
private void customUpdateTabs(CallbackInfo ci) {
|
||||
RecipeBookComponent instance = (RecipeBookComponent) (Object) this;
|
||||
int i = (width - 147) / 2 - xOffset - 30;
|
||||
int j = (height - 166) / 2 + 3;
|
||||
int k = 27;
|
||||
int l = 0;
|
||||
|
||||
for (RecipeBookTabButton recipeBookTabButton : instance.tabButtons) {
|
||||
RecipeBookCategories recipeBookCategories = recipeBookTabButton.getCategory();
|
||||
if (recipeBookCategories != RecipeBookCategories.CRAFTING_SEARCH && recipeBookCategories != RecipeBookCategories.FURNACE_SEARCH && recipeBookCategories != CobblemonRecipeCategories.COOKING_POT_SEARCH.toVanillaCategory()) {
|
||||
if (recipeBookTabButton.updateVisibility(book)) {
|
||||
recipeBookTabButton.setPosition(i, j + 27 * l++);
|
||||
recipeBookTabButton.startAnimation(minecraft);
|
||||
}
|
||||
} else {
|
||||
recipeBookTabButton.visible = true;
|
||||
recipeBookTabButton.setPosition(i, j + k * l++);
|
||||
}
|
||||
}
|
||||
|
||||
ci.cancel();
|
||||
@Definition(id = "recipeBookCategories", local = @Local(type = RecipeBookCategories.class))
|
||||
@Definition(id = "FURNACE_SEARCH", field = "Lnet/minecraft/client/RecipeBookCategories;FURNACE_SEARCH:Lnet/minecraft/client/RecipeBookCategories;")
|
||||
@Expression("recipeBookCategories != FURNACE_SEARCH")
|
||||
@ModifyExpressionValue(
|
||||
method = "updateTabs",
|
||||
at = @At(value = "MIXINEXTRAS:EXPRESSION")
|
||||
)
|
||||
private boolean notCookingPotSearch(boolean original, @Local RecipeBookCategories recipeBookCategories) {
|
||||
return original && recipeBookCategories != CobblemonRecipeCategories.COOKING_POT_SEARCH.toVanillaCategory();
|
||||
}
|
||||
}
|
||||
@@ -269,6 +269,9 @@ object Cobblemon {
|
||||
serverPlayerStructs.remove(it.player.uuid)
|
||||
serverPlayerDebuggingPokemonBrainEntities.remove(it.player.uuid)
|
||||
}
|
||||
PlatformEvents.PLAYER_RESPAWN.subscribe {
|
||||
serverPlayerStructs.remove(it.player.uuid)
|
||||
}
|
||||
PlatformEvents.PLAYER_DEATH.subscribe {
|
||||
PCLinkManager.removeLink(it.player.uuid)
|
||||
battleRegistry.getBattleByParticipatingPlayer(it.player)?.stop()
|
||||
|
||||
@@ -140,4 +140,21 @@ object CobblemonBlockEntities : PlatformRegistry<Registry<BlockEntityType<*>>, R
|
||||
"poke_snack",
|
||||
BlockEntityType.Builder.of(::PokeSnackBlockEntity, CobblemonBlocks.POKE_SNACK, CobblemonBlocks.POKE_CAKE).build(null)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val TERRAIN_PLANT: BlockEntityType<TerrainPlantBlockEntity> = this.create(
|
||||
"terrain_plant",
|
||||
BlockEntityType.Builder.of(::TerrainPlantBlockEntity,
|
||||
CobblemonBlocks.VOLTACONIA,
|
||||
CobblemonBlocks.LUCIBELL,
|
||||
CobblemonBlocks.VERDROOT
|
||||
).build(null)
|
||||
)
|
||||
@JvmField
|
||||
val MISTLEAF_FLOWER: BlockEntityType<MistleafFlowerBlockEntity> = this.create(
|
||||
"mistleaf",
|
||||
BlockEntityType.Builder.of(::MistleafFlowerBlockEntity,
|
||||
CobblemonBlocks.MISTLEAF
|
||||
).build(null)
|
||||
)
|
||||
}
|
||||
@@ -47,7 +47,6 @@ import com.cobblemon.mod.common.block.RevivalHerbBlock
|
||||
import com.cobblemon.mod.common.block.SaccharineLeafBlock
|
||||
import com.cobblemon.mod.common.block.SaccharineLogBlock
|
||||
import com.cobblemon.mod.common.block.SaccharineLogSlatheredBlock
|
||||
import com.cobblemon.mod.common.block.ScarekrowBlock
|
||||
import com.cobblemon.mod.common.block.StackableItemBlock
|
||||
import com.cobblemon.mod.common.block.TumblestoneBlock
|
||||
import com.cobblemon.mod.common.block.TypeGemClusterBlock
|
||||
@@ -59,8 +58,7 @@ import com.cobblemon.mod.common.block.WildNestBlock
|
||||
import com.cobblemon.mod.common.block.campfirepot.CampfireBlock
|
||||
import com.cobblemon.mod.common.block.campfirepot.CampfirePotBlock
|
||||
import com.cobblemon.mod.common.block.chest.GildedChestBlock
|
||||
import com.cobblemon.mod.common.block.decor.ActivatableDecorationBlock
|
||||
import com.cobblemon.mod.common.block.decor.RingTargetBlock
|
||||
import com.cobblemon.mod.common.block.decor.*
|
||||
import com.cobblemon.mod.common.block.general.BaleBlock
|
||||
import com.cobblemon.mod.common.block.general.HorizontalRotationCarpetBlock
|
||||
import com.cobblemon.mod.common.block.general.HorizontalRotationalBlock
|
||||
@@ -71,6 +69,7 @@ import com.cobblemon.mod.common.block.sign.CobblemonSignBlock
|
||||
import com.cobblemon.mod.common.block.sign.CobblemonWallHangingSignBlock
|
||||
import com.cobblemon.mod.common.block.sign.CobblemonWallSignBlock
|
||||
import com.cobblemon.mod.common.block.tmmachine.TMMachineBlock
|
||||
import com.cobblemon.mod.common.block.general.MintLitterBlock
|
||||
import com.cobblemon.mod.common.mixin.invoker.BlocksInvoker
|
||||
import com.cobblemon.mod.common.mixin.invoker.DoorBlockInvoker
|
||||
import com.cobblemon.mod.common.mixin.invoker.FireBlockInvoker
|
||||
@@ -696,15 +695,21 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
val CHIPPED_POT = create("chipped_pot", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.DECORATED_POT).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.TEAPOT))
|
||||
@JvmField
|
||||
val CRACKED_POT = create("cracked_pot", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.DECORATED_POT).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.TEAPOT))
|
||||
@JvmField
|
||||
val ELECTIRIZER = create("electirizer", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.IZER))
|
||||
@JvmField
|
||||
val MAGMARIZER = create("magmarizer", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.IZER))
|
||||
|
||||
@JvmField
|
||||
val SACHET = create("sachet", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOL).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.POUCH))
|
||||
@JvmField
|
||||
val METAL_POWDER = create("metal_powder", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOL).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.POUCH))
|
||||
val METAL_POWDER = create("metal_powder", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_POWDER_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.POUCH))
|
||||
@JvmField
|
||||
val QUICK_POWDER = create("quick_powder", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOL).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.POUCH))
|
||||
val QUICK_POWDER = create("quick_powder", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_POWDER_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.POUCH))
|
||||
@JvmField
|
||||
val BRIGHT_POWDER = create("bright_powder", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOL).mapColor(MapColor.NONE).noOcclusion().lightLevel{3}, DecorativeItemBlock.DecorativeItemBlockType.POUCH))
|
||||
val BRIGHT_POWDER = create("bright_powder", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_POWDER_SOUNDS).mapColor(MapColor.NONE).noOcclusion().lightLevel{3}, DecorativeItemBlock.DecorativeItemBlockType.POUCH))
|
||||
@JvmField
|
||||
val SOFT_SAND = create("soft_sand", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_POWDER_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), DecorativeItemBlock.DecorativeItemBlockType.POUCH))
|
||||
|
||||
@JvmField
|
||||
val NEVER_MELT_ICE = create("never_melt_ice", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion().friction(0.989F), DecorativeItemBlock.DecorativeItemBlockType.NEVERMELT))
|
||||
@@ -734,7 +739,7 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
val EJECT_BUTTON = create("eject_button", EjectButtonBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.NONE).pushReaction(PushReaction.DESTROY).noOcclusion().strength(0.125f), 40))
|
||||
|
||||
@JvmField
|
||||
val LOADED_DICE = create("loaded_dice", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.DICE))
|
||||
val LOADED_DICE = create("loaded_dice", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_DICE_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.DICE))
|
||||
@JvmField
|
||||
val IRON_BALL = create("iron_ball", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.IRON_BALL))
|
||||
@JvmField
|
||||
@@ -745,40 +750,46 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
val DUBIOUS_DISC = create("dubious_disc", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.UPGRADE))
|
||||
|
||||
@JvmField
|
||||
val THROAT_SPRAY = create("throat_spray", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.THROAT_SPRAY))
|
||||
val THROAT_SPRAY = create("throat_spray", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.THROAT_SPRAY))
|
||||
@JvmField
|
||||
val TERRAIN_EXTENDER = create("terrain_extender", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_METAL_CAN_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.EXTENDER))
|
||||
@JvmField
|
||||
val MOOMOO_MILK = create("moomoo_milk", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_JAR_GLASS_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.GLASS_BOTTLE))
|
||||
@JvmField
|
||||
val MEDICINAL_BREW = create("medicinal_brew", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_JAR_GLASS_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.GLASS_BOTTLE))
|
||||
|
||||
@JvmField
|
||||
val FULL_HEAL = create("full_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
|
||||
val FULL_HEAL = create("full_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
|
||||
@JvmField
|
||||
val ANTIDOTE = create("antidote", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
|
||||
val ANTIDOTE = create("antidote", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
|
||||
@JvmField
|
||||
val AWAKENING = create("awakening", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
|
||||
val AWAKENING = create("awakening", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
|
||||
@JvmField
|
||||
val BURN_HEAL = create("burn_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
|
||||
val BURN_HEAL = create("burn_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
|
||||
@JvmField
|
||||
val ICE_HEAL = create("ice_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
|
||||
val ICE_HEAL = create("ice_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
|
||||
@JvmField
|
||||
val PARALYZE_HEAL = create("paralyze_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
|
||||
val PARALYZE_HEAL = create("paralyze_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
|
||||
|
||||
@JvmField
|
||||
val ETHER = create("ether", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.ETHER))
|
||||
val ETHER = create("ether", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.ETHER))
|
||||
@JvmField
|
||||
val MAX_ETHER = create("max_ether", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.ETHER))
|
||||
val MAX_ETHER = create("max_ether", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.ETHER))
|
||||
@JvmField
|
||||
val ELIXIR = create("elixir", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.ETHER))
|
||||
val ELIXIR = create("elixir", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.ETHER))
|
||||
@JvmField
|
||||
val MAX_ELIXIR = create("max_elixir", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.ETHER))
|
||||
val MAX_ELIXIR = create("max_elixir", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.ETHER))
|
||||
|
||||
@JvmField
|
||||
val POTION = create("potion", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.POTION))
|
||||
val POTION = create("potion", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.POTION))
|
||||
@JvmField
|
||||
val SUPER_POTION = create("super_potion", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.POTION))
|
||||
val SUPER_POTION = create("super_potion", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.POTION))
|
||||
@JvmField
|
||||
val HYPER_POTION = create("hyper_potion", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.POTION))
|
||||
val HYPER_POTION = create("hyper_potion", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.POTION))
|
||||
@JvmField
|
||||
val MAX_POTION = create("max_potion", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.MAX_POTION))
|
||||
val MAX_POTION = create("max_potion", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.MAX_POTION))
|
||||
@JvmField
|
||||
val FULL_RESTORE = create("full_restore", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.MAX_POTION))
|
||||
val FULL_RESTORE = create("full_restore", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.MAX_POTION))
|
||||
|
||||
@JvmField
|
||||
val DIRE_HIT = create("dire_hit", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.BATTLE_ITEM))
|
||||
@@ -798,21 +809,21 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
val X_SPEED = create("x_${Stats.SPEED.identifier.path}", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.BATTLE_ITEM))
|
||||
|
||||
@JvmField
|
||||
val HP_UP = create("hp_up", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
val HP_UP = create("hp_up", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_PILLS_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
@JvmField
|
||||
val PROTEIN = create("protein", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
val PROTEIN = create("protein", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_PILLS_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
@JvmField
|
||||
val IRON = create("iron", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
val IRON = create("iron", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_PILLS_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
@JvmField
|
||||
val CARBOS = create("carbos", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
val CARBOS = create("carbos", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_PILLS_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
@JvmField
|
||||
val CALCIUM = create("calcium", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
val CALCIUM = create("calcium", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_PILLS_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
@JvmField
|
||||
val ZINC = create("zinc", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
val ZINC = create("zinc", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_PILLS_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
@JvmField
|
||||
val PP_UP = create("pp_up", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
val PP_UP = create("pp_up", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_PILLS_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
@JvmField
|
||||
val PP_MAX = create("pp_max", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
val PP_MAX = create("pp_max", StackableItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.ITEM_BLOCK_BOTTLE_PILLS_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.VITAMIN))
|
||||
|
||||
@JvmField
|
||||
val MONITOR = create("monitor", MonitorBlock(BlockBehaviour.Properties.of().mapColor(MapColor.METAL).sound(SoundType.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().strength(5.0F, 6.0F).lightLevel { if (it.getValue(MonitorBlock.SCREEN) != MonitorBlock.MonitorScreen.OFF) 13 else 0 }))
|
||||
@@ -885,29 +896,68 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
@JvmField
|
||||
val PEP_UP_FLOWER = this.create("pep_up_flower", FlowerBlock(MobEffects.LEVITATION, 10F, BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).noCollission().instabreak().sound(SoundType.GRASS).offsetType(BlockBehaviour.OffsetType.XZ).pushReaction(PushReaction.DESTROY)))
|
||||
@JvmField
|
||||
val POTTED_PEP_UP_FLOWER = this.create("potted_pep_up_flower", BlocksInvoker.createFlowerPotBlock(PEP_UP_FLOWER))
|
||||
@JvmField
|
||||
val HEARTY_GRAINS = this.create("hearty_grains", HeartyGrainsBlock(BlockBehaviour.Properties.of().pushReaction(PushReaction.DESTROY).ignitedByLava().mapColor(MapColor.PLANT).noCollission().randomTicks().instabreak()))
|
||||
|
||||
@JvmField
|
||||
val GALARICA_NUT_BUSH = this.create("galarica_nut_bush", NutBushBlock(BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).randomTicks().noCollission().sound(SoundType.SWEET_BERRY_BUSH).pushReaction(PushReaction.DESTROY)))
|
||||
|
||||
|
||||
@JvmField
|
||||
val POTTED_RED_APRICORN_SAPLING = this.create("potted_red_apricorn_sapling", BlocksInvoker.createFlowerPotBlock(RED_APRICORN_SAPLING))
|
||||
val RED_MINT_LEAF_LITTER = this.mintLitter("red_mint_leaf_litter", MapColor.COLOR_RED)
|
||||
@JvmField
|
||||
val POTTED_YELLOW_APRICORN_SAPLING = this.create("potted_yellow_apricorn_sapling", BlocksInvoker.createFlowerPotBlock(YELLOW_APRICORN_SAPLING))
|
||||
val POTTED_RED_MINT = this.flowerPot("potted_red_mint", RED_MINT_LEAF_LITTER)
|
||||
@JvmField
|
||||
val POTTED_GREEN_APRICORN_SAPLING = this.create("potted_green_apricorn_sapling", BlocksInvoker.createFlowerPotBlock(GREEN_APRICORN_SAPLING))
|
||||
val BLUE_MINT_LEAF_LITTER = this.mintLitter("blue_mint_leaf_litter", MapColor.COLOR_BLUE)
|
||||
@JvmField
|
||||
val POTTED_BLUE_APRICORN_SAPLING = this.create("potted_blue_apricorn_sapling", BlocksInvoker.createFlowerPotBlock(BLUE_APRICORN_SAPLING))
|
||||
val POTTED_BLUE_MINT = this.flowerPot("potted_blue_mint", BLUE_MINT_LEAF_LITTER)
|
||||
@JvmField
|
||||
val POTTED_PINK_APRICORN_SAPLING = this.create("potted_pink_apricorn_sapling", BlocksInvoker.createFlowerPotBlock(PINK_APRICORN_SAPLING))
|
||||
val CYAN_MINT_LEAF_LITTER = this.mintLitter("cyan_mint_leaf_litter", MapColor.COLOR_CYAN)
|
||||
@JvmField
|
||||
val POTTED_BLACK_APRICORN_SAPLING = this.create("potted_black_apricorn_sapling", BlocksInvoker.createFlowerPotBlock(BLACK_APRICORN_SAPLING))
|
||||
val POTTED_CYAN_MINT = this.flowerPot("potted_cyan_mint", CYAN_MINT_LEAF_LITTER)
|
||||
@JvmField
|
||||
val POTTED_WHITE_APRICORN_SAPLING = this.create("potted_white_apricorn_sapling", BlocksInvoker.createFlowerPotBlock(WHITE_APRICORN_SAPLING))
|
||||
val PINK_MINT_LEAF_LITTER = this.mintLitter("pink_mint_leaf_litter", MapColor.COLOR_PINK)
|
||||
@JvmField
|
||||
val POTTED_SACCHARINE_SAPLING = this.create("potted_saccharine_sapling", BlocksInvoker.createFlowerPotBlock(SACCHARINE_SAPLING))
|
||||
val POTTED_PINK_MINT = this.flowerPot("potted_pink_mint", PINK_MINT_LEAF_LITTER)
|
||||
@JvmField
|
||||
val GREEN_MINT_LEAF_LITTER = this.mintLitter("green_mint_leaf_litter", MapColor.COLOR_GREEN)
|
||||
@JvmField
|
||||
val POTTED_GREEN_MINT = this.flowerPot("potted_green_mint", GREEN_MINT_LEAF_LITTER)
|
||||
@JvmField
|
||||
val WHITE_MINT_LEAF_LITTER = this.mintLitter("white_mint_leaf_litter", MapColor.SNOW)
|
||||
@JvmField
|
||||
val POTTED_WHITE_MINT = this.flowerPot("potted_white_mint", WHITE_MINT_LEAF_LITTER)
|
||||
|
||||
@JvmField
|
||||
val LOBAILA = this.create("lobaila", LobailaFlowerBlock(BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).noCollission().instabreak().sound(SoundType.GRASS).offsetType(BlockBehaviour.OffsetType.XZ).ignitedByLava().pushReaction(PushReaction.DESTROY)))
|
||||
@JvmField
|
||||
val POMOHANA = this.create("pomohana", PomohanaFlowerBlock(BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).noCollission().instabreak().sound(SoundType.GRASS).ignitedByLava().pushReaction(PushReaction.DESTROY)))
|
||||
@JvmField
|
||||
val PAUVILLEA = this.create("pauvillea",PauvilleaFlowerBlock(BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).noCollission().sound(SoundType.GRASS).instabreak().ignitedByLava().pushReaction(PushReaction.DESTROY)))
|
||||
@JvmField
|
||||
val WISTENSU = this.create("wistensu", WistensuFlowerHeadBlock(BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).noCollission().sound(SoundType.GRASS).instabreak().ignitedByLava().pushReaction(PushReaction.DESTROY).lightLevel{11}))
|
||||
@JvmField
|
||||
val WISTENSU_VINE = this.create("wistensu_vine", WistensuFlowerVineBlock(BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).noCollission().sound(SoundType.GRASS).instabreak().ignitedByLava().pushReaction(PushReaction.DESTROY)))
|
||||
|
||||
@JvmField
|
||||
val ELECTRIC_SEED = this.terrainSeed("electric_seed", TerrainSeedBlock.TerrainSeedType.ELECTRIC)
|
||||
@JvmField
|
||||
val PSYCHIC_SEED = this.terrainSeed("psychic_seed", TerrainSeedBlock.TerrainSeedType.PSYCHIC)
|
||||
@JvmField
|
||||
val MISTY_SEED = this.terrainSeed("misty_seed", TerrainSeedBlock.TerrainSeedType.MISTY)
|
||||
@JvmField
|
||||
val GRASSY_SEED = this.terrainSeed("grassy_seed", TerrainSeedBlock.TerrainSeedType.GRASSY)
|
||||
@JvmField
|
||||
val VOLTACONIA = this.terrainPlant("voltaconia") { state -> if (state.getValue(TerrainPlantBlock.GLOWING)) 8 else 0 }
|
||||
@JvmField
|
||||
val VERDROOT = this.terrainPlant("verdroot") { state -> if (state.getValue(TerrainPlantBlock.GLOWING)) 5 else 0 }
|
||||
@JvmField
|
||||
val LUCIBELL = this.terrainPlant("lucibell") { state -> if (state.getValue(TerrainPlantBlock.GLOWING)) 8 else 0 }
|
||||
@JvmField
|
||||
val MISTLEAF = this.create(
|
||||
"mistleaf",
|
||||
MistleafFlowerBlock {
|
||||
if ((it.getValue(MistleafFlowerBlock.GLOWING) >= 1)) it.getValue(MistleafFlowerBlock.GLOWING) + 2 else 0
|
||||
}
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val HEARTY_GRAIN_BALE = this.create("hearty_grain_bale", BaleBlock(BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).instrument(NoteBlockInstrument.BANJO).strength(0.5F).sound(CobblemonSounds.HEARTY_GRAIN_BALE_SOUNDS)))
|
||||
@@ -1090,6 +1140,7 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
WildNestBlock.create(
|
||||
WildNestType.FIERY,
|
||||
BlockBehaviour.Properties.of()
|
||||
.strength(2.0F)
|
||||
.noOcclusion()
|
||||
.pushReaction(PushReaction.DESTROY)
|
||||
.lightLevel { state ->
|
||||
@@ -1104,47 +1155,48 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
)
|
||||
val NEST_GRASSY = this.create(
|
||||
"nest_grassy",
|
||||
WildNestBlock.create(WildNestType.GRASSY, BlockBehaviour.Properties.of().noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
WildNestBlock.create(WildNestType.GRASSY, BlockBehaviour.Properties.of().strength(2.0F).noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
)
|
||||
val NEST_LEAFY = this.create(
|
||||
"nest_leafy",
|
||||
WildNestBlock.create(WildNestType.LEAFY, BlockBehaviour.Properties.of().noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
WildNestBlock.create(WildNestType.LEAFY, BlockBehaviour.Properties.of().strength(2.0F).noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
)
|
||||
val NEST_ICY = this.create(
|
||||
"nest_icy",
|
||||
WildNestBlock.create(WildNestType.ICY, BlockBehaviour.Properties.of().noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
WildNestBlock.create(WildNestType.ICY, BlockBehaviour.Properties.of().strength(2.0F).noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
)
|
||||
val NEST_HAY = this.create(
|
||||
"nest_hay",
|
||||
WildNestBlock.create(WildNestType.PLAYER, BlockBehaviour.Properties.of().noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
WildNestBlock.create(WildNestType.PLAYER, BlockBehaviour.Properties.of().strength(2.0F).noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
)
|
||||
val NEST_KELP = this.create(
|
||||
"nest_kelp",
|
||||
WildNestBlock.create(WildNestType.KELP, BlockBehaviour.Properties.of().noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
WildNestBlock.create(WildNestType.KELP, BlockBehaviour.Properties.of().strength(2.0F).noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
)
|
||||
val NEST_ROCKY = this.create(
|
||||
"nest_rocky",
|
||||
WildNestBlock.create(WildNestType.ROCKY, BlockBehaviour.Properties.of().noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
WildNestBlock.create(WildNestType.ROCKY, BlockBehaviour.Properties.of().strength(2.0F).noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
)
|
||||
val NEST_SANDY = this.create(
|
||||
"nest_sandy",
|
||||
WildNestBlock.create(WildNestType.SANDY, BlockBehaviour.Properties.of().noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
WildNestBlock.create(WildNestType.SANDY, BlockBehaviour.Properties.of().strength(2.0F).noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
)
|
||||
val NEST_SHROOMY = this.create(
|
||||
"nest_shroomy",
|
||||
WildNestBlock.create(WildNestType.SHROOMY, BlockBehaviour.Properties.of().noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
WildNestBlock.create(WildNestType.SHROOMY, BlockBehaviour.Properties.of().strength(2.0F).noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
)
|
||||
val NEST_TWIGGY = this.create(
|
||||
"nest_twiggy",
|
||||
WildNestBlock.create(WildNestType.TWIGGY, BlockBehaviour.Properties.of().noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
WildNestBlock.create(WildNestType.TWIGGY, BlockBehaviour.Properties.of().strength(2.0F).noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
)
|
||||
val NEST_WATERY = this.create(
|
||||
"nest_watery",
|
||||
WildNestBlock.create(WildNestType.WATERY, BlockBehaviour.Properties.of().noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
WildNestBlock.create(WildNestType.WATERY, BlockBehaviour.Properties.of().strength(2.0F).noOcclusion().pushReaction(PushReaction.DESTROY))
|
||||
)
|
||||
|
||||
val EGG = this.create("egg", EggBlock(BlockBehaviour.Properties
|
||||
.ofFullCopy(Blocks.DRAGON_EGG)
|
||||
.strength(0.5F, Blocks.DRAGON_EGG.explosionResistance)
|
||||
.pushReaction(PushReaction.BLOCK)
|
||||
.sound(SoundType.BONE_BLOCK)
|
||||
))
|
||||
@@ -1162,13 +1214,163 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
))
|
||||
|
||||
@JvmField
|
||||
val SCAREKROW = this.create("scarekrow", ScarekrowBlock(
|
||||
BlockBehaviour.Properties.of()
|
||||
.pushReaction(PushReaction.DESTROY)
|
||||
.sound(SoundType.GRASS)
|
||||
.strength(0.1f)
|
||||
.noOcclusion()
|
||||
))
|
||||
val POTTED_AGUAV_BERRY = this.flowerPot("potted_aguav_berry", AGUAV_BERRY)
|
||||
@JvmField
|
||||
val POTTED_APICOT_BERRY = this.flowerPot("potted_apicot_berry", APICOT_BERRY)
|
||||
@JvmField
|
||||
val POTTED_ASPEAR_BERRY = this.flowerPot("potted_aspear_berry", ASPEAR_BERRY)
|
||||
@JvmField
|
||||
val POTTED_BABIRI_BERRY = this.flowerPot("potted_babiri_berry", BABIRI_BERRY)
|
||||
@JvmField
|
||||
val POTTED_BELUE_BERRY = this.flowerPot("potted_belue_berry", BELUE_BERRY)
|
||||
@JvmField
|
||||
val POTTED_BLUK_BERRY = this.flowerPot("potted_bluk_berry", BLUK_BERRY)
|
||||
@JvmField
|
||||
val POTTED_CHARTI_BERRY = this.flowerPot("potted_charti_berry", CHARTI_BERRY)
|
||||
@JvmField
|
||||
val POTTED_CHERI_BERRY = this.flowerPot("potted_cheri_berry", CHERI_BERRY)
|
||||
@JvmField
|
||||
val POTTED_CHESTO_BERRY = this.flowerPot("potted_chesto_berry", CHESTO_BERRY)
|
||||
@JvmField
|
||||
val POTTED_CHILAN_BERRY = this.flowerPot("potted_chilan_berry", CHILAN_BERRY)
|
||||
@JvmField
|
||||
val POTTED_CHOPLE_BERRY = this.flowerPot("potted_chople_berry", CHOPLE_BERRY)
|
||||
@JvmField
|
||||
val POTTED_COBA_BERRY = this.flowerPot("potted_coba_berry", COBA_BERRY)
|
||||
@JvmField
|
||||
val POTTED_COLBUR_BERRY = this.flowerPot("potted_colbur_berry", COLBUR_BERRY)
|
||||
@JvmField
|
||||
val POTTED_CORNN_BERRY = this.flowerPot("potted_cornn_berry", CORNN_BERRY)
|
||||
@JvmField
|
||||
val POTTED_CUSTAP_BERRY = this.flowerPot("potted_custap_berry", CUSTAP_BERRY)
|
||||
@JvmField
|
||||
val POTTED_DURIN_BERRY = this.flowerPot("potted_durin_berry", DURIN_BERRY)
|
||||
@JvmField
|
||||
val POTTED_EGGANT_BERRY = this.flowerPot("potted_eggant_berry", EGGANT_BERRY)
|
||||
@JvmField
|
||||
val POTTED_ENIGMA_BERRY = this.flowerPot("potted_enigma_berry", ENIGMA_BERRY)
|
||||
@JvmField
|
||||
val POTTED_FIGY_BERRY = this.flowerPot("potted_figy_berry", FIGY_BERRY)
|
||||
@JvmField
|
||||
val POTTED_GANLON_BERRY = this.flowerPot("potted_ganlon_berry", GANLON_BERRY)
|
||||
@JvmField
|
||||
val POTTED_GREPA_BERRY = this.flowerPot("potted_grepa_berry", GREPA_BERRY)
|
||||
@JvmField
|
||||
val POTTED_HABAN_BERRY = this.flowerPot("potted_haban_berry", HABAN_BERRY)
|
||||
@JvmField
|
||||
val POTTED_HONDEW_BERRY = this.flowerPot("potted_hondew_berry", HONDEW_BERRY)
|
||||
@JvmField
|
||||
val POTTED_HOPO_BERRY = this.flowerPot("potted_hopo_berry", HOPO_BERRY)
|
||||
@JvmField
|
||||
val POTTED_IAPAPA_BERRY = this.flowerPot("potted_iapapa_berry", IAPAPA_BERRY)
|
||||
@JvmField
|
||||
val POTTED_JABOCA_BERRY = this.flowerPot("potted_jaboca_berry", JABOCA_BERRY)
|
||||
@JvmField
|
||||
val POTTED_KASIB_BERRY = this.flowerPot("potted_kasib_berry", KASIB_BERRY)
|
||||
@JvmField
|
||||
val POTTED_KEBIA_BERRY = this.flowerPot("potted_kebia_berry", KEBIA_BERRY)
|
||||
@JvmField
|
||||
val POTTED_KEE_BERRY = this.flowerPot("potted_kee_berry", KEE_BERRY)
|
||||
@JvmField
|
||||
val POTTED_KELPSY_BERRY = this.flowerPot("potted_kelpsy_berry", KELPSY_BERRY)
|
||||
@JvmField
|
||||
val POTTED_LANSAT_BERRY = this.flowerPot("potted_lansat_berry", LANSAT_BERRY)
|
||||
@JvmField
|
||||
val POTTED_LEPPA_BERRY = this.flowerPot("potted_leppa_berry", LEPPA_BERRY)
|
||||
@JvmField
|
||||
val POTTED_LIECHI_BERRY = this.flowerPot("potted_liechi_berry", LIECHI_BERRY)
|
||||
@JvmField
|
||||
val POTTED_LUM_BERRY = this.flowerPot("potted_lum_berry", LUM_BERRY)
|
||||
@JvmField
|
||||
val POTTED_MAGO_BERRY = this.flowerPot("potted_mago_berry", MAGO_BERRY)
|
||||
@JvmField
|
||||
val POTTED_MAGOST_BERRY = this.flowerPot("potted_magost_berry", MAGOST_BERRY)
|
||||
@JvmField
|
||||
val POTTED_MARANGA_BERRY = this.flowerPot("potted_maranga_berry", MARANGA_BERRY)
|
||||
@JvmField
|
||||
val POTTED_MICLE_BERRY = this.flowerPot("potted_micle_berry", MICLE_BERRY)
|
||||
@JvmField
|
||||
val POTTED_NANAB_BERRY = this.flowerPot("potted_nanab_berry", NANAB_BERRY)
|
||||
@JvmField
|
||||
val POTTED_NOMEL_BERRY = this.flowerPot("potted_nomel_berry", NOMEL_BERRY)
|
||||
@JvmField
|
||||
val POTTED_OCCA_BERRY = this.flowerPot("potted_occa_berry", OCCA_BERRY)
|
||||
@JvmField
|
||||
val POTTED_ORAN_BERRY = this.flowerPot("potted_oran_berry", ORAN_BERRY)
|
||||
@JvmField
|
||||
val POTTED_PAMTRE_BERRY = this.flowerPot("potted_pamtre_berry", PAMTRE_BERRY)
|
||||
@JvmField
|
||||
val POTTED_PASSHO_BERRY = this.flowerPot("potted_passho_berry", PASSHO_BERRY)
|
||||
@JvmField
|
||||
val POTTED_PAYAPA_BERRY = this.flowerPot("potted_payapa_berry", PAYAPA_BERRY)
|
||||
@JvmField
|
||||
val POTTED_PECHA_BERRY = this.flowerPot("potted_pecha_berry", PECHA_BERRY)
|
||||
@JvmField
|
||||
val POTTED_PERSIM_BERRY = this.flowerPot("potted_persim_berry", PERSIM_BERRY)
|
||||
@JvmField
|
||||
val POTTED_PETAYA_BERRY = this.flowerPot("potted_petaya_berry", PETAYA_BERRY)
|
||||
@JvmField
|
||||
val POTTED_PINAP_BERRY = this.flowerPot("potted_pinap_berry", PINAP_BERRY)
|
||||
@JvmField
|
||||
val POTTED_POMEG_BERRY = this.flowerPot("potted_pomeg_berry", POMEG_BERRY)
|
||||
@JvmField
|
||||
val POTTED_QUALOT_BERRY = this.flowerPot("potted_qualot_berry", QUALOT_BERRY)
|
||||
@JvmField
|
||||
val POTTED_RABUTA_BERRY = this.flowerPot("potted_rabuta_berry", RABUTA_BERRY)
|
||||
@JvmField
|
||||
val POTTED_RAWST_BERRY = this.flowerPot("potted_rawst_berry", RAWST_BERRY)
|
||||
@JvmField
|
||||
val POTTED_RAZZ_BERRY = this.flowerPot("potted_razz_berry", RAZZ_BERRY)
|
||||
@JvmField
|
||||
val POTTED_RINDO_BERRY = this.flowerPot("potted_rindo_berry", RINDO_BERRY)
|
||||
@JvmField
|
||||
val POTTED_ROSELI_BERRY = this.flowerPot("potted_roseli_berry", ROSELI_BERRY)
|
||||
@JvmField
|
||||
val POTTED_ROWAP_BERRY = this.flowerPot("potted_rowap_berry", ROWAP_BERRY)
|
||||
@JvmField
|
||||
val POTTED_SALAC_BERRY = this.flowerPot("potted_salac_berry", SALAC_BERRY)
|
||||
@JvmField
|
||||
val POTTED_SHUCA_BERRY = this.flowerPot("potted_shuca_berry", SHUCA_BERRY)
|
||||
@JvmField
|
||||
val POTTED_SITRUS_BERRY = this.flowerPot("potted_sitrus_berry", SITRUS_BERRY)
|
||||
@JvmField
|
||||
val POTTED_SPELON_BERRY = this.flowerPot("potted_spelon_berry", SPELON_BERRY)
|
||||
@JvmField
|
||||
val POTTED_STARF_BERRY = this.flowerPot("potted_starf_berry", STARF_BERRY)
|
||||
@JvmField
|
||||
val POTTED_TAMATO_BERRY = this.flowerPot("potted_tamato_berry", TAMATO_BERRY)
|
||||
@JvmField
|
||||
val POTTED_TANGA_BERRY = this.flowerPot("potted_tanga_berry", TANGA_BERRY)
|
||||
@JvmField
|
||||
val POTTED_TOUGA_BERRY = this.flowerPot("potted_touga_berry", TOUGA_BERRY)
|
||||
@JvmField
|
||||
val POTTED_WACAN_BERRY = this.flowerPot("potted_wacan_berry", WACAN_BERRY)
|
||||
@JvmField
|
||||
val POTTED_WATMEL_BERRY = this.flowerPot("potted_watmel_berry", WATMEL_BERRY)
|
||||
@JvmField
|
||||
val POTTED_WEPEAR_BERRY = this.flowerPot("potted_wepear_berry", WEPEAR_BERRY)
|
||||
@JvmField
|
||||
val POTTED_WIKI_BERRY = this.flowerPot("potted_wiki_berry", WIKI_BERRY)
|
||||
@JvmField
|
||||
val POTTED_YACHE_BERRY = this.flowerPot("potted_yache_berry", YACHE_BERRY)
|
||||
@JvmField
|
||||
val POTTED_PEP_UP_FLOWER = this.flowerPot("potted_pep_up_flower", PEP_UP_FLOWER)
|
||||
@JvmField
|
||||
val POTTED_RED_APRICORN_SAPLING = this.flowerPot("potted_red_apricorn_sapling", RED_APRICORN_SAPLING)
|
||||
@JvmField
|
||||
val POTTED_YELLOW_APRICORN_SAPLING = this.flowerPot("potted_yellow_apricorn_sapling", YELLOW_APRICORN_SAPLING)
|
||||
@JvmField
|
||||
val POTTED_GREEN_APRICORN_SAPLING = this.flowerPot("potted_green_apricorn_sapling", GREEN_APRICORN_SAPLING)
|
||||
@JvmField
|
||||
val POTTED_BLUE_APRICORN_SAPLING = this.flowerPot("potted_blue_apricorn_sapling", BLUE_APRICORN_SAPLING)
|
||||
@JvmField
|
||||
val POTTED_PINK_APRICORN_SAPLING = this.flowerPot("potted_pink_apricorn_sapling", PINK_APRICORN_SAPLING)
|
||||
@JvmField
|
||||
val POTTED_BLACK_APRICORN_SAPLING = this.flowerPot("potted_black_apricorn_sapling", BLACK_APRICORN_SAPLING)
|
||||
@JvmField
|
||||
val POTTED_WHITE_APRICORN_SAPLING = this.flowerPot("potted_white_apricorn_sapling", WHITE_APRICORN_SAPLING)
|
||||
@JvmField
|
||||
val POTTED_SACCHARINE_SAPLING = this.flowerPot("potted_saccharine_sapling", SACCHARINE_SAPLING)
|
||||
|
||||
init {
|
||||
/**
|
||||
@@ -1277,4 +1479,57 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
}
|
||||
|
||||
fun typeGemClusters() = typeGemClusters.toMap()
|
||||
|
||||
private fun flowerPot(name: String, flower: Block) = this.create(
|
||||
name,
|
||||
FlowerPotBlock(
|
||||
flower,
|
||||
BlockBehaviour.Properties.of()
|
||||
.instabreak()
|
||||
.noOcclusion()
|
||||
.pushReaction(PushReaction.DESTROY)
|
||||
)
|
||||
)
|
||||
|
||||
private fun mintLitter(name: String, color: MapColor) = this.create(
|
||||
name,
|
||||
MintLitterBlock(
|
||||
BlockBehaviour.Properties.of()
|
||||
.sound(CobblemonSounds.MINT_SOUNDS)
|
||||
.mapColor(color)
|
||||
.noOcclusion()
|
||||
.noCollission()
|
||||
.pushReaction(PushReaction.DESTROY)
|
||||
)
|
||||
)
|
||||
|
||||
private fun terrainSeed(name: String, type: TerrainSeedBlock.TerrainSeedType) = this.create(
|
||||
name,
|
||||
TerrainSeedBlock(
|
||||
type,
|
||||
BlockBehaviour.Properties.of()
|
||||
.pushReaction(PushReaction.DESTROY)
|
||||
.ignitedByLava()
|
||||
.mapColor(MapColor.PLANT)
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ)
|
||||
.noCollission()
|
||||
.randomTicks()
|
||||
.instabreak()
|
||||
)
|
||||
)
|
||||
|
||||
private fun terrainPlant(name: String, lightLevel: (BlockState) -> Int) = this.create(
|
||||
name,
|
||||
TerrainPlantBlock(
|
||||
BlockBehaviour.Properties.of()
|
||||
.mapColor(MapColor.PLANT)
|
||||
.noCollission()
|
||||
.instabreak()
|
||||
.sound(SoundType.GRASS)
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ)
|
||||
.ignitedByLava()
|
||||
.pushReaction(PushReaction.DESTROY)
|
||||
.lightLevel(lightLevel)
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -205,8 +205,6 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val CAMPFIRE_POT_WHITE = campfirePotItem(CobblemonBlocks.WHITE_CAMPFIRE_POT, CampfirePotColor.WHITE)
|
||||
|
||||
@JvmField
|
||||
val SCAREKROW = blockItem("scarekrow", CobblemonBlocks.SCAREKROW)
|
||||
@JvmField
|
||||
val HEARTY_GRAINS = compostableItem("hearty_grains", ItemNameBlockItem(CobblemonBlocks.HEARTY_GRAINS, Properties().rarity(Rarity.COMMON)))
|
||||
@JvmField
|
||||
@@ -479,8 +477,8 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField val DUBIOUS_DISC = itemNameBlockItem("dubious_disc", CobblemonBlocks.DUBIOUS_DISC)
|
||||
@JvmField val DEEP_SEA_SCALE = noSettingsItem("deep_sea_scale")
|
||||
@JvmField val DEEP_SEA_TOOTH = noSettingsItem("deep_sea_tooth")
|
||||
@JvmField val ELECTIRIZER = noSettingsItem("electirizer")
|
||||
@JvmField val MAGMARIZER = noSettingsItem("magmarizer")
|
||||
@JvmField val ELECTIRIZER = itemNameBlockItem("electirizer", CobblemonBlocks.ELECTIRIZER)
|
||||
@JvmField val MAGMARIZER = itemNameBlockItem("magmarizer", CobblemonBlocks.MAGMARIZER)
|
||||
@JvmField val OVAL_STONE = noSettingsItem("oval_stone")
|
||||
@JvmField val PROTECTOR = noSettingsItem("protector")
|
||||
@JvmField val REAPER_CLOTH = noSettingsItem("reaper_cloth")
|
||||
@@ -729,7 +727,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val PEP_UP_FLOWER = compostableBlockItem("pep_up_flower", CobblemonBlocks.PEP_UP_FLOWER)
|
||||
@JvmField
|
||||
val MEDICINAL_BREW = noSettingsItem("medicinal_brew")
|
||||
val MEDICINAL_BREW = itemNameBlockItem("medicinal_brew", CobblemonBlocks.MEDICINAL_BREW)
|
||||
@JvmField
|
||||
val REMEDY = compostableItem("remedy", RemedyItem(RemedyItem.NORMAL), 0.65f)
|
||||
@JvmField
|
||||
@@ -737,7 +735,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val SUPERB_REMEDY = compostableItem("superb_remedy", RemedyItem(RemedyItem.SUPERB), 1f)
|
||||
@JvmField
|
||||
val MOOMOO_MILK = create("moomoo_milk", MoomooMilk(Item.Properties().craftRemainder(Items.GLASS_BOTTLE).stacksTo((16))))
|
||||
val MOOMOO_MILK = create("moomoo_milk", MoomooMilk(Item.Properties().craftRemainder(Items.GLASS_BOTTLE).stacksTo((16)), CobblemonBlocks.MOOMOO_MILK))
|
||||
|
||||
@JvmField
|
||||
val POTION = create("potion", PotionItem(PotionType.POTION, CobblemonBlocks.POTION))
|
||||
@@ -766,27 +764,27 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val RED_MINT_SEEDS = mintSeed("red", MintType.RED.getCropBlock())
|
||||
@JvmField
|
||||
val RED_MINT_LEAF = mintLeaf("red", MintLeafItem(MintType.RED))
|
||||
val RED_MINT_LEAF = compostableItemNameBlockItem("red_mint_leaf", CobblemonBlocks.RED_MINT_LEAF_LITTER, 0.50f)
|
||||
@JvmField
|
||||
val BLUE_MINT_SEEDS = mintSeed("blue", MintType.BLUE.getCropBlock())
|
||||
@JvmField
|
||||
val BLUE_MINT_LEAF = mintLeaf("blue", MintLeafItem(MintType.BLUE))
|
||||
val BLUE_MINT_LEAF = compostableItemNameBlockItem("blue_mint_leaf", CobblemonBlocks.BLUE_MINT_LEAF_LITTER, 0.50f)
|
||||
@JvmField
|
||||
val CYAN_MINT_SEEDS = mintSeed("cyan", MintType.CYAN.getCropBlock())
|
||||
@JvmField
|
||||
val CYAN_MINT_LEAF = mintLeaf("cyan", MintLeafItem(MintType.CYAN))
|
||||
val CYAN_MINT_LEAF = compostableItemNameBlockItem("cyan_mint_leaf", CobblemonBlocks.CYAN_MINT_LEAF_LITTER, 0.50f)
|
||||
@JvmField
|
||||
val PINK_MINT_SEEDS = mintSeed("pink", MintType.PINK.getCropBlock())
|
||||
@JvmField
|
||||
val PINK_MINT_LEAF = mintLeaf("pink", MintLeafItem(MintType.PINK))
|
||||
val PINK_MINT_LEAF = compostableItemNameBlockItem("pink_mint_leaf", CobblemonBlocks.PINK_MINT_LEAF_LITTER, 0.50f)
|
||||
@JvmField
|
||||
val GREEN_MINT_SEEDS = mintSeed("green", MintType.GREEN.getCropBlock())
|
||||
@JvmField
|
||||
val GREEN_MINT_LEAF = mintLeaf("green", MintLeafItem(MintType.GREEN))
|
||||
val GREEN_MINT_LEAF = compostableItemNameBlockItem("green_mint_leaf", CobblemonBlocks.GREEN_MINT_LEAF_LITTER, 0.50f)
|
||||
@JvmField
|
||||
val WHITE_MINT_SEEDS = mintSeed("white", MintType.WHITE.getCropBlock())
|
||||
@JvmField
|
||||
val WHITE_MINT_LEAF = mintLeaf("white", MintLeafItem(MintType.WHITE))
|
||||
val WHITE_MINT_LEAF = compostableItemNameBlockItem("white_mint_leaf", CobblemonBlocks.WHITE_MINT_LEAF_LITTER, 0.50f)
|
||||
|
||||
val mints = mutableMapOf<String, MintItem>()
|
||||
|
||||
@@ -987,7 +985,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val EJECT_PACK = heldItem("eject_pack")
|
||||
@JvmField
|
||||
val ELECTRIC_SEED = heldItem("electric_seed")
|
||||
val ELECTRIC_SEED = itemNameBlockItem("electric_seed", CobblemonBlocks.ELECTRIC_SEED)
|
||||
@JvmField
|
||||
val EVERSTONE = heldItem("everstone")
|
||||
@JvmField
|
||||
@@ -1003,7 +1001,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val FOCUS_SASH = heldItem("focus_sash")
|
||||
@JvmField
|
||||
val GRASSY_SEED = heldItem("grassy_seed")
|
||||
val GRASSY_SEED = itemNameBlockItem("grassy_seed", CobblemonBlocks.GRASSY_SEED)
|
||||
@JvmField
|
||||
val GRIP_CLAW = heldItem("grip_claw")
|
||||
@JvmField
|
||||
@@ -1051,7 +1049,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val POWER_WEIGHT = heldItem("power_weight")
|
||||
@JvmField
|
||||
val PSYCHIC_SEED = heldItem("psychic_seed")
|
||||
val PSYCHIC_SEED = itemNameBlockItem("psychic_seed", CobblemonBlocks.PSYCHIC_SEED)
|
||||
@JvmField
|
||||
val PROTECTIVE_PADS = heldItem("protective_pads")
|
||||
@JvmField
|
||||
@@ -1075,7 +1073,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val SILVER_POWDER = heldItem("silver_powder")
|
||||
@JvmField
|
||||
val SOFT_SAND = heldItem("soft_sand")
|
||||
val SOFT_SAND = itemNameBlockItem("soft_sand", CobblemonBlocks.SOFT_SAND)
|
||||
@JvmField
|
||||
val SMOKE_BALL = itemNameBlockItem("smoke_ball", CobblemonBlocks.SMOKE_BALL)
|
||||
@JvmField
|
||||
@@ -1083,7 +1081,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val STICKY_BARB = heldItem("sticky_barb")
|
||||
@JvmField
|
||||
val TERRAIN_EXTENDER = heldItem("terrain_extender")
|
||||
val TERRAIN_EXTENDER = itemNameBlockItem("terrain_extender", CobblemonBlocks.TERRAIN_EXTENDER)
|
||||
@JvmField
|
||||
val THROAT_SPRAY = itemNameBlockItem("throat_spray", CobblemonBlocks.THROAT_SPRAY)
|
||||
@JvmField
|
||||
@@ -1103,13 +1101,13 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val MIRROR_HERB = compostableHeldItem("mirror_herb", null, 0.85F)
|
||||
@JvmField
|
||||
val MISTY_SEED = heldItem("misty_seed")
|
||||
val MISTY_SEED = itemNameBlockItem("misty_seed", CobblemonBlocks.MISTY_SEED)
|
||||
@JvmField
|
||||
val POWER_HERB = compostableHeldItem("power_herb", null, 0.85F)
|
||||
@JvmField
|
||||
val WHITE_HERB = compostableHeldItem("white_herb", null, 0.85F)
|
||||
@JvmField
|
||||
val BRIGHT_POWDER = itemNameBlockItem("bright_powder", CobblemonBlocks.BRIGHT_POWDER)
|
||||
val BRIGHT_POWDER = glowItem("bright_powder", CobblemonBlocks.BRIGHT_POWDER)
|
||||
@JvmField
|
||||
val METAL_POWDER = itemNameBlockItem("metal_powder", CobblemonBlocks.METAL_POWDER)
|
||||
@JvmField
|
||||
@@ -1580,6 +1578,25 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
|
||||
private fun eggItem(name: String, block: Block, settings: Item.Properties = Item.Properties()): BlockItem = this.create(name, BlockItem(block, settings))
|
||||
|
||||
// Plants, Flora, and Flowers
|
||||
@JvmField
|
||||
val LOBAILA = compostableBlockItem("lobaila", CobblemonBlocks.LOBAILA, 0.65f)
|
||||
@JvmField
|
||||
val POMOHANA = compostableBlockItem("pomohana", CobblemonBlocks.POMOHANA, 0.3f)
|
||||
@JvmField
|
||||
val PAUVILLEA = compostableBlockItem("pauvillea", CobblemonBlocks.PAUVILLEA, 0.65f)
|
||||
@JvmField
|
||||
val WISTENSU = compostableBlockItem("wistensu", CobblemonBlocks.WISTENSU, 0.5f)
|
||||
|
||||
@JvmField
|
||||
val VOLTACONIA = compostableBlockItem("voltaconia", CobblemonBlocks.VOLTACONIA, 0.85f)
|
||||
@JvmField
|
||||
val VERDROOT = compostableBlockItem("verdroot", CobblemonBlocks.VERDROOT, 0.85f)
|
||||
@JvmField
|
||||
val MISTLEAF = compostableBlockItem("mistleaf", CobblemonBlocks.MISTLEAF, 0.85f)
|
||||
@JvmField
|
||||
val LUCIBELL = compostableBlockItem("lucibell", CobblemonBlocks.LUCIBELL, 0.85f)
|
||||
|
||||
private fun blockItem(name: String, block: Block, rarity: Rarity = Rarity.COMMON): BlockItem = this.create(name, BlockItem(block, Item.Properties().rarity(rarity)))
|
||||
|
||||
private fun itemNameBlockItem(name: String, block: Block, rarity: Rarity = Rarity.COMMON): ItemNameBlockItem = this.create(name, ItemNameBlockItem(block, Item.Properties().rarity(rarity)))
|
||||
@@ -1782,4 +1799,6 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
private fun foodItem(nutrition: Int, saturationModifier: Float): Item {
|
||||
return CobblemonItem(Item.Properties().food(FoodProperties.Builder().nutrition(nutrition).saturationModifier(saturationModifier).build()))
|
||||
}
|
||||
|
||||
private fun glowItem(name: String, block: Block): GlowItem = this.create(name, GlowItem(block, Item.Properties()))
|
||||
}
|
||||
@@ -45,6 +45,8 @@ object CobblemonMemories {
|
||||
@JvmField
|
||||
val MATE_SCAN_COOLDOWN = register("mate_scan_cooldown", PrimitiveCodec.BOOL)
|
||||
@JvmField
|
||||
val MATES_MET = register("mates_met", PrimitiveCodec.BOOL)
|
||||
@JvmField
|
||||
val NEST_LOCATION = register<BlockPos>("nest_location")
|
||||
@JvmField
|
||||
val PATERNAL_NEST_LOCATION = register<BlockPos>("paternal_nest", BlockPos.CODEC)
|
||||
@@ -114,8 +116,6 @@ object CobblemonMemories {
|
||||
val DISABLE_WALK_TO_WANTED_ITEM = register<Boolean>("disable_walk_to_wanted_item")
|
||||
@JvmField
|
||||
val TIME_TRYING_TO_REACH_WANTED_ITEM = register<Int>("time_trying_to_wanted_item")
|
||||
@JvmField
|
||||
val NEARBY_SCAREKROW = register<BlockPos>("nearby_scarekrow", BlockPos.CODEC)
|
||||
|
||||
@JvmStatic
|
||||
fun <U> register(id: String, codec: Codec<U>): MemoryModuleType<U> {
|
||||
|
||||
@@ -429,6 +429,7 @@ object CobblemonNetwork {
|
||||
list.add(PacketRegisterInfo(MovesRegistrySyncPacket.ID, MovesRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||
list.add(PacketRegisterInfo(BerryRegistrySyncPacket.ID, BerryRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||
list.add(PacketRegisterInfo(SpeciesRegistrySyncPacket.ID, SpeciesRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||
list.add(PacketRegisterInfo(DexEvolutionDisplaySyncPacket.ID, DexEvolutionDisplaySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||
list.add(PacketRegisterInfo(PropertiesCompletionRegistrySyncPacket.ID, PropertiesCompletionRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||
list.add(PacketRegisterInfo(StandardSpeciesFeatureSyncPacket.ID, StandardSpeciesFeatureSyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||
list.add(PacketRegisterInfo(GlobalSpeciesFeatureSyncPacket.ID, GlobalSpeciesFeatureSyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||
|
||||
@@ -151,6 +151,9 @@ object CobblemonSounds : PlatformRegistry<Registry<SoundEvent>, ResourceKey<Regi
|
||||
@JvmField
|
||||
val MONITOR_GLITCHING = this.create("block.monitor.glitching")
|
||||
|
||||
@JvmField
|
||||
val BRIGHT_POWDER_USE = this.create("block.bright_powder.use")
|
||||
|
||||
@JvmField
|
||||
val FOSSIL_MACHINE_ACTIVATE = this.create("block.fossil_machine.activate")
|
||||
@JvmField
|
||||
@@ -660,5 +663,95 @@ object CobblemonSounds : PlatformRegistry<Registry<SoundEvent>, ResourceKey<Regi
|
||||
SoundEvents.WOOL_FALL
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val ITEM_BLOCK_POWDER_PLACE = this.create("block.item_block.powder.place")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_POWDER_BREAK = this.create("block.item_block.powder.break")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_POWDER_STEP = this.create("block.item_block.powder.step")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_POWDER_SOUNDS = SoundType(1f, 1.1f,
|
||||
ITEM_BLOCK_POWDER_BREAK,
|
||||
ITEM_BLOCK_POWDER_STEP,
|
||||
ITEM_BLOCK_POWDER_PLACE,
|
||||
ITEM_BLOCK_POWDER_STEP,
|
||||
ITEM_BLOCK_POWDER_STEP
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val ITEM_BLOCK_BOTTLE_LIQUID_PLACE = this.create("block.item_block.bottle_liquid.place")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_BOTTLE_LIQUID_BREAK = this.create("block.item_block.bottle_liquid.break")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_BOTTLE_LIQUID_STEP = this.create("block.item_block.bottle_liquid.step")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_BOTTLE_LIQUID_SOUNDS = SoundType(1f, 1.1f,
|
||||
ITEM_BLOCK_BOTTLE_LIQUID_BREAK,
|
||||
ITEM_BLOCK_BOTTLE_LIQUID_STEP,
|
||||
ITEM_BLOCK_BOTTLE_LIQUID_PLACE,
|
||||
ITEM_BLOCK_BOTTLE_LIQUID_PLACE,
|
||||
ITEM_BLOCK_BOTTLE_LIQUID_PLACE
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val ITEM_BLOCK_BOTTLE_PILLS_PLACE = this.create("block.item_block.bottle_pills.place")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_BOTTLE_PILLS_BREAK = this.create("block.item_block.bottle_pills.break")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_BOTTLE_PILLS_STEP = this.create("block.item_block.bottle_pills.step")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_BOTTLE_PILLS_SOUNDS = SoundType(1f, 1.1f,
|
||||
ITEM_BLOCK_BOTTLE_PILLS_BREAK,
|
||||
ITEM_BLOCK_BOTTLE_PILLS_STEP,
|
||||
ITEM_BLOCK_BOTTLE_PILLS_PLACE,
|
||||
ITEM_BLOCK_BOTTLE_PILLS_PLACE,
|
||||
ITEM_BLOCK_BOTTLE_PILLS_PLACE
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val ITEM_BLOCK_DICE_PLACE = this.create("block.item_block.dice.place")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_DICE_BREAK = this.create("block.item_block.dice.break")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_DICE_STEP = this.create("block.item_block.dice.step")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_DICE_SOUNDS = SoundType(1f, 1.1f,
|
||||
ITEM_BLOCK_DICE_BREAK,
|
||||
ITEM_BLOCK_DICE_STEP,
|
||||
ITEM_BLOCK_DICE_PLACE,
|
||||
ITEM_BLOCK_DICE_STEP,
|
||||
ITEM_BLOCK_DICE_STEP
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val ITEM_BLOCK_METAL_CAN_PLACE = this.create("block.item_block.metal_can.place")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_METAL_CAN_BREAK = this.create("block.item_block.metal_can.break")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_METAL_CAN_STEP = this.create("block.item_block.metal_can.step")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_METAL_CAN_SOUNDS = SoundType(1f, 1.1f,
|
||||
ITEM_BLOCK_METAL_CAN_BREAK,
|
||||
ITEM_BLOCK_METAL_CAN_STEP,
|
||||
ITEM_BLOCK_METAL_CAN_PLACE,
|
||||
ITEM_BLOCK_METAL_CAN_STEP,
|
||||
ITEM_BLOCK_METAL_CAN_STEP
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val ITEM_BLOCK_JAR_GLASS_LIQUID_PLACE = this.create("block.item_block.jar_glass_liquid.place")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_JAR_GLASS_LIQUID_BREAK = this.create("block.item_block.jar_glass_liquid.break")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_JAR_GLASS_LIQUID_STEP = this.create("block.item_block.jar_glass_liquid.step")
|
||||
@JvmField
|
||||
val ITEM_BLOCK_JAR_GLASS_LIQUID_SOUNDS = SoundType(1f, 1.1f,
|
||||
ITEM_BLOCK_JAR_GLASS_LIQUID_BREAK,
|
||||
ITEM_BLOCK_JAR_GLASS_LIQUID_STEP,
|
||||
ITEM_BLOCK_JAR_GLASS_LIQUID_PLACE,
|
||||
ITEM_BLOCK_JAR_GLASS_LIQUID_STEP,
|
||||
ITEM_BLOCK_JAR_GLASS_LIQUID_STEP
|
||||
)
|
||||
|
||||
private fun create(name: String): SoundEvent = this.create(name, SoundEvent.createVariableRangeEvent(cobblemonResource(name)))
|
||||
}
|
||||
@@ -8,35 +8,26 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.ai.biggerbrain
|
||||
|
||||
import com.bedrockk.molang.Expression
|
||||
import com.bedrockk.molang.runtime.MoLangRuntime
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.CobblemonNetwork.sendPacket
|
||||
import com.cobblemon.mod.common.api.PrioritizedList
|
||||
import com.cobblemon.mod.common.api.Priority
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.Distraction
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.DistractionType
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.EntityFixation
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.LookAndMoveFixation
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.Objective
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.ObjectiveStatus
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.sense.Sense
|
||||
import com.cobblemon.mod.common.api.ai.movement.TraversalPolicy
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMostSpecificMoLangValue
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.setup
|
||||
import com.cobblemon.mod.common.api.text.text
|
||||
import com.cobblemon.mod.common.net.messages.client.debug.UpdateTrackedBrainDataPacket
|
||||
import com.cobblemon.mod.common.util.getMemorySafely
|
||||
import com.cobblemon.mod.common.util.getPlayer
|
||||
import com.cobblemon.mod.common.util.mainThreadRuntime
|
||||
import com.cobblemon.mod.common.util.resolveFloat
|
||||
import com.cobblemon.mod.common.util.withQueryValue
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.memory.MemoryModuleType
|
||||
import net.minecraft.world.entity.ai.memory.MemoryStatus
|
||||
import net.minecraft.world.entity.ai.memory.WalkTarget
|
||||
import java.util.UUID
|
||||
|
||||
/**
|
||||
@@ -119,8 +110,7 @@ class BiggerBrain(val entity: LivingEntity) {
|
||||
}
|
||||
}
|
||||
|
||||
val f = fixation
|
||||
if (f?.tick(entity, this) == false && fixation === f) {
|
||||
if (fixation?.tick(entity, this) == false) {
|
||||
fixation = null
|
||||
}
|
||||
|
||||
@@ -200,86 +190,4 @@ class BiggerBrain(val entity: LivingEntity) {
|
||||
fun <T> getMemory(memory: MemoryModuleType<T>): T? {
|
||||
return entity.brain.getMemorySafely(memory).orElse(null)
|
||||
}
|
||||
|
||||
fun tryMovementFixation(
|
||||
blockPos: () -> BlockPos?,
|
||||
speedMultiplier: Expression,
|
||||
closeEnoughDistance: Int = 0,
|
||||
traversalPolicy: () -> TraversalPolicy? = { null },
|
||||
description : String,
|
||||
distraction: Distraction,
|
||||
lookAtWalkTarget: Boolean = true,
|
||||
distractionTypes: Set<DistractionType> = setOf(DistractionType.FORCE),
|
||||
onMovementStopped : ((entity: LivingEntity, brain: BiggerBrain, status: MovementStatus?) -> Unit)? = null,
|
||||
) : Pair<EntityFixation?, ObjectiveStatus> {
|
||||
if (entity !is PathfinderMob) {
|
||||
return null to ObjectiveStatus.INVALID
|
||||
}
|
||||
|
||||
val speedMultiplier = mainThreadRuntime.resolveFloat(speedMultiplier)
|
||||
|
||||
if (!canDistract(distraction)) {
|
||||
return null to ObjectiveStatus.BLOCKED // We couldn't take over.
|
||||
}
|
||||
|
||||
val pos = blockPos() ?: return null to ObjectiveStatus.INACTIVE // Couldn't resolve the walk target
|
||||
|
||||
val movementTracker = RegularMovementTracker.attempt(
|
||||
entity = entity,
|
||||
walkTarget = WalkTarget(
|
||||
pos,
|
||||
speedMultiplier,
|
||||
closeEnoughDistance
|
||||
),
|
||||
policy = traversalPolicy(),
|
||||
)
|
||||
if (movementTracker != null && (fixation == null || (distraction != null && distract(distraction)))) {
|
||||
val fixation = fixate(
|
||||
LookAndMoveFixation(
|
||||
distractionTypes = distractionTypes,
|
||||
lookingTracker = if (lookAtWalkTarget) {
|
||||
LookingTracker.fromNavigationPathOrWalkTarget(
|
||||
entity,
|
||||
movementTracker.walkTarget
|
||||
)
|
||||
} else {
|
||||
null
|
||||
},
|
||||
movementTracker = movementTracker,
|
||||
description = description,
|
||||
onMovementComplete = onMovementStopped
|
||||
)
|
||||
)
|
||||
return fixation to ObjectiveStatus.ACTIVE
|
||||
}
|
||||
return null to ObjectiveStatus.INACTIVE
|
||||
}
|
||||
|
||||
inline fun <reified T : LivingEntity> checkObjectivePrerequisites(
|
||||
cooldownTicks: Int = -1,
|
||||
fixations: List<EntityFixation> = emptyList(),
|
||||
ifIneligible: () -> Unit = {},
|
||||
): ObjectiveStatus? {
|
||||
val status = if (entity !is T) {
|
||||
ObjectiveStatus.INVALID
|
||||
} else if (fixations.isNotEmpty() && fixations.any { isFixation(it) }) {
|
||||
ObjectiveStatus.FIXATED
|
||||
} else if (cooldownTicks > 0) {
|
||||
ObjectiveStatus.INACTIVE
|
||||
} else null
|
||||
|
||||
if (status != null && status != ObjectiveStatus.INACTIVE) {
|
||||
ifIneligible()
|
||||
}
|
||||
|
||||
return status
|
||||
}
|
||||
|
||||
inline fun <reified T : LivingEntity> checkObjectivePrerequisites(
|
||||
cooldownTicks: Int = -1,
|
||||
fixation: EntityFixation? = null,
|
||||
ifIneligible: () -> Unit = {},
|
||||
): ObjectiveStatus? {
|
||||
return checkObjectivePrerequisites<T>(cooldownTicks, fixation?.let(::listOf) ?: emptyList(), ifIneligible)
|
||||
}
|
||||
}
|
||||
+9
-40
@@ -8,9 +8,7 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.ai.biggerbrain
|
||||
|
||||
import com.cobblemon.mod.common.api.ai.movement.TraversalPolicy
|
||||
import com.cobblemon.mod.common.entity.ai.CobblemonWalkTarget
|
||||
import com.cobblemon.mod.common.entity.ai.OmniPathNavigation
|
||||
import com.cobblemon.mod.common.pokemon.ai.OmniPathNodeMaker
|
||||
import com.cobblemon.mod.common.util.deleteNode
|
||||
import java.util.function.Predicate
|
||||
@@ -33,33 +31,18 @@ import net.minecraft.world.phys.Vec3
|
||||
*/
|
||||
class RegularMovementTracker(
|
||||
val entity: PathfinderMob,
|
||||
override val walkTarget: WalkTarget,
|
||||
/**
|
||||
* The traversal rules for this movement. They stay attached to the path, including when it's recomputed or
|
||||
* re-planned because the target moved. Null uses the legacy rules. Only honoured by [OmniPathNavigation].
|
||||
*/
|
||||
policy: TraversalPolicy? = null,
|
||||
/** An already planned path to follow instead of planning one here. */
|
||||
initialPath: Path? = null
|
||||
override val walkTarget: WalkTarget
|
||||
) : MovementTracker {
|
||||
companion object {
|
||||
/**
|
||||
* Attempts to create a tracker for the given entity and target. Returns null if the path
|
||||
* couldn't be created.
|
||||
*/
|
||||
fun attempt(entity: PathfinderMob, walkTarget: WalkTarget, policy: TraversalPolicy? = null): RegularMovementTracker? {
|
||||
return RegularMovementTracker(entity, walkTarget, policy).takeIf { it.isValid }
|
||||
}
|
||||
|
||||
/** Creates a tracker that follows a path which was already planned, under the policy it was planned with. */
|
||||
fun following(entity: PathfinderMob, walkTarget: WalkTarget, path: Path, policy: TraversalPolicy?): RegularMovementTracker? {
|
||||
return RegularMovementTracker(entity, walkTarget, policy, path).takeIf { it.isValid }
|
||||
fun attempt(entity: PathfinderMob, walkTarget: WalkTarget): RegularMovementTracker? {
|
||||
return RegularMovementTracker(entity, walkTarget).takeIf { it.isValid }
|
||||
}
|
||||
}
|
||||
|
||||
/** The policy given explicitly, otherwise whatever the walk target asks for. */
|
||||
val policy: TraversalPolicy? = policy ?: (walkTarget as? CobblemonWalkTarget)?.policy
|
||||
|
||||
var isValid = false
|
||||
private set
|
||||
var started = false
|
||||
@@ -70,11 +53,7 @@ class RegularMovementTracker(
|
||||
|
||||
init {
|
||||
val hasReached = hasReached(entity, walkTarget)
|
||||
if (!hasReached && initialPath != null) {
|
||||
this.path = initialPath
|
||||
this.lastKnownTargetPos = walkTarget.target.currentBlockPosition()
|
||||
isValid = true
|
||||
} else if (!hasReached && hasFinishedPath(entity, walkTarget)) {
|
||||
if (!hasReached && hasFinishedPath(entity, walkTarget)) {
|
||||
this.lastKnownTargetPos = walkTarget.target.currentBlockPosition()
|
||||
isValid = true
|
||||
} else {
|
||||
@@ -185,25 +164,15 @@ class RegularMovementTracker(
|
||||
target: BlockPos
|
||||
): Path? {
|
||||
var path: Path? = null
|
||||
val navigation = entity.navigation
|
||||
if (policy != null && navigation is OmniPathNavigation) {
|
||||
// The policy replaces node filtering; destination filtering still applies below.
|
||||
var planned = navigation.planPath(target, 0, policy)
|
||||
if (planned != null && walkTarget is CobblemonWalkTarget) {
|
||||
while (planned.endNode?.type?.let { walkTarget.destinationNodeTypeFilter(it) } == false) {
|
||||
planned.deleteNode(planned.nodeCount - 1)
|
||||
}
|
||||
if (planned.nodeCount == 0) {
|
||||
planned = null
|
||||
}
|
||||
}
|
||||
path = planned
|
||||
} else if (walkTarget is CobblemonWalkTarget) {
|
||||
if (walkTarget is CobblemonWalkTarget) {
|
||||
withNodeFilter(
|
||||
entity = entity,
|
||||
nodeFilter = walkTarget.nodeTypeFilter,
|
||||
) {
|
||||
var resolvedPath = entity.navigation.createPath(target, 0)
|
||||
var resolvedPath = entity.navigation.createPath(
|
||||
walkTarget.target.currentBlockPosition(),
|
||||
0
|
||||
)
|
||||
if (resolvedPath != null) {
|
||||
// A CobblemonWalkTarget may have a destinationNodeTypeFilter, which is used to filter the end node of the path.
|
||||
// Mainly useful for when the thing setting the target did it a bit crudely or didn't know how far the navigator
|
||||
|
||||
@@ -10,15 +10,9 @@ package com.cobblemon.mod.common.api.ai.biggerbrain
|
||||
|
||||
import com.cobblemon.mod.common.api.ai.CobblemonWanderControl.WanderCenter
|
||||
import com.cobblemon.mod.common.api.ai.config.task.WanderTaskConfig.Companion.MAX_LOOK_DOWN_DISTANCE
|
||||
import com.cobblemon.mod.common.api.ai.movement.FluidKind
|
||||
import com.cobblemon.mod.common.api.ai.movement.MovementCapabilities
|
||||
import com.cobblemon.mod.common.api.ai.movement.MovementIntent
|
||||
import com.cobblemon.mod.common.api.ai.movement.Occupancy
|
||||
import com.cobblemon.mod.common.api.ai.movement.TraversalPolicy
|
||||
import com.cobblemon.mod.common.entity.OmniPathingEntity
|
||||
import com.cobblemon.mod.common.entity.ai.CobblemonRandomSurfacePos
|
||||
import com.cobblemon.mod.common.entity.ai.CobblemonWalkTarget
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.sqrt
|
||||
import net.minecraft.core.BlockPos
|
||||
@@ -28,7 +22,6 @@ import net.minecraft.world.entity.ai.behavior.BehaviorUtils
|
||||
import net.minecraft.world.entity.ai.memory.WalkTarget
|
||||
import net.minecraft.world.entity.ai.util.HoverRandomPos
|
||||
import net.minecraft.world.entity.ai.util.LandRandomPos
|
||||
import net.minecraft.world.entity.ai.util.RandomPos
|
||||
import net.minecraft.world.level.material.Fluids
|
||||
import net.minecraft.world.level.pathfinder.PathType
|
||||
|
||||
@@ -75,16 +68,12 @@ enum class WanderType(
|
||||
|
||||
return@choosePosition if (depth < requiredDepth) null else pos
|
||||
},
|
||||
createWalkTarget = { entity, pos, _, speedMultiplier ->
|
||||
createWalkTarget = { _, pos, _, speedMultiplier ->
|
||||
CobblemonWalkTarget(
|
||||
pos = pos,
|
||||
nodeTypeFilter = { it == PathType.WATER || it == PathType.WATER_BORDER },
|
||||
speedModifier = speedMultiplier,
|
||||
completionRange = 0,
|
||||
// Stays swimming in water, wherever in the water it's comfortable or not.
|
||||
policy = TraversalPolicy.forIntent(entity, MovementIntent.IDLE) { occupancy, fluid ->
|
||||
fluid == FluidKind.WATER && (occupancy == Occupancy.SWIM || occupancy == Occupancy.SWIM_SUBMERGED)
|
||||
}
|
||||
completionRange = 0
|
||||
)
|
||||
}
|
||||
),
|
||||
@@ -145,27 +134,7 @@ enum class WanderType(
|
||||
!avoidsTargetingAir || nodeType !in listOf(
|
||||
PathType.OPEN
|
||||
)
|
||||
},
|
||||
// Only goes through what it's comfortable with while idling, e.g. no swimming for non-breathers.
|
||||
policy = TraversalPolicy.forIntent(entity, MovementIntent.IDLE)
|
||||
)
|
||||
}
|
||||
),
|
||||
/**
|
||||
* Seafloor walkers in water: they can't swim, but can breathe, so they wander along the bottom (or wade, or step
|
||||
* out onto land) instead. Neither [LAND] nor [WATER] applies to them while they're in water.
|
||||
*/
|
||||
SEABED(
|
||||
isValid = { entity -> entity.isInWater && isSeafloorWalker(MovementCapabilities.of(entity)) },
|
||||
choosePosition = { entity, _, _, horizontalRange, verticalRange ->
|
||||
chooseBottomPosition(entity, horizontalRange, verticalRange)
|
||||
},
|
||||
createWalkTarget = { entity, pos, _, speedMultiplier ->
|
||||
CobblemonWalkTarget(
|
||||
pos = pos,
|
||||
speedModifier = speedMultiplier,
|
||||
completionRange = 0,
|
||||
policy = TraversalPolicy.forIntent(entity, MovementIntent.IDLE)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
@@ -251,43 +220,4 @@ enum class WanderType(
|
||||
return pos
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Bodies that walk along the bottom of water rather than swimming in it, and can breathe down there. */
|
||||
private fun isSeafloorWalker(caps: MovementCapabilities) = caps.canWalk && !caps.canSwimInWater && caps.canBreatheUnderwater
|
||||
|
||||
private const val BOTTOM_POSITION_SAMPLES = 10
|
||||
private const val MAX_BOTTOM_DROP = 24
|
||||
|
||||
/**
|
||||
* Picks a random position the entity could stand at, settling sampled points onto the bottom the way a non-swimmer
|
||||
* would sink onto it. Only positions an idle policy allows are kept; reachability is the pathfinder's job.
|
||||
*/
|
||||
private fun chooseBottomPosition(entity: PathfinderMob, horizontalRange: Int, verticalRange: Int): BlockPos? {
|
||||
val level = entity.level()
|
||||
val policy = TraversalPolicy.forIntent(entity, MovementIntent.IDLE)
|
||||
val origin = entity.blockPosition()
|
||||
val tethering = (entity as? PokemonEntity)?.tethering
|
||||
repeat(BOTTOM_POSITION_SAMPLES) {
|
||||
var pos = origin.offset(RandomPos.generateRandomDirection(entity.random, horizontalRange, verticalRange))
|
||||
var climbed = 0
|
||||
while (level.getBlockState(pos).isSolid && climbed++ < verticalRange) {
|
||||
pos = pos.above()
|
||||
}
|
||||
var occupancy = Occupancy.at(policy.capabilities, entity.eyeHeight, pos, level::getBlockState)
|
||||
var dropped = 0
|
||||
while (occupancy?.isStandable == false && dropped++ < MAX_BOTTOM_DROP && pos.y > level.minBuildHeight) {
|
||||
pos = pos.below()
|
||||
occupancy = Occupancy.at(policy.capabilities, entity.eyeHeight, pos, level::getBlockState)
|
||||
}
|
||||
if (occupancy == null || pos == origin) {
|
||||
return@repeat
|
||||
} else if (policy.cost(occupancy, FluidKind.of(level.getFluidState(pos))) == null) {
|
||||
return@repeat
|
||||
} else if (tethering?.canRoamTo(pos) == false) {
|
||||
return@repeat
|
||||
}
|
||||
return pos
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
+3
-20
@@ -16,8 +16,6 @@ import com.cobblemon.mod.common.api.ai.biggerbrain.MovementTracker
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.RegularMovementTracker
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.Distraction
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.DistractionType
|
||||
import com.cobblemon.mod.common.api.ai.movement.MovementIntent
|
||||
import com.cobblemon.mod.common.api.ai.movement.TraversalPolicy
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMostSpecificMoLangValue
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.pokemon.ai.moves.RealTimeMove
|
||||
@@ -45,8 +43,6 @@ class AttackFixation(
|
||||
var movementTracker: MovementTracker? = null
|
||||
var lookingTracker: LookingTracker? = null
|
||||
var activeMoveInstance: RealTimeMoveInstance? = null
|
||||
/** Ticks until it may plan again after a failed or impossible path, so it holds instead of re-pathing every tick. */
|
||||
var remainingRepathTicks = 0
|
||||
override fun getDescription(entity: LivingEntity): String {
|
||||
return "Attacking Target"
|
||||
}
|
||||
@@ -130,14 +126,6 @@ class AttackFixation(
|
||||
if (movementStatus != MovementStatus.PENDING) {
|
||||
movementTracker!!.stop()
|
||||
movementTracker = null
|
||||
if (movementStatus == MovementStatus.FAILED) {
|
||||
remainingRepathTicks = REPATH_COOLDOWN_TICKS
|
||||
}
|
||||
}
|
||||
} else if (remainingRepathTicks > 0) {
|
||||
remainingRepathTicks--
|
||||
if (lookingTracker == null) {
|
||||
lookingTracker = LookingTracker.forTargetEntity(entity, targetedEntity, trackEyeHeight = true)
|
||||
}
|
||||
} else {
|
||||
// Not moving right now and we need to figure out to what distance to the enemy we want to move to
|
||||
@@ -157,11 +145,7 @@ class AttackFixation(
|
||||
}
|
||||
if (idealDistanceToTarget < distanceToTarget) {
|
||||
val walkTarget = WalkTarget(EntityTracker(targetedEntity, true), speed, idealDistanceToTarget.toInt())
|
||||
val policy = TraversalPolicy.forIntent(entity, MovementIntent.URGENT)
|
||||
movementTracker = RegularMovementTracker.attempt(entity, walkTarget, policy)
|
||||
if (movementTracker == null) {
|
||||
remainingRepathTicks = REPATH_COOLDOWN_TICKS
|
||||
}
|
||||
movementTracker = RegularMovementTracker.attempt(entity, walkTarget)
|
||||
lookingTracker = LookingTracker.forTargetEntity(entity, targetedEntity, trackEyeHeight = true)
|
||||
} else if (lookingTracker == null) {
|
||||
// Fixate at looking at the target so we don't wander off
|
||||
@@ -172,7 +156,6 @@ class AttackFixation(
|
||||
return true
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val REPATH_COOLDOWN_TICKS = 20
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+5
-6
@@ -27,9 +27,9 @@ open class LookAndMoveFixation(
|
||||
val distractionTypes: Set<DistractionType>,
|
||||
/** How to describe the fixation in the debug overlay. */
|
||||
val description: String,
|
||||
override val lookingTracker: LookingTracker?,
|
||||
override val lookingTracker: LookingTracker,
|
||||
override val movementTracker: MovementTracker,
|
||||
val onMovementComplete: ((entity: LivingEntity, brain: BiggerBrain, status: MovementStatus?) -> Unit)? = null
|
||||
val onMovementComplete: ((entity: LivingEntity, brain: BiggerBrain) -> Unit)? = null
|
||||
): EntityFixation, LookingTrackerFixation, MovementTrackerFixation {
|
||||
override fun getDescription(entity: LivingEntity) = description
|
||||
|
||||
@@ -42,11 +42,10 @@ open class LookAndMoveFixation(
|
||||
}
|
||||
|
||||
override fun tick(entity: LivingEntity, brain: BiggerBrain): Boolean {
|
||||
lookingTracker?.tick()
|
||||
val status = tickMovementFixation()
|
||||
val continueFixation = status == MovementStatus.PENDING
|
||||
lookingTracker.tick()
|
||||
val continueFixation = tickMovementFixation() == MovementStatus.PENDING
|
||||
if (!continueFixation && onMovementComplete != null) {
|
||||
onMovementComplete.invoke(entity, brain, status)
|
||||
onMovementComplete.invoke(entity, brain)
|
||||
}
|
||||
return continueFixation
|
||||
}
|
||||
|
||||
+1
@@ -52,6 +52,7 @@ class AggressiveBehaviour(
|
||||
|
||||
private var remainingCooldownTicks = 0
|
||||
private var attackFixation : EntityFixation? = null
|
||||
override val observedMemories = listOf(MemoryModuleType.HURT_BY_ENTITY, CobblemonMemories.ATTACK_TARGET_DATA)
|
||||
|
||||
|
||||
override fun perform(
|
||||
|
||||
+3
-29
@@ -23,10 +23,6 @@ import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.Distraction
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.DistractionType
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.EntityFixation
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.LookAndMoveFixation
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.MovementStatus
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.MovementTracker
|
||||
import com.cobblemon.mod.common.api.ai.movement.MovementIntent
|
||||
import com.cobblemon.mod.common.api.ai.movement.TraversalPolicy
|
||||
import com.cobblemon.mod.common.api.ai.config.objective.ObjectiveConfig
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMostSpecificMoLangValue
|
||||
import com.cobblemon.mod.common.api.npc.configuration.MoLangConfigVariable
|
||||
@@ -50,10 +46,9 @@ class AttackTargetMelee(
|
||||
private val attackCooldownTicks: Int = 20
|
||||
) : Objective {
|
||||
private var movementTask: EntityFixation? = null
|
||||
private var movementTracker: MovementTracker? = null
|
||||
private var remainingCooldownTicks = 0
|
||||
/** Ticks until the chase may plan again after failing, so an unreachable target doesn't get re-pathed every tick. */
|
||||
private var remainingRepathTicks = 0
|
||||
|
||||
override val observedMemories = listOf(MemoryModuleType.ATTACK_TARGET)
|
||||
|
||||
override fun getDescription(entity: LivingEntity) = "Attack target melee"
|
||||
|
||||
@@ -121,26 +116,9 @@ class AttackTargetMelee(
|
||||
return ObjectiveStatus.FIXATED
|
||||
}
|
||||
|
||||
if (movementTracker?.lastStatus == MovementStatus.FAILED) {
|
||||
// Got as close as it's willing to (e.g. the bank of a lake it won't enter). Hold there for a bit.
|
||||
movementTracker = null
|
||||
remainingRepathTicks = REPATH_COOLDOWN_TICKS
|
||||
}
|
||||
if (remainingRepathTicks > 0) {
|
||||
remainingRepathTicks--
|
||||
entity.lookControl.setLookAt(target)
|
||||
return ObjectiveStatus.ACTIVE
|
||||
}
|
||||
|
||||
if (!brain.distract(Distraction.FORCE)) return ObjectiveStatus.BLOCKED
|
||||
val walkTarget = WalkTarget(EntityTracker(target, true), speed, 1)
|
||||
val policy = TraversalPolicy.forIntent(entity, MovementIntent.URGENT)
|
||||
val movementTracker = RegularMovementTracker.attempt(entity, walkTarget, policy)
|
||||
this.movementTracker = movementTracker
|
||||
if (movementTracker == null) {
|
||||
remainingRepathTicks = REPATH_COOLDOWN_TICKS
|
||||
return ObjectiveStatus.ACTIVE
|
||||
}
|
||||
val movementTracker = RegularMovementTracker.attempt(entity, walkTarget) ?: return ObjectiveStatus.ACTIVE
|
||||
movementTask = brain.fixate(LookAndMoveFixation(
|
||||
distractionTypes = setOf(DistractionType.FORCE),
|
||||
lookingTracker = LookingTracker.forTargetEntity(entity, target, trackEyeHeight = true),
|
||||
@@ -164,10 +142,6 @@ class AttackTargetMelee(
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val REPATH_COOLDOWN_TICKS = 20
|
||||
}
|
||||
|
||||
class Config : ObjectiveConfig {
|
||||
val speedMultiplier: ExpressionOrEntityVariable = Either.left("1.0".asExpression())
|
||||
val attackRange: ExpressionOrEntityVariable = Either.left("2.0".asExpression())
|
||||
|
||||
-167
@@ -1,167 +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.api.ai.biggerbrain.objective
|
||||
|
||||
import com.bedrockk.molang.Expression
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.CobblemonMemories
|
||||
import com.cobblemon.mod.common.api.Priority
|
||||
import com.cobblemon.mod.common.api.ai.BehaviourConfigurationContext
|
||||
import com.cobblemon.mod.common.api.ai.ExpressionOrEntityVariable
|
||||
import com.cobblemon.mod.common.api.ai.asSimplifiedExpression
|
||||
import com.cobblemon.mod.common.api.ai.asVariables
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.BiggerBrain
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.LookingTracker
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.RegularMovementTracker
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.Distraction
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.DistractionType
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.ConditionalLockFixation
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.EntityFixation
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.LookAndMoveFixation
|
||||
import com.cobblemon.mod.common.api.ai.config.objective.ObjectiveConfig
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMostSpecificMoLangValue
|
||||
import com.cobblemon.mod.common.api.npc.configuration.MoLangConfigVariable
|
||||
import com.cobblemon.mod.common.api.tags.CobblemonBlockTags
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.util.asExpression
|
||||
import com.cobblemon.mod.common.util.mainThreadRuntime
|
||||
import com.cobblemon.mod.common.util.resolveFloat
|
||||
import com.cobblemon.mod.common.util.toVec3d
|
||||
import com.cobblemon.mod.common.util.withQueryValue
|
||||
import com.mojang.datafixers.util.Either
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.ai.memory.MemoryModuleType
|
||||
import net.minecraft.world.entity.ai.memory.WalkTarget
|
||||
import net.minecraft.world.entity.ai.util.LandRandomPos
|
||||
|
||||
class AvoidScarekrow(
|
||||
private val speedMultiplier: Expression = "0.5".asExpression(),
|
||||
) : Objective {
|
||||
private var movementTask: EntityFixation? = null
|
||||
private var remainingCooldownTicks = 0
|
||||
|
||||
override fun getDescription(entity: LivingEntity) = "Avoiding target block"
|
||||
|
||||
override fun perform(
|
||||
entity: LivingEntity,
|
||||
brain: BiggerBrain,
|
||||
activeObjectiveTags: MutableSet<String>
|
||||
): ObjectiveStatus {
|
||||
if (entity !is PokemonEntity || !entity.isAlive) return ObjectiveStatus.INVALID
|
||||
|
||||
val target = brain.getMemory(CobblemonMemories.NEARBY_SCAREKROW)
|
||||
?: return ObjectiveStatus.INACTIVE
|
||||
|
||||
// if the scarekrow is gone we dont need to be scared anymore
|
||||
if (!entity.level().getBlockState(target).`is`(CobblemonBlockTags.SCAREKROWS)) {
|
||||
brain.eraseMemory(CobblemonMemories.NEARBY_SCAREKROW)
|
||||
return ObjectiveStatus.INACTIVE
|
||||
}
|
||||
|
||||
// finish existing movement task
|
||||
if (brain.isFixation(movementTask)) {
|
||||
return ObjectiveStatus.FIXATED
|
||||
}
|
||||
|
||||
// aggro against the player should take priority
|
||||
if (brain.getMemory(MemoryModuleType.ATTACK_TARGET) != null) {
|
||||
return ObjectiveStatus.BLOCKED
|
||||
}
|
||||
|
||||
if (remainingCooldownTicks > 0) {
|
||||
remainingCooldownTicks--
|
||||
}
|
||||
val runtime = mainThreadRuntime.withQueryValue("entity", entity.asMostSpecificMoLangValue())
|
||||
val speed = runtime.resolveFloat(speedMultiplier)
|
||||
|
||||
if (!brain.distract(Distraction.FORCE)) return ObjectiveStatus.BLOCKED
|
||||
var targetPos : BlockPos? = null
|
||||
|
||||
// fixate on running from the scarekrow until it is out of range
|
||||
brain.fixate(ConditionalLockFixation("Avoiding scarekrow") {
|
||||
brain.getMemory(CobblemonMemories.NEARBY_SCAREKROW) != null
|
||||
})
|
||||
|
||||
// find position
|
||||
val direction = entity.position().subtract(target.toVec3d())
|
||||
for (j in 0..9) {
|
||||
val targetVec3 = LandRandomPos.getPosAway(entity, (Cobblemon.config.scarekrowRadius * 1.2).toInt(), 7, direction)
|
||||
if (targetVec3 != null) {
|
||||
targetPos = BlockPos.containing(targetVec3)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Start a look-and-move fixation only when navigation accepts the selected position.
|
||||
if (targetPos != null) {
|
||||
val movementTracker = RegularMovementTracker.attempt(
|
||||
entity = entity,
|
||||
walkTarget = WalkTarget(
|
||||
targetPos,
|
||||
speed,
|
||||
0
|
||||
)
|
||||
)
|
||||
if (movementTracker != null) {
|
||||
movementTask = brain.fixate(
|
||||
LookAndMoveFixation(
|
||||
distractionTypes = setOf(
|
||||
DistractionType.FORCE
|
||||
),
|
||||
lookingTracker = LookingTracker.fromNavigationPathOrWalkTarget(
|
||||
entity,
|
||||
movementTracker.walkTarget
|
||||
),
|
||||
movementTracker = movementTracker,
|
||||
description = "Moving away from target block",
|
||||
)
|
||||
)
|
||||
return ObjectiveStatus.FIXATED
|
||||
}
|
||||
}
|
||||
|
||||
return ObjectiveStatus.FIXATED
|
||||
}
|
||||
|
||||
override fun onRegister(entity: LivingEntity, brain: BiggerBrain) {
|
||||
brain.subscribe(
|
||||
priority = Priority.LOW,
|
||||
memory = CobblemonMemories.NEARBY_SCAREKROW,
|
||||
) { value, labels ->
|
||||
if (value == null) {
|
||||
if (brain.isFixation(movementTask)) {
|
||||
brain.distract(Distraction.FORCE)
|
||||
movementTask = null
|
||||
}
|
||||
}
|
||||
return@subscribe true
|
||||
}
|
||||
}
|
||||
|
||||
class Config : ObjectiveConfig {
|
||||
val speedMultiplier: ExpressionOrEntityVariable = Either.left("0.5".asExpression())
|
||||
|
||||
override fun getVariables(
|
||||
entity: LivingEntity,
|
||||
behaviourConfigurationContext: BehaviourConfigurationContext
|
||||
): List<MoLangConfigVariable> {
|
||||
return listOf(speedMultiplier).asVariables()
|
||||
}
|
||||
|
||||
override fun create(
|
||||
entity: LivingEntity,
|
||||
behaviourConfigurationContext: BehaviourConfigurationContext
|
||||
): Objective {
|
||||
return AvoidScarekrow(
|
||||
speedMultiplier = speedMultiplier.asSimplifiedExpression(entity),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
@@ -43,6 +43,8 @@ class AvoidTarget(
|
||||
private var movementTask: EntityFixation? = null
|
||||
private var remainingCooldownTicks = 0
|
||||
|
||||
override val observedMemories = listOf(MemoryModuleType.AVOID_TARGET)
|
||||
|
||||
override fun getDescription(entity: LivingEntity) = "Avoiding target"
|
||||
|
||||
override fun perform(
|
||||
|
||||
+59
-55
@@ -32,6 +32,7 @@ import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMostSpecificMoLangV
|
||||
import com.cobblemon.mod.common.api.nest.WildNestType
|
||||
import com.cobblemon.mod.common.api.nest.WildNestTypes
|
||||
import com.cobblemon.mod.common.api.npc.configuration.MoLangConfigVariable
|
||||
import com.cobblemon.mod.common.api.pokemon.egg.EggGroup
|
||||
import com.cobblemon.mod.common.block.WildNestBlock
|
||||
import com.cobblemon.mod.common.block.entity.NestBlockEntity
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
@@ -53,7 +54,8 @@ import net.minecraft.world.phys.Vec3
|
||||
class Breed(
|
||||
private val speedMultiplier: Expression = "0.4".asExpression(),
|
||||
private val condition: Expression = "true".asExpression(),
|
||||
private val layDurationTicks: Int = 40
|
||||
private val layDurationTicks: Int = 40,
|
||||
private val meetDurationTicks: Int = 100
|
||||
) : Objective {
|
||||
private var fixation: EntityFixation? = null
|
||||
private var mateFixation: EntityFixation? = null
|
||||
@@ -76,9 +78,12 @@ class Breed(
|
||||
// is breeding disabled from any preset conditions
|
||||
if (!mainThreadRuntime.withQueryValue("entity", entity.asMostSpecificMoLangValue()).resolveBoolean(condition))
|
||||
return ObjectiveStatus.INACTIVE
|
||||
// try to get one parent to lead the other one and have the other one not do this stuff
|
||||
if (entity.uuid > mate.uuid)
|
||||
return ObjectiveStatus.INACTIVE
|
||||
// mates need to meet together briefly for a bit (kind of like vanilla mobs)
|
||||
if (!brain.hasMemoryValue(CobblemonMemories.MATES_MET) || !mate.biggerBrain.hasMemoryValue(CobblemonMemories.MATES_MET))
|
||||
return meetMate(entity, brain, mate)
|
||||
// mother (or ditto) goes to lay the egg and the other mate tries to follow along the best they can
|
||||
if (EggGroup.DITTO !in entity.pokemon.form.eggGroups && (EggGroup.DITTO in mate.pokemon.form.eggGroups || CobblemonBreeding.getMother(entity.pokemon, mate.pokemon, isSimulated = true) != entity.pokemon))
|
||||
return followMate(entity, brain, mate)
|
||||
|
||||
val nestPos = brain.getMemory(CobblemonMemories.NEST_LOCATION)
|
||||
if (nestPos != null)
|
||||
@@ -99,10 +104,9 @@ class Breed(
|
||||
|
||||
val nestCenter = Vec3.atCenterOf(nestPos)
|
||||
val speed = mainThreadRuntime.withQueryValue("entity", entity.asMostSpecificMoLangValue()).resolveFloat(speedMultiplier)
|
||||
// path to the nest site with mate until close enough (big bois had issues so we are also going to try to make it easier for them)
|
||||
if (entity.position().distanceTo(nestCenter) > closeEnough(entity) || mate.position().distanceTo(nestCenter) > closeEnough(mate)) {
|
||||
bringMate(mate, nestCenter, speed)
|
||||
return walkToNest(entity, brain, nestCenter, speed, "in Breed fixation: going to nest")
|
||||
// path to the nest site until close enough (big bois had issues so we are also going to try to make it easier for them)
|
||||
if (entity.position().distanceTo(nestCenter) > closeEnough(entity)) {
|
||||
return walkTo(entity, brain, nestCenter, speed, "in Breed fixation: going to nest")
|
||||
}
|
||||
return layEgg(entity, brain, mate, world, nest, nestPos)
|
||||
}
|
||||
@@ -112,17 +116,16 @@ class Breed(
|
||||
// probably should stop trying to build nest if there is an attack target
|
||||
if (brain.hasMemoryValue(MemoryModuleType.ATTACK_TARGET))
|
||||
return ObjectiveStatus.INACTIVE
|
||||
// find out what kinds of nests this couple can make togethr
|
||||
val types = WildNestTypes.combinedTypes(entity, mate)
|
||||
// find out what kinds of nests the mother makes
|
||||
val types = WildNestTypes.typesFor((CobblemonBreeding.getMother(entity.pokemon, mate.pokemon, isSimulated = true) ?: entity.pokemon).species)
|
||||
if (types.isEmpty())
|
||||
return ObjectiveStatus.INACTIVE
|
||||
|
||||
val nestCenter = Vec3.atCenterOf(nestPos)
|
||||
val speed = mainThreadRuntime.withQueryValue("entity", entity.asMostSpecificMoLangValue()).resolveFloat(speedMultiplier)
|
||||
// keep going until both mates are not too far from the nest
|
||||
if (entity.position().distanceTo(nestCenter) > closeEnough(entity) || mate.position().distanceTo(nestCenter) > closeEnough(mate)) {
|
||||
bringMate(mate, nestCenter, speed)
|
||||
return walkToNest(entity, brain, nestCenter, speed, "in Breed fixation: going to nest")
|
||||
// keep going until the mother is not too far from the nest
|
||||
if (entity.position().distanceTo(nestCenter) > closeEnough(entity)) {
|
||||
return walkTo(entity, brain, nestCenter, speed, "in Breed fixation: going to nest")
|
||||
}
|
||||
|
||||
// get our nest they are about to build and place it
|
||||
@@ -149,10 +152,12 @@ class Breed(
|
||||
return ObjectiveStatus.BLOCKED
|
||||
val egg = CobblemonBreeding.createEgg(entity.pokemon, mate.pokemon) ?: return ObjectiveStatus.INACTIVE
|
||||
nest.setItem(egg)
|
||||
// if a mate (other than the egg layer) cannot get to a nest then it should be a deadbeat lol
|
||||
val mateCanReach = mate.position().distanceTo(Vec3.atCenterOf(nestPos)) <= closeEnough(mate) || mate.navigation.createPath(nestPos, 0)?.let { it.distToTarget < 1.75f } == true
|
||||
|
||||
// wild nests are probably the only ones where we need to record the parents onto the nest
|
||||
if (nest.ownerUUID == null) {
|
||||
nest.parents = Pair(entity.uuid, mate.uuid)
|
||||
nest.parents = Pair(entity.uuid, if (mateCanReach) mate.uuid else null)
|
||||
nest.nestClaimedBy = Pair(entity.uuid, mate.uuid)
|
||||
}
|
||||
|
||||
@@ -164,9 +169,12 @@ class Breed(
|
||||
}
|
||||
|
||||
parent.pokemon.breedingCooldown = CobblemonBreeding.resetBreedingCooldown(parent.pokemon)
|
||||
parent.biggerBrain.setMemory(CobblemonMemories.PATERNAL_NEST_LOCATION, nestPos)
|
||||
parent.biggerBrain.setMemory(CobblemonMemories.EGG_IN_NEST, true)
|
||||
if (parent == entity || mateCanReach) {
|
||||
parent.biggerBrain.setMemory(CobblemonMemories.PATERNAL_NEST_LOCATION, nestPos)
|
||||
parent.biggerBrain.setMemory(CobblemonMemories.EGG_IN_NEST, true)
|
||||
}
|
||||
parent.biggerBrain.eraseMemory(CobblemonMemories.IDEAL_NEST_LOCATION)
|
||||
parent.biggerBrain.eraseMemory(CobblemonMemories.MATES_MET)
|
||||
|
||||
// todo do we want to use our own particles? look at this later
|
||||
world.sendParticles(
|
||||
@@ -189,11 +197,32 @@ class Breed(
|
||||
return ObjectiveStatus.FIXATED
|
||||
}
|
||||
|
||||
// path to the nest location
|
||||
private fun walkToNest(entity: PokemonEntity, brain: BiggerBrain, target: Vec3, speed: Float, description: String): ObjectiveStatus {
|
||||
// walk over to the mate and stay put for a lil bit
|
||||
private fun meetMate(entity: PokemonEntity, brain: BiggerBrain, mate: PokemonEntity): ObjectiveStatus {
|
||||
// stay active while the other mate shows up
|
||||
if (brain.hasMemoryValue(CobblemonMemories.MATES_MET))
|
||||
return ObjectiveStatus.ACTIVE
|
||||
val speed = mainThreadRuntime.withQueryValue("entity", entity.asMostSpecificMoLangValue()).resolveFloat(speedMultiplier)
|
||||
if (entity.distanceTo(mate) > closeEnough(entity) + mate.bbWidth / 2)
|
||||
return walkTo(entity, brain, mate.position(), speed, "in Breed fixation: going to mate")
|
||||
if (!brain.distract(comfortDistraction))
|
||||
return ObjectiveStatus.BLOCKED
|
||||
brain.setMemory(CobblemonMemories.MATES_MET, true, MATES_MET_TICKS)
|
||||
fixation = brain.fixate(DurationLockFixation("Breed: staying with mate", meetDurationTicks))
|
||||
return ObjectiveStatus.FIXATED
|
||||
}
|
||||
|
||||
// other mate doess their best to follow along
|
||||
private fun followMate(entity: PokemonEntity, brain: BiggerBrain, mate: PokemonEntity): ObjectiveStatus {
|
||||
val nestPos = mate.biggerBrain.getMemory(CobblemonMemories.NEST_LOCATION) ?: mate.biggerBrain.getMemory(CobblemonMemories.IDEAL_NEST_LOCATION) ?: return ObjectiveStatus.INACTIVE
|
||||
val speed = mainThreadRuntime.withQueryValue("entity", entity.asMostSpecificMoLangValue()).resolveFloat(speedMultiplier)
|
||||
return walkTo(entity, brain, Vec3.atCenterOf(nestPos), speed, "in Breed fixation: following mate to nest")
|
||||
}
|
||||
|
||||
// path to target location if able to
|
||||
private fun walkTo(entity: PokemonEntity, brain: BiggerBrain, target: Vec3, speed: Float, description: String): ObjectiveStatus {
|
||||
if (brain.isFixation(fixation))
|
||||
return ObjectiveStatus.FIXATED
|
||||
// wait for mate to get here
|
||||
if (entity.position().distanceTo(target) <= closeEnough(entity))
|
||||
return ObjectiveStatus.ACTIVE
|
||||
if (!brain.distract(comfortDistraction))
|
||||
@@ -210,31 +239,14 @@ class Breed(
|
||||
return ObjectiveStatus.FIXATED
|
||||
}
|
||||
|
||||
// have the other mates be told where to go
|
||||
private fun bringMate(mate: PokemonEntity, target: Vec3, speed: Float) {
|
||||
val mateBrain = mate.biggerBrain
|
||||
if (mate.position().distanceTo(target) <= closeEnough(mate) || mateBrain.isFixation(mateFixation))
|
||||
return
|
||||
if (!mateBrain.distract(comfortDistraction))
|
||||
return
|
||||
val tracker = RegularMovementTracker.attempt(mate, WalkTarget(target, speed, closeEnough(mate).toInt())) ?: return
|
||||
mateFixation = mateBrain.fixate(
|
||||
LookAndMoveFixation(
|
||||
distractionTypes = setOf(DistractionType.DAMAGE, DistractionType.FORCE),
|
||||
description = "Breed: folow mate",
|
||||
lookingTracker = LookingTracker.fromNavigationPathOrWalkTarget(mate, tracker.walkTarget),
|
||||
movementTracker = tracker
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// checks for what nests are valid for the mates
|
||||
private fun canUseNest(entity: PokemonEntity, mate: PokemonEntity, world: ServerLevel, nest: NestBlockEntity): Boolean {
|
||||
val nestType = (nest.blockState.block as? WildNestBlock)?.type ?: return false
|
||||
if (!isNestTypeAllowed(nestType, entity, mate))
|
||||
return false
|
||||
// the main restricter is if a nest is waterlogged so make sure we can check for that
|
||||
val waterlogged = nest.blockState.getOptionalValue(BlockStateProperties.WATERLOGGED).orElse(false)
|
||||
if (!isWaterGroupCompatible(entity, mate, waterlogged))
|
||||
if (waterlogged && "watery" !in (CobblemonBreeding.getMother(entity.pokemon, mate.pokemon, isSimulated = true) ?: entity.pokemon).species.nestTypes)
|
||||
return false
|
||||
|
||||
// check if the nest is claimed by other pokemon that exist and maybe on their way to it (CRAB NOTE: This helps prevent swarms of mons going to the same nest which looked weird)
|
||||
@@ -248,7 +260,7 @@ class Breed(
|
||||
|
||||
// make sure the nest type works for the mates and that wild use wild nests and owned pokemon use player placed nests
|
||||
private fun isNestTypeAllowed(nestType: WildNestType, entity: PokemonEntity, mate: PokemonEntity): Boolean {
|
||||
val allowed = WildNestTypes.combinedTypes(entity, mate).toMutableSet()
|
||||
val allowed = WildNestTypes.typesFor((CobblemonBreeding.getMother(entity.pokemon, mate.pokemon, isSimulated = true) ?: entity.pokemon).species).toMutableSet()
|
||||
if (!entity.pokemon.isWild() && !mate.pokemon.isWild()) {
|
||||
allowed.add(WildNestType.PLAYER)
|
||||
allowed.add(WildNestType.KELP)
|
||||
@@ -258,25 +270,14 @@ class Breed(
|
||||
return nestType in allowed
|
||||
}
|
||||
|
||||
// waterlogged nests only allow parents that both have a water egg group and land nests dont work for mates that only have water egg groups
|
||||
private fun isWaterGroupCompatible(entity: PokemonEntity, mate: PokemonEntity, nestWaterlogged: Boolean): Boolean {
|
||||
val mate1Groups = entity.pokemon.species.eggGroups.map { it.name.lowercase() }
|
||||
val mate2Groups = mate.pokemon.species.eggGroups.map { it.name.lowercase() }
|
||||
val mate1HasWaterGroup = mate1Groups.any { it in WATER_EGG_GROUPS || it == "ditto" }
|
||||
val mate2HasWaterGroup = mate2Groups.any { it in WATER_EGG_GROUPS || it == "ditto" }
|
||||
val mate1OnlyWaterGroup = mate1Groups.all { it in WATER_EGG_GROUPS }
|
||||
val mate2OnlyWaterGroup = mate2Groups.all { it in WATER_EGG_GROUPS }
|
||||
|
||||
return if (nestWaterlogged) mate1HasWaterGroup && mate2HasWaterGroup else !(mate1OnlyWaterGroup || mate2OnlyWaterGroup)
|
||||
}
|
||||
|
||||
class Config : ObjectiveConfig {
|
||||
val speedMultiplier: ExpressionOrEntityVariable = Either.left("0.4".asExpression())
|
||||
val condition: ExpressionOrEntityVariable = Either.left("true".asExpression())
|
||||
val layDurationTicks: ExpressionOrEntityVariable = Either.left("40".asExpression())
|
||||
val meetDurationTicks: ExpressionOrEntityVariable = Either.left("100".asExpression())
|
||||
|
||||
override fun getVariables(entity: LivingEntity, behaviourConfigurationContext: BehaviourConfigurationContext): List<MoLangConfigVariable> {
|
||||
return listOf(speedMultiplier, condition, layDurationTicks).asVariables()
|
||||
return listOf(speedMultiplier, condition, layDurationTicks, meetDurationTicks).asVariables()
|
||||
}
|
||||
|
||||
override fun create(entity: LivingEntity, behaviourConfigurationContext: BehaviourConfigurationContext): Objective {
|
||||
@@ -286,21 +287,24 @@ class Breed(
|
||||
CobblemonMemories.PATERNAL_NEST_LOCATION,
|
||||
CobblemonMemories.IDEAL_NEST_LOCATION,
|
||||
CobblemonMemories.EGG_IN_NEST,
|
||||
CobblemonMemories.MATES_MET,
|
||||
MemoryModuleType.ATTACK_TARGET
|
||||
)
|
||||
return Breed(
|
||||
speedMultiplier = speedMultiplier.asSimplifiedExpression(entity),
|
||||
condition = condition.asSimplifiedExpression(entity),
|
||||
layDurationTicks = layDurationTicks.resolveVariableInt(behaviourConfigurationContext.runtime)
|
||||
layDurationTicks = layDurationTicks.resolveVariableInt(behaviourConfigurationContext.runtime),
|
||||
meetDurationTicks = meetDurationTicks.resolveVariableInt(behaviourConfigurationContext.runtime)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// lets help those with more cushion for the pushing reach those nests to breed
|
||||
private fun closeEnough(entity: PokemonEntity) = CLOSE_ENOUGH_DISTANCE + entity.bbWidth / 2
|
||||
|
||||
companion object {
|
||||
private const val MATES_MET_TICKS = 2400L
|
||||
private const val CLOSE_ENOUGH_DISTANCE = 1.5 // we will have this be our baseline and then scale based on hitbox (like above) for the bigger mons
|
||||
private val WATER_EGG_GROUPS = setOf("water_1", "water_2", "water_3")
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -300,7 +300,7 @@ class DefendNest(
|
||||
description = "patrol method in DefendNest objective",
|
||||
lookingTracker = LookingTracker.fromNavigationPathOrWalkTarget(entity, tracker.walkTarget),
|
||||
movementTracker = tracker,
|
||||
onMovementComplete = { entity1, brain1, status -> patrolCooldownTicks = PATROL_PAUSE_TICKS + entity.random.nextInt(PATROL_PAUSE_RANDOM_TICKS) }
|
||||
onMovementComplete = { _, _ -> patrolCooldownTicks = PATROL_PAUSE_TICKS + entity.random.nextInt(PATROL_PAUSE_RANDOM_TICKS) }
|
||||
)
|
||||
)
|
||||
return ObjectiveStatus.FIXATED
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ import net.minecraft.world.entity.ai.memory.WalkTarget
|
||||
* Handles transition of nearest visible attacker to a valid attack target when wanting to defend owner.
|
||||
* Could possibly be more configurable in the future
|
||||
*/
|
||||
class DefendOwner : Objective {
|
||||
class DefendOwner() : Objective {
|
||||
var cooldownTicks = 0
|
||||
|
||||
override fun getDescription(entity: LivingEntity) = "Following parent species"
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ class Defensive(
|
||||
) : Objective {
|
||||
private var remainingCooldownTicks = 0
|
||||
private var trackedEntity: LivingEntity? = null
|
||||
override val observedMemories = listOf(MemoryModuleType.HURT_BY_ENTITY, CobblemonMemories.ATTACK_TARGET_DATA)
|
||||
|
||||
override fun getDescription(entity: LivingEntity) = "Defensive Behavior"
|
||||
|
||||
|
||||
+11
-17
@@ -13,7 +13,6 @@ import com.cobblemon.mod.common.api.ai.ExpressionOrEntityVariable
|
||||
import com.cobblemon.mod.common.api.ai.asVariables
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.BiggerBrain
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.Distraction
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.DistractionType
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.EntityFixation
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.PickupItem.Companion.dropItem
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.sense.PokemonItemSense.Companion.PICKUP_ITEMS
|
||||
@@ -68,8 +67,8 @@ class EatHeldItem(
|
||||
remainingCooldownTicks--
|
||||
return ObjectiveStatus.INACTIVE
|
||||
}
|
||||
val itemStack = entity.pokemon.heldItem()
|
||||
if (canEat(itemStack, entity) && brain.distract(distraction)) {
|
||||
val itemStack: ItemStack = entity.pokemon.heldItem()
|
||||
if (canEat(itemStack, entity)) {
|
||||
fixation = brain.fixate(EatHeldItemFixation(this))
|
||||
remainingCooldownTicks = 120
|
||||
return ObjectiveStatus.FIXATED
|
||||
@@ -91,7 +90,7 @@ class EatHeldItem(
|
||||
val itemStack: ItemStack = entity.pokemon.heldItem()
|
||||
val itemConfig = objective.pickupItems.findMatchingEntry(entity.registryAccess(), itemStack)
|
||||
if (objective.canEat(itemStack, entity)) {
|
||||
if (ticksRemaining-- < 0) {
|
||||
if (ticksRemaining < 0) {
|
||||
var resultItemStack = itemStack.finishUsingItem(world, entity)
|
||||
val configuredReturnItem = itemConfig?.returnItem
|
||||
resultItemStack = if (configuredReturnItem != ItemStack.EMPTY) ItemStack(BuiltInRegistries.ITEM.get(configuredReturnItem))
|
||||
@@ -118,15 +117,14 @@ class EatHeldItem(
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
if ((itemConfig?.fullnessValue ?: 0) > 0 && entity.random.nextFloat() < 0.4f) {
|
||||
} else if ((itemConfig?.fullnessValue ?: 0) > 0 && entity.random.nextFloat() < 0.4f) {
|
||||
ticksRemaining--
|
||||
entity.playSound(entity.getEatingSound(itemStack), 1.0f, 1.0f)
|
||||
world.broadcastEntityEvent(entity, 45.toByte())
|
||||
spawnFoodParticles(entity, itemStack)
|
||||
}
|
||||
return true
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -157,20 +155,16 @@ class EatHeldItem(
|
||||
override fun create(
|
||||
entity: LivingEntity,
|
||||
behaviourConfigurationContext: BehaviourConfigurationContext
|
||||
): Objective {
|
||||
): Objective? {
|
||||
var pickupItems = emptyList<ObtainableItem>()
|
||||
if (entity is PokemonEntity) {
|
||||
pickupItems = entity.config.getObjectList(PICKUP_ITEMS)
|
||||
pickupItems = entity.config.getObjectList<ObtainableItem>(PICKUP_ITEMS)
|
||||
}
|
||||
val cooldownTicks = cooldownTicks.resolveInt(behaviourConfigurationContext.runtime)
|
||||
return EatHeldItem(
|
||||
cooldownTicks = cooldownTicks,
|
||||
pickupItems = pickupItems
|
||||
)
|
||||
cooldownTicks = cooldownTicks,
|
||||
pickupItems = pickupItems
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val distraction = Distraction(DistractionType.IDLE_BOREDOM)
|
||||
}
|
||||
}
|
||||
-146
@@ -1,146 +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.api.ai.biggerbrain.objective
|
||||
|
||||
import com.bedrockk.molang.Expression
|
||||
import com.cobblemon.mod.common.api.ai.BehaviourConfigurationContext
|
||||
import com.cobblemon.mod.common.api.ai.ExpressionOrEntityVariable
|
||||
import com.cobblemon.mod.common.api.ai.asSimplifiedExpression
|
||||
import com.cobblemon.mod.common.api.ai.asVariables
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.BiggerBrain
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.LookingTracker
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.RegularMovementTracker
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.Distraction
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.DistractionType
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.EntityFixation
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.LookAndMoveFixation
|
||||
import com.cobblemon.mod.common.api.ai.config.objective.ObjectiveConfig
|
||||
import com.cobblemon.mod.common.api.ai.movement.MovementIntent
|
||||
import com.cobblemon.mod.common.api.ai.movement.TraversalPolicy
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMostSpecificMoLangValue
|
||||
import com.cobblemon.mod.common.api.npc.configuration.MoLangConfigVariable
|
||||
import com.cobblemon.mod.common.util.asExpression
|
||||
import com.cobblemon.mod.common.util.closestPosition
|
||||
import com.cobblemon.mod.common.util.getIsSubmerged
|
||||
import com.cobblemon.mod.common.util.mainThreadRuntime
|
||||
import com.cobblemon.mod.common.util.resolveFloat
|
||||
import com.cobblemon.mod.common.util.withQueryValue
|
||||
import com.mojang.datafixers.util.Either
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.util.Mth
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.memory.WalkTarget
|
||||
import net.minecraft.world.level.LevelReader
|
||||
import net.minecraft.world.level.block.Blocks
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType
|
||||
|
||||
class FindAir(
|
||||
val speedMultiplier: Expression,
|
||||
) : Objective {
|
||||
var fixation: EntityFixation? = null
|
||||
var cooldownTicks = 20
|
||||
override fun getDescription(entity: LivingEntity) = "Find air when submerged"
|
||||
override fun perform(
|
||||
entity: LivingEntity,
|
||||
brain: BiggerBrain,
|
||||
activeObjectiveTags: MutableSet<String>
|
||||
): ObjectiveStatus {
|
||||
if (entity !is PathfinderMob) {
|
||||
return ObjectiveStatus.INVALID
|
||||
} else if (brain.isFixation(fixation)) {
|
||||
return ObjectiveStatus.FIXATED
|
||||
}
|
||||
|
||||
fixation = null
|
||||
|
||||
if (!entity.getIsSubmerged() || entity.isInLava || cooldownTicks-- >= 0) {
|
||||
return ObjectiveStatus.INACTIVE
|
||||
}
|
||||
|
||||
cooldownTicks = 20
|
||||
|
||||
mainThreadRuntime.withQueryValue("entity", entity.asMostSpecificMoLangValue())
|
||||
val speedMultiplier = mainThreadRuntime.resolveFloat(speedMultiplier)
|
||||
|
||||
if (!brain.canDistract(distraction)) {
|
||||
return ObjectiveStatus.BLOCKED
|
||||
}
|
||||
|
||||
val iterable = BlockPos.betweenClosed(
|
||||
Mth.floor(entity.x - 4.0),
|
||||
entity.blockY - 1,
|
||||
Mth.floor(entity.z - 4.0),
|
||||
Mth.floor(entity.x + 4.0),
|
||||
Mth.floor(entity.y + 8.0),
|
||||
Mth.floor(entity.z + 4.0)
|
||||
)
|
||||
|
||||
val blockPos = entity.closestPosition(iterable) { isAirPos(entity.level(), it) }
|
||||
?: return ObjectiveStatus.INACTIVE
|
||||
|
||||
val walkTarget = WalkTarget(blockPos, speedMultiplier, 0)
|
||||
|
||||
val tracker = RegularMovementTracker.attempt(
|
||||
entity = entity,
|
||||
walkTarget = walkTarget,
|
||||
policy = TraversalPolicy.forIntent(
|
||||
entity = entity,
|
||||
intent = MovementIntent.URGENT,
|
||||
),
|
||||
)
|
||||
|
||||
if (tracker != null && brain.distract(distraction)) {
|
||||
brain.fixate(
|
||||
LookAndMoveFixation(
|
||||
distractionTypes = setOf(DistractionType.FORCE),
|
||||
description = "Finding air",
|
||||
lookingTracker = LookingTracker.fromNavigationPathOrWalkTarget(entity, walkTarget),
|
||||
movementTracker = tracker
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
return ObjectiveStatus.ACTIVE
|
||||
}
|
||||
|
||||
private fun isAirPos(world: LevelReader, pos: BlockPos): Boolean {
|
||||
val blockState = world.getBlockState(pos)
|
||||
val aboveState = world.getBlockState(pos.above())
|
||||
val notFluid = world.getFluidState(pos.above()).isEmpty || blockState.`is`(Blocks.BUBBLE_COLUMN)
|
||||
val canPathfindThroughAbove = aboveState.isPathfindable(PathComputationType.LAND)
|
||||
val solidBelow = !blockState.isPathfindable(PathComputationType.LAND)
|
||||
|
||||
return notFluid && canPathfindThroughAbove && solidBelow
|
||||
}
|
||||
|
||||
companion object {
|
||||
val distraction = Distraction(DistractionType.DAMAGE)
|
||||
}
|
||||
|
||||
class Config : ObjectiveConfig {
|
||||
val speedMultiplier: ExpressionOrEntityVariable = Either.left("0.5".asExpression())
|
||||
|
||||
override fun getVariables(
|
||||
entity: LivingEntity,
|
||||
behaviourConfigurationContext: BehaviourConfigurationContext
|
||||
): List<MoLangConfigVariable> {
|
||||
return listOf(speedMultiplier).asVariables()
|
||||
}
|
||||
|
||||
override fun create(
|
||||
entity: LivingEntity,
|
||||
behaviourConfigurationContext: BehaviourConfigurationContext
|
||||
): Objective {
|
||||
return FindAir(
|
||||
speedMultiplier = speedMultiplier.asSimplifiedExpression(entity),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -33,6 +33,7 @@ import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.behavior.EntityTracker
|
||||
import net.minecraft.world.entity.ai.memory.MemoryModuleType
|
||||
import net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities
|
||||
import net.minecraft.world.entity.ai.memory.WalkTarget
|
||||
|
||||
|
||||
@@ -54,6 +55,7 @@ class FriendlyBehaviour(
|
||||
) {
|
||||
private var remainingCooldownTicks = 0
|
||||
private var fixation: EntityFixation? = null
|
||||
override val observedMemories = listOf(MemoryModuleType.HURT_BY_ENTITY)
|
||||
private val closeEnoughDistance = 1.5
|
||||
private var remainingTicks = 0
|
||||
|
||||
@@ -155,7 +157,7 @@ class FriendlyBehaviour(
|
||||
),
|
||||
lookingTracker = LookingTracker.forTargetEntity(entity, trackedEntity!!),
|
||||
movementTracker = movementTracker,
|
||||
onMovementComplete = { entity1, brain1, status -> attemptFixation(entity, brain) } // maintains fixation between moving and looking
|
||||
onMovementComplete = { _, _ -> attemptFixation(entity, brain) } // maintains fixation between moving and looking
|
||||
)
|
||||
)
|
||||
return ObjectiveStatus.FIXATED
|
||||
|
||||
+3
-4
@@ -17,7 +17,6 @@ import com.cobblemon.mod.common.api.ai.asSimplifiedExpression
|
||||
import com.cobblemon.mod.common.api.ai.asVariables
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.BiggerBrain
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.LookingTracker
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.MovementStatus
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.RegularMovementTracker
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.Distraction
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.DistractionType
|
||||
@@ -271,7 +270,7 @@ class GatherNectar(
|
||||
}
|
||||
}
|
||||
|
||||
class DepositNectarInSaccharineLeavesFixation : EntityFixation {
|
||||
class DepositNectarInSaccharineLeavesFixation() : EntityFixation {
|
||||
var successfulPollinationTicks = 0
|
||||
var lastSoundPlayedTick = 0
|
||||
var hoverPos: Vec3? = null
|
||||
@@ -368,7 +367,7 @@ class GatherNectar(
|
||||
}
|
||||
}
|
||||
|
||||
fun onHiveMovementComplete(entity: LivingEntity, brain: BiggerBrain, status: MovementStatus?) {
|
||||
fun onHiveMovementComplete(entity: LivingEntity, brain: BiggerBrain) {
|
||||
if (entity !is PokemonEntity) return
|
||||
if(!tryEnterHive(entity)) {
|
||||
dropAndBlackListHive(entity)
|
||||
@@ -379,7 +378,7 @@ class GatherNectar(
|
||||
entity: PokemonEntity,
|
||||
blockPos: BlockPos,
|
||||
description : String,
|
||||
onMovementComplete : ((entity: LivingEntity, brain: BiggerBrain, status: MovementStatus?) -> Unit)? = null,
|
||||
onMovementComplete : ((entity: LivingEntity, brain: BiggerBrain) -> Unit)? = null,
|
||||
) : EntityFixation? {
|
||||
val speedMultiplier = mainThreadRuntime.resolveFloat(speedMultiplier)
|
||||
|
||||
|
||||
+15
-5
@@ -72,7 +72,10 @@ class GoToSleep(
|
||||
}
|
||||
entity.pokemon.status = PersistentStatusContainer(Statuses.SLEEP)
|
||||
}
|
||||
brain.setMemory(CobblemonMemories.POKEMON_SLEEPING, true)
|
||||
entity.brain.eraseMemory(MemoryModuleType.WALK_TARGET)
|
||||
entity.navigation.stop()
|
||||
entity.brain.setActiveActivityToFirstValid(listOf(CobblemonActivities.POKEMON_SLEEPING_ACTIVITY))
|
||||
entity.brain.setMemory(CobblemonMemories.POKEMON_SLEEPING, true)
|
||||
|
||||
// Become fixated
|
||||
fixation = brain.fixate(
|
||||
@@ -86,13 +89,20 @@ class GoToSleep(
|
||||
return ObjectiveStatus.BLOCKED
|
||||
}
|
||||
|
||||
|
||||
|
||||
class SleepFixation(
|
||||
val objective: GoToSleep,
|
||||
override val movementTracker: MovementTracker?,
|
||||
) : EntityFixation, MovementTrackerFixation {
|
||||
|
||||
override fun getDescription(entity: LivingEntity) = "Sleeping"
|
||||
override fun tickMovementFixation() = MovementStatus.PENDING
|
||||
override fun getDescription(entity: LivingEntity): String {
|
||||
return "Sleeping"
|
||||
}
|
||||
override fun tickMovementFixation(): MovementStatus? {
|
||||
return MovementStatus.PENDING
|
||||
}
|
||||
|
||||
override fun canDistract(distraction: Distraction, entity: LivingEntity): Boolean {
|
||||
if (distraction.isIdleBoredom) {
|
||||
return false
|
||||
@@ -102,13 +112,12 @@ class GoToSleep(
|
||||
}
|
||||
|
||||
override fun tick(entity: LivingEntity, brain: BiggerBrain): Boolean {
|
||||
if (brain.getMemory(CobblemonMemories.POKEMON_DROWSY) != true) {
|
||||
if (!entity.brain.getMemorySafely(CobblemonMemories.POKEMON_DROWSY).orElse(false)) {
|
||||
wakeUp(entity)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun wakeUp(entity: LivingEntity) {
|
||||
if (entity !is PokemonEntity) return
|
||||
val hasSleepStatus = entity.pokemon.status?.status == Statuses.SLEEP
|
||||
@@ -119,6 +128,7 @@ class GoToSleep(
|
||||
entity.pokemon.status = null
|
||||
}
|
||||
entity.brain.eraseMemory(CobblemonMemories.POKEMON_SLEEPING)
|
||||
entity.brain.useDefaultActivity()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+81
-43
@@ -15,22 +15,30 @@ import com.cobblemon.mod.common.api.ai.ExpressionOrEntityVariable
|
||||
import com.cobblemon.mod.common.api.ai.asSimplifiedExpression
|
||||
import com.cobblemon.mod.common.api.ai.asVariables
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.BiggerBrain
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.LookingTracker
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.MovementStatus
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.DistractionType
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.MovementTracker
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.RegularMovementTracker
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.Distraction
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.idleBoredomDistraction
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.EntityFixation
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.LookingTrackerFixation
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.MovementTrackerFixation
|
||||
import com.cobblemon.mod.common.api.ai.config.objective.ObjectiveConfig
|
||||
import com.cobblemon.mod.common.api.ai.resolveInt
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMostSpecificMoLangValue
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.util.asExpression
|
||||
import com.cobblemon.mod.common.util.distanceTo
|
||||
import com.cobblemon.mod.common.util.getMemorySafely
|
||||
import com.cobblemon.mod.common.util.mainThreadRuntime
|
||||
import com.cobblemon.mod.common.util.resolveFloat
|
||||
import com.cobblemon.mod.common.util.withQueryValue
|
||||
import com.mojang.datafixers.util.Either
|
||||
import net.minecraft.sounds.SoundEvents
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.memory.WalkTarget
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.Items
|
||||
import net.minecraft.world.level.GameRules
|
||||
@@ -71,11 +79,6 @@ class HarvestSweetBerryBush(
|
||||
return ObjectiveStatus.FIXATED
|
||||
}
|
||||
|
||||
if (!entity.level().gameRules.getRule(GameRules.RULE_MOBGRIEFING).get()) {
|
||||
// Not allowed to alter the world
|
||||
return ObjectiveStatus.INVALID
|
||||
}
|
||||
|
||||
val berryPosition = entity.biggerBrain.getMemory(CobblemonMemories.NEARBY_SWEET_BERRY_BUSH) ?: return ObjectiveStatus.INACTIVE
|
||||
|
||||
if (remainingCooldownTicks > 0) {
|
||||
@@ -85,58 +88,93 @@ class HarvestSweetBerryBush(
|
||||
|
||||
mainThreadRuntime.withQueryValue("entity", entity.asMostSpecificMoLangValue())
|
||||
val maxDistance = mainThreadRuntime.resolveFloat(maxDistance)
|
||||
val speedMultiplier = mainThreadRuntime.resolveFloat(speedMultiplier)
|
||||
|
||||
val distance = entity.distanceTo(berryPosition)
|
||||
if (distance < maxDistance) {
|
||||
if (remainingCooldownTicks <= 0 && brain.canDistract(idleBoredomDistraction)) {
|
||||
if (remainingCooldownTicks <= 0 && brain.distract(idleBoredomDistraction)) {
|
||||
remainingCooldownTicks = ticksBetweenAttempts
|
||||
val (fixation, status) = brain.tryMovementFixation(
|
||||
blockPos = { berryPosition },
|
||||
closeEnoughDistance = 1,
|
||||
speedMultiplier = speedMultiplier,
|
||||
distraction = idleBoredomDistraction,
|
||||
distractionTypes = setOf(DistractionType.FORCE, DistractionType.DAMAGE, DistractionType.COMFORT),
|
||||
description = "Harvesting sweet/glow berry",
|
||||
onMovementStopped = ::onPathingStopped
|
||||
val movementTracker = RegularMovementTracker.attempt(
|
||||
entity = entity,
|
||||
walkTarget = WalkTarget(
|
||||
berryPosition,
|
||||
speedMultiplier,
|
||||
1
|
||||
)
|
||||
)
|
||||
this.harvestTask = fixation
|
||||
return status
|
||||
if (movementTracker != null) {
|
||||
harvestTask = brain.fixate(
|
||||
fixation = HarvestSweetBerryBushFixation(
|
||||
entity = entity,
|
||||
movementTracker = movementTracker
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return ObjectiveStatus.ACTIVE
|
||||
}
|
||||
|
||||
private fun onPathingStopped(entity: LivingEntity, brain: BiggerBrain, status: MovementStatus?) {
|
||||
if (entity !is PokemonEntity) {
|
||||
return
|
||||
|
||||
class HarvestSweetBerryBushFixation(
|
||||
entity: PathfinderMob,
|
||||
override val movementTracker: MovementTracker,
|
||||
): EntityFixation, LookingTrackerFixation, MovementTrackerFixation {
|
||||
|
||||
|
||||
override val lookingTracker: LookingTracker = LookingTracker(entity = entity, lookTarget = movementTracker.walkTarget.target)
|
||||
override fun getDescription(entity: LivingEntity) = "Harvesting sweet/glow berry"
|
||||
override fun canDistract(distraction: Distraction, entity: LivingEntity): Boolean {
|
||||
return distraction.isDamage || distraction.isForce || (movementTracker.lastStatus == MovementStatus.COMPLETED && entity.brain.getMemorySafely(
|
||||
CobblemonMemories.NEARBY_SWEET_BERRY_BUSH).orElse(null) != null)
|
||||
}
|
||||
|
||||
if (status == MovementStatus.COMPLETED) {
|
||||
val world = entity.level()
|
||||
val blockPos = brain.getMemory(CobblemonMemories.NEARBY_SWEET_BERRY_BUSH) ?: return
|
||||
val blockState = world.getBlockState(blockPos)
|
||||
if (CaveVines.hasGlowBerries(blockState)) { // Glow Berries Case
|
||||
CaveVines.use(entity, blockState, world, blockPos)
|
||||
} else if (blockState.`is`(Blocks.SWEET_BERRY_BUSH)) { // Sweet Berries Case
|
||||
blockState.setValue(SweetBerryBushBlock.AGE, 1)
|
||||
var j: Int = 1 + entity.level().random.nextInt(2) + if (blockState.getValue<Int>(SweetBerryBushBlock.AGE) == 3) 1 else 0
|
||||
val itemStack: ItemStack = entity.pokemon.heldItem
|
||||
if (itemStack.isEmpty) {
|
||||
entity.pokemon.swapHeldItem(ItemStack(Items.SWEET_BERRIES))
|
||||
--j
|
||||
override fun onDistract(distraction: Distraction, entity: LivingEntity) {
|
||||
movementTracker.stop()
|
||||
}
|
||||
|
||||
override fun tick(entity: LivingEntity, brain: BiggerBrain): Boolean {
|
||||
lookingTracker.tick()
|
||||
movementTracker.tick()
|
||||
|
||||
if (movementTracker.lastStatus == MovementStatus.COMPLETED) {
|
||||
val world = entity.level()
|
||||
|
||||
if (entity !is PokemonEntity) return false
|
||||
|
||||
if (!world.gameRules.getRule(GameRules.RULE_MOBGRIEFING).get()) {
|
||||
// Not allowed to alter the world
|
||||
return false
|
||||
}
|
||||
if (j > 0) {
|
||||
Block.popResource(entity.level(), blockPos, ItemStack(Items.SWEET_BERRIES, j))
|
||||
val blockPos = entity.brain.getMemory(CobblemonMemories.NEARBY_SWEET_BERRY_BUSH).orElse(null) ?: return false
|
||||
val blockState = world.getBlockState(blockPos)
|
||||
if (CaveVines.hasGlowBerries(blockState)) { // Glow Berries Case
|
||||
CaveVines.use(entity, blockState, world, blockPos)
|
||||
} else if (blockState.`is`(Blocks.SWEET_BERRY_BUSH)) { // Sweet Berries Case
|
||||
blockState.setValue(SweetBerryBushBlock.AGE, 1)
|
||||
var j: Int = 1 + entity.level().random.nextInt(2) + if (blockState.getValue<Int>(SweetBerryBushBlock.AGE) == 3) 1 else 0
|
||||
val itemStack: ItemStack = entity.pokemon.heldItem
|
||||
if (itemStack.isEmpty) {
|
||||
entity.pokemon.swapHeldItem(ItemStack(Items.SWEET_BERRIES))
|
||||
--j
|
||||
}
|
||||
if (j > 0) {
|
||||
Block.popResource(entity.level(), blockPos, ItemStack(Items.SWEET_BERRIES, j))
|
||||
}
|
||||
entity.playSound(SoundEvents.SWEET_BERRY_BUSH_PICK_BERRIES, 1.0f, 1.0f)
|
||||
entity.level().setBlock(blockPos, blockState.setValue(SweetBerryBushBlock.AGE, 1) as BlockState, 2)
|
||||
entity.level().gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(entity))
|
||||
}
|
||||
entity.playSound(SoundEvents.SWEET_BERRY_BUSH_PICK_BERRIES, 1.0f, 1.0f)
|
||||
entity.level().setBlock(blockPos, blockState.setValue(SweetBerryBushBlock.AGE, 1) as BlockState, 2)
|
||||
entity.level().gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(entity))
|
||||
entity.brain.eraseMemory(CobblemonMemories.NEARBY_SWEET_BERRY_BUSH)
|
||||
return false
|
||||
} else if (movementTracker.lastStatus == MovementStatus.FAILED) {
|
||||
// Cannot reach, give up for a awhile
|
||||
entity.brain.setMemoryWithExpiry(CobblemonMemories.DISABLE_WALK_TO_BERRY_BUSH, true, 200)
|
||||
entity.brain.eraseMemory(CobblemonMemories.NEARBY_SWEET_BERRY_BUSH)
|
||||
return false
|
||||
}
|
||||
brain.eraseMemory(CobblemonMemories.NEARBY_SWEET_BERRY_BUSH)
|
||||
} else if (status == MovementStatus.FAILED) {
|
||||
// Cannot reach, give up for a while
|
||||
brain.setMemory(CobblemonMemories.DISABLE_WALK_TO_BERRY_BUSH, true, 200)
|
||||
brain.eraseMemory(CobblemonMemories.NEARBY_SWEET_BERRY_BUSH)
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -49,7 +49,7 @@ class MoveIntoWater(
|
||||
var isWanderTurnDirectionClockwise = true
|
||||
var wanderTurnChance = BASE_TURN_CHANCE
|
||||
var failCount = 0
|
||||
override fun getDescription(entity: LivingEntity) = "Return to water"
|
||||
override fun getDescription(entity: LivingEntity) = "Move into water if currently out of water"
|
||||
override fun perform(
|
||||
entity: LivingEntity,
|
||||
brain: BiggerBrain,
|
||||
@@ -84,12 +84,12 @@ class MoveIntoWater(
|
||||
val runtime = mainThreadRuntime
|
||||
val wanderControl = entity.brain.getMemorySafely(CobblemonMemories.WANDER_CONTROL).orElse(null)
|
||||
val allowLand = wanderControl?.allowLand
|
||||
?: runtime.resolveBoolean("(q.entity.movement.can_walk && q.entity.movement.avoids_land) || q.entity.movement.can_fly".asExpression())
|
||||
?: runtime.resolveBoolean("(q.entity.behaviour.moving.walk.can_walk && q.entity.behaviour.moving.walk.avoids_land) || q.entity.behaviour.moving.fly.can_fly".asExpression())
|
||||
val allowAir = wanderControl?.allowAir
|
||||
?: runtime.resolveBoolean("q.entity.movement.can_fly && !q.entity.movement.can_walk".asExpression())
|
||||
?: runtime.resolveBoolean("q.entity.behaviour.moving.fly.can_fly && !q.entity.behaviour.moving.walk.can_walk".asExpression())
|
||||
|
||||
val types = mutableSetOf<WanderType>()
|
||||
if (!(allowLand || allowAir)) {
|
||||
if ((allowLand || allowAir)) {
|
||||
types.add(WanderType.WATER)
|
||||
}
|
||||
|
||||
@@ -215,8 +215,7 @@ class MoveIntoWater(
|
||||
override fun tick(entity: LivingEntity, brain: BiggerBrain): Boolean {
|
||||
val movementStatus = tickMovementFixation()
|
||||
if (movementStatus == MovementStatus.COMPLETED) return false
|
||||
// We're done, yay!
|
||||
if (entity.isInWater) {
|
||||
if (!entity.isInWater) {
|
||||
return false
|
||||
}
|
||||
return movementStatus != MovementStatus.FAILED
|
||||
|
||||
+21
-11
@@ -55,21 +55,27 @@ class MoveOutOfWater(
|
||||
brain: BiggerBrain,
|
||||
activeObjectiveTags: MutableSet<String>
|
||||
): ObjectiveStatus {
|
||||
brain.checkObjectivePrerequisites<TamableAnimal>(
|
||||
cooldownTicks = remainingCooldownTicks--,
|
||||
fixation = movementTask,
|
||||
ifIneligible = { remainingCooldownTicks = ticksBetweenAttempts }
|
||||
)?.let { return it }
|
||||
|
||||
entity as TamableAnimal
|
||||
if (entity !is TamableAnimal) {
|
||||
return ObjectiveStatus.INVALID
|
||||
}
|
||||
|
||||
if (brain.isFixation(movementTask)) {
|
||||
remainingCooldownTicks = ticksBetweenAttempts
|
||||
return ObjectiveStatus.FIXATED
|
||||
}
|
||||
if (!entity.isInWater || entity.isUnderWater) {
|
||||
// Focus on not drowning first
|
||||
// TODO: 100% boned if in an underwater cave
|
||||
return ObjectiveStatus.INACTIVE
|
||||
}
|
||||
|
||||
remainingCooldownTicks = ticksBetweenAttempts
|
||||
|
||||
if (remainingCooldownTicks > 0) {
|
||||
remainingCooldownTicks--
|
||||
return ObjectiveStatus.INACTIVE
|
||||
} else {
|
||||
remainingCooldownTicks = ticksBetweenAttempts
|
||||
}
|
||||
|
||||
val maxDistance = mainThreadRuntime.resolveInt(maxDistance)
|
||||
val speedMultiplier = mainThreadRuntime.resolveFloat(speedMultiplier)
|
||||
@@ -77,15 +83,16 @@ class MoveOutOfWater(
|
||||
val runtime = mainThreadRuntime
|
||||
val wanderControl = entity.brain.getMemorySafely(CobblemonMemories.WANDER_CONTROL).orElse(null)
|
||||
val allowLand = wanderControl?.allowLand
|
||||
?: runtime.resolveBoolean("(q.entity.movement.can_walk && !q.entity.movement.avoids_land) || q.entity.movement.can_fly".asExpression())
|
||||
?: runtime.resolveBoolean("(q.entity.behaviour.moving.walk.can_walk && !q.entity.behaviour.moving.walk.avoids_land) || q.entity.behaviour.moving.fly.can_fly".asExpression())
|
||||
val allowAir = wanderControl?.allowAir
|
||||
?: runtime.resolveBoolean("q.entity.movement.can_fly && !q.entity.movement.can_walk".asExpression())
|
||||
?: runtime.resolveBoolean("q.entity.behaviour.moving.fly.can_fly && !q.entity.behaviour.moving.walk.can_walk".asExpression())
|
||||
|
||||
val types = mutableSetOf<WanderType>()
|
||||
if ((allowLand || allowAir)) {
|
||||
types.add(WanderType.LAND)
|
||||
}
|
||||
|
||||
|
||||
if (types.isEmpty()) {
|
||||
return ObjectiveStatus.INACTIVE
|
||||
}
|
||||
@@ -97,7 +104,10 @@ class MoveOutOfWater(
|
||||
walkTarget = CobblemonWalkTarget(
|
||||
BlockPos.containing(targetVec3.x, targetVec3.y, targetVec3.z),
|
||||
speedMultiplier,
|
||||
0
|
||||
0,
|
||||
nodeTypeFilter = { nodeType ->
|
||||
true
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+53
-29
@@ -10,27 +10,19 @@ package com.cobblemon.mod.common.api.ai.biggerbrain.objective
|
||||
|
||||
import com.bedrockk.molang.Expression
|
||||
import com.cobblemon.mod.common.CobblemonMemories
|
||||
import com.cobblemon.mod.common.api.ai.BehaviourConfigurationContext
|
||||
import com.cobblemon.mod.common.api.ai.ExpressionOrEntityVariable
|
||||
import com.cobblemon.mod.common.api.ai.asSimplifiedExpression
|
||||
import com.cobblemon.mod.common.api.ai.asVariables
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.BiggerBrain
|
||||
import com.cobblemon.mod.common.api.ai.*
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.*
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.Distraction
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.comfortDistraction
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.EntityFixation
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.MovementTrackerFixation
|
||||
import com.cobblemon.mod.common.api.ai.config.objective.ObjectiveConfig
|
||||
import com.cobblemon.mod.common.api.ai.movement.MovementIntent
|
||||
import com.cobblemon.mod.common.api.ai.movement.TraversalPolicy
|
||||
import com.cobblemon.mod.common.api.ai.resolveInt
|
||||
import com.cobblemon.mod.common.api.pokemon.status.Statuses
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.util.asExpression
|
||||
import com.cobblemon.mod.common.util.getBlockPositions
|
||||
import com.cobblemon.mod.common.util.mainThreadRuntime
|
||||
import com.cobblemon.mod.common.util.random
|
||||
import com.cobblemon.mod.common.util.resolveBoolean
|
||||
import com.cobblemon.mod.common.util.resolveDouble
|
||||
import com.cobblemon.mod.common.util.*
|
||||
import com.mojang.datafixers.util.Either
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.ai.memory.WalkTarget
|
||||
import net.minecraft.world.phys.AABB
|
||||
|
||||
|
||||
@@ -87,26 +79,58 @@ class MoveToRestingPlace(
|
||||
val hSearchDistance = mainThreadRuntime.resolveDouble(horizontalSearchDistance)
|
||||
val vSearchDistance = mainThreadRuntime.resolveDouble(verticalSearchDistance)
|
||||
|
||||
val (movementTask, status) = brain.tryMovementFixation(
|
||||
blockPos = {
|
||||
val positionList = entity.level()
|
||||
.getBlockPositions(AABB.ofSize(entity.position(), hSearchDistance, vSearchDistance, hSearchDistance))
|
||||
.filter(entity::canSleepAt)
|
||||
if (positionList.isEmpty()) null else positionList.random(1).firstOrNull()
|
||||
},
|
||||
speedMultiplier = speedMultiplier,
|
||||
closeEnoughDistance = 0,
|
||||
traversalPolicy = { TraversalPolicy.forIntent(entity, MovementIntent.IDLE) },
|
||||
description = "Moving to a resting place",
|
||||
distraction = comfortDistraction
|
||||
)
|
||||
val positionList = entity.level()
|
||||
.getBlockPositions(AABB.ofSize(entity.position(), hSearchDistance, vSearchDistance, hSearchDistance))
|
||||
.filter(entity::canSleepAt)
|
||||
val position = if (positionList.isEmpty()) null else positionList.random(1).firstOrNull()
|
||||
|
||||
this.movementTask = movementTask
|
||||
return status
|
||||
if (position != null && brain.distract(comfortDistraction)) {
|
||||
val speedMultiplier = mainThreadRuntime.resolveFloat(speedMultiplier)
|
||||
val movementTracker = RegularMovementTracker.attempt(
|
||||
entity = entity,
|
||||
walkTarget = WalkTarget(
|
||||
position,
|
||||
speedMultiplier,
|
||||
0
|
||||
)
|
||||
)
|
||||
if (movementTracker != null) {
|
||||
// Become fixated
|
||||
movementTask = brain.fixate(
|
||||
fixation = MoveToRestingPlaceFixation(
|
||||
movementTracker = movementTracker,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
} else {
|
||||
return ObjectiveStatus.INACTIVE
|
||||
}
|
||||
return ObjectiveStatus.ACTIVE
|
||||
}
|
||||
return ObjectiveStatus.INACTIVE
|
||||
}
|
||||
|
||||
|
||||
class MoveToRestingPlaceFixation(
|
||||
override val movementTracker: MovementTracker,
|
||||
) : EntityFixation, MovementTrackerFixation {
|
||||
override fun getDescription(entity: LivingEntity) = "Moving to a resting place"
|
||||
override fun canDistract(distraction: Distraction, entity: LivingEntity): Boolean {
|
||||
return distraction.isDamage || distraction.isForce || movementTracker.lastStatus == MovementStatus.COMPLETED
|
||||
}
|
||||
|
||||
override fun onDistract(distraction: Distraction, entity: LivingEntity) {
|
||||
movementTracker.stop()
|
||||
}
|
||||
|
||||
override fun tick(entity: LivingEntity, brain: BiggerBrain): Boolean {
|
||||
val movementStatus = tickMovementFixation()
|
||||
if (movementStatus == MovementStatus.COMPLETED) return false
|
||||
return movementStatus != MovementStatus.FAILED
|
||||
}
|
||||
}
|
||||
|
||||
class Config : ObjectiveConfig {
|
||||
val ticksBetweenAttempts: ExpressionOrEntityVariable = Either.left("60".asExpression())
|
||||
val horizontalSearchDistance: ExpressionOrEntityVariable = Either.left("10.0".asExpression())
|
||||
|
||||
+2
-1
@@ -51,6 +51,7 @@ class NeutralBehaviour(
|
||||
targetCondition = targetCondition, // target condition (will be checked on entity interaction)
|
||||
description = description,
|
||||
) {
|
||||
override val observedMemories = listOf(MemoryModuleType.HURT_BY_ENTITY, CobblemonMemories.ATTACK_TARGET_DATA)
|
||||
private var fixation: EntityFixation? = null
|
||||
|
||||
override fun perform(
|
||||
@@ -163,7 +164,7 @@ class NeutralBehaviour(
|
||||
): Objective {
|
||||
return NeutralBehaviour(
|
||||
condition = condition.asSimplifiedExpression(entity),
|
||||
targetCondition = targetCondition.asSimplifiedExpression(entity),
|
||||
targetCondition = condition.asSimplifiedExpression(entity),
|
||||
speedMultiplier = speedMultiplier.asSimplifiedExpression(entity),
|
||||
engageRange = engageRange.asSimplifiedExpression(entity),
|
||||
disengageRange = disengageRange.asSimplifiedExpression(entity),
|
||||
|
||||
+5
@@ -10,6 +10,7 @@ package com.cobblemon.mod.common.api.ai.biggerbrain.objective
|
||||
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.BiggerBrain
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.ai.memory.MemoryModuleType
|
||||
|
||||
/**
|
||||
* An ongoing priority for an entity. Objectives are managed by the [BiggerBrain] system. Objectives can act out
|
||||
@@ -28,6 +29,10 @@ interface Objective {
|
||||
val OBJECTIVE_TAG_WANDERING = "WANDERING"
|
||||
}
|
||||
|
||||
/** The memory types that, upon being changed, should trigger [onMemoryChanged]. */
|
||||
val observedMemories: List<MemoryModuleType<*>>
|
||||
get() = emptyList()
|
||||
|
||||
/** Gets a current description for this objective. This is purely used for the debug overlay. */
|
||||
fun getDescription(entity: LivingEntity): String
|
||||
/** Performs this objective's logic for a tick. */
|
||||
|
||||
+2
-4
@@ -110,7 +110,6 @@ class PickupItem(
|
||||
val lookingTracker = LookingTracker(entity = entity, lookTarget = movementTracker.walkTarget.target)
|
||||
collectItemTask = brain.fixate(
|
||||
fixation = PickupItemFixation(
|
||||
brain = brain,
|
||||
objective = this,
|
||||
itemEntity = itemEntity,
|
||||
movementTracker = movementTracker,
|
||||
@@ -141,7 +140,6 @@ class PickupItem(
|
||||
}
|
||||
|
||||
class PickupItemFixation(
|
||||
val brain: BiggerBrain,
|
||||
val objective: PickupItem,
|
||||
val itemEntity: ItemEntity,
|
||||
override val movementTracker: MovementTracker,
|
||||
@@ -150,8 +148,8 @@ class PickupItem(
|
||||
|
||||
override fun getDescription(entity: LivingEntity) = "Moving to desired item"
|
||||
override fun canDistract(distraction: Distraction, entity: LivingEntity): Boolean {
|
||||
return distraction.isDamage || distraction.isForce
|
||||
|| (movementTracker.lastStatus == MovementStatus.COMPLETED && brain.getMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM) != null)
|
||||
return distraction.isDamage || distraction.isForce || (movementTracker.lastStatus == MovementStatus.COMPLETED && entity.brain.getMemorySafely(
|
||||
CobblemonMemories.NEARBY_SWEET_BERRY_BUSH).orElse(null) != null)
|
||||
}
|
||||
|
||||
override fun onDistract(distraction: Distraction, entity: LivingEntity) {
|
||||
|
||||
+1
@@ -38,6 +38,7 @@ class SkittishBehaviour(
|
||||
description = description,
|
||||
) {
|
||||
private var remainingCooldownTicks = 0
|
||||
override val observedMemories = listOf(MemoryModuleType.HURT_BY_ENTITY, CobblemonMemories.ATTACK_TARGET_DATA)
|
||||
|
||||
override fun perform(
|
||||
entity: LivingEntity,
|
||||
|
||||
+1
-5
@@ -24,8 +24,6 @@ import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.EntityFixation
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.LookingTrackerFixation
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.MovementTrackerFixation
|
||||
import com.cobblemon.mod.common.api.ai.config.objective.ObjectiveConfig
|
||||
import com.cobblemon.mod.common.api.ai.movement.MovementIntent
|
||||
import com.cobblemon.mod.common.api.ai.movement.TraversalPolicy
|
||||
import com.cobblemon.mod.common.api.ai.resolveInt
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMostSpecificMoLangValue
|
||||
import com.cobblemon.mod.common.util.asExpression
|
||||
@@ -113,9 +111,7 @@ class StayNearOwner(
|
||||
owner,
|
||||
speedMultiplier,
|
||||
maxOf(completionRange, ceil(horizontalHitboxRadius).toInt()) - 1
|
||||
),
|
||||
// Will put up with some discomfort to keep up, but not as much as when chasing something.
|
||||
policy = TraversalPolicy.forIntent(entity, MovementIntent.COMFORT)
|
||||
)
|
||||
)
|
||||
if (movementTracker != null) {
|
||||
followTask = brain.fixate(
|
||||
|
||||
+1
@@ -58,6 +58,7 @@ class TerritorialBehaviour(
|
||||
|
||||
private var remainingCooldownTicks = 0
|
||||
private val objectiveDescription: String = mainThreadRuntime.resolveString(description)
|
||||
override val observedMemories = listOf(MemoryModuleType.HURT_BY_ENTITY, CobblemonMemories.ATTACK_TARGET_DATA)
|
||||
private var cryCooldownTicks = 0
|
||||
private var proximityAttackCooldown = 0
|
||||
private var satiationHitCount = 999
|
||||
|
||||
-224
@@ -1,224 +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.api.ai.biggerbrain.objective
|
||||
|
||||
import com.cobblemon.mod.common.api.ai.BehaviourConfigurationContext
|
||||
import com.cobblemon.mod.common.api.ai.ExpressionOrEntityVariable
|
||||
import com.cobblemon.mod.common.api.ai.asVariables
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.BiggerBrain
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.MovementStatus
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.MovementTracker
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.RegularMovementTracker
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.Distraction
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.EntityFixation
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.MovementTrackerFixation
|
||||
import com.cobblemon.mod.common.api.ai.config.objective.ObjectiveConfig
|
||||
import com.cobblemon.mod.common.api.ai.movement.FluidKind
|
||||
import com.cobblemon.mod.common.api.ai.movement.MovementCapabilities
|
||||
import com.cobblemon.mod.common.api.ai.movement.Occupancy
|
||||
import com.cobblemon.mod.common.api.ai.movement.TraversalPolicy
|
||||
import com.cobblemon.mod.common.api.ai.resolveFloat
|
||||
import com.cobblemon.mod.common.api.ai.resolveInt
|
||||
import com.cobblemon.mod.common.entity.ai.OmniPathNavigation
|
||||
import com.cobblemon.mod.common.util.asExpression
|
||||
import com.mojang.datafixers.util.Either
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.memory.WalkTarget
|
||||
|
||||
/**
|
||||
* Gets the entity out of a fluid that's killing it:
|
||||
* - A fluid it can neither swim nor breathe in, once its head is under. It sinks, and this looks for a route along the
|
||||
* bottom to anywhere its head would be above the surface, preferring the route that spends the least time under.
|
||||
* - Lava, when it isn't fire immune. Everything can swim in lava, so this looks for the quickest way to dry land or,
|
||||
* failing that, water.
|
||||
*
|
||||
* If there's no route, nothing is done about it and the entity drowns or burns. Once a route is found, the entity is
|
||||
* committed to it: damage and forceful distractions don't interrupt it while it's still in danger.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since September 30th, 2026
|
||||
*/
|
||||
class WalkOutOfWater(
|
||||
/** How far horizontally to look for somewhere to surface. */
|
||||
val horizontalRange: Int = 12,
|
||||
/** How far above the entity to look for somewhere to surface. */
|
||||
val verticalRange: Int = 12,
|
||||
/** How many of the closest exits to hand to the pathfinder. More exits make the search slower. */
|
||||
val maxExits: Int = 48,
|
||||
val speedMultiplier: Float = 0.4F,
|
||||
/**
|
||||
* How many times a route may be searched for while submerged. A search that finds nothing ends the attempt
|
||||
* outright; extra searches are only for when a found route gets blocked along the way.
|
||||
*/
|
||||
val maxSearches: Int = 3,
|
||||
) : Objective {
|
||||
var fixation: EntityFixation? = null
|
||||
/** Searches done since the entity's head last went under. */
|
||||
var searches = 0
|
||||
/** Set when a search found no way out. Reset once the entity's head is out of the fluid. */
|
||||
var gaveUp = false
|
||||
|
||||
override fun getDescription(entity: LivingEntity) = when {
|
||||
gaveUp -> "Escape deadly fluid (no way out)"
|
||||
else -> "Escape deadly fluid"
|
||||
}
|
||||
|
||||
override fun perform(
|
||||
entity: LivingEntity,
|
||||
brain: BiggerBrain,
|
||||
activeObjectiveTags: MutableSet<String>
|
||||
): ObjectiveStatus {
|
||||
if (entity !is PathfinderMob || entity.navigation !is OmniPathNavigation) {
|
||||
return ObjectiveStatus.INVALID
|
||||
}
|
||||
|
||||
// Cheap check first since this runs every tick for every Pokémon.
|
||||
val capabilities = if (entity.isInWater || entity.isInLava) MovementCapabilities.of(entity) else null
|
||||
val danger = capabilities?.let { deadlyFluid(entity, it) } ?: FluidKind.NONE
|
||||
if (capabilities == null || danger == FluidKind.NONE) {
|
||||
searches = 0
|
||||
gaveUp = false
|
||||
return if (brain.isFixation(fixation)) ObjectiveStatus.FIXATED else ObjectiveStatus.INACTIVE
|
||||
}
|
||||
|
||||
if (brain.isFixation(fixation)) {
|
||||
return ObjectiveStatus.FIXATED
|
||||
} else if (gaveUp || searches >= maxSearches) {
|
||||
return ObjectiveStatus.INACTIVE
|
||||
} else if (!brain.canDistract(Distraction.FORCE)) {
|
||||
return ObjectiveStatus.BLOCKED
|
||||
}
|
||||
|
||||
searches++
|
||||
val navigation = entity.navigation as OmniPathNavigation
|
||||
val policy = TraversalPolicy.escapeFluid(entity, danger)
|
||||
val searchRange = horizontalRange * 1.5F + verticalRange
|
||||
// Dry land first so the escape doesn't end knee-deep, then anywhere else that's safe.
|
||||
val isDryLand: (Occupancy, FluidKind) -> Boolean = { occupancy, fluid -> occupancy == Occupancy.WALK && fluid == FluidKind.NONE }
|
||||
val isSafe: (Occupancy, FluidKind) -> Boolean = when (danger) {
|
||||
// Wading in it is fine since the head's out. Lava is never a way out of water.
|
||||
FluidKind.LAVA -> { occupancy, fluid -> fluid != FluidKind.LAVA && policy.allows(occupancy, fluid) }
|
||||
else -> { occupancy, fluid -> occupancy == Occupancy.WADE && fluid == danger }
|
||||
}
|
||||
val path = sequenceOf(isDryLand, isSafe)
|
||||
.map { findExits(entity, capabilities, it) }
|
||||
.filter { it.isNotEmpty() }
|
||||
.mapNotNull { navigation.planPath(it, 0, policy, searchRange) }
|
||||
.firstOrNull { it.canReach() }
|
||||
|
||||
if (path == null) {
|
||||
gaveUp = true
|
||||
return ObjectiveStatus.INACTIVE
|
||||
}
|
||||
|
||||
val walkTarget = WalkTarget(path.target, speedMultiplier, 0)
|
||||
val tracker = RegularMovementTracker.following(entity, walkTarget, path, policy)
|
||||
if (tracker == null) {
|
||||
gaveUp = true
|
||||
return ObjectiveStatus.INACTIVE
|
||||
}
|
||||
// Only interrupt whatever else was going on once there's actually somewhere to go.
|
||||
brain.distract(Distraction.FORCE)
|
||||
fixation = brain.fixate(WalkOutOfWaterFixation(capabilities, tracker))
|
||||
return ObjectiveStatus.FIXATED
|
||||
}
|
||||
|
||||
/**
|
||||
* Nearby positions matching [accepts], closest first. Only positions the entity could be in are considered;
|
||||
* whether they can be reached is left to the pathfinder.
|
||||
*/
|
||||
private fun findExits(
|
||||
entity: PathfinderMob,
|
||||
capabilities: MovementCapabilities,
|
||||
accepts: (Occupancy, FluidKind) -> Boolean
|
||||
): Set<BlockPos> {
|
||||
val level = entity.level()
|
||||
val origin = entity.blockPosition()
|
||||
val exits = mutableListOf<BlockPos>()
|
||||
// Hardly anything below is useful: the way out of water is up the bank, not into a cave under the bed.
|
||||
for (pos in BlockPos.betweenClosed(
|
||||
origin.offset(-horizontalRange, -MAX_EXIT_DEPTH_BELOW, -horizontalRange),
|
||||
origin.offset(horizontalRange, verticalRange, horizontalRange)
|
||||
)) {
|
||||
val occupancy = Occupancy.at(capabilities, entity.eyeHeight, pos, level::getBlockState) ?: continue
|
||||
if (occupancy.isStandable && accepts(occupancy, FluidKind.of(level.getFluidState(pos)))) {
|
||||
exits.add(pos.immutable())
|
||||
}
|
||||
}
|
||||
// Closest horizontally so that exits straight overhead (unreachable cliff tops) don't crowd out the shore.
|
||||
return exits
|
||||
.sortedBy { (it.x - origin.x) * (it.x - origin.x) + (it.z - origin.z) * (it.z - origin.z) }
|
||||
.take(maxExits)
|
||||
.toSet()
|
||||
}
|
||||
|
||||
class WalkOutOfWaterFixation(
|
||||
private val capabilities: MovementCapabilities,
|
||||
override val movementTracker: MovementTracker
|
||||
) : EntityFixation, MovementTrackerFixation {
|
||||
override fun getDescription(entity: LivingEntity) = "Escaping deadly fluid"
|
||||
|
||||
override fun canDistract(distraction: Distraction, entity: LivingEntity): Boolean {
|
||||
// Nothing is more important than surviving, but once out of danger it's fair game.
|
||||
return deadlyFluid(entity, capabilities) == FluidKind.NONE
|
||||
}
|
||||
|
||||
override fun onDistract(distraction: Distraction, entity: LivingEntity) {
|
||||
movementTracker.stop()
|
||||
}
|
||||
|
||||
override fun tick(entity: LivingEntity, brain: BiggerBrain): Boolean {
|
||||
// Keeps going after surfacing, but by then canDistract lets anything more interesting take over.
|
||||
return tickMovementFixation() == MovementStatus.PENDING
|
||||
}
|
||||
}
|
||||
|
||||
class Config : ObjectiveConfig {
|
||||
val horizontalRange: ExpressionOrEntityVariable = Either.left("12".asExpression())
|
||||
val verticalRange: ExpressionOrEntityVariable = Either.left("12".asExpression())
|
||||
val maxExits: ExpressionOrEntityVariable = Either.left("48".asExpression())
|
||||
val speedMultiplier: ExpressionOrEntityVariable = Either.left("0.4".asExpression())
|
||||
val maxSearches: ExpressionOrEntityVariable = Either.left("3".asExpression())
|
||||
|
||||
override fun getVariables(entity: LivingEntity, behaviourConfigurationContext: BehaviourConfigurationContext) =
|
||||
listOf(horizontalRange, verticalRange, maxExits, speedMultiplier, maxSearches).asVariables()
|
||||
|
||||
override fun create(entity: LivingEntity, behaviourConfigurationContext: BehaviourConfigurationContext): Objective {
|
||||
val runtime = behaviourConfigurationContext.runtime
|
||||
return WalkOutOfWater(
|
||||
horizontalRange = horizontalRange.resolveInt(runtime),
|
||||
verticalRange = verticalRange.resolveInt(runtime),
|
||||
maxExits = maxExits.resolveInt(runtime),
|
||||
speedMultiplier = speedMultiplier.resolveFloat(runtime),
|
||||
maxSearches = maxSearches.resolveInt(runtime)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val MAX_EXIT_DEPTH_BELOW = 2
|
||||
|
||||
/** Whether the entity's head is in a fluid it can neither swim nor breathe in. */
|
||||
fun isDrowningIn(capabilities: MovementCapabilities, headFluid: FluidKind): Boolean {
|
||||
return headFluid != FluidKind.NONE && !capabilities.canSwimIn(headFluid) && !capabilities.canBreatheIn(headFluid)
|
||||
}
|
||||
|
||||
/** The fluid that's currently killing the entity, or [FluidKind.NONE]. */
|
||||
fun deadlyFluid(entity: LivingEntity, capabilities: MovementCapabilities): FluidKind {
|
||||
val headFluid = FluidKind.atEyes(entity)
|
||||
return when {
|
||||
isDrowningIn(capabilities, headFluid) -> headFluid
|
||||
entity.isInLava && capabilities.isHarmedBy(FluidKind.LAVA) -> FluidKind.LAVA
|
||||
else -> FluidKind.NONE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -14,15 +14,21 @@ import com.cobblemon.mod.common.api.ai.ExpressionOrEntityVariable
|
||||
import com.cobblemon.mod.common.api.ai.asVariables
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.BiggerBrain
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.LookingTracker
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.MovementTracker
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.RegularMovementTracker
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.Distraction
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.DistractionType
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.comfortDistraction
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.distraction.idleBoredomDistraction
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.EntityFixation
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.LookAndMoveFixation
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.fixation.MovementTrackerFixation
|
||||
import com.cobblemon.mod.common.api.ai.config.objective.ObjectiveConfig
|
||||
import com.cobblemon.mod.common.api.ai.resolveFloat
|
||||
import com.cobblemon.mod.common.api.ai.resolveInt
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.entity.pokemon.ai.PokemonMoveControl
|
||||
import com.cobblemon.mod.common.util.asExpression
|
||||
import com.mojang.datafixers.util.Either
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
@@ -86,7 +92,7 @@ class WalkTowardsParent(
|
||||
distractionTypes = setOf(DistractionType.DAMAGE, DistractionType.FORCE), // We are very fine to ignore this movement if forced or hurt
|
||||
lookingTracker = LookingTracker.forTargetEntity(entity, adult),
|
||||
movementTracker = movementTracker,
|
||||
onMovementComplete = { entity1, brain1, status -> cooldownTicks = 60 }
|
||||
onMovementComplete = { _, _ -> cooldownTicks = 60 }
|
||||
)
|
||||
)
|
||||
return ObjectiveStatus.FIXATED // We are now fixated on
|
||||
|
||||
+9
-16
@@ -48,9 +48,9 @@ import net.minecraft.world.entity.ai.memory.WalkTarget
|
||||
class WanderAround(
|
||||
val condition: Expression = "true".asExpression(),
|
||||
val cooldownTicks: Int = 80,
|
||||
val allowLand: Expression = "(q.entity.movement.can_walk && !q.entity.movement.avoids_land) || q.entity.movement.can_fly".asExpression(),
|
||||
val allowWater: Expression = "q.entity.movement.can_swim_in_water && !q.entity.movement.avoids_water".asExpression(),
|
||||
val allowAir: Expression = "q.entity.movement.can_fly && !q.entity.movement.can_walk".asExpression(),
|
||||
val allowLand: Expression = "(q.entity.behaviour.moving.walk.can_walk && !q.entity.behaviour.moving.walk.avoids_land) || q.entity.behaviour.moving.fly.can_fly".asExpression(),
|
||||
val allowWater: Expression = "q.entity.behaviour.moving.swim.can_swim_in_water && !q.entity.behaviour.moving.swim.avoids_water".asExpression(),
|
||||
val allowAir: Expression = "q.entity.behaviour.moving.fly.can_fly && !q.entity.behaviour.moving.walk.can_walk".asExpression(),
|
||||
val wanderChance: Expression = "1/(20*6)".asExpression(),
|
||||
val horizontalRange: Expression = "10".asExpression(),
|
||||
val verticalRange: Expression = "5".asExpression(),
|
||||
@@ -113,10 +113,6 @@ class WanderAround(
|
||||
if (allowWater && WanderType.WATER.isValid(entity)) {
|
||||
types.add(WanderType.WATER)
|
||||
}
|
||||
// Seafloor walkers can't swim, so allowWater's default never covers them; only an explicit opt-out stops them.
|
||||
if (wanderControl?.allowWater != false && WanderType.SEABED.isValid(entity)) {
|
||||
types.add(WanderType.SEABED)
|
||||
}
|
||||
|
||||
if (types.isEmpty()) {
|
||||
return ObjectiveStatus.INVALID
|
||||
@@ -161,9 +157,9 @@ class WanderAround(
|
||||
class Config : ObjectiveConfig {
|
||||
val condition: ExpressionOrEntityVariable = Either.left("true".asExpression())
|
||||
val cooldownTicks: ExpressionOrEntityVariable = Either.left("80".asExpression())
|
||||
val allowLand: ExpressionOrEntityVariable = Either.left("(q.entity.movement.can_walk && !q.entity.movement.avoids_land) || q.entity.movement.can_fly".asExpression())
|
||||
val allowWater: ExpressionOrEntityVariable = Either.left("q.entity.movement.can_swim_in_water && !q.entity.movement.avoids_water".asExpression())
|
||||
val allowAir: ExpressionOrEntityVariable = Either.left("q.entity.movement.can_fly && !q.entity.movement.can_walk".asExpression())
|
||||
val allowLand: ExpressionOrEntityVariable = Either.left("(q.entity.behaviour.moving.walk.can_walk && !q.entity.behaviour.moving.walk.avoids_land) || q.entity.behaviour.moving.fly.can_fly".asExpression())
|
||||
val allowWater: ExpressionOrEntityVariable = Either.left("q.entity.behaviour.moving.swim.can_swim_in_water && !q.entity.behaviour.moving.swim.avoids_water".asExpression())
|
||||
val allowAir: ExpressionOrEntityVariable = Either.left("q.entity.behaviour.moving.fly.can_fly && !q.entity.behaviour.moving.walk.can_walk".asExpression())
|
||||
val wanderChance: ExpressionOrEntityVariable = Either.left("1/(20*6)".asExpression())
|
||||
val horizontalRange: ExpressionOrEntityVariable = Either.left("10".asExpression())
|
||||
val verticalRange: ExpressionOrEntityVariable = Either.left("5".asExpression())
|
||||
@@ -221,9 +217,9 @@ class WanderAround(
|
||||
val wanderControl = entity.brain.getMemorySafely(CobblemonMemories.WANDER_CONTROL).orElse(null)
|
||||
runtime.withQueryValue("entity", entity.asMostSpecificMoLangValue())
|
||||
|
||||
val allowLand = wanderControl?.allowLand ?: runtime.resolveBoolean("(q.entity.movement.can_walk && !q.entity.movement.avoids_land) || q.entity.movement.can_fly".asExpression())
|
||||
val allowWater = wanderControl?.allowWater ?: runtime.resolveBoolean("q.entity.movement.can_swim_in_water && !q.entity.movement.avoids_water".asExpression())
|
||||
val allowAir = wanderControl?.allowAir ?: runtime.resolveBoolean("q.entity.movement.can_fly && !q.entity.movement.can_walk".asExpression())
|
||||
val allowLand = wanderControl?.allowLand ?: runtime.resolveBoolean("(q.entity.behaviour.moving.walk.can_walk && !q.entity.behaviour.moving.walk.avoids_land) || q.entity.behaviour.moving.fly.can_fly".asExpression())
|
||||
val allowWater = wanderControl?.allowWater ?: runtime.resolveBoolean("q.entity.behaviour.moving.swim.can_swim_in_water && !q.entity.behaviour.moving.swim.avoids_water".asExpression())
|
||||
val allowAir = wanderControl?.allowAir ?: runtime.resolveBoolean("q.entity.behaviour.moving.fly.can_fly && !q.entity.behaviour.moving.walk.can_walk".asExpression())
|
||||
|
||||
val types = mutableSetOf<WanderType>()
|
||||
if ((allowLand || allowAir) && WanderType.LAND.isValid(entity)) {
|
||||
@@ -232,9 +228,6 @@ class WanderAround(
|
||||
if (allowWater && WanderType.WATER.isValid(entity)) {
|
||||
types.add(WanderType.WATER)
|
||||
}
|
||||
if (wanderControl?.allowWater != false && WanderType.SEABED.isValid(entity)) {
|
||||
types.add(WanderType.SEABED)
|
||||
}
|
||||
|
||||
if (types.isEmpty()) {
|
||||
return null
|
||||
|
||||
+13
-29
@@ -15,8 +15,10 @@ import com.cobblemon.mod.common.api.ai.asVariables
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.BiggerBrain
|
||||
import com.cobblemon.mod.common.api.ai.resolveInt
|
||||
import com.cobblemon.mod.common.api.ai.config.sense.SenseConfig
|
||||
import com.cobblemon.mod.common.api.breeding.CobblemonBreeding
|
||||
import com.cobblemon.mod.common.api.nest.WildNestType
|
||||
import com.cobblemon.mod.common.api.nest.WildNestTypes
|
||||
import com.cobblemon.mod.common.api.pokemon.egg.EggGroup
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.util.asExpression
|
||||
import com.mojang.datafixers.util.Either
|
||||
@@ -27,6 +29,7 @@ import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.entity.ai.memory.MemoryModuleType
|
||||
import net.minecraft.world.level.block.Blocks
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
import kotlin.random.Random
|
||||
|
||||
class IdealNestPlacementSense(
|
||||
private var cooldownTicks: Int = 100,
|
||||
@@ -59,9 +62,11 @@ class IdealNestPlacementSense(
|
||||
val world = entity.level() as? ServerLevel ?: return
|
||||
|
||||
val mate = brain.getMemory(CobblemonMemories.POTENTIAL_MATE) as? PokemonEntity
|
||||
val combinedTypes = mate?.let { WildNestTypes.combinedTypes(entity, it) } ?: emptyList()
|
||||
if (mate == null || combinedTypes.isEmpty()) {
|
||||
debug(brain, "No mate or no combined nest types; clearing ideal nest memories.")
|
||||
// we are changing things a bit and making it so only the one laying the egg (mother or ditto) needs to plan where the nest goes
|
||||
if (mate != null && EggGroup.DITTO !in entity.pokemon.form.eggGroups && (EggGroup.DITTO in mate.pokemon.form.eggGroups || CobblemonBreeding.getMother(entity.pokemon, mate.pokemon, isSimulated = true) != entity.pokemon)) return
|
||||
val nestTypes = if (mate != null) WildNestTypes.typesFor((CobblemonBreeding.getMother(entity.pokemon, mate.pokemon, isSimulated = true) ?: entity.pokemon).species) else emptyList()
|
||||
if (mate == null || nestTypes.isEmpty()) {
|
||||
debug(brain, "No mate or no nest types; clearing ideal nest memories.")
|
||||
brain.eraseMemory(CobblemonMemories.IDEAL_NEST_LOCATION)
|
||||
mate?.biggerBrain?.eraseMemory(CobblemonMemories.IDEAL_NEST_LOCATION)
|
||||
return
|
||||
@@ -69,7 +74,7 @@ class IdealNestPlacementSense(
|
||||
|
||||
val storedNestPos = brain.getMemory(CobblemonMemories.IDEAL_NEST_LOCATION)
|
||||
if (storedNestPos != null) {
|
||||
if (isValidNestPlacement(world, entity, mate, storedNestPos, combinedTypes)) {
|
||||
if (isValidNestPlacement(world, entity, mate, storedNestPos, nestTypes)) {
|
||||
debug(brain, "Stored ideal nest still valid at $storedNestPos.")
|
||||
mate.biggerBrain.setMemory(CobblemonMemories.IDEAL_NEST_LOCATION, storedNestPos)
|
||||
return
|
||||
@@ -81,7 +86,7 @@ class IdealNestPlacementSense(
|
||||
}
|
||||
|
||||
val entityPos = entity.blockPosition()
|
||||
val validNestPosition = findValidNestPlacement(world, entity, mate, entityPos, combinedTypes)
|
||||
val validNestPosition = findValidNestPlacement(world, entity, mate, entityPos, nestTypes)
|
||||
|
||||
if (validNestPosition != null) {
|
||||
debug(brain, "Found ideal nest position at $validNestPosition.")
|
||||
@@ -98,14 +103,14 @@ class IdealNestPlacementSense(
|
||||
return BlockPos.betweenClosed(
|
||||
entityPos.offset(-detectionRadius, -5, -detectionRadius),
|
||||
entityPos.offset(detectionRadius, 5, detectionRadius)
|
||||
).map { it.immutable() }.shuffled().firstOrNull { pos ->
|
||||
).map { it.immutable() }.shuffled(Random(entity.random.nextLong())).firstOrNull { pos ->
|
||||
val blockBelowState = world.getBlockState(pos)
|
||||
val nestPos = pos.above()
|
||||
val blockAbove = world.getBlockState(nestPos).block
|
||||
val blockAbove2 = world.getBlockState(nestPos.above()).block
|
||||
val placement = WildNestTypes.resolvePlacement(sharedTypes, blockBelowState, world.getFluidState(nestPos)) ?: return@firstOrNull false
|
||||
|
||||
if (!isWaterGroupCompatible(entity, mate, placement.waterlogged)) return@firstOrNull false
|
||||
if (placement.waterlogged && WildNestType.WATERY !in sharedTypes) return@firstOrNull false
|
||||
|
||||
if (placement.waterlogged) {
|
||||
if (!(blockAbove == Blocks.WATER && blockAbove2 == Blocks.WATER)) return@firstOrNull false
|
||||
@@ -128,7 +133,7 @@ class IdealNestPlacementSense(
|
||||
val blockAbove2 = world.getBlockState(pos.above(2)).block
|
||||
val placement = WildNestTypes.resolvePlacement(sharedTypes, blockBelowState, world.getFluidState(pos)) ?: return false
|
||||
|
||||
if (!isWaterGroupCompatible(entity, mate, placement.waterlogged)) return false
|
||||
if (placement.waterlogged && WildNestType.WATERY !in sharedTypes) return false
|
||||
|
||||
if (placement.waterlogged) {
|
||||
if (!(blockAbove == Blocks.WATER && blockAbove2 == Blocks.WATER)) return false
|
||||
@@ -158,27 +163,6 @@ class IdealNestPlacementSense(
|
||||
}
|
||||
}
|
||||
|
||||
private fun isWaterGroupCompatible(
|
||||
entity: PokemonEntity,
|
||||
mate: PokemonEntity?,
|
||||
isNestWaterlogged: Boolean
|
||||
): Boolean {
|
||||
val waterEggGroups = setOf("water_1", "water_2", "water_3")
|
||||
val entityEggGroups = entity.pokemon.species.eggGroups.map { it.name.lowercase() }
|
||||
val entityHasWater = entityEggGroups.any { it in waterEggGroups || it == "ditto" }
|
||||
val entityOnlyWater = entityEggGroups.all { it in waterEggGroups }
|
||||
|
||||
val mateEggGroups = mate?.pokemon?.species?.eggGroups?.map { it.name.lowercase() } ?: emptyList()
|
||||
val mateHasWater = mateEggGroups.any { it in waterEggGroups || it == "ditto" }
|
||||
val mateOnlyWater = mateEggGroups.isNotEmpty() && mateEggGroups.all { it in waterEggGroups }
|
||||
|
||||
return if (isNestWaterlogged) {
|
||||
entityHasWater && mateHasWater
|
||||
} else {
|
||||
!(entityOnlyWater || mateOnlyWater)
|
||||
}
|
||||
}
|
||||
|
||||
private fun debug(brain: BiggerBrain, message: String) {
|
||||
brain.sendDebugMessage("[IdealNestPlacementSense] $message")
|
||||
}
|
||||
|
||||
+6
-31
@@ -15,6 +15,7 @@ import com.cobblemon.mod.common.api.ai.asVariables
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.BiggerBrain
|
||||
import com.cobblemon.mod.common.api.ai.config.sense.SenseConfig
|
||||
import com.cobblemon.mod.common.api.ai.resolveInt
|
||||
import com.cobblemon.mod.common.api.breeding.CobblemonBreeding
|
||||
import com.cobblemon.mod.common.api.nest.WildNestType
|
||||
import com.cobblemon.mod.common.api.nest.WildNestTypes
|
||||
import com.cobblemon.mod.common.block.WildNestBlock
|
||||
@@ -27,6 +28,7 @@ import net.minecraft.server.level.ServerLevel
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.PathfinderMob
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import kotlin.random.Random
|
||||
|
||||
class NestSense(
|
||||
private var cooldownTicks: Int = 200,
|
||||
@@ -102,7 +104,7 @@ class NestSense(
|
||||
return BlockPos.betweenClosed(
|
||||
entityPos.offset(-radiusXZ, -radiusY, -radiusXZ),
|
||||
entityPos.offset(radiusXZ, radiusY, radiusXZ)
|
||||
).firstOrNull { pos ->
|
||||
).map { it.immutable() }.shuffled(Random(pokemonEntity.random.nextLong())).firstOrNull { pos ->
|
||||
val blockEntity: BlockEntity? = world.getBlockEntity(pos)
|
||||
if (blockEntity !is NestBlockEntity) return@firstOrNull false
|
||||
|
||||
@@ -143,8 +145,8 @@ class NestSense(
|
||||
return@firstOrNull false
|
||||
}
|
||||
|
||||
// is this nest water group compatible? some of our nests can only be used by water egg grouup mons if they are water logged. reverse for land nests and water egg groups
|
||||
if (!isWaterGroupCompatible(pokemonEntity, mate, isNestWaterlogged)) {
|
||||
// we switched to only if the nest is waterlogged now rather than our old egg group check
|
||||
if (isNestWaterlogged && WildNestType.WATERY !in allowedTypes) {
|
||||
return@firstOrNull false
|
||||
}
|
||||
|
||||
@@ -160,36 +162,9 @@ class NestSense(
|
||||
val path = entity.navigation.createPath(targetPos, 0)
|
||||
return path != null && path.distToTarget < 1.75f
|
||||
}
|
||||
|
||||
private fun isWaterGroupCompatible(
|
||||
entity: PokemonEntity,
|
||||
mate: PokemonEntity?,
|
||||
isNestWaterlogged: Boolean
|
||||
): Boolean {
|
||||
val waterEggGroups = setOf("water_1", "water_2", "water_3")
|
||||
val entityEggGroups = entity.pokemon.species.eggGroups.map { it.name.lowercase() }
|
||||
val entityHasWater = entityEggGroups.any { it in waterEggGroups || it == "ditto" }
|
||||
val entityOnlyWater = entityEggGroups.all { it in waterEggGroups }
|
||||
|
||||
val mateEggGroups = mate?.pokemon?.species?.eggGroups?.map { it.name.lowercase() } ?: emptyList()
|
||||
val mateHasWater = mateEggGroups.any { it in waterEggGroups || it == "ditto" }
|
||||
val mateOnlyWater = mateEggGroups.isNotEmpty() && mateEggGroups.all { it in waterEggGroups }
|
||||
|
||||
return if (isNestWaterlogged) {
|
||||
entityHasWater && mateHasWater
|
||||
} else {
|
||||
!(entityOnlyWater || mateOnlyWater)
|
||||
}
|
||||
}
|
||||
|
||||
private fun allowedNestTypes(entity: PokemonEntity, brain: BiggerBrain): Set<WildNestType> {
|
||||
val mate = brain.getMemory(CobblemonMemories.POTENTIAL_MATE) as? PokemonEntity
|
||||
val types = if (mate != null) {
|
||||
WildNestTypes.combinedTypes(entity, mate)
|
||||
} else {
|
||||
WildNestTypes.typesFor(entity.pokemon.species)
|
||||
}
|
||||
val mutable = types.toMutableSet()
|
||||
val mutable = WildNestTypes.typesFor((mate?.let { CobblemonBreeding.getMother(entity.pokemon, it.pokemon, isSimulated = true) } ?: entity.pokemon).species).toMutableSet()
|
||||
if (!entity.pokemon.isWild() && mate != null && !mate.pokemon.isWild()) {
|
||||
mutable.add(WildNestType.PLAYER)
|
||||
mutable.add(WildNestType.KELP)
|
||||
|
||||
-105
@@ -1,105 +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.api.ai.biggerbrain.sense
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.CobblemonMemories
|
||||
import com.cobblemon.mod.common.api.ai.BehaviourConfigurationContext
|
||||
import com.cobblemon.mod.common.api.ai.ExpressionOrEntityVariable
|
||||
import com.cobblemon.mod.common.api.ai.asVariables
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.BiggerBrain
|
||||
import com.cobblemon.mod.common.api.ai.config.sense.SenseConfig
|
||||
import com.cobblemon.mod.common.api.ai.resolveInt
|
||||
import com.cobblemon.mod.common.api.tags.CobblemonBlockTags
|
||||
import com.cobblemon.mod.common.util.asExpression
|
||||
import com.cobblemon.mod.common.util.distanceTo
|
||||
import com.cobblemon.mod.common.util.getMemorySafely
|
||||
import com.mojang.datafixers.util.Either
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Vec3i
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
|
||||
class ScarekrowSense(
|
||||
private var cooldownTicks: Int = SCAN_INTERVAL
|
||||
) : Sense {
|
||||
override var ticksUntilNextExecution: Int = cooldownTicks
|
||||
override val memories = setOf(
|
||||
CobblemonMemories.NEARBY_SCAREKROW,
|
||||
)
|
||||
|
||||
override fun merge(other: Sense): Boolean {
|
||||
if (other is ScarekrowSense) {
|
||||
this.cooldownTicks = minOf(this.cooldownTicks, other.cooldownTicks)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun tick(entity: LivingEntity, brain: BiggerBrain) {
|
||||
ticksUntilNextExecution = cooldownTicks
|
||||
val brain = entity.brain
|
||||
|
||||
val searchRadius = Cobblemon.config.scarekrowRadius
|
||||
val currPos: BlockPos? = brain.getMemorySafely(CobblemonMemories.NEARBY_SCAREKROW).orElse(null)
|
||||
|
||||
if (currPos != null && entity.level().getBlockState(currPos).`is`(CobblemonBlockTags.SCAREKROWS)) {
|
||||
val distance = entity.distanceTo(currPos)
|
||||
if (distance > searchRadius) {
|
||||
brain.eraseMemory(CobblemonMemories.NEARBY_SCAREKROW)
|
||||
}
|
||||
}
|
||||
|
||||
val centerPos = entity.blockPosition()
|
||||
var scarekrowPos: BlockPos? = null
|
||||
var shortestDist = Double.MAX_VALUE
|
||||
val world = entity.level()
|
||||
BlockPos.betweenClosedStream(
|
||||
centerPos.offset(-searchRadius, -searchRadius, -searchRadius),
|
||||
centerPos.offset(searchRadius, searchRadius, searchRadius)
|
||||
).forEach { pos ->
|
||||
val state = world.getBlockState(pos)
|
||||
if (state.`is`(CobblemonBlockTags.SCAREKROWS)) {
|
||||
val distance = pos.distSqr(Vec3i(centerPos.x, centerPos.y, centerPos.z))
|
||||
if (distance < shortestDist) {
|
||||
scarekrowPos = BlockPos(pos)
|
||||
shortestDist = distance
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scarekrowPos != null) {
|
||||
brain.setMemory(CobblemonMemories.NEARBY_SCAREKROW, scarekrowPos)
|
||||
} else {
|
||||
brain.eraseMemory(CobblemonMemories.NEARBY_SCAREKROW)
|
||||
}
|
||||
}
|
||||
|
||||
class Config : SenseConfig {
|
||||
var condition: ExpressionOrEntityVariable = Either.left("true".asExpression())
|
||||
var cooldownTicks: ExpressionOrEntityVariable = Either.left("3".asExpression())
|
||||
|
||||
override fun getVariables(
|
||||
entity: LivingEntity,
|
||||
behaviourConfigurationContext: BehaviourConfigurationContext
|
||||
) = listOf(cooldownTicks).asVariables()
|
||||
|
||||
override fun create(entity: LivingEntity, behaviourConfigurationContext: BehaviourConfigurationContext): Sense {
|
||||
val cooldownTicks = cooldownTicks.resolveInt(behaviourConfigurationContext.runtime)
|
||||
return ScarekrowSense(
|
||||
cooldownTicks = cooldownTicks
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val SCAN_INTERVAL = 3
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
package com.cobblemon.mod.common.api.ai.biggerbrain.sense
|
||||
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.BiggerBrain
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.ai.memory.MemoryModuleType
|
||||
|
||||
@@ -22,6 +23,30 @@ import net.minecraft.world.entity.ai.memory.MemoryModuleType
|
||||
* @since December 29th, 2025
|
||||
*/
|
||||
interface Sense {
|
||||
companion object {
|
||||
val types = mutableMapOf(
|
||||
cobblemonResource("battling_pokemon") to BattlingPokemonSense::class.java,
|
||||
cobblemonResource("drowsy") to DrowsySense::class.java,
|
||||
cobblemonResource("nearby_entities") to NearbyEntitiesSense::class.java,
|
||||
cobblemonResource("npc_battling") to NPCBattlingSense::class.java,
|
||||
cobblemonResource("pokemon_adult") to PokemonAdultSense::class.java,
|
||||
cobblemonResource("hurt_by") to HurtBySense::class.java,
|
||||
cobblemonResource("mate_sensor") to MateSense::class.java,
|
||||
cobblemonResource("nest_sensor") to NestSense::class.java,
|
||||
cobblemonResource("egg_sensor") to EggSense::class.java,
|
||||
cobblemonResource("ideal_nest_location_sensor") to IdealNestPlacementSense::class.java,
|
||||
cobblemonResource("hurt_by") to HurtBySense::class.java,
|
||||
cobblemonResource("nearby_sweet_berry_bush") to SweetBerryBushSense::class.java,
|
||||
cobblemonResource("jukebox_playing") to JukeboxSense::class.java,
|
||||
cobblemonResource("nearby_sweet_berry_bush") to SweetBerryBushSense::class.java,
|
||||
cobblemonResource("pokemon_nearby_wanted_item") to PokemonItemSense.Config::class.java,
|
||||
cobblemonResource("flower_sense") to FlowerSense.Config::class.java,
|
||||
cobblemonResource("beehive_sense") to BeeHiveSense.Config::class.java,
|
||||
cobblemonResource("sacc_leaf_sense") to SaccLeafSense.Config::class.java,
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
/** The ticks until it will next be ticked. This is also displayed in the debug overlay. */
|
||||
var ticksUntilNextExecution: Int
|
||||
|
||||
|
||||
+1
-6
@@ -20,7 +20,6 @@ import com.cobblemon.mod.common.api.ai.biggerbrain.objective.EggRecovery
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.Defensive
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.EatGrass
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.EatHeldItem
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.FindAir
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.FocusDuringBattle
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.FriendlyBehaviour
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.GatherNectar
|
||||
@@ -40,11 +39,9 @@ import com.cobblemon.mod.common.api.ai.biggerbrain.objective.WanderAround
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.JumpOutOfWater
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.NeutralBehaviour
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.PointToSpawn
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.AvoidScarekrow
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.SkittishBehaviour
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.TerritorialBehaviour
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.WalkTowardsParent
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.objective.WalkOutOfWater
|
||||
import com.cobblemon.mod.common.api.npc.configuration.MoLangConfigVariable
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
@@ -63,7 +60,6 @@ interface ObjectiveConfig {
|
||||
cobblemonResource("maintain_fluid_y") to MaintainFluidY.Config::class.java,
|
||||
cobblemonResource("move_out_of_water") to MoveOutOfWater.Config::class.java,
|
||||
cobblemonResource("move_into_water") to MoveIntoWater.Config::class.java,
|
||||
cobblemonResource("walk_out_of_water") to WalkOutOfWater.Config::class.java,
|
||||
cobblemonResource("jump_out_of_water") to JumpOutOfWater.Config::class.java,
|
||||
cobblemonResource("move_to_resting_place") to MoveToRestingPlace.Config::class.java,
|
||||
cobblemonResource("go_to_sleep") to GoToSleep.Config::class.java,
|
||||
@@ -74,7 +70,6 @@ interface ObjectiveConfig {
|
||||
cobblemonResource("pickup_item") to PickupItem.Config::class.java,
|
||||
cobblemonResource("eat_held_item") to EatHeldItem.Config::class.java,
|
||||
cobblemonResource("gather_nectar") to GatherNectar.Config::class.java,
|
||||
cobblemonResource("find_air") to FindAir.Config::class.java,
|
||||
cobblemonResource("dance") to Dance.Config::class.java,
|
||||
cobblemonResource("defend_owner") to DefendOwner.Config::class.java,
|
||||
cobblemonResource("point_to_spawn") to PointToSpawn.Config::class.java,
|
||||
@@ -87,7 +82,7 @@ interface ObjectiveConfig {
|
||||
cobblemonResource("combat_neutral") to NeutralBehaviour.Config::class.java,
|
||||
cobblemonResource("combat_skittish") to SkittishBehaviour.Config::class.java,
|
||||
cobblemonResource("behaviour_friendly") to FriendlyBehaviour.Config::class.java,
|
||||
cobblemonResource("avoid_scarekrow") to AvoidScarekrow.Config::class.java,
|
||||
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.cobblemon.mod.common.api.ai.biggerbrain.sense.NearbyEntitiesSense
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.sense.PokemonAdultSense
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.sense.PokemonItemSense
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.sense.SaccLeafSense
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.sense.ScarekrowSense
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.sense.Sense
|
||||
import com.cobblemon.mod.common.api.ai.biggerbrain.sense.SweetBerryBushSense
|
||||
import com.cobblemon.mod.common.api.npc.configuration.MoLangConfigVariable
|
||||
@@ -53,13 +52,13 @@ interface SenseConfig {
|
||||
cobblemonResource("nest_sensor") to NestSense.Config::class.java,
|
||||
cobblemonResource("egg_sensor") to EggSense.Config::class.java,
|
||||
cobblemonResource("ideal_nest_location_sensor") to IdealNestPlacementSense.Config::class.java,
|
||||
cobblemonResource("pokemon_adult") to PokemonAdultSense.Config::class.java,
|
||||
cobblemonResource("nearby_sweet_berry_bush") to SweetBerryBushSense.Config::class.java,
|
||||
cobblemonResource("pokemon_nearby_wanted_item") to PokemonItemSense.Config::class.java,
|
||||
cobblemonResource("flower_sense") to FlowerSense.Config::class.java,
|
||||
cobblemonResource("beehive_sense") to BeeHiveSense.Config::class.java,
|
||||
cobblemonResource("sacc_leaf_sense") to SaccLeafSense.Config::class.java,
|
||||
cobblemonResource("scarekrow_sense") to ScarekrowSense.Config::class.java,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/** The variables that this sense config uses. These are used to declare variables on the entity cleanly. */
|
||||
|
||||
+31
-7
@@ -9,6 +9,7 @@
|
||||
package com.cobblemon.mod.common.api.ai.config.task
|
||||
|
||||
import com.bedrockk.molang.Expression
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.api.ai.BehaviourConfigurationContext
|
||||
import com.cobblemon.mod.common.api.ai.ExpressionOrEntityVariable
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMostSpecificMoLangValue
|
||||
@@ -17,6 +18,7 @@ import com.cobblemon.mod.common.util.asExpression
|
||||
import com.cobblemon.mod.common.util.mainThreadRuntime
|
||||
import com.cobblemon.mod.common.util.resolveBoolean
|
||||
import com.cobblemon.mod.common.util.withQueryValue
|
||||
import com.cobblemon.mod.common.world.gamerules.CobblemonGameRules
|
||||
import com.mojang.datafixers.util.Either
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.ai.behavior.BehaviorControl
|
||||
@@ -34,6 +36,8 @@ import net.minecraft.world.entity.ai.sensing.SensorType
|
||||
class HateEntityTaskConfig : SingleTaskConfig {
|
||||
val entityCondition: Expression = "true".asExpression()
|
||||
val range: ExpressionOrEntityVariable = Either.left("24".asExpression())
|
||||
val chance: Float = Cobblemon.config.predationChance
|
||||
private val coercedChance = chance.coerceIn(0f, 1f)
|
||||
|
||||
override fun getVariables(entity: LivingEntity, behaviourConfigurationContext: BehaviourConfigurationContext) = emptyList<MoLangConfigVariable>()
|
||||
override fun createTask(
|
||||
@@ -43,24 +47,44 @@ class HateEntityTaskConfig : SingleTaskConfig {
|
||||
val range = range.resolveFloat(behaviourConfigurationContext.runtime)
|
||||
behaviourConfigurationContext.addMemories(
|
||||
MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES,
|
||||
MemoryModuleType.ANGRY_AT
|
||||
MemoryModuleType.ANGRY_AT,
|
||||
MemoryModuleType.ATTACK_TARGET
|
||||
)
|
||||
behaviourConfigurationContext.addSensors(SensorType.NEAREST_LIVING_ENTITIES)
|
||||
return BehaviorBuilder.create { instance ->
|
||||
instance.group(
|
||||
instance.present(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES),
|
||||
instance.registered(MemoryModuleType.ANGRY_AT)
|
||||
).apply(instance) { entities, angryAt ->
|
||||
instance.registered(MemoryModuleType.ANGRY_AT),
|
||||
instance.registered(MemoryModuleType.ATTACK_TARGET),
|
||||
).apply(instance) { entities, angryAt, attackTarget ->
|
||||
Trigger { world, entity, _ ->
|
||||
val target = instance.get(entities).findClosest {
|
||||
mainThreadRuntime.withQueryValue("entity", entity.asMostSpecificMoLangValue())
|
||||
// bail if gamerule is disabled
|
||||
if (!world.gameRules.getBoolean(CobblemonGameRules.DO_POKEMON_PREDATION)) return@Trigger false
|
||||
val target = instance.get(entities).findClosest { hated ->
|
||||
mainThreadRuntime.withQueryValue("entity", hated.asMostSpecificMoLangValue())
|
||||
return@findClosest mainThreadRuntime.resolveBoolean(entityCondition)
|
||||
}.orElse(null)
|
||||
|
||||
var shouldTrigger = false
|
||||
if (target != null && target.distanceTo(entity) <= range) {
|
||||
angryAt.set(target.uuid)
|
||||
shouldTrigger = when {
|
||||
// set always attacking if activity chance is equal to 1.0
|
||||
coercedChance == 1f -> {
|
||||
angryAt.set(target.uuid)
|
||||
attackTarget.set(target)
|
||||
true
|
||||
}
|
||||
// roll the dice in other way
|
||||
coercedChance != 1f && world.random.nextFloat() < coercedChance -> {
|
||||
angryAt.set(target.uuid)
|
||||
attackTarget.set(target)
|
||||
true
|
||||
}
|
||||
// fallback to peaceful behavior in unattended cases
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
return@Trigger true
|
||||
return@Trigger shouldTrigger
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,105 +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.api.ai.movement
|
||||
|
||||
import com.cobblemon.mod.common.entity.MoLangScriptingEntity
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
|
||||
/**
|
||||
* What an entity would rather avoid, as opposed to what it can't do at all ([MovementCapabilities]). These turn into
|
||||
* a discomfort for each occupancy, which [MovementIntent] tolerates to differing degrees.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since October 1st, 2026
|
||||
*/
|
||||
data class MediumPreferences(
|
||||
val avoidsWater: Boolean = false,
|
||||
val avoidsLand: Boolean = false,
|
||||
/** Whether the entity is comfortable in lava, assuming it's fire immune. The species' canSwimInLava. */
|
||||
val prefersLava: Boolean = false,
|
||||
) {
|
||||
/**
|
||||
* How uncomfortable the entity is entering the occupancy, from 0 (natural) to 1 (only when desperate), or null if
|
||||
* it will never do so voluntarily. Hazards like burning or holding its breath are covered here too, since a
|
||||
* [MovementIntent] never tolerates them. Escaping a fluid uses its own rules.
|
||||
*/
|
||||
fun discomfort(occupancy: Occupancy, fluid: FluidKind, capabilities: MovementCapabilities): Float? {
|
||||
if (fluid == FluidKind.LAVA) {
|
||||
return when {
|
||||
capabilities.isHarmedBy(FluidKind.LAVA) -> null
|
||||
prefersLava -> 0F
|
||||
else -> LAVA_DISCOMFORT
|
||||
}
|
||||
}
|
||||
val breathes = capabilities.canBreatheIn(fluid)
|
||||
return when (occupancy) {
|
||||
Occupancy.WALK -> if (avoidsLand) 0.8F else 0F
|
||||
Occupancy.FLY -> 0F
|
||||
Occupancy.WADE -> if (avoidsWater) 0.7F else 0.3F
|
||||
Occupancy.SEABED -> if (breathes) 0F else null
|
||||
// Non-breathers swimming is a bit more than idle wandering will do, which matches the old wander filter.
|
||||
Occupancy.SWIM -> if (breathes) 0F else if (avoidsWater) 0.8F else 0.4F
|
||||
Occupancy.SWIM_SUBMERGED -> if (breathes) 0F else if (avoidsWater) 0.9F else 0.5F
|
||||
Occupancy.SINK, Occupancy.FALL -> null
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val LAVA_DISCOMFORT = 0.5F
|
||||
|
||||
// Config variable names, shared with NPCs which have no species behaviour to read these from.
|
||||
const val AVOIDS_WATER = "avoids_water"
|
||||
const val AVOIDS_LAND = "avoids_land"
|
||||
const val PREFERS_LAVA = "prefers_lava"
|
||||
|
||||
fun of(entity: LivingEntity): MediumPreferences {
|
||||
if (entity is PokemonEntity) {
|
||||
// The exposed form, like MovementCapabilities, so transformations and illusions agree.
|
||||
val moving = entity.exposedForm.behaviour.moving
|
||||
return MediumPreferences(
|
||||
avoidsWater = moving.swim.avoidsWater,
|
||||
avoidsLand = moving.walk.avoidsLand,
|
||||
prefersLava = moving.swim.canSwimInLava
|
||||
)
|
||||
} else if (entity is MoLangScriptingEntity) {
|
||||
return MediumPreferences(
|
||||
avoidsWater = entity.configFlag(AVOIDS_WATER, false),
|
||||
avoidsLand = entity.configFlag(AVOIDS_LAND, false),
|
||||
prefersLava = entity.configFlag(PREFERS_LAVA, false)
|
||||
)
|
||||
}
|
||||
return MediumPreferences()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Reads a boolean config variable, falling back if it isn't declared. */
|
||||
fun MoLangScriptingEntity.configFlag(name: String, default: Boolean): Boolean {
|
||||
// Vanilla may ask things like fireImmune() while the entity is still being constructed, before config exists.
|
||||
@Suppress("SENSELESS_COMPARISON")
|
||||
if (config == null) return default
|
||||
val value = config.map[name] ?: return default
|
||||
return value.asDouble() != 0.0
|
||||
}
|
||||
|
||||
/**
|
||||
* Why an entity is moving, which decides how much discomfort it will put up with along the way.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since October 1st, 2026
|
||||
*/
|
||||
enum class MovementIntent(val tolerance: Float) {
|
||||
/** Wandering and other things it's doing out of boredom. */
|
||||
IDLE(0.3F),
|
||||
/** Getting somewhere it would be more comfortable, like next to its owner. */
|
||||
COMFORT(0.6F),
|
||||
/** Chasing, fleeing, defending. Anything it can survive is on the table. */
|
||||
URGENT(1F)
|
||||
}
|
||||
-108
@@ -1,108 +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.api.ai.movement
|
||||
|
||||
import com.cobblemon.mod.common.entity.OmniPathingEntity
|
||||
import net.minecraft.tags.FluidTags
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.level.material.FluidState
|
||||
import net.minecraft.world.level.material.Fluids
|
||||
|
||||
/** The fluids that matter for movement decisions. */
|
||||
enum class FluidKind {
|
||||
NONE,
|
||||
WATER,
|
||||
LAVA;
|
||||
|
||||
companion object {
|
||||
fun of(fluidState: FluidState): FluidKind = when {
|
||||
fluidState.isEmpty -> NONE
|
||||
fluidState.`is`(FluidTags.WATER) -> WATER
|
||||
fluidState.`is`(FluidTags.LAVA) -> LAVA
|
||||
else -> NONE
|
||||
}
|
||||
|
||||
/** The fluid the entity's eyes are currently in, if any. */
|
||||
fun atEyes(entity: LivingEntity): FluidKind = when {
|
||||
entity.isEyeInFluid(FluidTags.WATER) -> WATER
|
||||
entity.isEyeInFluid(FluidTags.LAVA) -> LAVA
|
||||
else -> NONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A snapshot of what an entity's body is physically able to do. These are hard limits: no amount of
|
||||
* urgency lets an entity swim if it can't swim. Preferences and urgency live in [TraversalPolicy].
|
||||
*
|
||||
* Lava is viscous enough that every body can move through it freely; what differs is whether it burns.
|
||||
* Whether an entity actually likes being in lava (the species' canSwimInLava) is a preference, see [MediumPreferences].
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since September 30th, 2026
|
||||
*/
|
||||
data class MovementCapabilities(
|
||||
val canWalk: Boolean = true,
|
||||
val canFly: Boolean = false,
|
||||
val canSwimInWater: Boolean = false,
|
||||
val fireImmune: Boolean = false,
|
||||
val canBreatheUnderwater: Boolean = false,
|
||||
val canBreatheUnderLava: Boolean = false,
|
||||
val canWalkOnWater: Boolean = false,
|
||||
val canWalkOnLava: Boolean = false,
|
||||
) {
|
||||
fun canSwimIn(fluid: FluidKind) = when (fluid) {
|
||||
FluidKind.WATER -> canSwimInWater
|
||||
FluidKind.LAVA -> true
|
||||
FluidKind.NONE -> false
|
||||
}
|
||||
|
||||
/** Whether being in the fluid hurts, regardless of breathing. */
|
||||
fun isHarmedBy(fluid: FluidKind) = fluid == FluidKind.LAVA && !fireImmune
|
||||
|
||||
fun canBreatheIn(fluid: FluidKind) = when (fluid) {
|
||||
FluidKind.WATER -> canBreatheUnderwater
|
||||
FluidKind.LAVA -> canBreatheUnderLava
|
||||
FluidKind.NONE -> true
|
||||
}
|
||||
|
||||
fun canWalkOn(fluid: FluidKind) = when (fluid) {
|
||||
FluidKind.WATER -> canWalkOnWater
|
||||
FluidKind.LAVA -> canWalkOnLava
|
||||
FluidKind.NONE -> false
|
||||
}
|
||||
|
||||
/** Whether this body could ever end up in the given occupancy through its own movement. */
|
||||
fun canOccupy(occupancy: Occupancy) = when (occupancy) {
|
||||
Occupancy.WALK -> canWalk || canFly
|
||||
Occupancy.FLY -> canFly
|
||||
Occupancy.WADE, Occupancy.SEABED -> canWalk
|
||||
// Lava can always be swum in, and classification only produces swimming in water for water swimmers.
|
||||
Occupancy.SWIM, Occupancy.SWIM_SUBMERGED -> true
|
||||
Occupancy.SINK, Occupancy.FALL -> false
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun of(entity: LivingEntity): MovementCapabilities {
|
||||
if (entity !is OmniPathingEntity) {
|
||||
return MovementCapabilities(canBreatheUnderwater = entity.canBreatheUnderwater(), fireImmune = entity.fireImmune())
|
||||
}
|
||||
return MovementCapabilities(
|
||||
canWalk = entity.canWalk(),
|
||||
canFly = entity.canFly(),
|
||||
canSwimInWater = entity.canSwimInWater(),
|
||||
fireImmune = entity.fireImmune(),
|
||||
canBreatheUnderwater = entity.canSwimUnderFluid(Fluids.WATER.defaultFluidState()),
|
||||
canBreatheUnderLava = entity.canSwimUnderFluid(Fluids.LAVA.defaultFluidState()),
|
||||
canWalkOnWater = entity.canWalkOnWater(),
|
||||
canWalkOnLava = entity.canWalkOnLava(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +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.api.ai.movement
|
||||
|
||||
import com.bedrockk.molang.runtime.struct.QueryStruct
|
||||
import com.bedrockk.molang.runtime.value.DoubleValue
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
|
||||
/**
|
||||
* Creates the q.entity.movement struct: the entity's movement capabilities and preferences, the same for Pokémon and
|
||||
* NPCs. Values are read when queried, so they follow form changes and config edits.
|
||||
*
|
||||
* Unlike q.entity.behaviour.moving, which is the species data, this is what the movement system actually uses.
|
||||
* Lava has no swimming entry because every body can move through it; fire_immune decides whether it burns.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since October 1st, 2026
|
||||
*/
|
||||
fun createMovementStruct(entity: LivingEntity): QueryStruct {
|
||||
val capabilities = { MovementCapabilities.of(entity) }
|
||||
val preferences = { MediumPreferences.of(entity) }
|
||||
return QueryStruct(hashMapOf())
|
||||
.addFunction("can_walk") { DoubleValue(capabilities().canWalk) }
|
||||
.addFunction("can_fly") { DoubleValue(capabilities().canFly) }
|
||||
.addFunction("can_swim_in_water") { DoubleValue(capabilities().canSwimInWater) }
|
||||
.addFunction("can_breathe_underwater") { DoubleValue(capabilities().canBreatheUnderwater) }
|
||||
.addFunction("can_breathe_under_lava") { DoubleValue(capabilities().canBreatheUnderLava) }
|
||||
.addFunction("can_walk_on_water") { DoubleValue(capabilities().canWalkOnWater) }
|
||||
.addFunction("can_walk_on_lava") { DoubleValue(capabilities().canWalkOnLava) }
|
||||
.addFunction("fire_immune") { DoubleValue(capabilities().fireImmune) }
|
||||
.addFunction("avoids_water") { DoubleValue(preferences().avoidsWater) }
|
||||
.addFunction("avoids_land") { DoubleValue(preferences().avoidsLand) }
|
||||
.addFunction("prefers_lava") { DoubleValue(preferences().prefersLava) }
|
||||
.addFunction("is_seafloor_walker") {
|
||||
val caps = capabilities()
|
||||
DoubleValue(caps.canWalk && !caps.canSwimInWater && caps.canBreatheUnderwater)
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.api.ai.movement
|
||||
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.util.Mth
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
|
||||
/**
|
||||
* How a specific entity would be occupying a position. The same block of water is [SWIM] for a swimmer,
|
||||
* [SEABED] for a non-swimmer standing on the bottom, and [SINK] for a non-swimmer with nothing below it.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since September 30th, 2026
|
||||
*/
|
||||
enum class Occupancy {
|
||||
/** Standing on something with no fluid around the feet. */
|
||||
WALK,
|
||||
/** Airborne, with the ability to fly. */
|
||||
FLY,
|
||||
/** Standing on the bottom of a fluid it can't swim in, with its head above the surface. */
|
||||
WADE,
|
||||
/** Standing on the bottom of a fluid it can't swim in, with its head under the surface. */
|
||||
SEABED,
|
||||
/** In a fluid it can't swim in with nothing to stand on. It can only go down from here. */
|
||||
SINK,
|
||||
/** Swimming with its head above the surface. */
|
||||
SWIM,
|
||||
/** Swimming with its head under the surface. */
|
||||
SWIM_SUBMERGED,
|
||||
/** In the air without the ability to fly, with nothing to stand on. */
|
||||
FALL;
|
||||
|
||||
/** Whether an entity can come to rest here. [SINK] and [FALL] are only ever passed through on the way down. */
|
||||
val isStandable: Boolean
|
||||
get() = this != SINK && this != FALL
|
||||
|
||||
/** Whether the head is under a fluid in this occupancy, which is where breath gets spent. */
|
||||
val isSubmerged: Boolean
|
||||
get() = this == SEABED || this == SWIM_SUBMERGED
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Classifies an occupancy from already-resolved facts about a position.
|
||||
*
|
||||
* @param fluid The fluid at the entity's feet.
|
||||
* @param hasFloor Whether there is something to stand on: a solid block below, or a fluid surface the entity can walk on.
|
||||
* @param headFluid The fluid at the entity's eye level.
|
||||
*/
|
||||
fun classify(caps: MovementCapabilities, fluid: FluidKind, hasFloor: Boolean, headFluid: FluidKind): Occupancy {
|
||||
val headUnder = headFluid != FluidKind.NONE
|
||||
return when {
|
||||
fluid == FluidKind.NONE -> when {
|
||||
hasFloor -> WALK
|
||||
caps.canFly -> FLY
|
||||
else -> FALL
|
||||
}
|
||||
caps.canSwimIn(fluid) -> if (headUnder) SWIM_SUBMERGED else SWIM
|
||||
!hasFloor -> SINK
|
||||
headUnder -> SEABED
|
||||
else -> WADE
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Classifies the occupancy at a position using the given block lookup, or returns null if the position
|
||||
* is obstructed by a solid block. This only looks at the feet column; hitbox clearance is the pathfinder's job.
|
||||
*/
|
||||
fun at(caps: MovementCapabilities, eyeHeight: Float, pos: BlockPos, getState: (BlockPos) -> BlockState): Occupancy? {
|
||||
val state = getState(pos)
|
||||
if (state.isSolid) {
|
||||
return null
|
||||
}
|
||||
val fluid = FluidKind.of(state.fluidState)
|
||||
val below = getState(pos.below())
|
||||
val belowFluid = FluidKind.of(below.fluidState)
|
||||
val hasFloor = below.isSolid || (fluid == FluidKind.NONE && caps.canWalkOn(belowFluid))
|
||||
return classify(caps, fluid, hasFloor, fluidAtEyes(pos, eyeHeight, getState))
|
||||
}
|
||||
|
||||
/**
|
||||
* The fluid the eyes would be in when standing at the position. Compares the eye height against the fluid's
|
||||
* surface rather than just the block, so a small entity can wade through a thin layer of flowing water.
|
||||
*/
|
||||
private fun fluidAtEyes(pos: BlockPos, eyeHeight: Float, getState: (BlockPos) -> BlockState): FluidKind {
|
||||
val eyeOffset = Mth.floor(eyeHeight)
|
||||
val eyePos = pos.above(eyeOffset)
|
||||
val eyeFluidState = getState(eyePos).fluidState
|
||||
val eyeFluid = FluidKind.of(eyeFluidState)
|
||||
if (eyeFluid == FluidKind.NONE) {
|
||||
return FluidKind.NONE
|
||||
}
|
||||
// Fluid stacked on top fills the block, otherwise the surface is however high this fluid sits.
|
||||
val surface = if (FluidKind.of(getState(eyePos.above()).fluidState) == eyeFluid) 1F else eyeFluidState.ownHeight
|
||||
return if (eyeHeight - eyeOffset < surface) eyeFluid else FluidKind.NONE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,114 +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.api.ai.movement
|
||||
|
||||
import com.cobblemon.mod.common.entity.ai.OmniPathNavigation
|
||||
import com.cobblemon.mod.common.pokemon.ai.OmniPathNodeMaker
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.util.Mth
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
|
||||
/**
|
||||
* The rules for a single movement request: which occupancies the entity is willing to path through for this
|
||||
* particular reason, and what each one costs. A policy is attached to the path it produced by
|
||||
* [OmniPathNavigation], so recomputations of that path keep following the same rules.
|
||||
*
|
||||
* Positions in the open are only governed by a policy for their medium (walkable, open). Hazards such as fire, fences
|
||||
* and damaging blocks keep using the entity's regular pathfinding malus in [OmniPathNodeMaker]. Positions in a fluid
|
||||
* are always priced by the policy.
|
||||
*
|
||||
* Capabilities always win: an occupancy the body can't be in is never allowed, whatever the pricing says.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since September 30th, 2026
|
||||
*/
|
||||
class TraversalPolicy(
|
||||
val capabilities: MovementCapabilities,
|
||||
/** Shown in debugging. */
|
||||
val description: String,
|
||||
/** The cost of entering an occupancy in a fluid, or null if it's forbidden. */
|
||||
private val pricing: (Occupancy, FluidKind) -> Float?,
|
||||
) {
|
||||
/** The cost of entering a node in the given occupancy, or null if this request won't go there. */
|
||||
fun cost(occupancy: Occupancy, fluid: FluidKind): Float? {
|
||||
if (!occupancy.isStandable || !capabilities.canOccupy(occupancy)) {
|
||||
return null
|
||||
}
|
||||
return pricing(occupancy, fluid)
|
||||
}
|
||||
|
||||
fun allows(occupancy: Occupancy, fluid: FluidKind) = cost(occupancy, fluid) != null
|
||||
|
||||
override fun toString() = "TraversalPolicy($description)"
|
||||
|
||||
companion object {
|
||||
/** Path cost of something at the limit of what the entity will put up with. Comparable to the old fluid malus. */
|
||||
const val DISCOMFORT_COST = 16F
|
||||
/** Cost per node where the head is under a fluid the entity can't breathe in. Roughly "time spent drowning". */
|
||||
const val HELD_BREATH_COST = 4F
|
||||
/** Cost per node of being in lava without fire immunity. */
|
||||
const val BURNING_COST = 4F
|
||||
|
||||
/**
|
||||
* The usual policy: occupancies cost their discomfort, and anything more uncomfortable than the intent tolerates
|
||||
* is forbidden. Whatever the entity is currently standing in is tolerated so that it can make its way out,
|
||||
* unless it's something it would never enter voluntarily (burning, holding its breath); that's for escapes.
|
||||
*
|
||||
* @param within If given, the movement is confined to occupancies matching it, e.g. a swimmer wandering within
|
||||
* water. Choosing that medium was already the decision, so the intent's tolerance doesn't apply within it.
|
||||
* Hazards (burning, sinking) stay forbidden.
|
||||
*/
|
||||
fun forIntent(
|
||||
entity: LivingEntity,
|
||||
intent: MovementIntent,
|
||||
within: ((Occupancy, FluidKind) -> Boolean)? = null
|
||||
): TraversalPolicy {
|
||||
val capabilities = MovementCapabilities.of(entity)
|
||||
val preferences = MediumPreferences.of(entity)
|
||||
val level = entity.level()
|
||||
// The same position the pathfinder starts from, so the exemption below covers the actual start node.
|
||||
val box = entity.boundingBox
|
||||
val pos = BlockPos(Mth.floor(box.minX), Mth.floor(box.minY + 0.5), Mth.floor(box.minZ))
|
||||
val currentOccupancy = Occupancy.at(capabilities, entity.eyeHeight, pos, level::getBlockState)
|
||||
val currentFluid = FluidKind.of(level.getFluidState(pos))
|
||||
return TraversalPolicy(capabilities, intent.name.lowercase()) { occupancy, fluid ->
|
||||
if (within != null && !within(occupancy, fluid)) {
|
||||
return@TraversalPolicy null
|
||||
}
|
||||
val discomfort = preferences.discomfort(occupancy, fluid, capabilities) ?: return@TraversalPolicy null
|
||||
val tolerated = within != null || discomfort <= intent.tolerance ||
|
||||
(occupancy == currentOccupancy && fluid == currentFluid)
|
||||
if (tolerated) discomfort * DISCOMFORT_COST else null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A policy for an entity trying to get out of a fluid that's killing it: one it can neither swim nor breathe in,
|
||||
* or lava without fire immunity. Being in that fluid is allowed but expensive, so the shortest way out wins.
|
||||
* Anything else is held to [MovementIntent.URGENT] so it doesn't escape into something worse.
|
||||
*/
|
||||
fun escapeFluid(entity: LivingEntity, fluid: FluidKind): TraversalPolicy {
|
||||
val capabilities = MovementCapabilities.of(entity)
|
||||
val preferences = MediumPreferences.of(entity)
|
||||
return TraversalPolicy(capabilities, "escape ${fluid.name.lowercase()}") { occupancy, nodeFluid ->
|
||||
if (nodeFluid != fluid || fluid == FluidKind.NONE) {
|
||||
val discomfort = preferences.discomfort(occupancy, nodeFluid, capabilities) ?: return@TraversalPolicy null
|
||||
return@TraversalPolicy if (discomfort > MovementIntent.URGENT.tolerance) null else discomfort * DISCOMFORT_COST
|
||||
}
|
||||
when {
|
||||
capabilities.isHarmedBy(fluid) -> BURNING_COST
|
||||
occupancy == Occupancy.WADE -> 1F
|
||||
occupancy == Occupancy.SWIM -> 2F
|
||||
occupancy.isSubmerged -> HELD_BREATH_COST
|
||||
else -> 0F
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.battles.model
|
||||
|
||||
/**
|
||||
* How a [PokemonBattle] came to an end.
|
||||
*/
|
||||
enum class BattleEndResult {
|
||||
/** One side defeated the other. */
|
||||
VICTORY,
|
||||
/** A wild Pokémon was captured, ending the battle. */
|
||||
CAPTURE,
|
||||
/** An actor forfeited, giving the victory to the other side. */
|
||||
FORFEIT,
|
||||
/** A player fled from a wild Pokémon. */
|
||||
FLED,
|
||||
/** The battle was stopped without a winner, such as by a command, a player disconnecting or an error. */
|
||||
STOPPED
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
|
||||
import com.cobblemon.mod.common.api.battles.model.actor.EntityBackedBattleActor
|
||||
import com.cobblemon.mod.common.api.battles.model.actor.FleeableBattleActor
|
||||
import com.cobblemon.mod.common.api.events.CobblemonEvents
|
||||
import com.cobblemon.mod.common.api.events.battles.BattleEndedEvent
|
||||
import com.cobblemon.mod.common.api.events.battles.BattleFledEvent
|
||||
import com.cobblemon.mod.common.api.events.battles.BattleFleeAttemptEvent
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMoLangValue
|
||||
@@ -124,6 +125,12 @@ open class PokemonBattle(
|
||||
var winners = listOf<BattleActor>()
|
||||
var losers = listOf<BattleActor>()
|
||||
var ended = false
|
||||
/** How the battle ended, or null if it hasn't ended yet. */
|
||||
var endResult: BattleEndResult? = null
|
||||
/** The actor that forfeited the battle, if any. */
|
||||
var forfeitedBy: BattleActor? = null
|
||||
/** Whether a player fled from the battle. */
|
||||
var fled = false
|
||||
// TEMP battle showcase stuff
|
||||
var announcingRules = false
|
||||
var turn: Int = 0
|
||||
@@ -237,6 +244,10 @@ open class PokemonBattle(
|
||||
}
|
||||
|
||||
fun writeShowdownAction(vararg messages: String) {
|
||||
if (messages.any { it.contains("\n") || it.contains("\r") }) {
|
||||
LOGGER.warn("Refusing to forward Showdown action with an embedded line break for battle {}: {}", battleId, messages.joinToString(" | "))
|
||||
return
|
||||
}
|
||||
log(messages.joinToString("\n"))
|
||||
ShowdownService.service.send(battleId, messages.toList().toTypedArray())
|
||||
}
|
||||
@@ -256,6 +267,14 @@ open class PokemonBattle(
|
||||
|
||||
fun end() {
|
||||
ended = true
|
||||
val result = when {
|
||||
winners.isNotEmpty() && showdownMessages.any { "capture" in it } -> BattleEndResult.CAPTURE
|
||||
winners.isNotEmpty() && forfeitedBy != null -> BattleEndResult.FORFEIT
|
||||
winners.isNotEmpty() -> BattleEndResult.VICTORY
|
||||
fled -> BattleEndResult.FLED
|
||||
else -> BattleEndResult.STOPPED
|
||||
}
|
||||
endResult = result
|
||||
val awardToFainted = Cobblemon.config.awardExperienceToFaintedPokemon
|
||||
val awardOnLoss = Cobblemon.config.awardExperienceOnBattleLoss
|
||||
this.actors.forEach { actor ->
|
||||
@@ -337,6 +356,7 @@ open class PokemonBattle(
|
||||
}
|
||||
}
|
||||
}
|
||||
CobblemonEvents.BATTLE_ENDED.post(BattleEndedEvent(this, result, forfeitedBy.takeIf { result == BattleEndResult.FORFEIT }))
|
||||
sendUpdate(BattleEndPacket())
|
||||
BattleRegistry.closeBattle(this)
|
||||
}
|
||||
@@ -507,6 +527,7 @@ open class PokemonBattle(
|
||||
.forEach{it.pokemon.heal()}
|
||||
CobblemonEvents.BATTLE_FLED.post(BattleFledEvent(this, actors.asSequence().filterIsInstance<PlayerBattleActor>().iterator().next()))
|
||||
actors.filterIsInstance<EntityBackedBattleActor<*>>().mapNotNull { it.entity }.forEach { it.sendSystemMessage(battleLang("flee").yellow()) }
|
||||
fled = true
|
||||
stop()
|
||||
}
|
||||
}
|
||||
@@ -544,6 +565,7 @@ open class PokemonBattle(
|
||||
private fun checkForfeit(): Boolean {
|
||||
val forfeit = actors.find { it.responses.any { it is ForfeitActionResponse } }
|
||||
return forfeit?.let {
|
||||
forfeitedBy = it
|
||||
this.dispatchWaiting { this.broadcastChatMessage(battleLang("forfeit", it.getName()).red()) }
|
||||
writeShowdownAction(">forcelose ${it.showdownId}")
|
||||
true
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.cobblemon.mod.common.api.events.battles.BattleFaintedEvent
|
||||
import com.cobblemon.mod.common.api.events.battles.BattleFledEvent
|
||||
import com.cobblemon.mod.common.api.events.battles.BattleFleeAttemptEvent
|
||||
import com.cobblemon.mod.common.api.events.battles.BattleStartedEvent
|
||||
import com.cobblemon.mod.common.api.events.battles.BattleEndedEvent
|
||||
import com.cobblemon.mod.common.api.events.battles.BattleVictoryEvent
|
||||
import com.cobblemon.mod.common.api.events.battles.instruction.FormeChangeEvent
|
||||
import com.cobblemon.mod.common.api.events.battles.instruction.MegaEvolutionEvent
|
||||
@@ -139,6 +140,9 @@ object CobblemonEvents {
|
||||
@JvmField
|
||||
val BATTLE_FAINTED = EventObservable<BattleFaintedEvent>()
|
||||
|
||||
@JvmField
|
||||
val BATTLE_ENDED = EventObservable<BattleEndedEvent>()
|
||||
|
||||
// instructions
|
||||
@JvmField
|
||||
val MEGA_EVOLUTION = EventObservable<MegaEvolutionEvent>()
|
||||
|
||||
+69
@@ -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.api.events.battles
|
||||
|
||||
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.api.battles.model.BattleEndResult
|
||||
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.battles.model.actor.ActorType
|
||||
import com.cobblemon.mod.common.util.asArrayValue
|
||||
|
||||
/**
|
||||
* Event fired whenever a [PokemonBattle] ends, regardless of how it ended (victory, fleeing, being stopped, etc).
|
||||
*
|
||||
* [PokemonBattle.winners] and [PokemonBattle.losers] are only populated if the [result] has a winner,
|
||||
* that is [BattleEndResult.VICTORY], [BattleEndResult.CAPTURE] or [BattleEndResult.FORFEIT].
|
||||
*
|
||||
* @param result How the battle ended.
|
||||
* @param forfeitedBy The actor that forfeited, if the [result] is [BattleEndResult.FORFEIT].
|
||||
*/
|
||||
data class BattleEndedEvent(
|
||||
override val battle: PokemonBattle,
|
||||
val result: BattleEndResult,
|
||||
val forfeitedBy: BattleActor?
|
||||
) : BattleEvent {
|
||||
/** Whether one side won the battle, which includes captures and forfeits. */
|
||||
val hasWinner = battle.winners.isNotEmpty()
|
||||
val wasVictory = result == BattleEndResult.VICTORY
|
||||
val wasCapture = result == BattleEndResult.CAPTURE
|
||||
val wasForfeit = result == BattleEndResult.FORFEIT
|
||||
val wasFled = result == BattleEndResult.FLED
|
||||
val wasStopped = result == BattleEndResult.STOPPED
|
||||
|
||||
/** Whether the battle was between players and wild Pokémon. */
|
||||
val isPvW = battle.isPvW
|
||||
/** Whether the battle was between players and NPCs. */
|
||||
val isPvN = battle.isPvN
|
||||
/** Whether the battle was between players. */
|
||||
val isPvP = battle.isPvP
|
||||
|
||||
val context = mutableMapOf<String, MoValue>(
|
||||
"battle" to battle.struct,
|
||||
"result" to StringValue(result.name.lowercase()),
|
||||
"has_winner" to DoubleValue(hasWinner),
|
||||
"was_victory" to DoubleValue(wasVictory),
|
||||
"was_capture" to DoubleValue(wasCapture),
|
||||
"was_forfeit" to DoubleValue(wasForfeit),
|
||||
"was_fled" to DoubleValue(wasFled),
|
||||
"was_stopped" to DoubleValue(wasStopped),
|
||||
"is_pvw" to DoubleValue(isPvW),
|
||||
"is_pvn" to DoubleValue(isPvN),
|
||||
"is_pvp" to DoubleValue(isPvP),
|
||||
"winners" to battle.winners.asArrayValue { it.struct },
|
||||
"losers" to battle.losers.asArrayValue { it.struct },
|
||||
"players" to battle.actors.filter { it.type == ActorType.PLAYER }.asArrayValue { it.struct },
|
||||
"npcs" to battle.actors.filter { it.type == ActorType.NPC }.asArrayValue { it.struct },
|
||||
"wild_pokemon" to battle.actors.filter { it.type == ActorType.WILD }.asArrayValue { it.struct }
|
||||
).apply {
|
||||
forfeitedBy?.let { put("forfeited_by", it.struct) }
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ package com.cobblemon.mod.common.api.gui
|
||||
|
||||
import com.cobblemon.mod.common.client.gui.CobblemonRenderable
|
||||
import net.minecraft.client.gui.components.AbstractWidget
|
||||
import net.minecraft.client.gui.components.Renderable
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput
|
||||
import net.minecraft.network.chat.Component
|
||||
@@ -55,6 +54,8 @@ abstract class ParentWidget(
|
||||
}
|
||||
|
||||
override fun mouseClicked(pMouseX: Double, pMouseY: Double, pButton: Int): Boolean {
|
||||
if (!active) return false
|
||||
|
||||
return children.any {
|
||||
it.mouseClicked(pMouseX, pMouseY, pButton)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.api.gui
|
||||
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
interface TreeNode<T> {
|
||||
val children: List<TreeNode<T>>
|
||||
}
|
||||
|
||||
class TreeDrawingNode<T>(
|
||||
val value: T,
|
||||
val children: List<TreeDrawingNode<T>>,
|
||||
) {
|
||||
var x = 0
|
||||
var y = 0
|
||||
var offset = 0
|
||||
}
|
||||
|
||||
fun <T> createDrawingTree(treeNode: TreeNode<T>): TreeDrawingNode<T> {
|
||||
val root = setup(treeNode, 0, mutableListOf<Int>(), mutableListOf<Int>())
|
||||
addMods(root, 0)
|
||||
|
||||
return root
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
private fun <T> setup(
|
||||
treeNode: TreeNode<T>,
|
||||
depth: Int,
|
||||
nexts: MutableList<Int>,
|
||||
offset: MutableList<Int>,
|
||||
): TreeDrawingNode<T> {
|
||||
val children = treeNode.children.map { child ->
|
||||
setup(child, depth + 1, nexts, offset)
|
||||
}
|
||||
|
||||
val treeDrawingNode = TreeDrawingNode<T>(treeNode as T, children)
|
||||
treeDrawingNode.y = depth
|
||||
|
||||
while (nexts.size <= depth) {
|
||||
nexts.add(0)
|
||||
}
|
||||
|
||||
while (offset.size <= depth) {
|
||||
offset.add(0)
|
||||
}
|
||||
|
||||
var place =
|
||||
if (children.isEmpty()) {
|
||||
nexts[depth]
|
||||
} else if (children.size == 1) {
|
||||
// children.first().x - 1
|
||||
children.first().x
|
||||
} else {
|
||||
// (children[0].x + children[1].x) / 2
|
||||
(children.first().x + children.last().x) / 2
|
||||
}
|
||||
|
||||
offset[depth] = max(offset[depth], nexts[depth] - place)
|
||||
|
||||
if (children.isEmpty()) {
|
||||
treeDrawingNode.x = place
|
||||
} else {
|
||||
treeDrawingNode.x = place + offset[depth]
|
||||
}
|
||||
|
||||
nexts[depth] += 2
|
||||
treeDrawingNode.offset = offset[depth]
|
||||
|
||||
return treeDrawingNode
|
||||
}
|
||||
|
||||
private fun <T> addMods(
|
||||
treeNode: TreeDrawingNode<T>,
|
||||
modSum: Int,
|
||||
) {
|
||||
treeNode.x += modSum
|
||||
val newModSum = modSum + treeNode.offset
|
||||
|
||||
treeNode.children.forEach { child ->
|
||||
addMods(child, newModSum)
|
||||
}
|
||||
}
|
||||
|
||||
data class TreeDrawingBounds(val minX: Int, val maxX: Int, val minY: Int, val maxY: Int) {
|
||||
val width = maxX - minX
|
||||
val height = maxY - minY
|
||||
val xCenter = (maxX + minX) / 2.0
|
||||
val yCenter = (maxY + minY) / 2.0
|
||||
}
|
||||
|
||||
fun <T> calculateBounds(treeDrawingNode: TreeDrawingNode<T>): TreeDrawingBounds {
|
||||
var minX = treeDrawingNode.x
|
||||
var maxX = treeDrawingNode.x
|
||||
var minY = treeDrawingNode.y
|
||||
var maxY = treeDrawingNode.y
|
||||
|
||||
for (child in treeDrawingNode.children) {
|
||||
val childBounds = calculateBounds(child)
|
||||
|
||||
minX = min(minX, childBounds.minX)
|
||||
maxX = max(maxX, childBounds.maxX)
|
||||
minY = min(minY, childBounds.minY)
|
||||
maxY = max(maxY, childBounds.maxY)
|
||||
}
|
||||
|
||||
return TreeDrawingBounds(minX, maxX, minY, maxY)
|
||||
}
|
||||
File renamed without changes.
+2
@@ -16,6 +16,7 @@ import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMoLangValue
|
||||
import com.cobblemon.mod.common.battles.actor.PlayerBattleActor
|
||||
import com.cobblemon.mod.common.battles.actor.PokemonBattleActor
|
||||
import com.cobblemon.mod.common.entity.npc.NPCBattleActor
|
||||
import com.cobblemon.mod.common.util.asArrayValue
|
||||
|
||||
object BattleActorMoLangFunctions : AbstractMoLangFunctionHolder<BattleActor>() {
|
||||
override fun BattleActor.moLangFunctions(): MutableMap<String, (MoParams) -> Any> {
|
||||
@@ -25,6 +26,7 @@ object BattleActorMoLangFunctions : AbstractMoLangFunctionHolder<BattleActor>()
|
||||
functions["is_npc"] = { DoubleValue(actor.type == ActorType.NPC) }
|
||||
functions["is_player"] = { DoubleValue(actor.type == ActorType.PLAYER) }
|
||||
functions["is_wild"] = { DoubleValue(actor.type == ActorType.WILD) }
|
||||
functions["battle_pokemon"] = { actor.pokemonList.asArrayValue { it.struct } }
|
||||
|
||||
when (actor) {
|
||||
is NPCBattleActor -> {
|
||||
|
||||
+2
@@ -23,6 +23,7 @@ import com.cobblemon.mod.common.api.molang.MoLangLoadedFilesCache
|
||||
import com.cobblemon.mod.common.api.molang.ObjectValue
|
||||
import com.cobblemon.mod.common.api.moves.Moves
|
||||
import com.cobblemon.mod.common.api.npc.partyproviders.SimplePartyProvider
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonSpecies
|
||||
import com.cobblemon.mod.common.api.scheduling.ClientTaskTracker
|
||||
import com.cobblemon.mod.common.api.scheduling.ServerTaskTracker
|
||||
import com.cobblemon.mod.common.api.scripting.CobblemonScripts
|
||||
@@ -46,6 +47,7 @@ object GeneralMoLangFunctions {
|
||||
|
||||
init {
|
||||
functions["cobblemon_config"] = { Cobblemon.config.struct }
|
||||
functions["pokemon_species"] = { PokemonSpecies.struct }
|
||||
functions["print"] = { params ->
|
||||
val message = params.get<MoValue>(0).asString()
|
||||
LOGGER.info(message)
|
||||
|
||||
+13
@@ -32,6 +32,19 @@ object ItemStackMoLangFunctions : AbstractMoLangFunctionHolder<Pair<ItemStack, R
|
||||
functions["count"] = { DoubleValue(stack.count.toDouble()) }
|
||||
functions["damage_value"] = { DoubleValue(stack.damageValue) }
|
||||
functions["max_damage"] = { DoubleValue(stack.maxDamage) }
|
||||
functions["damage"] = damage@{ params ->
|
||||
val amount = params.getIntOrNull(0) ?: 1
|
||||
if (!stack.isDamageableItem) {
|
||||
return@damage DoubleValue.ONE
|
||||
}
|
||||
stack.damageValue += amount
|
||||
if (stack.damageValue >= stack.maxDamage) {
|
||||
stack.shrink(1)
|
||||
DoubleValue.ZERO
|
||||
} else {
|
||||
DoubleValue.ONE
|
||||
}
|
||||
}
|
||||
functions["is_empty"] = { DoubleValue(stack.isEmpty) }
|
||||
functions["shrink"] = { params -> stack.shrink(params.getInt(0)) }
|
||||
functions["grow"] = { params -> stack.grow(params.getInt(0)) }
|
||||
|
||||
+2
-5
@@ -16,7 +16,6 @@ import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.CobblemonMemories
|
||||
import com.cobblemon.mod.common.api.ai.CobblemonBlockPosTracker
|
||||
import com.cobblemon.mod.common.api.ai.CobblemonWanderControl
|
||||
import com.cobblemon.mod.common.api.ai.movement.createMovementStruct
|
||||
import com.cobblemon.mod.common.api.molang.ObjectValue
|
||||
import com.cobblemon.mod.common.entity.npc.NPCEntity
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
@@ -56,8 +55,6 @@ object LivingEntityMoLangFunctions : AbstractMoLangFunctionHolder<LivingEntity>(
|
||||
val entity = this
|
||||
val functions = hashMapOf<String, (MoParams) -> Any>()
|
||||
|
||||
val movementStruct = createMovementStruct(entity)
|
||||
functions["movement"] = { movementStruct }
|
||||
functions["is_player"] = { DoubleValue(entity is Player) }
|
||||
functions["is_npc"] = { DoubleValue(entity is NPCEntity) }
|
||||
functions["is_mob"] = { DoubleValue(entity is Mob) }
|
||||
@@ -101,14 +98,14 @@ object LivingEntityMoLangFunctions : AbstractMoLangFunctionHolder<LivingEntity>(
|
||||
val targetEntity = params.get<MoValue>(0)
|
||||
val maxDistance = params.getDoubleOrNull(1)?.toFloat() ?: 2.0F
|
||||
|
||||
val entity =
|
||||
val target =
|
||||
if (targetEntity is ObjectValue<*> && targetEntity.obj is Entity) {
|
||||
targetEntity.obj as Entity
|
||||
} else {
|
||||
return@isLookingAt DoubleValue.ZERO
|
||||
}
|
||||
|
||||
DoubleValue(entity.isLookingAt(entity, maxDistance))
|
||||
DoubleValue(entity.isLookingAt(target, maxDistance))
|
||||
}
|
||||
functions["is_living_entity"] = { DoubleValue.ONE }
|
||||
functions["is_flying"] = { DoubleValue(entity.isFallFlying) }
|
||||
|
||||
+9
-1
@@ -21,6 +21,7 @@ import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMoLangValue
|
||||
import com.cobblemon.mod.common.api.molang.ObjectValue
|
||||
import com.cobblemon.mod.common.api.moves.BenchedMove
|
||||
import com.cobblemon.mod.common.api.moves.Moves
|
||||
import com.cobblemon.mod.common.api.pokeball.PokeBalls
|
||||
import com.cobblemon.mod.common.api.pokemon.experience.SidemodExperienceSource
|
||||
import com.cobblemon.mod.common.api.pokemon.moves.LearnsetQuery
|
||||
import com.cobblemon.mod.common.api.pokemon.Natures
|
||||
@@ -50,6 +51,8 @@ object PokemonMoLangFunctions : AbstractMoLangFunctionHolder<Pokemon>() {
|
||||
|
||||
functions["id"] = { StringValue(pokemon.uuid.toString()) }
|
||||
functions["nickname"] = { StringValue(pokemon.nickname.toString()) }
|
||||
functions["primary_type"] = { StringValue(pokemon.form.primaryType.showdownId) }
|
||||
functions["secondary_type"] = { pokemon.form.secondaryType?.let { StringValue(it.showdownId) } ?: DoubleValue.ZERO }
|
||||
functions["level"] = { DoubleValue(pokemon.level.toDouble()) }
|
||||
functions["max_hp"] = { DoubleValue(pokemon.maxHealth.toDouble()) }
|
||||
functions["current_hp"] = { DoubleValue(pokemon.currentHealth.toDouble()) }
|
||||
@@ -67,7 +70,12 @@ object PokemonMoLangFunctions : AbstractMoLangFunctionHolder<Pokemon>() {
|
||||
}
|
||||
functions["behaviour"] = { pokemon.form.behaviour.struct }
|
||||
functions["behavior"] = { pokemon.form.behaviour.struct } // Inferior
|
||||
functions["pokeball"] = { StringValue(pokemon.caughtBall.toString()) }
|
||||
functions["pokeball"] = { pokemon.caughtBall.struct }
|
||||
functions["set_pokeball"] = setPokeball@{ params ->
|
||||
val ball = params.get<MoValue>(0).resolveFromObjectOrString { PokeBalls.getPokeBall(it.asIdentifierDefaultingNamespace()) } ?: return@setPokeball DoubleValue.ZERO
|
||||
pokemon.caughtBall = ball
|
||||
DoubleValue.ONE
|
||||
}
|
||||
functions["ability"] = { StringValue(pokemon.ability.name) }
|
||||
functions["set_ability"] = setAbility@{ params ->
|
||||
val ability = params.get<MoValue>(0).resolveFromObjectOrString { Abilities.get(it)?.create() } ?: return@setAbility DoubleValue.ZERO
|
||||
|
||||
@@ -45,7 +45,9 @@ enum class WildNestVariant(private val id: String) : StringRepresentable {
|
||||
FIERY_SOUL_SAND("fiery_soul_sand"),
|
||||
GRASSY_DEFAULT("grassy_default"),
|
||||
GRASSY_CRIMSON_ROOTS("grassy_crimson_roots"),
|
||||
//GRASSY_DRY("grassy_dry"),
|
||||
GRASSY_DRY_RED_SAND("grassy_dry_red_sand"),
|
||||
GRASSY_DRY_SAND("grassy_dry_sand"),
|
||||
GRASSY_DRY_TERRACOTTA("grassy_dry_terracotta"),
|
||||
GRASSY_FERN("grassy_fern"),
|
||||
GRASSY_WARPED_ROOTS("grassy_warped_roots"),
|
||||
|
||||
@@ -59,10 +61,14 @@ enum class WildNestVariant(private val id: String) : StringRepresentable {
|
||||
LEAFY_FLOWERING_AZALEA("leafy_flowering_azalea"),
|
||||
LEAFY_JUNGLE("leafy_jungle"),
|
||||
LEAFY_MANGROVE("leafy_mangrove"),
|
||||
LEAFY_ORANGE_POPLAR("leafy_orange_poplar"),
|
||||
LEAFY_PALE_OAK("leafy_pale_oak"),
|
||||
LEAFY_RED_POPLAR("leafy_red_poplar"),
|
||||
LEAFY_SACCHARINE("leafy_saccharine"),
|
||||
LEAFY_SACCHARINE_STICKY("leafy_saccharine_sticky"),
|
||||
LEAFY_SACCHARINE_DRIPPY("leafy_saccharine_drippy"),
|
||||
LEAFY_SPRUCE("leafy_spruce"),
|
||||
LEAFY_YELLOW_POPLAR("leafy_yellow_poplar"),
|
||||
|
||||
ICY_DEFAULT("icy_default"),
|
||||
ICY_ICE("icy_ice"),
|
||||
@@ -75,6 +81,7 @@ enum class WildNestVariant(private val id: String) : StringRepresentable {
|
||||
ROCKY_BASALT("rocky_basalt"),
|
||||
ROCKY_BLACKSTONE("rocky_blackstone"),
|
||||
ROCKY_CALCITE("rocky_calcite"),
|
||||
ROCKY_CINNABAR("rocky_cinnabar"),
|
||||
ROCKY_DEEPSLATE("rocky_deepslate"),
|
||||
ROCKY_DIORITE("rocky_diorite"),
|
||||
ROCKY_DRIPSTONE("rocky_dripstone"),
|
||||
@@ -85,6 +92,7 @@ enum class WildNestVariant(private val id: String) : StringRepresentable {
|
||||
ROCKY_SANDSTONE("rocky_sandstone"),
|
||||
ROCKY_SCULK("rocky_sculk"),
|
||||
ROCKY_SNOWY("rocky_snowy"),
|
||||
ROCKY_SULFUR("rocky_sulfur"),
|
||||
ROCKY_TERRACOTTA("rocky_terracotta"),
|
||||
ROCKY_TUFF("rocky_tuff"),
|
||||
|
||||
@@ -109,13 +117,16 @@ enum class WildNestVariant(private val id: String) : StringRepresentable {
|
||||
TWIGGY_DEAD_BUSH("twiggy_dead_bush"),
|
||||
TWIGGY_FLOWERING_AZALEA("twiggy_flowering_azalea"),
|
||||
TWIGGY_JUNGLE("twiggy_jungle"),
|
||||
TWIGGY_LEAFY("twiggy_leafy"),
|
||||
TWIGGY_MANGROVE_LEAVES("twiggy_mangrove_leaves"),
|
||||
TWIGGY_MANGROVE("twiggy_mangrove"),
|
||||
TWIGGY_ORANGE_POPLAR("twiggy_orange_poplar"),
|
||||
TWIGGY_PALE_OAK("twiggy_pale_oak"),
|
||||
TWIGGY_RED_POPLAR("twiggy_red_poplar"),
|
||||
TWIGGY_SACCHARINE("twiggy_saccharine"),
|
||||
TWIGGY_SACCHARINE_STICKY("twiggy_saccharine_sticky"),
|
||||
TWIGGY_SACCHARINE_DRIPPY("twiggy_saccharine_drippy"),
|
||||
TWIGGY_SPRUCE("twiggy_spruce"),
|
||||
TWIGGY_YELLOW_POPLAR("twiggy_yellow_poplar"),
|
||||
|
||||
WATERY_DEFAULT("watery_default"),
|
||||
WATERY_STONE("watery_stone"),
|
||||
@@ -153,6 +164,9 @@ object WildNestTypes {
|
||||
private val NEST_SURFACE_FIERY_SOUL_SAND = nestSurfaceTag("fiery_soul_sand")
|
||||
|
||||
private val NEST_SURFACE_GRASSY_CRIMSON_ROOTS = nestSurfaceTag("grassy_crimson_roots")
|
||||
private val NEST_SURFACE_GRASSY_DRY_RED_SAND = nestSurfaceTag("grassy_dry_red_sand")
|
||||
private val NEST_SURFACE_GRASSY_DRY_SAND = nestSurfaceTag("grassy_dry_sand")
|
||||
private val NEST_SURFACE_GRASSY_DRY_TERRACOTTA = nestSurfaceTag("grassy_dry_terracotta")
|
||||
private val NEST_SURFACE_GRASSY_FERN = nestSurfaceTag("grassy_fern")
|
||||
private val NEST_SURFACE_GRASSY_WARPED_ROOTS = nestSurfaceTag("grassy_warped_roots")
|
||||
|
||||
@@ -165,8 +179,12 @@ object WildNestTypes {
|
||||
private val NEST_SURFACE_LEAFY_FLOWERING_AZALEA = nestSurfaceTag("leafy_flowering_azalea")
|
||||
private val NEST_SURFACE_LEAFY_JUNGLE = nestSurfaceTag("leafy_jungle")
|
||||
private val NEST_SURFACE_LEAFY_MANGROVE = nestSurfaceTag("leafy_mangrove")
|
||||
private val NEST_SURFACE_LEAFY_ORANGE_POPLAR = nestSurfaceTag("leafy_orange_poplar")
|
||||
private val NEST_SURFACE_LEAFY_PALE_OAK = nestSurfaceTag("leafy_pale_oak")
|
||||
private val NEST_SURFACE_LEAFY_RED_POPLAR = nestSurfaceTag("leafy_red_poplar")
|
||||
private val NEST_SURFACE_LEAFY_SACCHARINE = nestSurfaceTag("leafy_saccharine")
|
||||
private val NEST_SURFACE_LEAFY_SPRUCE = nestSurfaceTag("leafy_spruce")
|
||||
private val NEST_SURFACE_LEAFY_YELLOW_POPLAR = nestSurfaceTag("leafy_yellow_poplar")
|
||||
|
||||
private val NEST_SURFACE_ICY_ICE = nestSurfaceTag("icy_ice")
|
||||
|
||||
@@ -175,6 +193,7 @@ object WildNestTypes {
|
||||
private val NEST_SURFACE_ROCKY_BASALT = nestSurfaceTag("rocky_basalt")
|
||||
private val NEST_SURFACE_ROCKY_BLACKSTONE = nestSurfaceTag("rocky_blackstone")
|
||||
private val NEST_SURFACE_ROCKY_CALCITE = nestSurfaceTag("rocky_calcite")
|
||||
private val NEST_SURFACE_ROCKY_CINNABAR = nestSurfaceTag("rocky_cinnabar")
|
||||
private val NEST_SURFACE_ROCKY_DEEPSLATE = nestSurfaceTag("rocky_deepslate")
|
||||
private val NEST_SURFACE_ROCKY_DIORITE = nestSurfaceTag("rocky_diorite")
|
||||
private val NEST_SURFACE_ROCKY_DRIPSTONE = nestSurfaceTag("rocky_dripstone")
|
||||
@@ -185,6 +204,7 @@ object WildNestTypes {
|
||||
private val NEST_SURFACE_ROCKY_SANDSTONE = nestSurfaceTag("rocky_sandstone")
|
||||
private val NEST_SURFACE_ROCKY_SCULK = nestSurfaceTag("rocky_sculk")
|
||||
private val NEST_SURFACE_ROCKY_SNOWY = nestSurfaceTag("rocky_snowy")
|
||||
private val NEST_SURFACE_ROCKY_SULFUR = nestSurfaceTag("rocky_sulfur")
|
||||
private val NEST_SURFACE_ROCKY_TERRACOTTA = nestSurfaceTag("rocky_terracotta")
|
||||
private val NEST_SURFACE_ROCKY_TUFF = nestSurfaceTag("rocky_tuff")
|
||||
|
||||
@@ -208,8 +228,12 @@ object WildNestTypes {
|
||||
private val NEST_SURFACE_TWIGGY_MANGROVE_LEAVES = nestSurfaceTag("twiggy_mangrove_leaves")
|
||||
private val NEST_SURFACE_TWIGGY_MANGROVE = nestSurfaceTag("twiggy_mangrove")
|
||||
private val NEST_SURFACE_TWIGGY_OAK = nestSurfaceTag("twiggy_oak")
|
||||
private val NEST_SURFACE_TWIGGY_ORANGE_POPLAR = nestSurfaceTag("twiggy_orange_poplar")
|
||||
private val NEST_SURFACE_TWIGGY_PALE_OAK = nestSurfaceTag("twiggy_pale_oak")
|
||||
private val NEST_SURFACE_TWIGGY_RED_POPLAR = nestSurfaceTag("twiggy_red_poplar")
|
||||
private val NEST_SURFACE_TWIGGY_SACCHARINE = nestSurfaceTag("twiggy_saccharine")
|
||||
private val NEST_SURFACE_TWIGGY_SPRUCE = nestSurfaceTag("twiggy_spruce")
|
||||
private val NEST_SURFACE_TWIGGY_YELLOW_POPLAR = nestSurfaceTag("twiggy_yellow_poplar")
|
||||
|
||||
private val NEST_SURFACE_WATERY_DRIPLEAF = nestSurfaceTag("watery_dripleaf")
|
||||
private val NEST_SURFACE_WATERY_STONE = nestSurfaceTag("watery_stone")
|
||||
@@ -313,7 +337,9 @@ object WildNestTypes {
|
||||
baseState.`is`(NEST_SURFACE_GRASSY_CRIMSON_ROOTS) -> WildNestVariant.GRASSY_CRIMSON_ROOTS
|
||||
baseState.`is`(NEST_SURFACE_GRASSY_WARPED_ROOTS) -> WildNestVariant.GRASSY_WARPED_ROOTS
|
||||
baseState.`is`(NEST_SURFACE_GRASSY_FERN) -> WildNestVariant.GRASSY_FERN
|
||||
//baseState.`is`(NEST_SURFACE_GRASSY_DRY) -> WildNestVariant.GRASSY_DRY
|
||||
baseState.`is`(NEST_SURFACE_GRASSY_DRY_RED_SAND) -> WildNestVariant.GRASSY_DRY_RED_SAND
|
||||
baseState.`is`(NEST_SURFACE_GRASSY_DRY_SAND) -> WildNestVariant.GRASSY_DRY_SAND
|
||||
baseState.`is`(NEST_SURFACE_GRASSY_DRY_TERRACOTTA) -> WildNestVariant.GRASSY_DRY_TERRACOTTA
|
||||
else -> null
|
||||
}
|
||||
WildNestType.LEAFY -> when {
|
||||
@@ -326,6 +352,9 @@ object WildNestTypes {
|
||||
baseState.`is`(NEST_SURFACE_LEAFY_FLOWERING_AZALEA) -> WildNestVariant.LEAFY_FLOWERING_AZALEA
|
||||
baseState.`is`(NEST_SURFACE_LEAFY_JUNGLE) -> WildNestVariant.LEAFY_JUNGLE
|
||||
baseState.`is`(NEST_SURFACE_LEAFY_MANGROVE) -> WildNestVariant.LEAFY_MANGROVE
|
||||
baseState.`is`(NEST_SURFACE_LEAFY_ORANGE_POPLAR) -> WildNestVariant.LEAFY_ORANGE_POPLAR
|
||||
baseState.`is`(NEST_SURFACE_LEAFY_PALE_OAK) -> WildNestVariant.LEAFY_PALE_OAK
|
||||
baseState.`is`(NEST_SURFACE_LEAFY_RED_POPLAR) -> WildNestVariant.LEAFY_RED_POPLAR
|
||||
baseState.`is`(NEST_SURFACE_LEAFY_SACCHARINE) -> saccharineVariantForHoneyLevel(
|
||||
baseState,
|
||||
WildNestVariant.LEAFY_SACCHARINE,
|
||||
@@ -333,6 +362,7 @@ object WildNestTypes {
|
||||
WildNestVariant.LEAFY_SACCHARINE_DRIPPY
|
||||
)
|
||||
baseState.`is`(NEST_SURFACE_LEAFY_SPRUCE) -> WildNestVariant.LEAFY_SPRUCE
|
||||
baseState.`is`(NEST_SURFACE_LEAFY_YELLOW_POPLAR) -> WildNestVariant.LEAFY_YELLOW_POPLAR
|
||||
else -> null
|
||||
}
|
||||
WildNestType.ICY -> when {
|
||||
@@ -347,6 +377,7 @@ object WildNestTypes {
|
||||
baseState.`is`(NEST_SURFACE_ROCKY_BASALT) -> WildNestVariant.ROCKY_BASALT
|
||||
baseState.`is`(NEST_SURFACE_ROCKY_BLACKSTONE) -> WildNestVariant.ROCKY_BLACKSTONE
|
||||
baseState.`is`(NEST_SURFACE_ROCKY_CALCITE) -> WildNestVariant.ROCKY_CALCITE
|
||||
baseState.`is`(NEST_SURFACE_ROCKY_CINNABAR) -> WildNestVariant.ROCKY_CINNABAR
|
||||
baseState.`is`(NEST_SURFACE_ROCKY_DEEPSLATE) -> WildNestVariant.ROCKY_DEEPSLATE
|
||||
baseState.`is`(NEST_SURFACE_ROCKY_DIORITE) -> WildNestVariant.ROCKY_DIORITE
|
||||
baseState.`is`(NEST_SURFACE_ROCKY_DRIPSTONE) -> WildNestVariant.ROCKY_DRIPSTONE
|
||||
@@ -357,6 +388,7 @@ object WildNestTypes {
|
||||
baseState.`is`(NEST_SURFACE_ROCKY_SANDSTONE) -> WildNestVariant.ROCKY_SANDSTONE
|
||||
baseState.`is`(NEST_SURFACE_ROCKY_SCULK) -> WildNestVariant.ROCKY_SCULK
|
||||
baseState.`is`(NEST_SURFACE_ROCKY_SNOWY) -> WildNestVariant.ROCKY_SNOWY
|
||||
baseState.`is`(NEST_SURFACE_ROCKY_SULFUR) -> WildNestVariant.ROCKY_SULFUR
|
||||
baseState.`is`(NEST_SURFACE_ROCKY_TERRACOTTA) -> WildNestVariant.ROCKY_TERRACOTTA
|
||||
baseState.`is`(NEST_SURFACE_ROCKY_TUFF) -> WildNestVariant.ROCKY_TUFF
|
||||
else -> null
|
||||
@@ -383,6 +415,9 @@ object WildNestTypes {
|
||||
baseState.`is`(NEST_SURFACE_TWIGGY_JUNGLE) -> WildNestVariant.TWIGGY_JUNGLE
|
||||
baseState.`is`(NEST_SURFACE_TWIGGY_MANGROVE_LEAVES) -> WildNestVariant.TWIGGY_MANGROVE_LEAVES
|
||||
baseState.`is`(NEST_SURFACE_TWIGGY_OAK) -> WildNestVariant.TWIGGY_OAK
|
||||
baseState.`is`(NEST_SURFACE_TWIGGY_ORANGE_POPLAR) -> WildNestVariant.TWIGGY_ORANGE_POPLAR
|
||||
baseState.`is`(NEST_SURFACE_TWIGGY_PALE_OAK) -> WildNestVariant.TWIGGY_PALE_OAK
|
||||
baseState.`is`(NEST_SURFACE_TWIGGY_RED_POPLAR) -> WildNestVariant.TWIGGY_RED_POPLAR
|
||||
baseState.`is`(NEST_SURFACE_TWIGGY_SACCHARINE) -> saccharineVariantForHoneyLevel(
|
||||
baseState,
|
||||
WildNestVariant.TWIGGY_SACCHARINE,
|
||||
@@ -390,6 +425,7 @@ object WildNestTypes {
|
||||
WildNestVariant.TWIGGY_SACCHARINE_DRIPPY
|
||||
)
|
||||
baseState.`is`(NEST_SURFACE_TWIGGY_SPRUCE) -> WildNestVariant.TWIGGY_SPRUCE
|
||||
baseState.`is`(NEST_SURFACE_TWIGGY_YELLOW_POPLAR) -> WildNestVariant.TWIGGY_YELLOW_POPLAR
|
||||
baseState.`is`(NEST_SURFACE_TWIGGY_MANGROVE) -> WildNestVariant.TWIGGY_MANGROVE
|
||||
baseState.`is`(NEST_SURFACE_TWIGGY_CHORUS) -> WildNestVariant.TWIGGY_CHORUS
|
||||
baseState.`is`(NEST_SURFACE_TWIGGY_DEAD_BUSH) -> WildNestVariant.TWIGGY_DEAD_BUSH
|
||||
@@ -406,7 +442,7 @@ object WildNestTypes {
|
||||
submerged && baseState.`is`(NEST_SURFACE_WATERY_DEAD_CORAL_FIRE) -> WildNestVariant.WATERY_DEAD_CORAL_FIRE
|
||||
submerged && baseState.`is`(NEST_SURFACE_WATERY_DEAD_CORAL_HORN) -> WildNestVariant.WATERY_DEAD_CORAL_HORN
|
||||
submerged && baseState.`is`(NEST_SURFACE_WATERY_DEAD_CORAL_TUBE) -> WildNestVariant.WATERY_DEAD_CORAL_TUBE
|
||||
submerged && baseState.`is`(NEST_SURFACE_WATERY_MANGROVE) -> WildNestVariant.WATERY_MANGROVE
|
||||
baseState.`is`(NEST_SURFACE_WATERY_MANGROVE) -> WildNestVariant.WATERY_MANGROVE
|
||||
submerged && baseState.`is`(NEST_SURFACE_WATERY_DEEPSLATE) -> WildNestVariant.WATERY_DEEPSLATE
|
||||
submerged && baseState.`is`(NEST_SURFACE_WATERY_STONE) -> WildNestVariant.WATERY_STONE
|
||||
baseState.`is`(NEST_SURFACE_WATERY_DRIPLEAF) -> WildNestVariant.WATERY_DRIPLEAF
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ object CatchRateModifiers {
|
||||
* Used by [PokeBalls.SAFARI_BALL].
|
||||
* Checks if the target is not battling, if true boost by *1.5
|
||||
*/
|
||||
val SAFARI = WorldStateModifier { _, entity -> if (!entity.isBattling) 1.5F else 1F }
|
||||
val SAFARI = MultiplierModifier(1.5f) { _, poke -> !poke.entity?.isBattling!! }
|
||||
|
||||
/**
|
||||
* Used by [PokeBalls.PARK_BALL].
|
||||
|
||||
@@ -13,6 +13,10 @@ import com.cobblemon.mod.common.api.molang.MoLangFunctions.addStandardFunctions
|
||||
import com.cobblemon.mod.common.api.molang.ObjectValue
|
||||
import com.cobblemon.mod.common.api.pokedex.entry.PokedexEntry
|
||||
import com.cobblemon.mod.common.api.pokedex.entry.PokedexForm
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonSpecies
|
||||
import com.cobblemon.mod.common.api.pokemon.feature.ChoiceSpeciesFeatureProvider
|
||||
import com.cobblemon.mod.common.api.pokemon.feature.SpeciesFeatures
|
||||
import com.cobblemon.mod.common.api.pokemon.feature.WeightedChoiceSpeciesFeatureProvider
|
||||
import com.cobblemon.mod.common.pokedex.scanner.PokedexEntityData
|
||||
import com.cobblemon.mod.common.pokemon.Gender
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
@@ -72,6 +76,57 @@ abstract class AbstractPokedexManager {
|
||||
} ?: PokedexEntryProgress.UNREGISTERED
|
||||
}
|
||||
|
||||
fun getHighestKnowledgeFor(entry: PokedexEntry, form: PokedexForm?): PokedexEntryProgress {
|
||||
if (form == null) return getHighestKnowledgeFor(entry)
|
||||
|
||||
val speciesRecord = getSpeciesRecord(entry.speciesId) ?: return PokedexEntryProgress.UNREGISTERED
|
||||
val hasAllAspects = entry.conditionAspects.all(speciesRecord::hasAspect)
|
||||
if (!hasAllAspects) {
|
||||
return PokedexEntryProgress.UNREGISTERED
|
||||
}
|
||||
|
||||
return speciesRecord.getFormRecord(form.displayForm)?.knowledge ?: PokedexEntryProgress.UNREGISTERED
|
||||
}
|
||||
|
||||
fun getHighestKnowledgeFor(entry: PokedexEntry, form: PokedexForm?, aspects: Iterable<String>): PokedexEntryProgress {
|
||||
val formKnowledge = getHighestKnowledgeFor(entry, form)
|
||||
|
||||
if (formKnowledge == PokedexEntryProgress.UNREGISTERED) return PokedexEntryProgress.UNREGISTERED
|
||||
|
||||
val seenAspects = getSeenAspects(entry)
|
||||
|
||||
// Aspects that select one of the species' own forms are already covered by the form knowledge check above,
|
||||
// so exempt them (and every other value of the same feature, since defaults like "phony" never appear on a form directly).
|
||||
val species = PokemonSpecies.getByIdentifier(entry.speciesId)
|
||||
val formAspects = species?.forms?.flatMapTo(hashSetOf()) { it.aspects } ?: emptySet()
|
||||
val formSelectingFeatureAspects = species?.let(SpeciesFeatures::getFeaturesFor).orEmpty()
|
||||
.mapNotNull { provider ->
|
||||
val allAspects: Collection<String> = when (provider) {
|
||||
is ChoiceSpeciesFeatureProvider -> provider.getAllAspects()
|
||||
is WeightedChoiceSpeciesFeatureProvider -> provider.getAllAspects().keys
|
||||
else -> return@mapNotNull null
|
||||
}
|
||||
allAspects.takeIf { it.any { aspect -> aspect in formAspects } }
|
||||
}
|
||||
.flatten()
|
||||
.toHashSet()
|
||||
|
||||
val allSeenAspects = aspects
|
||||
.filter { aspect ->
|
||||
if (Dexes.equivalentFormsLookup[aspect] != null) return@filter false
|
||||
if (aspect in formAspects || aspect in formSelectingFeatureAspects) return@filter false
|
||||
if (aspect.uppercase() in setOf(Gender.MALE.name, Gender.FEMALE.name, Gender.GENDERLESS.name)) return@filter false
|
||||
if ("shiny".equals(aspect, ignoreCase = true)) return@filter false
|
||||
|
||||
return@filter true
|
||||
}
|
||||
.all { aspect -> seenAspects.contains(aspect) }
|
||||
|
||||
if (!allSeenAspects) return PokedexEntryProgress.UNREGISTERED
|
||||
|
||||
return formKnowledge
|
||||
}
|
||||
|
||||
fun getEncounteredForms(entry: PokedexEntry) : List<PokedexForm> {
|
||||
return getFormsWithKnowledge(entry, PokedexEntryProgress.SEEN)
|
||||
}
|
||||
|
||||
@@ -40,6 +40,17 @@ object Dexes : JsonDataRegistry<PokedexDef> {
|
||||
//Maps a dex id to its PokedexDef
|
||||
val dexEntryMap = linkedMapOf<ResourceLocation, PokedexDef>()
|
||||
|
||||
val equivalentForms = mapOf(
|
||||
"galar" to listOf("region-bias-galar", "bias-galar", "galar-bias", "galarian", "galar"),
|
||||
"alola" to listOf("region-bias-alola", "bias-alola", "alola-bias", "alolan", "alola"),
|
||||
"hisui" to listOf("region-bias-hisui", "bias-hisui", "hisui-bias", "hisuian", "hisui"),
|
||||
"paldea" to listOf("region-bias-paldea", "bias-paldea", "paldea-bias", "paldean", "paldea"),
|
||||
)
|
||||
|
||||
val equivalentFormsLookup = equivalentForms.flatMap { (key, values) ->
|
||||
values.map { it to key }
|
||||
}.toMap()
|
||||
|
||||
override fun reload(data: Map<ResourceLocation, PokedexDef>) {
|
||||
dexEntryMap.clear()
|
||||
data.entries.sortedBy { it.value.sortOrder }.forEach { (id, def) -> dexEntryMap[id] = def }
|
||||
@@ -49,4 +60,9 @@ object Dexes : JsonDataRegistry<PokedexDef> {
|
||||
override fun sync(player: ServerPlayer) {
|
||||
PokedexDexSyncPacket(dexEntryMap.values).sendToPlayer(player)
|
||||
}
|
||||
|
||||
fun getFormEquivalents(formName: String): List<String> {
|
||||
val key = equivalentFormsLookup[formName.lowercase()]
|
||||
return equivalentForms[key] ?: listOf(formName.lowercase())
|
||||
}
|
||||
}
|
||||
@@ -121,6 +121,7 @@ class SpeciesDexRecord {
|
||||
|
||||
fun addAspects(addedAspects: Set<String>) {
|
||||
aspects.addAll(addedAspects)
|
||||
pokedexManager.onSpeciesRecordUpdated(this)
|
||||
}
|
||||
|
||||
/** Returns true if the given Pokémon contains new information. Internal because it's only to be called from [FormDexRecord.wouldBeDifferent]. */
|
||||
|
||||
@@ -8,13 +8,20 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.pokedex.entry
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.CobblemonItems
|
||||
import com.cobblemon.mod.common.api.data.JsonDataRegistry
|
||||
import com.cobblemon.mod.common.api.molang.ExpressionLike
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonSpecies
|
||||
import com.cobblemon.mod.common.api.reactive.SimpleObservable
|
||||
import com.cobblemon.mod.common.net.messages.client.data.DexEntrySyncPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.data.DexEvolutionDisplaySyncPacket
|
||||
import com.cobblemon.mod.common.pokemon.FormData
|
||||
import com.cobblemon.mod.common.util.adapters.ExpressionLikeAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.IdentifierAdapter
|
||||
import com.cobblemon.mod.common.util.asIdentifierDefaultingNamespace
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import com.cobblemon.mod.common.util.lang
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.reflect.TypeToken
|
||||
@@ -38,6 +45,8 @@ object DexEntries : JsonDataRegistry<PokedexEntry> {
|
||||
|
||||
val entries = mutableMapOf<ResourceLocation, PokedexEntry>()
|
||||
|
||||
val evolutionDisplays = mutableListOf<DexEvolutionDisplay>()
|
||||
|
||||
override fun reload(data: Map<ResourceLocation, PokedexEntry>) {
|
||||
data.forEach { _, entry ->
|
||||
entries[entry.id] = entry
|
||||
@@ -50,6 +59,7 @@ object DexEntries : JsonDataRegistry<PokedexEntry> {
|
||||
}
|
||||
}
|
||||
}
|
||||
computeEvolutionDisplays()
|
||||
observable.emit(this)
|
||||
}
|
||||
|
||||
@@ -57,5 +67,58 @@ object DexEntries : JsonDataRegistry<PokedexEntry> {
|
||||
|
||||
override fun sync(player: ServerPlayer) {
|
||||
DexEntrySyncPacket(entries.values).sendToPlayer(player)
|
||||
DexEvolutionDisplaySyncPacket(evolutionDisplays).sendToPlayer(player)
|
||||
}
|
||||
}
|
||||
|
||||
fun computeEvolutionDisplays() {
|
||||
evolutionDisplays.clear()
|
||||
PokemonSpecies.species.forEach {
|
||||
try {
|
||||
evolutionDisplays.addAll(buildDisplays(it.standardForm) + it.forms.flatMap { form -> buildDisplays(form) })
|
||||
} catch (e: Exception) {
|
||||
Cobblemon.LOGGER.error("Failed to build dex evolution displays for ${it.resourceIdentifier}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun buildDisplays(form: FormData): List<DexEvolutionDisplay> {
|
||||
val result = mutableListOf<DexEvolutionDisplay>()
|
||||
(form.ownEvolutions ?: form.evolutions).forEach { evolution ->
|
||||
val requirements = mutableListOf<DexEvolutionRequirementDisplay>()
|
||||
getToolTipHeaderIcon(evolution)?.let { header ->
|
||||
requirements.add(header)
|
||||
}
|
||||
evolution.requirements.mapNotNull { resolveRequirementData(it) }.forEach { requirement ->
|
||||
requirements.add(requirement)
|
||||
}
|
||||
|
||||
listOfNotNull(evolution.result, evolution.shedder).forEach resultLoop@{ resultProperties ->
|
||||
val resultSpecies = resultProperties.species
|
||||
?.let { PokemonSpecies.getByIdentifier(it.asIdentifierDefaultingNamespace()) }
|
||||
?: return@resultLoop
|
||||
|
||||
// The result's own aspects win, otherwise carry the source form's aspects over
|
||||
// like a real evolution does (Alola-Bias Pichu -> Alola-Bias Pikachu)
|
||||
val resultForm = resultSpecies.getForm(resultProperties.aspects).takeIf { it != resultSpecies.standardForm }
|
||||
?: resultSpecies.getForm(form.aspects.toSet() + resultProperties.aspects)
|
||||
val toAspects = resultProperties.aspects + resultForm.aspects
|
||||
val resultRequirements = if (resultProperties === evolution.shedder) {
|
||||
requirements + CobblemonDexEvolutionRequirementDisplay(CobblemonItems.POKE_BALL, lang("ui.pokedex.evolution.shedder.tooltip"))
|
||||
} else {
|
||||
requirements
|
||||
}
|
||||
|
||||
result.add(DexEvolutionDisplay(
|
||||
fromSpecies = form.species.resourceIdentifier,
|
||||
fromForm = form.name,
|
||||
fromAspects = form.aspects.toSet(),
|
||||
toSpecies = resultSpecies.resourceIdentifier,
|
||||
toForm = resultForm.name,
|
||||
toAspects = toAspects,
|
||||
requirements = resultRequirements,
|
||||
))
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
+466
@@ -0,0 +1,466 @@
|
||||
/*
|
||||
* 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.pokedex.entry
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonItems
|
||||
import com.cobblemon.mod.common.api.conditional.RegistryLikeCondition
|
||||
import com.cobblemon.mod.common.api.conditional.RegistryLikeIdentifierCondition
|
||||
import com.cobblemon.mod.common.api.conditional.RegistryLikeTagCondition
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonSpecies
|
||||
import com.cobblemon.mod.common.api.pokemon.evolution.Evolution
|
||||
import com.cobblemon.mod.common.api.pokemon.feature.IntSpeciesFeatureProvider
|
||||
import com.cobblemon.mod.common.api.pokemon.feature.SpeciesFeatures
|
||||
import com.cobblemon.mod.common.api.pokemon.requirement.Requirement
|
||||
import com.cobblemon.mod.common.api.pokemon.stats.Stats
|
||||
import com.cobblemon.mod.common.api.text.add
|
||||
import com.cobblemon.mod.common.api.text.green
|
||||
import com.cobblemon.mod.common.api.types.ElementalTypes
|
||||
import com.cobblemon.mod.common.pokemon.evolution.variants.ItemInteractionEvolution
|
||||
import com.cobblemon.mod.common.pokemon.evolution.variants.TradeEvolution
|
||||
import com.cobblemon.mod.common.pokemon.requirements.*
|
||||
import com.cobblemon.mod.common.util.adapters.RegistryAccessResolver
|
||||
import com.cobblemon.mod.common.util.asIdentifierDefaultingNamespace
|
||||
import com.cobblemon.mod.common.util.asTranslated
|
||||
import com.cobblemon.mod.common.util.lang
|
||||
import net.minecraft.core.registries.BuiltInRegistries
|
||||
import net.minecraft.core.registries.Registries
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.MutableComponent
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.util.ExtraCodecs
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.Items
|
||||
import net.minecraft.world.level.biome.Biome
|
||||
import net.minecraft.world.level.levelgen.structure.Structure
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
|
||||
data class DexEvolutionDisplay(
|
||||
val fromSpecies: ResourceLocation,
|
||||
val fromForm: String,
|
||||
val fromAspects: Set<String>,
|
||||
val toSpecies: ResourceLocation,
|
||||
val toForm: String,
|
||||
val toAspects: Set<String>,
|
||||
val requirements: List<DexEvolutionRequirementDisplay>,
|
||||
)
|
||||
|
||||
interface DexEvolutionRequirementDisplay {
|
||||
val icon: Item
|
||||
val tooltip: MutableComponent
|
||||
}
|
||||
|
||||
data class CobblemonDexEvolutionRequirementDisplay(
|
||||
override val icon: Item,
|
||||
override val tooltip: MutableComponent,
|
||||
) : DexEvolutionRequirementDisplay
|
||||
|
||||
data class CobblemonBiomeDexEvolutionRequirementDisplay(
|
||||
override val icon: Item,
|
||||
override val tooltip: MutableComponent,
|
||||
val condition: ExtraCodecs.TagOrElementLocation? = null,
|
||||
val antiCondition: ExtraCodecs.TagOrElementLocation? = null,
|
||||
) : DexEvolutionRequirementDisplay
|
||||
|
||||
fun getToolTipHeaderIcon(evolution: Evolution): DexEvolutionRequirementDisplay? {
|
||||
when (evolution) {
|
||||
is ItemInteractionEvolution -> return getToolTipHeaderIcon(evolution)
|
||||
is TradeEvolution -> return getToolTipHeaderIcon(evolution)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
fun getToolTipHeaderIcon(itemInteractionEvolution: ItemInteractionEvolution): CobblemonDexEvolutionRequirementDisplay? {
|
||||
val item = itemInteractionEvolution.requiredContext.items.orElse(null)?.firstOrNull()?.value() ?: return null
|
||||
return CobblemonDexEvolutionRequirementDisplay(item, lang("ui.pokedex.evolution.item_interact.tooltip", item.description.plainCopy().green()))
|
||||
}
|
||||
|
||||
fun getToolTipHeaderIcon(tradeEvolution: TradeEvolution): CobblemonDexEvolutionRequirementDisplay {
|
||||
val species = tradeEvolution.requiredContext.species
|
||||
val tooltip = if (species == null) {
|
||||
lang("ui.pokedex.evolution.trade.tooltip.with_any_species")
|
||||
} else {
|
||||
PokemonSpecies.getByIdentifier(species.asIdentifierDefaultingNamespace())
|
||||
?.let { lang("ui.pokedex.evolution.trade.tooltip.with_species", it.translatedName.plainCopy().green()) }
|
||||
?: lang("ui.pokedex.evolution.trade.tooltip.with_any_species")
|
||||
}
|
||||
return CobblemonDexEvolutionRequirementDisplay(CobblemonItems.LINK_CABLE, tooltip)
|
||||
}
|
||||
|
||||
fun resolveRequirementData(requirement: Requirement): DexEvolutionRequirementDisplay? {
|
||||
val icon = requirement.pokedexIcon?.let {
|
||||
RegistryAccessResolver.getAccess().registryOrThrow(Registries.ITEM).get(it)
|
||||
}
|
||||
|
||||
val tooltip = requirement.pokedexTooltip?.let {
|
||||
Component.translatable(it)
|
||||
}
|
||||
|
||||
if (icon != null && tooltip != null) {
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
return buildRequirementData(requirement)
|
||||
}
|
||||
|
||||
fun buildRequirementData(requirement: Requirement): DexEvolutionRequirementDisplay? {
|
||||
when (requirement) {
|
||||
is AdvancementRequirement -> return buildAdvancementRequirement(requirement)
|
||||
is BattleCriticalHitsRequirement -> return buildBattleCriticalHitsRequirement(requirement)
|
||||
is BiomeRequirement -> return buildBiomeRequirement(requirement)
|
||||
is BlocksTraveledRequirement -> return buildBlocksTraveledRequirement(requirement)
|
||||
is DamageTakenRequirement -> return buildDamageTakenRequirement(requirement)
|
||||
is DefeatRequirement -> return buildDefeatRequirement(requirement)
|
||||
is FriendshipRequirement -> return buildFriendshipRequirement(requirement)
|
||||
is HeldItemRequirement -> return buildHeldItemRequirement(requirement)
|
||||
is LevelRequirement -> return buildLevelRequirement(requirement)
|
||||
is MoonPhaseRequirement -> return buildMoonPhaseRequirement(requirement)
|
||||
is MoveSetRequirement -> return buildMoveSetRequirement(requirement)
|
||||
is MoveTypeRequirement -> return buildMoveTypeRequirement(requirement)
|
||||
is NegateRequirement -> return buildNegateRequirement(requirement)
|
||||
is OwnerHoldsItemRequirement -> return buildOwnerHoldsItemRequirement(requirement)
|
||||
is PartyMemberRequirement -> return buildPartyMemberRequirement(requirement)
|
||||
is PokemonPropertiesRequirement -> return buildPokemonPropertiesRequirement(requirement)
|
||||
is PropertyRangeRequirement -> return buildPropertyRangeRequirement(requirement)
|
||||
is RecoilRequirement -> return buildRecoilRequirement(requirement)
|
||||
is StatCompareRequirement -> return buildStatCompareRequirement(requirement)
|
||||
is StatEqualRequirement -> return buildStatEqualRequirement(requirement)
|
||||
is StructureRequirement -> return buildStructureRequirement(requirement)
|
||||
is TimeRangeRequirement -> return buildTimeRangeRequirement(requirement)
|
||||
is UseMoveRequirement -> return buildUseMoveRequirement(requirement)
|
||||
is WeatherRequirement -> return buildWeatherRequirement(requirement)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
fun buildAdvancementRequirement(advancementRequirement: AdvancementRequirement): DexEvolutionRequirementDisplay {
|
||||
val icon = Items.BOOK
|
||||
val identifier = advancementRequirement.requiredAdvancement
|
||||
val advancementLanguageKey = "${identifier.namespace}.${identifier.path.substringAfterLast('/')}"
|
||||
val advancementComponent = Component.translatable("advancements.$advancementLanguageKey").green()
|
||||
val tooltip = lang("ui.pokedex.requirement.advancement.tooltip", advancementComponent)
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildBattleCriticalHitsRequirement(battleCriticalHitsRequirement: BattleCriticalHitsRequirement): DexEvolutionRequirementDisplay {
|
||||
val icon = CobblemonItems.MEDICINAL_LEEK
|
||||
val criticalsComponent = Component.literal(battleCriticalHitsRequirement.amount.toString()).green()
|
||||
val tooltip = lang("ui.pokedex.requirement.battle_critical_hits.tooltip", criticalsComponent)
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
private fun tagDisplayName(registry: String, id: ResourceLocation): MutableComponent {
|
||||
return Component.translatableWithFallback("tag.$registry.${id.namespace}.${id.path.replace('/', '.')}", prettifyPath(id.path))
|
||||
}
|
||||
|
||||
private fun prettifyPath(path: String): String {
|
||||
return path.substringAfterLast('/').removePrefix("is_").split('_').joinToString(" ") { part -> part.replaceFirstChar(Char::titlecase) }
|
||||
}
|
||||
|
||||
fun buildNegateRequirement(negateRequirement: NegateRequirement): DexEvolutionRequirementDisplay? {
|
||||
val inner = negateRequirement.inner
|
||||
when (inner) {
|
||||
is BiomeRequirement -> buildBiomeRequirement(inner, negated = true)?.let { return it }
|
||||
is StructureRequirement -> buildStructureRequirement(inner, negated = true)?.let { return it }
|
||||
}
|
||||
val innerDisplay = resolveRequirementData(inner) ?: return null
|
||||
return CobblemonDexEvolutionRequirementDisplay(innerDisplay.icon, lang("ui.pokedex.requirement.negate.tooltip", innerDisplay.tooltip))
|
||||
}
|
||||
|
||||
fun buildBiomeRequirement(biomeRequirement: BiomeRequirement, negated: Boolean = false): DexEvolutionRequirementDisplay? {
|
||||
// Negating "in X" is "not in X"; negating both a condition and an anticondition isn't expressible as one line
|
||||
if (negated && biomeRequirement.biomeCondition != null && biomeRequirement.biomeAnticondition != null) return null
|
||||
val condition = if (negated) biomeRequirement.biomeAnticondition else biomeRequirement.biomeCondition
|
||||
val antiCondition = if (negated) biomeRequirement.biomeCondition else biomeRequirement.biomeAnticondition
|
||||
if (condition == null && antiCondition == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
val icon = Items.COMPASS
|
||||
val displayName: (RegistryLikeCondition<Biome>) -> MutableComponent = {
|
||||
when (it) {
|
||||
is RegistryLikeTagCondition -> tagDisplayName("worldgen.biome", it.tag.location())
|
||||
is RegistryLikeIdentifierCondition -> Component.translatable("biome.${it.identifier.namespace}.${it.identifier.path}")
|
||||
else -> Component.literal(it.toString())
|
||||
}
|
||||
}
|
||||
|
||||
val tooltip = if (condition != null && antiCondition != null) {
|
||||
lang("ui.pokedex.requirement.biome.both.tooltip", displayName(condition).green(), displayName(antiCondition).green())
|
||||
} else if (condition != null) {
|
||||
lang("ui.pokedex.requirement.biome.tooltip", displayName(condition).green())
|
||||
} else {
|
||||
lang("ui.pokedex.requirement.biome.anticondition.tooltip", displayName(antiCondition!!).green())
|
||||
}
|
||||
|
||||
var conditionConverted: ExtraCodecs.TagOrElementLocation? = null
|
||||
if (condition != null) {
|
||||
val conditionIdentifier = if (condition is RegistryLikeIdentifierCondition) condition.identifier else (condition as RegistryLikeTagCondition).tag.location
|
||||
conditionConverted = ExtraCodecs.TagOrElementLocation(conditionIdentifier, condition is RegistryLikeTagCondition)
|
||||
}
|
||||
|
||||
var antiConditionConverted: ExtraCodecs.TagOrElementLocation? = null
|
||||
if (antiCondition != null) {
|
||||
val conditionIdentifier = if (antiCondition is RegistryLikeIdentifierCondition) antiCondition.identifier else (antiCondition as RegistryLikeTagCondition).tag.location
|
||||
antiConditionConverted = ExtraCodecs.TagOrElementLocation(conditionIdentifier, antiCondition is RegistryLikeTagCondition)
|
||||
}
|
||||
|
||||
return CobblemonBiomeDexEvolutionRequirementDisplay(icon, tooltip, conditionConverted, antiConditionConverted)
|
||||
}
|
||||
|
||||
fun buildBlocksTraveledRequirement(blocksTraveledRequirement: BlocksTraveledRequirement): DexEvolutionRequirementDisplay {
|
||||
val icon = Items.LEATHER_BOOTS
|
||||
val blocksComponent = Component.literal(blocksTraveledRequirement.amount.toString()).green()
|
||||
val tooltip = lang("ui.pokedex.requirement.blocks_traveled.tooltip", blocksComponent)
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildDamageTakenRequirement(damageTakenRequirement: DamageTakenRequirement): DexEvolutionRequirementDisplay {
|
||||
val icon = CobblemonItems.PUNCHING_GLOVE
|
||||
val blocksComponent = Component.literal(damageTakenRequirement.amount.toString()).green()
|
||||
val tooltip = lang("ui.pokedex.requirement.damage_taken.tooltip", blocksComponent)
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildDefeatRequirement(defeatRequirement: DefeatRequirement): DexEvolutionRequirementDisplay? {
|
||||
val description = describePokemonProperties(defeatRequirement.target) ?: return null
|
||||
val icon = CobblemonItems.PUNCHING_GLOVE
|
||||
val defeatedAmount = defeatRequirement.amount
|
||||
|
||||
val descriptionComponent = Component.literal(defeatedAmount.toString()).green().add(" ").add(description)
|
||||
val tooltip = lang("ui.pokedex.requirement.defeat.tooltip", descriptionComponent)
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildFriendshipRequirement(friendshipRequirement: FriendshipRequirement): DexEvolutionRequirementDisplay {
|
||||
val icon = CobblemonItems.SOOTHE_BELL
|
||||
val friendshipAmountComponent = Component.literal(friendshipRequirement.amount.toString()).green()
|
||||
val tooltip = lang("ui.pokedex.requirement.friendship.tooltip", friendshipAmountComponent)
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildHeldItemRequirement(heldItemRequirement: HeldItemRequirement): DexEvolutionRequirementDisplay? {
|
||||
val items = heldItemRequirement.itemCondition.items.getOrNull() ?: return null
|
||||
val item = items.firstOrNull()?.value() ?: return null
|
||||
val itemComponent = items.unwrapKey().map { tag ->
|
||||
val id = tag.location()
|
||||
val fallback = id.path.substringAfterLast('/').split('_').joinToString(" ") { part -> part.replaceFirstChar(Char::titlecase) }
|
||||
Component.translatableWithFallback("tag.item.${id.namespace}.${id.path.replace('/', '.')}", fallback)
|
||||
}.orElseGet { item.description.plainCopy() }
|
||||
val tooltip = lang("ui.pokedex.requirement.held_item.tooltip", itemComponent.green())
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(item, tooltip)
|
||||
}
|
||||
|
||||
fun buildLevelRequirement(levelRequirement: LevelRequirement): DexEvolutionRequirementDisplay {
|
||||
val minLevel = levelRequirement.minLevel
|
||||
val maxLevel = levelRequirement.maxLevel
|
||||
|
||||
val icon = CobblemonItems.RARE_CANDY
|
||||
val tooltip =
|
||||
if (minLevel == maxLevel || maxLevel == Int.MAX_VALUE)
|
||||
lang("ui.pokedex.requirement.level.tooltip.min", Component.literal(minLevel.toString()).green())
|
||||
else
|
||||
lang("ui.pokedex.requirement.level.tooltip.between", Component.literal(minLevel.toString()).green(), Component.literal(maxLevel.toString()).green())
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildMoonPhaseRequirement(moonPhaseRequirement: MoonPhaseRequirement): DexEvolutionRequirementDisplay {
|
||||
val icon = Items.CLOCK
|
||||
val moonPhaseComponent = moonPhaseRequirement.moonPhase.displayName().plainCopy().green()
|
||||
val tooltip = lang("ui.pokedex.requirement.moon_phase.tooltip", moonPhaseComponent)
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildMoveSetRequirement(moveSetRequirement: MoveSetRequirement): DexEvolutionRequirementDisplay {
|
||||
val icon = CobblemonItems.TECHNICAL_MACHINE
|
||||
val tooltip = lang("ui.pokedex.requirement.has_move.tooltip", moveSetRequirement.move.displayName.plainCopy().green())
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildMoveTypeRequirement(moveTypeRequirement: MoveTypeRequirement): DexEvolutionRequirementDisplay {
|
||||
val type = ElementalTypes.get(moveTypeRequirement.type.name)
|
||||
val icon = when (type) {
|
||||
ElementalTypes.NORMAL -> CobblemonItems.NORMAL_GEM
|
||||
ElementalTypes.FIRE -> CobblemonItems.FIRE_GEM
|
||||
ElementalTypes.WATER -> CobblemonItems.WATER_GEM
|
||||
ElementalTypes.GRASS -> CobblemonItems.GRASS_GEM
|
||||
ElementalTypes.ELECTRIC -> CobblemonItems.ELECTRIC_GEM
|
||||
ElementalTypes.ICE -> CobblemonItems.ICE_GEM
|
||||
ElementalTypes.FIGHTING -> CobblemonItems.FIGHTING_GEM
|
||||
ElementalTypes.POISON -> CobblemonItems.POISON_GEM
|
||||
ElementalTypes.GROUND -> CobblemonItems.GROUND_GEM
|
||||
ElementalTypes.FLYING -> CobblemonItems.FLYING_GEM
|
||||
ElementalTypes.PSYCHIC -> CobblemonItems.PSYCHIC_GEM
|
||||
ElementalTypes.BUG -> CobblemonItems.BUG_GEM
|
||||
ElementalTypes.ROCK -> CobblemonItems.ROCK_GEM
|
||||
ElementalTypes.GHOST -> CobblemonItems.GHOST_GEM
|
||||
ElementalTypes.DRAGON -> CobblemonItems.DRAGON_GEM
|
||||
ElementalTypes.DARK -> CobblemonItems.DARK_GEM
|
||||
ElementalTypes.STEEL -> CobblemonItems.STEEL_GEM
|
||||
ElementalTypes.FAIRY -> CobblemonItems.FAIRY_GEM
|
||||
else -> CobblemonItems.NORMAL_GEM
|
||||
}
|
||||
|
||||
val tooltip = lang("ui.pokedex.requirement.has_move_type.tooltip", moveTypeRequirement.type.displayName.plainCopy().green())
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildOwnerHoldsItemRequirement(ownerHoldsItemRequirement: OwnerHoldsItemRequirement): DexEvolutionRequirementDisplay? {
|
||||
val item = ownerHoldsItemRequirement.itemCondition.items.orElse(null)?.firstOrNull()?.value() ?: return null
|
||||
val tooltip = lang("ui.pokedex.requirement.owner_held_item.tooltip", item.description.plainCopy().green())
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(item, tooltip)
|
||||
}
|
||||
|
||||
fun buildPartyMemberRequirement(partyMemberRequirement: PartyMemberRequirement): DexEvolutionRequirementDisplay? {
|
||||
val description = describePokemonProperties(partyMemberRequirement.target) ?: return null
|
||||
val icon = CobblemonItems.POKE_BALL
|
||||
val tooltip = if (partyMemberRequirement.contains) {
|
||||
lang("ui.pokedex.requirement.party_member.tooltip", description)
|
||||
} else {
|
||||
lang("ui.pokedex.requirement.party_member.anticondition.tooltip", description)
|
||||
}
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildPokemonPropertiesRequirement(pokemonPropertiesRequirement: PokemonPropertiesRequirement): DexEvolutionRequirementDisplay? {
|
||||
val description = describePokemonProperties(pokemonPropertiesRequirement.target) ?: return null
|
||||
val icon = Items.NAME_TAG
|
||||
val tooltip = lang("ui.pokedex.requirement.pokemon_properties.tooltip", description)
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildPropertyRangeRequirement(propertyRangeRequirement: PropertyRangeRequirement): DexEvolutionRequirementDisplay? {
|
||||
val provider = SpeciesFeatures.getFeature(propertyRangeRequirement.feature) as? IntSpeciesFeatureProvider ?: return null
|
||||
val displayName = provider.display?.name?.takeIf { it.isNotBlank() }?.asTranslated()?.green() ?: return null
|
||||
val icon = provider.itemPoints.keys.firstOrNull()?.let { BuiltInRegistries.ITEM.get(it) } ?: Items.NAME_TAG
|
||||
|
||||
val range = propertyRangeRequirement.range
|
||||
val tooltip = lang(
|
||||
"ui.pokedex.requirement.property_range.tooltip",
|
||||
displayName,
|
||||
Component.literal(range.first.toString()).green(),
|
||||
Component.literal(range.last.toString()).green()
|
||||
)
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildRecoilRequirement(recoilRequirement: RecoilRequirement): DexEvolutionRequirementDisplay {
|
||||
val icon = CobblemonItems.LIFE_ORB
|
||||
val recoilComponent = Component.literal(recoilRequirement.amount.toString()).green()
|
||||
val tooltip = lang("ui.pokedex.requirement.recoil.tooltip", recoilComponent)
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildStatCompareRequirement(statCompareRequirement: StatCompareRequirement): DexEvolutionRequirementDisplay {
|
||||
val highStat = Stats.getStat(statCompareRequirement.highStat)
|
||||
val lowStat = Stats.getStat(statCompareRequirement.lowStat)
|
||||
|
||||
val icon = when (highStat) {
|
||||
Stats.HP, Stats.EVASION, Stats.ACCURACY -> CobblemonItems.HEALTH_MOCHI
|
||||
Stats.ATTACK -> CobblemonItems.MUSCLE_MOCHI
|
||||
Stats.DEFENCE -> CobblemonItems.RESIST_MOCHI
|
||||
Stats.SPECIAL_ATTACK -> CobblemonItems.GENIUS_MOCHI
|
||||
Stats.SPECIAL_DEFENCE -> CobblemonItems.CLEVER_MOCHI
|
||||
Stats.SPEED -> CobblemonItems.SWIFT_MOCHI
|
||||
}
|
||||
|
||||
val highStatComponent = highStat.displayName.plainCopy().green()
|
||||
val lowStatComponent = lowStat.displayName.plainCopy().green()
|
||||
val tooltip = lang("ui.pokedex.requirement.stat_compare.tooltip", highStatComponent, lowStatComponent)
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildStatEqualRequirement(statEqualRequirement: StatEqualRequirement): DexEvolutionRequirementDisplay {
|
||||
val statOne = Stats.getStat(statEqualRequirement.statOne)
|
||||
val statTwo = Stats.getStat(statEqualRequirement.statTwo)
|
||||
|
||||
val statOneComponent = statOne.displayName.plainCopy().green()
|
||||
val statTwoComponent = statTwo.displayName.plainCopy().green()
|
||||
|
||||
val icon = CobblemonItems.FRESH_START_MOCHI
|
||||
val tooltip = lang("ui.pokedex.requirement.stat_equal.tooltip", statOneComponent, statTwoComponent)
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildStructureRequirement(structureRequirement: StructureRequirement, negated: Boolean = false): DexEvolutionRequirementDisplay? {
|
||||
if (negated && structureRequirement.structureCondition != null && structureRequirement.structureAnticondition != null) return null
|
||||
val condition = if (negated) structureRequirement.structureAnticondition else structureRequirement.structureCondition
|
||||
val anticondition = if (negated) structureRequirement.structureCondition else structureRequirement.structureAnticondition
|
||||
if (condition == null && anticondition == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
val icon = Items.FILLED_MAP
|
||||
val displayName: (RegistryLikeCondition<Structure>) -> MutableComponent = {
|
||||
when (it) {
|
||||
is RegistryLikeTagCondition -> tagDisplayName("worldgen.structure", it.tag.location())
|
||||
is RegistryLikeIdentifierCondition -> Component.literal(prettifyPath(it.identifier.path))
|
||||
else -> Component.literal(it.toString())
|
||||
}
|
||||
}
|
||||
val tooltip = if (condition != null && anticondition != null) {
|
||||
lang("ui.pokedex.requirement.structure.both.tooltip", displayName(condition).green(), displayName(anticondition).green())
|
||||
} else if (condition != null) {
|
||||
lang("ui.pokedex.requirement.structure.tooltip", displayName(condition).green())
|
||||
} else {
|
||||
lang("ui.pokedex.requirement.structure.anticondition.tooltip", displayName(anticondition!!).green())
|
||||
}
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildTimeRangeRequirement(timeRangeRequirement: TimeRangeRequirement): DexEvolutionRequirementDisplay? {
|
||||
val icon = Items.CLOCK
|
||||
val timeRangeComponent = timeRangeRequirement.range.displayName()?.plainCopy() ?: return null
|
||||
val tooltip = lang("ui.pokedex.requirement.time_range.tooltip", timeRangeComponent.green())
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildUseMoveRequirement(useMoveRequirement: UseMoveRequirement): DexEvolutionRequirementDisplay {
|
||||
val icon = CobblemonItems.CHOICE_BAND
|
||||
val tooltip = lang("ui.pokedex.requirement.use_move.tooltip", useMoveRequirement.move.displayName.plainCopy().green())
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
|
||||
fun buildWeatherRequirement(weatherRequirement: WeatherRequirement): DexEvolutionRequirementDisplay {
|
||||
val icon: Item
|
||||
val tooltip: MutableComponent
|
||||
|
||||
if (weatherRequirement.isThundering == true) {
|
||||
icon = Items.LIGHTNING_ROD
|
||||
tooltip = lang("ui.pokedex.requirement.weather.tooltip.thundering")
|
||||
} else {
|
||||
icon = Items.WATER_BUCKET
|
||||
tooltip = lang("ui.pokedex.requirement.weather.tooltip.raining")
|
||||
}
|
||||
|
||||
return CobblemonDexEvolutionRequirementDisplay(icon, tooltip)
|
||||
}
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* 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.pokedex.entry
|
||||
|
||||
import com.cobblemon.mod.common.api.pokemon.Natures
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonProperties
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonSpecies
|
||||
import com.cobblemon.mod.common.api.pokemon.feature.IntSpeciesFeature
|
||||
import com.cobblemon.mod.common.api.pokemon.feature.IntSpeciesFeatureProvider
|
||||
import com.cobblemon.mod.common.api.pokemon.feature.SpeciesFeatures
|
||||
import com.cobblemon.mod.common.api.pokemon.feature.StringSpeciesFeature
|
||||
import com.cobblemon.mod.common.api.properties.CustomPokemonProperty
|
||||
import com.cobblemon.mod.common.api.text.add
|
||||
import com.cobblemon.mod.common.api.text.green
|
||||
import com.cobblemon.mod.common.api.types.ElementalTypes
|
||||
import com.cobblemon.mod.common.util.asIdentifierDefaultingNamespace
|
||||
import com.cobblemon.mod.common.util.asTranslated
|
||||
import com.cobblemon.mod.common.util.lang
|
||||
import net.minecraft.core.registries.BuiltInRegistries
|
||||
import net.minecraft.locale.Language
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.MutableComponent
|
||||
import net.minecraft.world.item.Items
|
||||
|
||||
fun describePokemonProperties(properties: PokemonProperties): MutableComponent? {
|
||||
if (hasUndescribedProperty(properties)) {
|
||||
return null
|
||||
}
|
||||
|
||||
val descriptors = mutableListOf<MutableComponent>()
|
||||
|
||||
properties.species?.let { PokemonSpecies.getByIdentifier(it.asIdentifierDefaultingNamespace()) }?.let {
|
||||
descriptors.add(it.translatedName.plainCopy().green())
|
||||
}
|
||||
properties.gender?.let {
|
||||
descriptors.add(lang("gender.${it.name.lowercase()}").green())
|
||||
}
|
||||
properties.nickname?.let {
|
||||
descriptors.add(lang("ui.pokedex.requirement.properties.nickname", it.plainCopy().green()))
|
||||
}
|
||||
properties.type?.let {
|
||||
val typeName = ElementalTypes.get(it)?.displayName?.plainCopy() ?: Component.literal(it)
|
||||
descriptors.add(lang("ui.pokedex.requirement.properties.type", typeName.green()))
|
||||
}
|
||||
properties.nature?.let {
|
||||
val natureName = Natures.getNature(it.asIdentifierDefaultingNamespace())?.displayName?.asTranslated() ?: Component.literal(it)
|
||||
descriptors.add(lang("ui.pokedex.requirement.properties.nature", natureName.green()))
|
||||
}
|
||||
properties.customProperties.forEach { customProperty ->
|
||||
describeCustomProperty(customProperty)?.let { descriptors.add(it) }
|
||||
}
|
||||
|
||||
val heldItemDescriptor = properties.heldItem?.let { heldItem ->
|
||||
val itemId = heldItem.substringBefore('[').trim().asIdentifierDefaultingNamespace()
|
||||
val item = BuiltInRegistries.ITEM.get(itemId)
|
||||
if (item == Items.AIR) null else lang("ui.pokedex.requirement.properties.held_item", item.description.plainCopy().green())
|
||||
}
|
||||
|
||||
if (descriptors.isEmpty() && heldItemDescriptor == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
val mainDescriptor = when {
|
||||
descriptors.isEmpty() -> null
|
||||
descriptors.size == 1 -> descriptors[0]
|
||||
else -> {
|
||||
val allButLast = descriptors.dropLast(1).reduce { acc, next -> acc.add(", ").add(next) }
|
||||
lang("ui.pokedex.requirement.properties.and", allButLast, descriptors.last())
|
||||
}
|
||||
}
|
||||
|
||||
return when {
|
||||
mainDescriptor != null && heldItemDescriptor != null -> mainDescriptor.add(" ").add(heldItemDescriptor)
|
||||
mainDescriptor != null -> mainDescriptor
|
||||
else -> heldItemDescriptor
|
||||
}
|
||||
}
|
||||
|
||||
private fun hasUndescribedProperty(properties: PokemonProperties): Boolean {
|
||||
return properties.form != null ||
|
||||
properties.shiny != null ||
|
||||
properties.level != null ||
|
||||
properties.friendship != null ||
|
||||
properties.fullness != null ||
|
||||
properties.pokeball != null ||
|
||||
properties.ability != null ||
|
||||
properties.status != null ||
|
||||
properties.teraType != null ||
|
||||
properties.dmaxLevel != null ||
|
||||
properties.gmaxFactor != null ||
|
||||
properties.tradeable != null ||
|
||||
properties.originalTrainerType != null ||
|
||||
properties.originalTrainer != null ||
|
||||
properties.moves != null ||
|
||||
properties.movesetBuilders != null ||
|
||||
properties.cosmeticItem != null ||
|
||||
properties.scaleModifier != null ||
|
||||
properties.isAlpha != null ||
|
||||
properties.minPerfectIVs != null ||
|
||||
properties.customProperties.any { describeCustomProperty(it) == null }
|
||||
}
|
||||
|
||||
private fun describeCustomProperty(property: CustomPokemonProperty): MutableComponent? {
|
||||
return when (property) {
|
||||
is IntSpeciesFeature -> describeIntSpeciesFeature(property)
|
||||
is StringSpeciesFeature -> describeStringSpeciesFeature(property)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
private fun describeIntSpeciesFeature(property: IntSpeciesFeature): MutableComponent? {
|
||||
val value = Component.literal(property.value.toString())
|
||||
|
||||
val overrideKey = "ui.pokedex.requirement.properties.custom.${property.name}"
|
||||
if (Language.getInstance().has("cobblemon.$overrideKey")) {
|
||||
return lang(overrideKey, value.green())
|
||||
}
|
||||
|
||||
val displayName = (SpeciesFeatures.getFeature(property.name) as? IntSpeciesFeatureProvider)
|
||||
?.display?.name?.takeIf { it.isNotBlank() }
|
||||
?: return null
|
||||
|
||||
return lang("ui.pokedex.requirement.properties.int_feature", value.green(), displayName.asTranslated().green())
|
||||
}
|
||||
|
||||
private fun describeStringSpeciesFeature(property: StringSpeciesFeature): MutableComponent? {
|
||||
val key = "ui.pokedex.requirement.properties.custom.${property.name}"
|
||||
if (!Language.getInstance().has("cobblemon.$key")) {
|
||||
return null
|
||||
}
|
||||
|
||||
val value = PokemonSpecies.getByIdentifier(property.value.asIdentifierDefaultingNamespace())?.translatedName?.plainCopy()
|
||||
?: Component.literal(property.value)
|
||||
|
||||
return lang(key, value.green())
|
||||
}
|
||||
@@ -30,7 +30,6 @@ import com.cobblemon.mod.common.api.moves.MoveTemplate
|
||||
import com.cobblemon.mod.common.api.moves.MovesetBuilder
|
||||
import com.cobblemon.mod.common.api.moves.adapters.MoveTemplateAdapter
|
||||
import com.cobblemon.mod.common.api.npc.configuration.MoLangConfigVariable
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonSpecies.getByIdentifier
|
||||
import com.cobblemon.mod.common.api.pokemon.effect.ShoulderEffect
|
||||
import com.cobblemon.mod.common.api.pokemon.effect.adapter.ShoulderEffectAdapter
|
||||
import com.cobblemon.mod.common.api.pokemon.egg.EggGroup
|
||||
|
||||
+16
-2
@@ -15,6 +15,8 @@ import com.cobblemon.mod.common.block.entity.PokeSnackBlockEntity
|
||||
import com.cobblemon.mod.common.client.entity.PokemonClientDelegate
|
||||
import com.cobblemon.mod.common.client.render.MatrixWrapper
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.ParticleStatus
|
||||
import net.minecraft.core.particles.BlockParticleOption
|
||||
import net.minecraft.core.particles.ParticleOptions
|
||||
import net.minecraft.core.particles.ParticleTypes
|
||||
@@ -40,13 +42,25 @@ sealed class ParticleData {
|
||||
val chance: Double,
|
||||
val amount: Int,
|
||||
val locatorResolver: (Map<String, MatrixWrapper>) -> List<String>
|
||||
): ParticleData()
|
||||
): ParticleData() {
|
||||
fun amount(): Int = when(Minecraft.getInstance().options.particles().get()) {
|
||||
ParticleStatus.ALL -> amount
|
||||
ParticleStatus.DECREASED -> amount / 2
|
||||
ParticleStatus.MINIMAL -> amount / 4
|
||||
}
|
||||
}
|
||||
|
||||
data class MinecraftParticle(
|
||||
val particle: ParticleOptions,
|
||||
val chance: Double,
|
||||
val amount: Int
|
||||
): ParticleData()
|
||||
): ParticleData() {
|
||||
fun amount(): Int = when(Minecraft.getInstance().options.particles().get()) {
|
||||
ParticleStatus.ALL -> amount
|
||||
ParticleStatus.DECREASED -> amount / 2
|
||||
ParticleStatus.MINIMAL -> amount / 4
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,8 @@ package com.cobblemon.mod.common.api.pokemon.requirement
|
||||
import com.cobblemon.mod.common.api.pokemon.evolution.ContextEvolution
|
||||
import com.cobblemon.mod.common.api.pokemon.evolution.Evolution
|
||||
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import java.util.WeakHashMap
|
||||
|
||||
/**
|
||||
* Represents a universal requirement suitable for various checks on pokemon..
|
||||
@@ -32,4 +34,11 @@ fun interface Requirement {
|
||||
*/
|
||||
fun check(pokemon: Pokemon): Boolean
|
||||
|
||||
val pokedexIcon: ResourceLocation? get() = pokedexIconOverrides[this]
|
||||
val pokedexTooltip: String? get() = pokedexTooltipOverrides[this]
|
||||
|
||||
companion object {
|
||||
val pokedexIconOverrides = WeakHashMap<Requirement, ResourceLocation>()
|
||||
val pokedexTooltipOverrides = WeakHashMap<Requirement, String>()
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,12 @@
|
||||
package com.cobblemon.mod.common.api.riding.stats
|
||||
|
||||
import com.cobblemon.mod.common.api.cooking.Flavour
|
||||
import com.cobblemon.mod.common.api.tags.CobblemonItemTags
|
||||
import com.cobblemon.mod.common.util.lang
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.MutableComponent
|
||||
import net.minecraft.tags.TagKey
|
||||
import net.minecraft.world.item.Item
|
||||
|
||||
/**
|
||||
* A stat that is used for riding Pokémon. The exact implementation of each of these depends on the [com.cobblemon.mod.common.api.riding.controller.RideController].
|
||||
@@ -20,13 +23,14 @@ import net.minecraft.network.chat.MutableComponent
|
||||
* @since February 17th, 2025
|
||||
*/
|
||||
enum class RidingStat(
|
||||
val flavour: Flavour
|
||||
val flavour: Flavour,
|
||||
val powerItem: TagKey<Item>
|
||||
) {
|
||||
ACCELERATION(Flavour.SPICY),
|
||||
SKILL(Flavour.DRY),
|
||||
SPEED(Flavour.SWEET),
|
||||
STAMINA(Flavour.SOUR),
|
||||
JUMP(Flavour.BITTER);
|
||||
ACCELERATION(Flavour.SPICY, CobblemonItemTags.POWER_BRACER),
|
||||
SKILL(Flavour.DRY, CobblemonItemTags.POWER_BELT),
|
||||
SPEED(Flavour.SWEET, CobblemonItemTags.POWER_ANKLET),
|
||||
STAMINA(Flavour.SOUR, CobblemonItemTags.POWER_WEIGHT),
|
||||
JUMP(Flavour.BITTER, CobblemonItemTags.POWER_BAND);
|
||||
|
||||
companion object {
|
||||
fun getByName(name: String) = RidingStat.entries.firstOrNull { it.name.equals(name, ignoreCase = true) }
|
||||
|
||||
@@ -10,6 +10,8 @@ package com.cobblemon.mod.common.api.spawning
|
||||
|
||||
import com.cobblemon.mod.common.api.spawning.TimeRange.Companion.timeRanges
|
||||
import com.cobblemon.mod.common.api.spawning.condition.SpawningCondition
|
||||
import com.cobblemon.mod.common.util.lang
|
||||
import net.minecraft.network.chat.MutableComponent
|
||||
import com.cobblemon.mod.common.util.adapters.IntRangesAdapter
|
||||
|
||||
/**
|
||||
@@ -49,4 +51,25 @@ class TimeRange : IntRanges {
|
||||
|
||||
constructor() : super()
|
||||
constructor(vararg ranges: IntRange) : super(*ranges)
|
||||
|
||||
fun displayName(): MutableComponent? {
|
||||
val key = timeRanges.entries.firstOrNull { entry -> this == entry.value }?.key ?: return null
|
||||
return lang("ui.time_range.$key")
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is TimeRange) return false
|
||||
|
||||
if (other.ranges.size != this.ranges.size) return false
|
||||
other.ranges.forEachIndexed { index, otherRange ->
|
||||
if (this.ranges[index] != otherRange) return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return ranges.hashCode()
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -42,8 +42,8 @@ abstract class AreaTypeSpawningCondition<T : AreaSpawnablePosition> : SpawningCo
|
||||
override fun copyFrom(other: SpawningCondition<*>, merger: Merger) {
|
||||
super.copyFrom(other, merger)
|
||||
if (other is AreaTypeSpawningCondition) {
|
||||
merger.mergeSingle(minHeight, other.minHeight)
|
||||
merger.mergeSingle(maxHeight, other.maxHeight)
|
||||
minHeight = merger.mergeSingle(minHeight, other.minHeight)
|
||||
maxHeight = merger.mergeSingle(maxHeight, other.maxHeight)
|
||||
neededNearbyBlocks = merger.merge(neededNearbyBlocks, other.neededNearbyBlocks)?.toMutableList()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.spawning.condition
|
||||
|
||||
import com.cobblemon.mod.common.util.lang
|
||||
import net.minecraft.network.chat.MutableComponent
|
||||
import net.minecraft.world.level.Level
|
||||
|
||||
/**
|
||||
@@ -42,4 +44,7 @@ enum class MoonPhase {
|
||||
fun ofWorld(world: Level): MoonPhase = VALUES[world.moonPhase]
|
||||
}
|
||||
|
||||
fun displayName(): MutableComponent {
|
||||
return lang("ui.moon_phase.${this.name.lowercase()}")
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -46,7 +46,7 @@ abstract class SubmergedTypeSpawningCondition<T : SubmergedSpawnablePosition> :
|
||||
super.copyFrom(other, merger)
|
||||
if (other is SubmergedTypeSpawningCondition) {
|
||||
minDepth = merger.mergeSingle(minDepth, other.minDepth)
|
||||
maxDepth = merger.mergeSingle(minDepth, other.minDepth)
|
||||
maxDepth = merger.mergeSingle(maxDepth, other.maxDepth)
|
||||
fluidIsSource = merger.mergeSingle(fluidIsSource, other.fluidIsSource)
|
||||
fluid = merger.mergeSingle(fluid, other.fluid)
|
||||
}
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ abstract class SurfaceTypeSpawningCondition<T : SurfaceSpawnablePosition> : Area
|
||||
super.copyFrom(other, merger)
|
||||
if (other is SurfaceTypeSpawningCondition) {
|
||||
minDepth = merger.mergeSingle(minDepth, other.minDepth)
|
||||
maxDepth = merger.mergeSingle(minDepth, other.minDepth)
|
||||
maxDepth = merger.mergeSingle(maxDepth, other.maxDepth)
|
||||
fluid = merger.mergeSingle(fluid, other.fluid)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import com.cobblemon.mod.common.api.spawning.position.SpawnablePosition
|
||||
import com.cobblemon.mod.common.api.types.ElementalTypes
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.entity.pokemon.ai.sensors.AlphaLevelMatchingSensor
|
||||
import com.cobblemon.mod.common.util.asIdentifierDefaultingNamespace
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.entity.Entity
|
||||
|
||||
@@ -76,7 +77,7 @@ open class SpawnBaitInfluence(val effects: List<SpawnBait.Effect>, val onUsed: (
|
||||
?: return super.affectWeight(detail, spawnablePosition, weight)
|
||||
|
||||
val detailSpecies = pokemonDetail.pokemon.species
|
||||
?.let { PokemonSpecies.getByName(it) }
|
||||
?.let { PokemonSpecies.getByIdentifier(it.asIdentifierDefaultingNamespace()) }
|
||||
?: return super.affectWeight(detail, spawnablePosition, weight)
|
||||
|
||||
val formData = detailSpecies.getForm(pokemonDetail.pokemon.aspects)
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.util.isBoxLoaded
|
||||
import com.cobblemon.mod.common.util.removeIf
|
||||
import com.cobblemon.mod.common.util.squeezeWithinBounds
|
||||
import com.cobblemon.mod.common.util.toBlockPos
|
||||
import com.cobblemon.mod.common.util.toVec3f
|
||||
import com.cobblemon.mod.common.util.weightedSelection
|
||||
import kotlin.math.max
|
||||
@@ -190,13 +191,12 @@ interface Spawner {
|
||||
}
|
||||
|
||||
fun isValidStartPoint(world: Level, chunk: ChunkAccess, startPos: BlockPos.MutableBlockPos): Boolean {
|
||||
val y = startPos.y
|
||||
if (!world.isLoaded(startPos) || !world.isLoaded(startPos.setY(y + 1))) {
|
||||
val abovePos = startPos.above()
|
||||
if (!world.isLoaded(startPos) || !world.isLoaded(abovePos)) {
|
||||
return false
|
||||
}
|
||||
|
||||
val mid = chunk.getBlockState(startPos.setY(y))
|
||||
val above = chunk.getBlockState(startPos.setY(y + 1))
|
||||
val mid = chunk.getBlockState(startPos)
|
||||
val above = chunk.getBlockState(abovePos)
|
||||
|
||||
// Above must be non-solid
|
||||
if (!above.isPathfindable(PathComputationType.AIR)) {
|
||||
@@ -212,52 +212,50 @@ interface Spawner {
|
||||
}
|
||||
|
||||
fun constrainArea(area: SpawningZoneInput): SpawningZoneInput? {
|
||||
val basePos = BlockPos.MutableBlockPos(area.baseX, area.baseY, area.baseZ)
|
||||
val originalY = area.baseY
|
||||
|
||||
val (chunkX, chunkZ) = Pair(SectionPos.blockToSectionCoord(area.baseX), SectionPos.blockToSectionCoord(area.baseZ))
|
||||
val world = area.world
|
||||
val centerPos = area.getCenter().toBlockPos()
|
||||
|
||||
val (centerChunkX, centerChunkZ) = Pair(SectionPos.blockToSectionCoord(centerPos.x), SectionPos.blockToSectionCoord(centerPos.z))
|
||||
// if the chunk isn't loaded, we don't want to go further & we don't want the getChunk function below to load/create the chunk.
|
||||
if (!area.world.areEntitiesLoaded(ChunkPos.asLong(chunkX, chunkZ))) return null
|
||||
if (!world.areEntitiesLoaded(ChunkPos.asLong(centerChunkX, centerChunkZ))) return null
|
||||
|
||||
val chunk = area.world.getChunk(chunkX, chunkZ, ChunkStatus.FULL) ?: return null
|
||||
val chunk = world.getChunk(centerChunkX, centerChunkZ, ChunkStatus.FULL) ?: return null
|
||||
|
||||
var valid = isValidStartPoint(area.world, chunk, basePos)
|
||||
val probePos = centerPos.mutable()
|
||||
var validY = if (isValidStartPoint(world, chunk, probePos)) centerPos.y else null
|
||||
|
||||
if (!valid) {
|
||||
var offset = 1
|
||||
do {
|
||||
if (isValidStartPoint(area.world, chunk, basePos.setY(originalY + offset))) {
|
||||
valid = true
|
||||
basePos.y = originalY + offset
|
||||
if (validY == null) {
|
||||
for (offset in 1..Cobblemon.config.maxVerticalCorrectionBlocks) {
|
||||
if (isValidStartPoint(world, chunk, probePos.set(centerPos.x, centerPos.y + offset, centerPos.z))) {
|
||||
validY = centerPos.y + offset
|
||||
break
|
||||
} else if (isValidStartPoint(area.world, chunk, basePos.setY(originalY - offset))) {
|
||||
valid = true
|
||||
basePos.y = originalY - offset
|
||||
} else if (isValidStartPoint(world, chunk, probePos.set(centerPos.x, centerPos.y - offset, centerPos.z))) {
|
||||
validY = centerPos.y - offset
|
||||
break
|
||||
}
|
||||
offset++
|
||||
} while (offset <= Cobblemon.config.maxVerticalCorrectionBlocks)
|
||||
}
|
||||
|
||||
if (valid) {
|
||||
val min = area.world.squeezeWithinBounds(basePos)
|
||||
val max = area.world.squeezeWithinBounds(basePos.move(area.length, area.height, area.width))
|
||||
if (area.world.isLoaded(min) && area.world.isLoaded(max) &&
|
||||
min.x < max.x && min.y < max.y && min.z < max.z
|
||||
) {
|
||||
return SpawningZoneInput(
|
||||
cause = area.cause,
|
||||
world = area.world,
|
||||
baseX = min.x,
|
||||
baseY = min.y,
|
||||
baseZ = min.z,
|
||||
length = max.x - min.x,
|
||||
height = max.y - min.y,
|
||||
width = max.z - min.z
|
||||
)
|
||||
}
|
||||
}
|
||||
val targetY = validY ?: return null
|
||||
val newBaseY = (targetY - (area.height / 2)).coerceIn(world.minBuildHeight, world.maxBuildHeight)
|
||||
val minPos = world.squeezeWithinBounds(BlockPos(area.baseX, newBaseY, area.baseZ))
|
||||
val maxPos = world.squeezeWithinBounds(BlockPos(area.baseX + area.length, newBaseY + area.height, area.baseZ + area.width))
|
||||
|
||||
val finalBox = AABB(
|
||||
minPos.x.toDouble(), minPos.y.toDouble(), minPos.z.toDouble(),
|
||||
maxPos.x.toDouble(), maxPos.y.toDouble(), maxPos.z.toDouble()
|
||||
)
|
||||
if (minPos.x < maxPos.x && minPos.y < maxPos.y && minPos.z < maxPos.z && world.isBoxLoaded(finalBox)) {
|
||||
return SpawningZoneInput(
|
||||
cause = area.cause,
|
||||
world = world,
|
||||
baseX = minPos.x,
|
||||
baseY = minPos.y,
|
||||
baseZ = minPos.z,
|
||||
length = maxPos.x - minPos.x,
|
||||
height = maxPos.y - minPos.y,
|
||||
width = maxPos.z - minPos.z
|
||||
)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@ object CobblemonBlockTags {
|
||||
@JvmField val SEES_SKY = createTag("sees_sky")
|
||||
@JvmField val SHINY_STONE_ORES = createTag("shiny_stone_ores")
|
||||
@JvmField val SIGNS = createTag("signs")
|
||||
@JvmField val SCAREKROWS = createTag("scarekrows")
|
||||
@JvmField val SKY_TUMBLESTONE_BRICKS = createTag("sky_tumblestone_bricks")
|
||||
@JvmField val SKY_TUMBLESTONES = createTag("sky_tumblestones")
|
||||
@JvmField val SMALL_FLOWERS = createTag("small_flowers")
|
||||
|
||||
@@ -121,7 +121,7 @@ object CobblemonItemTags {
|
||||
@JvmField val DESTINY_KNOT = create("held/destiny_knot")
|
||||
@JvmField val EVERSTONE = create("held/everstone")
|
||||
@JvmField val EXPERIENCE_SHARE = create("held/experience_share")
|
||||
@JvmField val IS_FRIENDSHIP_BOOSTER = create("is_friendship_booster")
|
||||
@JvmField val IS_FRIENDSHIP_BOOSTER = create("held/is_friendship_booster")
|
||||
@JvmField val ANY_HELD_ITEM = create("held/is_held_item")
|
||||
@JvmField val BLACKLISTED_ITEMS_TO_HOLD = create("held/blacklisted_items_to_hold")
|
||||
@JvmField val WHITELISTED_ITEMS_TO_HOLD = create("held/whitelisted_items_to_hold")
|
||||
|
||||
@@ -34,6 +34,7 @@ class ElementalType(
|
||||
val resourceLocation: ResourceLocation = ResourceLocation.fromNamespaceAndPath(Cobblemon.MODID, "ui/types.png"),
|
||||
val showdownId: String = ShowdownIdentifiable.REGEX.replace(name.lowercase(), ""),
|
||||
val typeGem: ResourceLocation = ResourceLocation.fromNamespaceAndPath(Cobblemon.MODID, showdownId + "_gem"),
|
||||
val order: Int = 1000
|
||||
) : ShowdownIdentifiable {
|
||||
|
||||
override fun showdownId(): String {
|
||||
|
||||
@@ -25,7 +25,8 @@ object ElementalTypes {
|
||||
hue = 0xE8E8DA,
|
||||
textureXMultiplier = 0,
|
||||
primaryColor = 0x8FA689,
|
||||
secondaryColor = 0xFFFBE2
|
||||
secondaryColor = 0xFFFBE2,
|
||||
order = 0
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -35,7 +36,8 @@ object ElementalTypes {
|
||||
hue = 0xFF6E21,
|
||||
textureXMultiplier = 1,
|
||||
primaryColor = 0xF92D2D,
|
||||
secondaryColor = 0xF99B1D
|
||||
secondaryColor = 0xF99B1D,
|
||||
order = 1
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -45,7 +47,8 @@ object ElementalTypes {
|
||||
hue = 0x3FA5FF,
|
||||
textureXMultiplier = 2,
|
||||
primaryColor = 0x377AF6,
|
||||
secondaryColor = 0x50DDF9
|
||||
secondaryColor = 0x50DDF9,
|
||||
order = 2
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -55,7 +58,8 @@ object ElementalTypes {
|
||||
hue = 0x62D14F,
|
||||
textureXMultiplier = 3,
|
||||
primaryColor = 0x0EAE95,
|
||||
secondaryColor = 0xC6F554
|
||||
secondaryColor = 0xC6F554,
|
||||
order = 3
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -65,7 +69,8 @@ object ElementalTypes {
|
||||
hue = 0xFFD314,
|
||||
textureXMultiplier = 4,
|
||||
primaryColor = 0xF7AB19,
|
||||
secondaryColor = 0xFFF257
|
||||
secondaryColor = 0xFFF257,
|
||||
order = 4
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -75,7 +80,8 @@ object ElementalTypes {
|
||||
hue = 0x54F2F2,
|
||||
textureXMultiplier = 5,
|
||||
primaryColor = 0x41BAED,
|
||||
secondaryColor = 0x91F4F9
|
||||
secondaryColor = 0x91F4F9,
|
||||
order = 5
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -85,7 +91,8 @@ object ElementalTypes {
|
||||
hue = 0xEF565D,
|
||||
textureXMultiplier = 6,
|
||||
primaryColor = 0xC8356B,
|
||||
secondaryColor = 0xF36A3F
|
||||
secondaryColor = 0xF36A3F,
|
||||
order = 6
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -95,7 +102,8 @@ object ElementalTypes {
|
||||
hue = 0xD651FF,
|
||||
textureXMultiplier = 7,
|
||||
primaryColor = 0x7B41DD,
|
||||
secondaryColor = 0xE568F4
|
||||
secondaryColor = 0xE568F4,
|
||||
order = 7
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -105,7 +113,8 @@ object ElementalTypes {
|
||||
hue = 0xF4A453,
|
||||
textureXMultiplier = 8,
|
||||
primaryColor = 0xE08835,
|
||||
secondaryColor = 0xFFD057
|
||||
secondaryColor = 0xFFD057,
|
||||
order = 8
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -115,7 +124,8 @@ object ElementalTypes {
|
||||
hue = 0xB8B2FF,
|
||||
textureXMultiplier = 9,
|
||||
primaryColor = 0x6083F6,
|
||||
secondaryColor = 0xD5CCFA
|
||||
secondaryColor = 0xD5CCFA,
|
||||
order = 9
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -125,7 +135,8 @@ object ElementalTypes {
|
||||
hue = 0xFF5E9E,
|
||||
textureXMultiplier = 10,
|
||||
primaryColor = 0xE553CE,
|
||||
secondaryColor = 0xF69DD5
|
||||
secondaryColor = 0xF69DD5,
|
||||
order = 10
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -135,7 +146,8 @@ object ElementalTypes {
|
||||
hue = 0xD3D319,
|
||||
textureXMultiplier = 11,
|
||||
primaryColor = 0x9FBE1B,
|
||||
secondaryColor = 0xE9FB5B
|
||||
secondaryColor = 0xE9FB5B,
|
||||
order = 11
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -145,7 +157,8 @@ object ElementalTypes {
|
||||
hue = 0xB7A16E,
|
||||
textureXMultiplier = 12,
|
||||
primaryColor = 0x9F814A,
|
||||
secondaryColor = 0xEECB7A
|
||||
secondaryColor = 0xEECB7A,
|
||||
order = 12
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -155,7 +168,8 @@ object ElementalTypes {
|
||||
hue = 0x9C80F7,
|
||||
textureXMultiplier = 13,
|
||||
primaryColor = 0x4F57DD,
|
||||
secondaryColor = 0xC182F1
|
||||
secondaryColor = 0xC182F1,
|
||||
order = 13
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -165,7 +179,8 @@ object ElementalTypes {
|
||||
hue = 0x7580FF,
|
||||
textureXMultiplier = 14,
|
||||
primaryColor = 0x4E68E2,
|
||||
secondaryColor = 0x47C7F7
|
||||
secondaryColor = 0x47C7F7,
|
||||
order = 14
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -175,7 +190,8 @@ object ElementalTypes {
|
||||
hue = 0x587DA0,
|
||||
textureXMultiplier = 15,
|
||||
primaryColor = 0x465B99,
|
||||
secondaryColor = 0x689EBF
|
||||
secondaryColor = 0x689EBF,
|
||||
order = 15
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -185,7 +201,8 @@ object ElementalTypes {
|
||||
hue = 0xABD1F4,
|
||||
textureXMultiplier = 16,
|
||||
primaryColor = 0x628CB9,
|
||||
secondaryColor = 0xD6F7F3
|
||||
secondaryColor = 0xD6F7F3,
|
||||
order = 16
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -195,18 +212,21 @@ object ElementalTypes {
|
||||
hue = 0xFF7FE5,
|
||||
textureXMultiplier = 17,
|
||||
primaryColor = 0xE2678C,
|
||||
secondaryColor = 0xF5A7B7
|
||||
secondaryColor = 0xF5A7B7,
|
||||
order = 17
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
fun register(name: String, displayName: MutableComponent, hue: Int, textureXMultiplier: Int, primaryColor: Int, secondaryColor: Int): ElementalType {
|
||||
@JvmOverloads
|
||||
fun register(name: String, displayName: MutableComponent, hue: Int, textureXMultiplier: Int, primaryColor: Int, secondaryColor: Int, order: Int = 1000): ElementalType {
|
||||
return ElementalType(
|
||||
name = name,
|
||||
displayName = displayName,
|
||||
hue = hue,
|
||||
textureXMultiplier = textureXMultiplier,
|
||||
primaryColor = primaryColor,
|
||||
secondaryColor = secondaryColor
|
||||
secondaryColor = secondaryColor,
|
||||
order = order
|
||||
).also {
|
||||
allTypes.add(it)
|
||||
}
|
||||
|
||||
@@ -117,6 +117,9 @@ abstract class ShowdownActionResponse(val type: ShowdownActionResponseType) {
|
||||
|
||||
data class MoveActionResponse(var moveName: String, var targetPnx: String? = null, var gimmickID: String? = null): ShowdownActionResponse(ShowdownActionResponseType.MOVE) {
|
||||
override fun isValid(activeBattlePokemon: ActiveBattlePokemon, showdownMoveSet: ShowdownMoveset?, forceSwitch: Boolean): Boolean {
|
||||
// Ensure that the gimmick ID the player is sending is valid
|
||||
gimmickID?.let { if (it !in VALID_GIMMICK_IDS) return false }
|
||||
|
||||
if (forceSwitch || showdownMoveSet == null) {
|
||||
return false
|
||||
}
|
||||
@@ -168,6 +171,10 @@ data class MoveActionResponse(var moveName: String, var targetPnx: String? = nul
|
||||
gimmickID = buffer.readNullable { buffer.readString() }
|
||||
return this
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val VALID_GIMMICK_IDS = ShowdownMoveset.Gimmick.entries.map { it.id }.toSet()
|
||||
}
|
||||
}
|
||||
|
||||
data class HealItemActionResponse(var item: String) : ShowdownActionResponse(ShowdownActionResponseType.FORCE_PASS) {
|
||||
@@ -183,7 +190,8 @@ data class HealItemActionResponse(var item: String) : ShowdownActionResponse(Sho
|
||||
}
|
||||
|
||||
override fun isValid(activeBattlePokemon: ActiveBattlePokemon, showdownMoveSet: ShowdownMoveset?, forceSwitch: Boolean): Boolean {
|
||||
return !forceSwitch
|
||||
// Previously checked for !forceSwitch, excepts in the case of a forceSwitch, this couldn't legally be sent anyway.
|
||||
return false
|
||||
}
|
||||
|
||||
override fun toShowdownString(activeBattlePokemon: ActiveBattlePokemon, showdownMoveSet: ShowdownMoveset?): String {
|
||||
|
||||
Loaded 100 of 2750 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user