Compare commits
316 Commits
Vulkan
...
serverside
| Author | SHA1 | Date | |
|---|---|---|---|
| 4a771a3e21 | |||
| 0aa109a341 | |||
| 6d44255175 | |||
| f8bb35cb2b | |||
| 52f1aed124 | |||
| 6ae1ba1e17 | |||
| 9105f30fec | |||
| 839c849a9d | |||
| 275f507096 | |||
| 01c5a4072a | |||
| 1697707114 | |||
| 34b0b7dc31 | |||
| 691e1022e3 | |||
| 18fd157474 | |||
| 4948158fa8 | |||
| e3b972c928 | |||
| ad056cb64e | |||
| 3e22ddead5 | |||
| 5c7e27c52d | |||
| 3a5c6f12c0 | |||
| 627eee7a6d | |||
| 7c4c99089b | |||
| 00ec14d319 | |||
| 56188bc7d2 | |||
| 9b2429d388 | |||
| 2aa68ec41d | |||
| 13c9f95750 | |||
| b0549cecff | |||
| 95fb4a0e6a | |||
| 2a3aadc2fa | |||
| 52bddca0df | |||
| 606dede9ef | |||
| e8c9d8391a | |||
| 88ca223bbc | |||
| 4a51bbc796 | |||
| 94ca0e2729 | |||
| 5befdbcddc | |||
| 3e02d7f9dc | |||
| 48b38d9285 | |||
| 8c7c787a8f | |||
| fc0cf56b48 | |||
| 32c63ae15b | |||
| bbf62f7ee3 | |||
| 6211542708 | |||
| a2d5e8cdb3 | |||
| 692b304898 | |||
| 0ca93e311c | |||
| c7aab012ae | |||
| 80ccab21da | |||
| 663ce3cde6 | |||
| 43fee18ae4 | |||
| 014310631e | |||
| 4f7e934c98 | |||
| 563dcd7de6 | |||
| 0a5cc734de | |||
| 0da158fecc | |||
| a7e8bbaf6a | |||
| 80732943c8 | |||
| 994c86d5ba | |||
| 18ccbbbb8e | |||
| 31c3fb9a1e | |||
| 8bdb383b2e | |||
| d13ec687ed | |||
| 43069703cd | |||
| 6d76ace604 | |||
| 9b139575e7 | |||
| efb9129edf | |||
| 6a380f6a7b | |||
| 0798ca01c5 | |||
| 8bfc1430c8 | |||
| bd6621183d | |||
| ccc8076c66 | |||
| 004103551f | |||
| ea47e11ecf | |||
| 8a3837b04b | |||
| edfeaa618b | |||
| 961cdbe868 | |||
| ff6ab67b69 | |||
| c01fb4a716 | |||
| 8bd524791f | |||
| 26059d5656 | |||
| 3f23281e8d | |||
| fb25423deb | |||
| 6928c8dc28 | |||
| 7dfe0e4c50 | |||
| 1429ae5434 | |||
| 3fb4d5a233 | |||
| 872226e5c5 | |||
| fb46820b1f | |||
| a786678bcb | |||
| 0d35a3ea8e | |||
| 6f87e22048 | |||
| 7c07c1e5bd | |||
| 4ddb9659f5 | |||
| e74b8c89ba | |||
| 1b536e4aef | |||
| 335f11acd3 | |||
| b55b560cce | |||
| d87a152052 | |||
| db5a9c7c84 | |||
| 2508efdd91 | |||
| 4852720e14 | |||
| f39d156b11 | |||
| e21eb61335 | |||
| c49f385e3c | |||
| 0584b0e593 | |||
| 220ac89ad8 | |||
| e8e56b66a3 | |||
| 634d8a5b52 | |||
| b621c9fb8d | |||
| 696f84a064 | |||
| 5c13ff8960 | |||
| e102cd78cd | |||
| c5a782acba | |||
| 2008ea2b0c | |||
| 0f349461d9 | |||
| baf464aa02 | |||
| 51d83d803a | |||
| 2b3244159b | |||
| 9255c22d0e | |||
| 4d573c4aea | |||
| a59f359133 | |||
| c83d02c30c | |||
| d01573b03e | |||
| b1fb74539f | |||
| 40962ec9ba | |||
| 0515ac2919 | |||
| 8072695391 | |||
| 2c140bf7d7 | |||
| d3e88b40f4 | |||
| 5e0e15777c | |||
| b57fc5c9aa | |||
| 91ea68075e | |||
| 0840ec8b00 | |||
| d9f37ad7d6 | |||
| 992a7129e5 | |||
| 1d5ea329de | |||
| 00d0a0d2fc | |||
| 95d4314982 | |||
| b588b937ea | |||
| f524ad027e | |||
| b3111b9548 | |||
| 6c38cb3dee | |||
| d75b2dfc1c | |||
| a5b44d65c6 | |||
| 7a1c61405c | |||
| bcb8794d30 | |||
| f9775b115e | |||
| a56a2c2ba3 | |||
| b2efb33a5b | |||
| 5928cfe4b4 | |||
| 234204590f | |||
| e3838c560a | |||
| 6cbc9db1d8 | |||
| 127dcfcb46 | |||
| d1abdd822d | |||
| 85b7ccb38e | |||
| fc157b738e | |||
| 977afffe98 | |||
| 180b22f21a | |||
| d0330ad62f | |||
| 4d22b18f3c | |||
| df797b240e | |||
| a50ef86302 | |||
| 4aede27d75 | |||
| e616c63ebe | |||
| 03ec333a26 | |||
| 27446965db | |||
| c6d7313225 | |||
| 160912a17a | |||
| d408aacbc8 | |||
| 4889287e69 | |||
| 6acdfabb7f | |||
| 3c01d00772 | |||
| 736bb022d2 | |||
| e92130d6cc | |||
| a44dfa92a6 | |||
| 4c8ee862e5 | |||
| 73b89fe573 | |||
| fed2600dbe | |||
| 1d7d94cfec | |||
| 5577261774 | |||
| bf0f3131a0 | |||
| 1b98ea59d7 | |||
| c38efd9d6b | |||
| 4889119061 | |||
| accb2d6af3 | |||
| 24b426a17b | |||
| 8c1bccb430 | |||
| 3cb2a70f4d | |||
| a313cb3db1 | |||
| c29c6d1870 | |||
| b4a64b0c3d | |||
| 1439ca5c08 | |||
| 97ad3bc78f | |||
| b59d8cff8d | |||
| 0e93aa4aea | |||
| 28f8099777 | |||
| c83b0ae533 | |||
| 5ceeebe567 | |||
| e8db9803be | |||
| f009fd41ab | |||
| 9faa3b0a54 | |||
| 0e70478dd3 | |||
| 309b6c6013 | |||
| f20af18b62 | |||
| 7d3329fd98 | |||
| 9a880c3ab1 | |||
| 0b247f04b4 | |||
| 7f1d664731 | |||
| a2288d740b | |||
| 958f0347a3 | |||
| 859bb2e34e | |||
| a2acd08e0d | |||
| b986583fc4 | |||
| c6355f96a6 | |||
| 723d171746 | |||
| 63098d8519 | |||
| 44b743267b | |||
| 720155c408 | |||
| 334b487e23 | |||
| 6e674f3732 | |||
| d130a602d6 | |||
| 8d1ff02937 | |||
| 15b1603e35 | |||
| 4ad0a22db7 | |||
| 35bc1df32c | |||
| bb2a1158c2 | |||
| 76f6f6f746 | |||
| 3b771b5300 | |||
| 9497918e06 | |||
| e52c5d5c67 | |||
| 1ce4750dfc | |||
| 2b371340ff | |||
| e8d906b407 | |||
| 572973c69a | |||
| 9f2d6b9c78 | |||
| 54277040e9 | |||
| bbe333fab7 | |||
| 37fed5a924 | |||
| 5fc29334cd | |||
| 9d32e92e0a | |||
| b08ee76a00 | |||
| 2a4cc6e63d | |||
| 6b2560f98b | |||
| 08111d8874 | |||
| 80f48cd5a4 | |||
| 40cd6c1386 | |||
| e9a13dffb8 | |||
| 22680baad7 | |||
| cca480e5d8 | |||
| 249c3423d9 | |||
| 15cb6468d9 | |||
| f24019d648 | |||
| 733d03c630 | |||
| c3e84648f1 | |||
| 76c33b6b58 | |||
| 26a947ea13 | |||
| 91334c0e5c | |||
| 172b05aeac | |||
| b84e5ca265 | |||
| 20ef5a10fc | |||
| 33640fd35d | |||
| e5f7c5728f | |||
| 5a9bbf9829 | |||
| 23ca022ee9 | |||
| 6c80165523 | |||
| d598061fa7 | |||
| 02498aa189 | |||
| d535f6aa57 | |||
| 933753a38a | |||
| 5483cdbc51 | |||
| 1ea62fd5ec | |||
| aaf0361c50 | |||
| a08feebde0 | |||
| f7131fd2ca | |||
| 2100f4a6fe | |||
| 996f097b9d | |||
| 2e1d737268 | |||
| d374870fb7 | |||
| 5c303df32c | |||
| dfc4b51e89 | |||
| 765202d582 | |||
| 0d2e5adbed | |||
| 68e9d64779 | |||
| b64b44f301 | |||
| 8c07bb37f3 | |||
| c1f6c2dbbd | |||
| 2eb1c16837 | |||
| e5fb8477d3 | |||
| 428cacd262 | |||
| 76926d38db | |||
| 9fec679b03 | |||
| 853a1d1490 | |||
| 01273e31bc | |||
| ebb4808bdc | |||
| fd09adb1a7 | |||
| 82b7b439a4 | |||
| f1b3ae120b | |||
| 70ee20e817 | |||
| f713d65f9c | |||
| c2b98ef694 | |||
| 140c9f6a50 | |||
| c704d61d03 | |||
| aae484fbdf | |||
| a546a97e34 | |||
| 3ca9d98c05 | |||
| 460b73e35c | |||
| 8901a191d9 | |||
| 1bbe35c9f1 | |||
| f92e957826 | |||
| 636e6736a3 | |||
| 8e29f65815 | |||
| a9309078f3 | |||
| 9692e978de | |||
| 914372b858 |
+2
-2
@@ -538,7 +538,7 @@ ij_groovy_wrap_chain_calls_after_dot = false
|
||||
ij_groovy_wrap_long_lines = false
|
||||
|
||||
[{*.har,*.json,*.png.mcmeta,mcmod.info,pack.mcmeta}]
|
||||
indent_size = 4
|
||||
indent_size = 2
|
||||
ij_json_array_wrapping = split_into_lines
|
||||
ij_json_keep_blank_lines_in_code = 0
|
||||
ij_json_keep_indents_on_empty_lines = false
|
||||
@@ -688,7 +688,7 @@ ij_markdown_wrap_text_inside_blockquotes = true
|
||||
ij_toml_keep_indents_on_empty_lines = false
|
||||
|
||||
[{*.yaml,*.yml}]
|
||||
indent_size = 4
|
||||
indent_size = 2
|
||||
ij_yaml_align_values_properties = do_not_align
|
||||
ij_yaml_autoinsert_sequence_marker = true
|
||||
ij_yaml_block_mapping_on_new_line = false
|
||||
|
||||
+8
-3
@@ -18,12 +18,17 @@ variables:
|
||||
.build_java:
|
||||
#image: eclipse-temurin:17
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
key: "gradleCache_$CI_JOB_NAME_SLUG"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
retry:
|
||||
max: 2
|
||||
when:
|
||||
- runner_system_failure
|
||||
- stuck_or_timeout_failure
|
||||
|
||||
|
||||
build:
|
||||
@@ -63,7 +68,7 @@ build:
|
||||
extends: .build_java
|
||||
|
||||
|
||||
api:
|
||||
.api:
|
||||
stage: api
|
||||
needs: []
|
||||
script:
|
||||
@@ -87,7 +92,7 @@ api:
|
||||
|
||||
|
||||
# generate and publish API javadocs
|
||||
pages:
|
||||
.pages:
|
||||
stage: pages
|
||||
needs: []
|
||||
script:
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
[submodule "coreSubProjects"]
|
||||
path = coreSubProjects
|
||||
url = https://gitlab.com/jeseibel/distant-horizons-core.git
|
||||
url = https://gitlab.com/jeseibel/distant-horizons-core.git
|
||||
@@ -0,0 +1,7 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Fabric Client & Server" type="CompoundRunConfigurationType">
|
||||
<toRun name="Fabric Client (:fabric)" type="Application" />
|
||||
<toRun name="Fabric Server (:fabric)" type="Application" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -0,0 +1,7 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Forge Client & Server" type="CompoundRunConfigurationType">
|
||||
<toRun name="Forge Client (gradle)" type="GradleRunConfiguration" />
|
||||
<toRun name="Forge Server (gradle)" type="GradleRunConfiguration" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -0,0 +1,24 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Forge Client (gradle)" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="forge:runClient" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -0,0 +1,24 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Forge Server (gradle)" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="forge:runServer" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -0,0 +1,7 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Neoforge Client & Server" type="CompoundRunConfigurationType">
|
||||
<toRun name="Neoforge Client (gradle)" type="GradleRunConfiguration" />
|
||||
<toRun name="Neoforge Server (gradle)" type="GradleRunConfiguration" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -0,0 +1,24 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Neoforge Client (gradle)" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="neoforge:runClient" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -0,0 +1,24 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Neoforge Server (gradle)" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="neoforge:runServer" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
+20
-20
@@ -27,8 +27,8 @@ def writeBuildGradlePredefine(List<String> mcVers, int mcIndex)
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("# DON'T TOUCH THIS FILE, This is handled by the build script\n");
|
||||
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < mcVers.size(); i++)
|
||||
{
|
||||
String verStr = mcVers[i].replace(".", "_");
|
||||
@@ -104,7 +104,7 @@ subprojects { p ->
|
||||
apply plugin: "com.github.johnrengelman.shadow"
|
||||
if (isMinecraftSubProject)
|
||||
apply plugin: "systems.manifold.manifold-gradle-plugin"
|
||||
|
||||
|
||||
// Apply forge's loom
|
||||
if ((findProject(":forge") && p == project(":forge")) ||
|
||||
(findProject(":neoforge") && p == project(":neoforge"))
|
||||
@@ -118,7 +118,7 @@ subprojects { p ->
|
||||
manifold {
|
||||
manifoldVersion = rootProject.manifold_version
|
||||
}
|
||||
|
||||
|
||||
|
||||
// set up custom configurations (configurations are a way to handle dependencies)
|
||||
configurations {
|
||||
@@ -191,7 +191,7 @@ subprojects { p ->
|
||||
forgeShadowMe("org.joml:joml:${rootProject.joml_version}")
|
||||
else
|
||||
implementation("org.joml:joml:${rootProject.joml_version}")
|
||||
|
||||
|
||||
// JUnit tests
|
||||
implementation("org.junit.jupiter:junit-jupiter:5.8.2")
|
||||
implementation("org.junit.jupiter:junit-jupiter-engine:5.8.2")
|
||||
@@ -201,25 +201,24 @@ subprojects { p ->
|
||||
// Note: MC 1.16 uses 8.2.1, and versions after use 8.5.12
|
||||
// We cannot relocate this library since we call some MC classes that reference it
|
||||
implementation("it.unimi.dsi:fastutil:${rootProject.fastutil_version}")
|
||||
|
||||
|
||||
|
||||
|
||||
// Compression
|
||||
forgeShadowMe("org.lz4:lz4-java:${rootProject.lz4_version}") // LZ4
|
||||
forgeShadowMe("org.tukaani:xz:${rootProject.xz_version}") // LZMA
|
||||
|
||||
// Sqlite Database
|
||||
forgeShadowMe("org.xerial:sqlite-jdbc:${rootProject.sqlite_jdbc_version}")
|
||||
|
||||
|
||||
// NightConfig (includes Toml & Json)
|
||||
forgeShadowMe("com.electronwill.night-config:toml:${rootProject.nightconfig_version}")
|
||||
forgeShadowMe("com.electronwill.night-config:json:${rootProject.nightconfig_version}")
|
||||
|
||||
// SVG (not needed atm)
|
||||
// forgeShadowMe("com.formdev:svgSalamander:${rootProject.svgSalamander_version}")
|
||||
|
||||
|
||||
// Netty
|
||||
// Breaks 1.16.5
|
||||
//forgeShadowMe("io.netty:netty-all:${rootProject.netty_version}")
|
||||
implementation("io.netty:netty-buffer:${rootProject.netty_version}")
|
||||
|
||||
// Remember, for lwjgl dependencies that arent included in Minecraft, you need to also need to add it to the ShadowJar thing
|
||||
forgeShadowMe("org.lwjgl:lwjgl-jawt:${rootProject.lwjgl_version}") {
|
||||
@@ -277,7 +276,7 @@ subprojects { p ->
|
||||
if (isMinecraftSubProject && p != project(":common")) {
|
||||
configurations.push(project.configurations.shadowCommon) // Shadow the common subproject
|
||||
relocate "com.seibel.distanthorizons.common", "loaderCommon.${p.name}.com.seibel.distanthorizons.common" // Move the loader files to a different location
|
||||
|
||||
|
||||
if (findProject(":fabricLike") && p != project(":fabricLike")) {
|
||||
configurations.push(project.configurations.shadowFabricLike) // Shadow the fabricLike subproject
|
||||
relocate "com.seibel.distanthorizons.fabriclike", "loaderCommon.${p.name}.com.seibel.distanthorizons.fabriclike" // Move the loader files to a different location
|
||||
@@ -291,11 +290,11 @@ subprojects { p ->
|
||||
|
||||
// Compression (LZ4)
|
||||
relocate "net.jpountz", "${librariesLocation}.jpountz"
|
||||
|
||||
|
||||
// Sqlite Database
|
||||
//At the moment, there is a bug in this library which doesnt allow it to be relocated
|
||||
// relocate "org.sqlite", "${librariesLocation}.sqlite"
|
||||
|
||||
|
||||
// JOML
|
||||
if (project.hasProperty("embed_joml") && embed_joml == "true")
|
||||
relocate "org.joml", "${librariesLocation}.joml"
|
||||
@@ -305,9 +304,10 @@ subprojects { p ->
|
||||
|
||||
// SVG (not needed atm)
|
||||
// relocate "com.kitfox.svg", "${librariesLocation}.kitfox.svg"
|
||||
|
||||
|
||||
// Netty
|
||||
relocate "io.netty", "${librariesLocation}.netty"
|
||||
// Don't relocate, it causes problems with using MC's FriendlyByteBufs
|
||||
// relocate "io.netty", "${librariesLocation}.netty"
|
||||
|
||||
mergeServiceFiles()
|
||||
}
|
||||
@@ -329,7 +329,7 @@ subprojects { p ->
|
||||
"META-INF/neoforge.mods.toml",
|
||||
|
||||
// The mixins for each of the loaders
|
||||
"DistantHorizons."+ p.name +".fabricLike.mixins.json"
|
||||
"DistantHorizons." + p.name + ".fabricLike.mixins.json"
|
||||
]
|
||||
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
|
||||
|
||||
@@ -388,14 +388,14 @@ subprojects { p ->
|
||||
fabric_incompatibility_list : fabric_incompatibility_list,
|
||||
fabric_recommend_list : fabric_recommend_list,
|
||||
]
|
||||
|
||||
|
||||
// replace any properties in the sub-projects with the values defined here
|
||||
inputs.properties replaceProperties
|
||||
replaceProperties.put "project", project
|
||||
filesMatching(resourceTargets) {
|
||||
expand replaceProperties
|
||||
}
|
||||
|
||||
|
||||
intoTargets.each { target ->
|
||||
if (file(target).exists()) {
|
||||
copy {
|
||||
@@ -639,4 +639,4 @@ task cleanMergedJars() {
|
||||
}
|
||||
}
|
||||
// add cleanMergedJars to the end of the "clean" task
|
||||
tasks["clean"].finalizedBy(cleanMergedJars)
|
||||
tasks["clean"].finalizedBy(cleanMergedJars)
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "==================== Note: All build jars will be in the folder called 'buildAllJars' ===================="
|
||||
mkdir -p buildAllJars | true
|
||||
mkdir -p buildAllJars
|
||||
rm -rf buildAllJars/*
|
||||
|
||||
# Loop trough everything in the version properties folder
|
||||
for d in versionProperties/*; do
|
||||
@@ -11,12 +12,17 @@ for d in versionProperties/*; do
|
||||
# Clean out the folders, build it, and merge it
|
||||
# (We could use "./" to run gradlew, but as it is a shell script im going to be running it with the "sh" command)
|
||||
echo "==================== Cleaning workspace to build $version ===================="
|
||||
sh gradlew clean -PmcVer=$version --no-daemon || true
|
||||
sh gradlew clean -PmcVer=$version
|
||||
if [ $? != 0 ]; then continue; fi
|
||||
|
||||
echo "====================Building $version ===================="
|
||||
sh gradlew build -PmcVer=$version --no-daemon || true
|
||||
sh gradlew build -PmcVer=$version
|
||||
if [ $? != 0 ]; then continue; fi
|
||||
|
||||
echo "==================== Merging $version ===================="
|
||||
sh gradlew mergeJars -PmcVer=$version --no-daemon || true
|
||||
sh gradlew mergeJars -PmcVer=$version
|
||||
if [ $? != 0 ]; then continue; fi
|
||||
|
||||
echo "==================== Moving jar ===================="
|
||||
mv Merged/*.jar buildAllJars/ || true
|
||||
# The "| true" at the end of those are just to make sure the script continues even if a build fails
|
||||
mv Merged/*.jar buildAllJars/
|
||||
done
|
||||
|
||||
+8
-2
@@ -1,3 +1,10 @@
|
||||
buildscript {
|
||||
configurations.configureEach {
|
||||
resolutionStrategy {
|
||||
force 'org.spongepowered:vanillagradle:0.2.1-20240507.024226-82'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// temporary fix for broken spongepowered version
|
||||
buildscript {
|
||||
@@ -35,5 +42,4 @@ publishing {
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+168
-12
@@ -1,18 +1,30 @@
|
||||
package com.seibel.distanthorizons.common;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.*;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent;
|
||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent;
|
||||
import com.seibel.distanthorizons.common.wrappers.DependencySetup;
|
||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftDedicatedServerWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.config.ConfigBase;
|
||||
import com.seibel.distanthorizons.core.config.eventHandlers.presets.ThreadPresetConfigEventHandler;
|
||||
import com.seibel.distanthorizons.core.config.types.AbstractConfigType;
|
||||
import com.seibel.distanthorizons.core.config.types.ConfigEntry;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.jar.ModJarInfo;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.network.messages.MessageRegistry;
|
||||
import com.seibel.distanthorizons.core.network.messages.base.CodecCrashMessage;
|
||||
import com.seibel.distanthorizons.core.util.objects.Pair;
|
||||
import com.seibel.distanthorizons.core.world.DhServerWorld;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModAccessor;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
||||
@@ -23,9 +35,25 @@ import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static com.mojang.brigadier.arguments.DoubleArgumentType.doubleArg;
|
||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
|
||||
import static com.seibel.distanthorizons.core.network.messages.MessageRegistry.DEBUG_ENABLE_CODEC_CRASH_MESSAGE;
|
||||
import static net.minecraft.commands.Commands.argument;
|
||||
import static net.minecraft.commands.Commands.literal;
|
||||
|
||||
#if MC_VER >= MC_1_19_2
|
||||
import net.minecraft.network.chat.Component;
|
||||
#else // < 1.19.2
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Base for all mod loader initializers
|
||||
* and handles most setup.
|
||||
@@ -67,7 +95,7 @@ public abstract class AbstractModInitializer
|
||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeDhInitEvent.class, null);
|
||||
|
||||
this.startup();
|
||||
this.printModInfo(true);
|
||||
this.printModInfo();
|
||||
|
||||
this.createClientProxy().registerEvents();
|
||||
this.createServerProxy(false).registerEvents();
|
||||
@@ -91,7 +119,7 @@ public abstract class AbstractModInitializer
|
||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeDhInitEvent.class, null);
|
||||
|
||||
this.startup();
|
||||
this.printModInfo(false);
|
||||
this.printModInfo();
|
||||
|
||||
// This prevents returning uninitialized Config values,
|
||||
// resulting from a circular reference mid-initialization in a static class
|
||||
@@ -100,6 +128,8 @@ public abstract class AbstractModInitializer
|
||||
|
||||
this.createServerProxy(true).registerEvents();
|
||||
|
||||
this.initializeModCompat();
|
||||
|
||||
LOGGER.info(ModInfo.READABLE_NAME + " Initialized");
|
||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterDhInitEvent.class, null);
|
||||
|
||||
@@ -130,17 +160,14 @@ public abstract class AbstractModInitializer
|
||||
this.createInitialBindings();
|
||||
}
|
||||
|
||||
private void printModInfo(boolean printGitInfo)
|
||||
private void printModInfo()
|
||||
{
|
||||
LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION);
|
||||
|
||||
if (printGitInfo)
|
||||
{
|
||||
// Useful for dev builds
|
||||
LOGGER.info("DH Branch: " + ModJarInfo.Git_Branch);
|
||||
LOGGER.info("DH Commit: " + ModJarInfo.Git_Commit);
|
||||
LOGGER.info("DH Jar Build Source: " + ModJarInfo.Build_Source);
|
||||
}
|
||||
// Useful for dev builds
|
||||
LOGGER.info("DH Branch: " + ModJarInfo.Git_Branch);
|
||||
LOGGER.info("DH Commit: " + ModJarInfo.Git_Commit);
|
||||
LOGGER.info("DH Jar Build Source: " + ModJarInfo.Build_Source);
|
||||
}
|
||||
|
||||
protected <T extends IModAccessor> void tryCreateModCompatAccessor(String modId, Class<? super T> accessorClass, Supplier<T> accessorConstructor)
|
||||
@@ -166,7 +193,136 @@ public abstract class AbstractModInitializer
|
||||
LOGGER.info("Mod Post-Initialized");
|
||||
}
|
||||
|
||||
private void initCommands() { /* currently unimplemented */ }
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
private void initCommands()
|
||||
{
|
||||
LiteralArgumentBuilder<CommandSourceStack> builder = literal("dhconfig")
|
||||
.requires(source -> source.hasPermission(4));
|
||||
|
||||
for (AbstractConfigType<?, ?> type : ConfigBase.INSTANCE.entries)
|
||||
{
|
||||
if (!(type instanceof ConfigEntry))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//noinspection PatternVariableCanBeUsed
|
||||
ConfigEntry configEntry = (ConfigEntry) type;
|
||||
if (configEntry.getServersideShortName() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Function<
|
||||
Function<CommandContext<CommandSourceStack>, Object>,
|
||||
Command<CommandSourceStack>
|
||||
> makeConfigUpdater = getter -> c -> {
|
||||
Object value = getter.apply(c);
|
||||
|
||||
c.getSource().sendSuccess(
|
||||
#if MC_VER >= MC_1_20_1
|
||||
() -> Component.literal("Changed the value of "+configEntry.getServersideShortName()+" to "+value),
|
||||
#elif MC_VER >= MC_1_19_2
|
||||
Component.literal("Changed the value of "+configEntry.getServersideShortName()+" to "+value),
|
||||
#else
|
||||
new TranslatableComponent("Changed the value of "+configEntry.getServersideShortName()+" to "+value),
|
||||
#endif
|
||||
true);
|
||||
configEntry.set(value);
|
||||
return 1;
|
||||
};
|
||||
|
||||
LiteralArgumentBuilder<CommandSourceStack> subcommand = literal(configEntry.getServersideShortName())
|
||||
.executes(c -> {
|
||||
#if MC_VER >= MC_1_20_1
|
||||
c.getSource().sendSuccess(() -> Component.literal("Current value of "+configEntry.getServersideShortName()+" is "+configEntry.get()), true);
|
||||
#elif MC_VER >= MC_1_19_2
|
||||
c.getSource().sendSuccess(Component.literal("Current value of "+configEntry.getServersideShortName()+" is "+configEntry.get()), true);
|
||||
#else // < 1.19.2
|
||||
c.getSource().sendSuccess(new TranslatableComponent("Current value of "+configEntry.getServersideShortName()+" is "+configEntry.get()), true);
|
||||
#endif
|
||||
return 1;
|
||||
});
|
||||
|
||||
if (Enum.class.isAssignableFrom(configEntry.getType()))
|
||||
{
|
||||
for (Object choice : configEntry.getType().getEnumConstants())
|
||||
{
|
||||
subcommand.then(
|
||||
literal(choice.toString())
|
||||
.executes(makeConfigUpdater.apply(c -> choice))
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean setterAdded = false;
|
||||
|
||||
for (java.util.Map.Entry<Class<?>, Pair<Supplier<ArgumentType<?>>, BiFunction<CommandContext<?>, String, ?>>> pair : new HashMap<
|
||||
Class<?>,
|
||||
Pair<
|
||||
Supplier<ArgumentType<?>>,
|
||||
BiFunction<CommandContext<?>, String, ?>>
|
||||
>() {{
|
||||
this.put(Integer.class, new Pair<>(() -> integer((int) configEntry.getMin(), (int) configEntry.getMax()), IntegerArgumentType::getInteger));
|
||||
this.put(Double.class, new Pair<>(() -> doubleArg((double) configEntry.getMin(), (double) configEntry.getMax()), DoubleArgumentType::getDouble));
|
||||
this.put(Boolean.class, new Pair<>(BoolArgumentType::bool, BoolArgumentType::getBool));
|
||||
this.put(String.class, new Pair<>(StringArgumentType::string, StringArgumentType::getString));
|
||||
}}.entrySet())
|
||||
{
|
||||
if (!pair.getKey().isAssignableFrom(configEntry.getType()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
subcommand.then(argument("value", pair.getValue().first.get())
|
||||
.executes(makeConfigUpdater.apply(c -> pair.getValue().second.apply(c, "value"))));
|
||||
|
||||
setterAdded = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!setterAdded)
|
||||
{
|
||||
throw new RuntimeException("Config type of "+type.getName()+" is not supported: "+configEntry.getType().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
builder.then(subcommand);
|
||||
}
|
||||
|
||||
this.commandDispatcher.register(builder);
|
||||
|
||||
if (DEBUG_ENABLE_CODEC_CRASH_MESSAGE)
|
||||
{
|
||||
LiteralArgumentBuilder<CommandSourceStack> dhcrash = literal("dhcrash")
|
||||
.requires(source -> source.hasPermission(4))
|
||||
.then(literal("encode")
|
||||
.executes(c -> {
|
||||
assert SharedApi.getIDhServerWorld() != null;
|
||||
((DhServerWorld) SharedApi.getIDhServerWorld()).remotePlayerConnectionHandler
|
||||
#if MC_VER >= MC_1_19_2
|
||||
.getConnectedPlayer(ServerPlayerWrapper.getWrapper(Objects.requireNonNull(c.getSource().getPlayer())))
|
||||
#else
|
||||
.getConnectedPlayer(ServerPlayerWrapper.getWrapper(Objects.requireNonNull(c.getSource().getPlayerOrException())))
|
||||
#endif
|
||||
.session.sendMessage(new CodecCrashMessage(CodecCrashMessage.ECrashPhase.ENCODE));
|
||||
return 1;
|
||||
}))
|
||||
.then(literal("decode")
|
||||
.executes(c -> {
|
||||
assert SharedApi.getIDhServerWorld() != null;
|
||||
((DhServerWorld) SharedApi.getIDhServerWorld()).remotePlayerConnectionHandler
|
||||
#if MC_VER >= MC_1_19_2
|
||||
.getConnectedPlayer(ServerPlayerWrapper.getWrapper(Objects.requireNonNull(c.getSource().getPlayer())))
|
||||
#else
|
||||
.getConnectedPlayer(ServerPlayerWrapper.getWrapper(Objects.requireNonNull(c.getSource().getPlayerOrException())))
|
||||
#endif
|
||||
.session.sendMessage(new CodecCrashMessage(CodecCrashMessage.ECrashPhase.DECODE));
|
||||
return 1;
|
||||
}));
|
||||
this.commandDispatcher.register(dhcrash);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -179,4 +335,4 @@ public abstract class AbstractModInitializer
|
||||
void registerEvents();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
package com.seibel.distanthorizons.common;
|
||||
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.logging.ConfigBasedLogger;
|
||||
import com.seibel.distanthorizons.core.network.event.internal.IncompatibleMessageEvent;
|
||||
import com.seibel.distanthorizons.core.network.event.internal.ProtocolErrorEvent;
|
||||
import com.seibel.distanthorizons.core.network.messages.MessageRegistry;
|
||||
import com.seibel.distanthorizons.core.network.messages.NetworkMessage;
|
||||
import com.seibel.distanthorizons.core.network.messages.base.CloseReasonMessage;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public abstract class AbstractPluginPacketSender implements IPluginPacketSender
|
||||
{
|
||||
private static final ConfigBasedLogger LOGGER = new ConfigBasedLogger(LogManager.getLogger(),
|
||||
() -> Config.Client.Advanced.Logging.logNetworkEvent.get());
|
||||
|
||||
#if MC_VER >= MC_1_21_1
|
||||
public static final ResourceLocation WRAPPER_PACKET_RESOURCE = ResourceLocation.fromNamespaceAndPath(ModInfo.RESOURCE_NAMESPACE, ModInfo.WRAPPER_PACKET_PATH);
|
||||
#else
|
||||
public static final ResourceLocation WRAPPER_PACKET_RESOURCE = new ResourceLocation(ModInfo.RESOURCE_NAMESPACE, ModInfo.WRAPPER_PACKET_PATH);
|
||||
#endif
|
||||
|
||||
|
||||
@Override
|
||||
public final void sendPluginPacketServer(IServerPlayerWrapper serverPlayer, NetworkMessage message)
|
||||
{
|
||||
this.sendPluginPacketServer((ServerPlayer) serverPlayer.getWrappedMcObject(), message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void sendPluginPacketClient(NetworkMessage message);
|
||||
public abstract void sendPluginPacketServer(ServerPlayer serverPlayer, NetworkMessage message);
|
||||
|
||||
@Nullable
|
||||
public static NetworkMessage decodeMessage(FriendlyByteBuf in)
|
||||
{
|
||||
NetworkMessage message = null;
|
||||
|
||||
try
|
||||
{
|
||||
in.markReaderIndex();
|
||||
|
||||
int protocolVersion = in.readShort();
|
||||
if (protocolVersion != ModInfo.PROTOCOL_VERSION)
|
||||
{
|
||||
return new IncompatibleMessageEvent(protocolVersion);
|
||||
}
|
||||
|
||||
message = MessageRegistry.INSTANCE.createMessage(in.readUnsignedShort());
|
||||
message.decode(in);
|
||||
|
||||
if (in.isReadable())
|
||||
{
|
||||
throw new IOException("Buffer has not been fully read");
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
in.resetReaderIndex();
|
||||
|
||||
LOGGER.error("Failed to decode message", e);
|
||||
LOGGER.error("Buffer: {}", in);
|
||||
LOGGER.error("Buffer contents: [{}]", ByteBufUtil.hexDump(in));
|
||||
|
||||
return new ProtocolErrorEvent(e, message, true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Prevent connection crashing if not entire buffer has been read
|
||||
in.readerIndex(in.writerIndex());
|
||||
}
|
||||
}
|
||||
|
||||
public static void encodeMessage(FriendlyByteBuf out, NetworkMessage message)
|
||||
{
|
||||
// This is intentionally unhandled, because errors related to this are unlikely to appear in wild
|
||||
Objects.requireNonNull(message);
|
||||
out.writeShort(ModInfo.PROTOCOL_VERSION);
|
||||
|
||||
try
|
||||
{
|
||||
out.markWriterIndex();
|
||||
out.writeShort(MessageRegistry.INSTANCE.getMessageId(message));
|
||||
message.encode(out);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error("Failed to encode message", e);
|
||||
LOGGER.error("Message: {}", message);
|
||||
|
||||
message.getSession().tryHandleMessage(new ProtocolErrorEvent(e, message, false));
|
||||
|
||||
// Encode close reason message instead
|
||||
out.resetWriterIndex();
|
||||
message = new CloseReasonMessage("Internal error on other side");
|
||||
out.writeShort(MessageRegistry.INSTANCE.getMessageId(message));
|
||||
message.encode(out);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.seibel.distanthorizons.common;
|
||||
|
||||
#if MC_VER >= MC_1_20_6
|
||||
|
||||
import com.seibel.distanthorizons.core.network.messages.NetworkMessage;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public record CommonPacketPayload(
|
||||
@Nullable NetworkMessage message
|
||||
) implements CustomPacketPayload
|
||||
{
|
||||
public static final Type<CommonPacketPayload> TYPE = new Type<>(AbstractPluginPacketSender.WRAPPER_PACKET_RESOURCE);
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Type<? extends CustomPacketPayload> type()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
|
||||
public static class Codec implements StreamCodec<FriendlyByteBuf, CommonPacketPayload>
|
||||
{
|
||||
@NotNull
|
||||
@Override
|
||||
public CommonPacketPayload decode(@NotNull FriendlyByteBuf in)
|
||||
{
|
||||
return new CommonPacketPayload(AbstractPluginPacketSender.decodeMessage(in));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(@NotNull FriendlyByteBuf out, CommonPacketPayload payload)
|
||||
{
|
||||
AbstractPluginPacketSender.encodeMessage(out, payload.message());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
+4
-14
@@ -179,19 +179,9 @@ public class WrapperFactory implements IWrapperFactory
|
||||
|
||||
|
||||
// level wrapper
|
||||
ILevelWrapper levelWrapper;
|
||||
if (level instanceof ServerLevel)
|
||||
{
|
||||
levelWrapper = ServerLevelWrapper.getWrapper((ServerLevel)level);
|
||||
}
|
||||
else if (level instanceof ClientLevel)
|
||||
{
|
||||
levelWrapper = ClientLevelWrapper.getWrapper((ClientLevel)level);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ClassCastException(createChunkWrapperErrorMessage(objectArray));
|
||||
}
|
||||
ILevelWrapper levelWrapper = level.isClientSide()
|
||||
? ClientLevelWrapper.getWrapper((ClientLevel)level)
|
||||
: ServerLevelWrapper.getWrapper((ServerLevel)level);
|
||||
|
||||
|
||||
return new ChunkWrapper(chunk, lightSource, levelWrapper);
|
||||
@@ -215,7 +205,7 @@ public class WrapperFactory implements IWrapperFactory
|
||||
expectedClassNames = new String[]
|
||||
{
|
||||
ChunkAccess.class.getName(),
|
||||
ServerLevel.class.getName() + "] or [" + ClientLevel.class.getName()
|
||||
"[ServerLevel] or [ClientLevel]" // Classes are not referenced by names to avoid exception when one of them is missing
|
||||
};
|
||||
//#endif
|
||||
|
||||
|
||||
+2
-5
@@ -54,7 +54,6 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.EmptyBlockGetter;
|
||||
#else
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
@@ -542,9 +541,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
{
|
||||
|
||||
#if MC_VER > MC_1_17_1
|
||||
// use the given level if possible, otherwise try using the currently loaded one
|
||||
Level level = (levelWrapper != null ? (Level) levelWrapper.getWrappedMcObject() : null);
|
||||
level = (level == null ? Minecraft.getInstance().level : level);
|
||||
Level level = (Level)Objects.requireNonNull(levelWrapper.getWrappedMcObject());
|
||||
#endif
|
||||
|
||||
Block block;
|
||||
@@ -759,4 +756,4 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+7
-3
@@ -22,9 +22,12 @@ package com.seibel.distanthorizons.common.wrappers.chunk;
|
||||
import com.seibel.distanthorizons.common.wrappers.block.BiomeWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.DhLitWorldGenRegion;
|
||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
|
||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.world.EWorldEnvironment;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.ChunkLightStorage;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
@@ -140,7 +143,8 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
|
||||
// FIXME +1 is to handle the fact that LodDataBuilder adds +1 to all block lighting calculations, also done in the relative position validator
|
||||
|
||||
chunksNeedingClientLightUpdating.add(this);
|
||||
if (SharedApi.getEnvironment() != EWorldEnvironment.Server_Only)
|
||||
chunksNeedingClientLightUpdating.add(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -348,7 +352,7 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
if (this.chunk instanceof LevelChunk)
|
||||
{
|
||||
LevelChunk levelChunk = (LevelChunk) this.chunk;
|
||||
if (levelChunk.getLevel() instanceof ClientLevel)
|
||||
if (levelChunk.getLevel().isClientSide())
|
||||
{
|
||||
// connected to a server
|
||||
return this.isMcClientLightingCorrect;
|
||||
@@ -605,4 +609,4 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
// return this.blockBiomeHashCode;
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
+30
-17
@@ -1,21 +1,20 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.level;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.level.IServerKeyedClientLevel;
|
||||
import com.seibel.distanthorizons.core.level.IKeyedClientLevelManager;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class KeyedClientLevelManager implements IKeyedClientLevelManager
|
||||
{
|
||||
public static final KeyedClientLevelManager INSTANCE = new KeyedClientLevelManager();
|
||||
|
||||
/** This is set and managed by the ClientApi for servers with support for DH. */
|
||||
private IServerKeyedClientLevel overrideWrapper = null;
|
||||
private boolean useOverrideWrapper = false;
|
||||
@Nullable
|
||||
private IServerKeyedClientLevel serverKeyedLevel = null;
|
||||
private boolean enabled = false;
|
||||
|
||||
|
||||
|
||||
//=============//
|
||||
@@ -30,25 +29,39 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager
|
||||
// level override logic //
|
||||
//======================//
|
||||
|
||||
@Override
|
||||
public void setServerKeyedLevel(IServerKeyedClientLevel clientLevel) { this.overrideWrapper = clientLevel; }
|
||||
@Override
|
||||
public IServerKeyedClientLevel getOverrideWrapper() { return this.overrideWrapper; }
|
||||
|
||||
@Override
|
||||
public IServerKeyedClientLevel getServerKeyedLevel(ILevelWrapper level, String serverLevelKey)
|
||||
@Nullable
|
||||
public IServerKeyedClientLevel getServerKeyedLevel()
|
||||
{
|
||||
Objects.requireNonNull(level);
|
||||
Objects.requireNonNull(serverLevelKey);
|
||||
return new ServerKeyedClientLevel((ClientLevel) level.getWrappedMcObject(), serverLevelKey);
|
||||
return this.serverKeyedLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IServerKeyedClientLevel setServerKeyedLevel(IClientLevelWrapper clientLevel, String levelKey)
|
||||
{
|
||||
IServerKeyedClientLevel keyedLevel = new ServerKeyedClientLevel((ClientLevel) clientLevel.getWrappedMcObject(), levelKey);
|
||||
this.serverKeyedLevel = keyedLevel;
|
||||
this.enabled = true;
|
||||
return keyedLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseOverrideWrapper(boolean useOverrideWrapper) { this.useOverrideWrapper = useOverrideWrapper; }
|
||||
public void clearServerKeyedLevel()
|
||||
{
|
||||
this.serverKeyedLevel = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUseOverrideWrapper() { return this.useOverrideWrapper; }
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-1
@@ -18,4 +18,11 @@ public class ServerKeyedClientLevel extends ClientLevelWrapper implements IServe
|
||||
@Override
|
||||
public String getServerLevelKey() { return this.serverLevelKey; }
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDimensionName()
|
||||
{
|
||||
return this.getServerLevelKey();
|
||||
}
|
||||
|
||||
}
|
||||
+22
-3
@@ -44,6 +44,7 @@ import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -53,6 +54,7 @@ import net.minecraft.network.chat.TextComponent;
|
||||
#endif
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -222,12 +224,20 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
@Override
|
||||
public IClientLevelWrapper getWrappedClientLevel()
|
||||
{
|
||||
if (MINECRAFT.level == null)
|
||||
return this.getWrappedClientLevel(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IClientLevelWrapper getWrappedClientLevel(boolean bypassMultiverse)
|
||||
{
|
||||
ClientLevel level = MINECRAFT.level;
|
||||
if (level == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return ClientLevelWrapper.getWrapperIgnoringOverride(MINECRAFT.level);
|
||||
return ClientLevelWrapper.getWrapper(level, bypassMultiverse);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -266,7 +276,10 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
public void sendChatMessage(String string)
|
||||
{
|
||||
LocalPlayer player = this.getPlayer();
|
||||
if (player == null) return;
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#if MC_VER < MC_1_19_2
|
||||
player.sendMessage(new TextComponent(string), getPlayer().getUUID());
|
||||
#else
|
||||
@@ -306,4 +319,10 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
@Override
|
||||
public void executeOnRenderThread(Runnable runnable) { MINECRAFT.execute(runnable); }
|
||||
|
||||
@Override
|
||||
public boolean isWorldInitialized()
|
||||
{
|
||||
throw new NotImplementedException("TODO");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-1
@@ -28,4 +28,10 @@ public class MinecraftDedicatedServerWrapper implements IMinecraftSharedWrapper
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean isWorldInitialized()
|
||||
{
|
||||
return this.dedicatedServer.getWorldData().overworldData().isInitialized();
|
||||
}
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.misc;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface IMixinServerPlayer
|
||||
{
|
||||
@Nullable
|
||||
ServerLevel distantHorizons$getDimensionChangeDestination();
|
||||
|
||||
}
|
||||
+82
-16
@@ -1,54 +1,120 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.misc;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.util.math.Vec3d;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* This wrapper transparently ensures that underlying {@link ServerPlayer} is always valid,
|
||||
* unless the player has disconnected.
|
||||
*/
|
||||
public class ServerPlayerWrapper implements IServerPlayerWrapper
|
||||
{
|
||||
private static final ConcurrentMap<ServerPlayer, ServerPlayerWrapper>
|
||||
serverPlayerWrapperMap = new MapMaker().weakKeys().makeMap();
|
||||
private static final ConcurrentMap<ServerGamePacketListenerImpl, ServerPlayerWrapper> serverPlayerWrapperMap = new MapMaker().weakKeys().weakValues().makeMap();
|
||||
|
||||
private final ServerPlayer serverPlayer;
|
||||
private final ServerGamePacketListenerImpl connection;
|
||||
private ServerPlayer serverPlayer()
|
||||
{
|
||||
return this.connection.player;
|
||||
}
|
||||
|
||||
public static ServerPlayerWrapper getWrapper(ServerPlayer serverPlayer)
|
||||
{
|
||||
return serverPlayerWrapperMap.computeIfAbsent(serverPlayer, ServerPlayerWrapper::new);
|
||||
return serverPlayerWrapperMap.computeIfAbsent(serverPlayer.connection, ignored -> new ServerPlayerWrapper(serverPlayer.connection));
|
||||
}
|
||||
|
||||
private ServerPlayerWrapper(ServerPlayer serverPlayer)
|
||||
private ServerPlayerWrapper(ServerGamePacketListenerImpl connection)
|
||||
{
|
||||
this.serverPlayer = serverPlayer;
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
public UUID getUUID()
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return serverPlayer.getUUID();
|
||||
return this.serverPlayer().getName().getString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IServerLevelWrapper getLevel()
|
||||
{
|
||||
#if MC_VER < MC_1_20_1
|
||||
return ServerLevelWrapper.getWrapper(this.serverPlayer.getLevel());
|
||||
#else
|
||||
return ServerLevelWrapper.getWrapper(this.serverPlayer.serverLevel());
|
||||
ServerLevel level = ((IMixinServerPlayer) this.serverPlayer()).distantHorizons$getDimensionChangeDestination();
|
||||
if (level == null)
|
||||
{
|
||||
#if MC_VER < MC_1_20_1
|
||||
level = this.serverPlayer().getLevel();
|
||||
#else
|
||||
level = this.serverPlayer().serverLevel();
|
||||
#endif
|
||||
}
|
||||
|
||||
return ServerLevelWrapper.getWrapper(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getPosition()
|
||||
{
|
||||
Vec3 position = this.serverPlayer().position();
|
||||
return new Vec3d(position.x, position.y, position.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewDistance()
|
||||
{
|
||||
return this.serverPlayer().server.getPlayerList().getViewDistance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketAddress getRemoteAddress()
|
||||
{
|
||||
#if MC_VER >= MC_1_19_4
|
||||
return this.serverPlayer().connection.getRemoteAddress();
|
||||
#else // < 1.19.4
|
||||
return this.serverPlayer().connection.connection.getRemoteAddress();
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getWrappedMcObject()
|
||||
{
|
||||
return serverPlayer;
|
||||
return this.serverPlayer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Wrapped{" + serverPlayer.toString() + "}";
|
||||
return "Wrapped{" + this.serverPlayer() + "}";
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof ServerPlayerWrapper))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ServerPlayerWrapper that = (ServerPlayerWrapper) o;
|
||||
return Objects.equal(this.connection, that.connection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hashCode(this.connection);
|
||||
}
|
||||
|
||||
}
|
||||
+33
-19
@@ -9,6 +9,7 @@ import com.seibel.distanthorizons.common.wrappers.block.ClientBlockStateColorCac
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.level.*;
|
||||
import com.seibel.distanthorizons.core.level.IServerKeyedClientLevel;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
|
||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
@@ -69,23 +70,31 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
||||
// wrapper logic //
|
||||
//===============//
|
||||
|
||||
@Nullable
|
||||
public static IClientLevelWrapper getWrapper(@Nullable ClientLevel level)
|
||||
public static IClientLevelWrapper getWrapper(@NotNull ClientLevel level)
|
||||
{
|
||||
if (level == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// used if the client is connected to a server that defines the currently loaded level
|
||||
if (KEYED_CLIENT_LEVEL_MANAGER.getUseOverrideWrapper())
|
||||
{
|
||||
return KEYED_CLIENT_LEVEL_MANAGER.getOverrideWrapper();
|
||||
}
|
||||
|
||||
return getWrapperIgnoringOverride(level);
|
||||
return getWrapper(level, false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IClientLevelWrapper getWrapper(@Nullable ClientLevel level, boolean bypassLevelKeyManager)
|
||||
{
|
||||
if (!bypassLevelKeyManager)
|
||||
{
|
||||
if (level == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// used if the client is connected to a server that defines the currently loaded level
|
||||
IServerKeyedClientLevel overrideLevel = KEYED_CLIENT_LEVEL_MANAGER.getServerKeyedLevel();
|
||||
if (overrideLevel != null)
|
||||
{
|
||||
return overrideLevel;
|
||||
}
|
||||
}
|
||||
|
||||
return LEVEL_WRAPPER_BY_CLIENT_LEVEL.computeIfAbsent(level, ClientLevelWrapper::new);
|
||||
}
|
||||
public static IClientLevelWrapper getWrapperIgnoringOverride(@NotNull ClientLevel level) { return LEVEL_WRAPPER_BY_CLIENT_LEVEL.computeIfAbsent(level, ClientLevelWrapper::new); }
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -118,8 +127,6 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//====================//
|
||||
// base level methods //
|
||||
//====================//
|
||||
@@ -179,6 +186,13 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
||||
|
||||
@Override
|
||||
public IDimensionTypeWrapper getDimensionType() { return DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType()); }
|
||||
|
||||
|
||||
@Override
|
||||
public String getDimensionName()
|
||||
{
|
||||
return this.level.dimension().location().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EDhApiLevelType getLevelType() { return EDhApiLevelType.CLIENT_LEVEL; }
|
||||
@@ -288,7 +302,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
||||
return "Wrapped{null}";
|
||||
}
|
||||
|
||||
return "Wrapped{" + this.level.toString() + "@" + this.getDimensionType().getDimensionName() + "}";
|
||||
return "Wrapped{" + this.level.toString() + "@" + this.getDimensionName() + "}";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+21
-7
@@ -44,7 +44,9 @@ public class DimensionTypeWrapper implements IDimensionTypeWrapper
|
||||
{
|
||||
//first we check if the biome has already been wrapped
|
||||
if (dimensionTypeWrapperMap.containsKey(dimensionType) && dimensionTypeWrapperMap.get(dimensionType) != null)
|
||||
{
|
||||
return dimensionTypeWrapperMap.get(dimensionType);
|
||||
}
|
||||
|
||||
|
||||
//if it hasn't been created yet, we create it and save it in the map
|
||||
@@ -61,22 +63,26 @@ public class DimensionTypeWrapper implements IDimensionTypeWrapper
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDimensionName()
|
||||
private String getDimensionName()
|
||||
{
|
||||
return dimensionType.effectsLocation().getPath();
|
||||
#if MC_VER >= MC_1_17_1
|
||||
return this.dimensionType.effectsLocation().getPath();
|
||||
#else // < 1.17.1
|
||||
// effectsLocation() is marked as client only, so using the backing field directly
|
||||
return dimensionType.effectsLocation.getPath();
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCeiling()
|
||||
{
|
||||
return dimensionType.hasCeiling();
|
||||
return this.dimensionType.hasCeiling();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSkyLight()
|
||||
{
|
||||
return dimensionType.hasSkyLight();
|
||||
return this.dimensionType.hasSkyLight();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,7 +91,15 @@ public class DimensionTypeWrapper implements IDimensionTypeWrapper
|
||||
return this.dimensionType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getTeleportationScale(IDimensionTypeWrapper to)
|
||||
{
|
||||
return DimensionType.getTeleportationScale(this.dimensionType, (DimensionType) to.getWrappedMcObject());
|
||||
}
|
||||
|
||||
// there's definitely a better way of doing this, but it should work well enough for now
|
||||
@Override
|
||||
public boolean isTheEnd() { return this.getDimensionName().equalsIgnoreCase("the_end"); }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
@@ -102,4 +116,4 @@ public class DimensionTypeWrapper implements IDimensionTypeWrapper
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+28
-16
@@ -83,13 +83,19 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
||||
@Override
|
||||
public File getSaveFolder()
|
||||
{
|
||||
return level.getChunkSource().getDataStorage().dataFolder;
|
||||
return this.level.getChunkSource().getDataStorage().dataFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionTypeWrapper getDimensionType()
|
||||
{
|
||||
return DimensionTypeWrapper.getDimensionTypeWrapper(level.dimensionType());
|
||||
return DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDimensionName()
|
||||
{
|
||||
return this.level.dimension().location().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,25 +103,25 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
||||
|
||||
public ServerLevel getLevel()
|
||||
{
|
||||
return level;
|
||||
return this.level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCeiling()
|
||||
{
|
||||
return level.dimensionType().hasCeiling();
|
||||
return this.level.dimensionType().hasCeiling();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSkyLight()
|
||||
{
|
||||
return level.dimensionType().hasSkyLight();
|
||||
return this.level.dimensionType().hasSkyLight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHeight()
|
||||
{
|
||||
return level.getHeight();
|
||||
return this.level.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,37 +130,43 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
||||
#if MC_VER < MC_1_17_1
|
||||
return 0;
|
||||
#else
|
||||
return level.getMinBuildHeight();
|
||||
return this.level.getMinBuildHeight();
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkWrapper tryGetChunk(DhChunkPos pos)
|
||||
{
|
||||
if (!level.hasChunk(pos.getX(), pos.getZ())) return null;
|
||||
ChunkAccess chunk = level.getChunk(pos.getX(), pos.getZ(), ChunkStatus.FULL, false);
|
||||
if (chunk == null) return null;
|
||||
return new ChunkWrapper(chunk, level, this);
|
||||
if (!this.level.hasChunk(pos.getX(), pos.getZ()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ChunkAccess chunk = this.level.getChunk(pos.getX(), pos.getZ(), ChunkStatus.FULL, false);
|
||||
if (chunk == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ChunkWrapper(chunk, this.level, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasChunkLoaded(int chunkX, int chunkZ)
|
||||
{
|
||||
// world.hasChunk(chunkX, chunkZ); THIS DOES NOT WORK FOR CLIENT LEVEL CAUSE MOJANG ALWAYS RETURN TRUE FOR THAT!
|
||||
ChunkSource source = level.getChunkSource();
|
||||
ChunkSource source = this.level.getChunkSource();
|
||||
return source.hasChunk(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockStateWrapper getBlockState(DhBlockPos pos)
|
||||
{
|
||||
return BlockStateWrapper.fromBlockState(level.getBlockState(McObjectConverter.Convert(pos)), this);
|
||||
return BlockStateWrapper.fromBlockState(this.level.getBlockState(McObjectConverter.Convert(pos)), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBiomeWrapper getBiome(DhBlockPos pos)
|
||||
{
|
||||
return BiomeWrapper.getBiomeWrapper(level.getBiome(McObjectConverter.Convert(pos)), this);
|
||||
return BiomeWrapper.getBiomeWrapper(this.level.getBiome(McObjectConverter.Convert(pos)), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -185,6 +197,6 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
||||
//================//
|
||||
|
||||
@Override
|
||||
public String toString() { return "Wrapped{" + this.level.toString() + "@" + this.getDimensionType().getDimensionName() + "}"; }
|
||||
public String toString() { return "Wrapped{" + this.level.toString() + "@" + this.getDimensionName() + "}"; }
|
||||
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -128,7 +128,7 @@ public class ChunkLoader
|
||||
ChunkPos actualPos = new ChunkPos(tagLevel.getInt("xPos"), tagLevel.getInt("zPos"));
|
||||
if (!Objects.equals(chunkPos, actualPos))
|
||||
{
|
||||
#if MC_VER > MC_1_17_1
|
||||
#if MC_VER >= MC_1_18_2
|
||||
if (actualPos.equals(ChunkPos.ZERO))
|
||||
#else
|
||||
if (actualPos.equals(ChunkPos.INVALID_CHUNK_POS))
|
||||
|
||||
@@ -47,4 +47,7 @@ accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite frames
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite framesY [I
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite mainImage [Lcom/mojang/blaze3d/platform/NativeImage;
|
||||
|
||||
# DimensionTypeWrapper workaround
|
||||
accessible field net/minecraft/world/level/dimension/DimensionType effectsLocation Lnet/minecraft/resources/ResourceLocation;
|
||||
|
||||
extendable class com/mojang/math/Matrix4f
|
||||
|
||||
+1
-1
Submodule coreSubProjects updated: 4712a77d00...7cd1a37914
+14
-3
@@ -5,19 +5,25 @@ plugins {
|
||||
loom {
|
||||
accessWidenerPath = project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")
|
||||
|
||||
// Custom logging
|
||||
log4jConfigs.from(file("log4j-dev.xml"))
|
||||
|
||||
// "runs" isn't required, but when we do need it then it can be useful
|
||||
runs {
|
||||
client {
|
||||
client()
|
||||
setConfigName("Fabric Client")
|
||||
ideConfigGenerated(true)
|
||||
runDir("../run")
|
||||
runDir("../run/client")
|
||||
vmArgs("-Dio.netty.leakDetection.level=advanced")
|
||||
programArgs("--username", "Dev")
|
||||
}
|
||||
server {
|
||||
server()
|
||||
setConfigName("Fabric Server")
|
||||
ideConfigGenerated(true)
|
||||
runDir("../run")
|
||||
runDir("../run/server")
|
||||
vmArgs("-Dio.netty.leakDetection.level=advanced")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,6 +75,11 @@ dependencies {
|
||||
addModJar(fabricApi.module("fabric-events-interaction-v0", rootProject.fabric_api_version))
|
||||
addModJar(fabricApi.module("fabric-rendering-v1", rootProject.fabric_api_version)) // TODO: Remove this as it is only needed in 1 line (FabricClientProxy)
|
||||
addModJar(fabricApi.module("fabric-networking-api-v1", rootProject.fabric_api_version))
|
||||
addModJar(fabricApi.module("fabric-entity-events-v1", rootProject.fabric_api_version))
|
||||
if (minecraft_version >= "1.19.2")
|
||||
addModJar(fabricApi.module("fabric-command-api-v2", rootProject.fabric_api_version))
|
||||
else // < 1.19.2
|
||||
addModJar(fabricApi.module("fabric-command-api-v1", rootProject.fabric_api_version))
|
||||
|
||||
// used by mod menu in MC 1.20.6+
|
||||
addModJar(fabricApi.module("fabric-screen-api-v1", rootProject.fabric_api_version))
|
||||
@@ -149,4 +160,4 @@ sourcesJar {
|
||||
def commonSources = project(":common").sourcesJar
|
||||
dependsOn commonSources
|
||||
from commonSources.archiveFile.map { zipTree(it) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration name="Dev" monitorInterval="10">
|
||||
<Loggers>
|
||||
<Logger name="com.seibel.distanthorizons.core.network" level="trace" additivity="false">
|
||||
<AppenderRef ref="DebugFile" level="${sys:fabric.log.debug.level:-debug}" />
|
||||
<AppenderRef ref="SysOut" />
|
||||
<AppenderRef ref="LatestFile" level="${sys:fabric.log.level:-info}" />
|
||||
<AppenderRef ref="ServerGuiConsole" />
|
||||
</Logger>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -19,9 +19,8 @@
|
||||
|
||||
package com.seibel.distanthorizons.fabric;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.seibel.distanthorizons.common.AbstractModInitializer;
|
||||
import com.seibel.distanthorizons.common.AbstractPluginPacketSender;
|
||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
@@ -38,17 +37,24 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.ISodiumAcce
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
import com.seibel.distanthorizons.fabric.wrappers.modAccessor.SodiumAccessor;
|
||||
//import io.netty.buffer.ByteBuf;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
|
||||
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
|
||||
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
|
||||
#if MC_VER >= MC_1_20_6
|
||||
import com.seibel.distanthorizons.common.CommonPacketPayload;
|
||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||
#else
|
||||
import com.seibel.distanthorizons.core.network.messages.NetworkMessage;
|
||||
#endif
|
||||
|
||||
#if MC_VER < MC_1_19_4
|
||||
import java.nio.FloatBuffer;
|
||||
#endif
|
||||
@@ -60,7 +66,6 @@ import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
/**
|
||||
@@ -89,6 +94,7 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
||||
* Registers Fabric Events
|
||||
* @author Ran
|
||||
*/
|
||||
@Override
|
||||
public void registerEvents()
|
||||
{
|
||||
LOGGER.info("Registering Fabric Client Events");
|
||||
@@ -246,17 +252,29 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
||||
// networking event //
|
||||
//==================//
|
||||
|
||||
// ClientPlayNetworking.registerGlobalReceiver(new ResourceLocation(ModInfo.NETWORKING_RESOURCE_NAMESPACE, ModInfo.MULTIVERSE_PLUGIN_NAMESPACE),
|
||||
// (Minecraft client, ClientPacketListener handler, FriendlyByteBuf friendlyByteBuf, PacketSender responseSender) ->
|
||||
// {
|
||||
// // converting to a ByteBuf is necessary otherwise Fabric will complain when the game boots
|
||||
// ByteBuf nettyByteBuf = friendlyByteBuf.asByteBuf();
|
||||
//
|
||||
// // remove the Bukkit/Forge packet ID byte
|
||||
// nettyByteBuf.readByte();
|
||||
//
|
||||
// ClientApi.INSTANCE.serverMessageReceived(nettyByteBuf);
|
||||
// });
|
||||
#if MC_VER >= MC_1_20_6
|
||||
PayloadTypeRegistry.playC2S().register(CommonPacketPayload.TYPE, new CommonPacketPayload.Codec());
|
||||
PayloadTypeRegistry.playS2C().register(CommonPacketPayload.TYPE, new CommonPacketPayload.Codec());
|
||||
ClientPlayNetworking.registerGlobalReceiver(CommonPacketPayload.TYPE, (payload, context) ->
|
||||
{
|
||||
if (payload.message() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ClientApi.INSTANCE.pluginMessageReceived(payload.message());
|
||||
});
|
||||
#else
|
||||
ClientPlayNetworking.registerGlobalReceiver(AbstractPluginPacketSender.WRAPPER_PACKET_RESOURCE, (client, handler, buffer, packetSender) ->
|
||||
{
|
||||
// Forge packet ID
|
||||
buffer.readByte();
|
||||
NetworkMessage message = AbstractPluginPacketSender.decodeMessage(buffer);
|
||||
if (message != null)
|
||||
{
|
||||
ClientApi.INSTANCE.pluginMessageReceived(message);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
public void onKeyInput()
|
||||
@@ -285,14 +303,14 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
||||
// Diff and trigger events
|
||||
for (int keyCode : currentKeyDown)
|
||||
{
|
||||
if (!previouslyPressKeyCodes.contains(keyCode))
|
||||
if (!this.previouslyPressKeyCodes.contains(keyCode))
|
||||
{
|
||||
ClientApi.INSTANCE.keyPressedEvent(keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the set
|
||||
previouslyPressKeyCodes = currentKeyDown;
|
||||
this.previouslyPressKeyCodes = currentKeyDown;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.*;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import com.seibel.distanthorizons.fabric.wrappers.modAccessor.*;
|
||||
@@ -40,6 +41,12 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
#if MC_VER >= MC_1_19_2
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
#else // < 1.19.2
|
||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||
#endif
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.function.Consumer;
|
||||
@@ -51,14 +58,22 @@ import java.util.function.Consumer;
|
||||
*/
|
||||
public class FabricMain extends AbstractModInitializer implements ClientModInitializer, DedicatedServerModInitializer
|
||||
{
|
||||
private static final ResourceLocation INITIAL_PHASE = ResourceLocation.tryParse("distanthorizons:dedicated_server_initial");
|
||||
#if MC_VER >= MC_1_21_1
|
||||
private static final ResourceLocation INITIAL_PHASE = ResourceLocation.fromNamespaceAndPath(ModInfo.RESOURCE_NAMESPACE, ModInfo.DEDICATED_SERVER_INITIAL_PATH);
|
||||
#else
|
||||
private static final ResourceLocation INITIAL_PHASE = new ResourceLocation(ModInfo.RESOURCE_NAMESPACE, ModInfo.DEDICATED_SERVER_INITIAL_PATH);
|
||||
#endif
|
||||
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void createInitialBindings() { SingletonInjector.INSTANCE.bind(IModChecker.class, ModChecker.INSTANCE); }
|
||||
protected void createInitialBindings()
|
||||
{
|
||||
SingletonInjector.INSTANCE.bind(IModChecker.class, ModChecker.INSTANCE);
|
||||
SingletonInjector.INSTANCE.bind(IPluginPacketSender.class, new FabricPluginPacketSender());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IEventProxy createClientProxy() { return new FabricClientProxy(); }
|
||||
@@ -102,7 +117,12 @@ public class FabricMain extends AbstractModInitializer implements ClientModIniti
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void subscribeRegisterCommandsEvent(Consumer<CommandDispatcher<CommandSourceStack>> eventHandler) { }
|
||||
protected void subscribeRegisterCommandsEvent(Consumer<CommandDispatcher<CommandSourceStack>> eventHandler)
|
||||
{
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess #if MC_VER >= MC_1_19_2 , environment #endif ) -> {
|
||||
eventHandler.accept(dispatcher);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void subscribeClientStartedEvent(Runnable eventHandler) { ClientLifecycleEvents.CLIENT_STARTED.register((mc) -> eventHandler.run()); }
|
||||
@@ -120,15 +140,21 @@ public class FabricMain extends AbstractModInitializer implements ClientModIniti
|
||||
SingletonInjector.INSTANCE.runDelayedSetup();
|
||||
|
||||
if (Config.Client.Advanced.Graphics.Fog.disableVanillaFog.get() && SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("bclib"))
|
||||
{
|
||||
ModAccessorInjector.INSTANCE.get(IBCLibAccessor.class).setRenderCustomFog(false); // Remove BCLib's fog
|
||||
}
|
||||
|
||||
#if MC_VER >= MC_1_20_1
|
||||
if (SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("sodium"))
|
||||
{
|
||||
ModAccessorInjector.INSTANCE.get(ISodiumAccessor.class).setFogOcclusion(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ConfigBase.INSTANCE == null)
|
||||
{
|
||||
throw new IllegalStateException("Config was not initialized. Make sure to call LodCommonMain.initConfig() before calling this method.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.seibel.distanthorizons.fabric;
|
||||
|
||||
import com.seibel.distanthorizons.common.AbstractPluginPacketSender;
|
||||
import com.seibel.distanthorizons.core.network.messages.NetworkMessage;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
#if MC_VER >= MC_1_20_6
|
||||
import com.seibel.distanthorizons.common.CommonPacketPayload;
|
||||
#else // < 1.20.6
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
#endif
|
||||
|
||||
public class FabricPluginPacketSender extends AbstractPluginPacketSender
|
||||
{
|
||||
@Override
|
||||
public void sendPluginPacketClient(NetworkMessage message)
|
||||
{
|
||||
#if MC_VER >= MC_1_20_6
|
||||
ClientPlayNetworking.send(new CommonPacketPayload(message));
|
||||
#else // < 1.20.6
|
||||
FriendlyByteBuf buffer = PacketByteBufs.create();
|
||||
// Forge packet ID
|
||||
buffer.writeByte(0);
|
||||
AbstractPluginPacketSender.encodeMessage(buffer, message);
|
||||
ClientPlayNetworking.send(WRAPPER_PACKET_RESOURCE, buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPluginPacketServer(ServerPlayer serverPlayer, NetworkMessage message)
|
||||
{
|
||||
#if MC_VER >= MC_1_20_6
|
||||
ServerPlayNetworking.send(serverPlayer, new CommonPacketPayload(message));
|
||||
#else // < 1.20.6
|
||||
FriendlyByteBuf buffer = PacketByteBufs.create();
|
||||
// Forge packet ID
|
||||
buffer.writeByte(0);
|
||||
AbstractPluginPacketSender.encodeMessage(buffer, message);
|
||||
ServerPlayNetworking.send(serverPlayer, WRAPPER_PACKET_RESOURCE, buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,11 +13,13 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.distanthorizons.fabric.testing.TestWorldGenBindingEvent;
|
||||
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
@@ -25,6 +27,14 @@ import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
#if MC_VER >= MC_1_20_6
|
||||
import com.seibel.distanthorizons.common.CommonPacketPayload;
|
||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||
#else
|
||||
import com.seibel.distanthorizons.core.network.messages.NetworkMessage;
|
||||
import com.seibel.distanthorizons.common.AbstractPluginPacketSender;
|
||||
#endif
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@@ -54,7 +64,7 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
|
||||
|
||||
private boolean isValidTime()
|
||||
{
|
||||
if (isDedicated)
|
||||
if (this.isDedicated)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -68,6 +78,7 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
|
||||
private ServerPlayerWrapper getServerPlayerWrapper(ServerPlayer player) { return ServerPlayerWrapper.getWrapper(player); }
|
||||
|
||||
/** Registers Fabric Events */
|
||||
@Override
|
||||
public void registerEvents()
|
||||
{
|
||||
LOGGER.info("Registering Fabric Server Events");
|
||||
@@ -90,15 +101,15 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
|
||||
//TODO: Check if both of these use the correct timed events. (i.e. is it 'ed' or 'ing' one?)
|
||||
ServerLifecycleEvents.SERVER_STARTING.register((server) ->
|
||||
{
|
||||
if (isValidTime())
|
||||
if (this.isValidTime())
|
||||
{
|
||||
ServerApi.INSTANCE.serverLoadEvent(isDedicated);
|
||||
ServerApi.INSTANCE.serverLoadEvent(this.isDedicated);
|
||||
}
|
||||
});
|
||||
// ServerWorldUnloadEvent
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register((server) ->
|
||||
{
|
||||
if (isValidTime())
|
||||
if (this.isValidTime())
|
||||
{
|
||||
ServerApi.INSTANCE.serverUnloadEvent();
|
||||
}
|
||||
@@ -107,25 +118,25 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
|
||||
// ServerLevelLoadEvent
|
||||
ServerWorldEvents.LOAD.register((server, level) ->
|
||||
{
|
||||
if (isValidTime())
|
||||
if (this.isValidTime())
|
||||
{
|
||||
ServerApi.INSTANCE.serverLevelLoadEvent(getServerLevelWrapper(level));
|
||||
ServerApi.INSTANCE.serverLevelLoadEvent(this.getServerLevelWrapper(level));
|
||||
}
|
||||
});
|
||||
// ServerLevelUnloadEvent
|
||||
ServerWorldEvents.UNLOAD.register((server, level) ->
|
||||
{
|
||||
if (isValidTime())
|
||||
if (this.isValidTime())
|
||||
{
|
||||
ServerApi.INSTANCE.serverLevelUnloadEvent(getServerLevelWrapper(level));
|
||||
ServerApi.INSTANCE.serverLevelUnloadEvent(this.getServerLevelWrapper(level));
|
||||
}
|
||||
});
|
||||
|
||||
// ServerChunkLoadEvent
|
||||
ServerChunkEvents.CHUNK_LOAD.register((server, chunk) ->
|
||||
{
|
||||
ILevelWrapper level = getServerLevelWrapper((ServerLevel) chunk.getLevel());
|
||||
if (isValidTime())
|
||||
ILevelWrapper level = this.getServerLevelWrapper((ServerLevel) chunk.getLevel());
|
||||
if (this.isValidTime())
|
||||
{
|
||||
ServerApi.INSTANCE.serverChunkLoadEvent(
|
||||
new ChunkWrapper(chunk, chunk.getLevel(), level),
|
||||
@@ -136,18 +147,56 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
|
||||
|
||||
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) ->
|
||||
{
|
||||
if (isValidTime())
|
||||
if (this.isValidTime())
|
||||
{
|
||||
ServerApi.INSTANCE.serverPlayerJoinEvent(getServerPlayerWrapper(handler.player));
|
||||
ServerApi.INSTANCE.serverPlayerJoinEvent(this.getServerPlayerWrapper(handler.player));
|
||||
}
|
||||
});
|
||||
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) ->
|
||||
{
|
||||
if (isValidTime())
|
||||
if (this.isValidTime())
|
||||
{
|
||||
ServerApi.INSTANCE.serverPlayerDisconnectEvent(getServerPlayerWrapper(handler.player));
|
||||
ServerApi.INSTANCE.serverPlayerDisconnectEvent(this.getServerPlayerWrapper(handler.player));
|
||||
}
|
||||
});
|
||||
ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, origin, dest) ->
|
||||
{
|
||||
if (this.isValidTime())
|
||||
{
|
||||
ServerApi.INSTANCE.serverPlayerLevelChangeEvent(
|
||||
this.getServerPlayerWrapper(player),
|
||||
this.getServerLevelWrapper(origin),
|
||||
this.getServerLevelWrapper(dest)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
if (this.isDedicated)
|
||||
{
|
||||
#if MC_VER >= MC_1_20_6
|
||||
PayloadTypeRegistry.playC2S().register(CommonPacketPayload.TYPE, new CommonPacketPayload.Codec());
|
||||
PayloadTypeRegistry.playS2C().register(CommonPacketPayload.TYPE, new CommonPacketPayload.Codec());
|
||||
ServerPlayNetworking.registerGlobalReceiver(CommonPacketPayload.TYPE, (payload, context) ->
|
||||
{
|
||||
if (payload.message() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ServerApi.INSTANCE.pluginMessageReceived(ServerPlayerWrapper.getWrapper(context.player()), payload.message());
|
||||
});
|
||||
#else
|
||||
ServerPlayNetworking.registerGlobalReceiver(AbstractPluginPacketSender.WRAPPER_PACKET_RESOURCE, (server, serverPlayer, handler, buffer, packetSender) ->
|
||||
{
|
||||
// Forge packet ID
|
||||
buffer.readByte();
|
||||
NetworkMessage message = AbstractPluginPacketSender.decodeMessage(buffer);
|
||||
if (message != null)
|
||||
{
|
||||
ServerApi.INSTANCE.pluginMessageReceived(ServerPlayerWrapper.getWrapper(serverPlayer), message);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -65,4 +65,4 @@ public class MixinClientLevel
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
+1
-29
@@ -21,33 +21,9 @@ import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
@Mixin(ClientPacketListener.class)
|
||||
public class MixinClientPacketListener
|
||||
{
|
||||
@Shadow
|
||||
private ClientLevel level;
|
||||
|
||||
@Unique
|
||||
private ClientLevel previousLevel;
|
||||
|
||||
|
||||
@Inject(method = "handleLogin", at = @At("RETURN"))
|
||||
void onHandleLoginEnd(CallbackInfo ci) { ClientApi.INSTANCE.onClientOnlyConnected(); }
|
||||
|
||||
@Inject(method = "handleRespawn", at = @At("HEAD"))
|
||||
void onHandleRespawnStart(CallbackInfo ci) { this.previousLevel = this.level; }
|
||||
@Inject(method = "handleRespawn", at = @At("RETURN"))
|
||||
void onHandleRespawnEnd(CallbackInfo ci)
|
||||
{
|
||||
// If the player changes dimensions the "this.level" will be changed halfway through the respawn method.
|
||||
// By checking if the object references are the same, we can see if the previous level should be unloaded
|
||||
// or if the player just respawned in the same level.
|
||||
if (this.previousLevel != this.level)
|
||||
{
|
||||
ClientApi.INSTANCE.clientLevelUnloadEvent(ClientLevelWrapper.getWrapper(this.previousLevel));
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(ClientLevelWrapper.getWrapper(this.level));
|
||||
}
|
||||
|
||||
this.previousLevel = null;
|
||||
}
|
||||
|
||||
#if MC_VER < MC_1_19_4
|
||||
@Inject(method = "cleanup", at = @At("HEAD"))
|
||||
#else
|
||||
@@ -55,10 +31,6 @@ public class MixinClientPacketListener
|
||||
#endif
|
||||
void onCleanupStart(CallbackInfo ci)
|
||||
{
|
||||
if (this.level != null)
|
||||
{
|
||||
ClientApi.INSTANCE.clientLevelUnloadEvent(ClientLevelWrapper.getWrapper(this.level));
|
||||
}
|
||||
ClientApi.INSTANCE.onClientOnlyDisconnected();
|
||||
}
|
||||
|
||||
@@ -72,4 +44,4 @@ public class MixinClientPacketListener
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
+26
-2
@@ -2,6 +2,8 @@ package com.seibel.distanthorizons.fabric.mixins.client;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch;
|
||||
import com.seibel.distanthorizons.common.wrappers.gui.updater.UpdateModScreen;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.jar.installer.GitlabGetter;
|
||||
@@ -12,7 +14,9 @@ import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -25,8 +29,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
* @author coolGi
|
||||
*/
|
||||
@Mixin(Minecraft.class)
|
||||
public class MixinMinecraft
|
||||
public abstract class MixinMinecraft
|
||||
{
|
||||
@Shadow
|
||||
public abstract boolean isLocalServer();
|
||||
|
||||
@Unique
|
||||
private ClientLevel lastLevel;
|
||||
|
||||
/**
|
||||
* Can be enabled for testing the auto updater UI. <br/>
|
||||
* will always show the auto updater if set to true.
|
||||
@@ -113,7 +123,21 @@ public class MixinMinecraft
|
||||
}
|
||||
#endif
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "updateLevelInEngines")
|
||||
public void updateLevelInEngines(ClientLevel level, CallbackInfo ci)
|
||||
{
|
||||
if (this.lastLevel != null && level != this.lastLevel)
|
||||
{
|
||||
ClientApi.INSTANCE.clientLevelUnloadEvent(ClientLevelWrapper.getWrapper(this.lastLevel));
|
||||
}
|
||||
if (level != null)
|
||||
{
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(ClientLevelWrapper.getWrapper(level, true));
|
||||
}
|
||||
this.lastLevel = level;
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "close()V")
|
||||
public void close(CallbackInfo ci) { SelfUpdater.onClose(); }
|
||||
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2023 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.fabric.mixins.server;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.misc.IMixinServerPlayer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
#if MC_VER >= MC_1_21_1
|
||||
import net.minecraft.world.level.portal.DimensionTransition;
|
||||
#endif
|
||||
|
||||
|
||||
@Mixin(ServerPlayer.class)
|
||||
public class MixinServerPlayer implements IMixinServerPlayer
|
||||
{
|
||||
@Unique
|
||||
@Nullable
|
||||
private ServerLevel dimensionChangeDestination;
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ServerLevel distantHorizons$getDimensionChangeDestination()
|
||||
{
|
||||
return this.dimensionChangeDestination;
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "changeDimension")
|
||||
#if MC_VER >= MC_1_21_1
|
||||
public void changeDimension(DimensionTransition dimensionTransition, CallbackInfoReturnable<Entity> cir)
|
||||
{
|
||||
this.dimensionChangeDestination = dimensionTransition.newLevel();
|
||||
}
|
||||
#else
|
||||
public void changeDimension(ServerLevel destination, CallbackInfoReturnable<Entity> cir)
|
||||
{
|
||||
this.dimensionChangeDestination = destination;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MC_VER >= MC_1_20_1
|
||||
@Inject(at = @At("RETURN"), method = "setServerLevel")
|
||||
public void setServerLevel(ServerLevel level, CallbackInfo ci)
|
||||
#else
|
||||
@Inject(at = @At("RETURN"), method = "setLevel")
|
||||
public void setLevel(ServerLevel level, CallbackInfo ci)
|
||||
#endif
|
||||
{
|
||||
this.dimensionChangeDestination = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,8 @@
|
||||
"mixins": [
|
||||
"server.MixinChunkGenerator",
|
||||
"server.MixinChunkMap",
|
||||
"server.MixinUtilBackgroundThread"
|
||||
"server.MixinUtilBackgroundThread",
|
||||
"server.MixinServerPlayer"
|
||||
],
|
||||
"client": [
|
||||
"client.MixinClientLevel",
|
||||
@@ -24,4 +25,4 @@
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"plugin": "com.seibel.distanthorizons.fabric.mixins.FabricMixinPlugin"
|
||||
}
|
||||
}
|
||||
+7
-5
@@ -37,15 +37,17 @@ loom {
|
||||
client {
|
||||
client()
|
||||
setConfigName("Forge Client")
|
||||
ideConfigGenerated(true)
|
||||
runDir("../run")
|
||||
// vmArgs("-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg)
|
||||
ideConfigGenerated(false)
|
||||
runDir("../run/client")
|
||||
vmArgs("-Dio.netty.leakDetection.level=advanced")
|
||||
programArgs("--username", "Dev")
|
||||
}
|
||||
server {
|
||||
server()
|
||||
setConfigName("Forge Server")
|
||||
ideConfigGenerated(true)
|
||||
runDir("../run")
|
||||
ideConfigGenerated(false)
|
||||
runDir("../run/server")
|
||||
vmArgs("-Dio.netty.leakDetection.level=advanced")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,6 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
//import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
@@ -53,8 +51,6 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
//import net.minecraftforge.network.NetworkRegistry;
|
||||
//import net.minecraftforge.network.simple.SimpleChannel;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
@@ -79,8 +75,6 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
{
|
||||
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
// private static SimpleChannel multiversePluginChannel;
|
||||
|
||||
|
||||
#if MC_VER < MC_1_19_2
|
||||
@@ -95,7 +89,7 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
public void registerEvents()
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
this.setupNetworkingListeners();
|
||||
ForgePluginPacketSender.setPacketHandler(ClientApi.INSTANCE::pluginMessageReceived);
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +121,7 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
#endif
|
||||
{
|
||||
LOGGER.info("level load");
|
||||
|
||||
|
||||
#if MC_VER < MC_1_19_2
|
||||
LevelAccessor level = event.getWorld();
|
||||
#else
|
||||
@@ -139,7 +133,7 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
}
|
||||
|
||||
ClientLevel clientLevel = (ClientLevel) level;
|
||||
IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel);
|
||||
IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel, true);
|
||||
// TODO this causes a crash due to level being set to null somewhere
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(clientLevelWrapper);
|
||||
}
|
||||
@@ -151,7 +145,7 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
#endif
|
||||
{
|
||||
LOGGER.info("level unload");
|
||||
|
||||
|
||||
#if MC_VER < MC_1_19_2
|
||||
LevelAccessor level = event.getWorld();
|
||||
#else
|
||||
@@ -270,66 +264,6 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
}
|
||||
|
||||
|
||||
|
||||
//============//
|
||||
// networking //
|
||||
//============//
|
||||
|
||||
public void setupNetworkingListeners()
|
||||
{
|
||||
// multiversePluginChannel = NetworkRegistry.newSimpleChannel(
|
||||
// new ResourceLocation(ModInfo.NETWORKING_RESOURCE_NAMESPACE, ModInfo.MULTIVERSE_PLUGIN_NAMESPACE),
|
||||
// // network protocol version
|
||||
// () -> ModInfo.MULTIVERSE_PLUGIN_PROTOCOL_VERSION +"",
|
||||
// // client accepted versions
|
||||
// ForgeClientProxy::isReceivedProtocolVersionAcceptable,
|
||||
// // server accepted versions
|
||||
// ForgeClientProxy::isReceivedProtocolVersionAcceptable
|
||||
// );
|
||||
//
|
||||
// multiversePluginChannel.registerMessage(0/*should be incremented for each simple channel we listen to*/, ByteBuf.class,
|
||||
// // encoder
|
||||
// (pack, friendlyByteBuf) -> { },
|
||||
// // decoder
|
||||
// (friendlyByteBuf) -> friendlyByteBuf.asByteBuf(),
|
||||
// // message consumer
|
||||
// (nettyByteBuf, contextRef) ->
|
||||
// {
|
||||
// ClientApi.INSTANCE.serverMessageReceived(nettyByteBuf);
|
||||
// contextRef.get().setPacketHandled(true);
|
||||
// }
|
||||
// );
|
||||
}
|
||||
|
||||
public static boolean isReceivedProtocolVersionAcceptable(String versionString)
|
||||
{
|
||||
if (versionString.toLowerCase().contains("allowvanilla"))
|
||||
{
|
||||
// allow using networking on vanilla servers
|
||||
return true;
|
||||
}
|
||||
else if (versionString.toLowerCase().contains("absent"))
|
||||
{
|
||||
// allow using networking even if DH isn't installed on the server
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// DH is installed on the server, check if the version is valid to use
|
||||
try
|
||||
{
|
||||
int version = Integer.parseInt(versionString);
|
||||
return ModInfo.MULTIVERSE_PLUGIN_PROTOCOL_VERSION == version;
|
||||
}
|
||||
catch (NumberFormatException ignored)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//===========//
|
||||
// rendering //
|
||||
//===========//
|
||||
@@ -363,5 +297,4 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,8 @@ import com.seibel.distanthorizons.common.wrappers.gui.GetConfigScreen;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.common.wrappers.gui.GetConfigScreen;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
|
||||
@@ -36,15 +38,16 @@ import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.*;
|
||||
#if MC_VER == MC_1_16_5
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
|
||||
#elif MC_VER == MC_1_17_1
|
||||
import net.minecraftforge.fmlserverevents.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fmlserverevents.FMLServerAboutToStartEvent;
|
||||
#else
|
||||
import net.minecraftforge.event.server.ServerStartingEvent;
|
||||
import net.minecraftforge.event.server.ServerAboutToStartEvent;
|
||||
#endif
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
#if MC_VER < MC_1_17_1
|
||||
@@ -83,7 +86,11 @@ public class ForgeMain extends AbstractModInitializer
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createInitialBindings() { SingletonInjector.INSTANCE.bind(IModChecker.class, ModChecker.INSTANCE); }
|
||||
protected void createInitialBindings()
|
||||
{
|
||||
SingletonInjector.INSTANCE.bind(IModChecker.class, ModChecker.INSTANCE);
|
||||
SingletonInjector.INSTANCE.bind(IPluginPacketSender.class, new ForgePluginPacketSender());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IEventProxy createClientProxy() { return new ForgeClientProxy(); }
|
||||
@@ -137,7 +144,7 @@ public class ForgeMain extends AbstractModInitializer
|
||||
@Override
|
||||
protected void subscribeServerStartingEvent(Consumer<MinecraftServer> eventHandler)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.addListener((#if MC_VER >= MC_1_18_2 ServerStartingEvent #else FMLServerStartingEvent #endif e) ->
|
||||
MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGH, (#if MC_VER >= MC_1_18_2 ServerAboutToStartEvent #else FMLServerAboutToStartEvent #endif e) ->
|
||||
{
|
||||
eventHandler.accept(e.getServer());
|
||||
});
|
||||
@@ -146,4 +153,4 @@ public class ForgeMain extends AbstractModInitializer
|
||||
@Override
|
||||
protected void runDelayedSetup() { SingletonInjector.INSTANCE.runDelayedSetup(); }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package com.seibel.distanthorizons.forge;
|
||||
|
||||
import com.seibel.distanthorizons.common.AbstractPluginPacketSender;
|
||||
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
||||
import com.seibel.distanthorizons.core.network.messages.NetworkMessage;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
#if MC_VER >= MC_1_20_2
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import net.minecraftforge.network.ChannelBuilder;
|
||||
import net.minecraftforge.network.SimpleChannel;
|
||||
#elif MC_VER >= MC_1_18_2
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
import net.minecraftforge.network.simple.SimpleChannel;
|
||||
#elif MC_VER >= MC_1_17_1
|
||||
import net.minecraftforge.fmllegacy.network.NetworkRegistry;
|
||||
import net.minecraftforge.fmllegacy.network.PacketDistributor;
|
||||
import net.minecraftforge.fmllegacy.network.simple.SimpleChannel;
|
||||
#else // < 1.17.1
|
||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
#endif
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ForgePluginPacketSender extends AbstractPluginPacketSender
|
||||
{
|
||||
public static final SimpleChannel PLUGIN_CHANNEL =
|
||||
#if MC_VER >= MC_1_20_2
|
||||
ChannelBuilder.named(AbstractPluginPacketSender.WRAPPER_PACKET_RESOURCE)
|
||||
.networkProtocolVersion(1)
|
||||
.serverAcceptedVersions((status, version) -> true)
|
||||
.clientAcceptedVersions((status, version) -> true)
|
||||
.simpleChannel();
|
||||
#else // < 1.20.2
|
||||
NetworkRegistry.newSimpleChannel(
|
||||
AbstractPluginPacketSender.WRAPPER_PACKET_RESOURCE,
|
||||
() -> "1",
|
||||
ignored -> true,
|
||||
ignored -> true
|
||||
);
|
||||
#endif
|
||||
|
||||
public static void setPacketHandler(Consumer<NetworkMessage> consumer)
|
||||
{
|
||||
setPacketHandler((player, message) -> consumer.accept(message));
|
||||
}
|
||||
public static void setPacketHandler(BiConsumer<IServerPlayerWrapper, NetworkMessage> consumer)
|
||||
{
|
||||
#if MC_VER >= MC_1_20_2
|
||||
PLUGIN_CHANNEL.messageBuilder(MessageWrapper.class, 0)
|
||||
.encoder((wrapper, out) -> AbstractPluginPacketSender.encodeMessage(out, wrapper.message))
|
||||
.decoder(in -> new MessageWrapper(AbstractPluginPacketSender.decodeMessage(in)))
|
||||
.consumerNetworkThread((wrapper, context) ->
|
||||
{
|
||||
if (wrapper.message != null)
|
||||
{
|
||||
if (context.getSender() != null)
|
||||
{
|
||||
consumer.accept(ServerPlayerWrapper.getWrapper(context.getSender()), wrapper.message);
|
||||
}
|
||||
else
|
||||
{
|
||||
consumer.accept(null, wrapper.message);
|
||||
}
|
||||
}
|
||||
context.setPacketHandled(true);
|
||||
})
|
||||
.add();
|
||||
#else // < 1.20.2
|
||||
PLUGIN_CHANNEL.registerMessage(0, MessageWrapper.class,
|
||||
(wrapper, out) -> AbstractPluginPacketSender.encodeMessage(out, wrapper.message),
|
||||
in -> new MessageWrapper(AbstractPluginPacketSender.decodeMessage(in)),
|
||||
(wrapper, context) ->
|
||||
{
|
||||
if (wrapper.message != null)
|
||||
{
|
||||
if (context.get().getSender() != null)
|
||||
{
|
||||
consumer.accept(ServerPlayerWrapper.getWrapper(context.get().getSender()), wrapper.message);
|
||||
}
|
||||
else
|
||||
{
|
||||
consumer.accept(null, wrapper.message);
|
||||
}
|
||||
}
|
||||
context.get().setPacketHandled(true);
|
||||
}
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPluginPacketClient(NetworkMessage message)
|
||||
{
|
||||
#if MC_VER >= MC_1_20_2
|
||||
PLUGIN_CHANNEL.send(new MessageWrapper(message), PacketDistributor.SERVER.noArg());
|
||||
#else // < 1.20.2
|
||||
PLUGIN_CHANNEL.send(PacketDistributor.SERVER.noArg(), new MessageWrapper(message));
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPluginPacketServer(ServerPlayer serverPlayer, NetworkMessage message)
|
||||
{
|
||||
#if MC_VER >= MC_1_20_2
|
||||
PLUGIN_CHANNEL.send(new MessageWrapper(message), PacketDistributor.PLAYER.with(serverPlayer));
|
||||
#else // < 1.20.2
|
||||
PLUGIN_CHANNEL.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new MessageWrapper(message));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Forge doesn't support using abstract classes
|
||||
@SuppressWarnings({"ClassCanBeRecord", "RedundantSuppression"})
|
||||
public static class MessageWrapper
|
||||
{
|
||||
public final NetworkMessage message;
|
||||
|
||||
public MessageWrapper(NetworkMessage message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,16 +3,20 @@ package com.seibel.distanthorizons.forge;
|
||||
import com.seibel.distanthorizons.common.AbstractModInitializer;
|
||||
import com.seibel.distanthorizons.common.util.ProxyUtil;
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.distanthorizons.core.api.internal.ServerApi;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
#if MC_VER < MC_1_19_2
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
@@ -22,6 +26,13 @@ import net.minecraftforge.event.level.LevelEvent;
|
||||
#endif
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
#if MC_VER >= MC_1_19_4
|
||||
import net.minecraft.core.registries.Registries;
|
||||
#else // < 1.19.4
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
#endif
|
||||
|
||||
#if MC_VER == MC_1_16_5
|
||||
import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
|
||||
@@ -47,7 +58,6 @@ public class ForgeServerProxy implements AbstractModInitializer.IEventProxy
|
||||
#endif
|
||||
|
||||
private final ServerApi serverApi = ServerApi.INSTANCE;
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
private final boolean isDedicated;
|
||||
public static Supplier<Boolean> isGenerationThreadChecker = null;
|
||||
|
||||
@@ -57,6 +67,10 @@ public class ForgeServerProxy implements AbstractModInitializer.IEventProxy
|
||||
public void registerEvents()
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
if (this.isDedicated)
|
||||
{
|
||||
ForgePluginPacketSender.setPacketHandler(ServerApi.INSTANCE::pluginMessageReceived);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +125,7 @@ public class ForgeServerProxy implements AbstractModInitializer.IEventProxy
|
||||
{
|
||||
if (GetEventLevel(event) instanceof ServerLevel)
|
||||
{
|
||||
this.serverApi.serverLevelLoadEvent(this.getServerLevelWrapper((ServerLevel) GetEventLevel(event)));
|
||||
this.serverApi.serverLevelLoadEvent(getServerLevelWrapper((ServerLevel) GetEventLevel(event)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +139,7 @@ public class ForgeServerProxy implements AbstractModInitializer.IEventProxy
|
||||
{
|
||||
if (GetEventLevel(event) instanceof ServerLevel)
|
||||
{
|
||||
this.serverApi.serverLevelUnloadEvent(this.getServerLevelWrapper((ServerLevel) GetEventLevel(event)));
|
||||
this.serverApi.serverLevelUnloadEvent(getServerLevelWrapper((ServerLevel) GetEventLevel(event)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +152,26 @@ public class ForgeServerProxy implements AbstractModInitializer.IEventProxy
|
||||
this.serverApi.serverChunkLoadEvent(chunk, levelWrapper);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event)
|
||||
{
|
||||
this.serverApi.serverPlayerJoinEvent(getServerPlayerWrapper(event));
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void playerLoggedOutEvent(PlayerEvent.PlayerLoggedOutEvent event)
|
||||
{
|
||||
this.serverApi.serverPlayerDisconnectEvent(getServerPlayerWrapper(event));
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void playerChangedDimensionEvent(PlayerEvent.PlayerChangedDimensionEvent event)
|
||||
{
|
||||
this.serverApi.serverPlayerLevelChangeEvent(
|
||||
getServerPlayerWrapper(event),
|
||||
getServerLevelWrapper(event.getFrom(), event),
|
||||
getServerLevelWrapper(event.getTo(), event)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
@@ -147,4 +181,20 @@ public class ForgeServerProxy implements AbstractModInitializer.IEventProxy
|
||||
private static ServerLevelWrapper getServerLevelWrapper(ServerLevel level) { return ServerLevelWrapper.getWrapper(level); }
|
||||
|
||||
|
||||
private static ServerLevelWrapper getServerLevelWrapper(ResourceKey<Level> resourceKey, PlayerEvent event)
|
||||
{
|
||||
//noinspection DataFlowIssue (possible NPE after getServer())
|
||||
return getServerLevelWrapper(event.getEntity().getServer().getLevel(resourceKey));
|
||||
}
|
||||
|
||||
private static ServerPlayerWrapper getServerPlayerWrapper(PlayerEvent event) {
|
||||
return ServerPlayerWrapper.getWrapper(
|
||||
#if MC_VER >= MC_1_19_2
|
||||
(ServerPlayer) event.getEntity()
|
||||
#else
|
||||
(ServerPlayer) event.getPlayer()
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,4 +26,4 @@ public class MixinClientPacketListener
|
||||
ClientApi.INSTANCE.onClientOnlyDisconnected();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -2,6 +2,8 @@ package com.seibel.distanthorizons.forge.mixins.client;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch;
|
||||
import com.seibel.distanthorizons.common.wrappers.gui.updater.UpdateModScreen;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.jar.installer.GitlabGetter;
|
||||
@@ -11,7 +13,9 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -104,4 +108,4 @@ public class MixinMinecraft
|
||||
SelfUpdater.onClose();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2023 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.forge.mixins.server;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.misc.IMixinServerPlayer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraftforge.common.util.ITeleporter;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
|
||||
@Mixin(ServerPlayer.class)
|
||||
public class MixinServerPlayer implements IMixinServerPlayer
|
||||
{
|
||||
@Unique
|
||||
@Nullable
|
||||
private volatile ServerLevel distantHorizons$dimensionChangeDestination;
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ServerLevel distantHorizons$getDimensionChangeDestination()
|
||||
{
|
||||
return this.distantHorizons$dimensionChangeDestination;
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "changeDimension", remap = false)
|
||||
public void changeDimension(ServerLevel destination, ITeleporter teleporter, CallbackInfoReturnable<Entity> cir)
|
||||
{
|
||||
this.distantHorizons$dimensionChangeDestination = destination;
|
||||
}
|
||||
|
||||
#if MC_VER >= MC_1_20_1
|
||||
@Inject(at = @At("RETURN"), method = "setServerLevel")
|
||||
public void setServerLevel(ServerLevel level, CallbackInfo ci)
|
||||
#else
|
||||
@Inject(at = @At("RETURN"), method = "setLevel")
|
||||
public void setLevel(ServerLevel level, CallbackInfo ci)
|
||||
#endif
|
||||
{
|
||||
this.distantHorizons$dimensionChangeDestination = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,8 @@
|
||||
"server.MixinUtilBackgroundThread",
|
||||
"server.MixinChunkGenerator",
|
||||
"server.MixinTFChunkGenerator",
|
||||
"server.MixinChunkMap"
|
||||
"server.MixinChunkMap",
|
||||
"server.MixinServerPlayer"
|
||||
],
|
||||
"client": [
|
||||
"client.MixinClientPacketListener",
|
||||
|
||||
+1
-2
@@ -31,7 +31,6 @@ fastutil_version=8.2.1
|
||||
|
||||
# Minecraft related libraries (included in MC's jar)
|
||||
log4j_version=2.23.1
|
||||
netty_version=4.1.94.Final
|
||||
lwjgl_version=3.3.1
|
||||
joml_version=1.10.2
|
||||
|
||||
@@ -52,4 +51,4 @@ versionStr=
|
||||
mcVer=1.21.1
|
||||
|
||||
# Defines the maximum amount of memory Minecraft is allowed when run in a development environment
|
||||
#minecraftMemoryJavaArg="-Xmx4G"
|
||||
#minecraftMemoryJavaArg="-Xmx4G"
|
||||
@@ -29,15 +29,17 @@ loom {
|
||||
client {
|
||||
client()
|
||||
setConfigName("NeoForge Client")
|
||||
ideConfigGenerated(true)
|
||||
runDir("../run")
|
||||
//vmArgs("-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg)
|
||||
ideConfigGenerated(false)
|
||||
runDir("../run/client")
|
||||
vmArgs("-Dio.netty.leakDetection.level=advanced")
|
||||
programArgs("--username", "Dev")
|
||||
}
|
||||
server {
|
||||
server()
|
||||
setConfigName("NeoForge Server")
|
||||
ideConfigGenerated(true)
|
||||
runDir("../run")
|
||||
ideConfigGenerated(false)
|
||||
runDir("../run/server")
|
||||
vmArgs("-Dio.netty.leakDetection.level=advanced")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,4 +99,4 @@ sourcesJar {
|
||||
def commonSources = project(":common").sourcesJar
|
||||
dependsOn commonSources
|
||||
from commonSources.archiveFile.map { zipTree(it) }
|
||||
}
|
||||
}
|
||||
+2
-65
@@ -35,7 +35,6 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
@@ -47,8 +46,6 @@ import net.neoforged.neoforge.event.level.LevelEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
|
||||
//import net.neoforged.network.NetworkRegistry;
|
||||
//import net.neoforged.network.simple.SimpleChannel;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
@@ -93,7 +90,6 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
public void registerEvents()
|
||||
{
|
||||
NeoForge.EVENT_BUS.register(this);
|
||||
setupNetworkingListeners();
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +133,7 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
}
|
||||
|
||||
ClientLevel clientLevel = (ClientLevel) level;
|
||||
IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel);
|
||||
IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel, true);
|
||||
// TODO this causes a crash due to level being set to null somewhere
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(clientLevelWrapper);
|
||||
}
|
||||
@@ -246,65 +242,6 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
|
||||
|
||||
|
||||
//============//
|
||||
// networking //
|
||||
//============//
|
||||
|
||||
public static void setupNetworkingListeners()
|
||||
{
|
||||
// multiversePluginChannel = NetworkRegistry.newSimpleChannel(
|
||||
// new ResourceLocation(ModInfo.NETWORKING_RESOURCE_NAMESPACE, ModInfo.MULTIVERSE_PLUGIN_NAMESPACE),
|
||||
// // network protocol version
|
||||
// () -> ModInfo.MULTIVERSE_PLUGIN_PROTOCOL_VERSION +"",
|
||||
// // client accepted versions
|
||||
// ForgeClientProxy::isReceivedProtocolVersionAcceptable,
|
||||
// // server accepted versions
|
||||
// ForgeClientProxy::isReceivedProtocolVersionAcceptable
|
||||
// );
|
||||
//
|
||||
// multiversePluginChannel.registerMessage(0/*should be incremented for each simple channel we listen to*/, ByteBuf.class,
|
||||
// // encoder
|
||||
// (pack, friendlyByteBuf) -> { },
|
||||
// // decoder
|
||||
// (friendlyByteBuf) -> friendlyByteBuf.asByteBuf(),
|
||||
// // message consumer
|
||||
// (nettyByteBuf, contextRef) ->
|
||||
// {
|
||||
// ClientApi.INSTANCE.serverMessageReceived(nettyByteBuf);
|
||||
// contextRef.get().setPacketHandled(true);
|
||||
// }
|
||||
// );
|
||||
}
|
||||
|
||||
public static boolean isReceivedProtocolVersionAcceptable(String versionString)
|
||||
{
|
||||
if (versionString.toLowerCase().contains("allowvanilla"))
|
||||
{
|
||||
// allow using networking on vanilla servers
|
||||
return true;
|
||||
}
|
||||
else if (versionString.toLowerCase().contains("absent"))
|
||||
{
|
||||
// allow using networking even if DH isn't installed on the server
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// DH is installed on the server, check if the version is valid to use
|
||||
try
|
||||
{
|
||||
int version = Integer.parseInt(versionString);
|
||||
return ModInfo.MULTIVERSE_PLUGIN_PROTOCOL_VERSION == version;
|
||||
}
|
||||
catch (NumberFormatException ignored)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//===========//
|
||||
// rendering //
|
||||
//===========//
|
||||
@@ -347,4 +284,4 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
private static LevelAccessor GetEventLevel(LevelEvent e) { return e.getLevel(); }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,9 @@ import com.seibel.distanthorizons.common.AbstractModInitializer;
|
||||
import com.seibel.distanthorizons.common.wrappers.gui.GetConfigScreen;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.api.internal.ServerApi;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
@@ -32,6 +34,7 @@ import com.seibel.distanthorizons.neoforge.wrappers.modAccessor.ModChecker;
|
||||
import com.seibel.distanthorizons.neoforge.wrappers.modAccessor.OptifineAccessor;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.neoforged.bus.api.EventPriority;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.fml.ModLoadingContext;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
@@ -40,13 +43,14 @@ import net.neoforged.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStartingEvent;
|
||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
#if MC_VER < MC_1_20_6
|
||||
import net.neoforged.neoforge.client.ConfigScreenHandler;
|
||||
#else
|
||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -55,19 +59,46 @@ import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
* check out the ClientProxy.
|
||||
*/
|
||||
@Mod(ModInfo.ID)
|
||||
@SuppressWarnings("unused")
|
||||
public class NeoforgeMain extends AbstractModInitializer
|
||||
{
|
||||
public NeoforgeMain(IEventBus eventBus)
|
||||
{
|
||||
eventBus.addListener((FMLClientSetupEvent e) -> this.onInitializeClient());
|
||||
eventBus.addListener((FMLDedicatedServerSetupEvent e) -> this.onInitializeServer());
|
||||
eventBus.addListener((FMLClientSetupEvent e) -> {
|
||||
this.onInitializeClient();
|
||||
eventBus.addListener(this::registerNetworkingClient);
|
||||
});
|
||||
eventBus.addListener((FMLDedicatedServerSetupEvent e) -> {
|
||||
this.onInitializeServer();
|
||||
eventBus.addListener(this::registerNetworkingServer);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
//============//
|
||||
// networking //
|
||||
//============//
|
||||
public void registerNetworkingClient(RegisterPayloadHandlersEvent event)
|
||||
{
|
||||
NeoforgePluginPacketSender.setPacketHandler(event, ClientApi.INSTANCE::pluginMessageReceived);
|
||||
}
|
||||
public void registerNetworkingServer(RegisterPayloadHandlersEvent event)
|
||||
{
|
||||
NeoforgePluginPacketSender.setPacketHandler(event, ServerApi.INSTANCE::pluginMessageReceived);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected IEventProxy createServerProxy(boolean isDedicated) { return new NeoforgeServerProxy(isDedicated); }
|
||||
|
||||
@Override
|
||||
protected void createInitialBindings() { SingletonInjector.INSTANCE.bind(IModChecker.class, ModChecker.INSTANCE); }
|
||||
protected void createInitialBindings()
|
||||
{
|
||||
SingletonInjector.INSTANCE.bind(IModChecker.class, ModChecker.INSTANCE);
|
||||
SingletonInjector.INSTANCE.bind(IPluginPacketSender.class, new NeoforgePluginPacketSender());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IEventProxy createClientProxy() { return new NeoforgeClientProxy(); }
|
||||
@@ -116,10 +147,10 @@ public class NeoforgeMain extends AbstractModInitializer
|
||||
@Override
|
||||
protected void subscribeServerStartingEvent(Consumer<MinecraftServer> eventHandler)
|
||||
{
|
||||
NeoForge.EVENT_BUS.addListener((ServerStartingEvent e) -> { eventHandler.accept(e.getServer()); });
|
||||
NeoForge.EVENT_BUS.addListener(EventPriority.HIGH, (ServerStartingEvent e) -> { eventHandler.accept(e.getServer()); });
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runDelayedSetup() { SingletonInjector.INSTANCE.runDelayedSetup(); }
|
||||
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.seibel.distanthorizons.neoforge;
|
||||
|
||||
import com.seibel.distanthorizons.common.CommonPacketPayload;
|
||||
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
||||
import com.seibel.distanthorizons.common.AbstractPluginPacketSender;
|
||||
import com.seibel.distanthorizons.core.network.messages.NetworkMessage;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
|
||||
import net.neoforged.neoforge.network.registration.PayloadRegistrar;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class NeoforgePluginPacketSender extends AbstractPluginPacketSender
|
||||
{
|
||||
private static BiConsumer<IServerPlayerWrapper, NetworkMessage> packetConsumer;
|
||||
|
||||
public static void setPacketHandler(RegisterPayloadHandlersEvent event, Consumer<NetworkMessage> consumer)
|
||||
{
|
||||
setPacketHandler(event, (player, buffer) -> consumer.accept(buffer));
|
||||
}
|
||||
public static void setPacketHandler(RegisterPayloadHandlersEvent event, BiConsumer<IServerPlayerWrapper, NetworkMessage> consumer)
|
||||
{
|
||||
packetConsumer = consumer;
|
||||
|
||||
PayloadRegistrar registrar = event.registrar("1").optional();
|
||||
registrar.playBidirectional(CommonPacketPayload.TYPE, new CommonPacketPayload.Codec(), (payload, context) ->
|
||||
{
|
||||
ServerPlayerWrapper serverPlayer = Optional.of(context.player())
|
||||
.map(player -> player instanceof ServerPlayer ? (ServerPlayer) player : null)
|
||||
.map(ServerPlayerWrapper::getWrapper)
|
||||
.orElse(null);
|
||||
|
||||
if (payload.message() != null)
|
||||
{
|
||||
packetConsumer.accept(serverPlayer, payload.message());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPluginPacketClient(NetworkMessage message)
|
||||
{
|
||||
PacketDistributor.sendToServer(new CommonPacketPayload(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPluginPacketServer(ServerPlayer serverPlayer, NetworkMessage message)
|
||||
{
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new CommonPacketPayload(message));
|
||||
}
|
||||
|
||||
}
|
||||
+35
-1
@@ -3,15 +3,20 @@ package com.seibel.distanthorizons.neoforge;
|
||||
import com.seibel.distanthorizons.common.AbstractModInitializer;
|
||||
import com.seibel.distanthorizons.common.util.ProxyUtil;
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.distanthorizons.core.api.internal.ServerApi;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
||||
import net.neoforged.neoforge.event.level.ChunkEvent;
|
||||
import net.neoforged.neoforge.event.level.LevelEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
@@ -123,6 +128,26 @@ public class NeoforgeServerProxy implements AbstractModInitializer.IEventProxy
|
||||
this.serverApi.serverChunkLoadEvent(chunk, levelWrapper);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event)
|
||||
{
|
||||
this.serverApi.serverPlayerJoinEvent(getServerPlayerWrapper(event));
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void playerLoggedOutEvent(PlayerEvent.PlayerLoggedOutEvent event)
|
||||
{
|
||||
this.serverApi.serverPlayerDisconnectEvent(getServerPlayerWrapper(event));
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void playerChangedDimensionEvent(PlayerEvent.PlayerChangedDimensionEvent event)
|
||||
{
|
||||
this.serverApi.serverPlayerLevelChangeEvent(
|
||||
getServerPlayerWrapper(event),
|
||||
getServerLevelWrapper(event.getFrom(), event),
|
||||
getServerLevelWrapper(event.getTo(), event)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
@@ -130,6 +155,15 @@ public class NeoforgeServerProxy implements AbstractModInitializer.IEventProxy
|
||||
//================//
|
||||
|
||||
private static ServerLevelWrapper getServerLevelWrapper(ServerLevel level) { return ServerLevelWrapper.getWrapper(level); }
|
||||
private static ServerLevelWrapper getServerLevelWrapper(ResourceKey<Level> resourceKey, PlayerEvent event)
|
||||
{
|
||||
//noinspection DataFlowIssue (possible NPE after getServer())
|
||||
return getServerLevelWrapper(event.getEntity().getServer().getLevel(resourceKey));
|
||||
}
|
||||
|
||||
private static ServerPlayerWrapper getServerPlayerWrapper(PlayerEvent event)
|
||||
{
|
||||
return ServerPlayerWrapper.getWrapper((ServerPlayer) event.getEntity());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+10
-1
@@ -1,8 +1,11 @@
|
||||
package com.seibel.distanthorizons.neoforge.mixins.client;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@@ -10,10 +13,16 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(ClientPacketListener.class)
|
||||
public class MixinClientPacketListener
|
||||
{
|
||||
@Shadow
|
||||
private ClientLevel level;
|
||||
// TODO update fabric version as well
|
||||
|
||||
@Inject(method = "handleLogin", at = @At("RETURN"))
|
||||
void onHandleLoginEnd(CallbackInfo ci) { ClientApi.INSTANCE.onClientOnlyConnected(); }
|
||||
void onHandleLoginEnd(CallbackInfo ci)
|
||||
{
|
||||
ClientApi.INSTANCE.onClientOnlyConnected();
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(ClientLevelWrapper.getWrapper(this.level, true));
|
||||
}
|
||||
|
||||
#if MC_VER < MC_1_19_4
|
||||
@Inject(method = "cleanup", at = @At("HEAD"))
|
||||
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2023 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.neoforge.mixins.server;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.misc.IMixinServerPlayer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
#if MC_VER >= MC_1_21_1
|
||||
import net.minecraft.world.level.portal.DimensionTransition;
|
||||
#endif
|
||||
|
||||
|
||||
@Mixin(ServerPlayer.class)
|
||||
public class MixinServerPlayer implements IMixinServerPlayer
|
||||
{
|
||||
@Unique
|
||||
@Nullable
|
||||
private ServerLevel distantHorizons$dimensionChangeDestination;
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ServerLevel distantHorizons$getDimensionChangeDestination()
|
||||
{
|
||||
return this.distantHorizons$dimensionChangeDestination;
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "changeDimension")
|
||||
#if MC_VER >= MC_1_21_1
|
||||
public void changeDimension(DimensionTransition dimensionTransition, CallbackInfoReturnable<Entity> cir)
|
||||
{
|
||||
this.distantHorizons$dimensionChangeDestination = dimensionTransition.newLevel();
|
||||
}
|
||||
#else
|
||||
public void changeDimension(ServerLevel destination, CallbackInfoReturnable<Entity> cir)
|
||||
{
|
||||
this.distantHorizons$dimensionChangeDestination = destination;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MC_VER >= MC_1_20_1
|
||||
@Inject(at = @At("RETURN"), method = "setServerLevel")
|
||||
public void setServerLevel(ServerLevel level, CallbackInfo ci)
|
||||
#else
|
||||
@Inject(at = @At("RETURN"), method = "setLevel")
|
||||
public void setLevel(ServerLevel level, CallbackInfo ci)
|
||||
#endif
|
||||
{
|
||||
this.distantHorizons$dimensionChangeDestination = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,8 @@
|
||||
"server.MixinUtilBackgroundThread",
|
||||
"server.MixinChunkGenerator",
|
||||
"server.MixinTFChunkGenerator",
|
||||
"server.MixinChunkMap"
|
||||
"server.MixinChunkMap",
|
||||
"server.MixinServerPlayer"
|
||||
],
|
||||
"client": [
|
||||
"client.MixinClientPacketListener",
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
# Usage: .\verifyall.ps1 [forge|fabric|whatever to put before ":classes"]
|
||||
|
||||
param (
|
||||
[string]$prefix
|
||||
)
|
||||
|
||||
# Clear the screen
|
||||
Clear-Host
|
||||
|
||||
# Define an array to hold completed builds with color information
|
||||
$completedBuilds = @()
|
||||
|
||||
# Get all version properties files
|
||||
$versionFiles = Get-ChildItem -Path "./versionProperties/" -Filter "*.properties"
|
||||
|
||||
foreach ($versionFile in $versionFiles) {
|
||||
$version = [System.IO.Path]::GetFileNameWithoutExtension($versionFile.Name)
|
||||
|
||||
# Run the gradle command
|
||||
$gradleCommand = ".\gradlew $($prefix)classes -PmcVer=$version"
|
||||
$process = Start-Process -FilePath "cmd.exe" -ArgumentList "/c $gradleCommand" -NoNewWindow -PassThru -Wait
|
||||
|
||||
# Determine the result color
|
||||
if ($process.ExitCode -eq 0) {
|
||||
$color = "Green"
|
||||
} else {
|
||||
$color = "Red"
|
||||
}
|
||||
|
||||
# Print the result with formatting
|
||||
$versionLength = $version.Length
|
||||
$topChars = ("^" * $versionLength)
|
||||
$bottomChars = ("=" * $versionLength)
|
||||
|
||||
Write-Host "# $topChars" -ForegroundColor $color
|
||||
Write-Host "# $version" -ForegroundColor $color
|
||||
Write-Host "# $bottomChars" -ForegroundColor $color
|
||||
Write-Host
|
||||
|
||||
# Add result to completed builds with color
|
||||
$completedBuilds += @{ Version = $version; Color = $color }
|
||||
}
|
||||
|
||||
# Run clean and classes gradle tasks
|
||||
Start-Process -FilePath "cmd.exe" -ArgumentList "/c .\gradlew clean" -NoNewWindow -Wait
|
||||
Start-Process -FilePath "cmd.exe" -ArgumentList "/c .\gradlew classes" -NoNewWindow -Wait
|
||||
|
||||
# Print build results
|
||||
Write-Host
|
||||
Write-Host "Build results:"
|
||||
|
||||
foreach ($build in $completedBuilds) {
|
||||
Write-Host $build.Version -ForegroundColor $build.Color -NoNewline
|
||||
Write-Host " " -NoNewline # Add a space between versions
|
||||
}
|
||||
|
||||
Write-Host # End the line after all versions are printed
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Usage: ./verifyall.sh [forge|fabric|whatever to put before ":classes"]
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
prefix="$1:"
|
||||
fi
|
||||
|
||||
clear
|
||||
trap "echo; exit" INT
|
||||
|
||||
declare -a completed_builds
|
||||
for version in $(ls ./versionProperties/); do
|
||||
version=${version%".properties"}
|
||||
|
||||
result=""
|
||||
if ./gradlew "$prefix"classes -PmcVer=$version; then
|
||||
result+="\e[1;32m"
|
||||
echo -ne "\e[1;32m"
|
||||
else
|
||||
result+="\e[1;31m"
|
||||
echo -ne "\e[1;31m"
|
||||
fi
|
||||
result+=$version
|
||||
result+="\e[0m"
|
||||
|
||||
version_length=${#version}
|
||||
top_chars=$(printf '^%.0s' $(seq 1 $version_length))
|
||||
bottom_chars=$(printf '=%.0s' $(seq 1 $version_length))
|
||||
echo "# $top_chars"
|
||||
echo "# $version"
|
||||
echo "# $bottom_chars"
|
||||
echo -e "\e[0m"
|
||||
|
||||
completed_builds+=($result)
|
||||
done
|
||||
|
||||
./gradlew clean
|
||||
./gradlew classes
|
||||
|
||||
echo
|
||||
echo -e "\e[1mBuild results:\e[0m"
|
||||
echo -e "${completed_builds[*]}"
|
||||
@@ -7,6 +7,9 @@ accessWidenerVersion=1_16
|
||||
builds_for=fabric,forge
|
||||
embed_joml=true
|
||||
|
||||
# Netty
|
||||
netty_version=4.1.25.Final
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.14.24
|
||||
fabric_api_version=0.42.0+1.16
|
||||
|
||||
@@ -7,6 +7,9 @@ accessWidenerVersion=1_17
|
||||
builds_for=fabric,forge
|
||||
embed_joml=true
|
||||
|
||||
# Netty
|
||||
netty_version=4.1.25.Final
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.14.24
|
||||
fabric_api_version=0.46.1+1.17
|
||||
|
||||
@@ -7,6 +7,9 @@ accessWidenerVersion=1_18
|
||||
builds_for=fabric,forge
|
||||
embed_joml=true
|
||||
|
||||
# Netty
|
||||
netty_version=4.1.68.Final
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.14.24
|
||||
fabric_api_version=0.76.0+1.18.2
|
||||
|
||||
@@ -7,6 +7,9 @@ accessWidenerVersion=1_19_2
|
||||
builds_for=fabric,forge
|
||||
embed_joml=true
|
||||
|
||||
# Netty
|
||||
netty_version=4.1.77.Final
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.14.24
|
||||
fabric_api_version=0.76.1+1.19.2
|
||||
|
||||
@@ -6,6 +6,9 @@ compatible_minecraft_versions=["1.19.4"]
|
||||
accessWidenerVersion=1_19_4
|
||||
builds_for=fabric,forge
|
||||
|
||||
# Netty
|
||||
netty_version=4.1.82.Final
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.14.24
|
||||
fabric_api_version=0.87.1+1.19.4
|
||||
|
||||
@@ -6,6 +6,9 @@ compatible_minecraft_versions=["1.20", "1.20.1"]
|
||||
accessWidenerVersion=1_20
|
||||
builds_for=fabric,forge
|
||||
|
||||
# Netty
|
||||
netty_version=4.1.82.Final
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.15.6
|
||||
fabric_api_version=0.90.4+1.20.1
|
||||
|
||||
@@ -6,6 +6,9 @@ compatible_minecraft_versions=["1.20.2"]
|
||||
accessWidenerVersion=1_20_2
|
||||
builds_for=fabric,forge
|
||||
|
||||
# Netty
|
||||
netty_version=4.1.97.Final
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.15.6
|
||||
fabric_api_version=0.90.4+1.20.2
|
||||
|
||||
@@ -7,6 +7,9 @@ accessWidenerVersion=1_20_2
|
||||
builds_for=fabric,forge
|
||||
# neoforge can be added once the issue with mixins has been resolved
|
||||
|
||||
# Netty
|
||||
netty_version=4.1.97.Final
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.15.6
|
||||
fabric_api_version=0.91.2+1.20.4
|
||||
|
||||
@@ -7,6 +7,9 @@ accessWidenerVersion=1_20_6
|
||||
builds_for=fabric,neoforge
|
||||
# forge is broken due to gradle/build script issues
|
||||
|
||||
# Netty
|
||||
netty_version=4.1.97.Final
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.15.10
|
||||
fabric_api_version=0.97.8+1.20.6
|
||||
@@ -50,4 +53,4 @@ neoforge_version=20.6.70-beta
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
enable_terrafirmacraft=0
|
||||
enable_terrafirmacraft=0
|
||||
@@ -7,6 +7,9 @@ accessWidenerVersion=1_20_6
|
||||
builds_for=fabric,neoforge
|
||||
# forge is broken due to gradle/build script issues
|
||||
|
||||
# Netty
|
||||
netty_version=4.1.97.Final
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.15.11
|
||||
fabric_api_version=0.100.1+1.21
|
||||
@@ -50,4 +53,4 @@ neoforge_version=21.1.6
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
enable_terrafirmacraft=0
|
||||
enable_terrafirmacraft=0
|
||||
@@ -0,0 +1,4 @@
|
||||
Remove-Item -Recurse -Force "run/client/Distant_Horizons_server_data"
|
||||
|
||||
Get-ChildItem -Path "run/server" -Recurse -Filter "Distant_Horizons" | ForEach-Object { Remove-Item -Recurse -Force $_.FullName }
|
||||
Get-ChildItem -Path "run/server" -Recurse -Filter "DistantHorizons.sqlite" | ForEach-Object { Remove-Item -Force $_.FullName }
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm -rf run/client/Distant_Horizons_server_data
|
||||
rm -rf $(find run/server -name "Distant_Horizons")
|
||||
rm -rf $(find run/server -name "DistantHorizons.sqlite")
|
||||
Reference in New Issue
Block a user