9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2026-01-04 15:41:30 +00:00

Compare commits

...

230 Commits

Author SHA1 Message Date
Brian Neumann-Fopiano
9ac4024e4e v+ 2024-04-15 11:43:09 -04:00
CrazyDev22
16affd11cc fix HMCLeaves leave decay 2024-04-04 23:46:14 +02:00
CrazyDev22
33b0dec9da fix ClassCastException when replacing to IrisBlockData 2024-04-04 23:45:25 +02:00
Brian Neumann-Fopiano
121a463788 v+
Woot
2024-04-03 03:03:32 -04:00
Julian Krings
3625e70948 Merge pull request #1085 from VolmitDev/impl_mmoitem
Impl MMOItems
2024-04-02 19:03:25 +02:00
CrazyDev22
3d90207172 make MMOItems getItemTypes synchronous to reduce lag 2024-04-02 12:03:00 +02:00
CrazyDev22
ca7dc19c81 make mmoitems item creation synchronous 2024-04-01 23:20:11 +02:00
CrazyDev22
d0f16dbbc4 fix using Type::toString instead of Type::getId for mmoitems 2024-04-01 23:18:41 +02:00
CrazyDev22
fd91c223b7 add unload debug tools 2024-04-01 22:08:28 +02:00
CrazyDev22
93690b766c implement MMOItemsDataProvider 2024-04-01 17:26:33 +02:00
CrazyDev22
cc4af9950b fix scanning for item provider instead of block provider to processUpdate 2024-04-01 17:26:10 +02:00
Brian Fopiano
a6281483dd Merge pull request #1084 from RePixelatedMC/PixelatedDev
Pixelated dev
2024-03-31 12:45:06 -04:00
RePixelatedMC
f587816b30 merges 2024-03-31 18:33:35 +02:00
RePixelatedMC
eea3c3ab0b Merge remote-tracking branch 'origin/master' into PixelatedDev
# Conflicts:
#	core/src/main/java/com/volmit/iris/core/nms/INMSBinding.java
#	nms/v1_19_R1/src/main/java/com/volmit/iris/core/nms/v1_19_R1/NMSBinding.java
#	nms/v1_19_R2/src/main/java/com/volmit/iris/core/nms/v1_19_R2/NMSBinding.java
#	nms/v1_19_R3/src/main/java/com/volmit/iris/core/nms/v1_19_R3/NMSBinding.java
#	nms/v1_20_R1/src/main/java/com/volmit/iris/core/nms/v1_20_R1/NMSBinding.java
#	nms/v1_20_R2/src/main/java/com/volmit/iris/core/nms/v1_20_R2/NMSBinding.java
#	nms/v1_20_R3/src/main/java/com/volmit/iris/core/nms/v1_20_R3/NMSBinding.java
2024-03-31 18:25:26 +02:00
RePixelatedMC
ba68ab9e06 f 2024-03-31 17:58:47 +02:00
RePixelatedMC
eb94d97ea4 - Fixed caves breaksurface
- changes
2024-03-31 17:53:10 +02:00
Brian Neumann-Fopiano
04ad02719c d 2024-03-30 18:48:00 -04:00
Brian Fopiano
f68f25b92f Merge pull request #1083 from VolmitDev/fix_object_collision_check
fix object collision check
2024-03-30 17:51:40 -04:00
Brian Fopiano
767cca36c8 Merge pull request #1080 from svdgoor/no-camel-1-19-R3
Cancels Camel spawns on 1-19-R3
2024-03-30 17:50:44 -04:00
Brian Fopiano
b30172fe89 Merge pull request #1082 from VolmitDev/shut_up_spigot
Remove usage of System.out
2024-03-30 17:49:31 -04:00
CrazyDev22
b2934b0cc2 fix object collision check 2024-03-27 19:02:20 +01:00
RePixelatedMC
50686795d0 - Added /iris what region
- Sort of Fixed EngineStatus
- Added /iris hasAccess
- Added /iris irisworlds/worlds
- Added Some dev commands
- Redid / improved the mantle tectonic unload
- Convert still not working so ignore that
- Cleaned Iris of IrisPackBenchmarking.java im redoing it on second thought.
- Adjusted build.gradle
- Renamed some tectonic stuff
- Fixed Eta
- Fixed entities spawning inside blocks or at least it should.
- Lib update fixes all the iris titles/actionbars
- Cave spawning adjustments, now they get engine height if caveStartHeight is too large. <optional>
- Perhaps more?
2024-03-20 11:32:44 +01:00
CrazyDev22
5561a4dc2f fix wrong color bug 2024-03-20 08:46:56 +01:00
CrazyDev22
15b8780e17 remove usage of System.out 2024-03-20 08:44:00 +01:00
svdgoor
15c4d312cb Merge remote-tracking branch 'origin/master' 2024-03-18 17:29:02 +01:00
svdgoor
ccbea89253 prevent spawning camels on 1.19.R3 2024-03-18 17:28:08 +01:00
RePixelatedMC
7b1e666b3b - No studio tectonic clearing. 2024-03-18 11:22:35 +01:00
RePixelatedMC
8af212fca8 - Fixed entities spawning inside blocks or at least it should. 2024-03-17 17:55:08 +01:00
Brian Fopiano
352ee7a622 Merge pull request #1079 from VolmitDev/better_plugin_compat
Better plugin compat
2024-03-17 02:55:19 -04:00
Brian Fopiano
f26d0fac0b Merge pull request #1078 from VolmitDev/fix_v1_19_R3
Remove Cherry Grove from 1.19.4 biomes list
2024-03-17 02:55:03 -04:00
RePixelatedMC
9612fef2a4 - Added /iris what region
- Sort of Fixed EngineStatus
- Added /iris hasAccess
- Added /iris irisworlds/worlds
- Added Some dev commands
- Redid / improved the mantle tectonic unload
- Convert still not working so ignore that
- Cleaned Iris of IrisPackBenchmarking.java im redoing it on second thought.
- Adjusted build.gradle
- Renamed some tectonic stuff
- Perhaps more?
2024-03-16 12:40:40 +01:00
CrazyDev22
a691d49abc fix only the 0 0 chunk being updated 2024-03-08 19:35:07 +01:00
CrazyDev22
289eca35ec fix missing method parameter types 2024-03-07 19:41:28 +01:00
CrazyDev22
e9ca30257c woops 2024-03-07 18:48:09 +01:00
Julian Krings
6b21997baa Merge branch 'VolmitSoftware:master' into better_plugin_compat 2024-03-07 17:24:59 +01:00
CrazyDev22
6d3dbf84ef add HMCLeaves compatibility 2024-03-07 17:24:09 +01:00
CrazyDev22
eb45339c81 add oraxen furniture support 2024-03-07 17:23:32 +01:00
CrazyDev22
65e3fdd26c make implementing blocks that need world context possible 2024-03-07 17:23:00 +01:00
RePixelatedMC
34cad85942 - Fixed Eta 2024-03-01 12:32:53 +01:00
RePixelatedMC
e407679d2b - Improved eta calculation 2024-03-01 11:44:00 +01:00
Julian Krings
8a08a3e148 Remove Cherry Grove from 1.19.4 biomes list 2024-02-27 11:30:40 +01:00
Brian Fopiano
a01d27d273 Merge pull request #1075 from VolmitDev/fix_pregen
Fix Pregen oversight
2024-02-22 18:42:16 -05:00
Brian Fopiano
43f642ae8b Merge pull request #1076 from VolmitDev/custom-spawn-reason
Add implement custom spawn reason
2024-02-22 18:41:59 -05:00
CrazyDev22
93c1265de9 Add implement custom spawn reason 2024-02-22 21:25:37 +01:00
CrazyDev22
d08600fbaa Fix Pregen oversight 2024-02-22 17:27:38 +01:00
RePixelatedMC
fb9f8d28f4 - Lib update fixes all the iris titles/actionbars
- Iris .schem Converter
2024-02-21 21:24:35 +01:00
Brian Fopiano
cd3e9f772d Merge pull request #1074 from MoritzR200/master
Fixed file separators in '/iris import'
2024-02-17 09:54:59 -05:00
Brian Fopiano
7a95441799 Merge pull request #1071 from VolmitDev/fix_nullpointer
Fix nullpointer
2024-02-17 09:54:40 -05:00
Brian Fopiano
9345828c97 Merge pull request #1073 from RePixelatedMC/PixelatedDev
Fixes?
2024-02-17 09:54:14 -05:00
MoritzR200
58d88dd079 Fixed backslashes being used as file separators regardless of platform (in /iris import)). 2024-02-17 13:31:00 +01:00
RePixelatedMC
6cbc2374b3 whoopsies 2024-02-15 20:43:29 +01:00
RePixelatedMC
12bd11386d Merge remote-tracking branch 'CrazyDev/jigsaw_placement_fix' into PixelatedDev 2024-02-14 09:13:37 +01:00
RePixelatedMC
0497045388 - Fixed /Iris height when ran in console
- Added Dynamic worldHeight
2024-02-13 08:51:48 +01:00
Julian Krings
d3f1640855 Merge branch 'VolmitSoftware:master' into jigsaw_placement_fix 2024-02-12 21:30:19 +01:00
CrazyDev22
960e2fcc61 try again if engine setup fails 2024-02-12 11:43:21 +01:00
CrazyDev22
6a012cf400 fix setup being set before engine setup 2024-02-12 11:42:47 +01:00
Brian Neumann-Fopiano
d658ec2099 oops 2024-02-04 17:37:00 -05:00
Brian Fopiano
c9a07bd9d7 Merge pull request #1069 from RePixelatedMC/PixelatedDev
This should be the last pr for the update
2024-01-26 07:35:39 -05:00
RePixelatedMC
dc4cfc49ad Merge remote-tracking branch 'origin/master' into PixelatedDev 2024-01-26 10:58:48 +01:00
RePixelatedMC
9fc72868d7 disabled perms check 2024-01-26 10:57:03 +01:00
Brian Fopiano
7d4c9d6c1e Merge pull request #1066 from VolmitDev/better-version-compat
Better version compat
2024-01-25 10:51:56 -05:00
Brian Fopiano
e68b1a52ee Merge pull request #1067 from RePixelatedMC/PixelatedDev
Feature and fIxes!
2024-01-25 10:51:45 -05:00
RePixelatedMC
955e8622b5 Merge remote-tracking branch 'VolmitDev/better-version-compat' into PixelatedDev 2024-01-25 14:57:47 +01:00
Julian Krings
82640de06b v+ 2024-01-25 14:47:19 +01:00
RePixelatedMC
c93cb19563 - !Fixed pregen skipping chunks
- !Improved stacking for partof
- improved DeepSearch
- Some SFG Fixes
- Added some Todos
- Improvements to objects being placed in the air
- Studio BoardSVC for debug
2024-01-25 11:23:38 +01:00
Julian Krings
ccb7855d7d Merge branch 'VolmitSoftware:master' into jigsaw_placement_fix 2024-01-20 15:10:05 +01:00
RePixelatedMC
20f05bf317 whoop 2024-01-14 16:32:15 +01:00
Julian Krings
ab658f58f9 Merge branch 'VolmitSoftware:master' into better-version-compat 2024-01-13 10:52:50 +01:00
Brian Fopiano
1b3916749a Merge pull request #1063 from RePixelatedMC/PixelatedDev
Quite some more fixes
2024-01-12 10:38:06 -05:00
RePixelatedMC
e29ec657d3 e 2024-01-12 16:10:02 +01:00
RePixelatedMC
04f3a226a1 whoop 2024-01-12 16:07:02 +01:00
RePixelatedMC
099d1cc362 - Added DeepSearchPregenerator.java < although not finished the base is functional >
- Fixes!
- Dynmap SFG detection now works!
2024-01-12 15:56:04 +01:00
RePixelatedMC
c11e9bf704 Merge remote-tracking branch 'origin/master' into PixelatedDev 2024-01-11 22:56:48 +01:00
RePixelatedMC
ffa0b984a0 whoop 2024-01-10 18:47:14 +01:00
RePixelatedMC
f0f9261ed3 whoop 2024-01-04 15:29:23 +01:00
RePixelatedMC
ba433bc244 - Display true height instead of engine height option added! 2024-01-04 15:26:25 +01:00
Julian Krings
27f8ad982a Merge branch 'VolmitSoftware:master' into jigsaw_placement_fix 2023-12-31 19:15:39 +01:00
CrazyDev22
9b89ae7846 reimplement IrisCompat 2023-12-31 19:13:57 +01:00
Brian Fopiano
c11b5342e3 Merge pull request #1062 from RePixelatedMC/master
Fixed a rare crash - Crazydev
2023-12-30 08:56:53 -05:00
RePixelatedMC
b9c88f5b12 Fixed a rare crash - Crazydev 2023-12-30 14:36:07 +01:00
RePixelatedMC
02c7ab71d4 Merge remote-tracking branch 'PixelsV3/PixelatedDev' into PixelatedDev
# Conflicts:
#	core/src/main/java/com/volmit/iris/core/pregenerator/TurboPregenerator.java
2023-12-30 14:31:22 +01:00
RePixelatedMC
8ec1ac9875 sync 2023-12-30 14:29:31 +01:00
RePixelatedMC
e03027a386 Now using klist for tounload 2023-12-30 14:15:59 +01:00
Julian Krings
387cf566c9 Merge branch 'VolmitSoftware:master' into jigsaw_placement_fix 2023-12-30 11:25:33 +01:00
Brian Fopiano
dff7665934 Merge pull request #1053 from RePixelatedMC/Pixeldev
Pixeldev
2023-12-29 16:32:21 -05:00
RePixelatedMC
9421d788f3 Backup 2023-12-28 17:56:30 +01:00
RePixelatedMC
d960574b24 Ah yes 2023-12-28 14:41:16 +01:00
RePixelatedMC
e8671cbbf0 whoop 2023-12-27 09:13:14 +01:00
RePixelatedMC
cbf8039eea Cleanup p2 2023-12-27 09:09:11 +01:00
RePixelatedMC
d7415e3711 Merged CommandWorldManager.java into CommandIris.java 2023-12-27 09:05:05 +01:00
RePixelatedMC
26e71ee6b5 small tweak 2023-12-27 08:06:40 +01:00
RePixelatedMC
f8c42b3e48 cleaning up 2023-12-27 07:35:24 +01:00
RePixelatedMC
886bed9634 o 2023-12-26 13:38:31 +01:00
RePixelatedMC
7b7023fc99 Added ToUpgradedVersion 2023-12-26 13:32:37 +01:00
RePixelatedMC
701bfe4a54 Merge pull request #10 from CrazyDev05/Pixeldev
Fix lastUse and Implement MultiBurst
2023-12-25 14:14:16 +01:00
CrazyDev22
290d7a93ab switch to burst 2023-12-25 13:53:45 +01:00
CrazyDev22
729bcc7ba0 fix lastUse 2023-12-25 13:52:31 +01:00
RePixelatedMC
e46b68e2f3 comment 2023-12-24 16:41:20 +01:00
RePixelatedMC
cdf73c4629 Nvmr 2023-12-24 16:40:44 +01:00
RePixelatedMC
2f0dd2d172 Quick fix 2023-12-24 16:17:41 +01:00
RePixelatedMC
7e5704bf80 No idea why crazy recommended this 2023-12-24 15:17:56 +01:00
RePixelatedMC
ef96fb9a0e Removed debug code 2023-12-24 15:06:53 +01:00
RePixelatedMC
f2370ad814 Merge pull request #9 from CrazyDev05/Pixeldev
Sync with Master
2023-12-24 15:03:24 +01:00
RePixelatedMC
0783620104 Way to tired 2023-12-24 15:00:02 +01:00
RePixelatedMC
2193b02c0a Removed debug code 2023-12-24 14:40:41 +01:00
RePixelatedMC
aef05bad20 Deleted leftovers and a couple of changes 2023-12-24 14:32:13 +01:00
CrazyDev22
e002ab6378 disable 1.20.4 nms bindings for now 2023-12-23 21:17:35 +01:00
Julian Krings
a2c2b4a2d4 Sync with Master 2023-12-23 20:53:33 +01:00
Julian Krings
3ae896457b Merge branch 'Pixeldev' into origin 2023-12-23 20:53:18 +01:00
Julian Krings
683a90ed09 Merge branch 'VolmitSoftware:master' into jigsaw_placement_fix 2023-12-23 20:52:13 +01:00
Brian Fopiano
5685e25234 Merge pull request #1061 from CrazyDev05/build_fix
fix missing dependency
2023-12-23 14:43:07 -05:00
CrazyDev22
6edf083e7b fix <world>/iris/iris/pack path 2023-12-23 20:39:54 +01:00
CrazyDev22
995d1495eb fix missing dependency 2023-12-23 20:14:43 +01:00
Julian Krings
d5f74631cd Merge branch 'VolmitSoftware:master' into jigsaw_placement_fix 2023-12-23 18:37:59 +01:00
Brian Fopiano
dd5b9b2e81 Merge pull request #1060 from CrazyDev05/build_fix
Build fix
2023-12-23 12:32:09 -05:00
RePixelatedMC
ca78200c1c Deleted leftovers 2023-12-23 15:01:27 +01:00
RePixelatedMC
d73c2a65ae - Saving iris and mc version data to engine 2023-12-23 14:57:33 +01:00
CrazyDev22
0ee2cb8e3c why did I add that 2023-12-23 11:47:26 +01:00
CrazyDev22
5ba429ec73 implement getBiomes method 2023-12-23 11:40:06 +01:00
CrazyDev22
709825d073 decrease build time to ~30s
revert single version building
2023-12-23 11:39:40 +01:00
Julian Krings
3fe73af5e8 Merge branch 'VolmitSoftware:master' into jigsaw_placement_fix 2023-12-23 10:20:30 +01:00
Brian Fopiano
ccc0b0dd7d Merge pull request #1057 from CrazyDev05/single_nms
add ability to only compile for one mc version
2023-12-22 20:03:58 -05:00
Brian Fopiano
1114ede267 Merge pull request #1058 from IkyMax/master
Update to 1.20.4
2023-12-22 20:03:37 -05:00
Brian Fopiano
5546f12499 Merge pull request #1052 from CrazyDev05/worldedit_fix
Worldedit fix
2023-12-22 20:03:24 -05:00
Brian Fopiano
4f38acb592 Merge pull request #1055 from CrazyDev05/multiversion_fix
NoSuchFieldError: CHERRY_GROVE fix
2023-12-22 20:03:11 -05:00
RePixelatedMC
39f59e023c Merge pull request #7 from CrazyDev05/Pixeldev
implement showing location instead of teleporting
2023-12-22 21:36:42 +01:00
CrazyDev22
5ed5322fce implement showing location instead of teleporting 2023-12-22 21:23:01 +01:00
RePixelatedMC
33b926d547 Merge pull request #6 from CrazyDev05/Pixeldev
Fixes!
2023-12-22 19:54:54 +01:00
CrazyDev22
af8778c6cd fix ArrayIndexOutOfBoundsException
fix NullPointerException
fix ConcurrentModificationException x2
2023-12-22 19:36:07 +01:00
RePixelatedMC
bb4ad08cc5 Merge pull request #5 from CrazyDev05/Pixeldev
More Improvements
2023-12-22 16:39:30 +01:00
CrazyDev22
ee4eb7b3f0 fix 2023-12-22 16:34:39 +01:00
CrazyDev22
5bc024a6ee Merge remote-tracking branch 'pixeldev/Pixeldev' into Pixeldev 2023-12-22 16:33:51 +01:00
RePixelatedMC
0546caeb05 - Fixed Process Threads displaying the incorrect value on startup. 2023-12-22 16:24:48 +01:00
CrazyDev22
a75348d3ee Merge remote-tracking branch 'pixeldev/Pixeldev' into Pixeldev 2023-12-22 16:19:49 +01:00
CrazyDev22
3f3f947f43 change the Param description 2023-12-22 16:17:56 +01:00
RePixelatedMC
5127b7c959 - Added DiskSpace to Splash
- Changed form ofSize to contain a space
2023-12-22 16:16:48 +01:00
CrazyDev22
a28df78792 switch to lz4 block compression 2023-12-22 16:13:57 +01:00
CrazyDev22
4f888f16bc Add Compression Test Command 2023-12-22 16:13:46 +01:00
RePixelatedMC
55ed9d7132 - Added DiskSpace check 2023-12-22 15:59:05 +01:00
CrazyDev22
779a56c3a1 add compression test command 2023-12-22 15:50:27 +01:00
RePixelatedMC
f6440bde07 - Added Sufficient Permission check 2023-12-22 15:33:22 +01:00
RePixelatedMC
930dc2fd1c Merge pull request #4 from CrazyDev05/Pixeldev
increase unload speed
2023-12-22 11:48:23 +01:00
CrazyDev22
1e96fd529b increase unload speed 2023-12-22 11:17:55 +01:00
RePixelatedMC
167c865bb2 e 2023-12-22 09:00:57 +01:00
RePixelatedMC
4e6b6c11a3 Merge remote-tracking branch 'PixelsV3/Pixeldev' into Pixeldev
# Conflicts:
#	core/src/main/java/com/volmit/iris/util/mantle/Mantle.java
2023-12-22 08:37:27 +01:00
RePixelatedMC
bfdb71ca91 Merge pull request #3 from CrazyDev05/Pixeldev
TectonicPlate unloading improvements
2023-12-22 08:35:35 +01:00
IkyMax
f590f9824e Update to 1.20.4 2023-12-21 15:58:45 -06:00
CrazyDev22
b3a087702d show unloaded tectonicplates count 2023-12-21 22:36:50 +01:00
CrazyDev22
1a786fb418 give hyperLock a purpose again 2023-12-21 22:36:05 +01:00
CrazyDev22
650d38e212 Implement MultiThreading in the TectonicPlates unloader 2023-12-21 22:30:08 +01:00
RePixelatedMC
130cb7ad93 So that works 2023-12-21 22:04:19 +01:00
CrazyDev22
85e8ffeaa3 Merge remote-tracking branch 'pixeldev/Pixeldev' into Pixeldev 2023-12-21 20:55:37 +01:00
RePixelatedMC
db40f608fa try this out 2023-12-21 20:55:10 +01:00
RePixelatedMC
a7b471682a try this out 2023-12-21 15:39:26 +01:00
CrazyDev22
4595fea7d7 fix NullPointerException 2023-12-21 12:34:14 +01:00
CrazyDev22
4580f8d9a4 fix StackOverflowError 2023-12-21 12:21:20 +01:00
CrazyDev22
37f76fa133 Dynamically define tectonicLimit and cooldown 2023-12-20 14:43:37 +01:00
RePixelatedMC
5507c35547 new structure 2023-12-17 17:42:28 +01:00
CrazyDev22
350328f99c fix remapping not working 2023-12-16 18:40:53 +01:00
CrazyDev22
91ec6b773d add ability to only compile for one mc version 2023-12-16 17:22:45 +01:00
RePixelatedMC
c0fdf23133 cleanup 2023-12-16 14:32:06 +01:00
RePixelatedMC
28523a9593 e 2023-12-16 14:29:56 +01:00
RePixelatedMC
07e0b52ea3 e 2023-12-16 14:08:10 +01:00
RePixelatedMC
008e758da8 To many issues that are just not worth dealing with 2023-12-16 13:51:31 +01:00
RePixelatedMC
7ce219a6a8 - Added warning mode
- ignoreUnstable Changed to ignoreBootMode
2023-12-16 13:45:21 +01:00
RePixelatedMC
1809d4a53f - Added JDK version check for an SFG
- Fixed duplicate cpu message on boot when on intel and unstable
2023-12-15 20:14:34 +01:00
RePixelatedMC
54ae026c2b - Fixed LazyPregenerator.java and improved it. ( Speed decrease on server restart when lazy starts the job up dont know why)
- Mem leak fix only works when there is 1 iris world for now ( working on it ) + A capped performance limit still very alpha like seems stable tho.

- Disabled HotDropWorldSVC acts a bit weird sometimes.
2023-12-15 19:06:53 +01:00
RePixelatedMC
57c647fa0e Whoops 2023-12-07 18:09:36 +01:00
RePixelatedMC
9745f23fb2 - Saving the LazyPregen Progress in world folder
- Added option to pause to LazyPregen
- Added option to stop to LazyPregen
- Re-Added the functionality continue pregen on startup
2023-12-07 17:57:45 +01:00
RePixelatedMC
7d2062f298 e 2023-12-07 16:06:33 +01:00
RePixelatedMC
306a1948cf - Moved iris regen to studio
- Moved Iris LazyPregen into its own cmd
- Fixed the mem leak "i hope"
- Added Silent option to the lazy pregen
2023-12-07 16:04:40 +01:00
RePixelatedMC
ac4c00d3f2 Thanks Crazydev! 2023-12-07 14:27:08 +01:00
RePixelatedMC
db43bc300e Sync 2023-12-07 11:26:14 +01:00
RePixelatedMC
6494cded62 Sync 2023-12-07 10:41:17 +01:00
RePixelatedMC
b5c1e7e2da Sync 2023-12-06 15:56:19 +01:00
RePixelatedMC
83e311870f Sync 2023-12-03 16:56:56 +01:00
RePixelatedMC
8fc6e3b335 Dev code + added maxcpm for lazy gen 2023-12-03 12:45:36 +01:00
RePixelatedMC
18a69e97b3 not really lazy but oh well at least it fixed a crash 2023-11-30 10:19:57 +01:00
RePixelatedMC
80d8449f02 Bug when on intel cpu and unstable mode and changed how SFG works 2023-11-29 18:04:56 +01:00
RePixelatedMC
d830aa1d1a Bug when on intel cpu and unstable mode and moved more to SFG 2023-11-29 16:26:34 +01:00
RePixelatedMC
d473126d4c What was this even meant to do? 2023-11-29 16:16:11 +01:00
RePixelatedMC
17f8fe69fb so I didnt know that 2023-11-29 14:43:06 +01:00
Julian Krings
7263d102c7 cleanup / possibly fix a bug 2023-11-29 14:34:00 +01:00
RePixelatedMC
815b2235a2 FINALLY 2023-11-29 13:48:58 +01:00
RePixelatedMC
f61247f8bb Raw data 2023-11-29 11:31:26 +01:00
RePixelatedMC
205d9d528e back to debug 2023-11-29 10:47:45 +01:00
RePixelatedMC
1044f901bd o 2023-11-29 10:41:48 +01:00
RePixelatedMC
de261a38fd o 2023-11-29 10:39:48 +01:00
RePixelatedMC
81776e60fb So now it actually it works 2023-11-29 10:31:44 +01:00
RePixelatedMC
0c179eae86 e 2023-11-26 19:42:25 +01:00
RePixelatedMC
c30de98449 e 2023-11-26 19:02:50 +01:00
RePixelatedMC
47990cde46 Thanks @CrazyDev! 2023-11-24 20:44:56 +01:00
Julian Krings
b098c210ce removed unnecessary code 2023-11-24 17:03:32 +01:00
RePixelatedMC
6edd8bf119 Ah 2023-11-24 15:55:17 +01:00
RePixelatedMC
de0e124ebb For fuck's sake, why haven't I done this earlier 2023-11-24 15:38:12 +01:00
RePixelatedMC
5fc012a557 no way im spending more time on something stupid as this 2023-11-24 15:27:05 +01:00
RePixelatedMC
32afcc3478 - Fixed hotdrop being activated on world creation
- Improved /iris delete
- Unfinished code
2023-11-24 15:21:15 +01:00
RePixelatedMC
a27f37945d Merge branch 'VolmitSoftware:master' into Pixeldev 2023-11-24 14:26:06 +01:00
RePixelatedMC
0adfe6911f smth like this 2023-11-24 13:08:42 +01:00
RePixelatedMC
8bb1964b30 smth like this 2023-11-23 16:49:45 +01:00
RePixelatedMC
cc95e1ae63 More more 2023-11-23 16:47:55 +01:00
Julian Krings
9843f18c96 Fix jigsaw piece collision/merging 2023-11-22 13:45:55 +01:00
Julian Krings
18ea61fcc0 Move Biome List for DummyBiomeProvider into NMSBindings 2023-11-21 12:50:54 +01:00
Julian Krings
5b3fdb6e62 Optimise WorldEdit check 2023-11-17 15:43:59 +01:00
RePixelatedMC
c5220c8d06 Fix for HotDropWorldSVC.java not working 2023-11-17 12:20:47 +01:00
RePixelatedMC
74e87a7fae Fix for HotDropWorldSVC.java not working 2023-11-17 12:17:46 +01:00
Julian Krings
c809f50c3b Optimise check for wand item 2023-11-17 11:49:23 +01:00
Julian Krings
e7e46f78c7 Disable WorldEditLink when WorldEdit not present/loaded 2023-11-17 11:41:57 +01:00
Julian Krings
2b449a1f3d Add Settings check before calling WorldEditLink 2023-11-17 11:40:56 +01:00
Brian Neumann-Fopiano
f257f2c551 updated my mac path 2023-11-15 15:47:40 -05:00
Brian Fopiano
7f91d73d27 Merge pull request #1051 from RePixelatedMC/Pixeldev
Whoops
2023-11-15 12:24:00 -05:00
RePixelatedMC
15a90edb03 More robust and some debugging 2023-11-15 18:06:54 +01:00
RePixelatedMC
b2f1e16d9a more aggressive 2023-11-15 16:56:34 +01:00
RePixelatedMC
f544455708 Merge branch 'VolmitSoftware:master' into Pixeldev 2023-11-15 16:38:43 +01:00
RePixelatedMC
5118997188 Whoop 2023-11-15 16:37:34 +01:00
Brian Fopiano
b6ae649cd1 Merge pull request #1050 from RePixelatedMC/Pixeldev
Mem leak Fix + more
2023-11-15 10:02:52 -05:00
RePixelatedMC
a6d0d85b84 deleted unused class 2023-11-15 12:48:26 +01:00
RePixelatedMC
c71c2494af sync 2023-11-15 12:22:36 +01:00
RePixelatedMC
4a3a7bc98d Whoop 2023-11-15 11:16:33 +01:00
RePixelatedMC
4e4f7f693d Sync 2023-11-15 11:14:26 +01:00
RePixelatedMC
7a729c39a6 e 2023-11-15 09:58:46 +01:00
RePixelatedMC
48b757f693 Forgot those 2023-11-15 08:43:38 +01:00
RePixelatedMC
b449938730 Merge branch 'VolmitSoftware:master' into Pixeldev 2023-11-15 08:18:39 +01:00
RePixelatedMC
ba55ff6a4b typo 2023-11-12 10:19:39 +01:00
RePixelatedMC
2b4bc621ac misc 2023-11-11 21:56:28 +01:00
RePixelatedMC
acac2d0fc5 Removed GPT 4 Comments lmao 2023-11-11 21:26:31 +01:00
RePixelatedMC
6ff5975918 - HotDrop iris worlds lmao 2023-11-11 21:25:24 +01:00
RePixelatedMC
8912cfe37b fixed declaration 2023-11-11 16:14:37 +01:00
RePixelatedMC
9e02c318a1 Refactoring and a new pregen message 2023-11-11 09:50:24 +01:00
RePixelatedMC
df3e4b055f Merge branch 'master' into Pixeldev 2023-11-06 17:30:18 +01:00
104 changed files with 6241 additions and 2101 deletions

View File

@@ -1,3 +1,5 @@
import java.util.function.Consumer
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
@@ -23,7 +25,7 @@ plugins {
id "de.undercouch.download" version "5.0.1"
}
version '3.0.0-1.19.2-1.20.2'
version '3.2.3-1.19.2-1.20.4'
def specialSourceVersion = '1.11.0' //[NMS]
// ADD YOURSELF AS A NEW LINE IF YOU WANT YOUR OWN BUILD TASK GENERATED
@@ -35,13 +37,14 @@ registerCustomOutputTask('Coco', 'D://mcsm/plugins')
registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins')
registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.19.4/plugins')
registerCustomOutputTask('CrazyDev22', 'C://Users/Julian/Desktop/server/plugins')
registerCustomOutputTask('Pixel', 'C://Users/repix/Iris Dimension Engine/1.20.1 - Iris Coding/plugins')
registerCustomOutputTask('Pixel', 'C://Users/repix/Iris Dimension Engine/1.20.4 - Iris Development/plugins')
// ========================== UNIX ==============================
registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/development/server/plugins')
registerCustomOutputTaskUnix('PsychoLT', '/Users/brianfopiano/Desktop/REMOTES/RemoteMinecraft/plugins')
registerCustomOutputTaskUnix('PsychoLT', '/Volumes/PRO-G40/Minecraft/MinecraftDevelopment/Server/plugins')
// ==============================================================
def NMS_BINDINGS = Map.of(
"v1_20_R3", "1.20.4-R0.1-SNAPSHOT",
"v1_20_R2", "1.20.2-R0.1-SNAPSHOT",
"v1_20_R1", "1.20.1-R0.1-SNAPSHOT",
"v1_19_R3", "1.19.4-R0.1-SNAPSHOT",
@@ -53,16 +56,14 @@ NMS_BINDINGS.each {
def value = it.value
def nms = value.split("-")[0];
project(":nms:${key}") {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'de.undercouch.download'
dependencies {
implementation project(":core")
implementation "org.spigotmc:spigot-api:${value}"
implementation "org.bukkit:craftbukkit:${value}:remapped-mojang" //[NMS]
compileOnly "org.spigotmc:spigot-api:${value}"
compileOnly "org.bukkit:craftbukkit:${value}:remapped-mojang" //[NMS]
}
def buildToolsJar = new File(rootProject.buildDir, "tools/BuildTools.jar")
def specialSourceJar = new File(rootProject.buildDir, "tools/SpecialSource.jar")
@@ -80,109 +81,102 @@ NMS_BINDINGS.each {
def m2s = m2.getAbsolutePath();
// ======================== Building Mapped Jars =============================
Runnable downloadBuildtools = () -> {
if (!buildToolsJar.exists()) {
download.run {
src 'https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar'
dest buildToolsJar
ext {
executeBuildTools = new Runnable() {
@Override
void run() {
//Download
if (!buildToolsJar.exists()) {
download.run {
src 'https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar'
dest buildToolsJar
}
}
//Execute
if (!buildToolsHint.exists()) {
buildToolsFolder.mkdirs()
project.javaexec {
classpath = files(buildToolsJar)
workingDir = buildToolsFolder
args = [
"--rev",
nms,
"--compile",
"craftbukkit",
"--remap"
]
}
}
}
}
}
tasks.register("executeBuildTools") {
doLast {
property("executeBuildTools").run();
}
}
Runnable downloadSpecialSource = () -> {
tasks.build.doLast {
//Download
if (!specialSourceJar.exists()) {
download.run {
src 'https://repo.maven.apache.org/maven2/net/md-5/SpecialSource/' + specialSourceVersion + '/SpecialSource-'+specialSourceVersion+'-shaded.jar'
dest specialSourceJar
}
}
}
specialSourceFolder.mkdirs();
Runnable executeBuildTools = () -> {
if (!buildToolsHint.exists()) {
downloadBuildtools.run()
buildToolsFolder.mkdirs()
javaexec {
classpath = files(buildToolsJar)
workingDir = buildToolsFolder
args = [
"--rev",
nms,
"--compile",
"craftbukkit",
"--remap"
]
//Copy
copy {
from outputJar
into specialSourceFolder
}
//obfuscate
javaexec {
workingDir = specialSourceFolder
classpath = files(specialSourceJar,
new File(m2s + "/org/spigotmc/spigot/" + value + "/spigot-" + value + "-remapped-mojang.jar"))
mainClass = "net.md_5.specialsource.SpecialSource"
args = [
"--live",
"-i",
ssiJar.getName(),
"-o",
ssobfJar.getName(),
"-m",
m2s + "/org/spigotmc/minecraft-server/" + value + "/minecraft-server-" + value + "-maps-mojang.txt",
"--reverse",
]
}
//remap
javaexec {
workingDir = specialSourceFolder
classpath = files(specialSourceJar,
new File(m2s + "/org/spigotmc/spigot/" + value + "/spigot-" + value + "-remapped-obf.jar"))
mainClass = "net.md_5.specialsource.SpecialSource"
args = [
"--live",
"-i",
ssobfJar.getName(),
"-o",
ssJar.getName(),
"-m",
m2s + "/org/spigotmc/minecraft-server/" + value + "/minecraft-server-" + value + "-maps-spigot.csrg"
]
}
//copy
copy {
from ssJar
into outputJar.getParentFile()
rename {
outputJar.getName()
}
}
}
tasks.register("executeBuildTools") {
doFirst {
executeBuildTools.run()
}
}
tasks.register("copyBuildToSpecialSource", Copy) {
doFirst {
downloadSpecialSource.run()
specialSourceFolder.mkdirs();
}
group "remapping"
from outputJar
into specialSourceFolder
dependsOn(jar)
}
tasks.register("specialSourceRemapObfuscate", JavaExec) {
group "remapping"
dependsOn(copyBuildToSpecialSource)
workingDir = specialSourceFolder
classpath = files(specialSourceJar,
new File(m2s + "/org/spigotmc/spigot/" + value + "/spigot-" + value + "-remapped-mojang.jar"))
mainClass = "net.md_5.specialsource.SpecialSource"
args = [
"--live",
"-i",
ssiJar.getName(),
"-o",
ssobfJar.getName(),
"-m",
m2s + "/org/spigotmc/minecraft-server/" + value + "/minecraft-server-" + value + "-maps-mojang.txt",
"--reverse",
]
}
tasks.register("specialSourceRemap", JavaExec) {
group "remapping"
dependsOn(specialSourceRemapObfuscate)
workingDir = specialSourceFolder
classpath = files(specialSourceJar,
new File(m2s + "/org/spigotmc/spigot/" + value + "/spigot-" + value + "-remapped-obf.jar"))
mainClass = "net.md_5.specialsource.SpecialSource"
args = [
"--live",
"-i",
ssobfJar.getName(),
"-o",
ssJar.getName(),
"-m",
m2s + "/org/spigotmc/minecraft-server/" + value + "/minecraft-server-" + value + "-maps-spigot.csrg"
]
}
tasks.register("copySpecialSourceToBuild", Copy) {
group "remapping"
from ssJar
into outputJar.getParentFile()
rename {
outputJar.getName()
}
dependsOn(specialSourceRemap)
}
tasks.build.dependsOn(copySpecialSourceToBuild)
executeBuildTools.run()
}
}
@@ -194,13 +188,6 @@ shadowJar {
relocate 'com.dfsek.paralithic', 'com.volmit.iris.util.paralithic'
relocate 'io.papermc.lib', 'com.volmit.iris.util.paper'
relocate 'net.kyori', 'com.volmit.iris.util.kyori'
dependencies {
include(dependency('io.papermc:paperlib'))
include(dependency('com.dfsek:Paralithic'))
include(dependency('net.kyori:'))
include(project(":core"))
NMS_BINDINGS.each {include(project(":nms:${it.key}"))}
}
archiveFileName.set("Iris-${project.version}.jar")
}
@@ -211,13 +198,13 @@ dependencies {
}
}
configurations.all {
configurations.configureEach {
resolutionStrategy.cacheChangingModulesFor 60, 'minutes'
resolutionStrategy.cacheDynamicVersionsFor 60, 'minutes'
}
allprojects {
getPlugins().apply("java")
apply plugin: 'java'
repositories {
mavenLocal {
@@ -248,22 +235,22 @@ allprojects {
implementation 'com.dfsek:Paralithic:0.4.0'
implementation 'io.papermc:paperlib:1.0.5'
implementation "net.kyori:adventure-text-minimessage:4.13.1"
implementation 'net.kyori:adventure-platform-bukkit:4.3.0'
implementation 'net.kyori:adventure-platform-bukkit:4.3.2'
implementation 'net.kyori:adventure-api:4.13.1'
implementation 'io.lumine:Mythic-Dist:5.2.1'
compileOnly 'io.lumine:Mythic-Dist:5.2.1'
// Dynamically Loaded
implementation 'io.timeandspace:smoothie-map:2.0.2'
implementation 'it.unimi.dsi:fastutil:8.5.8'
implementation 'com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2'
implementation 'org.zeroturnaround:zt-zip:1.14'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'org.ow2.asm:asm:9.2'
implementation 'com.google.guava:guava:31.1-jre'
implementation 'bsf:bsf:2.4.0'
implementation 'rhino:js:1.7R2'
implementation 'com.github.ben-manes.caffeine:caffeine:3.0.6'
implementation 'org.apache.commons:commons-lang3:3.12.0'
compileOnly 'io.timeandspace:smoothie-map:2.0.2'
compileOnly 'it.unimi.dsi:fastutil:8.5.8'
compileOnly 'com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2'
compileOnly 'org.zeroturnaround:zt-zip:1.14'
compileOnly 'com.google.code.gson:gson:2.9.0'
compileOnly 'org.ow2.asm:asm:9.2'
compileOnly 'com.google.guava:guava:33.0.0-jre'
compileOnly 'bsf:bsf:2.4.0'
compileOnly 'rhino:js:1.7R2'
compileOnly 'com.github.ben-manes.caffeine:caffeine:3.0.6'
compileOnly 'org.apache.commons:commons-lang3:3.12.0'
}
/**
@@ -302,8 +289,24 @@ task iris(type: Copy) {
task setup() {
group "iris"
dependsOn(clean)
NMS_BINDINGS.each {
dependsOn(project(":nms:${it.key}").executeBuildTools)
dependsOn(":nms:${it.key}:clean");
}
doLast {
NMS_BINDINGS.each {
project(":nms:${it.key}").property("executeBuildTools").run();
}
}
}
NMS_BINDINGS.keySet().forEach {
def nms = it
tasks.register("setup-${nms}") {
group "iris"
dependsOn(":nms:${nms}:clean")
dependsOn(":nms:${nms}:executeBuildTools")
}
}
@@ -341,4 +344,4 @@ def registerCustomOutputTaskUnix(name, path) {
}
}
tasks.build.dependsOn(shadowJar)
tasks.build.dependsOn(shadowJar)

View File

@@ -33,6 +33,10 @@ compileJava {
options.encoding = "UTF-8"
}
repositories {
maven { url 'https://nexus.phoenixdevt.fr/repository/maven-public/'}
}
/**
* Dependencies.
*
@@ -47,18 +51,21 @@ compileJava {
*/
dependencies {
// Provided or Classpath
implementation 'org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT'
implementation 'org.apache.logging.log4j:log4j-api:2.19.0'
implementation 'org.apache.logging.log4j:log4j-core:2.19.0'
implementation 'commons-lang:commons-lang:2.6'
implementation 'com.github.oshi:oshi-core:5.8.5'
compileOnly 'org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT'
compileOnly 'org.apache.logging.log4j:log4j-api:2.19.0'
compileOnly 'org.apache.logging.log4j:log4j-core:2.19.0'
compileOnly 'commons-io:commons-io:2.13.0'
compileOnly 'commons-lang:commons-lang:2.6'
compileOnly 'com.github.oshi:oshi-core:5.8.5'
compileOnly 'org.lz4:lz4-java:1.8.0'
// Third Party Integrations
implementation 'com.ticxo.playeranimator:PlayerAnimator:R1.2.7'
implementation 'com.github.oraxen:oraxen:1.158.0'
implementation 'com.github.LoneDev6:api-itemsadder:3.4.1-r4'
implementation 'com.github.PlaceholderAPI:placeholderapi:2.11.3'
implementation 'com.github.Ssomar-Developement:SCore:4.23.10.8'
compileOnly 'com.ticxo.playeranimator:PlayerAnimator:R1.2.7'
compileOnly 'com.github.oraxen:oraxen:1.158.0'
compileOnly 'com.github.LoneDev6:api-itemsadder:3.4.1-r4'
compileOnly 'com.github.PlaceholderAPI:placeholderapi:2.11.3'
compileOnly 'com.github.Ssomar-Developement:SCore:4.23.10.8'
compileOnly 'net.Indyuce:MMOItems-API:6.9.5-SNAPSHOT'
//implementation files('libs/CustomItems.jar')
}
@@ -80,6 +87,4 @@ processResources {
'apiversion': apiVersion.toString()
)
}
}
tasks.compileJava.dependsOn(delombok)
}

View File

@@ -30,7 +30,6 @@ import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
import com.volmit.iris.core.pregenerator.LazyPregenerator;
import com.volmit.iris.core.service.ChunkHandlerSVC;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.EnginePanic;
@@ -39,8 +38,8 @@ import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisWorld;
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
import com.volmit.iris.engine.platform.DummyChunkGenerator;
import com.volmit.iris.engine.safeguard.IrisSafeguard;
import com.volmit.iris.engine.safeguard.UtilsSFG;
import com.volmit.iris.core.safeguard.IrisSafeguard;
import com.volmit.iris.core.safeguard.UtilsSFG;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.exceptions.IrisException;
@@ -64,6 +63,7 @@ import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.Queue;
import com.volmit.iris.util.scheduling.ShurikenQueue;
import io.papermc.lib.PaperLib;
import lombok.Getter;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.serializer.ComponentSerializer;
import org.bukkit.Bukkit;
@@ -94,11 +94,12 @@ import java.lang.management.OperatingSystemMXBean;
import java.net.URL;
import java.util.Date;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.volmit.iris.engine.safeguard.IrisSafeguard.unstablemode;
import static com.volmit.iris.engine.safeguard.ServerBootSFG.passedserversoftware;
import static com.volmit.iris.core.safeguard.IrisSafeguard.*;
import static com.volmit.iris.core.safeguard.ServerBootSFG.passedserversoftware;
import static com.volmit.iris.util.misc.getHardware.getCPUModel;
import static com.volmit.iris.util.misc.getHardware.getCPUThreads;
@SuppressWarnings("CanBeFinal")
public class Iris extends VolmitPlugin implements Listener {
@@ -127,6 +128,10 @@ public class Iris extends VolmitPlugin implements Listener {
private KMap<Class<? extends IrisService>, IrisService> services;
public static VolmitSender getSender() {
if (sender == null) {
sender = new VolmitSender(Bukkit.getConsoleSender());
sender.setTag(instance.getTag());
}
return sender;
}
@@ -193,10 +198,10 @@ public class Iris extends VolmitPlugin implements Listener {
public static void msg(String string) {
try {
sender.sendMessage(string);
getSender().sendMessage(string);
} catch (Throwable e) {
try {
System.out.println(instance.getTag() + string.replaceAll("(<([^>]+)>)", ""));
instance.getLogger().info(instance.getTag() + string.replaceAll("(<([^>]+)>)", ""));
} catch (Throwable ignored1) {
}
@@ -350,7 +355,7 @@ public class Iris extends VolmitPlugin implements Listener {
}
}
private static int getJavaVersion() {
public static int getJavaVersion() {
String version = System.getProperty("java.version");
if (version.startsWith("1.")) {
version = version.substring(2, 3);
@@ -363,6 +368,13 @@ public class Iris extends VolmitPlugin implements Listener {
return Integer.parseInt(version);
}
public static String getJava() {
String javaRuntimeName = System.getProperty("java.vm.name");
String javaRuntimeVendor = System.getProperty("java.vendor");
String javaRuntimeVersion = System.getProperty("java.vm.version");
return String.format("%s %s (build %s)", javaRuntimeName, javaRuntimeVendor, javaRuntimeVersion);
}
public static void reportErrorChunk(int x, int z, Throwable e, String extra) {
if (IrisSettings.get().getGeneral().isDebug()) {
File f = instance.getDataFile("debug", "chunk-errors", "chunk." + x + "." + z + ".txt");
@@ -425,7 +437,7 @@ public class Iris extends VolmitPlugin implements Listener {
}
pw.close();
System.out.println("DUMPED! See " + fi.getAbsolutePath());
Iris.info("DUMPED! See " + fi.getAbsolutePath());
} catch (Throwable e) {
e.printStackTrace();
}
@@ -442,18 +454,15 @@ public class Iris extends VolmitPlugin implements Listener {
private static void fixShading() {
ShadeFix.fix(ComponentSerializer.class);
}
private ChunkHandlerSVC chunkHandlerSVC;
private void enable() {
instance = this;
services = new KMap<>();
setupAudience();
initialize("com.volmit.iris.core.service").forEach((i) -> services.put((Class<? extends IrisService>) i.getClass(), (IrisService) i));
INMS.get();
IO.delete(new File("iris"));
setupAudience();
IrisSafeguard.IrisSafeguardSystem();
sender = new VolmitSender(Bukkit.getConsoleSender());
sender.setTag(getTag());
instance = this;
getSender().setTag(getTag());
compat = IrisCompat.configured(getDataFile("compat.json"));
linkMultiverseCore = new MultiverseCoreLink();
linkMythicMobs = new MythicMobsLink();
@@ -470,14 +479,8 @@ public class Iris extends VolmitPlugin implements Listener {
J.s(this::setupPapi);
J.a(ServerConfigurator::configure, 20);
splash();
UtilsSFG.UnstableMode();
UtilsSFG.SupportedServerSoftware();
UtilsSFG.printIncompatibleWarnings();
UtilsSFG.unstablePrompt();
if(IrisSettings.get().getGeneral().useIntegratedChunkHandler) {
chunkHandlerSVC = new ChunkHandlerSVC(this);
Iris.info(C.LIGHT_PURPLE + "Started Intergrated ChunkHandlerSVC");
}
UtilsSFG.splash();
autoStartStudio();
checkForBukkitWorlds();
IrisToolbelt.retainMantleDataForSlice(String.class.getCanonicalName());
@@ -532,7 +535,7 @@ public class Iris extends VolmitPlugin implements Listener {
Iris.info("Starting up auto Studio!");
try {
Player r = new KList<>(getServer().getOnlinePlayers()).getRandom();
Iris.service(StudioSVC.class).open(r != null ? new VolmitSender(r) : sender, 1337, IrisSettings.get().getGenerator().getDefaultWorldType(), (w) -> {
Iris.service(StudioSVC.class).open(r != null ? new VolmitSender(r) : getSender(), 1337, IrisSettings.get().getGenerator().getDefaultWorldType(), (w) -> {
J.s(() -> {
for (Player i : getServer().getOnlinePlayers()) {
i.setGameMode(GameMode.SPECTATOR);
@@ -599,9 +602,11 @@ public class Iris extends VolmitPlugin implements Listener {
if (unstablemode) {
return C.BOLD + "" + C.DARK_GRAY + "[" + C.BOLD + "" + C.RED + "Iris" + C.BOLD + C.DARK_GRAY + "]" + C.RESET + "" + C.GRAY + ": ";
}
else {
return C.BOLD + "" + C.DARK_GRAY + "[" + C.BOLD + "" + C.IRIS + "Iris" + C.BOLD + C.DARK_GRAY + "]" + C.RESET + "" + C.GRAY + ": ";
if (warningmode) {
return C.BOLD + "" + C.DARK_GRAY + "[" + C.BOLD + "" + C.GOLD + "Iris" + C.BOLD + C.DARK_GRAY + "]" + C.RESET + "" + C.GRAY + ": ";
}
return C.BOLD + "" + C.DARK_GRAY + "[" + C.BOLD + "" + C.IRIS + "Iris" + C.BOLD + C.DARK_GRAY + "]" + C.RESET + "" + C.GRAY + ": ";
}
private boolean setupChecks() {
@@ -731,7 +736,7 @@ public class Iris extends VolmitPlugin implements Listener {
File ff = new File(w.worldFolder(), "iris/pack");
if (!ff.exists() || ff.listFiles().length == 0) {
ff.mkdirs();
service(StudioSVC.class).installIntoWorld(sender, dim.getLoadKey(), ff.getParentFile());
service(StudioSVC.class).installIntoWorld(getSender(), dim.getLoadKey(), w.worldFolder());
}
return new BukkitChunkGenerator(w, false, ff, dim.getLoadKey());
@@ -748,6 +753,9 @@ public class Iris extends VolmitPlugin implements Listener {
if (unstablemode) {
info = new String[]{"", "", "", "", "", padd2 + C.RED + " Iris", padd2 + C.GRAY + " by " + C.DARK_RED + "Volmit Software", padd2 + C.GRAY + " v" + C.RED + getDescription().getVersion()};
}
if (warningmode) {
info = new String[]{"", "", "", "", "", padd2 + C.GOLD + " Iris", padd2 + C.GRAY + " by " + C.GOLD + "Volmit Software", padd2 + C.GRAY + " v" + C.GOLD + getDescription().getVersion()};
}
String[] splashstable = {
padd + C.GRAY + " @@@@@@@@@@@@@@" + C.DARK_GRAY + "@@@",
@@ -776,9 +784,28 @@ public class Iris extends VolmitPlugin implements Listener {
padd + C.GRAY + "" + C.RED + " '(((())))' " + C.DARK_GRAY + "&&&&&&&&" + C.GRAY + "&&&&&&&@@",
padd + C.GRAY + " " + C.DARK_GRAY + "@@@" + C.GRAY + "@@@@@@@@@@@@@@"
};
String[] splash = unstablemode ? splashunstable : splashstable; // Choose the appropriate splash array based on unstablemode
String[] splashwarning = {
padd + C.GRAY + " @@@@@@@@@@@@@@" + C.DARK_GRAY + "@@@",
padd + C.GRAY + " @@&&&&&&&&&" + C.DARK_GRAY + "&&&&&&" + C.GOLD + " .(((()))). ",
padd + C.GRAY + "@@@&&&&&&&&" + C.DARK_GRAY + "&&&&&" + C.GOLD + " .((((((())))))). ",
padd + C.GRAY + "@@@&&&&&" + C.DARK_GRAY + "&&&&&&&" + C.GOLD + " ((((((((())))))))) " + C.GRAY + " @",
padd + C.GRAY + "@@@&&&&" + C.DARK_GRAY + "@@@@@&" + C.GOLD + " ((((((((-))))))))) " + C.GRAY + " @@",
padd + C.GRAY + "@@@&&" + C.GOLD + " ((((((({ })))))))) " + C.GRAY + " &&@@@",
padd + C.GRAY + "@@" + C.GOLD + " ((((((((-))))))))) " + C.DARK_GRAY + "&@@@@@" + C.GRAY + "&&&&@@@",
padd + C.GRAY + "@" + C.GOLD + " ((((((((())))))))) " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&@@@",
padd + C.GRAY + "" + C.GOLD + " '((((((()))))))' " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&&@@@",
padd + C.GRAY + "" + C.GOLD + " '(((())))' " + C.DARK_GRAY + "&&&&&&&&" + C.GRAY + "&&&&&&&@@",
padd + C.GRAY + " " + C.DARK_GRAY + "@@@" + C.GRAY + "@@@@@@@@@@@@@@"
};
String[] splash;
File freeSpace = new File(Bukkit.getWorldContainer() + ".");
if (unstablemode) {
splash = splashunstable;
} else if (warningmode) {
splash = splashwarning;
} else {
splash = splashstable;
}
OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean();
String osArch = osBean.getArch();
String osName = osBean.getName();
@@ -786,22 +813,45 @@ public class Iris extends VolmitPlugin implements Listener {
if (!passedserversoftware) {
Iris.info("Server type & version: " + C.RED + Bukkit.getVersion());
} else { Iris.info("Server type & version: " + Bukkit.getVersion()); }
Iris.info("Java: " + getJava());
if (!instance.getServer().getVersion().contains("Purpur")) {
if (instance.getServer().getVersion().contains("Spigot") && instance.getServer().getVersion().contains("Bukkit")) {
Iris.info(C.RED + " Iris requires paper or above to function properly..");
} else {
Iris.info(C.YELLOW + "Purpur is recommended to use with iris.");
}
}
Iris.info("Server OS: " + osName + " (" + osArch + ")");
if(unstablemode) Iris.info("Server Cpu: " + C.DARK_RED + getCPUModel());
try {
if (warningmode){
Iris.info("Server Cpu: " + C.GOLD + getCPUModel());
} else {
if(unstablemode){
Iris.info("Server Cpu: " + C.DARK_RED + getCPUModel());
} else {
if (getCPUModel().contains("Intel")) {
Iris.info("Server Cpu: " + C.BLUE + getCPUModel());
}
if (getCPUModel().contains("Ryzen")) {
Iris.info("Server Cpu: " + C.RED + getCPUModel());
}
if (!getCPUModel().contains("Ryzen") && !getCPUModel().contains("Intel")) {
Iris.info("Server Cpu: " + C.GRAY + getCPUModel());
}
}
}
} catch (Exception e){
Iris.info("Server Cpu: " + C.DARK_RED + "Failed");
}
if(getCPUModel().contains("Intel")) Iris.info("Server Cpu: " + C.BLUE + getCPUModel());
if(getCPUModel().contains("Ryzen")) Iris.info("Server Cpu: " + C.RED + getCPUModel());
if(!getCPUModel().contains("Intel") && !getCPUModel().contains("Ryzen")) Iris.info("Server Cpu: " + C.DARK_GRAY + getCPUModel());
Iris.info("Process Threads: " + getCPUThreads());
Iris.info("Process Threads: " + Runtime.getRuntime().availableProcessors());
Iris.info("Process Memory: " + getHardware.getProcessMemory() + " MB");
Iris.info("Free DiskSpace: " + Form.ofSize(freeSpace.getFreeSpace(), 1024));
if (getHardware.getProcessMemory() < 5999) {
Iris.warn("6GB+ Ram is recommended");
}
Iris.info("Bukkit version: " + Bukkit.getBukkitVersion());
Iris.info("Java version: " + getJavaVersion());
Iris.info("Custom Biomes: " + INMS.get().countCustomBiomes());
setupChecks();
printPacks();
@@ -834,4 +884,33 @@ public class Iris extends VolmitPlugin implements Listener {
}
Iris.info(" " + dimName + " v" + version);
}
public int getIrisVersion() {
String input = Iris.instance.getDescription().getVersion();
int hyphenIndex = input.indexOf('-');
if (hyphenIndex != -1) {
String result = input.substring(0, hyphenIndex);
result = result.replaceAll("\\.", "");
return Integer.parseInt(result);
}
return -1;
}
public int getMCVersion() {
try {
String version = Bukkit.getVersion();
Matcher matcher = Pattern.compile("\\(MC: ([\\d.]+)\\)").matcher(version);
if (matcher.find()) {
version = matcher.group(1).replaceAll("\\.", "");
long versionNumber = Long.parseLong(version);
if (versionNumber > Integer.MAX_VALUE) {
return -1;
}
return (int) versionNumber;
}
return -1;
} catch (Exception e) {
return -1;
}
}
}

View File

@@ -24,6 +24,7 @@ import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.json.JSONException;
import com.volmit.iris.util.json.JSONObject;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.ChronoLatch;
import lombok.Data;
import java.io.File;
@@ -135,7 +136,7 @@ public class IrisSettings {
@Data
public static class IrisSettingsPerformance {
public boolean trimMantleInStudio = false;
public boolean trimMantleInStudio = false;
public int mantleKeepAlive = 30;
public int cacheSize = 4_096;
public int resourceLoaderCacheSize = 1_024;
@@ -145,8 +146,7 @@ public class IrisSettings {
@Data
public static class IrisSettingsGeneral {
public boolean bootUnstable = false;
public boolean useIntegratedChunkHandler = false;
public boolean ignoreBootMode = false;
public boolean commandSounds = true;
public boolean debug = false;
public boolean disableNMS = false;
@@ -177,6 +177,7 @@ public class IrisSettings {
public static class IrisSettingsGenerator {
public String defaultWorldType = "overworld";
public int maxBiomeChildDepth = 4;
// public boolean forceConvertTo320Height = false;
public boolean preventLeafDecay = true;
}

View File

@@ -24,6 +24,7 @@ import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisBiomeCustom;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisRange;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.format.C;
@@ -94,6 +95,29 @@ public class ServerConfigurator {
public static void installDataPacks(boolean fullInstall) {
Iris.info("Checking Data Packs...");
File packs = new File("plugins/Iris/packs");
double ultimateMaxHeight = 0;
double ultimateMinHeight = 0;
if (packs.exists() && packs.isDirectory()) {
for (File pack : packs.listFiles()) {
IrisData data = IrisData.get(pack);
if (pack.isDirectory()) {
File dimensionsFolder = new File(pack, "dimensions");
if (dimensionsFolder.exists() && dimensionsFolder.isDirectory()) {
for (File file : dimensionsFolder.listFiles()) {
if (file.isFile() && file.getName().endsWith(".json")) {
IrisDimension dim = data.getDimensionLoader().load(file.getName().split("\\Q.\\E")[0]);
if (ultimateMaxHeight < dim.getDimensionHeight().getMax()) {
ultimateMaxHeight = dim.getDimensionHeight().getMax();
}
if (ultimateMinHeight > dim.getDimensionHeight().getMin()) {
ultimateMinHeight = dim.getDimensionHeight().getMin();
}
}
}
}
}
}
}
if (packs.exists()) {
for (File i : packs.listFiles()) {
@@ -113,7 +137,7 @@ public class ServerConfigurator {
Iris.verbose(" Checking Dimension " + dim.getLoadFile().getPath());
for (File dpack : getDatapacksFolder()) {
dim.installDataPack(() -> data, dpack);
dim.installDataPack(() -> data, dpack, ultimateMaxHeight, ultimateMinHeight);
}
}
}

View File

@@ -0,0 +1,134 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.commands;
import com.volmit.iris.Iris;
import com.volmit.iris.core.pregenerator.DeepSearchPregenerator;
import com.volmit.iris.core.pregenerator.PregenTask;
import com.volmit.iris.core.pregenerator.TurboPregenerator;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.util.data.Dimension;
import com.volmit.iris.util.decree.DecreeExecutor;
import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.Position2;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.util.Vector;
import java.io.File;
import java.io.IOException;
@Decree(name = "DeepSearch", aliases = "search", description = "Pregenerate your Iris worlds!")
public class CommandDeepSearch implements DecreeExecutor {
public String worldName;
@Decree(description = "DeepSearch a world")
public void start(
@Param(description = "The radius of the pregen in blocks", aliases = "size")
int radius,
@Param(description = "The world to pregen", contextual = true)
World world,
@Param(aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0")
Vector center
) {
worldName = world.getName();
File worldDirectory = new File(Bukkit.getWorldContainer(), world.getName());
File TurboFile = new File(worldDirectory, "DeepSearch.json");
if (TurboFile.exists()) {
if (DeepSearchPregenerator.getInstance() != null) {
sender().sendMessage(C.BLUE + "DeepSearch is already in progress");
Iris.info(C.YELLOW + "DeepSearch is already in progress");
return;
} else {
try {
TurboFile.delete();
} catch (Exception e){
Iris.error("Failed to delete the old instance file of DeepSearch!");
return;
}
}
}
try {
if (sender().isPlayer() && access() == null) {
sender().sendMessage(C.RED + "The engine access for this world is null!");
sender().sendMessage(C.RED + "Please make sure the world is loaded & the engine is initialized. Generate a new chunk, for example.");
}
DeepSearchPregenerator.DeepSearchJob DeepSearchJob = DeepSearchPregenerator.DeepSearchJob.builder()
.world(world)
.radiusBlocks(radius)
.position(0)
.build();
File SearchGenFile = new File(worldDirectory, "DeepSearch.json");
DeepSearchPregenerator pregenerator = new DeepSearchPregenerator(DeepSearchJob, SearchGenFile);
pregenerator.start();
String msg = C.GREEN + "DeepSearch started in " + C.GOLD + worldName + C.GREEN + " of " + C.GOLD + (radius * 2) + C.GREEN + " by " + C.GOLD + (radius * 2) + C.GREEN + " blocks from " + C.GOLD + center.getX() + "," + center.getZ();
sender().sendMessage(msg);
Iris.info(msg);
} catch (Throwable e) {
sender().sendMessage(C.RED + "Epic fail. See console.");
Iris.reportError(e);
e.printStackTrace();
}
}
@Decree(description = "Stop the active DeepSearch task", aliases = "x")
public void stop(@Param(aliases = "world", description = "The world to pause") World world) throws IOException {
DeepSearchPregenerator DeepSearchInstance = DeepSearchPregenerator.getInstance();
File worldDirectory = new File(Bukkit.getWorldContainer(), world.getName());
File turboFile = new File(worldDirectory, "DeepSearch.json");
if (DeepSearchInstance != null) {
DeepSearchInstance.shutdownInstance(world);
sender().sendMessage(C.LIGHT_PURPLE + "Closed Turbogen instance for " + world.getName());
} else if (turboFile.exists() && turboFile.delete()) {
sender().sendMessage(C.LIGHT_PURPLE + "Closed Turbogen instance for " + world.getName());
} else if (turboFile.exists()) {
Iris.error("Failed to delete the old instance file of Turbo Pregen!");
} else {
sender().sendMessage(C.YELLOW + "No active pregeneration tasks to stop");
}
}
@Decree(description = "Pause / continue the active pregeneration task", aliases = {"t", "resume", "unpause"})
public void pause(
@Param(aliases = "world", description = "The world to pause")
World world
) {
if (TurboPregenerator.getInstance() != null) {
TurboPregenerator.setPausedTurbo(world);
sender().sendMessage(C.GREEN + "Paused/unpaused Turbo Pregen, now: " + (TurboPregenerator.isPausedTurbo(world) ? "Paused" : "Running") + ".");
} else {
File worldDirectory = new File(Bukkit.getWorldContainer(), world.getName());
File TurboFile = new File(worldDirectory, "DeepSearch.json");
if (TurboFile.exists()){
TurboPregenerator.loadTurboGenerator(world.getName());
sender().sendMessage(C.YELLOW + "Started DeepSearch back up!");
} else {
sender().sendMessage(C.YELLOW + "No active DeepSearch tasks to pause/unpause.");
}
}
}
}

View File

@@ -0,0 +1,284 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.commands;
import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
import com.volmit.iris.core.service.IrisEngineSVC;
import com.volmit.iris.core.tools.IrisPackBenchmarking;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.mantle.components.MantleObjectComponent;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisCave;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisEntity;
import com.volmit.iris.util.data.Dimension;
import com.volmit.iris.util.decree.DecreeExecutor;
import com.volmit.iris.util.decree.DecreeOrigin;
import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.mantle.TectonicPlate;
import com.volmit.iris.util.math.Vector3d;
import com.volmit.iris.util.plugin.VolmitSender;
import io.lumine.mythic.bukkit.adapters.BukkitEntity;
import net.jpountz.lz4.LZ4BlockInputStream;
import net.jpountz.lz4.LZ4BlockOutputStream;
import net.jpountz.lz4.LZ4FrameInputStream;
import net.jpountz.lz4.LZ4FrameOutputStream;
import org.apache.commons.lang.RandomStringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EntityType;
import java.io.*;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@Decree(name = "Developer", origin = DecreeOrigin.BOTH, description = "Iris World Manager", aliases = {"dev"})
public class CommandDeveloper implements DecreeExecutor {
private CommandTurboPregen turboPregen;
@Decree(description = "Get Loaded TectonicPlates Count", origin = DecreeOrigin.BOTH, sync = true)
public void EngineStatus() {
List<World> IrisWorlds = new ArrayList<>();
int TotalLoadedChunks = 0;
int TotalQueuedTectonicPlates = 0;
int TotalNotQueuedTectonicPlates = 0;
int TotalTectonicPlates = 0;
long lowestUnloadDuration = 0;
long highestUnloadDuration = 0;
for (World world : Bukkit.getWorlds()) {
try {
if (IrisToolbelt.access(world).getEngine() != null) {
IrisWorlds.add(world);
}
} catch (Exception e) {
// no
}
}
for (World world : IrisWorlds) {
Engine engine = IrisToolbelt.access(world).getEngine();
TotalQueuedTectonicPlates += (int) engine.getMantle().getToUnload();
TotalNotQueuedTectonicPlates += (int) engine.getMantle().getNotQueuedLoadedRegions();
TotalTectonicPlates += engine.getMantle().getLoadedRegionCount();
if (highestUnloadDuration <= (long) engine.getMantle().getTectonicDuration()) {
highestUnloadDuration = (long) engine.getMantle().getTectonicDuration();
}
if (lowestUnloadDuration >= (long) engine.getMantle().getTectonicDuration()) {
lowestUnloadDuration = (long) engine.getMantle().getTectonicDuration();
}
for (Chunk chunk : world.getLoadedChunks()) {
if (chunk.isLoaded()) {
TotalLoadedChunks++;
}
}
}
Iris.info("-------------------------");
Iris.info(C.DARK_PURPLE + "Engine Status");
Iris.info(C.DARK_PURPLE + "Total Loaded Chunks: " + C.LIGHT_PURPLE + TotalLoadedChunks);
Iris.info(C.DARK_PURPLE + "Tectonic Limit: " + C.LIGHT_PURPLE + IrisEngineSVC.getTectonicLimit());
Iris.info(C.DARK_PURPLE + "Tectonic Total Plates: " + C.LIGHT_PURPLE + TotalTectonicPlates);
Iris.info(C.DARK_PURPLE + "Tectonic Active Plates: " + C.LIGHT_PURPLE + TotalNotQueuedTectonicPlates);
Iris.info(C.DARK_PURPLE + "Tectonic ToUnload: " + C.LIGHT_PURPLE + TotalQueuedTectonicPlates);
Iris.info(C.DARK_PURPLE + "Lowest Tectonic Unload Duration: " + C.LIGHT_PURPLE + Form.duration(lowestUnloadDuration));
Iris.info(C.DARK_PURPLE + "Highest Tectonic Unload Duration: " + C.LIGHT_PURPLE + Form.duration(highestUnloadDuration));
Iris.info(C.DARK_PURPLE + "Cache Size: " + C.LIGHT_PURPLE + Form.f(IrisData.cacheSize()));
Iris.info("-------------------------");
}
@Decree(description = "Test")
public void benchmarkMantle(
@Param(description = "The world to bench", aliases = {"world"})
World world
) throws IOException, ClassNotFoundException {
Engine engine = IrisToolbelt.access(world).getEngine();
int maxHeight = engine.getTarget().getHeight();
File folder = new File(Bukkit.getWorldContainer(), world.getName());
int c = 0;
//MCAUtil.read()
File tectonicplates = new File(folder, "mantle");
for (File i : Objects.requireNonNull(tectonicplates.listFiles())) {
TectonicPlate.read(maxHeight, i);
c++;
Iris.info("Loaded count: " + c );
}
}
@Decree(description = "Test")
public void packBenchmark(
@Param(description = "The pack to bench", aliases = {"pack"})
IrisDimension dimension
) {
Iris.info("test");
IrisPackBenchmarking benchmark = new IrisPackBenchmarking(dimension, 1);
}
@Decree(description = "test")
public void test() throws NoSuchFieldException, IllegalAccessException {
IrisEngineSVC.instance.engineStatus();
}
@Decree(description = "UnloadChunks for good reasons.")
public void unloadchunks() {
List<World> IrisWorlds = new ArrayList<>();
int chunksUnloaded = 0;
for (World world : Bukkit.getWorlds()) {
try {
if (IrisToolbelt.access(world).getEngine() != null) {
IrisWorlds.add(world);
}
} catch (Exception e) {
// no
}
}
for (World world : IrisWorlds) {
for (Chunk chunk : world.getLoadedChunks()) {
if (chunk.isLoaded()) {
chunk.unload();
chunksUnloaded++;
}
}
}
Iris.info(C.IRIS + "Chunks Unloaded: " + chunksUnloaded);
}
@Decree(description = "Test", aliases = {"ip"})
public void network() {
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface ni : Collections.list(networkInterfaces)) {
Iris.info("Display Name: %s", ni.getDisplayName());
Enumeration<InetAddress> inetAddresses = ni.getInetAddresses();
for (InetAddress ia : Collections.list(inetAddresses)) {
Iris.info("IP: %s", ia.getHostAddress());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Decree(description = "Test the compression algorithms")
public void compression(
@Param(description = "base IrisWorld") World world,
@Param(description = "raw TectonicPlate File") String path,
@Param(description = "Algorithm to Test") String algorithm,
@Param(description = "Amount of Tests") int amount) {
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;
}
File file = new File(path);
if (!file.exists()) return;
Engine engine = IrisToolbelt.access(world).getEngine();
if(engine != null) {
int height = engine.getTarget().getHeight();
ExecutorService service = Executors.newFixedThreadPool(1);
VolmitSender sender = sender();
service.submit(() -> {
try {
DataInputStream raw = new DataInputStream(new FileInputStream(file));
TectonicPlate plate = new TectonicPlate(height, raw);
raw.close();
double d1 = 0;
double d2 = 0;
long size = 0;
File folder = new File("tmp");
folder.mkdirs();
for (int i = 0; i < amount; i++) {
File tmp = new File(folder, RandomStringUtils.randomAlphanumeric(10) + "." + algorithm + ".bin");
DataOutputStream dos = createOutput(tmp, algorithm);
long start = System.currentTimeMillis();
plate.write(dos);
dos.close();
d1 += System.currentTimeMillis() - start;
if (size == 0)
size = tmp.length();
start = System.currentTimeMillis();
DataInputStream din = createInput(tmp, algorithm);
new TectonicPlate(height, din);
din.close();
d2 += System.currentTimeMillis() - start;
tmp.delete();
}
IO.delete(folder);
sender.sendMessage(algorithm + " is " + Form.fileSize(size) + " big after compression");
sender.sendMessage(algorithm + " Took " + d2/amount + "ms to read");
sender.sendMessage(algorithm + " Took " + d1/amount + "ms to write");
} catch (Throwable e) {
e.printStackTrace();
}
});
service.shutdown();
} else {
Iris.info(C.RED + "Engine is null!");
}
}
private DataInputStream createInput(File file, String algorithm) throws Throwable {
FileInputStream in = new FileInputStream(file);
return new DataInputStream(switch (algorithm) {
case "gzip" -> new GZIPInputStream(in);
case "lz4f" -> new LZ4FrameInputStream(in);
case "lz4b" -> new LZ4BlockInputStream(in);
default -> throw new IllegalStateException("Unexpected value: " + algorithm);
});
}
private DataOutputStream createOutput(File file, String algorithm) throws Throwable {
FileOutputStream out = new FileOutputStream(file);
return new DataOutputStream(switch (algorithm) {
case "gzip" -> new GZIPOutputStream(out);
case "lz4f" -> new LZ4FrameOutputStream(out);
case "lz4b" -> new LZ4BlockOutputStream(out);
default -> throw new IllegalStateException("Unexpected value: " + algorithm);
});
}
}

View File

@@ -34,7 +34,9 @@ public class CommandFind implements DecreeExecutor {
@Decree(description = "Find a biome")
public void biome(
@Param(description = "The biome to look for")
IrisBiome biome
IrisBiome biome,
@Param(description = "Should you be teleported", defaultValue = "true")
boolean teleport
) {
Engine e = engine();
@@ -43,13 +45,15 @@ public class CommandFind implements DecreeExecutor {
return;
}
e.gotoBiome(biome, player());
e.gotoBiome(biome, player(), teleport);
}
@Decree(description = "Find a region")
public void region(
@Param(description = "The region to look for")
IrisRegion region
IrisRegion region,
@Param(description = "Should you be teleported", defaultValue = "true")
boolean teleport
) {
Engine e = engine();
@@ -58,13 +62,15 @@ public class CommandFind implements DecreeExecutor {
return;
}
e.gotoRegion(region, player());
e.gotoRegion(region, player(), teleport);
}
@Decree(description = "Find a structure")
public void structure(
@Param(description = "The structure to look for")
IrisJigsawStructure structure
IrisJigsawStructure structure,
@Param(description = "Should you be teleported", defaultValue = "true")
boolean teleport
) {
Engine e = engine();
@@ -73,13 +79,15 @@ public class CommandFind implements DecreeExecutor {
return;
}
e.gotoJigsaw(structure, player());
e.gotoJigsaw(structure, player(), teleport);
}
@Decree(description = "Find a point of interest.")
public void poi(
@Param(description = "The type of PoI to look for.")
String type
String type,
@Param(description = "Should you be teleported", defaultValue = "true")
boolean teleport
) {
Engine e = engine();
if (e == null) {
@@ -87,13 +95,15 @@ public class CommandFind implements DecreeExecutor {
return;
}
e.gotoPOI(type, player());
e.gotoPOI(type, player(), teleport);
}
@Decree(description = "Find an object")
public void object(
@Param(description = "The object to look for", customHandler = ObjectHandler.class)
String object
String object,
@Param(description = "Should you be teleported", defaultValue = "true")
boolean teleport
) {
Engine e = engine();
@@ -102,6 +112,6 @@ public class CommandFind implements DecreeExecutor {
return;
}
e.gotoObject(object, player());
e.gotoObject(object, player(), teleport);
}
}

View File

@@ -20,60 +20,67 @@ package com.volmit.iris.core.commands;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisBenchmarking;
import com.volmit.iris.core.tools.IrisCreator;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.core.safeguard.UtilsSFG;
import com.volmit.iris.engine.object.IrisWorld;
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.engine.safeguard.UtilsSFG;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.decree.DecreeContext;
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
import com.volmit.iris.engine.platform.DummyChunkGenerator;
import com.volmit.iris.util.decree.DecreeExecutor;
import com.volmit.iris.util.decree.DecreeOrigin;
import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.decree.specialhandlers.NullablePlayerHandler;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.mantle.MantleChunk;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.jobs.QueueJob;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Difficulty;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.Console;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static com.volmit.iris.Iris.service;
import static com.volmit.iris.core.service.EditSVC.deletingWorld;
import static com.volmit.iris.core.tools.IrisBenchmarking.inProgress;
import static com.volmit.iris.engine.safeguard.IrisSafeguard.unstablemode;
import static com.volmit.iris.engine.safeguard.ServerBootSFG.incompatiblePlugins;
import static com.volmit.iris.core.safeguard.IrisSafeguard.unstablemode;
import static com.volmit.iris.core.safeguard.ServerBootSFG.incompatibilities;
import static org.bukkit.Bukkit.getServer;
@Decree(name = "iris", aliases = {"ir", "irs"}, description = "Basic Command")
public class CommandIris implements DecreeExecutor {
private CommandStudio studio;
private CommandPregen pregen;
private CommandLazyPregen lazyPregen;
private CommandSettings settings;
private CommandObject object;
private CommandJigsaw jigsaw;
private CommandWhat what;
private CommandEdit edit;
private CommandFind find;
private CommandWorldManager manager;
public static @Getter String BenchDimension;
private CommandDeveloper developer;
public static boolean worldCreation = false;
String WorldToLoad;
String WorldEngine;
String worldNameToCheck = "YourWorldName";
VolmitSender sender = Iris.getSender();
@Decree(description = "Create a new world", aliases = {"+", "c"})
public void create(
@@ -85,7 +92,7 @@ public class CommandIris implements DecreeExecutor {
long seed
) {
if(sender() instanceof Player) {
if (incompatiblePlugins.get("Multiverse-Core")) {
if (incompatibilities.get("Multiverse-Core")) {
sender().sendMessage(C.RED + "Your server has an incompatibility that may corrupt all worlds on the server if not handled properly.");
sender().sendMessage(C.RED + "it is strongly advised for you to take action. see log for full detail");
sender().sendMessage(C.RED + "----------------------------------------------------------------");
@@ -93,7 +100,7 @@ public class CommandIris implements DecreeExecutor {
sender().sendMessage(C.RED + UtilsSFG.MSGIncompatibleWarnings());
sender().sendMessage(C.RED + "----------------------------------------------------------------");
}
if (unstablemode && !incompatiblePlugins.get("Multiverse-Core")) {
if (unstablemode && !incompatibilities.get("Multiverse-Core")) {
sender().sendMessage(C.RED + "Your server is experiencing an incompatibility with the Iris plugin.");
sender().sendMessage(C.RED + "Please rectify this problem to avoid further complications.");
sender().sendMessage(C.RED + "----------------------------------------------------------------");
@@ -119,6 +126,7 @@ public class CommandIris implements DecreeExecutor {
}
try {
worldCreation = true;
IrisToolbelt.createWorld()
.dimension(type.getLoadKey())
.name(name)
@@ -130,9 +138,10 @@ public class CommandIris implements DecreeExecutor {
sender().sendMessage(C.RED + "Exception raised during creation. See the console for more details.");
Iris.error("Exception raised during world creation: " + e.getMessage());
Iris.reportError(e);
worldCreation = false;
return;
}
worldCreation = false;
sender().sendMessage(C.GREEN + "Successfully created your world!");
}
@@ -165,6 +174,8 @@ public class CommandIris implements DecreeExecutor {
public void version() {
sender().sendMessage(C.GREEN + "Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software");
}
//todo Move to React
@Decree(description = "Benchmark your server", origin = DecreeOrigin.CONSOLE)
public void serverbenchmark() throws InterruptedException {
if(!inProgress) {
@@ -173,8 +184,9 @@ public class CommandIris implements DecreeExecutor {
Iris.info(C.RED + "Benchmark already is in progress.");
}
}
/*
/todo Fix PREGEN
/todo
@Decree(description = "Benchmark a pack", origin = DecreeOrigin.CONSOLE)
public void packbenchmark(
@Param(description = "Dimension to benchmark")
@@ -186,28 +198,16 @@ public class CommandIris implements DecreeExecutor {
IrisPackBenchmarking.runBenchmark();
} */
/* /todo Different approach this feels useless atm
@Decree(description = "Check for instabilities", origin = DecreeOrigin.CONSOLE)
public void fixunstable() throws InterruptedException {
if (unstablemode){
sender().sendMessage(C.RED + "Incompatibilities are posted in console..");
Iris.info(C.RED + "Your server is experiencing an incompatibility with the Iris plugin.");
Iris.info(C.RED + "Please rectify this problem to avoid further complications.");
Iris.info(C.RED + "----------------------------------------------------------------");
Iris.info(C.RED + "Command ran: /iris fixunstable");
UtilsSFG.printIncompatibleWarnings();
Iris.info(C.RED + "----------------------------------------------------------------");
} else {
Iris.info(C.BLUE + "Iris is running stable..");
sender().sendMessage("Iris is running stable..");
}
} */
@Decree(description = "Print world height information", origin = DecreeOrigin.PLAYER)
public void height() {
sender().sendMessage(C.GREEN + "" + sender().player().getWorld().getMinHeight() + " to " + sender().player().getWorld().getMaxHeight());
sender().sendMessage(C.GREEN + "Total Height: " + (sender().player().getWorld().getMaxHeight() - sender().player().getWorld().getMinHeight()));
if (sender().isPlayer()) {
sender().sendMessage(C.GREEN + "" + sender().player().getWorld().getMinHeight() + " to " + sender().player().getWorld().getMaxHeight());
sender().sendMessage(C.GREEN + "Total Height: " + (sender().player().getWorld().getMaxHeight() - sender().player().getWorld().getMinHeight()));
} else {
World mainWorld = getServer().getWorlds().get(0);
Iris.info(C.GREEN + "" + mainWorld.getMinHeight() + " to " + mainWorld.getMaxHeight());
Iris.info(C.GREEN + "Total Height: " + (mainWorld.getMaxHeight() - mainWorld.getMinHeight()));
}
}
@Decree(description = "QOL command to open a overworld studio world.", sync = true)
@@ -216,6 +216,44 @@ public class CommandIris implements DecreeExecutor {
Iris.service(StudioSVC.class).open(sender(), 1337, "overworld");
}
@Decree(description = "Check if iris has access to that specific world")
public void hasAccess(
@Param(description = "The world to access", aliases = {"world"})
World world
) {
Engine engine = IrisToolbelt.access(world).getEngine();
if (engine != null) {
sender().sendMessage("Access granted successfully.");
} else {
sender().sendMessage(C.RED + "Failed to grant access.");
}
}
@Decree(description = "All Iris Worlds on the server.", aliases = {"worlds"})
public void irisworlds() {
List<World> IrisWorlds = new ArrayList<>();
for (World world : Bukkit.getWorlds()) {
try {
if (IrisToolbelt.access(world).getEngine() != null) {
IrisWorlds.add(world);
}
} catch (Exception e) {
// no
}
}
if (sender().isPlayer()) {
sender.sendMessage(C.IRIS + "Iris Worlds:");
for (World world : IrisWorlds) {
sender.sendMessage(C.GREEN + "- " + world.getName());
}
} else {
Iris.info(C.IRIS + "Iris Worlds:");
for (World world : IrisWorlds) {
sender.sendMessage(C.GREEN + "- " + world.getName());
}
}
}
@Decree(description = "Remove an Iris world", aliases = {"del", "rm", "delete"}, sync = true)
public void remove(
@Param(description = "The world to remove")
@@ -224,7 +262,7 @@ public class CommandIris implements DecreeExecutor {
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()));
sender().sendMessage(C.RED + "This is not an Iris world. Iris worlds: " + String.join(", ", getServer().getWorlds().stream().filter(IrisToolbelt::isIrisWorld).map(World::getName).toList()));
return;
}
sender().sendMessage(C.GREEN + "Removing world: " + world.getName());
@@ -241,7 +279,7 @@ public class CommandIris implements DecreeExecutor {
IrisToolbelt.evacuate(world, "Deleting world");
deletingWorld = true;
Bukkit.unloadWorld(world, false);
int retries = 10;
int retries = 12;
if (delete) {
if (deleteDirectory(world.getWorldFolder())) {
sender().sendMessage(C.GREEN + "Successfully removed world folder");
@@ -251,13 +289,12 @@ public class CommandIris implements DecreeExecutor {
sender().sendMessage(C.GREEN + "Successfully removed world folder");
break;
}
sender().sendMessage(C.GREEN + "DEBUG1");
retries--;
if (retries == 0){
sender().sendMessage(C.RED + "Failed to remove world folder");
break;
}
J.sleep(2000);
J.sleep(3000);
}
}
}
@@ -366,77 +403,6 @@ public class CommandIris implements DecreeExecutor {
sender().sendMessage(C.GREEN + "Hotloaded settings");
}
@Decree(name = "regen", description = "Regenerate nearby chunks.", aliases = "rg", sync = true, origin = DecreeOrigin.PLAYER)
public void regen(
@Param(name = "radius", description = "The radius of nearby cunks", defaultValue = "5")
int radius
) {
if (IrisToolbelt.isIrisWorld(player().getWorld())) {
VolmitSender sender = sender();
J.a(() -> {
DecreeContext.touch(sender);
PlatformChunkGenerator plat = IrisToolbelt.access(player().getWorld());
Engine engine = plat.getEngine();
try {
Chunk cx = player().getLocation().getChunk();
KList<Runnable> js = new KList<>();
BurstExecutor b = MultiBurst.burst.burst();
b.setMulticore(false);
int rad = engine.getMantle().getRealRadius();
for (int i = -(radius + rad); i <= radius + rad; i++) {
for (int j = -(radius + rad); j <= radius + rad; j++) {
engine.getMantle().getMantle().deleteChunk(i + cx.getX(), j + cx.getZ());
}
}
for (int i = -radius; i <= radius; i++) {
for (int j = -radius; j <= radius; j++) {
int finalJ = j;
int finalI = i;
b.queue(() -> plat.injectChunkReplacement(player().getWorld(), finalI + cx.getX(), finalJ + cx.getZ(), (f) -> {
synchronized (js) {
js.add(f);
}
}));
}
}
b.complete();
sender().sendMessage(C.GREEN + "Regenerating " + Form.f(js.size()) + " Sections");
QueueJob<Runnable> r = new QueueJob<>() {
final KList<Future<?>> futures = new KList<>();
@Override
public void execute(Runnable runnable) {
futures.add(J.sfut(runnable));
if (futures.size() > 64) {
while (futures.isNotEmpty()) {
try {
futures.remove(0).get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}
}
}
@Override
public String getName() {
return "Regenerating";
}
};
r.queue(js);
r.execute(sender());
} catch (Throwable e) {
sender().sendMessage("Unable to parse view-distance");
}
});
} else {
sender().sendMessage(C.RED + "You must be in an Iris World to use regen!");
}
}
@Decree(description = "Update the pack of a world (UNSAFE!)", name = "^world", aliases = "update-world")
public void updateWorld(
@Param(description = "The world to update", contextual = true)
@@ -472,4 +438,190 @@ public class CommandIris implements DecreeExecutor {
Iris.service(StudioSVC.class).installIntoWorld(sender(), pack.getLoadKey(), folder);
}
@Decree(description = "Unload an Iris World", origin = DecreeOrigin.PLAYER, sync = true)
public void unloadWorld(
@Param(description = "The world to unload")
World world
) {
if (!IrisToolbelt.isIrisWorld(world)) {
sender().sendMessage(C.RED + "This is not an Iris world. Iris worlds: " + String.join(", ", getServer().getWorlds().stream().filter(IrisToolbelt::isIrisWorld).map(World::getName).toList()));
return;
}
sender().sendMessage(C.GREEN + "Unloading world: " + world.getName());
try {
IrisToolbelt.evacuate(world);
Bukkit.unloadWorld(world, false);
sender().sendMessage(C.GREEN + "World unloaded successfully.");
} catch (Exception e) {
sender().sendMessage(C.RED + "Failed to unload the world: " + e.getMessage());
e.printStackTrace();
}
}
@Decree(description = "Load an Iris World", origin = DecreeOrigin.PLAYER, sync = true, aliases = {"import"})
public void loadWorld(
@Param(description = "The name of the world to load")
String world
) {
World worldloaded = Bukkit.getWorld(world);
worldNameToCheck = world;
boolean worldExists = doesWorldExist(worldNameToCheck);
WorldEngine = world;
if (!worldExists) {
sender().sendMessage(C.YELLOW + world + " Doesnt exist on the server.");
return;
}
WorldToLoad = world;
File BUKKIT_YML = new File("bukkit.yml");
String pathtodim = world + File.separator +"iris"+File.separator +"pack"+File.separator +"dimensions"+File.separator;
File directory = new File(Bukkit.getWorldContainer(), pathtodim);
String dimension = null;
if (directory.exists() && directory.isDirectory()) {
File[] files = directory.listFiles();
if (files != null) {
for (File file : files) {
if (file.isFile()) {
String fileName = file.getName();
if (fileName.endsWith(".json")) {
dimension = fileName.substring(0, fileName.length() - 5);
sender().sendMessage(C.BLUE + "Generator: " + dimension);
}
}
}
}
} else {
sender().sendMessage(C.GOLD + world + " is not an iris world.");
return;
}
sender().sendMessage(C.GREEN + "Loading world: " + world);
YamlConfiguration yml = YamlConfiguration.loadConfiguration(BUKKIT_YML);
String gen = "Iris:" + dimension;
ConfigurationSection section = yml.contains("worlds") ? yml.getConfigurationSection("worlds") : yml.createSection("worlds");
if (!section.contains(world)) {
section.createSection(world).set("generator", gen);
try {
yml.save(BUKKIT_YML);
Iris.info("Registered \"" + world + "\" in bukkit.yml");
} catch (IOException e) {
Iris.error("Failed to update bukkit.yml!");
e.printStackTrace();
}
}
checkForBukkitWorlds();
sender().sendMessage(C.GREEN + world + " loaded successfully.");
}
@Decree(description = "Evacuate an iris world", origin = DecreeOrigin.PLAYER, sync = true)
public void evacuate(
@Param(description = "Evacuate the world")
World world
) {
if (!IrisToolbelt.isIrisWorld(world)) {
sender().sendMessage(C.RED + "This is not an Iris world. Iris worlds: " + String.join(", ", getServer().getWorlds().stream().filter(IrisToolbelt::isIrisWorld).map(World::getName).toList()));
return;
}
sender().sendMessage(C.GREEN + "Evacuating world" + world.getName());
IrisToolbelt.evacuate(world);
}
boolean doesWorldExist(String worldName) {
File worldContainer = Bukkit.getWorldContainer();
File worldDirectory = new File(worldContainer, worldName);
return worldDirectory.exists() && worldDirectory.isDirectory();
}
private void checkForBukkitWorlds() {
FileConfiguration fc = new YamlConfiguration();
try {
fc.load(new File("bukkit.yml"));
ConfigurationSection section = fc.getConfigurationSection("worlds");
if (section == null) {
return;
}
List<String> worldsToLoad = Collections.singletonList(WorldToLoad);
for (String s : section.getKeys(false)) {
if (!worldsToLoad.contains(s)) {
continue;
}
ConfigurationSection entry = section.getConfigurationSection(s);
if (!entry.contains("generator", true)) {
continue;
}
String generator = entry.getString("generator");
if (generator.startsWith("Iris:")) {
generator = generator.split("\\Q:\\E")[1];
} else if (generator.equalsIgnoreCase("Iris")) {
generator = IrisSettings.get().getGenerator().getDefaultWorldType();
} else {
continue;
}
Iris.info("2 World: %s | Generator: %s", s, generator);
if (Bukkit.getWorlds().stream().anyMatch(w -> w.getName().equals(s))) {
continue;
}
Iris.info(C.LIGHT_PURPLE + "Preparing Spawn for " + s + "' using Iris:" + generator + "...");
new WorldCreator(s)
.generator(getDefaultWorldGenerator(s, generator))
.environment(IrisData.loadAnyDimension(generator).getEnvironment())
.createWorld();
Iris.info(C.LIGHT_PURPLE + "Loaded " + s + "!");
}
} catch (Throwable e) {
e.printStackTrace();
}
}
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
Iris.debug("Default World Generator Called for " + worldName + " using ID: " + id);
if (worldName.equals("test")) {
try {
throw new RuntimeException();
} catch (Throwable e) {
Iris.info(e.getStackTrace()[1].getClassName());
if (e.getStackTrace()[1].getClassName().contains("com.onarandombox.MultiverseCore")) {
Iris.debug("MVC Test detected, Quick! Send them the dummy!");
return new DummyChunkGenerator();
}
}
}
IrisDimension dim;
if (id == null || id.isEmpty()) {
dim = IrisData.loadAnyDimension(IrisSettings.get().getGenerator().getDefaultWorldType());
} else {
dim = IrisData.loadAnyDimension(id);
}
Iris.debug("Generator ID: " + id + " requested by bukkit/plugin");
if (dim == null) {
Iris.warn("Unable to find dimension type " + id + " Looking for online packs...");
service(StudioSVC.class).downloadSearch(new VolmitSender(Bukkit.getConsoleSender()), id, true);
dim = IrisData.loadAnyDimension(id);
if (dim == null) {
throw new RuntimeException("Can't find dimension " + id + "!");
} else {
Iris.info("Resolved missing dimension, proceeding with generation.");
}
}
Iris.debug("Assuming IrisDimension: " + dim.getName());
IrisWorld w = IrisWorld.builder()
.name(worldName)
.seed(1337)
.environment(dim.getEnvironment())
.worldFolder(new File(Bukkit.getWorldContainer(), worldName))
.minHeight(dim.getMinHeight())
.maxHeight(dim.getMaxHeight())
.build();
Iris.debug("Generator Config: " + w.toString());
File ff = new File(w.worldFolder(), "iris/pack");
if (!ff.exists() || ff.listFiles().length == 0) {
ff.mkdirs();
service(StudioSVC.class).installIntoWorld(sender, dim.getLoadKey(), ff.getParentFile());
}
return new BukkitChunkGenerator(w, false, ff, dim.getLoadKey());
}
}

View File

@@ -0,0 +1,121 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.commands;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.gui.PregeneratorJob;
import com.volmit.iris.core.pregenerator.LazyPregenerator;
import com.volmit.iris.core.pregenerator.PregenTask;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.util.decree.DecreeExecutor;
import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.Position2;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.util.Vector;
import java.io.File;
import java.io.IOException;
@Decree(name = "lazypregen", aliases = "lazy", description = "Pregenerate your Iris worlds!")
public class CommandLazyPregen implements DecreeExecutor {
public String worldName;
@Decree(description = "Pregenerate a world")
public void start(
@Param(description = "The radius of the pregen in blocks", aliases = "size")
int radius,
@Param(description = "The world to pregen", contextual = true)
World world,
@Param(aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0")
Vector center,
@Param(aliases = "maxcpm", description = "Limit the chunks per minute the pregen will generate", defaultValue = "999999999")
int cpm,
@Param(aliases = "silent", description = "Silent generation", defaultValue = "false")
boolean silent
) {
worldName = world.getName();
File worldDirectory = new File(Bukkit.getWorldContainer(), world.getName());
File lazyFile = new File(worldDirectory, "lazygen.json");
if (lazyFile.exists()) {
sender().sendMessage(C.BLUE + "Lazy pregen is already in progress");
Iris.info(C.YELLOW + "Lazy pregen is already in progress");
return;
}
try {
if (sender().isPlayer() && access() == null) {
sender().sendMessage(C.RED + "The engine access for this world is null!");
sender().sendMessage(C.RED + "Please make sure the world is loaded & the engine is initialized. Generate a new chunk, for example.");
}
LazyPregenerator.LazyPregenJob pregenJob = LazyPregenerator.LazyPregenJob.builder()
.world(worldName)
.healingPosition(0)
.healing(false)
.chunksPerMinute(cpm)
.radiusBlocks(radius)
.position(0)
.silent(silent)
.build();
File lazyGenFile = new File(worldDirectory, "lazygen.json");
LazyPregenerator pregenerator = new LazyPregenerator(pregenJob, lazyGenFile);
pregenerator.start();
String msg = C.GREEN + "LazyPregen started in " + C.GOLD + worldName + C.GREEN + " of " + C.GOLD + (radius * 2) + C.GREEN + " by " + C.GOLD + (radius * 2) + C.GREEN + " blocks from " + C.GOLD + center.getX() + "," + center.getZ();
sender().sendMessage(msg);
Iris.info(msg);
} catch (Throwable e) {
sender().sendMessage(C.RED + "Epic fail. See console.");
Iris.reportError(e);
e.printStackTrace();
}
}
@Decree(description = "Stop the active pregeneration task", aliases = "x")
public void stop(
@Param(aliases = "world", description = "The world to pause")
World world
) throws IOException {
if (LazyPregenerator.getInstance() != null) {
LazyPregenerator.getInstance().shutdownInstance(world);
sender().sendMessage(C.LIGHT_PURPLE + "Closed lazygen instance for " + world.getName());
} else {
sender().sendMessage(C.YELLOW + "No active pregeneration tasks to stop");
}
}
@Decree(description = "Pause / continue the active pregeneration task", aliases = {"t", "resume", "unpause"})
public void pause(
@Param(aliases = "world", description = "The world to pause")
World world
) {
if (LazyPregenerator.getInstance() != null) {
LazyPregenerator.getInstance().setPausedLazy(world);
sender().sendMessage(C.GREEN + "Paused/unpaused Lazy Pregen, now: " + (LazyPregenerator.getInstance().isPausedLazy(world) ? "Paused" : "Running") + ".");
} else {
sender().sendMessage(C.YELLOW + "No active Lazy Pregen tasks to pause/unpause.");
}
}
}

View File

@@ -19,6 +19,7 @@
package com.volmit.iris.core.commands;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.gui.PregeneratorJob;
import com.volmit.iris.core.pregenerator.LazyPregenerator;
import com.volmit.iris.core.pregenerator.PregenTask;
@@ -43,75 +44,36 @@ public class CommandPregen implements DecreeExecutor {
@Param(description = "The world to pregen", contextual = true)
World world,
@Param(aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0")
Vector center,
@Param(aliases = "method", description = "The pregen method that will get used. Lazy or Async", defaultValue = "async")
String method
) {
if(method.equals("async") || method.equals("lazy")){
if (method.equalsIgnoreCase("async")) {
try {
if (sender().isPlayer() && access() == null) {
sender().sendMessage(C.RED + "The engine access for this world is null!");
sender().sendMessage(C.RED + "Please make sure the world is loaded & the engine is initialized. Generate a new chunk, for example.");
}
radius = Math.max(radius, 1024);
int w = (radius >> 9 + 1) * 2;
IrisToolbelt.pregenerate(PregenTask
.builder()
.center(new Position2(center.getBlockX() >> 9, center.getBlockZ() >> 9))
.width(w)
.height(w)
.build(), world);
String msg = C.GREEN + "Pregen started in " + C.GOLD + world.getName() + C.GREEN + " of " + C.GOLD + (radius * 2) + C.GREEN + " by " + C.GOLD + (radius * 2) + C.GREEN + " blocks from " + C.GOLD + center.getX() + "," + center.getZ();
sender().sendMessage(msg);
Iris.info(msg);
} catch (Throwable e) {
sender().sendMessage(C.RED + "Epic fail. See console.");
Iris.reportError(e);
e.printStackTrace();
}
Vector center
) {
try {
if (sender().isPlayer() && access() == null) {
sender().sendMessage(C.RED + "The engine access for this world is null!");
sender().sendMessage(C.RED + "Please make sure the world is loaded & the engine is initialized. Generate a new chunk, for example.");
}
if (method.equalsIgnoreCase("lazy")) {
String worldName = world.getName();
try {
if (sender().isPlayer() && access() == null) {
sender().sendMessage(C.RED + "The engine access for this world is null!");
sender().sendMessage(C.RED + "Please make sure the world is loaded & the engine is initialized. Generate a new chunk, for example.");
}
LazyPregenerator.LazyPregenJob pregenJob = LazyPregenerator.LazyPregenJob.builder()
.world(worldName)
.healingPosition(0)
.healing(false)
.chunksPerMinute(999999999)
.radiusBlocks(radius)
.position(0)
.build();
LazyPregenerator pregenerator = new LazyPregenerator(pregenJob, new File("plugins/Iris/lazygen.json"));
pregenerator.start();
String msg = C.GREEN + "Pregen started in " + C.GOLD + worldName + C.GREEN + " of " + C.GOLD + (radius * 2) + C.GREEN + " by " + C.GOLD + (radius * 2) + C.GREEN + " blocks from " + C.GOLD + center.getX() + "," + center.getZ();
sender().sendMessage(msg);
Iris.info(msg);
} catch (Throwable e) {
sender().sendMessage(C.RED + "Epic fail. See console.");
Iris.reportError(e);
e.printStackTrace();
}
}
} else {
sender().sendMessage(C.RED + "Please use a valid method.");
radius = Math.max(radius, 1024);
int w = (radius >> 9 + 1) * 2;
IrisToolbelt.pregenerate(PregenTask
.builder()
.center(new Position2(center.getBlockX() >> 9, center.getBlockZ() >> 9))
.gui(true)
.width(w)
.height(w)
.build(), world);
String msg = C.GREEN + "Pregen started in " + C.GOLD + world.getName() + C.GREEN + " of " + C.GOLD + (radius * 2) + C.GREEN + " by " + C.GOLD + (radius * 2) + C.GREEN + " blocks from " + C.GOLD + center.getX() + "," + center.getZ();
sender().sendMessage(msg);
Iris.info(msg);
} catch (Throwable e) {
sender().sendMessage(C.RED + "Epic fail. See console.");
Iris.reportError(e);
e.printStackTrace();
}
}
@Decree(description = "Stop the active pregeneration task", aliases = "x")
public void stop() {
if (PregeneratorJob.shutdownInstance()) {
Iris.info( C.BLUE + "Finishing up mca region...");
sender().sendMessage(C.DARK_BLUE + "Stopped pregeneration task");
} else {
sender().sendMessage(C.YELLOW + "No active pregeneration tasks to stop");
}

View File

@@ -26,12 +26,15 @@ import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.project.IrisProject;
import com.volmit.iris.core.service.ConversionSVC;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisConverter;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.decree.DecreeContext;
import com.volmit.iris.util.decree.DecreeExecutor;
import com.volmit.iris.util.decree.DecreeOrigin;
import com.volmit.iris.util.decree.annotations.Decree;
@@ -45,11 +48,17 @@ import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.json.JSONArray;
import com.volmit.iris.util.json.JSONObject;
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.Spiraler;
import com.volmit.iris.util.noise.CNG;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.O;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import com.volmit.iris.util.scheduling.jobs.QueueJob;
import io.papermc.lib.PaperLib;
import org.bukkit.*;
import org.bukkit.event.inventory.InventoryType;
@@ -67,12 +76,16 @@ import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
@Decree(name = "studio", aliases = {"std", "s"}, description = "Studio Commands", studio = true)
public class CommandStudio implements DecreeExecutor {
private CommandFind find;
private CommandEdit edit;
private CommandDeepSearch deepSearch;
public static String hrf(Duration duration) {
return duration.toString().substring(2).replaceAll("(\\d[HMS])(?!$)", "$1 ").toLowerCase();
@@ -143,12 +156,83 @@ public class CommandStudio implements DecreeExecutor {
sender().sendMessage(C.GREEN + "The \"" + dimension.getName() + "\" pack has version: " + dimension.getVersion());
}
@Decree(name = "regen", description = "Regenerate nearby chunks.", aliases = "rg", sync = true, origin = DecreeOrigin.PLAYER)
public void regen(
@Param(name = "radius", description = "The radius of nearby cunks", defaultValue = "5")
int radius
) {
if (IrisToolbelt.isIrisWorld(player().getWorld())) {
VolmitSender sender = sender();
J.a(() -> {
DecreeContext.touch(sender);
PlatformChunkGenerator plat = IrisToolbelt.access(player().getWorld());
Engine engine = plat.getEngine();
try {
Chunk cx = player().getLocation().getChunk();
KList<Runnable> js = new KList<>();
BurstExecutor b = MultiBurst.burst.burst();
b.setMulticore(false);
int rad = engine.getMantle().getRealRadius();
for (int i = -(radius + rad); i <= radius + rad; i++) {
for (int j = -(radius + rad); j <= radius + rad; j++) {
engine.getMantle().getMantle().deleteChunk(i + cx.getX(), j + cx.getZ());
}
}
for (int i = -radius; i <= radius; i++) {
for (int j = -radius; j <= radius; j++) {
int finalJ = j;
int finalI = i;
b.queue(() -> plat.injectChunkReplacement(player().getWorld(), finalI + cx.getX(), finalJ + cx.getZ(), (f) -> {
synchronized (js) {
js.add(f);
}
}));
}
}
b.complete();
sender().sendMessage(C.GREEN + "Regenerating " + Form.f(js.size()) + " Sections");
QueueJob<Runnable> r = new QueueJob<>() {
final KList<Future<?>> futures = new KList<>();
@Override
public void execute(Runnable runnable) {
futures.add(J.sfut(runnable));
if (futures.size() > 64) {
while (futures.isNotEmpty()) {
try {
futures.remove(0).get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}
}
}
@Override
public String getName() {
return "Regenerating";
}
};
r.queue(js);
r.execute(sender());
} catch (Throwable e) {
sender().sendMessage("Unable to parse view-distance");
}
});
} else {
sender().sendMessage(C.RED + "You must be in an Iris World to use regen!");
}
}
@Decree(description = "Convert objects in the \"convert\" folder")
public void convert() {
Iris.service(ConversionSVC.class).check(sender());
//IrisConverter.convertSchematics(sender());
}
@Decree(description = "Execute a script", aliases = "run", origin = DecreeOrigin.PLAYER)
public void execute(
@Param(description = "The script to run")

View File

@@ -0,0 +1,131 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.commands;
import com.volmit.iris.Iris;
import com.volmit.iris.core.pregenerator.LazyPregenerator;
import com.volmit.iris.core.pregenerator.TurboPregenerator;
import com.volmit.iris.core.pregenerator.TurboPregenerator;
import com.volmit.iris.util.decree.DecreeExecutor;
import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.format.C;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.util.Vector;
import java.io.File;
import java.io.IOException;
@Decree(name = "turbopregen", aliases = "turbo", description = "Pregenerate your Iris worlds!")
public class CommandTurboPregen implements DecreeExecutor {
public String worldName;
@Decree(description = "Pregenerate a world")
public void start(
@Param(description = "The radius of the pregen in blocks", aliases = "size")
int radius,
@Param(description = "The world to pregen", contextual = true)
World world,
@Param(aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0")
Vector center
) {
worldName = world.getName();
File worldDirectory = new File(Bukkit.getWorldContainer(), world.getName());
File TurboFile = new File(worldDirectory, "turbogen.json");
if (TurboFile.exists()) {
if (TurboPregenerator.getInstance() != null) {
sender().sendMessage(C.BLUE + "Turbo pregen is already in progress");
Iris.info(C.YELLOW + "Turbo pregen is already in progress");
return;
} else {
try {
TurboFile.delete();
} catch (Exception e){
Iris.error("Failed to delete the old instance file of Turbo Pregen!");
return;
}
}
}
try {
if (sender().isPlayer() && access() == null) {
sender().sendMessage(C.RED + "The engine access for this world is null!");
sender().sendMessage(C.RED + "Please make sure the world is loaded & the engine is initialized. Generate a new chunk, for example.");
}
TurboPregenerator.TurboPregenJob pregenJob = TurboPregenerator.TurboPregenJob.builder()
.world(worldName)
.radiusBlocks(radius)
.position(0)
.build();
File TurboGenFile = new File(worldDirectory, "turbogen.json");
TurboPregenerator pregenerator = new TurboPregenerator(pregenJob, TurboGenFile);
pregenerator.start();
String msg = C.GREEN + "TurboPregen started in " + C.GOLD + worldName + C.GREEN + " of " + C.GOLD + (radius * 2) + C.GREEN + " by " + C.GOLD + (radius * 2) + C.GREEN + " blocks from " + C.GOLD + center.getX() + "," + center.getZ();
sender().sendMessage(msg);
Iris.info(msg);
} catch (Throwable e) {
sender().sendMessage(C.RED + "Epic fail. See console.");
Iris.reportError(e);
e.printStackTrace();
}
}
@Decree(description = "Stop the active pregeneration task", aliases = "x")
public void stop(@Param(aliases = "world", description = "The world to pause") World world) throws IOException {
TurboPregenerator turboPregenInstance = TurboPregenerator.getInstance();
File worldDirectory = new File(Bukkit.getWorldContainer(), world.getName());
File turboFile = new File(worldDirectory, "turbogen.json");
if (turboPregenInstance != null) {
turboPregenInstance.shutdownInstance(world);
sender().sendMessage(C.LIGHT_PURPLE + "Closed Turbogen instance for " + world.getName());
} else if (turboFile.exists() && turboFile.delete()) {
sender().sendMessage(C.LIGHT_PURPLE + "Closed Turbogen instance for " + world.getName());
} else if (turboFile.exists()) {
Iris.error("Failed to delete the old instance file of Turbo Pregen!");
} else {
sender().sendMessage(C.YELLOW + "No active pregeneration tasks to stop");
}
}
@Decree(description = "Pause / continue the active pregeneration task", aliases = {"t", "resume", "unpause"})
public void pause(
@Param(aliases = "world", description = "The world to pause")
World world
) {
if (TurboPregenerator.getInstance() != null) {
TurboPregenerator.setPausedTurbo(world);
sender().sendMessage(C.GREEN + "Paused/unpaused Turbo Pregen, now: " + (TurboPregenerator.isPausedTurbo(world) ? "Paused" : "Running") + ".");
} else {
File worldDirectory = new File(Bukkit.getWorldContainer(), world.getName());
File TurboFile = new File(worldDirectory, "turbogen.json");
if (TurboFile.exists()){
TurboPregenerator.loadTurboGenerator(world.getName());
sender().sendMessage(C.YELLOW + "Started Turbo Pregen back up!");
} else {
sender().sendMessage(C.YELLOW + "No active Turbo Pregen tasks to pause/unpause.");
}
}
}
}

View File

@@ -22,7 +22,9 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.edit.BlockSignal;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.data.B;
import com.volmit.iris.util.decree.DecreeExecutor;
import com.volmit.iris.util.decree.DecreeOrigin;
@@ -37,6 +39,7 @@ import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
@Decree(name = "what", origin = DecreeOrigin.PLAYER, studio = true, description = "Iris What?")
@@ -82,6 +85,19 @@ public class CommandWhat implements DecreeExecutor {
}
}
@Decree(description = "What region am i in?", origin = DecreeOrigin.PLAYER)
public void region() {
try {
Chunk chunk = world().getChunkAt(player().getLocation().getBlockZ() / 16, player().getLocation().getBlockZ() / 16);
IrisRegion r = engine().getRegion(chunk);
sender().sendMessage("IRegion: " + r.getLoadKey() + " (" + r.getName() + ")");
} catch (Throwable e) {
Iris.reportError(e);
sender().sendMessage(C.IRIS + "Iris worlds only.");
}
}
@Decree(description = "What block am i looking at?", origin = DecreeOrigin.PLAYER)
public void block() {
BlockData bd;
@@ -147,7 +163,7 @@ public class CommandWhat implements DecreeExecutor {
sender().sendMessage("Found " + v.get() + " Nearby Markers (" + marker + ")");
} else {
sender().sendMessage("Iris worlds only.");
sender().sendMessage(C.IRIS + "Iris worlds only.");
}
}
}

View File

@@ -1,250 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.commands;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisWorld;
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
import com.volmit.iris.engine.platform.DummyChunkGenerator;
import com.volmit.iris.util.decree.DecreeExecutor;
import com.volmit.iris.util.decree.DecreeOrigin;
import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.Bukkit;
import org.bukkit.Difficulty;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.generator.ChunkGenerator;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import static com.volmit.iris.Iris.service;
// Not done yet but works
@Decree(name = "worldmanager", origin = DecreeOrigin.PLAYER, description = "Iris World Manager", aliases = {"manager"})
public class CommandWorldManager implements DecreeExecutor {
public Difficulty difficulty = Difficulty.NORMAL;
String WorldToLoad;
String WorldEngine;
String worldNameToCheck = "YourWorldName";
VolmitSender sender = Iris.getSender();
@Decree(description = "Unload an Iris World", origin = DecreeOrigin.PLAYER, sync = true)
public void unloadWorld(
@Param(description = "The world to unload")
World world
) {
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 + "Unloading world: " + world.getName());
try {
IrisToolbelt.evacuate(world);
Bukkit.unloadWorld(world, false);
sender().sendMessage(C.GREEN + "World unloaded successfully.");
} catch (Exception e) {
sender().sendMessage(C.RED + "Failed to unload the world: " + e.getMessage());
e.printStackTrace();
}
}
@Decree(description = "Load an Iris World", origin = DecreeOrigin.PLAYER, sync = true, aliases = {"import"})
public void loadWorld(
@Param(description = "The name of the world to load")
String world
) {
World worldloaded = Bukkit.getWorld(world);
worldNameToCheck = world;
boolean worldExists = doesWorldExist(worldNameToCheck);
WorldEngine = world;
if (!worldExists) {
sender().sendMessage(C.YELLOW + world + " Doesnt exist on the server.");
return;
}
WorldToLoad = world;
File BUKKIT_YML = new File("bukkit.yml");
String pathtodim = world + "\\iris\\pack\\dimensions\\";
File directory = new File(Bukkit.getWorldContainer(), pathtodim);
String dimension = null;
if (directory.exists() && directory.isDirectory()) {
File[] files = directory.listFiles();
if (files != null) {
for (File file : files) {
if (file.isFile()) {
String fileName = file.getName();
if (fileName.endsWith(".json")) {
dimension = fileName.substring(0, fileName.length() - 5);
sender().sendMessage(C.BLUE + "Generator: " + dimension);
}
}
}
}
} else {
sender().sendMessage(C.GOLD + world + " is not an iris world.");
return;
}
sender().sendMessage(C.GREEN + "Loading world: " + world);
YamlConfiguration yml = YamlConfiguration.loadConfiguration(BUKKIT_YML);
String gen = "Iris:" + dimension;
ConfigurationSection section = yml.contains("worlds") ? yml.getConfigurationSection("worlds") : yml.createSection("worlds");
if (!section.contains(world)) {
section.createSection(world).set("generator", gen);
try {
yml.save(BUKKIT_YML);
Iris.info("Registered \"" + world + "\" in bukkit.yml");
} catch (IOException e) {
Iris.error("Failed to update bukkit.yml!");
e.printStackTrace();
}
}
checkForBukkitWorlds();
sender().sendMessage(C.GREEN + world + " loaded successfully.");
}
@Decree(description = "Evacuate an iris world", origin = DecreeOrigin.PLAYER, sync = true)
public void evacuate(
@Param(description = "Evacuate the world")
World world
) {
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 + "Evacuating world" + world.getName());
IrisToolbelt.evacuate(world);
}
boolean doesWorldExist(String worldName) {
File worldContainer = Bukkit.getWorldContainer();
File worldDirectory = new File(worldContainer, worldName);
return worldDirectory.exists() && worldDirectory.isDirectory();
}
private void checkForBukkitWorlds() {
FileConfiguration fc = new YamlConfiguration();
try {
fc.load(new File("bukkit.yml"));
ConfigurationSection section = fc.getConfigurationSection("worlds");
if (section == null) {
return;
}
List<String> worldsToLoad = Collections.singletonList(WorldToLoad);
for (String s : section.getKeys(false)) {
if (!worldsToLoad.contains(s)) {
continue;
}
ConfigurationSection entry = section.getConfigurationSection(s);
if (!entry.contains("generator", true)) {
continue;
}
String generator = entry.getString("generator");
if (generator.startsWith("Iris:")) {
generator = generator.split("\\Q:\\E")[1];
} else if (generator.equalsIgnoreCase("Iris")) {
generator = IrisSettings.get().getGenerator().getDefaultWorldType();
} else {
continue;
}
Iris.info("2 World: %s | Generator: %s", s, generator);
if (Bukkit.getWorlds().stream().anyMatch(w -> w.getName().equals(s))) {
continue;
}
Iris.info(C.LIGHT_PURPLE + "Preparing Spawn for " + s + "' using Iris:" + generator + "...");
new WorldCreator(s)
.generator(getDefaultWorldGenerator(s, generator))
.environment(IrisData.loadAnyDimension(generator).getEnvironment())
.createWorld();
Iris.info(C.LIGHT_PURPLE + "Loaded " + s + "!");
}
} catch (Throwable e) {
e.printStackTrace();
}
}
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
Iris.debug("Default World Generator Called for " + worldName + " using ID: " + id);
if (worldName.equals("test")) {
try {
throw new RuntimeException();
} catch (Throwable e) {
Iris.info(e.getStackTrace()[1].getClassName());
if (e.getStackTrace()[1].getClassName().contains("com.onarandombox.MultiverseCore")) {
Iris.debug("MVC Test detected, Quick! Send them the dummy!");
return new DummyChunkGenerator();
}
}
}
IrisDimension dim;
if (id == null || id.isEmpty()) {
dim = IrisData.loadAnyDimension(IrisSettings.get().getGenerator().getDefaultWorldType());
} else {
dim = IrisData.loadAnyDimension(id);
}
Iris.debug("Generator ID: " + id + " requested by bukkit/plugin");
if (dim == null) {
Iris.warn("Unable to find dimension type " + id + " Looking for online packs...");
service(StudioSVC.class).downloadSearch(new VolmitSender(Bukkit.getConsoleSender()), id, true);
dim = IrisData.loadAnyDimension(id);
if (dim == null) {
throw new RuntimeException("Can't find dimension " + id + "!");
} else {
Iris.info("Resolved missing dimension, proceeding with generation.");
}
}
Iris.debug("Assuming IrisDimension: " + dim.getName());
IrisWorld w = IrisWorld.builder()
.name(worldName)
.seed(1337)
.environment(dim.getEnvironment())
.worldFolder(new File(Bukkit.getWorldContainer(), worldName))
.minHeight(dim.getMinHeight())
.maxHeight(dim.getMaxHeight())
.build();
Iris.debug("Generator Config: " + w.toString());
File ff = new File(w.worldFolder(), "iris/pack");
if (!ff.exists() || ff.listFiles().length == 0) {
ff.mkdirs();
service(StudioSVC.class).installIntoWorld(sender, dim.getLoadKey(), ff.getParentFile());
}
return new BukkitChunkGenerator(w, false, ff, dim.getLoadKey());
}
}

View File

@@ -24,6 +24,7 @@ import com.volmit.iris.core.pregenerator.IrisPregenerator;
import com.volmit.iris.core.pregenerator.PregenListener;
import com.volmit.iris.core.pregenerator.PregenTask;
import com.volmit.iris.core.pregenerator.PregeneratorMethod;
import com.volmit.iris.core.tools.IrisPackBenchmarking;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.Form;
@@ -44,6 +45,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Consumer;
import static com.volmit.iris.core.tools.IrisPackBenchmarking.benchmarkInProgress;
public class PregeneratorJob implements PregenListener {
private static final Color COLOR_EXISTS = parseColor("#4d7d5b");
private static final Color COLOR_BLACK = parseColor("#4d7d5b");
@@ -86,7 +89,7 @@ public class PregeneratorJob implements PregenListener {
max.setZ(Math.max((zz << 5) + 31, max.getZ()));
});
if (IrisSettings.get().getGui().isUseServerLaunchedGuis()) {
if (IrisSettings.get().getGui().isUseServerLaunchedGuis() && task.isGui()) {
open();
}

View File

@@ -1,8 +1,10 @@
package com.volmit.iris.core.link;
import com.volmit.iris.engine.framework.Engine;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
@@ -28,6 +30,7 @@ public abstract class ExternalDataProvider {
public abstract BlockData getBlockData(Identifier blockId) throws MissingResourceException;
public abstract ItemStack getItemStack(Identifier itemId) throws MissingResourceException;
public void processUpdate(Engine engine, Block block, Identifier blockId) {};
public abstract Identifier[] getBlockTypes();

View File

@@ -0,0 +1,135 @@
package com.volmit.iris.core.link;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.IrisBlockData;
import com.volmit.iris.util.reflect.WrappedField;
import com.volmit.iris.util.reflect.WrappedReturningMethod;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Leaves;
import org.bukkit.inventory.ItemStack;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.function.Supplier;
public class HMCLeavesDataProvider extends ExternalDataProvider {
private Object apiInstance;
private WrappedReturningMethod<Object, Material> worldBlockType;
private WrappedReturningMethod<Object, Boolean> setCustomBlock;
private Map<String, Object> blockDataMap = Map.of();
private Map<String, Supplier<ItemStack>> itemDataField = Map.of();
public HMCLeavesDataProvider() {
super("HMCLeaves");
}
@Override
public String getPluginId() {
return "HMCLeaves";
}
@Override
public void init() {
try {
worldBlockType = new WrappedReturningMethod<>((Class<Object>) Class.forName("io.github.fisher2911.hmcleaves.data.BlockData"), "worldBlockType");
apiInstance = getApiInstance(Class.forName("io.github.fisher2911.hmcleaves.api.HMCLeavesAPI"));
setCustomBlock = new WrappedReturningMethod<>((Class<Object>) apiInstance.getClass(), "setCustomBlock", Location.class, String.class, boolean.class);
Object config = getLeavesConfig(apiInstance.getClass());
blockDataMap = getMap(config, "blockDataMap");
itemDataField = getMap(config, "itemSupplierMap");
} catch (Throwable e) {
Iris.error("Failed to initialize HMCLeavesDataProvider: " + e.getMessage());
}
}
@Override
public BlockData getBlockData(Identifier blockId) throws MissingResourceException {
Object o = blockDataMap.get(blockId.key());
if (o == null)
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
Material material = worldBlockType.invoke(o, new Object[0]);
if (material == null)
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
BlockData blockData = Bukkit.createBlockData(material);
if (IrisSettings.get().getGenerator().preventLeafDecay && blockData instanceof Leaves leaves)
leaves.setPersistent(true);
return new IrisBlockData(blockData, blockId);
}
@Override
public ItemStack getItemStack(Identifier itemId) throws MissingResourceException {
if (!itemDataField.containsKey(itemId.key()))
throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key());
return itemDataField.get(itemId.key()).get();
}
@Override
public void processUpdate(Engine engine, Block block, Identifier blockId) {
Boolean result = setCustomBlock.invoke(apiInstance, new Object[]{block.getLocation(), blockId.key(), false});
if (result == null || !result)
Iris.warn("Failed to set custom block! " + blockId.key() + " " + block.getX() + " " + block.getY() + " " + block.getZ());
else if (IrisSettings.get().getGenerator().preventLeafDecay) {
BlockData blockData = block.getBlockData();
if (blockData instanceof Leaves leaves)
leaves.setPersistent(true);
}
}
@Override
public Identifier[] getBlockTypes() {
KList<Identifier> names = new KList<>();
for (String name : blockDataMap.keySet()) {
try {
Identifier key = new Identifier("hmcleaves", name);
if (getBlockData(key) != null)
names.add(key);
} catch (MissingResourceException ignored) {
}
}
return names.toArray(new Identifier[0]);
}
@Override
public Identifier[] getItemTypes() {
KList<Identifier> names = new KList<>();
for (String name : itemDataField.keySet()) {
try {
Identifier key = new Identifier("hmcleaves", name);
if (getItemStack(key) != null)
names.add(key);
} catch (MissingResourceException ignored) {
}
}
return names.toArray(new Identifier[0]);
}
@Override
public boolean isValidProvider(Identifier id, boolean isItem) {
return (isItem ? itemDataField.keySet() : blockDataMap.keySet()).contains(id.key());
}
private <C, T> Map<String, T> getMap(C config, String name) {
WrappedField<C, Map<String, T>> field = new WrappedField<>((Class<C>) config.getClass(), name);
return field.get(config);
}
private <A> A getApiInstance(Class<A> apiClass) {
WrappedReturningMethod<A, A> instance = new WrappedReturningMethod<>(apiClass, "getInstance");
return instance.invoke();
}
private <A, C> C getLeavesConfig(Class<A> apiClass) {
WrappedReturningMethod<A, A> instance = new WrappedReturningMethod<>(apiClass, "getInstance");
WrappedField<A, C> config = new WrappedField<>(apiClass, "config");
return config.get(instance.invoke());
}
}

View File

@@ -0,0 +1,106 @@
package com.volmit.iris.core.link;
import com.volmit.iris.Iris;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.scheduling.J;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.block.CustomBlock;
import org.bukkit.Bukkit;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack;
import java.util.MissingResourceException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
public class MMOItemsDataProvider extends ExternalDataProvider {
public MMOItemsDataProvider() {
super("MMOItems");
}
@Override
public void init() {
Iris.info("Setting up MMOItems Link...");
}
@Override
public BlockData getBlockData(Identifier blockId) throws MissingResourceException {
int id = -1;
try {
id = Integer.parseInt(blockId.key());
} catch (NumberFormatException ignored) {}
CustomBlock block = api().getCustomBlocks().getBlock(id);
if (block == null) throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
return block.getState().getBlockData();
}
@Override
public ItemStack getItemStack(Identifier itemId) throws MissingResourceException {
String[] parts = itemId.namespace().split("_", 2);
if (parts.length != 2)
throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key());
CompletableFuture<ItemStack> future = new CompletableFuture<>();
Runnable run = () -> future.complete(api().getItem(parts[1], itemId.key()));
if (Bukkit.isPrimaryThread()) run.run();
else J.s(run);
ItemStack item = null;
try {
item = future.get();
} catch (InterruptedException | ExecutionException ignored) {}
if (item == null)
throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key());
return item;
}
@Override
public Identifier[] getBlockTypes() {
KList<Identifier> names = new KList<>();
for (Integer id : api().getCustomBlocks().getBlockIds()) {
try {
Identifier key = new Identifier("mmoitems", String.valueOf(id));
if (getBlockData(key) != null)
names.add(key);
} catch (MissingResourceException ignored) {
}
}
return names.toArray(new Identifier[0]);
}
@Override
public Identifier[] getItemTypes() {
KList<Identifier> names = new KList<>();
Runnable run = () -> {
for (Type type : api().getTypes().getAll()) {
for (String name : api().getTemplates().getTemplateNames(type)) {
try {
Identifier key = new Identifier("mmoitems_" + type.getId(), name);
if (getItemStack(key) != null)
names.add(key);
} catch (MissingResourceException ignored) {
}
}
}
};
if (Bukkit.isPrimaryThread()) run.run();
else {
try {
J.sfut(run).get();
} catch (InterruptedException | ExecutionException e) {
Iris.error("Failed getting MMOItems item types!");
Iris.reportError(e);
}
}
return names.toArray(new Identifier[0]);
}
@Override
public boolean isValidProvider(Identifier id, boolean isItem) {
return isItem ? id.namespace().split("_", 2).length == 2 : id.namespace().equals("mmoitems");
}
private MMOItems api() {
return MMOItems.plugin;
}
}

View File

@@ -19,18 +19,25 @@
package com.volmit.iris.core.link;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.B;
import com.volmit.iris.util.data.IrisBlockData;
import com.volmit.iris.util.reflect.WrappedField;
import io.th0rgal.oraxen.api.OraxenItems;
import io.th0rgal.oraxen.items.ItemBuilder;
import io.th0rgal.oraxen.mechanics.Mechanic;
import io.th0rgal.oraxen.mechanics.MechanicFactory;
import io.th0rgal.oraxen.mechanics.MechanicsManager;
import io.th0rgal.oraxen.mechanics.provided.gameplay.block.BlockMechanic;
import io.th0rgal.oraxen.mechanics.provided.gameplay.block.BlockMechanicFactory;
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureFactory;
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic;
import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanicFactory;
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanicFactory;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.MultipleFacing;
import org.bukkit.inventory.ItemStack;
@@ -69,6 +76,8 @@ public class OraxenDataProvider extends ExternalDataProvider {
return newBlockData;
} else if (factory instanceof StringBlockMechanicFactory f) {
return f.createTripwireData(blockId.key());
} else if (factory instanceof FurnitureFactory) {
return new IrisBlockData(B.getAir(), blockId);
} else
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
}
@@ -79,6 +88,14 @@ public class OraxenDataProvider extends ExternalDataProvider {
return opt.orElseThrow(() -> new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key())).build();
}
@Override
public void processUpdate(Engine engine, Block block, Identifier blockId) {
Mechanic mechanic = getFactory(blockId).getMechanic(blockId.key());
if (mechanic instanceof FurnitureMechanic f) {
f.place(block.getLocation());
}
}
@Override
public Identifier[] getBlockTypes() {
KList<Identifier> names = new KList<>();

View File

@@ -1,11 +1,17 @@
package com.volmit.iris.core.link;
import com.volmit.iris.util.data.Cuboid;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
public class WorldEditLink {
private static Boolean enabled = null;
public static Cuboid getSelection(Player p) {
if (!hasWorldEdit())
return null;
try {
Object instance = Class.forName("com.sk89q.worldedit.WorldEdit").getDeclaredMethod("getInstance").invoke(null);
Object sessionManager = instance.getClass().getDeclaredMethod("getSessionManager").invoke(instance);
@@ -28,4 +34,10 @@ public class WorldEditLink {
}
return null;
}
public static boolean hasWorldEdit() {
if (enabled == null)
enabled = Bukkit.getPluginManager().isPluginEnabled("WorldEdit");
return enabled;
}
}

View File

@@ -40,6 +40,8 @@ import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.io.*;
import java.util.Locale;
@@ -52,6 +54,8 @@ import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@Data
@EqualsAndHashCode(exclude = "manager")
@ToString(exclude = "manager")
public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
public static final AtomicDouble tlt = new AtomicDouble(0);
private static final int CACHE_SIZE = 100000;

View File

@@ -19,8 +19,11 @@
package com.volmit.iris.core.nms;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IrisEntity;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.math.Vector3d;
import com.volmit.iris.util.nbt.mca.palette.MCABiomeContainer;
import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess;
import com.volmit.iris.util.nbt.tag.CompoundTag;
@@ -31,6 +34,9 @@ import org.bukkit.WorldCreator;
import org.bukkit.block.Biome;
import org.bukkit.entity.Dolphin;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemStack;
@@ -71,6 +77,8 @@ public interface INMSBinding {
Object getBiomeBase(Object registry, Biome biome);
KList<Biome> getBiomes();
boolean isBukkit();
int getBiomeId(Biome biome);
@@ -100,4 +108,8 @@ public interface INMSBinding {
void setTreasurePos(Dolphin dolphin, com.volmit.iris.core.nms.container.BlockPos pos);
void inject(long seed, Engine engine, World world) throws NoSuchFieldException, IllegalAccessException;
Vector3d getBoundingbox(org.bukkit.entity.EntityType entity);
Entity spawnEntity(Location location, EntityType type, CreatureSpawnEvent.SpawnReason reason);
}

View File

@@ -22,8 +22,10 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMSBinding;
import com.volmit.iris.core.nms.container.BlockPos;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.math.Vector3d;
import com.volmit.iris.util.nbt.mca.palette.MCABiomeContainer;
import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess;
import com.volmit.iris.util.nbt.tag.CompoundTag;
@@ -33,6 +35,8 @@ import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.entity.Dolphin;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemStack;
@@ -84,6 +88,15 @@ public class NMSBinding1X implements INMSBinding {
}
public Vector3d getBoundingbox() {
return null;
}
@Override
public Entity spawnEntity(Location location, EntityType type, CreatureSpawnEvent.SpawnReason reason) {
return location.getWorld().spawnEntity(location, type);
}
@Override
public void deserializeTile(CompoundTag s, Location newPosition) {
@@ -163,6 +176,11 @@ public class NMSBinding1X implements INMSBinding {
return null;
}
@Override
public KList<Biome> getBiomes() {
return new KList<>(Biome.values()).qdel(Biome.CUSTOM);
}
@Override
public boolean isBukkit() {
return true;
@@ -197,6 +215,11 @@ public class NMSBinding1X implements INMSBinding {
}
@Override
public Vector3d getBoundingbox(org.bukkit.entity.EntityType entity) {
return null;
}
@Override
public MCAPaletteAccess createPalette() {
Iris.error("Cannot use the global data palette! Iris is incapable of using MCA generation on this version of minecraft!");

View File

@@ -0,0 +1,275 @@
package com.volmit.iris.core.pregenerator;
import com.google.gson.Gson;
import com.volmit.iris.Iris;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.math.RollingSequence;
import com.volmit.iris.util.math.Spiraler;
import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
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 org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantLock;
public class DeepSearchPregenerator extends Thread implements Listener {
@Getter
private static DeepSearchPregenerator instance;
private final DeepSearchJob job;
private final File destination;
private final int maxPosition;
private World world;
private final ChronoLatch latch;
private static AtomicInteger foundChunks;
private final AtomicInteger foundLast;
private final AtomicInteger foundTotalChunks;
private final AtomicLong startTime;
private final RollingSequence chunksPerSecond;
private final RollingSequence chunksPerMinute;
private final AtomicInteger chunkCachePos;
private final AtomicInteger chunkCacheSize;
private int pos;
private final AtomicInteger foundCacheLast;
private final AtomicInteger foundCache;
private LinkedHashMap<Integer, Position2> chunkCache;
private KList<Position2> chunkQueue;
private final ReentrantLock cacheLock;
private static final Map<String, DeepSearchJob> jobs = new HashMap<>();
public DeepSearchPregenerator(DeepSearchJob job, File destination) {
this.job = job;
this.chunkCacheSize = new AtomicInteger(); // todo
this.chunkCachePos = new AtomicInteger(1000);
this.foundCacheLast = new AtomicInteger();
this.foundCache = new AtomicInteger();
this.cacheLock = new ReentrantLock();
this.destination = destination;
this.chunkCache = new LinkedHashMap<>();
this.maxPosition = new Spiraler(job.getRadiusBlocks() * 2, job.getRadiusBlocks() * 2, (x, z) -> {
}).count();
this.world = Bukkit.getWorld(job.getWorld().getUID());
this.chunkQueue = new KList<>();
this.latch = new ChronoLatch(3000);
this.startTime = new AtomicLong(M.ms());
this.chunksPerSecond = new RollingSequence(10);
this.chunksPerMinute = new RollingSequence(10);
foundChunks = new AtomicInteger(0);
this.foundLast = new AtomicInteger(0);
this.foundTotalChunks = new AtomicInteger((int) Math.ceil(Math.pow((2.0 * job.getRadiusBlocks()) / 16, 2)));
this.pos = 0;
jobs.put(job.getWorld().getName(), job);
DeepSearchPregenerator.instance = this;
}
@EventHandler
public void on(WorldUnloadEvent e) {
if (e.getWorld().equals(world)) {
interrupt();
}
}
public void run() {
while (!interrupted()) {
tick();
}
try {
saveNow();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void tick() {
DeepSearchJob job = jobs.get(world.getName());
// chunkCache(); //todo finish this
if (latch.flip() && !job.paused) {
if (cacheLock.isLocked()) {
Iris.info("DeepFinder: Caching: " + chunkCachePos.get() + " Of " + chunkCacheSize.get());
} else {
long eta = computeETA();
save();
int secondGenerated = foundChunks.get() - foundLast.get();
foundLast.set(foundChunks.get());
secondGenerated = secondGenerated / 3;
chunksPerSecond.put(secondGenerated);
chunksPerMinute.put(secondGenerated * 60);
Iris.info("DeepFinder: " + C.IRIS + world.getName() + C.RESET + " Searching: " + Form.f(foundChunks.get()) + " of " + Form.f(foundTotalChunks.get()) + " " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration((double) eta, 2));
}
}
if (foundChunks.get() >= foundTotalChunks.get()) {
Iris.info("Completed DeepSearch!");
interrupt();
}
}
private long computeETA() {
return (long) ((foundTotalChunks.get() - foundChunks.get()) / chunksPerSecond.getAverage()) * 1000;
// todo broken
}
private final ExecutorService executorService = Executors.newSingleThreadExecutor();
private void queueSystem(Position2 chunk) {
if (chunkQueue.isEmpty()) {
for (int limit = 512; limit != 0; limit--) {
pos = job.getPosition() + 1;
chunkQueue.add(getChunk(pos));
}
} else {
//MCAUtil.read();
}
}
private void findInChunk(World world, int x, int z) throws IOException {
int xx = x * 16;
int zz = z * 16;
Engine engine = IrisToolbelt.access(world).getEngine();
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
int height = engine.getHeight(xx + i, zz + j);
if (height > 300) {
File found = new File("plugins" + "iris" + "found.txt");
FileWriter writer = new FileWriter(found);
if (!found.exists()) {
found.createNewFile();
}
IrisBiome biome = engine.getBiome(xx, engine.getHeight(), zz);
Iris.info("Found at! " + xx + ", " + zz + "Biome ID: " + biome.getName() + ", ");
writer.write("Biome at: X: " + xx + " Z: " + zz + "Biome ID: " + biome.getName() + ", ");
return;
}
}
}
}
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 static void setPausedDeep(World world) {
DeepSearchJob job = jobs.get(world.getName());
if (isPausedDeep(world)){
job.paused = false;
} else {
job.paused = true;
}
if ( job.paused) {
Iris.info(C.BLUE + "DeepSearch: " + C.IRIS + world.getName() + C.BLUE + " Paused");
} else {
Iris.info(C.BLUE + "DeepSearch: " + C.IRIS + world.getName() + C.BLUE + " Resumed");
}
}
public static boolean isPausedDeep(World world) {
DeepSearchJob job = jobs.get(world.getName());
return job != null && job.isPaused();
}
public void shutdownInstance(World world) throws IOException {
Iris.info("DeepSearch: " + C.IRIS + world.getName() + C.BLUE + " Shutting down..");
DeepSearchJob job = jobs.get(world.getName());
File worldDirectory = new File(Bukkit.getWorldContainer(), world.getName());
File deepFile = new File(worldDirectory, "DeepSearch.json");
if (job == null) {
Iris.error("No DeepSearch job found for world: " + world.getName());
return;
}
try {
if (!job.isPaused()) {
job.setPaused(true);
}
save();
jobs.remove(world.getName());
new BukkitRunnable() {
@Override
public void run() {
while (deepFile.exists()){
deepFile.delete();
J.sleep(1000);
}
Iris.info("DeepSearch: " + C.IRIS + world.getName() + C.BLUE + " File deleted and instance closed.");
}
}.runTaskLater(Iris.instance, 20L);
} catch (Exception e) {
Iris.error("Failed to shutdown DeepSearch for " + world.getName());
e.printStackTrace();
} finally {
saveNow();
interrupt();
}
}
public void saveNow() throws IOException {
IO.writeAll(this.destination, new Gson().toJson(job));
}
@Data
@Builder
public static class DeepSearchJob {
private World world;
@Builder.Default
private int radiusBlocks = 5000;
@Builder.Default
private int position = 0;
@Builder.Default
boolean paused = false;
}
}

View File

@@ -19,7 +19,9 @@
package com.volmit.iris.core.pregenerator;
import com.volmit.iris.Iris;
import com.volmit.iris.core.pack.IrisPack;
import com.volmit.iris.core.tools.IrisPackBenchmarking;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
@@ -30,15 +32,12 @@ import com.volmit.iris.util.math.RollingSequence;
import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.Looper;
import lombok.Getter;
import lombok.Setter;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import static com.volmit.iris.core.tools.IrisPackBenchmarking.benchmark;
public class IrisPregenerator {
private final PregenTask task;
@@ -50,6 +49,7 @@ public class IrisPregenerator {
private final RollingSequence chunksPerSecond;
private final RollingSequence chunksPerMinute;
private final RollingSequence regionsPerMinute;
private final KList<Integer> chunksPerSecondHistory;
private static AtomicInteger generated;
private final AtomicInteger generatedLast;
private final AtomicInteger generatedLastMinute;
@@ -62,8 +62,6 @@ public class IrisPregenerator {
private final KSet<Position2> net;
private final ChronoLatch cl;
private final ChronoLatch saveLatch = new ChronoLatch(30000);
static long long_generatedChunks = 0;
static long long_totalChunks = 0;
public IrisPregenerator(PregenTask task, PregeneratorMethod generator, PregenListener listener) {
this.listener = listenify(listener);
@@ -80,6 +78,7 @@ public class IrisPregenerator {
chunksPerSecond = new RollingSequence(10);
chunksPerMinute = new RollingSequence(10);
regionsPerMinute = new RollingSequence(10);
chunksPerSecondHistory = new KList<>();
generated = new AtomicInteger(0);
generatedLast = new AtomicInteger(0);
generatedLastMinute = new AtomicInteger(0);
@@ -93,6 +92,7 @@ public class IrisPregenerator {
int secondGenerated = generated.get() - generatedLast.get();
generatedLast.set(generated.get());
chunksPerSecond.put(secondGenerated);
chunksPerSecondHistory.add(secondGenerated);
if (minuteLatch.flip()) {
int minuteGenerated = generated.get() - generatedLastMinute.get();
@@ -100,8 +100,6 @@ public class IrisPregenerator {
chunksPerMinute.put(minuteGenerated);
regionsPerMinute.put((double) minuteGenerated / 1024D);
}
long_generatedChunks = generated.get();
long_totalChunks = totalChunks.get();
listener.onTick(chunksPerSecond.getAverage(), chunksPerMinute.getAverage(),
regionsPerMinute.getAverage(),
@@ -112,10 +110,10 @@ public class IrisPregenerator {
if (cl.flip()) {
double percentage = ((double) generated.get() / (double) totalChunks.get()) * 100;
if(benchmark) {
Iris.info(C.GREEN +"Benchmark: " + C.WHITE + Form.f(generated.get()) + " of " + Form.f(totalChunks.get()) + " (%.0f%%) " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration((double) eta, 2), percentage);
if (!IrisPackBenchmarking.benchmarkInProgress) {
Iris.info("Pregen: " + Form.f(generated.get()) + " of " + Form.f(totalChunks.get()) + " (%.0f%%) " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration(eta, 2), percentage);
} else {
Iris.info("Pregen: " + Form.f(generated.get()) + " of " + Form.f(totalChunks.get()) + " (%.0f%%) " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration((double) eta, 2), percentage);
Iris.info("Benchmarking: " + Form.f(generated.get()) + " of " + Form.f(totalChunks.get()) + " (%.0f%%) " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration(eta, 2), percentage);
}
}
return 1000;
@@ -128,17 +126,10 @@ public class IrisPregenerator {
// If yes, use smooth function (which gets more accurate over time since its less sensitive to outliers)
((totalChunks.get() - generated.get()) * ((double) (M.ms() - startTime.get()) / (double) generated.get())) :
// If no, use quick function (which is less accurate over time but responds better to the initial delay)
((totalChunks.get() - generated.get()) / chunksPerSecond.getAverage()) * 1000 //
((totalChunks.get() - generated.get()) / chunksPerSecond.getAverage()) * 1000
);
}
public static long getLongGeneratedChunks() {
return long_generatedChunks;
}
public static long getLongTotalChunks() {
return long_totalChunks;
}
public void close() {
shutdown.set(true);
@@ -151,6 +142,11 @@ public class IrisPregenerator {
task.iterateRegions((x, z) -> visitRegion(x, z, true));
task.iterateRegions((x, z) -> visitRegion(x, z, false));
shutdown();
if (!IrisPackBenchmarking.benchmarkInProgress) {
Iris.info(C.IRIS + "Pregen stopped.");
} else {
IrisPackBenchmarking.instance.finishedBenchmark(chunksPerSecondHistory);
}
}
private void checkRegions() {
@@ -167,7 +163,10 @@ public class IrisPregenerator {
generator.close();
ticker.interrupt();
listener.onClose();
getMantle().trim(0);
Mantle mantle = getMantle();
if (mantle != null) {
mantle.trim(0, 0);
}
}
private void visitRegion(int x, int z, boolean regions) {

View File

@@ -14,22 +14,32 @@ import com.volmit.iris.util.scheduling.J;
import io.papermc.lib.PaperLib;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
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 org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.HashMap;
import java.util.Map;
public class LazyPregenerator extends Thread implements Listener {
@Getter
private static LazyPregenerator instance;
private final LazyPregenJob job;
private final File destination;
private final int maxPosition;
private final World world;
private World world;
private final long rate;
private final ChronoLatch latch;
private static AtomicInteger lazyGeneratedChunks;
@@ -37,6 +47,9 @@ public class LazyPregenerator extends Thread implements Listener {
private final AtomicInteger lazyTotalChunks;
private final AtomicLong startTime;
private final RollingSequence chunksPerSecond;
private final RollingSequence chunksPerMinute;
private static final Map<String, LazyPregenJob> jobs = new HashMap<>();
public LazyPregenerator(LazyPregenJob job, File destination) {
this.job = job;
@@ -44,16 +57,16 @@ public class LazyPregenerator extends Thread implements Listener {
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(6000);
startTime = new AtomicLong(M.ms());
chunksPerSecond = new RollingSequence(10);
this.rate = Math.round((1D / (job.getChunksPerMinute() / 60D)) * 1000D);
this.latch = new ChronoLatch(15000);
this.startTime = new AtomicLong(M.ms());
this.chunksPerSecond = new RollingSequence(10);
this.chunksPerMinute = new RollingSequence(10);
lazyGeneratedChunks = new AtomicInteger(0);
generatedLast = new AtomicInteger(0);
lazyTotalChunks = new AtomicInteger();
int radius = job.getRadiusBlocks();
lazyTotalChunks.set((int) Math.ceil(Math.pow((2.0 * radius) / 16, 2)));
this.generatedLast = new AtomicInteger(0);
this.lazyTotalChunks = new AtomicInteger((int) Math.ceil(Math.pow((2.0 * job.getRadiusBlocks()) / 16, 2)));
jobs.put(job.getWorld(), job);
LazyPregenerator.instance = this;
}
public LazyPregenerator(File file) throws IOException {
@@ -63,7 +76,6 @@ public class LazyPregenerator extends Thread implements Listener {
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);
@@ -97,18 +109,18 @@ public class LazyPregenerator extends Thread implements Listener {
}
public void tick() {
if (latch.flip()) {
LazyPregenJob job = jobs.get(world.getName());
if (latch.flip() && !job.paused) {
long eta = computeETA();
save();
int secondGenerated = lazyGeneratedChunks.get() - generatedLast.get();
generatedLast.set(lazyGeneratedChunks.get());
secondGenerated = secondGenerated / 6;
secondGenerated = secondGenerated / 15;
chunksPerSecond.put(secondGenerated);
Iris.info("LazyGen: " + C.IRIS + world.getName() + C.RESET + " RTT: " + Form.f(lazyGeneratedChunks.get()) + " of " + Form.f(lazyTotalChunks.get()) + " " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration((double) eta, 2));
//Iris.info("Debug: " + maxPosition);
//Iris.info("Debug1: " + job.getPosition());
// todo: Maxpos borked
chunksPerMinute.put(secondGenerated * 60);
if (!job.isSilent()) {
Iris.info("LazyGen: " + C.IRIS + world.getName() + C.RESET + " RTT: " + Form.f(lazyGeneratedChunks.get()) + " of " + Form.f(lazyTotalChunks.get()) + " " + Form.f((int) chunksPerMinute.getAverage()) + "/m ETA: " + Form.duration((double) eta, 2));
}
}
if (lazyGeneratedChunks.get() >= lazyTotalChunks.get()) {
@@ -123,27 +135,40 @@ public class LazyPregenerator extends Thread implements Listener {
} else {
int pos = job.getPosition() + 1;
job.setPosition(pos);
tickGenerate(getChunk(pos));
if (!job.paused) {
tickGenerate(getChunk(pos));
}
}
}
private long computeETA() {
return (long) (lazyTotalChunks.get() > 1024 ? // Generated chunks exceed 1/8th of total?
// If yes, use smooth function (which gets more accurate over time since its less sensitive to outliers)
((lazyTotalChunks.get() - lazyGeneratedChunks.get()) * ((double) (M.ms() - startTime.get()) / (double) lazyGeneratedChunks.get())) :
// If no, use quick function (which is less accurate over time but responds better to the initial delay)
((lazyTotalChunks.get() - lazyGeneratedChunks.get()) / chunksPerSecond.getAverage()) * 1000 //
);
return (long) ((lazyTotalChunks.get() - lazyGeneratedChunks.get()) / chunksPerMinute.getAverage()) * 1000;
// todo broken
}
private final ExecutorService executorService = Executors.newSingleThreadExecutor();
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);
}
lazyGeneratedChunks.addAndGet(1);
executorService.submit(() -> {
CountDownLatch latch = new CountDownLatch(1);
if (PaperLib.isPaper()) {
PaperLib.getChunkAtAsync(world, chunk.getX(), chunk.getZ(), true)
.thenAccept((i) -> {
Iris.verbose("Generated Async " + chunk);
latch.countDown();
});
} else {
J.s(() -> {
world.getChunkAt(chunk.getX(), chunk.getZ());
Iris.verbose("Generated " + chunk);
latch.countDown();
});
}
try {
latch.await();
} catch (InterruptedException ignored) {}
lazyGeneratedChunks.addAndGet(1);
});
}
private void tickRegenerate(Position2 chunk) {
@@ -177,6 +202,63 @@ public class LazyPregenerator extends Thread implements Listener {
});
}
public static void setPausedLazy(World world) {
LazyPregenJob job = jobs.get(world.getName());
if (isPausedLazy(world)){
job.paused = false;
} else {
job.paused = true;
}
if ( job.paused) {
Iris.info(C.BLUE + "LazyGen: " + C.IRIS + world.getName() + C.BLUE + " Paused");
} else {
Iris.info(C.BLUE + "LazyGen: " + C.IRIS + world.getName() + C.BLUE + " Resumed");
}
}
public static boolean isPausedLazy(World world) {
LazyPregenJob job = jobs.get(world.getName());
return job != null && job.isPaused();
}
public void shutdownInstance(World world) throws IOException {
Iris.info("LazyGen: " + C.IRIS + world.getName() + C.BLUE + " Shutting down..");
LazyPregenJob job = jobs.get(world.getName());
File worldDirectory = new File(Bukkit.getWorldContainer(), world.getName());
File lazyFile = new File(worldDirectory, "lazygen.json");
if (job == null) {
Iris.error("No Lazygen job found for world: " + world.getName());
return;
}
try {
if (!job.isPaused()) {
job.setPaused(true);
}
save();
jobs.remove(world.getName());
new BukkitRunnable() {
@Override
public void run() {
while (lazyFile.exists()){
lazyFile.delete();
J.sleep(1000);
}
Iris.info("LazyGen: " + C.IRIS + world.getName() + C.BLUE + " File deleted and instance closed.");
}
}.runTaskLater(Iris.instance, 20L);
} catch (Exception e) {
Iris.error("Failed to shutdown Lazygen for " + world.getName());
e.printStackTrace();
} finally {
saveNow();
interrupt();
}
}
public void saveNow() throws IOException {
IO.writeAll(this.destination, new Gson().toJson(job));
}
@@ -190,10 +272,15 @@ public class LazyPregenerator extends Thread implements Listener {
@Builder.Default
private boolean healing = false;
@Builder.Default
private int chunksPerMinute = 32; // 48 hours is roughly 5000 radius
private int chunksPerMinute = 32;
@Builder.Default
private int radiusBlocks = 5000;
@Builder.Default
private int position = 0;
@Builder.Default
boolean silent = false;
@Builder.Default
boolean paused = false;
}
}

View File

@@ -35,6 +35,8 @@ public class PregenTask {
private static final KList<Position2> ORDER_CENTER = computeChunkOrder();
private static final KMap<Position2, KList<Position2>> ORDERS = new KMap<>();
@Builder.Default
private boolean gui = false;
@Builder.Default
private Position2 center = new Position2(0, 0);
@Builder.Default

View File

@@ -0,0 +1,342 @@
package com.volmit.iris.core.pregenerator;
import com.google.gson.Gson;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.math.RollingSequence;
import com.volmit.iris.util.math.Spiraler;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.HyperLock;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import io.papermc.lib.PaperLib;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import org.apache.logging.log4j.core.util.ExecutorServices;
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 org.bukkit.scheduler.BukkitRunnable;
import org.checkerframework.checker.units.qual.N;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.IntStream;
public class TurboPregenerator extends Thread implements Listener {
@Getter
private static TurboPregenerator instance;
private final TurboPregenJob job;
private final File destination;
private final int maxPosition;
private World world;
private final ChronoLatch latch;
private static AtomicInteger turboGeneratedChunks;
private final AtomicInteger generatedLast;
private final AtomicLong cachedLast;
private final RollingSequence cachePerSecond;
private final AtomicInteger turboTotalChunks;
private final AtomicLong startTime;
private final RollingSequence chunksPerSecond;
private final RollingSequence chunksPerMinute;
private KList<Position2> queue;
private ConcurrentHashMap<Integer, Position2> cache;
private AtomicInteger maxWaiting;
private ReentrantLock cachinglock;
private AtomicBoolean caching;
private final HyperLock hyperLock;
private MultiBurst burst;
private static final Map<String, TurboPregenJob> jobs = new HashMap<>();
public TurboPregenerator(TurboPregenJob job, File destination) {
this.job = job;
queue = new KList<>(512);
this.maxWaiting = new AtomicInteger(128);
this.destination = destination;
this.maxPosition = new Spiraler(job.getRadiusBlocks() * 2, job.getRadiusBlocks() * 2, (x, z) -> {
}).count();
this.world = Bukkit.getWorld(job.getWorld());
this.latch = new ChronoLatch(3000);
this.burst = MultiBurst.burst;
this.hyperLock = new HyperLock();
this.startTime = new AtomicLong(M.ms());
this.cachePerSecond = new RollingSequence(10);
this.chunksPerSecond = new RollingSequence(10);
this.chunksPerMinute = new RollingSequence(10);
turboGeneratedChunks = new AtomicInteger(0);
this.generatedLast = new AtomicInteger(0);
this.cachedLast = new AtomicLong(0);
this.caching = new AtomicBoolean(false);
this.turboTotalChunks = new AtomicInteger((int) Math.ceil(Math.pow((2.0 * job.getRadiusBlocks()) / 16, 2)));
cache = new ConcurrentHashMap<>(turboTotalChunks.get());
this.cachinglock = new ReentrantLock();
jobs.put(job.getWorld(), job);
TurboPregenerator.instance = this;
}
public TurboPregenerator(File file) throws IOException {
this(new Gson().fromJson(IO.readAll(file), TurboPregenerator.TurboPregenJob.class), file);
}
public static void loadTurboGenerator(String i) {
World x = Bukkit.getWorld(i);
File turbogen = new File(x.getWorldFolder(), "turbogen.json");
if (turbogen.exists()) {
try {
TurboPregenerator p = new TurboPregenerator(turbogen);
p.start();
Iris.info("Started Turbo 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()) {
tick();
}
try {
saveNow();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void tick() {
TurboPregenJob job = jobs.get(world.getName());
if (!cachinglock.isLocked() && cache.isEmpty() && !caching.get()) {
ExecutorService cache = Executors.newFixedThreadPool(1);
cache.submit(this::cache);
}
if (latch.flip() && caching.get()) {
long secondCached = cache.mappingCount() - cachedLast.get();
cachedLast.set(cache.mappingCount());
secondCached = secondCached / 3;
cachePerSecond.put(secondCached);
Iris.info("TurboGen: " + C.IRIS + world.getName() + C.RESET + C.BLUE + " Caching: " + Form.f(cache.mappingCount()) + " of " + Form.f(turboTotalChunks.get()) + " " + Form.f((int) cachePerSecond.getAverage()) + "/s");
}
if (latch.flip() && !job.paused && !cachinglock.isLocked()) {
long eta = computeETA();
save();
int secondGenerated = turboGeneratedChunks.get() - generatedLast.get();
generatedLast.set(turboGeneratedChunks.get());
secondGenerated = secondGenerated / 3;
chunksPerSecond.put(secondGenerated);
chunksPerMinute.put(secondGenerated * 60);
Iris.info("TurboGen: " + C.IRIS + world.getName() + C.RESET + " RTT: " + Form.f(turboGeneratedChunks.get()) + " of " + Form.f(turboTotalChunks.get()) + " " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration((double) eta, 2));
}
if (turboGeneratedChunks.get() >= turboTotalChunks.get()) {
Iris.info("Completed Turbo Gen!");
interrupt();
} else {
if (!cachinglock.isLocked()) {
int pos = job.getPosition() + 1;
job.setPosition(pos);
if (!job.paused) {
if (queue.size() < maxWaiting.get()) {
Position2 chunk = cache.get(pos);
queue.add(chunk);
}
waitForChunksPartial();
}
}
}
}
private void cache() {
if (!cachinglock.isLocked()) {
cachinglock.lock();
caching.set(true);
PrecisionStopwatch p = PrecisionStopwatch.start();
BurstExecutor b = MultiBurst.burst.burst(turboTotalChunks.get());
b.setMulticore(true);
int[] list = IntStream.rangeClosed(0, turboTotalChunks.get()).toArray();
AtomicInteger order = new AtomicInteger(turboTotalChunks.get());
int threads = Runtime.getRuntime().availableProcessors();
if (threads > 1) threads--;
ExecutorService process = Executors.newFixedThreadPool(threads);
for (int id : list) {
b.queue(() -> {
cache.put(id, getChunk(id));
order.addAndGet(-1);
});
}
b.complete();
if (order.get() < 0) {
cachinglock.unlock();
caching.set(false);
Iris.info("Completed Caching in: " + Form.duration(p.getMilliseconds(), 2));
}
} else {
Iris.error("TurboCache is locked!");
}
}
private void waitForChunksPartial() {
while (!queue.isEmpty() && maxWaiting.get() > queue.size()) {
try {
for (Position2 c : new KList<>(queue)) {
tickGenerate(c);
queue.remove(c);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
private long computeETA() {
return (long) ((turboTotalChunks.get() - turboGeneratedChunks.get()) / chunksPerMinute.getAverage()) * 1000;
// todo broken
}
private final ExecutorService executorService = Executors.newFixedThreadPool(10);
private void tickGenerate(Position2 chunk) {
executorService.submit(() -> {
CountDownLatch latch = new CountDownLatch(1);
PaperLib.getChunkAtAsync(world, chunk.getX(), chunk.getZ(), true)
.thenAccept((i) -> {
latch.countDown();
});
try {
latch.await();
} catch (InterruptedException ignored) {
}
turboGeneratedChunks.addAndGet(1);
});
}
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 static void setPausedTurbo(World world) {
TurboPregenJob job = jobs.get(world.getName());
if (isPausedTurbo(world)) {
job.paused = false;
} else {
job.paused = true;
}
if (job.paused) {
Iris.info(C.BLUE + "TurboGen: " + C.IRIS + world.getName() + C.BLUE + " Paused");
} else {
Iris.info(C.BLUE + "TurboGen: " + C.IRIS + world.getName() + C.BLUE + " Resumed");
}
}
public static boolean isPausedTurbo(World world) {
TurboPregenJob job = jobs.get(world.getName());
return job != null && job.isPaused();
}
public void shutdownInstance(World world) throws IOException {
Iris.info("turboGen: " + C.IRIS + world.getName() + C.BLUE + " Shutting down..");
TurboPregenJob job = jobs.get(world.getName());
File worldDirectory = new File(Bukkit.getWorldContainer(), world.getName());
File turboFile = new File(worldDirectory, "turbogen.json");
if (job == null) {
Iris.error("No turbogen job found for world: " + world.getName());
return;
}
try {
if (!job.isPaused()) {
job.setPaused(true);
}
save();
jobs.remove(world.getName());
new BukkitRunnable() {
@Override
public void run() {
while (turboFile.exists()) {
turboFile.delete();
J.sleep(1000);
}
Iris.info("turboGen: " + C.IRIS + world.getName() + C.BLUE + " File deleted and instance closed.");
}
}.runTaskLater(Iris.instance, 20L);
} catch (Exception e) {
Iris.error("Failed to shutdown turbogen for " + world.getName());
e.printStackTrace();
} finally {
saveNow();
interrupt();
}
}
public void saveNow() throws IOException {
IO.writeAll(this.destination, new Gson().toJson(job));
}
@Data
@Builder
public static class TurboPregenJob {
private String world;
@Builder.Default
private int radiusBlocks = 5000;
@Builder.Default
private int position = 0;
@Builder.Default
boolean paused = false;
}
}

View File

@@ -23,20 +23,28 @@ import com.volmit.iris.core.pregenerator.PregenListener;
import com.volmit.iris.core.pregenerator.PregeneratorMethod;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.scheduling.J;
import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.Future;
public class AsyncPregenMethod implements PregeneratorMethod {
private final World world;
private final MultiBurst burst;
private final KList<Future<?>> future;
private final Map<Chunk, Long> lastUse;
public AsyncPregenMethod(World world, int threads) {
if (!PaperLib.isPaper()) {
@@ -46,6 +54,7 @@ public class AsyncPregenMethod implements PregeneratorMethod {
this.world = world;
burst = MultiBurst.burst;
future = new KList<>(1024);
this.lastUse = new KMap<>();
}
private void unloadAndSaveAllChunks() {
@@ -56,8 +65,12 @@ public class AsyncPregenMethod implements PregeneratorMethod {
return;
}
for (Chunk i : world.getLoadedChunks()) {
i.unload(true);
for (Chunk i : new ArrayList<>(lastUse.keySet())) {
Long lastUseTime = lastUse.get(i);
if (lastUseTime != null && M.ms() - lastUseTime >= 10000) {
i.unload();
lastUse.remove(i);
}
}
world.save();
}).get();
@@ -72,7 +85,8 @@ public class AsyncPregenMethod implements PregeneratorMethod {
if (i == null) {
}
Chunk c = Bukkit.getWorld(world.getUID()).getChunkAt(x, z);
lastUse.put(c, M.ms());
listener.onChunkGenerated(x, z);
listener.onChunkCleaned(x, z);
return 0;

View File

@@ -18,25 +18,33 @@
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.PregeneratorMethod;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.scheduling.J;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
public class MedievalPregenMethod implements PregeneratorMethod {
private final World world;
private final KList<CompletableFuture<?>> futures;
private final Map<Chunk, Long> lastUse;
public MedievalPregenMethod(World world) {
this.world = world;
futures = new KList<>();
this.lastUse = new KMap<>();
}
private void waitForChunks() {
@@ -52,11 +60,19 @@ public class MedievalPregenMethod implements PregeneratorMethod {
}
private void unloadAndSaveAllChunks() {
waitForChunks();
try {
J.sfut(() -> {
for (Chunk i : world.getLoadedChunks()) {
i.unload(true);
if (world == null) {
Iris.warn("World was null somehow...");
return;
}
for (Chunk i : new ArrayList<>(lastUse.keySet())) {
Long lastUseTime = lastUse.get(i);
if (lastUseTime != null && M.ms() - lastUseTime >= 10) {
i.unload();
lastUse.remove(i);
}
}
world.save();
}).get();
@@ -104,6 +120,8 @@ public class MedievalPregenMethod implements PregeneratorMethod {
listener.onChunkGenerating(x, z);
futures.add(J.sfut(() -> {
world.getChunkAt(x, z);
Chunk c = Bukkit.getWorld(world.getUID()).getChunkAt(x, z);
lastUse.put(c, M.ms());
listener.onChunkGenerated(x, z);
listener.onChunkCleaned(x, z);
}));

View File

@@ -1,10 +1,12 @@
package com.volmit.iris.engine.safeguard;
package com.volmit.iris.core.safeguard;
import com.volmit.iris.Iris;
public class IrisSafeguard {
// more planned and WIP
public static boolean unstablemode = false;
public static boolean warningmode = false;
public static boolean stablemode = false;
public static void IrisSafeguardSystem() {
Iris.info("Enabled Iris SafeGuard");
ServerBootSFG.BootCheck();

View File

@@ -0,0 +1,80 @@
package com.volmit.iris.core.safeguard;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.util.format.C;
public class ModesSFG {
public static void selectMode() {
if (IrisSafeguard.unstablemode) {
Iris.safeguard(C.DARK_RED + "Iris is running in Unstable Mode");
unstable();
}
if (IrisSafeguard.warningmode) {
Iris.safeguard(C.GOLD + "Iris is running in Warning Mode");
warning();
}
if (IrisSafeguard.stablemode) {
stable();
}
}
public static void stable() {
Iris.safeguard(C.BLUE + "Iris is running Stable");
}
public static void unstable() {
UtilsSFG.printIncompatibleWarnings();
if (IrisSafeguard.unstablemode) {
Iris.info("");
Iris.info(C.DARK_GRAY + "--==<" + C.RED + " IMPORTANT " + C.DARK_GRAY + ">==--");
Iris.info(C.RED + "Iris is running in unstable mode which may cause the following issues:");
Iris.info(C.DARK_RED + "Server Issues");
Iris.info(C.RED + "- Server won't boot");
Iris.info(C.RED + "- Data Loss");
Iris.info(C.RED + "- Unexpected behavior.");
Iris.info(C.RED + "- And More...");
Iris.info(C.DARK_RED + "World Issues");
Iris.info(C.RED + "- Worlds can't load due to corruption.");
Iris.info(C.RED + "- Worlds may slowly corrupt until they can't load.");
Iris.info(C.RED + "- World data loss.");
Iris.info(C.RED + "- And More...");
Iris.info(C.DARK_RED + "ATTENTION: " + C.RED + "While running Iris in unstable mode, you won't be eligible for support.");
Iris.info(C.DARK_RED + "CAUSE: " + C.RED + UtilsSFG.MSGIncompatibleWarnings());
if (IrisSettings.get().getGeneral().ignoreBootMode) {
Iris.info(C.DARK_RED + "Boot Unstable is set to true, continuing with the startup process.");
} else {
Iris.info(C.DARK_RED + "Go to plugins/iris/settings.json and set ignoreBootMode to true if you wish to proceed.");
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// no
}
}
}
Iris.info("");
}
}
public static void warning() {
UtilsSFG.printIncompatibleWarnings();
if (IrisSafeguard.warningmode) {
Iris.info("");
Iris.info(C.DARK_GRAY + "--==<" + C.GOLD + " IMPORTANT " + C.DARK_GRAY + ">==--");
Iris.info(C.GOLD + "Iris is running in warning mode which may cause the following issues:");
Iris.info(C.YELLOW + "- Data Loss");
Iris.info(C.YELLOW + "- Errors");
Iris.info(C.YELLOW + "- Broken worlds");
Iris.info(C.YELLOW + "- Unexpected behavior.");
Iris.info(C.YELLOW + "- And perhaps further complications.");
Iris.info(C.GOLD + "CAUSE: " + C.YELLOW + UtilsSFG.MSGIncompatibleWarnings());
Iris.info("");
}
}
}

View File

@@ -0,0 +1,8 @@
package com.volmit.iris.core.safeguard;
public class PerformanceSFG {
public static void calculatePerformance() {
}
}

View File

@@ -0,0 +1,163 @@
package com.volmit.iris.core.safeguard;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;
import java.io.File;
import java.nio.channels.FileChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.HashMap;
import java.util.Map;
import java.util.StringJoiner;
import static com.volmit.iris.Iris.getJavaVersion;
import static com.volmit.iris.Iris.instance;
import static com.volmit.iris.core.safeguard.IrisSafeguard.*;
public class ServerBootSFG {
public static final Map<String, Boolean> incompatibilities = new HashMap<>();
public static boolean isJDK17 = true;
public static boolean hasEnoughDiskSpace = true;
public static boolean isJRE = false;
public static boolean hasPrivileges = true;
public static boolean unsuportedversion = false;
protected static boolean safeguardPassed;
public static boolean passedserversoftware = true;
protected static int count;
protected static byte severityLow;
protected static byte severityMedium;
protected static byte severityHigh;
public static String allIncompatibilities;
public static void BootCheck() {
Iris.info("Checking for possible conflicts..");
org.bukkit.plugin.PluginManager pluginManager = Bukkit.getPluginManager();
Plugin[] plugins = pluginManager.getPlugins();
incompatibilities.clear();
incompatibilities.put("Multiverse-Core", false);
incompatibilities.put("dynmap", false);
incompatibilities.put("TerraformGenerator", false);
incompatibilities.put("Stratos", false);
String pluginName;
for (Plugin plugin : plugins) {
pluginName = plugin.getName();
Boolean flag = incompatibilities.get(pluginName);
if (flag != null && !flag) {
severityHigh++;
incompatibilities.put(pluginName, true);
}
}
StringJoiner joiner = new StringJoiner(", ");
for (Map.Entry<String, Boolean> entry : incompatibilities.entrySet()) {
if (entry.getValue()) {
joiner.add(entry.getKey());
}
}
if (
!instance.getServer().getVersion().contains("Purpur") &&
!instance.getServer().getVersion().contains("Paper") &&
!instance.getServer().getVersion().contains("Spigot") &&
!instance.getServer().getVersion().contains("Pufferfish") &&
!instance.getServer().getVersion().contains("Bukkit")) {
passedserversoftware = false;
joiner.add("Server Software");
severityHigh++;
}
if (INMS.get() instanceof NMSBinding1X) {
unsuportedversion = true;
joiner.add("Unsupported Minecraft Version");
severityHigh++;
}
if (getJavaVersion() != 17) {
isJDK17 = false;
joiner.add("Unsupported Java version");
severityMedium++;
}
if (!isJDK()) {
isJRE = true;
joiner.add("Unsupported JDK");
severityMedium++;
}
// if (!hasPrivileges()){
// hasPrivileges = false;
// joiner.add("Insufficient Privileges");
// severityMedium++;
// } Some servers dont like this
if (!enoughDiskSpace()){
hasEnoughDiskSpace = false;
joiner.add("Insufficient Disk Space");
severityMedium++;
}
allIncompatibilities = joiner.toString();
safeguardPassed = (severityHigh == 0 && severityMedium == 0 && severityLow == 0);
count = severityHigh + severityMedium + severityLow;
if (safeguardPassed) {
stablemode = true;
Iris.safeguard("Stable mode has been activated.");
}
if (!safeguardPassed) {
if (severityMedium >= 1 && severityHigh == 0) {
warningmode = true;
Iris.safeguard("Warning mode has been activated.");
}
if (severityHigh >= 1) {
unstablemode = true;
Iris.safeguard("Unstable mode has been activated.");
}
}
}
public static boolean isJDK() {
try {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
// If the compiler is null, it means this is a JRE environment, not a JDK.
return compiler != null;
} catch (Exception ignored) {}
return false;
}
public static boolean hasPrivileges() {
Path pv = Paths.get(Bukkit.getWorldContainer() + "iristest.json");
try (FileChannel fc = FileChannel.open(pv, StandardOpenOption.CREATE, StandardOpenOption.DELETE_ON_CLOSE, StandardOpenOption.READ, StandardOpenOption.WRITE)) {
if (Files.isReadable(pv) && Files.isWritable(pv)) {
return true;
}
} catch (Exception e) {
return false;
}
return false;
}
public static boolean enoughDiskSpace() {
File freeSpace = new File(Bukkit.getWorldContainer() + ".");
double gigabytes = freeSpace.getFreeSpace() / (1024.0 * 1024.0 * 1024.0);
if (gigabytes > 3){
return true;
} else {
return false;
}
}
private static boolean checkJavac(String path) {
return !path.isEmpty() && (new File(path, "javac").exists() || new File(path, "javac.exe").exists());
}
}

View File

@@ -0,0 +1,68 @@
package com.volmit.iris.core.safeguard;
import com.volmit.iris.Iris;
import com.volmit.iris.util.format.C;
public class UtilsSFG {
public static void splash() {
ModesSFG.selectMode();
}
public static void printIncompatibleWarnings() {
// String SupportedIrisVersion = getDescription().getVersion(); //todo Automatic version
if (ServerBootSFG.safeguardPassed) {
Iris.safeguard(C.BLUE + "0 Conflicts found");
} else {
if (IrisSafeguard.unstablemode) {
Iris.safeguard(C.DARK_RED + "" + ServerBootSFG.count + " Conflicts found");
}
if (IrisSafeguard.warningmode) {
Iris.safeguard(C.YELLOW + "" + ServerBootSFG.count + " Conflicts found");
}
if (ServerBootSFG.incompatibilities.get("Multiverse-Core")) {
Iris.safeguard(C.RED + "Multiverse");
Iris.safeguard(C.RED + "- The plugin Multiverse is not compatible with the server.");
Iris.safeguard(C.RED + "- If you want to have a world manager, consider using PhantomWorlds or MyWorlds instead.");
}
if (ServerBootSFG.incompatibilities.get("dynmap")) {
Iris.safeguard(C.RED + "Dynmap");
Iris.safeguard(C.RED + "- The plugin Dynmap is not compatible with the server.");
Iris.safeguard(C.RED + "- If you want to have a map plugin like Dynmap, consider Bluemap.");
}
if (ServerBootSFG.incompatibilities.get("TerraformGenerator") || ServerBootSFG.incompatibilities.get("Stratos")) {
Iris.safeguard(C.YELLOW + "Terraform Generator / Stratos");
Iris.safeguard(C.YELLOW + "- Iris is not compatible with other worldgen plugins.");
}
if (ServerBootSFG.unsuportedversion) {
Iris.safeguard(C.RED + "Server Version");
Iris.safeguard(C.RED + "- Iris only supports 1.19.2 > 1.20.4");
}
if (!ServerBootSFG.passedserversoftware) {
Iris.safeguard(C.YELLOW + "Unsupported Server Software");
Iris.safeguard(C.YELLOW + "- Please consider using Paper or Purpur instead.");
}
if (!ServerBootSFG.hasPrivileges) {
Iris.safeguard(C.YELLOW + "Insufficient Privileges");
Iris.safeguard(C.YELLOW + "- The server has insufficient Privileges to run iris. Please contact support.");
}
if (!ServerBootSFG.hasEnoughDiskSpace) {
Iris.safeguard(C.YELLOW + "Insufficient Disk Space");
Iris.safeguard(C.YELLOW + "- The server has insufficient Free DiskSpace to run iris required 3GB+.");
}
if (!ServerBootSFG.isJDK17) {
Iris.safeguard(C.YELLOW + "Unsupported java version");
Iris.safeguard(C.YELLOW + "- Please consider using JDK 17 Instead of JDK " + Iris.getJavaVersion());
}
if (ServerBootSFG.isJRE) {
Iris.safeguard(C.YELLOW + "Unsupported Server JDK");
Iris.safeguard(C.YELLOW + "- Please consider using JDK 17 Instead of JRE " + Iris.getJavaVersion());
}
}
}
public static String MSGIncompatibleWarnings() {
return ServerBootSFG.allIncompatibilities;
}
}

View File

@@ -19,6 +19,7 @@
package com.volmit.iris.core.service;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
@@ -124,17 +125,32 @@ public class BoardSVC implements IrisService, BoardProvider {
int y = player.getLocation().getBlockY() - player.getWorld().getMinHeight();
int z = player.getLocation().getBlockZ();
lines.add("&7&m ");
lines.add(C.GREEN + "Speed" + C.GRAY + ": " + Form.f(engine.getGeneratedPerSecond(), 0) + "/s " + Form.duration(1000D / engine.getGeneratedPerSecond(), 0));
lines.add(C.AQUA + "Cache" + C.GRAY + ": " + Form.f(IrisData.cacheSize()));
lines.add(C.AQUA + "Mantle" + C.GRAY + ": " + engine.getMantle().getLoadedRegionCount());
lines.add("&7&m ");
lines.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName());
lines.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiomeOrMantle(x, y, z).getName());
lines.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z) + player.getWorld().getMinHeight()));
lines.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getComplex().getSlopeStream().get(x, z), 2));
lines.add(C.AQUA + "BUD/s" + C.GRAY + ": " + Form.f(engine.getBlockUpdatesPerSecond()));
lines.add("&7&m ");
if(IrisSettings.get().getGeneral().debug){
lines.add("&7&m ");
lines.add(C.GREEN + "Speed" + C.GRAY + ": " + Form.f(engine.getGeneratedPerSecond(), 0) + "/s " + Form.duration(1000D / engine.getGeneratedPerSecond(), 0));
lines.add(C.AQUA + "Cache" + C.GRAY + ": " + Form.f(IrisData.cacheSize()));
lines.add(C.AQUA + "Mantle" + C.GRAY + ": " + engine.getMantle().getLoadedRegionCount());
lines.add(C.LIGHT_PURPLE + "Carving" + C.GRAY + ": " + engine.getMantle().isCarved(x,y,z));
lines.add("&7&m ");
lines.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName());
lines.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiomeOrMantle(x, y, z).getName());
lines.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z)));
lines.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getComplex().getSlopeStream().get(x, z), 2));
lines.add(C.AQUA + "BUD/s" + C.GRAY + ": " + Form.f(engine.getBlockUpdatesPerSecond()));
lines.add("&7&m ");
} else {
lines.add("&7&m ");
lines.add(C.GREEN + "Speed" + C.GRAY + ": " + Form.f(engine.getGeneratedPerSecond(), 0) + "/s " + Form.duration(1000D / engine.getGeneratedPerSecond(), 0));
lines.add(C.AQUA + "Cache" + C.GRAY + ": " + Form.f(IrisData.cacheSize()));
lines.add(C.AQUA + "Mantle" + C.GRAY + ": " + engine.getMantle().getLoadedRegionCount());
lines.add("&7&m ");
lines.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName());
lines.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiomeOrMantle(x, y, z).getName());
lines.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z)));
lines.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getComplex().getSlopeStream().get(x, z), 2));
lines.add(C.AQUA + "BUD/s" + C.GRAY + ": " + Form.f(engine.getBlockUpdatesPerSecond()));
lines.add("&7&m ");
}
}
}
}

View File

@@ -1,163 +0,0 @@
package com.volmit.iris.core.service;
import com.volmit.iris.core.tools.IrisToolbelt;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
public class ChunkHandlerSVC implements Listener {
// Idk how it works but it works lol
private final JavaPlugin plugin;
private static BukkitTask task;
private final Map<World, ChunkUnloader> worlds = new ConcurrentHashMap<>();
private static final Map<Chunk, Set<Player>> playersInChunk = new ConcurrentHashMap<>();
public ChunkHandlerSVC(JavaPlugin plugin) {
this.plugin = plugin;
Bukkit.getPluginManager().registerEvents(this, plugin);
for (World world : Bukkit.getWorlds()) {
if (IrisToolbelt.isIrisWorld(world)) {
worlds.put(world, new ChunkUnloader(plugin, world));
}
}
startTask();
}
private void startTask() {
if (task == null) {
task = new BukkitRunnable() {
@Override
public void run() {
worlds.values().forEach(ChunkUnloader::update);
}
}.runTaskTimerAsynchronously(plugin, 0L, 1L);
}
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
Chunk previousChunk = event.getFrom().getChunk();
Chunk currentChunk = event.getTo().getChunk();
if (!previousChunk.equals(currentChunk)) {
playersInChunk.computeIfAbsent(previousChunk, k -> ConcurrentHashMap.newKeySet()).remove(player);
playersInChunk.computeIfAbsent(currentChunk, k -> ConcurrentHashMap.newKeySet()).add(player);
}
}
public static void exit() {
if (task != null) {
task.cancel();
}
}
@EventHandler
public void onWorldLoad(WorldLoadEvent event) {
World world = event.getWorld();
if (IrisToolbelt.isIrisWorld(world)) {
worlds.put(world, new ChunkUnloader(plugin, world));
}
}
@EventHandler
public void onWorldUnload(WorldUnloadEvent event) {
worlds.remove(event.getWorld());
}
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
World world = event.getWorld();
if (worlds.containsKey(world)) {
worlds.get(world).onChunkLoad(event.getChunk());
}
}
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
World world = event.getWorld();
if (worlds.containsKey(world)) {
worlds.get(world).onChunkUnload(event.getChunk());
}
}
private static class ChunkUnloader {
private final JavaPlugin plugin;
private final World world;
private final Map<Chunk, Long> chunks = new ConcurrentHashMap<>();
private ChunkUnloader(JavaPlugin plugin, World world) {
this.plugin = plugin;
this.world = world;
}
public void onChunkLoad(Chunk chunk) {
// System.out.printf("%s > Loaded Chunk [x=%s, z=%s]%n", world.getName(), chunk.getX(), chunk.getZ());
chunks.put(chunk, System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(3));
}
public void onChunkUnload(Chunk chunk) {
chunks.remove(chunk);
playersInChunk.remove(chunk);
}
public void update() {
try {
long currentTime = System.currentTimeMillis();
Set<Chunk> chunkSet = new HashSet<>(chunks.keySet());
for (Chunk chunk : chunkSet) {
if (!chunk.isLoaded()) {
continue;
}
if (isChunkNearby(chunk)) {
chunks.put(chunk, currentTime + TimeUnit.MINUTES.toMillis(3));
} else if (chunks.get(chunk) <= currentTime) {
unloadChunk(chunk);
}
}
} catch (Exception e) {
// Log the error message
System.out.println("Error in update method: " + e.getMessage());
}
}
private boolean isChunkNearby(Chunk chunk) {
Set<Player> players = playersInChunk.get(chunk);
if (players == null) {
players = ConcurrentHashMap.newKeySet();
playersInChunk.put(chunk, players);
}
return !players.isEmpty();
}
private void unloadChunk(Chunk chunk) {
try {
// System.out.printf("%s > Unloading Chunk [x=%s, z=%s]%n", world.getName(), chunk.getX(), chunk.getZ());
Bukkit.getScheduler().runTask(plugin, () -> chunk.unload(true));
} catch (Exception e) {
System.out.println("Error unloading chunk: " + e.getMessage());
}
}
}
}

View File

@@ -1,119 +1,138 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.service;
import com.volmit.iris.Iris;
import com.volmit.iris.core.link.*;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.IrisService;
import lombok.Data;
import org.bukkit.Bukkit;
import org.bukkit.block.data.BlockData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.inventory.ItemStack;
import java.util.MissingResourceException;
import java.util.Optional;
@Data
public class ExternalDataSVC implements IrisService {
private KList<ExternalDataProvider> providers = new KList<>(), activeProviders = new KList<>();
@Override
public void onEnable() {
Iris.info("Loading ExternalDataProvider...");
Bukkit.getPluginManager().registerEvents(this, Iris.instance);
providers.add(new OraxenDataProvider());
if (Bukkit.getPluginManager().getPlugin("Oraxen") != null) {
Iris.info("Oraxen found, loading OraxenDataProvider...");
}
providers.add(new ItemAdderDataProvider());
if (Bukkit.getPluginManager().getPlugin("ItemAdder") != null) {
Iris.info("ItemAdder found, loading ItemAdderDataProvider...");
}
providers.add(new ExecutableItemsDataProvider());
if (Bukkit.getPluginManager().getPlugin("ExecutableItems") != null) {
Iris.info("ExecutableItems found, loading ExecutableItemsDataProvider...");
}
for (ExternalDataProvider p : providers) {
if (p.isReady()) {
activeProviders.add(p);
p.init();
Iris.info("Enabled ExternalDataProvider for %s.", p.getPluginId());
}
}
}
@Override
public void onDisable() {
}
@EventHandler
public void onPluginEnable(PluginEnableEvent e) {
if (activeProviders.stream().noneMatch(p -> p.getPlugin().equals(e.getPlugin()))) {
providers.stream().filter(p -> p.isReady() && p.getPlugin().equals(e.getPlugin())).findFirst().ifPresent(edp -> {
activeProviders.add(edp);
edp.init();
Iris.info("Enabled ExternalDataProvider for %s.", edp.getPluginId());
});
}
}
public Optional<BlockData> getBlockData(Identifier key) {
Optional<ExternalDataProvider> provider = activeProviders.stream().filter(p -> p.isValidProvider(key, false)).findFirst();
if (provider.isEmpty())
return Optional.empty();
try {
return Optional.of(provider.get().getBlockData(key));
} catch (MissingResourceException e) {
Iris.error(e.getMessage() + " - [" + e.getClassName() + ":" + e.getKey() + "]");
return Optional.empty();
}
}
public Optional<ItemStack> getItemStack(Identifier key) {
Optional<ExternalDataProvider> provider = activeProviders.stream().filter(p -> p.isValidProvider(key, true)).findFirst();
if (provider.isEmpty()) {
Iris.warn("No matching Provider found for modded material \"%s\"!", key);
return Optional.empty();
}
try {
return Optional.of(provider.get().getItemStack(key));
} catch (MissingResourceException e) {
Iris.error(e.getMessage() + " - [" + e.getClassName() + ":" + e.getKey() + "]");
return Optional.empty();
}
}
public Identifier[] getAllBlockIdentifiers() {
KList<Identifier> names = new KList<>();
activeProviders.forEach(p -> names.add(p.getBlockTypes()));
return names.toArray(new Identifier[0]);
}
public Identifier[] getAllItemIdentifiers() {
KList<Identifier> names = new KList<>();
activeProviders.forEach(p -> names.add(p.getItemTypes()));
return names.toArray(new Identifier[0]);
}
}
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.service;
import com.volmit.iris.Iris;
import com.volmit.iris.core.link.*;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.IrisService;
import lombok.Data;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.inventory.ItemStack;
import java.util.MissingResourceException;
import java.util.Optional;
@Data
public class ExternalDataSVC implements IrisService {
private KList<ExternalDataProvider> providers = new KList<>(), activeProviders = new KList<>();
@Override
public void onEnable() {
Iris.info("Loading ExternalDataProvider...");
Bukkit.getPluginManager().registerEvents(this, Iris.instance);
providers.add(new OraxenDataProvider());
if (Bukkit.getPluginManager().getPlugin("Oraxen") != null) {
Iris.info("Oraxen found, loading OraxenDataProvider...");
}
providers.add(new ItemAdderDataProvider());
if (Bukkit.getPluginManager().getPlugin("ItemAdder") != null) {
Iris.info("ItemAdder found, loading ItemAdderDataProvider...");
}
providers.add(new ExecutableItemsDataProvider());
if (Bukkit.getPluginManager().getPlugin("ExecutableItems") != null) {
Iris.info("ExecutableItems found, loading ExecutableItemsDataProvider...");
}
providers.add(new HMCLeavesDataProvider());
if (Bukkit.getPluginManager().getPlugin("HMCLeaves") != null) {
Iris.info("BlockAdder found, loading HMCLeavesDataProvider...");
}
providers.add(new MMOItemsDataProvider());
if (Bukkit.getPluginManager().getPlugin("MMOItems") != null) {
Iris.info("MMOItems found, loading MMOItemsDataProvider...");
}
for (ExternalDataProvider p : providers) {
if (p.isReady()) {
activeProviders.add(p);
p.init();
Iris.info("Enabled ExternalDataProvider for %s.", p.getPluginId());
}
}
}
@Override
public void onDisable() {
}
@EventHandler
public void onPluginEnable(PluginEnableEvent e) {
if (activeProviders.stream().noneMatch(p -> p.getPlugin().equals(e.getPlugin()))) {
providers.stream().filter(p -> p.isReady() && p.getPlugin().equals(e.getPlugin())).findFirst().ifPresent(edp -> {
activeProviders.add(edp);
edp.init();
Iris.info("Enabled ExternalDataProvider for %s.", edp.getPluginId());
});
}
}
public Optional<BlockData> getBlockData(Identifier key) {
Optional<ExternalDataProvider> provider = activeProviders.stream().filter(p -> p.isValidProvider(key, false)).findFirst();
if (provider.isEmpty())
return Optional.empty();
try {
return Optional.of(provider.get().getBlockData(key));
} catch (MissingResourceException e) {
Iris.error(e.getMessage() + " - [" + e.getClassName() + ":" + e.getKey() + "]");
return Optional.empty();
}
}
public Optional<ItemStack> getItemStack(Identifier key) {
Optional<ExternalDataProvider> provider = activeProviders.stream().filter(p -> p.isValidProvider(key, true)).findFirst();
if (provider.isEmpty()) {
Iris.warn("No matching Provider found for modded material \"%s\"!", key);
return Optional.empty();
}
try {
return Optional.of(provider.get().getItemStack(key));
} catch (MissingResourceException e) {
Iris.error(e.getMessage() + " - [" + e.getClassName() + ":" + e.getKey() + "]");
return Optional.empty();
}
}
public void processUpdate(Engine engine, Block block, Identifier blockId) {
Optional<ExternalDataProvider> provider = activeProviders.stream().filter(p -> p.isValidProvider(blockId, false)).findFirst();
if (provider.isEmpty()) {
Iris.warn("No matching Provider found for modded material \"%s\"!", blockId);
return;
}
provider.get().processUpdate(engine, block, blockId);
}
public Identifier[] getAllBlockIdentifiers() {
KList<Identifier> names = new KList<>();
activeProviders.forEach(p -> names.add(p.getBlockTypes()));
return names.toArray(new Identifier[0]);
}
public Identifier[] getAllItemIdentifiers() {
KList<Identifier> names = new KList<>();
activeProviders.forEach(p -> names.add(p.getItemTypes()));
return names.toArray(new Identifier[0]);
}
}

View File

@@ -0,0 +1,308 @@
package com.volmit.iris.core.service;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.mantle.TectonicPlate;
import com.volmit.iris.util.misc.getHardware;
import com.volmit.iris.util.plugin.IrisService;
import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.Looper;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.ServerLoadEvent;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.event.world.WorldUnloadEvent;
import org.checkerframework.checker.units.qual.A;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Supplier;
public class IrisEngineSVC implements IrisService {
public static IrisEngineSVC instance;
public boolean isServerShuttingDown = false;
public boolean isServerLoaded = false;
private static final AtomicInteger tectonicLimit = new AtomicInteger(30);
private ReentrantLock lastUseLock;
private KMap<World, Long> lastUse;
private List<World> IrisWorlds;
private Looper cacheTicker;
private Looper trimTicker;
private Looper unloadTicker;
private Looper updateTicker;
private PrecisionStopwatch trimAlive;
private PrecisionStopwatch unloadAlive;
public PrecisionStopwatch trimActiveAlive;
public PrecisionStopwatch unloadActiveAlive;
private AtomicInteger TotalTectonicPlates;
private AtomicInteger TotalQueuedTectonicPlates;
private AtomicInteger TotalNotQueuedTectonicPlates;
private AtomicBoolean IsUnloadAlive;
private AtomicBoolean IsTrimAlive;
ChronoLatch cl;
public List<World> corruptedIrisWorlds = new ArrayList<>();
@Override
public void onEnable() {
this.cl = new ChronoLatch(5000);
lastUse = new KMap<>();
lastUseLock = new ReentrantLock();
IrisWorlds = new ArrayList<>();
IsUnloadAlive = new AtomicBoolean(true);
IsTrimAlive = new AtomicBoolean(true);
trimActiveAlive = new PrecisionStopwatch();
unloadActiveAlive = new PrecisionStopwatch();
trimAlive = new PrecisionStopwatch();
unloadAlive = new PrecisionStopwatch();
TotalTectonicPlates = new AtomicInteger();
TotalQueuedTectonicPlates = new AtomicInteger();
TotalNotQueuedTectonicPlates = new AtomicInteger();
tectonicLimit.set(2);
long t = getHardware.getProcessMemory();
while (t > 200) {
tectonicLimit.getAndAdd(1);
t = t - 200;
}
this.setup();
trimAlive.begin();
unloadAlive.begin();
trimActiveAlive.begin();
unloadActiveAlive.begin();
updateTicker.start();
cacheTicker.start();
trimTicker.start();
unloadTicker.start();
instance = this;
}
public void engineStatus() {
boolean trimAlive = trimTicker.isAlive();
boolean unloadAlive = unloadTicker.isAlive();
Iris.info("Status:");
Iris.info("- Trim: " + trimAlive);
Iris.info("- Unload: " + unloadAlive);
}
public static int getTectonicLimit() {
return tectonicLimit.get();
}
public void EngineReport() {
Iris.info(C.RED + "CRITICAL ENGINE FAILURE! The Tectonic Trim subsystem has not responded for: " + Form.duration(trimAlive.getMillis()) + ".");
}
@EventHandler
public void onWorldUnload(WorldUnloadEvent event) {
updateWorlds();
}
@EventHandler
public void onWorldLoad(WorldLoadEvent event) {
updateWorlds();
}
@EventHandler
public void onServerBoot(ServerLoadEvent event) {
isServerLoaded = true;
}
@EventHandler
public void onPluginDisable(PluginDisableEvent event) {
if (event.getPlugin().equals(Iris.instance)) {
isServerShuttingDown = true;
}
}
public void updateWorlds() {
for (World world : Bukkit.getWorlds()) {
try {
if (IrisToolbelt.access(world).getEngine() != null) {
IrisWorlds.add(world);
}
} catch (Exception e) {
// no
}
}
}
private void setup() {
cacheTicker = new Looper() {
@Override
protected long loop() {
long now = System.currentTimeMillis();
lastUseLock.lock();
try {
for (World key : new ArrayList<>(lastUse.keySet())) {
Long last = lastUse.get(key);
if (last == null)
continue;
if (now - last > 60000) {
lastUse.remove(key);
}
}
} finally {
lastUseLock.unlock();
}
return 1000;
}
};
updateTicker = new Looper() {
@Override
protected long loop() {
try {
TotalQueuedTectonicPlates.set(0);
TotalNotQueuedTectonicPlates.set(0);
TotalTectonicPlates.set(0);
for (World world : IrisWorlds) {
Engine engine = Objects.requireNonNull(IrisToolbelt.access(world)).getEngine();
TotalQueuedTectonicPlates.addAndGet((int) engine.getMantle().getToUnload());
TotalNotQueuedTectonicPlates.addAndGet((int) engine.getMantle().getNotQueuedLoadedRegions());
TotalTectonicPlates.addAndGet(engine.getMantle().getLoadedRegionCount());
}
if (!isServerShuttingDown && isServerLoaded) {
if (!trimTicker.isAlive()) {
Iris.info(C.IRIS + "TrimTicker found dead! Booting it up!");
try {
trimTicker.start();
} catch (Exception e) {
Iris.error("What happened?");
e.printStackTrace();
}
}
if (!unloadTicker.isAlive()) {
Iris.info(C.IRIS + "UnloadTicker found dead! Booting it up!");
try {
unloadTicker.start();
} catch (Exception e) {
Iris.error("What happened?");
e.printStackTrace();
}
}
}
} catch (Exception e) {
return -1;
}
return 1000;
}
};
trimTicker = new Looper() {
private final Supplier<Engine> supplier = createSupplier();
@Override
protected long loop() {
long start = System.currentTimeMillis();
trimAlive.reset();
try {
Engine engine = supplier.get();
if (engine != null) {
engine.getMantle().trim(tectonicLimit.get() / lastUse.size());
}
} catch (Throwable e) {
Iris.reportError(e);
Iris.info(C.RED + "EngineSVC: Failed to trim. Please contact support!");
e.printStackTrace();
return -1;
}
int size = lastUse.size();
long time = (size > 0 ? 1000/size : 1000) - (System.currentTimeMillis() - start);
if (time <= 0)
return 0;
return time;
}
};
unloadTicker = new Looper() {
private final Supplier<Engine> supplier = createSupplier();
@Override
protected long loop() {
long start = System.currentTimeMillis();
unloadAlive.reset();
try {
Engine engine = supplier.get();
if (engine != null) {
long unloadStart = System.currentTimeMillis();
int count = engine.getMantle().unloadTectonicPlate(tectonicLimit.get() / lastUse.size());
if (count > 0) {
Iris.debug(C.GOLD + "Unloaded " + C.YELLOW + count + " TectonicPlates in " + C.RED + Form.duration(System.currentTimeMillis() - unloadStart, 2));
}
}
} catch (Throwable e) {
Iris.reportError(e);
Iris.info(C.RED + "EngineSVC: Failed to unload.");
e.printStackTrace();
return -1;
}
int size = lastUse.size();
long time = (size > 0 ? 1000/size : 1000) - (System.currentTimeMillis() - start);
if (time <= 0)
return 0;
return time;
}
};
}
private Supplier<Engine> createSupplier() {
AtomicInteger i = new AtomicInteger();
return () -> {
List<World> worlds = Bukkit.getWorlds();
if (i.get() >= worlds.size()) {
i.set(0);
}
try {
for (int j = 0; j < worlds.size(); j++) {
World world = worlds.get(i.getAndIncrement());
PlatformChunkGenerator generator = IrisToolbelt.access(world);
if (i.get() >= worlds.size()) {
i.set(0);
}
if (generator != null) {
Engine engine = generator.getEngine();
if (engine != null && !engine.isStudio()) {
lastUseLock.lock();
lastUse.put(world, System.currentTimeMillis());
lastUseLock.unlock();
return engine;
}
}
}
} catch (Throwable e) {
Iris.info(C.RED + "EngineSVC: Failed to create supplier.");
e.printStackTrace();
Iris.reportError(e);
}
return null;
};
}
@Override
public void onDisable() {
cacheTicker.interrupt();
trimTicker.interrupt();
unloadTicker.interrupt();
lastUse.clear();
}
}

View File

@@ -54,6 +54,7 @@ import java.util.Objects;
public class WandSVC implements IrisService {
private static ItemStack dust;
private static ItemStack wand;
public static void pasteSchematic(IrisObject s, Location at) {
s.place(at);
@@ -226,17 +227,19 @@ public class WandSVC implements IrisService {
return getCuboidFromItem(p.getInventory().getItemInMainHand());
}
Cuboid c = WorldEditLink.getSelection(p);
if (IrisSettings.get().getWorld().worldEditWandCUI) {
Cuboid c = WorldEditLink.getSelection(p);
if (c != null) {
return new Location[]{c.getLowerNE(), c.getUpperSW()};
if (c != null) {
return new Location[]{c.getLowerNE(), c.getUpperSW()};
}
}
return null;
}
public static boolean isHoldingWand(Player p) {
return isHoldingIrisWand(p) || WorldEditLink.getSelection(p) != null;
return isHoldingIrisWand(p) || (IrisSettings.get().getWorld().worldEditWandCUI && WorldEditLink.getSelection(p) != null);
}
public static boolean isHoldingIrisWand(Player p) {
@@ -251,7 +254,6 @@ public class WandSVC implements IrisService {
* @return True if it is
*/
public static boolean isWand(ItemStack is) {
ItemStack wand = createWand();
if (is.getItemMeta() == null) return false;
return is.getType().equals(wand.getType()) &&
is.getItemMeta().getDisplayName().equals(wand.getItemMeta().getDisplayName()) &&
@@ -261,7 +263,7 @@ public class WandSVC implements IrisService {
@Override
public void onEnable() {
ItemStack wand = createWand();
wand = createWand();
dust = createDust();
J.ar(() -> {

View File

@@ -0,0 +1,395 @@
package com.volmit.iris.core.tools;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.*;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.nbt.io.NBTUtil;
import com.volmit.iris.util.nbt.io.NamedTag;
import com.volmit.iris.util.nbt.tag.*;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.reflect.V;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.util.Vector;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
public class IrisConverter {
public static void convertSchematics(VolmitSender sender) {
File folder = Iris.instance.getDataFolder("convert");
FilenameFilter filter = (dir, name) -> name.endsWith(".schem");
File[] fileList = folder.listFiles(filter);
ExecutorService executorService = Executors.newFixedThreadPool(1);
executorService.submit(() -> {
for (File schem : fileList) {
try {
PrecisionStopwatch p = new PrecisionStopwatch();
boolean largeObject = false;
NamedTag tag = null;
try {
tag = NBTUtil.read(schem);
} catch (IOException e) {
Iris.info(C.RED + "Failed to read: " + schem.getName());
throw new RuntimeException(e);
}
CompoundTag compound = (CompoundTag) tag.getTag();
if (compound.containsKey("Palette") && compound.containsKey("Width") && compound.containsKey("Height") && compound.containsKey("Length")) {
int objW = ((ShortTag) compound.get("Width")).getValue();
int objH = ((ShortTag) compound.get("Height")).getValue();
int objD = ((ShortTag) compound.get("Length")).getValue();
int mv = objW * objH * objD;
AtomicInteger v = new AtomicInteger(0);
AtomicInteger fv = new AtomicInteger(0);
if (mv > 500_000) {
largeObject = true;
Iris.info(C.GRAY + "Converting.. "+ schem.getName() + " -> " + schem.getName().replace(".schem", ".iob"));
Iris.info(C.GRAY + "- It may take a while");
if (sender.isPlayer()) {
J.a(() -> {
// while (v.get() != mv) {
// double pr = ((double) v.get() / (double ) mv);
// sender.sendProgress(pr, "Converting");
// J.sleep(16);
// }
});
}
}
CompoundTag paletteTag = (CompoundTag) compound.get("Palette");
Map<Integer, BlockData> blockmap = new HashMap<>(paletteTag.size(), 0.9f);
for (Map.Entry<String, Tag<?>> entry : paletteTag.getValue().entrySet()) {
String blockName = entry.getKey();
BlockData bd = Bukkit.createBlockData(blockName);
Tag<?> blockTag = entry.getValue();
int blockId = ((IntTag) blockTag).getValue();
blockmap.put(blockId, bd);
}
ByteArrayTag byteArray = (ByteArrayTag) compound.get("BlockData");
byte[] originalBlockArray = byteArray.getValue();
int b = 0;
int a = 0;
Map<Integer, Byte> y = new HashMap<>();
Map<Integer, Byte> x = new HashMap<>();
Map<Integer, Byte> z = new HashMap<>();
// Height adjustments
for (int h = 0; h < objH; h++) {
if (b == 0) {
y.put(h, (byte) 0);
}
if (b > 0) {
y.put(h, (byte) 1);
}
a = 0;
b = 0;
for (int d = 0; d < objD; d++) {
for (int w = 0; w < objW; w++) {
BlockData db = blockmap.get((int) originalBlockArray[fv.get()]);
if(db.getAsString().contains("minecraft:air")) {
a++;
} else {
b++;
}
fv.getAndAdd(1);
}
}
}
fv.set(0);
// Width adjustments
for (int w = 0; w < objW; w++) {
if (b == 0) {
x.put(w, (byte) 0);
}
if (b > 0) {
x.put(w, (byte) 1);
}
a = 0;
b = 0;
for (int h = 0; h < objH; h++) {
for (int d = 0; d < objD; d++) {
BlockData db = blockmap.get((int) originalBlockArray[fv.get()]);
if(db.getAsString().contains("minecraft:air")) {
a++;
} else {
b++;
}
fv.getAndAdd(1);
}
}
}
fv.set(0);
// Depth adjustments
for (int d = 0; d < objD; d++) {
if (b == 0) {
z.put(d, (byte) 0);
}
if (b > 0) {
z.put(d, (byte) 1);
}
a = 0;
b = 0;
for (int h = 0; h < objH; h++) {
for (int w = 0; w < objW; w++) {
BlockData db = blockmap.get((int) originalBlockArray[fv.get()]);
if(db.getAsString().contains("minecraft:air")) {
a++;
} else {
b++;
}
fv.getAndAdd(1);
}
}
}
fv.set(0);
int CorrectObjH = getCorrectY(y, objH);
int CorrectObjW = getCorrectX(x, objW);
int CorrectObjD = getCorrectZ(z, objD);
//IrisObject object = new IrisObject(CorrectObjW, CorrectObjH, CorrectObjH);
IrisObject object = new IrisObject(objW, objH, objD);
Vector originalVector = new Vector(objW,objH,objD);
int[] yc = null;
int[] xc = null;
int[] zc = null;
int fo = 0;
int so = 0;
int o = 0;
int c = 0;
for (Integer i : y.keySet()) {
if (y.get(i) == 0) {
o++;
}
if (y.get(i) == 1) {
c++;
if (c == 1) {
fo = o;
}
o = 0;
}
}
so = o;
yc = new int[]{fo, so};
fo = 0;
so = 0;
o = 0;
c = 0;
for (Integer i : x.keySet()) {
if (x.get(i) == 0) {
o++;
}
if (x.get(i) == 1) {
c++;
if (c == 1) {
fo = o;
}
o = 0;
}
}
so = o;
xc = new int[]{fo, so};
fo = 0;
so = 0;
o = 0;
c = 0;
for (Integer i : z.keySet()) {
if (z.get(i) == 0) {
o++;
}
if (z.get(i) == 1) {
c++;
if (c == 1) {
fo = o;
}
o = 0;
}
}
so = o;
zc = new int[]{fo, so};
int h1, h2, w1, w2, v1 = 0, volume = objW * objH * objD;
Map<Integer, Integer> blockLocationMap = new LinkedHashMap<>();
boolean hasAir = false;
int pos = 0;
for (int i : originalBlockArray) {
blockLocationMap.put(pos, i);
pos++;
}
for (int h = 0; h < objH; h++) {
for (int d = 0; d < objD; d++) {
for (int w = 0; w < objW; w++) {
BlockData bd = blockmap.get((int) originalBlockArray[v.get()]);
if (!bd.getMaterial().isAir()) {
object.setUnsigned(w, h, d, bd);
}
v.getAndAdd(1);
}
}
}
try {
object.write(new File(folder, schem.getName().replace(".schem", ".iob")));
} catch (IOException e) {
Iris.info(C.RED + "Failed to save: " + schem.getName());
throw new RuntimeException(e);
}
if (sender.isPlayer()) {
if (largeObject) {
sender.sendMessage(C.IRIS + "Converted "+ schem.getName() + " -> " + schem.getName().replace(".schem", ".iob") + " in " + Form.duration(p.getMillis()));
} else {
sender.sendMessage(C.IRIS + "Converted " + schem.getName() + " -> " + schem.getName().replace(".schem", ".iob"));
}
}
if (largeObject) {
Iris.info(C.GRAY + "Converted "+ schem.getName() + " -> " + schem.getName().replace(".schem", ".iob") + " in " + Form.duration(p.getMillis()));
} else {
Iris.info(C.GRAY + "Converted " + schem.getName() + " -> " + schem.getName().replace(".schem", ".iob"));
}
// schem.delete();
}
} catch (Exception e) {
Iris.info(C.RED + "Failed to convert: " + schem.getName());
if (sender.isPlayer()) {
sender.sendMessage(C.RED + "Failed to convert: " + schem.getName());
}
e.printStackTrace();
Iris.reportError(e);
}
}
});
}
public static boolean isNewPointFurther(int[] originalPoint, int[] oldPoint, int[] newPoint) {
int oX = oldPoint[1];
int oY = oldPoint[2];
int oZ = oldPoint[3];
int nX = newPoint[1];
int nY = newPoint[2];
int nZ = newPoint[3];
int orX = originalPoint[1];
int orY = originalPoint[2];
int orZ = originalPoint[3];
double oldDistance = Math.sqrt(Math.pow(oX - orX, 2) + Math.pow(oY - orY, 2) + Math.pow(oZ - orZ, 2));
double newDistance = Math.sqrt(Math.pow(nX - orX, 2) + Math.pow(nY - orY, 2) + Math.pow(nZ - orZ, 2));
if (newDistance > oldDistance) {
return true;
}
return false;
}
public static int[] getCoordinates(int pos, int obX, int obY, int obZ) {
int z = 0;
int[] coords = new int[4];
for (int h = 0; h < obY; h++) {
for (int d = 0; d < obZ; d++) {
for (int w = 0; w < obX; w++) {
if (z == pos) {
coords[1] = w;
coords[2] = h;
coords[3] = d;
return coords;
}
z++;
}
}
}
return null;
}
public static int getCorrectY(Map<Integer, Byte> y, int H) {
int fo = 0;
int so = 0;
int o = 0;
int c = 0;
for (Integer i : y.keySet()) {
if (y.get(i) == 0) {
o++;
}
if (y.get(i) == 1) {
c++;
if(c == 1){
fo = o;
}
o = 0;
}
}
so = o;
return H = H - (fo + so);
}
public static int getCorrectX(Map<Integer, Byte> x, int W) {
int fo = 0;
int so = 0;
int o = 0;
int c = 0;
for (Integer i : x.keySet()) {
if (x.get(i) == 0) {
o++;
}
if (x.get(i) == 1) {
c++;
if(c == 1){
fo = o;
}
o = 0;
}
}
so = o;
return W = W - (fo + so);
}
public static int getCorrectZ(Map<Integer, Byte> z, int D) {
int fo = 0;
int so = 0;
int o = 0;
int c = 0;
for (Integer i : z.keySet()) {
if (z.get(i) == 0) {
o++;
}
if (z.get(i) == 1) {
c++;
if(c == 1){
fo = o;
}
o = 0;
}
}
so = o;
return D = D - (fo + so);
}
}

View File

@@ -24,9 +24,10 @@ import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.ServerConfigurator;
import com.volmit.iris.core.pregenerator.PregenTask;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.engine.safeguard.UtilsSFG;
import com.volmit.iris.core.safeguard.UtilsSFG;
import com.volmit.iris.util.exceptions.IrisException;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
@@ -45,9 +46,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
import static com.volmit.iris.core.tools.IrisPackBenchmarking.benchmark;
import static com.volmit.iris.engine.safeguard.IrisSafeguard.unstablemode;
import static com.volmit.iris.core.safeguard.IrisSafeguard.unstablemode;
/**
* Makes it a lot easier to setup an engine, world, studio or whatever
@@ -83,6 +82,10 @@ public class IrisCreator {
* the world itself. Studio worlds are deleted when they are unloaded.
*/
private boolean studio = false;
/**
* Benchmark mode
*/
private boolean benchmark = false;
public static boolean removeFromBukkitYml(String name) throws IOException {
YamlConfiguration yml = YamlConfiguration.loadConfiguration(BUKKIT_YML);
@@ -107,7 +110,7 @@ public class IrisCreator {
* @return the IrisAccess
* @throws IrisException shit happens
*/
IrisPackBenchmarking PackBench = new IrisPackBenchmarking();
public World create() throws IrisException {
if (unstablemode){
Iris.info(C.RED + "Your server is experiencing an incompatibility with the Iris plugin. Please rectify this problem to avoid further complications.");
@@ -173,7 +176,6 @@ public class IrisCreator {
}
}
}
//if (benchmark){loaded = true;}
});
@@ -191,7 +193,7 @@ public class IrisCreator {
done.set(true);
if (sender.isPlayer()) {
if (sender.isPlayer() && !benchmark) {
J.s(() -> {
sender.player().teleport(new Location(world.get(), 0, world.get().getHighestBlockYAt(0, 0), 0));
});

View File

@@ -2,169 +2,200 @@ package com.volmit.iris.core.tools;
import com.volmit.iris.Iris;
import com.volmit.iris.core.pregenerator.IrisPregenerator;
import com.volmit.iris.core.pregenerator.LazyPregenerator;
import com.volmit.iris.core.pregenerator.PregenTask;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.exceptions.IrisException;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.scheduling.J;
import org.apache.commons.io.FileUtils;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import lombok.Getter;
import org.bukkit.Bukkit;
import java.io.File;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import static com.volmit.iris.core.commands.CommandIris.BenchDimension;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.time.Clock;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.concurrent.*;
public class IrisPackBenchmarking {
public static boolean loaded = false;
public static boolean benchmark = false;
static boolean cancelled = false;
static boolean pregenInProgress = false;
static long startTime;
static long totalChunks;
static long generatedChunks;
static double elapsedTimeNs;
@Getter
public static IrisPackBenchmarking instance;
public static boolean benchmarkInProgress = false;
private IrisDimension IrisDimension;
private int radius;
private boolean finished = false;
PrecisionStopwatch stopwatch;
public static void runBenchmark() {
// IrisPackBenchmarking IrisPackBenchmarking = new IrisPackBenchmarking();
benchmark = true;
Iris.info(C.BLUE + "Benchmarking Dimension: " + C.AQUA + BenchDimension);
//progress();
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
Iris.info(C.GOLD + "Setting everything up..");
try {
String BenchmarkFolder = "\\Benchmark";
File folder = new File(BenchmarkFolder);
if (folder.exists() && folder.isDirectory()) {
FileUtils.deleteDirectory(folder);
Iris.debug("Deleted old Benchmark");
} else {
Iris.info(C.GOLD + "Old Benchmark not found!");
if(folder.exists()){
Iris.info(C.RED + "FAILED To remove old Benchmark!");
//cancelled = true;
public IrisPackBenchmarking(IrisDimension dimension, int r) {
instance = this;
this.IrisDimension = dimension;
this.radius = r;
runBenchmark();
}
}
private void runBenchmark() {
this.stopwatch = new PrecisionStopwatch();
ExecutorService service = Executors.newSingleThreadExecutor();
service.submit(() -> {
Iris.info("Setting up benchmark environment ");
benchmarkInProgress = true;
File file = new File("benchmark");
if (file.exists()) {
deleteDirectory(file.toPath());
}
createBenchmark();
while (!IrisToolbelt.isIrisWorld(Bukkit.getWorld("benchmark"))) {
J.sleep(1000);
Iris.debug("Iris PackBenchmark: Waiting...");
}
Iris.info("Starting Benchmark!");
stopwatch.begin();
startBenchmark();
});
}
public boolean getBenchmarkInProgress() {
return benchmarkInProgress;
}
public void finishedBenchmark(KList<Integer> cps) {
try {
String time = Form.duration(stopwatch.getMillis());
Engine engine = IrisToolbelt.access(Bukkit.getWorld("benchmark")).getEngine();
Iris.info("-----------------");
Iris.info("Results:");
Iris.info("- Total time: " + time);
Iris.info("- Average CPS: " + calculateAverage(cps));
Iris.info(" - Median CPS: " + calculateMedian(cps));
Iris.info(" - Highest CPS: " + findHighest(cps));
Iris.info(" - Lowest CPS: " + findLowest(cps));
Iris.info("-----------------");
Iris.info("Creating a report..");
File profilers = new File("plugins" + File.separator + "Iris" + File.separator + "packbenchmarks");
profilers.mkdir();
File results = new File("plugins " + File.separator + "Iris", IrisDimension.getName() + LocalDateTime.now(Clock.systemDefaultZone()) + ".txt");
results.createNewFile();
KMap<String, Double> metrics = engine.getMetrics().pull();
try (FileWriter writer = new FileWriter(results)) {
writer.write("-----------------\n");
writer.write("Results:\n");
writer.write("Dimension: " + IrisDimension.getName() + "\n");
writer.write("- Date of Benchmark: " + LocalDateTime.now(Clock.systemDefaultZone()) + "\n");
writer.write("\n");
writer.write("Metrics");
for (String m : metrics.k()) {
double i = metrics.get(m);
writer.write("- " + m + ": " + i);
}
} catch (Exception e) {
throw new RuntimeException();
writer.write("- " + metrics);
writer.write("Benchmark: " + LocalDateTime.now(Clock.systemDefaultZone()) + "\n");
writer.write("- Total time: " + time + "\n");
writer.write("- Average CPS: " + calculateAverage(cps) + "\n");
writer.write(" - Median CPS: " + calculateMedian(cps) + "\n");
writer.write(" - Highest CPS: " + findHighest(cps) + "\n");
writer.write(" - Lowest CPS: " + findLowest(cps) + "\n");
writer.write("-----------------\n");
Iris.info("Finished generating a report!");
} catch (IOException e) {
Iris.error("An error occurred writing to the file.");
e.printStackTrace();
}
}).thenRun(() -> {
Iris.info(C.GOLD + "Creating Benchmark Environment");
createBenchmark();
}).thenRun(() -> {
Iris.info( C.BLUE + "Benchmark Started!");
boolean done = false;
startBenchmarkTimer();
startBenchmark();
basicScheduler();
}).thenRun(() -> {
});
// cancelled = future.cancel(true);
try {
future.get();
} catch (InterruptedException | ExecutionException e) {
Bukkit.getServer().unloadWorld("benchmark", true);
stopwatch.end();
} catch (Exception e) {
Iris.error("Something has gone wrong!");
e.printStackTrace();
}
}
private static void results(){
double averageCps = calculateAverageCPS();
Iris.info("Benchmark Dimension: " + BenchDimension);
Iris.info("Speeds");
Iris.info("- Average CPS: " + roundToTwoDecimalPlaces(averageCps));
Iris.info("Duration: " + roundToTwoDecimalPlaces(elapsedTimeNs));
}
private static void basicScheduler() {
while (true) {
totalChunks = IrisPregenerator.getLongTotalChunks();
generatedChunks = IrisPregenerator.getLongGeneratedChunks();
if(totalChunks > 0) {
if (generatedChunks >= totalChunks) {
Iris.info("Benchmark Completed!");
elapsedTimeNs = stopBenchmarkTimer();
results();
break;
}
}
//J.sleep(100); test
}
}
static void createBenchmark(){
private void createBenchmark(){
try {
IrisToolbelt.createWorld()
.dimension(BenchDimension)
.name("Benchmark")
.dimension(IrisDimension.getName())
.name("benchmark")
.seed(1337)
.studio(false)
.benchmark(true)
.create();
} catch (IrisException e) {
throw new RuntimeException(e);
}
}
static void startBenchmark(){
private void startBenchmark(){
int x = 0;
int z = 0;
IrisToolbelt.pregenerate(PregenTask
.builder()
.gui(false)
.center(new Position2(x, z))
.width(5)
.height(5)
.build(), Bukkit.getWorld("Benchmark")
.build(), Bukkit.getWorld("benchmark")
);
}
static void startLazyBenchmark(){
int x = 0;
int z = 0;
LazyPregenerator.LazyPregenJob pregenJob = LazyPregenerator.LazyPregenJob.builder()
//.world("Benchmark")
.healingPosition(0)
.healing(false)
.chunksPerMinute(3200)
.radiusBlocks(5000)
.position(0)
.build();
LazyPregenerator pregenerator = new LazyPregenerator(pregenJob, new File("plugins/Iris/lazygen.json"));
pregenerator.start();
}
public static double calculateAverageCPS() {
double elapsedTimeSec = elapsedTimeNs / 1_000_000_000.0; // Convert to seconds
return generatedChunks / elapsedTimeSec;
}
private static void startBenchmarkTimer() {
startTime = System.nanoTime();
}
private static double stopBenchmarkTimer() {
long endTime = System.nanoTime();
return (endTime - startTime) / 1_000_000_000.0;
}
public static void deleteDirectory(File dir) {
File[] files = dir.listFiles();
if(files != null) {
for(File file: files) {
if(file.isDirectory()) {
deleteDirectory(file);
} else {
file.delete();
}
}
private double calculateAverage(KList<Integer> list) {
double sum = 0;
for (int num : list) {
sum += num;
}
dir.delete();
return sum / list.size();
}
private static double roundToTwoDecimalPlaces(double value) {
return Double.parseDouble(String.format("%.2f", value));
private double calculateMedian(KList<Integer> list) {
Collections.sort(list);
int middle = list.size() / 2;
if (list.size() % 2 == 1) {
return list.get(middle);
} else {
return (list.get(middle - 1) + list.get(middle)) / 2.0;
}
}
private int findLowest(KList<Integer> list) {
return Collections.min(list);
}
private int findHighest(KList<Integer> list) {
return Collections.max(list);
}
private boolean deleteDirectory(Path dir) {
try {
Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
Files.delete(dir);
return FileVisitResult.CONTINUE;
}
});
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
}

View File

@@ -19,8 +19,7 @@
package com.volmit.iris.core.tools;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisWorld;
import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
import org.bukkit.Bukkit;
import org.bukkit.World;
@@ -79,6 +78,7 @@ public class IrisWorldCreator {
? dim.getLoader().getDataFolder() :
new File(w.worldFolder(), "iris/pack"), dimensionName);
return new WorldCreator(name)
.environment(findEnvironment())
.generateStructures(true)

View File

@@ -35,6 +35,8 @@ import com.volmit.iris.util.noise.CNG;
import com.volmit.iris.util.stream.ProceduralStream;
import com.volmit.iris.util.stream.interpolation.Interpolated;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
@@ -42,6 +44,8 @@ import org.bukkit.block.data.BlockData;
import java.util.UUID;
@Data
@EqualsAndHashCode(exclude = "data")
@ToString(exclude = "data")
public class IrisComplex implements DataProvider {
private static final BlockData AIR = Material.AIR.createBlockData();
private RNG rng;

View File

@@ -21,6 +21,7 @@ package com.volmit.iris.engine;
import com.google.common.util.concurrent.AtomicDouble;
import com.google.gson.Gson;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.ServerConfigurator;
import com.volmit.iris.core.events.IrisEngineHotloadEvent;
import com.volmit.iris.core.gui.PregeneratorJob;
@@ -50,6 +51,9 @@ import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
@@ -62,8 +66,12 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Data
@EqualsAndHashCode(exclude = "context")
@ToString(exclude = "context")
public class IrisEngine implements Engine {
private final AtomicInteger bud;
private final AtomicInteger buds;
@@ -250,7 +258,14 @@ public class IrisEngine implements Engine {
if (!f.exists()) {
try {
f.getParentFile().mkdirs();
IO.writeAll(f, new Gson().toJson(new IrisEngineData()));
IrisEngineData data = new IrisEngineData();
data.getStatistics().setVersion(Iris.instance.getIrisVersion());
data.getStatistics().setMCVersion(Iris.instance.getMCVersion());
data.getStatistics().setUpgradedVersion(Iris.instance.getIrisVersion());
if (data.getStatistics().getVersion() == -1 || data.getStatistics().getMCVersion() == -1 ) {
Iris.error("Failed to setup Engine Data!");
}
IO.writeAll(f, new Gson().toJson(data));
} catch (IOException e) {
e.printStackTrace();
}
@@ -418,7 +433,6 @@ public class IrisEngine implements Engine {
J.a(() -> {
try {
getMantle().trim();
getData().getObjectLoader().clean();
} catch (Throwable e) {
Iris.reportError(e);
@@ -518,4 +532,19 @@ public class IrisEngine implements Engine {
public int getCacheID() {
return cacheId;
}
private boolean EngineSafe() {
// Todo: this has potential if done right
int EngineMCVersion = getEngineData().getStatistics().getMCVersion();
int EngineIrisVersion = getEngineData().getStatistics().getVersion();
int MinecraftVersion = Iris.instance.getMCVersion();
int IrisVersion = Iris.instance.getIrisVersion();
if (EngineIrisVersion != IrisVersion) {
return false;
}
if (EngineMCVersion != MinecraftVersion) {
return false;
}
return true;
}
}

View File

@@ -19,8 +19,6 @@
package com.volmit.iris.engine;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.tools.IrisPackBenchmarking;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.mantle.EngineMantle;
@@ -38,6 +36,8 @@ import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.parallel.BurstExecutor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.bukkit.util.BlockVector;
import java.io.File;
@@ -45,10 +45,9 @@ import java.io.IOException;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import static com.volmit.iris.core.tools.IrisPackBenchmarking.benchmark;
import static com.volmit.iris.engine.safeguard.PerformanceSFG.lowPerformance;
@Data
@EqualsAndHashCode(exclude = "engine")
@ToString(exclude = "engine")
public class IrisEngineMantle implements EngineMantle {
private final Engine engine;
private final Mantle mantle;
@@ -286,22 +285,10 @@ public class IrisEngineMantle implements EngineMantle {
x = Math.max(x, c);
x = (Math.max(x, 16) + 16) >> 4;
x = x % 2 == 0 ? x + 1 : x;
if (benchmark){
x = 4;
Iris.info("Mantle Size: " + x + " Chunks " + C.BLUE + "BENCHMARK MODE");
} else {
if(lowPerformance){
x = 4;
Iris.info("Mantle Size: " + x + " Chunks" + C.GOLD + "LOW PERFORMANCE MODE");
} else {
Iris.info("Mantle Size: " + x + " Chunks");
Iris.info(" Object Mantle Size: " + u + " (" + ((Math.max(u, 16) + 16) >> 4) + ")");
Iris.info(" Jigsaw Mantle Size: " + jig + " (" + ((Math.max(jig, 16) + 16) >> 4) + ")");
Iris.info(" Carving Mantle Size: " + c + " (" + ((Math.max(c, 16) + 16) >> 4) + ")");
}
}
Iris.info("Mantle Size: " + x + " Chunks");
Iris.info(" Object Mantle Size: " + u + " (" + ((Math.max(u, 16) + 16) >> 4) + ")");
Iris.info(" Jigsaw Mantle Size: " + jig + " (" + ((Math.max(jig, 16) + 16) >> 4) + ")");
Iris.info(" Carving Mantle Size: " + c + " (" + ((Math.max(c, 16) + 16) >> 4) + ")");
return x;
}

View File

@@ -25,11 +25,15 @@ import com.volmit.iris.engine.scripting.EngineExecutionEnvironment;
import com.volmit.iris.engine.scripting.IrisScriptingAPI;
import com.volmit.iris.util.format.C;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.apache.bsf.BSFException;
import org.apache.bsf.BSFManager;
import org.apache.bsf.engines.javascript.JavaScriptEngine;
@Data
@EqualsAndHashCode(exclude = "engine")
@ToString(exclude = "engine")
public class IrisExecutionEnvironment implements EngineExecutionEnvironment {
private final BSFManager manager;
private final Engine engine;

View File

@@ -21,6 +21,7 @@ package com.volmit.iris.engine.data.chunk;
import com.volmit.iris.core.nms.BiomeBaseInjector;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.util.data.IrisBiomeStorage;
import com.volmit.iris.util.data.IrisBlockData;
import lombok.Setter;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@@ -120,6 +121,8 @@ public class LinkedTerrainChunk implements TerrainChunk {
@Override
public synchronized void setBlock(int x, int y, int z, BlockData blockData) {
if (blockData instanceof IrisBlockData d)
blockData = d.getBase();
rawChunkData.setBlock(x, y, z, blockData);
}

View File

@@ -20,6 +20,7 @@ package com.volmit.iris.engine.data.chunk;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.BiomeBaseInjector;
import com.volmit.iris.util.data.IrisBlockData;
import com.volmit.iris.util.nbt.mca.Chunk;
import com.volmit.iris.util.nbt.mca.NBTWorld;
import lombok.AllArgsConstructor;
@@ -88,6 +89,8 @@ public class MCATerrainChunk implements TerrainChunk {
if (blockData == null) {
Iris.error("NULL BD");
}
if (blockData instanceof IrisBlockData data)
blockData = data.getBase();
mcaChunk.setBlockStateAt(xx, y, zz, NBTWorld.getCompound(blockData), false);
}

View File

@@ -44,7 +44,13 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
if (decorator != null) {
if (!decorator.isStacking()) {
if (height >= 0 || height < getEngine().getHeight()) {
data.set(x, height, z, fixFaces(decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()), realX, height, realZ));
if (null != decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData())) {
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
height--;
data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData()));
} else {
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
}
}
} else {
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());

View File

@@ -40,7 +40,13 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
if (decorator != null) {
if (!decorator.isStacking()) {
if (height >= 0 || height < getEngine().getHeight()) {
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
if (null != decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData())) {
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
height++;
data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData()));
} else {
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
}
}
} else {
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());

View File

@@ -40,7 +40,13 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
if (decorator != null) {
if (!decorator.isStacking()) {
if (height >= 0 || height < getEngine().getHeight()) {
data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
if (null != decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData())) {
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
height++;
data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData()));
} else {
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
}
}
} else {
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());

View File

@@ -46,7 +46,13 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
if (decorator != null) {
if (!decorator.isStacking()) {
data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
if (null != decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData())) {
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
height++;
data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData()));
} else {
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
}
} else {
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
if (decorator.isScaleStack()) {

View File

@@ -22,10 +22,12 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.gui.components.RenderType;
import com.volmit.iris.core.gui.components.Renderer;
import com.volmit.iris.core.link.Identifier;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.core.nms.container.BlockPos;
import com.volmit.iris.core.nms.container.Pair;
import com.volmit.iris.core.service.ExternalDataSVC;
import com.volmit.iris.engine.IrisComplex;
import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.data.chunk.TerrainChunk;
@@ -38,6 +40,7 @@ import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.context.IrisContext;
import com.volmit.iris.util.data.B;
import com.volmit.iris.util.data.DataProvider;
import com.volmit.iris.util.data.IrisBlockData;
import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.documentation.ChunkCoordinates;
import com.volmit.iris.util.format.C;
@@ -254,6 +257,11 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
if (B.isUpdatable(data)) {
getMantle().updateBlock(x, y, z);
}
if (data instanceof IrisBlockData d) {
getMantle().getMantle().set(x, y, z, d.getCustom());
} else {
getMantle().getMantle().remove(x, y, z, Identifier.class);
}
}
void blockUpdatedMetric();
@@ -277,6 +285,11 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
Iris.warn("Failed to set tile entity data at [%d %d %d | %s] for tile %s!", x, betterY, z, c.getBlock(x, betterY, z).getBlockData().getMaterial().getKey(), tile.getData().getTileId());
});
}));
getMantle().getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.CUSTOM, () -> J.s(() -> {
getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), Identifier.class, (x, y, z, v) -> {
Iris.service(ExternalDataSVC.class).processUpdate(this, c.getBlock(x & 15, y + getWorld().minHeight(), z & 15), v);
});
}));
getMantle().getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.UPDATE, () -> J.s(() -> {
PrecisionStopwatch p = PrecisionStopwatch.start();
@@ -523,8 +536,9 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
return getTarget().getBurster();
}
@Deprecated
default void clean() {
burst().lazy(() -> getMantle().trim());
burst().lazy(() -> getMantle().trim(10));
}
@BlockCoordinates
@@ -803,7 +817,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
return getBiomeOrMantle(l.getBlockX(), l.getBlockY(), l.getBlockZ());
}
default void gotoBiome(IrisBiome biome, Player player) {
default void gotoBiome(IrisBiome biome, Player player, boolean teleport) {
Set<String> regionKeys = getDimension()
.getAllRegions(this).stream()
.filter((i) -> i.getAllBiomes(this).contains(biome))
@@ -815,13 +829,13 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
&& lb.matches(engine, chunk);
if (!regionKeys.isEmpty()) {
locator.find(player);
locator.find(player, teleport, "Biome " + biome.getName());
} else {
player.sendMessage(C.RED + biome.getName() + " is not in any defined regions!");
}
}
default void gotoJigsaw(IrisJigsawStructure s, Player player) {
default void gotoJigsaw(IrisJigsawStructure s, Player player, boolean teleport) {
if (s.getLoadKey().equals(getDimension().getStronghold())) {
KList<Position2> p = getDimension().getStrongholds(getSeedManager().getSpawn());
@@ -858,7 +872,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
if (getDimension().getJigsawStructures().stream()
.map(IrisJigsawStructurePlacement::getStructure)
.collect(Collectors.toSet()).contains(s.getLoadKey())) {
Locator.jigsawStructure(s.getLoadKey()).find(player);
Locator.jigsawStructure(s.getLoadKey()).find(player, teleport, "Structure " + s.getLoadKey());
} else {
Set<String> biomeKeys = getDimension().getAllBiomes(this).stream()
.filter((i) -> i.getJigsawStructures()
@@ -885,7 +899,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
};
if (!regionKeys.isEmpty()) {
locator.find(player);
locator.find(player, teleport, "Structure " + s.getLoadKey());
} else {
player.sendMessage(C.RED + s.getLoadKey() + " is not in any defined regions, biomes or dimensions!");
}
@@ -893,7 +907,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
}
default void gotoObject(String s, Player player) {
default void gotoObject(String s, Player player, boolean teleport) {
Set<String> biomeKeys = getDimension().getAllBiomes(this).stream()
.filter((i) -> i.getObjects().stream().anyMatch((f) -> f.getPlace().contains(s)))
.map(IrisRegistrant::getLoadKey)
@@ -916,23 +930,23 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
};
if (!regionKeys.isEmpty()) {
locator.find(player);
locator.find(player, teleport, "Object " + s);
} else {
player.sendMessage(C.RED + s + " is not in any defined regions or biomes!");
}
}
default void gotoRegion(IrisRegion r, Player player) {
default void gotoRegion(IrisRegion r, Player player, boolean teleport) {
if (!getDimension().getAllRegions(this).contains(r)) {
player.sendMessage(C.RED + r.getName() + " is not defined in the dimension!");
return;
}
Locator.region(r.getLoadKey()).find(player);
Locator.region(r.getLoadKey()).find(player, teleport, "Region " + r.getName());
}
default void gotoPOI(String type, Player p) {
Locator.poi(type).find(p);
default void gotoPOI(String type, Player p, boolean teleport) {
Locator.poi(type).find(p, teleport, "POI " + type);
}
default void cleanupMantleChunk(int x, int z) {

View File

@@ -21,8 +21,12 @@ package com.volmit.iris.engine.framework;
import com.volmit.iris.Iris;
import com.volmit.iris.util.math.RollingSequence;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
@EqualsAndHashCode(exclude = "engine")
@ToString(exclude = "engine")
public class EngineAssignedComponent implements EngineComponent {
private final Engine engine;
private final RollingSequence metrics;

View File

@@ -23,8 +23,12 @@ import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisWorld;
import com.volmit.iris.util.parallel.MultiBurst;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
@EqualsAndHashCode(exclude = "data")
@ToString(exclude = "data")
public class EngineTarget {
private final MultiBurst burster;
private final IrisData data;

View File

@@ -27,6 +27,7 @@ import com.volmit.iris.engine.object.IrisJigsawStructure;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.context.ChunkContext;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.Position2;
@@ -39,6 +40,7 @@ import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import com.volmit.iris.util.scheduling.jobs.SingleJob;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import java.util.Set;
@@ -109,23 +111,35 @@ public interface Locator<T> {
boolean matches(Engine engine, Position2 chunk);
default void find(Player player) {
find(player, 30_000);
default void find(Player player, boolean teleport, String message) {
find(player, location -> {
if (teleport) {
J.s(() -> player.teleport(location));
} else {
player.sendMessage(C.GREEN + message + " at: " + location.getBlockX() + " " + location.getBlockY() + " " + location.getBlockZ());
}
});
}
default void find(Player player, long timeout) {
default void find(Player player, Consumer<Location> consumer) {
find(player, 30_000, consumer);
}
default void find(Player player, long timeout, Consumer<Location> consumer) {
AtomicLong checks = new AtomicLong();
long ms = M.ms();
new SingleJob("Searching", () -> {
try {
Position2 at = find(IrisToolbelt.access(player.getWorld()).getEngine(), new Position2(player.getLocation().getBlockX() >> 4, player.getLocation().getBlockZ() >> 4), timeout, checks::set).get();
World world = player.getWorld();
Engine engine = IrisToolbelt.access(world).getEngine();
Position2 at = find(engine, new Position2(player.getLocation().getBlockX() >> 4, player.getLocation().getBlockZ() >> 4), timeout, checks::set).get();
if (at != null) {
J.s(() -> player.teleport(new Location(player.getWorld(), (at.getX() << 4) + 8,
IrisToolbelt.access(player.getWorld()).getEngine().getHeight(
consumer.accept(new Location(world, (at.getX() << 4) + 8,
engine.getHeight(
(at.getX() << 4) + 8,
(at.getZ() << 4) + 8, false),
(at.getZ() << 4) + 8)));
(at.getZ() << 4) + 8));
}
} catch (WrongEngineBroException | InterruptedException | ExecutionException e) {
e.printStackTrace();

View File

@@ -60,7 +60,7 @@ public class HeightmapObjectPlacer implements IObjectPlacer {
@Override
public boolean isCarved(int x, int y, int z) {
return false;
return oplacer.isCarved(x,y,z);
}
public boolean isSolid(int param1Int1, int param1Int2, int param1Int3) {

View File

@@ -18,6 +18,7 @@
package com.volmit.iris.engine.jigsaw;
import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
@@ -38,6 +39,9 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.util.BlockVector;
import java.util.ArrayList;
import java.util.List;
@SuppressWarnings("ALL")
@Data
public class PlannedPiece {
@@ -72,6 +76,7 @@ public class PlannedPiece {
this.object.setLoadKey(piece.getObject());
this.ogObject.setLoadKey(piece.getObject());
this.connected = new KList<>();
}
public void setPosition(IrisPosition p) {
@@ -133,10 +138,29 @@ public class PlannedPiece {
return getWorldPosition(c.getPosition());
}
public List<IrisPosition> getConnectorWorldPositions() {
List<IrisPosition> worldPositions = new ArrayList<>();
for (IrisJigsawPieceConnector connector : this.piece.getConnectors()) {
IrisPosition worldPosition = getWorldPosition(connector.getPosition());
worldPositions.add(worldPosition);
}
return worldPositions;
}
public IrisPosition getWorldPosition(IrisPosition position) {
return this.position.add(position).add(new IrisPosition(object.getCenter()));
}
public void debugPrintConnectorPositions() {
Iris.debug("Connector World Positions for PlannedPiece at " + position + ":");
List<IrisPosition> connectorPositions = getConnectorWorldPositions();
for (IrisPosition pos : connectorPositions) {
Iris.debug(" - Connector at: " + pos);
}
}
public boolean isFull() {
return connected.size() >= piece.getConnectors().size() || isDead();
}

View File

@@ -28,7 +28,6 @@ import com.volmit.iris.engine.object.*;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.matter.slices.JigsawPieceMatter;
import com.volmit.iris.util.matter.slices.container.JigsawPieceContainer;
import lombok.Data;
import org.bukkit.Axis;
@@ -75,7 +74,7 @@ public class PlannedStructure {
}
}
public void place(MantleWriter placer, Mantle e, Engine eng) {
public void place(IObjectPlacer placer, Mantle e, Engine eng) {
IrisObjectPlacement options = new IrisObjectPlacement();
options.getRotation().setEnabled(false);
int startHeight = pieces.get(0).getPosition().getY();
@@ -85,7 +84,7 @@ public class PlannedStructure {
}
}
public void place(PlannedPiece i, int startHeight, IrisObjectPlacement o, MantleWriter placer, Mantle e, Engine eng) {
public void place(PlannedPiece i, int startHeight, IrisObjectPlacement o, IObjectPlacer placer, Mantle e, Engine eng) {
IrisObjectPlacement options = o;
if (i.getPiece().getPlacementOptions() != null) {
@@ -101,7 +100,7 @@ public class PlannedStructure {
int sz = (v.getD() / 2);
int xx = i.getPosition().getX() + sx;
int zz = i.getPosition().getZ() + sz;
RNG rng = new RNG(Cache.key(xx, zz));
RNG rngf = new RNG(Cache.key(xx, zz));
int offset = i.getPosition().getY() - startHeight;
int height;
@@ -123,69 +122,10 @@ public class PlannedStructure {
int id = rng.i(0, Integer.MAX_VALUE);
JigsawPieceContainer container = JigsawPieceContainer.toContainer(i.getPiece());
vo.place(xx, height, zz, new IObjectPlacer() {
@Override
public int getHighest(int x, int z, IrisData data) {
return placer.getHighest(x, z, data);
}
@Override
public int getHighest(int x, int z, IrisData data, boolean ignoreFluid) {
return placer.getHighest(x, z, data, ignoreFluid);
}
@Override
public void set(int x, int y, int z, BlockData d) {
placer.setData(x, y, z, container);
placer.set(x, y, z, d);
}
@Override
public BlockData get(int x, int y, int z) {
placer.setData(x, y, z, container);
return placer.get(x, y, z);
}
@Override
public boolean isPreventingDecay() {
return placer.isPreventingDecay();
}
@Override
public boolean isCarved(int x, int y, int z) {
return placer.isCarved(x, y, z);
}
@Override
public boolean isSolid(int x, int y, int z) {
return placer.isSolid(x, y, z);
}
@Override
public boolean isUnderwater(int x, int z) {
return placer.isUnderwater(x, z);
}
@Override
public int getFluidHeight() {
return placer.getFluidHeight();
}
@Override
public boolean isDebugSmartBore() {
return placer.isDebugSmartBore();
}
@Override
public void setTile(int xx, int yy, int zz, TileData<? extends TileState> tile) {
placer.setTile(xx, yy, zz, tile);
}
@Override
public Engine getEngine() {
return placer.getEngine();
}
}, options, rng, (b, data) -> e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id), null, getData());
vo.place(xx, height, zz, placer, options, rng, (b, data) -> {
e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id);
e.set(b.getX(), b.getY(), b.getZ(), container);
}, null, getData());
}
public void place(World world) {
@@ -208,6 +148,7 @@ public class PlannedStructure {
for (IrisJigsawPieceConnector i : piece.getAvailableConnectors().shuffleCopy(rng)) {
if (generateConnectorOutwards(piece, i)) {
b = true;
piece.debugPrintConnectorPositions();
}
}
@@ -360,10 +301,6 @@ public class PlannedStructure {
public boolean collidesWith(PlannedPiece piece, PlannedPiece ignore) {
for (PlannedPiece i : pieces) {
if (i.equals(ignore)) {
continue;
}
if (i.collidesWith(piece)) {
return true;
}

View File

@@ -23,6 +23,7 @@ import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.IrisComplex;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineTarget;
import com.volmit.iris.engine.framework.SeedManager;
import com.volmit.iris.engine.mantle.components.MantleJigsawComponent;
import com.volmit.iris.engine.mantle.components.MantleObjectComponent;
import com.volmit.iris.engine.object.IObjectPlacer;
@@ -143,8 +144,8 @@ public interface EngineMantle extends IObjectPlacer {
return getEngine().getDimension().isDebugSmartBore();
}
default void trim(long dur) {
getMantle().trim(dur);
default void trim(long dur, int limit) {
getMantle().trim(dur, limit);
}
default IrisData getData() {
@@ -175,8 +176,11 @@ public interface EngineMantle extends IObjectPlacer {
}
default void trim() {
getMantle().trim(TimeUnit.SECONDS.toMillis(IrisSettings.get().getPerformance().getMantleKeepAlive()));
default void trim(int limit) {
getMantle().trim(TimeUnit.SECONDS.toMillis(IrisSettings.get().getPerformance().getMantleKeepAlive()), limit);
}
default int unloadTectonicPlate(int tectonicLimit){
return getMantle().unloadTectonicPlate(tectonicLimit);
}
default MultiBurst burst() {
@@ -257,6 +261,9 @@ public interface EngineMantle extends IObjectPlacer {
default int getLoadedRegionCount() {
return getMantle().getLoadedRegionCount();
}
default long getLastUseMapMemoryUsage(){
return getMantle().LastUseMapMemoryUsage();
}
MantleJigsawComponent getJigsawComponent();
@@ -288,4 +295,14 @@ public interface EngineMantle extends IObjectPlacer {
});
}
}
}
default long getToUnload(){
return getMantle().getToUnload().size();
}
default long getNotQueuedLoadedRegions(){
return getMantle().getLoadedRegions().size() - getMantle().getToUnload().size();
}
default double getTectonicDuration(){
return getMantle().getAdjustedIdleDuration().get();
}
}

View File

@@ -20,8 +20,12 @@ package com.volmit.iris.engine.mantle;
import com.volmit.iris.util.mantle.MantleFlag;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
@EqualsAndHashCode(exclude = "engineMantle")
@ToString(exclude = "engineMantle")
public abstract class IrisMantleComponent implements MantleComponent {
private final EngineMantle engineMantle;
private final MantleFlag flag;

View File

@@ -23,6 +23,7 @@ import com.volmit.iris.engine.mantle.EngineMantle;
import com.volmit.iris.engine.mantle.IrisMantleComponent;
import com.volmit.iris.engine.mantle.MantleWriter;
import com.volmit.iris.engine.object.*;
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.ChunkCoordinates;
@@ -53,8 +54,6 @@ public class MantleJigsawComponent extends IrisMantleComponent {
@ChunkCoordinates
private void generateJigsaw(MantleWriter writer, RNG rng, int x, int z, IrisBiome biome, IrisRegion region) {
boolean placed = false;
if (getDimension().getStronghold() != null) {
List<Position2> poss = getDimension().getStrongholds(seed());
@@ -63,47 +62,36 @@ public class MantleJigsawComponent extends IrisMantleComponent {
if (x == pos.getX() >> 4 && z == pos.getZ() >> 4) {
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(getDimension().getStronghold());
place(writer, pos.toIris(), structure, rng);
placed = true;
return;
}
}
}
}
if (!placed) {
for (IrisJigsawStructurePlacement i : biome.getJigsawStructures()) {
if (rng.nextInt(i.getRarity()) == 0) {
IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15));
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure());
place(writer, position, structure, rng);
placed = true;
}
}
}
boolean placed = placeStructures(writer, rng, x, z, biome.getJigsawStructures());
if (!placed)
placed = placeStructures(writer, rng, x, z, region.getJigsawStructures());
if (!placed)
placeStructures(writer, rng, x, z, getDimension().getJigsawStructures());
}
if (!placed) {
for (IrisJigsawStructurePlacement i : region.getJigsawStructures()) {
if (rng.nextInt(i.getRarity()) == 0) {
IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15));
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure());
place(writer, position, structure, rng);
placed = true;
}
}
}
if (!placed) {
for (IrisJigsawStructurePlacement i : getDimension().getJigsawStructures()) {
if (rng.nextInt(i.getRarity()) == 0) {
IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15));
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure());
place(writer, position, structure, rng);
}
@ChunkCoordinates
private boolean placeStructures(MantleWriter writer, RNG rng, int x, int z, KList<IrisJigsawStructurePlacement> structures) {
for (IrisJigsawStructurePlacement i : structures) {
if (rng.nextInt(i.getRarity()) == 0) {
IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15));
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure());
place(writer, position, structure, rng);
return true;
}
}
return false;
}
@ChunkCoordinates
public IrisJigsawStructure guess(int x, int z) {
// todo The guess doesnt bring into account that the placer may return -1
boolean t = false;
RNG rng = new RNG(cng.fit(-Integer.MAX_VALUE, Integer.MAX_VALUE, x, z));
IrisBiome biome = getEngineMantle().getEngine().getSurfaceBiome((x << 4) + 8, (z << 4) + 8);
IrisRegion region = getEngineMantle().getEngine().getRegion((x << 4) + 8, (z << 4) + 8);

View File

@@ -123,6 +123,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
}
public Set<String> guess(int x, int z) {
// todo The guess doesnt bring into account that the placer may return -1
RNG rng = applyNoise(x, z, Cache.key(x, z) + seed());
IrisBiome biome = getEngineMantle().getEngine().getSurfaceBiome((x << 4) + 8, (z << 4) + 8);
IrisRegion region = getEngineMantle().getEngine().getRegion((x << 4) + 8, (z << 4) + 8);

View File

@@ -18,6 +18,7 @@
package com.volmit.iris.engine.object;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.util.data.DataProvider;
@@ -69,6 +70,17 @@ public class IrisBiomeGeneratorLink {
double g = getCachedGenerator(xg).getHeight(x, z, seed);
g = g < 0 ? 0 : g;
g = g > 1 ? 1 : g;
// if (IrisSettings.get().getGenerator().forceConvertTo320Height) {
// if (max > 320 || min > 320) {
// double scaleFactor = 320.0 / Math.max(max, min);
// min *= (int) scaleFactor;
// max *= (int) scaleFactor;
// if (min < 0) {
//
// }
// }
// }
// todo This
return IrisInterpolation.lerp(min, max, g);
}

View File

@@ -82,13 +82,17 @@ public class IrisCavePlacer implements IRare {
}
if (y == -1) {
int h = (int) caveStartHeight.get(rng, x, z, data);
int ma = breakSurface ? h : (int) (engine.getComplex().getHeightStream().get(x, z) - 9);
y = Math.min(h, ma);
if(!breakSurface) {
int eH = engine.getHeight(x, z);
if (caveStartHeight.getMax() > eH) {
caveStartHeight.setMax(eH);
}
}
y = (int) caveStartHeight.get(rng, x, z, data);
}
try {
cave.generate(mantle, rng, engine, x + rng.nextInt(15), y, z + rng.nextInt(15), waterHint);
cave.generate(mantle, rng, engine, x + rng.nextInt(15), y, z + rng.nextInt(15), waterHint);
} catch (Throwable e) {
e.printStackTrace();
fail.set(true);

View File

@@ -234,7 +234,7 @@ public class IrisCompat {
filters.add(new IrisCompatabilityBlockFilter("ACACIA_WALL_SIGN", "LEGACY_WALL_SIGN"));
filters.add(new IrisCompatabilityBlockFilter("ACACIA_SIGN", "LEGACY_SIGN_POST"));
filters.add(new IrisCompatabilityBlockFilter("SCAFFOLDING", "BIRCH_FENCE"));
filters.add(new IrisCompatabilityBlockFilter("LOOM", "LOOM"));
//filters.add(new IrisCompatabilityBlockFilter("LOOM", "LOOM"));
filters.add(new IrisCompatabilityBlockFilter("LECTERN", "BOOKSHELF"));
filters.add(new IrisCompatabilityBlockFilter("LANTERN", "REDSTONE_LAMP"));
filters.add(new IrisCompatabilityBlockFilter("JIGSAW", "AIR"));
@@ -254,6 +254,7 @@ public class IrisCompat {
filters.add(new IrisCompatabilityBlockFilter("BAMBOO", "BIRCH_FENCE"));
filters.add(new IrisCompatabilityBlockFilter("BAMBOO_SAPLING", "BIRCH_SAPLING"));
filters.add(new IrisCompatabilityBlockFilter("POTTED_BAMBOO", "POTTED_BIRCH_SAPLING"));
filters.add(new IrisCompatabilityBlockFilter("GRASS", "SHORT_GRASS"));
return filters;
}
@@ -262,7 +263,7 @@ public class IrisCompat {
String buf = n;
int err = 16;
BlockData tx = B.getOrNull(buf);
BlockData tx = B.getOrNull(buf, false);
if (tx != null) {
return tx;
@@ -271,11 +272,19 @@ public class IrisCompat {
searching:
while (true) {
if (err-- <= 0) {
return B.get("STONE");
Iris.error("Can't find block data for " + n);
return B.getNoCompat("STONE");
}
String m = buf;
if (m.contains("[")) {
m = m.split("\\Q[\\E")[0];
}
if (m.contains(":")) {
m = m.split("\\Q:\\E", 2)[1];
}
for (IrisCompatabilityBlockFilter i : blockFilters) {
if (i.getWhen().equalsIgnoreCase(buf)) {
if (i.getWhen().equalsIgnoreCase(i.isExact() ? buf : m)) {
BlockData b = i.getReplace();
if (b != null) {
@@ -287,7 +296,8 @@ public class IrisCompat {
}
}
return B.get("STONE");
Iris.error("Can't find block data for " + n);
return B.getNoCompat("STONE");
}
}
@@ -330,7 +340,7 @@ public class IrisCompat {
}
buf = n;
BlockData tx = B.getOrNull(buf);
BlockData tx = B.getOrNull(buf, false);
if (tx != null) {
return tx.getMaterial();

View File

@@ -57,13 +57,13 @@ public class IrisCompatabilityBlockFilter {
public BlockData getReplace() {
return replaceData.aquire(() ->
{
BlockData b = B.getOrNull(supplement);
BlockData b = B.getOrNull(supplement, false);
if (b == null) {
return null;
}
Iris.warn("Compat: Using " + supplement + " in place of " + when + " since this server doesnt support '" + supplement + "'");
Iris.warn("Compat: Using '%s' in place of '%s' since this server doesnt support '%s'", supplement, when, when);
return b;
});

View File

@@ -22,9 +22,11 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.DataProvider;
import com.volmit.iris.util.data.Dimension;
import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.json.JSONObject;
import com.volmit.iris.util.math.Position2;
@@ -40,6 +42,7 @@ import org.bukkit.Material;
import org.bukkit.World.Environment;
import org.bukkit.block.data.BlockData;
import java.io.DataInput;
import java.io.File;
import java.io.IOException;
@@ -439,7 +442,7 @@ public class IrisDimension extends IrisRegistrant {
return landBiomeStyle;
}
public boolean installDataPack(DataProvider data, File datapacks) {
public boolean installDataPack(DataProvider data, File datapacks, double ultimateMaxHeight, double ultimateMinHeight) {
boolean write = false;
boolean changed = false;
@@ -470,6 +473,8 @@ public class IrisDimension extends IrisRegistrant {
if (!dimensionHeight.equals(new IrisRange(-64, 320)) && this.name.equalsIgnoreCase("overworld")) {
Iris.verbose(" Installing Data Pack Dimension Types: \"minecraft:overworld\", \"minecraft:the_nether\", \"minecraft:the_end\"");
dimensionHeight.setMax(ultimateMaxHeight);
dimensionHeight.setMin(ultimateMinHeight);
changed = writeDimensionType(changed, datapacks);
}

View File

@@ -24,11 +24,36 @@ import lombok.Data;
public class IrisEngineStatistics {
private int totalHotloads = 0;
private int chunksGenerated = 0;
private int IrisToUpgradedVersion = 0;
private int IrisCreationVersion = 0;
private int MinecraftVersion = 0;
public void generatedChunk() {
chunksGenerated++;
}
public void setUpgradedVersion(int i) {
IrisToUpgradedVersion = i;
}
public int getUpgradedVersion() {
return IrisToUpgradedVersion;
}
public void setVersion(int i) {
IrisCreationVersion = i;
}
public int getVersion() {
return IrisCreationVersion;
}
public void setMCVersion(int i) {
MinecraftVersion = i;
}
public int getMCVersion() {
return MinecraftVersion;
}
public void hotloaded() {
totalHotloads++;
}

View File

@@ -21,6 +21,7 @@ package com.volmit.iris.engine.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.util.collection.KList;
@@ -41,6 +42,7 @@ import org.bukkit.*;
import org.bukkit.attribute.Attributable;
import org.bukkit.entity.*;
import org.bukkit.entity.Panda.Gene;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.loot.LootContext;
@@ -67,6 +69,9 @@ public class IrisEntity extends IrisRegistrant {
@Desc("The type of entity to spawn. To spawn a mythic mob, set this type to unknown and define mythic type.")
private EntityType type = EntityType.UNKNOWN;
@Desc("The SpawnReason to spawn the entity with.")
private CreatureSpawnEvent.SpawnReason reason = CreatureSpawnEvent.SpawnReason.NATURAL;
@Desc("The custom name of this entity")
private String customName = "";
@@ -457,7 +462,7 @@ public class IrisEntity extends IrisRegistrant {
}
return at.getWorld().spawnEntity(at, getType());
return INMS.get().spawnEntity(at, getType(), getReason());
}
public boolean isCitizens() {

View File

@@ -19,21 +19,28 @@
package com.volmit.iris.engine.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.math.Vector3d;
import com.volmit.iris.util.matter.MatterMarker;
import com.volmit.iris.util.matter.slices.MarkerMatter;
import io.lumine.mythic.bukkit.adapters.BukkitEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.BoundingBox;
@Snippet("entity-spawn")
@Accessors(chain = true)
@@ -165,12 +172,19 @@ public class IrisEntitySpawn implements IRare {
return null;
}
Entity e = irisEntity.spawn(g, at.add(0.5, 0, 0.5), rng.aquire(() -> new RNG(g.getSeedManager().getEntity())));
Vector3d boundingBox = INMS.get().getBoundingbox(irisEntity.getType());
if (!ignoreSurfaces && boundingBox != null) {
boolean isClearForSpawn = isAreaClearForSpawn(at, boundingBox);
if (!isClearForSpawn) {
return null;
}
}
Entity e = irisEntity.spawn(g, at.add(0.5, 0.5, 0.5), rng.aquire(() -> new RNG(g.getSeedManager().getEntity())));
if (e != null) {
Iris.debug("Spawned " + C.DARK_AQUA + "Entity<" + getEntity() + "> " + C.GREEN + e.getType() + C.LIGHT_PURPLE + " @ " + C.GRAY + e.getLocation().getX() + ", " + e.getLocation().getY() + ", " + e.getLocation().getZ());
}
return e;
} catch (Throwable e) {
Iris.reportError(e);
@@ -179,4 +193,25 @@ public class IrisEntitySpawn implements IRare {
return null;
}
}
private boolean isAreaClearForSpawn(Location center, Vector3d boundingBox) {
World world = center.getWorld();
int startX = center.getBlockX() - (int) (boundingBox.x / 2);
int endX = center.getBlockX() + (int) (boundingBox.x / 2);
int startY = center.getBlockY();
int endY = center.getBlockY() + (int) boundingBox.y;
int startZ = center.getBlockZ() - (int) (boundingBox.z / 2);
int endZ = center.getBlockZ() + (int) (boundingBox.z / 2);
for (int x = startX; x <= endX; x++) {
for (int y = startY; y <= endY; y++) {
for (int z = startZ; z <= endZ; z++) {
if (world.getBlockAt(x, y, z).getType() != Material.AIR) {
return false;
}
}
}
}
return true;
}
}

View File

@@ -23,11 +23,13 @@ import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.PlacedObject;
import com.volmit.iris.engine.framework.placer.HeightmapObjectPlacer;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.context.IrisContext;
import com.volmit.iris.util.data.B;
import com.volmit.iris.util.data.IrisBlockData;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.interpolation.IrisInterpolation;
import com.volmit.iris.util.json.JSONObject;
@@ -505,6 +507,13 @@ public class IrisObject extends IrisRegistrant {
return -1;
}
// if (config.getCarvingSupport().supportsSurface()) {
// int y = placer.getHighest(x, z, rdata);
// if (placer.isCarved(x, y, z)) {
// return -1;
// }
// }
// Rotation calculation
int slopeRotationY = 0;
ProceduralStream<Double> heightStream = rdata.getEngine().getComplex().getHeightStream();
@@ -691,15 +700,18 @@ public class IrisObject extends IrisRegistrant {
if (!config.getAllowedCollisions().isEmpty() || !config.getForbiddenCollisions().isEmpty()) {
Engine engine = rdata.getEngine();
String key;
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
for (int i = x - Math.floorDiv(w, 2) + (int) offset.getX(); i <= x + Math.floorDiv(w, 2) - (w % 2 == 0 ? 1 : 0) + (int) offset.getX(); i++) {
for (int j = y - Math.floorDiv(h, 2) + (int) offset.getY(); j <= y + Math.floorDiv(h, 2) - (h % 2 == 0 ? 1 : 0) + (int) offset.getY(); j++) {
for (int k = z - Math.floorDiv(d, 2) + (int) offset.getZ(); k <= z + Math.floorDiv(d, 2) - (d % 2 == 0 ? 1 : 0) + (int) offset.getX(); k++) {
key = engine.getObjectPlacementKey(i, j, k);
PlacedObject p = engine.getObjectPlacement(i, j, k);
if (p == null) continue;
IrisObject o = p.getObject();
if (o == null) continue;
String key = o.getLoadKey();
if (key != null) {
if (config.getForbiddenCollisions().contains(key) && !config.getAllowedCollisions().contains(key)) {
Iris.warn("%s collides with %s (%s / %s / %s)", getLoadKey(), key, i, j, k);
// Iris.debug("%s collides with %s (%s / %s / %s)", getLoadKey(), key, i, j, k);
return -1;
}
}
@@ -800,7 +812,7 @@ public class IrisObject extends IrisRegistrant {
if (j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) {
BlockData newData = j.getReplace(rng, i.getX() + x, i.getY() + y, i.getZ() + z, rdata).clone();
if (newData.getMaterial() == data.getMaterial())
if (newData.getMaterial() == data.getMaterial() && !(newData instanceof IrisBlockData || data instanceof IrisBlockData))
data = data.merge(newData);
else
data = newData;

View File

@@ -1,413 +1,432 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.platform;
import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.engine.IrisEngine;
import com.volmit.iris.engine.data.chunk.TerrainChunk;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineTarget;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisWorld;
import com.volmit.iris.engine.object.StudioMode;
import com.volmit.iris.engine.platform.studio.StudioGenerator;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.IrisBiomeStorage;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.hunk.view.BiomeGridHunkHolder;
import com.volmit.iris.util.hunk.view.ChunkDataHunkHolder;
import com.volmit.iris.util.io.ReactiveFolder;
import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.Looper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Setter;
import org.bukkit.*;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.generator.BiomeProvider;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.generator.WorldInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Consumer;
@EqualsAndHashCode(callSuper = true)
@Data
public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChunkGenerator, Listener {
private static final int LOAD_LOCKS = Runtime.getRuntime().availableProcessors() * 4;
private final Semaphore loadLock;
private final IrisWorld world;
private final File dataLocation;
private final String dimensionKey;
private final ReactiveFolder folder;
private final ReentrantLock lock = new ReentrantLock();
private final KList<BlockPopulator> populators;
private final ChronoLatch hotloadChecker;
private final AtomicBoolean setup;
private final boolean studio;
private final AtomicInteger a = new AtomicInteger(0);
private Engine engine;
private Looper hotloader;
private StudioMode lastMode;
private DummyBiomeProvider dummyBiomeProvider;
@Setter
private StudioGenerator studioGenerator;
private boolean initialized = false;
public BukkitChunkGenerator(IrisWorld world, boolean studio, File dataLocation, String dimensionKey) {
setup = new AtomicBoolean(false);
studioGenerator = null;
dummyBiomeProvider = new DummyBiomeProvider();
populators = new KList<>();
loadLock = new Semaphore(LOAD_LOCKS);
this.world = world;
this.hotloadChecker = new ChronoLatch(1000, false);
this.studio = studio;
this.dataLocation = dataLocation;
this.dimensionKey = dimensionKey;
this.folder = new ReactiveFolder(dataLocation, (_a, _b, _c) -> hotload());
Bukkit.getServer().getPluginManager().registerEvents(this, Iris.instance);
}
private static Field getField(Class clazz, String fieldName)
throws NoSuchFieldException {
try {
return clazz.getDeclaredField(fieldName);
} catch (NoSuchFieldException e) {
Class superClass = clazz.getSuperclass();
if (superClass == null) {
throw e;
} else {
return getField(superClass, fieldName);
}
}
}
@EventHandler
public void onWorldInit(WorldInitEvent event) {
try {
if (!initialized) {
world.setRawWorldSeed(event.getWorld().getSeed());
if (world.name().equals(event.getWorld().getName())) {
INMS.get().inject(event.getWorld().getSeed(), getEngine(event.getWorld()), event.getWorld());
Iris.info("Injected Iris Biome Source into " + event.getWorld().getName());
initialized = true;
}
}
} catch (Throwable e) {
e.printStackTrace();
}
}
private void setupEngine() {
IrisData data = IrisData.get(dataLocation);
IrisDimension dimension = data.getDimensionLoader().load(dimensionKey);
if (dimension == null) {
Iris.error("Oh No! There's no pack in " + data.getDataFolder().getPath() + " or... there's no dimension for the key " + dimensionKey);
IrisDimension test = IrisData.loadAnyDimension(dimensionKey);
if (test != null) {
Iris.warn("Looks like " + dimensionKey + " exists in " + test.getLoadFile().getPath() + " ");
Iris.service(StudioSVC.class).installIntoWorld(Iris.getSender(), dimensionKey, dataLocation.getParentFile().getParentFile());
Iris.warn("Attempted to install into " + data.getDataFolder().getPath());
data.dump();
data.clearLists();
test = data.getDimensionLoader().load(dimensionKey);
if (test != null) {
Iris.success("Woo! Patched the Engine!");
dimension = test;
} else {
Iris.error("Failed to patch dimension!");
throw new RuntimeException("Missing Dimension: " + dimensionKey);
}
} else {
Iris.error("Nope, you don't have an installation containing " + dimensionKey + " try downloading it?");
throw new RuntimeException("Missing Dimension: " + dimensionKey);
}
}
lastMode = StudioMode.NORMAL;
engine = new IrisEngine(new EngineTarget(world, dimension, data), studio);
populators.clear();
}
@Override
public void injectChunkReplacement(World world, int x, int z, Consumer<Runnable> jobs) {
try {
loadLock.acquire();
IrisBiomeStorage st = new IrisBiomeStorage();
TerrainChunk tc = TerrainChunk.createUnsafe(world, st);
Hunk<BlockData> blocks = Hunk.view(tc);
Hunk<Biome> biomes = Hunk.view(tc, tc.getMinHeight(), tc.getMaxHeight());
this.world.bind(world);
getEngine().generate(x << 4, z << 4, blocks, biomes, true);
Iris.debug("Regenerated " + x + " " + z);
int t = 0;
for (int i = getEngine().getHeight() >> 4; i >= 0; i--) {
if (!world.isChunkLoaded(x, z)) {
continue;
}
Chunk c = world.getChunkAt(x, z);
for (Entity ee : c.getEntities()) {
if (ee instanceof Player) {
continue;
}
J.s(ee::remove);
}
J.s(() -> engine.getWorldManager().onChunkLoad(c, false));
int finalI = i;
jobs.accept(() -> {
for (int xx = 0; xx < 16; xx++) {
for (int yy = 0; yy < 16; yy++) {
for (int zz = 0; zz < 16; zz++) {
if (yy + (finalI << 4) >= engine.getHeight() || yy + (finalI << 4) < 0) {
continue;
}
c.getBlock(xx, yy + (finalI << 4) + world.getMinHeight(), zz)
.setBlockData(tc.getBlockData(xx, yy + (finalI << 4) + world.getMinHeight(), zz), false);
}
}
}
});
}
loadLock.release();
} catch (Throwable e) {
loadLock.release();
Iris.error("======================================");
e.printStackTrace();
Iris.reportErrorChunk(x, z, e, "CHUNK");
Iris.error("======================================");
ChunkData d = Bukkit.createChunkData(world);
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
d.setBlock(i, 0, j, Material.RED_GLAZED_TERRACOTTA.createBlockData());
}
}
}
}
private Engine getEngine(WorldInfo world) {
if (setup.get()) {
return getEngine();
}
lock.lock();
if (setup.get()) {
return getEngine();
}
setup.set(true);
getWorld().setRawWorldSeed(world.getSeed());
setupEngine();
this.hotloader = studio ? new Looper() {
@Override
protected long loop() {
if (hotloadChecker.flip()) {
folder.check();
}
return 250;
}
} : null;
if (studio) {
hotloader.setPriority(Thread.MIN_PRIORITY);
hotloader.start();
hotloader.setName(getTarget().getWorld().name() + " Hotloader");
}
lock.unlock();
return engine;
}
@Override
public void close() {
withExclusiveControl(() -> {
if (isStudio()) {
hotloader.interrupt();
}
getEngine().close();
folder.clear();
populators.clear();
});
}
@Override
public boolean isStudio() {
return studio;
}
@Override
public void hotload() {
if (!isStudio()) {
return;
}
withExclusiveControl(() -> getEngine().hotload());
}
public void withExclusiveControl(Runnable r) {
J.a(() -> {
try {
loadLock.acquire(LOAD_LOCKS);
r.run();
loadLock.release(LOAD_LOCKS);
} catch (Throwable e) {
Iris.reportError(e);
}
});
}
@Override
public void touch(World world) {
getEngine(world);
}
@Override
public void generateNoise(@NotNull WorldInfo world, @NotNull Random random, int x, int z, @NotNull ChunkGenerator.ChunkData d) {
try {
getEngine(world);
computeStudioGenerator();
TerrainChunk tc = TerrainChunk.create(d, new IrisBiomeStorage());
this.world.bind(world);
if (studioGenerator != null) {
studioGenerator.generateChunk(getEngine(), tc, x, z);
} else {
ChunkDataHunkHolder blocks = new ChunkDataHunkHolder(tc);
BiomeGridHunkHolder biomes = new BiomeGridHunkHolder(tc, tc.getMinHeight(), tc.getMaxHeight());
getEngine().generate(x << 4, z << 4, blocks, biomes, false);
blocks.apply();
biomes.apply();
}
Iris.debug("Generated " + x + " " + z);
} catch (Throwable e) {
Iris.error("======================================");
e.printStackTrace();
Iris.reportErrorChunk(x, z, e, "CHUNK");
Iris.error("======================================");
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
d.setBlock(i, 0, j, Material.RED_GLAZED_TERRACOTTA.createBlockData());
}
}
}
}
@Override
public int getBaseHeight(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull HeightMap heightMap) {
return 4;
}
private void computeStudioGenerator() {
if (!getEngine().getDimension().getStudioMode().equals(lastMode)) {
lastMode = getEngine().getDimension().getStudioMode();
getEngine().getDimension().getStudioMode().inject(this);
}
}
@NotNull
@Override
public List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
return populators;
}
@Override
public boolean isParallelCapable() {
return true;
}
@Override
public boolean shouldGenerateCaves() {
return false;
}
@Override
public boolean shouldGenerateDecorations() {
return false;
}
@Override
public boolean shouldGenerateMobs() {
return false;
}
@Override
public boolean shouldGenerateStructures() {
return false;
}
@Override
public boolean shouldGenerateNoise() {
return false;
}
@Override
public boolean shouldGenerateSurface() {
return false;
}
@Override
public boolean shouldGenerateBedrock() {
return false;
}
@Nullable
@Override
public BiomeProvider getDefaultBiomeProvider(@NotNull WorldInfo worldInfo) {
return dummyBiomeProvider;
}
}
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.platform;
import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.engine.IrisEngine;
import com.volmit.iris.engine.data.chunk.TerrainChunk;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineTarget;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisWorld;
import com.volmit.iris.engine.object.StudioMode;
import com.volmit.iris.engine.platform.studio.StudioGenerator;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.IrisBiomeStorage;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.hunk.view.BiomeGridHunkHolder;
import com.volmit.iris.util.hunk.view.ChunkDataHunkHolder;
import com.volmit.iris.util.io.ReactiveFolder;
import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.Looper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Setter;
import org.bukkit.*;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.generator.BiomeProvider;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.generator.WorldInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Consumer;
@EqualsAndHashCode(callSuper = true)
@Data
public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChunkGenerator, Listener {
private static final int LOAD_LOCKS = Runtime.getRuntime().availableProcessors() * 4;
private final Semaphore loadLock;
private final IrisWorld world;
private final File dataLocation;
private final String dimensionKey;
private final ReactiveFolder folder;
private final ReentrantLock lock = new ReentrantLock();
private final KList<BlockPopulator> populators;
private final ChronoLatch hotloadChecker;
private final AtomicBoolean setup;
private final boolean studio;
private final AtomicInteger a = new AtomicInteger(0);
private Engine engine;
private Looper hotloader;
private StudioMode lastMode;
private DummyBiomeProvider dummyBiomeProvider;
@Setter
private StudioGenerator studioGenerator;
private boolean initialized = false;
public BukkitChunkGenerator(IrisWorld world, boolean studio, File dataLocation, String dimensionKey) {
setup = new AtomicBoolean(false);
studioGenerator = null;
dummyBiomeProvider = new DummyBiomeProvider();
populators = new KList<>();
loadLock = new Semaphore(LOAD_LOCKS);
this.world = world;
this.hotloadChecker = new ChronoLatch(1000, false);
this.studio = studio;
this.dataLocation = dataLocation;
this.dimensionKey = dimensionKey;
this.folder = new ReactiveFolder(dataLocation, (_a, _b, _c) -> hotload());
Bukkit.getServer().getPluginManager().registerEvents(this, Iris.instance);
}
private static Field getField(Class clazz, String fieldName)
throws NoSuchFieldException {
try {
return clazz.getDeclaredField(fieldName);
} catch (NoSuchFieldException e) {
Class superClass = clazz.getSuperclass();
if (superClass == null) {
throw e;
} else {
return getField(superClass, fieldName);
}
}
}
@EventHandler
public void onWorldInit(WorldInitEvent event) {
try {
if (!initialized) {
world.setRawWorldSeed(event.getWorld().getSeed());
if (world.name().equals(event.getWorld().getName())) {
Engine engine = getEngine(event.getWorld());
if (engine == null) {
Iris.warn("Failed to get Engine!");
J.s(() -> {
Engine engine1 = getEngine(event.getWorld());
if (engine1 != null) {
try {
INMS.get().inject(event.getWorld().getSeed(), engine1, event.getWorld());
Iris.info("Injected Iris Biome Source into " + event.getWorld().getName());
initialized = true;
} catch (Throwable e) {
e.printStackTrace();
}
}
}, 10);
} else {
INMS.get().inject(event.getWorld().getSeed(), engine, event.getWorld());
Iris.info("Injected Iris Biome Source into " + event.getWorld().getName());
initialized = true;
}
}
}
} catch (Throwable e) {
e.printStackTrace();
}
}
private void setupEngine() {
IrisData data = IrisData.get(dataLocation);
IrisDimension dimension = data.getDimensionLoader().load(dimensionKey);
if (dimension == null) {
Iris.error("Oh No! There's no pack in " + data.getDataFolder().getPath() + " or... there's no dimension for the key " + dimensionKey);
IrisDimension test = IrisData.loadAnyDimension(dimensionKey);
if (test != null) {
Iris.warn("Looks like " + dimensionKey + " exists in " + test.getLoadFile().getPath() + " ");
Iris.service(StudioSVC.class).installIntoWorld(Iris.getSender(), dimensionKey, dataLocation.getParentFile().getParentFile());
Iris.warn("Attempted to install into " + data.getDataFolder().getPath());
data.dump();
data.clearLists();
test = data.getDimensionLoader().load(dimensionKey);
if (test != null) {
Iris.success("Woo! Patched the Engine!");
dimension = test;
} else {
Iris.error("Failed to patch dimension!");
throw new RuntimeException("Missing Dimension: " + dimensionKey);
}
} else {
Iris.error("Nope, you don't have an installation containing " + dimensionKey + " try downloading it?");
throw new RuntimeException("Missing Dimension: " + dimensionKey);
}
}
lastMode = StudioMode.NORMAL;
engine = new IrisEngine(new EngineTarget(world, dimension, data), studio);
populators.clear();
}
@Override
public void injectChunkReplacement(World world, int x, int z, Consumer<Runnable> jobs) {
try {
loadLock.acquire();
IrisBiomeStorage st = new IrisBiomeStorage();
TerrainChunk tc = TerrainChunk.createUnsafe(world, st);
Hunk<BlockData> blocks = Hunk.view(tc);
Hunk<Biome> biomes = Hunk.view(tc, tc.getMinHeight(), tc.getMaxHeight());
this.world.bind(world);
getEngine().generate(x << 4, z << 4, blocks, biomes, true);
Iris.debug("Regenerated " + x + " " + z);
int t = 0;
for (int i = getEngine().getHeight() >> 4; i >= 0; i--) {
if (!world.isChunkLoaded(x, z)) {
continue;
}
Chunk c = world.getChunkAt(x, z);
for (Entity ee : c.getEntities()) {
if (ee instanceof Player) {
continue;
}
J.s(ee::remove);
}
J.s(() -> engine.getWorldManager().onChunkLoad(c, false));
int finalI = i;
jobs.accept(() -> {
for (int xx = 0; xx < 16; xx++) {
for (int yy = 0; yy < 16; yy++) {
for (int zz = 0; zz < 16; zz++) {
if (yy + (finalI << 4) >= engine.getHeight() || yy + (finalI << 4) < 0) {
continue;
}
c.getBlock(xx, yy + (finalI << 4) + world.getMinHeight(), zz)
.setBlockData(tc.getBlockData(xx, yy + (finalI << 4) + world.getMinHeight(), zz), false);
}
}
}
});
}
loadLock.release();
} catch (Throwable e) {
loadLock.release();
Iris.error("======================================");
e.printStackTrace();
Iris.reportErrorChunk(x, z, e, "CHUNK");
Iris.error("======================================");
ChunkData d = Bukkit.createChunkData(world);
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
d.setBlock(i, 0, j, Material.RED_GLAZED_TERRACOTTA.createBlockData());
}
}
}
}
private Engine getEngine(WorldInfo world) {
if (setup.get()) {
return getEngine();
}
lock.lock();
try {
if (setup.get()) {
return getEngine();
}
getWorld().setRawWorldSeed(world.getSeed());
setupEngine();
setup.set(true);
this.hotloader = studio ? new Looper() {
@Override
protected long loop() {
if (hotloadChecker.flip()) {
folder.check();
}
return 250;
}
} : null;
if (studio) {
hotloader.setPriority(Thread.MIN_PRIORITY);
hotloader.start();
hotloader.setName(getTarget().getWorld().name() + " Hotloader");
}
return engine;
} finally {
lock.unlock();
}
}
@Override
public void close() {
withExclusiveControl(() -> {
if (isStudio()) {
hotloader.interrupt();
}
getEngine().close();
folder.clear();
populators.clear();
});
}
@Override
public boolean isStudio() {
return studio;
}
@Override
public void hotload() {
if (!isStudio()) {
return;
}
withExclusiveControl(() -> getEngine().hotload());
}
public void withExclusiveControl(Runnable r) {
J.a(() -> {
try {
loadLock.acquire(LOAD_LOCKS);
r.run();
loadLock.release(LOAD_LOCKS);
} catch (Throwable e) {
Iris.reportError(e);
}
});
}
@Override
public void touch(World world) {
getEngine(world);
}
@Override
public void generateNoise(@NotNull WorldInfo world, @NotNull Random random, int x, int z, @NotNull ChunkGenerator.ChunkData d) {
try {
getEngine(world);
computeStudioGenerator();
TerrainChunk tc = TerrainChunk.create(d, new IrisBiomeStorage());
this.world.bind(world);
if (studioGenerator != null) {
studioGenerator.generateChunk(getEngine(), tc, x, z);
} else {
ChunkDataHunkHolder blocks = new ChunkDataHunkHolder(tc);
BiomeGridHunkHolder biomes = new BiomeGridHunkHolder(tc, tc.getMinHeight(), tc.getMaxHeight());
getEngine().generate(x << 4, z << 4, blocks, biomes, false);
blocks.apply();
biomes.apply();
}
Iris.debug("Generated " + x + " " + z);
} catch (Throwable e) {
Iris.error("======================================");
e.printStackTrace();
Iris.reportErrorChunk(x, z, e, "CHUNK");
Iris.error("======================================");
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
d.setBlock(i, 0, j, Material.RED_GLAZED_TERRACOTTA.createBlockData());
}
}
}
}
@Override
public int getBaseHeight(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull HeightMap heightMap) {
return 4;
}
private void computeStudioGenerator() {
if (!getEngine().getDimension().getStudioMode().equals(lastMode)) {
lastMode = getEngine().getDimension().getStudioMode();
getEngine().getDimension().getStudioMode().inject(this);
}
}
@NotNull
@Override
public List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
return populators;
}
@Override
public boolean isParallelCapable() {
return true;
}
@Override
public boolean shouldGenerateCaves() {
return false;
}
@Override
public boolean shouldGenerateDecorations() {
return false;
}
@Override
public boolean shouldGenerateMobs() {
return false;
}
@Override
public boolean shouldGenerateStructures() {
return false;
}
@Override
public boolean shouldGenerateNoise() {
return false;
}
@Override
public boolean shouldGenerateSurface() {
return false;
}
@Override
public boolean shouldGenerateBedrock() {
return false;
}
@Nullable
@Override
public BiomeProvider getDefaultBiomeProvider(@NotNull WorldInfo worldInfo) {
return dummyBiomeProvider;
}
}

View File

@@ -1,5 +1,6 @@
package com.volmit.iris.engine.platform;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.util.collection.KList;
import org.bukkit.block.Biome;
import org.bukkit.generator.BiomeProvider;
@@ -9,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
public class DummyBiomeProvider extends BiomeProvider {
private final List<Biome> ALL = new KList<>(Biome.values()).qdel(Biome.CHERRY_GROVE).qdel(Biome.CUSTOM);
private final List<Biome> ALL = INMS.get().getBiomes();
@NotNull
@Override

View File

@@ -1,15 +0,0 @@
package com.volmit.iris.engine.safeguard;
import com.volmit.iris.core.IrisSettings;
import oshi.SystemInfo;
import oshi.hardware.GlobalMemory;
import static com.volmit.iris.util.misc.getHardware.*;
public class PerformanceSFG {
public static boolean lowPerformance = false;
public static void calculatePerformance(){
}
}

View File

@@ -1,78 +0,0 @@
package com.volmit.iris.engine.safeguard;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
import com.volmit.iris.util.format.C;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import java.util.*;
import static com.volmit.iris.Iris.dump;
import static com.volmit.iris.Iris.instance;
import static com.volmit.iris.engine.safeguard.IrisSafeguard.unstablemode;
public class ServerBootSFG {
public static final Map<String, Boolean> incompatiblePlugins = new HashMap<>();
public static boolean unsuportedversion = false;
protected static boolean safeguardPassed;
public static boolean passedserversoftware = true;
protected static byte count;
public static String allIncompatiblePlugins;
public static void BootCheck() {
Iris.info("Checking for possible conflicts..");
org.bukkit.plugin.PluginManager pluginManager = Bukkit.getPluginManager();
Plugin[] plugins = pluginManager.getPlugins();
incompatiblePlugins.clear();
incompatiblePlugins.put("Multiverse-Core", false);
incompatiblePlugins.put("Dynmap", false);
incompatiblePlugins.put("TerraformGenerator", false);
incompatiblePlugins.put("Stratos", false);
String pluginName;
for (Plugin plugin : plugins) {
pluginName = plugin.getName();
Boolean flag = incompatiblePlugins.get(pluginName);
if (flag != null && !flag) {
count++;
incompatiblePlugins.put(pluginName, true);
}
}
StringJoiner joiner = new StringJoiner(", ");
for (Map.Entry<String, Boolean> entry : incompatiblePlugins.entrySet()) {
if (entry.getValue()) {
joiner.add(entry.getKey());
}
}
if (
!instance.getServer().getVersion().contains("Purpur") &&
!instance.getServer().getVersion().contains("Paper") &&
!instance.getServer().getVersion().contains("Spigot") &&
!instance.getServer().getVersion().contains("Pufferfish") &&
!instance.getServer().getVersion().contains("Bukkit"))
{
passedserversoftware = false;
joiner.add("Server Software");
count++;
}
if (INMS.get() instanceof NMSBinding1X) {
unsuportedversion = true;
joiner.add("Unsupported Minecraft Version");
count++;
}
allIncompatiblePlugins = joiner.toString();
safeguardPassed = (count == 0);
if(!safeguardPassed){
unstablemode = true;
Iris.safeguard("Unstable mode has been activated.");
}
}
}

View File

@@ -1,99 +0,0 @@
package com.volmit.iris.engine.safeguard;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.util.format.C;
import static com.volmit.iris.engine.safeguard.IrisSafeguard.unstablemode;
import static com.volmit.iris.engine.safeguard.ServerBootSFG.*;
public class UtilsSFG {
public static void UnstableMode(){
if (unstablemode) {
Iris.safeguard(C.DARK_RED + "Iris is running in Unstable Mode");
} else {
Iris.safeguard(C.BLUE + "Iris is running Stable");
}
}
public static void SupportedServerSoftware(){
if (!passedserversoftware) {
Iris.safeguard(C.DARK_RED + "Server is running unsupported server software");
Iris.safeguard(C.RED + "Supported: Purpur, Pufferfish, Paper, Spigot, Bukkit");
}
}
public static void printIncompatibleWarnings(){
// String SupportedIrisVersion = getDescription().getVersion(); //todo Automatic version
if (safeguardPassed) {
Iris.safeguard(C.BLUE + "0 Conflicts found");
} else {
Iris.safeguard(C.DARK_RED + "" + count + " Conflicts found");
unstablemode = true;
if (incompatiblePlugins.get("Multiverse-Core")) {
Iris.safeguard(C.RED + "Multiverse");
Iris.safeguard(C.RED + "- The plugin Multiverse is not compatible with the server.");
Iris.safeguard(C.RED + "- If you want to have a world manager, consider using PhantomWorlds or MyWorlds instead.");
}
if (incompatiblePlugins.get("Dynmap")) {
Iris.safeguard(C.RED + "Dynmap");
Iris.safeguard(C.RED + "- The plugin Dynmap is not compatible with the server.");
Iris.safeguard(C.RED + "- If you want to have a map plugin like Dynmap, consider Bluemap.");
}
if (incompatiblePlugins.get("TerraformGenerator") || incompatiblePlugins.get("Stratos")) {
Iris.safeguard(C.YELLOW + "Terraform Generator / Stratos");
Iris.safeguard(C.YELLOW + "- Iris is not compatible with other worldgen plugins.");
}
if (unsuportedversion) {
Iris.safeguard(C.RED + "Server Version");
Iris.safeguard(C.RED + "- Iris only supports 1.19.2 > 1.20.2");
}
if (!passedserversoftware) {
Iris.safeguard(C.RED + "Unsupported Server Software");
Iris.safeguard(C.RED + "- Please consider using Paper or Purpur instead.");
}
}
}
public static String MSGIncompatibleWarnings() {
return allIncompatiblePlugins;
}
public static void unstablePrompt() {
if (unstablemode) {
Iris.info("");
Iris.info(C.DARK_GRAY + "--==<" + C.RED + " IMPORTANT " + C.DARK_GRAY + ">==--");
Iris.info(C.RED + "Iris is running in unstable mode what may cause the following issues.");
Iris.info(C.DARK_RED + "Server Issues");
Iris.info(C.RED + "- Server wont boot");
Iris.info(C.RED + "- Data Loss");
Iris.info(C.RED + "- Unexpected behavior.");
Iris.info(C.RED + "- And More..");
Iris.info(C.DARK_RED + "World Issues");
Iris.info(C.RED + "- Worlds cant load due to corruption..");
Iris.info(C.RED + "- Worlds may slowly corrupt till they wont be able to load.");
Iris.info(C.RED + "- World data loss.");
Iris.info(C.RED + "- And More..");
Iris.info(C.DARK_RED + "ATTENTION:" + C.RED + " While running iris in unstable mode you wont be eligible for support.");
Iris.info(C.DARK_RED + "CAUSE: " + C.RED + MSGIncompatibleWarnings());
Iris.info("");
if (IrisSettings.get().getGeneral().bootUnstable) {
Iris.info(C.DARK_RED + "Boot Unstable is set to true, continuing with the startup process.");
}
if (!IrisSettings.get().getGeneral().isBootUnstable()) {
Iris.info(C.DARK_RED + "Go to plugins/iris/settings.json and set ignoreUnstable to true if you wish to proceed.");
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// No
}
}
}
Iris.info("");
}
}
}

View File

@@ -27,10 +27,14 @@ import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisExpression;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
@Data
@EqualsAndHashCode(exclude = "engine")
@ToString(exclude = "engine")
public class IrisScriptingAPI {
private final Engine engine;
private IrisRegistrant preprocessorObject;

View File

@@ -22,6 +22,7 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.link.Identifier;
import com.volmit.iris.core.service.ExternalDataSVC;
import com.volmit.iris.engine.object.IrisCompat;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.scheduling.ChronoLatch;
@@ -144,6 +145,7 @@ public class B {
Arrays.stream(new Material[]{
GRASS,
TALL_GRASS,
TALL_SEAGRASS,
FERN,
LARGE_FERN,
CORNFLOWER,
@@ -406,7 +408,7 @@ public class B {
return mat.getMaterial().isSolid();
}
public static BlockData getOrNull(String bdxf) {
public static BlockData getOrNull(String bdxf, boolean warn) {
try {
String bd = bdxf.trim();
@@ -422,9 +424,9 @@ public class B {
return DIRT_PATH.createBlockData();
}
BlockData bdx = parseBlockData(bd);
BlockData bdx = parseBlockData(bd, warn);
if (bdx == null) {
if (bdx == null && warn) {
if (clw.flip()) {
Iris.warn("Unknown Block Data '" + bd + "'");
}
@@ -443,8 +445,8 @@ public class B {
return null;
}
public static BlockData get(String bdxf) {
BlockData bd = getOrNull(bdxf);
public static BlockData getNoCompat(String bdxf) {
BlockData bd = getOrNull(bdxf, true);
if (bd != null) {
return bd;
@@ -453,20 +455,34 @@ public class B {
return AIR;
}
private static synchronized BlockData createBlockData(String s) {
public static BlockData get(String bdxf) {
if (bdxf.contains(":")) {
if (bdxf.startsWith("minecraft:")) {
return Iris.compat.getBlock(bdxf);
} else {
return getNoCompat(bdxf);
}
} else {
return Iris.compat.getBlock(bdxf);
}
}
private static synchronized BlockData createBlockData(String s, boolean warn) {
try {
return Bukkit.createBlockData(s);
} catch (IllegalArgumentException e) {
if (s.contains("[")) {
return createBlockData(s.split("\\Q[\\E")[0]);
return createBlockData(s.split("\\Q[\\E")[0], warn);
}
}
Iris.error("Can't find block data for " + s);
if (warn) {
Iris.error("Can't find block data for " + s);
}
return null;
}
private static BlockData parseBlockData(String ix) {
private static BlockData parseBlockData(String ix, boolean warn) {
try {
BlockData bx = null;
@@ -480,7 +496,7 @@ public class B {
if (bx == null) {
try {
bx = createBlockData(ix.toLowerCase());
bx = createBlockData(ix.toLowerCase(), warn);
} catch (Throwable e) {
e.printStackTrace();
}
@@ -488,7 +504,7 @@ public class B {
if (bx == null) {
try {
bx = createBlockData("minecraft:" + ix.toLowerCase());
bx = createBlockData("minecraft:" + ix.toLowerCase(), warn);
} catch (Throwable e) {
}
@@ -548,7 +564,7 @@ public class B {
for (String key : stateMap.keySet()) { //Iterate through every state and check if its valid
try {
String newState = block + "[" + key + "=" + stateMap.get(key) + "]";
createBlockData(newState);
createBlockData(newState, warn);
newStates.put(key, stateMap.get(key));
} catch (IllegalArgumentException ignored) {
@@ -562,7 +578,7 @@ public class B {
Iris.debug("Converting " + ix + " to " + newBlock);
try {
return createBlockData(newBlock);
return createBlockData(newBlock, warn);
} catch (Throwable e1) {
Iris.reportError(e1);
}

View File

@@ -0,0 +1,127 @@
package com.volmit.iris.util.data;
import com.volmit.iris.core.link.Identifier;
import lombok.Data;
import lombok.NonNull;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.SoundGroup;
import org.bukkit.block.*;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.structure.Mirror;
import org.bukkit.block.structure.StructureRotation;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@Data
public class IrisBlockData implements BlockData{
private final @NonNull BlockData base;
private final @NotNull Identifier custom;
@NotNull
@Override
public Material getMaterial() {
return base.getMaterial();
}
@NotNull
@Override
public String getAsString() {
return base.getAsString();
}
@NotNull
@Override
public String getAsString(boolean b) {
return base.getAsString(b);
}
@NotNull
@Override
public BlockData merge(@NotNull BlockData blockData) {
return new IrisBlockData(base.merge(blockData), custom);
}
@Override
public boolean matches(@Nullable BlockData blockData) {
if (blockData instanceof IrisBlockData b)
return custom.equals(b.custom) && base.matches(b.base);
return base.matches(blockData);
}
@NotNull
@Override
public BlockData clone() {
return new IrisBlockData(base.clone(), custom);
}
@NotNull
@Override
public SoundGroup getSoundGroup() {
return base.getSoundGroup();
}
@Override
public int getLightEmission() {
return base.getLightEmission();
}
@Override
public boolean isOccluding() {
return base.isOccluding();
}
@Override
public boolean requiresCorrectToolForDrops() {
return base.requiresCorrectToolForDrops();
}
@Override
public boolean isPreferredTool(@NotNull ItemStack itemStack) {
return base.isPreferredTool(itemStack);
}
@NotNull
@Override
public PistonMoveReaction getPistonMoveReaction() {
return base.getPistonMoveReaction();
}
@Override
public boolean isSupported(@NotNull Block block) {
return base.isSupported(block);
}
@Override
public boolean isSupported(@NotNull Location location) {
return base.isSupported(location);
}
@Override
public boolean isFaceSturdy(@NotNull BlockFace blockFace, @NotNull BlockSupport blockSupport) {
return base.isFaceSturdy(blockFace, blockSupport);
}
@NotNull
@Override
public Material getPlacementMaterial() {
return base.getPlacementMaterial();
}
@Override
public void rotate(@NotNull StructureRotation structureRotation) {
base.rotate(structureRotation);
}
@Override
public void mirror(@NotNull Mirror mirror) {
base.mirror(mirror);
}
@NotNull
@Override
public BlockState createBlockState() {
return base.createBlockState();
}
}

View File

@@ -683,23 +683,23 @@ public class Form {
*/
public static String ofSize(long s, int div) {
double d = (double) s;
String sub = "Bytes";
String sub = " Bytes";
if (d > div - 1) {
d /= div;
sub = "KB";
sub = " KB";
if (d > div - 1) {
d /= div;
sub = "MB";
sub = " MB";
if (d > div - 1) {
d /= div;
sub = "GB";
sub = " GB";
if (d > div - 1) {
d /= div;
sub = "TB";
sub = " TB";
}
}
}

View File

@@ -23,8 +23,10 @@ import com.volmit.iris.util.function.Consumer2;
import java.util.LinkedHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
public class HashPalette<T> implements Palette<T> {
private final ReentrantLock lock = new ReentrantLock();
private final LinkedHashMap<T, Integer> palette;
private final KMap<Integer, T> lookup;
private final AtomicInteger size;
@@ -47,14 +49,18 @@ public class HashPalette<T> implements Palette<T> {
@Override
public int add(T t) {
int index = size.getAndIncrement();
palette.put(t, index);
lock.lock();
try {
int index = size.getAndIncrement();
palette.put(t, index);
if (t != null) {
lookup.put(index, t);
if (t != null) {
lookup.put(index, t);
}
return index;
} finally {
lock.unlock();
}
return index;
}
@Override
@@ -74,12 +80,17 @@ public class HashPalette<T> implements Palette<T> {
@Override
public void iterate(Consumer2<T, Integer> c) {
for (T i : palette.keySet()) {
if (i == null) {
continue;
}
lock.lock();
try {
for (T i : palette.keySet()) {
if (i == null) {
continue;
}
c.accept(i, id(i));
c.accept(i, id(i));
}
} finally {
lock.unlock();
}
}
}

View File

@@ -19,6 +19,7 @@
package com.volmit.iris.util.hunk.view;
import com.volmit.iris.util.data.B;
import com.volmit.iris.util.data.IrisBlockData;
import com.volmit.iris.util.hunk.Hunk;
import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.ChunkData;
@@ -72,7 +73,8 @@ public class ChunkDataHunkView implements Hunk<BlockData> {
}
try {
if (t instanceof IrisBlockData d)
t = d.getBase();
chunk.setBlock(x, y + chunk.getMinHeight(), z, t);
} catch (Throwable ignored) {

View File

@@ -18,15 +18,17 @@
package com.volmit.iris.util.mantle;
import com.google.common.util.concurrent.AtomicDouble;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.service.IrisEngineSVC;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.mantle.EngineMantle;
import com.volmit.iris.engine.mantle.MantleWriter;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.documentation.ChunkCoordinates;
import com.volmit.iris.util.documentation.RegionCoordinates;
@@ -45,27 +47,31 @@ import org.bukkit.Chunk;
import java.io.EOFException;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantLock;
/**
* The mantle can store any type of data slice anywhere and manage regions & IO on it's own.
* This class is fully thread safe read & writeNodeData
*/
public class Mantle {
private static final boolean disableClear = System.getProperty("disableClear", "false").equals("true");
private final File dataFolder;
@Getter
private final int worldHeight;
private final Map<Long, Long> lastUse;
@Getter
private final Map<Long, TectonicPlate> loadedRegions;
private final HyperLock hyperLock;
private final KSet<Long> unload;
private final AtomicBoolean closed;
private final MultiBurst ioBurst;
private final AtomicBoolean io;
private final AtomicBoolean ioTrim;
private final AtomicBoolean ioTectonicUnload;
/**
* Create a new mantle
@@ -79,9 +85,9 @@ public class Mantle {
this.closed = new AtomicBoolean(false);
this.dataFolder = dataFolder;
this.worldHeight = worldHeight;
this.io = new AtomicBoolean(false);
this.ioTrim = new AtomicBoolean(false);
this.ioTectonicUnload = new AtomicBoolean(false);
dataFolder.mkdirs();
unload = new KSet<>();
loadedRegions = new KMap<>();
lastUse = new KMap<>();
ioBurst = MultiBurst.burst;
@@ -108,7 +114,7 @@ public class Mantle {
* @return the file
*/
public static File fileForRegion(File folder, Long key) {
File f = new File(folder, "p." + key + ".ttp");
File f = new File(folder, "p." + key + ".ttp.lz4b");
if (!f.getParentFile().exists()) {
f.getParentFile().mkdirs();
}
@@ -374,46 +380,126 @@ public class Mantle {
Iris.debug("The Mantle has Closed " + C.DARK_AQUA + dataFolder.getAbsolutePath());
}
/**
* Estimates the memory usage of the lastUse map.
*
* @return Estimated memory usage in bytes.
*/
public long LastUseMapMemoryUsage() {
long numberOfEntries = lastUse.size();
long bytesPerEntry = Long.BYTES * 2;
return numberOfEntries * bytesPerEntry;
}
@Getter
private final AtomicDouble adjustedIdleDuration = new AtomicDouble(0);
@Getter
private final AtomicInteger forceAggressiveThreshold = new AtomicInteger(30);
@Getter
private final AtomicLong oldestTectonicPlate = new AtomicLong(0);
private final ReentrantLock unloadLock = new ReentrantLock();
@Getter
private final KList<Long> toUnload = new KList<>();
/**
* Save & unload regions that have not been used for more than the
* specified amount of milliseconds
*
* @param idleDuration the duration
* @param baseIdleDuration the duration
*/
public synchronized void trim(long idleDuration) {
public synchronized void trim(long baseIdleDuration, int tectonicLimit) {
if (closed.get()) {
throw new RuntimeException("The Mantle is closed");
}
io.set(true);
Iris.debug("Trimming Tectonic Plates older than " + Form.duration((double) idleDuration, 0));
unload.clear();
adjustedIdleDuration.set(baseIdleDuration);
for (Long i : lastUse.keySet()) {
hyperLock.withLong(i, () -> {
if (M.ms() - lastUse.get(i) >= idleDuration) {
unload.add(i);
}
});
if (loadedRegions != null) {
if (loadedRegions.size() > tectonicLimit) {
// todo update this correctly and maybe do something when its above a 100%
adjustedIdleDuration.set(Math.max(adjustedIdleDuration.get() - (1000 * (((loadedRegions.size() - tectonicLimit) / (double) tectonicLimit) * 100) * 0.4), 4000));
}
}
for (Long i : unload) {
hyperLock.withLong(i, () -> {
TectonicPlate m = loadedRegions.remove(i);
lastUse.remove(i);
try {
m.write(fileForRegion(dataFolder, i));
} catch (IOException e) {
e.printStackTrace();
ioTrim.set(true);
unloadLock.lock();
try {
if (lastUse != null && IrisEngineSVC.instance != null) {
if (!lastUse.isEmpty()) {
Iris.debug("Trimming Tectonic Plates older than " + Form.duration(adjustedIdleDuration.get(), 0));
for (long i : new ArrayList<>(lastUse.keySet())) {
double finalAdjustedIdleDuration = adjustedIdleDuration.get();
hyperLock.withLong(i, () -> {
Long lastUseTime = lastUse.get(i);
if (lastUseTime != null && M.ms() - lastUseTime >= finalAdjustedIdleDuration) {
toUnload.add(i);
Iris.debug("Tectonic Region added to unload");
IrisEngineSVC.instance.trimActiveAlive.reset();
}
});
}
}
}
Iris.debug("Unloaded Tectonic Plate " + C.DARK_GREEN + Cache.keyX(i) + " " + Cache.keyZ(i));
});
} catch (Throwable e) {
Iris.reportError(e);
} finally {
ioTrim.set(false);
unloadLock.unlock();
}
io.set(false);
}
public synchronized int unloadTectonicPlate(int tectonicLimit) {
AtomicInteger i = new AtomicInteger();
unloadLock.lock();
BurstExecutor burst = null;
if (IrisEngineSVC.instance != null) {
try {
KList<Long> copy = toUnload.copy();
if (!disableClear) toUnload.clear();
burst = MultiBurst.burst.burst(copy.size());
burst.setMulticore(copy.size() > tectonicLimit);
for (int j = 0; j < copy.size(); j++) {
Long id = copy.get(j);
if (id == null) {
Iris.error("Null id in unloadTectonicPlate at index " + j);
continue;
}
burst.queue(() ->
hyperLock.withLong(id, () -> {
TectonicPlate m = loadedRegions.get(id);
if (m != null) {
try {
m.write(fileForRegion(dataFolder, id));
loadedRegions.remove(id);
lastUse.remove(id);
if (disableClear) toUnload.remove(id);
i.incrementAndGet();
Iris.debug("Unloaded Tectonic Plate " + C.DARK_GREEN + Cache.keyX(id) + " " + Cache.keyZ(id));
IrisEngineSVC.instance.unloadActiveAlive.reset();
} catch (IOException e) {
Iris.reportError(e);
}
}
}));
}
burst.complete();
} catch (Throwable e) {
e.printStackTrace();
if (burst != null)
burst.complete();
} finally {
unloadLock.unlock();
ioTectonicUnload.set(true);
}
return i.get();
}
return i.get();
}
/**
* This retreives a future of the Tectonic Plate at the given coordinates.
* All methods accessing tectonic plates should go through this method
@@ -424,7 +510,7 @@ public class Mantle {
*/
@RegionCoordinates
private TectonicPlate get(int x, int z) {
if (io.get()) {
if (ioTrim.get()) {
try {
return getSafe(x, z).get();
} catch (InterruptedException e) {
@@ -481,6 +567,8 @@ public class Mantle {
}
File file = fileForRegion(dataFolder, x, z);
if (!file.exists())
file = new File(dataFolder, file.getName().substring(".lz4b".length()));
if (file.exists()) {
try {
@@ -519,10 +607,6 @@ public class Mantle {
}
public int getWorldHeight() {
return worldHeight;
}
public MantleChunk getChunk(Chunk e) {
return getChunk(e.getX(), e.getZ());
}
@@ -554,4 +638,4 @@ public class Mantle {
public boolean shouldReduce(Engine engine) {
return !engine.isStudio() || IrisSettings.get().getPerformance().isTrimMantleInStudio();
}
}
}

View File

@@ -33,7 +33,8 @@ public enum MantleFlag {
CLEANED,
PLANNED,
ETCHED,
TILE;
TILE,
CUSTOM;
static StateList getStateList() {
return new StateList(MantleFlag.values());

View File

@@ -26,6 +26,10 @@ import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import lombok.Getter;
import net.jpountz.lz4.LZ4BlockInputStream;
import net.jpountz.lz4.LZ4BlockOutputStream;
import net.jpountz.lz4.LZ4FrameInputStream;
import net.jpountz.lz4.LZ4FrameOutputStream;
import java.io.*;
import java.util.concurrent.atomic.AtomicReferenceArray;
@@ -79,8 +83,14 @@ public class TectonicPlate {
public static TectonicPlate read(int worldHeight, File file) throws IOException, ClassNotFoundException {
FileInputStream fin = new FileInputStream(file);
GZIPInputStream gzi = new GZIPInputStream(fin);
DataInputStream din = new DataInputStream(gzi);
DataInputStream din;
if (file.getName().endsWith("ttp.lz4b")) {
LZ4BlockInputStream lz4 = new LZ4BlockInputStream(fin);
din = new DataInputStream(lz4);
} else {
GZIPInputStream gzi = new GZIPInputStream(fin);
din = new DataInputStream(gzi);
}
TectonicPlate p = new TectonicPlate(worldHeight, din);
din.close();
@@ -164,8 +174,14 @@ public class TectonicPlate {
public void write(File file) throws IOException {
PrecisionStopwatch p = PrecisionStopwatch.start();
FileOutputStream fos = new FileOutputStream(file);
GZIPOutputStream gzo = new GZIPOutputStream(fos);
DataOutputStream dos = new DataOutputStream(gzo);
DataOutputStream dos;
if (file.getName().endsWith("ttp.lz4b")) {
LZ4BlockOutputStream lz4 = new LZ4BlockOutputStream(fos);
dos = new DataOutputStream(lz4);
} else {
GZIPOutputStream gzo = new GZIPOutputStream(fos);
dos = new DataOutputStream(gzo);
}
write(dos);
dos.close();
Iris.debug("Saved Tectonic Plate " + C.DARK_GREEN + file.getName().split("\\Q.\\E")[0] + C.RED + " in " + Form.duration(p.getMilliseconds(), 2));

View File

@@ -0,0 +1,168 @@
package com.volmit.iris.util.math;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import java.security.SecureRandom;
import java.util.List;
import java.util.UUID;
import java.nio.charset.StandardCharsets;
public class RNGV2 extends SecureRandom {
private static final long serialVersionUID = 5222938581174415179L;
private static final char[] CHARGEN = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-=!@#$%^&*()_+`~[];',./<>?:\\\"{}|\\\\".toCharArray();
private final long sx;
// Constructor with no seed
public RNGV2() {
super();
sx = 0;
}
public RNGV2(long seed) {
super();
this.setSeed(seed);
this.sx = seed;
}
// Constructor with a string seed
public RNGV2(String seed) {
this(UUID.nameUUIDFromBytes(seed.getBytes(StandardCharsets.UTF_8)).getLeastSignificantBits() +
UUID.nameUUIDFromBytes(seed.getBytes(StandardCharsets.UTF_8)).getMostSignificantBits() +
(seed.length() * 32564L));
}
public RNGV2 nextParallelRNG(int signature) {
return new RNGV2(sx + signature);
}
public RNGV2 nextParallelRNG(long signature) {
return new RNGV2(sx + signature);
}
public String s(int length) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < length; i++) {
sb.append(c());
}
return sb.toString();
}
public char c() {
return CHARGEN[i(CHARGEN.length - 1)];
}
// Pick a random enum
public <T> T e(Class<T> t) {
T[] c = t.getEnumConstants();
return c[i(c.length)];
}
public boolean b() {
return nextBoolean();
}
public boolean b(double percent) {
return d() > percent;
}
public short si(int lowerBound, int upperBound) {
return (short) (lowerBound + (nextFloat() * ((upperBound - lowerBound) + 1)));
}
public short si(int upperBound) {
return si(0, upperBound);
}
public short si() {
return si(1);
}
public float f(float lowerBound, float upperBound) {
return lowerBound + (nextFloat() * ((upperBound - lowerBound)));
}
public float f(float upperBound) {
return f(0, upperBound);
}
public float f() {
return f(1);
}
public double d(double lowerBound, double upperBound) {
return lowerBound + (nextDouble() * (upperBound - lowerBound));
}
public double d(double upperBound) {
return d(0, upperBound);
}
public double d() {
return nextDouble();
}
public int i(int lowerBound, int upperBound) {
if (lowerBound >= upperBound) {
throw new IllegalArgumentException("Upper bound must be greater than lower bound");
}
return lowerBound + this.nextInt(upperBound - lowerBound + 1);
}
public int i(int upperBound) {
return i(0, upperBound);
}
public long l(long lowerBound, long upperBound) {
return Math.round(d(lowerBound, upperBound));
}
public long l(long upperBound) {
return l(0, upperBound);
}
public int imax() {
return i(Integer.MIN_VALUE, Integer.MAX_VALUE);
}
public long lmax() {
return l(Long.MIN_VALUE, Long.MAX_VALUE);
}
public float fmax() {
return f(Float.MIN_VALUE, Float.MAX_VALUE);
}
public double dmax() {
return d(Double.MIN_VALUE, Double.MAX_VALUE);
}
public short simax() {
return si(Short.MIN_VALUE, Short.MAX_VALUE);
}
public boolean chance(double chance) {
return nextDouble() <= chance;
}
public <T> T pick(List<T> pieces) {
if (pieces.isEmpty()) {
return null;
}
if (pieces.size() == 1) {
return pieces.get(0);
}
return pieces.get(this.nextInt(pieces.size()));
}
public long getSeed() {
return sx;
}
}

View File

@@ -18,6 +18,7 @@
package com.volmit.iris.util.matter.slices;
import com.volmit.iris.util.data.IrisBlockData;
import com.volmit.iris.util.data.palette.Palette;
import com.volmit.iris.util.matter.Sliced;
import org.bukkit.Bukkit;
@@ -39,7 +40,11 @@ public class BlockMatter extends RawMatter<BlockData> {
public BlockMatter(int width, int height, int depth) {
super(width, height, depth, BlockData.class);
registerWriter(World.class, ((w, d, x, y, z) -> w.getBlockAt(x, y, z).setBlockData(d)));
registerWriter(World.class, ((w, d, x, y, z) -> {
if (d instanceof IrisBlockData c)
w.getBlockAt(x, y, z).setBlockData(c.getBase());
else w.getBlockAt(x, y, z).setBlockData(d);
}));
registerReader(World.class, (w, x, y, z) -> {
BlockData d = w.getBlockAt(x, y, z).getBlockData();
return d.getMaterial().isAir() ? null : d;

View File

@@ -0,0 +1,36 @@
package com.volmit.iris.util.matter.slices;
import com.volmit.iris.core.link.Identifier;
import com.volmit.iris.util.data.palette.Palette;
import com.volmit.iris.util.matter.Sliced;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@Sliced
public class IdentifierMatter extends RawMatter<Identifier> {
public IdentifierMatter() {
this(1, 1, 1);
}
public IdentifierMatter(int width, int height, int depth) {
super(width, height, depth, Identifier.class);
}
@Override
public Palette<Identifier> getGlobalPalette() {
return null;
}
@Override
public void writeNode(Identifier b, DataOutputStream dos) throws IOException {
dos.writeUTF(b.toString());
}
@Override
public Identifier readNode(DataInputStream din) throws IOException {
return Identifier.fromString(din.readUTF());
}
}

View File

@@ -13,15 +13,24 @@ public class getHardware {
OperatingSystem os = systemInfo.getOperatingSystem();
return os.toString();
}
public static int getCPUThreads(){
SystemInfo systemInfo = new SystemInfo();
CentralProcessor processor = systemInfo.getHardware().getProcessor();
return processor.getLogicalProcessorCount();
}
public static long getProcessMemory(){
long maxMemory = Runtime.getRuntime().maxMemory() / (1024 * 1024);
return maxMemory;
}
public static long getProcessUsedMemory() {
Runtime runtime = Runtime.getRuntime();
long totalMemory = runtime.totalMemory();
long freeMemory = runtime.freeMemory();
long usedMemory = totalMemory - freeMemory;
return usedMemory / (1024 * 1024);
}
public static long getAvailableProcessMemory(){
long availableMemory = getHardware.getProcessMemory() - getHardware.getProcessUsedMemory();
return availableMemory;
}
public static String getCPUModel() {
try {

View File

@@ -107,7 +107,7 @@ public class NBTWorld {
p.deleteCharAt(p.length() - 1).append(']');
}
BlockData b = B.getOrNull(p.toString());
BlockData b = B.getOrNull(p.toString(), true);
if (b == null) {
return B.getAir();

View File

@@ -18,6 +18,8 @@
package com.volmit.iris.util.plugin;
import com.volmit.iris.util.format.C;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -28,4 +30,5 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target(FIELD)
public @interface Command {
String value() default "";
}

View File

@@ -9,6 +9,7 @@ libraries:
- com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2
- com.github.ben-manes.caffeine:caffeine:3.0.5
- org.apache.commons:commons-lang3:3.12.0
- commons-io:commons-io:2.13.0
- io.timeandspace:smoothie-map:2.0.2
- com.google.guava:guava:31.0.1-jre
- com.google.code.gson:gson:2.8.9
@@ -17,6 +18,7 @@ libraries:
- org.ow2.asm:asm:9.2
- rhino:js:1.7R2
- bsf:bsf:2.4.0
- org.lz4:lz4-java:1.8.0
commands:
iris:
aliases: [ ir, irs ]

View File

@@ -1,38 +1,20 @@
package com.volmit.iris.core.nms.v1_19_R1;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMSBinding;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.json.JSONObject;
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.mca.NBTWorld;
import com.volmit.iris.util.nbt.mca.palette.*;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.TagParser;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.LevelChunk;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import java.util.concurrent.atomic.AtomicInteger;
import org.bukkit.*;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_19_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
@@ -42,20 +24,45 @@ import org.bukkit.craftbukkit.v1_19_R1.entity.CraftDolphin;
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
import org.bukkit.entity.Dolphin;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import sun.misc.Unsafe;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMSBinding;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.json.JSONObject;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.math.Vector3d;
import com.volmit.iris.util.matter.MatterBiomeInject;
import com.volmit.iris.util.nbt.io.NBTUtil;
import com.volmit.iris.util.nbt.mca.NBTWorld;
import com.volmit.iris.util.nbt.mca.palette.*;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.TagParser;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.LevelChunk;
import sun.misc.Unsafe;
public class NMSBinding implements INMSBinding {
private final KMap<Biome, Object> baseBiomeCache = new KMap<>();
@@ -270,6 +277,11 @@ public class NMSBinding implements INMSBinding {
return v;
}
@Override
public KList<Biome> getBiomes() {
return new KList<>(Biome.values()).qdel(Biome.CUSTOM);
}
@Override
public boolean isBukkit() {
return true;
@@ -477,6 +489,34 @@ public class NMSBinding implements INMSBinding {
biomeSource.set(serverLevel.getChunkSource().chunkMap.generator, customBiomeSource);
}
public Vector3d getBoundingbox(org.bukkit.entity.EntityType entity) {
Field[] fields = EntityType.class.getDeclaredFields();
for (Field field : fields) {
if (Modifier.isStatic(field.getModifiers()) && field.getType().equals(EntityType.class)) {
try {
EntityType entityType = (EntityType) field.get(null);
if (entityType.getDescriptionId().equals("entity.minecraft." + entity.name().toLowerCase())) {
Vector<Float> v1 = new Vector<>();
v1.add(entityType.getHeight());
entityType.getDimensions();
Vector3d box = new Vector3d( entityType.getWidth(), entityType.getHeight(), entityType.getWidth());
//System.out.println("Entity Type: " + entityType.getDescriptionId() + ", " + "Height: " + height + ", Width: " + width);
return box;
}
} catch (IllegalAccessException e) {
Iris.error("Unable to get entity dimensions!");
e.printStackTrace();
}
}
}
return null;
}
@Override
public Entity spawnEntity(Location location, org.bukkit.entity.EntityType type, CreatureSpawnEvent.SpawnReason reason) {
return ((CraftWorld) location.getWorld()).spawn(location, type.getEntityClass(), null, reason);
}
private static Field getField(Class<?> clazz, Class<?> fieldType) throws NoSuchFieldException {
try {
for (Field f : clazz.getDeclaredFields()) {

View File

@@ -1,35 +1,17 @@
package com.volmit.iris.core.nms.v1_19_R2;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMSBinding;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.json.JSONObject;
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.mca.NBTWorld;
import com.volmit.iris.util.nbt.mca.palette.*;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
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.TagParser;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.LevelChunk;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import java.util.concurrent.atomic.AtomicInteger;
import org.bukkit.*;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
@@ -42,20 +24,46 @@ import org.bukkit.craftbukkit.v1_19_R2.entity.CraftDolphin;
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack;
import org.bukkit.entity.Dolphin;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import sun.misc.Unsafe;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMSBinding;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.json.JSONObject;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.math.Vector3d;
import com.volmit.iris.util.matter.MatterBiomeInject;
import com.volmit.iris.util.nbt.io.NBTUtil;
import com.volmit.iris.util.nbt.mca.NBTWorld;
import com.volmit.iris.util.nbt.mca.palette.*;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
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.TagParser;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.LevelChunk;
import sun.misc.Unsafe;
public class NMSBinding implements INMSBinding {
private final KMap<Biome, Object> baseBiomeCache = new KMap<>();
@@ -270,6 +278,11 @@ public class NMSBinding implements INMSBinding {
return v;
}
@Override
public KList<Biome> getBiomes() {
return new KList<>(Biome.values()).qdel(Biome.CUSTOM);
}
@Override
public boolean isBukkit() {
return true;
@@ -477,6 +490,35 @@ public class NMSBinding implements INMSBinding {
biomeSource.set(serverLevel.getChunkSource().chunkMap.generator, customBiomeSource);
}
public Vector3d getBoundingbox(org.bukkit.entity.EntityType entity) {
Field[] fields = EntityType.class.getDeclaredFields();
for (Field field : fields) {
if (Modifier.isStatic(field.getModifiers()) && field.getType().equals(EntityType.class)) {
try {
EntityType entityType = (EntityType) field.get(null);
if (entityType.getDescriptionId().equals("entity.minecraft." + entity.name().toLowerCase())) {
Vector<Float> v1 = new Vector<>();
v1.add(entityType.getHeight());
entityType.getDimensions();
Vector3d box = new Vector3d( entityType.getWidth(), entityType.getHeight(), entityType.getWidth());
//System.out.println("Entity Type: " + entityType.getDescriptionId() + ", " + "Height: " + height + ", Width: " + width);
return box;
}
} catch (IllegalAccessException e) {
Iris.error("Unable to get entity dimensions!");
e.printStackTrace();
}
}
}
return null;
}
@Override
public Entity spawnEntity(Location location, org.bukkit.entity.EntityType type, CreatureSpawnEvent.SpawnReason reason) {
return ((CraftWorld) location.getWorld()).spawn(location, type.getEntityClass(), null, reason);
}
private static Field getField(Class<?> clazz, Class<?> fieldType) throws NoSuchFieldException {
try {
for (Field f : clazz.getDeclaredFields()) {

View File

@@ -1,19 +1,51 @@
package com.volmit.iris.core.nms.v1_19_R3;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import java.util.concurrent.atomic.AtomicInteger;
import org.bukkit.*;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_19_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R3.block.CraftBlock;
import org.bukkit.craftbukkit.v1_19_R3.block.data.CraftBlockData;
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftDolphin;
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
import org.bukkit.entity.Dolphin;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMSBinding;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.json.JSONObject;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.math.Vector3d;
import com.volmit.iris.util.matter.MatterBiomeInject;
import com.volmit.iris.util.nbt.io.NBTUtil;
import com.volmit.iris.util.nbt.mca.NBTWorld;
import com.volmit.iris.util.nbt.mca.palette.*;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
@@ -24,6 +56,7 @@ import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.TagParser;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
@@ -31,34 +64,8 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk;
import org.bukkit.*;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_19_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R3.block.CraftBlock;
import org.bukkit.craftbukkit.v1_19_R3.block.data.CraftBlockData;
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftDolphin;
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
import org.bukkit.entity.Dolphin;
import org.bukkit.entity.Entity;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import sun.misc.Unsafe;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
public class NMSBinding implements INMSBinding {
private final KMap<Biome, Object> baseBiomeCache = new KMap<>();
private final BlockData AIR = Material.AIR.createBlockData();
@@ -272,6 +279,12 @@ public class NMSBinding implements INMSBinding {
return v;
}
@Override
public KList<Biome> getBiomes() {
return new KList<>(Biome.values()).qdel(Biome.CHERRY_GROVE).qdel(Biome.CUSTOM);
}
@Override
public boolean isBukkit() {
return true;
@@ -479,6 +492,37 @@ public class NMSBinding implements INMSBinding {
biomeSource.set(serverLevel.getChunkSource().chunkMap.generator, customBiomeSource);
}
public Vector3d getBoundingbox(org.bukkit.entity.EntityType entity) {
Field[] fields = EntityType.class.getDeclaredFields();
for (Field field : fields) {
if (Modifier.isStatic(field.getModifiers()) && field.getType().equals(EntityType.class)) {
try {
EntityType entityType = (EntityType) field.get(null);
if (entityType.getDescriptionId().equals("entity.minecraft." + entity.name().toLowerCase())) {
Vector<Float> v1 = new Vector<>();
v1.add(entityType.getHeight());
entityType.getDimensions();
Vector3d box = new Vector3d( entityType.getWidth(), entityType.getHeight(), entityType.getWidth());
//System.out.println("Entity Type: " + entityType.getDescriptionId() + ", " + "Height: " + height + ", Width: " + width);
return box;
}
} catch (IllegalAccessException e) {
Iris.error("Unable to get entity dimensions!");
e.printStackTrace();
}
}
}
return null;
}
@Override
public Entity spawnEntity(Location location, org.bukkit.entity.EntityType type, CreatureSpawnEvent.SpawnReason reason) {
if (type == org.bukkit.entity.EntityType.CAMEL) {
return null;
}
return ((CraftWorld) location.getWorld()).spawn(location, type.getEntityClass(), null, reason);
}
private static Field getField(Class<?> clazz, Class<?> fieldType) throws NoSuchFieldException {
try {
for (Field f : clazz.getDeclaredFields()) {

View File

@@ -5,10 +5,12 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMSBinding;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.json.JSONObject;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.math.Vector3d;
import com.volmit.iris.util.matter.MatterBiomeInject;
import com.volmit.iris.util.nbt.io.NBTUtil;
import com.volmit.iris.util.nbt.mca.NBTWorld;
@@ -24,6 +26,7 @@ import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.TagParser;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
@@ -44,6 +47,9 @@ import org.bukkit.craftbukkit.v1_20_R1.entity.CraftDolphin;
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack;
import org.bukkit.entity.Dolphin;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.entity.EntityType;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
@@ -55,8 +61,10 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import java.util.concurrent.atomic.AtomicInteger;
public class NMSBinding implements INMSBinding {
@@ -274,6 +282,11 @@ public class NMSBinding implements INMSBinding {
return v;
}
@Override
public KList<Biome> getBiomes() {
return new KList<>(Biome.values()).qadd(Biome.CHERRY_GROVE).qdel(Biome.CUSTOM);
}
@Override
public boolean isBukkit() {
return true;
@@ -468,6 +481,34 @@ public class NMSBinding implements INMSBinding {
cd.getHandle().setGotFish(true);
}
public Vector3d getBoundingbox(org.bukkit.entity.EntityType entity) {
Field[] fields = net.minecraft.world.entity.EntityType.class.getDeclaredFields();
for (Field field : fields) {
if (Modifier.isStatic(field.getModifiers()) && field.getType().equals(net.minecraft.world.entity.EntityType.class)) {
try {
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) field.get(null);
if (entityType.getDescriptionId().equals("entity.minecraft." + entity.name().toLowerCase())) {
Vector<Float> v1 = new Vector<>();
v1.add(entityType.getHeight());
entityType.getDimensions();
Vector3d box = new Vector3d( entityType.getWidth(), entityType.getHeight(), entityType.getWidth());
//System.out.println("Entity Type: " + entityType.getDescriptionId() + ", " + "Height: " + height + ", Width: " + width);
return box;
}
} catch (IllegalAccessException e) {
Iris.error("Unable to get entity dimensions!");
e.printStackTrace();
}
}
}
return null;
}
@Override
public Entity spawnEntity(Location location, org.bukkit.entity.EntityType type, CreatureSpawnEvent.SpawnReason reason) {
return ((CraftWorld) location.getWorld()).spawn(location, type.getEntityClass(), null, reason);
}
public void inject(long seed, Engine engine, World world) throws NoSuchFieldException, IllegalAccessException {
ServerLevel serverLevel = ((CraftWorld)world).getHandle();
Class<?> clazz = serverLevel.getChunkSource().chunkMap.generator.getClass();

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