9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-22 16:49:14 +00:00

Compare commits

...

194 Commits

Author SHA1 Message Date
Brian Fopiano
065b748036 Merge pull request #938 from VolmitSoftware/Development
Development
2022-12-09 18:09:21 -08:00
Brian Neumann-Fopiano
76891d246f HUGE changes 2022-12-09 18:05:47 -08:00
Brian Neumann-Fopiano
0832007991 it compiles, not working 2022-12-08 19:40:13 -08:00
Brian Fopiano
87302a046c Merge pull request #933 from VolmitSoftware/Development
Development
2022-11-30 10:07:07 -08:00
Brian Neumann-Fopiano
f0f7453b32 V+ 2022-11-30 10:05:34 -08:00
Brian Neumann-Fopiano
2991bea248 updated pack 2022-11-30 10:04:25 -08:00
Brian Neumann-Fopiano
673b42c2f5 Papi and Biome location better 2022-11-30 08:55:27 -08:00
Brian Neumann-Fopiano
7d994e27e3 "A Biome" changed to be more desctiptive 2022-11-30 08:55:05 -08:00
Brian Fopiano
5f2b82aac7 Merge pull request #926 from VolmitSoftware/Development
Development
2022-11-12 13:34:06 -08:00
Brian Neumann-Fopiano
af1a03cb67 Optimization Overhaul 2022-11-12 13:31:39 -08:00
Vatuu
85fbbeca9d Preparing the POI System. 2022-11-05 15:12:17 +01:00
Brian Fopiano
a64272620f Merge pull request #920 from VolmitSoftware/Development
Development
2022-10-28 13:14:47 -07:00
Brian Neumann-Fopiano
ef9966d02b V+ 2022-10-28 13:07:11 -07:00
Vatuu
a28e5bb38a Updated overworld version. 2022-10-28 22:03:23 +02:00
Vatuu
34670759e9 Fixed eyes of enders not properly targeting strongholds. 2022-10-28 22:02:05 +02:00
Vatuu
7dd1d3881a Fixed strongholds not generating properly. 2022-10-28 22:01:23 +02:00
Brian Fopiano
7b93542014 Merge pull request #916 from VolmitSoftware/Development
Grad
2022-10-21 02:01:15 -07:00
Vatuu
ea1ac0a154 V+ 2022-10-21 08:38:56 +02:00
Vatuu
35c7068fa6 Merge remote-tracking branch 'origin/master' 2022-10-21 08:36:36 +02:00
Vatuu
db4cbb2ea6 Updated overworld tag. 2022-10-21 08:36:11 +02:00
Brian Neumann-Fopiano
fa7c073999 Grad 2022-10-12 03:13:25 -07:00
Brian Fopiano
72a077662d Merge pull request #915 from VolmitSoftware/Development
V+
2022-10-12 02:54:10 -07:00
Brian Neumann-Fopiano
137abb04b2 V+ 2022-10-12 02:52:49 -07:00
Vatuu
211b15332d Code Cleanup, the second. 2022-10-12 07:13:03 +02:00
Brian Fopiano
f6fbcade17 Merge pull request #913 from VolmitSoftware/Development
Development
2022-10-07 18:58:13 -07:00
Brian Fopiano
1ef115fee8 V+ 2022-10-07 18:51:45 -07:00
Vatuu
7973444fc5 Code Cleanup. 2022-10-07 23:58:21 +02:00
Vatuu
2bdb0bfa69 Fixed #901: Longs are now properly parsed by decree. 2022-10-05 04:20:08 +02:00
Vatuu
bfb6f82ea3 Fixed /iris create not installing datapacks. 2022-10-05 04:16:50 +02:00
Brian Fopiano
7729ce3753 Merge pull request #911 from VolmitSoftware/Development
Development
2022-09-30 21:19:06 -07:00
Brian Fopiano
f6ea171669 V+ 2022-09-30 21:18:58 -07:00
tanticle
ff081ebc11 Merge remote-tracking branch 'origin/Development' into Development 2022-09-28 02:41:14 +02:00
tanticle
0818f971fe Added #816: Whitelist and blacklist for decorators. 2022-09-28 02:40:52 +02:00
tanticle
27070f44c7 Fixed block drops. 2022-09-28 02:00:34 +02:00
Brian Fopiano
8331cbe375 Merge pull request #910 from VolmitSoftware/Development
Hotfix
2022-09-25 16:43:11 -07:00
Vatuu
f533ec34b0 Hotfix 2022-09-25 16:42:36 -07:00
Vatuu
23d4fcb827 Hotfix because Brian did a bad 2022-09-26 01:09:08 +02:00
Brian Fopiano
a248962f1b Merge pull request #909 from VolmitSoftware/Development
Development
2022-09-23 20:03:37 -07:00
Vatuu
afa8fad8e9 V+ 2022-09-24 04:54:32 +02:00
Vatuu
4c423bb493 Resolved #878: Certain values in settings are no longer ignored. 2022-09-24 04:52:42 +02:00
Vatuu
e660fe9e1e Resolved #892: Snow no longer replaces objects. 2022-09-24 04:43:47 +02:00
Vatuu
23c1d12e73 Removed deprecated repository. 2022-09-23 14:58:39 +02:00
Brian Fopiano
9cf2785626 Merge pull request #908 from VolmitSoftware/iris-go-fast-but-not-stable
Pregen improvements
2022-09-21 07:27:20 -07:00
Brian Fopiano
b8b65c7e3e Merge pull request #907 from VolmitSoftware/Development
Development
2022-09-21 07:13:01 -07:00
Vatuu
dcb467280a V+ 2022-09-21 01:52:20 +02:00
Vatuu
6aa802b42d Merge remote-tracking branch 'origin/Development' into Development 2022-09-21 01:49:58 +02:00
Vatuu
d78f6ca589 Resolved #900: Remaining time in days corrected. 2022-09-21 01:48:53 +02:00
Vatuu
493f8e0cc0 Resolved #897: Adjusted Y-Offset 2022-09-21 01:12:35 +02:00
Vatuu
119563c553 Resolved #871: Removed /iris std clean 2022-09-20 23:55:18 +02:00
cyberpwn
2d61e6af66 Pregen improvements 2022-09-16 09:09:23 -04:00
Brian Fopiano
aa1be934a9 Merge pull request #899 from VolmitSoftware/iris-go-fast-but-not-stable
Jesus Fucking Christ
2022-09-16 02:05:01 -07:00
Brian Fopiano
f9c98b0a60 Needs to be Sync now 2022-09-16 01:52:17 -07:00
Brian Fopiano
bd66fa3bf5 Tag Bump 2022-09-16 00:50:38 -07:00
Brian Fopiano
380f191f6a V+ 2022-09-16 00:48:27 -07:00
cyberpwn
7e217b5fba More permits 2022-09-16 03:40:31 -04:00
cyberpwn
c4a516a858 f 2022-09-16 03:37:36 -04:00
cyberpwn
bdf181e348 ff 2022-09-16 03:28:47 -04:00
cyberpwn
f4ea1343b4 m 2022-09-16 03:27:32 -04:00
cyberpwn
a37ccddd38 f 2022-09-16 03:26:23 -04:00
cyberpwn
243ef8c0be f 2022-09-16 03:24:56 -04:00
cyberpwn
00d099383b Fix 2022-09-16 03:22:56 -04:00
cyberpwn
dda3f0b8e9 Mhmmmmm 2022-09-16 03:16:57 -04:00
cyberpwn
00f4d8b1ee Hmm? 2022-09-16 03:16:04 -04:00
cyberpwn
2f5198d533 Safe 2022-09-15 02:35:34 -04:00
cyberpwn
148261f876 Dirrrrrrrrrrrrty 2022-09-15 02:32:29 -04:00
cyberpwn
60843b3bb9 f 2022-09-14 13:30:39 -04:00
DanMB
2ad9a525bd Biome holder injection post gen 2022-09-14 03:56:06 -04:00
DanMB
78e9f21439 f 2022-09-13 23:32:11 -04:00
DanMB
a66d60eaea woah 2022-09-13 23:06:52 -04:00
DanMB
3aa3c13477 Test speed 2022-09-13 22:55:26 -04:00
cyberpwn
cc850522e6 BRRRRRRRRRRRRRRRRRRR 2022-09-13 09:29:07 -04:00
Brian Fopiano
6d28f57f88 Merge pull request #894 from VolmitSoftware/master
d
2022-09-12 16:00:36 -07:00
Brian Fopiano
563e0a7cd4 V+ 2022-09-12 16:00:14 -07:00
Brian Fopiano
2f2f857e98 Merge pull request #893 from VolmitSoftware/Development
Development
2022-09-12 15:59:20 -07:00
cyberpwn
251c52a2ee Fix cave mod engine npe 2022-09-12 17:26:14 -04:00
cyberpwn
7528bd343b 3x 2022-09-12 07:06:45 -04:00
cyberpwn
06d9f279ac f 2022-09-11 23:00:15 -04:00
cyberpwn
044403b829 Fix incorrect object positions 2022-09-11 21:31:21 -04:00
Brian Fopiano
5a24dd3b49 Revert "Revert "Eat me""
This reverts commit 3189b3c7a5.
2022-09-11 21:00:55 -04:00
Brian Fopiano
3189b3c7a5 Revert "Eat me"
This reverts commit da777da476.
2022-09-11 21:00:38 -04:00
cyberpwn
3bf1c6a282 Merge remote-tracking branch 'origin/Development' into Development 2022-09-11 20:59:04 -04:00
cyberpwn
7c7309c3ab Unload mantle when not generating 2022-09-11 20:58:58 -04:00
Brian Fopiano
da777da476 Eat me 2022-09-11 17:57:08 -07:00
cyberpwn
3d0c0a11ed Merge remote-tracking branch 'origin/Development' into Development 2022-09-10 02:04:58 -04:00
cyberpwn
e545269b93 Even less waste work & prefetch caching 2022-09-10 02:03:59 -04:00
Brian Fopiano
141ca76647 Merge pull request #890 from VolmitSoftware/Development
Development
2022-09-09 18:05:56 -07:00
Brian Fopiano
94557830f5 v+ 2022-09-09 18:02:21 -07:00
Vatuu
49acb7faba Merge remote-tracking branch 'origin/Development' into Development 2022-09-09 21:42:53 +02:00
Vatuu
1904f67662 Fixed Issue #864: Mantle not retaining object placements. 2022-09-09 19:48:23 +02:00
Vatuu
5b2bf38344 Fixed Issue #884: Cache freaking out on global override. 2022-09-09 18:10:52 +02:00
cyberpwn
494c38a153 Merge remote-tracking branch 'origin/Development' into Development 2022-09-09 01:25:16 -04:00
cyberpwn
dd4b85cbfe Fixes 2022-09-09 01:24:20 -04:00
Brian Fopiano
8f7b54a5a4 Merge pull request #889 from VolmitSoftware/Development
Development
2022-09-08 17:26:41 -07:00
Vatuu
cec502340e V+ 2022-09-09 01:15:53 +02:00
Vatuu
64e27c7fb0 Disabled blockdrops as hotfix. 2022-09-09 01:15:07 +02:00
cyberpwn
b2bbd31548 Disable multicore chunks 2022-09-07 17:07:34 -04:00
Brian Fopiano
17df92a07c Merge pull request #887 from VolmitSoftware/Development
Development
2022-09-06 20:55:18 -07:00
Brian Fopiano
2b749b5ab7 NMS update / Compile 2022-09-06 20:51:59 -07:00
cyberpwn
28e3402d88 r 2022-09-05 14:17:56 -04:00
cyberpwn
d96bb061e0 Update repo 2022-09-05 14:14:50 -04:00
Brian Fopiano
e6def804f8 Merge pull request #883 from VolmitSoftware/Development
Development
2022-09-02 17:48:22 -07:00
Vatuu
a5be48c07c V+ 2022-09-02 23:35:38 +02:00
Vatuu
fe3909f594 Fixed block drops not firing for biomes. 2022-09-02 23:32:51 +02:00
Vatuu
f37d91a530 Fixed loot table object override not working. 2022-09-02 23:26:47 +02:00
Vatuu
614ef78771 Fixed reliance on outdated spigot api version. 2022-09-02 20:32:17 +02:00
Brian Fopiano
fb294fc03c Merge pull request #879 from VolmitSoftware/Development
Changelog:

- Fixed Vines, Again! for Floors
- Merged stability changes
- Made the folder checking system recursive
2022-08-30 10:20:38 -07:00
Vatuu
8c7e7c3d48 Merge remote-tracking branch 'origin/Development' into Development 2022-08-30 19:15:16 +02:00
Vatuu
98b6280652 V+ 2022-08-30 19:15:05 +02:00
Vatuu
7c4c2d6382 Fixed autocomplete only going two dirs deep. 2022-08-30 19:14:28 +02:00
Vatuu
1a29ea302e Fixed vines not properly generating using decorators. 2022-08-30 18:06:17 +02:00
Brian Fopiano
be39fce741 Merge pull request #876 from VolmitSoftware/Development
Changelog:

Fixed Versioning compilation issues
Forceblock nolonger Crashes
Forceblock Works now (as intended, as far as we can tell)
2022-08-26 16:10:38 -07:00
Brian Fopiano
4fed2e6e5f Merge branch 'master' into Development 2022-08-26 16:10:26 -07:00
Vatuu
14ae5809b0 Forceblock now properly works. 2022-08-26 19:05:33 +02:00
Vatuu
0f66aa47c9 Reverted generator change 2022-08-26 18:36:09 +02:00
Vatuu
cf85d300f4 Solving seed collisions on generators? 2022-08-26 17:54:56 +02:00
Vatuu
91d60e56df Fixed jar using the wrong version. 2022-08-26 17:27:49 +02:00
Brian Fopiano
1d3681beb4 Merge pull request #872 from VolmitSoftware/Development
Development
2022-08-23 18:51:22 -04:00
Vatuu
0b403cf329 Merge remote-tracking branch 'origin/Development' into Development 2022-08-23 17:22:17 +02:00
Vatuu
8ba75899e3 Fixed block drops. 2022-08-23 17:21:54 +02:00
Vatuu
4d4ed72159 _Maybe_ fixed mantle not retaining after restart? 2022-08-23 17:19:16 +02:00
Vatuu
b72bf072b3 _Maybe_ fixed mantle not retaining after restart? 2022-08-23 17:11:28 +02:00
Vatuu
4edcb54b31 Fixed /iris what biome not working. 2022-08-23 15:51:04 +02:00
Brian Fopiano
eae7fc0e53 V+ 2022-08-18 19:00:47 -07:00
Brian Fopiano
fddacd4410 Merge pull request #863 from VolmitSoftware/Development
Development Update
2022-08-18 19:00:04 -07:00
Brian Fopiano
de6c4b9a30 Merge remote-tracking branch 'origin/Development' into Development 2022-08-17 20:22:04 -07:00
Brian Fopiano
6990e34138 Removed SoftDepends, Fixed Auth 2022-08-17 20:21:59 -07:00
DanMB
d9883697ef Change dep to match nms version var 2022-08-16 19:14:35 -07:00
Brian Fopiano
05a26ff8b2 Revert "helping with version Nomners"
This reverts commit 0765c21cef.
2022-08-16 16:01:36 -07:00
Brian Fopiano
84bb082d44 Merge pull request #856 from VolmitSoftware/Development
Development
2022-08-16 13:06:00 -07:00
Brian Fopiano
a0db94d84f Merge branch 'master' into Development 2022-08-16 13:05:54 -07:00
Brian Fopiano
0367b4ecd7 v+ 2022-08-16 13:04:27 -07:00
Vatuu
dbc425dce6 Added autocomplete for enchantment types. 2022-08-16 16:08:25 +02:00
Vatuu
116c017c6d Fixed enchantments not applying to loot. 2022-08-16 15:45:48 +02:00
Vatuu
9c387475f0 Cleaned up IrisLoot. 2022-08-16 15:21:18 +02:00
Brian Fopiano
0765c21cef helping with version Nomners 2022-08-13 03:20:42 -07:00
Brian Fopiano
2871038584 v+ 2022-08-12 15:43:39 -07:00
Brian Fopiano
340885f939 Merge pull request #849 from VolmitSoftware/Development
Development
2022-08-12 15:43:09 -07:00
Vatuu
1e32e47f54 Merge remote-tracking branch 'origin/Development' into Development 2022-08-13 00:37:59 +02:00
Vatuu
3c759f3b01 Kinda fixed vine issues with PAINT. 2022-08-13 00:37:42 +02:00
DanMB
6615f34d20 Merge remote-tracking branch 'origin/Development' into Development 2022-08-12 08:05:53 -07:00
DanMB
3a4aac1ee4 Get all 2022-08-12 08:05:48 -07:00
Brian Fopiano
4d6c092615 Performance... 2022-08-11 18:34:38 -07:00
DanMB
93421a1dc9 An attempt 2022-08-11 18:18:00 -07:00
Brian Fopiano
209458a856 Merge pull request #847 from VolmitSoftware/Development
Development update
2022-08-09 13:50:26 -07:00
DanMB
82bd94620e Lock biomes first before generating to help cache 2022-08-07 16:10:49 -07:00
DanMB
af9f017871 Hold your horses pregenerator 2022-08-07 16:09:36 -07:00
Brian Fopiano
2f8922ea87 Updating Version and NMS 2022-08-07 14:14:39 -07:00
Brian Fopiano
0ea936f3fe Merge pull request #845 from VolmitSoftware/Development
Development
2022-08-04 08:50:17 -07:00
Brian Fopiano
d1870ee0a8 V+ 2022-08-04 08:43:03 -07:00
Vatuu
d2151690ad Fixed pregen memory leak. 2022-08-04 00:27:33 +02:00
Brian Fopiano
dff373e7d5 Merge pull request #843 from CocoTheOwner/sortedNoise
sort noise
2022-07-30 16:23:45 -07:00
CocoTheOwner
0aec2a664f sort noise 2022-07-30 22:19:02 +01:00
Brian Fopiano
723b696393 Merge pull request #838 from VolmitSoftware/Development
Development
2022-07-29 10:04:58 -07:00
Brian Fopiano
f5f89eb4e4 Merge branch 'master' into Development 2022-07-29 10:04:53 -07:00
Brian Fopiano
df15332c7f Merge pull request #832 from CocoTheOwner/noWarn
Remove warning on create
2022-07-29 10:04:22 -07:00
Vatuu
61d9e5a869 V+ 2022-07-29 19:03:18 +02:00
Brian Fopiano
9628b66a97 Merge pull request #837 from VolmitSoftware/Development
Development Update
2022-07-29 10:02:04 -07:00
Vatuu
5e041366d4 Update to 1.19.1 2022-07-28 18:29:01 +02:00
Vatuu
3ecae8d72c Removed debug printout. 2022-07-28 17:45:51 +02:00
Vatuu
5709ce9d82 Fixed the QOL command being a bitch. 2022-07-28 15:54:31 +02:00
Vatuu
ce3c334ac5 Fixed vines and derivatives not placing properly in objects. 2022-07-27 19:35:18 +02:00
Vatuu
2ed5aa8730 Removed leftover debug message. 2022-07-26 21:41:06 +02:00
Vatuu
8480a63dda Fixed sculk veins not being recognized as vines. 2022-07-26 21:40:28 +02:00
CocoTheOwner
132a1695f3 Bey 2022-07-24 14:20:12 +01:00
Brian Fopiano
21775630c3 Merge pull request #830 from VolmitSoftware/Development
Development
2022-07-21 19:38:44 -07:00
Brian Fopiano
eac2ef7c6d V+ 2022-07-21 19:38:14 -07:00
Vatuu
386997f646 Added forceBlock field for surface decorator. 2022-07-22 02:18:37 +02:00
Vatuu
637b90ad62 Fixed stilted facing blocks not rotating. 2022-07-22 02:06:44 +02:00
Vatuu
95d755c2ec Fixed underwater structures not being waterlogged. 2022-07-22 02:06:00 +02:00
Brian Fopiano
781aeebef6 Merge pull request #826 from CDFN/patch-1
Update bug template for 1.19
2022-07-17 13:17:56 -07:00
Brian Fopiano
5e133fd51a Merge pull request #827 from CocoTheOwner/commands
Add /iris remove command
2022-07-17 13:03:58 -07:00
Brian Fopiano
85f62a3b9d we really cant do this override 2022-07-17 11:08:02 -07:00
DanMB
a32de58c8b Lazy pregen 2022-07-17 08:52:56 -07:00
Brian Fopiano
1cb2ea6c17 Merge pull request #829 from VolmitSoftware/Development
Development
2022-07-16 15:46:30 -07:00
CocoTheOwner
6a37ab7af2 sync world unload 2022-07-16 12:39:42 +02:00
CocoTheOwner
e0f0aaf767 Add remove command 2022-07-16 12:36:28 +02:00
Vatuu
3d7c5b050a Revert "Revert "Added convenience command.""
This reverts commit 6bc57c255f.
2022-07-16 12:33:39 +02:00
Vatuu
6bc57c255f Revert "Added convenience command."
This reverts commit 6b32eb3441.
2022-07-16 11:53:40 +02:00
Vatuu
b82edfe688 V+ 2022-07-16 02:55:59 +02:00
Vatuu
6b32eb3441 Added convenience command. 2022-07-16 02:52:06 +02:00
Vatuu
23a07fa8a5 Fixed vines and glow lichen not generating properly. 2022-07-16 02:41:03 +02:00
Vatuu
b019faedd2 Made the creator not error without a sender. 2022-07-15 20:02:26 +02:00
Bartosz Stefańczyk
4430433a10 Update bug template for 1.19 2022-07-15 16:05:15 +02:00
Brian Fopiano
f52cd29e7b Merge pull request #821 from VolmitSoftware/Development
Development
2022-07-07 14:23:57 -07:00
Vatuu
6a44e593a6 V+ 2022-07-07 23:04:32 +02:00
Vatuu
f7065fe034 Datenpackete werden nun in allen registrierten Welten generiert. 2022-07-07 22:54:54 +02:00
Vatuu
0a247956f7 Fixed colour and printout. 2022-07-07 22:28:59 +02:00
DanMB
03836acded ffff 2022-07-07 13:12:59 -07:00
Brian Fopiano
b5fb277982 Merge pull request #819 from VolmitSoftware/Development
Development update 2.2.2
2022-07-01 16:11:20 -07:00
Vatuu
e523d3c166 V+ 2022-07-02 01:04:39 +02:00
Vatuu
41477e4aa6 Made the overworld use releases instead. (Hack) 2022-07-02 01:03:18 +02:00
Vatuu
fbaf42a8c4 Merge remote-tracking branch 'origin/Development' into Development 2022-07-01 21:00:17 +02:00
Vatuu
1c3668047b Fixed PlaceholderAPI issues. 2022-07-01 20:59:54 +02:00
Vatuu
7d78c69b6e /iris create now registers to bukkit.yml 2022-07-01 18:40:13 +02:00
556 changed files with 23143 additions and 14364 deletions

View File

@@ -39,6 +39,7 @@ body:
- 1.17 - 1.17
- 1.17.1 - 1.17.1
- 1.18 - 1.18
- 1.19
validations: validations:
required: true required: true
- type: input - type: input

View File

@@ -24,21 +24,22 @@ plugins {
id "de.undercouch.download" version "5.0.1" id "de.undercouch.download" version "5.0.1"
} }
version '2.2.1-1.19' // Needs to be version specific version '2.3.10-1.19.3' // Needs to be version specific
def nmsVersion = "1.19" def nmsVersion = "1.19.3" //[NMS]
def apiVersion = '1.19' def apiVersion = '1.19'
def spigotJarVersion = '1.19-R0.1-SNAPSHOT' def specialSourceVersion = '1.11.0' //[NMS]
def spigotJarVersion = '1.19.3-R0.1-SNAPSHOT' //[NMS]
def name = getRootProject().getName() // Defined in settings.gradle def name = getRootProject().getName() // Defined in settings.gradle
def main = 'com.volmit.iris.Iris' def main = 'com.volmit.iris.Iris'
// ADD YOURSELF AS A NEW LINE IF YOU WANT YOUR OWN BUILD TASK GENERATED // ADD YOURSELF AS A NEW LINE IF YOU WANT YOUR OWN BUILD TASK GENERATED
// ======================== WINDOWS ============================= // ======================== WINDOWS =============================
registerCustomOutputTask('Cyberpwn', 'C://Users/cyberpwn/Documents/development/server/plugins') registerCustomOutputTask('Cyberpwn', 'C://Users/cyberpwn/Documents/development/server/plugins')
registerCustomOutputTask('Psycho', 'D://Dan/MinecraftDevelopment/server/plugins') registerCustomOutputTask('Psycho', 'C://Dan/MinecraftDevelopment/Server/plugins')
registerCustomOutputTask('ArcaneArts', 'C://Users/arcane/Documents/development/server/plugins') registerCustomOutputTask('ArcaneArts', 'C://Users/arcane/Documents/development/server/plugins')
registerCustomOutputTask('Coco', 'D://Documents/MC/plugins') registerCustomOutputTask('Coco', 'D://Documents/MC/plugins')
registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins') registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins')
registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.19/plugins') registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.19.3/plugins')
// ========================== UNIX ============================== // ========================== UNIX ==============================
registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/development/server/plugins') registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/development/server/plugins')
registerCustomOutputTaskUnix('PsychoLT', '/Users/brianfopiano/Desktop/REMOTES/RemoteMinecraft/plugins') registerCustomOutputTaskUnix('PsychoLT', '/Users/brianfopiano/Desktop/REMOTES/RemoteMinecraft/plugins')
@@ -73,11 +74,8 @@ repositories {
includeGroup("org.spigotmc") includeGroup("org.spigotmc")
} }
} }
maven { url "https://dl.cloudsmith.io/public/arcane/archive/maven/" } maven { url "https://arcanearts.jfrog.io/artifactory/archives" }
maven { url "https://maven.enginehub.org/repo/" }
mavenCentral()
mavenLocal()
maven { url "https://jitpack.io"}
} }
/** /**
@@ -124,10 +122,10 @@ dependencies {
// Provided or Classpath // Provided or Classpath
compileOnly 'org.projectlombok:lombok:1.18.24' compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24' annotationProcessor 'org.projectlombok:lombok:1.18.24'
implementation 'org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT' implementation 'org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT'
implementation 'me.clip:placeholderapi:2.11.1' implementation 'me.clip:placeholderapi:2.11.1'
implementation 'io.th0rgal:oraxen:1.94.0' implementation 'io.th0rgal:oraxen:1.94.0'
implementation 'org.bukkit:craftbukkit:1.19-R0.1-SNAPSHOT:remapped-mojang' implementation 'org.bukkit:craftbukkit:1.19.3-R0.1-SNAPSHOT:remapped-mojang' //[NMS]
implementation 'com.github.LoneDev6:api-itemsadder:3.1.0b' implementation 'com.github.LoneDev6:api-itemsadder:3.1.0b'
// Shaded // Shaded
@@ -194,7 +192,7 @@ task downloadBuildtools(type: Download) {
task downloadSpecialSource(type: Download) { task downloadSpecialSource(type: Download) {
group "remapping" group "remapping"
src 'https://repo.maven.apache.org/maven2/net/md-5/SpecialSource/1.10.0/SpecialSource-1.10.0-shaded.jar' src 'https://repo.maven.apache.org/maven2/net/md-5/SpecialSource/' + specialSourceVersion + '/SpecialSource-'+specialSourceVersion+'-shaded.jar'
dest specialSourceJar dest specialSourceJar
onlyIf { onlyIf {
!specialSourceJar.exists() !specialSourceJar.exists()

View File

@@ -20,7 +20,6 @@ pluginManagement {
mavenLocal() mavenLocal()
mavenCentral() mavenCentral()
gradlePluginPortal() gradlePluginPortal()
maven { url "https://dl.cloudsmith.io/public/arcane/archive/maven/" }
} }
} }
rootProject.name = 'Iris' rootProject.name = 'Iris'

View File

@@ -23,9 +23,12 @@ import com.google.gson.JsonParseException;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.ServerConfigurator; import com.volmit.iris.core.ServerConfigurator;
import com.volmit.iris.core.link.*; import com.volmit.iris.core.link.IrisPapiExpansion;
import com.volmit.iris.core.link.MultiverseCoreLink;
import com.volmit.iris.core.link.MythicMobsLink;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.nms.INMS; import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.pregenerator.LazyPregenerator;
import com.volmit.iris.core.service.StudioSVC; import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.EnginePanic; import com.volmit.iris.engine.EnginePanic;
@@ -40,7 +43,10 @@ import com.volmit.iris.util.exceptions.IrisException;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.function.NastyRunnable; import com.volmit.iris.util.function.NastyRunnable;
import com.volmit.iris.util.io.*; import com.volmit.iris.util.io.FileWatcher;
import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.io.InstanceState;
import com.volmit.iris.util.io.JarScanner;
import com.volmit.iris.util.math.M; import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.parallel.MultiBurst; import com.volmit.iris.util.parallel.MultiBurst;
@@ -55,11 +61,7 @@ import com.volmit.iris.util.scheduling.ShurikenQueue;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.serializer.ComponentSerializer; import net.kyori.adventure.text.serializer.ComponentSerializer;
import org.bukkit.Bukkit; import org.bukkit.*;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@@ -81,11 +83,13 @@ import java.lang.annotation.Annotation;
import java.net.URL; import java.net.URL;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.Objects;
@SuppressWarnings("CanBeFinal") @SuppressWarnings("CanBeFinal")
public class Iris extends VolmitPlugin implements Listener { public class Iris extends VolmitPlugin implements Listener {
public static final String OVERWORLD_TAG = "2092";
private static final Queue<Runnable> syncJobs = new ShurikenQueue<>(); private static final Queue<Runnable> syncJobs = new ShurikenQueue<>();
public static Iris instance; public static Iris instance;
public static BukkitAudiences audiences; public static BukkitAudiences audiences;
public static MultiverseCoreLink linkMultiverseCore; public static MultiverseCoreLink linkMultiverseCore;
@@ -182,6 +186,7 @@ public class Iris extends VolmitPlugin implements Listener {
} }
} }
} }
public static File getCached(String name, String url) { public static File getCached(String name, String url) {
String h = IO.hash(name + "@" + url); String h = IO.hash(name + "@" + url);
File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h); File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h);
@@ -381,6 +386,44 @@ public class Iris extends VolmitPlugin implements Listener {
} }
} }
public static void dump() {
try {
File fi = Iris.instance.getDataFile("dump", "td-" + new java.sql.Date(M.ms()) + ".txt");
FileOutputStream fos = new FileOutputStream(fi);
Map<Thread, StackTraceElement[]> f = Thread.getAllStackTraces();
PrintWriter pw = new PrintWriter(fos);
for (Thread i : f.keySet()) {
pw.println("========================================");
pw.println("Thread: '" + i.getName() + "' ID: " + i.getId() + " STATUS: " + i.getState().name());
for (StackTraceElement j : f.get(i)) {
pw.println(" @ " + j.toString());
}
pw.println("========================================");
pw.println();
pw.println();
}
pw.close();
System.out.println("DUMPED! See " + fi.getAbsolutePath());
} catch (Throwable e) {
e.printStackTrace();
}
}
public static void panic() {
EnginePanic.panic();
}
public static void addPanic(String s, String v) {
EnginePanic.add(s, v);
}
private static void fixShading() {
ShadeFix.fix(ComponentSerializer.class);
}
private void enable() { private void enable() {
instance = this; instance = this;
services = new KMap<>(); services = new KMap<>();
@@ -400,6 +443,7 @@ public class Iris extends VolmitPlugin implements Listener {
J.s(() -> { J.s(() -> {
J.a(() -> PaperLib.suggestPaper(this)); J.a(() -> PaperLib.suggestPaper(this));
J.a(() -> IO.delete(getTemp())); J.a(() -> IO.delete(getTemp()));
J.a(LazyPregenerator::loadLazyGenerators, 100);
J.a(this::bstats); J.a(this::bstats);
J.ar(this::checkConfigHotload, 60); J.ar(this::checkConfigHotload, 60);
J.sr(this::tickQueue, 0); J.sr(this::tickQueue, 0);
@@ -417,8 +461,8 @@ public class Iris extends VolmitPlugin implements Listener {
FileConfiguration fc = new YamlConfiguration(); FileConfiguration fc = new YamlConfiguration();
try { try {
fc.load(new File("bukkit.yml")); fc.load(new File("bukkit.yml"));
searching: for(String i : fc.getKeys(true)) searching:
{ for (String i : fc.getKeys(true)) {
if (i.startsWith("worlds.") && i.endsWith(".generator")) { if (i.startsWith("worlds.") && i.endsWith(".generator")) {
String worldName = i.split("\\Q.\\E")[1]; String worldName = i.split("\\Q.\\E")[1];
String generator = IrisSettings.get().getGenerator().getDefaultWorldType(); String generator = IrisSettings.get().getGenerator().getDefaultWorldType();
@@ -430,10 +474,8 @@ public class Iris extends VolmitPlugin implements Listener {
continue; continue;
} }
for(World j : Bukkit.getWorlds()) for (World j : Bukkit.getWorlds()) {
{ if (j.getName().equals(worldName)) {
if(j.getName().equals(worldName))
{
continue searching; continue searching;
} }
} }
@@ -482,44 +524,10 @@ public class Iris extends VolmitPlugin implements Listener {
} }
} }
public static void dump() {
try {
File fi = Iris.instance.getDataFile("dump", "td-" + new java.sql.Date(M.ms()) + ".txt");
FileOutputStream fos = new FileOutputStream(fi);
Map<Thread, StackTraceElement[]> f = Thread.getAllStackTraces();
PrintWriter pw = new PrintWriter(fos);
for(Thread i : f.keySet()) {
pw.println("========================================");
pw.println("Thread: '" + i.getName() + "' ID: " + i.getId() + " STATUS: " + i.getState().name());
for(StackTraceElement j : f.get(i)) {
pw.println(" @ " + j.toString());
}
pw.println("========================================");
pw.println();
pw.println();
}
pw.close();
System.out.println("DUMPED! See " + fi.getAbsolutePath());
} catch(Throwable e) {
e.printStackTrace();
}
}
public void postShutdown(Runnable r) { public void postShutdown(Runnable r) {
postShutdown.add(r); postShutdown.add(r);
} }
public static void panic() {
EnginePanic.panic();
}
public static void addPanic(String s, String v) {
EnginePanic.add(s, v);
}
public void onEnable() { public void onEnable() {
enable(); enable();
super.onEnable(); super.onEnable();
@@ -536,10 +544,6 @@ public class Iris extends VolmitPlugin implements Listener {
super.onDisable(); super.onDisable();
} }
private static void fixShading() {
ShadeFix.fix(ComponentSerializer.class);
}
private void setupPapi() { private void setupPapi() {
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new IrisPapiExpansion().register(); new IrisPapiExpansion().register();
@@ -723,7 +727,8 @@ public class Iris extends VolmitPlugin implements Listener {
JsonObject json = JsonParser.parseReader(r).getAsJsonObject(); JsonObject json = JsonParser.parseReader(r).getAsJsonObject();
if (json.has("version")) if (json.has("version"))
version = json.get("version").getAsString(); version = json.get("version").getAsString();
} catch(IOException | JsonParseException ignored) { } } catch (IOException | JsonParseException ignored) {
}
Iris.info(" " + dimName + " v" + version); Iris.info(" " + dimName + " v" + version);
} }
} }

View File

@@ -50,6 +50,57 @@ public class IrisSettings {
}; };
} }
public static IrisSettings get() {
if (settings != null) {
return settings;
}
settings = new IrisSettings();
File s = Iris.instance.getDataFile("settings.json");
if (!s.exists()) {
try {
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
} catch (JSONException | IOException e) {
e.printStackTrace();
Iris.reportError(e);
}
} else {
try {
String ss = IO.readAll(s);
settings = new Gson().fromJson(ss, IrisSettings.class);
try {
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
} catch (IOException e) {
e.printStackTrace();
}
} catch (Throwable ee) {
// Iris.reportError(ee); causes a self-reference & stackoverflow
Iris.error("Configuration Error in settings.json! " + ee.getClass().getSimpleName() + ": " + ee.getMessage());
}
}
return settings;
}
public static void invalidate() {
synchronized (settings) {
settings = null;
}
}
public void forceSave() {
File s = Iris.instance.getDataFile("settings.json");
try {
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
} catch (JSONException | IOException e) {
e.printStackTrace();
Iris.reportError(e);
}
}
@Data @Data
public static class IrisSettingsAutoconfiguration { public static class IrisSettingsAutoconfiguration {
public boolean configureSpigotTimeoutTime = true; public boolean configureSpigotTimeoutTime = true;
@@ -132,55 +183,4 @@ public class IrisSettings {
public boolean disableTimeAndWeather = true; public boolean disableTimeAndWeather = true;
public boolean autoStartDefaultStudio = false; public boolean autoStartDefaultStudio = false;
} }
public static IrisSettings get() {
if(settings != null) {
return settings;
}
settings = new IrisSettings();
File s = Iris.instance.getDataFile("settings.json");
if(!s.exists()) {
try {
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
} catch(JSONException | IOException e) {
e.printStackTrace();
Iris.reportError(e);
}
} else {
try {
String ss = IO.readAll(s);
settings = new Gson().fromJson(ss, IrisSettings.class);
try {
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
} catch(IOException e) {
e.printStackTrace();
}
} catch(Throwable ee) {
// Iris.reportError(ee); causes a self-reference & stackoverflow
Iris.error("Configuration Error in settings.json! " + ee.getClass().getSimpleName() + ": " + ee.getMessage());
}
}
return settings;
}
public static void invalidate() {
synchronized(settings) {
settings = null;
}
}
public void forceSave() {
File s = Iris.instance.getDataFile("settings.json");
try {
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
} catch(JSONException | IOException e) {
e.printStackTrace();
Iris.reportError(e);
}
}
} }

View File

@@ -27,7 +27,6 @@ import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -38,6 +37,7 @@ import org.bukkit.entity.Player;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class ServerConfigurator { public class ServerConfigurator {
@@ -82,41 +82,19 @@ public class ServerConfigurator {
} }
} }
private static File getDatapacksFolder() { private static List<File> getDatapacksFolder() {
if (!IrisSettings.get().getGeneral().forceMainWorld.isEmpty()) { if (!IrisSettings.get().getGeneral().forceMainWorld.isEmpty()) {
return new File(IrisSettings.get().getGeneral().forceMainWorld + "/datapacks"); return new KList<File>().qadd(new File(IrisSettings.get().getGeneral().forceMainWorld + "/datapacks"));
}
KList<File> worlds = new KList<>();
Bukkit.getServer().getWorlds().forEach(w -> worlds.add(new File(w.getWorldFolder(), "datapacks")));
return worlds;
} }
File props = new File("server.properties");
if(props.exists()) {
try {
KList<String> m = new KList<>(IO.readAll(props).split("\\Q\n\\E"));
for(String i : m) {
if(i.trim().startsWith("level-name=")) {
return new File(i.trim().split("\\Q=\\E")[1] + "/datapacks");
}
}
} catch(IOException e) {
Iris.reportError(e);
e.printStackTrace();
}
}
return null;
}
public static void installDataPacks(boolean fullInstall) { public static void installDataPacks(boolean fullInstall) {
Iris.info("Checking Data Packs..."); Iris.info("Checking Data Packs...");
boolean reboot = false;
File packs = new File("plugins/Iris/packs"); File packs = new File("plugins/Iris/packs");
File dpacks = getDatapacksFolder();
if(dpacks == null) {
Iris.error("Cannot find the datapacks folder! Please try generating a default world first maybe? Is this a new server?");
return;
}
if (packs.exists()) { if (packs.exists()) {
for (File i : packs.listFiles()) { for (File i : packs.listFiles()) {
@@ -135,8 +113,8 @@ public class ServerConfigurator {
} }
Iris.verbose(" Checking Dimension " + dim.getLoadFile().getPath()); Iris.verbose(" Checking Dimension " + dim.getLoadFile().getPath());
if(dim.installDataPack(() -> data, dpacks)) { for (File dpack : getDatapacksFolder()) {
reboot = true; dim.installDataPack(() -> data, dpack);
} }
} }
} }
@@ -147,19 +125,12 @@ public class ServerConfigurator {
Iris.info("Data Packs Setup!"); Iris.info("Data Packs Setup!");
if(fullInstall) { if (fullInstall)
verifyDataPacksPost(IrisSettings.get().getAutoConfiguration().isAutoRestartOnCustomBiomeInstall()); verifyDataPacksPost(IrisSettings.get().getAutoConfiguration().isAutoRestartOnCustomBiomeInstall());
} }
}
private static void verifyDataPacksPost(boolean allowRestarting) { private static void verifyDataPacksPost(boolean allowRestarting) {
File packs = new File("plugins/Iris/packs"); File packs = new File("plugins/Iris/packs");
File dpacks = getDatapacksFolder();
if(dpacks == null) {
Iris.error("Cannot find the datapacks folder! Please try generating a default world first maybe? Is this a new server?");
return;
}
boolean bad = false; boolean bad = false;
if (packs.exists()) { if (packs.exists()) {

View File

@@ -20,20 +20,14 @@ package com.volmit.iris.core.commands;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.service.StudioSVC; import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.IrisCave;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisJigsawPiece;
import com.volmit.iris.engine.object.IrisJigsawPool;
import com.volmit.iris.engine.object.IrisJigsawStructure;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.DecreeExecutor;
import com.volmit.iris.util.decree.DecreeOrigin; import com.volmit.iris.util.decree.DecreeOrigin;
import com.volmit.iris.util.decree.annotations.Decree; import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param; import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import java.awt.Desktop; import java.awt.*;
@Decree(name = "edit", origin = DecreeOrigin.PLAYER, studio = true, description = "Edit something") @Decree(name = "edit", origin = DecreeOrigin.PLAYER, studio = true, description = "Edit something")

View File

@@ -76,6 +76,20 @@ public class CommandFind implements DecreeExecutor {
e.gotoJigsaw(structure, player()); e.gotoJigsaw(structure, player());
} }
@Decree(description = "Find a point of interest.")
public void poi(
@Param(description = "The type of PoI to look for.")
String type
) {
Engine e = engine();
if (e == null) {
sender().sendMessage(C.GOLD + "Not in an Iris World!");
return;
}
e.gotoPOI(type, player());
}
@Decree(description = "Find an object") @Decree(description = "Find an object")
public void object( public void object(
@Param(description = "The object to look for", customHandler = ObjectHandler.class) @Param(description = "The object to look for", customHandler = ObjectHandler.class)

View File

@@ -38,10 +38,12 @@ import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.jobs.QueueJob; import com.volmit.iris.util.scheduling.jobs.QueueJob;
import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
@@ -76,8 +78,6 @@ public class CommandIris implements DecreeExecutor {
return; return;
} }
sender().sendMessage(C.RED + "You should not be using this command to create new worlds. Instead, use the tutorial: https://docs.volmit.com/iris/getting-started");
try { try {
IrisToolbelt.createWorld() IrisToolbelt.createWorld()
.dimension(type.getLoadKey()) .dimension(type.getLoadKey())
@@ -96,6 +96,37 @@ public class CommandIris implements DecreeExecutor {
sender().sendMessage(C.GREEN + "Successfully created your world!"); sender().sendMessage(C.GREEN + "Successfully created your world!");
} }
@Decree(description = "Remove an Iris world", aliases = {"del", "rm"}, sync = true)
public void remove(
@Param(description = "The world to remove")
World world,
@Param(description = "Whether to also remove the folder (if set to false, just does not load the world)", defaultValue = "true")
boolean delete
) {
if (!IrisToolbelt.isIrisWorld(world)) {
sender().sendMessage(C.RED + "This is not an Iris world. Iris worlds: " + String.join(", ", Bukkit.getServer().getWorlds().stream().filter(IrisToolbelt::isIrisWorld).map(World::getName).toList()));
return;
}
sender().sendMessage(C.GREEN + "Removing world: " + world.getName());
try {
if (IrisToolbelt.removeWorld(world)) {
sender().sendMessage(C.GREEN + "Successfully removed " + world.getName() + " from bukkit.yml");
} else {
sender().sendMessage(C.YELLOW + "Looks like the world was already removed from bukkit.yml");
}
} catch (IOException e) {
sender().sendMessage(C.RED + "Failed to save bukkit.yml because of " + e.getMessage());
e.printStackTrace();
}
IrisToolbelt.evacuate(world, "Deleting world");
Bukkit.unloadWorld(world, false);
if (delete && world.getWorldFolder().delete()) {
sender().sendMessage(C.GREEN + "Successfully removed world folder");
} else {
sender().sendMessage(C.RED + "Failed to remove world folder");
}
}
@Decree(description = "Print version information") @Decree(description = "Print version information")
public void version() { public void version() {
sender().sendMessage(C.GREEN + "Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software"); sender().sendMessage(C.GREEN + "Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software");
@@ -107,6 +138,12 @@ public class CommandIris implements DecreeExecutor {
sender().sendMessage(C.GREEN + "Total Height: " + (sender().player().getWorld().getMaxHeight() - sender().player().getWorld().getMinHeight())); sender().sendMessage(C.GREEN + "Total Height: " + (sender().player().getWorld().getMaxHeight() - sender().player().getWorld().getMinHeight()));
} }
@Decree(description = "QOL command to open a overworld studio world.", sync = true)
public void so() {
sender().sendMessage(C.GREEN + "Opening studio for the \"Overworld\" pack (seed: 1337)");
Iris.service(StudioSVC.class).open(sender(), 1337, "overworld");
}
@Decree(description = "Set aura spins") @Decree(description = "Set aura spins")
public void aura( public void aura(
@Param(description = "The h color value", defaultValue = "-20") @Param(description = "The h color value", defaultValue = "-20")
@@ -170,10 +207,14 @@ public class CommandIris implements DecreeExecutor {
@Param(name = "overwrite", description = "Whether or not to overwrite the pack with the downloaded one", aliases = "force", defaultValue = "false") @Param(name = "overwrite", description = "Whether or not to overwrite the pack with the downloaded one", aliases = "force", defaultValue = "false")
boolean overwrite boolean overwrite
) { ) {
branch = pack.equals("overworld") ? "stable" : branch;
sender().sendMessage(C.GREEN + "Downloading pack: " + pack + "/" + branch + (trim ? " trimmed" : "") + (overwrite ? " overwriting" : "")); sender().sendMessage(C.GREEN + "Downloading pack: " + pack + "/" + branch + (trim ? " trimmed" : "") + (overwrite ? " overwriting" : ""));
if (pack.equals("overworld")) {
String url = "https://github.com/IrisDimensions/overworld/releases/download/" + Iris.OVERWORLD_TAG + "/overworld.zip";
Iris.service(StudioSVC.class).downloadRelease(sender(), url, trim, overwrite);
} else {
Iris.service(StudioSVC.class).downloadSearch(sender(), "IrisDimensions/" + pack + "/" + branch, trim, overwrite); Iris.service(StudioSVC.class).downloadSearch(sender(), "IrisDimensions/" + pack + "/" + branch, trim, overwrite);
} }
}
@Decree(description = "Get metrics for your world", aliases = "measure", origin = DecreeOrigin.PLAYER) @Decree(description = "Get metrics for your world", aliases = "measure", origin = DecreeOrigin.PLAYER)
public void metrics() { public void metrics() {

View File

@@ -25,13 +25,7 @@ import com.volmit.iris.core.service.ObjectSVC;
import com.volmit.iris.core.service.StudioSVC; import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.service.WandSVC; import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IObjectPlacer; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.engine.object.IrisObjectPlacement;
import com.volmit.iris.engine.object.IrisObjectPlacementScaleInterpolator;
import com.volmit.iris.engine.object.IrisObjectRotation;
import com.volmit.iris.engine.object.TileData;
import com.volmit.iris.util.data.Cuboid; import com.volmit.iris.util.data.Cuboid;
import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.DecreeExecutor;
import com.volmit.iris.util.decree.DecreeOrigin; import com.volmit.iris.util.decree.DecreeOrigin;
@@ -53,14 +47,7 @@ import org.bukkit.util.Vector;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Decree(name = "object", aliases = "o", origin = DecreeOrigin.PLAYER, studio = true, description = "Iris object manipulation") @Decree(name = "object", aliases = "o", origin = DecreeOrigin.PLAYER, studio = true, description = "Iris object manipulation")
@@ -319,8 +306,7 @@ public class CommandObject implements DecreeExecutor {
Map<Block, BlockData> futureChanges = new HashMap<>(); Map<Block, BlockData> futureChanges = new HashMap<>();
if(scale != 1) if (scale != 1) {
{
o = o.scaled(scale, IrisObjectPlacementScaleInterpolator.TRICUBIC); o = o.scaled(scale, IrisObjectPlacementScaleInterpolator.TRICUBIC);
} }
@@ -427,8 +413,7 @@ public class CommandObject implements DecreeExecutor {
Cuboid locs = WorldEditLink.getSelection(sender().player()); Cuboid locs = WorldEditLink.getSelection(sender().player());
if(locs == null) if (locs == null) {
{
sender().sendMessage(C.RED + "You don't have a WorldEdit selection in this world."); sender().sendMessage(C.RED + "You don't have a WorldEdit selection in this world.");
return; return;
} }

View File

@@ -28,20 +28,7 @@ import com.volmit.iris.core.service.ConversionSVC;
import com.volmit.iris.core.service.StudioSVC; import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.InventorySlotType; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisBiomePaletteLayer;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisEntity;
import com.volmit.iris.engine.object.IrisGenerator;
import com.volmit.iris.engine.object.IrisInterpolator;
import com.volmit.iris.engine.object.IrisLootTable;
import com.volmit.iris.engine.object.IrisNoiseGenerator;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.engine.object.IrisObjectPlacement;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.engine.object.IrisScript;
import com.volmit.iris.engine.object.NoiseStyle;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.collection.KSet;
@@ -61,28 +48,15 @@ import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.math.Spiraler; import com.volmit.iris.util.math.Spiraler;
import com.volmit.iris.util.noise.CNG; import com.volmit.iris.util.noise.CNG;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.O; import com.volmit.iris.util.scheduling.O;
import com.volmit.iris.util.scheduling.PrecisionStopwatch; import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import com.volmit.iris.util.scheduling.jobs.Job;
import com.volmit.iris.util.scheduling.jobs.JobCollection;
import com.volmit.iris.util.scheduling.jobs.QueueJob;
import com.volmit.iris.util.scheduling.jobs.SingleJob;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.FluidCollisionMode;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.util.BlockVector; import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.awt.*;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
@@ -93,20 +67,16 @@ import java.time.Duration;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.Date; import java.util.Date;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
@Decree(name = "studio", aliases = {"std", "s"}, description = "Studio Commands", studio = true) @Decree(name = "studio", aliases = {"std", "s"}, description = "Studio Commands", studio = true)
public class CommandStudio implements DecreeExecutor { public class CommandStudio implements DecreeExecutor {
public static String hrf(Duration duration) {
return duration.toString().substring(2).replaceAll("(\\d[HMS])(?!$)", "$1 ").toLowerCase();
}
private CommandFind find; private CommandFind find;
private CommandEdit edit; private CommandEdit edit;
public static String hrf(Duration duration) {
return duration.toString().substring(2).replaceAll("(\\d[HMS])(?!$)", "$1 ").toLowerCase();
}
@Decree(description = "Download a project.", aliases = "dl") @Decree(description = "Download a project.", aliases = "dl")
public void download( public void download(
@@ -165,130 +135,6 @@ public class CommandStudio implements DecreeExecutor {
} }
} }
@Decree(description = "Clean an Iris Project, optionally beautifying JSON & fixing block ids with missing keys. Also rebuilds the vscode schemas. ")
public void clean(
@Param(description = "The project to update", contextual = true)
IrisDimension project,
@Param(defaultValue = "true", description = "Filters all valid JSON files with a beautifier (indentation: 4)")
boolean beautify,
@Param(name = "fix-ids", defaultValue = "true", description = "Fixes any block ids used such as \"dirt\" will be converted to \"minecraft:dirt\"")
boolean fixIds,
@Param(name = "rewrite-objects", defaultValue = "false", description = "Imports all objects and re-writes them cleaning up positions & block data in the process.")
boolean rewriteObjects
) {
KList<Job> jobs = new KList<>();
KList<File> files = new KList<File>();
files(Iris.instance.getDataFolder("packs", project.getLoadKey()), files);
MultiBurst burst = MultiBurst.burst;
jobs.add(new SingleJob("Updating Workspace", () -> {
if(!new IrisProject(Iris.service(StudioSVC.class).getWorkspaceFolder(project.getLoadKey())).updateWorkspace()) {
sender().sendMessage(C.GOLD + "Invalid project: " + project.getLoadKey() + ". Try deleting the code-workspace file and try again.");
}
J.sleep(250);
}));
sender().sendMessage("Files: " + files.size());
if(fixIds) {
QueueJob<File> r = new QueueJob<>() {
@Override
public void execute(File f) {
try {
JSONObject p = new JSONObject(IO.readAll(f));
fixBlocks(p);
J.sleep(1);
IO.writeAll(f, p.toString(4));
} catch(IOException e) {
e.printStackTrace();
}
}
@Override
public String getName() {
return "Fixing IDs";
}
};
r.queue(files);
jobs.add(r);
}
if(beautify) {
QueueJob<File> r = new QueueJob<>() {
@Override
public void execute(File f) {
try {
JSONObject p = new JSONObject(IO.readAll(f));
IO.writeAll(f, p.toString(4));
J.sleep(1);
} catch(IOException e) {
e.printStackTrace();
}
}
@Override
public String getName() {
return "Beautify";
}
};
r.queue(files);
jobs.add(r);
}
if(rewriteObjects) {
QueueJob<Runnable> q = new QueueJob<>() {
@Override
public void execute(Runnable runnable) {
runnable.run();
J.sleep(50);
}
@Override
public String getName() {
return "Rewriting Objects";
}
};
IrisData data = IrisData.get(Iris.service(StudioSVC.class).getWorkspaceFolder(project.getLoadKey()));
for(String f : data.getObjectLoader().getPossibleKeys()) {
Future<?> gg = burst.complete(() -> {
File ff = data.getObjectLoader().findFile(f);
IrisObject oo = new IrisObject(0, 0, 0);
try {
oo.read(ff);
} catch(Throwable e) {
Iris.error("FAILER TO READ: " + f);
return;
}
try {
oo.write(ff);
} catch(IOException e) {
Iris.error("FAILURE TO WRITE: " + oo.getLoadFile());
}
});
q.queue(() -> {
try {
gg.get();
} catch(InterruptedException | ExecutionException e) {
e.printStackTrace();
}
});
}
jobs.add(q);
}
new JobCollection("Cleaning", jobs).execute(sender());
}
@Decree(description = "Get the version of a pack") @Decree(description = "Get the version of a pack")
public void version( public void version(
@Param(defaultValue = "default", description = "The dimension get the version of", aliases = "dim", contextual = true) @Param(defaultValue = "default", description = "The dimension get the version of", aliases = "dim", contextual = true)

View File

@@ -65,7 +65,7 @@ public class CommandWhat implements DecreeExecutor {
@Decree(description = "What biome am i in?", origin = DecreeOrigin.PLAYER) @Decree(description = "What biome am i in?", origin = DecreeOrigin.PLAYER)
public void biome() { public void biome() {
try { try {
IrisBiome b = engine().getBiome(player().getLocation().getBlockX(), player().getLocation().getBlockY(), player().getLocation().getBlockZ()); IrisBiome b = engine().getBiome(player().getLocation().getBlockX(), player().getLocation().getBlockY() - player().getWorld().getMinHeight(), player().getLocation().getBlockZ());
sender().sendMessage("IBiome: " + b.getLoadKey() + " (" + b.getDerivative().name() + ")"); sender().sendMessage("IBiome: " + b.getLoadKey() + " (" + b.getDerivative().name() + ")");
} catch (Throwable e) { } catch (Throwable e) {

View File

@@ -19,14 +19,9 @@
package com.volmit.iris.core.edit; package com.volmit.iris.core.edit;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.service.WandSVC; import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.engine.object.IrisDirection; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.IrisJigsawPiece;
import com.volmit.iris.engine.object.IrisJigsawPieceConnector;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.engine.object.IrisPosition;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.data.Cuboid; import com.volmit.iris.util.data.Cuboid;
@@ -71,8 +66,7 @@ public class JigsawEditor implements Listener {
} }
editors.put(player, this); editors.put(player, this);
if(object == null) if (object == null) {
{
throw new RuntimeException("Object is null! " + piece.getObject()); throw new RuntimeException("Object is null! " + piece.getObject());
} }
this.object = object; this.object = object;
@@ -157,10 +151,8 @@ public class JigsawEditor implements Listener {
} }
} }
private void removeKey(JSONObject o, String... path) private void removeKey(JSONObject o, String... path) {
{ if (path.length == 1) {
if(path.length == 1)
{
o.remove(path[0]); o.remove(path[0]);
return; return;
} }
@@ -170,12 +162,10 @@ public class JigsawEditor implements Listener {
removeKey(o.getJSONObject(path[0]), s.toArray(new String[0])); removeKey(o.getJSONObject(path[0]), s.toArray(new String[0]));
} }
private List<JSONObject> getObjectsInArray(JSONObject a, String key) private List<JSONObject> getObjectsInArray(JSONObject a, String key) {
{
KList<JSONObject> o = new KList<>(); KList<JSONObject> o = new KList<>();
for(int i = 0; i < a.getJSONArray(key).length(); i++) for (int i = 0; i < a.getJSONArray(key).length(); i++) {
{
o.add(a.getJSONArray(key).getJSONObject(i)); o.add(a.getJSONArray(key).getJSONObject(i));
} }
@@ -195,8 +185,7 @@ public class JigsawEditor implements Listener {
j.remove("placementOptions"); // otherwise j.remove("placementOptions"); // otherwise
// Remove key in all objects in array // Remove key in all objects in array
for(JSONObject i : getObjectsInArray(j, "connectors")) for (JSONObject i : getObjectsInArray(j, "connectors")) {
{
removeKey(i, "rotateConnector"); removeKey(i, "rotateConnector");
} }

View File

@@ -35,24 +35,9 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.JComboBox; import javax.swing.*;
import javax.swing.JComponent; import java.awt.*;
import javax.swing.JFrame; import java.awt.event.*;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.JViewport;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -148,7 +133,7 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener, List
JFrame frame = new JFrame("Noise Explorer"); JFrame frame = new JFrame("Noise Explorer");
NoiseExplorerGUI nv = new NoiseExplorerGUI(); NoiseExplorerGUI nv = new NoiseExplorerGUI();
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
KList<String> li = new KList<>(NoiseStyle.values()).toStringList(); KList<String> li = new KList<>(NoiseStyle.values()).toStringList().sort();
combo = new JComboBox<>(li.toArray(new String[0])); combo = new JComboBox<>(li.toArray(new String[0]));
combo.setSelectedItem("STATIC"); combo.setSelectedItem("STATIC");
combo.setFocusable(false); combo.setFocusable(false);

View File

@@ -35,12 +35,8 @@ import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.scheduling.ChronoLatch; import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import javax.swing.JFrame; import javax.swing.*;
import javax.swing.JPanel; import java.awt.*;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@@ -66,12 +62,12 @@ public class PregeneratorJob implements PregenListener {
private final IrisPregenerator pregenerator; private final IrisPregenerator pregenerator;
private final Position2 min; private final Position2 min;
private final Position2 max; private final Position2 max;
private final ChronoLatch cl = new ChronoLatch(TimeUnit.MINUTES.toMillis(1));
private final Engine engine;
private JFrame frame; private JFrame frame;
private PregenRenderer renderer; private PregenRenderer renderer;
private int rgc = 0; private int rgc = 0;
private final ChronoLatch cl = new ChronoLatch(TimeUnit.MINUTES.toMillis(1));
private String[] info; private String[] info;
private final Engine engine;
public PregeneratorJob(PregenTask task, PregeneratorMethod method, Engine engine) { public PregeneratorJob(PregenTask task, PregeneratorMethod method, Engine engine) {
this.engine = engine; this.engine = engine;
@@ -83,7 +79,6 @@ public class PregeneratorJob implements PregenListener {
this.pregenerator = new IrisPregenerator(task, method, this); this.pregenerator = new IrisPregenerator(task, method, this);
max = new Position2(0, 0); max = new Position2(0, 0);
min = new Position2(0, 0); min = new Position2(0, 0);
KList<Runnable> draw = new KList<>();
task.iterateRegions((xx, zz) -> { task.iterateRegions((xx, zz) -> {
min.setX(Math.min(xx << 5, min.getX())); min.setX(Math.min(xx << 5, min.getX()));
min.setZ(Math.min(zz << 5, min.getZ())); min.setZ(Math.min(zz << 5, min.getZ()));
@@ -98,10 +93,6 @@ public class PregeneratorJob implements PregenListener {
J.a(this.pregenerator::start, 20); J.a(this.pregenerator::start, 20);
} }
public Mantle getMantle() {
return pregenerator.getMantle();
}
public static boolean shutdownInstance() { public static boolean shutdownInstance() {
if (instance == null) { if (instance == null) {
return false; return false;
@@ -148,6 +139,10 @@ public class PregeneratorJob implements PregenListener {
return Color.RED; return Color.RED;
} }
public Mantle getMantle() {
return pregenerator.getMantle();
}
public PregeneratorJob onProgress(Consumer<Double> c) { public PregeneratorJob onProgress(Consumer<Double> c) {
onProgress.add(c); onProgress.add(c);
return this; return this;
@@ -206,8 +201,7 @@ public class PregeneratorJob implements PregenListener {
renderer.l = new ReentrantLock(); renderer.l = new ReentrantLock();
renderer.frame = frame; renderer.frame = frame;
renderer.job = this; renderer.job = this;
renderer.func = (c, b) -> renderer.func = (c, b) -> {
{
renderer.l.lock(); renderer.l.lock();
renderer.order.add(() -> renderer.draw(c, b, renderer.bg)); renderer.order.add(() -> renderer.draw(c, b, renderer.bg));
renderer.l.unlock(); renderer.l.unlock();
@@ -239,10 +233,6 @@ public class PregeneratorJob implements PregenListener {
@Override @Override
public void onChunkGenerating(int x, int z) { public void onChunkGenerating(int x, int z) {
if(engine != null) {
return;
}
draw(x, z, COLOR_GENERATING); draw(x, z, COLOR_GENERATING);
} }

View File

@@ -44,16 +44,10 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.JFrame; import javax.swing.*;
import javax.swing.JPanel;
import javax.swing.event.MouseInputListener; import javax.swing.event.MouseInputListener;
import java.awt.*; import java.awt.*;
import java.awt.event.KeyEvent; import java.awt.event.*;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -218,12 +212,18 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener
BiFunction<Double, Double, Integer> colorFunction = (d, dx) -> Color.black.getRGB(); BiFunction<Double, Double, Integer> colorFunction = (d, dx) -> Color.black.getRGB();
switch (currentType) { switch (currentType) {
case BIOME, DECORATOR_LOAD, OBJECT_LOAD, LAYER_LOAD -> colorFunction = (x, z) -> engine.getComplex().getTrueBiomeStream().get(x, z).getColor(engine, currentType).getRGB(); case BIOME, DECORATOR_LOAD, OBJECT_LOAD, LAYER_LOAD ->
case BIOME_LAND -> colorFunction = (x, z) -> engine.getComplex().getLandBiomeStream().get(x, z).getColor(engine, currentType).getRGB(); colorFunction = (x, z) -> engine.getComplex().getTrueBiomeStream().get(x, z).getColor(engine, currentType).getRGB();
case BIOME_SEA -> colorFunction = (x, z) -> engine.getComplex().getSeaBiomeStream().get(x, z).getColor(engine, currentType).getRGB(); case BIOME_LAND ->
case REGION -> colorFunction = (x, z) -> engine.getComplex().getRegionStream().get(x, z).getColor(engine.getComplex(), currentType).getRGB(); colorFunction = (x, z) -> engine.getComplex().getLandBiomeStream().get(x, z).getColor(engine, currentType).getRGB();
case CAVE_LAND -> colorFunction = (x, z) -> engine.getComplex().getCaveBiomeStream().get(x, z).getColor(engine, currentType).getRGB(); case BIOME_SEA ->
case HEIGHT -> colorFunction = (x, z) -> Color.getHSBColor(engine.getComplex().getHeightStream().get(x, z).floatValue(), 100, 100).getRGB(); colorFunction = (x, z) -> engine.getComplex().getSeaBiomeStream().get(x, z).getColor(engine, currentType).getRGB();
case REGION ->
colorFunction = (x, z) -> engine.getComplex().getRegionStream().get(x, z).getColor(engine.getComplex(), currentType).getRGB();
case CAVE_LAND ->
colorFunction = (x, z) -> engine.getComplex().getCaveBiomeStream().get(x, z).getColor(engine, currentType).getRGB();
case HEIGHT ->
colorFunction = (x, z) -> Color.getHSBColor(engine.getComplex().getHeightStream().get(x, z).floatValue(), 100, 100).getRGB();
} }
return colorFunction.apply(wx, wz); return colorFunction.apply(wx, wz);
@@ -433,13 +433,9 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener
if (engine.isClosed()) { if (engine.isClosed()) {
EventQueue.invokeLater(() -> { EventQueue.invokeLater(() -> {
try try {
{
setVisible(false); setVisible(false);
} } catch (Throwable e) {
catch(Throwable e)
{
} }
}); });
@@ -739,7 +735,8 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener
IrisComplex complex = engine.getComplex(); IrisComplex complex = engine.getComplex();
File r = null; File r = null;
switch (currentType) { switch (currentType) {
case BIOME, LAYER_LOAD, DECORATOR_LOAD, OBJECT_LOAD, HEIGHT -> r = complex.getTrueBiomeStream().get(getWorldX(hx), getWorldZ(hz)).openInVSCode(); case BIOME, LAYER_LOAD, DECORATOR_LOAD, OBJECT_LOAD, HEIGHT ->
r = complex.getTrueBiomeStream().get(getWorldX(hx), getWorldZ(hz)).openInVSCode();
case BIOME_LAND -> r = complex.getLandBiomeStream().get(getWorldX(hx), getWorldZ(hz)).openInVSCode(); case BIOME_LAND -> r = complex.getLandBiomeStream().get(getWorldX(hx), getWorldZ(hz)).openInVSCode();
case BIOME_SEA -> r = complex.getSeaBiomeStream().get(getWorldX(hx), getWorldZ(hz)).openInVSCode(); case BIOME_SEA -> r = complex.getSeaBiomeStream().get(getWorldX(hx), getWorldZ(hz)).openInVSCode();
case REGION -> r = complex.getRegionStream().get(getWorldX(hx), getWorldZ(hz)).openInVSCode(); case REGION -> r = complex.getRegionStream().get(getWorldX(hx), getWorldZ(hz)).openInVSCode();

View File

@@ -21,7 +21,7 @@ package com.volmit.iris.core.gui.components;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.interpolation.IrisInterpolation; import com.volmit.iris.util.interpolation.IrisInterpolation;
import java.awt.Color; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.function.BiFunction; import java.util.function.BiFunction;
@@ -38,12 +38,18 @@ public class IrisRenderer {
BiFunction<Double, Double, Integer> colorFunction = (d, dx) -> Color.black.getRGB(); BiFunction<Double, Double, Integer> colorFunction = (d, dx) -> Color.black.getRGB();
switch (currentType) { switch (currentType) {
case BIOME, DECORATOR_LOAD, OBJECT_LOAD, LAYER_LOAD -> colorFunction = (x, z) -> renderer.getComplex().getTrueBiomeStream().get(x, z).getColor(renderer, currentType).getRGB(); case BIOME, DECORATOR_LOAD, OBJECT_LOAD, LAYER_LOAD ->
case BIOME_LAND -> colorFunction = (x, z) -> renderer.getComplex().getLandBiomeStream().get(x, z).getColor(renderer, currentType).getRGB(); colorFunction = (x, z) -> renderer.getComplex().getTrueBiomeStream().get(x, z).getColor(renderer, currentType).getRGB();
case BIOME_SEA -> colorFunction = (x, z) -> renderer.getComplex().getSeaBiomeStream().get(x, z).getColor(renderer, currentType).getRGB(); case BIOME_LAND ->
case REGION -> colorFunction = (x, z) -> renderer.getComplex().getRegionStream().get(x, z).getColor(renderer.getComplex(), currentType).getRGB(); colorFunction = (x, z) -> renderer.getComplex().getLandBiomeStream().get(x, z).getColor(renderer, currentType).getRGB();
case CAVE_LAND -> colorFunction = (x, z) -> renderer.getComplex().getCaveBiomeStream().get(x, z).getColor(renderer, currentType).getRGB(); case BIOME_SEA ->
case HEIGHT -> colorFunction = (x, z) -> Color.getHSBColor(renderer.getComplex().getHeightStream().get(x, z).floatValue(), 100, 100).getRGB(); colorFunction = (x, z) -> renderer.getComplex().getSeaBiomeStream().get(x, z).getColor(renderer, currentType).getRGB();
case REGION ->
colorFunction = (x, z) -> renderer.getComplex().getRegionStream().get(x, z).getColor(renderer.getComplex(), currentType).getRGB();
case CAVE_LAND ->
colorFunction = (x, z) -> renderer.getComplex().getCaveBiomeStream().get(x, z).getColor(renderer, currentType).getRGB();
case HEIGHT ->
colorFunction = (x, z) -> Color.getHSBColor(renderer.getComplex().getHeightStream().get(x, z).floatValue(), 100, 100).getRGB();
} }
double x, z; double x, z;

View File

@@ -18,7 +18,7 @@
package com.volmit.iris.core.gui.components; package com.volmit.iris.core.gui.components;
import java.awt.Color; import java.awt.*;
@FunctionalInterface @FunctionalInterface
public interface Renderer { public interface Renderer {

View File

@@ -20,6 +20,7 @@ package com.volmit.iris.core.link;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.platform.PlatformChunkGenerator; import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.Location; import org.bukkit.Location;
@@ -52,22 +53,22 @@ public class IrisPapiExpansion extends PlaceholderExpansion {
Location l = null; Location l = null;
PlatformChunkGenerator a = null; PlatformChunkGenerator a = null;
if(player.isOnline()) { if (player.isOnline() && player.getPlayer() != null) {
l = player.getPlayer().getLocation(); l = player.getPlayer().getLocation().add(0, 2, 0);
a = IrisToolbelt.access(l.getWorld()); a = IrisToolbelt.access(l.getWorld());
} }
if (p.equalsIgnoreCase("biome_name")) { if (p.equalsIgnoreCase("biome_name")) {
if (a != null) { if (a != null) {
return a.getEngine().getBiome(l).getName(); return getBiome(a, l).getName();
} }
} else if (p.equalsIgnoreCase("biome_id")) { } else if (p.equalsIgnoreCase("biome_id")) {
if (a != null) { if (a != null) {
return a.getEngine().getBiome(l).getLoadKey(); return getBiome(a, l).getLoadKey();
} }
} else if (p.equalsIgnoreCase("biome_file")) { } else if (p.equalsIgnoreCase("biome_file")) {
if (a != null) { if (a != null) {
return a.getEngine().getBiome(l).getLoadFile().getPath(); return getBiome(a, l).getLoadFile().getPath();
} }
} else if (p.equalsIgnoreCase("region_name")) { } else if (p.equalsIgnoreCase("region_name")) {
if (a != null) { if (a != null) {
@@ -107,4 +108,8 @@ public class IrisPapiExpansion extends PlaceholderExpansion {
return null; return null;
} }
private IrisBiome getBiome(PlatformChunkGenerator a, Location l) {
return a.getEngine().getBiome(l.getBlockX(), l.getBlockY() - l.getWorld().getMinHeight(), l.getBlockZ());
}
} }

View File

@@ -17,7 +17,8 @@ public class ItemAdderDataProvider extends ExternalDataProvider {
} }
@Override @Override
public void init() { } public void init() {
}
@Override @Override
public BlockData getBlockData(NamespacedKey blockId) throws MissingResourceException { public BlockData getBlockData(NamespacedKey blockId) throws MissingResourceException {

View File

@@ -50,10 +50,8 @@ public class MythicMobsLink {
/** /**
* Spawn a mythic mob at this location * Spawn a mythic mob at this location
* *
* @param mob * @param mob The mob
* The mob * @param location The location
* @param location
* The location
* @return The mob, or null if it can't be spawned * @return The mob, or null if it can't be spawned
*/ */
public @Nullable public @Nullable
@@ -105,7 +103,8 @@ public class MythicMobsLink {
Method getMobNames = mobManager.getClass().getDeclaredMethod("getMobNames"); Method getMobNames = mobManager.getClass().getDeclaredMethod("getMobNames");
mobs = (Collection<String>) getMobNames.invoke(mobManager); mobs = (Collection<String>) getMobNames.invoke(mobManager);
return mobs; return mobs;
} catch(ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException |
IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@@ -46,7 +46,9 @@ public class OraxenDataProvider extends ExternalDataProvider {
private Map<String, MechanicFactory> factories; private Map<String, MechanicFactory> factories;
public OraxenDataProvider() { super("Oraxen"); } public OraxenDataProvider() {
super("Oraxen");
}
@Override @Override
public void init() { public void init() {
@@ -87,7 +89,8 @@ public class OraxenDataProvider extends ExternalDataProvider {
NamespacedKey key = new NamespacedKey("oraxen", name); NamespacedKey key = new NamespacedKey("oraxen", name);
if (getBlockData(key) != null) if (getBlockData(key) != null)
names.add(key); names.add(key);
} catch(MissingResourceException ignored) { } } catch (MissingResourceException ignored) {
}
} }
return names.toArray(new NamespacedKey[0]); return names.toArray(new NamespacedKey[0]);

View File

@@ -5,10 +5,8 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class WorldEditLink { public class WorldEditLink {
public static Cuboid getSelection(Player p) public static Cuboid getSelection(Player p) {
{ try {
try
{
Object instance = Class.forName("com.sk89q.worldedit.WorldEdit").getDeclaredMethod("getInstance").invoke(null); Object instance = Class.forName("com.sk89q.worldedit.WorldEdit").getDeclaredMethod("getInstance").invoke(null);
Object sessionManager = instance.getClass().getDeclaredMethod("getSessionManager").invoke(instance); Object sessionManager = instance.getClass().getDeclaredMethod("getSessionManager").invoke(instance);
Object player = Class.forName("com.sk89q.worldedit.bukkit.BukkitAdapter").getDeclaredMethod("adapt", Player.class).invoke(null, p); Object player = Class.forName("com.sk89q.worldedit.bukkit.BukkitAdapter").getDeclaredMethod("adapt", Player.class).invoke(null, p);
@@ -25,10 +23,7 @@ public class WorldEditLink {
(int) min.getClass().getDeclaredMethod("getY").invoke(max), (int) min.getClass().getDeclaredMethod("getY").invoke(max),
(int) min.getClass().getDeclaredMethod("getZ").invoke(max) (int) min.getClass().getDeclaredMethod("getZ").invoke(max)
); );
} } catch (Throwable e) {
catch(Throwable e)
{
} }

View File

@@ -18,12 +18,7 @@
package com.volmit.iris.core.loader; package com.volmit.iris.core.loader;
import com.google.gson.ExclusionStrategy; import com.google.gson.*;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonToken;
@@ -39,6 +34,8 @@ import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.context.IrisContext; import com.volmit.iris.util.context.IrisContext;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.scheduling.ChronoLatch; import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import lombok.Data; import lombok.Data;
@@ -116,6 +113,7 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
public static IrisObject loadAnyObject(String key) { public static IrisObject loadAnyObject(String key) {
return loadAny(key, (dm) -> dm.getObjectLoader().load(key, false)); return loadAny(key, (dm) -> dm.getObjectLoader().load(key, false));
} }
public static IrisMatterObject loadAnyMatter(String key) { public static IrisMatterObject loadAnyMatter(String key) {
return loadAny(key, (dm) -> dm.getMatterLoader().load(key, false)); return loadAny(key, (dm) -> dm.getMatterLoader().load(key, false));
} }
@@ -467,4 +465,38 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
public boolean isClosed() { public boolean isClosed() {
return closed; return closed;
} }
public void savePrefetch(Engine engine) {
BurstExecutor b = MultiBurst.burst.burst(loaders.size());
for (ResourceLoader<?> i : loaders.values()) {
b.queue(() -> {
try {
i.saveFirstAccess(engine);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
b.complete();
Iris.info("Saved Prefetch Cache to speed up future world startups");
}
public void loadPrefetch(Engine engine) {
BurstExecutor b = MultiBurst.burst.burst(loaders.size());
for (ResourceLoader<?> i : loaders.values()) {
b.queue(() -> {
try {
i.loadFirstAccess(engine);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
b.complete();
Iris.info("Loaded Prefetch Cache to reduce generation disk use.");
}
} }

View File

@@ -29,7 +29,7 @@ import com.volmit.iris.util.json.JSONObject;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import lombok.Data; import lombok.Data;
import java.awt.Desktop; import java.awt.*;
import java.io.File; import java.io.File;
@Data @Data

View File

@@ -68,33 +68,26 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject> {
if (possibleKeys != null) { if (possibleKeys != null) {
return possibleKeys; return possibleKeys;
} }
Iris.debug("Building " + resourceTypeName + " Possibility Lists"); Iris.debug("Building " + resourceTypeName + " Possibility Lists");
KSet<String> m = new KSet<>(); KSet<String> m = new KSet<>();
for (File i : getFolders()) { for (File i : getFolders()) {
for(File j : i.listFiles()) { m.addAll(getFiles(i, ".iob", true));
if(j.isFile() && j.getName().endsWith(".iob")) {
m.add(j.getName().replaceAll("\\Q.iob\\E", ""));
} else if(j.isDirectory()) {
for(File k : j.listFiles()) {
if(k.isFile() && k.getName().endsWith(".iob")) {
m.add(j.getName() + "/" + k.getName().replaceAll("\\Q.iob\\E", ""));
} else if(k.isDirectory()) {
for(File l : k.listFiles()) {
if(l.isFile() && l.getName().endsWith(".iob")) {
m.add(j.getName() + "/" + k.getName() + "/" + l.getName().replaceAll("\\Q.iob\\E", ""));
}
}
}
}
}
} }
possibleKeys = m.toArray(new String[0]);
return possibleKeys;
} }
KList<String> v = new KList<>(m); private KList<String> getFiles(File dir, String ext, boolean skipDirName) {
possibleKeys = v.toArray(new String[0]); KList<String> paths = new KList<>();
return possibleKeys; String name = skipDirName ? "" : dir.getName() + "/";
for (File f : dir.listFiles()) {
if (f.isFile() && f.getName().endsWith(ext)) {
paths.add(name + f.getName().replaceAll("\\Q" + ext + "\\E", ""));
} else if (f.isDirectory()) {
getFiles(f, ext, false).forEach(e -> paths.add(name + e));
}
}
return paths;
} }
public File findFile(String name) { public File findFile(String name) {

View File

@@ -23,37 +23,44 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.project.SchemaBuilder; import com.volmit.iris.core.project.SchemaBuilder;
import com.volmit.iris.core.service.PreservationSVC; import com.volmit.iris.core.service.PreservationSVC;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.MeteredCache; import com.volmit.iris.engine.framework.MeteredCache;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.data.KCache; import com.volmit.iris.util.data.KCache;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.io.CustomOutputStream;
import com.volmit.iris.util.io.IO; import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.json.JSONArray; import com.volmit.iris.util.json.JSONArray;
import com.volmit.iris.util.json.JSONObject; import com.volmit.iris.util.json.JSONObject;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.scheduling.ChronoLatch; import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.PrecisionStopwatch; import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import lombok.Data; import lombok.Data;
import java.io.File; import java.io.*;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@Data @Data
public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache { public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
public static final AtomicDouble tlt = new AtomicDouble(0); public static final AtomicDouble tlt = new AtomicDouble(0);
private static final int CACHE_SIZE = 100000; private static final int CACHE_SIZE = 100000;
protected final AtomicReference<KList<File>> folderCache;
protected KSet<String> firstAccess;
protected File root; protected File root;
protected String folderName; protected String folderName;
protected String resourceTypeName; protected String resourceTypeName;
protected KCache<String, T> loadCache; protected KCache<String, T> loadCache;
protected final AtomicReference<KList<File>> folderCache;
protected Class<? extends T> objectClass; protected Class<? extends T> objectClass;
protected String cname; protected String cname;
protected String[] possibleKeys = null; protected String[] possibleKeys = null;
@@ -63,6 +70,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
public ResourceLoader(File root, IrisData manager, String folderName, String resourceTypeName, Class<? extends T> objectClass) { public ResourceLoader(File root, IrisData manager, String folderName, String resourceTypeName, Class<? extends T> objectClass) {
this.manager = manager; this.manager = manager;
firstAccess = new KSet<>();
folderCache = new AtomicReference<>(); folderCache = new AtomicReference<>();
sec = new ChronoLatch(5000); sec = new ChronoLatch(5000);
loads = new AtomicInteger(); loads = new AtomicInteger();
@@ -221,6 +229,24 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
return m; return m;
} }
public KList<T> loadAllParallel(KList<String> s) {
KList<T> m = new KList<>();
BurstExecutor burst = MultiBurst.burst.burst(s.size());
for (String i : s) {
burst.queue(() -> {
T t = load(i);
if (t != null) {
m.add(t);
}
});
}
burst.complete();
return m;
}
public KList<T> loadAll(KList<String> s, Consumer<T> postLoad) { public KList<T> loadAll(KList<String> s, Consumer<T> postLoad) {
KList<T> m = new KList<>(); KList<T> m = new KList<>();
@@ -282,12 +308,52 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
return null; return null;
} }
firstAccess.add(name);
return loadCache.get(name); return loadCache.get(name);
} }
public void loadFirstAccess(Engine engine) throws IOException {
String id = "DIM" + Math.abs(engine.getSeedManager().getSeed() + engine.getDimension().getVersion() + engine.getDimension().getLoadKey().hashCode());
File file = Iris.instance.getDataFile("prefetch/" + id + "/" + Math.abs(getFolderName().hashCode()) + ".ipfch");
if (!file.exists()) {
return;
}
FileInputStream fin = new FileInputStream(file);
GZIPInputStream gzi = new GZIPInputStream(fin);
DataInputStream din = new DataInputStream(gzi);
int m = din.readInt();
KList<String> s = new KList<>();
for (int i = 0; i < m; i++) {
s.add(din.readUTF());
}
din.close();
file.deleteOnExit();
Iris.info("Loading " + s.size() + " prefetch " + getFolderName());
loadAllParallel(s);
}
public void saveFirstAccess(Engine engine) throws IOException {
String id = "DIM" + Math.abs(engine.getSeedManager().getSeed() + engine.getDimension().getVersion() + engine.getDimension().getLoadKey().hashCode());
File file = Iris.instance.getDataFile("prefetch/" + id + "/" + Math.abs(getFolderName().hashCode()) + ".ipfch");
file.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(file);
GZIPOutputStream gzo = new CustomOutputStream(fos, 9);
DataOutputStream dos = new DataOutputStream(gzo);
dos.writeInt(firstAccess.size());
for (String i : firstAccess) {
dos.writeUTF(i);
}
dos.flush();
dos.close();
}
public KList<File> getFolders() { public KList<File> getFolders() {
synchronized (folderCache) { synchronized (folderCache) {
if (folderCache.get() == null) { if (folderCache.get() == null) {
KList<File> fc = new KList<>(); KList<File> fc = new KList<>();

View File

@@ -20,7 +20,7 @@ package com.volmit.iris.core.nms;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.nms.v19_1.NMSBinding19_1; import com.volmit.iris.core.nms.v19_3.NMSBinding19_3;
import com.volmit.iris.core.nms.v1X.NMSBinding1X; import com.volmit.iris.core.nms.v1X.NMSBinding1X;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -28,7 +28,7 @@ import org.bukkit.Bukkit;
public class INMS { public class INMS {
//@builder //@builder
private static final KMap<String, Class<? extends INMSBinding>> bindings = new KMap<String, Class<? extends INMSBinding>>() private static final KMap<String, Class<? extends INMSBinding>> bindings = new KMap<String, Class<? extends INMSBinding>>()
.qput("v1_19_R1", NMSBinding19_1.class); .qput("v1_19_R2", NMSBinding19_3.class);
//@done //@done
private static final INMSBinding binding = bind(); private static final INMSBinding binding = bind();

View File

@@ -18,9 +18,11 @@
package com.volmit.iris.core.nms; package com.volmit.iris.core.nms;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.nbt.mca.palette.MCABiomeContainer; import com.volmit.iris.util.nbt.mca.palette.MCABiomeContainer;
import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess; import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess;
import com.volmit.iris.util.nbt.tag.CompoundTag; import com.volmit.iris.util.nbt.tag.CompoundTag;
import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator; import org.bukkit.WorldCreator;
@@ -54,8 +56,11 @@ public interface INMSBinding {
String getTrueBiomeBaseKey(Location location); String getTrueBiomeBaseKey(Location location);
Object getCustomBiomeBaseFor(String mckey); Object getCustomBiomeBaseFor(String mckey);
Object getCustomBiomeBaseHolderFor(String mckey); Object getCustomBiomeBaseHolderFor(String mckey);
int getBiomeBaseIdForKey(String key);
String getKeyForBiomeBase(Object biomeBase); String getKeyForBiomeBase(Object biomeBase);
Object getBiomeBase(World world, Biome biome); Object getBiomeBase(World world, Biome biome);
@@ -83,4 +88,6 @@ public interface INMSBinding {
} }
MCAPaletteAccess createPalette(); MCAPaletteAccess createPalette();
void injectBiomesFromMantle(Chunk e, Mantle mantle);
} }

View File

@@ -0,0 +1,151 @@
package com.volmit.iris.core.nms.v19_3;
import com.mojang.serialization.Codec;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisBiomeCustom;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.math.RNG;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.biome.Climate;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R2.block.CraftBlock;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
public class CustomBiomeSource extends BiomeSource {
private final long seed;
private final Engine engine;
private final Registry<Biome> biomeCustomRegistry;
private final Registry<Biome> biomeRegistry;
private final AtomicCache<RegistryAccess> registryAccess = new AtomicCache<>();
private final RNG rng;
private final KMap<String, Holder<Biome>> customBiomes;
public CustomBiomeSource(long seed, Engine engine, World world) {
super(getAllBiomes(
((RegistryAccess) getFor(RegistryAccess.Frozen.class, ((CraftServer) Bukkit.getServer()).getHandle().getServer()))
.registry(Registries.BIOME).orElse(null),
((CraftWorld) world).getHandle().registryAccess().registry(Registries.BIOME).orElse(null),
engine));
this.engine = engine;
this.seed = seed;
this.biomeCustomRegistry = registry().registry(Registries.BIOME).orElse(null);
this.biomeRegistry = ((CraftWorld) world).getHandle().registryAccess().registry(Registries.BIOME).orElse(null);
this.rng = new RNG(engine.getSeedManager().getBiome());
this.customBiomes = fillCustomBiomes(biomeCustomRegistry, engine);
}
private static List<Holder<Biome>> getAllBiomes(Registry<Biome> customRegistry, Registry<Biome> registry, Engine engine) {
List<Holder<Biome>> b = new ArrayList<>();
for (IrisBiome i : engine.getAllBiomes()) {
if (i.isCustom()) {
for (IrisBiomeCustom j : i.getCustomDerivitives()) {
b.add(customRegistry.getHolder(customRegistry.getResourceKey(customRegistry
.get(new ResourceLocation(engine.getDimension().getLoadKey() + ":" + j.getId()))).get()).get());
}
} else {
b.add(CraftBlock.biomeToBiomeBase(registry, i.getVanillaDerivative()));
}
}
return b;
}
private static Object getFor(Class<?> type, Object source) {
Object o = fieldFor(type, source);
if (o != null) {
return o;
}
return invokeFor(type, source);
}
private static Object fieldFor(Class<?> returns, Object in) {
return fieldForClass(returns, in.getClass(), in);
}
private static Object invokeFor(Class<?> returns, Object in) {
for (Method i : in.getClass().getMethods()) {
if (i.getReturnType().equals(returns)) {
i.setAccessible(true);
try {
Iris.debug("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName() + "()");
return i.invoke(in);
} catch (Throwable e) {
e.printStackTrace();
}
}
}
return null;
}
@SuppressWarnings("unchecked")
private static <T> T fieldForClass(Class<T> returnType, Class<?> sourceType, Object in) {
for (Field i : sourceType.getDeclaredFields()) {
if (i.getType().equals(returnType)) {
i.setAccessible(true);
try {
Iris.debug("[NMS] Found " + returnType.getSimpleName() + " in " + sourceType.getSimpleName() + "." + i.getName());
return (T) i.get(in);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
return null;
}
private KMap<String, Holder<Biome>> fillCustomBiomes(Registry<Biome> customRegistry, Engine engine) {
KMap<String, Holder<Biome>> m = new KMap<>();
for (IrisBiome i : engine.getAllBiomes()) {
if (i.isCustom()) {
for (IrisBiomeCustom j : i.getCustomDerivitives()) {
m.put(j.getId(), customRegistry.getHolder(customRegistry.getResourceKey(customRegistry
.get(new ResourceLocation(engine.getDimension().getLoadKey() + ":" + j.getId()))).get()).get());
}
}
}
return m;
}
private RegistryAccess registry() {
return registryAccess.aquire(() -> (RegistryAccess) getFor(RegistryAccess.Frozen.class, ((CraftServer) Bukkit.getServer()).getHandle().getServer()));
}
@Override
protected Codec<? extends BiomeSource> codec() {
throw new UnsupportedOperationException("Not supported");
}
@Override
public Holder<Biome> getNoiseBiome(int x, int y, int z, Climate.Sampler sampler) {
int m = (y - engine.getMinHeight()) << 2;
IrisBiome ib = engine.getComplex().getTrueBiomeStream().get(x << 2, z << 2);
if (ib.isCustom()) {
return customBiomes.get(ib.getCustomBiome(rng, x << 2, m, z << 2).getId());
} else {
org.bukkit.block.Biome v = ib.getSkyBiome(rng, x << 2, m, z << 2);
return CraftBlock.biomeToBiomeBase(biomeRegistry, v);
}
}
}

View File

@@ -16,49 +16,40 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package com.volmit.iris.core.nms.v19_1; package com.volmit.iris.core.nms.v19_3;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMSBinding; import com.volmit.iris.core.nms.INMSBinding;
import com.volmit.iris.engine.data.cache.AtomicCache; import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.matter.MatterBiomeInject;
import com.volmit.iris.util.nbt.io.NBTUtil; import com.volmit.iris.util.nbt.io.NBTUtil;
import com.volmit.iris.util.nbt.mca.NBTWorld; import com.volmit.iris.util.nbt.mca.NBTWorld;
import com.volmit.iris.util.nbt.mca.palette.MCABiomeContainer; import com.volmit.iris.util.nbt.mca.palette.*;
import com.volmit.iris.util.nbt.mca.palette.MCAChunkBiomeContainer;
import com.volmit.iris.util.nbt.mca.palette.MCAGlobalPalette;
import com.volmit.iris.util.nbt.mca.palette.MCAIdMap;
import com.volmit.iris.util.nbt.mca.palette.MCAIdMapper;
import com.volmit.iris.util.nbt.mca.palette.MCAPalette;
import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess;
import com.volmit.iris.util.nbt.mca.palette.MCAPalettedContainer;
import com.volmit.iris.util.nbt.mca.palette.MCAWrappedPalettedContainer;
import com.volmit.iris.util.nbt.tag.CompoundTag; import com.volmit.iris.util.nbt.tag.CompoundTag;
import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.core.*; import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.NbtIo;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.BitStorage;
import net.minecraft.util.Mth;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.LevelChunkSection; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.Palette; import org.bukkit.*;
import net.minecraft.world.level.chunk.PalettedContainer;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_19_R2.CraftChunk;
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
import org.bukkit.craftbukkit.v1_19_R1.CraftServer; import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; import org.bukkit.craftbukkit.v1_19_R2.block.data.CraftBlockData;
import org.bukkit.craftbukkit.v1_19_R1.block.data.CraftBlockData;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -68,13 +59,12 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public class NMSBinding19_1 implements INMSBinding { public class NMSBinding19_3 implements INMSBinding {
private final KMap<Biome, Object> baseBiomeCache = new KMap<>(); private final KMap<Biome, Object> baseBiomeCache = new KMap<>();
private final BlockData AIR = Material.AIR.createBlockData(); private final BlockData AIR = Material.AIR.createBlockData();
@@ -85,6 +75,56 @@ public class NMSBinding19_1 implements INMSBinding {
private final AtomicCache<Method> byIdRef = new AtomicCache<>(); private final AtomicCache<Method> byIdRef = new AtomicCache<>();
private Field biomeStorageCache = null; private Field biomeStorageCache = null;
private static Object getFor(Class<?> type, Object source) {
Object o = fieldFor(type, source);
if (o != null) {
return o;
}
return invokeFor(type, source);
}
private static Object invokeFor(Class<?> returns, Object in) {
for (Method i : in.getClass().getMethods()) {
if (i.getReturnType().equals(returns)) {
i.setAccessible(true);
try {
Iris.debug("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName() + "()");
return i.invoke(in);
} catch (Throwable e) {
e.printStackTrace();
}
}
}
return null;
}
private static Object fieldFor(Class<?> returns, Object in) {
return fieldForClass(returns, in.getClass(), in);
}
@SuppressWarnings("unchecked")
private static <T> T fieldForClass(Class<T> returnType, Class<?> sourceType, Object in) {
for (Field i : sourceType.getDeclaredFields()) {
if (i.getType().equals(returnType)) {
i.setAccessible(true);
try {
Iris.debug("[NMS] Found " + returnType.getSimpleName() + " in " + sourceType.getSimpleName() + "." + i.getName());
return (T) i.get(in);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
return null;
}
private static Class<?> getClassType(Class<?> type, int ordinal) {
return type.getDeclaredClasses()[ordinal];
}
@Override @Override
public boolean hasTile(Location l) { public boolean hasTile(Location l) {
return ((CraftWorld) l.getWorld()).getHandle().getBlockEntity(new BlockPos(l.getBlockX(), l.getBlockY(), l.getBlockZ()), false) != null; return ((CraftWorld) l.getWorld()).getHandle().getBlockEntity(new BlockPos(l.getBlockX(), l.getBlockY(), l.getBlockZ()), false) != null;
@@ -157,32 +197,16 @@ public class NMSBinding19_1 implements INMSBinding {
private Registry<net.minecraft.world.level.biome.Biome> getCustomBiomeRegistry() { private Registry<net.minecraft.world.level.biome.Biome> getCustomBiomeRegistry() {
return registry().registry(Registry.BIOME_REGISTRY).orElse(null); return registry().registry(Registries.BIOME).orElse(null);
} }
private Registry<Block> getBlockRegistry() { private Registry<Block> getBlockRegistry() {
return registry().registry(Registry.BLOCK_REGISTRY).orElse(null); return registry().registry(Registries.BLOCK).orElse(null);
} }
@Override @Override
public Object getBiomeBaseFromId(int id) { public Object getBiomeBaseFromId(int id) {
try { return getCustomBiomeRegistry().getHolder(id);
return byIdRef.aquire(() -> {
for(Method i : IdMap.class.getDeclaredMethods()) {
if(i.getParameterCount() == 1 && i.getParameterTypes()[0].equals(int.class)) {
Iris.info("[NMS] Found byId method in " + IdMap.class.getSimpleName() + "." + i.getName() + "(int) => " + Biome.class.getSimpleName());
return i;
}
}
Iris.error("Cannot find byId method!");
return null;
}).invoke(getCustomBiomeRegistry(), id);
} catch(IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
return null;
} }
@Override @Override
@@ -197,7 +221,7 @@ public class NMSBinding19_1 implements INMSBinding {
@Override @Override
public int getTrueBiomeBaseId(Object biomeBase) { public int getTrueBiomeBaseId(Object biomeBase) {
return getCustomBiomeRegistry().getId((net.minecraft.world.level.biome.Biome) biomeBase); return getCustomBiomeRegistry().getId(((Holder<net.minecraft.world.level.biome.Biome>) biomeBase).value());
} }
@Override @Override
@@ -214,11 +238,16 @@ public class NMSBinding19_1 implements INMSBinding {
public Object getCustomBiomeBaseFor(String mckey) { public Object getCustomBiomeBaseFor(String mckey) {
return getCustomBiomeRegistry().get(new ResourceLocation(mckey)); return getCustomBiomeRegistry().get(new ResourceLocation(mckey));
} }
@Override @Override
public Object getCustomBiomeBaseHolderFor(String mckey) { public Object getCustomBiomeBaseHolderFor(String mckey) {
return getCustomBiomeRegistry().getHolder(getTrueBiomeBaseId(getCustomBiomeRegistry().get(new ResourceLocation(mckey)))).get(); return getCustomBiomeRegistry().getHolder(getTrueBiomeBaseId(getCustomBiomeRegistry().get(new ResourceLocation(mckey)))).get();
} }
public int getBiomeBaseIdForKey(String key) {
return getCustomBiomeRegistry().getId(getCustomBiomeRegistry().get(new ResourceLocation(key)));
}
@Override @Override
public String getKeyForBiomeBase(Object biomeBase) { public String getKeyForBiomeBase(Object biomeBase) {
return getCustomBiomeRegistry().getKey((net.minecraft.world.level.biome.Biome) biomeBase).getPath(); // something, not something:something return getCustomBiomeRegistry().getKey((net.minecraft.world.level.biome.Biome) biomeBase).getPath(); // something, not something:something
@@ -226,7 +255,8 @@ public class NMSBinding19_1 implements INMSBinding {
@Override @Override
public Object getBiomeBase(World world, Biome biome) { public Object getBiomeBase(World world, Biome biome) {
return getBiomeBase(((CraftWorld) world).getHandle().registryAccess().registry(Registry.BIOME_REGISTRY).orElse(null), biome); return org.bukkit.craftbukkit.v1_19_R2.block.CraftBlock.biomeToBiomeBase(((CraftWorld) world).getHandle()
.registryAccess().registry(Registries.BIOME).orElse(null), biome);
} }
@Override @Override
@@ -237,13 +267,13 @@ public class NMSBinding19_1 implements INMSBinding {
return v; return v;
} }
//noinspection unchecked //noinspection unchecked
v = org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, biome); v = org.bukkit.craftbukkit.v1_19_R2.block.CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, biome);
if (v == null) { if (v == null) {
// Ok so there is this new biome name called "CUSTOM" in Paper's new releases. // Ok so there is this new biome name called "CUSTOM" in Paper's new releases.
// But, this does NOT exist within CraftBukkit which makes it return an error. // But, this does NOT exist within CraftBukkit which makes it return an error.
// So, we will just return the ID that the plains biome returns instead. // So, we will just return the ID that the plains biome returns instead.
//noinspection unchecked //noinspection unchecked
return org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, Biome.PLAINS); return org.bukkit.craftbukkit.v1_19_R2.block.CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, Biome.PLAINS);
} }
baseBiomeCache.put(biome, v); baseBiomeCache.put(biome, v);
return v; return v;
@@ -258,7 +288,7 @@ public class NMSBinding19_1 implements INMSBinding {
public int getBiomeId(Biome biome) { public int getBiomeId(Biome biome) {
for (World i : Bukkit.getWorlds()) { for (World i : Bukkit.getWorlds()) {
if (i.getEnvironment().equals(World.Environment.NORMAL)) { if (i.getEnvironment().equals(World.Environment.NORMAL)) {
Registry<net.minecraft.world.level.biome.Biome> registry = ((CraftWorld) i).getHandle().registryAccess().registry(Registry.BIOME_REGISTRY).orElse(null); Registry<net.minecraft.world.level.biome.Biome> registry = ((CraftWorld) i).getHandle().registryAccess().registry(Registries.BIOME).orElse(null);
return registry.getId((net.minecraft.world.level.biome.Biome) getBiomeBase(registry, biome)); return registry.getId((net.minecraft.world.level.biome.Biome) getBiomeBase(registry, biome));
} }
} }
@@ -338,50 +368,24 @@ public class NMSBinding19_1 implements INMSBinding {
return true; return true;
} }
public void setBiomes(int cx, int cz, World world, Hunk<Object> biomes) {
LevelChunk c = ((CraftWorld) world).getHandle().getChunk(cx, cz);
biomes.iterateSync((x, y, z, b) -> c.setBiome(x, y, z, (Holder<net.minecraft.world.level.biome.Biome>) b));
c.setUnsaved(true);
}
@Override @Override
public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) { public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) {
try { try {
ChunkAccess s = (ChunkAccess) getFieldForBiomeStorage(chunk).get(chunk); ChunkAccess s = (ChunkAccess) getFieldForBiomeStorage(chunk).get(chunk);
Holder<net.minecraft.world.level.biome.Biome> biome = (Holder<net.minecraft.world.level.biome.Biome>) somethingVeryDirty; Holder<net.minecraft.world.level.biome.Biome> biome = (Holder<net.minecraft.world.level.biome.Biome>) somethingVeryDirty;
s.setBiome(x, y, z, biome); s.setBiome(x, y, z, biome);
/*int l = QuartPos.fromBlock(s.getMinBuildHeight());
int i1 = l + QuartPos.fromBlock(s.getHeight()) - 1;
PalettedContainer<Holder<net.minecraft.world.level.biome.Biome>> palette = getPalette(s, s.getSectionIndex(QuartPos.toBlock(Mth.clamp(y, l, i1))));
int index = getPaletteIndex(x, y, z, s, palette);
int data = getPaletteDataId(palette, biome);
setPaletteData(palette, index, data);*/
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
Iris.reportError(e); Iris.reportError(e);
e.printStackTrace(); e.printStackTrace();
} }
} }
private PalettedContainer<Holder<net.minecraft.world.level.biome.Biome>> getPalette(ChunkAccess ca, int index) {
LevelChunkSection[] sections = fieldForClass(LevelChunkSection[].class, ChunkAccess.class, ca);
return fieldForClass(PalettedContainer.class, LevelChunkSection.class, sections[index]);
}
private int getPaletteIndex(int x, int y, int z, ChunkAccess s, PalettedContainer<?> palette) {
int l = QuartPos.fromBlock(s.getMinBuildHeight());
int i1 = l + QuartPos.fromBlock(s.getHeight()) - 1;
int j1 = Mth.clamp(y, l, i1);
return fieldForClass(PalettedContainer.Strategy.class, PalettedContainer.class, palette).getIndex(x & 3, j1 & 3, z & 3);
}
private <T extends Holder<?>> int getPaletteDataId(PalettedContainer<T> palette, T data) throws ClassNotFoundException {
Class<?> dataType = getClassType(PalettedContainer.class, 1);
Object paletteData = fieldFor(dataType, palette);
Palette<T> fuckinFinally = fieldForClass(Palette.class,dataType, paletteData);
return fuckinFinally.idFor(data);
}
private void setPaletteData(PalettedContainer<?> palette, int index, int data) throws ClassNotFoundException {
Class<?> dataType = getClassType(PalettedContainer.class, 1);
Object paletteData = fieldFor(dataType, palette);
BitStorage storage = fieldForClass(BitStorage.class, dataType, paletteData);
storage.set(index, data);
}
private Field getFieldForBiomeStorage(Object storage) { private Field getFieldForBiomeStorage(Object storage) {
Field f = biomeStorageCache; Field f = biomeStorageCache;
@@ -428,53 +432,21 @@ public class NMSBinding19_1 implements INMSBinding {
i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState()); i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState());
} }
private static Object getFor(Class<?> type, Object source) { @Override
Object o = fieldFor(type, source); public void injectBiomesFromMantle(Chunk e, Mantle mantle) {
LevelChunk chunk = ((CraftChunk) e).getHandle();
if(o != null) { AtomicInteger c = new AtomicInteger();
return o; AtomicInteger r = new AtomicInteger();
} mantle.iterateChunk(e.getX(), e.getZ(), MatterBiomeInject.class, (x, y, z, b) -> {
if (b != null) {
return invokeFor(type, source); if (b.isCustom()) {
} chunk.setBiome(x, y, z, getCustomBiomeRegistry().getHolder(b.getBiomeId()).get());
c.getAndIncrement();
private static Object invokeFor(Class<?> returns, Object in) { } else {
for(Method i : in.getClass().getMethods()) { chunk.setBiome(x, y, z, (Holder<net.minecraft.world.level.biome.Biome>) getBiomeBase(e.getWorld(), b.getBiome()));
if(i.getReturnType().equals(returns)) { r.getAndIncrement();
i.setAccessible(true);
try {
Iris.debug("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName() + "()");
return i.invoke(in);
} catch(Throwable e) {
e.printStackTrace();
} }
} }
} });
return null;
}
private static Object fieldFor(Class<?> returns, Object in) {
return fieldForClass(returns, in.getClass(), in);
}
@SuppressWarnings("unchecked")
private static <T> T fieldForClass(Class<T> returnType, Class<?> sourceType, Object in) {
for(Field i : sourceType.getDeclaredFields()) {
if(i.getType().equals(returnType)) {
i.setAccessible(true);
try {
Iris.debug("[NMS] Found " + returnType.getSimpleName() + " in " + sourceType.getSimpleName() + "." + i.getName());
return (T) i.get(in);
} catch(IllegalAccessException e) {
e.printStackTrace();
}
}
}
return null;
}
private static Class<?> getClassType(Class<?> type, int ordinal) {
return type.getDeclaredClasses()[ordinal];
} }
} }

View File

@@ -20,9 +20,11 @@ package com.volmit.iris.core.nms.v1X;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMSBinding; import com.volmit.iris.core.nms.INMSBinding;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.nbt.mca.palette.MCABiomeContainer; import com.volmit.iris.util.nbt.mca.palette.MCABiomeContainer;
import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess; import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess;
import com.volmit.iris.util.nbt.tag.CompoundTag; import com.volmit.iris.util.nbt.tag.CompoundTag;
import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
@@ -57,6 +59,11 @@ public class NMSBinding1X implements INMSBinding {
return null; return null;
} }
@Override
public void injectBiomesFromMantle(Chunk e, Mantle mantle) {
}
@Override @Override
public void deserializeTile(CompoundTag s, Location newPosition) { public void deserializeTile(CompoundTag s, Location newPosition) {
@@ -117,6 +124,11 @@ public class NMSBinding1X implements INMSBinding {
return null; return null;
} }
@Override
public int getBiomeBaseIdForKey(String key) {
return 0;
}
@Override @Override
public String getKeyForBiomeBase(Object biomeBase) { public String getKeyForBiomeBase(Object biomeBase) {
return null; return null;

View File

@@ -54,8 +54,7 @@ public class IrisPack {
* Create an iris pack backed by a data folder * Create an iris pack backed by a data folder
* the data folder is assumed to be in the Iris/packs/NAME folder * the data folder is assumed to be in the Iris/packs/NAME folder
* *
* @param name * @param name the name
* the name
*/ */
public IrisPack(String name) { public IrisPack(String name) {
this(packsPack(name)); this(packsPack(name));
@@ -64,8 +63,7 @@ public class IrisPack {
/** /**
* Create an iris pack backed by a data folder * Create an iris pack backed by a data folder
* *
* @param folder * @param folder the folder of the pack. Must be a directory
* the folder of the pack. Must be a directory
*/ */
public IrisPack(File folder) { public IrisPack(File folder) {
this.folder = folder; this.folder = folder;
@@ -84,13 +82,10 @@ public class IrisPack {
/** /**
* Create a new pack from the input url * Create a new pack from the input url
* *
* @param sender * @param sender the sender
* the sender * @param url the url, or name, or really anything see IrisPackRepository.from(String)
* @param url
* the url, or name, or really anything see IrisPackRepository.from(String)
* @return the iris pack * @return the iris pack
* @throws IrisException * @throws IrisException fails
* fails
*/ */
public static Future<IrisPack> from(VolmitSender sender, String url) throws IrisException { public static Future<IrisPack> from(VolmitSender sender, String url) throws IrisException {
IrisPackRepository repo = IrisPackRepository.from(url); IrisPackRepository repo = IrisPackRepository.from(url);
@@ -108,13 +103,10 @@ public class IrisPack {
/** /**
* Create a pack from a repo * Create a pack from a repo
* *
* @param sender * @param sender the sender
* the sender * @param repo the repo
* @param repo
* the repo
* @return the pack * @return the pack
* @throws MalformedURLException * @throws MalformedURLException shit happens
* shit happens
*/ */
public static Future<IrisPack> from(VolmitSender sender, IrisPackRepository repo) throws MalformedURLException { public static Future<IrisPack> from(VolmitSender sender, IrisPackRepository repo) throws MalformedURLException {
CompletableFuture<IrisPack> pack = new CompletableFuture<>(); CompletableFuture<IrisPack> pack = new CompletableFuture<>();
@@ -127,11 +119,9 @@ public class IrisPack {
/** /**
* Create a blank pack with a given name * Create a blank pack with a given name
* *
* @param name * @param name the name of the pack
* the name of the pack
* @return the pack * @return the pack
* @throws IrisException * @throws IrisException if the pack already exists or another error
* if the pack already exists or another error
*/ */
public static IrisPack blank(String name) throws IrisException { public static IrisPack blank(String name) throws IrisException {
File f = packsPack(name); File f = packsPack(name);
@@ -159,8 +149,7 @@ public class IrisPack {
/** /**
* Get a packs pack folder for a name. Such that overworld would resolve as Iris/packs/overworld * Get a packs pack folder for a name. Such that overworld would resolve as Iris/packs/overworld
* *
* @param name * @param name the name
* the name
* @return the file path * @return the file path
*/ */
public static File packsPack(String name) { public static File packsPack(String name) {
@@ -243,8 +232,7 @@ public class IrisPack {
/** /**
* Install this pack into a world * Install this pack into a world
* *
* @param world * @param world the world to install into (world/iris/pack)
* the world to install into (world/iris/pack)
* @return the installed pack * @return the installed pack
*/ */
public IrisPack install(World world) throws IrisException { public IrisPack install(World world) throws IrisException {
@@ -254,8 +242,7 @@ public class IrisPack {
/** /**
* Install this pack into a world * Install this pack into a world
* *
* @param world * @param world the world to install into (world/iris/pack)
* the world to install into (world/iris/pack)
* @return the installed pack * @return the installed pack
*/ */
public IrisPack install(IrisWorld world) throws IrisException { public IrisPack install(IrisWorld world) throws IrisException {
@@ -265,8 +252,7 @@ public class IrisPack {
/** /**
* Install this pack into a world * Install this pack into a world
* *
* @param folder * @param folder the folder to install this pack into
* the folder to install this pack into
* @return the installed pack * @return the installed pack
*/ */
public IrisPack install(File folder) throws IrisException { public IrisPack install(File folder) throws IrisException {
@@ -289,8 +275,7 @@ public class IrisPack {
* Create a new pack using this pack as a template. The new pack will be renamed & have a renamed dimension * Create a new pack using this pack as a template. The new pack will be renamed & have a renamed dimension
* to match it. * to match it.
* *
* @param newName * @param newName the new pack name
* the new pack name
* @return the new IrisPack * @return the new IrisPack
*/ */
public IrisPack install(String newName) throws IrisException { public IrisPack install(String newName) throws IrisException {
@@ -345,8 +330,7 @@ public class IrisPack {
/** /**
* Find all files in this pack with the given extension * Find all files in this pack with the given extension
* *
* @param fileExtension * @param fileExtension the extension
* the extension
* @return the list of files * @return the list of files
*/ */
public KList<File> collectFiles(String fileExtension) { public KList<File> collectFiles(String fileExtension) {

View File

@@ -55,6 +55,7 @@ public class IrisPregenerator {
private final KSet<Position2> retry; private final KSet<Position2> retry;
private final KSet<Position2> net; private final KSet<Position2> net;
private final ChronoLatch cl; private final ChronoLatch cl;
private final ChronoLatch saveLatch = new ChronoLatch(30000);
public IrisPregenerator(PregenTask task, PregeneratorMethod generator, PregenListener listener) { public IrisPregenerator(PregenTask task, PregeneratorMethod generator, PregenListener listener) {
this.listener = listenify(listener); this.listener = listenify(listener);
@@ -140,6 +141,7 @@ public class IrisPregenerator {
generator.close(); generator.close();
ticker.interrupt(); ticker.interrupt();
listener.onClose(); listener.onClose();
getMantle().trim(0);
} }
private void visitRegion(int x, int z, boolean regions) { private void visitRegion(int x, int z, boolean regions) {
@@ -167,13 +169,23 @@ public class IrisPregenerator {
} else if (!regions) { } else if (!regions) {
hit = true; hit = true;
listener.onRegionGenerating(x, z); listener.onRegionGenerating(x, z);
PregenTask.iterateRegion(x, z, (xx, zz) -> generator.generateChunk(xx, zz, listener)); PregenTask.iterateRegion(x, z, (xx, zz) -> {
while (paused.get() && !shutdown.get()) {
J.sleep(50);
}
generator.generateChunk(xx, zz, listener);
});
} }
if (hit) { if (hit) {
listener.onRegionGenerated(x, z); listener.onRegionGenerated(x, z);
if (saveLatch.flip()) {
listener.onSaving(); listener.onSaving();
generator.save(); generator.save();
}
generatedRegions.add(pos); generatedRegions.add(pos);
checkRegions(); checkRegions();
} }

View File

@@ -0,0 +1,163 @@
package com.volmit.iris.core.pregenerator;
import com.google.gson.Gson;
import com.volmit.iris.Iris;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.math.Spiraler;
import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J;
import io.papermc.lib.PaperLib;
import lombok.Builder;
import lombok.Data;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldUnloadEvent;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
public class LazyPregenerator extends Thread implements Listener {
private final LazyPregenJob job;
private final File destination;
private final int maxPosition;
private final World world;
private final long rate;
private final ChronoLatch latch;
public LazyPregenerator(LazyPregenJob job, File destination) {
this.job = job;
this.destination = destination;
this.maxPosition = new Spiraler(job.getRadiusBlocks() * 2, job.getRadiusBlocks() * 2, (x, z) -> {
}).count();
this.world = Bukkit.getWorld(job.getWorld());
this.rate = Math.round((1D / (job.chunksPerMinute / 60D)) * 1000D);
this.latch = new ChronoLatch(60000);
}
public LazyPregenerator(File file) throws IOException {
this(new Gson().fromJson(IO.readAll(file), LazyPregenJob.class), file);
}
public static void loadLazyGenerators() {
for (World i : Bukkit.getWorlds()) {
File lazygen = new File(i.getWorldFolder(), "lazygen.json");
if (lazygen.exists()) {
try {
LazyPregenerator p = new LazyPregenerator(lazygen);
p.start();
Iris.info("Started Lazy Pregenerator: " + p.job);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
}
@EventHandler
public void on(WorldUnloadEvent e) {
if (e.getWorld().equals(world)) {
interrupt();
}
}
public void run() {
while (!interrupted()) {
J.sleep(rate);
tick();
}
try {
saveNow();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void tick() {
if (latch.flip()) {
save();
Iris.info("LazyGen: " + world.getName() + " RTT: " + Form.duration((Math.pow((job.radiusBlocks / 16D), 2) / job.chunksPerMinute) * 60 * 1000, 2));
}
if (job.getPosition() >= maxPosition) {
if (job.isHealing()) {
int pos = (job.getHealingPosition() + 1) % maxPosition;
job.setHealingPosition(pos);
tickRegenerate(getChunk(pos));
} else {
Iris.verbose("Completed Lazy Gen!");
interrupt();
}
} else {
int pos = job.getPosition() + 1;
job.setPosition(pos);
tickGenerate(getChunk(pos));
}
}
private void tickGenerate(Position2 chunk) {
if (PaperLib.isPaper()) {
PaperLib.getChunkAtAsync(world, chunk.getX(), chunk.getZ(), true).thenAccept((i) -> Iris.verbose("Generated Async " + chunk));
} else {
J.s(() -> world.getChunkAt(chunk.getX(), chunk.getZ()));
Iris.verbose("Generated " + chunk);
}
}
private void tickRegenerate(Position2 chunk) {
J.s(() -> world.regenerateChunk(chunk.getX(), chunk.getZ()));
Iris.verbose("Regenerated " + chunk);
}
public Position2 getChunk(int position) {
int p = -1;
AtomicInteger xx = new AtomicInteger();
AtomicInteger zz = new AtomicInteger();
Spiraler s = new Spiraler(job.getRadiusBlocks() * 2, job.getRadiusBlocks() * 2, (x, z) -> {
xx.set(x);
zz.set(z);
});
while (s.hasNext() && p++ < position) {
s.next();
}
return new Position2(xx.get(), zz.get());
}
public void save() {
J.a(() -> {
try {
saveNow();
} catch (Throwable e) {
e.printStackTrace();
}
});
}
public void saveNow() throws IOException {
IO.writeAll(this.destination, new Gson().toJson(job));
}
@Data
@Builder
public static class LazyPregenJob {
private String world;
@Builder.Default
private int healingPosition = 0;
@Builder.Default
private boolean healing = false;
@Builder.Default
private int chunksPerMinute = 32; // 48 hours is roughly 5000 radius
@Builder.Default
private int radiusBlocks = 5000;
@Builder.Default
private int position = 0;
}
}

View File

@@ -49,7 +49,7 @@ public class PregenTask {
} }
public static void iterateRegion(int xr, int zr, Spiraled s) { public static void iterateRegion(int xr, int zr, Spiraled s) {
iterateRegion(xr, zr, s, new Position2(0, 0)); iterateRegion(xr, zr, s, new Position2(-(xr << 5), -(zr << 5)));
} }
private static KList<Position2> computeOrder(Position2 pull) { private static KList<Position2> computeOrder(Position2 pull) {

View File

@@ -43,10 +43,8 @@ public interface PregeneratorMethod {
/** /**
* Return true if regions can be generated * Return true if regions can be generated
* *
* @param x * @param x the x region
* the x region * @param z the z region
* @param z
* the z region
* @return true if they can be * @return true if they can be
*/ */
boolean supportsRegions(int x, int z, PregenListener listener); boolean supportsRegions(int x, int z, PregenListener listener);
@@ -54,10 +52,8 @@ public interface PregeneratorMethod {
/** /**
* Return the name of the method being used * Return the name of the method being used
* *
* @param x * @param x the x region
* the x region * @param z the z region
* @param z
* the z region
* @return the name * @return the name
*/ */
String getMethod(int x, int z); String getMethod(int x, int z);
@@ -66,22 +62,17 @@ public interface PregeneratorMethod {
* Called to generate a region. Execute sync, if multicore internally, wait * Called to generate a region. Execute sync, if multicore internally, wait
* for the task to complete * for the task to complete
* *
* @param x * @param x the x
* the x * @param z the z
* @param z * @param listener signal chunks generating & generated. Parallel capable.
* the z
* @param listener
* signal chunks generating & generated. Parallel capable.
*/ */
void generateRegion(int x, int z, PregenListener listener); void generateRegion(int x, int z, PregenListener listener);
/** /**
* Called to generate a chunk. You can go async so long as save will wait on the threads to finish * Called to generate a chunk. You can go async so long as save will wait on the threads to finish
* *
* @param x * @param x the x
* the x * @param z the z
* @param z
* the z
*/ */
void generateChunk(int x, int z, PregenListener listener); void generateChunk(int x, int z, PregenListener listener);

View File

@@ -19,7 +19,6 @@
package com.volmit.iris.core.pregenerator.methods; package com.volmit.iris.core.pregenerator.methods;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.pregenerator.PregenListener; import com.volmit.iris.core.pregenerator.PregenListener;
import com.volmit.iris.core.pregenerator.PregeneratorMethod; import com.volmit.iris.core.pregenerator.PregeneratorMethod;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
@@ -31,6 +30,7 @@ import io.papermc.lib.PaperLib;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import java.util.Objects;
import java.util.concurrent.Future; import java.util.concurrent.Future;
public class AsyncPregenMethod implements PregeneratorMethod { public class AsyncPregenMethod implements PregeneratorMethod {
@@ -68,18 +68,44 @@ public class AsyncPregenMethod implements PregeneratorMethod {
private void completeChunk(int x, int z, PregenListener listener) { private void completeChunk(int x, int z, PregenListener listener) {
try { try {
PaperLib.getChunkAtAsync(world, x, z, true).get(); future.add(PaperLib.getChunkAtAsync(world, x, z, true).thenApply((i) -> {
if (i == null) {
}
listener.onChunkGenerated(x, z); listener.onChunkGenerated(x, z);
listener.onChunkCleaned(x, z); listener.onChunkCleaned(x, z);
return 0;
}));
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
J.sleep(5); }
future.add(burst.complete(() -> completeChunk(x, z, listener))); }
private void waitForChunksPartial(int maxWaiting) {
future.removeWhere(Objects::isNull);
while (future.size() > maxWaiting) {
try {
Future<?> i = future.remove(0);
if (i == null) {
continue;
}
i.get();
} catch (Throwable e) {
e.printStackTrace();
}
} }
} }
private void waitForChunks() { private void waitForChunks() {
for (Future<?> i : future.copy()) { for (Future<?> i : future.copy()) {
if (i == null) {
continue;
}
try { try {
i.get(); i.get();
future.remove(i); future.remove(i);
@@ -87,6 +113,8 @@ public class AsyncPregenMethod implements PregeneratorMethod {
e.printStackTrace(); e.printStackTrace();
} }
} }
future.removeWhere(Objects::isNull);
} }
@Override @Override
@@ -107,7 +135,7 @@ public class AsyncPregenMethod implements PregeneratorMethod {
@Override @Override
public void save() { public void save() {
waitForChunks(); waitForChunksPartial(256);
unloadAndSaveAllChunks(); unloadAndSaveAllChunks();
} }
@@ -123,11 +151,10 @@ public class AsyncPregenMethod implements PregeneratorMethod {
@Override @Override
public void generateChunk(int x, int z, PregenListener listener) { public void generateChunk(int x, int z, PregenListener listener) {
if(future.size() > IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism())) { // TODO: FIX
waitForChunks();
}
listener.onChunkGenerating(x, z); listener.onChunkGenerating(x, z);
if (future.size() > 256) {
waitForChunksPartial(256);
}
future.add(burst.complete(() -> completeChunk(x, z, listener))); future.add(burst.complete(() -> completeChunk(x, z, listener)));
} }

View File

@@ -18,17 +18,11 @@
package com.volmit.iris.core.pregenerator.methods; package com.volmit.iris.core.pregenerator.methods;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.pregenerator.PregenListener; import com.volmit.iris.core.pregenerator.PregenListener;
import com.volmit.iris.core.pregenerator.PregeneratorMethod; import com.volmit.iris.core.pregenerator.PregeneratorMethod;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.util.mantle.Mantle; import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.math.Position2;
import org.bukkit.World; import org.bukkit.World;
import java.io.File;
public class HybridPregenMethod implements PregeneratorMethod { public class HybridPregenMethod implements PregeneratorMethod {
private final PregeneratorMethod inWorld; private final PregeneratorMethod inWorld;
private final World world; private final World world;

View File

@@ -25,16 +25,7 @@ import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.loader.IrisRegistrant; import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.core.loader.ResourceLoader; import com.volmit.iris.core.loader.ResourceLoader;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.IrisBlockData;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisEntity;
import com.volmit.iris.engine.object.IrisGenerator;
import com.volmit.iris.engine.object.IrisLootTable;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.engine.object.IrisObjectPlacement;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.engine.object.IrisSpawner;
import com.volmit.iris.engine.object.annotations.Snippet; import com.volmit.iris.engine.object.annotations.Snippet;
import com.volmit.iris.engine.platform.PlatformChunkGenerator; import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
@@ -60,8 +51,7 @@ import org.bukkit.GameMode;
import org.bukkit.World; import org.bukkit.World;
import org.zeroturnaround.zip.ZipUtil; import org.zeroturnaround.zip.ZipUtil;
import java.awt.Desktop; import java.awt.*;
import java.awt.GraphicsEnvironment;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Objects; import java.util.Objects;

View File

@@ -22,17 +22,7 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.loader.IrisRegistrant; import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.core.loader.ResourceLoader; import com.volmit.iris.core.loader.ResourceLoader;
import com.volmit.iris.engine.object.annotations.ArrayType; import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MaxNumber;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListBlockType;
import com.volmit.iris.engine.object.annotations.RegistryListFont;
import com.volmit.iris.engine.object.annotations.RegistryListItemType;
import com.volmit.iris.engine.object.annotations.RegistryListResource;
import com.volmit.iris.engine.object.annotations.RegistryListSpecialEntity;
import com.volmit.iris.engine.object.annotations.Required;
import com.volmit.iris.engine.object.annotations.Snippet;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.data.B; import com.volmit.iris.util.data.B;
@@ -41,7 +31,7 @@ import com.volmit.iris.util.json.JSONObject;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import java.awt.GraphicsEnvironment; import java.awt.*;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.List; import java.util.List;
@@ -52,7 +42,7 @@ public class SchemaBuilder {
private static final String SYMBOL_LIMIT__N = "*"; private static final String SYMBOL_LIMIT__N = "*";
private static final String SYMBOL_TYPE__N = ""; private static final String SYMBOL_TYPE__N = "";
private static final JSONArray POTION_TYPES = getPotionTypes(); private static final JSONArray POTION_TYPES = getPotionTypes();
private static final JSONArray ENCHANT_TYPES = getEnchantmentTypes(); private static final JSONArray ENCHANT_TYPES = getEnchantTypes();
private static final JSONArray ITEM_TYPES = new JSONArray(B.getItemTypes()); private static final JSONArray ITEM_TYPES = new JSONArray(B.getItemTypes());
private static final JSONArray FONT_TYPES = new JSONArray(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()); private static final JSONArray FONT_TYPES = new JSONArray(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
private final KMap<String, JSONObject> definitions; private final KMap<String, JSONObject> definitions;
@@ -67,16 +57,6 @@ public class SchemaBuilder {
this.root = root; this.root = root;
} }
private static JSONArray getEnchantmentTypes() {
JSONArray a = new JSONArray();
for(Field gg : Enchantment.class.getDeclaredFields()) {
a.put(gg.getName());
}
return a;
}
private static JSONArray getPotionTypes() { private static JSONArray getPotionTypes() {
JSONArray a = new JSONArray(); JSONArray a = new JSONArray();
@@ -87,6 +67,14 @@ public class SchemaBuilder {
return a; return a;
} }
private static JSONArray getEnchantTypes() {
JSONArray array = new JSONArray();
for (Enchantment e : Enchantment.values()) {
array.put(e.getKey().getKey());
}
return array;
}
public JSONObject construct() { public JSONObject construct() {
JSONObject schema = new JSONObject(); JSONObject schema = new JSONObject();
schema.put("$schema", "http://json-schema.org/draft-07/schema#"); schema.put("$schema", "http://json-schema.org/draft-07/schema#");
@@ -309,7 +297,7 @@ public class SchemaBuilder {
prop.put("$ref", "#/definitions/" + key); prop.put("$ref", "#/definitions/" + key);
description.add(SYMBOL_TYPE__N + " Must be a valid Font Family (use ctrl+space for auto complete!)"); description.add(SYMBOL_TYPE__N + " Must be a valid Font Family (use ctrl+space for auto complete!)");
} else if(k.getType().equals(Enchantment.class)) { } else if (k.isAnnotationPresent(RegistryListEnchantment.class)) {
String key = "enum-enchantment"; String key = "enum-enchantment";
if (!definitions.containsKey(key)) { if (!definitions.containsKey(key)) {
@@ -483,7 +471,7 @@ public class SchemaBuilder {
items.put("$ref", "#/definitions/" + key); items.put("$ref", "#/definitions/" + key);
prop.put("items", items); prop.put("items", items);
description.add(SYMBOL_TYPE__N + " Must be a valid Font Family (use ctrl+space for auto complete!)"); description.add(SYMBOL_TYPE__N + " Must be a valid Font Family (use ctrl+space for auto complete!)");
} else if(t.type().equals(Enchantment.class)) { } else if (k.isAnnotationPresent(RegistryListEnchantment.class)) {
fancyType = "List of Enchantment Types"; fancyType = "List of Enchantment Types";
String key = "enum-enchantment"; String key = "enum-enchantment";
@@ -552,7 +540,8 @@ public class SchemaBuilder {
warnings.add("Undefined array type for field " + k.getName() + " (" + k.getType().getSimpleName() + ") in class " + cl.getSimpleName()); warnings.add("Undefined array type for field " + k.getName() + " (" + k.getType().getSimpleName() + ") in class " + cl.getSimpleName());
} }
} }
default -> warnings.add("Unexpected Schema Type: " + type + " for field " + k.getName() + " (" + k.getType().getSimpleName() + ") in class " + cl.getSimpleName()); default ->
warnings.add("Unexpected Schema Type: " + type + " for field " + k.getName() + " (" + k.getType().getSimpleName() + ") in class " + cl.getSimpleName());
} }
KList<String> d = new KList<>(); KList<String> d = new KList<>();

View File

@@ -38,8 +38,8 @@ import java.util.concurrent.CompletableFuture;
public class CommandSVC implements IrisService, DecreeSystem { public class CommandSVC implements IrisService, DecreeSystem {
private final KMap<String, CompletableFuture<String>> futures = new KMap<>(); private final KMap<String, CompletableFuture<String>> futures = new KMap<>();
private CompletableFuture<String> consoleFuture = null;
private final transient AtomicCache<VirtualDecreeCommand> commandCache = new AtomicCache<>(); private final transient AtomicCache<VirtualDecreeCommand> commandCache = new AtomicCache<>();
private CompletableFuture<String> consoleFuture = null;
@Override @Override
public void onEnable() { public void onEnable() {

View File

@@ -20,12 +20,7 @@ package com.volmit.iris.core.service;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.IrisDirection; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.IrisJigsawPiece;
import com.volmit.iris.engine.object.IrisJigsawPieceConnector;
import com.volmit.iris.engine.object.IrisJigsawPool;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.engine.object.IrisPosition;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;

View File

@@ -19,13 +19,27 @@
package com.volmit.iris.core.service; package com.volmit.iris.core.service;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.documentation.ChunkCoordinates;
import com.volmit.iris.util.function.Consumer4;
import com.volmit.iris.util.math.Spiraler;
import com.volmit.iris.util.matter.MatterStructurePOI;
import com.volmit.iris.util.plugin.IrisService; import com.volmit.iris.util.plugin.IrisService;
import net.minecraft.core.BlockPos;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftDolphin;
import org.bukkit.entity.Dolphin;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.generator.structure.StructureType;
import java.util.concurrent.atomic.AtomicReference;
public class DolphinSVC implements IrisService { public class DolphinSVC implements IrisService {
@Override @Override
public void onEnable() { public void onEnable() {
@@ -36,10 +50,6 @@ public class DolphinSVC implements IrisService {
} }
/**
* Prevents dolphins from being fed, to locate a treasure map.
* Note: This results in odd dolphin behaviour, but it's the best we can do.
*/
@EventHandler @EventHandler
public void on(PlayerInteractEntityEvent event) { public void on(PlayerInteractEntityEvent event) {
if (!IrisToolbelt.isIrisWorld(event.getPlayer().getWorld())) { if (!IrisToolbelt.isIrisWorld(event.getPlayer().getWorld())) {
@@ -48,7 +58,38 @@ public class DolphinSVC implements IrisService {
Material hand = event.getPlayer().getInventory().getItem(event.getHand()).getType(); Material hand = event.getPlayer().getInventory().getItem(event.getHand()).getType();
if (event.getRightClicked().getType().equals(EntityType.DOLPHIN) && (hand.equals(Material.TROPICAL_FISH) || hand.equals(Material.PUFFERFISH) || hand.equals(Material.COD) || hand.equals(Material.SALMON))) { if (event.getRightClicked().getType().equals(EntityType.DOLPHIN) && (hand.equals(Material.TROPICAL_FISH) || hand.equals(Material.PUFFERFISH) || hand.equals(Material.COD) || hand.equals(Material.SALMON))) {
Engine e = IrisToolbelt.access(event.getPlayer().getWorld()).getEngine();
searchNearestTreasure(e, event.getPlayer().getLocation().getBlockX() >> 4, event.getPlayer().getLocation().getBlockZ() >> 4, e.getMantle().getRadius() - 1, StructureType.BURIED_TREASURE, (x, y, z, p) -> {
event.setCancelled(true); event.setCancelled(true);
Dolphin d = (Dolphin) event.getRightClicked();
CraftDolphin cd = (CraftDolphin) d;
d.getWorld().playSound(d, Sound.ENTITY_DOLPHIN_EAT, SoundCategory.NEUTRAL, 1, 1);
cd.getHandle().setTreasurePos(new BlockPos(x, y, z));
cd.getHandle().setGotFish(true);
});
} }
} }
@ChunkCoordinates
public void findTreasure(Engine engine, int chunkX, int chunkY, StructureType type, Consumer4<Integer, Integer, Integer, MatterStructurePOI> consumer) {
AtomicReference<MatterStructurePOI> ref = new AtomicReference<>();
engine.getMantle().getMantle().iterateChunk(chunkX, chunkY, MatterStructurePOI.class, ref.get() == null ? (x, y, z, d) -> {
if (d.getType().equals(type.getKey().getKey())) {
ref.set(d);
consumer.accept(x, y, z, d);
}
} : (x, y, z, d) -> {
});
}
@ChunkCoordinates
public void searchNearestTreasure(Engine engine, int chunkX, int chunkY, int radius, StructureType type, Consumer4<Integer, Integer, Integer, MatterStructurePOI> consumer) {
AtomicReference<MatterStructurePOI> ref = new AtomicReference<>();
new Spiraler(radius * 2, radius * 2, (x, z) -> findTreasure(engine, x, z, type, ref.get() == null ? (i, d, g, a) -> {
ref.set(a);
consumer.accept(i, d, g, a);
} : (i, d, g, a) -> {
})).setOffset(chunkX, chunkY).drain();
}
} }

View File

@@ -43,7 +43,8 @@ public class ExternalDataSVC implements IrisService {
} }
@Override @Override
public void onDisable() { } public void onDisable() {
}
public void addProvider(ExternalDataProvider... provider) { public void addProvider(ExternalDataProvider... provider) {
for (ExternalDataProvider p : provider) { for (ExternalDataProvider p : provider) {

View File

@@ -23,35 +23,97 @@ public class LogFilterSVC implements IrisService, Filter {
((Logger) LogManager.getRootLogger()).addFilter(this); ((Logger) LogManager.getRootLogger()).addFilter(this);
} }
public void initialize() { } public void initialize() {
public void start() { }
public void stop() { }
public void onDisable() { }
public boolean isStarted() { return true; }
public boolean isStopped() { return false; }
public State getState() {
try { return State.STARTED; }
catch (Exception var2) { return null; }
} }
public Filter.Result getOnMatch() { return Result.NEUTRAL; } public void start() {
public Filter.Result getOnMismatch() { return Result.NEUTRAL; } }
public Result filter(LogEvent event) { return check(event.getMessage().getFormattedMessage()); } public void stop() {
public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) { return check(msg.toString()); } }
public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) { return check(msg.getFormattedMessage()); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object... params) { return check(message); } public void onDisable() {
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0) { return check(message); } }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2) { return check(message); } public boolean isStarted() {
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3) { return check(message); } return true;
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4) { return check(message); } }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6) { return check(message); } public boolean isStopped() {
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7) { return check(message); } return false;
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7, Object p8) { return check(message); } }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7, Object p8, Object p9) { return check(message); }
public State getState() {
try {
return State.STARTED;
} catch (Exception var2) {
return null;
}
}
public Filter.Result getOnMatch() {
return Result.NEUTRAL;
}
public Filter.Result getOnMismatch() {
return Result.NEUTRAL;
}
public Result filter(LogEvent event) {
return check(event.getMessage().getFormattedMessage());
}
public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) {
return check(msg.toString());
}
public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
return check(msg.getFormattedMessage());
}
public Result filter(Logger logger, Level level, Marker marker, String message, Object... params) {
return check(message);
}
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0) {
return check(message);
}
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1) {
return check(message);
}
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2) {
return check(message);
}
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3) {
return check(message);
}
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4) {
return check(message);
}
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) {
return check(message);
}
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6) {
return check(message);
}
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7) {
return check(message);
}
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7, Object p8) {
return check(message);
}
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7, Object p8, Object p9) {
return check(message);
}
private Result check(String string) { private Result check(String string) {
if (FILTERS.stream().anyMatch(string::contains)) if (FILTERS.stream().anyMatch(string::contains))

View File

@@ -65,8 +65,7 @@ public class ObjectSVC implements IrisService {
/** /**
* Reverts all the block changes provided, 200 blocks per tick * Reverts all the block changes provided, 200 blocks per tick
* *
* @param blocks * @param blocks The blocks to remove
* The blocks to remove
*/ */
private void revert(Map<Block, BlockData> blocks) { private void revert(Map<Block, BlockData> blocks) {
int amount = 0; int amount = 0;

View File

@@ -36,8 +36,8 @@ import java.util.stream.Collectors;
public class PreservationSVC implements IrisService { public class PreservationSVC implements IrisService {
private final List<Thread> threads = new CopyOnWriteArrayList<>(); private final List<Thread> threads = new CopyOnWriteArrayList<>();
private final List<ExecutorService> services = new CopyOnWriteArrayList<>(); private final List<ExecutorService> services = new CopyOnWriteArrayList<>();
private Looper dereferencer;
private final List<MeteredCache> caches = new CopyOnWriteArrayList<>(); private final List<MeteredCache> caches = new CopyOnWriteArrayList<>();
private Looper dereferencer;
public void register(Thread t) { public void register(Thread t) {
threads.add(t); threads.add(t);

View File

@@ -57,7 +57,7 @@ public class StudioSVC implements IrisService {
@Override @Override
public void onEnable() { public void onEnable() {
J.a(() -> { J.s(() -> {
String pack = IrisSettings.get().getGenerator().getDefaultWorldType(); String pack = IrisSettings.get().getGenerator().getDefaultWorldType();
File f = IrisPack.packsPack(pack); File f = IrisPack.packsPack(pack);
@@ -171,7 +171,7 @@ public class StudioSVC implements IrisService {
String[] nodes = url.split("\\Q/\\E"); String[] nodes = url.split("\\Q/\\E");
String repo = nodes.length == 1 ? "IrisDimensions/" + nodes[0] : nodes[0] + "/" + nodes[1]; String repo = nodes.length == 1 ? "IrisDimensions/" + nodes[0] : nodes[0] + "/" + nodes[1];
branch = nodes.length > 2 ? nodes[2] : branch; branch = nodes.length > 2 ? nodes[2] : branch;
download(sender, repo, branch, trim, forceOverwrite); download(sender, repo, branch, trim, forceOverwrite, false);
} catch (Throwable e) { } catch (Throwable e) {
Iris.reportError(e); Iris.reportError(e);
e.printStackTrace(); e.printStackTrace();
@@ -179,12 +179,22 @@ public class StudioSVC implements IrisService {
} }
} }
public void download(VolmitSender sender, String repo, String branch, boolean trim) throws JsonSyntaxException, IOException { public void downloadRelease(VolmitSender sender, String url, boolean trim, boolean forceOverwrite) {
download(sender, repo, branch, trim, false); try {
download(sender, "IrisDimensions", url, trim, forceOverwrite, true);
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
sender.sendMessage("Failed to download 'IrisDimensions/overworld' from " + url + ".");
}
} }
public void download(VolmitSender sender, String repo, String branch, boolean trim, boolean forceOverwrite) throws JsonSyntaxException, IOException { public void download(VolmitSender sender, String repo, String branch, boolean trim) throws JsonSyntaxException, IOException {
String url = "https://codeload.github.com/" + repo + "/zip/refs/heads/" + branch; download(sender, repo, branch, trim, false, false);
}
public void download(VolmitSender sender, String repo, String branch, boolean trim, boolean forceOverwrite, boolean directUrl) throws JsonSyntaxException, IOException {
String url = directUrl ? branch : "https://codeload.github.com/" + repo + "/zip/refs/heads/" + branch;
sender.sendMessage("Downloading " + url + " "); //The extra space stops a bug in adventure API from repeating the last letter of the URL sender.sendMessage("Downloading " + url + " "); //The extra space stops a bug in adventure API from repeating the last letter of the URL
File zip = Iris.getNonCachedFile("pack-" + trim + "-" + repo, url); File zip = Iris.getNonCachedFile("pack-" + trim + "-" + repo, url);
File temp = Iris.getTemp(); File temp = Iris.getTemp();

View File

@@ -22,15 +22,7 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IObjectPlacer; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.engine.object.IrisObjectPlacement;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.engine.object.IrisTreeModes;
import com.volmit.iris.engine.object.IrisTreeSize;
import com.volmit.iris.engine.object.TileData;
import com.volmit.iris.engine.platform.PlatformChunkGenerator; import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
@@ -39,12 +31,7 @@ import com.volmit.iris.util.math.BlockPosition;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.plugin.IrisService; import com.volmit.iris.util.plugin.IrisService;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import org.bukkit.Bukkit; import org.bukkit.*;
import org.bukkit.HeightMap;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.TreeType;
import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.TileState; import org.bukkit.block.TileState;
@@ -79,8 +66,7 @@ public class TreeSVC implements IrisService {
* <br>4. Check biome, region and dimension for overrides for that sapling type -> Found -> use</br> * <br>4. Check biome, region and dimension for overrides for that sapling type -> Found -> use</br>
* <br>5. Exit if none are found, cancel event if one or more are.</br> * <br>5. Exit if none are found, cancel event if one or more are.</br>
* *
* @param event * @param event Checks the given event for sapling overrides
* Checks the given event for sapling overrides
*/ */
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void on(StructureGrowEvent event) { public void on(StructureGrowEvent event) {
@@ -242,14 +228,10 @@ public class TreeSVC implements IrisService {
* Finds a single object placement (which may contain more than one object) for the requirements species, location & * Finds a single object placement (which may contain more than one object) for the requirements species, location &
* size * size
* *
* @param worldAccess * @param worldAccess The world to access (check for biome, region, dimension, etc)
* The world to access (check for biome, region, dimension, etc) * @param location The location of the growth event (For biome/region finding)
* @param location * @param type The bukkit TreeType to match
* The location of the growth event (For biome/region finding) * @param size The size of the sapling area
* @param type
* The bukkit TreeType to match
* @param size
* The size of the sapling area
* @return An object placement which contains the matched tree, or null if none were found / it's disabled. * @return An object placement which contains the matched tree, or null if none were found / it's disabled.
*/ */
private IrisObjectPlacement getObjectPlacement(PlatformChunkGenerator worldAccess, Location location, TreeType type, IrisTreeSize size) { private IrisObjectPlacement getObjectPlacement(PlatformChunkGenerator worldAccess, Location location, TreeType type, IrisTreeSize size) {
@@ -274,12 +256,9 @@ public class TreeSVC implements IrisService {
/** /**
* Filters out mismatches and returns matches * Filters out mismatches and returns matches
* *
* @param objects * @param objects The object placements to check
* The object placements to check * @param size The size of the sapling area to filter with
* @param size * @param type The type of the tree to filter with
* The size of the sapling area to filter with
* @param type
* The type of the tree to filter with
* @return A list of objectPlacements that matched. May be empty. * @return A list of objectPlacements that matched. May be empty.
*/ */
private KList<IrisObjectPlacement> matchObjectPlacements(KList<IrisObjectPlacement> objects, IrisTreeSize size, TreeType type) { private KList<IrisObjectPlacement> matchObjectPlacements(KList<IrisObjectPlacement> objects, IrisTreeSize size, TreeType type) {
@@ -298,12 +277,9 @@ public class TreeSVC implements IrisService {
/** /**
* Get the Cuboid of sapling sizes at a location & blockData predicate * Get the Cuboid of sapling sizes at a location & blockData predicate
* *
* @param at * @param at this location
* this location * @param valid with this blockData predicate
* @param valid * @param world the world to check in
* with this blockData predicate
* @param world
* the world to check in
* @return A cuboid containing only saplings * @return A cuboid containing only saplings
*/ */
public Cuboid getSaplings(Location at, Predicate<BlockData> valid, World world) { public Cuboid getSaplings(Location at, Predicate<BlockData> valid, World world) {
@@ -355,14 +331,10 @@ public class TreeSVC implements IrisService {
/** /**
* Grows the blockPosition list by means of checking neighbours in * Grows the blockPosition list by means of checking neighbours in
* *
* @param world * @param world the world to check in
* the world to check in * @param center the location of this position
* @param center * @param valid validation on blockData to check block with
* the location of this position * @param l list of block positions to add new neighbors too
* @param valid
* validation on blockData to check block with
* @param l
* list of block positions to add new neighbors too
*/ */
private void grow(World world, BlockPosition center, Predicate<BlockData> valid, KList<BlockPosition> l) { private void grow(World world, BlockPosition center, Predicate<BlockData> valid, KList<BlockPosition> l) {
// Make sure size is less than 50, the block to check isn't already in, and make sure the blockData still matches // Make sure size is less than 50, the block to check isn't already in, and make sure the blockData still matches

View File

@@ -21,17 +21,13 @@ package com.volmit.iris.core.service;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.IrisDimension; import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisVillagerOverride;
import com.volmit.iris.engine.object.IrisVillagerTrade;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.plugin.IrisService; import com.volmit.iris.util.plugin.IrisService;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Villager; import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.VillagerAcquireTradeEvent;
import org.bukkit.event.entity.VillagerCareerChangeEvent; import org.bukkit.event.entity.VillagerCareerChangeEvent;
import java.util.List; import java.util.List;

View File

@@ -33,11 +33,7 @@ import com.volmit.iris.util.matter.WorldMatter;
import com.volmit.iris.util.plugin.IrisService; import com.volmit.iris.util.plugin.IrisService;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import org.bukkit.Bukkit; import org.bukkit.*;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -66,8 +62,7 @@ public class WandSVC implements IrisService {
/** /**
* Creates an Iris Object from the 2 coordinates selected with a wand * Creates an Iris Object from the 2 coordinates selected with a wand
* *
* @param p * @param p The wand player
* The wand player
* @return The new object * @return The new object
*/ */
public static IrisObject createSchematic(Player p) { public static IrisObject createSchematic(Player p) {
@@ -122,8 +117,7 @@ public class WandSVC implements IrisService {
/** /**
* Converts a user friendly location string to an actual Location * Converts a user friendly location string to an actual Location
* *
* @param s * @param s The string
* The string
* @return The location * @return The location
*/ */
public static Location stringToLocation(String s) { public static Location stringToLocation(String s) {
@@ -140,8 +134,7 @@ public class WandSVC implements IrisService {
/** /**
* Get a user friendly string of a location * Get a user friendly string of a location
* *
* @param loc * @param loc The location
* The location
* @return The string * @return The string
*/ */
public static String locationToString(Location loc) { public static String locationToString(Location loc) {
@@ -182,8 +175,7 @@ public class WandSVC implements IrisService {
/** /**
* Finds an existing wand in a users inventory * Finds an existing wand in a users inventory
* *
* @param inventory * @param inventory The inventory to search
* The inventory to search
* @return The slot number the wand is in. Or -1 if none are found * @return The slot number the wand is in. Or -1 if none are found
*/ */
public static int findWand(Inventory inventory) { public static int findWand(Inventory inventory) {
@@ -207,10 +199,8 @@ public class WandSVC implements IrisService {
/** /**
* Creates an Iris wand. The locations should be the currently selected locations, or null * Creates an Iris wand. The locations should be the currently selected locations, or null
* *
* @param a * @param a Location A
* Location A * @param b Location B
* @param b
* Location B
* @return A new wand * @return A new wand
*/ */
public static ItemStack createWand(Location a, Location b) { public static ItemStack createWand(Location a, Location b) {
@@ -232,15 +222,13 @@ public class WandSVC implements IrisService {
} }
public static Location[] getCuboid(Player p) { public static Location[] getCuboid(Player p) {
if(isHoldingIrisWand(p)) if (isHoldingIrisWand(p)) {
{
return getCuboidFromItem(p.getInventory().getItemInMainHand()); return getCuboidFromItem(p.getInventory().getItemInMainHand());
} }
Cuboid c = WorldEditLink.getSelection(p); Cuboid c = WorldEditLink.getSelection(p);
if(c != null) if (c != null) {
{
return new Location[]{c.getLowerNE(), c.getUpperSW()}; return new Location[]{c.getLowerNE(), c.getUpperSW()};
} }
@@ -259,8 +247,7 @@ public class WandSVC implements IrisService {
/** /**
* Is the itemstack passed an Iris wand * Is the itemstack passed an Iris wand
* *
* @param is * @param is The itemstack
* The itemstack
* @return True if it is * @return True if it is
*/ */
public static boolean isWand(ItemStack is) { public static boolean isWand(ItemStack is) {
@@ -307,10 +294,8 @@ public class WandSVC implements IrisService {
/** /**
* Draw the outline of a selected region * Draw the outline of a selected region
* *
* @param d * @param d The cuboid
* The cuboid * @param p The player to show it to
* @param p
* The player to show it to
*/ */
public void draw(Cuboid d, Player p) { public void draw(Cuboid d, Player p) {
draw(new Location[]{d.getLowerNE(), d.getUpperSW()}, p); draw(new Location[]{d.getLowerNE(), d.getUpperSW()}, p);
@@ -319,10 +304,8 @@ public class WandSVC implements IrisService {
/** /**
* Draw the outline of a selected region * Draw the outline of a selected region
* *
* @param d * @param d A pair of locations
* A pair of locations * @param p The player to show them to
* @param p
* The player to show them to
*/ */
public void draw(Location[] d, Player p) { public void draw(Location[] d, Player p) {
Vector gx = Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65); Vector gx = Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65);
@@ -427,8 +410,7 @@ public class WandSVC implements IrisService {
/** /**
* Is the player holding Dust? * Is the player holding Dust?
* *
* @param p * @param p The player
* The player
* @return True if they are * @return True if they are
*/ */
public boolean isHoldingDust(Player p) { public boolean isHoldingDust(Player p) {
@@ -439,8 +421,7 @@ public class WandSVC implements IrisService {
/** /**
* Is the itemstack passed Iris dust? * Is the itemstack passed Iris dust?
* *
* @param is * @param is The itemstack
* The itemstack
* @return True if it is * @return True if it is
*/ */
public boolean isDust(ItemStack is) { public boolean isDust(ItemStack is) {
@@ -450,12 +431,9 @@ public class WandSVC implements IrisService {
/** /**
* Update the location on an Iris wand * Update the location on an Iris wand
* *
* @param left * @param left True for first location, false for second
* True for first location, false for second * @param a The location
* @param a * @param item The wand
* The location
* @param item
* The wand
* @return The updated wand * @return The updated wand
*/ */
public ItemStack update(boolean left, Location a, ItemStack item) { public ItemStack update(boolean left, Location a, ItemStack item) {

View File

@@ -21,6 +21,7 @@ package com.volmit.iris.core.tools;
import com.google.common.util.concurrent.AtomicDouble; import com.google.common.util.concurrent.AtomicDouble;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.ServerConfigurator;
import com.volmit.iris.core.pregenerator.PregenTask; import com.volmit.iris.core.pregenerator.PregenTask;
import com.volmit.iris.core.service.StudioSVC; import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.engine.object.IrisDimension; import com.volmit.iris.engine.object.IrisDimension;
@@ -33,13 +34,12 @@ import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.O; import com.volmit.iris.util.scheduling.O;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.bukkit.Bukkit; import org.bukkit.*;
import org.bukkit.GameRule; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.Location; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
@@ -51,32 +51,28 @@ import java.util.function.Supplier;
@Data @Data
@Accessors(fluent = true, chain = true) @Accessors(fluent = true, chain = true)
public class IrisCreator { public class IrisCreator {
private static final File BUKKIT_YML = new File(Bukkit.getServer().getWorldContainer(), "bukkit.yml");
/** /**
* Specify an area to pregenerate during creation * Specify an area to pregenerate during creation
*/ */
private PregenTask pregen; private PregenTask pregen;
/** /**
* Specify a sender to get updates & progress info + tp when world is created. * Specify a sender to get updates & progress info + tp when world is created.
*/ */
private VolmitSender sender; private VolmitSender sender;
/** /**
* The seed to use for this generator * The seed to use for this generator
*/ */
private long seed = 1337; private long seed = 1337;
/** /**
* The dimension to use. This can be any online dimension, or a dimension in the * The dimension to use. This can be any online dimension, or a dimension in the
* packs folder * packs folder
*/ */
private String dimension = IrisSettings.get().getGenerator().getDefaultWorldType(); private String dimension = IrisSettings.get().getGenerator().getDefaultWorldType();
/** /**
* The name of this world. * The name of this world.
*/ */
private String name = "irisworld"; private String name = "irisworld";
/** /**
* Studio mode makes the engine hotloadable and uses the dimension in * Studio mode makes the engine hotloadable and uses the dimension in
* your Iris/packs folder instead of copying the dimension files into * your Iris/packs folder instead of copying the dimension files into
@@ -84,12 +80,25 @@ public class IrisCreator {
*/ */
private boolean studio = false; private boolean studio = false;
public static boolean removeFromBukkitYml(String name) throws IOException {
YamlConfiguration yml = YamlConfiguration.loadConfiguration(BUKKIT_YML);
ConfigurationSection section = yml.getConfigurationSection("worlds");
if (section == null) {
return false;
}
section.set(name, null);
if (section.getValues(false).keySet().stream().noneMatch(k -> section.get(k) != null)) {
yml.set("worlds", null);
}
yml.save(BUKKIT_YML);
return true;
}
/** /**
* Create the IrisAccess (contains the world) * Create the IrisAccess (contains the world)
* *
* @return the IrisAccess * @return the IrisAccess
* @throws IrisException * @throws IrisException shit happens
* shit happens
*/ */
public World create() throws IrisException { public World create() throws IrisException {
if (Bukkit.isPrimaryThread()) { if (Bukkit.isPrimaryThread()) {
@@ -102,6 +111,9 @@ public class IrisCreator {
throw new IrisException("Dimension cannot be found null for id " + dimension()); throw new IrisException("Dimension cannot be found null for id " + dimension());
} }
if (sender == null)
sender = Iris.getSender();
if (!studio()) { if (!studio()) {
Iris.service(StudioSVC.class).installIntoWorld(sender, d.getLoadKey(), new File(name())); Iris.service(StudioSVC.class).installIntoWorld(sender, d.getLoadKey(), new File(name()));
} }
@@ -117,6 +129,7 @@ public class IrisCreator {
.seed(seed) .seed(seed)
.studio(studio) .studio(studio)
.create(); .create();
ServerConfigurator.installDataPacks(false);
access = (PlatformChunkGenerator) wc.generator(); access = (PlatformChunkGenerator) wc.generator();
PlatformChunkGenerator finalAccess1 = access; PlatformChunkGenerator finalAccess1 = access;
@@ -174,7 +187,8 @@ public class IrisCreator {
world.get().setTime(6000); world.get().setTime(6000);
} }
}); });
} } else
addToBukkitYml();
if (pregen != null) { if (pregen != null) {
CompletableFuture<Boolean> ff = new CompletableFuture<>(); CompletableFuture<Boolean> ff = new CompletableFuture<>();
@@ -204,7 +218,22 @@ public class IrisCreator {
e.printStackTrace(); e.printStackTrace();
} }
} }
return world.get(); return world.get();
} }
private void addToBukkitYml() {
YamlConfiguration yml = YamlConfiguration.loadConfiguration(BUKKIT_YML);
String gen = "Iris:" + dimension;
ConfigurationSection section = yml.contains("worlds") ? yml.getConfigurationSection("worlds") : yml.createSection("worlds");
if (!section.contains(name)) {
section.createSection(name).set("generator", gen);
try {
yml.save(BUKKIT_YML);
Iris.info("Registered \"" + name + "\" in bukkit.yml");
} catch (IOException e) {
Iris.error("Failed to update bukkit.yml!");
e.printStackTrace();
}
}
}
} }

View File

@@ -32,11 +32,10 @@ import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.io.File; import java.io.File;
import java.lang.reflect.Method; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -55,8 +54,7 @@ public class IrisToolbelt {
* - GithubUsername/repository * - GithubUsername/repository
* - GithubUsername/repository/branch * - GithubUsername/repository/branch
* *
* @param dimension * @param dimension the dimension id such as overworld or flat
* the dimension id such as overworld or flat
* @return the IrisDimension or null * @return the IrisDimension or null
*/ */
public static IrisDimension getDimension(String dimension) { public static IrisDimension getDimension(String dimension) {
@@ -85,8 +83,7 @@ public class IrisToolbelt {
/** /**
* Checks if the given world is an Iris World (same as access(world) != null) * Checks if the given world is an Iris World (same as access(world) != null)
* *
* @param world * @param world the world
* the world
* @return true if it is an Iris Access world * @return true if it is an Iris Access world
*/ */
public static boolean isIrisWorld(World world) { public static boolean isIrisWorld(World world) {
@@ -109,8 +106,7 @@ public class IrisToolbelt {
/** /**
* Get the Iris generator for the given world * Get the Iris generator for the given world
* *
* @param world * @param world the given world
* the given world
* @return the IrisAccess or null if it's not an Iris World * @return the IrisAccess or null if it's not an Iris World
*/ */
public static PlatformChunkGenerator access(World world) { public static PlatformChunkGenerator access(World world) {
@@ -140,10 +136,8 @@ public class IrisToolbelt {
/** /**
* Start a pregenerator task * Start a pregenerator task
* *
* @param task * @param task the scheduled task
* the scheduled task * @param method the method to execute the task
* @param method
* the method to execute the task
* @return the pregenerator job (already started) * @return the pregenerator job (already started)
*/ */
public static PregeneratorJob pregenerate(PregenTask task, PregeneratorMethod method, Engine engine) { public static PregeneratorJob pregenerate(PregenTask task, PregeneratorMethod method, Engine engine) {
@@ -154,10 +148,8 @@ public class IrisToolbelt {
* Start a pregenerator task. If the supplied generator is headless, headless mode is used, * Start a pregenerator task. If the supplied generator is headless, headless mode is used,
* otherwise Hybrid mode is used. * otherwise Hybrid mode is used.
* *
* @param task * @param task the scheduled task
* the scheduled task * @param gen the Iris Generator
* @param gen
* the Iris Generator
* @return the pregenerator job (already started) * @return the pregenerator job (already started)
*/ */
public static PregeneratorJob pregenerate(PregenTask task, PlatformChunkGenerator gen) { public static PregeneratorJob pregenerate(PregenTask task, PlatformChunkGenerator gen) {
@@ -169,10 +161,8 @@ public class IrisToolbelt {
* Start a pregenerator task. If the supplied generator is headless, headless mode is used, * Start a pregenerator task. If the supplied generator is headless, headless mode is used,
* otherwise Hybrid mode is used. * otherwise Hybrid mode is used.
* *
* @param task * @param task the scheduled task
* the scheduled task * @param world the World
* @param world
* the World
* @return the pregenerator job (already started) * @return the pregenerator job (already started)
*/ */
public static PregeneratorJob pregenerate(PregenTask task, World world) { public static PregeneratorJob pregenerate(PregenTask task, World world) {
@@ -187,8 +177,7 @@ public class IrisToolbelt {
* Evacuate all players from the world into literally any other world. * Evacuate all players from the world into literally any other world.
* If there are no other worlds, kick them! Not the best but what's mine is mine sometimes... * If there are no other worlds, kick them! Not the best but what's mine is mine sometimes...
* *
* @param world * @param world the world to evac
* the world to evac
*/ */
public static boolean evacuate(World world) { public static boolean evacuate(World world) {
for (World i : Bukkit.getWorlds()) { for (World i : Bukkit.getWorlds()) {
@@ -208,10 +197,8 @@ public class IrisToolbelt {
/** /**
* Evacuate all players from the world * Evacuate all players from the world
* *
* @param world * @param world the world to leave
* the world to leave * @param m the message
* @param m
* the message
* @return true if it was evacuated. * @return true if it was evacuated.
*/ */
public static boolean evacuate(World world, String m) { public static boolean evacuate(World world, String m) {
@@ -221,7 +208,6 @@ public class IrisToolbelt {
new VolmitSender(j, Iris.instance.getTag()).sendMessage("You have been evacuated from this world. " + m); new VolmitSender(j, Iris.instance.getTag()).sendMessage("You have been evacuated from this world. " + m);
j.teleport(i.getSpawnLocation()); j.teleport(i.getSpawnLocation());
} }
return true; return true;
} }
} }
@@ -239,13 +225,21 @@ public class IrisToolbelt {
public static <T> T getMantleData(World world, int x, int y, int z, Class<T> of) { public static <T> T getMantleData(World world, int x, int y, int z, Class<T> of) {
PlatformChunkGenerator e = access(world); PlatformChunkGenerator e = access(world);
if(e == null) {return null;} if (e == null) {
return null;
}
return e.getEngine().getMantle().getMantle().get(x, y - world.getMinHeight(), z, of); return e.getEngine().getMantle().getMantle().get(x, y - world.getMinHeight(), z, of);
} }
public static <T> void deleteMantleData(World world, int x, int y, int z, Class<T> of) { public static <T> void deleteMantleData(World world, int x, int y, int z, Class<T> of) {
PlatformChunkGenerator e = access(world); PlatformChunkGenerator e = access(world);
if(e == null) {return;} if (e == null) {
return;
}
e.getEngine().getMantle().getMantle().remove(x, y - world.getMinHeight(), z, of); e.getEngine().getMantle().getMantle().remove(x, y - world.getMinHeight(), z, of);
} }
public static boolean removeWorld(World world) throws IOException {
return IrisCreator.removeFromBukkitYml(world.getName());
}
} }

View File

@@ -26,7 +26,7 @@ import org.bukkit.Particle;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.awt.Color; import java.awt.*;
public class WandSelection { public class WandSelection {
private final Cuboid c; private final Cuboid c;

View File

@@ -23,16 +23,11 @@ import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.data.cache.Cache; import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.InferredType; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisDecorationPart;
import com.volmit.iris.engine.object.IrisDecorator;
import com.volmit.iris.engine.object.IrisGenerator;
import com.volmit.iris.engine.object.IrisInterpolator;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.context.IrisContext;
import com.volmit.iris.util.data.DataProvider; import com.volmit.iris.util.data.DataProvider;
import com.volmit.iris.util.math.M; import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
@@ -112,96 +107,106 @@ public class IrisComplex implements DataProvider {
.getAllBiomes(this).forEach((b) -> b .getAllBiomes(this).forEach((b) -> b
.getGenerators() .getGenerators()
.forEach((c) -> registerGenerator(c.getCachedGenerator(this))))); .forEach((c) -> registerGenerator(c.getCachedGenerator(this)))));
overlayStream = ProceduralStream.ofDouble((x, z) -> 0.0D); overlayStream = ProceduralStream.ofDouble((x, z) -> 0.0D).waste("Overlay Stream");
engine.getDimension().getOverlayNoise().forEach(i -> overlayStream = overlayStream.add((x, z) -> i.get(rng, getData(), x, z))); engine.getDimension().getOverlayNoise().forEach(i -> overlayStream = overlayStream.add((x, z) -> i.get(rng, getData(), x, z)));
rockStream = engine.getDimension().getRockPalette().getLayerGenerator(rng.nextParallelRNG(45), data).stream() rockStream = engine.getDimension().getRockPalette().getLayerGenerator(rng.nextParallelRNG(45), data).stream()
.select(engine.getDimension().getRockPalette().getBlockData(data)); .select(engine.getDimension().getRockPalette().getBlockData(data)).waste("Rock Stream");
fluidStream = engine.getDimension().getFluidPalette().getLayerGenerator(rng.nextParallelRNG(78), data).stream() fluidStream = engine.getDimension().getFluidPalette().getLayerGenerator(rng.nextParallelRNG(78), data).stream()
.select(engine.getDimension().getFluidPalette().getBlockData(data)); .select(engine.getDimension().getFluidPalette().getBlockData(data)).waste("Fluid Stream");
regionStyleStream = engine.getDimension().getRegionStyle().create(rng.nextParallelRNG(883), getData()).stream() regionStyleStream = engine.getDimension().getRegionStyle().create(rng.nextParallelRNG(883), getData()).stream()
.zoom(engine.getDimension().getRegionZoom()); .zoom(engine.getDimension().getRegionZoom()).waste("Region Style");
regionIdentityStream = regionStyleStream.fit(Integer.MIN_VALUE, Integer.MAX_VALUE); regionIdentityStream = regionStyleStream.fit(Integer.MIN_VALUE, Integer.MAX_VALUE).waste("Region Identity Stream");
regionStream = focusRegion != null ? regionStream = focusRegion != null ?
ProceduralStream.of((x, z) -> focusRegion, ProceduralStream.of((x, z) -> focusRegion,
Interpolated.of(a -> 0D, a -> focusRegion)) Interpolated.of(a -> 0D, a -> focusRegion))
: regionStyleStream : regionStyleStream
.selectRarity(data.getRegionLoader().loadAll(engine.getDimension().getRegions())) .selectRarity(data.getRegionLoader().loadAll(engine.getDimension().getRegions()))
.cache2D("regionStream", engine, cacheSize); .cache2D("regionStream", engine, cacheSize).waste("Region Stream");
regionIDStream = regionIdentityStream.convertCached((i) -> new UUID(Double.doubleToLongBits(i), String.valueOf(i * 38445).hashCode() * 3245556666L)); regionIDStream = regionIdentityStream.convertCached((i) -> new UUID(Double.doubleToLongBits(i),
caveBiomeStream = regionStream.convert((r) String.valueOf(i * 38445).hashCode() * 3245556666L)).waste("Region ID Stream");
caveBiomeStream = regionStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getRegion().get(x, z))
.convert((r)
-> engine.getDimension().getCaveBiomeStyle().create(rng.nextParallelRNG(InferredType.CAVE.ordinal()), getData()).stream() -> engine.getDimension().getCaveBiomeStyle().create(rng.nextParallelRNG(InferredType.CAVE.ordinal()), getData()).stream()
.zoom(r.getCaveBiomeZoom()) .zoom(r.getCaveBiomeZoom())
.selectRarity(data.getBiomeLoader().loadAll(r.getCaveBiomes())) .selectRarity(data.getBiomeLoader().loadAll(r.getCaveBiomes()))
.onNull(emptyBiome) .onNull(emptyBiome)
).convertAware2D(ProceduralStream::get).cache2D("caveBiomeStream", engine, cacheSize); ).convertAware2D(ProceduralStream::get).cache2D("caveBiomeStream", engine, cacheSize).waste("Cave Biome Stream");
inferredStreams.put(InferredType.CAVE, caveBiomeStream); inferredStreams.put(InferredType.CAVE, caveBiomeStream);
landBiomeStream = regionStream.convert((r) landBiomeStream = regionStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getRegion().get(x, z))
.convert((r)
-> engine.getDimension().getLandBiomeStyle().create(rng.nextParallelRNG(InferredType.LAND.ordinal()), getData()).stream() -> engine.getDimension().getLandBiomeStyle().create(rng.nextParallelRNG(InferredType.LAND.ordinal()), getData()).stream()
.zoom(r.getLandBiomeZoom()) .zoom(r.getLandBiomeZoom())
.selectRarity(data.getBiomeLoader().loadAll(r.getLandBiomes(), (t) -> t.setInferredType(InferredType.LAND))) .selectRarity(data.getBiomeLoader().loadAll(r.getLandBiomes(), (t) -> t.setInferredType(InferredType.LAND)))
).convertAware2D(ProceduralStream::get) ).convertAware2D(ProceduralStream::get)
.cache2D("landBiomeStream", engine, cacheSize); .cache2D("landBiomeStream", engine, cacheSize).waste("Land Biome Stream");
inferredStreams.put(InferredType.LAND, landBiomeStream); inferredStreams.put(InferredType.LAND, landBiomeStream);
seaBiomeStream = regionStream.convert((r) seaBiomeStream = regionStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getRegion().get(x, z))
.convert((r)
-> engine.getDimension().getSeaBiomeStyle().create(rng.nextParallelRNG(InferredType.SEA.ordinal()), getData()).stream() -> engine.getDimension().getSeaBiomeStyle().create(rng.nextParallelRNG(InferredType.SEA.ordinal()), getData()).stream()
.zoom(r.getSeaBiomeZoom()) .zoom(r.getSeaBiomeZoom())
.selectRarity(data.getBiomeLoader().loadAll(r.getSeaBiomes(), (t) -> t.setInferredType(InferredType.SEA))) .selectRarity(data.getBiomeLoader().loadAll(r.getSeaBiomes(), (t) -> t.setInferredType(InferredType.SEA)))
).convertAware2D(ProceduralStream::get) ).convertAware2D(ProceduralStream::get)
.cache2D("seaBiomeStream", engine, cacheSize); .cache2D("seaBiomeStream", engine, cacheSize).waste("Sea Biome Stream");
inferredStreams.put(InferredType.SEA, seaBiomeStream); inferredStreams.put(InferredType.SEA, seaBiomeStream);
shoreBiomeStream = regionStream.convert((r) shoreBiomeStream = regionStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getRegion().get(x, z))
.convert((r)
-> engine.getDimension().getShoreBiomeStyle().create(rng.nextParallelRNG(InferredType.SHORE.ordinal()), getData()).stream() -> engine.getDimension().getShoreBiomeStyle().create(rng.nextParallelRNG(InferredType.SHORE.ordinal()), getData()).stream()
.zoom(r.getShoreBiomeZoom()) .zoom(r.getShoreBiomeZoom())
.selectRarity(data.getBiomeLoader().loadAll(r.getShoreBiomes(), (t) -> t.setInferredType(InferredType.SHORE))) .selectRarity(data.getBiomeLoader().loadAll(r.getShoreBiomes(), (t) -> t.setInferredType(InferredType.SHORE)))
).convertAware2D(ProceduralStream::get).cache2D("shoreBiomeStream", engine, cacheSize); ).convertAware2D(ProceduralStream::get).cache2D("shoreBiomeStream", engine, cacheSize).waste("Shore Biome Stream");
inferredStreams.put(InferredType.SHORE, shoreBiomeStream); inferredStreams.put(InferredType.SHORE, shoreBiomeStream);
bridgeStream = focusBiome != null ? ProceduralStream.of((x, z) -> focusBiome.getInferredType(), bridgeStream = focusBiome != null ? ProceduralStream.of((x, z) -> focusBiome.getInferredType(),
Interpolated.of(a -> 0D, a -> focusBiome.getInferredType())) : Interpolated.of(a -> 0D, a -> focusBiome.getInferredType())) :
engine.getDimension().getContinentalStyle().create(rng.nextParallelRNG(234234565), getData()) engine.getDimension().getContinentalStyle().create(rng.nextParallelRNG(234234565), getData())
.bake().scale(1D / engine.getDimension().getContinentZoom()).bake().stream() .bake().scale(1D / engine.getDimension().getContinentZoom()).bake().stream()
.convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND) .convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND)
.cache2D("bridgeStream", engine, cacheSize); .cache2D("bridgeStream", engine, cacheSize).waste("Bridge Stream");
baseBiomeStream = focusBiome != null ? ProceduralStream.of((x, z) -> focusBiome, baseBiomeStream = focusBiome != null ? ProceduralStream.of((x, z) -> focusBiome,
Interpolated.of(a -> 0D, a -> focusBiome)) : Interpolated.of(a -> 0D, a -> focusBiome)) :
bridgeStream.convertAware2D((t, x, z) -> inferredStreams.get(t).get(x, z)) bridgeStream.convertAware2D((t, x, z) -> inferredStreams.get(t).get(x, z))
.convertAware2D(this::implode) .convertAware2D(this::implode)
.cache2D("baseBiomeStream", engine, cacheSize); .cache2D("baseBiomeStream", engine, cacheSize).waste("Base Biome Stream");
heightStream = ProceduralStream.of((x, z) -> { heightStream = ProceduralStream.of((x, z) -> {
IrisBiome b = focusBiome != null ? focusBiome : baseBiomeStream.get(x, z); IrisBiome b = focusBiome != null ? focusBiome : baseBiomeStream.get(x, z);
return getHeight(engine, b, x, z, engine.getSeedManager().getHeight()); return getHeight(engine, b, x, z, engine.getSeedManager().getHeight());
}, Interpolated.DOUBLE).clamp(0, engine.getHeight()).cache2D("heightStream", engine, cacheSize); }, Interpolated.DOUBLE).cache2D("heightStream", engine, cacheSize).waste("Height Stream");
roundedHeighteightStream = heightStream.round(); roundedHeighteightStream = heightStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getHeight().get(x, z))
slopeStream = heightStream.slope(3).cache2D("slopeStream", engine, cacheSize); .round().waste("Rounded Height Stream");
slopeStream = heightStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getHeight().get(x, z))
.slope(3).cache2D("slopeStream", engine, cacheSize).waste("Slope Stream");
trueBiomeStream = focusBiome != null ? ProceduralStream.of((x, y) -> focusBiome, Interpolated.of(a -> 0D, trueBiomeStream = focusBiome != null ? ProceduralStream.of((x, y) -> focusBiome, Interpolated.of(a -> 0D,
b -> focusBiome)) b -> focusBiome))
.cache2D("trueBiomeStream-focus", engine, cacheSize) : heightStream .cache2D("trueBiomeStream-focus", engine, cacheSize) : heightStream
.convertAware2D((h, x, z) -> .convertAware2D((h, x, z) ->
fixBiomeType(h, baseBiomeStream.get(x, z), fixBiomeType(h, baseBiomeStream.get(x, z),
regionStream.get(x, z), x, z, fluidHeight)) regionStream.contextInjecting((c, xx, zz) -> IrisContext.getOr(engine).getChunkContext().getRegion().get(xx, zz)).get(x, z), x, z, fluidHeight))
.cache2D("trueBiomeStream", engine, cacheSize); .cache2D("trueBiomeStream", engine, cacheSize).waste("True Biome Stream");
trueBiomeDerivativeStream = trueBiomeStream.convert(IrisBiome::getDerivative).cache2D("trueBiomeDerivativeStream", engine, cacheSize); trueBiomeDerivativeStream = trueBiomeStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getBiome().get(x, z))
heightFluidStream = heightStream.max(fluidHeight).cache2D("heightFluidStream", engine, cacheSize); .convert(IrisBiome::getDerivative).cache2D("trueBiomeDerivativeStream", engine, cacheSize).waste("True Biome Derivative Stream");
maxHeightStream = ProceduralStream.ofDouble((x, z) -> height); heightFluidStream = heightStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getHeight().get(x, z))
terrainSurfaceDecoration = trueBiomeStream .max(fluidHeight).cache2D("heightFluidStream", engine, cacheSize).waste("Height Fluid Stream");
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainSurfaceDecoration", engine, cacheSize); maxHeightStream = ProceduralStream.ofDouble((x, z) -> height).waste("Max Height Stream");
terrainCeilingDecoration = trueBiomeStream terrainSurfaceDecoration = trueBiomeStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getBiome().get(x, z))
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCeilingDecoration", engine, cacheSize); .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainSurfaceDecoration", engine, cacheSize).waste("Surface Decoration Stream");
terrainCaveSurfaceDecoration = caveBiomeStream terrainCeilingDecoration = trueBiomeStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getBiome().get(x, z))
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainCaveSurfaceDecoration", engine, cacheSize); .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCeilingDecoration", engine, cacheSize).waste("Ceiling Decoration Stream");
terrainCaveCeilingDecoration = caveBiomeStream terrainCaveSurfaceDecoration = caveBiomeStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getCave().get(x, z))
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCaveCeilingDecoration", engine, cacheSize); .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainCaveSurfaceDecoration", engine, cacheSize).waste("Cave Surface Stream");
shoreSurfaceDecoration = trueBiomeStream terrainCaveCeilingDecoration = caveBiomeStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getCave().get(x, z))
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SHORE_LINE)).cache2D("shoreSurfaceDecoration", engine, cacheSize); .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCaveCeilingDecoration", engine, cacheSize).waste("Cave Ceiling Stream");
seaSurfaceDecoration = trueBiomeStream shoreSurfaceDecoration = trueBiomeStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getBiome().get(x, z))
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_SURFACE)).cache2D("seaSurfaceDecoration", engine, cacheSize); .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SHORE_LINE)).cache2D("shoreSurfaceDecoration", engine, cacheSize).waste("Shore Surface Stream");
seaFloorDecoration = trueBiomeStream seaSurfaceDecoration = trueBiomeStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getBiome().get(x, z))
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_FLOOR)).cache2D("seaFloorDecoration", engine, cacheSize); .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_SURFACE)).cache2D("seaSurfaceDecoration", engine, cacheSize).waste("Sea Surface Stream");
baseBiomeIDStream = trueBiomeStream.convertAware2D((b, x, z) -> { seaFloorDecoration = trueBiomeStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getBiome().get(x, z))
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_FLOOR)).cache2D("seaFloorDecoration", engine, cacheSize).waste("Sea Floor Stream");
baseBiomeIDStream = trueBiomeStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getBiome().get(x, z))
.convertAware2D((b, x, z) -> {
UUID d = regionIDStream.get(x, z); UUID d = regionIDStream.get(x, z);
return new UUID(b.getLoadKey().hashCode() * 818223L, return new UUID(b.getLoadKey().hashCode() * 818223L,
d.hashCode()); d.hashCode());
}) })
.cache2D("", engine, cacheSize); .cache2D("", engine, cacheSize).waste("Biome ID Stream");
//@done //@done
} }
@@ -315,6 +320,7 @@ public class IrisComplex implements DataProvider {
return 0; return 0;
}); });
;
double d = 0; double d = 0;

View File

@@ -27,25 +27,13 @@ import com.volmit.iris.core.gui.PregeneratorJob;
import com.volmit.iris.core.project.IrisProject; import com.volmit.iris.core.project.IrisProject;
import com.volmit.iris.core.service.PreservationSVC; import com.volmit.iris.core.service.PreservationSVC;
import com.volmit.iris.engine.data.cache.AtomicCache; import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.*;
import com.volmit.iris.engine.framework.EngineEffects;
import com.volmit.iris.engine.framework.EngineMetrics;
import com.volmit.iris.engine.framework.EngineMode;
import com.volmit.iris.engine.framework.EngineTarget;
import com.volmit.iris.engine.framework.EngineWorldManager;
import com.volmit.iris.engine.framework.SeedManager;
import com.volmit.iris.engine.framework.WrongEngineBroException;
import com.volmit.iris.engine.mantle.EngineMantle; import com.volmit.iris.engine.mantle.EngineMantle;
import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.IrisBiomePaletteLayer;
import com.volmit.iris.engine.object.IrisDecorator;
import com.volmit.iris.engine.object.IrisEngineData;
import com.volmit.iris.engine.object.IrisJigsawStructure;
import com.volmit.iris.engine.object.IrisObjectPlacement;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.engine.scripting.EngineExecutionEnvironment; import com.volmit.iris.engine.scripting.EngineExecutionEnvironment;
import com.volmit.iris.util.atomics.AtomicRollingSequence; import com.volmit.iris.util.atomics.AtomicRollingSequence;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.context.IrisContext; import com.volmit.iris.util.context.IrisContext;
import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
@@ -55,18 +43,22 @@ import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.mantle.MantleFlag; import com.volmit.iris.util.mantle.MantleFlag;
import com.volmit.iris.util.math.M; import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.matter.MatterStructurePOI;
import com.volmit.iris.util.scheduling.ChronoLatch; import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.PrecisionStopwatch; import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import lombok.Data; import lombok.Data;
import net.minecraft.core.BlockPos;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import oshi.util.tuples.Pair;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@@ -89,11 +81,11 @@ public class IrisEngine implements Engine {
private final boolean studio; private final boolean studio;
private final AtomicRollingSequence wallClock; private final AtomicRollingSequence wallClock;
private final int art; private final int art;
private EngineMode mode;
private final AtomicCache<IrisEngineData> engineData = new AtomicCache<>(); private final AtomicCache<IrisEngineData> engineData = new AtomicCache<>();
private final AtomicBoolean cleaning; private final AtomicBoolean cleaning;
private final ChronoLatch cleanLatch; private final ChronoLatch cleanLatch;
private final SeedManager seedManager; private final SeedManager seedManager;
private EngineMode mode;
private EngineEffects effects; private EngineEffects effects;
private EngineExecutionEnvironment execution; private EngineExecutionEnvironment execution;
private EngineWorldManager worldManager; private EngineWorldManager worldManager;
@@ -128,8 +120,9 @@ public class IrisEngine implements Engine {
context = new IrisContext(this); context = new IrisContext(this);
cleaning = new AtomicBoolean(false); cleaning = new AtomicBoolean(false);
context.touch(); context.touch();
Iris.info("Initializing Engine: " + target.getWorld().name() + "/" + target.getDimension().getLoadKey() + " (" + target.getDimension().getDimensionHeight() + " height) Seed: " + getSeedManager().getSeed());
getData().setEngine(this); getData().setEngine(this);
getData().loadPrefetch(this);
Iris.info("Initializing Engine: " + target.getWorld().name() + "/" + target.getDimension().getLoadKey() + " (" + target.getDimension().getDimensionHeight() + " height) Seed: " + getSeedManager().getSeed());
minHeight = 0; minHeight = 0;
failing = false; failing = false;
closed = false; closed = false;
@@ -145,6 +138,7 @@ public class IrisEngine implements Engine {
} }
private void tickRandomPlayer() { private void tickRandomPlayer() {
recycle();
if (perSecondBudLatch.flip()) { if (perSecondBudLatch.flip()) {
buds.set(bud.get()); buds.set(bud.get());
bud.set(0); bud.set(0);
@@ -192,8 +186,8 @@ public class IrisEngine implements Engine {
} }
@Override @Override
public void generateMatter(int x, int z, boolean multicore) { public void generateMatter(int x, int z, boolean multicore, ChunkContext context) {
getMantle().generateMatter(x, z, multicore); getMantle().generateMatter(x, z, multicore, context);
} }
@Override @Override
@@ -201,6 +195,13 @@ public class IrisEngine implements Engine {
return getMantle().getObjectComponent().guess(x, z); return getMantle().getObjectComponent().guess(x, z);
} }
@Override
public Set<Pair<String, BlockPos>> getPOIsAt(int chunkX, int chunkY) {
Set<Pair<String, BlockPos>> pois = new HashSet<>();
getMantle().getMantle().iterateChunk(chunkX, chunkY, MatterStructurePOI.class, (x, y, z, d) -> pois.add(new Pair<>(d.getType(), new BlockPos(x, y, z))));
return pois;
}
@Override @Override
public IrisJigsawStructure getStructureAt(int x, int z) { public IrisJigsawStructure getStructureAt(int x, int z) {
return getMantle().getJigsawComponent().guess(x, z); return getMantle().getJigsawComponent().guess(x, z);
@@ -234,7 +235,11 @@ public class IrisEngine implements Engine {
getTarget().setDimension(getData().getDimensionLoader().load(getDimension().getLoadKey())); getTarget().setDimension(getData().getDimensionLoader().load(getDimension().getLoadKey()));
prehotload(); prehotload();
setupEngine(); setupEngine();
J.a(() -> { synchronized(ServerConfigurator.class) { ServerConfigurator.installDataPacks(false); } }); J.a(() -> {
synchronized (ServerConfigurator.class) {
ServerConfigurator.installDataPacks(false);
}
});
} }
@Override @Override
@@ -453,7 +458,10 @@ public class IrisEngine implements Engine {
getMantle().getMantle().flag(x >> 4, z >> 4, MantleFlag.REAL, true); getMantle().getMantle().flag(x >> 4, z >> 4, MantleFlag.REAL, true);
getMetrics().getTotal().put(p.getMilliseconds()); getMetrics().getTotal().put(p.getMilliseconds());
generated.incrementAndGet(); generated.incrementAndGet();
recycle();
if (generated.get() == 661) {
J.a(() -> getData().savePrefetch(this));
}
} catch (Throwable e) { } catch (Throwable e) {
Iris.reportError(e); Iris.reportError(e);
fail("Failed to generate " + x + ", " + z, e); fail("Failed to generate " + x + ", " + z, e);

View File

@@ -27,13 +27,7 @@ import com.volmit.iris.engine.mantle.components.MantleCarvingComponent;
import com.volmit.iris.engine.mantle.components.MantleFluidBodyComponent; import com.volmit.iris.engine.mantle.components.MantleFluidBodyComponent;
import com.volmit.iris.engine.mantle.components.MantleJigsawComponent; import com.volmit.iris.engine.mantle.components.MantleJigsawComponent;
import com.volmit.iris.engine.mantle.components.MantleObjectComponent; import com.volmit.iris.engine.mantle.components.MantleObjectComponent;
import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.IrisDepositGenerator;
import com.volmit.iris.engine.object.IrisJigsawStructurePlacement;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.engine.object.IrisObjectPlacement;
import com.volmit.iris.engine.object.IrisObjectScale;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.collection.KSet;

View File

@@ -20,20 +20,10 @@ package com.volmit.iris.engine;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.engine.data.cache.Cache; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineAssignedWorldManager; import com.volmit.iris.engine.framework.EngineAssignedWorldManager;
import com.volmit.iris.engine.object.IRare; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisBlockDrops;
import com.volmit.iris.engine.object.IrisEngineChunkData;
import com.volmit.iris.engine.object.IrisEngineData;
import com.volmit.iris.engine.object.IrisEngineSpawnerCooldown;
import com.volmit.iris.engine.object.IrisEntitySpawn;
import com.volmit.iris.engine.object.IrisMarker;
import com.volmit.iris.engine.object.IrisPosition;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.engine.object.IrisSpawner;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.collection.KSet;
@@ -41,6 +31,7 @@ import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.mantle.Mantle; import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.mantle.MantleFlag; import com.volmit.iris.util.mantle.MantleFlag;
import com.volmit.iris.util.math.M; import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.matter.MatterMarker; import com.volmit.iris.util.matter.MatterMarker;
import com.volmit.iris.util.parallel.MultiBurst; import com.volmit.iris.util.parallel.MultiBurst;
@@ -55,6 +46,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -69,7 +61,6 @@ import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@@ -91,6 +82,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
private int actuallySpawned = 0; private int actuallySpawned = 0;
private int cooldown = 0; private int cooldown = 0;
private List<Entity> precount = new KList<>(); private List<Entity> precount = new KList<>();
private KSet<Position2> injectBiomes = new KSet<>();
public IrisWorldManager() { public IrisWorldManager() {
super(null); super(null);
@@ -473,6 +465,10 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
getEngine().getMantle().save(); getEngine().getMantle().save();
} }
public void requestBiomeInject(Position2 p) {
injectBiomes.add(p);
}
@Override @Override
public void onChunkLoad(Chunk e, boolean generated) { public void onChunkLoad(Chunk e, boolean generated) {
if (getEngine().isClosed()) { if (getEngine().isClosed()) {
@@ -482,6 +478,10 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
energy += 0.3; energy += 0.3;
fixEnergy(); fixEnergy();
getEngine().cleanupMantleChunk(e.getX(), e.getZ()); getEngine().cleanupMantleChunk(e.getX(), e.getZ());
if (generated) {
//INMS.get().injectBiomesFromMantle(e, getMantle());
}
} }
private void spawn(IrisPosition block, IrisSpawner spawner, boolean initial) { private void spawn(IrisPosition block, IrisSpawner spawner, boolean initial) {
@@ -617,7 +617,6 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
@Override @Override
public void onBlockBreak(BlockBreakEvent e) { public void onBlockBreak(BlockBreakEvent e) {
if (e.getBlock().getWorld().equals(getTarget().getWorld().realWorld())) { if (e.getBlock().getWorld().equals(getTarget().getWorld().realWorld())) {
J.a(() -> { J.a(() -> {
MatterMarker marker = getMantle().get(e.getBlock().getX(), e.getBlock().getY(), e.getBlock().getZ(), MatterMarker.class); MatterMarker marker = getMantle().get(e.getBlock().getX(), e.getBlock().getY(), e.getBlock().getZ(), MatterMarker.class);
@@ -635,52 +634,30 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
}); });
KList<ItemStack> d = new KList<>(); KList<ItemStack> d = new KList<>();
Runnable drop = () -> J.s(() -> d.forEach((i) -> e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().clone().add(0.5, 0.5, 0.5), i))); IrisBiome b = getEngine().getBiome(e.getBlock().getLocation().clone().subtract(0, getEngine().getWorld().minHeight(), 0));
IrisBiome b = getEngine().getBiome(e.getBlock().getLocation()); List<IrisBlockDrops> dropProviders = filterDrops(b.getBlockDrops(), e, getData());
if(dropItems(e, d, drop, b.getBlockDrops(), b)) {
return;
}
if (dropProviders.stream().noneMatch(IrisBlockDrops::isSkipParents)) {
IrisRegion r = getEngine().getRegion(e.getBlock().getLocation()); IrisRegion r = getEngine().getRegion(e.getBlock().getLocation());
dropProviders.addAll(filterDrops(r.getBlockDrops(), e, getData()));
if(dropItems(e, d, drop, r.getBlockDrops(), b)) { dropProviders.addAll(filterDrops(getEngine().getDimension().getBlockDrops(), e, getData()));
return;
} }
for(IrisBlockDrops i : getEngine().getDimension().getBlockDrops()) { dropProviders.forEach(provider -> provider.fillDrops(false, d));
if(i.shouldDropFor(e.getBlock().getBlockData(), getData())) {
if(i.isReplaceVanillaDrops()) { if (dropProviders.stream().anyMatch(IrisBlockDrops::isReplaceVanillaDrops)) {
e.setDropItems(false); e.setDropItems(false);
} }
i.fillDrops(false, d); if (d.isNotEmpty()) {
World w = e.getBlock().getWorld();
if(i.isSkipParents()) { J.s(() -> d.forEach(item -> w.dropItemNaturally(e.getBlock().getLocation().clone().add(.5, .5, .5), item)));
drop.run();
return;
}
}
} }
} }
} }
private boolean dropItems(BlockBreakEvent e, KList<ItemStack> d, Runnable drop, KList<IrisBlockDrops> blockDrops, IrisBiome b) { private List<IrisBlockDrops> filterDrops(KList<IrisBlockDrops> drops, BlockBreakEvent e, IrisData data) {
for(IrisBlockDrops i : blockDrops) { return new KList<>(drops.stream().filter(d -> d.shouldDropFor(e.getBlock().getBlockData(), data)).toList());
if(i.shouldDropFor(e.getBlock().getBlockData(), getData())) {
if(i.isReplaceVanillaDrops()) {
e.setDropItems(false);
}
i.fillDrops(false, d);
if(i.isSkipParents()) {
drop.run();
return true;
}
}
}
return false;
} }
@Override @Override

View File

@@ -18,23 +18,20 @@
package com.volmit.iris.engine.actuator; package com.volmit.iris.engine.actuator;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS; import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.data.chunk.TerrainChunk;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineAssignedActuator; import com.volmit.iris.engine.framework.EngineAssignedActuator;
import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisBiomeCustom; import com.volmit.iris.engine.object.IrisBiomeCustom;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.hunk.view.BiomeGridHunkView;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.parallel.BurstExecutor; import com.volmit.iris.util.matter.MatterBiomeInject;
import com.volmit.iris.util.matter.slices.BiomeInjectMatter;
import com.volmit.iris.util.scheduling.ChronoLatch; import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.PrecisionStopwatch; import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import io.papermc.lib.PaperLib;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.generator.ChunkGenerator;
public class IrisBiomeActuator extends EngineAssignedActuator<Biome> { public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
private final RNG rng; private final RNG rng;
@@ -46,72 +43,34 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
} }
@BlockCoordinates @BlockCoordinates
private boolean injectBiome(Hunk<Biome> h, int x, int y, int z, Object bb) { @Override
public void onActuate(int x, int z, Hunk<Biome> h, boolean multicore, ChunkContext context) {
try { try {
if(h instanceof BiomeGridHunkView hh) { PrecisionStopwatch p = PrecisionStopwatch.start();
ChunkGenerator.BiomeGrid g = hh.getChunk();
if(g instanceof TerrainChunk) { int m = 0;
((TerrainChunk) g).getBiomeBaseInjector().setBiome(x, y, z, bb); for (int xf = 0; xf < h.getWidth(); xf++) {
IrisBiome ib;
for (int zf = 0; zf < h.getDepth(); zf++) {
ib = context.getBiome().get(xf, zf);
MatterBiomeInject matter = null;
if (ib.isCustom()) {
IrisBiomeCustom custom = ib.getCustomBiome(rng, x, 0, z);
matter = BiomeInjectMatter.get(INMS.get().getBiomeBaseIdForKey(getDimension().getLoadKey() + ":" + custom.getId()));
} else { } else {
hh.forceBiomeBaseInto(x, y, z, bb); Biome v = ib.getSkyBiome(rng, x, 0, z);
matter = BiomeInjectMatter.get(v);
} }
return true;
getEngine().getMantle().getMantle().set(x + xf, 0, z + zf, matter);
m++;
} }
}
getEngine().getMetrics().getBiome().put(p.getMilliseconds());
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
return false;
}
@BlockCoordinates
@Override
public void onActuate(int x, int z, Hunk<Biome> h, boolean multicore) {
PrecisionStopwatch p = PrecisionStopwatch.start();
BurstExecutor burst = burst().burst(PaperLib.isPaper() && multicore);
for(int xf = 0; xf < h.getWidth(); xf++) {
int finalXf = xf;
burst.queue(() -> {
IrisBiome ib;
for(int zf = 0; zf < h.getDepth(); zf++) {
ib = getComplex().getTrueBiomeStream().get(finalXf + x, zf + z);
int maxHeight = (int) (getComplex().getFluidHeight() + ib.getMaxWithObjectHeight(getData()));
if(ib.isCustom()) {
try {
IrisBiomeCustom custom = ib.getCustomBiome(rng, x, 0, z);
Object biomeBase = INMS.get().getCustomBiomeBaseHolderFor(getDimension().getLoadKey() + ":" + custom.getId());
if(biomeBase == null || !injectBiome(h, x, 0, z, biomeBase)) {
throw new RuntimeException("Cant inject biome!");
}
for(int i = 0; i < maxHeight; i++) {
injectBiome(h, finalXf, i, zf, biomeBase);
}
} catch(Throwable e) {
Iris.reportError(e);
Biome v = ib.getSkyBiome(rng, x, 0, z);
for(int i = 0; i < maxHeight; i++) {
h.set(finalXf, i, zf, v);
}
}
} else {
Biome v = ib.getSkyBiome(rng, x, 0, z);
if(v != null) {
for(int i = 0; i < maxHeight; i++) {
h.set(finalXf, i, zf, v);
}
} else if(cl.flip()) {
Iris.error("No biome provided for " + ib.getLoadKey());
}
}
}
});
}
burst.complete();
getEngine().getMetrics().getBiome().put(p.getMilliseconds());
} }
} }

View File

@@ -18,19 +18,15 @@
package com.volmit.iris.engine.actuator; package com.volmit.iris.engine.actuator;
import com.volmit.iris.engine.decorator.IrisCeilingDecorator; import com.volmit.iris.engine.decorator.*;
import com.volmit.iris.engine.decorator.IrisSeaFloorDecorator;
import com.volmit.iris.engine.decorator.IrisSeaSurfaceDecorator;
import com.volmit.iris.engine.decorator.IrisShoreLineDecorator;
import com.volmit.iris.engine.decorator.IrisSurfaceDecorator;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineAssignedActuator; import com.volmit.iris.engine.framework.EngineAssignedActuator;
import com.volmit.iris.engine.framework.EngineDecorator; import com.volmit.iris.engine.framework.EngineDecorator;
import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.scheduling.PrecisionStopwatch; import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Material; import org.bukkit.Material;
@@ -66,19 +62,16 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
@BlockCoordinates @BlockCoordinates
@Override @Override
public void onActuate(int x, int z, Hunk<BlockData> output, boolean multicore) { public void onActuate(int x, int z, Hunk<BlockData> output, boolean multicore, ChunkContext context) {
if (!getEngine().getDimension().isDecorate()) { if (!getEngine().getDimension().isDecorate()) {
return; return;
} }
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
BurstExecutor burst = burst().burst(multicore);
for (int i = 0; i < output.getWidth(); i++) { for (int i = 0; i < output.getWidth(); i++) {
int finalI = i;
burst.queue(() -> {
int height; int height;
int realX = Math.round(x + finalI); int realX = Math.round(x + i);
int realZ; int realZ;
IrisBiome biome, cave; IrisBiome biome, cave;
for (int j = 0; j < output.getDepth(); j++) { for (int j = 0; j < output.getDepth(); j++) {
@@ -86,42 +79,42 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
int emptyFor = 0; int emptyFor = 0;
int lastSolid = 0; int lastSolid = 0;
realZ = Math.round(z + j); realZ = Math.round(z + j);
height = (int) Math.round(getComplex().getHeightStream().get(realX, realZ)); height = (int) Math.round(context.getHeight().get(i, j));
biome = getComplex().getTrueBiomeStream().get(realX, realZ); biome = context.getBiome().get(i, j);
cave = shouldRay ? getComplex().getCaveBiomeStream().get(realX, realZ) : null; cave = shouldRay ? context.getCave().get(i, j) : null;
if (biome.getDecorators().isEmpty() && (cave == null || cave.getDecorators().isEmpty())) { if (biome.getDecorators().isEmpty() && (cave == null || cave.getDecorators().isEmpty())) {
continue; continue;
} }
if (height < getDimension().getFluidHeight()) { if (height < getDimension().getFluidHeight()) {
getSeaSurfaceDecorator().decorate(finalI, j, getSeaSurfaceDecorator().decorate(i, j,
realX, Math.round(finalI + 1), Math.round(x + finalI - 1), realX, Math.round(i + 1), Math.round(x + i - 1),
realZ, Math.round(z + j + 1), Math.round(z + j - 1), realZ, Math.round(z + j + 1), Math.round(z + j - 1),
output, biome, getDimension().getFluidHeight(), getEngine().getHeight()); output, biome, getDimension().getFluidHeight(), getEngine().getHeight());
getSeaFloorDecorator().decorate(finalI, j, getSeaFloorDecorator().decorate(i, j,
realX, realZ, output, biome, height + 1, realX, realZ, output, biome, height + 1,
getDimension().getFluidHeight() + 1); getDimension().getFluidHeight() + 1);
} }
if (height == getDimension().getFluidHeight()) { if (height == getDimension().getFluidHeight()) {
getShoreLineDecorator().decorate(finalI, j, getShoreLineDecorator().decorate(i, j,
realX, Math.round(x + finalI + 1), Math.round(x + finalI - 1), realX, Math.round(x + i + 1), Math.round(x + i - 1),
realZ, Math.round(z + j + 1), Math.round(z + j - 1), realZ, Math.round(z + j + 1), Math.round(z + j - 1),
output, biome, height, getEngine().getHeight()); output, biome, height, getEngine().getHeight());
} }
getSurfaceDecorator().decorate(finalI, j, realX, realZ, output, biome, height, getEngine().getHeight() - height); getSurfaceDecorator().decorate(i, j, realX, realZ, output, biome, height, getEngine().getHeight() - height);
if (cave != null && cave.getDecorators().isNotEmpty()) { if (cave != null && cave.getDecorators().isNotEmpty()) {
for (int k = height; k > 0; k--) { for (int k = height; k > 0; k--) {
solid = PREDICATE_SOLID.test(output.get(finalI, k, j)); solid = PREDICATE_SOLID.test(output.get(i, k, j));
if (solid) { if (solid) {
if (emptyFor > 0) { if (emptyFor > 0) {
getSurfaceDecorator().decorate(finalI, j, realX, realZ, output, cave, k, lastSolid); getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, lastSolid);
getCeilingDecorator().decorate(finalI, j, realX, realZ, output, cave, lastSolid - 1, emptyFor); getCeilingDecorator().decorate(i, j, realX, realZ, output, cave, lastSolid - 1, emptyFor);
emptyFor = 0; emptyFor = 0;
} }
lastSolid = k; lastSolid = k;
@@ -131,10 +124,8 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
} }
} }
} }
});
} }
burst.complete();
getEngine().getMetrics().getDecoration().put(p.getMilliseconds()); getEngine().getMetrics().getDecoration().put(p.getMilliseconds());
} }

View File

@@ -23,10 +23,10 @@ import com.volmit.iris.engine.framework.EngineAssignedActuator;
import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisRegion; import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.scheduling.PrecisionStopwatch; import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Material; import org.bukkit.Material;
@@ -50,17 +50,13 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
@BlockCoordinates @BlockCoordinates
@Override @Override
public void onActuate(int x, int z, Hunk<BlockData> h, boolean multicore) { public void onActuate(int x, int z, Hunk<BlockData> h, boolean multicore, ChunkContext context) {
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
BurstExecutor e = burst().burst(multicore);
for (int xf = 0; xf < h.getWidth(); xf++) { for (int xf = 0; xf < h.getWidth(); xf++) {
int finalXf = xf; terrainSliver(x, z, xf, h, context);
e.queue(() -> terrainSliver(x, z, finalXf, h));
} }
e.complete();
getEngine().getMetrics().getTerrain().put(p.getMilliseconds()); getEngine().getMetrics().getTerrain().put(p.getMilliseconds());
} }
@@ -71,17 +67,13 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
/** /**
* This is calling 1/16th of a chunk x/z slice. It is a plane from sky to bedrock 1 thick in the x direction. * This is calling 1/16th of a chunk x/z slice. It is a plane from sky to bedrock 1 thick in the x direction.
* *
* @param x * @param x the chunk x in blocks
* the chunk x in blocks * @param z the chunk z in blocks
* @param z * @param xf the current x slice
* the chunk z in blocks * @param h the blockdata
* @param xf
* the current x slice
* @param h
* the blockdata
*/ */
@BlockCoordinates @BlockCoordinates
public void terrainSliver(int x, int z, int xf, Hunk<BlockData> h) { public void terrainSliver(int x, int z, int xf, Hunk<BlockData> h, ChunkContext context) {
int zf, realX, realZ, hf, he; int zf, realX, realZ, hf, he;
IrisBiome biome; IrisBiome biome;
IrisRegion region; IrisRegion region;
@@ -89,9 +81,9 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
for (zf = 0; zf < h.getDepth(); zf++) { for (zf = 0; zf < h.getDepth(); zf++) {
realX = xf + x; realX = xf + x;
realZ = zf + z; realZ = zf + z;
biome = getComplex().getTrueBiomeStream().get(realX, realZ); biome = context.getBiome().get(xf, zf);
region = getComplex().getRegionStream().get(realX, realZ); region = context.getRegion().get(xf, zf);
he = (int) Math.round(Math.min(h.getHeight(), getComplex().getHeightStream().get(realX, realZ))); he = (int) Math.round(Math.min(h.getHeight(), context.getHeight().get(xf, zf)));
hf = Math.round(Math.max(Math.min(h.getHeight(), getDimension().getFluidHeight()), he)); hf = Math.round(Math.max(Math.min(h.getHeight(), getDimension().getFluidHeight()), he));
if (hf < 0) { if (hf < 0) {
@@ -126,7 +118,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
continue; continue;
} }
h.set(xf, i, zf, getComplex().getFluidStream().get(realX, +realZ)); h.set(xf, i, zf, context.getFluid().get(xf, zf));
continue; continue;
} }
@@ -153,7 +145,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
if (ore != null) { if (ore != null) {
h.set(xf, i, zf, ore); h.set(xf, i, zf, ore);
} else { } else {
h.set(xf, i, zf, getComplex().getRockStream().get(realX, realZ)); h.set(xf, i, zf, context.getRock().get(xf, zf));
} }
} }
} }

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.engine.data.chunk; package com.volmit.iris.engine.data.chunk;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.BiomeBaseInjector; import com.volmit.iris.core.nms.BiomeBaseInjector;
import com.volmit.iris.core.nms.INMS; import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.util.data.IrisBiomeStorage; import com.volmit.iris.util.data.IrisBiomeStorage;
@@ -38,7 +37,7 @@ public class LinkedTerrainChunk implements TerrainChunk {
private final BiomeGrid storage; private final BiomeGrid storage;
private ChunkData rawChunkData; private ChunkData rawChunkData;
@Setter @Setter
private boolean unsafe = false; private boolean unsafe = true;
public LinkedTerrainChunk(World world) { public LinkedTerrainChunk(World world) {
this(null, Bukkit.createChunkData(world)); this(null, Bukkit.createChunkData(world));

View File

@@ -49,10 +49,8 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
/** /**
* Get biome at x, z within chunk being generated * Get biome at x, z within chunk being generated
* *
* @param x * @param x - 0-15
* - 0-15 * @param z - 0-15
* @param z
* - 0-15
* @return Biome value * @return Biome value
* @deprecated biomes are now 3-dimensional * @deprecated biomes are now 3-dimensional
*/ */
@@ -63,12 +61,9 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
/** /**
* Get biome at x, z within chunk being generated * Get biome at x, z within chunk being generated
* *
* @param x * @param x - 0-15
* - 0-15 * @param y - 0-255
* @param y * @param z - 0-15
* - 0-255
* @param z
* - 0-15
* @return Biome value * @return Biome value
*/ */
Biome getBiome(int x, int y, int z); Biome getBiome(int x, int y, int z);
@@ -76,12 +71,9 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
/** /**
* Set biome at x, z within chunk being generated * Set biome at x, z within chunk being generated
* *
* @param x * @param x - 0-15
* - 0-15 * @param z - 0-15
* @param z * @param bio - Biome value
* - 0-15
* @param bio
* - Biome value
* @deprecated biomes are now 3-dimensional * @deprecated biomes are now 3-dimensional
*/ */
@Deprecated @Deprecated
@@ -90,14 +82,10 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
/** /**
* Set biome at x, z within chunk being generated * Set biome at x, z within chunk being generated
* *
* @param x * @param x - 0-15
* - 0-15 * @param y - 0-255
* @param y * @param z - 0-15
* - 0-255 * @param bio - Biome value
* @param z
* - 0-15
* @param bio
* - Biome value
*/ */
void setBiome(int x, int y, int z, Biome bio); void setBiome(int x, int y, int z, Biome bio);
@@ -115,15 +103,11 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
* <p> * <p>
* Setting blocks outside the chunk's bounds does nothing. * Setting blocks outside the chunk's bounds does nothing.
* *
* @param x * @param x the x location in the chunk from 0-15 inclusive
* the x location in the chunk from 0-15 inclusive * @param y the y location in the chunk from 0 (inclusive) - maxHeight
* @param y
* the y location in the chunk from 0 (inclusive) - maxHeight
* (exclusive) * (exclusive)
* @param z * @param z the z location in the chunk from 0-15 inclusive
* the z location in the chunk from 0-15 inclusive * @param blockData the type to set the block to
* @param blockData
* the type to set the block to
*/ */
void setBlock(int x, int y, int z, BlockData blockData); void setBlock(int x, int y, int z, BlockData blockData);
@@ -132,13 +116,10 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
* <p> * <p>
* Getting blocks outside the chunk's bounds returns air. * Getting blocks outside the chunk's bounds returns air.
* *
* @param x * @param x the x location in the chunk from 0-15 inclusive
* the x location in the chunk from 0-15 inclusive * @param y the y location in the chunk from 0 (inclusive) - maxHeight
* @param y
* the y location in the chunk from 0 (inclusive) - maxHeight
* (exclusive) * (exclusive)
* @param z * @param z the z location in the chunk from 0-15 inclusive
* the z location in the chunk from 0-15 inclusive
* @return the data of the block or the BlockData for air if x, y or z are * @return the data of the block or the BlockData for air if x, y or z are
* outside the chunk's bounds * outside the chunk's bounds
*/ */

View File

@@ -18,12 +18,7 @@
package com.volmit.iris.engine.data.io; package com.volmit.iris.engine.data.io;
import java.io.BufferedInputStream; import java.io.*;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL; import java.net.URL;
public interface Deserializer<T> { public interface Deserializer<T> {

View File

@@ -18,12 +18,7 @@
package com.volmit.iris.engine.data.io; package com.volmit.iris.engine.data.io;
import java.io.BufferedOutputStream; import java.io.*;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public interface Serializer<T> { public interface Serializer<T> {

View File

@@ -18,13 +18,7 @@
package com.volmit.iris.engine.data.io; package com.volmit.iris.engine.data.io;
import java.io.File; import java.io.*;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
public interface StringDeserializer<T> extends Deserializer<T> { public interface StringDeserializer<T> extends Deserializer<T> {

View File

@@ -18,13 +18,7 @@
package com.volmit.iris.engine.data.io; package com.volmit.iris.engine.data.io;
import java.io.File; import java.io.*;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.io.Writer;
public interface StringSerializer<T> extends Serializer<T> { public interface StringSerializer<T> extends Serializer<T> {

View File

@@ -23,11 +23,13 @@ import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisDecorationPart; import com.volmit.iris.engine.object.IrisDecorationPart;
import com.volmit.iris.engine.object.IrisDecorator; import com.volmit.iris.engine.object.IrisDecorator;
import com.volmit.iris.util.data.B;
import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.Hunk;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.MultipleFacing;
import org.bukkit.block.data.type.PointedDripstone; import org.bukkit.block.data.type.PointedDripstone;
public class IrisCeilingDecorator extends IrisEngineDecorator { public class IrisCeilingDecorator extends IrisEngineDecorator {
@@ -39,11 +41,10 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
@Override @Override
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) { public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) {
IrisDecorator decorator = getDecorator(biome, realX, realZ); IrisDecorator decorator = getDecorator(biome, realX, realZ);
if (decorator != null) { if (decorator != null) {
if (!decorator.isStacking()) { if (!decorator.isStacking()) {
if (height >= 0 || height < getEngine().getHeight()) { if (height >= 0 || height < getEngine().getHeight()) {
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData())); data.set(x, height, z, fixFaces(decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()), realX, height, realZ));
} }
} else { } else {
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
@@ -98,4 +99,24 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
} }
} }
} }
private BlockData fixFaces(BlockData b, int x, int y, int z) {
if (B.isVineBlock(b)) {
MultipleFacing data = (MultipleFacing) b.clone();
boolean found = false;
for (BlockFace f : BlockFace.values()) {
if (!f.isCartesian())
continue;
Material m = getEngine().getMantle().get(x + f.getModX(), y + f.getModY(), z + f.getModZ()).getMaterial();
if (m.isSolid()) {
found = true;
data.setFace(f, m.isSolid());
}
}
if (!found)
data.setFace(BlockFace.UP, true);
return data;
}
return b;
}
} }

View File

@@ -25,12 +25,14 @@ import com.volmit.iris.engine.object.InferredType;
import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisDecorationPart; import com.volmit.iris.engine.object.IrisDecorationPart;
import com.volmit.iris.engine.object.IrisDecorator; import com.volmit.iris.engine.object.IrisDecorator;
import com.volmit.iris.util.data.B;
import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.Hunk;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.data.Bisected; import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.MultipleFacing;
import org.bukkit.block.data.type.PointedDripstone; import org.bukkit.block.data.type.PointedDripstone;
public class IrisSurfaceDecorator extends IrisEngineDecorator { public class IrisSurfaceDecorator extends IrisEngineDecorator {
@@ -55,7 +57,18 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
bd = decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()); bd = decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData());
if (!underwater) { if (!underwater) {
if(!canGoOn(bd, bdx)) { if (!canGoOn(bd, bdx) && (!decorator.isForcePlace() && decorator.getForceBlock() == null)) {
return;
}
}
if (decorator.getForceBlock() != null) {
data.set(x, height, z, fixFaces(decorator.getForceBlock().getBlockData(getData()), x, height, z));
} else if (!decorator.isForcePlace()) {
if (decorator.getWhitelist() != null && decorator.getWhitelist().stream().noneMatch(d -> d.getBlockData(getData()).equals(bdx))) {
return;
}
if (decorator.getBlacklist() != null && decorator.getWhitelist().stream().anyMatch(d -> d.getBlockData(getData()).equals(bdx))) {
return; return;
} }
} }
@@ -72,8 +85,9 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
((Bisected) bd).setHalf(Bisected.Half.BOTTOM); ((Bisected) bd).setHalf(Bisected.Half.BOTTOM);
} }
data.set(x, height + 1, z, bd); if (B.isAir(data.get(x, height + 1, z))) {
data.set(x, height + 1, z, fixFaces(bd, x, height + 1, z));
}
} else { } else {
if (height < getDimension().getFluidHeight()) { if (height < getDimension().getFluidHeight()) {
max = getDimension().getFluidHeight(); max = getDimension().getFluidHeight();
@@ -139,4 +153,24 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
} }
} }
} }
private BlockData fixFaces(BlockData b, int x, int y, int z) {
if (B.isVineBlock(b)) {
MultipleFacing data = (MultipleFacing) b.clone();
boolean found = false;
for (BlockFace f : BlockFace.values()) {
if (!f.isCartesian())
continue;
Material m = getEngine().getMantle().get(x + f.getModX(), y + f.getModY(), z + f.getModZ()).getMaterial();
if (m.isSolid()) {
found = true;
data.setFace(f, m.isSolid());
}
}
if (!found)
data.setFace(BlockFace.UP, true);
return data;
}
return b;
}
} }

View File

@@ -24,7 +24,6 @@ import com.volmit.iris.core.gui.components.RenderType;
import com.volmit.iris.core.gui.components.Renderer; import com.volmit.iris.core.gui.components.Renderer;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.loader.IrisRegistrant; import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.IrisComplex; import com.volmit.iris.engine.IrisComplex;
import com.volmit.iris.engine.data.cache.Cache; import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.data.chunk.TerrainChunk; import com.volmit.iris.engine.data.chunk.TerrainChunk;
@@ -33,6 +32,7 @@ import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.scripting.EngineExecutionEnvironment; import com.volmit.iris.engine.scripting.EngineExecutionEnvironment;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.context.IrisContext; import com.volmit.iris.util.context.IrisContext;
import com.volmit.iris.util.data.B; import com.volmit.iris.util.data.B;
import com.volmit.iris.util.data.DataProvider; import com.volmit.iris.util.data.DataProvider;
@@ -56,6 +56,7 @@ import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.PrecisionStopwatch; import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import com.volmit.iris.util.stream.ProceduralStream; import com.volmit.iris.util.stream.ProceduralStream;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import net.minecraft.core.BlockPos;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
@@ -69,8 +70,9 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import oshi.util.tuples.Pair;
import java.awt.Color; import java.awt.*;
import java.util.Arrays; import java.util.Arrays;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@@ -195,7 +197,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
return getComplex().getRegionStream().get(x, z); return getComplex().getRegionStream().get(x, z);
} }
void generateMatter(int x, int z, boolean multicore); void generateMatter(int x, int z, boolean multicore, ChunkContext context);
@BlockCoordinates @BlockCoordinates
default IrisBiome getCaveOrMantleBiome(int x, int y, int z) { default IrisBiome getCaveOrMantleBiome(int x, int y, int z) {
@@ -215,6 +217,9 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
@ChunkCoordinates @ChunkCoordinates
Set<String> getObjectsAt(int x, int z); Set<String> getObjectsAt(int x, int z);
@ChunkCoordinates
Set<Pair<String, BlockPos>> getPOIsAt(int x, int z);
@ChunkCoordinates @ChunkCoordinates
IrisJigsawStructure getStructureAt(int x, int z); IrisJigsawStructure getStructureAt(int x, int z);
@@ -422,21 +427,27 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
default KList<IrisLootTable> getLootTables(RNG rng, Block b) { default KList<IrisLootTable> getLootTables(RNG rng, Block b) {
int rx = b.getX(); int rx = b.getX();
int rz = b.getZ(); int rz = b.getZ();
int ry = b.getY() - getWorld().minHeight();
double he = getComplex().getHeightStream().get(rx, rz); double he = getComplex().getHeightStream().get(rx, rz);
PlacedObject po = getObjectPlacement(rx, b.getY(), rz); KList<IrisLootTable> tables = new KList<>();
if(po != null && po.getPlacement() != null) {
PlacedObject po = getObjectPlacement(rx, ry, rz);
if (po != null && po.getPlacement() != null) {
if (B.isStorageChest(b.getBlockData())) { if (B.isStorageChest(b.getBlockData())) {
IrisLootTable table = po.getPlacement().getTable(b.getBlockData(), getData()); IrisLootTable table = po.getPlacement().getTable(b.getBlockData(), getData());
if (table != null) { if (table != null) {
tables.add(table);
if (po.getPlacement().isOverrideGlobalLoot()) {
return new KList<>(table); return new KList<>(table);
} }
} }
} }
}
IrisRegion region = getComplex().getRegionStream().get(rx, rz); IrisRegion region = getComplex().getRegionStream().get(rx, rz);
IrisBiome biomeSurface = getComplex().getTrueBiomeStream().get(rx, rz); IrisBiome biomeSurface = getComplex().getTrueBiomeStream().get(rx, rz);
IrisBiome biomeUnder = b.getY() < he ? getComplex().getCaveBiomeStream().get(rx, rz) : biomeSurface; IrisBiome biomeUnder = ry < he ? getComplex().getCaveBiomeStream().get(rx, rz) : biomeSurface;
KList<IrisLootTable> tables = new KList<>();
double multiplier = 1D * getDimension().getLoot().getMultiplier() * region.getLoot().getMultiplier() * biomeSurface.getLoot().getMultiplier() * biomeUnder.getLoot().getMultiplier(); double multiplier = 1D * getDimension().getLoot().getMultiplier() * region.getLoot().getMultiplier() * biomeSurface.getLoot().getMultiplier() * biomeUnder.getLoot().getMultiplier();
injectTables(tables, getDimension().getLoot()); injectTables(tables, getDimension().getLoot());
injectTables(tables, region.getLoot()); injectTables(tables, region.getLoot());
@@ -467,7 +478,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
if (i == null) if (i == null)
continue; continue;
b++; b++;
items.addAll(i.getLoot(debug, items.isEmpty(), rng, slot, x, y, z, b + b, mgf + b)); items.addAll(i.getLoot(debug, rng, slot, x, y, z));
} }
if (PaperLib.isPaper() && getWorld().hasRealWorld()) { if (PaperLib.isPaper() && getWorld().hasRealWorld()) {
@@ -507,7 +518,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
@BlockCoordinates @BlockCoordinates
default IrisBiome getBiome(Location l) { default IrisBiome getBiome(Location l) {
return getBiome(l.getBlockX(), l.getBlockY(), l.getBlockZ()); return getBiome(l.getBlockX(), l.getBlockY() - getWorld().minHeight(), l.getBlockZ());
} }
@BlockCoordinates @BlockCoordinates
@@ -901,6 +912,10 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
Locator.region(r.getLoadKey()).find(player); Locator.region(r.getLoadKey()).find(player);
} }
default void gotoPOI(String type, Player p) {
Locator.poi(type).find(p);
}
default void cleanupMantleChunk(int x, int z) { default void cleanupMantleChunk(int x, int z) {
if (IrisSettings.get().getPerformance().isTrimMantleInStudio() || !isStudio()) { if (IrisSettings.get().getPerformance().isTrimMantleInStudio() || !isStudio()) {
J.a(() -> getMantle().cleanupChunk(x, z)); J.a(() -> getMantle().cleanupChunk(x, z));

View File

@@ -18,10 +18,11 @@
package com.volmit.iris.engine.framework; package com.volmit.iris.engine.framework;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.Hunk;
public interface EngineActuator<O> extends EngineComponent { public interface EngineActuator<O> extends EngineComponent {
@BlockCoordinates @BlockCoordinates
void actuate(int x, int z, Hunk<O> output, boolean multicore); void actuate(int x, int z, Hunk<O> output, boolean multicore, ChunkContext context);
} }

View File

@@ -18,6 +18,7 @@
package com.volmit.iris.engine.framework; package com.volmit.iris.engine.framework;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.Hunk;
@@ -26,11 +27,11 @@ public abstract class EngineAssignedActuator<T> extends EngineAssignedComponent
super(engine, name); super(engine, name);
} }
public abstract void onActuate(int x, int z, Hunk<T> output, boolean multicore); public abstract void onActuate(int x, int z, Hunk<T> output, boolean multicore, ChunkContext context);
@BlockCoordinates @BlockCoordinates
@Override @Override
public void actuate(int x, int z, Hunk<T> output, boolean multicore) { public void actuate(int x, int z, Hunk<T> output, boolean multicore, ChunkContext context) {
onActuate(x, z, output, multicore); onActuate(x, z, output, multicore, context);
} }
} }

View File

@@ -19,6 +19,7 @@
package com.volmit.iris.engine.framework; package com.volmit.iris.engine.framework;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.Hunk;
@@ -28,13 +29,13 @@ public abstract class EngineAssignedModifier<T> extends EngineAssignedComponent
} }
@BlockCoordinates @BlockCoordinates
public abstract void onModify(int x, int z, Hunk<T> output, boolean multicore); public abstract void onModify(int x, int z, Hunk<T> output, boolean multicore, ChunkContext context);
@BlockCoordinates @BlockCoordinates
@Override @Override
public void modify(int x, int z, Hunk<T> output, boolean multicore) { public void modify(int x, int z, Hunk<T> output, boolean multicore, ChunkContext context) {
try { try {
onModify(x, z, output, multicore); onModify(x, z, output, multicore, context);
} catch (Throwable e) { } catch (Throwable e) {
Iris.error("Modifier Failure: " + getName()); Iris.error("Modifier Failure: " + getName());
e.printStackTrace(); e.printStackTrace();

View File

@@ -24,28 +24,25 @@ import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.Position2; import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import io.papermc.lib.PaperLib; import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.EnderSignal; import org.bukkit.entity.EnderSignal;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.WorldSaveEvent; import org.bukkit.event.world.WorldSaveEvent;
import org.bukkit.event.world.WorldUnloadEvent; import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.inventory.EquipmentSlot;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
public abstract class EngineAssignedWorldManager extends EngineAssignedComponent implements EngineWorldManager, Listener { public abstract class EngineAssignedWorldManager extends EngineAssignedComponent implements EngineWorldManager, Listener {
private final int taskId; private final int taskId;
protected AtomicBoolean ignoreTP = new AtomicBoolean(false);
public EngineAssignedWorldManager() { public EngineAssignedWorldManager() {
super(null, null); super(null, null);
@@ -67,8 +64,6 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent
} }
} }
protected AtomicBoolean ignoreTP = new AtomicBoolean(false);
// @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) // @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
// public void on(PlayerTeleportEvent e) { // public void on(PlayerTeleportEvent e) {
// if(ignoreTP.get()) { // if(ignoreTP.get()) {
@@ -103,35 +98,43 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent
} }
@EventHandler @EventHandler
public void on(EntitySpawnEvent e) { public void onItemUse(PlayerInteractEvent e) {
if(e.getEntity().getWorld().equals(getTarget().getWorld().realWorld())) { if (e.getItem() == null || e.getHand() != EquipmentSlot.HAND) {
if(e.getEntityType().equals(EntityType.ENDER_SIGNAL)) { return;
KList<Position2> p = getEngine().getDimension().getStrongholds(getEngine().getSeedManager().getSpawn()); }
Position2 px = new Position2(e.getEntity().getLocation().getBlockX(), e.getEntity().getLocation().getBlockZ()); if (e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_AIR) {
Position2 pr = null; return;
double d = Double.MAX_VALUE; }
if (e.getPlayer().getWorld().equals(getTarget().getWorld().realWorld()) && e.getItem().getType() == Material.ENDER_EYE) {
Iris.debug("Ps: " + p.size()); KList<Position2> positions = getEngine().getDimension().getStrongholds(getEngine().getSeedManager().getSpawn());
if (positions.isEmpty()) {
for(Position2 i : p) { return;
Iris.debug("- " + i.getX() + " " + i.getZ());
} }
for(Position2 i : p) { Position2 playerPos = new Position2(e.getPlayer().getLocation().getBlockX(), e.getPlayer().getLocation().getBlockZ());
double dx = i.distance(px); Position2 pr = positions.get(0);
if(dx < d) { double d = pr.distance(playerPos);
d = dx;
pr = i; for (Position2 pos : positions) {
double distance = pos.distance(playerPos);
if (distance < d) {
d = distance;
pr = pos;
} }
} }
if(pr != null) { if (e.getPlayer().getGameMode() != GameMode.CREATIVE) {
e.getEntity().getWorld().playSound(e.getEntity().getLocation(), Sound.ITEM_TRIDENT_THROW, 1f, 1.6f); if (e.getItem().getAmount() > 1) {
Location ll = new Location(e.getEntity().getWorld(), pr.getX(), 40, pr.getZ()); e.getPlayer().getInventory().getItemInMainHand().setAmount(e.getItem().getAmount() - 1);
Iris.debug("ESignal: " + ll.getBlockX() + " " + ll.getBlockZ()); } else {
((EnderSignal) e.getEntity()).setTargetLocation(ll); e.getPlayer().getInventory().setItemInMainHand(null);
} }
} }
EnderSignal eye = e.getPlayer().getWorld().spawn(e.getPlayer().getLocation().clone().add(0, 0.5F, 0), EnderSignal.class);
eye.setTargetLocation(new Location(e.getPlayer().getWorld(), pr.getX(), 40, pr.getZ()));
eye.getWorld().playSound(eye, Sound.ENTITY_ENDER_EYE_LAUNCH, 1, 1);
Iris.debug("ESignal: " + eye.getTargetLocation().getBlockX() + " " + eye.getTargetLocation().getBlockX());
} }
} }

View File

@@ -20,14 +20,20 @@ package com.volmit.iris.engine.framework;
import com.volmit.iris.engine.IrisComplex; import com.volmit.iris.engine.IrisComplex;
import com.volmit.iris.engine.mantle.EngineMantle; import com.volmit.iris.engine.mantle.EngineMantle;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.context.IrisContext;
import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.math.RollingSequence;
import com.volmit.iris.util.parallel.BurstExecutor; import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst; import com.volmit.iris.util.parallel.MultiBurst;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
public interface EngineMode extends Staged { public interface EngineMode extends Staged {
public static final RollingSequence r = new RollingSequence(64);
public static final RollingSequence r2 = new RollingSequence(256);
void close(); void close();
Engine getEngine(); Engine getEngine();
@@ -37,12 +43,12 @@ public interface EngineMode extends Staged {
} }
default EngineStage burst(EngineStage... stages) { default EngineStage burst(EngineStage... stages) {
return (x, z, blocks, biomes, multicore) -> { return (x, z, blocks, biomes, multicore, ctx) -> {
BurstExecutor e = burst().burst(stages.length); BurstExecutor e = burst().burst(stages.length);
e.setMulticore(multicore); e.setMulticore(multicore);
for (EngineStage i : stages) { for (EngineStage i : stages) {
e.queue(() -> i.generate(x, z, blocks, biomes, multicore)); e.queue(() -> i.generate(x, z, blocks, biomes, multicore, ctx));
} }
e.complete(); e.complete();
@@ -57,14 +63,17 @@ public interface EngineMode extends Staged {
return getEngine().getMantle(); return getEngine().getMantle();
} }
default void generateMatter(int x, int z, boolean multicore) { default void generateMatter(int x, int z, boolean multicore, ChunkContext context) {
getMantle().generateMatter(x, z, multicore); getMantle().generateMatter(x, z, multicore, context);
} }
@BlockCoordinates @BlockCoordinates
default void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore) { default void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore) {
ChunkContext ctx = new ChunkContext(x, z, getComplex());
IrisContext.getOr(getEngine()).setChunkContext(ctx);
for (EngineStage i : getStages()) { for (EngineStage i : getStages()) {
i.generate(x, z, blocks, biomes, multicore); i.generate(x, z, blocks, biomes, multicore, ctx);
} }
} }
} }

View File

@@ -18,10 +18,11 @@
package com.volmit.iris.engine.framework; package com.volmit.iris.engine.framework;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.Hunk;
public interface EngineModifier<T> extends EngineComponent { public interface EngineModifier<T> extends EngineComponent {
@BlockCoordinates @BlockCoordinates
void modify(int x, int z, Hunk<T> t, boolean multicore); void modify(int x, int z, Hunk<T> t, boolean multicore, ChunkContext context);
} }

View File

@@ -19,6 +19,7 @@
package com.volmit.iris.engine.framework; package com.volmit.iris.engine.framework;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisEffect; import com.volmit.iris.engine.object.IrisEffect;
import com.volmit.iris.engine.object.IrisRegion; import com.volmit.iris.engine.object.IrisRegion;
@@ -48,6 +49,9 @@ public class EnginePlayer {
public void tick() { public void tick() {
sample(); sample();
if (!IrisSettings.get().getWorld().isEffectSystem())
return;
J.a(() -> { J.a(() -> {
if (region != null) { if (region != null) {
for (IrisEffect j : region.getEffects()) { for (IrisEffect j : region.getEffects()) {

View File

@@ -18,6 +18,7 @@
package com.volmit.iris.engine.framework; package com.volmit.iris.engine.framework;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.Hunk;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
@@ -25,7 +26,7 @@ import org.bukkit.block.data.BlockData;
public interface EngineStage { public interface EngineStage {
@BlockCoordinates @BlockCoordinates
void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore); void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore, ChunkContext context);
default void close() { default void close() {
if (this instanceof EngineComponent c) { if (this instanceof EngineComponent c) {

View File

@@ -24,6 +24,7 @@ import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisJigsawStructure; import com.volmit.iris.engine.object.IrisJigsawStructure;
import com.volmit.iris.engine.object.IrisObject; import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.engine.object.IrisRegion; import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.math.M; import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.Position2; import com.volmit.iris.util.math.Position2;
@@ -35,9 +36,12 @@ import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.PrecisionStopwatch; import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import com.volmit.iris.util.scheduling.jobs.SingleJob; import com.volmit.iris.util.scheduling.jobs.SingleJob;
import net.minecraft.core.BlockPos;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import oshi.util.tuples.Pair;
import java.util.Set;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@@ -48,8 +52,6 @@ import java.util.function.Consumer;
@FunctionalInterface @FunctionalInterface
public interface Locator<T> { public interface Locator<T> {
boolean matches(Engine engine, Position2 chunk);
static void cancelSearch() { static void cancelSearch() {
if (LocatorCanceller.cancel != null) { if (LocatorCanceller.cancel != null) {
LocatorCanceller.cancel.run(); LocatorCanceller.cancel.run();
@@ -57,6 +59,56 @@ public interface Locator<T> {
} }
} }
static Locator<IrisRegion> region(String loadKey) {
return (e, c) -> e.getRegion((c.getX() << 4) + 8, (c.getZ() << 4) + 8).getLoadKey().equals(loadKey);
}
static Locator<IrisJigsawStructure> jigsawStructure(String loadKey) {
return (e, c) -> {
IrisJigsawStructure s = e.getStructureAt(c.getX(), c.getZ());
return s != null && s.getLoadKey().equals(loadKey);
};
}
static Locator<IrisObject> object(String loadKey) {
return (e, c) -> e.getObjectsAt(c.getX(), c.getZ()).contains(loadKey);
}
static Locator<IrisBiome> surfaceBiome(String loadKey) {
return (e, c) -> e.getSurfaceBiome((c.getX() << 4) + 8, (c.getZ() << 4) + 8).getLoadKey().equals(loadKey);
}
static Locator<BlockPos> poi(String type) {
return (e, c) -> {
Set<Pair<String, BlockPos>> pos = e.getPOIsAt((c.getX() << 4) + 8, (c.getZ() << 4) + 8);
return pos.stream().anyMatch(p -> p.getA().equals(type));
};
}
static Locator<IrisBiome> caveBiome(String loadKey) {
return (e, c) -> e.getCaveBiome((c.getX() << 4) + 8, (c.getZ() << 4) + 8).getLoadKey().equals(loadKey);
}
static Locator<IrisBiome> caveOrMantleBiome(String loadKey) {
return (e, c) -> {
AtomicBoolean found = new AtomicBoolean(false);
e.generateMatter(c.getX(), c.getZ(), true, new ChunkContext(c.getX() << 4, c.getZ() << 4, e.getComplex(), false));
e.getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), MatterCavern.class, (x, y, z, t) -> {
if (found.get()) {
return;
}
if (t != null && t.getCustomBiome().equals(loadKey)) {
found.set(true);
}
});
return found.get();
};
}
boolean matches(Engine engine, Position2 chunk);
default void find(Player player) { default void find(Player player) {
find(player, 30_000); find(player, 30_000);
} }
@@ -148,45 +200,4 @@ public interface Locator<T> {
return null; return null;
}); });
} }
static Locator<IrisRegion> region(String loadKey) {
return (e, c) -> e.getRegion((c.getX() << 4) + 8, (c.getZ() << 4) + 8).getLoadKey().equals(loadKey);
}
static Locator<IrisJigsawStructure> jigsawStructure(String loadKey) {
return (e, c) -> {
IrisJigsawStructure s = e.getStructureAt(c.getX(), c.getZ());
return s != null && s.getLoadKey().equals(loadKey);
};
}
static Locator<IrisObject> object(String loadKey) {
return (e, c) -> e.getObjectsAt(c.getX(), c.getZ()).contains(loadKey);
}
static Locator<IrisBiome> surfaceBiome(String loadKey) {
return (e, c) -> e.getSurfaceBiome((c.getX() << 4) + 8, (c.getZ() << 4) + 8).getLoadKey().equals(loadKey);
}
static Locator<IrisBiome> caveBiome(String loadKey) {
return (e, c) -> e.getCaveBiome((c.getX() << 4) + 8, (c.getZ() << 4) + 8).getLoadKey().equals(loadKey);
}
static Locator<IrisBiome> caveOrMantleBiome(String loadKey) {
return (e, c) -> {
AtomicBoolean found = new AtomicBoolean(false);
e.generateMatter(c.getX(), c.getZ(), true);
e.getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), MatterCavern.class, (x, y, z, t) -> {
if(found.get()) {
return;
}
if(t != null && t.getCustomBiome().equals(loadKey)) {
found.set(true);
}
});
return found.get();
};
}
} }

View File

@@ -21,16 +21,7 @@ package com.volmit.iris.engine.jigsaw;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IObjectPlacer; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.InventorySlotType;
import com.volmit.iris.engine.object.IrisJigsawPiece;
import com.volmit.iris.engine.object.IrisJigsawPieceConnector;
import com.volmit.iris.engine.object.IrisLootTable;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.engine.object.IrisObjectRotation;
import com.volmit.iris.engine.object.IrisObjectTranslate;
import com.volmit.iris.engine.object.IrisPosition;
import com.volmit.iris.engine.object.TileData;
import com.volmit.iris.engine.platform.PlatformChunkGenerator; import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.context.IrisContext; import com.volmit.iris.util.context.IrisContext;

View File

@@ -23,16 +23,7 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.data.cache.Cache; import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IObjectPlacer; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.IrisDirection;
import com.volmit.iris.engine.object.IrisJigsawPiece;
import com.volmit.iris.engine.object.IrisJigsawPieceConnector;
import com.volmit.iris.engine.object.IrisJigsawStructure;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.engine.object.IrisObjectPlacement;
import com.volmit.iris.engine.object.IrisObjectRotation;
import com.volmit.iris.engine.object.IrisPosition;
import com.volmit.iris.engine.object.ObjectPlaceMode;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.mantle.Mantle; import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
@@ -107,7 +98,7 @@ public class PlannedStructure {
int zz = i.getPosition().getZ() + sz; int zz = i.getPosition().getZ() + sz;
RNG rngf = new RNG(Cache.key(xx, zz)); RNG rngf = new RNG(Cache.key(xx, zz));
int offset = i.getPosition().getY() - startHeight; int offset = i.getPosition().getY() - startHeight;
int height = 0; int height;
if (i.getStructure().getStructure().getLockY() == -1) { if (i.getStructure().getStructure().getLockY() == -1) {
if (i.getStructure().getStructure().getOverrideYRange() != null) { if (i.getStructure().getStructure().getOverrideYRange() != null) {
@@ -126,8 +117,7 @@ public class PlannedStructure {
} }
int id = rng.i(0, Integer.MAX_VALUE); int id = rng.i(0, Integer.MAX_VALUE);
vo.place(xx, height, zz, placer, options, rng, e.shouldReduce(eng) ? null : (b) vo.place(xx, height, zz, placer, options, rng, (b, data) -> e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id), null, getData());
-> e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id), null, getData());
} }
public void place(World world) { public void place(World world) {
@@ -220,10 +210,7 @@ public class PlannedStructure {
return generateRotatedPiece(piece, pieceConnector, idea, IrisObjectRotation.of(x, y, z)); return generateRotatedPiece(piece, pieceConnector, idea, IrisObjectRotation.of(x, y, z));
} }
private boolean generatePositionedPiece(PlannedPiece piece, private boolean generatePositionedPiece(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector, PlannedPiece test, IrisJigsawPieceConnector testConnector) {
IrisJigsawPieceConnector pieceConnector,
PlannedPiece test,
IrisJigsawPieceConnector testConnector) {
test.setPosition(new IrisPosition(0, 0, 0)); test.setPosition(new IrisPosition(0, 0, 0));
IrisPosition connector = piece.getWorldPosition(pieceConnector); IrisPosition connector = piece.getWorldPosition(pieceConnector);
IrisDirection desiredDirection = pieceConnector.getDirection().reverse(); IrisDirection desiredDirection = pieceConnector.getDirection().reverse();

View File

@@ -30,6 +30,7 @@ import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisPosition; import com.volmit.iris.engine.object.IrisPosition;
import com.volmit.iris.engine.object.TileData; import com.volmit.iris.engine.object.TileData;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.context.IrisContext; import com.volmit.iris.util.context.IrisContext;
import com.volmit.iris.util.data.B; import com.volmit.iris.util.data.B;
import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.BlockCoordinates;
@@ -188,7 +189,8 @@ public interface EngineMantle extends IObjectPlacer {
@ChunkCoordinates @ChunkCoordinates
default void generateMatter(int x, int z, boolean multicore) { default void generateMatter(int x, int z, boolean multicore, ChunkContext context) {
synchronized (this) {
if (!getEngine().getDimension().isUseMantle()) { if (!getEngine().getDimension().isUseMantle()) {
return; return;
} }
@@ -206,7 +208,7 @@ public interface EngineMantle extends IObjectPlacer {
MantleChunk mc = getMantle().getChunk(xx, zz); MantleChunk mc = getMantle().getChunk(xx, zz);
for (MantleComponent k : getComponents()) { for (MantleComponent k : getComponents()) {
generateMantleComponent(writer, xx, zz, k, mc); generateMantleComponent(writer, xx, zz, k, mc, context);
} }
}); });
}); });
@@ -215,9 +217,10 @@ public interface EngineMantle extends IObjectPlacer {
burst.complete(); burst.complete();
} }
}
default void generateMantleComponent(MantleWriter writer, int x, int z, MantleComponent c, MantleChunk mc) { default void generateMantleComponent(MantleWriter writer, int x, int z, MantleComponent c, MantleChunk mc, ChunkContext context) {
mc.raiseFlag(c.getFlag(), () -> c.generateLayer(writer, x, z)); mc.raiseFlag(c.getFlag(), () -> c.generateLayer(writer, x, z, context));
} }
@ChunkCoordinates @ChunkCoordinates

View File

@@ -21,6 +21,7 @@ package com.volmit.iris.engine.mantle;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.IrisComplex; import com.volmit.iris.engine.IrisComplex;
import com.volmit.iris.engine.object.IrisDimension; import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.documentation.ChunkCoordinates; import com.volmit.iris.util.documentation.ChunkCoordinates;
import com.volmit.iris.util.mantle.Mantle; import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.mantle.MantleFlag; import com.volmit.iris.util.mantle.MantleFlag;
@@ -60,5 +61,5 @@ public interface MantleComponent {
MantleFlag getFlag(); MantleFlag getFlag();
@ChunkCoordinates @ChunkCoordinates
void generateLayer(MantleWriter writer, int x, int z); void generateLayer(MantleWriter writer, int x, int z, ChunkContext context);
} }

View File

@@ -123,8 +123,7 @@ public class MantleWriter implements IObjectPlacer {
return (x * x) + (z * z); return (x * x) + (z * z);
} }
public <T> void setDataWarped(int x, int y, int z, T t, RNG rng, IrisData data, IrisGeneratorStyle style) public <T> void setDataWarped(int x, int y, int z, T t, RNG rng, IrisData data, IrisGeneratorStyle style) {
{
setData((int) Math.round(style.warp(rng, data, x, x, y, -z)), setData((int) Math.round(style.warp(rng, data, x, x, y, -z)),
(int) Math.round(style.warp(rng, data, y, z, -x, y)), (int) Math.round(style.warp(rng, data, y, z, -x, y)),
(int) Math.round(style.warp(rng, data, z, -y, z, x)), t); (int) Math.round(style.warp(rng, data, z, -y, z, x)), t);
@@ -219,20 +218,13 @@ public class MantleWriter implements IObjectPlacer {
/** /**
* Set a sphere into the mantle * Set a sphere into the mantle
* *
* @param cx * @param cx the center x
* the center x * @param cy the center y
* @param cy * @param cz the center z
* the center y * @param radius the radius of this sphere
* @param cz * @param fill should it be filled? or just the outer shell?
* the center z * @param data the data to set
* @param radius * @param <T> the type of data to apply to the mantle
* the radius of this sphere
* @param fill
* should it be filled? or just the outer shell?
* @param data
* the data to set
* @param <T>
* the type of data to apply to the mantle
*/ */
public <T> void setSphere(int cx, int cy, int cz, double radius, boolean fill, T data) { public <T> void setSphere(int cx, int cy, int cz, double radius, boolean fill, T data) {
setElipsoid(cx, cy, cz, radius, radius, radius, fill, data); setElipsoid(cx, cy, cz, radius, radius, radius, fill, data);
@@ -249,24 +241,15 @@ public class MantleWriter implements IObjectPlacer {
/** /**
* Set an elipsoid into the mantle * Set an elipsoid into the mantle
* *
* @param cx * @param cx the center x
* the center x * @param cy the center y
* @param cy * @param cz the center z
* the center y * @param rx the x radius
* @param cz * @param ry the y radius
* the center z * @param rz the z radius
* @param rx * @param fill should it be filled or just the outer shell?
* the x radius * @param data the data to set
* @param ry * @param <T> the type of data to apply to the mantle
* the y radius
* @param rz
* the z radius
* @param fill
* should it be filled or just the outer shell?
* @param data
* the data to set
* @param <T>
* the type of data to apply to the mantle
*/ */
public <T> void setElipsoidFunction(int cx, int cy, int cz, double rx, double ry, double rz, boolean fill, Function3<Integer, Integer, Integer, T> data) { public <T> void setElipsoidFunction(int cx, int cy, int cz, double rx, double ry, double rz, boolean fill, Function3<Integer, Integer, Integer, T> data) {
rx += 0.5; rx += 0.5;
@@ -385,22 +368,14 @@ public class MantleWriter implements IObjectPlacer {
/** /**
* Set a cuboid of data in the mantle * Set a cuboid of data in the mantle
* *
* @param x1 * @param x1 the min x
* the min x * @param y1 the min y
* @param y1 * @param z1 the min z
* the min y * @param x2 the max x
* @param z1 * @param y2 the max y
* the min z * @param z2 the max z
* @param x2 * @param data the data to set
* the max x * @param <T> the type of data to apply to the mantle
* @param y2
* the max y
* @param z2
* the max z
* @param data
* the data to set
* @param <T>
* the type of data to apply to the mantle
*/ */
public <T> void setCuboid(int x1, int y1, int z1, int x2, int y2, int z2, T data) { public <T> void setCuboid(int x1, int y1, int z1, int x2, int y2, int z2, T data) {
int j, k; int j, k;
@@ -417,20 +392,13 @@ public class MantleWriter implements IObjectPlacer {
/** /**
* Set a pyramid of data in the mantle * Set a pyramid of data in the mantle
* *
* @param cx * @param cx the center x
* the center x * @param cy the base y
* @param cy * @param cz the center z
* the base y * @param data the data to set
* @param cz * @param size the size of the pyramid (width of base & height)
* the center z * @param filled should it be filled or hollow
* @param data * @param <T> the type of data to apply to the mantle
* the data to set
* @param size
* the size of the pyramid (width of base & height)
* @param filled
* should it be filled or hollow
* @param <T>
* the type of data to apply to the mantle
*/ */
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
public <T> void setPyramid(int cx, int cy, int cz, T data, int size, boolean filled) { public <T> void setPyramid(int cx, int cy, int cz, T data, int size, boolean filled) {
@@ -454,18 +422,12 @@ public class MantleWriter implements IObjectPlacer {
/** /**
* Set a 3d line * Set a 3d line
* *
* @param a * @param a the first point
* the first point * @param b the second point
* @param b * @param radius the radius
* the second point * @param filled hollow or filled?
* @param radius * @param data the data
* the radius * @param <T> the type of data to apply to the mantle
* @param filled
* hollow or filled?
* @param data
* the data
* @param <T>
* the type of data to apply to the mantle
*/ */
public <T> void setLine(IrisPosition a, IrisPosition b, double radius, boolean filled, T data) { public <T> void setLine(IrisPosition a, IrisPosition b, double radius, boolean filled, T data) {
setLine(ImmutableList.of(a, b), radius, filled, data); setLine(ImmutableList.of(a, b), radius, filled, data);
@@ -478,16 +440,11 @@ public class MantleWriter implements IObjectPlacer {
/** /**
* Set lines for points * Set lines for points
* *
* @param vectors * @param vectors the points
* the points * @param radius the radius
* @param radius * @param filled hollow or filled?
* the radius * @param data the data to set
* @param filled * @param <T> the type of data to apply to the mantle
* hollow or filled?
* @param data
* the data to set
* @param <T>
* the type of data to apply to the mantle
*/ */
public <T> void setLineConsumer(List<IrisPosition> vectors, double radius, boolean filled, Function3<Integer, Integer, Integer, T> data) { public <T> void setLineConsumer(List<IrisPosition> vectors, double radius, boolean filled, Function3<Integer, Integer, Integer, T> data) {
Set<IrisPosition> vset = new KSet<>(); Set<IrisPosition> vset = new KSet<>();
@@ -553,20 +510,13 @@ public class MantleWriter implements IObjectPlacer {
/** /**
* Set a cylinder in the mantle * Set a cylinder in the mantle
* *
* @param cx * @param cx the center x
* the center x * @param cy the base y
* @param cy * @param cz the center z
* the base y * @param data the data to set
* @param cz * @param radius the radius
* the center z * @param height the height of the cyl
* @param data * @param filled filled or not
* the data to set
* @param radius
* the radius
* @param height
* the height of the cyl
* @param filled
* filled or not
*/ */
public <T> void setCylinder(int cx, int cy, int cz, T data, double radius, int height, boolean filled) { public <T> void setCylinder(int cx, int cy, int cz, T data, double radius, int height, boolean filled) {
setCylinder(cx, cy, cz, data, radius, radius, height, filled); setCylinder(cx, cy, cz, data, radius, radius, height, filled);
@@ -575,22 +525,14 @@ public class MantleWriter implements IObjectPlacer {
/** /**
* Set a cylinder in the mantle * Set a cylinder in the mantle
* *
* @param cx * @param cx the center x
* the center x * @param cy the base y
* @param cy * @param cz the center z
* the base y * @param data the data to set
* @param cz * @param radiusX the x radius
* the center z * @param radiusZ the z radius
* @param data * @param height the height of this cyl
* the data to set * @param filled filled or hollow?
* @param radiusX
* the x radius
* @param radiusZ
* the z radius
* @param height
* the height of this cyl
* @param filled
* filled or hollow?
*/ */
public <T> void setCylinder(int cx, int cy, int cz, T data, double radiusX, double radiusZ, int height, boolean filled) { public <T> void setCylinder(int cx, int cy, int cz, T data, double radiusX, double radiusZ, int height, boolean filled) {
int affected = 0; int affected = 0;

View File

@@ -25,6 +25,7 @@ import com.volmit.iris.engine.mantle.MantleWriter;
import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisCarving; import com.volmit.iris.engine.object.IrisCarving;
import com.volmit.iris.engine.object.IrisRegion; import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.documentation.ChunkCoordinates; import com.volmit.iris.util.documentation.ChunkCoordinates;
import com.volmit.iris.util.mantle.MantleFlag; import com.volmit.iris.util.mantle.MantleFlag;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
@@ -35,7 +36,7 @@ public class MantleCarvingComponent extends IrisMantleComponent {
} }
@Override @Override
public void generateLayer(MantleWriter writer, int x, int z) { public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
RNG rng = new RNG(Cache.key(x, z) + seed()); RNG rng = new RNG(Cache.key(x, z) + seed());
int xxx = 8 + (x << 4); int xxx = 8 + (x << 4);
int zzz = 8 + (z << 4); int zzz = 8 + (z << 4);

View File

@@ -25,6 +25,7 @@ import com.volmit.iris.engine.mantle.MantleWriter;
import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisFluidBodies; import com.volmit.iris.engine.object.IrisFluidBodies;
import com.volmit.iris.engine.object.IrisRegion; import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.documentation.ChunkCoordinates; import com.volmit.iris.util.documentation.ChunkCoordinates;
import com.volmit.iris.util.mantle.MantleFlag; import com.volmit.iris.util.mantle.MantleFlag;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
@@ -35,7 +36,7 @@ public class MantleFluidBodyComponent extends IrisMantleComponent {
} }
@Override @Override
public void generateLayer(MantleWriter writer, int x, int z) { public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
RNG rng = new RNG(Cache.key(x, z) + seed() + 405666); RNG rng = new RNG(Cache.key(x, z) + seed() + 405666);
int xxx = 8 + (x << 4); int xxx = 8 + (x << 4);
int zzz = 8 + (z << 4); int zzz = 8 + (z << 4);

View File

@@ -22,12 +22,8 @@ import com.volmit.iris.engine.jigsaw.PlannedStructure;
import com.volmit.iris.engine.mantle.EngineMantle; import com.volmit.iris.engine.mantle.EngineMantle;
import com.volmit.iris.engine.mantle.IrisMantleComponent; import com.volmit.iris.engine.mantle.IrisMantleComponent;
import com.volmit.iris.engine.mantle.MantleWriter; import com.volmit.iris.engine.mantle.MantleWriter;
import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.IrisJigsawStructure; import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.engine.object.IrisJigsawStructurePlacement;
import com.volmit.iris.engine.object.IrisPosition;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.engine.object.NoiseStyle;
import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.documentation.ChunkCoordinates; import com.volmit.iris.util.documentation.ChunkCoordinates;
import com.volmit.iris.util.mantle.MantleFlag; import com.volmit.iris.util.mantle.MantleFlag;
@@ -46,7 +42,7 @@ public class MantleJigsawComponent extends IrisMantleComponent {
} }
@Override @Override
public void generateLayer(MantleWriter writer, int x, int z) { public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
RNG rng = new RNG(cng.fit(-Integer.MAX_VALUE, Integer.MAX_VALUE, x, z)); RNG rng = new RNG(cng.fit(-Integer.MAX_VALUE, Integer.MAX_VALUE, x, z));
int xxx = 8 + (x << 4); int xxx = 8 + (x << 4);
int zzz = 8 + (z << 4); int zzz = 8 + (z << 4);

View File

@@ -28,10 +28,13 @@ import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.engine.object.IrisObjectPlacement; import com.volmit.iris.engine.object.IrisObjectPlacement;
import com.volmit.iris.engine.object.IrisRegion; import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.data.B;
import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.documentation.ChunkCoordinates; import com.volmit.iris.util.documentation.ChunkCoordinates;
import com.volmit.iris.util.mantle.MantleFlag; import com.volmit.iris.util.mantle.MantleFlag;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.matter.MatterStructurePOI;
import java.util.Set; import java.util.Set;
@@ -41,7 +44,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
} }
@Override @Override
public void generateLayer(MantleWriter writer, int x, int z) { public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
RNG rng = new RNG(Cache.key(x, z) + seed()); RNG rng = new RNG(Cache.key(x, z) + seed());
int xxx = 8 + (x << 4); int xxx = 8 + (x << 4);
int zzz = 8 + (z << 4); int zzz = 8 + (z << 4);
@@ -95,9 +98,12 @@ public class MantleObjectComponent extends IrisMantleComponent {
int xx = rng.i(x, x + 15); int xx = rng.i(x, x + 15);
int zz = rng.i(z, z + 15); int zz = rng.i(z, z + 15);
int id = rng.i(0, Integer.MAX_VALUE); int id = rng.i(0, Integer.MAX_VALUE);
v.place(xx, -1, zz, writer, objectPlacement, rng, v.place(xx, -1, zz, writer, objectPlacement, rng, (b, data) -> {
getMantle().shouldReduce(getEngineMantle().getEngine()) ? null : (b) -> writer.setData(b.getX(), b.getY(), b.getZ(), writer.setData(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id);
v.getLoadKey() + "@" + id), null, getData()); if (objectPlacement.isDolphinTarget() && objectPlacement.isUnderwater() && B.isStorageChest(data)) {
writer.setData(b.getX(), b.getY(), b.getZ(), MatterStructurePOI.BURIED_TREASURE);
}
}, null, getData());
} }
} }

View File

@@ -31,8 +31,8 @@ public class ModeEnclosure extends IrisEngineMode implements EngineMode {
var biome = new IrisBiomeActuator(getEngine()); var biome = new IrisBiomeActuator(getEngine());
registerStage(burst( registerStage(burst(
(x, z, k, p, m) -> terrain.actuate(x, z, k, m), (x, z, k, p, m, c) -> terrain.actuate(x, z, k, m, c),
(x, z, k, p, m) -> biome.actuate(x, z, p, m) (x, z, k, p, m, c) -> biome.actuate(x, z, p, m, c)
)); ));
} }
} }

View File

@@ -31,8 +31,8 @@ public class ModeIslands extends IrisEngineMode implements EngineMode {
var biome = new IrisBiomeActuator(getEngine()); var biome = new IrisBiomeActuator(getEngine());
registerStage(burst( registerStage(burst(
(x, z, k, p, m) -> terrain.actuate(x, z, k, m), (x, z, k, p, m, c) -> terrain.actuate(x, z, k, m, c),
(x, z, k, p, m) -> biome.actuate(x, z, p, m) (x, z, k, p, m, c) -> biome.actuate(x, z, p, m, c)
)); ));
} }
} }

View File

@@ -23,6 +23,7 @@ import com.volmit.iris.engine.actuator.IrisDecorantActuator;
import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator; import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineMode; import com.volmit.iris.engine.framework.EngineMode;
import com.volmit.iris.engine.framework.EngineStage;
import com.volmit.iris.engine.framework.IrisEngineMode; import com.volmit.iris.engine.framework.IrisEngineMode;
import com.volmit.iris.engine.modifier.IrisCarveModifier; import com.volmit.iris.engine.modifier.IrisCarveModifier;
import com.volmit.iris.engine.modifier.IrisDepositModifier; import com.volmit.iris.engine.modifier.IrisDepositModifier;
@@ -30,7 +31,6 @@ import com.volmit.iris.engine.modifier.IrisPerfectionModifier;
import com.volmit.iris.engine.modifier.IrisPostModifier; import com.volmit.iris.engine.modifier.IrisPostModifier;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
public class ModeOverworld extends IrisEngineMode implements EngineMode { public class ModeOverworld extends IrisEngineMode implements EngineMode {
public ModeOverworld(Engine engine) { public ModeOverworld(Engine engine) {
super(engine); super(engine);
@@ -41,17 +41,30 @@ public class ModeOverworld extends IrisEngineMode implements EngineMode {
var post = new IrisPostModifier(getEngine()); var post = new IrisPostModifier(getEngine());
var deposit = new IrisDepositModifier(getEngine()); var deposit = new IrisDepositModifier(getEngine());
var perfection = new IrisPerfectionModifier(getEngine()); var perfection = new IrisPerfectionModifier(getEngine());
EngineStage sBiome = (x, z, k, p, m, c) -> biome.actuate(x, z, p, m, c);
EngineStage sGenMatter = (x, z, k, p, m, c) -> generateMatter(x >> 4, z >> 4, m, c);
EngineStage sTerrain = (x, z, k, p, m, c) -> terrain.actuate(x, z, k, m, c);
EngineStage sDecorant = (x, z, k, p, m, c) -> decorant.actuate(x, z, k, m, c);
EngineStage sCave = (x, z, k, p, m, c) -> cave.modify(x >> 4, z >> 4, k, m, c);
EngineStage sDeposit = (x, z, k, p, m, c) -> deposit.modify(x, z, k, m, c);
EngineStage sPost = (x, z, k, p, m, c) -> post.modify(x, z, k, m, c);
EngineStage sInsertMatter = (x, z, K, p, m, c) -> getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, K, m);
EngineStage sPerfection = (x, z, k, p, m, c) -> perfection.modify(x, z, k, m, c);
registerStage(burst( registerStage(burst(
(x, z, k, p, m) -> generateMatter(x >> 4, z >> 4, m), sGenMatter,
(x, z, k, p, m) -> terrain.actuate(x, z, k, m), sTerrain
(x, z, k, p, m) -> biome.actuate(x, z, p, m)
)); ));
registerStage((x, z, k, p, m) -> cave.modify(x >> 4, z >> 4, k, m)); registerStage(burst(
registerStage((x, z, k, p, m) -> deposit.modify(x, z, k, m)); sCave,
registerStage((x, z, k, p, m) -> decorant.actuate(x, z, k, m)); sPost
registerStage((x, z, k, p, m) -> post.modify(x, z, k, m)); ));
registerStage((x, z, K, p, m) -> getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, K, m)); registerStage(burst(
registerStage((x, z, k, p, m) -> perfection.modify(x, z, k, m)); sDeposit,
sInsertMatter,
sDecorant
));
registerStage(sPerfection);
} }
} }

View File

@@ -31,8 +31,8 @@ public class ModeSuperFlat extends IrisEngineMode implements EngineMode {
var biome = new IrisBiomeActuator(getEngine()); var biome = new IrisBiomeActuator(getEngine());
registerStage(burst( registerStage(burst(
(x, z, k, p, m) -> terrain.actuate(x, z, k, m), (x, z, k, p, m, c) -> terrain.actuate(x, z, k, m, c),
(x, z, k, p, m) -> biome.actuate(x, z, p, m) (x, z, k, p, m, c) -> biome.actuate(x, z, p, m, c)
)); ));
} }
} }

View File

@@ -22,14 +22,10 @@ import com.volmit.iris.engine.actuator.IrisDecorantActuator;
import com.volmit.iris.engine.data.cache.Cache; import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineAssignedModifier; import com.volmit.iris.engine.framework.EngineAssignedModifier;
import com.volmit.iris.engine.object.InferredType; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisDecorationPart;
import com.volmit.iris.engine.object.IrisDecorator;
import com.volmit.iris.engine.object.IrisPosition;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.context.IrisContext; import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.data.B; import com.volmit.iris.util.data.B;
import com.volmit.iris.util.function.Consumer4; import com.volmit.iris.util.function.Consumer4;
import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.Hunk;
@@ -58,7 +54,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
} }
@Override @Override
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore) { public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore, ChunkContext context) {
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
Mantle mantle = getEngine().getMantle().getMantle(); Mantle mantle = getEngine().getMantle().getMantle();
MantleChunk mc = getEngine().getMantle().getMantle().getChunk(x, z); MantleChunk mc = getEngine().getMantle().getMantle().getChunk(x, z);
@@ -130,7 +126,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
biome.setInferredType(InferredType.CAVE); biome.setInferredType(InferredType.CAVE);
BlockData d = biome.getWall().get(rng, i.getX() + (x << 4), i.getY(), i.getZ() + (z << 4), getData()); BlockData d = biome.getWall().get(rng, i.getX() + (x << 4), i.getY(), i.getZ() + (z << 4), getData());
if(d != null && B.isSolid(output.get(i.getX(), i.getY(), i.getZ())) && i.getY() <= getComplex().getHeightStream().get(i.getX() + (x << 4), i.getZ() + (z << 4))) { if (d != null && B.isSolid(output.get(i.getX(), i.getY(), i.getZ())) && i.getY() <= context.getHeight().get(i.getX(), i.getZ())) {
output.set(i.getX(), i.getY(), i.getZ(), d); output.set(i.getX(), i.getY(), i.getZ(), d);
} }
} }
@@ -156,7 +152,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
if (i == buf + 1) { if (i == buf + 1) {
buf = i; buf = i;
zone.ceiling = buf; zone.ceiling = buf;
} else if(zone.isValid()) { } else if (zone.isValid(getEngine())) {
processZone(output, mc, mantle, zone, rx, rz, rx + (x << 4), rz + (z << 4)); processZone(output, mc, mantle, zone, rx, rz, rx + (x << 4), rz + (z << 4));
zone = new CaveZone(); zone = new CaveZone();
zone.setFloor(i); zone.setFloor(i);
@@ -164,7 +160,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
} }
} }
if(zone.isValid()) { if (zone.isValid(getEngine())) {
processZone(output, mc, mantle, zone, rx, rz, rx + (x << 4), rz + (z << 4)); processZone(output, mc, mantle, zone, rx, rz, rx + (x << 4), rz + (z << 4));
} }
}); });
@@ -275,8 +271,8 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
return (ceiling - floor) - 1; return (ceiling - floor) - 1;
} }
public boolean isValid() { public boolean isValid(Engine engine) {
return floor < ceiling && ceiling - floor >= 1 && floor >= 0 && ceiling <= IrisContext.get().getEngine().getHeight() && airThickness() > 0; return floor < ceiling && ceiling - floor >= 1 && floor >= 0 && ceiling <= engine.getHeight() && airThickness() > 0;
} }
public String toString() { public String toString() {

View File

@@ -24,6 +24,7 @@ import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisDepositGenerator; import com.volmit.iris.engine.object.IrisDepositGenerator;
import com.volmit.iris.engine.object.IrisObject; import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.engine.object.IrisRegion; import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.data.B; import com.volmit.iris.util.data.B;
import com.volmit.iris.util.data.HeightMap; import com.volmit.iris.util.data.HeightMap;
import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.Hunk;
@@ -42,41 +43,41 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
} }
@Override @Override
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore) { public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore, ChunkContext context) {
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
generateDeposits(rng, output, Math.floorDiv(x, 16), Math.floorDiv(z, 16), multicore); generateDeposits(rng, output, Math.floorDiv(x, 16), Math.floorDiv(z, 16), multicore, context);
getEngine().getMetrics().getDeposit().put(p.getMilliseconds()); getEngine().getMetrics().getDeposit().put(p.getMilliseconds());
} }
public void generateDeposits(RNG rx, Hunk<BlockData> terrain, int x, int z, boolean multicore) { public void generateDeposits(RNG rx, Hunk<BlockData> terrain, int x, int z, boolean multicore, ChunkContext context) {
RNG ro = rx.nextParallelRNG(x * x).nextParallelRNG(z * z); RNG ro = rx.nextParallelRNG(x * x).nextParallelRNG(z * z);
IrisRegion region = getComplex().getRegionStream().get((x * 16) + 7, (z * 16) + 7); IrisRegion region = context.getRegion().get(7, 7);
IrisBiome biome = getComplex().getTrueBiomeStream().get((x * 16) + 7, (z * 16) + 7); IrisBiome biome = context.getBiome().get(7, 7);
BurstExecutor burst = burst().burst(multicore); BurstExecutor burst = burst().burst(multicore);
for (IrisDepositGenerator k : getDimension().getDeposits()) { for (IrisDepositGenerator k : getDimension().getDeposits()) {
burst.queue(() -> generate(k, terrain, ro, x, z, false)); burst.queue(() -> generate(k, terrain, ro, x, z, false, context));
} }
for (IrisDepositGenerator k : region.getDeposits()) { for (IrisDepositGenerator k : region.getDeposits()) {
for (int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) { for (int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
burst.queue(() -> generate(k, terrain, ro, x, z, false)); burst.queue(() -> generate(k, terrain, ro, x, z, false, context));
} }
} }
for (IrisDepositGenerator k : biome.getDeposits()) { for (IrisDepositGenerator k : biome.getDeposits()) {
for (int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) { for (int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
burst.queue(() -> generate(k, terrain, ro, x, z, false)); burst.queue(() -> generate(k, terrain, ro, x, z, false, context));
} }
} }
burst.complete(); burst.complete();
} }
public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe) { public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe, ChunkContext context) {
generate(k, data, rng, cx, cz, safe, null); generate(k, data, rng, cx, cz, safe, null, context);
} }
public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe, HeightMap he) { public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe, HeightMap he, ChunkContext context) {
for (int l = 0; l < rng.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) { for (int l = 0; l < rng.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
IrisObject clump = k.getClump(rng, getData()); IrisObject clump = k.getClump(rng, getData());
@@ -92,7 +93,7 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
int x = rng.i(af, bf); int x = rng.i(af, bf);
int z = rng.i(af, bf); int z = rng.i(af, bf);
int height = (he != null ? he.getHeight((cx << 4) + x, (cz << 4) + z) : (int) (Math.round( int height = (he != null ? he.getHeight((cx << 4) + x, (cz << 4) + z) : (int) (Math.round(
getComplex().getHeightStream().get((cx << 4) + x, (cz << 4) + z) context.getHeight().get(x, z)
))) - 7; ))) - 7;
if (height <= 0) { if (height <= 0) {

View File

@@ -20,6 +20,7 @@ package com.volmit.iris.engine.modifier;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineAssignedModifier; import com.volmit.iris.engine.framework.EngineAssignedModifier;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.data.B; import com.volmit.iris.util.data.B;
import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.parallel.BurstExecutor; import com.volmit.iris.util.parallel.BurstExecutor;
@@ -41,7 +42,7 @@ public class IrisPerfectionModifier extends EngineAssignedModifier<BlockData> {
} }
@Override @Override
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore) { public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore, ChunkContext context) {
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
AtomicBoolean changed = new AtomicBoolean(true); AtomicBoolean changed = new AtomicBoolean(true);
int passes = 0; int passes = 0;

View File

@@ -21,6 +21,7 @@ package com.volmit.iris.engine.modifier;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineAssignedModifier; import com.volmit.iris.engine.framework.EngineAssignedModifier;
import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.data.B; import com.volmit.iris.util.data.B;
import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
@@ -28,6 +29,7 @@ import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Levelled; import org.bukkit.block.data.Levelled;
import org.bukkit.block.data.MultipleFacing;
import org.bukkit.block.data.Waterlogged; import org.bukkit.block.data.Waterlogged;
import org.bukkit.block.data.type.Slab; import org.bukkit.block.data.type.Slab;
@@ -44,7 +46,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
} }
@Override @Override
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore) { public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore, ChunkContext context) {
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
AtomicInteger i = new AtomicInteger(); AtomicInteger i = new AtomicInteger();
AtomicInteger j = new AtomicInteger(); AtomicInteger j = new AtomicInteger();
@@ -53,14 +55,14 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
for (j.set(0); j.get() < output.getDepth(); j.getAndIncrement()) { for (j.set(0); j.get() < output.getDepth(); j.getAndIncrement()) {
int ii = i.get(); int ii = i.get();
int jj = j.get(); int jj = j.get();
post(ii, jj, sync, ii + x, jj + z); post(ii, jj, sync, ii + x, jj + z, context);
} }
} }
getEngine().getMetrics().getPost().put(p.getMilliseconds()); getEngine().getMetrics().getPost().put(p.getMilliseconds());
} }
private void post(int currentPostX, int currentPostZ, Hunk<BlockData> currentData, int x, int z) { private void post(int currentPostX, int currentPostZ, Hunk<BlockData> currentData, int x, int z, ChunkContext context) {
int h = getEngine().getMantle().trueHeight(x, z); int h = getEngine().getMantle().trueHeight(x, z);
int ha = getEngine().getMantle().trueHeight(x + 1, z); int ha = getEngine().getMantle().trueHeight(x + 1, z);
int hb = getEngine().getMantle().trueHeight(x, z + 1); int hb = getEngine().getMantle().trueHeight(x, z + 1);
@@ -135,7 +137,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
} }
// Wall Patcher // Wall Patcher
IrisBiome biome = getComplex().getTrueBiomeStream().get(x, z); IrisBiome biome = context.getBiome().get(currentPostX, currentPostZ);
if (getDimension().isPostProcessingWalls()) { if (getDimension().isPostProcessingWalls()) {
if (!biome.getWall().getPalette().isEmpty()) { if (!biome.getWall().getPalette().isEmpty()) {
@@ -221,10 +223,20 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
// Foliage // Foliage
b = getPostBlock(x, h + 1, z, currentPostX, currentPostZ, currentData); b = getPostBlock(x, h + 1, z, currentPostX, currentPostZ, currentData);
if (B.isVineBlock(b) && b instanceof MultipleFacing f) {
int finalH = h + 1;
f.getAllowedFaces().forEach(face -> {
BlockData d = getPostBlock(x + face.getModX(), finalH + face.getModY(), z + face.getModZ(), currentPostX, currentPostZ, currentData);
f.setFace(face, !B.isAir(d) && !B.isVineBlock(d));
});
setPostBlock(x, h + 1, z, b, currentPostX, currentPostZ, currentData);
}
if (B.isFoliage(b) || b.getMaterial().equals(Material.DEAD_BUSH)) { if (B.isFoliage(b) || b.getMaterial().equals(Material.DEAD_BUSH)) {
Material onto = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData).getMaterial(); Material onto = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData).getMaterial();
if(!B.canPlaceOnto(b.getMaterial(), onto)) { if (!B.canPlaceOnto(b.getMaterial(), onto) && !B.isDecorant(b)) {
setPostBlock(x, h + 1, z, AIR, currentPostX, currentPostZ, currentData); setPostBlock(x, h + 1, z, AIR, currentPostX, currentPostZ, currentData);
} }
} }
@@ -242,7 +254,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
public boolean isSolid(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) { public boolean isSolid(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().isSolid(); return d.getMaterial().isSolid() && !B.isVineBlock(d);
} }
public boolean isSolidNonSlab(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) { public boolean isSolidNonSlab(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {

View File

@@ -18,11 +18,7 @@
package com.volmit.iris.engine.object; package com.volmit.iris.engine.object;
import com.volmit.iris.engine.object.annotations.Desc; import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.engine.object.annotations.MaxNumber;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.Required;
import com.volmit.iris.engine.object.annotations.Snippet;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;

View File

@@ -18,12 +18,7 @@
package com.volmit.iris.engine.object; package com.volmit.iris.engine.object;
import com.volmit.iris.engine.object.annotations.DependsOn; import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MaxNumber;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.Required;
import com.volmit.iris.engine.object.annotations.Snippet;
import com.volmit.iris.util.math.M; import com.volmit.iris.util.math.M;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;

View File

@@ -25,13 +25,7 @@ import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.engine.IrisComplex; import com.volmit.iris.engine.IrisComplex;
import com.volmit.iris.engine.data.cache.AtomicCache; import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.annotations.ArrayType; import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.engine.object.annotations.DependsOn;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MaxNumber;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListResource;
import com.volmit.iris.engine.object.annotations.Required;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.collection.KSet;
@@ -52,7 +46,7 @@ import org.bukkit.Material;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import java.awt.Color; import java.awt.*;
@Accessors(chain = true) @Accessors(chain = true)
@NoArgsConstructor @NoArgsConstructor
@@ -83,7 +77,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
@MinNumber(2) @MinNumber(2)
@Required @Required
@Desc("This is the human readable name for this biome. This can and should be different than the file name. This is not used for loading biomes in other objects.") @Desc("This is the human readable name for this biome. This can and should be different than the file name. This is not used for loading biomes in other objects.")
private String name = "A Biome"; private String name = "Subterranean Land";
@ArrayType(min = 1, type = IrisBiomeCustom.class) @ArrayType(min = 1, type = IrisBiomeCustom.class)
@Desc("If the biome type custom is defined, specify this") @Desc("If the biome type custom is defined, specify this")
private KList<IrisBiomeCustom> customDerivitives; private KList<IrisBiomeCustom> customDerivitives;

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