Compare commits
94 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1e52ee15b5 | |||
| b54d478de1 | |||
| 8008d61636 | |||
| cf38aef742 | |||
| 8621bf631b | |||
| c31c27167f | |||
| 35d97fa98f | |||
| 8627270e5c | |||
| 69dd7e932d | |||
| 74371bd70d | |||
| 4a38b15ece | |||
| 96429eec00 | |||
| c49e38a58c | |||
| b2047ce0c0 | |||
| 5b60d515e9 | |||
| cf0205caa4 | |||
| c91ab1deb1 | |||
| 2b5dd236aa | |||
| 0658479921 | |||
| ff8b07ac12 | |||
| fb87ee529a | |||
| 1fabc24e45 | |||
| 9ab2cfcb6a | |||
| e81e31fc24 | |||
| e69b7dec7d | |||
| 534e4a4377 | |||
| 3193773583 | |||
| 4d4906228e | |||
| e4a1d7478a | |||
| cf8eaa57cf | |||
| 2211add5e0 | |||
| e432358e1b | |||
| 3ccce80e1d | |||
| 1952f91540 | |||
| 0e1017111e | |||
| b4be8ab83f | |||
| 3b807dae95 | |||
| 9fdaeed69b | |||
| b7d627f0f5 | |||
| 733bbc0b58 | |||
| 17f6147e13 | |||
| 08c4c8667a | |||
| 526791aae7 | |||
| 8fdd6dcccc | |||
| fb4f5819fd | |||
| 58554f3891 | |||
| 5020084663 | |||
| 5aaab01ac9 | |||
| 024f60de9b | |||
| 1ccc46869d | |||
| 3edcb8d03d | |||
| d7189f0f05 | |||
| f19aa7831e | |||
| 601eeb7fbe | |||
| a8f20a407b | |||
| 872a7d9fa8 | |||
| 310b85ad83 | |||
| b8d94ba7eb | |||
| 4c112aa8ae | |||
| df6da4b48a | |||
| c3e8449979 | |||
| d8707bfe01 | |||
| f07940c11f | |||
| 889c3d32c9 | |||
| 1e502c5933 | |||
| f01e31f475 | |||
| 4285f32b94 | |||
| af5bcafa45 | |||
| 909870b321 | |||
| 2b5dd8b77e | |||
| 4d4e4a9706 | |||
| ac82e90dc2 | |||
| 8063141406 | |||
| 5c17e9599b | |||
| 2e54f2166d | |||
| a0bd2ba4a1 | |||
| 38102ac17f | |||
| 139c5869c9 | |||
| 79206420f9 | |||
| e046b972ca | |||
| ea4949b3a2 | |||
| 05d5f0b943 | |||
| 81df84dc37 | |||
| ff9bab99c7 | |||
| 301ea26a03 | |||
| bd7a03b0ca | |||
| 4e0619a269 | |||
| 8b13afeb23 | |||
| ce44feeb40 | |||
| 821e86b875 | |||
| 015e596eda | |||
| 09e535abf4 | |||
| 855f7f0f9a | |||
| 5fa3e3cb7f |
+89
-37
@@ -3,8 +3,10 @@ image: gradle:eclipse-temurin
|
||||
|
||||
# all stages need to be defined here
|
||||
stages:
|
||||
- build_18_1
|
||||
- build_18_2
|
||||
- build_18_1
|
||||
- build_17_1
|
||||
- build_16_5
|
||||
|
||||
variables:
|
||||
# Pull core when building
|
||||
@@ -17,47 +19,97 @@ before_script:
|
||||
- echo GE_JOB_ID=$CI_JOB_ID >> generate_jars.env
|
||||
|
||||
|
||||
|
||||
# 1.16.5 build
|
||||
build_16_5:
|
||||
stage: build_16_5
|
||||
script:
|
||||
- ./gradlew deleteMerged --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer=1.16.5 --gradle-user-home cache/;
|
||||
- ./gradlew merge --gradle-user-home cache/;
|
||||
image: eclipse-temurin:16
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_16_5-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
# 1.17.1 build
|
||||
build_17_1:
|
||||
stage: build_17_1
|
||||
script:
|
||||
- ./gradlew deleteMerged --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer=1.17.1 --gradle-user-home cache/;
|
||||
- ./gradlew merge --gradle-user-home cache/;
|
||||
image: eclipse-temurin:16
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_17_1-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
# even if one build fails, upload the successful jars
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
# 1.18.1 build
|
||||
build_18_1:
|
||||
stage: build_18_1
|
||||
script:
|
||||
- ./gradlew deleteMerged --gradle-user-home cache/; # make sure any previously merged jars are removed before running this job
|
||||
- ./gradlew build -PmcVer=1.18.1 --gradle-user-home cache/;
|
||||
- ./gradlew merge --gradle-user-home cache/;
|
||||
# build using Java 17
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_18_1-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
# relative to the root directory
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
stage: build_18_1
|
||||
script:
|
||||
- ./gradlew deleteMerged --gradle-user-home cache/; # make sure any previously merged jars are removed before running this job
|
||||
- ./gradlew build -PmcVer=1.18.1 --gradle-user-home cache/;
|
||||
- ./gradlew merge --gradle-user-home cache/;
|
||||
# build using Java 17
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_18_1-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
# relative to the root directory
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
# 1.18.2 build
|
||||
build_18_2:
|
||||
stage: build_18_2
|
||||
script:
|
||||
- ./gradlew deleteMerged --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer=1.18.2 --gradle-user-home cache/;
|
||||
- ./gradlew merge --gradle-user-home cache/;
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_18_2-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
stage: build_18_2
|
||||
script:
|
||||
- ./gradlew deleteMerged --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer=1.18.2 --gradle-user-home cache/;
|
||||
- ./gradlew merge --gradle-user-home cache/;
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_18_2-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
|
||||
# unused deployment stage
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# 1.16.5 version
|
||||
|
||||
java_version=8
|
||||
minecraft_version=1.16.5
|
||||
parchment_version=2022.03.06
|
||||
compatible_minecraft_versions=["1.16.4", "1.16.5"]
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.13.2
|
||||
fabric_api_version=0.42.0+1.16
|
||||
# Fabric mod versions
|
||||
modmenu_version=1.16.22
|
||||
starlight_version_fabric=
|
||||
phosphor_version_fabric=
|
||||
lithium_version=mc1.16.5-0.6.6
|
||||
sodium_version=3488820
|
||||
iris_version=1.16.x-v1.1.4
|
||||
bclib_version=
|
||||
immersive_portals_version =
|
||||
|
||||
# Fabric mod run
|
||||
# 0 = Dont enable and dont run
|
||||
# 1 = Can be refranced in code but dosnt run
|
||||
# 2 = Can be refranced in code and runs in client
|
||||
enable_starlight=0
|
||||
enable_phosphor=0
|
||||
enable_lithium=0
|
||||
enable_sodium=1
|
||||
enable_iris=0
|
||||
enable_bclib=0
|
||||
|
||||
# Forge loader
|
||||
forge_version=36.2.28
|
||||
# Forge mod versions
|
||||
starlight_version_forge=
|
||||
terraforged_version=3285909
|
||||
|
||||
# Forge mod run
|
||||
# 0 = Dont enable and dont run
|
||||
# 1 = Can be refranced in code but dosnt run
|
||||
# 2 = Can be refranced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=2
|
||||
|
||||
# Quilt loader
|
||||
quilt_loader_version=0.16.0-beta.10
|
||||
@@ -0,0 +1,46 @@
|
||||
# 1.17.1 version
|
||||
|
||||
java_version=16
|
||||
minecraft_version=1.17.1
|
||||
parchment_version=2021.12.12
|
||||
compatible_minecraft_versions=["1.17", "1.17.1"]
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.13.2
|
||||
fabric_api_version=0.46.1+1.17
|
||||
# Fabric mod versions
|
||||
modmenu_version=2.0.14
|
||||
starlight_version_fabric=3442770
|
||||
phosphor_version_fabric=
|
||||
lithium_version=mc1.17.1-0.7.5
|
||||
sodium_version=3605275
|
||||
iris_version=1.17.x-v1.1.4
|
||||
bclib_version=
|
||||
immersive_portals_version = 0.14-1.17
|
||||
|
||||
# Fabric mod run
|
||||
# 0 = Dont enable and dont run
|
||||
# 1 = Can be refranced in code but dosnt run
|
||||
# 2 = Can be refranced in code and runs in client
|
||||
enable_starlight=0
|
||||
enable_phosphor=0
|
||||
enable_lithium=0
|
||||
enable_sodium=1
|
||||
enable_iris=0
|
||||
enable_bclib=0
|
||||
|
||||
# Forge loader
|
||||
forge_version=37.1.1
|
||||
# Forge mod versions
|
||||
starlight_version_forge=3457784
|
||||
terraforged_version=
|
||||
|
||||
# Forge mod run
|
||||
# 0 = Dont enable and dont run
|
||||
# 1 = Can be refranced in code but dosnt run
|
||||
# 2 = Can be refranced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
|
||||
# Quilt loader
|
||||
quilt_loader_version=0.16.0-beta.10
|
||||
+9
-2
@@ -1,7 +1,9 @@
|
||||
# 1.18.1 version based stuff
|
||||
# 1.18.1 version
|
||||
|
||||
java_version=17
|
||||
minecraft_version=1.18.1
|
||||
java_version = 17
|
||||
parchment_version=2022.03.06
|
||||
compatible_minecraft_versions=["1.18", "1.18.1"]
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.13.3
|
||||
@@ -31,9 +33,14 @@ fabric_api_version=0.46.6+1.18
|
||||
forge_version=39.1.2
|
||||
# Forge mod versions
|
||||
starlight_version_forge=3559934
|
||||
terraforged_version=
|
||||
|
||||
# Forge mod run
|
||||
# 0 = Dont enable and don't run
|
||||
# 1 = Can be referenced in code but doesn't run
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
|
||||
# Quilt loader
|
||||
quilt_loader_version=0.16.0-beta.10
|
||||
+9
-3
@@ -1,8 +1,9 @@
|
||||
# 1.18.2 version based stuff
|
||||
# architectury_plugin_version = 3.4-SNAPSHOT
|
||||
# dev_architectury_loom_version = 0.10.0-SNAPSHOT
|
||||
|
||||
java_version=17
|
||||
minecraft_version=1.18.2
|
||||
java_version = 17
|
||||
parchment_version=2022.03.13
|
||||
compatible_minecraft_versions=["1.18.2"]
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.13.3
|
||||
@@ -32,9 +33,14 @@ fabric_api_version=0.48.0+1.18.2
|
||||
forge_version=40.0.18
|
||||
# Forge mod versions
|
||||
starlight_version_forge=0
|
||||
terraforged_version=
|
||||
|
||||
# Forge mod run
|
||||
# 0 = Don't enable and don't run
|
||||
# 1 = Can be referenced in code but doesn't run
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
|
||||
# Quilt loader
|
||||
quilt_loader_version=0.16.0-beta.10
|
||||
@@ -1,5 +1,3 @@
|
||||
# THIS VERSION IS NO LONGER MAINTAINED! ALL DEVELOPMENT HAVE BEEN MOVED OVER TO THE MAIN BRANCH
|
||||
|
||||
# <img src="https://gitlab.com/jeseibel/distant-horizons-core/-/raw/main/_logo%20files/LOD%20logo%20flat%20-%20with%20boarder.png" width="32"> Distant Horizons
|
||||
|
||||
> A mod that adds a Level of Detail System to Minecraft
|
||||
@@ -16,8 +14,17 @@ If you want to see a quick demo, check out a video covering the mod here:
|
||||
|
||||
<a href="https://www.youtube.com/watch?v=H2tnvEVbO1c" target="_blank"></a>
|
||||
|
||||
## About this branch
|
||||
This is a test branch to add support for the quilt mod loader (https://quiltmc.org/)
|
||||
|
||||
### Versions
|
||||
|
||||
This branch is for these versions of Minecraft
|
||||
- 1.18.2
|
||||
- 1.18.1 & 1.18
|
||||
- 1.17.1 & 1.17
|
||||
- 1.16.5 & 1.16.4
|
||||
|
||||
Architectury version: 3.4-SNAPSHOT\
|
||||
Java Compiler plugin: Manifold Preprocessor
|
||||
|
||||
@@ -30,17 +37,36 @@ Modmenu version: 3.1.0
|
||||
#### 1.18.1 mods
|
||||
Forge version: 39.1.2\
|
||||
Fabric version: 0.13.3\
|
||||
Fabric API version: 0.46.6+1.18\
|
||||
Fabric API version: 0.42.6+1.18\
|
||||
Modmenu version: 3.0.1
|
||||
|
||||
#### 1.17.1 mods
|
||||
Forge version: 37.1.1\
|
||||
Fabric version: 0.13.2\
|
||||
Fabric API version: 0.46.1+1.17\
|
||||
Modmenu version: 2.0.14
|
||||
|
||||
#### 1.16.5 mods
|
||||
Forge version: 36.2.28\
|
||||
Fabric vetsion: 0.13.2\
|
||||
Fabric API version: 0.42.0+1.16\
|
||||
Modmenu version: 1.16.22
|
||||
|
||||
|
||||
|
||||
Notes:\
|
||||
This version has been confirmed to work in IDE and Retail Minecraft.\
|
||||
(Retail running forge version 1.18.1-39.0.5 and fabric version 1.18-0.12.12 and 1.18.1-0.13.2)
|
||||
This version has been confirmed to work in IDE and Retail Minecraft with ether the Fabric or Forge mod-loader.
|
||||
|
||||
|
||||
## Source Code Installation
|
||||
|
||||
#### Nightlly builds
|
||||
This mod has an autobuild system to automatically build the mod on each commit
|
||||
- 1.18.2: https://gitlab.com/jeseibel/minecraft-lod-mod/-/jobs/artifacts/main/download?job=build_18_2
|
||||
- 1.18.1: https://gitlab.com/jeseibel/minecraft-lod-mod/-/jobs/artifacts/main/download?job=build_18_1
|
||||
- 1.17.1: https://gitlab.com/jeseibel/minecraft-lod-mod/-/jobs/artifacts/main/download?job=build_17_1
|
||||
- 1.16.5: https://gitlab.com/jeseibel/minecraft-lod-mod/-/jobs/artifacts/main/download?job=build_16_5
|
||||
|
||||
See the Fabric Documentation online for more detailed instructions:\
|
||||
https://fabricmc.net/wiki/tutorial:setup
|
||||
|
||||
@@ -62,11 +88,13 @@ https://fabricmc.net/wiki/tutorial:setup
|
||||
4. Import the project into eclipse
|
||||
|
||||
## Switching Versions
|
||||
This branch support 2 built versions:
|
||||
This branch support 4 built versions:
|
||||
- 1.18.2
|
||||
- 1.18.1 (which also runs on 1.18)
|
||||
- 1.17.1 (which also runs on 1.17)
|
||||
- 1.16.5 (which also runs 1.16.5)
|
||||
|
||||
To switch between active versions, change `mcVer=1.18.?` in `gradle.properties` file.
|
||||
To switch between active versions, change `mcVer=1.?` in `gradle.properties` file.
|
||||
|
||||
If running on IDE, to ensure IDE pickup the changed versions, you will need to run a gradle command again to allow gradle to update all the libs. (In IntellJ you will also need to do a gradle sync again if it didn't start it automatically.)
|
||||
>Note: There may be a `java.nio.file.FileSystemException` thrown on running the command after switching versions. To fix it, either restart your IDE (as your IDE is locking up a file) or use tools like LockHunter to unlock the linked file. (Often a lib file under `common\build\lib` or `forge\build\lib` or `fabric\build\lib`). If anyone knows how to solve this issue please comment to this issue: https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/233
|
||||
@@ -82,12 +110,12 @@ If running on IDE, to ensure IDE pickup the changed versions, you will need to r
|
||||
6. The compiled jar file will be in the folder `Merged`
|
||||
|
||||
**If in terminal:**
|
||||
1. `git clone -b 1.18.X --recurse-submodules https://gitlab.com/jeseibel/minecraft-lod-mod.git`
|
||||
1. `git clone --recurse-submodules https://gitlab.com/jeseibel/minecraft-lod-mod.git`
|
||||
2. `cd minecraft-lod-mod`
|
||||
3. `./gradlew assemble`
|
||||
4. `./gradlew mergeJars`
|
||||
5. The compiled jar file will be in the folder `Merged`
|
||||
>Note: You can add the arg: `-PmcVer=1.18.?` to tell gradle to build a selected MC version instead of having to manually modify the `gradle.properties` file.
|
||||
>Note: You can add the arg: `-PmcVer=1.?` to tell gradle to build a selected MC version instead of having to manually modify the `gradle.properties` file.
|
||||
|
||||
|
||||
## Other commands
|
||||
@@ -101,7 +129,12 @@ If running on IDE, to ensure IDE pickup the changed versions, you will need to r
|
||||
|
||||
The Minecraft source code is NOT added to your workspace in an editable way. Minecraft is treated like a normal Library. Sources are there for documentation and research purposes only.
|
||||
|
||||
Source code uses Mojang mappings.
|
||||
Source code uses Mojang mappings & [Parchment](https://parchmentmc.org/) mappings.
|
||||
|
||||
To generate the source code run `./gradlew genSources`\
|
||||
If your IDE fails to auto-detect the sources JAR when browsing Minecraft classes manually select the JAR file ending with -sources.jar when prompted by your IDE
|
||||
|
||||
In IntelliJ it's at the top where it says choose sources when browsing Minecraft classes
|
||||
|
||||
## Useful commands
|
||||
|
||||
|
||||
+181
-48
@@ -9,31 +9,69 @@ buildscript {
|
||||
|
||||
plugins {
|
||||
id "architectury-plugin" version "3.4-SNAPSHOT"
|
||||
id "dev.architectury.loom" version "0.10.0-SNAPSHOT" apply false
|
||||
id "dev.architectury.loom" version "0.11.0-SNAPSHOT" apply false
|
||||
}
|
||||
|
||||
def writeBuildGradlePredefine() {
|
||||
def excapedMCVersion = rootProject.minecraft_version.replace(".", "_")
|
||||
new File(projectDir, "build.properties").text = "MC_VERSION_${excapedMCVersion}=\n"
|
||||
}
|
||||
|
||||
def loadProperties() {
|
||||
def defaultMcVersion = '1.18.2'
|
||||
if (!project.hasProperty("mcVer")) {
|
||||
println "No mcVer set! Defaulting to ${defaultMcVersion}."
|
||||
println "Tip: Use -PmcVer='${defaultMcVersion}' in cmd arg to set mcVer."
|
||||
def writeBuildGradlePredefine(List<String> mcVers, int mcIndex) {
|
||||
ArrayList<String> redefineList = new ArrayList<String>()
|
||||
for (int i=0; i<mcVers.size(); i++) {
|
||||
String mcStr = mcVers.get(i).replace(".", "_")
|
||||
if (mcIndex<i) {
|
||||
redefineList.add("PRE_MC_"+mcStr)
|
||||
}
|
||||
if (mcIndex==i) {
|
||||
redefineList.add("MC_"+mcStr)
|
||||
}
|
||||
if (mcIndex>=i) {
|
||||
redefineList.add("POST_MC_"+mcStr)
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder()
|
||||
for (String s : redefineList) {
|
||||
sb.append(s)
|
||||
sb.append("=\n")
|
||||
}
|
||||
new File(projectDir, "build.properties").text = sb.toString()
|
||||
}
|
||||
|
||||
// Sets up the variables for Manifold in the code
|
||||
def loadProperties() {
|
||||
def defaultMcVersion = "1.18.2"
|
||||
def mcVersion = ""
|
||||
def mcVers = mcVersions.split(",")
|
||||
int mcIndex = -1
|
||||
println "Avalible MC versions: ${mcVersions}"
|
||||
if (project.hasProperty("mcVer")) {
|
||||
mcVersion = mcVer
|
||||
mcIndex = Arrays.asList(mcVers).indexOf(mcVer)
|
||||
}
|
||||
if (mcIndex == -1) {
|
||||
println "No mcVer set or the set mcVer is invalid! Defaulting to ${defaultMcVersion}."
|
||||
println "Tip: Use -PmcVer='${defaultMcVersion}' in cmd arg to set mcVer."
|
||||
mcVersion = defaultMcVersion
|
||||
mcIndex = Arrays.asList(mcVers).indexOf(defaultMcVersion)
|
||||
assert mcIndex != -1
|
||||
}
|
||||
def mcVersion = project.hasProperty("mcVer") ? mcVer : defaultMcVersion
|
||||
|
||||
println "Loading properties file at " + mcVersion + ".properties"
|
||||
def props = new Properties()
|
||||
props.load(new FileInputStream("$rootProject.rootDir/"+"$mcVersion"+".properties"))
|
||||
|
||||
|
||||
props.each { prop ->
|
||||
rootProject.ext.set(prop.key, prop.value)
|
||||
// println "Added prop [key:" + prop.key + ", value:" + prop.value + "]"
|
||||
}
|
||||
writeBuildGradlePredefine()
|
||||
writeBuildGradlePredefine(Arrays.asList(mcVers), mcIndex)
|
||||
|
||||
// Stuff for access wideners
|
||||
def mcVersionToAcsessWidenerVersion = [
|
||||
"1.16.5": "1_16",
|
||||
"1.17.1": "1_17",
|
||||
"1.18.1": "1_18",
|
||||
"1.18.2": "1_18",
|
||||
]
|
||||
// Use this as sometimes multiple versions use the same access wideners
|
||||
rootProject.ext.set("acsessWidenerVersion", mcVersionToAcsessWidenerVersion.get(mcVersion))
|
||||
}
|
||||
loadProperties()
|
||||
|
||||
@@ -43,11 +81,16 @@ architectury {
|
||||
minecraft = rootProject.minecraft_version
|
||||
}
|
||||
|
||||
|
||||
subprojects { p ->
|
||||
apply plugin: "dev.architectury.loom"
|
||||
|
||||
loom {
|
||||
silentMojangMappingsLicense()
|
||||
|
||||
if (p != project(":core")) {
|
||||
accessWidenerPath = project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener")
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
@@ -58,32 +101,51 @@ subprojects { p ->
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
||||
// The following line declares the mojmap mappings
|
||||
mappings loom.officialMojangMappings()
|
||||
|
||||
// The following line declares the mojmap mappings & parchment mappings
|
||||
mappings loom.layered() {
|
||||
// Mojmap mappings
|
||||
officialMojangMappings()
|
||||
// Parchment mappings (it adds parameter mappings & javadoc)
|
||||
parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip")
|
||||
}
|
||||
|
||||
//Manifold
|
||||
annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}"
|
||||
|
||||
// Toml
|
||||
implementation("com.electronwill.night-config:toml:${rootProject.toml_version}")
|
||||
|
||||
if (p != project(":forge")) {
|
||||
if (p != project(":forge") && p != project(":fabric")) {
|
||||
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
|
||||
// Do NOT use other classes from fabric loader unless working with fabric
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
}
|
||||
|
||||
if (p == project(":fabric")) {
|
||||
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
|
||||
// Do NOT use other classes from fabric loader unless working with fabric
|
||||
if (rootProject.use_quilt_rather_than_fabric == "true") {
|
||||
// Quilt loader
|
||||
modImplementation "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}"
|
||||
modImplementation "org.quiltmc:quilt-json5:1.0.0" // Needed for quilt loader but for some reason it dosnt come with it
|
||||
} else {
|
||||
// Fabric loader
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
}
|
||||
}
|
||||
|
||||
if (p != project(":core")) {
|
||||
common(project(":core")) { transitive false }
|
||||
shadowMe(project(":core")) { transitive false }
|
||||
}
|
||||
}
|
||||
|
||||
// Allows the jar to run standalone
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Implementation-Title': rootProject.archives_base_name,
|
||||
'Implementation-Version': rootProject.mod_version,
|
||||
'Main-Class': 'com.seibel.lod.core.JarMain'
|
||||
'Main-Class': 'com.seibel.lod.core.JarMain' // When changing the main of the jar change this line
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,13 +159,22 @@ allprojects { p ->
|
||||
version = rootProject.mod_version
|
||||
group = rootProject.maven_group
|
||||
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
// For parchment mappings
|
||||
maven { url "https://maven.parchmentmc.org" }
|
||||
|
||||
// used to download and compile dependencies from git repos
|
||||
maven { url 'https://jitpack.io' }
|
||||
|
||||
// For Manifold Preprocessor
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
||||
|
||||
// For Manifold Preprocessor
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
||||
|
||||
|
||||
// Required for ModMenu
|
||||
maven { url "https://maven.terraformersmc.com/" }
|
||||
|
||||
// Required for importing Modrinth mods
|
||||
maven {
|
||||
@@ -122,6 +193,12 @@ allprojects { p ->
|
||||
}
|
||||
}
|
||||
|
||||
// Required for Quilt
|
||||
maven {
|
||||
name 'Quilt'
|
||||
url 'https://maven.quiltmc.org/repository/release'
|
||||
}
|
||||
|
||||
// These 2 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/fabric"
|
||||
@@ -135,24 +212,55 @@ allprojects { p ->
|
||||
includeGroup "forge-mod"
|
||||
}
|
||||
}
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/quilt"
|
||||
content {
|
||||
includeGroup "quilt-mod"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Make a new author thing for quilt as quilt uses a different layout for their authors
|
||||
// The output to look something like this {"James":"Developer","coolGi":"Developer}
|
||||
def currentAuthor = ""
|
||||
def quiltAuthors = "{"
|
||||
def authorCounter = false;
|
||||
for (reader in rootProject.mod_authors) {
|
||||
if (authorCounter)
|
||||
currentAuthor = currentAuthor + reader
|
||||
|
||||
if (reader == "\"") {
|
||||
authorCounter = !authorCounter
|
||||
if (!authorCounter) {
|
||||
currentAuthor = currentAuthor.substring(0, currentAuthor.length() - 1); // Delete the qotation mark at the end of the authors name
|
||||
quiltAuthors = quiltAuthors + "\"" + currentAuthor + "\":\"Developer\"," // Add the author to the string
|
||||
currentAuthor = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
quiltAuthors = quiltAuthors.substring(0, quiltAuthors.length() - 1) // Delete the final comma
|
||||
quiltAuthors = quiltAuthors + "}"
|
||||
|
||||
|
||||
// Put stuff from gradle.properties into the mod info
|
||||
processResources {
|
||||
def resourceTargets = ["fabric.mod.json", "META-INF/mods.toml"] // Location of where to put
|
||||
def resourceTargets = ["fabric.mod.json", "quilt.mod.json", "META-INF/mods.toml"] // Location of where to put
|
||||
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
|
||||
def replaceProperties = [
|
||||
version: mod_version,
|
||||
mod_name: mod_name,
|
||||
authors: mod_authors,
|
||||
description: mod_description,
|
||||
homepage: mod_homepage,
|
||||
source: mod_source,
|
||||
issues: mod_issues,
|
||||
minecraft_version: minecraft_version,
|
||||
java_version: java_version
|
||||
] // The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties
|
||||
version : mod_version,
|
||||
mod_name : mod_name,
|
||||
authors : mod_authors,
|
||||
quilt_authors : quiltAuthors,
|
||||
description : mod_description,
|
||||
homepage : mod_homepage,
|
||||
source : mod_source,
|
||||
issues : mod_issues,
|
||||
minecraft_version : minecraft_version,
|
||||
compatible_minecraft_versions: compatible_minecraft_versions,
|
||||
java_version : java_version
|
||||
]
|
||||
// The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties
|
||||
//TODO: Make Forge loader version also be relaced with non hardcoded value instead of "[36,41)"
|
||||
|
||||
inputs.properties replaceProperties
|
||||
@@ -175,8 +283,37 @@ allprojects { p ->
|
||||
}
|
||||
|
||||
|
||||
// Copies the correct accesswidener and renames it
|
||||
task copyAccessWidener(type: Copy) {
|
||||
from project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener")
|
||||
into(file(p.file("build/resources/main")))
|
||||
rename "${rootProject.acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener"
|
||||
}
|
||||
|
||||
task copyCoreResources(type: Copy) {
|
||||
from fileTree(project(":core").file("src/main/resources"))
|
||||
into p.file("build/resources/main")
|
||||
}
|
||||
|
||||
task copyCommonResources(type: Copy) {
|
||||
from fileTree(project(":common").file("src/main/resources"))
|
||||
into p.file("build/resources/main")
|
||||
}
|
||||
|
||||
|
||||
// Is this necessary for running the fabric build
|
||||
if (p == project(":common")) {
|
||||
println "Copying [common/src/main/resources/${acsessWidenerVersion}.lod.accesswidner] to [fabric/build/resources/main]."
|
||||
|
||||
copy {
|
||||
from project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener")
|
||||
into project(":fabric").file("build/resources/main")
|
||||
rename "${acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener"
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
// Add Manifold Preprocessor
|
||||
// Add Manifold Preprocessor
|
||||
// def excapedMCVersion = rootProject.minecraft_version.replace(".", "_")
|
||||
// options.compilerArgs += ['-Xplugin:Manifold', "-AMC_VERSION_${excapedMCVersion}"]
|
||||
//
|
||||
@@ -188,33 +325,29 @@ allprojects { p ->
|
||||
//options.compilerArgs += ['-XprintProcessorInfo']
|
||||
//options.compilerArgs += ['-XprintRounds']
|
||||
|
||||
// println options.compilerArgs
|
||||
// println options.compilerArgs
|
||||
|
||||
options.encoding = "UTF-8"
|
||||
// Set the java version
|
||||
if (p != project(":core")) {
|
||||
options.compilerArgs += ['-Xplugin:Manifold']
|
||||
options.release = rootProject.java_version as Integer
|
||||
} else if (p == project(":core")) {
|
||||
options.release = 8; // Core should use Java 8 no matter what
|
||||
}
|
||||
// TODO: make everything use java 8
|
||||
// options.release = 8 // Use Java 8 for everything so back porting is easier
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
// Disable running the core and common
|
||||
if (p == project(":core") || p == project(":common")) {
|
||||
runClient.enabled = false
|
||||
runServer.enabled = false
|
||||
}
|
||||
|
||||
|
||||
// this is necessary for running the fabric build
|
||||
if (p == project(":common")) {
|
||||
println "Coping [common/src/main/resources/lod.accesswidner] to [fabric/build/resources/main]."
|
||||
|
||||
copy {
|
||||
from "$rootProject.rootDir/common/src/main/resources"
|
||||
into "$rootProject.rootDir/fabric/build/resources/main"
|
||||
include "*.accesswidener"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -222,4 +355,4 @@ allprojects { p ->
|
||||
// the previous merges to each new build job in the CI/CD pipeline
|
||||
task deleteMerged(type: Delete) {
|
||||
delete files("./Merged")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-13
@@ -1,17 +1,5 @@
|
||||
loom {
|
||||
accessWidenerPath.set(file("src/main/resources/lod.accesswidener"))
|
||||
}
|
||||
|
||||
architectury {
|
||||
common()
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
tasks {
|
||||
remapJar {
|
||||
remapAccessWidener.set(false)
|
||||
}
|
||||
}
|
||||
common(rootProject.enabled_platforms.split(","))
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -290,6 +290,11 @@ public class Config
|
||||
@ConfigAnnotations.Entry(minValue = -4096, maxValue = 4096)
|
||||
public static int caveCullingHeight = IAdvancedGraphics.CAVE_CULLING_HEIGHT_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _earthCurveRatio = IAdvancedGraphics.EARTH_CURVE_RATIO_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 0, maxValue = 5000)
|
||||
public static int earthCurveRatio = IAdvancedGraphics.EARTH_CURVE_RATIO_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
/*
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _backsideCullingRange = IAdvancedGraphics.VANILLA_CULLING_RANGE_DESC;
|
||||
@@ -373,8 +378,8 @@ public class Config
|
||||
{
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _numberOfWorldGenerationThreads = IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 1, maxValue = 50)
|
||||
public static int numberOfWorldGenerationThreads = IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DEFAULT.defaultValue;
|
||||
@ConfigAnnotations.Entry(minValue = 0.1, maxValue = 50.0)
|
||||
public static double numberOfWorldGenerationThreads = IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DEFAULT.defaultValue;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _numberOfBufferBuilderThreads = IThreading.NUMBER_OF_BUFFER_BUILDER_THREADS_DESC;
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common;
|
||||
|
||||
import com.seibel.lod.common.forge.LodForgeMethodCaller;
|
||||
|
||||
@@ -1,8 +1,29 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.forge;
|
||||
|
||||
import com.seibel.lod.common.wrappers.minecraft.MinecraftClientWrapper;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.ColorResolver;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
@@ -16,4 +37,6 @@ import java.util.Random;
|
||||
*/
|
||||
public interface LodForgeMethodCaller {
|
||||
List<BakedQuad> getQuads(MinecraftClientWrapper mc, Block block, BlockState blockState, Direction direction, Random random);
|
||||
|
||||
int colorResolverGetColor(ColorResolver resolver, Biome biome, double x, double z);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.networking;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.networking;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.networking;
|
||||
|
||||
import com.seibel.lod.core.ModInfo;
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers;
|
||||
|
||||
import com.seibel.lod.common.LodCommonMain;
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,4 +1,22 @@
|
||||
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers;
|
||||
|
||||
import com.seibel.lod.core.enums.config.DistanceGenerationMode;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,7 +1,27 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.block;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -14,13 +34,13 @@ public class BlockDetailMap
|
||||
private BlockDetailMap() {}
|
||||
|
||||
public static BlockDetailWrapper getOrMakeBlockDetailCache(BlockState bs, BlockPos pos, LevelReader getter) {
|
||||
if (!bs.getFluidState().isEmpty()) {
|
||||
bs = bs.getFluidState().createLegacyBlock();
|
||||
}
|
||||
BlockDetailWrapper cache = map.get(bs);
|
||||
if (cache != null) return cache;
|
||||
if (bs.getFluidState().isEmpty()) {
|
||||
cache = BlockDetailWrapper.make(bs, pos, getter);
|
||||
} else {
|
||||
cache = BlockDetailWrapper.make(bs.getFluidState().createLegacyBlock(), pos, getter);
|
||||
}
|
||||
cache = BlockDetailWrapper.make(bs, pos, getter);
|
||||
//ApiShared.LOGGER.info("New blockDetail cache for {} to {} ", bs, cache);
|
||||
BlockDetailWrapper cacheCAS = map.putIfAbsent(bs, cache);
|
||||
return cacheCAS==null ? cache : cacheCAS;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.block;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -50,6 +69,8 @@ import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/*-- WARN: This class should NEVER hold reference to anything large,
|
||||
as this is never dealloc until the end of runtime!! --*/
|
||||
public class BlockDetailWrapper extends IBlockDetailWrapper
|
||||
{
|
||||
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
@@ -139,10 +160,6 @@ public class BlockDetailWrapper extends IBlockDetailWrapper
|
||||
return tempColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private static final Block[] BLOCK_TO_AVOID = {Blocks.AIR, Blocks.CAVE_AIR, Blocks.BARRIER};
|
||||
|
||||
private static final Direction[] DIRECTION_ORDER = {Direction.UP, Direction.NORTH, Direction.EAST, Direction.WEST, Direction.SOUTH, Direction.DOWN};
|
||||
@@ -154,10 +171,11 @@ public class BlockDetailWrapper extends IBlockDetailWrapper
|
||||
}
|
||||
|
||||
final BlockState state;
|
||||
final BlockPos samplePos;
|
||||
final LevelReader sampleGetter;
|
||||
|
||||
boolean isShapeResolved = false;
|
||||
//boolean isShapeResolved = false;
|
||||
//^ Shapes no longer lazy resolved due to memory leaks from needing
|
||||
// to keep a reference to the block getter
|
||||
|
||||
boolean[] dontOccludeFaces = null;
|
||||
boolean noCollision = false;
|
||||
boolean noFullFace = false;
|
||||
@@ -172,14 +190,12 @@ public class BlockDetailWrapper extends IBlockDetailWrapper
|
||||
|
||||
public BlockDetailWrapper(BlockState state, BlockPos pos, LevelReader getter) {
|
||||
this.state = state;
|
||||
this.samplePos = pos;
|
||||
this.sampleGetter = getter;
|
||||
resolveShapes(getter, pos);
|
||||
//ApiShared.LOGGER.info("Created BlockDetailWrapper for blockstate {} at {}", state, pos);
|
||||
}
|
||||
|
||||
private BlockDetailWrapper() {
|
||||
this.state = null;
|
||||
this.samplePos = null;
|
||||
this.sampleGetter = null;
|
||||
}
|
||||
|
||||
static BlockDetailWrapper make(BlockState bs, BlockPos pos, LevelReader getter) {
|
||||
@@ -194,8 +210,8 @@ public class BlockDetailWrapper extends IBlockDetailWrapper
|
||||
}
|
||||
}
|
||||
|
||||
private void resolveShapes() {
|
||||
if (isShapeResolved) return;
|
||||
private void resolveShapes(LevelReader sampleGetter, BlockPos samplePos) {
|
||||
//if (isShapeResolved) return;
|
||||
if (state.getFluidState().isEmpty()) {
|
||||
noCollision = state.getCollisionShape(sampleGetter, samplePos).isEmpty();
|
||||
dontOccludeFaces = new boolean[6];
|
||||
@@ -222,7 +238,6 @@ public class BlockDetailWrapper extends IBlockDetailWrapper
|
||||
} else { // Liquid Block
|
||||
dontOccludeFaces = new boolean[6];
|
||||
}
|
||||
isShapeResolved = true;
|
||||
}
|
||||
|
||||
private void resolveColors() {
|
||||
@@ -241,12 +256,13 @@ public class BlockDetailWrapper extends IBlockDetailWrapper
|
||||
quads = Minecraft.getInstance().getModelManager().getBlockModelShaper().
|
||||
getBlockModel(state).getQuads(state, null, random);
|
||||
}
|
||||
|
||||
if (quads != null && !quads.isEmpty()) {
|
||||
needPostTinting = quads.get(0).isTinted();
|
||||
needShade = quads.get(0).isShade();
|
||||
tintIndex = quads.get(0).getTintIndex();
|
||||
baseColor = calculateColorFromTexture(quads.get(0).getSprite(),
|
||||
baseColor = calculateColorFromTexture(
|
||||
#if PRE_MC_1_17_1 quads.get(0).sprite,
|
||||
#else quads.get(0).getSprite(), #endif
|
||||
ColorMode.getColorMode(state.getBlock()));
|
||||
} else { // Backup method.
|
||||
needPostTinting = false;
|
||||
@@ -256,13 +272,11 @@ public class BlockDetailWrapper extends IBlockDetailWrapper
|
||||
ColorMode.getColorMode(state.getBlock()));
|
||||
}
|
||||
} else { // Liquid Block
|
||||
|
||||
needPostTinting = true;
|
||||
needShade = false;
|
||||
tintIndex = 0;
|
||||
baseColor = calculateColorFromTexture(Minecraft.getInstance().getModelManager().getBlockModelShaper().getParticleIcon(state),
|
||||
ColorMode.getColorMode(state.getBlock()));
|
||||
|
||||
}
|
||||
isColorResolved = true;
|
||||
}
|
||||
@@ -292,21 +306,21 @@ public class BlockDetailWrapper extends IBlockDetailWrapper
|
||||
@Override
|
||||
public boolean hasFaceCullingFor(LodDirection dir)
|
||||
{
|
||||
resolveShapes();
|
||||
//resolveShapes();
|
||||
return !dontOccludeFaces[dir.ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNoCollision()
|
||||
{
|
||||
resolveShapes();
|
||||
//resolveShapes();
|
||||
return noCollision;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean noFaceIsFullFace()
|
||||
{
|
||||
resolveShapes();
|
||||
//resolveShapes();
|
||||
return noFullFace;
|
||||
}
|
||||
|
||||
@@ -322,5 +336,8 @@ public class BlockDetailWrapper extends IBlockDetailWrapper
|
||||
{
|
||||
return ((BlockDetailWrapper)iBlockDetail).state.getBlock().equals(state.getBlock());
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
return "BlockDetail{" + state + "}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.block;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
+25
-1
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.block;
|
||||
|
||||
|
||||
@@ -18,11 +37,16 @@ public class TextureAtlasSpriteWrapper {
|
||||
* The code has been modified to use TextureAtlasSprite
|
||||
*/
|
||||
public static int getPixelRGBA(TextureAtlasSprite sprite, int frameIndex, int x, int y) {
|
||||
#if PRE_MC_1_17_1
|
||||
return sprite.mainImage[0].getPixelRGBA(
|
||||
x + sprite.framesX[frameIndex] * sprite.getWidth(),
|
||||
y + sprite.framesY[frameIndex] * sprite.getHeight());
|
||||
#else
|
||||
if (sprite.animatedTexture != null) {
|
||||
x += sprite.animatedTexture.getFrameX(frameIndex) * sprite.width;
|
||||
y += sprite.animatedTexture.getFrameY(frameIndex) * sprite.height;
|
||||
}
|
||||
|
||||
return sprite.mainImage[0].getPixelRGBA(x, y);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
+45
-18
@@ -1,5 +1,25 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.block;
|
||||
|
||||
import com.seibel.lod.common.LodCommonMain;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.color.block.BlockTintCache;
|
||||
@@ -33,17 +53,21 @@ public class TintGetterOverrideFast implements BlockAndTintGetter {
|
||||
}
|
||||
|
||||
private Biome _getBiome(BlockPos pos) {
|
||||
#if MC_VERSION_1_18_2
|
||||
#if POST_MC_1_18_2
|
||||
return parent.getBiome(pos).value();
|
||||
#elif MC_VERSION_1_18_1
|
||||
#else
|
||||
return parent.getBiome(pos);
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver) {
|
||||
Biome b = _getBiome(blockPos);
|
||||
return colorResolver.getColor(b, blockPos.getX(), blockPos.getZ());
|
||||
if (LodCommonMain.forgeMethodCaller != null) {
|
||||
return LodCommonMain.forgeMethodCaller.colorResolverGetColor(colorResolver, _getBiome(blockPos),
|
||||
blockPos.getX(), blockPos.getZ());
|
||||
} else {
|
||||
return colorResolver.getColor(_getBiome(blockPos), blockPos.getX(), blockPos.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,10 +101,6 @@ public class TintGetterOverrideFast implements BlockAndTintGetter {
|
||||
return parent.getBlockEntity(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> Optional<T> getBlockEntity(BlockPos blockPos, BlockEntityType<T> blockEntityType) {
|
||||
return parent.getBlockEntity(blockPos, blockEntityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState(BlockPos blockPos) {
|
||||
@@ -107,11 +127,6 @@ public class TintGetterOverrideFast implements BlockAndTintGetter {
|
||||
return parent.getBlockStates(aABB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockHitResult isBlockInLine(ClipBlockStateContext clipBlockStateContext) {
|
||||
return parent.isBlockInLine(clipBlockStateContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockHitResult clip(ClipContext clipContext) {
|
||||
return parent.clip(clipContext);
|
||||
@@ -133,6 +148,22 @@ public class TintGetterOverrideFast implements BlockAndTintGetter {
|
||||
return parent.getBlockFloorHeight(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxBuildHeight() {
|
||||
return parent.getMaxBuildHeight();
|
||||
}
|
||||
|
||||
#if POST_MC_1_17_1
|
||||
@Override
|
||||
public <T extends BlockEntity> Optional<T> getBlockEntity(BlockPos blockPos, BlockEntityType<T> blockEntityType) {
|
||||
return parent.getBlockEntity(blockPos, blockEntityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockHitResult isBlockInLine(ClipBlockStateContext clipBlockStateContext) {
|
||||
return parent.isBlockInLine(clipBlockStateContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return parent.getHeight();
|
||||
@@ -143,11 +174,6 @@ public class TintGetterOverrideFast implements BlockAndTintGetter {
|
||||
return parent.getMinBuildHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxBuildHeight() {
|
||||
return parent.getMaxBuildHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSectionsCount() {
|
||||
return parent.getSectionsCount();
|
||||
@@ -187,4 +213,5 @@ public class TintGetterOverrideFast implements BlockAndTintGetter {
|
||||
public int getSectionYFromSectionIndex(int i) {
|
||||
return parent.getSectionYFromSectionIndex(i);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
+48
-19
@@ -1,5 +1,25 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.block;
|
||||
|
||||
import com.seibel.lod.common.LodCommonMain;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.color.block.BlockTintCache;
|
||||
@@ -34,10 +54,10 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter {
|
||||
}
|
||||
|
||||
private Biome _getBiome(BlockPos pos) {
|
||||
#if MC_VERSION_1_18_2
|
||||
#if POST_MC_1_18_2
|
||||
return parent.getBiome(pos).value();
|
||||
#elif MC_VERSION_1_18_1
|
||||
return parent.getBiome(pos);
|
||||
#else
|
||||
return parent.getBiome(pos);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -55,7 +75,14 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter {
|
||||
while (cursor3D.advance())
|
||||
{
|
||||
mutableBlockPos.set(cursor3D.nextX(), cursor3D.nextY(), cursor3D.nextZ());
|
||||
int n = colorResolver.getColor(_getBiome(mutableBlockPos), mutableBlockPos.getX(), mutableBlockPos.getZ());
|
||||
int n;
|
||||
if (LodCommonMain.forgeMethodCaller != null) {
|
||||
n = LodCommonMain.forgeMethodCaller.colorResolverGetColor(colorResolver, _getBiome(mutableBlockPos),
|
||||
mutableBlockPos.getX(), mutableBlockPos.getZ());
|
||||
} else {
|
||||
n = colorResolver.getColor(_getBiome(mutableBlockPos), mutableBlockPos.getX(), mutableBlockPos.getZ());
|
||||
}
|
||||
|
||||
k += (n & 0xFF0000) >> 16;
|
||||
l += (n & 0xFF00) >> 8;
|
||||
m += n & 0xFF;
|
||||
@@ -99,11 +126,6 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter {
|
||||
return parent.getBlockEntity(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> Optional<T> getBlockEntity(BlockPos blockPos, BlockEntityType<T> blockEntityType) {
|
||||
return parent.getBlockEntity(blockPos, blockEntityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState(BlockPos blockPos) {
|
||||
return parent.getBlockState(blockPos);
|
||||
@@ -129,11 +151,6 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter {
|
||||
return parent.getBlockStates(aABB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockHitResult isBlockInLine(ClipBlockStateContext clipBlockStateContext) {
|
||||
return parent.isBlockInLine(clipBlockStateContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockHitResult clip(ClipContext clipContext) {
|
||||
return parent.clip(clipContext);
|
||||
@@ -155,6 +172,22 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter {
|
||||
return parent.getBlockFloorHeight(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxBuildHeight() {
|
||||
return parent.getMaxBuildHeight();
|
||||
}
|
||||
|
||||
#if POST_MC_1_17_1
|
||||
@Override
|
||||
public <T extends BlockEntity> Optional<T> getBlockEntity(BlockPos blockPos, BlockEntityType<T> blockEntityType) {
|
||||
return parent.getBlockEntity(blockPos, blockEntityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockHitResult isBlockInLine(ClipBlockStateContext clipBlockStateContext) {
|
||||
return parent.isBlockInLine(clipBlockStateContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return parent.getHeight();
|
||||
@@ -165,11 +198,6 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter {
|
||||
return parent.getMinBuildHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxBuildHeight() {
|
||||
return parent.getMaxBuildHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSectionsCount() {
|
||||
return parent.getSectionsCount();
|
||||
@@ -209,4 +237,5 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter {
|
||||
public int getSectionYFromSectionIndex(int i) {
|
||||
return parent.getSectionYFromSectionIndex(i);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.chunk;
|
||||
|
||||
import java.util.Objects;
|
||||
@@ -129,7 +148,11 @@ public class ChunkPosWrapper extends AbstractChunkPosWrapper
|
||||
public AbstractBlockPosWrapper getWorldPosition()
|
||||
{
|
||||
// the parameter here is the y position
|
||||
#if PRE_MC_1_17_1
|
||||
BlockPos blockPos = chunkPos.getWorldPosition();
|
||||
#else
|
||||
BlockPos blockPos = chunkPos.getMiddleBlockPosition(0);
|
||||
#endif
|
||||
return new BlockPosWrapper(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.chunk;
|
||||
|
||||
import com.seibel.lod.common.wrappers.block.BlockDetailWrapper;
|
||||
@@ -14,7 +33,9 @@ import com.seibel.lod.common.wrappers.world.BiomeWrapper;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.LightedWorldGenRegion;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
#if POST_MC_1_17_1
|
||||
import net.minecraft.core.QuartPos;
|
||||
#endif
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.block.LiquidBlockContainer;
|
||||
@@ -45,13 +66,21 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
|
||||
@Override
|
||||
public int getHeight(){
|
||||
#if PRE_MC_1_17_1
|
||||
return 255;
|
||||
#else
|
||||
return chunk.getHeight();
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinBuildHeight()
|
||||
{
|
||||
#if PRE_MC_1_17_1
|
||||
return 0;
|
||||
#else
|
||||
return chunk.getMinBuildHeight();
|
||||
#endif
|
||||
}
|
||||
@Override
|
||||
public int getMaxBuildHeight()
|
||||
@@ -68,13 +97,19 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
@Override
|
||||
public IBiomeWrapper getBiome(int x, int y, int z)
|
||||
{
|
||||
#if MC_VERSION_1_18_2
|
||||
#if PRE_MC_1_17_1
|
||||
return BiomeWrapper.getBiomeWrapper(chunk.getBiomes().getNoiseBiome(
|
||||
x >> 2, y >> 2, z >> 2));
|
||||
#elif PRE_MC_1_18_1
|
||||
return BiomeWrapper.getBiomeWrapper(chunk.getBiomes().getNoiseBiome(
|
||||
QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)));
|
||||
#elif PRE_MC_1_18_2
|
||||
return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome(
|
||||
QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)));
|
||||
#else
|
||||
return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome(
|
||||
QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)).value());
|
||||
#elif MC_VERSION_1_18_1
|
||||
return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome(
|
||||
QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -127,7 +162,7 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
|
||||
@Override
|
||||
public int getMaxY(int x, int z) {
|
||||
return chunk.getHeight(Heightmap.Types.MOTION_BLOCKING, Math.floorMod(x, 16), Math.floorMod(z, 16));
|
||||
return chunk.getHeight(Heightmap.Types.WORLD_SURFACE, Math.floorMod(x, 16), Math.floorMod(z, 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,11 +189,14 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
|
||||
@Override
|
||||
public boolean isLightCorrect(){
|
||||
//return true;
|
||||
#if PRE_MC_1_18_1
|
||||
return true;
|
||||
#else
|
||||
if (chunk instanceof LevelChunk) {
|
||||
return ((LevelChunk) chunk).isClientLightReady();
|
||||
}
|
||||
return chunk.isLightCorrect();
|
||||
#endif
|
||||
}
|
||||
|
||||
public boolean isWaterLogged(int x, int y, int z)
|
||||
@@ -204,5 +242,10 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
{
|
||||
return lightSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return chunk.getClass().getSimpleName() + chunk.getPos();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +50,9 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.client.resources.language.I18n; // translation
|
||||
import net.minecraft.client.gui.narration.NarratableEntry; // Remove in 1.16
|
||||
#if POST_MC_1_17_1
|
||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Based upon TinyConfig
|
||||
@@ -528,6 +530,17 @@ public abstract class ConfigGui
|
||||
Objects.requireNonNull(minecraft).setScreen(this.parent);
|
||||
}
|
||||
|
||||
// addRenderableWidget in 1.17 and over
|
||||
// addButton in 1.16 and below
|
||||
private Button addBtn(Button button) {
|
||||
#if PRE_MC_1_17_1
|
||||
this.addButton(button);
|
||||
#else
|
||||
this.addRenderableWidget(button);
|
||||
#endif
|
||||
return button;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init()
|
||||
{
|
||||
@@ -535,14 +548,11 @@ public abstract class ConfigGui
|
||||
if (!reload)
|
||||
loadFromFile();
|
||||
|
||||
// addRenderableWidget in 1.17 and over
|
||||
// addButton in 1.16 and below
|
||||
this.addRenderableWidget(new Button(this.width / 2 - 154, this.height - 28, 150, 20, CommonComponents.GUI_CANCEL, button -> {
|
||||
addBtn(new Button(this.width / 2 - 154, this.height - 28, 150, 20, CommonComponents.GUI_CANCEL, button -> {
|
||||
loadFromFile();
|
||||
Objects.requireNonNull(minecraft).setScreen(parent);
|
||||
}));
|
||||
|
||||
Button done = this.addRenderableWidget(new Button(this.width / 2 + 4, this.height - 28, 150, 20, CommonComponents.GUI_DONE, (button) -> {
|
||||
Button done = addBtn(new Button(this.width / 2 + 4, this.height - 28, 150, 20, CommonComponents.GUI_DONE, (button) -> {
|
||||
saveToFile();
|
||||
Objects.requireNonNull(minecraft).setScreen(parent);
|
||||
}));
|
||||
@@ -753,10 +763,12 @@ public abstract class ConfigGui
|
||||
|
||||
// Only for 1.17 and over
|
||||
// Remove in 1.16 and below
|
||||
#if POST_MC_1_17_1
|
||||
@Override
|
||||
public List<? extends NarratableEntry> narratables()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
+15
-2
@@ -542,6 +542,19 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.caveCullingHeight");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEarthCurveRatio()
|
||||
{
|
||||
return (int) ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.earthCurveRatio").value;
|
||||
}
|
||||
@Override
|
||||
public void setEarthCurveRatio(int newEarthCurveRatio)
|
||||
{
|
||||
if (newEarthCurveRatio < 50) newEarthCurveRatio = 0;
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.earthCurveRatio").value = newEarthCurveRatio;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.earthCurveRatio");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,12 +716,12 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
public static class Threading implements IThreading
|
||||
{
|
||||
@Override
|
||||
public int getNumberOfWorldGenerationThreads()
|
||||
public double getNumberOfWorldGenerationThreads()
|
||||
{
|
||||
return Config.Client.Advanced.Threading.numberOfWorldGenerationThreads;
|
||||
}
|
||||
@Override
|
||||
public void setNumberOfWorldGenerationThreads(int newNumberOfWorldGenerationThreads)
|
||||
public void setNumberOfWorldGenerationThreads(double newNumberOfWorldGenerationThreads)
|
||||
{
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.threading.numberOfWorldGenerationThreads").value = newNumberOfWorldGenerationThreads;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.threading.numberOfWorldGenerationThreads");
|
||||
|
||||
@@ -1,7 +1,27 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.config;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.ImageButton;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -11,9 +31,12 @@ import net.minecraft.resources.ResourceLocation;
|
||||
* Creates a button with a texture on it
|
||||
*/
|
||||
public class TexturedButtonWidget extends ImageButton {
|
||||
#if POST_MC_1_17_1
|
||||
public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, ResourceLocation texture, OnPress pressAction) {
|
||||
super(x, y, width, height, u, v, texture, pressAction);
|
||||
}
|
||||
#endif
|
||||
|
||||
public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, ResourceLocation texture, int textureWidth, int textureHeight, OnPress pressAction) {
|
||||
super(x, y, width, height, u, v, hoveredVOffset, texture, textureWidth, textureHeight, pressAction);
|
||||
}
|
||||
@@ -28,9 +51,15 @@ public class TexturedButtonWidget extends ImageButton {
|
||||
|
||||
@Override
|
||||
public void renderButton(PoseStack matrices, int mouseX, int mouseY, float delta) {
|
||||
#if PRE_MC_1_17_1
|
||||
Minecraft.getInstance().getTextureManager().bind(WIDGETS_LOCATION);
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, this.alpha);
|
||||
#else
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, WIDGETS_LOCATION);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, this.alpha);
|
||||
#endif
|
||||
|
||||
int i = this.getYImage(this.isHovered);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
|
||||
+15
-36
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -59,6 +59,7 @@ import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -163,40 +164,6 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper
|
||||
return LodUtil.getDimensionIDFromWorld(WorldWrapper.getWorldWrapper(mc.level));
|
||||
}
|
||||
|
||||
/** This texture changes every frame */
|
||||
@Override
|
||||
public ILightMapWrapper getCurrentLightMap()
|
||||
{
|
||||
// get the current lightMap if the cache is empty
|
||||
if (lightMap == null)
|
||||
{
|
||||
LightTexture tex = mc.gameRenderer.lightTexture();
|
||||
lightMap = tex.lightPixels;
|
||||
}
|
||||
return new LightMapWrapper(lightMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color int at the given pixel coordinates
|
||||
* from the current lightmap.
|
||||
* @param blockLight x location in texture space
|
||||
* @param skyLight z location in texture space
|
||||
*/
|
||||
@Override
|
||||
public int getColorIntFromLightMap(int blockLight, int skyLight)
|
||||
{
|
||||
if (lightMap == null)
|
||||
{
|
||||
//sendChatMessage("new");
|
||||
// make sure the lightMap is up-to-date
|
||||
getCurrentLightMap();
|
||||
}
|
||||
|
||||
return lightMap.getPixelRGBA(blockLight, skyLight);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=============//
|
||||
// Simple gets //
|
||||
//=============//
|
||||
@@ -222,7 +189,11 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper
|
||||
@Override
|
||||
public ChunkPosWrapper getPlayerChunkPos()
|
||||
{
|
||||
#if PRE_MC_1_17_1
|
||||
ChunkPos playerPos = new ChunkPos(getPlayer().blockPosition());
|
||||
#else
|
||||
ChunkPos playerPos = getPlayer().chunkPosition();
|
||||
#endif
|
||||
return new ChunkPosWrapper(playerPos.x, playerPos.z);
|
||||
}
|
||||
|
||||
@@ -356,6 +327,14 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper
|
||||
return mc.getCurrentServer() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerSkylight() {
|
||||
if (mc.level == null) return -1;
|
||||
if (mc.player == null) return -1;
|
||||
if (mc.player.blockPosition() == null) return -1;
|
||||
return mc.level.getBrightness(LightLayer.SKY, mc.player.blockPosition());
|
||||
}
|
||||
|
||||
public ServerData getCurrentServer()
|
||||
{
|
||||
return mc.getCurrentServer();
|
||||
|
||||
+83
-122
@@ -1,6 +1,26 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.minecraft;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Color;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -10,7 +30,10 @@ import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.seibel.lod.common.wrappers.misc.LightMapWrapper;
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorHandler;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
|
||||
import com.seibel.lod.core.wrapperInterfaces.misc.ILightMapWrapper;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
@@ -38,9 +61,15 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
#if PRE_MC_1_17_1
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
#else
|
||||
import net.minecraft.world.level.material.FogType;
|
||||
#endif
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,7 +86,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
private static final Minecraft MC = Minecraft.getInstance();
|
||||
private static final GameRenderer GAME_RENDERER = MC.gameRenderer;
|
||||
private static final IWrapperFactory FACTORY = WrapperFactory.INSTANCE;
|
||||
|
||||
|
||||
public LightMapWrapper lightmap = null;
|
||||
|
||||
@Override
|
||||
public Vec3f getLookAtVector()
|
||||
{
|
||||
@@ -92,7 +123,11 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
@Override
|
||||
public Mat4f getDefaultProjectionMatrix(float partialTicks)
|
||||
{
|
||||
#if PRE_MC_1_17_1
|
||||
return McObjectConverter.Convert(GAME_RENDERER.getProjectionMatrix(GAME_RENDERER.getMainCamera(), partialTicks, true));
|
||||
#else
|
||||
return McObjectConverter.Convert(GAME_RENDERER.getProjectionMatrix(GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true)));
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,8 +138,14 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
|
||||
@Override
|
||||
public Color getFogColor(float partialTicks) {
|
||||
|
||||
#if PRE_MC_1_17_1
|
||||
float[] colorValues = new float[4];
|
||||
GL15.glGetFloatv(GL15.GL_FOG_COLOR, colorValues);
|
||||
#else
|
||||
FogRenderer.setupColor(GAME_RENDERER.getMainCamera(), partialTicks, MC.level, 1, GAME_RENDERER.getDarkenWorldAmount(partialTicks));
|
||||
float[] colorValues = RenderSystem.getShaderFogColor();
|
||||
#endif
|
||||
return new Color(colorValues[0], colorValues[1], colorValues[2], colorValues[3]);
|
||||
}
|
||||
// getSpecialFogColor() is the same as getFogColor()
|
||||
@@ -112,7 +153,11 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
@Override
|
||||
public Color getSkyColor() {
|
||||
if (MC.level.dimensionType().hasSkyLight()) {
|
||||
#if PRE_MC_1_17_1
|
||||
Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getBlockPosition(), MC.getFrameTime());
|
||||
#else
|
||||
Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getPosition(), MC.getFrameTime());
|
||||
#endif
|
||||
return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z);
|
||||
} else
|
||||
return new Color(0, 0, 0);
|
||||
@@ -128,7 +173,12 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
@Override
|
||||
public int getRenderDistance()
|
||||
{
|
||||
return MC.options.getEffectiveRenderDistance();
|
||||
#if PRE_MC_1_18_1
|
||||
//FIXME: How to resolve this?
|
||||
return MC.options.renderDistance;
|
||||
#else
|
||||
return MC.options.getEffectiveRenderDistance();
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,16 +220,13 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
|
||||
public boolean usingBackupGetVanillaRenderedChunks = false;
|
||||
@Override
|
||||
public HashSet<AbstractChunkPosWrapper> getVanillaRenderedChunks()
|
||||
{
|
||||
public HashSet<AbstractChunkPosWrapper> getVanillaRenderedChunks() {
|
||||
ISodiumAccessor sodium = ModAccessorHandler.get(ISodiumAccessor.class);
|
||||
if (sodium != null)
|
||||
{
|
||||
if (sodium != null) {
|
||||
return sodium.getNormalRenderedChunks();
|
||||
}
|
||||
IOptifineAccessor optifine = ModAccessorHandler.get(IOptifineAccessor.class);
|
||||
if (optifine != null)
|
||||
{
|
||||
if (optifine != null) {
|
||||
HashSet<AbstractChunkPosWrapper> pos = optifine.getNormalRenderedChunks();
|
||||
if (pos == null)
|
||||
pos = getMaximumRenderedChunks();
|
||||
@@ -188,13 +235,14 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
if (!usingBackupGetVanillaRenderedChunks) {
|
||||
try {
|
||||
LevelRenderer levelRenderer = MC.levelRenderer;
|
||||
LinkedHashSet<LevelRenderer.RenderChunkInfo> chunks = levelRenderer.renderChunkStorage.get().renderChunks;
|
||||
Collection<LevelRenderer.RenderChunkInfo> chunks =
|
||||
#if PRE_MC_1_18_1 levelRenderer.renderChunks;
|
||||
#else levelRenderer.renderChunkStorage.get().renderChunks; #endif
|
||||
|
||||
return (chunks.stream().map((chunk) -> {
|
||||
#if MC_VERSION_1_18_2
|
||||
AABB chunkBoundingBox = chunk.chunk.getBoundingBox();
|
||||
#elif MC_VERSION_1_18_1
|
||||
AABB chunkBoundingBox = chunk.chunk.bb;
|
||||
#endif
|
||||
AABB chunkBoundingBox =
|
||||
#if PRE_MC_1_18_2 chunk.chunk.bb;
|
||||
#else chunk.chunk.getBoundingBox(); #endif
|
||||
return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16),
|
||||
Math.floorDiv((int) chunkBoundingBox.minZ, 16));
|
||||
}).collect(Collectors.toCollection(HashSet::new)));
|
||||
@@ -205,7 +253,8 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
+ " Using Backup Method.");
|
||||
MinecraftClientWrapper.INSTANCE.sendChatMessage(
|
||||
"\u00A7eOverdraw prevention will be worse than normal.");
|
||||
} catch (Exception e2) {}
|
||||
} catch (Exception e2) {
|
||||
}
|
||||
ApiShared.LOGGER.error("getVanillaRenderedChunks Error: ", e);
|
||||
usingBackupGetVanillaRenderedChunks = true;
|
||||
}
|
||||
@@ -213,125 +262,37 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
return getMaximumRenderedChunks();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int[] getLightmapPixels()
|
||||
{
|
||||
LightTexture tex = GAME_RENDERER.lightTexture();
|
||||
//tex.tick(); // This call makes no sense, but it fixes pause menu flicker bug
|
||||
NativeImage lightMapPixels = tex.lightTexture.getPixels();
|
||||
LightMapWrapper lightMap = new LightMapWrapper(lightMapPixels);
|
||||
|
||||
|
||||
int lightMapHeight = getLightmapTextureHeight();
|
||||
int lightMapWidth = getLightmapTextureWidth();
|
||||
|
||||
int[] pixels = new int[lightMapWidth * lightMapHeight];
|
||||
for (int u = 0; u < lightMapWidth; u++)
|
||||
{
|
||||
for (int v = 0; v < lightMapWidth; v++)
|
||||
{
|
||||
// this could probably be kept as a int, but
|
||||
// it is easier to test and see the colors when debugging this way.
|
||||
// When creating a new release this should be changed to the int version.
|
||||
int col = lightMap.getLightValue(u, v);
|
||||
|
||||
// these should both create a totally white image
|
||||
// int col =
|
||||
// Integer.MAX_VALUE;
|
||||
// int col =
|
||||
// 0b11111111 + // red
|
||||
// (0b11111111 << 8) + // green
|
||||
// (0b11111111 << 16) + // blue
|
||||
// (0b11111111 << 24); // blue
|
||||
|
||||
// int col =
|
||||
// ((c.getRed() & 0xFF) << 16) | // blue
|
||||
// ((c.getGreen() & 0xFF) << 8) | // green
|
||||
// ((c.getBlue() & 0xFF)) | // red
|
||||
// ((c.getAlpha() & 0xFF) << 24); // alpha
|
||||
|
||||
// 2D array stored in a 1D array.
|
||||
// Thank you Tim from College ;)
|
||||
pixels[u * lightMapWidth + v] = col;
|
||||
}
|
||||
}
|
||||
|
||||
return pixels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILightMapWrapper getLightmapWrapper() {
|
||||
return new LightMapWrapper(GAME_RENDERER.lightTexture());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getLightmapTextureHeight()
|
||||
{
|
||||
int height = -1;
|
||||
|
||||
LightTexture lightTexture = GAME_RENDERER.lightTexture();
|
||||
if (lightTexture != null)
|
||||
{
|
||||
NativeImage tex = lightTexture.lightPixels;
|
||||
if (tex != null)
|
||||
{
|
||||
height = tex.getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getLightmapTextureWidth()
|
||||
{
|
||||
int width = -1;
|
||||
|
||||
LightTexture lightTexture = GAME_RENDERER.lightTexture();
|
||||
if (lightTexture != null)
|
||||
{
|
||||
NativeImage tex = lightTexture.lightPixels;
|
||||
if (tex != null)
|
||||
{
|
||||
width = tex.getWidth();
|
||||
}
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getLightmapGLFormat() {
|
||||
int glFormat = -1;
|
||||
|
||||
LightTexture lightTexture = GAME_RENDERER.lightTexture();
|
||||
if (lightTexture != null) {
|
||||
NativeImage tex = lightTexture.lightPixels;
|
||||
if (tex != null) {
|
||||
glFormat = tex.format().glFormat();
|
||||
}
|
||||
}
|
||||
|
||||
return glFormat;
|
||||
return lightmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFogStateSpecial() {
|
||||
#if PRE_MC_1_17_1
|
||||
Camera camera = GAME_RENDERER.getMainCamera();
|
||||
FluidState fluidState = camera.getFluidInCamera();
|
||||
Entity entity = camera.getEntity();
|
||||
boolean isUnderWater = (entity instanceof LivingEntity) && ((LivingEntity)entity).hasEffect(MobEffects.BLINDNESS);
|
||||
isUnderWater |= fluidState.is(FluidTags.WATER);
|
||||
isUnderWater |= fluidState.is(FluidTags.LAVA);
|
||||
return isUnderWater;
|
||||
#else
|
||||
Entity entity = GAME_RENDERER.getMainCamera().getEntity();
|
||||
boolean isBlind = (entity instanceof LivingEntity) && ((LivingEntity)entity).hasEffect(MobEffects.BLINDNESS);
|
||||
return GAME_RENDERER.getMainCamera().getFluidInCamera() != FogType.NONE || isBlind;
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryDisableVanillaFog() {
|
||||
return true; // Handled via MixinFogRenderer in both forge and fabric
|
||||
}
|
||||
|
||||
public void updateLightmap(NativeImage lightPixels) {
|
||||
if (lightmap== null) {
|
||||
lightmap = new LightMapWrapper();
|
||||
}
|
||||
lightmap.uploadLightmap(lightPixels);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.minecraft;
|
||||
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IProfilerWrapper;
|
||||
|
||||
@@ -1,43 +1,67 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.misc;
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.seibel.lod.core.wrapperInterfaces.misc.ILightMapWrapper;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GL32;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 11-21-2021
|
||||
*/
|
||||
public class LightMapWrapper implements ILightMapWrapper
|
||||
{
|
||||
static NativeImage lightMap = null;
|
||||
private int textureId = 0;
|
||||
|
||||
private LightTexture tex;
|
||||
|
||||
public LightMapWrapper(NativeImage newLightMap)
|
||||
public LightMapWrapper()
|
||||
{
|
||||
lightMap = newLightMap;
|
||||
}
|
||||
|
||||
public LightMapWrapper(LightTexture lightTexture) {
|
||||
tex = lightTexture;
|
||||
private void createLightmap(NativeImage image)
|
||||
{
|
||||
textureId = GL32.glGenTextures();
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, textureId);
|
||||
GL32.glTexImage2D(GL32.GL_TEXTURE_2D, 0, image.format().glFormat(), image.getWidth(), image.getHeight(),
|
||||
0, image.format().glFormat(), GL32.GL_UNSIGNED_BYTE, (ByteBuffer) null);
|
||||
}
|
||||
|
||||
public static void setLightMap(NativeImage newLightMap)
|
||||
public void uploadLightmap(NativeImage image)
|
||||
{
|
||||
lightMap = newLightMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(int skyLight, int blockLight)
|
||||
{
|
||||
return lightMap.getPixelRGBA(skyLight, blockLight);
|
||||
int currentBind = GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D);
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, textureId);
|
||||
if (textureId == 0) {
|
||||
createLightmap(image);
|
||||
}
|
||||
// NativeImage::upload(int levelOfDetail, int xOffset, int yOffset, bool shouldCleanup?)
|
||||
image.upload(0, 0, 0, false);
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, currentBind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bind() {
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, tex.lightTexture.getId());
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, textureId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -138,7 +138,11 @@ public class WorldWrapper implements IWorldWrapper
|
||||
@Override
|
||||
public short getMinHeight()
|
||||
{
|
||||
#if PRE_MC_1_17_1
|
||||
return (short) 0;
|
||||
#else
|
||||
return (short) world.getMinBuildHeight();
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @throws UnsupportedOperationException if the WorldWrapper isn't for a ServerWorld */
|
||||
@@ -182,6 +186,4 @@ public class WorldWrapper implements IWorldWrapper
|
||||
ChunkSource source = world.getChunkSource();
|
||||
return source.hasChunk(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+32
-11
@@ -1,8 +1,9 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2021 Tom Lee (TomTheFurry)
|
||||
* Copyright (C) 2021 Tom Lee (TomTheFurry)
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,6 +17,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration;
|
||||
|
||||
@@ -254,7 +256,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
}
|
||||
|
||||
public ExecutorService executors = Executors.newFixedThreadPool(
|
||||
CONFIG.client().advanced().threading().getNumberOfWorldGenerationThreads(), threadFactory);
|
||||
CONFIG.client().advanced().threading()._getWorldGenerationThreadPoolSize(), threadFactory);
|
||||
|
||||
public <T> T joinSync(CompletableFuture<T> f) {
|
||||
if (!unsafeThreadingRecorded && !f.isDone()) {
|
||||
@@ -271,7 +273,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
new LodThreadFactory("Gen-Worker-Thread", Thread.MIN_PRIORITY));
|
||||
}
|
||||
|
||||
public boolean tryAddPoint(int px, int pz, int range, Steps target, boolean genAllDetails)
|
||||
public boolean tryAddPoint(int px, int pz, int range, Steps target, boolean genAllDetails, double runTimeRatio)
|
||||
{
|
||||
int boxSize = range * 2 + 1;
|
||||
int x = Math.floorDiv(px, boxSize) * boxSize + range;
|
||||
@@ -283,7 +285,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
return false;
|
||||
}
|
||||
// System.out.println(x + ", "+z);
|
||||
events.add(new GenerationEvent(new ChunkPos(x, z), range, this, target, genAllDetails));
|
||||
events.add(new GenerationEvent(new ChunkPos(x, z), range, this, target, genAllDetails, runTimeRatio));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -348,8 +350,13 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
if (!(generator instanceof NoiseBasedChunkGenerator ||
|
||||
generator instanceof DebugLevelSource ||
|
||||
generator instanceof FlatLevelSource)) {
|
||||
EVENT_LOGGER.warn("Unknown Chunk Generator detected: [{}], Distant Generation May Fail!", generator.getClass());
|
||||
EVENT_LOGGER.warn("If it does crash, set Distant Generation to OFF or Generation Mode to None.");
|
||||
if (generator.getClass().toString().equals("class com.terraforged.mod.chunk.TFChunkGenerator")) {
|
||||
EVENT_LOGGER.info("TerraForge Chunk Generator detected: [{}], Distant Generation will try its best to support it.", generator.getClass());
|
||||
EVENT_LOGGER.info("If it does crash, set Distant Generation to OFF or Generation Mode to None.");
|
||||
} else {
|
||||
EVENT_LOGGER.warn("Unknown Chunk Generator detected: [{}], Distant Generation May Fail!", generator.getClass());
|
||||
EVENT_LOGGER.warn("If it does crash, set Distant Generation to OFF or Generation Mode to None.");
|
||||
}
|
||||
}
|
||||
params = new GlobalParameters((ServerLevel) ((WorldWrapper) serverlevel).getWorld(), lodBuilder, lodDim);
|
||||
}
|
||||
@@ -368,7 +375,10 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
}
|
||||
if (chunkData == null)
|
||||
{
|
||||
return new ProtoChunk(chunkPos, UpgradeData.EMPTY, level, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null);
|
||||
return new ProtoChunk(chunkPos, UpgradeData.EMPTY
|
||||
#if POST_MC_1_17_1, level #endif
|
||||
#if POST_MC_1_18_1, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null #endif
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -376,7 +386,10 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
return ChunkLoader.read(level, lightEngine, chunkPos, chunkData);
|
||||
} catch (Exception e) {
|
||||
LOAD_LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e);
|
||||
return new ProtoChunk(chunkPos, UpgradeData.EMPTY, level, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null);
|
||||
return new ProtoChunk(chunkPos, UpgradeData.EMPTY
|
||||
#if POST_MC_1_17_1, level #endif
|
||||
#if POST_MC_1_18_1, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null #endif
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,8 +427,10 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
// Continue...
|
||||
}
|
||||
if (target == null)
|
||||
target = new ProtoChunk(chunkPos, UpgradeData.EMPTY, params.level,
|
||||
params.biomes, null);
|
||||
target = new ProtoChunk(chunkPos, UpgradeData.EMPTY
|
||||
#if POST_MC_1_17_1, params.level #endif
|
||||
#if POST_MC_1_18_1, params.biomes, null #endif
|
||||
);
|
||||
return target;
|
||||
};
|
||||
|
||||
@@ -474,19 +489,23 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
}
|
||||
|
||||
boolean isFull = target.getStatus() == ChunkStatus.FULL || target instanceof LevelChunk;
|
||||
#if POST_MC_1_18_1
|
||||
boolean isPartial = target.isOldNoiseGeneration();
|
||||
#endif
|
||||
if (isFull)
|
||||
{
|
||||
LOAD_LOGGER.info("Detected full existing chunk at {}", target.getPos());
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk,
|
||||
new LodBuilderConfig(DistanceGenerationMode.FULL), true, e.genAllDetails);
|
||||
}
|
||||
#if POST_MC_1_18_1
|
||||
else if (isPartial)
|
||||
{
|
||||
LOAD_LOGGER.info("Detected old existing chunk at {}", target.getPos());
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk,
|
||||
new LodBuilderConfig(generationMode), true, e.genAllDetails);
|
||||
}
|
||||
#endif
|
||||
else if (target.getStatus() == ChunkStatus.EMPTY && generationMode == DistanceGenerationMode.NONE)
|
||||
{
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim,wrappedChunk,
|
||||
@@ -571,10 +590,12 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
{
|
||||
if (p instanceof ProtoChunk)
|
||||
((ProtoChunk) p).setLightCorrect(true);
|
||||
#if POST_MC_1_18_1
|
||||
if (p instanceof LevelChunk) {
|
||||
((LevelChunk) p).setLightCorrect(true);
|
||||
((LevelChunk) p).setClientLightReady(true);
|
||||
}
|
||||
#endif
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
+37
-6
@@ -1,4 +1,22 @@
|
||||
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@@ -25,16 +43,19 @@ public final class GenerationEvent
|
||||
final ChunkPos pos;
|
||||
final int range;
|
||||
final Future<?> future;
|
||||
long nanotime;
|
||||
long creationNanotime;
|
||||
final int id;
|
||||
final Steps target;
|
||||
final LightGenerationMode lightMode;
|
||||
final PrefEvent pEvent = new PrefEvent();
|
||||
final boolean genAllDetails;
|
||||
|
||||
final double runTimeRatio;
|
||||
|
||||
public GenerationEvent(ChunkPos pos, int range, BatchGenerationEnvironment generationGroup, Steps target, boolean genAllDetails)
|
||||
public GenerationEvent(ChunkPos pos, int range, BatchGenerationEnvironment generationGroup,
|
||||
Steps target, boolean genAllDetails, double runTimeRatio)
|
||||
{
|
||||
nanotime = System.nanoTime();
|
||||
creationNanotime = System.nanoTime();
|
||||
this.pos = pos;
|
||||
this.range = range;
|
||||
id = generationFutureDebugIDs++;
|
||||
@@ -44,14 +65,24 @@ public final class GenerationEvent
|
||||
|
||||
this.lightMode = mode;
|
||||
this.genAllDetails = genAllDetails;
|
||||
this.runTimeRatio = runTimeRatio;
|
||||
|
||||
future = generationGroup.executors.submit(() ->
|
||||
{
|
||||
long startTime = System.nanoTime();
|
||||
BatchGenerationEnvironment.isDistantGeneratorThread.set(true);
|
||||
try {
|
||||
generationGroup.generateLodFromList(this);
|
||||
} finally {
|
||||
BatchGenerationEnvironment.isDistantGeneratorThread.remove();
|
||||
if (!Thread.interrupted() && runTimeRatio < 1.0) {
|
||||
long endTime = System.nanoTime();
|
||||
try {
|
||||
long deltaMs = TimeUnit.NANOSECONDS.toMillis(endTime - startTime);
|
||||
Thread.sleep((long) (deltaMs/runTimeRatio - deltaMs));
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -64,7 +95,7 @@ public final class GenerationEvent
|
||||
public boolean hasTimeout(int duration, TimeUnit unit)
|
||||
{
|
||||
long currentTime = System.nanoTime();
|
||||
long delta = currentTime - nanotime;
|
||||
long delta = currentTime - creationNanotime;
|
||||
return (delta > TimeUnit.NANOSECONDS.convert(duration, unit));
|
||||
}
|
||||
|
||||
@@ -99,7 +130,7 @@ public final class GenerationEvent
|
||||
|
||||
public void refreshTimeout()
|
||||
{
|
||||
nanotime = System.nanoTime();
|
||||
creationNanotime = System.nanoTime();
|
||||
LodUtil.checkInterruptsUnchecked();
|
||||
}
|
||||
|
||||
|
||||
+28
-4
@@ -1,4 +1,22 @@
|
||||
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration;
|
||||
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
@@ -13,7 +31,9 @@ import net.minecraft.server.level.ThreadedLevelLightEngine;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeManager;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
#if POST_MC_1_18_1
|
||||
import net.minecraft.world.level.chunk.storage.ChunkScanAccess;
|
||||
#endif
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||
import net.minecraft.world.level.storage.WorldData;
|
||||
@@ -22,7 +42,6 @@ public final class GlobalParameters
|
||||
{
|
||||
public final ChunkGenerator generator;
|
||||
public final StructureManager structures;
|
||||
public final BiomeManager biomeManager;
|
||||
public final WorldGenSettings worldGenSettings;
|
||||
public final ThreadedLevelLightEngine lightEngine;
|
||||
public final LodBuilder lodBuilder;
|
||||
@@ -30,9 +49,12 @@ public final class GlobalParameters
|
||||
public final Registry<Biome> biomes;
|
||||
public final RegistryAccess registry;
|
||||
public final long worldSeed;
|
||||
public final ChunkScanAccess chunkScanner;
|
||||
public final ServerLevel level; // TODO: Figure out a way to remove this. Maybe ClientLevel also works?
|
||||
public final DataFixer fixerUpper;
|
||||
#if POST_MC_1_18_1
|
||||
public final BiomeManager biomeManager;
|
||||
public final ChunkScanAccess chunkScanner; // FIXME: Figure out if this is actually needed
|
||||
#endif
|
||||
|
||||
public GlobalParameters(ServerLevel level, LodBuilder lodBuilder, LodDimension lodDim)
|
||||
{
|
||||
@@ -46,10 +68,12 @@ public final class GlobalParameters
|
||||
registry = server.registryAccess();
|
||||
biomes = registry.registryOrThrow(Registry.BIOME_REGISTRY);
|
||||
worldSeed = worldGenSettings.seed();
|
||||
#if POST_MC_1_18_1
|
||||
biomeManager = new BiomeManager(level, BiomeManager.obfuscateSeed(worldSeed));
|
||||
chunkScanner = level.getChunkSource().chunkScanner();
|
||||
#endif
|
||||
structures = server.getStructureManager();
|
||||
generator = level.getChunkSource().getGenerator();
|
||||
chunkScanner = level.getChunkSource().chunkScanner();
|
||||
fixerUpper = server.getFixerUpper();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration;
|
||||
|
||||
|
||||
+28
-1
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration;
|
||||
|
||||
@@ -7,14 +26,18 @@ import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.WorldGenStruct
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
#if POST_MC_1_18_1
|
||||
import net.minecraft.world.level.levelgen.structure.StructureCheck;
|
||||
#endif
|
||||
|
||||
public final class ThreadedParameters
|
||||
{
|
||||
private static final ThreadLocal<ThreadedParameters> localParam = new ThreadLocal<ThreadedParameters>();
|
||||
final ServerLevel level;
|
||||
public WorldGenStructFeatManager structFeat = null;
|
||||
#if POST_MC_1_18_1
|
||||
public final StructureCheck structCheck;
|
||||
#endif
|
||||
boolean isValid = true;
|
||||
public final PerfCalculator perf = new PerfCalculator();
|
||||
|
||||
@@ -36,13 +59,17 @@ public final class ThreadedParameters
|
||||
private ThreadedParameters(GlobalParameters param)
|
||||
{
|
||||
level = param.level;
|
||||
#if PRE_MC_1_18_1
|
||||
structFeat = new WorldGenStructFeatManager(param.worldGenSettings, level);
|
||||
#else
|
||||
structCheck = new StructureCheck(param.chunkScanner, param.registry, param.structures,
|
||||
param.level.dimension(), param.generator, level, param.generator.getBiomeSource(), param.worldSeed,
|
||||
param.fixerUpper);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void makeStructFeat(WorldGenLevel genLevel, GlobalParameters param)
|
||||
{
|
||||
structFeat = new WorldGenStructFeatManager(param.worldGenSettings, genLevel, structCheck);
|
||||
structFeat = new WorldGenStructFeatManager(param.worldGenSettings, genLevel #if POST_MC_1_18_1, structCheck #endif);
|
||||
}
|
||||
}
|
||||
+138
-180
@@ -1,4 +1,22 @@
|
||||
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.mimicObject;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
@@ -16,11 +34,6 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
#if MC_VERSION_1_18_2
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
|
||||
#endif
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.SectionPos;
|
||||
@@ -28,40 +41,46 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.*;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.DataLayer;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.world.level.chunk.PalettedContainer;
|
||||
import net.minecraft.world.level.chunk.UpgradeData;
|
||||
import net.minecraft.world.level.chunk.*;
|
||||
import net.minecraft.world.level.chunk.storage.ChunkSerializer;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
#if POST_MC_1_18_1
|
||||
import net.minecraft.world.level.levelgen.blending.BlendingData;
|
||||
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext;
|
||||
import net.minecraft.world.ticks.LevelChunkTicks;
|
||||
#endif
|
||||
#if POST_MC_1_18_2
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
|
||||
#endif
|
||||
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.ticks.LevelChunkTicks;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ChunkLoader
|
||||
{
|
||||
#if POST_MC_1_18_1
|
||||
private static final Codec<PalettedContainer<BlockState>> BLOCK_STATE_CODEC = PalettedContainer.codec(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState());
|
||||
private static final ConfigBasedLogger LOGGER = BatchGenerationEnvironment.LOAD_LOGGER;
|
||||
#endif
|
||||
private static final String TAG_UPGRADE_DATA = "UpgradeData";
|
||||
private static final String BLOCK_TICKS_TAG = "block_ticks";
|
||||
private static final String FLUID_TICKS_TAG = "fluid_ticks";
|
||||
|
||||
private static final String BLOCK_TICKS_TAG_18 = "block_ticks";
|
||||
private static final String FLUID_TICKS_TAG_18 = "fluid_ticks";
|
||||
private static final String BLOCK_TICKS_TAG_PRE18 = "TileTicks";
|
||||
private static final String FLUID_TICKS_TAG_PRE18 = "LiquidTicks";
|
||||
private static final ConfigBasedLogger LOGGER = BatchGenerationEnvironment.LOAD_LOGGER;
|
||||
|
||||
#if POST_MC_1_18_1
|
||||
private static BlendingData readBlendingData(CompoundTag chunkData)
|
||||
{
|
||||
BlendingData blendingData = null;
|
||||
@@ -73,36 +92,51 @@ public class ChunkLoader
|
||||
}
|
||||
return blendingData;
|
||||
}
|
||||
#endif
|
||||
|
||||
private static LevelChunkSection[] readSections(LevelAccessor level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag chunkData)
|
||||
{
|
||||
#if POST_MC_1_18_1
|
||||
Registry<Biome> biomes = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
|
||||
#if MC_VERSION_1_18_1
|
||||
Codec<PalettedContainer<Biome>> biomeCodec = PalettedContainer.codec(
|
||||
biomes, biomes.byNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getOrThrow(Biomes.PLAINS));
|
||||
#elif MC_VERSION_1_18_2
|
||||
Codec<PalettedContainer<Holder<Biome>>> biomeCodec = PalettedContainer.codec(
|
||||
biomes.asHolderIdMap(), biomes.holderByNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getHolderOrThrow(Biomes.PLAINS));
|
||||
#if PRE_MC_1_18_2
|
||||
Codec<PalettedContainer<Biome>> biomeCodec = PalettedContainer.codec(
|
||||
biomes, biomes.byNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getOrThrow(Biomes.PLAINS));
|
||||
#else
|
||||
Codec<PalettedContainer<Holder<Biome>>> biomeCodec = PalettedContainer.codec(
|
||||
biomes.asHolderIdMap(), biomes.holderByNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getHolderOrThrow(Biomes.PLAINS));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int i = level.getSectionsCount();
|
||||
int i = #if PRE_MC_1_17_1 16; #else level.getSectionsCount(); #endif
|
||||
LevelChunkSection[] chunkSections = new LevelChunkSection[i];
|
||||
|
||||
boolean isLightOn = chunkData.getBoolean("isLightOn");
|
||||
boolean hasSkyLight = level.dimensionType().hasSkyLight();
|
||||
ListTag tagSections = chunkData.getList("sections", 10);
|
||||
ListTag tagSections = chunkData.getList("Sections", 10);
|
||||
if (tagSections.isEmpty()) tagSections = chunkData.getList("sections", 10);
|
||||
|
||||
for (int j = 0; j < tagSections.size(); ++j)
|
||||
{
|
||||
CompoundTag tagSection = tagSections.getCompound(j);
|
||||
byte sectionYPos = tagSection.getByte("Y");
|
||||
int sectionYPos = tagSection.getByte("Y");
|
||||
|
||||
#if PRE_MC_1_18_1
|
||||
if (tagSection.contains("Palette", 9) && tagSection.contains("BlockStates", 12)) {
|
||||
LevelChunkSection levelChunkSection = new LevelChunkSection(sectionYPos << 4);
|
||||
levelChunkSection.getStates().read(tagSection.getList("Palette", 10),
|
||||
tagSection.getLongArray("BlockStates"));
|
||||
levelChunkSection.recalcBlockCounts();
|
||||
if (!levelChunkSection.isEmpty())
|
||||
chunkSections[#if PRE_MC_1_17_1 sectionYPos #else level.getSectionIndexFromSectionY(sectionYPos) #endif]
|
||||
= levelChunkSection;
|
||||
}
|
||||
#else
|
||||
int sectionId = level.getSectionIndexFromSectionY(sectionYPos);
|
||||
if (sectionId >= 0 && sectionId < chunkSections.length)
|
||||
{
|
||||
PalettedContainer<BlockState> blockStateContainer;
|
||||
#if MC_VERSION_1_18_1
|
||||
#if PRE_MC_1_18_2
|
||||
PalettedContainer<Biome> biomeContainer;
|
||||
#elif MC_VERSION_1_18_2
|
||||
#else
|
||||
PalettedContainer<Holder<Biome>> biomeContainer;
|
||||
#endif
|
||||
|
||||
@@ -110,27 +144,26 @@ public class ChunkLoader
|
||||
? BLOCK_STATE_CODEC.parse(NbtOps.INSTANCE, tagSection.getCompound("block_states")).promotePartial(string -> logErrors(chunkPos, sectionYPos, string)).getOrThrow(false, LOGGER::error)
|
||||
: new PalettedContainer<BlockState>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES);
|
||||
|
||||
#if MC_VERSION_1_18_1
|
||||
#if PRE_MC_1_18_2
|
||||
biomeContainer = tagSection.contains("biomes", 10)
|
||||
? biomeCodec.parse(NbtOps.INSTANCE, tagSection.getCompound("biomes")).promotePartial(string -> logErrors(chunkPos, sectionYPos, string)).getOrThrow(false, LOGGER::error)
|
||||
: new PalettedContainer<Biome>(biomes, biomes.getOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES);
|
||||
#elif MC_VERSION_1_18_2
|
||||
#else
|
||||
biomeContainer = tagSection.contains("biomes", 10)
|
||||
? biomeCodec.parse(NbtOps.INSTANCE, tagSection.getCompound("biomes")).promotePartial(string -> logErrors(chunkPos, i, (String) string)).getOrThrow(false, LOGGER::error)
|
||||
: new PalettedContainer<Holder<Biome>>(biomes.asHolderIdMap(), biomes.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES);
|
||||
#endif
|
||||
|
||||
|
||||
chunkSections[sectionId] = new LevelChunkSection(sectionYPos, blockStateContainer, biomeContainer);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!isLightOn)
|
||||
continue;
|
||||
|
||||
if (!isLightOn) continue;
|
||||
if (tagSection.contains("BlockLight", 7))
|
||||
lightEngine.queueSectionData(LightLayer.BLOCK, SectionPos.of(chunkPos, sectionYPos), new DataLayer(tagSection.getByteArray("BlockLight")), true);
|
||||
lightEngine.queueSectionData(LightLayer.BLOCK, SectionPos.of(chunkPos, sectionYPos),
|
||||
new DataLayer(tagSection.getByteArray("BlockLight")), true);
|
||||
if (hasSkyLight && tagSection.contains("SkyLight", 7))
|
||||
lightEngine.queueSectionData(LightLayer.SKY, SectionPos.of(chunkPos, sectionYPos), new DataLayer(tagSection.getByteArray("SkyLight")), true);
|
||||
lightEngine.queueSectionData(LightLayer.SKY, SectionPos.of(chunkPos, sectionYPos),
|
||||
new DataLayer(tagSection.getByteArray("SkyLight")), true);
|
||||
}
|
||||
return chunkSections;
|
||||
}
|
||||
@@ -147,115 +180,6 @@ public class ChunkLoader
|
||||
Heightmap.primeHeightmaps(chunk, ChunkStatus.FULL.heightmapsAfter());
|
||||
}
|
||||
|
||||
#if MC_VERSION_1_18_1
|
||||
private static Map<StructureFeature<?>, StructureStart<?>> unpackStructureStart(StructurePieceSerializationContext structurePieceSerializationContext, CompoundTag compoundTag, long l)
|
||||
{
|
||||
HashMap<StructureFeature<?>, StructureStart<?>> map = Maps.newHashMap();
|
||||
CompoundTag compoundTag2 = compoundTag.getCompound("starts");
|
||||
for (String string : compoundTag2.getAllKeys())
|
||||
{
|
||||
String string2 = string.toLowerCase(Locale.ROOT);
|
||||
StructureFeature<?> structureFeature = StructureFeature.STRUCTURES_REGISTRY.get(string2);
|
||||
if (structureFeature == null)
|
||||
{
|
||||
LOGGER.error("Unknown structure start: {}", (Object) string2);
|
||||
continue;
|
||||
}
|
||||
StructureStart<?> structureStart = StructureFeature.loadStaticStart(structurePieceSerializationContext, compoundTag2.getCompound(string), l);
|
||||
if (structureStart == null)
|
||||
continue;
|
||||
map.put(structureFeature, structureStart);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static Map<StructureFeature<?>, LongSet> unpackStructureReferences(ChunkPos chunkPos, CompoundTag compoundTag)
|
||||
{
|
||||
HashMap<StructureFeature<?>, LongSet> map = Maps.newHashMap();
|
||||
CompoundTag compoundTag2 = compoundTag.getCompound("References");
|
||||
for (String string : compoundTag2.getAllKeys())
|
||||
{
|
||||
String string2 = string.toLowerCase(Locale.ROOT);
|
||||
StructureFeature<?> structureFeature = StructureFeature.STRUCTURES_REGISTRY.get(string2);
|
||||
if (structureFeature == null)
|
||||
{
|
||||
LOGGER.warn("Found reference to unknown structure '{}' in chunk {}, discarding", (Object) string2, (Object) chunkPos);
|
||||
continue;
|
||||
}
|
||||
map.put(structureFeature, new LongOpenHashSet(Arrays.stream(compoundTag2.getLongArray(string)).filter(l ->
|
||||
{
|
||||
ChunkPos chunkPos2 = new ChunkPos(l);
|
||||
if (chunkPos2.getChessboardDistance(chunkPos) > 8)
|
||||
{
|
||||
LOGGER.warn("Found invalid structure reference [ {} @ {} ] for chunk {}.", (Object) string2, (Object) chunkPos2, (Object) chunkPos);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}).toArray()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
#elif MC_VERSION_1_18_2
|
||||
private static Map<ConfiguredStructureFeature<?, ?>, StructureStart> unpackStructureStart(StructurePieceSerializationContext structurePieceSerializationContext, CompoundTag compoundTag, long l) {
|
||||
Map<ConfiguredStructureFeature<?, ?>, StructureStart> map = Maps.newHashMap();
|
||||
Registry<ConfiguredStructureFeature<?, ?>> structStartRegistry = structurePieceSerializationContext.registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY);
|
||||
CompoundTag compoundTag2 = compoundTag.getCompound("starts");
|
||||
for (String string : compoundTag2.getAllKeys()) {
|
||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(string);
|
||||
ConfiguredStructureFeature<?, ?> structureFeature = structStartRegistry.get(resourceLocation);
|
||||
// String string2 = string.toLowerCase(Locale.ROOT);
|
||||
// ConfiguredStructureFeature<?, ?> structureFeature = StructureFeature.STRUCTURES_REGISTRY.get(string2);
|
||||
if (structureFeature == null) {
|
||||
LOGGER.error("Unknown structure start: {}", resourceLocation);
|
||||
continue;
|
||||
}
|
||||
StructureStart structureStart = StructureFeature.loadStaticStart(structurePieceSerializationContext, compoundTag2.getCompound(string), l);
|
||||
if (structureStart == null)
|
||||
continue;
|
||||
map.put(structureFeature, structureStart);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static Map<ConfiguredStructureFeature<?, ?>, LongSet> unpackStructureReferences(RegistryAccess registryAccess, ChunkPos chunkPos, CompoundTag compoundTag)
|
||||
{
|
||||
Map<ConfiguredStructureFeature<?, ?>, LongSet> map = Maps.newHashMap();
|
||||
Registry<ConfiguredStructureFeature<?, ?>> structRegistry = registryAccess.registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY);
|
||||
CompoundTag compoundTag2 = compoundTag.getCompound("References");
|
||||
for (String string : compoundTag2.getAllKeys())
|
||||
{
|
||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(string);
|
||||
ConfiguredStructureFeature<?, ?> structureFeature = structRegistry.get(resourceLocation);
|
||||
// String string2 = string.toLowerCase(Locale.ROOT);
|
||||
// ConfiguredStructureFeature<?, ?> structureFeature = StructureFeature.STRUCTURES_REGISTRY.get(string2);
|
||||
if (structureFeature == null)
|
||||
{
|
||||
LOGGER.warn("Found reference to unknown structure '{}' in chunk {}, discarding", resourceLocation, chunkPos);
|
||||
continue;
|
||||
}
|
||||
map.put(structureFeature, new LongOpenHashSet(Arrays.stream(compoundTag2.getLongArray(string)).filter(l ->
|
||||
{
|
||||
ChunkPos chunkPos2 = new ChunkPos(l);
|
||||
if (chunkPos2.getChessboardDistance(chunkPos) > 8)
|
||||
{
|
||||
LOGGER.warn("Found invalid structure reference [ {} @ {} ] for chunk {}.", resourceLocation, chunkPos2, chunkPos);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}).toArray()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
#endif
|
||||
|
||||
private static void readStructures(WorldGenLevel level, LevelChunk chunk, CompoundTag chunkData)
|
||||
{
|
||||
CompoundTag tagStructures = chunkData.getCompound("structures");
|
||||
chunk.setAllStarts(
|
||||
unpackStructureStart(StructurePieceSerializationContext.fromLevel(level.getLevel()), tagStructures, level.getSeed()));
|
||||
chunk.setAllReferences(unpackStructureReferences(#if MC_VERSION_1_18_2 level.registryAccess() ,#endif chunk.getPos(), tagStructures));
|
||||
}
|
||||
|
||||
private static void readPostPocessings(LevelChunk chunk, CompoundTag chunkData)
|
||||
{
|
||||
ListTag tagPostProcessings = chunkData.getList("PostProcessing", 9);
|
||||
@@ -269,49 +193,83 @@ public class ChunkLoader
|
||||
}
|
||||
}
|
||||
|
||||
public static ChunkStatus.ChunkType readChunkType(CompoundTag compoundTag)
|
||||
public static ChunkStatus.ChunkType readChunkType(CompoundTag tagLevel)
|
||||
{
|
||||
return ChunkStatus.byName(compoundTag.getString("Status")).getChunkType();
|
||||
ChunkStatus chunkStatus = ChunkStatus.byName(tagLevel.getString("Status"));
|
||||
if (chunkStatus != null) {
|
||||
return chunkStatus.getChunkType();
|
||||
}
|
||||
return ChunkStatus.ChunkType.PROTOCHUNK;
|
||||
}
|
||||
|
||||
public static LevelChunk read(WorldGenLevel level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag chunkData)
|
||||
{
|
||||
|
||||
ChunkPos actualPos = new ChunkPos(chunkData.getInt("xPos"), chunkData.getInt("zPos"));
|
||||
if (!Objects.equals(chunkPos, actualPos))
|
||||
{
|
||||
LOGGER.error("Chunk file at {} is in the wrong location; Ignoring. (Expected {}, got {})", (Object) chunkPos, (Object) chunkPos, (Object) actualPos);
|
||||
#if PRE_MC_1_18_1
|
||||
CompoundTag tagLevel = chunkData.getCompound("Level");
|
||||
#else
|
||||
CompoundTag tagLevel = chunkData;
|
||||
#endif
|
||||
|
||||
ChunkPos actualPos = new ChunkPos(tagLevel.getInt("xPos"), tagLevel.getInt("zPos"));
|
||||
if (!Objects.equals(chunkPos, actualPos)) {
|
||||
LOGGER.error("Chunk file at {} is in the wrong location; Ignoring. (Expected {}, got {})", chunkPos, chunkPos, actualPos);
|
||||
return null;
|
||||
}
|
||||
|
||||
ChunkStatus.ChunkType chunkType = readChunkType(chunkData);
|
||||
BlendingData blendingData = readBlendingData(chunkData);
|
||||
|
||||
ChunkStatus.ChunkType chunkType = readChunkType(tagLevel);
|
||||
#if PRE_MC_1_18_1
|
||||
if (chunkType != ChunkStatus.ChunkType.LEVELCHUNK)
|
||||
return null;
|
||||
#else
|
||||
BlendingData blendingData = readBlendingData(tagLevel);
|
||||
if (chunkType == ChunkStatus.ChunkType.PROTOCHUNK && (blendingData == null || !blendingData.oldNoise()))
|
||||
return null;
|
||||
|
||||
// Prepare the light engine
|
||||
boolean isLightOn = chunkData.getBoolean("isLightOn");
|
||||
if (isLightOn)
|
||||
level.getLightEngine().retainData(chunkPos, true);
|
||||
|
||||
// Read params for making the LevelChunk
|
||||
UpgradeData upgradeData = chunkData.contains(TAG_UPGRADE_DATA, 10)
|
||||
? new UpgradeData(chunkData.getCompound(TAG_UPGRADE_DATA), level)
|
||||
#endif
|
||||
|
||||
long inhabitedTime = tagLevel.getLong("InhabitedTime");
|
||||
|
||||
//================== Read params for making the LevelChunk ==================
|
||||
UpgradeData upgradeData = tagLevel.contains(TAG_UPGRADE_DATA, 10)
|
||||
? new UpgradeData(tagLevel.getCompound(TAG_UPGRADE_DATA)#if POST_MC_1_17_1, level #endif)
|
||||
: UpgradeData.EMPTY;
|
||||
LevelChunkTicks<Block> blockTicks = LevelChunkTicks.load(chunkData.getList(BLOCK_TICKS_TAG, 10),
|
||||
|
||||
boolean isLightOn = tagLevel.getBoolean("isLightOn");
|
||||
if (isLightOn) lightEngine.retainData(chunkPos, true);
|
||||
#if PRE_MC_1_18_1
|
||||
ChunkBiomeContainer chunkBiomeContainer = new ChunkBiomeContainer(
|
||||
level.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY)#if POST_MC_1_17_1, level #endif,
|
||||
chunkPos, level.getLevel().getChunkSource().getGenerator().getBiomeSource(),
|
||||
tagLevel.contains("Biomes", 11) ? tagLevel.getIntArray("Biomes") : null);
|
||||
|
||||
TickList<Block> blockTicks = tagLevel.contains(BLOCK_TICKS_TAG_PRE18, 9)
|
||||
? ChunkTickList.create(tagLevel.getList(BLOCK_TICKS_TAG_PRE18, 10), Registry.BLOCK::getKey, Registry.BLOCK::get)
|
||||
: new ProtoTickList<Block>(block -> (block == null || block.defaultBlockState().isAir()), chunkPos,
|
||||
tagLevel.getList("ToBeTicked", 9)#if POST_MC_1_17_1, level #endif);
|
||||
|
||||
TickList<Fluid> fluidTicks = tagLevel.contains(FLUID_TICKS_TAG_PRE18, 9)
|
||||
? ChunkTickList.create(tagLevel.getList(FLUID_TICKS_TAG_PRE18, 10), Registry.FLUID::getKey, Registry.FLUID::get)
|
||||
: new ProtoTickList<Fluid>(fluid -> (fluid == null || fluid == Fluids.EMPTY), chunkPos,
|
||||
tagLevel.getList("LiquidsToBeTicked", 9)#if POST_MC_1_17_1, level #endif);
|
||||
#else
|
||||
LevelChunkTicks<Block> blockTicks = LevelChunkTicks.load(tagLevel.getList(BLOCK_TICKS_TAG_18, 10),
|
||||
string -> Registry.BLOCK.getOptional(ResourceLocation.tryParse(string)), chunkPos);
|
||||
LevelChunkTicks<Fluid> fluidTicks = LevelChunkTicks.load(chunkData.getList(FLUID_TICKS_TAG, 10),
|
||||
LevelChunkTicks<Fluid> fluidTicks = LevelChunkTicks.load(tagLevel.getList(FLUID_TICKS_TAG_18, 10),
|
||||
string -> Registry.FLUID.getOptional(ResourceLocation.tryParse(string)), chunkPos);
|
||||
long inhabitedTime = chunkData.getLong("InhabitedTime");
|
||||
LevelChunkSection[] chunkSections = readSections(level, lightEngine, actualPos, chunkData);
|
||||
|
||||
// Make chunk
|
||||
LevelChunk chunk = new LevelChunk((Level) level, chunkPos, upgradeData, blockTicks, fluidTicks, inhabitedTime, chunkSections, null, blendingData);
|
||||
|
||||
#endif
|
||||
|
||||
LevelChunkSection[] levelChunkSections = readSections(level, lightEngine, chunkPos, tagLevel);
|
||||
|
||||
// ====================== Make the chunk =========================
|
||||
#if PRE_MC_1_18_1
|
||||
LevelChunk chunk = new LevelChunk((Level) level.getLevel(), chunkPos, chunkBiomeContainer, upgradeData, blockTicks,
|
||||
fluidTicks, inhabitedTime, levelChunkSections, null);
|
||||
#else
|
||||
LevelChunk chunk = new LevelChunk((Level) level, chunkPos, upgradeData, blockTicks,
|
||||
fluidTicks, inhabitedTime, levelChunkSections, null, blendingData);
|
||||
#endif
|
||||
// Set some states after object creation
|
||||
chunk.setLightCorrect(isLightOn);
|
||||
readHeightmaps(chunk, chunkData);
|
||||
readStructures(level, chunk, chunkData);
|
||||
readPostPocessings(chunk, chunkData);
|
||||
return chunk;
|
||||
}
|
||||
|
||||
+24
@@ -1,10 +1,31 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.mimicObject;
|
||||
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IStarlightAccessor;
|
||||
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
#if POST_MC_1_17_1
|
||||
import net.minecraft.world.level.LevelHeightAccessor;
|
||||
#endif
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.LightChunkGetter;
|
||||
|
||||
@@ -34,7 +55,10 @@ public class LightGetterAdaptor implements LightChunkGetter {
|
||||
public BlockGetter getLevel() {
|
||||
return shouldReturnNull ? null : (genRegion != null ? genRegion : heightGetter);
|
||||
}
|
||||
|
||||
#if POST_MC_1_17_1
|
||||
public LevelHeightAccessor getLevelHeightAccessor() {
|
||||
return heightGetter;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
+49
-16
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.mimicObject;
|
||||
|
||||
import java.util.List;
|
||||
@@ -23,7 +42,9 @@ import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.ColorResolver;
|
||||
#if POST_MC_1_17_1
|
||||
import net.minecraft.world.level.LevelHeightAccessor;
|
||||
#endif
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
@@ -48,11 +69,30 @@ public class LightedWorldGenRegion extends WorldGenRegion {
|
||||
private final ChunkPos firstPos;
|
||||
private final List<ChunkAccess> cache;
|
||||
Long2ObjectOpenHashMap<ChunkAccess> chunkMap = new Long2ObjectOpenHashMap<ChunkAccess>();
|
||||
#if PRE_MC_1_18_1
|
||||
private ChunkPos overrideCenterPos = null;
|
||||
public void setOverrideCenter(ChunkPos pos) {overrideCenterPos = pos;}
|
||||
#if PRE_MC_1_17_1
|
||||
@Override
|
||||
public int getCenterX() {
|
||||
return overrideCenterPos==null ? super.getCenterX() : overrideCenterPos.x;
|
||||
}
|
||||
@Override
|
||||
public int getCenterZ() {
|
||||
return overrideCenterPos==null ? super.getCenterX() : overrideCenterPos.z;
|
||||
}
|
||||
#else
|
||||
@Override
|
||||
public ChunkPos getCenter() {
|
||||
return overrideCenterPos==null ? super.getCenter() : overrideCenterPos;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
public LightedWorldGenRegion(ServerLevel serverLevel, WorldGenLevelLightEngine lightEngine,
|
||||
List<ChunkAccess> list, ChunkStatus chunkStatus, int i,
|
||||
LightGenerationMode lightMode, EmptyChunkGenerator generator) {
|
||||
super(serverLevel, list, chunkStatus, i);
|
||||
super(serverLevel, list #if POST_MC_1_17_1, chunkStatus, i #endif);
|
||||
this.lightMode = lightMode;
|
||||
this.firstPos = list.get(0).getPos();
|
||||
this.generator = generator;
|
||||
@@ -60,14 +100,9 @@ public class LightedWorldGenRegion extends WorldGenRegion {
|
||||
writeRadius = i;
|
||||
cache = list;
|
||||
size = Mth.floor(Math.sqrt(list.size()));
|
||||
|
||||
this.tintCaches = Util.make(new Object2ObjectArrayMap(3), object2ObjectArrayMap -> {
|
||||
object2ObjectArrayMap.put(BiomeColors.GRASS_COLOR_RESOLVER, new BlockTintCache((pos) -> {return calculateBlockTint(pos, BiomeColors.GRASS_COLOR_RESOLVER);}));
|
||||
object2ObjectArrayMap.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new BlockTintCache((pos) -> {return calculateBlockTint(pos, BiomeColors.FOLIAGE_COLOR_RESOLVER);}));
|
||||
object2ObjectArrayMap.put(BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache((pos) -> {return calculateBlockTint(pos, BiomeColors.WATER_COLOR_RESOLVER);}));
|
||||
});
|
||||
}
|
||||
|
||||
#if POST_MC_1_17_1
|
||||
// Bypass BCLib mixin overrides.
|
||||
@Override
|
||||
public boolean ensureCanWrite(BlockPos blockPos) {
|
||||
@@ -80,14 +115,17 @@ public class LightedWorldGenRegion extends WorldGenRegion {
|
||||
if (k > this.writeRadius || l > this.writeRadius) {
|
||||
return false;
|
||||
}
|
||||
#if POST_MC_1_18_1
|
||||
if (center.isUpgrading()) {
|
||||
LevelHeightAccessor levelHeightAccessor = center.getHeightAccessorForGeneration();
|
||||
if (blockPos.getY() < levelHeightAccessor.getMinBuildHeight() || blockPos.getY() >= levelHeightAccessor.getMaxBuildHeight()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO Check this
|
||||
// @Override
|
||||
@@ -172,7 +210,7 @@ public class LightedWorldGenRegion extends WorldGenRegion {
|
||||
public ChunkAccess getChunk(int i, int j, ChunkStatus chunkStatus, boolean bl) {
|
||||
ChunkAccess chunk = getChunkAccess(i, j, chunkStatus, bl);
|
||||
if (chunk instanceof LevelChunk) {
|
||||
chunk = new ImposterProtoChunk((LevelChunk) chunk, true);
|
||||
chunk = new ImposterProtoChunk((LevelChunk) chunk #if POST_MC_1_18_1, true #endif);
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
@@ -236,21 +274,16 @@ public class LightedWorldGenRegion extends WorldGenRegion {
|
||||
public boolean canSeeSky(BlockPos blockPos) {
|
||||
return (getBrightness(LightLayer.SKY, blockPos) >= getMaxLightLevel());
|
||||
}
|
||||
|
||||
|
||||
|
||||
private final Object2ObjectArrayMap<ColorResolver, BlockTintCache> tintCaches;
|
||||
|
||||
public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver)
|
||||
{
|
||||
BlockTintCache blockTintCache = (BlockTintCache) this.tintCaches.get(colorResolver);
|
||||
return blockTintCache.getColor(blockPos);
|
||||
return calculateBlockTint(blockPos, colorResolver);
|
||||
}
|
||||
|
||||
private Biome _getBiome(BlockPos pos) {
|
||||
#if MC_VERSION_1_18_2
|
||||
#if POST_MC_1_18_2
|
||||
return getBiome(pos).value();
|
||||
#elif MC_VERSION_1_18_1
|
||||
#else
|
||||
return getBiome(pos);
|
||||
#endif
|
||||
}
|
||||
|
||||
+48
-3
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.mimicObject;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -5,7 +24,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
#if POST_MC_1_17_1
|
||||
import net.minecraft.world.level.LevelHeightAccessor;
|
||||
#endif
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.DataLayer;
|
||||
@@ -18,7 +39,9 @@ import net.minecraft.world.level.lighting.SkyLightEngine;
|
||||
public class WorldGenLevelLightEngine extends LevelLightEngine {
|
||||
public static final int MAX_SOURCE_LEVEL = 15;
|
||||
public static final int LIGHT_SECTION_PADDING = 1;
|
||||
#if POST_MC_1_17_1
|
||||
protected final LevelHeightAccessor levelHeightAccessor;
|
||||
#endif
|
||||
@Nullable
|
||||
public final BlockLightEngine blockEngine;
|
||||
@Nullable
|
||||
@@ -26,7 +49,9 @@ public class WorldGenLevelLightEngine extends LevelLightEngine {
|
||||
|
||||
public WorldGenLevelLightEngine(LightGetterAdaptor genRegion) {
|
||||
super(genRegion, false, false);
|
||||
#if POST_MC_1_17_1
|
||||
this.levelHeightAccessor = genRegion.getLevelHeightAccessor();
|
||||
#endif
|
||||
this.blockEngine = new BlockLightEngine(genRegion);
|
||||
this.skyEngine = new SkyLightEngine(genRegion);
|
||||
}
|
||||
@@ -123,18 +148,35 @@ public class WorldGenLevelLightEngine extends LevelLightEngine {
|
||||
chunkAccess.setLightCorrect(false);
|
||||
|
||||
LevelChunkSection[] levelChunkSections = chunkAccess.getSections();
|
||||
for (int i = 0; i < chunkAccess.getSectionsCount(); ++i) {
|
||||
for (int i = 0; i <
|
||||
#if POST_MC_1_17_1
|
||||
chunkAccess.getSectionsCount()
|
||||
#else
|
||||
16
|
||||
#endif
|
||||
; ++i) {
|
||||
LevelChunkSection levelChunkSection = levelChunkSections[i];
|
||||
#if PRE_MC_1_17_1
|
||||
if (!LevelChunkSection.isEmpty(levelChunkSection)) {
|
||||
updateSectionStatus(SectionPos.of(chunkPos, i), false);
|
||||
}
|
||||
#elif PRE_MC_1_18_1
|
||||
if (!LevelChunkSection.isEmpty(levelChunkSection)) {
|
||||
int j = this.levelHeightAccessor.getSectionYFromSectionIndex(i);
|
||||
updateSectionStatus(SectionPos.of(chunkPos, j), false);
|
||||
}
|
||||
#else
|
||||
if (levelChunkSection.hasOnlyAir()) continue;
|
||||
int j = this.levelHeightAccessor.getSectionYFromSectionIndex(i);
|
||||
updateSectionStatus(SectionPos.of(chunkPos, j), false);
|
||||
#endif
|
||||
}
|
||||
enableLightSources(chunkPos, true);
|
||||
if (needLightBlockUpdate) {
|
||||
chunkAccess.getLights().forEach(blockPos ->
|
||||
onBlockEmissionIncrease(blockPos, chunkAccess.getLightEmission(blockPos)));
|
||||
onBlockEmissionIncrease(blockPos, chunkAccess.getLightEmission(blockPos)));
|
||||
}
|
||||
|
||||
|
||||
chunkAccess.setLightCorrect(true);
|
||||
}
|
||||
|
||||
@@ -161,6 +203,8 @@ public class WorldGenLevelLightEngine extends LevelLightEngine {
|
||||
this.skyEngine.retainData(chunkPos, bl);
|
||||
}
|
||||
}
|
||||
|
||||
#if POST_MC_1_17_1
|
||||
@Override
|
||||
public int getLightSectionCount() {
|
||||
throw new UnsupportedOperationException("This should never be used!");
|
||||
@@ -173,4 +217,5 @@ public class WorldGenLevelLightEngine extends LevelLightEngine {
|
||||
public int getMaxLightSection() {
|
||||
throw new UnsupportedOperationException("This should never be used!");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
+115
-78
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.mimicObject;
|
||||
|
||||
import java.util.Iterator;
|
||||
@@ -6,6 +25,8 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@@ -23,16 +44,21 @@ import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
||||
#if POST_MC_1_18_1
|
||||
import net.minecraft.world.level.levelgen.structure.StructureCheck;
|
||||
#endif
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
|
||||
public class WorldGenStructFeatManager extends StructureFeatureManager {
|
||||
final WorldGenLevel genLevel;
|
||||
WorldGenSettings worldGenSettings;
|
||||
#if POST_MC_1_18_1
|
||||
StructureCheck structureCheck;
|
||||
#endif
|
||||
public WorldGenStructFeatManager(WorldGenSettings worldGenSettings,
|
||||
WorldGenLevel genLevel, StructureCheck structureCheck) {
|
||||
super(genLevel, worldGenSettings, structureCheck);
|
||||
WorldGenLevel genLevel #if POST_MC_1_18_1, StructureCheck structureCheck #endif) {
|
||||
|
||||
super(genLevel, worldGenSettings #if POST_MC_1_18_1, structureCheck #endif);
|
||||
this.genLevel = genLevel;
|
||||
this.worldGenSettings = worldGenSettings;
|
||||
}
|
||||
@@ -41,7 +67,7 @@ public class WorldGenStructFeatManager extends StructureFeatureManager {
|
||||
public WorldGenStructFeatManager forWorldGenRegion(WorldGenRegion worldGenRegion) {
|
||||
if (worldGenRegion == genLevel)
|
||||
return this;
|
||||
return new WorldGenStructFeatManager(worldGenSettings, worldGenRegion, structureCheck);
|
||||
return new WorldGenStructFeatManager(worldGenSettings, worldGenRegion #if POST_MC_1_18_1, structureCheck #endif);
|
||||
}
|
||||
|
||||
private ChunkAccess _getChunk(int x, int z, ChunkStatus status) {
|
||||
@@ -49,86 +75,97 @@ public class WorldGenStructFeatManager extends StructureFeatureManager {
|
||||
return genLevel.getChunk(x, z, status, false);
|
||||
}
|
||||
|
||||
#if PRE_MC_1_18_1
|
||||
@Override
|
||||
public boolean hasAnyStructureAt(BlockPos blockPos) {
|
||||
SectionPos sectionPos = SectionPos.of(blockPos);
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return false;
|
||||
return chunk.hasAnyStructureReferences();
|
||||
}
|
||||
public Stream<? extends StructureStart<?>> startsForFeature(SectionPos sectionPos2,
|
||||
StructureFeature<?> structureFeature) {
|
||||
ChunkAccess chunk = _getChunk(sectionPos2.x(), sectionPos2.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return Stream.empty();
|
||||
|
||||
|
||||
|
||||
#if MC_VERSION_1_18_1
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public List<? extends StructureStart<?>> startsForFeature(SectionPos sectionPos,
|
||||
StructureFeature<?> structureFeature) {
|
||||
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return List.of();
|
||||
|
||||
// Copied from StructureFeatureManager::startsForFeature(...) with slight tweaks
|
||||
LongSet longSet = chunk.getReferencesForFeature(structureFeature);
|
||||
ImmutableList.Builder builder = ImmutableList.builder();
|
||||
LongIterator longIterator = longSet.iterator();
|
||||
while (longIterator.hasNext()) {
|
||||
long l = (Long)longIterator.next();
|
||||
SectionPos sectPos = SectionPos.of(new ChunkPos(l), genLevel.getMinSection());
|
||||
ChunkAccess startChunk = _getChunk(sectPos.x(), sectPos.z(), ChunkStatus.STRUCTURE_STARTS);
|
||||
if (startChunk == null) continue;
|
||||
StructureStart<?> structureStart = this.getStartForFeature(sectPos, structureFeature, startChunk);
|
||||
if (structureStart == null || !structureStart.isValid()) continue;
|
||||
builder.add(structureStart);
|
||||
}
|
||||
return builder.build();
|
||||
return chunk.getReferencesForFeature(structureFeature).stream().map(pos -> {
|
||||
SectionPos sectPos = SectionPos.of(ChunkPos.getX(pos), 0, ChunkPos.getZ(pos));
|
||||
ChunkAccess startChunk = _getChunk(sectPos.x(), sectPos.z(), ChunkStatus.STRUCTURE_STARTS);
|
||||
if (startChunk == null) return null;
|
||||
return this.getStartForFeature(sectPos, structureFeature, startChunk);
|
||||
}).filter(structureStart -> structureStart != null && structureStart.isValid());
|
||||
}
|
||||
#elif MC_VERSION_1_18_2
|
||||
|
||||
#else
|
||||
@Override
|
||||
public List<StructureStart> startsForFeature(SectionPos sectionPos, Predicate<ConfiguredStructureFeature<?, ?>> predicate) {
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return List.of();
|
||||
|
||||
// Copied from StructureFeatureManager::startsForFeature(...)
|
||||
Map<ConfiguredStructureFeature<?, ?>, LongSet> map = chunk.getAllReferences();
|
||||
|
||||
ImmutableList.Builder<StructureStart> builder = ImmutableList.builder();
|
||||
Iterator<Map.Entry<ConfiguredStructureFeature<?, ?>, LongSet>> var5 = map.entrySet().iterator();
|
||||
|
||||
while(var5.hasNext()) {
|
||||
Map.Entry<ConfiguredStructureFeature<?, ?>, LongSet> entry = var5.next();
|
||||
ConfiguredStructureFeature<?, ?> configuredStructureFeature = entry.getKey();
|
||||
if (predicate.test(configuredStructureFeature)) {
|
||||
LongSet var10002 = (LongSet)entry.getValue();
|
||||
Objects.requireNonNull(builder);
|
||||
this.fillStartsForFeature(configuredStructureFeature, var10002, builder::add);
|
||||
}
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StructureStart> startsForFeature(SectionPos sectionPos, ConfiguredStructureFeature<?, ?> configuredStructureFeature) {
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return List.of();
|
||||
|
||||
// Copied from StructureFeatureManager::startsForFeature(...)
|
||||
LongSet longSet = chunk.getReferencesForFeature(configuredStructureFeature);
|
||||
ImmutableList.Builder<StructureStart> builder = ImmutableList.builder();
|
||||
Objects.requireNonNull(builder);
|
||||
this.fillStartsForFeature(configuredStructureFeature, longSet, builder::add);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<ConfiguredStructureFeature<?, ?>, LongSet> getAllStructuresAt(BlockPos blockPos) {
|
||||
public boolean hasAnyStructureAt(BlockPos blockPos) {
|
||||
SectionPos sectionPos = SectionPos.of(blockPos);
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return Map.of();
|
||||
return chunk.getAllReferences();
|
||||
if (chunk == null) return false;
|
||||
return chunk.hasAnyStructureReferences();
|
||||
}
|
||||
#endif
|
||||
#if MC_1_18_1
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public List<? extends StructureStart<?>> startsForFeature(SectionPos sectionPos,
|
||||
StructureFeature<?> structureFeature) {
|
||||
|
||||
}
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return List.of();
|
||||
|
||||
// Copied from StructureFeatureManager::startsForFeature(...) with slight tweaks
|
||||
LongSet longSet = chunk.getReferencesForFeature(structureFeature);
|
||||
ImmutableList.Builder builder = ImmutableList.builder();
|
||||
LongIterator longIterator = longSet.iterator();
|
||||
while (longIterator.hasNext()) {
|
||||
long l = (Long)longIterator.next();
|
||||
SectionPos sectPos = SectionPos.of(new ChunkPos(l), genLevel.getMinSection());
|
||||
ChunkAccess startChunk = _getChunk(sectPos.x(), sectPos.z(), ChunkStatus.STRUCTURE_STARTS);
|
||||
if (startChunk == null) continue;
|
||||
StructureStart<?> structureStart = this.getStartForFeature(sectPos, structureFeature, startChunk);
|
||||
if (structureStart == null || !structureStart.isValid()) continue;
|
||||
builder.add(structureStart);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
#else
|
||||
@Override
|
||||
public List<StructureStart> startsForFeature(SectionPos sectionPos, Predicate<ConfiguredStructureFeature<?, ?>> predicate) {
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return List.of();
|
||||
|
||||
// Copied from StructureFeatureManager::startsForFeature(...)
|
||||
Map<ConfiguredStructureFeature<?, ?>, LongSet> map = chunk.getAllReferences();
|
||||
|
||||
ImmutableList.Builder<StructureStart> builder = ImmutableList.builder();
|
||||
Iterator<Map.Entry<ConfiguredStructureFeature<?, ?>, LongSet>> var5 = map.entrySet().iterator();
|
||||
|
||||
while(var5.hasNext()) {
|
||||
Map.Entry<ConfiguredStructureFeature<?, ?>, LongSet> entry = var5.next();
|
||||
ConfiguredStructureFeature<?, ?> configuredStructureFeature = entry.getKey();
|
||||
if (predicate.test(configuredStructureFeature)) {
|
||||
LongSet var10002 = (LongSet)entry.getValue();
|
||||
Objects.requireNonNull(builder);
|
||||
this.fillStartsForFeature(configuredStructureFeature, var10002, builder::add);
|
||||
}
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StructureStart> startsForFeature(SectionPos sectionPos, ConfiguredStructureFeature<?, ?> configuredStructureFeature) {
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return (List<StructureStart>) Stream.empty();
|
||||
|
||||
// Copied from StructureFeatureManager::startsForFeature(...)
|
||||
LongSet longSet = chunk.getReferencesForFeature(configuredStructureFeature);
|
||||
ImmutableList.Builder<StructureStart> builder = ImmutableList.builder();
|
||||
Objects.requireNonNull(builder);
|
||||
this.fillStartsForFeature(configuredStructureFeature, longSet, builder::add);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<ConfiguredStructureFeature<?, ?>, LongSet> getAllStructuresAt(BlockPos blockPos) {
|
||||
SectionPos sectionPos = SectionPos.of(blockPos);
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return (Map<ConfiguredStructureFeature<?, ?>, LongSet>) Stream.empty();
|
||||
return chunk.getAllReferences();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
+25
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -17,7 +36,9 @@ import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.levelgen.DebugLevelSource;
|
||||
import net.minecraft.world.level.levelgen.FlatLevelSource;
|
||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||
#if POST_MC_1_18_1
|
||||
import net.minecraft.world.level.levelgen.blending.Blender;
|
||||
#endif
|
||||
|
||||
public final class StepBiomes {
|
||||
/**
|
||||
@@ -48,8 +69,12 @@ public final class StepBiomes {
|
||||
|
||||
for (ChunkAccess chunk : chunksToDo) {
|
||||
// System.out.println("StepBiomes: "+chunk.getPos());
|
||||
#if PRE_MC_1_18_1
|
||||
environment.params.generator.createBiomes(environment.params.biomes, chunk);
|
||||
#else
|
||||
chunk = environment.joinSync(environment.params.generator.createBiomes(environment.params.biomes, Runnable::run, Blender.of(worldGenRegion),
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
+34
-11
@@ -1,9 +1,29 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.LightedWorldGenRegion;
|
||||
import com.seibel.lod.core.util.gridList.ArrayGridList;
|
||||
|
||||
import net.minecraft.ReportedException;
|
||||
@@ -11,7 +31,10 @@ import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
#if POST_MC_1_18_1
|
||||
import net.minecraft.world.level.levelgen.blending.Blender;
|
||||
#endif
|
||||
|
||||
public final class StepFeatures {
|
||||
/**
|
||||
@@ -29,7 +52,7 @@ public final class StepFeatures {
|
||||
|
||||
public final ChunkStatus STATUS = ChunkStatus.FEATURES;
|
||||
|
||||
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
|
||||
public void generateGroup(ThreadedParameters tParams, LightedWorldGenRegion worldGenRegion,
|
||||
ArrayGridList<ChunkAccess> chunks) {
|
||||
ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
|
||||
|
||||
@@ -41,20 +64,20 @@ public final class StepFeatures {
|
||||
|
||||
for (ChunkAccess chunk : chunksToDo) {
|
||||
try {
|
||||
#if PRE_MC_1_18_1
|
||||
worldGenRegion.setOverrideCenter(chunk.getPos());
|
||||
Heightmap.primeHeightmaps(chunk, STATUS.heightmapsAfter());
|
||||
environment.params.generator.applyBiomeDecoration(worldGenRegion, tParams.structFeat);
|
||||
#else
|
||||
Heightmap.primeHeightmaps(chunk, STATUS.heightmapsAfter());
|
||||
environment.params.generator.applyBiomeDecoration(worldGenRegion, chunk,
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion));
|
||||
Blender.generateBorderTicks(worldGenRegion, chunk);
|
||||
#endif
|
||||
} catch (ReportedException e) {
|
||||
e.printStackTrace();
|
||||
// FIXME: Features concurrent modification issue. Something about cocobeans just
|
||||
// aren't happy
|
||||
// For now just retry.
|
||||
// FIXME: Features concurrent modification issue. Something about cocobeans might just
|
||||
// error out. For now just retry.
|
||||
}
|
||||
}/*
|
||||
for (ChunkAccess chunk : chunks) {
|
||||
Heightmap.primeHeightmaps(chunk,
|
||||
EnumSet.of(Heightmap.Types.MOTION_BLOCKING, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES,
|
||||
Heightmap.Types.OCEAN_FLOOR, Heightmap.Types.WORLD_SURFACE));
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
-2
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.step;
|
||||
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
@@ -9,6 +28,7 @@ import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
import net.minecraft.world.level.lighting.LightEventListener;
|
||||
|
||||
public final class StepLight {
|
||||
@@ -27,9 +47,10 @@ public final class StepLight {
|
||||
|
||||
public final ChunkStatus STATUS = ChunkStatus.LIGHT;
|
||||
|
||||
public void generateGroup(LightEventListener lightEngine,
|
||||
public void generateGroup(
|
||||
#if PRE_MC_1_17_1 LevelLightEngine lightEngine,
|
||||
#else LightEventListener lightEngine, #endif
|
||||
ArrayGridList<ChunkAccess> chunks) {
|
||||
//ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
|
||||
|
||||
for (ChunkAccess chunk : chunks) {
|
||||
if (chunk.getStatus().isOrAfter(STATUS)) continue;
|
||||
@@ -52,7 +73,9 @@ public final class StepLight {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
#if POST_MC_1_18_1
|
||||
if (chunk instanceof LevelChunk) ((LevelChunk)chunk).setClientLightReady(true);
|
||||
#endif
|
||||
chunk.setLightCorrect(true);
|
||||
}
|
||||
lightEngine.runUpdates(Integer.MAX_VALUE, true, true);
|
||||
|
||||
+33
-1
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -9,9 +28,12 @@ import com.google.common.collect.Sets;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.util.Mth;
|
||||
#if POST_MC_1_17_1
|
||||
import net.minecraft.world.level.LevelHeightAccessor;
|
||||
#endif
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
@@ -19,7 +41,9 @@ import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.NoiseSettings;
|
||||
#if POST_MC_1_18_1
|
||||
import net.minecraft.world.level.levelgen.blending.Blender;
|
||||
#endif
|
||||
|
||||
public final class StepNoise {
|
||||
/**
|
||||
@@ -50,8 +74,16 @@ public final class StepNoise {
|
||||
|
||||
for (ChunkAccess chunk : chunksToDo) {
|
||||
// System.out.println("StepNoise: "+chunk.getPos());
|
||||
#if PRE_MC_1_17_1
|
||||
environment.params.generator.fillFromNoise(worldGenRegion, tParams.structFeat, chunk);
|
||||
#elif PRE_MC_1_18_1
|
||||
chunk = environment.joinSync(environment.params.generator.fillFromNoise(Runnable::run,
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk));
|
||||
#else
|
||||
chunk = environment.joinSync(environment.params.generator.fillFromNoise(Runnable::run, Blender.of(worldGenRegion),
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk));
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk));
|
||||
#endif
|
||||
LodUtil.checkInterruptsUnchecked(); // Speed up termination responsiveness
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
+22
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -53,6 +72,8 @@ public final class StepStructureStart {
|
||||
// System.out.println("StepStructureStart: "+chunk.getPos());
|
||||
environment.params.generator.createStructures(environment.params.registry, tParams.structFeat, chunk, environment.params.structures,
|
||||
environment.params.worldSeed);
|
||||
|
||||
#if POST_MC_1_18_1
|
||||
try {
|
||||
tParams.structCheck.onStructureLoad(chunk.getPos(), chunk.getAllStarts());
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
@@ -61,6 +82,7 @@ public final class StepStructureStart {
|
||||
// TODO: Figure out in the future why this happens even though I am using new structFeat
|
||||
throw new StepStructureStart.StructStartCorruptedException(e);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+25
-2
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -39,8 +58,12 @@ public final class StepSurface {
|
||||
|
||||
for (ChunkAccess chunk : chunksToDo) {
|
||||
// System.out.println("StepSurface: "+chunk.getPos());
|
||||
environment.params.generator.buildSurface(worldGenRegion, tParams.structFeat.forWorldGenRegion(worldGenRegion),
|
||||
chunk);
|
||||
#if PRE_MC_1_18_1
|
||||
environment.params.generator.buildSurfaceAndBedrock(worldGenRegion, chunk);
|
||||
|
||||
#else
|
||||
environment.params.generator.buildSurface(worldGenRegion, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
accessWidener v1 named
|
||||
|
||||
# used when determining where to save files to
|
||||
accessible field net/minecraft/world/level/storage/DimensionDataStorage dataFolder Ljava/io/File;
|
||||
|
||||
# used when rendering
|
||||
accessible field com/mojang/blaze3d/vertex/VertexBuffer vertexCount I
|
||||
accessible field com/mojang/blaze3d/vertex/VertexBuffer id I
|
||||
accessible method net/minecraft/client/renderer/GameRenderer getFov (Lnet/minecraft/client/Camera;FZ)D
|
||||
|
||||
# pre-render setup
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer renderChunks Lit/unimi/dsi/fastutil/objects/ObjectList;
|
||||
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;
|
||||
|
||||
# used for grabbing vanilla rendered chunks
|
||||
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;
|
||||
#accessible field net/minecraft/world/entity/Entity blockPosition Lnet/minecraft/core/BlockPos;
|
||||
|
||||
# lighting
|
||||
accessible field net/minecraft/client/renderer/LightTexture lightPixels Lcom/mojang/blaze3d/platform/NativeImage;
|
||||
accessible field net/minecraft/client/renderer/LightTexture lightTexture Lnet/minecraft/client/renderer/texture/DynamicTexture;
|
||||
accessible field net/minecraft/world/level/lighting/LevelLightEngine blockEngine Lnet/minecraft/world/level/lighting/LayerLightEngine;
|
||||
accessible field net/minecraft/world/level/lighting/LevelLightEngine skyEngine Lnet/minecraft/world/level/lighting/LayerLightEngine;
|
||||
|
||||
# world generation
|
||||
accessible method net/minecraft/world/level/levelgen/Heightmap setHeight (III)V
|
||||
accessible field net/minecraft/world/level/biome/Biome generationSettings Lnet/minecraft/world/level/biome/BiomeGenerationSettings;
|
||||
accessible field net/minecraft/world/level/biome/Biome biomeCategory Lnet/minecraft/world/level/biome/Biome$BiomeCategory;
|
||||
#accessible field net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator settings Lnet/minecraft/core/Holder;
|
||||
#accessible method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doCreateBiomes (Lnet/minecraft/core/Registry;Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V
|
||||
accessible method net/minecraft/world/level/lighting/LayerLightEngine queueSectionData (JLnet/minecraft/world/level/chunk/DataLayer;Z)V
|
||||
|
||||
# lod generation from save file
|
||||
accessible field net/minecraft/server/level/ChunkMap mainThreadExecutor Lnet/minecraft/util/thread/BlockableEventLoop;
|
||||
accessible method net/minecraft/server/level/ChunkMap readChunk (Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/nbt/CompoundTag;
|
||||
|
||||
# grabbing textures
|
||||
accessible field net/minecraft/client/renderer/block/model/BakedQuad sprite Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite framesX [I
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite framesY [I
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite mainImage [Lcom/mojang/blaze3d/platform/NativeImage;
|
||||
|
||||
extendable class com/mojang/math/Matrix4f
|
||||
@@ -0,0 +1,48 @@
|
||||
accessWidener v1 named
|
||||
|
||||
|
||||
# used when determining where to save files to
|
||||
accessible field net/minecraft/world/level/storage/DimensionDataStorage dataFolder Ljava/io/File;
|
||||
|
||||
# used when rendering
|
||||
accessible field com/mojang/blaze3d/vertex/VertexBuffer indexCount I
|
||||
accessible field com/mojang/blaze3d/vertex/VertexBuffer vertextBufferId I
|
||||
accessible method net/minecraft/client/renderer/GameRenderer getFov (Lnet/minecraft/client/Camera;FZ)D
|
||||
|
||||
# pre-render setup
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer renderChunks Lit/unimi/dsi/fastutil/objects/ObjectArrayList;
|
||||
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;
|
||||
|
||||
# used for grabbing vanilla rendered chunks
|
||||
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;
|
||||
|
||||
# lighting
|
||||
accessible field net/minecraft/client/renderer/LightTexture lightPixels Lcom/mojang/blaze3d/platform/NativeImage;
|
||||
accessible field net/minecraft/client/renderer/LightTexture lightTexture Lnet/minecraft/client/renderer/texture/DynamicTexture;
|
||||
accessible field net/minecraft/world/level/lighting/LevelLightEngine blockEngine Lnet/minecraft/world/level/lighting/LayerLightEngine;
|
||||
accessible field net/minecraft/world/level/lighting/LevelLightEngine skyEngine Lnet/minecraft/world/level/lighting/LayerLightEngine;
|
||||
|
||||
# world generation
|
||||
accessible method net/minecraft/world/level/levelgen/Heightmap setHeight (III)V
|
||||
accessible field net/minecraft/world/level/biome/Biome generationSettings Lnet/minecraft/world/level/biome/BiomeGenerationSettings;
|
||||
accessible field net/minecraft/world/level/biome/Biome biomeCategory Lnet/minecraft/world/level/biome/Biome$BiomeCategory;
|
||||
# accessible field net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator settings Lnet/minecraft/core/Holder;
|
||||
#accessible method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doCreateBiomes (Lnet/minecraft/core/Registry;Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V
|
||||
accessible method net/minecraft/world/level/lighting/LayerLightEngine queueSectionData (JLnet/minecraft/world/level/chunk/DataLayer;Z)V
|
||||
|
||||
# lod generation from save file
|
||||
accessible field net/minecraft/server/level/ChunkMap mainThreadExecutor Lnet/minecraft/util/thread/BlockableEventLoop;
|
||||
accessible method net/minecraft/server/level/ChunkMap readChunk (Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/nbt/CompoundTag;
|
||||
|
||||
|
||||
# grabbing textures
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite animatedTexture Lnet/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture;
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite width I
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite height I
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite mainImage [Lcom/mojang/blaze3d/platform/NativeImage;
|
||||
accessible class net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture
|
||||
accessible method net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture getFrameX (I)I
|
||||
accessible method net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture getFrameY (I)I
|
||||
extendable class com/mojang/math/Matrix4f
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
accessWidener v1 named
|
||||
|
||||
|
||||
# used when determining where to save files to
|
||||
accessible field net/minecraft/world/level/storage/DimensionDataStorage dataFolder Ljava/io/File;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"accessWidener": "lod.accesswidener"
|
||||
}
|
||||
+1
-1
Submodule core updated: 02b0637adc...83a2fa86d9
@@ -0,0 +1,15 @@
|
||||
architectury {
|
||||
common(rootProject.enabled_platforms.split(","))
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Use Fabric loader as both Quilt and Fabric can use it
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
|
||||
// Fabric API
|
||||
fabricApi.module("fabric-lifecycle-events-v1", rootProject.fabric_api_version)
|
||||
fabricApi.module("fabric-key-binding-api-v1", rootProject.fabric_api_version)
|
||||
fabricApi.module("fabric-networking-api-v1", rootProject.fabric_api_version)
|
||||
|
||||
compileClasspath(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric_like.mixins;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
|
||||
#if PRE_MC_1_18_1
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.levelgen.WorldgenRandom;
|
||||
|
||||
@Mixin(ChunkGenerator.class)
|
||||
public class MixinChunkGenerator {
|
||||
@Redirect(method = "applyBiomeDecoration", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/biome/Biome;generate(Lnet/minecraft/world/level/StructureFeatureManager;"
|
||||
+ "Lnet/minecraft/world/level/chunk/ChunkGenerator;Lnet/minecraft/server/level/WorldGenRegion;J"
|
||||
+ "Lnet/minecraft/world/level/levelgen/WorldgenRandom;Lnet/minecraft/core/BlockPos;)V"
|
||||
|
||||
))
|
||||
private void wrapBiomeGenerateCall(Biome biome, StructureFeatureManager structFeatManager, ChunkGenerator generator,
|
||||
WorldGenRegion genRegion, long l, WorldgenRandom random, BlockPos pos) {
|
||||
synchronized(ChunkGenerator.class) {
|
||||
biome.generate(structFeatManager, (ChunkGenerator)(Object)this, genRegion, l, random, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
@Mixin(ChunkGenerator.class)
|
||||
public class MixinChunkGenerator {}
|
||||
#endif
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric_like.mixins;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraft.client.renderer.FogRenderer.FogMode;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
#if PRE_MC_1_17_1
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
#else
|
||||
import net.minecraft.world.level.material.FogType;
|
||||
#endif
|
||||
|
||||
@Mixin(FogRenderer.class)
|
||||
public class MixinFogRenderer {
|
||||
private static ILodConfigWrapperSingleton CONFIG;
|
||||
|
||||
// Using this instead of Float.MAX_VALUE because Sodium don't like it.
|
||||
private static final float A_REALLY_REALLY_BIG_VALUE = 420694206942069.F;
|
||||
private static final float A_EVEN_LARGER_VALUE = 42069420694206942069.F;
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "setupFog(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/FogRenderer$FogMode;FZ)V")
|
||||
private static void disableSetupFog(Camera camera, FogMode fogMode, float f, boolean bl, CallbackInfo callback) {
|
||||
if (CONFIG == null) CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
#if PRE_MC_1_17_1
|
||||
FluidState fluidState = camera.getFluidInCamera();
|
||||
boolean cameraNotInFluid = fluidState.isEmpty();
|
||||
#else
|
||||
FogType fogTypes = camera.getFluidInCamera();
|
||||
boolean cameraNotInFluid = fogTypes == FogType.NONE;
|
||||
#endif
|
||||
|
||||
Entity entity = camera.getEntity();
|
||||
boolean isSpecialFog = (entity instanceof LivingEntity) && ((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS);
|
||||
if (!isSpecialFog && cameraNotInFluid && fogMode == FogMode.FOG_TERRAIN
|
||||
&& CONFIG.client().graphics().fogQuality().getDisableVanillaFog())
|
||||
{
|
||||
#if PRE_MC_1_17_1
|
||||
RenderSystem.fogStart(A_REALLY_REALLY_BIG_VALUE);
|
||||
RenderSystem.fogEnd(A_EVEN_LARGER_VALUE);
|
||||
#else
|
||||
RenderSystem.setShaderFogStart(A_REALLY_REALLY_BIG_VALUE);
|
||||
RenderSystem.setShaderFogEnd(A_EVEN_LARGER_VALUE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+22
-2
@@ -1,4 +1,23 @@
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric_like.mixins;
|
||||
|
||||
import com.seibel.lod.common.wrappers.config.ConfigGui;
|
||||
import com.seibel.lod.common.wrappers.config.TexturedButtonWidget;
|
||||
@@ -34,7 +53,8 @@ public class MixinOptionsScreen extends Screen {
|
||||
@Inject(at = @At("HEAD"),method = "init")
|
||||
private void lodconfig$init(CallbackInfo ci) {
|
||||
if (SingletonHandler.get(ILodConfigWrapperSingleton.class).client().getOptionsButton())
|
||||
this.addRenderableWidget(new TexturedButtonWidget(
|
||||
this. #if PRE_MC_1_17_1 addButton #else addRenderableWidget #endif
|
||||
(new TexturedButtonWidget(
|
||||
// Where the button is on the screen
|
||||
this.width / 2 - 180, this.height / 6 - 12,
|
||||
// Width and height of the button
|
||||
+39
-20
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
package com.seibel.lod.fabric_like.mixins;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Matrix4f;
|
||||
@@ -28,6 +28,7 @@ import com.seibel.lod.core.objects.math.Mat4f;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -55,6 +56,40 @@ public class MixinWorldRenderer
|
||||
throw new NullPointerException("Null cannot be cast to non-null type.");
|
||||
}
|
||||
|
||||
|
||||
// Inject rendering at first call to renderChunkLayer
|
||||
// HEAD or RETURN
|
||||
#if PRE_MC_1_17_1
|
||||
@Inject(at = @At("RETURN"), method = "renderSky(Lcom/mojang/blaze3d/vertex/PoseStack;F)V")
|
||||
private void renderSky(PoseStack matrixStackIn, float partialTicks, CallbackInfo callback)
|
||||
{
|
||||
// get the partial ticks since renderBlockLayer doesn't
|
||||
// have access to them
|
||||
previousPartialTicks = partialTicks;
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"),
|
||||
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDD)V",
|
||||
cancellable = true)
|
||||
private void renderChunkLayer(RenderType renderType, PoseStack matrixStackIn, double xIn, double yIn, double zIn, CallbackInfo callback)
|
||||
{
|
||||
// only render before solid blocks
|
||||
if (renderType.equals(RenderType.solid()))
|
||||
{
|
||||
// get MC's current projection matrix
|
||||
float[] mcProjMatrixRaw = new float[16];
|
||||
GL15.glGetFloatv(GL15.GL_PROJECTION_MATRIX, mcProjMatrixRaw);
|
||||
Mat4f mcProjectionMatrix = new Mat4f(mcProjMatrixRaw);
|
||||
mcProjectionMatrix.transpose();
|
||||
Mat4f mcModelViewMatrix = McObjectConverter.Convert(matrixStackIn.last().pose());
|
||||
|
||||
ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
|
||||
}
|
||||
if (Config.Client.Advanced.lodOnlyMode) {
|
||||
callback.cancel();
|
||||
}
|
||||
}
|
||||
#else
|
||||
@Inject(method = "renderClouds", at = @At("HEAD"), cancellable = true)
|
||||
public void renderClouds(PoseStack poseStack, Matrix4f projectionMatrix, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) {
|
||||
// get the partial ticks since renderChunkLayer doesn't
|
||||
@@ -62,23 +97,6 @@ public class MixinWorldRenderer
|
||||
previousPartialTicks = tickDelta;
|
||||
}
|
||||
|
||||
/* Inject rendering at renderSky
|
||||
// HEAD or RETURN
|
||||
@Inject(at = @At("RETURN"),
|
||||
method = "renderSky",
|
||||
cancellable = true)
|
||||
private void renderLod(PoseStack modelViewMatrixStack, Matrix4f projectionMatrix, float f,
|
||||
#if MC_VERSION_1_18_2 Camera camera, boolean bl,#endif Runnable r, CallbackInfo callback) {
|
||||
|
||||
Mat4f mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrixStack.last().pose());
|
||||
Mat4f mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix);
|
||||
|
||||
ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
|
||||
|
||||
}*/
|
||||
|
||||
// Inject rendering at first call to renderChunkLayer
|
||||
// HEAD or RETURN
|
||||
@Inject(at = @At("HEAD"),
|
||||
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V",
|
||||
cancellable = true)
|
||||
@@ -96,4 +114,5 @@ public class MixinWorldRenderer
|
||||
callback.cancel();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.seibel.lod.fabric_like.mixins.events;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.seibel.lod.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(LightTexture.class)
|
||||
public class MixinLightmap {
|
||||
@Shadow
|
||||
@Final
|
||||
public NativeImage lightPixels;
|
||||
|
||||
@Inject(method="updateLightTexture", at=@At(
|
||||
value="INVOKE",
|
||||
target="Lnet/minecraft/client/renderer/texture/DynamicTexture;upload()V"))
|
||||
public void updateLightTexture(float f, CallbackInfo ci) {
|
||||
//ApiShared.LOGGER.info("Lightmap update");
|
||||
MinecraftRenderWrapper.INSTANCE.updateLightmap(lightPixels);
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric_like.mixins.unsafe;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
#if POST_MC_1_18_1
|
||||
|
||||
import net.minecraft.util.ThreadingDetector;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
/**
|
||||
* Why does this exist? But okay! (Will be probably removed when the experimental generator is done)
|
||||
*/
|
||||
@Mixin(ThreadingDetector.class)
|
||||
public class MixinThreadingDectector {
|
||||
@Mutable
|
||||
@Shadow
|
||||
private Semaphore lock;
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void setSemaphore(CallbackInfo ci) {
|
||||
this.lock = new Semaphore(2);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@Mixin(ServerLevel.class)
|
||||
public class MixinThreadingDectector {} //FIXME: Is there some way to make this file just not be added?
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.seibel.lod.fabric_like.mixins",
|
||||
"mixins": [
|
||||
"unsafe.MixinThreadingDectector"
|
||||
],
|
||||
"client": [
|
||||
"MixinOptionsScreen",
|
||||
"MixinWorldRenderer",
|
||||
"MixinFogRenderer",
|
||||
"MixinChunkGenerator",
|
||||
"events.MixinLightmap"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
+8
-29
@@ -1,13 +1,9 @@
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.1.0"
|
||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||
}
|
||||
|
||||
version = rootProject.mod_version+"-"+rootProject.minecraft_version+"-"+new Date().format("yyyy_MM_dd_HH_mm")
|
||||
|
||||
loom {
|
||||
accessWidenerPath.set(project(":common").file("src/main/resources/lod.accesswidener"))
|
||||
}
|
||||
|
||||
architectury {
|
||||
platformSetupLoomIde()
|
||||
fabric()
|
||||
@@ -23,11 +19,6 @@ configurations {
|
||||
modImplementation.extendsFrom addModJar
|
||||
}
|
||||
|
||||
repositories {
|
||||
// Required for ModMenu
|
||||
maven { url "https://maven.terraformersmc.com/" }
|
||||
}
|
||||
|
||||
def addMod(path, enabled) {
|
||||
if (enabled == "2")
|
||||
dependencies { modImplementation(path) }
|
||||
@@ -58,7 +49,7 @@ dependencies {
|
||||
implementation "org.joml:joml:1.10.2"
|
||||
modImplementation(fabricApi.module("fabric-rendering-data-attachment-v1", rootProject.fabric_api_version))
|
||||
modImplementation(fabricApi.module("fabric-rendering-fluids-v1", rootProject.fabric_api_version))
|
||||
|
||||
|
||||
// Lithium
|
||||
addMod("maven.modrinth:lithium:${rootProject.lithium_version}", rootProject.enable_lithium)
|
||||
|
||||
@@ -99,38 +90,26 @@ dependencies {
|
||||
shadowMe 'org.apache.commons:commons-compress:1.21'
|
||||
}
|
||||
|
||||
// This method copies the access wideners from the common project to the fabric project. And it was generated by Github Copilot
|
||||
task copyAccessWidener(type: Copy) {
|
||||
from project(":common").file("src/main/resources/lod.accesswidener")
|
||||
into file("src/generated/resources")
|
||||
}
|
||||
|
||||
task copyCoreResources(type: Copy) {
|
||||
from fileTree(project(":core").file("src/main/resources"))
|
||||
into file("build/resources/main")
|
||||
}
|
||||
|
||||
task deleteResources(type: Delete) {
|
||||
delete file("build/resources/main")
|
||||
}
|
||||
|
||||
task copyCommonResources(type: Copy) {
|
||||
from fileTree(project(":common").file("src/main/resources"))
|
||||
into file("build/resources/main")
|
||||
processResources {
|
||||
dependsOn(copyCoreResources)
|
||||
dependsOn(copyCommonResources)
|
||||
dependsOn(copyAccessWidener)
|
||||
}
|
||||
|
||||
runClient {
|
||||
dependsOn(copyCoreResources)
|
||||
dependsOn(copyCommonResources)
|
||||
dependsOn(copyAccessWidener)
|
||||
jvmArgs "-XX:-OmitStackTraceInFastThrow"
|
||||
finalizedBy(deleteResources)
|
||||
}
|
||||
|
||||
processResources {
|
||||
dependsOn(copyAccessWidener)
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
exclude "architectury.common.json"
|
||||
configurations = [project.configurations.shadowMe]
|
||||
relocate 'org.tukaani', 'shaded.tukaani'
|
||||
relocate 'org.apache.commons.compress', 'shaded.apache.commons.compress'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -31,12 +31,14 @@ import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
|
||||
import com.seibel.lod.fabric.mixins.MixinUtilBackgroudThread;
|
||||
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.keybinding.v1.KeyBindingHelper;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -77,7 +79,9 @@ public class ClientProxy
|
||||
|
||||
/* World Events */
|
||||
//ServerChunkEvents.CHUNK_LOAD.register(this::chunkLoadEvent);
|
||||
//ClientChunkEvents.CHUNK_LOAD.register(this::chunkLoadEvent);
|
||||
#if PRE_MC_1_18_1 // in 1.18+, we use mixin hook in setClientLightReady(true)
|
||||
ClientChunkEvents.CHUNK_LOAD.register(this::chunkLoadEvent);
|
||||
#endif
|
||||
|
||||
/* World Events */
|
||||
ServerWorldEvents.LOAD.register((server, level) -> this.worldLoadEvent(level));
|
||||
@@ -116,6 +120,7 @@ public class ClientProxy
|
||||
/** This is also called when a new dimension loads */
|
||||
public void worldLoadEvent(Level level)
|
||||
{
|
||||
if (Minecraft.getInstance().screen instanceof TitleScreen) return;
|
||||
if (level != null) {
|
||||
eventApi.worldLoadEvent(WorldWrapper.getWorldWrapper(level));
|
||||
}
|
||||
@@ -155,8 +160,8 @@ public class ClientProxy
|
||||
// recreate the LOD where the blocks were changed
|
||||
eventApi.blockChangeEvent(chunk, dimType);
|
||||
}
|
||||
|
||||
private static final List<Integer> KEY_TO_CHECK_FOR = List.of(GLFW.GLFW_KEY_F6, GLFW.GLFW_KEY_F8);
|
||||
|
||||
private static final int[] KEY_TO_CHECK_FOR = {GLFW.GLFW_KEY_F6, GLFW.GLFW_KEY_F8};
|
||||
|
||||
HashSet<Integer> previousKeyDown = new HashSet<Integer>();
|
||||
|
||||
@@ -169,7 +174,7 @@ public class ClientProxy
|
||||
// Note: Minecraft's InputConstants is same as GLFW Key values
|
||||
//TODO: Use mixin to hook directly into the GLFW Keyboard event in minecraft KeyboardHandler
|
||||
// Check all keys we need
|
||||
for (int i = InputConstants.KEY_A; i <= InputConstants.KEY_Z; i++) {
|
||||
for (int i = GLFW.GLFW_KEY_A; i <= GLFW.GLFW_KEY_Z; i++) {
|
||||
if (InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), i)) {
|
||||
currectKeyDown.add(i);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -47,23 +47,17 @@ import net.fabricmc.api.ClientModInitializer;
|
||||
* @author Ran
|
||||
* @version 12-1-2021
|
||||
*/
|
||||
public class Main implements ClientModInitializer
|
||||
public class Main
|
||||
{
|
||||
// This is a client mod so it should implement ClientModInitializer and in fabric.mod.json it should have "environment": "client"
|
||||
// Once it works on servers change the implement to ModInitializer and in fabric.mod.json it should be "environment": "*"
|
||||
|
||||
public static ClientProxy client_proxy;
|
||||
|
||||
|
||||
// Do if implements ClientModInitializer
|
||||
// This loads the mod before minecraft loads which causes a lot of issues
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
// no.
|
||||
}
|
||||
public static boolean isQuilt;
|
||||
|
||||
// This loads the mod after minecraft loads which doesn't causes a lot of issues
|
||||
public static void init() {
|
||||
scuffedQuiltChecker();
|
||||
LodCommonMain.initConfig();
|
||||
LodCommonMain.startup(null, false, new NetworkHandler());
|
||||
FabricDependencySetup.createInitialBindings();
|
||||
@@ -93,4 +87,13 @@ public class Main implements ClientModInitializer
|
||||
FabricDependencySetup.finishBinding();
|
||||
ApiShared.LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION);
|
||||
}
|
||||
|
||||
public static void scuffedQuiltChecker() {
|
||||
try {
|
||||
Class.forName("org.quiltmc.loader.api.QuiltLoader");
|
||||
isQuilt = true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
isQuilt = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
|
||||
import com.seibel.lod.fabric.Main;
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraft.client.renderer.FogRenderer.FogMode;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.material.FogType;
|
||||
|
||||
@Mixin(FogRenderer.class)
|
||||
public class MixinFogRenderer {
|
||||
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
|
||||
// Using this instead of Float.MAX_VALUE because Sodium don't like it.
|
||||
private static final float A_REALLY_REALLY_BIG_VALUE = 420694206942069.F;
|
||||
private static final float A_EVEN_LARGER_VALUE = 42069420694206942069.F;
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "setupFog(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/FogRenderer$FogMode;FZ)V")
|
||||
private static void disableSetupFog(Camera camera, FogMode fogMode, float f, boolean bl, CallbackInfo callback) {
|
||||
FogType fogTypes = camera.getFluidInCamera();
|
||||
Entity entity = camera.getEntity();
|
||||
boolean isUnderWater = (entity instanceof LivingEntity) && ((LivingEntity)entity).hasEffect(MobEffects.BLINDNESS);
|
||||
if (!isUnderWater) {
|
||||
if (fogMode == FogMode.FOG_TERRAIN && fogTypes == FogType.NONE && CONFIG.client().graphics().fogQuality().getDisableVanillaFog()) {
|
||||
RenderSystem.setShaderFogStart(A_REALLY_REALLY_BIG_VALUE);
|
||||
RenderSystem.setShaderFogEnd(A_EVEN_LARGER_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
|
||||
import com.seibel.lod.fabric.Main;
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@@ -16,7 +35,17 @@ import net.minecraft.Util;
|
||||
@Mixin(Util.class)
|
||||
public class MixinUtilBackgroudThread
|
||||
{
|
||||
|
||||
@Inject(method = "backgroundExecutor", at = @At("HEAD"), cancellable = true)
|
||||
private static void overrideUtil$backgroundExecutor(CallbackInfoReturnable<ExecutorService> ci)
|
||||
{
|
||||
if (ClientProxy.isGenerationThreadChecker != null && ClientProxy.isGenerationThreadChecker.get())
|
||||
{
|
||||
//ApiShared.LOGGER.info("util backgroundExecutor triggered");
|
||||
ci.setReturnValue(new DummyRunExecutorService());
|
||||
}
|
||||
}
|
||||
|
||||
#if POST_MC_1_17_1
|
||||
@Inject(method = "wrapThreadWithTaskName(Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Runnable;",
|
||||
at = @At("HEAD"), cancellable = true)
|
||||
private static void overrideUtil$wrapThreadWithTaskName(String string, Runnable r, CallbackInfoReturnable<Runnable> ci)
|
||||
@@ -27,6 +56,8 @@ public class MixinUtilBackgroudThread
|
||||
ci.setReturnValue(r);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if POST_MC_1_18_1
|
||||
@Inject(method = "wrapThreadWithTaskName(Ljava/lang/String;Ljava/util/function/Supplier;)Ljava/util/function/Supplier;",
|
||||
at = @At("HEAD"), cancellable = true)
|
||||
private static void overrideUtil$wrapThreadWithTaskNameForSupplier(String string, Supplier<?> r, CallbackInfoReturnable<Supplier<?>> ci)
|
||||
@@ -37,14 +68,6 @@ public class MixinUtilBackgroudThread
|
||||
ci.setReturnValue(r);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "backgroundExecutor", at = @At("HEAD"), cancellable = true)
|
||||
private static void overrideUtil$backgroundExecutor(CallbackInfoReturnable<ExecutorService> ci)
|
||||
{
|
||||
if (ClientProxy.isGenerationThreadChecker != null && ClientProxy.isGenerationThreadChecker.get())
|
||||
{
|
||||
//ApiShared.LOGGER.info("util backgroundExecutor triggered");
|
||||
ci.setReturnValue(new DummyRunExecutorService());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins.events;
|
||||
|
||||
import com.seibel.lod.fabric.Main;
|
||||
|
||||
@@ -1,13 +1,34 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins.events;
|
||||
|
||||
import com.seibel.lod.fabric.Main;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
#if MC_VERSION_1_18_2
|
||||
#if POST_MC_1_18_2
|
||||
import net.minecraft.core.Holder;
|
||||
#endif
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -20,27 +41,26 @@ import java.util.function.Supplier;
|
||||
/**
|
||||
* This class is used for world loading events
|
||||
* @author Ran
|
||||
*
|
||||
* FIXME: Why does forge not have the 1.18+ onChunkLightReady mixin?
|
||||
*/
|
||||
|
||||
@Mixin(ClientLevel.class)
|
||||
public class MixinClientLevel {
|
||||
#if MC_VERSION_1_18_2
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void loadWorldEvent(ClientPacketListener clientPacketListener, ClientLevel.ClientLevelData clientLevelData, ResourceKey resourceKey, Holder holder, int i, int j, Supplier supplier, LevelRenderer levelRenderer, boolean bl, long l, CallbackInfo ci) {
|
||||
private void loadWorldEvent(ClientPacketListener clientPacketListener, ClientLevel.ClientLevelData clientLevelData, ResourceKey resourceKey,
|
||||
#if POST_MC_1_18_2 Holder holder, #else DimensionType dimensionType, #endif int i,
|
||||
#if POST_MC_1_18_1 int j, #endif Supplier supplier, LevelRenderer levelRenderer, boolean bl, long l, CallbackInfo ci) {
|
||||
Main.client_proxy.worldLoadEvent((ClientLevel) (Object) this);
|
||||
}
|
||||
#elif MC_VERSION_1_18_1
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void loadWorldEvent(ClientPacketListener clientPacketListener, ClientLevel.ClientLevelData clientLevelData, ResourceKey resourceKey, DimensionType dimensionType, int i, int j, Supplier supplier, LevelRenderer levelRenderer, boolean bl, long l, CallbackInfo ci) {
|
||||
Main.client_proxy.worldLoadEvent((ClientLevel) (Object) this);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if POST_MC_1_18_1
|
||||
@Inject(method = "setLightReady", at = @At("HEAD"))
|
||||
private void onChunkLightReady(int x, int z, CallbackInfo ci) {
|
||||
ClientLevel l = (ClientLevel) (Object) this;
|
||||
LevelChunk chunk = l.getChunkSource().getChunk(x, z, false);
|
||||
if (chunk!=null && !chunk.isClientLightReady())
|
||||
if (chunk!=null&& !chunk.isClientLightReady())
|
||||
Main.client_proxy.chunkLoadEvent(l, chunk);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins.events;
|
||||
|
||||
import com.seibel.lod.fabric.Main;
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins.events;
|
||||
|
||||
import com.seibel.lod.fabric.Main;
|
||||
@@ -14,13 +33,19 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
*/
|
||||
@Mixin(ServerLevel.class)
|
||||
public class MixinServerLevel {
|
||||
#if PRE_MC_1_17_1
|
||||
@Inject(method = "save", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;save(Z)V", shift = At.Shift.AFTER))
|
||||
private void saveWorldEvent(ProgressListener progressListener, boolean bl, boolean bl2, CallbackInfo ci) {
|
||||
Main.client_proxy.worldSaveEvent();
|
||||
}
|
||||
#else
|
||||
@Inject(method = "save", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/entity/PersistentEntitySectionManager;saveAll()V", shift = At.Shift.AFTER))
|
||||
private void saveWorldEvent_sA(ProgressListener progressListener, boolean bl, boolean bl2, CallbackInfo ci) {
|
||||
Main.client_proxy.worldSaveEvent();
|
||||
}
|
||||
|
||||
@Inject(method = "save", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/entity/PersistentEntitySectionManager;autoSave()V", shift = At.Shift.AFTER))
|
||||
private void saveWorldEvent_aS(ProgressListener progressListener, boolean bl, boolean bl2, CallbackInfo ci) {
|
||||
Main.client_proxy.worldSaveEvent();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.seibel.lod.fabric.mixins.unsafe;
|
||||
|
||||
import net.minecraft.util.ThreadingDetector;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
/**
|
||||
* Why does this exist? But okay! (Will be probably removed when the experimental generator is done)
|
||||
*/
|
||||
@Mixin(ThreadingDetector.class)
|
||||
public class MixinThreadingDectector {
|
||||
@Mutable
|
||||
@Shadow
|
||||
private Semaphore lock;
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void setSemaphore(CallbackInfo ci) {
|
||||
this.lock = new Semaphore(2);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.networking;
|
||||
|
||||
import com.seibel.lod.common.networking.NetworkInterface;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.seibel.lod.fabric.quilt;
|
||||
|
||||
/**
|
||||
* Used to call classes that are in Quilt
|
||||
* @author Ran
|
||||
*/
|
||||
public class QuiltUtils {
|
||||
public static boolean isModLoaded(String modId) {
|
||||
try {
|
||||
return (boolean) Class.forName("org.quiltmc.loader.api.QuiltLoader").getDeclaredMethod("isModLoaded", String.class).invoke(null, modId);
|
||||
} catch (Exception ignored) { }
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.wrappers;
|
||||
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.wrappers.config;
|
||||
|
||||
import com.seibel.lod.common.wrappers.config.ConfigGui;
|
||||
|
||||
@@ -1,6 +1,27 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.wrappers.modAccessor;
|
||||
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
import com.seibel.lod.fabric.Main;
|
||||
import com.seibel.lod.fabric.quilt.QuiltUtils;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
public class ModChecker implements IModChecker {
|
||||
@@ -8,6 +29,10 @@ public class ModChecker implements IModChecker {
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String modid) {
|
||||
return FabricLoader.getInstance().isModLoaded(modid);
|
||||
if (Main.isQuilt) {
|
||||
return QuiltUtils.isModLoaded(modid);
|
||||
} else {
|
||||
return FabricLoader.getInstance().isModLoaded(modid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.wrappers.modAccessor;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
+84
-9
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.wrappers.modAccessor;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -6,37 +25,93 @@ import java.util.stream.Collectors;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
|
||||
|
||||
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
#if PRE_MC_1_17_1
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
#else
|
||||
import net.minecraft.world.level.LevelHeightAccessor;
|
||||
#endif
|
||||
|
||||
public class SodiumAccessor implements ISodiumAccessor {
|
||||
IWrapperFactory factory = SingletonHandler.get(IWrapperFactory.class);
|
||||
private final IWrapperFactory factory = SingletonHandler.get(IWrapperFactory.class);
|
||||
private final IMinecraftRenderWrapper MC_RENDER = SingletonHandler.get(IMinecraftRenderWrapper.class);
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
return "Sodium-Fabric-1.18.X";
|
||||
return "Sodium-Fabric";
|
||||
}
|
||||
|
||||
#if POST_MC_1_17_1
|
||||
@Override
|
||||
public HashSet<AbstractChunkPosWrapper> getNormalRenderedChunks() {
|
||||
SodiumWorldRenderer renderer = SodiumWorldRenderer.instance();
|
||||
LevelHeightAccessor height = Minecraft.getInstance().level;
|
||||
LevelHeightAccessor height = Minecraft.getInstance().level;
|
||||
|
||||
#if POST_MC_1_18_1
|
||||
// 0b11 = Lighted chunk & loaded chunk
|
||||
return renderer.getChunkTracker().getChunks(0b00).filter(
|
||||
(long l) -> {
|
||||
return true;
|
||||
//for (int i = height.getMinSection(); i<height.getMaxSection(); i++) {
|
||||
// SectionPos p = SectionPos.of(new ChunkPos(l), i);
|
||||
// if (renderer.isBoxVisible(p.minBlockX()+1, p.minBlockY()+1, p.minBlockZ()+1,
|
||||
// p.maxBlockX()-1, p.maxBlockY()-1, p.maxBlockZ()-1)) return true;
|
||||
//}
|
||||
//return false;
|
||||
}).mapToObj((long l) -> {
|
||||
return (AbstractChunkPosWrapper)factory.createChunkPos(l);
|
||||
}).collect(Collectors.toCollection(HashSet::new));
|
||||
#else
|
||||
// TODO: Maybe use a mixin to make this more efficient, and maybe ignore changes behind the camera
|
||||
return MC_RENDER.getMaximumRenderedChunks().stream().filter((AbstractChunkPosWrapper chunk) -> {
|
||||
return (renderer.isBoxVisible(
|
||||
chunk.getMinBlockX()+1, height.getMinBuildHeight()+1, chunk.getMinBlockZ()+1,
|
||||
chunk.getMinBlockX()+15, height.getMaxBuildHeight()-1, chunk.getMinBlockZ()+15));
|
||||
}).collect(Collectors.toCollection(HashSet::new));
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
@Override
|
||||
public HashSet<AbstractChunkPosWrapper> getNormalRenderedChunks() {
|
||||
SodiumWorldRenderer renderer = SodiumWorldRenderer.getInstance();
|
||||
LevelAccessor height = Minecraft.getInstance().level;
|
||||
// TODO: Maybe use a mixin to make this more efficient
|
||||
return MC_RENDER.getMaximumRenderedChunks().stream().filter((AbstractChunkPosWrapper chunk) -> {
|
||||
FakeChunkEntity AABB = new FakeChunkEntity(chunk.getX(), chunk.getZ(), height.getMaxBuildHeight());
|
||||
return (renderer.isEntityVisible(AABB));
|
||||
}).collect(Collectors.toCollection(HashSet::new));
|
||||
}
|
||||
|
||||
private static class FakeChunkEntity extends Entity {
|
||||
public int cx;
|
||||
public int cz;
|
||||
public int my;
|
||||
public FakeChunkEntity(int chunkX, int chunkZ, int maxHeight) {
|
||||
super(EntityType.AREA_EFFECT_CLOUD, null);
|
||||
cx = chunkX;
|
||||
cz = chunkZ;
|
||||
my = maxHeight;
|
||||
}
|
||||
@Override
|
||||
public AABB getBoundingBoxForCulling() {
|
||||
return new AABB(cx*16+1, 1, cz*16+1,
|
||||
cx*16+15, my-1, cz*16+15);
|
||||
}
|
||||
@Override
|
||||
protected void defineSynchedData() {}
|
||||
@Override
|
||||
protected void readAdditionalSaveData(CompoundTag paramCompoundTag) {}
|
||||
@Override
|
||||
protected void addAdditionalSaveData(CompoundTag paramCompoundTag) {}
|
||||
@Override
|
||||
public Packet<?> getAddEntityPacket() {
|
||||
throw new UnsupportedOperationException("This is a FAKE CHUNK ENTITY... For tricking the Sodium to check a AABB.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
+19
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.wrappers.modAccessor;
|
||||
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IStarlightAccessor;
|
||||
|
||||
@@ -2,17 +2,12 @@
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.seibel.lod.fabric.mixins",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"unsafe.MixinThreadingDectector",
|
||||
"MixinUtilBackgroudThread",
|
||||
"events.MixinServerLevel"
|
||||
],
|
||||
"client": [
|
||||
"MixinMinecraft",
|
||||
"MixinOptionsScreen",
|
||||
"MixinWorldRenderer",
|
||||
"MixinFogRenderer",
|
||||
"events.MixinClientLevel",
|
||||
"events.MixinMinecraft",
|
||||
"events.MixinBlockUpdate"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
"name": "${mod_name}",
|
||||
"description": "${description}",
|
||||
"authors": ["${authors}"],
|
||||
"authors": $authors,
|
||||
|
||||
"contact": {
|
||||
"homepage": "${homepage}",
|
||||
@@ -18,16 +18,14 @@
|
||||
|
||||
"environment": "client",
|
||||
"entrypoints": {
|
||||
"client": [
|
||||
"com.seibel.lod.fabric.Main"
|
||||
],
|
||||
"modmenu": [
|
||||
"com.seibel.lod.fabric.wrappers.config.ModMenuIntegration"
|
||||
]
|
||||
},
|
||||
|
||||
"mixins": [
|
||||
"fabric.lod.mixins.json"
|
||||
"fabric.lod.mixins.json",
|
||||
"fabric-like.lod.mixins.json"
|
||||
],
|
||||
|
||||
"accessWidener" : "lod.accesswidener",
|
||||
@@ -36,12 +34,9 @@
|
||||
"fabric-lifecycle-events-v1": "*",
|
||||
"fabric-key-binding-api-v1": "*",
|
||||
"fabric-networking-api-v1": "*",
|
||||
"minecraft": "${minecraft_version}",
|
||||
"minecraft": $compatible_minecraft_versions,
|
||||
"java": ">=${java_version}"
|
||||
},
|
||||
"suggests": {
|
||||
"another-mod": "*"
|
||||
},
|
||||
|
||||
"custom": {
|
||||
"modmenu": {
|
||||
|
||||
+5
-13
@@ -1,12 +1,10 @@
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.1.0"
|
||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||
}
|
||||
|
||||
version = rootProject.mod_version+"-"+rootProject.minecraft_version+"-"+new Date().format("yyyy_MM_dd_HH_mm")
|
||||
|
||||
loom {
|
||||
accessWidenerPath.set(project(":common").file("src/main/resources/lod.accesswidener"))
|
||||
|
||||
forge {
|
||||
convertAccessWideners.set(true)
|
||||
extraAccessWideners.add("lod.accesswidener")
|
||||
@@ -40,6 +38,8 @@ dependencies {
|
||||
addMod("curse.maven:starlight-forge-526854:${rootProject.starlight_version_forge}", rootProject.enable_starlight_forge)
|
||||
annotationProcessor "org.spongepowered:mixin:0.8.4:processor"
|
||||
|
||||
addMod("curse.maven:TerraForged-363820:${rootProject.terraforged_version}", rootProject.enable_terraforged)
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowMe(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
|
||||
|
||||
@@ -56,22 +56,14 @@ dependencies {
|
||||
shadowMe 'org.apache.commons:commons-compress:1.21'
|
||||
}
|
||||
|
||||
task copyCoreResources(type: Copy) {
|
||||
from fileTree(project(":core").file("src/main/resources"))
|
||||
into file("build/resources/main")
|
||||
}
|
||||
|
||||
task copyCommonResources(type: Copy) {
|
||||
from fileTree(project(":common").file("src/main/resources"))
|
||||
into file("build/resources/main")
|
||||
}
|
||||
|
||||
processResources {
|
||||
dependsOn(copyAccessWidener)
|
||||
dependsOn(copyCoreResources)
|
||||
dependsOn(copyCommonResources)
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
exclude "architectury.common.json"
|
||||
dependencies {
|
||||
exclude(dependency("net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"))
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,6 +23,7 @@ import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.api.EventApi;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
@@ -76,6 +77,7 @@ public class ForgeClientProxy
|
||||
@SubscribeEvent
|
||||
public void worldLoadEvent(WorldEvent.Load event)
|
||||
{
|
||||
if (Minecraft.getInstance().screen instanceof TitleScreen) return;
|
||||
if (event.getWorld() != null) {
|
||||
eventApi.worldLoadEvent(WorldWrapper.getWorldWrapper(event.getWorld()));
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -35,10 +35,11 @@ import com.seibel.lod.forge.wrappers.modAccessor.OptifineAccessor;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.ColorResolver;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.ConfigGuiHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -46,6 +47,13 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
#if PRE_MC_1_17_1
|
||||
import net.minecraftforge.fml.ExtensionPoint;
|
||||
#elif MC_1_17_1
|
||||
import net.minecraftforge.fmlclient.ConfigGuiHandler;
|
||||
#else // 1.18+
|
||||
import net.minecraftforge.client.ConfigGuiHandler;
|
||||
#endif
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -86,13 +94,15 @@ public class ForgeMain implements LodForgeMethodCaller
|
||||
ModAccessorHandler.bind(IOptifineAccessor.class, new OptifineAccessor());
|
||||
}
|
||||
|
||||
ModAccessorHandler.finishBinding();
|
||||
|
||||
|
||||
ModAccessorHandler.finishBinding();
|
||||
|
||||
#if PRE_MC_1_17_1
|
||||
ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY,
|
||||
() -> (client, parent) -> ConfigGui.getScreen(parent, ""));
|
||||
#else
|
||||
ModLoadingContext.get().registerExtensionPoint(ConfigGuiHandler.ConfigGuiFactory.class,
|
||||
() -> new ConfigGuiHandler.ConfigGuiFactory((client, parent) -> ConfigGui.getScreen(parent, "")));
|
||||
#endif
|
||||
forgeClientProxy = new ForgeClientProxy();
|
||||
MinecraftForge.EVENT_BUS.register(forgeClientProxy);
|
||||
}
|
||||
@@ -102,4 +112,14 @@ public class ForgeMain implements LodForgeMethodCaller
|
||||
public List<BakedQuad> getQuads(MinecraftClientWrapper mc, Block block, BlockState blockState, Direction direction, Random random) {
|
||||
return mc.getModelManager().getBlockModelShaper().getBlockModel(block.defaultBlockState()).getQuads(blockState, direction, random, dataMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int colorResolverGetColor(ColorResolver resolver, Biome biome, double x, double z) {
|
||||
#if MC_1_17_1
|
||||
return resolver.m_130045_(biome, x, z);
|
||||
#else
|
||||
return resolver.getColor(biome, x, z);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.forge.fabric.api.networking.v1;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ChunkMap;
|
||||
import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.ServerPlayerConnection;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.chunk.ChunkSource;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import com.seibel.lod.forge.mixins.fabric.mixin.networking.accessor.EntityTrackerAccessor;
|
||||
import com.seibel.lod.forge.mixins.fabric.mixin.networking.accessor.ThreadedAnvilChunkStorageAccessor;
|
||||
|
||||
/**
|
||||
* For example, a block entity may use the methods in this class to send a packet to all clients which can see the block entity in order notify clients about a change.
|
||||
*
|
||||
* <p>The word "tracking" means that an entity/chunk on the server is known to a player's client (within in view distance) and the (block) entity should notify tracking clients of changes.
|
||||
*
|
||||
* <p>These methods should only be called on the server thread and only be used on logical a server.
|
||||
*/
|
||||
public final class PlayerLookup {
|
||||
/**
|
||||
* Gets all the players on the minecraft server.
|
||||
*
|
||||
* <p>The returned collection is immutable.
|
||||
*
|
||||
* @param server the server
|
||||
* @return all players on the server
|
||||
*/
|
||||
public static Collection<ServerPlayer> all(MinecraftServer server) {
|
||||
Objects.requireNonNull(server, "The server cannot be null");
|
||||
|
||||
// return an immutable collection to guard against accidental removals.
|
||||
if (server.getPlayerList() != null) {
|
||||
return Collections.unmodifiableCollection(server.getPlayerList().getPlayers());
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the players in a server world.
|
||||
*
|
||||
* <p>The returned collection is immutable.
|
||||
*
|
||||
* @param world the server world
|
||||
* @return the players in the server world
|
||||
*/
|
||||
public static Collection<ServerPlayer> world(ServerLevel world) {
|
||||
Objects.requireNonNull(world, "The world cannot be null");
|
||||
|
||||
// return an immutable collection to guard against accidental removals.
|
||||
return Collections.unmodifiableCollection(world.players());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all players tracking a chunk in a server world.
|
||||
*
|
||||
* @param world the server world
|
||||
* @param pos the chunk in question
|
||||
* @return the players tracking the chunk
|
||||
*/
|
||||
public static Collection<ServerPlayer> tracking(ServerLevel world, ChunkPos pos) {
|
||||
Objects.requireNonNull(world, "The world cannot be null");
|
||||
Objects.requireNonNull(pos, "The chunk pos cannot be null");
|
||||
|
||||
return world.getChunkSource().chunkMap.getPlayers(pos, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all players tracking an entity in a server world.
|
||||
*
|
||||
* <p>The returned collection is immutable.
|
||||
*
|
||||
* <p><b>Warning</b>: If the provided entity is a player, it is not
|
||||
* guaranteed by the contract that said player is included in the
|
||||
* resulting stream.
|
||||
*
|
||||
* @param entity the entity being tracked
|
||||
* @return the players tracking the entity
|
||||
* @throws IllegalArgumentException if the entity is not in a server world
|
||||
*/
|
||||
public static Collection<ServerPlayer> tracking(Entity entity) {
|
||||
Objects.requireNonNull(entity, "Entity cannot be null");
|
||||
ChunkSource manager = entity.level.getChunkSource();
|
||||
|
||||
if (manager instanceof ServerChunkCache) {
|
||||
ChunkMap storage = ((ServerChunkCache) manager).chunkMap;
|
||||
EntityTrackerAccessor tracker = ((ThreadedAnvilChunkStorageAccessor) storage).getEntityMap().get(entity.getId());
|
||||
|
||||
// return an immutable collection to guard against accidental removals.
|
||||
if (tracker != null) {
|
||||
return Collections.unmodifiableCollection(tracker.getPlayersTracking()
|
||||
.stream().map(ServerPlayerConnection::getPlayer).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Only supported on server worlds!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all players tracking a block entity in a server world.
|
||||
*
|
||||
* @param blockEntity the block entity
|
||||
* @return the players tracking the block position
|
||||
* @throws IllegalArgumentException if the block entity is not in a server world
|
||||
*/
|
||||
public static Collection<ServerPlayer> tracking(BlockEntity blockEntity) {
|
||||
Objects.requireNonNull(blockEntity, "BlockEntity cannot be null");
|
||||
|
||||
//noinspection ConstantConditions - IJ intrinsics don't know hasWorld == true will result in no null
|
||||
if (!blockEntity.hasLevel() || blockEntity.getLevel().isClientSide()) {
|
||||
throw new IllegalArgumentException("Only supported on server worlds!");
|
||||
}
|
||||
|
||||
return tracking((ServerLevel) blockEntity.getLevel(), blockEntity.getBlockPos());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all players tracking a block position in a server world.
|
||||
*
|
||||
* @param world the server world
|
||||
* @param pos the block position
|
||||
* @return the players tracking the block position
|
||||
*/
|
||||
public static Collection<ServerPlayer> tracking(ServerLevel world, BlockPos pos) {
|
||||
Objects.requireNonNull(pos, "BlockPos cannot be null");
|
||||
|
||||
return tracking(world, new ChunkPos(pos));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all players around a position in a world.
|
||||
*
|
||||
* <p>The distance check is done in the three-dimensional space instead of in the horizontal plane.
|
||||
*
|
||||
* @param world the world
|
||||
* @param pos the position
|
||||
* @param radius the maximum distance from the position in blocks
|
||||
* @return the players around the position
|
||||
*/
|
||||
public static Collection<ServerPlayer> around(ServerLevel world, Vec3 pos, double radius) {
|
||||
double radiusSq = radius * radius;
|
||||
|
||||
return world(world)
|
||||
.stream()
|
||||
.filter((p) -> p.distanceToSqr(pos) <= radiusSq)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all players around a position in a world.
|
||||
*
|
||||
* <p>The distance check is done in the three-dimensional space instead of in the horizontal plane.
|
||||
*
|
||||
* @param world the world
|
||||
* @param pos the position (can be a block pos)
|
||||
* @param radius the maximum distance from the position in blocks
|
||||
* @return the players around the position
|
||||
*/
|
||||
public static Collection<ServerPlayer> around(ServerLevel world, Vec3i pos, double radius) {
|
||||
double radiusSq = radius * radius;
|
||||
|
||||
return world(world)
|
||||
.stream()
|
||||
.filter((p) -> p.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) <= radiusSq)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private PlayerLookup() {
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -24,15 +24,15 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import com.seibel.lod.forge.fabric.api.event.Event;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
class ArrayBackedEvent<T> extends Event<T> {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger("fabric-api-base");
|
||||
static final Logger LOGGER = LogManager.getLogger("fabric-api-base");
|
||||
|
||||
private final Function<T[], T> invokerFactory;
|
||||
private final Object lock = new Object();
|
||||
|
||||
+3
-3
@@ -26,8 +26,8 @@ import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -47,7 +47,7 @@ public abstract class AbstractNetworkAddon<H> {
|
||||
|
||||
protected AbstractNetworkAddon(GlobalReceiverRegistry<H> receiver, String description) {
|
||||
this.receiver = receiver;
|
||||
this.logger = LoggerFactory.getLogger(description);
|
||||
this.logger = LogManager.getLogger(description);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import com.seibel.lod.forge.fabric.api.networking.v1.PacketByteBufs;
|
||||
import com.seibel.lod.forge.fabric.api.networking.v1.ServerLoginConnectionEvents;
|
||||
import com.seibel.lod.forge.fabric.api.networking.v1.ServerLoginNetworking;
|
||||
@@ -31,7 +31,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public final class NetworkingImpl {
|
||||
public static final String MOD_ID = "fabric-networking-api-v1";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
|
||||
/**
|
||||
* Id of packet used to register supported channels.
|
||||
*/
|
||||
|
||||
+4
@@ -51,7 +51,11 @@ public final class ClientLoginNetworkAddon extends AbstractNetworkAddon<ClientLo
|
||||
}
|
||||
|
||||
public boolean handlePacket(ClientboundCustomQueryPacket packet) {
|
||||
#if MC_1_16_5
|
||||
return handlePacket(packet.getTransactionId(), packet.getName(), packet.getInternalData());
|
||||
#else
|
||||
return handlePacket(packet.getTransactionId(), packet.getIdentifier(), packet.getData());
|
||||
#endif
|
||||
}
|
||||
|
||||
private boolean handlePacket(int queryId, ResourceLocation channelName, FriendlyByteBuf originalBuf) {
|
||||
|
||||
+16
-2
@@ -26,6 +26,7 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import com.seibel.lod.forge.mixins.fabric.mixin.networking.accessor.ClientboundCustomQueryPacketAccessor;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import net.minecraft.network.Connection;
|
||||
@@ -112,7 +113,11 @@ public final class ServerLoginNetworkAddon extends AbstractNetworkAddon<ServerLo
|
||||
// Compression is not needed for local transport
|
||||
if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) {
|
||||
this.connection.send(new ClientboundLoginCompressionPacket(this.server.getCompressionThreshold()), (channelFuture) ->
|
||||
#if MC_1_16_5
|
||||
this.connection.setupCompression(this.server.getCompressionThreshold())
|
||||
#else
|
||||
this.connection.setupCompression(this.server.getCompressionThreshold(), true)
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -159,8 +164,17 @@ public final class ServerLoginNetworkAddon extends AbstractNetworkAddon<ServerLo
|
||||
@Override
|
||||
public Packet<?> createPacket(ResourceLocation channelName, FriendlyByteBuf buf) {
|
||||
int queryId = this.queryIdFactory.nextId();
|
||||
ClientboundCustomQueryPacket ret;
|
||||
|
||||
ClientboundCustomQueryPacket ret = new ClientboundCustomQueryPacket(queryId, channelName, buf);
|
||||
#if MC_1_16_5
|
||||
ret = new ClientboundCustomQueryPacket();
|
||||
ClientboundCustomQueryPacketAccessor access = (ClientboundCustomQueryPacketAccessor) ret;
|
||||
access.setIdentifier(channelName);
|
||||
access.setTransactionId(queryId);
|
||||
access.setData(buf);
|
||||
#else
|
||||
ret = new ClientboundCustomQueryPacket(queryId, channelName, buf);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -179,7 +193,7 @@ public final class ServerLoginNetworkAddon extends AbstractNetworkAddon<ServerLo
|
||||
}
|
||||
|
||||
public void registerOutgoingPacket(ClientboundCustomQueryPacket packet) {
|
||||
this.channels.put(packet.getTransactionId(), packet.getIdentifier());
|
||||
this.channels.put(packet.getTransactionId(), #if MC_1_16_5 packet.getName() #else packet.getIdentifier() #endif);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user