Compare commits
137 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fc516a20d5 | |||
| 791c2c3426 | |||
| b00079897a | |||
| 37b73e1d5c | |||
| 4bd1136713 | |||
| ef98dbd5fd | |||
| 5df0a60b06 | |||
| 9feb20eff8 | |||
| c9267d61a8 | |||
| a29e225a80 | |||
| ae0f3c2b3b | |||
| 852ea75449 | |||
| ab6a5dad2b | |||
| 1a1eaca280 | |||
| 0272f8c57f | |||
| cf09358710 | |||
| b5d833fa3d | |||
| 329dbe9585 | |||
| c7ae7f155e | |||
| 5f7dbb8662 | |||
| ee21548151 | |||
| ca00125960 | |||
| 4067264e72 | |||
| 9c2d243ad4 | |||
| de9d8b0d2e | |||
| 67f4615b34 | |||
| cd7a130ee4 | |||
| 4d17f7aecf | |||
| a59e7500ab | |||
| 40040294e7 | |||
| 783e61ec3d | |||
| e09db5d7df | |||
| 91f9ef3f4b | |||
| d52a3abb14 | |||
| 16370b0b6e | |||
| bfa60b48cf | |||
| 50518bfe21 | |||
| 80e4467829 | |||
| 396315bd05 | |||
| 7a0fec2c2f | |||
| 4afaaa7b12 | |||
| b057041467 | |||
| 33e6ce6376 | |||
| 118ef39c30 | |||
| 1013e1c824 | |||
| b0e924c7fe | |||
| 1777acd1d4 | |||
| 8276a862f8 | |||
| 4329acf91d | |||
| 72f83b40f7 | |||
| a33eb30a53 | |||
| d3e96f50a8 | |||
| 3aefeb98b4 | |||
| 3553ff8e60 | |||
| 945a2c0c5a | |||
| 8c7974e216 | |||
| 37756cd759 | |||
| c60cc4f013 | |||
| 87cce2e33c | |||
| 40ada9c186 | |||
| 55fb458266 | |||
| 79d2466fa2 | |||
| d750e489df | |||
| a206e49b2b | |||
| 0b691ebcd5 | |||
| 3c35c52803 | |||
| 0ed4964ee5 | |||
| b7cf7b61c8 | |||
| 54b0ccfce6 | |||
| 050d00b628 | |||
| 2733201ac3 | |||
| 26bf03205c | |||
| 628d57d216 | |||
| 58ed8259f2 | |||
| 062ed5bcc8 | |||
| 539d152caa | |||
| a1af4335e0 | |||
| e68b112020 | |||
| fab6d187ca | |||
| 0daa00cec2 | |||
| f3036850ce | |||
| 51c8b47bba | |||
| 89efd53d61 | |||
| 7667f51cf3 | |||
| 61eaa5a734 | |||
| 1d589d1a62 | |||
| 03b1eeb77e | |||
| 8446df72f7 | |||
| c07397e9c0 | |||
| 29a92aeb93 | |||
| 8467782b80 | |||
| c8dbb21ea4 | |||
| 63e1c12564 | |||
| 52f58150da | |||
| d1d642a7bb | |||
| 8e45358aad | |||
| a959c7220b | |||
| e06425c5eb | |||
| 66ce258fe1 | |||
| 181881a661 | |||
| af0d8d1d2f | |||
| 6c68e94b96 | |||
| 93313a5c50 | |||
| 0527baa708 | |||
| ce1fbde937 | |||
| 764abdac45 | |||
| b42d3d8f74 | |||
| cd67a773c5 | |||
| 6d7bade7ca | |||
| dea8d4498a | |||
| 2969916f34 | |||
| 8785224c51 | |||
| 605f02a655 | |||
| 8099d37c14 | |||
| dd4dbefe9a | |||
| 52a15fd349 | |||
| 3b3be6aed4 | |||
| aeb7d6d0f9 | |||
| 5336dbafec | |||
| 6079cb4830 | |||
| 50ff174104 | |||
| b77ef89df6 | |||
| a701dd29a9 | |||
| ab36fdd545 | |||
| f87afb34f4 | |||
| 053917d3d7 | |||
| 063ba01970 | |||
| 72a888f3ff | |||
| 0bd36bff1d | |||
| 2bf125b7ac | |||
| ba3cf8fd56 | |||
| 951f2a4ee7 | |||
| d55b1bb3c2 | |||
| 275ecb78c3 | |||
| 64ac0d6017 | |||
| 29381bce7b | |||
| e5536de44f |
@@ -1,19 +0,0 @@
|
|||||||
**/.git
|
|
||||||
**/.gitlab
|
|
||||||
**/.cache
|
|
||||||
|
|
||||||
buildAllJars
|
|
||||||
|
|
||||||
**/_Misc Files
|
|
||||||
*.bat
|
|
||||||
*.md
|
|
||||||
*.sh
|
|
||||||
*.txt
|
|
||||||
|
|
||||||
coreSubProjects/*.md
|
|
||||||
coreSubProjects/*.txt
|
|
||||||
|
|
||||||
**/.gitignore
|
|
||||||
**/.gitattributes
|
|
||||||
**/.gitlab-cy.yml
|
|
||||||
**/.gitmodules
|
|
||||||
@@ -25,6 +25,8 @@ hs_err_pid*
|
|||||||
Merged/
|
Merged/
|
||||||
# Folder created by the buildAll scripts
|
# Folder created by the buildAll scripts
|
||||||
buildAllJars/
|
buildAllJars/
|
||||||
|
_buildAllJars/
|
||||||
|
_buildWorkers/
|
||||||
|
|
||||||
relocate_natives/.venv/
|
relocate_natives/.venv/
|
||||||
relocate_natives/__pycache__/
|
relocate_natives/__pycache__/
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ build:
|
|||||||
parallel:
|
parallel:
|
||||||
matrix:
|
matrix:
|
||||||
- MC_VER: [
|
- MC_VER: [
|
||||||
"1.26.1",
|
"26.1.2",
|
||||||
"1.21.11", "1.21.10", "1.21.9", "1.21.8", "1.21.6", "1.21.5", "1.21.4", "1.21.3", "1.21.1",
|
"1.21.11", "1.21.10", "1.21.9", "1.21.8", "1.21.6", "1.21.5", "1.21.4", "1.21.3", "1.21.1",
|
||||||
"1.20.6", "1.20.4", "1.20.2", "1.20.1",
|
"1.20.6", "1.20.4", "1.20.2", "1.20.1",
|
||||||
"1.19.4", "1.19.2",
|
"1.19.4", "1.19.2",
|
||||||
|
|||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
FROM eclipse-temurin:25-jdk
|
|
||||||
|
|
||||||
WORKDIR /home/build/
|
|
||||||
COPY ./gradlew .
|
|
||||||
RUN chmod +x ./gradlew
|
|
||||||
CMD echo "\r========== [CLEAN: $MC_VER] ==========" && \
|
|
||||||
./gradlew clean -PmcVer="$MC_VER" --gradle-user-home .gradle-cache/ && \
|
|
||||||
echo "\r========== [BUILD: $MC_VER] ==========" && \
|
|
||||||
./gradlew build -PmcVer="$MC_VER" --gradle-user-home .gradle-cache/ && \
|
|
||||||
echo "\r========== [MERGE: $MC_VER] ==========" && \
|
|
||||||
./gradlew mergeJars -PmcVer="$MC_VER" --gradle-user-home .gradle-cache/ && \
|
|
||||||
echo "\r========== [DONE: $MC_VER] =========="
|
|
||||||
@@ -14,89 +14,11 @@ Below is a video demonstrating the system:
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## Minecraft and Library Versions
|
|
||||||
|
|
||||||
### This branch supports the following versions of Minecraft:
|
|
||||||
|
|
||||||
#### 1.20.4, 1.20.3 (Default)
|
|
||||||
Fabric: 0.15.1\
|
|
||||||
Fabric API: 0.91.2+1.20.4\
|
|
||||||
Forge: 49.0.30\
|
|
||||||
NeoForge: 118-beta\
|
|
||||||
Parchment: 1.20.2:2023.12.10\
|
|
||||||
Modmenu: 9.0.0-pre.1
|
|
||||||
|
|
||||||
#### 1.20.2
|
|
||||||
Fabric: 0.14.24\
|
|
||||||
Fabric API: 0.90.4+1.20.2\
|
|
||||||
Forge: 48.0.13\
|
|
||||||
Parchment: 1.20.1:2023.09.03\
|
|
||||||
Modmenu: 8.0.0
|
|
||||||
|
|
||||||
#### 1.20.1, 1.20
|
|
||||||
Fabric: 0.14.24\
|
|
||||||
Fabric API: 0.90.4+1.20.1\
|
|
||||||
Forge: 47.2.1\
|
|
||||||
Parchment: 1.20.1:2023.09.03\
|
|
||||||
Modmenu: 7.2.2
|
|
||||||
|
|
||||||
#### 1.19.4
|
|
||||||
Fabric: 0.14.24\
|
|
||||||
Fabric API: 0.87.1+1.19.4\
|
|
||||||
Forge: 45.2.4\
|
|
||||||
Parchment: 1.19.4:2023.06.26\
|
|
||||||
Modmenu: 6.3.1
|
|
||||||
|
|
||||||
#### 1.19.2
|
|
||||||
Fabric: 0.14.24\
|
|
||||||
Fabric API: 0.76.1+1.19.2\
|
|
||||||
Forge: 43.3.2\
|
|
||||||
Parchment: 1.19.2:2022.11.27\
|
|
||||||
Modmenu: 4.2.0-beta.2
|
|
||||||
|
|
||||||
#### 1.18.2
|
|
||||||
Fabric: 0.14.24\
|
|
||||||
Fabric API: 0.76.0+1.18.2\
|
|
||||||
Forge: 40.2.10\
|
|
||||||
Parchment: 1.18.2:2022.11.06\
|
|
||||||
Modmenu: 3.2.5
|
|
||||||
|
|
||||||
#### 1.17.1, 1.17
|
|
||||||
Fabric: 0.14.24\
|
|
||||||
Fabric API: 0.46.1+1.17\
|
|
||||||
Forge: 37.1.1\
|
|
||||||
Parchment: 1.17.1:2021.12.12\
|
|
||||||
Modmenu: 2.0.14
|
|
||||||
|
|
||||||
#### 1.16.5, 1.16.4
|
|
||||||
Fabric: 0.14.24\
|
|
||||||
Fabric API: 0.42.0+1.16\
|
|
||||||
Forge: 36.2.39\
|
|
||||||
Parchment: 1.16.5:2022.03.06\
|
|
||||||
Modmenu: 1.16.22
|
|
||||||
|
|
||||||
### Versions no longer supported
|
|
||||||
- 1.18.1, 1.18
|
|
||||||
- 1.19.1, 1.19
|
|
||||||
- 1.19.3
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
### Plugin and Library versions
|
|
||||||
|
|
||||||
Gradle: 8.5\
|
|
||||||
Fabric loom: 1.4-SNAPSHOT\
|
|
||||||
Architectury loom (Forge gradle replacement): 1.4-SNAPSHOT\
|
|
||||||
Sponge vanilla gradle: 0.2.1-SNAPSHOT\
|
|
||||||
Java Preprocessor plugin: Manifold Preprocessor
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## Source Code Installation
|
## Source Code Installation
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
* A Java Development Kit (JDK) for Java 17 (recommended) or newer. <br>
|
* A Java Development Kit (JDK) for Java 25 (recommended) or newer. <br>
|
||||||
Visit https://www.oracle.com/java/technologies/downloads/ for installers.
|
Visit https://www.oracle.com/java/technologies/downloads/ for installers.
|
||||||
* Git or someway to clone git projects. <br>
|
* Git or someway to clone git projects. <br>
|
||||||
Visit https://git-scm.com/ for installers.
|
Visit https://git-scm.com/ for installers.
|
||||||
@@ -104,15 +26,10 @@ Java Preprocessor plugin: Manifold Preprocessor
|
|||||||
|
|
||||||
**If using IntelliJ:**
|
**If using IntelliJ:**
|
||||||
1. Install the Manifold plugin
|
1. Install the Manifold plugin
|
||||||
|
- https://plugins.jetbrains.com/plugin/10057-manifold-ij
|
||||||
2. Open IDEA and import the build.gradle
|
2. Open IDEA and import the build.gradle
|
||||||
3. Refresh the Gradle project in IDEA if required
|
3. Refresh the Gradle project in IDEA if required
|
||||||
|
|
||||||
**If using Eclipse: (Note that Eclipse doesn't support Manifold's preprocessor!)**
|
|
||||||
1. Run the command: `./gradlew geneclipseruns`
|
|
||||||
2. Run the command: `./gradlew eclipse`
|
|
||||||
3. Make sure eclipse has the JDK 17 installed. (This is needed so that eclipse can run minecraft)
|
|
||||||
4. Import the project into eclipse
|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## Switching Versions
|
## Switching Versions
|
||||||
@@ -127,72 +44,42 @@ In IntelliJ, you will also need to do a gradle sync if it didn't happen automati
|
|||||||
## Compiling
|
## Compiling
|
||||||
|
|
||||||
Prerequisites:
|
Prerequisites:
|
||||||
- JDK 17 or newer
|
- JDK 25 or newer
|
||||||
|
|
||||||
From the File Explorer:
|
|
||||||
1. Download and extract the project zip
|
|
||||||
2. Download the core from https://gitlab.com/distant-horizons-team/distant-horizons-core and extract into a folder called `coreSubProjects`
|
|
||||||
3. Open a terminal emulator in the project folder (On Windows you can type `cmd` in the title bar)
|
|
||||||
4. Run the commands: `./gradlew assemble` (You may need to use a `.\` on Windows)
|
|
||||||
5. Merge the jars with `./gradlew mergeJars`
|
|
||||||
6. The compiled jar file will be in the folder `Merged`
|
|
||||||
|
|
||||||
From the command line:
|
From the command line:
|
||||||
1. `git clone --recurse-submodules https://gitlab.com/distant-horizons-team/distant-horizons.git`
|
1. `git clone --recurse-submodules https://gitlab.com/distant-horizons-team/distant-horizons.git`
|
||||||
2. `cd distant-horizons`
|
2. `cd distant-horizons`
|
||||||
3. `./gradlew assemble`
|
3. `./gradlew assemble`
|
||||||
4. `./gradlew mergeJars`
|
5. The compiled jar file will be in the folder `\build\libs`
|
||||||
5. The compiled jar file will be in the folder `Merged`
|
|
||||||
|
|
||||||
Run tests with: `./gradlew test`
|
From the File Explorer:
|
||||||
|
1. Download and extract the project zip
|
||||||
|
2. Download the core from https://gitlab.com/distant-horizons-team/distant-horizons-core and extract into a folder called `coreSubProjects`
|
||||||
|
3. Open command prompt/terminal in the project folder
|
||||||
|
4. Run the commands: `./gradlew assemble`
|
||||||
|
6. The compiled jar file will be in the folder `\build\libs`
|
||||||
|
|
||||||
>Note: You can add the argument `-PmcVer=?` to tell gradle to build a selected MC version instead of having to modify the `gradle.properties` file.\
|
>Note: You can add the argument `-PmcVer=?` to tell gradle to build a selected MC version instead of having to modify the `gradle.properties` file.\
|
||||||
> For example: `./gradlew assemble -PmcVer=1.18.2`
|
> For example: `./gradlew assemble -PmcVer=1.18.2`
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## Compiling with Docker
|
|
||||||
|
|
||||||
`./compile <version>`
|
|
||||||
|
|
||||||
You can also locally compile the DH jars without a Java environment by using Docker. Where `<version>` is the version of Minecraft to compile for (ie `1.20.1`), or the keyword `all`. See [Versions](#minecraft-and-library-versions) for a list of all supported values.
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## Other commands
|
## Other commands
|
||||||
|
|
||||||
`./gradlew --refresh-dependencies` to refresh local dependencies.
|
|
||||||
|
|
||||||
`./gradlew clean` to delete any compiled code.
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## Note to self
|
|
||||||
|
|
||||||
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 & [Parchment](https://parchmentmc.org/) mappings.
|
|
||||||
|
|
||||||
To generate the source code run `./gradlew genSources` <br>
|
|
||||||
If your IDE fails to auto-detect the source jars when browsing Minecraft classes; manually select the JAR file ending with -sources.jar when prompted by your IDE. <br>
|
|
||||||
(In IntelliJ it's at the top where it says "choose sources" when browsing a Minecraft class)
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## Other Useful commands
|
|
||||||
|
|
||||||
Run the standalone jar: `./gradlew run` <br>
|
Run the standalone jar: `./gradlew run` <br>
|
||||||
Build the standalone jar: `./gradlew core:build` <br>
|
Build the standalone jar: `./gradlew core:build` <br>
|
||||||
Only build Fabric: `./gradlew fabric:assemble` or `./gradlew fabric:build` <br>
|
Only build Fabric: `./gradlew fabric:assemble` or `./gradlew fabric:build` <br>
|
||||||
Only build Forge: `./gradlew forge:assemble` or `./gradlew forge:build` <br>
|
Only build Forge: `./gradlew forge:assemble` or `./gradlew forge:build` <br>
|
||||||
Run the Fabric client (for debugging): `./gradlew fabric:runClient` <br>
|
Run the Fabric client (for debugging): `./gradlew fabric:runClient` <br>
|
||||||
Run the Forge client (for debugging): `./gradlew forge:runClient` <br>
|
Run the Forge client (for debugging): `./gradlew forge:runClient` <br>
|
||||||
|
Delete all compiled code: `./gradlew clean` <br>
|
||||||
|
Refresh local dependencies: `./gradlew --refresh-dependencies`
|
||||||
|
|
||||||
To build all versions: `./buildAll` (all builds will end up in the `Merged` folder)
|
To build all versions: `./buildAll`
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## Open Source Acknowledgements
|
## Open Source Libraries
|
||||||
|
|
||||||
Forgix (To merge multiple mod versions into one jar) [_Formerly_ [_DHJarMerger_](https://github.com/Ran-helo/DHJarMerger)]\
|
Forgix (To merge multiple mod versions into one jar) [_Formerly_ [_DHJarMerger_](https://github.com/Ran-helo/DHJarMerger)]\
|
||||||
https://github.com/PacifistMC/Forgix
|
https://github.com/PacifistMC/Forgix
|
||||||
@@ -208,3 +95,18 @@ https://github.com/blackears/svgSalamander
|
|||||||
|
|
||||||
sqlite-jdbc\
|
sqlite-jdbc\
|
||||||
https://github.com/xerial/sqlite-jdbc
|
https://github.com/xerial/sqlite-jdbc
|
||||||
|
|
||||||
|
|
||||||
|
## Acknowledgements
|
||||||
|
|
||||||
|
Distant Horizons has been graciously provided an open source license for <a href="https://www.yourkit.com/java/profiler/">YourKit Java Profiler</a>.
|
||||||
|
|
||||||
|
> <img src="https://www.yourkit.com/images/yklogo.png">
|
||||||
|
>
|
||||||
|
> YourKit supports open source projects with innovative and intelligent tools
|
||||||
|
for monitoring and profiling Java and .NET applications.
|
||||||
|
YourKit is the creator of <a href="https://www.yourkit.com/java/profiler/">YourKit Java Profiler</a>,
|
||||||
|
<a href="https://www.yourkit.com/dotnet-profiler/">YourKit .NET Profiler</a>,
|
||||||
|
and <a href="https://www.yourkit.com/youmonitor/">YourKit YouMonitor</a>.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,4 +5,24 @@ plugins {
|
|||||||
|
|
||||||
forgix {
|
forgix {
|
||||||
autoRun = true
|
autoRun = true
|
||||||
|
|
||||||
|
// add the mod loaders to the end of the jar
|
||||||
|
// put together in the format: "a", "a-b", "a-b-c"
|
||||||
|
String modLoaders = "";
|
||||||
|
((String) gradle.builds_for)
|
||||||
|
.split(",")
|
||||||
|
.each
|
||||||
|
{ loader ->
|
||||||
|
def loaderName = loader.trim()
|
||||||
|
if (modLoaders != "")
|
||||||
|
{
|
||||||
|
modLoaders += "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
modLoaders += loaderName;
|
||||||
|
}
|
||||||
|
// merged jars are named in the format:
|
||||||
|
// "DistantHorizons-3.0.1-b-dev-26.1-fabric-neoforge.jar"
|
||||||
|
archiveClassifier = modLoaders
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
echo "==================== Note: All build jars will be in the folder called 'buildAllJars' ===================="
|
echo "==================== Note: All build jars will be in the folder called 'buildAllJars' ===================="
|
||||||
mkdir -p buildAllJars
|
mkdir -p buildAllJars
|
||||||
rm -rf buildAllJars/*
|
rm -rf buildAllJars/*
|
||||||
|
rm -rf build/forgix/*
|
||||||
|
|
||||||
# Loop trough everything in the version properties folder
|
# Loop trough everything in the version properties folder
|
||||||
for d in versionProperties/*; do
|
for d in versionProperties/*; do
|
||||||
@@ -19,10 +20,6 @@ for d in versionProperties/*; do
|
|||||||
sh gradlew build -PmcVer=$version
|
sh gradlew build -PmcVer=$version
|
||||||
if [ $? != 0 ]; then continue; fi
|
if [ $? != 0 ]; then continue; fi
|
||||||
|
|
||||||
echo "==================== Merging $version ===================="
|
|
||||||
sh gradlew mergeJars -PmcVer=$version
|
|
||||||
if [ $? != 0 ]; then continue; fi
|
|
||||||
|
|
||||||
echo "==================== Moving jar ===================="
|
echo "==================== Moving jar ===================="
|
||||||
mv build/merged/*.jar buildAllJars/
|
mv build/forgix/*.jar buildAllJars/
|
||||||
done
|
done
|
||||||
|
|||||||
+2
-4
@@ -6,6 +6,7 @@
|
|||||||
echo ==================== Note: All build jars will be in the folder called 'buildAllJars' ====================
|
echo ==================== Note: All build jars will be in the folder called 'buildAllJars' ====================
|
||||||
mkdir buildAllJars
|
mkdir buildAllJars
|
||||||
del buildAllJars/*
|
del buildAllJars/*
|
||||||
|
del build/forgix/*
|
||||||
|
|
||||||
@rem Loop trough everything in the version properties folder
|
@rem Loop trough everything in the version properties folder
|
||||||
for %%f in (versionProperties\*) do (
|
for %%f in (versionProperties\*) do (
|
||||||
@@ -19,11 +20,8 @@ for %%f in (versionProperties\*) do (
|
|||||||
echo ==================== Building !version! ====================
|
echo ==================== Building !version! ====================
|
||||||
call .\gradlew.bat build -PmcVer="!version!"
|
call .\gradlew.bat build -PmcVer="!version!"
|
||||||
|
|
||||||
echo ==================== Merging !version! ====================
|
|
||||||
call .\gradlew.bat mergeJars -PmcVer="!version!"
|
|
||||||
|
|
||||||
echo ==================== Moving jar ====================
|
echo ==================== Moving jar ====================
|
||||||
move build\merged\*.jar buildAllJars\
|
move build\forgix\*.jar buildAllJars\
|
||||||
)
|
)
|
||||||
|
|
||||||
endlocal
|
endlocal
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
@echo off & setlocal enabledelayedexpansion
|
||||||
|
|
||||||
|
|
||||||
|
echo ==================== Getting versions to build... ====================
|
||||||
|
mkdir _buildAllJars 2>nul
|
||||||
|
del _buildAllJars\* /Q 2>nul
|
||||||
|
|
||||||
|
set "ROOT=%~dp0"
|
||||||
|
set "WORK_DIR=%ROOT%_buildWorkers"
|
||||||
|
mkdir "%WORK_DIR%" 2>nul
|
||||||
|
|
||||||
|
|
||||||
|
REM get the number of versions to compile
|
||||||
|
set count=0
|
||||||
|
for %%f in (versionProperties\*) do set /a count+=1
|
||||||
|
echo ==================== Found %count% versions to build in parallel ====================
|
||||||
|
|
||||||
|
REM Launch a parallel job for each version
|
||||||
|
for %%f in (%ROOT%versionProperties\*) do (
|
||||||
|
set version=%%~nf
|
||||||
|
|
||||||
|
echo starting [!version!]...
|
||||||
|
start "Build !version!" cmd /c ""%ROOT%build_worker.bat" "!version!" "%ROOT%" "%WORK_DIR%" ""..\..\_buildAllJars"""
|
||||||
|
|
||||||
|
REM Minor timeout between launches so we can stop the build early if we only want
|
||||||
|
REM to test part of the script and to reduce startup load
|
||||||
|
timeout /t 3 /nobreak
|
||||||
|
|
||||||
|
REM 2>nul to supress a harmless warning that the for loop
|
||||||
|
REM "cannot find the drive specified"
|
||||||
|
) 2>nul
|
||||||
|
|
||||||
|
|
||||||
|
echo ==================== All builds started... Completed Jars will be in _buildAllJars ====================
|
||||||
|
endlocal
|
||||||
@@ -18,7 +18,7 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.gradleup.shadow:shadow-gradle-plugin:9.0.0'
|
implementation 'com.gradleup.shadow:shadow-gradle-plugin:9.0.0'
|
||||||
implementation 'xyz.wagyourtail.unimined:xyz.wagyourtail.unimined.gradle.plugin:1.4.17-kappa'
|
implementation 'xyz.wagyourtail.unimined:xyz.wagyourtail.unimined.gradle.plugin:1.4.18-kappa'
|
||||||
implementation 'xyz.wagyourtail:manifold-gradle:1.0.0-SNAPSHOT'
|
implementation 'xyz.wagyourtail:manifold-gradle:1.0.0-SNAPSHOT'
|
||||||
implementation 'xyz.wagyourtail.jvmdowngrader:xyz.wagyourtail.jvmdowngrader.gradle.plugin:1.3.4'
|
implementation 'xyz.wagyourtail.jvmdowngrader:xyz.wagyourtail.jvmdowngrader.gradle.plugin:1.3.4'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,12 @@ repositories {
|
|||||||
url "https://www.cursemaven.com"
|
url "https://www.cursemaven.com"
|
||||||
content { includeGroup "curse.maven" }
|
content { includeGroup "curse.maven" }
|
||||||
}
|
}
|
||||||
maven { url "https://repo.spongepowered.org/maven/" }
|
maven {
|
||||||
|
url "https://repo.spongepowered.org/maven/"
|
||||||
|
// exclusion is needed since sponge has a deprecated version of fabric
|
||||||
|
// that gradle would prefer to get over the up-to-date version modrinth provides
|
||||||
|
content { excludeGroupByRegex "net\\.fabricmc(\\..*)?" }
|
||||||
|
}
|
||||||
maven { url "https://maven.terraformersmc.com/" }
|
maven { url "https://maven.terraformersmc.com/" }
|
||||||
maven { url "https://maven.neoforged.net/releases/" }
|
maven { url "https://maven.neoforged.net/releases/" }
|
||||||
flatDir {
|
flatDir {
|
||||||
@@ -286,7 +291,6 @@ class NativeTransformer implements ResourceTransformer {
|
|||||||
if (isNotCommonProject) {
|
if (isNotCommonProject) {
|
||||||
shadowJar {
|
shadowJar {
|
||||||
configurations = [project.configurations.shadowMe]
|
configurations = [project.configurations.shadowMe]
|
||||||
relocate "com.seibel.distanthorizons.common", "loaderCommon.${project.name}.com.seibel.distanthorizons.common"
|
|
||||||
def librariesLocation = "DistantHorizons.libraries"
|
def librariesLocation = "DistantHorizons.libraries"
|
||||||
|
|
||||||
// LZ4
|
// LZ4
|
||||||
@@ -354,20 +358,64 @@ if (isNotCommonProject) {
|
|||||||
def isClient = runTask.name.toLowerCase().contains("client")
|
def isClient = runTask.name.toLowerCase().contains("client")
|
||||||
runTask.workingDir = rootProject.file("run/${isClient ? 'client' : 'server'}")
|
runTask.workingDir = rootProject.file("run/${isClient ? 'client' : 'server'}")
|
||||||
|
|
||||||
|
// Minecraft automatically has G1GC args present,
|
||||||
|
// remove them so we can use ZGC instead
|
||||||
|
def filteredArgs = runTask.jvmArgs.findAll { arg ->
|
||||||
|
!arg.startsWith("-XX:+UseG1GC") &&
|
||||||
|
!arg.startsWith("-XX:G1") &&
|
||||||
|
!arg.startsWith("-XX:MaxGCPauseMillis")
|
||||||
|
}
|
||||||
|
runTask.jvmArgs = filteredArgs
|
||||||
|
|
||||||
|
// fix (Neo)forge debug running
|
||||||
|
doFirst {
|
||||||
|
def modsDir = rootProject.file("run/${isClient ? 'client' : 'server'}/mods")
|
||||||
|
modsDir.mkdirs()
|
||||||
|
|
||||||
|
// Remove any stale DH jars before copying the fresh one
|
||||||
|
modsDir.listFiles()?.each { file ->
|
||||||
|
if (file.name.startsWith(rootProject.mod_name)) file.delete()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy shadow jar into mods folder so (Neo)Forge discovers it properly
|
||||||
|
copy {
|
||||||
|
from shadowJar.archiveFile
|
||||||
|
into modsDir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// JVM args
|
// JVM args
|
||||||
runTask.jvmArgs(
|
runTask.jvmArgs(
|
||||||
"-Dio.netty.leakDetection.level=advanced",
|
"-Dio.netty.leakDetection.level=advanced",
|
||||||
//"-XX:+UseZGC",
|
// TODO only use for modern java versions
|
||||||
|
"-XX:+UseZGC",
|
||||||
|
// TODO don't use for even more modern-er java versions
|
||||||
//"-XX:+ZGenerational",
|
//"-XX:+ZGenerational",
|
||||||
|
rootProject.minecraftMemoryJavaArg,
|
||||||
)
|
)
|
||||||
if (isClient) {
|
if (isClient)
|
||||||
|
{
|
||||||
runTask.jvmArgs(
|
runTask.jvmArgs(
|
||||||
"-Dminecraft.api.auth.host=https://nope.invalid",
|
"-Dminecraft.api.auth.host=https://nope.invalid",
|
||||||
"-Dminecraft.api.account.host=https://nope.invalid",
|
"-Dminecraft.api.account.host=https://nope.invalid",
|
||||||
"-Dminecraft.api.session.host=https://nope.invalid",
|
"-Dminecraft.api.session.host=https://nope.invalid",
|
||||||
"-Dminecraft.api.services.host=https://nope.invalid",
|
"-Dminecraft.api.services.host=https://nope.invalid",
|
||||||
)
|
)
|
||||||
runTask.args("--username", "Dev", "--renderDebugLabels", "--tracy")
|
runTask.args(
|
||||||
|
// use a consistent username for easier debugging in a given world (vs randomly teleporting to a new user each time the game boots)
|
||||||
|
"--username", "Dev",
|
||||||
|
// "--renderDebugLabels" is a Mojang command to show render names in RenderDoc
|
||||||
|
"--renderDebugLabels"
|
||||||
|
)
|
||||||
|
|
||||||
|
// enabling tracy causes constant memory growth so it isn't always desired
|
||||||
|
if (rootProject.minecraftEnableTracy == "true")
|
||||||
|
{
|
||||||
|
// "--tracy" is a Mojang command to allow individual frames to be debugged using Tracy https://github.com/wolfpld/tracy/releases/tag/v0.13.1
|
||||||
|
runTask.args("--tracy")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -417,6 +465,7 @@ if (isNotCommonProject) {
|
|||||||
issues : rootProject.mod_issues,
|
issues : rootProject.mod_issues,
|
||||||
discord : rootProject.mod_discord,
|
discord : rootProject.mod_discord,
|
||||||
minecraft_version : rootProject.minecraft_version,
|
minecraft_version : rootProject.minecraft_version,
|
||||||
|
accessWidenerVersion : rootProject.accessWidenerVersion,
|
||||||
compatible_minecraft_versions: rootProject.compatible_minecraft_versions,
|
compatible_minecraft_versions: rootProject.compatible_minecraft_versions,
|
||||||
compatible_forgemc_versions : compatible_forgemc_versions,
|
compatible_forgemc_versions : compatible_forgemc_versions,
|
||||||
java_version : rootProject.java_version,
|
java_version : rootProject.java_version,
|
||||||
@@ -447,11 +496,11 @@ if (isNotCommonProject) {
|
|||||||
|
|
||||||
// ==================== Resource Copy Tasks ====================
|
// ==================== Resource Copy Tasks ====================
|
||||||
|
|
||||||
task copyCommonLoaderResources(type: Copy) {
|
// task copyCommonLoaderResources(type: Copy) {
|
||||||
from project(":common").file("src/main/resources/${rootProject.accessWidenerVersion}.distanthorizons.accesswidener")
|
// from project(":common").file("src/main/resources/${rootProject.accessWidenerVersion}.distanthorizons.accesswidener")
|
||||||
into(file(project.file("build/resources/main")))
|
// into(file(project.file("build/resources/main")))
|
||||||
rename "${rootProject.accessWidenerVersion}.distanthorizons.accesswidener", "distanthorizons.accesswidener"
|
// rename "${rootProject.accessWidenerVersion}.distanthorizons.accesswidener", "distanthorizons.accesswidener"
|
||||||
}
|
// }
|
||||||
|
|
||||||
task copyCoreResources(type: Copy) {
|
task copyCoreResources(type: Copy) {
|
||||||
from fileTree(project(":core").file("src/main/resources"))
|
from fileTree(project(":core").file("src/main/resources"))
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
@echo off & setlocal enabledelayedexpansion
|
||||||
|
|
||||||
|
set "VERSION=%~1"
|
||||||
|
set "ROOT=%~2"
|
||||||
|
set "WORK_DIR=%~3"
|
||||||
|
set "WORKER=%WORK_DIR%\%VERSION%"
|
||||||
|
set "JAR_OUTPUT_DIR=%~4"
|
||||||
|
|
||||||
|
REM remove the ending "\" from the root folder, otherwise the final quote
|
||||||
|
REM in the robocopy command will be escaped and it won't run
|
||||||
|
if "%ROOT:~-1%"=="\" set "ROOT=%ROOT:~0,-1%"
|
||||||
|
set "WORKER=%~3\%~1"
|
||||||
|
|
||||||
|
set "BUILT_JAR_DIR=%WORKER%\build\forgix"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo ==================== [%VERSION%] Copying workspace ====================
|
||||||
|
mkdir "%WORKER%"
|
||||||
|
robocopy "%ROOT%" "%WORKER%" /E /XD "%WORKER%" "_buildWorkers" "buildAllJars" ".gradle" "build" ".git" ".idea" ".gitlab" "run" "testScripts" /NFL /NDL
|
||||||
|
|
||||||
|
echo ==================== [%VERSION%] Cleaning ====================
|
||||||
|
cd /d "%WORKER%"
|
||||||
|
call .\gradlew.bat clean
|
||||||
|
REM optional arg that can be added if we want to log the result to a file
|
||||||
|
REM >"%WORK_DIR%\build_%VERSION%.log" 2>&1
|
||||||
|
|
||||||
|
echo ==================== [%VERSION%] Assembling ====================
|
||||||
|
call .\gradlew.bat assemble -PmcVer="%VERSION%"
|
||||||
|
REM optional arg that can be added if we want to log the result to a file
|
||||||
|
REM >>"%WORK_DIR%\build_%VERSION%.log" 2>&1
|
||||||
|
|
||||||
|
echo ==================== [%VERSION%] Exporting ====================
|
||||||
|
mkdir "%JAR_OUTPUT_DIR%"
|
||||||
|
robocopy "%BUILT_JAR_DIR%" "%JAR_OUTPUT_DIR%" /NFL /NDL
|
||||||
|
|
||||||
|
echo ==================== [%VERSION%] Done ====================
|
||||||
|
endlocal
|
||||||
|
|
||||||
|
REM can be uncommented for debugging
|
||||||
|
REM pause
|
||||||
+12
-12
@@ -8,8 +8,8 @@ import com.seibel.distanthorizons.common.commands.CommandInitializer;
|
|||||||
import com.seibel.distanthorizons.common.wrappers.DependencySetup;
|
import com.seibel.distanthorizons.common.wrappers.DependencySetup;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.DhDebugScreenEntry;
|
import com.seibel.distanthorizons.common.wrappers.gui.DhDebugScreenEntry;
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftServerWrapper;
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftServerWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.Initializer;
|
||||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.config.ConfigHandler;
|
import com.seibel.distanthorizons.core.config.ConfigHandler;
|
||||||
import com.seibel.distanthorizons.core.config.eventHandlers.presets.ThreadPresetConfigEventHandler;
|
import com.seibel.distanthorizons.core.config.eventHandlers.presets.ThreadPresetConfigEventHandler;
|
||||||
@@ -21,10 +21,8 @@ import com.seibel.distanthorizons.core.jar.updater.SelfUpdater;
|
|||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.AbstractDebugWireframeRenderer;
|
import com.seibel.distanthorizons.core.render.renderer.AbstractDebugWireframeRenderer;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.StubDebugWireframeRenderer;
|
import com.seibel.distanthorizons.core.render.renderer.StubDebugWireframeRenderer;
|
||||||
import com.seibel.distanthorizons.core.util.NativeDialogUtil;
|
import com.seibel.distanthorizons.common.wrappers.gui.NativeDialogUtil;
|
||||||
import com.seibel.distanthorizons.core.util.ThreadUtil;
|
import com.seibel.distanthorizons.core.util.ThreadUtil;
|
||||||
import com.seibel.distanthorizons.core.util.threading.DhThreadFactory;
|
|
||||||
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IIrisAccessor;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IIrisAccessor;
|
||||||
@@ -97,7 +95,8 @@ public abstract class AbstractModInitializer
|
|||||||
|
|
||||||
// Client uses config for auto-updater, so it's initialized here instead of post-init stage
|
// Client uses config for auto-updater, so it's initialized here instead of post-init stage
|
||||||
this.initConfig();
|
this.initConfig();
|
||||||
logModIncompatibilityWarnings(); // needs to be called after config loading
|
logIncompatibilityWarnings(); // needs to be called after config loading
|
||||||
|
Initializer.postConfigInit();
|
||||||
|
|
||||||
LOGGER.info(ModInfo.READABLE_NAME + " client Initialized.");
|
LOGGER.info(ModInfo.READABLE_NAME + " client Initialized.");
|
||||||
|
|
||||||
@@ -139,6 +138,7 @@ public abstract class AbstractModInitializer
|
|||||||
MinecraftServerWrapper.INSTANCE.dedicatedServer = (DedicatedServer)server;
|
MinecraftServerWrapper.INSTANCE.dedicatedServer = (DedicatedServer)server;
|
||||||
|
|
||||||
this.initConfig();
|
this.initConfig();
|
||||||
|
Initializer.postConfigInit();
|
||||||
this.postInit();
|
this.postInit();
|
||||||
this.postServerInit();
|
this.postServerInit();
|
||||||
this.commandInitializer.onServerReady();
|
this.commandInitializer.onServerReady();
|
||||||
@@ -161,7 +161,7 @@ public abstract class AbstractModInitializer
|
|||||||
private void startup()
|
private void startup()
|
||||||
{
|
{
|
||||||
DependencySetup.createSharedBindings();
|
DependencySetup.createSharedBindings();
|
||||||
SharedApi.init();
|
Initializer.preConfigInit();
|
||||||
this.createInitialSharedBindings();
|
this.createInitialSharedBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,9 +263,9 @@ public abstract class AbstractModInitializer
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==================================//
|
//======================//
|
||||||
// mod partial compatibility checks //
|
// compatibility checks //
|
||||||
//==================================//
|
//======================//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -274,7 +274,7 @@ public abstract class AbstractModInitializer
|
|||||||
* This method will log (and display to chat if enabled)
|
* This method will log (and display to chat if enabled)
|
||||||
* these warnings and potential fixes.
|
* these warnings and potential fixes.
|
||||||
*/
|
*/
|
||||||
private static void logModIncompatibilityWarnings()
|
private static void logIncompatibilityWarnings()
|
||||||
{
|
{
|
||||||
boolean showChatWarnings = Config.Common.Logging.Warning.showModCompatibilityWarningsOnStartup.get();
|
boolean showChatWarnings = Config.Common.Logging.Warning.showModCompatibilityWarningsOnStartup.get();
|
||||||
IModChecker modChecker = SingletonInjector.INSTANCE.get(IModChecker.class);
|
IModChecker modChecker = SingletonInjector.INSTANCE.get(IModChecker.class);
|
||||||
@@ -375,10 +375,10 @@ public abstract class AbstractModInitializer
|
|||||||
renderApi = versionConstants.getDefaultRenderingApi();
|
renderApi = versionConstants.getDefaultRenderingApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iris only supports nataive OpenGL
|
// Iris only supports native OpenGL
|
||||||
if (renderApi != EDhApiRenderApi.OPEN_GL)
|
if (renderApi != EDhApiRenderApi.OPEN_GL)
|
||||||
{
|
{
|
||||||
String irisUnsupportedMessage = "Iris doesn't support DH when using the ["+EDhApiRenderApi.BLAZE_3D+"] rendering API, this will need to be fixed on Iris' end. As a temporary fix please change the rendering API to ["+EDhApiRenderApi.OPEN_GL+"] in DH's config file.";
|
String irisUnsupportedMessage = "Iris doesn't support DH when using the ["+EDhApiRenderApi.BLAZE_3D+"] rendering API, this will need to be fixed on Iris end. As a temporary fix please change the rendering API to ["+EDhApiRenderApi.OPEN_GL+"] in the DH config file.";
|
||||||
LOGGER.fatal(irisUnsupportedMessage);
|
LOGGER.fatal(irisUnsupportedMessage);
|
||||||
NativeDialogUtil.showDialog(ModInfo.READABLE_NAME, irisUnsupportedMessage, "ok", "error");
|
NativeDialogUtil.showDialog(ModInfo.READABLE_NAME, irisUnsupportedMessage, "ok", "error");
|
||||||
|
|
||||||
|
|||||||
+110
@@ -0,0 +1,110 @@
|
|||||||
|
package com.seibel.distanthorizons.common.commonMixins;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||||
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
|
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||||
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.Camera;
|
||||||
|
import net.minecraft.world.effect.MobEffects;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
|
||||||
|
|
||||||
|
import net.minecraft.client.Camera;
|
||||||
|
import net.minecraft.world.effect.MobEffects;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
|
||||||
|
#if MC_VER < MC_1_17_1
|
||||||
|
import net.minecraft.world.level.material.FluidState;
|
||||||
|
import net.minecraft.client.renderer.FogRenderer;
|
||||||
|
import net.minecraft.client.renderer.FogRenderer.FogMode;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
#elif MC_VER < MC_1_21_3
|
||||||
|
import net.minecraft.world.level.material.FogType;
|
||||||
|
import net.minecraft.client.renderer.FogRenderer;
|
||||||
|
import net.minecraft.client.renderer.FogRenderer.FogMode;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
#elif MC_VER < MC_1_21_6
|
||||||
|
import net.minecraft.world.level.material.FogType;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
import com.mojang.blaze3d.shaders.FogShape;
|
||||||
|
import net.minecraft.client.renderer.FogRenderer;
|
||||||
|
import net.minecraft.client.renderer.FogRenderer.FogMode;
|
||||||
|
import net.minecraft.client.renderer.FogParameters;
|
||||||
|
import org.joml.Vector4f;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
#else
|
||||||
|
import net.minecraft.world.level.material.FogType;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public class MixinVanillaFogCommon
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
#if MC_VER < MC_1_21_6
|
||||||
|
public static boolean cancelFog(Camera camera, FogRenderer.FogMode fogMode)
|
||||||
|
#else
|
||||||
|
public static boolean cancelFog()
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
#if MC_VER < MC_1_21_6
|
||||||
|
Entity entity = camera.getEntity();
|
||||||
|
#elif MC_VER <= MC_1_21_10
|
||||||
|
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
||||||
|
Entity entity = camera.getEntity();
|
||||||
|
#else
|
||||||
|
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
||||||
|
Entity entity = camera.entity();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
boolean cameraNotInFluid = cameraNotInFluid(camera);
|
||||||
|
boolean isSpecialFog = (entity instanceof LivingEntity) && ((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS);
|
||||||
|
|
||||||
|
boolean cancelFog = !isSpecialFog;
|
||||||
|
cancelFog = cancelFog && cameraNotInFluid;
|
||||||
|
#if MC_VER < MC_1_21_6
|
||||||
|
cancelFog = cancelFog && (fogMode == FogRenderer.FogMode.FOG_TERRAIN);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cancelFog = cancelFog && !SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class).isFogStateSpecial();
|
||||||
|
cancelFog = cancelFog && !Config.Client.Advanced.Graphics.Fog.enableVanillaFog.get();
|
||||||
|
|
||||||
|
|
||||||
|
return cancelFog;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean cameraNotInFluid(Camera camera)
|
||||||
|
{
|
||||||
|
#if MC_VER < MC_1_17_1
|
||||||
|
FluidState fluidState = camera.getFluidInCamera();
|
||||||
|
boolean cameraNotInFluid = fluidState.isEmpty();
|
||||||
|
#else
|
||||||
|
FogType fogTypes = camera.getFluidInCamera();
|
||||||
|
boolean cameraNotInFluid = fogTypes == FogType.NONE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return cameraNotInFluid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+21
-21
@@ -299,27 +299,27 @@ public class BlazeDebugWireframeRenderer extends AbstractDebugWireframeRenderer
|
|||||||
|
|
||||||
// render //
|
// render //
|
||||||
|
|
||||||
//try (RenderPass renderPass = commandEncoder.createRenderPass(
|
try (RenderPass renderPass = commandEncoder.createRenderPass(
|
||||||
// this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
// BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureView,
|
BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureView,
|
||||||
// /*optionalClearColorAsInt*/ OptionalInt.empty(),
|
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
||||||
// BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView,
|
BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView,
|
||||||
// /*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
||||||
//{
|
{
|
||||||
// // Bind instance data //
|
// Bind instance data //
|
||||||
// renderPass.setUniform("uniformBlock", this.uniformBuffer);
|
renderPass.setUniform("uniformBlock", this.uniformBuffer);
|
||||||
//
|
|
||||||
// renderPass.setPipeline(this.pipeline);
|
renderPass.setPipeline(this.pipeline);
|
||||||
// renderPass.setIndexBuffer(this.boxIndexBuffer, VertexFormat.IndexType.INT);
|
renderPass.setIndexBuffer(this.boxIndexBuffer, VertexFormat.IndexType.INT);
|
||||||
//
|
|
||||||
// renderPass.setVertexBuffer(0, this.boxVertexBuffer);
|
renderPass.setVertexBuffer(0, this.boxVertexBuffer);
|
||||||
//
|
|
||||||
// renderPass.drawIndexed(
|
renderPass.drawIndexed(
|
||||||
// /*indexStart*/ 0,
|
/*indexStart*/ 0,
|
||||||
// /*firstIndex*/0,
|
/*firstIndex*/0,
|
||||||
// /*indexCount*/BOX_OUTLINE_INDICES.length,
|
/*indexCount*/BOX_OUTLINE_INDICES.length,
|
||||||
// /*instanceCount*/1);
|
/*instanceCount*/1);
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
private String getRenderPassName() { return "distantHorizons:McDebugRenderer"; }
|
private String getRenderPassName() { return "distantHorizons:McDebugRenderer"; }
|
||||||
|
|
||||||
|
|||||||
+33
-15
@@ -57,6 +57,7 @@ import com.seibel.distanthorizons.core.logging.DhLogger;
|
|||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.logging.f3.F3Screen;
|
import com.seibel.distanthorizons.core.logging.f3.F3Screen;
|
||||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||||
|
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.GenericRenderObjectFactory;
|
import com.seibel.distanthorizons.core.render.renderer.GenericRenderObjectFactory;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IDhGenericObjectVertexBufferContainer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IDhGenericObjectVertexBufferContainer;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.RenderableBoxGroup;
|
import com.seibel.distanthorizons.core.render.renderer.RenderableBoxGroup;
|
||||||
@@ -330,13 +331,16 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
@Override
|
@Override
|
||||||
public void render(RenderParams renderEventParam, IProfilerWrapper profiler, boolean renderingWithSsao)
|
public void render(RenderParams renderEventParam, IProfilerWrapper profiler, boolean renderingWithSsao)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
try (IProfilerWrapper.IProfileBlock generic_profile = profiler.push("setup"))
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
//==============//
|
//==============//
|
||||||
// render setup //
|
// render setup //
|
||||||
//==============//
|
//==============//
|
||||||
//#region
|
//#region
|
||||||
|
|
||||||
profiler.push("setup");
|
|
||||||
|
|
||||||
this.init();
|
this.init();
|
||||||
|
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericRenderSetupEvent.class, renderEventParam);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericRenderSetupEvent.class, renderEventParam);
|
||||||
@@ -491,13 +495,11 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
// render //
|
// render //
|
||||||
|
|
||||||
profiler.popPush("rendering");
|
profiler.popPush("rendering");
|
||||||
profiler.push(boxGroup.getResourceLocationNamespace());
|
try (IProfilerWrapper.IProfileBlock namespace_profile = profiler.push(boxGroup.getResourceLocationNamespace());
|
||||||
profiler.push(boxGroup.getResourceLocationPath());
|
IProfilerWrapper.IProfileBlock location_profile = profiler.push(boxGroup.getResourceLocationPath()))
|
||||||
|
{
|
||||||
this.renderBoxGroupInstanced(renderEventParam, boxGroup, profiler);
|
this.renderBoxGroupInstanced(renderEventParam, boxGroup, profiler);
|
||||||
|
}
|
||||||
profiler.pop(); // resource path
|
|
||||||
profiler.pop(); // resource namespace
|
|
||||||
|
|
||||||
boxGroup.postRender(renderEventParam);
|
boxGroup.postRender(renderEventParam);
|
||||||
}
|
}
|
||||||
@@ -515,10 +517,9 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericRenderCleanupEvent.class, renderEventParam);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericRenderCleanupEvent.class, renderEventParam);
|
||||||
|
|
||||||
profiler.pop();
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private String getRenderPassName() { return "distantHorizons:McGenericObjectRenderer"; }
|
private String getRenderPassName() { return "distantHorizons:McGenericObjectRenderer"; }
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
@@ -545,8 +546,6 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
// update instance data //
|
// update instance data //
|
||||||
|
|
||||||
profiler.push("vertex setup");
|
|
||||||
|
|
||||||
BlazeGenericObjectVertexContainer container = (BlazeGenericObjectVertexContainer) boxGroup.vertexBufferContainer;
|
BlazeGenericObjectVertexContainer container = (BlazeGenericObjectVertexContainer) boxGroup.vertexBufferContainer;
|
||||||
|
|
||||||
LightMapWrapper lightMapWrapper = (LightMapWrapper) renderEventParam.lightmap;
|
LightMapWrapper lightMapWrapper = (LightMapWrapper) renderEventParam.lightmap;
|
||||||
@@ -556,7 +555,6 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
|
|
||||||
// Bind instance data //
|
// Bind instance data //
|
||||||
profiler.popPush("binding");
|
|
||||||
|
|
||||||
|
|
||||||
renderPass.setUniform("vertUniformBlock", this.vertUniformBuffer);
|
renderPass.setUniform("vertUniformBlock", this.vertUniformBuffer);
|
||||||
@@ -568,7 +566,6 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
renderPass.setVertexBuffer(0, container.vboGpuBuffer);
|
renderPass.setVertexBuffer(0, container.vboGpuBuffer);
|
||||||
|
|
||||||
// Draw instanced
|
// Draw instanced
|
||||||
profiler.popPush("render");
|
|
||||||
if (container.uploadedBoxCount > 0)
|
if (container.uploadedBoxCount > 0)
|
||||||
{
|
{
|
||||||
renderPass.drawIndexed(
|
renderPass.drawIndexed(
|
||||||
@@ -579,7 +576,6 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
profiler.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
@@ -620,5 +616,27 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//================//
|
||||||
|
// base overrides //
|
||||||
|
//================//
|
||||||
|
//region
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
// close is called outside the render thread and buffer closing must be done on the render thread
|
||||||
|
RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("Generic Obj Cleanup", () ->
|
||||||
|
{
|
||||||
|
if (this.vertUniformBuffer != null)
|
||||||
|
{
|
||||||
|
this.vertUniformBuffer.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
+22
-4
@@ -6,13 +6,16 @@ public class BlazeDhMetaRenderer {}
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.textures.GpuTexture;
|
import com.mojang.blaze3d.textures.GpuTexture;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterColorDepthTextureCreatedEvent;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiTextureCreatedParam;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||||
import com.seibel.distanthorizons.core.util.ColorUtil;
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhMetaRenderer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhMetaRenderer;
|
||||||
|
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -57,9 +60,24 @@ public class BlazeDhMetaRenderer implements IDhMetaRenderer
|
|||||||
@Override
|
@Override
|
||||||
public void runRenderPassSetup(RenderParams renderParams)
|
public void runRenderPassSetup(RenderParams renderParams)
|
||||||
{
|
{
|
||||||
// textures
|
int oldWidth = this.dhDepthTextureWrapper.getWidth();
|
||||||
this.dhDepthTextureWrapper.tryCreateOrResize();
|
int oldHeight = this.dhDepthTextureWrapper.getHeight();
|
||||||
this.dhColorTextureWrapper.tryCreateOrResize();
|
|
||||||
|
boolean texturesChanged = false;
|
||||||
|
texturesChanged = this.dhDepthTextureWrapper.tryCreateOrResize() | texturesChanged;
|
||||||
|
texturesChanged = this.dhColorTextureWrapper.tryCreateOrResize() | texturesChanged;
|
||||||
|
|
||||||
|
if (texturesChanged)
|
||||||
|
{
|
||||||
|
int newTextureWidth = MC_RENDER.getTargetFramebufferViewportWidth();
|
||||||
|
int newTextureHeight = MC_RENDER.getTargetFramebufferViewportHeight();
|
||||||
|
|
||||||
|
DhApiTextureCreatedParam textureCreatedParam = new DhApiTextureCreatedParam(
|
||||||
|
oldWidth, oldHeight,
|
||||||
|
newTextureWidth, newTextureHeight
|
||||||
|
);
|
||||||
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterColorDepthTextureCreatedEvent.class, textureCreatedParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+13
-14
@@ -19,6 +19,7 @@ import com.mojang.blaze3d.systems.RenderPass;
|
|||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeBufferRenderEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeBufferRenderEvent;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeRenderPassEvent;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
@@ -151,8 +152,9 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
{
|
{
|
||||||
this.tryInit();
|
this.tryInit();
|
||||||
|
|
||||||
|
try(IProfilerWrapper.IProfileBlock terrain_profile = profiler.push("terrain render"))
|
||||||
profiler.push("vert unique uniforms");
|
{
|
||||||
|
profiler.popPush("vert unique uniforms");
|
||||||
{
|
{
|
||||||
// create data //
|
// create data //
|
||||||
|
|
||||||
@@ -203,9 +205,9 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
.putFloat(earthCurveRatio) // uEarthRadius
|
.putFloat(earthCurveRatio) // uEarthRadius
|
||||||
|
|
||||||
.putVec3(
|
.putVec3(
|
||||||
(float)renderEventParam.exactCameraPosition.x,
|
(float) renderEventParam.exactCameraPosition.x,
|
||||||
(float)renderEventParam.exactCameraPosition.y,
|
(float) renderEventParam.exactCameraPosition.y,
|
||||||
(float)renderEventParam.exactCameraPosition.z) // uCameraPos
|
(float) renderEventParam.exactCameraPosition.z) // uCameraPos
|
||||||
.putMat4f(combinedMatrix.createJomlMatrix()) // uCombinedMatrix
|
.putMat4f(combinedMatrix.createJomlMatrix()) // uCombinedMatrix
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
@@ -264,10 +266,12 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
|
|
||||||
// render pass setup
|
// render pass setup
|
||||||
{
|
{
|
||||||
profiler.popPush("setup");
|
profiler.popPush("rendering");
|
||||||
|
|
||||||
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam);
|
||||||
|
|
||||||
// create a render pass
|
// create a render pass
|
||||||
try(RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureView,
|
BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureView,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
||||||
@@ -290,10 +294,8 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
|
|
||||||
for (int lodIndex = 0; lodIndex < bufferContainers.size(); lodIndex++)
|
for (int lodIndex = 0; lodIndex < bufferContainers.size(); lodIndex++)
|
||||||
{
|
{
|
||||||
profiler.popPush("binding");
|
|
||||||
|
|
||||||
LodBufferContainer bufferContainer = bufferContainers.get(lodIndex);
|
LodBufferContainer bufferContainer = bufferContainers.get(lodIndex);
|
||||||
BlazeLodUniformBufferWrapper uniformWrapper = (BlazeLodUniformBufferWrapper)bufferContainer.uniformContainer;
|
BlazeLodUniformBufferWrapper uniformWrapper = (BlazeLodUniformBufferWrapper) bufferContainer.uniformContainer;
|
||||||
|
|
||||||
boolean columnBuilderDebugEnabled = Config.Client.Advanced.Debugging.ColumnBuilderDebugging.columnBuilderDebugEnable.get();
|
boolean columnBuilderDebugEnabled = Config.Client.Advanced.Debugging.ColumnBuilderDebugging.columnBuilderDebugEnable.get();
|
||||||
if (columnBuilderDebugEnabled)
|
if (columnBuilderDebugEnabled)
|
||||||
@@ -314,8 +316,6 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
profiler.popPush("rendering");
|
|
||||||
|
|
||||||
// render each buffer
|
// render each buffer
|
||||||
IVertexBufferWrapper[] bufferWrapperList = opaquePass ? bufferContainer.vboOpaqueWrappers : bufferContainer.vboTransparentWrappers;
|
IVertexBufferWrapper[] bufferWrapperList = opaquePass ? bufferContainer.vboOpaqueWrappers : bufferContainer.vboTransparentWrappers;
|
||||||
for (int i = 0; i < bufferWrapperList.length; i++)
|
for (int i = 0; i < bufferWrapperList.length; i++)
|
||||||
@@ -353,8 +353,7 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
profiler.pop();
|
|
||||||
}
|
}
|
||||||
private String getIndexBufferName() { return "distantHorizons:LodIndexBuffer"; }
|
private String getIndexBufferName() { return "distantHorizons:LodIndexBuffer"; }
|
||||||
private String getRenderPassName() { return "distantHorizons:McLodRenderer"; }
|
private String getRenderPassName() { return "distantHorizons:McLodRenderer"; }
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ import com.seibel.distanthorizons.common.render.openGl.glObject.enums.GLEnums;
|
|||||||
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
|
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IDhGenericObjectVertexBufferContainer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IDhGenericObjectVertexBufferContainer;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.RenderableBoxGroup;
|
import com.seibel.distanthorizons.core.render.renderer.RenderableBoxGroup;
|
||||||
import com.seibel.distanthorizons.core.util.ColorUtil;
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
import org.lwjgl.opengl.GL32;
|
import org.lwjgl.opengl.GL32;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|||||||
+22
-5
@@ -1,15 +1,26 @@
|
|||||||
package com.seibel.distanthorizons.common.render.blaze.wrappers;
|
package com.seibel.distanthorizons.common.render.blaze.wrappers;
|
||||||
|
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_10
|
||||||
|
public class RenderPipelineBuilderWrapper {}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.pipeline.BlendFunction;
|
import com.mojang.blaze3d.pipeline.BlendFunction;
|
||||||
import com.mojang.blaze3d.pipeline.ColorTargetState;
|
|
||||||
import com.mojang.blaze3d.pipeline.DepthStencilState;
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
import com.mojang.blaze3d.platform.CompareOp;
|
|
||||||
import com.mojang.blaze3d.platform.PolygonMode;
|
import com.mojang.blaze3d.platform.PolygonMode;
|
||||||
import com.mojang.blaze3d.shaders.UniformType;
|
import com.mojang.blaze3d.shaders.UniformType;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import net.minecraft.resources.Identifier;
|
import net.minecraft.resources.Identifier;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
import com.mojang.blaze3d.platform.DepthTestFunction;
|
||||||
|
#else
|
||||||
|
import com.mojang.blaze3d.pipeline.ColorTargetState;
|
||||||
|
import com.mojang.blaze3d.pipeline.DepthStencilState;
|
||||||
|
import com.mojang.blaze3d.platform.CompareOp;
|
||||||
|
#endif
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -206,15 +217,20 @@ public class RenderPipelineBuilderWrapper
|
|||||||
this.blazePipelineBuilder.withoutBlend();
|
this.blazePipelineBuilder.withoutBlend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DepthTestFunction depthTestFunction;
|
||||||
switch (this.depthTest)
|
switch (this.depthTest)
|
||||||
{
|
{
|
||||||
case NONE:
|
case NONE:
|
||||||
|
depthTestFunction = DepthTestFunction.NO_DEPTH_TEST;
|
||||||
break;
|
break;
|
||||||
case LESS:
|
case LESS:
|
||||||
|
depthTestFunction = DepthTestFunction.LESS_DEPTH_TEST;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new UnsupportedOperationException("No depth test defined for type ["+this.depthTest+"].");
|
||||||
}
|
}
|
||||||
this.blazepipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.NONE);
|
this.blazePipelineBuilder.withDepthTestFunction(depthTestFunction);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -349,3 +365,4 @@ public class RenderPipelineBuilderWrapper
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
+1
-6
@@ -140,7 +140,7 @@ public class BlazeVertexBufferWrapper implements IVertexBufferWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void uploadIndexBuffer(ByteBuffer buffer, int vertexCount)
|
public void uploadIndexBuffer(ByteBuffer indexBuffer, int vertexCount)
|
||||||
{
|
{
|
||||||
int oldIndexCount = this.indexCount;
|
int oldIndexCount = this.indexCount;
|
||||||
// 4 vertices per face, but 6 indices (IE 2 triangles) per face, aka need to multiply by 1.5
|
// 4 vertices per face, but 6 indices (IE 2 triangles) per face, aka need to multiply by 1.5
|
||||||
@@ -169,17 +169,12 @@ public class BlazeVertexBufferWrapper implements IVertexBufferWrapper
|
|||||||
this.indexGpuBuffer.close();
|
this.indexGpuBuffer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteBuffer indexBuffer = IndexBufferBuilder.createBuffer(this.vertexCount);
|
|
||||||
|
|
||||||
int usage = GpuBuffer.USAGE_COPY_DST
|
int usage = GpuBuffer.USAGE_COPY_DST
|
||||||
| GpuBuffer.USAGE_INDEX;
|
| GpuBuffer.USAGE_INDEX;
|
||||||
this.indexGpuBuffer = GPU_DEVICE.createBuffer(BlazeVertexBufferWrapper::getIndexBufferName, usage, indexBuffer.capacity());
|
this.indexGpuBuffer = GPU_DEVICE.createBuffer(BlazeVertexBufferWrapper::getIndexBufferName, usage, indexBuffer.capacity());
|
||||||
|
|
||||||
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.indexGpuBuffer, /*offset*/ 0, indexBuffer.capacity());
|
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.indexGpuBuffer, /*offset*/ 0, indexBuffer.capacity());
|
||||||
COMMAND_ENCODER.writeToBuffer(bufferSlice, indexBuffer);
|
COMMAND_ENCODER.writeToBuffer(bufferSlice, indexBuffer);
|
||||||
|
|
||||||
MemoryUtil.memFree(indexBuffer);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static String getIndexBufferName() { return "distantHorizons:LodIndexBuffer"; }
|
private static String getIndexBufferName() { return "distantHorizons:LodIndexBuffer"; }
|
||||||
|
|||||||
+19
-9
@@ -13,7 +13,7 @@ import com.mojang.blaze3d.textures.*;
|
|||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.util.ColorUtil;
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
|
|
||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
@@ -79,21 +79,30 @@ public class BlazeTextureWrapper
|
|||||||
//=======//
|
//=======//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
/** does nothing if the texture is already created and the correct size */
|
/**
|
||||||
public void tryCreateOrResize()
|
* does nothing if the texture is already created and the correct size
|
||||||
|
* @return true if the texture was (re)created
|
||||||
|
*/
|
||||||
|
public boolean tryCreateOrResize()
|
||||||
{
|
{
|
||||||
this.tryCreateTexture();
|
boolean textureChanged = this.tryCreateTexture();
|
||||||
this.tryCreateSampler();
|
this.tryCreateSampler();
|
||||||
|
return textureChanged;
|
||||||
}
|
}
|
||||||
private void tryCreateTexture()
|
private boolean tryCreateTexture()
|
||||||
{
|
{
|
||||||
int viewWidth = MC_RENDER.getTargetFramebufferViewportWidth();
|
int viewWidth = MC_RENDER.getTargetFramebufferViewportWidth();
|
||||||
int viewHeight = MC_RENDER.getTargetFramebufferViewportHeight();
|
int viewHeight = MC_RENDER.getTargetFramebufferViewportHeight();
|
||||||
|
|
||||||
if (this.texture == null
|
if (this.texture != null
|
||||||
|| this.width != viewWidth
|
&& this.width == viewWidth
|
||||||
|| this.height != viewHeight)
|
&& this.height == viewHeight)
|
||||||
{
|
{
|
||||||
|
// no changes needed
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this.texture != null)
|
if (this.texture != null)
|
||||||
{
|
{
|
||||||
this.texture.close();
|
this.texture.close();
|
||||||
@@ -114,7 +123,8 @@ public class BlazeTextureWrapper
|
|||||||
/*depthOrLayers*/ 1, /*mipLevels*/ 1
|
/*depthOrLayers*/ 1, /*mipLevels*/ 1
|
||||||
);
|
);
|
||||||
this.textureView = GPU_DEVICE.createTextureView(this.texture);
|
this.textureView = GPU_DEVICE.createTextureView(this.texture);
|
||||||
}
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
private void tryCreateSampler()
|
private void tryCreateSampler()
|
||||||
{
|
{
|
||||||
|
|||||||
+5
-8
@@ -10,10 +10,10 @@ import com.seibel.distanthorizons.common.render.openGl.glObject.GLProxy;
|
|||||||
import com.seibel.distanthorizons.common.render.openGl.glObject.GlDhFramebuffer;
|
import com.seibel.distanthorizons.common.render.openGl.glObject.GlDhFramebuffer;
|
||||||
import com.seibel.distanthorizons.common.render.openGl.glObject.texture.*;
|
import com.seibel.distanthorizons.common.render.openGl.glObject.texture.*;
|
||||||
import com.seibel.distanthorizons.common.render.openGl.postProcessing.apply.GlDhApplyShader;
|
import com.seibel.distanthorizons.common.render.openGl.postProcessing.apply.GlDhApplyShader;
|
||||||
import com.seibel.distanthorizons.common.render.openGl.terrain.GlDhTerrainShaderProgram;
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
|
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
@@ -21,7 +21,7 @@ import com.seibel.distanthorizons.core.render.DhApiRenderProxy;
|
|||||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.ILightMapWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.ILightMapWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.AbstractOptifineAccessor;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhMetaRenderer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhMetaRenderer;
|
||||||
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
||||||
import com.seibel.distanthorizons.coreapi.DependencyInjection.OverrideInjector;
|
import com.seibel.distanthorizons.coreapi.DependencyInjection.OverrideInjector;
|
||||||
@@ -45,6 +45,8 @@ public class GlDhMetaRenderer implements IDhMetaRenderer
|
|||||||
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
||||||
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
|
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
|
||||||
|
|
||||||
|
private static final IOptifineAccessor OPTIFINE_ACCESSOR = ModAccessorInjector.INSTANCE.get(IOptifineAccessor.class);
|
||||||
|
|
||||||
|
|
||||||
private int activeFramebufferId = -1;
|
private int activeFramebufferId = -1;
|
||||||
private int activeColorTextureId = -1;
|
private int activeColorTextureId = -1;
|
||||||
@@ -242,7 +244,7 @@ public class GlDhMetaRenderer implements IDhMetaRenderer
|
|||||||
|
|
||||||
|
|
||||||
// create or get the frame buffer
|
// create or get the frame buffer
|
||||||
if (AbstractOptifineAccessor.optifinePresent())
|
if (OPTIFINE_ACCESSOR != null)
|
||||||
{
|
{
|
||||||
// use MC/Optifine's default Framebuffer so shaders won't remove the LODs
|
// use MC/Optifine's default Framebuffer so shaders won't remove the LODs
|
||||||
int currentFramebufferId = MC_RENDER.getTargetFramebuffer();
|
int currentFramebufferId = MC_RENDER.getTargetFramebuffer();
|
||||||
@@ -383,10 +385,6 @@ public class GlDhMetaRenderer implements IDhMetaRenderer
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// needs to be fired after all the textures have been created/bound
|
|
||||||
boolean clearTextures = !ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeTextureClearEvent.class, renderParams);
|
|
||||||
if (clearTextures)
|
|
||||||
{
|
|
||||||
GL32.glClearDepth(1.0);
|
GL32.glClearDepth(1.0);
|
||||||
|
|
||||||
float[] clearColorValues = new float[4];
|
float[] clearColorValues = new float[4];
|
||||||
@@ -408,7 +406,6 @@ public class GlDhMetaRenderer implements IDhMetaRenderer
|
|||||||
{
|
{
|
||||||
GL32.glClear(GL32.GL_COLOR_BUFFER_BIT | GL32.GL_DEPTH_BUFFER_BIT);
|
GL32.glClear(GL32.GL_COLOR_BUFFER_BIT | GL32.GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+35
-15
@@ -413,7 +413,8 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
|
|
||||||
// render setup //
|
// render setup //
|
||||||
profiler.push("setup");
|
try (IProfilerWrapper.IProfileBlock setup_profile = profiler.push("setup"))
|
||||||
|
{
|
||||||
|
|
||||||
this.init();
|
this.init();
|
||||||
|
|
||||||
@@ -504,8 +505,9 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
// render //
|
// render //
|
||||||
|
|
||||||
profiler.popPush("rendering");
|
profiler.popPush("rendering");
|
||||||
profiler.push(boxGroup.getResourceLocationNamespace());
|
try (IProfilerWrapper.IProfileBlock namespace_profile = profiler.push(boxGroup.getResourceLocationNamespace());
|
||||||
profiler.push(boxGroup.getResourceLocationPath());
|
IProfilerWrapper.IProfileBlock location_profile = profiler.push(boxGroup.getResourceLocationPath()))
|
||||||
|
{
|
||||||
if (this.instancedRenderingAvailable)
|
if (this.instancedRenderingAvailable)
|
||||||
{
|
{
|
||||||
this.renderBoxGroupInstanced(shaderProgram, renderEventParam, boxGroup, camPos, profiler);
|
this.renderBoxGroupInstanced(shaderProgram, renderEventParam, boxGroup, camPos, profiler);
|
||||||
@@ -514,8 +516,7 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
{
|
{
|
||||||
this.renderBoxGroupDirect(shaderProgram, renderEventParam, boxGroup, camPos, profiler);
|
this.renderBoxGroupDirect(shaderProgram, renderEventParam, boxGroup, camPos, profiler);
|
||||||
}
|
}
|
||||||
profiler.pop(); // resource path
|
}
|
||||||
profiler.pop(); // resource namespace
|
|
||||||
|
|
||||||
boxGroup.postRender(renderEventParam);
|
boxGroup.postRender(renderEventParam);
|
||||||
}
|
}
|
||||||
@@ -538,8 +539,7 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
shaderProgram.unbind();
|
shaderProgram.unbind();
|
||||||
|
}
|
||||||
profiler.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
@@ -556,10 +556,10 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
RenderableBoxGroup boxGroup, Vec3d camPos,
|
RenderableBoxGroup boxGroup, Vec3d camPos,
|
||||||
IProfilerWrapper profiler)
|
IProfilerWrapper profiler)
|
||||||
{
|
{
|
||||||
|
try (IProfilerWrapper.IProfileBlock render_profile = profiler.push("vertex setup"))
|
||||||
|
{
|
||||||
|
|
||||||
// update instance data //
|
// update instance data //
|
||||||
|
|
||||||
profiler.push("vertex setup");
|
|
||||||
|
|
||||||
DhApiRenderableBoxGroupShading shading = boxGroup.shading;
|
DhApiRenderableBoxGroupShading shading = boxGroup.shading;
|
||||||
if (shading == null)
|
if (shading == null)
|
||||||
{
|
{
|
||||||
@@ -576,7 +576,7 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
// Bind instance data //
|
// Bind instance data //
|
||||||
profiler.popPush("binding");
|
profiler.popPush("binding");
|
||||||
|
|
||||||
GlGenericObjectVertexContainer container = (GlGenericObjectVertexContainer)(boxGroup.vertexBufferContainer);
|
GlGenericObjectVertexContainer container = (GlGenericObjectVertexContainer) (boxGroup.vertexBufferContainer);
|
||||||
|
|
||||||
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, container.color);
|
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, container.color);
|
||||||
GL32.glEnableVertexAttribArray(1);
|
GL32.glEnableVertexAttribArray(1);
|
||||||
@@ -620,8 +620,7 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
GL32.glDisableVertexAttribArray(3);
|
GL32.glDisableVertexAttribArray(3);
|
||||||
GL32.glDisableVertexAttribArray(4);
|
GL32.glDisableVertexAttribArray(4);
|
||||||
GL32.glDisableVertexAttribArray(5);
|
GL32.glDisableVertexAttribArray(5);
|
||||||
|
}
|
||||||
profiler.pop();
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Clean way to handle both {@link GL33#glVertexAttribDivisor} and {@link ARBInstancedArrays#glVertexAttribDivisorARB}
|
* Clean way to handle both {@link GL33#glVertexAttribDivisor} and {@link ARBInstancedArrays#glVertexAttribDivisorARB}
|
||||||
@@ -689,8 +688,6 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
profiler.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
@@ -751,4 +748,27 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//================//
|
||||||
|
// base overrides //
|
||||||
|
//================//
|
||||||
|
//region
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
if (this.boxVertexBuffer != null)
|
||||||
|
{
|
||||||
|
this.boxVertexBuffer.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.boxIndexBuffer != null)
|
||||||
|
{
|
||||||
|
this.boxIndexBuffer.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-9
@@ -21,13 +21,17 @@ package com.seibel.distanthorizons.common.render.openGl.glObject;
|
|||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiGLErrorHandlingMode;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiGLErrorHandlingMode;
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
|
||||||
|
import com.seibel.distanthorizons.api.enums.config.EDhApiLoggerLevel;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
|
import com.seibel.distanthorizons.core.config.types.ConfigEntry;
|
||||||
|
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.jar.EPlatform;
|
import com.seibel.distanthorizons.core.jar.EPlatform;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.util.objects.GLMessages.*;
|
import com.seibel.distanthorizons.core.util.objects.GLMessages.*;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IIrisAccessor;
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
import org.lwjgl.opengl.GL;
|
import org.lwjgl.opengl.GL;
|
||||||
@@ -46,10 +50,30 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
*/
|
*/
|
||||||
public class GLProxy
|
public class GLProxy
|
||||||
{
|
{
|
||||||
public static final DhLogger LOGGER = new DhLoggerBuilder()
|
private static final IIrisAccessor IRIS_ACCESSOR = ModAccessorInjector.INSTANCE.get(IIrisAccessor.class);
|
||||||
.fileLevelConfig(Config.Common.Logging.logRendererGLEventToFile)
|
|
||||||
.chatLevelConfig(Config.Common.Logging.logRendererGLEventToChat)
|
public static final DhLogger LOGGER;
|
||||||
.build();
|
static
|
||||||
|
{
|
||||||
|
DhLoggerBuilder loggerBuilder = new DhLoggerBuilder();
|
||||||
|
loggerBuilder.fileLevelConfig(Config.Common.Logging.logRendererGLEventToFile);
|
||||||
|
|
||||||
|
// don't send chat messages if Iris is present since
|
||||||
|
// Iris is known to cause (harmless) GL errors
|
||||||
|
// and this can confuse users
|
||||||
|
boolean irisPresent = (IRIS_ACCESSOR != null);
|
||||||
|
if (!irisPresent)
|
||||||
|
{
|
||||||
|
loggerBuilder.chatLevelConfig(Config.Common.Logging.logRendererGLEventToChat);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER = loggerBuilder.build();
|
||||||
|
|
||||||
|
if (irisPresent)
|
||||||
|
{
|
||||||
|
LOGGER.info("Iris detected, Distant Horizons OpenGL error logging won't be sent in the chat due to Iris throwing known (harmless) OpenGL errors. This is a bug with Iris, not Distant Horizons.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static final Set<String> LOGGED_GL_MESSAGES = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
|
public static final Set<String> LOGGED_GL_MESSAGES = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
|
||||||
|
|
||||||
@@ -238,7 +262,7 @@ public class GLProxy
|
|||||||
//region
|
//region
|
||||||
|
|
||||||
/** this method is called on the render thread at the point of the GL Error */
|
/** this method is called on the render thread at the point of the GL Error */
|
||||||
private static void logMessage(GLMessage msg)
|
private static void logMessage(GLMessage glMessage)
|
||||||
{
|
{
|
||||||
EDhApiGLErrorHandlingMode errorHandlingMode = Config.Client.Advanced.Debugging.OpenGl.glErrorHandlingMode.get();
|
EDhApiGLErrorHandlingMode errorHandlingMode = Config.Client.Advanced.Debugging.OpenGl.glErrorHandlingMode.get();
|
||||||
if (errorHandlingMode == EDhApiGLErrorHandlingMode.IGNORE)
|
if (errorHandlingMode == EDhApiGLErrorHandlingMode.IGNORE)
|
||||||
@@ -249,19 +273,26 @@ public class GLProxy
|
|||||||
|
|
||||||
|
|
||||||
boolean onlyLogOnce = Config.Client.Advanced.Debugging.OpenGl.onlyLogGlErrorsOnce.get();
|
boolean onlyLogOnce = Config.Client.Advanced.Debugging.OpenGl.onlyLogGlErrorsOnce.get();
|
||||||
String errorMessage = "GL ERROR [" + msg.id + "] from [" + msg.source + "]: [" + msg.message + "]"+(onlyLogOnce ? " this message will only be logged once" : "")+".";
|
|
||||||
if (onlyLogOnce
|
if (onlyLogOnce
|
||||||
&& !LOGGED_GL_MESSAGES.add(errorMessage))
|
&& !LOGGED_GL_MESSAGES.add(glMessage.message))
|
||||||
{
|
{
|
||||||
// this message has already been logged
|
// this message has already been logged
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String errorMessage = "GL ERROR [" + glMessage.id + "] from [" + glMessage.source + "]: [" + glMessage.message + "].";
|
||||||
|
if (onlyLogOnce)
|
||||||
|
{
|
||||||
|
errorMessage += " This message will only be logged once.";
|
||||||
|
errorMessage += " Note: Distant Horizons will catch and log OpenGL errors from other mods, not just DH itself; if everything is rendering correctly these errors can probably be ignored.";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// create an exception so we get a stacktrace of where the message was triggered from
|
// create an exception so we get a stacktrace of where the message was triggered from
|
||||||
RuntimeException exception = new RuntimeException(errorMessage);
|
RuntimeException exception = new RuntimeException(errorMessage);
|
||||||
|
|
||||||
if (msg.type == EGLMessageType.ERROR || msg.type == EGLMessageType.UNDEFINED_BEHAVIOR)
|
if (glMessage.type == EGLMessageType.ERROR || glMessage.type == EGLMessageType.UNDEFINED_BEHAVIOR)
|
||||||
{
|
{
|
||||||
// critical error
|
// critical error
|
||||||
|
|
||||||
@@ -278,7 +309,7 @@ public class GLProxy
|
|||||||
{
|
{
|
||||||
// non-critical log
|
// non-critical log
|
||||||
|
|
||||||
EGLMessageSeverity severity = msg.severity;
|
EGLMessageSeverity severity = glMessage.severity;
|
||||||
if (severity == null)
|
if (severity == null)
|
||||||
{
|
{
|
||||||
// just in case the message was malformed
|
// just in case the message was malformed
|
||||||
|
|||||||
+287
-41
@@ -21,14 +21,19 @@ package com.seibel.distanthorizons.common.render.openGl.glObject.buffer;
|
|||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
|
||||||
import com.seibel.distanthorizons.common.render.openGl.glObject.GLProxy;
|
import com.seibel.distanthorizons.common.render.openGl.glObject.GLProxy;
|
||||||
import com.seibel.distanthorizons.common.render.openGl.glObject.GLState;
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
|
import com.seibel.distanthorizons.core.jar.EPlatform;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
import com.seibel.distanthorizons.core.logging.f3.F3Screen;
|
||||||
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
|
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
|
||||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||||
import com.seibel.distanthorizons.core.util.ThreadUtil;
|
import com.seibel.distanthorizons.core.util.ThreadUtil;
|
||||||
|
import com.seibel.distanthorizons.core.util.objects.Pair;
|
||||||
|
import com.seibel.distanthorizons.core.util.objects.pooling.PhantomLoggingHelper;
|
||||||
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
|
import com.seibel.distanthorizons.coreapi.util.StringUtil;
|
||||||
import org.lwjgl.opengl.GL32;
|
import org.lwjgl.opengl.GL32;
|
||||||
import org.lwjgl.opengl.GL44;
|
import org.lwjgl.opengl.GL44;
|
||||||
|
|
||||||
@@ -36,9 +41,12 @@ import java.lang.ref.PhantomReference;
|
|||||||
import java.lang.ref.Reference;
|
import java.lang.ref.Reference;
|
||||||
import java.lang.ref.ReferenceQueue;
|
import java.lang.ref.ReferenceQueue;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.locks.StampedLock;
|
||||||
|
|
||||||
public class GLBuffer implements AutoCloseable
|
public class GLBuffer implements AutoCloseable
|
||||||
{
|
{
|
||||||
@@ -50,26 +58,57 @@ public class GLBuffer implements AutoCloseable
|
|||||||
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
|
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
|
||||||
|
|
||||||
|
|
||||||
|
// TODO move to a shared location that can be handled by both GL and Blaze3D buffers
|
||||||
|
/** if enabled the number of GC'ed buffers will be logged */
|
||||||
|
private static final boolean LOG_PHANTOM_RECOVERY = ModInfo.IS_DEV_BUILD;
|
||||||
|
/** If enabled buffers allocation/upload stacks will be logged when GC'ed. */
|
||||||
|
private static final boolean LOG_PHANTOM_ALLOCATION_STACKS = false; // disabled by default due to the increased GC load
|
||||||
|
|
||||||
public static final double BUFFER_EXPANSION_MULTIPLIER = 1.3;
|
public static final double BUFFER_EXPANSION_MULTIPLIER = 1.3;
|
||||||
public static final double BUFFER_SHRINK_TRIGGER = BUFFER_EXPANSION_MULTIPLIER * BUFFER_EXPANSION_MULTIPLIER;
|
public static final double BUFFER_SHRINK_TRIGGER = BUFFER_EXPANSION_MULTIPLIER * BUFFER_EXPANSION_MULTIPLIER;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On macOS the legacy OpenGL -> Metal bridge crashes with SIGBUS in
|
||||||
|
* {@code _platform_memmove} when {@code glBufferData} or {@code glBufferSubData}
|
||||||
|
* are called with a large ByteBuffer in one shot. To work around it, we split
|
||||||
|
* the upload into smaller sub-data calls that each fit comfortably inside the
|
||||||
|
* driver's internal staging path. <br>
|
||||||
|
* 256 KiB tuned empirically against macOS 26.5 — a 1 MiB chunk still
|
||||||
|
* tripped the same {@code _platform_memmove} crash inside
|
||||||
|
* {@code glBufferSubData_Exec}, but 256 KiB consistently survives.
|
||||||
|
*/
|
||||||
|
public static final int MAC_UPLOAD_CHUNK_BYTES = 256 * 1024;
|
||||||
|
/** Threshold above which the chunked path kicks in on macOS. */
|
||||||
|
public static final int MAC_UPLOAD_CHUNK_THRESHOLD = MAC_UPLOAD_CHUNK_BYTES;
|
||||||
/** the number of active buffers, can be used for debugging */
|
/** the number of active buffers, can be used for debugging */
|
||||||
public static AtomicInteger bufferCount = new AtomicInteger(0);
|
public static AtomicInteger bufferCount = new AtomicInteger(0);
|
||||||
|
|
||||||
private static final int PHANTOM_REF_CHECK_TIME_IN_MS = 5 * 1000;
|
private static final int PHANTOM_REF_CHECK_TIME_IN_MS = 5 * 1000;
|
||||||
private static final ConcurrentHashMap<PhantomReference<? extends GLBuffer>, Integer> PHANTOM_TO_BUFFER_ID = new ConcurrentHashMap<>();
|
private static final ConcurrentHashMap<PhantomReference<? extends GLBuffer>, Integer> PHANTOM_TO_BUFFER_ID = new ConcurrentHashMap<>();
|
||||||
private static final ConcurrentHashMap<Integer, PhantomReference<? extends GLBuffer>> BUFFER_ID_TO_PHANTOM = new ConcurrentHashMap<>();
|
private static final ConcurrentHashMap<Integer, PhantomReference<? extends GLBuffer>> BUFFER_ID_TO_PHANTOM = new ConcurrentHashMap<>();
|
||||||
|
private static final ConcurrentHashMap<Integer, String> BUFFER_ID_TO_ALLOCATION_STRING = new ConcurrentHashMap<>();
|
||||||
private static final ReferenceQueue<GLBuffer> PHANTOM_REFERENCE_QUEUE = new ReferenceQueue<>();
|
private static final ReferenceQueue<GLBuffer> PHANTOM_REFERENCE_QUEUE = new ReferenceQueue<>();
|
||||||
private static final ThreadPoolExecutor CLEANUP_THREAD = ThreadUtil.makeSingleDaemonThreadPool("GLBuffer Cleanup");
|
private static final ThreadPoolExecutor CLEANUP_THREAD = ThreadUtil.makeSingleDaemonThreadPool("GLBuffer Cleanup");
|
||||||
|
|
||||||
|
|
||||||
protected int id;
|
protected volatile int id = 0;
|
||||||
public final int getId() { return this.id; }
|
public final int getId() { return this.id; }
|
||||||
protected int size = 0;
|
protected int size = 0;
|
||||||
public int getSize() { return this.size; }
|
public int getSize() { return this.size; }
|
||||||
protected boolean bufferStorage;
|
protected boolean bufferStorage;
|
||||||
public final boolean isBufferStorage() { return this.bufferStorage; }
|
|
||||||
protected boolean isMapped = false;
|
protected boolean isMapped = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locking on the render thread isn't great, but is needed due to an inconsistent
|
||||||
|
* race condition where VBOs can be marked as deleted outside the render thread. <br><br>
|
||||||
|
*
|
||||||
|
* But, due to being a read-write lock the chance of freezing
|
||||||
|
* the render thread is very low
|
||||||
|
* and since this is a stamped lock, the optimistic read time is basically zero.
|
||||||
|
* (The optimistic lock time doesn't even appear in the profiler).
|
||||||
|
*/
|
||||||
|
public final StampedLock renderStampLock = new StampedLock();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==============//
|
//==============//
|
||||||
@@ -112,13 +151,28 @@ public class GLBuffer implements AutoCloseable
|
|||||||
LodUtil.assertNotReach("Thread ["+Thread.currentThread()+"] tried to create a GLBuffer outside the MC render thread.");
|
LodUtil.assertNotReach("Thread ["+Thread.currentThread()+"] tried to create a GLBuffer outside the MC render thread.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// destroy the old buffer if one is present
|
|
||||||
if (this.id != 0)
|
// lock to prevent the render thread from accessing the buffer's ID
|
||||||
|
// while we are removing it
|
||||||
|
long writeStamp = renderStampLock.writeLock();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
destroyBufferIdNow(this.id);
|
final int oldId = this.id;
|
||||||
|
this.id = GLMC.glGenBuffers();
|
||||||
|
//LOGGER.info("created [" + newId + "].");
|
||||||
|
|
||||||
|
// destroy the old buffer
|
||||||
|
// after the new one has been created
|
||||||
|
// to hopefully prevent a rare race conditions where the old ID
|
||||||
|
// is still used somewhere
|
||||||
|
if (oldId != 0)
|
||||||
|
{
|
||||||
|
// this ID doesn't need to be tracked anymore
|
||||||
|
tryRemoveBufferIdFromPhantom(oldId);
|
||||||
|
destroyBufferIdNow(oldId, "destroyOldAndCreate");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.id = GLMC.glGenBuffers();
|
|
||||||
this.bufferStorage = asBufferStorage;
|
this.bufferStorage = asBufferStorage;
|
||||||
bufferCount.getAndIncrement();
|
bufferCount.getAndIncrement();
|
||||||
|
|
||||||
@@ -126,9 +180,20 @@ public class GLBuffer implements AutoCloseable
|
|||||||
PHANTOM_TO_BUFFER_ID.put(phantom, this.id);
|
PHANTOM_TO_BUFFER_ID.put(phantom, this.id);
|
||||||
BUFFER_ID_TO_PHANTOM.put(this.id, phantom);
|
BUFFER_ID_TO_PHANTOM.put(this.id, phantom);
|
||||||
|
|
||||||
|
this.updateAllocationStackTrace();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
renderStampLock.unlock(writeStamp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void destroyAsync()
|
protected void destroyAsync()
|
||||||
|
{
|
||||||
|
// lock to prevent the render thread from accessing the buffer's ID
|
||||||
|
// while we are removing it
|
||||||
|
long writeStamp = renderStampLock.writeLock();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (this.id == 0)
|
if (this.id == 0)
|
||||||
{
|
{
|
||||||
@@ -137,47 +202,68 @@ public class GLBuffer implements AutoCloseable
|
|||||||
}
|
}
|
||||||
|
|
||||||
final int idToDelete = this.id; // saving the ID to a separate variable is necessary so it can be captured by the lambda
|
final int idToDelete = this.id; // saving the ID to a separate variable is necessary so it can be captured by the lambda
|
||||||
RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("GLBuffer destroyAsync", () -> { destroyBufferIdNow(idToDelete); });
|
|
||||||
|
|
||||||
|
// remove the phantom tracking now so the phantom doesn't have the chance to
|
||||||
|
// get garbage collected before the render thread task runs
|
||||||
|
// (this can happen if MC is running at extremely low framerates like 1 fps via mods)
|
||||||
|
tryRemoveBufferIdFromPhantom(idToDelete);
|
||||||
|
|
||||||
|
// mark the old data is invalid before deleting to prevent a rare race condition
|
||||||
|
// where the queued on render thread task runs before the ID is cleared
|
||||||
this.id = 0;
|
this.id = 0;
|
||||||
this.size = 0;
|
this.size = 0;
|
||||||
|
|
||||||
|
//LOGGER.info("async destroy [" + idToDelete + "].");
|
||||||
|
RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("GLBuffer destroyAsync", () -> { destroyBufferIdNow(idToDelete, "destroyAsync"); });
|
||||||
}
|
}
|
||||||
private static void destroyBufferIdNow(int id)
|
finally
|
||||||
|
{
|
||||||
|
renderStampLock.unlock(writeStamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void destroyBufferIdNow(int id, String cause)
|
||||||
{
|
{
|
||||||
// only delete valid buffers
|
// only delete valid buffers
|
||||||
if (id == 0)
|
if (id == 0)
|
||||||
{
|
{
|
||||||
LOGGER.warn("Attempted to destroy a buffer with ID 0, VRAM memory leaks may occur.");
|
LOGGER.warn("Attempted to destroy a buffer with ID 0, VRAM memory leaks may occur, cause: ["+cause+"].");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove and clear the phantom reference if present
|
bufferCount.decrementAndGet();
|
||||||
if (BUFFER_ID_TO_PHANTOM.containsKey(id))
|
GLMC.glDeleteBuffers(id);
|
||||||
{
|
|
||||||
Reference<? extends GLBuffer> phantom = BUFFER_ID_TO_PHANTOM.get(id);
|
|
||||||
|
|
||||||
|
if (Config.Client.Advanced.Debugging.logBufferGarbageCollection.get())
|
||||||
|
{
|
||||||
|
LOGGER.info("destroyed buffer [" + id + "], remaining: [" + BUFFER_ID_TO_PHANTOM.size() + "], cause: ["+cause+"].");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** should be called before {@link GLBuffer#destroyBufferIdNow} */
|
||||||
|
private static void tryRemoveBufferIdFromPhantom(int id)
|
||||||
|
{
|
||||||
|
// will contain nothing if stack tracking isn't enabled
|
||||||
|
BUFFER_ID_TO_ALLOCATION_STRING.remove(id);
|
||||||
|
|
||||||
|
PhantomReference<? extends GLBuffer> phantom = BUFFER_ID_TO_PHANTOM.remove(id);
|
||||||
|
if (phantom != null)
|
||||||
|
{
|
||||||
// if we are manually closing this buffer, we don't want the phantom reference to accidentally close it again
|
// if we are manually closing this buffer, we don't want the phantom reference to accidentally close it again
|
||||||
// this can cause a race condition were we accidentally delete an in-use buffer and cause NVIDIA
|
// this can cause a race condition were we accidentally delete an in-use buffer and cause NVIDIA
|
||||||
// to throw an EXCEPTION_ACCESS_VIOLATION when we attempt to render it
|
// to throw an EXCEPTION_ACCESS_VIOLATION when we attempt to render it
|
||||||
phantom.clear();
|
phantom.clear();
|
||||||
|
|
||||||
PHANTOM_TO_BUFFER_ID.remove(phantom);
|
Integer phantomId = PHANTOM_TO_BUFFER_ID.remove(phantom);
|
||||||
BUFFER_ID_TO_PHANTOM.remove(id);
|
if (phantomId == null)
|
||||||
}
|
|
||||||
|
|
||||||
bufferCount.decrementAndGet();
|
|
||||||
|
|
||||||
// destroy the buffer if it exists,
|
|
||||||
// the buffer may not exist if the destroy method is called twice
|
|
||||||
if (GL32.glIsBuffer(id))
|
|
||||||
{
|
{
|
||||||
GLMC.glDeleteBuffers(id);
|
LOGGER.warn("No Phantom->ID binding stored for ID ["+id+"]");
|
||||||
|
|
||||||
if (Config.Client.Advanced.Debugging.logBufferGarbageCollection.get())
|
|
||||||
{
|
|
||||||
LOGGER.info("destroyed buffer [" + id + "], remaining: [" + BUFFER_ID_TO_PHANTOM.size() + "]");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGGER.warn("Unable to remove phantom GLBuffer with ID ["+id+"], buffer may have already been deleted.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
@@ -210,9 +296,12 @@ public class GLBuffer implements AutoCloseable
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// re-binding the old VBO is necessary for old MC versions (IE 1.16.5 and older)
|
// re-binding the old buffers is necessary for old MC versions for the following reasons:
|
||||||
// otherwise the screen may be black when on the home menu
|
// for 16.5 and older the screen may be black when on the home menu
|
||||||
int previousBoundVbo = GL32.glGetInteger(GL32.GL_ARRAY_BUFFER_BINDING);
|
// and for 1.19.2 - 1.21.4 the inventory/UI will render without a background
|
||||||
|
int vao = GL32.glGetInteger(GL32.GL_VERTEX_ARRAY_BINDING);
|
||||||
|
int vbo = GL32.glGetInteger(GL32.GL_ARRAY_BUFFER_BINDING);
|
||||||
|
int ebo = GL32.glGetInteger(GL32.GL_ELEMENT_ARRAY_BUFFER_BINDING);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -238,7 +327,9 @@ public class GLBuffer implements AutoCloseable
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, GL32.glIsBuffer(previousBoundVbo) ? previousBoundVbo : 0);
|
GL32.glBindVertexArray(GL32.glIsVertexArray(vao) ? vao : 0);
|
||||||
|
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, GL32.glIsBuffer(vbo) ? vbo : 0);
|
||||||
|
GL32.glBindBuffer(GL32.GL_ELEMENT_ARRAY_BUFFER, GL32.glIsBuffer(ebo) ? ebo: 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** Requires the buffer to be bound */
|
/** Requires the buffer to be bound */
|
||||||
@@ -258,8 +349,25 @@ public class GLBuffer implements AutoCloseable
|
|||||||
LodUtil.assertTrue(!this.bufferStorage, "Buffer is bufferStorage but its trying to use bufferData upload method!");
|
LodUtil.assertTrue(!this.bufferStorage, "Buffer is bufferStorage but its trying to use bufferData upload method!");
|
||||||
|
|
||||||
int bbSize = bb.limit() - bb.position();
|
int bbSize = bb.limit() - bb.position();
|
||||||
GL32.glBufferData(this.getBufferBindingTarget(), bb, bufferDataHint);
|
int target = this.getBufferBindingTarget();
|
||||||
|
|
||||||
|
if (shouldUploadToGpuInChunks(bbSize))
|
||||||
|
{
|
||||||
|
// Two-step path used on macOS to dodge the Apple OpenGL -> Metal
|
||||||
|
// memmove SIGBUS triggered by uploading a large ByteBuffer in one
|
||||||
|
// glBufferData call:
|
||||||
|
// 1) allocate-only with the size overload (no memcpy)
|
||||||
|
// 2) fill the buffer through chunked glBufferSubData calls
|
||||||
|
GL32.glBufferData(target, (long) bbSize, bufferDataHint);
|
||||||
|
subDataUploadInChunks(target, 0, bb, MAC_UPLOAD_CHUNK_BYTES);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GL32.glBufferData(target, bb, bufferDataHint);
|
||||||
|
}
|
||||||
this.size = bbSize;
|
this.size = bbSize;
|
||||||
|
|
||||||
|
this.updateAllocationStackTrace();
|
||||||
}
|
}
|
||||||
/** Requires the buffer to be bound */
|
/** Requires the buffer to be bound */
|
||||||
protected void uploadSubData(ByteBuffer bb, int maxExpansionSize, int bufferDataHint)
|
protected void uploadSubData(ByteBuffer bb, int maxExpansionSize, int bufferDataHint)
|
||||||
@@ -267,14 +375,30 @@ public class GLBuffer implements AutoCloseable
|
|||||||
LodUtil.assertTrue(!this.bufferStorage, "Buffer is bufferStorage but its trying to use subData upload method!");
|
LodUtil.assertTrue(!this.bufferStorage, "Buffer is bufferStorage but its trying to use subData upload method!");
|
||||||
|
|
||||||
int bbSize = bb.limit() - bb.position();
|
int bbSize = bb.limit() - bb.position();
|
||||||
|
int target = this.getBufferBindingTarget();
|
||||||
if (this.size < bbSize || this.size > bbSize * BUFFER_SHRINK_TRIGGER)
|
if (this.size < bbSize || this.size > bbSize * BUFFER_SHRINK_TRIGGER)
|
||||||
{
|
{
|
||||||
int newSize = (int) (bbSize * BUFFER_EXPANSION_MULTIPLIER);
|
int newSize = (int) (bbSize * BUFFER_EXPANSION_MULTIPLIER);
|
||||||
if (newSize > maxExpansionSize) newSize = maxExpansionSize;
|
if (newSize > maxExpansionSize)
|
||||||
GL32.glBufferData(this.getBufferBindingTarget(), newSize, bufferDataHint);
|
{
|
||||||
|
newSize = maxExpansionSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// allocate-only — no memcpy, safe on macOS regardless of size
|
||||||
|
GL32.glBufferData(target, (long) newSize, bufferDataHint);
|
||||||
this.size = newSize;
|
this.size = newSize;
|
||||||
}
|
}
|
||||||
GL32.glBufferSubData(this.getBufferBindingTarget(), 0, bb);
|
|
||||||
|
if (shouldUploadToGpuInChunks(bbSize))
|
||||||
|
{
|
||||||
|
subDataUploadInChunks(target, 0, bb, MAC_UPLOAD_CHUNK_BYTES);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GL32.glBufferSubData(target, 0, bb);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateAllocationStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
@@ -316,7 +440,6 @@ public class GLBuffer implements AutoCloseable
|
|||||||
{
|
{
|
||||||
// recreate if the buffer storage type changed
|
// recreate if the buffer storage type changed
|
||||||
this.bind();
|
this.bind();
|
||||||
destroyBufferIdNow(this.id);
|
|
||||||
this.destroyOldAndCreate(uploadMethod.useBufferStorage);
|
this.destroyOldAndCreate(uploadMethod.useBufferStorage);
|
||||||
this.bind();
|
this.bind();
|
||||||
}
|
}
|
||||||
@@ -333,6 +456,91 @@ public class GLBuffer implements AutoCloseable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macOS-only mitigation for the SIGBUS in
|
||||||
|
* {@code libsystem_platform.dylib _platform_memmove} that happens when the
|
||||||
|
* Apple OpenGL -> Metal translation layer copies a single large ByteBuffer
|
||||||
|
* out of LWJGL into driver memory. Splitting the copy into
|
||||||
|
* {@link #MAC_UPLOAD_CHUNK_BYTES} slices keeps every memmove inside a size
|
||||||
|
* the bridge handles reliably.
|
||||||
|
*/
|
||||||
|
private static boolean shouldUploadToGpuInChunks(int byteCount)
|
||||||
|
{
|
||||||
|
return EPlatform.get() == EPlatform.MACOS
|
||||||
|
&& byteCount > MAC_UPLOAD_CHUNK_THRESHOLD;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uploads {@code bb} into the currently bound buffer at {@code baseOffset}
|
||||||
|
* using a sequence of {@link GL32#glBufferSubData(int, long, ByteBuffer)}
|
||||||
|
* calls of at most {@code chunkBytes} each. The buffer's position/limit are
|
||||||
|
* restored before returning.
|
||||||
|
*/
|
||||||
|
private static void subDataUploadInChunks(int target, int baseOffset, ByteBuffer bb, int chunkBytes)
|
||||||
|
{
|
||||||
|
final int origPos = bb.position();
|
||||||
|
final int origLimit = bb.limit();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final int total = origLimit - origPos;
|
||||||
|
int uploaded = 0;
|
||||||
|
while (uploaded < total)
|
||||||
|
{
|
||||||
|
int chunk = Math.min(chunkBytes, total - uploaded);
|
||||||
|
bb.position(origPos + uploaded);
|
||||||
|
bb.limit(origPos + uploaded + chunk);
|
||||||
|
GL32.glBufferSubData(target, (long) (baseOffset + uploaded), bb);
|
||||||
|
uploaded += chunk;
|
||||||
|
// Force the driver to drain its command queue between chunks
|
||||||
|
// so the OpenGL -> Metal bridge processes (and frees) each
|
||||||
|
// staging copy before the next sub-data call piles another
|
||||||
|
// memmove on top of it.
|
||||||
|
if (uploaded < total)
|
||||||
|
{
|
||||||
|
GL32.glFlush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
bb.limit(origLimit);
|
||||||
|
bb.position(origPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* used to help track down leaks where the buffer isn't properly closed
|
||||||
|
* Note: this probably needs extending to accept a stack trace from outside where it's being called
|
||||||
|
* since it's often called on the render thread in an un-helpful location.
|
||||||
|
*/
|
||||||
|
public void updateAllocationStackTrace()
|
||||||
|
{
|
||||||
|
if (LOG_PHANTOM_ALLOCATION_STACKS)
|
||||||
|
{
|
||||||
|
String stack;
|
||||||
|
|
||||||
|
RenderThreadTaskHandler.QueuedRunnable parentQueuedRunnable;
|
||||||
|
// if this is running on the render thread, try getting the render task's stack trace instead
|
||||||
|
// since it's a lot more helpful than wherever the render thread tasks themselves are being run from
|
||||||
|
if (RenderThreadTaskHandler.INSTANCE.isCurrentThread()
|
||||||
|
&& (parentQueuedRunnable = RenderThreadTaskHandler.INSTANCE.getCurrentlyRunningTask()) != null
|
||||||
|
&& parentQueuedRunnable.stackTrace != null)
|
||||||
|
{
|
||||||
|
// trim off the getStacktrace() and queueRunningOnRenderThread() methods
|
||||||
|
StackTraceElement[] trimmedElements = Arrays.copyOfRange(parentQueuedRunnable.stackTrace, 2, parentQueuedRunnable.stackTrace.length);
|
||||||
|
stack = StringUtil.join("\n", trimmedElements).intern();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// not running on the render thread, use the normal stack trace
|
||||||
|
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
||||||
|
stack = StringUtil.join("\n", stackTraceElements).intern();
|
||||||
|
}
|
||||||
|
|
||||||
|
BUFFER_ID_TO_ALLOCATION_STRING.put(this.id, stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -344,8 +552,13 @@ public class GLBuffer implements AutoCloseable
|
|||||||
|
|
||||||
private static void runPhantomReferenceCleanupLoop()
|
private static void runPhantomReferenceCleanupLoop()
|
||||||
{
|
{
|
||||||
|
// these arrays are stored here so they don't have to be re-allocated each loop
|
||||||
|
ArrayList<Pair<String, AtomicInteger>> allocationStackTraceCountPairList = new ArrayList<>();
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
allocationStackTraceCountPairList.clear();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -354,20 +567,53 @@ public class GLBuffer implements AutoCloseable
|
|||||||
}
|
}
|
||||||
catch (InterruptedException ignore) { }
|
catch (InterruptedException ignore) { }
|
||||||
|
|
||||||
|
int collectedCount = 0;
|
||||||
|
|
||||||
Reference<? extends GLBuffer> phantomRef = PHANTOM_REFERENCE_QUEUE.poll();
|
Reference<? extends GLBuffer> phantomRef = PHANTOM_REFERENCE_QUEUE.poll();
|
||||||
while (phantomRef != null)
|
while (phantomRef != null)
|
||||||
{
|
{
|
||||||
// destroy the buffer if it hasn't been cleared yet
|
// destroy the buffer if it hasn't been cleared yet
|
||||||
if (PHANTOM_TO_BUFFER_ID.containsKey(phantomRef))
|
Integer idRef = PHANTOM_TO_BUFFER_ID.remove((PhantomReference<? extends GLBuffer>)phantomRef); // cast to make IntelliJ happy
|
||||||
|
if (idRef != null)
|
||||||
{
|
{
|
||||||
int id = PHANTOM_TO_BUFFER_ID.get(phantomRef);
|
BUFFER_ID_TO_PHANTOM.remove(idRef);
|
||||||
RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("GLBuffer phantom destroy", () -> { destroyBufferIdNow(id); });
|
final int id = idRef;
|
||||||
//LOGGER.warn("Buffer Phantom collected, ID: ["+id+"]");
|
RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("GLBuffer phantom destroy", () -> { destroyBufferIdNow(id, "runPhantomReferenceCleanupLoop"); });
|
||||||
|
//LOGGER.info("Buffer Phantom collected, ID: ["+id+"]");
|
||||||
|
|
||||||
|
if (LOG_PHANTOM_ALLOCATION_STACKS) // stack trace shouldn't be null, but just in case
|
||||||
|
{
|
||||||
|
String stack = BUFFER_ID_TO_ALLOCATION_STRING.get(idRef);
|
||||||
|
PhantomLoggingHelper.putAndIncrementTrackingString(stack, allocationStackTraceCountPairList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGGER.warn("Failed to find Buffer ID for phantom reference: ["+phantomRef+"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
collectedCount++;
|
||||||
phantomRef = PHANTOM_REFERENCE_QUEUE.poll();
|
phantomRef = PHANTOM_REFERENCE_QUEUE.poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (LOG_PHANTOM_RECOVERY)
|
||||||
|
{
|
||||||
|
// we only want to log when something has been returned
|
||||||
|
if (collectedCount != 0)
|
||||||
|
{
|
||||||
|
LOGGER.warn("GLBuffer phantom recovered: ["+ F3Screen.NUMBER_FORMAT.format(collectedCount)+"].");
|
||||||
|
|
||||||
|
// log stack traces if present
|
||||||
|
if (LOG_PHANTOM_ALLOCATION_STACKS)
|
||||||
|
{
|
||||||
|
PhantomLoggingHelper.LogAllocationStackTracePairCounts(LOGGER, allocationStackTraceCountPairList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
+5
-4
@@ -37,10 +37,11 @@ public class GLIndexBuffer extends GLBuffer
|
|||||||
protected int glType = GL32.GL_UNSIGNED_INT;
|
protected int glType = GL32.GL_UNSIGNED_INT;
|
||||||
public int getGlType() { return this.glType; }
|
public int getGlType() { return this.glType; }
|
||||||
|
|
||||||
public GLIndexBuffer(boolean isBufferStorage)
|
|
||||||
{
|
|
||||||
super(isBufferStorage);
|
public GLIndexBuffer(boolean isBufferStorage) { super(isBufferStorage); }
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroyAsync()
|
public void destroyAsync()
|
||||||
|
|||||||
+7
-3
@@ -22,15 +22,16 @@ package com.seibel.distanthorizons.common.render.openGl.glObject.buffer;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.common.render.openGl.glObject.GLProxy;
|
import com.seibel.distanthorizons.common.render.openGl.glObject.GLProxy;
|
||||||
|
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.IndexBufferBuilder;
|
||||||
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodQuadBuilder;
|
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodQuadBuilder;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.jar.EPlatform;
|
|
||||||
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
|
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IVertexBufferWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IVertexBufferWrapper;
|
||||||
import org.lwjgl.opengl.GL32;
|
import org.lwjgl.opengl.GL32;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
|
||||||
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a container for a OpenGL
|
* This is a container for a OpenGL
|
||||||
@@ -83,7 +84,10 @@ public class GLVertexBuffer extends GLBuffer implements IVertexBufferWrapper
|
|||||||
int maxSize = LodQuadBuilder.getMaxBufferByteSize();
|
int maxSize = LodQuadBuilder.getMaxBufferByteSize();
|
||||||
int maxVertexCount = maxSize / LodQuadBuilder.BYTES_PER_VERTEX;
|
int maxVertexCount = maxSize / LodQuadBuilder.BYTES_PER_VERTEX;
|
||||||
int maxQuadCount = (maxVertexCount / 4);
|
int maxQuadCount = (maxVertexCount / 4);
|
||||||
GLOBAL_QUAD_IBO.upload(maxQuadCount);
|
|
||||||
|
ByteBuffer buffer = IndexBufferBuilder.createBuffer(maxQuadCount);
|
||||||
|
GLOBAL_QUAD_IBO.upload(buffer, maxQuadCount);
|
||||||
|
MemoryUtil.memFree(buffer);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,7 +162,7 @@ public class GLVertexBuffer extends GLBuffer implements IVertexBufferWrapper
|
|||||||
this.quadIBO = new GlQuadIndexBuffer();
|
this.quadIBO = new GlQuadIndexBuffer();
|
||||||
|
|
||||||
int quadCount = (vertexCount / 4);
|
int quadCount = (vertexCount / 4);
|
||||||
this.quadIBO.upload(quadCount);
|
this.quadIBO.upload(buffer, quadCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|||||||
+1
-5
@@ -43,7 +43,7 @@ public class GlQuadIndexBuffer extends GLIndexBuffer
|
|||||||
|
|
||||||
public GlQuadIndexBuffer() { super(false); }
|
public GlQuadIndexBuffer() { super(false); }
|
||||||
|
|
||||||
public void upload(int quadCount)
|
public void upload(ByteBuffer buffer, int quadCount)
|
||||||
{
|
{
|
||||||
if (quadCount < 0)
|
if (quadCount < 0)
|
||||||
{
|
{
|
||||||
@@ -63,12 +63,8 @@ public class GlQuadIndexBuffer extends GLIndexBuffer
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.glType = GL32.GL_UNSIGNED_INT;
|
this.glType = GL32.GL_UNSIGNED_INT;
|
||||||
ByteBuffer buffer = IndexBufferBuilder.createBuffer(quadCount);
|
|
||||||
this.bind();
|
|
||||||
super.uploadBuffer(buffer, EDhApiGpuUploadMethod.DATA,
|
super.uploadBuffer(buffer, EDhApiGpuUploadMethod.DATA,
|
||||||
this.indicesCount * GLEnums.getTypeSize(this.glType), GL32.GL_STATIC_DRAW);
|
this.indicesCount * GLEnums.getTypeSize(this.glType), GL32.GL_STATIC_DRAW);
|
||||||
|
|
||||||
MemoryUtil.memFree(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|||||||
-8
@@ -122,8 +122,6 @@ public class GlDhFarFadeRenderer implements IDhFarFadeRenderer
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//profiler.push("Fade Generate");
|
|
||||||
|
|
||||||
this.init();
|
this.init();
|
||||||
|
|
||||||
// resize the framebuffer if necessary
|
// resize the framebuffer if necessary
|
||||||
@@ -141,8 +139,6 @@ public class GlDhFarFadeRenderer implements IDhFarFadeRenderer
|
|||||||
GlDhFarFadeShader.INSTANCE.setProjectionMatrix(renderParams.mcModelViewMatrix, renderParams.mcProjectionMatrix);
|
GlDhFarFadeShader.INSTANCE.setProjectionMatrix(renderParams.mcModelViewMatrix, renderParams.mcProjectionMatrix);
|
||||||
GlDhFarFadeShader.INSTANCE.render(renderParams);
|
GlDhFarFadeShader.INSTANCE.render(renderParams);
|
||||||
|
|
||||||
//profiler.popPush("Fade Apply");
|
|
||||||
|
|
||||||
GlDhFarFadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
|
GlDhFarFadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
|
||||||
GlDhFarFadeApplyShader.INSTANCE.readFramebuffer = GlDhFarFadeShader.INSTANCE.frameBuffer;
|
GlDhFarFadeApplyShader.INSTANCE.readFramebuffer = GlDhFarFadeShader.INSTANCE.frameBuffer;
|
||||||
GlDhFarFadeApplyShader.INSTANCE.drawFramebuffer = GlDhMetaRenderer.INSTANCE.getActiveFramebufferId();
|
GlDhFarFadeApplyShader.INSTANCE.drawFramebuffer = GlDhMetaRenderer.INSTANCE.getActiveFramebufferId();
|
||||||
@@ -152,10 +148,6 @@ public class GlDhFarFadeRenderer implements IDhFarFadeRenderer
|
|||||||
{
|
{
|
||||||
LOGGER.error("Unexpected error during fade render, error: ["+e.getMessage()+"].", e);
|
LOGGER.error("Unexpected error during fade render, error: ["+e.getMessage()+"].", e);
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
//profiler.pop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//emdregion
|
//emdregion
|
||||||
|
|||||||
+3
-12
@@ -135,14 +135,9 @@ public class GlVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
|
|
||||||
|
|
||||||
IProfilerWrapper profiler = MC_CLIENT.getProfiler();
|
IProfilerWrapper profiler = MC_CLIENT.getProfiler();
|
||||||
profiler.pop(); // get out of "terrain"
|
try (IProfilerWrapper.IProfileBlock fade_profile = profiler.push("DH-Vanilla Fade");
|
||||||
profiler.push("DH-Vanilla Fade");
|
GLState mcState = new GLState())
|
||||||
|
|
||||||
|
|
||||||
try(GLState mcState = new GLState())
|
|
||||||
{
|
{
|
||||||
profiler.push("Vanilla Fade Generate");
|
|
||||||
|
|
||||||
this.init();
|
this.init();
|
||||||
|
|
||||||
// resize the framebuffer if necessary
|
// resize the framebuffer if necessary
|
||||||
@@ -165,19 +160,15 @@ public class GlVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
// otherwise we can directly render to their texture
|
// otherwise we can directly render to their texture
|
||||||
if (MC_RENDER.mcRendersToFrameBuffer())
|
if (MC_RENDER.mcRendersToFrameBuffer())
|
||||||
{
|
{
|
||||||
profiler.popPush("Vanilla Fade Apply");
|
|
||||||
|
|
||||||
GlDhFarFadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
|
GlDhFarFadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
|
||||||
GlDhFarFadeApplyShader.INSTANCE.readFramebuffer = GlDhVanillaFadeShader.INSTANCE.frameBuffer;
|
GlDhFarFadeApplyShader.INSTANCE.readFramebuffer = GlDhVanillaFadeShader.INSTANCE.frameBuffer;
|
||||||
GlDhFarFadeApplyShader.INSTANCE.drawFramebuffer = MC_RENDER.getTargetFramebuffer();
|
GlDhFarFadeApplyShader.INSTANCE.drawFramebuffer = MC_RENDER.getTargetFramebuffer();
|
||||||
GlDhFarFadeApplyShader.INSTANCE.render(renderParams);
|
GlDhFarFadeApplyShader.INSTANCE.render(renderParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
profiler.pop();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LOGGER.error("Unexpected error during fade render, error: ["+e.getMessage()+"].", e);
|
LOGGER.error("Unexpected error during fade render, error: [" + e.getMessage() + "].", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+30
-3
@@ -289,6 +289,9 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
|
|||||||
GLMC.disableBlend();
|
GLMC.disableBlend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// needs to be triggered after DH attempts to set the GL state so that Iris
|
||||||
|
// can override it as needed
|
||||||
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -296,8 +299,6 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
|
|||||||
// rendering //
|
// rendering //
|
||||||
//===========//
|
//===========//
|
||||||
|
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam);
|
|
||||||
|
|
||||||
if (IRIS_ACCESSOR != null)
|
if (IRIS_ACCESSOR != null)
|
||||||
{
|
{
|
||||||
// done to fix a bug with Iris where face culling isn't properly set or reverted in the MC state manager
|
// done to fix a bug with Iris where face culling isn't properly set or reverted in the MC state manager
|
||||||
@@ -313,6 +314,12 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
|
|||||||
for (int lodIndex = 0; lodIndex < bufferContainers.size(); lodIndex++)
|
for (int lodIndex = 0; lodIndex < bufferContainers.size(); lodIndex++)
|
||||||
{
|
{
|
||||||
LodBufferContainer bufferContainer = bufferContainers.get(lodIndex);
|
LodBufferContainer bufferContainer = bufferContainers.get(lodIndex);
|
||||||
|
if (!bufferContainer.buffersUploaded)
|
||||||
|
{
|
||||||
|
// make sure we don't accidentally try
|
||||||
|
// rendering a buffer that is (or is going to be) freed
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// set uniforms and fire events
|
// set uniforms and fire events
|
||||||
{
|
{
|
||||||
@@ -337,13 +344,27 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// for lock information please view the lock's javadocs
|
||||||
|
long vboReadStamp = vbo.renderStampLock.readLock();
|
||||||
|
long iboReadStamp = vbo.getQuadIBO().renderStampLock.readLock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// don't render empty sections
|
||||||
if (vbo.getVertexCount() == 0)
|
if (vbo.getVertexCount() == 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// don't render deleted VBOs (this will crash the driver/game)
|
||||||
|
if (vbo.getId() == 0
|
||||||
|
|| vbo.getQuadIBO().getId() == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// 4 vertices per face, but 6 indices (IE 2 triangles) per face, aka need to multiply by 1.5
|
// 4 vertices per face, but 6 indices (IE 2 triangles) per face, aka need to multiply by 1.5
|
||||||
int indexCount = (int)(vbo.getVertexCount() * 1.5);
|
int indexCount = (int) (vbo.getVertexCount() * 1.5);
|
||||||
|
|
||||||
vbo.bind();
|
vbo.bind();
|
||||||
vbo.getQuadIBO().bind();
|
vbo.getQuadIBO().bind();
|
||||||
@@ -357,6 +378,12 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
|
|||||||
vbo.unbind();
|
vbo.unbind();
|
||||||
vbo.getQuadIBO().unbind();
|
vbo.getQuadIBO().unbind();
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
vbo.renderStampLock.unlock(vboReadStamp);
|
||||||
|
vbo.getQuadIBO().renderStampLock.unlock(iboReadStamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-2
@@ -25,7 +25,7 @@ import com.seibel.distanthorizons.common.render.blaze.BlazeDhRenderApiDefinition
|
|||||||
import com.seibel.distanthorizons.common.render.openGl.GlDhRenderApiDefinition;
|
import com.seibel.distanthorizons.common.render.openGl.GlDhRenderApiDefinition;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.GenericRenderObjectFactory;
|
import com.seibel.distanthorizons.core.render.renderer.GenericRenderObjectFactory;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.ClassicConfigGUI;
|
import com.seibel.distanthorizons.common.wrappers.gui.classicConfig.ClassicConfigGUI;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.LangWrapper;
|
import com.seibel.distanthorizons.common.wrappers.gui.LangWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.level.KeyedClientLevelManager;
|
import com.seibel.distanthorizons.common.wrappers.level.KeyedClientLevelManager;
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftServerWrapper;
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftServerWrapper;
|
||||||
@@ -80,9 +80,20 @@ public class DependencySetup
|
|||||||
SingletonInjector.INSTANCE.bind(IConfigGui.class, ClassicConfigGUI.CONFIG_CORE_INTERFACE);
|
SingletonInjector.INSTANCE.bind(IConfigGui.class, ClassicConfigGUI.CONFIG_CORE_INTERFACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean renderingApiBindingsSet = false;
|
||||||
/** will be called from a DH thread, not the render thread */
|
/** will be called from a DH thread, not the render thread */
|
||||||
public static void setRenderingApiBindings()
|
public synchronized static void setRenderingApiBindings()
|
||||||
{
|
{
|
||||||
|
// shouldn't happen, but there was a single report that this method was triggered twice
|
||||||
|
if (renderingApiBindingsSet)
|
||||||
|
{
|
||||||
|
LOGGER.warn("Rendering bindings already set, skipping. How did this happen?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
renderingApiBindingsSet = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EDhApiRenderApi renderingApiEnum = Config.Client.Advanced.Graphics.Experimental.renderingApi.get();
|
EDhApiRenderApi renderingApiEnum = Config.Client.Advanced.Graphics.Experimental.renderingApi.get();
|
||||||
if (renderingApiEnum == EDhApiRenderApi.AUTO)
|
if (renderingApiEnum == EDhApiRenderApi.AUTO)
|
||||||
{
|
{
|
||||||
|
|||||||
+4
-4
@@ -93,8 +93,8 @@ public class VersionConstants implements IVersionConstants
|
|||||||
return "1.21.10";
|
return "1.21.10";
|
||||||
#elif MC_VER == MC_1_21_11
|
#elif MC_VER == MC_1_21_11
|
||||||
return "1.21.11";
|
return "1.21.11";
|
||||||
#elif MC_VER == MC_1_26_1
|
#elif MC_VER == MC_26_1_2
|
||||||
return "21.6";
|
return "26.1.2";
|
||||||
#else
|
#else
|
||||||
ERROR MC version constant missing
|
ERROR MC version constant missing
|
||||||
#endif
|
#endif
|
||||||
@@ -104,10 +104,10 @@ public class VersionConstants implements IVersionConstants
|
|||||||
@Override
|
@Override
|
||||||
public EDhApiRenderApi getDefaultRenderingApi()
|
public EDhApiRenderApi getDefaultRenderingApi()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_26_1
|
#if MC_VER <= MC_1_21_11
|
||||||
return EDhApiRenderApi.OPEN_GL;
|
return EDhApiRenderApi.OPEN_GL;
|
||||||
#else
|
#else
|
||||||
ERROR MC version constant missing
|
return EDhApiRenderApi.BLAZE_3D;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+31
-6
@@ -6,7 +6,7 @@ import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSour
|
|||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
||||||
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPosMutable;
|
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPosMutable;
|
||||||
import com.seibel.distanthorizons.core.util.ColorUtil;
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
import com.seibel.distanthorizons.core.util.FullDataPointUtil;
|
import com.seibel.distanthorizons.core.util.FullDataPointUtil;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||||
@@ -46,7 +46,7 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
|
|||||||
|
|
||||||
private static final ConcurrentHashMap<BlockBiomeWrapperPair, Integer> COLOR_BY_BLOCK_BIOME_PAIR = new ConcurrentHashMap<>();
|
private static final ConcurrentHashMap<BlockBiomeWrapperPair, Integer> COLOR_BY_BLOCK_BIOME_PAIR = new ConcurrentHashMap<>();
|
||||||
/** returned if the color cache is incomplete */
|
/** returned if the color cache is incomplete */
|
||||||
public static final int INVALID_COLOR = Integer.MIN_VALUE;
|
public static final int INVALID_COLOR = -1;
|
||||||
|
|
||||||
|
|
||||||
protected BiomeWrapper biomeWrapper;
|
protected BiomeWrapper biomeWrapper;
|
||||||
@@ -60,6 +60,7 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
|
|||||||
//=============//
|
//=============//
|
||||||
// constructor //
|
// constructor //
|
||||||
//=============//
|
//=============//
|
||||||
|
//region
|
||||||
|
|
||||||
public AbstractDhTintGetter() { }
|
public AbstractDhTintGetter() { }
|
||||||
|
|
||||||
@@ -76,11 +77,14 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
|
|||||||
this.smoothingRadiusInBlocks = Config.Client.Advanced.Graphics.Quality.lodBiomeBlending.get();
|
this.smoothingRadiusInBlocks = Config.Client.Advanced.Graphics.Quality.lodBiomeBlending.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
//================//
|
|
||||||
// shared methods //
|
//===============//
|
||||||
//================//
|
// color getters //
|
||||||
|
//===============//
|
||||||
|
//region
|
||||||
|
|
||||||
/** Called by MC's tint getter */
|
/** Called by MC's tint getter */
|
||||||
@Override
|
@Override
|
||||||
@@ -195,7 +199,7 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
|
|||||||
BlockBiomeWrapperPair pair = BlockBiomeWrapperPair.get(this.blockStateWrapper, biomeWrapper);
|
BlockBiomeWrapperPair pair = BlockBiomeWrapperPair.get(this.blockStateWrapper, biomeWrapper);
|
||||||
|
|
||||||
// use the cached color if possible
|
// use the cached color if possible
|
||||||
Integer cachedColor = COLOR_BY_BLOCK_BIOME_PAIR.get(pair); // explicit Integer return here reduces unnecessary allocations
|
Integer cachedColor = COLOR_BY_BLOCK_BIOME_PAIR.get(pair);
|
||||||
if (cachedColor != null)
|
if (cachedColor != null)
|
||||||
{
|
{
|
||||||
return cachedColor;
|
return cachedColor;
|
||||||
@@ -335,6 +339,27 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//===========//
|
||||||
|
// set color //
|
||||||
|
//===========//
|
||||||
|
//region
|
||||||
|
|
||||||
|
/**
|
||||||
|
* can be used in newer MC versions
|
||||||
|
* where the color getting logic is a bit more manual
|
||||||
|
*/
|
||||||
|
public static void setStaticColor(BlockStateWrapper blockStateWrapper, BiomeWrapper biomeWrapper, Integer colorInt)
|
||||||
|
{
|
||||||
|
BlockBiomeWrapperPair pair = BlockBiomeWrapperPair.get(blockStateWrapper, biomeWrapper);
|
||||||
|
COLOR_BY_BLOCK_BIOME_PAIR.put(pair, colorInt);
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -232,12 +232,13 @@ public class BiomeWrapper implements IBiomeWrapper
|
|||||||
resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome);
|
resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome);
|
||||||
#elif MC_VER <= MC_1_19_2
|
#elif MC_VER <= MC_1_19_2
|
||||||
resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome.value());
|
resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome.value());
|
||||||
#elif MC_VER <= MC_1_21_4
|
#elif MC_VER <= MC_1_21_1
|
||||||
resourceLocation = registryAccess.registryOrThrow(Registries.BIOME).getKey(this.biome.value());
|
resourceLocation = registryAccess.registryOrThrow(Registries.BIOME).getKey(this.biome.value());
|
||||||
#else
|
#else
|
||||||
resourceLocation = registryAccess.lookupOrThrow(Registries.BIOME).getKey(this.biome.value());
|
resourceLocation = registryAccess.lookupOrThrow(Registries.BIOME).getKey(this.biome.value());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (resourceLocation == null)
|
if (resourceLocation == null)
|
||||||
{
|
{
|
||||||
String biomeName;
|
String biomeName;
|
||||||
@@ -362,7 +363,7 @@ public class BiomeWrapper implements IBiomeWrapper
|
|||||||
Biome unwrappedBiome = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).get(resourceLocation);
|
Biome unwrappedBiome = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).get(resourceLocation);
|
||||||
success = (unwrappedBiome != null);
|
success = (unwrappedBiome != null);
|
||||||
Holder<Biome> biome = new Holder.Direct<>(unwrappedBiome);
|
Holder<Biome> biome = new Holder.Direct<>(unwrappedBiome);
|
||||||
#elif MC_VER <= MC_1_21_4
|
#elif MC_VER <= MC_1_21_1
|
||||||
Biome unwrappedBiome = registryAccess.registryOrThrow(Registries.BIOME).get(resourceLocation);
|
Biome unwrappedBiome = registryAccess.registryOrThrow(Registries.BIOME).get(resourceLocation);
|
||||||
success = (unwrappedBiome != null);
|
success = (unwrappedBiome != null);
|
||||||
Holder<Biome> biome = new Holder.Direct<>(unwrappedBiome);
|
Holder<Biome> biome = new Holder.Direct<>(unwrappedBiome);
|
||||||
|
|||||||
+390
-299
@@ -20,15 +20,17 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.block;
|
package com.seibel.distanthorizons.common.wrappers.block;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiBlockMaterial;
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiBlockMaterial;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBlockStateWrapperCreatedEvent;
|
||||||
import com.seibel.distanthorizons.common.wrappers.WrapperFactory;
|
import com.seibel.distanthorizons.common.wrappers.WrapperFactory;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.config.types.ConfigEntry;
|
import com.seibel.distanthorizons.core.config.types.ConfigEntry;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.util.ColorUtil;
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||||
|
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||||
import net.minecraft.tags.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.world.level.block.BeaconBeamBlock;
|
import net.minecraft.world.level.block.BeaconBeamBlock;
|
||||||
@@ -51,6 +53,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.level.EmptyBlockGetter;
|
import net.minecraft.world.level.EmptyBlockGetter;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
#elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2
|
#elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2
|
||||||
import net.minecraft.tags.TagKey;
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -88,7 +91,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
public static final ConcurrentHashMap<String, BlockStateWrapper> WRAPPER_BY_RESOURCE_LOCATION = new ConcurrentHashMap<>();
|
public static final ConcurrentHashMap<String, BlockStateWrapper> WRAPPER_BY_RESOURCE_LOCATION = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public static final String AIR_STRING = "AIR";
|
public static final String AIR_STRING = "AIR";
|
||||||
public static final BlockStateWrapper AIR = new BlockStateWrapper(null, null);
|
public static final BlockStateWrapper AIR = new BlockStateWrapper(null, null, null);
|
||||||
|
|
||||||
public static final String DIRT_RESOURCE_LOCATION_STRING = "minecraft:dirt";
|
public static final String DIRT_RESOURCE_LOCATION_STRING = "minecraft:dirt";
|
||||||
public static final String WATER_RESOURCE_LOCATION_STRING = "minecraft:water";
|
public static final String WATER_RESOURCE_LOCATION_STRING = "minecraft:water";
|
||||||
@@ -123,6 +126,9 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
private final boolean isBeaconBlock;
|
private final boolean isBeaconBlock;
|
||||||
private final boolean isBeaconBaseBlock;
|
private final boolean isBeaconBaseBlock;
|
||||||
private final boolean allowsBeaconBeamPassage;
|
private final boolean allowsBeaconBeamPassage;
|
||||||
|
private final boolean isSolid;
|
||||||
|
private final boolean isLiquid;
|
||||||
|
private final boolean allowApiColorOverride;
|
||||||
/** null if this block can't tint beacons */
|
/** null if this block can't tint beacons */
|
||||||
private final Color beaconTintColor;
|
private final Color beaconTintColor;
|
||||||
private final Color mapColor;
|
private final Color mapColor;
|
||||||
@@ -134,26 +140,6 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
//==============//
|
//==============//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
public static BlockStateWrapper fromBlockState(BlockState blockState, ILevelWrapper levelWrapper)
|
|
||||||
{
|
|
||||||
if (blockState == null || blockState.isAir())
|
|
||||||
{
|
|
||||||
return AIR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (WRAPPER_BY_BLOCK_STATE.containsKey(blockState))
|
|
||||||
{
|
|
||||||
return WRAPPER_BY_BLOCK_STATE.get(blockState);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BlockStateWrapper newWrapper = new BlockStateWrapper(blockState, levelWrapper);
|
|
||||||
WRAPPER_BY_BLOCK_STATE.put(blockState, newWrapper);
|
|
||||||
return newWrapper;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can be faster than {@link BlockStateWrapper#fromBlockState(BlockState, ILevelWrapper)}
|
* Can be faster than {@link BlockStateWrapper#fromBlockState(BlockState, ILevelWrapper)}
|
||||||
* in cases where the same block state is expected to be referenced multiple times.
|
* in cases where the same block state is expected to be referenced multiple times.
|
||||||
@@ -173,19 +159,124 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
return fromBlockState(blockState, levelWrapper);
|
return fromBlockState(blockState, levelWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static BlockStateWrapper fromBlockState(@Nullable BlockState blockState, ILevelWrapper levelWrapper)
|
||||||
|
{
|
||||||
|
// air is a special case
|
||||||
|
if (isAir(blockState))
|
||||||
|
{
|
||||||
|
return AIR;
|
||||||
|
}
|
||||||
|
|
||||||
private BlockStateWrapper(@Nullable BlockState blockState, ILevelWrapper levelWrapper)
|
// pooling wrappers significantly improves chunk->LOD processing speed
|
||||||
|
// and also reduces GC pressure
|
||||||
|
BlockStateWrapper existingWrapper = WRAPPER_BY_BLOCK_STATE.get(blockState);
|
||||||
|
if (existingWrapper != null)
|
||||||
|
{
|
||||||
|
return existingWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// synchronized so the API event only fires once per block
|
||||||
|
synchronized (WRAPPER_BY_BLOCK_STATE)
|
||||||
|
{
|
||||||
|
// if another thread already finished this block, use that wrapper
|
||||||
|
existingWrapper = WRAPPER_BY_BLOCK_STATE.get(blockState);
|
||||||
|
if (existingWrapper != null)
|
||||||
|
{
|
||||||
|
return existingWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// create a wrapper specifically for the API event to use
|
||||||
|
BlockStateWrapper apiWrapper = new BlockStateWrapper(blockState, levelWrapper, null);
|
||||||
|
DhApiBlockStateWrapperCreatedEvent.EventParam eventParam = new DhApiBlockStateWrapperCreatedEvent.EventParam(apiWrapper);
|
||||||
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBlockStateWrapperCreatedEvent.class, eventParam);
|
||||||
|
|
||||||
|
if (!eventParam.getOverridesSet())
|
||||||
|
{
|
||||||
|
// no API changes needed, use the existing object
|
||||||
|
WRAPPER_BY_BLOCK_STATE.putIfAbsent(blockState, apiWrapper);
|
||||||
|
return apiWrapper;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// create a new wrapper using whatever overrides the API user set
|
||||||
|
BlockStateWrapper returnWrapper = new BlockStateWrapper(blockState, levelWrapper, eventParam);
|
||||||
|
WRAPPER_BY_BLOCK_STATE.putIfAbsent(blockState, returnWrapper);
|
||||||
|
return returnWrapper;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private BlockStateWrapper(
|
||||||
|
@Nullable BlockState blockState, ILevelWrapper levelWrapper,
|
||||||
|
@Nullable DhApiBlockStateWrapperCreatedEvent.EventParam overrideEventParam)
|
||||||
{
|
{
|
||||||
this.blockState = blockState;
|
this.blockState = blockState;
|
||||||
this.serialString = this.serialize(levelWrapper);
|
this.serialString = serialize(blockState, levelWrapper);
|
||||||
this.hashCode = Objects.hash(this.serialString);
|
this.hashCode = Objects.hash(this.serialString);
|
||||||
this.blockMaterialId = this.calculateEDhApiBlockMaterialId().index;
|
String lowerCaseSerial = this.serialString.toLowerCase();
|
||||||
this.opacity = this.calculateOpacity();
|
|
||||||
|
|
||||||
String lowercaseSerial = this.serialString.toLowerCase();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// is liquid //
|
||||||
|
{
|
||||||
|
if (this.isAir()
|
||||||
|
|| this.blockState == null) // == null isn't necessary since its handled in isAir() but is here to prevent intellij from complaining
|
||||||
|
{
|
||||||
|
this.isLiquid = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if MC_VER < MC_1_20_1
|
||||||
|
this.isLiquid = this.blockState.getMaterial().isLiquid() || !this.blockState.getFluidState().isEmpty();
|
||||||
|
#else
|
||||||
|
this.isLiquid = !this.blockState.getFluidState().isEmpty();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// API overriding //
|
||||||
|
{
|
||||||
|
if (overrideEventParam != null
|
||||||
|
&& overrideEventParam.getBlockMaterial() != null)
|
||||||
|
{
|
||||||
|
this.blockMaterialId = overrideEventParam.getBlockMaterial().index;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// no API override, use the base logic
|
||||||
|
this.blockMaterialId = calculateEDhApiBlockMaterialId(this.blockState, lowerCaseSerial, this.isLiquid).index;
|
||||||
|
}
|
||||||
|
|
||||||
|
// allow overriding if present
|
||||||
|
if (overrideEventParam != null
|
||||||
|
&& overrideEventParam.getOpacity() != null)
|
||||||
|
{
|
||||||
|
this.opacity = overrideEventParam.getOpacity();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.opacity = calculateOpacity(this.blockState, isAir(this.blockState), this.isLiquid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// allow overriding if present
|
||||||
|
if (overrideEventParam != null
|
||||||
|
&& overrideEventParam.getAllowApiColorOverride() != null)
|
||||||
|
{
|
||||||
|
this.allowApiColorOverride = overrideEventParam.getAllowApiColorOverride();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.allowApiColorOverride = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// beacon handling //
|
||||||
|
{
|
||||||
|
|
||||||
// beacon base blocks
|
// beacon base blocks
|
||||||
#if MC_VER <= MC_1_18_2
|
#if MC_VER <= MC_1_18_2
|
||||||
|
|
||||||
@@ -203,7 +294,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
for (int i = 0; i < oldBeaconBaseBlockNameList.size(); i++)
|
for (int i = 0; i < oldBeaconBaseBlockNameList.size(); i++)
|
||||||
{
|
{
|
||||||
String baseBlockName = oldBeaconBaseBlockNameList.get(i);
|
String baseBlockName = oldBeaconBaseBlockNameList.get(i);
|
||||||
if (lowercaseSerial.contains(baseBlockName))
|
if (lowerCaseSerial.contains(baseBlockName))
|
||||||
{
|
{
|
||||||
isBeaconBaseBlock = true;
|
isBeaconBaseBlock = true;
|
||||||
break;
|
break;
|
||||||
@@ -231,7 +322,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// beacon block
|
// beacon block
|
||||||
this.isBeaconBlock = lowercaseSerial.contains("minecraft:beacon");
|
this.isBeaconBlock = lowerCaseSerial.contains("minecraft:beacon");
|
||||||
|
|
||||||
|
|
||||||
// beacon tint color
|
// beacon tint color
|
||||||
@@ -261,15 +352,15 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
if (this.blockState != null)
|
if (this.blockState != null)
|
||||||
{
|
{
|
||||||
// get block properties (defaults to the values used by air)
|
// get block properties (defaults to the values used by air)
|
||||||
boolean canOcclude = this.getCanOcclude();
|
boolean canOcclude = getCanOcclude(this.blockState);
|
||||||
boolean propagatesSkyLightDown = this.getPropagatesSkyLightDown();
|
boolean propagatesSkyLightDown = getPropagatesSkyLightDown(this.blockState);
|
||||||
|
|
||||||
if (lowercaseSerial.contains("minecraft:bedrock"))
|
if (lowerCaseSerial.contains("minecraft:bedrock"))
|
||||||
{
|
{
|
||||||
// bedrock is a special case fully opaque block that does allow beacons through
|
// bedrock is a special case fully opaque block that does allow beacons through
|
||||||
allowsBeaconBeamPassage = true;
|
allowsBeaconBeamPassage = true;
|
||||||
}
|
}
|
||||||
else if (lowercaseSerial.contains("minecraft:tinted_glass"))
|
else if (lowerCaseSerial.contains("minecraft:tinted_glass"))
|
||||||
{
|
{
|
||||||
// tinted glass is a special case where it isn't fully opaque,
|
// tinted glass is a special case where it isn't fully opaque,
|
||||||
// but should block beacons
|
// but should block beacons
|
||||||
@@ -293,26 +384,232 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
allowsBeaconBeamPassage = true;
|
allowsBeaconBeamPassage = true;
|
||||||
}
|
}
|
||||||
this.allowsBeaconBeamPassage = allowsBeaconBeamPassage;
|
this.allowsBeaconBeamPassage = allowsBeaconBeamPassage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int mcColor = 0;
|
// map color //
|
||||||
|
{
|
||||||
if (this.blockState != null)
|
if (this.blockState != null)
|
||||||
{
|
{
|
||||||
|
int mcColor = 0;
|
||||||
|
|
||||||
#if MC_VER < MC_1_20_1
|
#if MC_VER < MC_1_20_1
|
||||||
mcColor = this.blockState.getMaterial().getColor().col;
|
mcColor = this.blockState.getMaterial().getColor().col;
|
||||||
#else
|
#else
|
||||||
mcColor = this.blockState.getMapColor(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).col;
|
mcColor = this.blockState.getMapColor(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).col;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this.mapColor = ColorUtil.toColorObjRGB(mcColor);
|
this.mapColor = ColorUtil.toColorObjRGB(mcColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.mapColor = new Color(0,0,0,0);
|
this.mapColor = new Color(0, 0, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//LOGGER.trace("Created BlockStateWrapper ["+this.serialString+"] for ["+blockState+"] with material ID ["+this.EDhApiBlockMaterialId+"]");
|
|
||||||
|
// is solid //
|
||||||
|
{
|
||||||
|
if (this.isAir()
|
||||||
|
|| this.blockState == null) // "== null" isn't necessary since its handled in isAir() but is here to prevent IntelliJ from complaining
|
||||||
|
{
|
||||||
|
this.isSolid = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if MC_VER < MC_1_20_1
|
||||||
|
this.isSolid = this.blockState.getMaterial().isSolid();
|
||||||
|
#else
|
||||||
|
this.isSolid = !this.blockState.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).isEmpty();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// static constructor helpers //
|
||||||
|
//region
|
||||||
|
|
||||||
|
private static EDhApiBlockMaterial calculateEDhApiBlockMaterialId(
|
||||||
|
@Nullable BlockState blockState,
|
||||||
|
String lowercaseSerialString,
|
||||||
|
boolean isLiquid
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (blockState == null)
|
||||||
|
{
|
||||||
|
return EDhApiBlockMaterial.AIR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (blockState.is(BlockTags.LEAVES)
|
||||||
|
|| lowercaseSerialString.contains("bamboo")
|
||||||
|
|| lowercaseSerialString.contains("cactus")
|
||||||
|
|| lowercaseSerialString.contains("chorus_flower")
|
||||||
|
|| lowercaseSerialString.contains("mushroom")
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EDhApiBlockMaterial.LEAVES;
|
||||||
|
}
|
||||||
|
else if (blockState.is(Blocks.LAVA))
|
||||||
|
{
|
||||||
|
return EDhApiBlockMaterial.LAVA;
|
||||||
|
}
|
||||||
|
else if (isLiquid
|
||||||
|
|| blockState.is(Blocks.WATER))
|
||||||
|
{
|
||||||
|
return EDhApiBlockMaterial.WATER;
|
||||||
|
}
|
||||||
|
else if (blockState.getSoundType() == SoundType.WOOD
|
||||||
|
|| lowercaseSerialString.contains("root")
|
||||||
|
#if MC_VER >= MC_1_19_4
|
||||||
|
|| blockState.getSoundType() == SoundType.CHERRY_WOOD
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EDhApiBlockMaterial.WOOD;
|
||||||
|
}
|
||||||
|
else if (blockState.getSoundType() == SoundType.METAL
|
||||||
|
#if MC_VER >= MC_1_19_2
|
||||||
|
|| blockState.getSoundType() == SoundType.COPPER
|
||||||
|
#endif
|
||||||
|
#if MC_VER >= MC_1_20_4
|
||||||
|
|| blockState.getSoundType() == SoundType.COPPER_BULB
|
||||||
|
|| blockState.getSoundType() == SoundType.COPPER_GRATE
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EDhApiBlockMaterial.METAL;
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
lowercaseSerialString.contains("grass_block")
|
||||||
|
|| lowercaseSerialString.contains("grass_slab")
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EDhApiBlockMaterial.GRASS;
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
lowercaseSerialString.contains("dirt")
|
||||||
|
|| lowercaseSerialString.contains("gravel")
|
||||||
|
|| lowercaseSerialString.contains("mud")
|
||||||
|
|| lowercaseSerialString.contains("podzol")
|
||||||
|
|| lowercaseSerialString.contains("mycelium")
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EDhApiBlockMaterial.DIRT;
|
||||||
|
}
|
||||||
|
#if MC_VER >= MC_1_17_1
|
||||||
|
else if (blockState.getSoundType() == SoundType.DEEPSLATE
|
||||||
|
|| blockState.getSoundType() == SoundType.DEEPSLATE_BRICKS
|
||||||
|
|| blockState.getSoundType() == SoundType.DEEPSLATE_TILES
|
||||||
|
|| blockState.getSoundType() == SoundType.POLISHED_DEEPSLATE
|
||||||
|
|| lowercaseSerialString.contains("deepslate") )
|
||||||
|
{
|
||||||
|
return EDhApiBlockMaterial.DEEPSLATE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else if (lowercaseSerialString.contains("snow"))
|
||||||
|
{
|
||||||
|
return EDhApiBlockMaterial.SNOW;
|
||||||
|
}
|
||||||
|
else if (lowercaseSerialString.contains("sand"))
|
||||||
|
{
|
||||||
|
return EDhApiBlockMaterial.SAND;
|
||||||
|
}
|
||||||
|
else if (lowercaseSerialString.contains("terracotta"))
|
||||||
|
{
|
||||||
|
return EDhApiBlockMaterial.TERRACOTTA;
|
||||||
|
}
|
||||||
|
else if (blockState.is(BlockTags.BASE_STONE_NETHER))
|
||||||
|
{
|
||||||
|
return EDhApiBlockMaterial.NETHER_STONE;
|
||||||
|
}
|
||||||
|
else if (lowercaseSerialString.contains("stone")
|
||||||
|
|| lowercaseSerialString.contains("ore"))
|
||||||
|
{
|
||||||
|
return EDhApiBlockMaterial.STONE;
|
||||||
|
}
|
||||||
|
else if (blockState.getLightEmission() > 0)
|
||||||
|
{
|
||||||
|
return EDhApiBlockMaterial.ILLUMINATED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return EDhApiBlockMaterial.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int calculateOpacity(
|
||||||
|
@Nullable BlockState blockState,
|
||||||
|
boolean isAir, boolean isLiquid
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// get block properties (defaults to the values used by air)
|
||||||
|
boolean canOcclude = getCanOcclude(blockState);
|
||||||
|
boolean propagatesSkyLightDown = getPropagatesSkyLightDown(blockState);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// this method isn't perfect, but works well enough for our use case
|
||||||
|
int opacity;
|
||||||
|
if (isAir)
|
||||||
|
{
|
||||||
|
opacity = LodUtil.BLOCK_FULLY_TRANSPARENT;
|
||||||
|
}
|
||||||
|
else if (isLiquid && !canOcclude)
|
||||||
|
{
|
||||||
|
// probably not a waterlogged block (which should block light entirely)
|
||||||
|
|
||||||
|
// +1 to indicate that the block is translucent (in between transparent and opaque)
|
||||||
|
opacity = LodUtil.BLOCK_FULLY_TRANSPARENT + 1;
|
||||||
|
}
|
||||||
|
else if (propagatesSkyLightDown && !canOcclude)
|
||||||
|
{
|
||||||
|
// probably glass or some other fully transparent block
|
||||||
|
|
||||||
|
// !canOcclude is required to ignore stairs and slabs since
|
||||||
|
// propagateSkyLightDown is true for them, but they're solid and don't actually let light through
|
||||||
|
|
||||||
|
opacity = LodUtil.BLOCK_FULLY_TRANSPARENT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// default for all other blocks
|
||||||
|
opacity = LodUtil.BLOCK_FULLY_OPAQUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return opacity;
|
||||||
|
}
|
||||||
|
private static boolean getCanOcclude(@Nullable BlockState blockState)
|
||||||
|
{
|
||||||
|
// defaults to the value used by air
|
||||||
|
boolean canOcclude = false;
|
||||||
|
if (blockState != null)
|
||||||
|
{
|
||||||
|
canOcclude = blockState.canOcclude();
|
||||||
|
}
|
||||||
|
|
||||||
|
return canOcclude;
|
||||||
|
}
|
||||||
|
private static boolean getPropagatesSkyLightDown(@Nullable BlockState blockState)
|
||||||
|
{
|
||||||
|
// defaults to the value used by air
|
||||||
|
boolean propagatesSkyLightDown = true;
|
||||||
|
if (blockState != null)
|
||||||
|
{
|
||||||
|
#if MC_VER < MC_1_21_3
|
||||||
|
propagatesSkyLightDown = blockState.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
|
||||||
|
#else
|
||||||
|
propagatesSkyLightDown = blockState.propagatesSkylightDown();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return propagatesSkyLightDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -390,15 +687,6 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
return waterBlock;
|
return waterBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearCachedIgnoreBlocks()
|
|
||||||
{
|
|
||||||
rendererIgnoredBlocks = null;
|
|
||||||
rendererIgnoredCaveBlocks = null;
|
|
||||||
waterSurfaceReplacementBlocks = null;
|
|
||||||
waterSubsurfaceReplacementBlocks = null;
|
|
||||||
waterBlock = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -455,7 +743,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
List<BlockState> blockStatesToIgnore = defaultBlockStateToIgnore.blockState.getBlock().getStateDefinition().getPossibleStates();
|
List<BlockState> blockStatesToIgnore = defaultBlockStateToIgnore.blockState.getBlock().getStateDefinition().getPossibleStates();
|
||||||
for (BlockState blockState : blockStatesToIgnore)
|
for (BlockState blockState : blockStatesToIgnore)
|
||||||
{
|
{
|
||||||
BlockStateWrapper newBlockToIgnore = BlockStateWrapper.fromBlockState(blockState, levelWrapper);
|
BlockStateWrapper newBlockToIgnore = fromBlockState(blockState, levelWrapper);
|
||||||
blockStateWrappers.add(newBlockToIgnore);
|
blockStateWrappers.add(newBlockToIgnore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -478,6 +766,15 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
return blockStateWrappers;
|
return blockStateWrappers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clearCachedIgnoreBlocks()
|
||||||
|
{
|
||||||
|
rendererIgnoredBlocks = null;
|
||||||
|
rendererIgnoredCaveBlocks = null;
|
||||||
|
waterSurfaceReplacementBlocks = null;
|
||||||
|
waterSubsurfaceReplacementBlocks = null;
|
||||||
|
waterBlock = null;
|
||||||
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -489,74 +786,6 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOpacity() { return this.opacity; }
|
public int getOpacity() { return this.opacity; }
|
||||||
private int calculateOpacity()
|
|
||||||
{
|
|
||||||
// get block properties (defaults to the values used by air)
|
|
||||||
boolean canOcclude = this.getCanOcclude();
|
|
||||||
boolean propagatesSkyLightDown = this.getPropagatesSkyLightDown();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// this method isn't perfect, but works well enough for our use case
|
|
||||||
int opacity;
|
|
||||||
if (this.isAir())
|
|
||||||
{
|
|
||||||
opacity = LodUtil.BLOCK_FULLY_TRANSPARENT;
|
|
||||||
}
|
|
||||||
else if (this.isLiquid() && !canOcclude)
|
|
||||||
{
|
|
||||||
// probably not a waterlogged block (which should block light entirely)
|
|
||||||
|
|
||||||
// +1 to indicate that the block is translucent (in between transparent and opaque)
|
|
||||||
opacity = LodUtil.BLOCK_FULLY_TRANSPARENT + 1;
|
|
||||||
}
|
|
||||||
else if (propagatesSkyLightDown && !canOcclude)
|
|
||||||
{
|
|
||||||
// probably glass or some other fully transparent block
|
|
||||||
|
|
||||||
// !canOcclude is required to ignore stairs and slabs since
|
|
||||||
// propagateSkyLightDown is true for them, but they're solid and don't actually let light through
|
|
||||||
|
|
||||||
opacity = LodUtil.BLOCK_FULLY_TRANSPARENT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// default for all other blocks
|
|
||||||
opacity = LodUtil.BLOCK_FULLY_OPAQUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return opacity;
|
|
||||||
}
|
|
||||||
private boolean getCanOcclude()
|
|
||||||
{
|
|
||||||
// defaults to the value used by air
|
|
||||||
boolean canOcclude = false;
|
|
||||||
if (this.blockState != null)
|
|
||||||
{
|
|
||||||
canOcclude = this.blockState.canOcclude();
|
|
||||||
}
|
|
||||||
|
|
||||||
return canOcclude;
|
|
||||||
}
|
|
||||||
private boolean getPropagatesSkyLightDown()
|
|
||||||
{
|
|
||||||
// defaults to the value used by air
|
|
||||||
boolean propagatesSkyLightDown = true;
|
|
||||||
if (this.blockState != null)
|
|
||||||
{
|
|
||||||
#if MC_VER < MC_1_21_3
|
|
||||||
propagatesSkyLightDown = this.blockState.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
|
|
||||||
#else
|
|
||||||
propagatesSkyLightDown = this.blockState.propagatesSkylightDown();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return propagatesSkyLightDown;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLightEmission() { return (this.blockState != null) ? this.blockState.getLightEmission() : 0; }
|
public int getLightEmission() { return (this.blockState != null) ? this.blockState.getLightEmission() : 0; }
|
||||||
@@ -564,77 +793,17 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
@Override
|
@Override
|
||||||
public String getSerialString() { return this.serialString; }
|
public String getSerialString() { return this.serialString; }
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj)
|
|
||||||
{
|
|
||||||
if (this == obj)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj == null || this.getClass() != obj.getClass())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockStateWrapper that = (BlockStateWrapper) obj;
|
|
||||||
// the serialized value is used so we can test the contents instead of the references
|
|
||||||
return Objects.equals(this.getSerialString(), that.getSerialString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() { return this.hashCode; }
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getWrappedMcObject() { return this.blockState; }
|
public Object getWrappedMcObject() { return this.blockState; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAir() { return this.isAir(this.blockState); }
|
public boolean isAir() { return isAir(this.blockState); }
|
||||||
public boolean isAir(BlockState blockState) { return blockState == null || blockState.isAir(); }
|
public static boolean isAir(BlockState blockState) { return blockState == null || blockState.isAir(); }
|
||||||
|
|
||||||
private Boolean blockIsSolid = null;
|
|
||||||
@Override
|
|
||||||
public boolean isSolid()
|
|
||||||
{
|
|
||||||
if (this.isAir()
|
|
||||||
|| this.blockState == null) // == null isn't necessary since its handled in isAir() but is here to prevent intellij from complaining
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// cached since getCollisionShape() is a dictionary lookup that allocates objects
|
|
||||||
// and this call is used in a high traffic location
|
|
||||||
if (this.blockIsSolid != null)
|
|
||||||
{
|
|
||||||
return this.blockIsSolid;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER < MC_1_20_1
|
|
||||||
this.blockIsSolid = this.blockState.getMaterial().isSolid();
|
|
||||||
#else
|
|
||||||
this.blockIsSolid = !this.blockState.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).isEmpty();
|
|
||||||
#endif
|
|
||||||
return this.blockIsSolid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLiquid()
|
public boolean isSolid() { return this.isSolid; }
|
||||||
{
|
@Override
|
||||||
if (this.isAir()
|
public boolean isLiquid() { return this.isLiquid; }
|
||||||
|| this.blockState == null) // == null isn't necessary since its handled in isAir() but is here to prevent intellij from complaining
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if MC_VER < MC_1_20_1
|
|
||||||
return this.blockState.getMaterial().isLiquid() || !this.blockState.getFluidState().isEmpty();
|
|
||||||
#else
|
|
||||||
return !this.blockState.getFluidState().isEmpty();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBeaconBlock() { return this.isBeaconBlock; }
|
public boolean isBeaconBlock() { return this.isBeaconBlock; }
|
||||||
@Override
|
@Override
|
||||||
@@ -643,6 +812,8 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
public boolean isBeaconTintBlock() { return this.beaconTintColor != null; }
|
public boolean isBeaconTintBlock() { return this.beaconTintColor != null; }
|
||||||
@Override
|
@Override
|
||||||
public boolean allowsBeaconBeamPassage() { return this.allowsBeaconBeamPassage; }
|
public boolean allowsBeaconBeamPassage() { return this.allowsBeaconBeamPassage; }
|
||||||
|
@Override
|
||||||
|
public boolean allowApiColorOverride() { return this.allowApiColorOverride; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Color getMapColor() { return this.mapColor; }
|
public Color getMapColor() { return this.mapColor; }
|
||||||
@@ -652,9 +823,6 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
@Override
|
@Override
|
||||||
public byte getMaterialId() { return this.blockMaterialId; }
|
public byte getMaterialId() { return this.blockMaterialId; }
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() { return this.getSerialString(); }
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -664,9 +832,9 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
//=======================//
|
//=======================//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
private String serialize(ILevelWrapper levelWrapper)
|
private static String serialize(BlockState blockState, ILevelWrapper levelWrapper)
|
||||||
{
|
{
|
||||||
if (this.blockState == null)
|
if (blockState == null)
|
||||||
{
|
{
|
||||||
return AIR_STRING;
|
return AIR_STRING;
|
||||||
}
|
}
|
||||||
@@ -687,27 +855,26 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_17_1
|
#if MC_VER <= MC_1_17_1
|
||||||
resourceLocation = Registry.BLOCK.getKey(this.blockState.getBlock());
|
resourceLocation = Registry.BLOCK.getKey(blockState.getBlock());
|
||||||
#elif MC_VER <= MC_1_19_2
|
#elif MC_VER <= MC_1_19_2
|
||||||
resourceLocation = registryAccess.registryOrThrow(Registry.BLOCK_REGISTRY).getKey(this.blockState.getBlock());
|
resourceLocation = registryAccess.registryOrThrow(Registry.BLOCK_REGISTRY).getKey(blockState.getBlock());
|
||||||
#elif MC_VER <= MC_1_21_4
|
#elif MC_VER <= MC_1_21_1
|
||||||
resourceLocation = registryAccess.registryOrThrow(Registries.BLOCK).getKey(this.blockState.getBlock());
|
resourceLocation = registryAccess.registryOrThrow(Registries.BLOCK).getKey(blockState.getBlock());
|
||||||
#else
|
#else
|
||||||
resourceLocation = registryAccess.lookupOrThrow(Registries.BLOCK).getKey(this.blockState.getBlock());
|
resourceLocation = registryAccess.lookupOrThrow(Registries.BLOCK).getKey(blockState.getBlock());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (resourceLocation == null)
|
if (resourceLocation == null)
|
||||||
{
|
{
|
||||||
LOGGER.warn("No ResourceLocation found, unable to serialize: " + this.blockState);
|
LOGGER.warn("No ResourceLocation found, unable to serialize: " + blockState);
|
||||||
return AIR_STRING;
|
return AIR_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.serialString = resourceLocation.getNamespace() + RESOURCE_LOCATION_SEPARATOR + resourceLocation.getPath()
|
String serialString = resourceLocation.getNamespace() + RESOURCE_LOCATION_SEPARATOR + resourceLocation.getPath()
|
||||||
+ STATE_STRING_SEPARATOR + serializeBlockStateProperties(this.blockState);
|
+ STATE_STRING_SEPARATOR + serializeBlockStateProperties(blockState);
|
||||||
|
return serialString;
|
||||||
return this.serialString;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -791,7 +958,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
#elif MC_VER <= MC_1_19_2
|
#elif MC_VER <= MC_1_19_2
|
||||||
net.minecraft.core.RegistryAccess registryAccess = level.registryAccess();
|
net.minecraft.core.RegistryAccess registryAccess = level.registryAccess();
|
||||||
block = registryAccess.registryOrThrow(Registry.BLOCK_REGISTRY).get(resourceLocation);
|
block = registryAccess.registryOrThrow(Registry.BLOCK_REGISTRY).get(resourceLocation);
|
||||||
#elif MC_VER <= MC_1_21_4
|
#elif MC_VER <= MC_1_21_1
|
||||||
net.minecraft.core.RegistryAccess registryAccess = level.registryAccess();
|
net.minecraft.core.RegistryAccess registryAccess = level.registryAccess();
|
||||||
block = registryAccess.registryOrThrow(Registries.BLOCK).get(resourceLocation);
|
block = registryAccess.registryOrThrow(Registries.BLOCK).get(resourceLocation);
|
||||||
#else
|
#else
|
||||||
@@ -846,7 +1013,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
foundState = block.defaultBlockState();
|
foundState = block.defaultBlockState();
|
||||||
}
|
}
|
||||||
|
|
||||||
foundWrapper = new BlockStateWrapper(foundState, levelWrapper);
|
foundWrapper = fromBlockState(foundState, levelWrapper);
|
||||||
return foundWrapper;
|
return foundWrapper;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -859,6 +1026,11 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
// put if absent in case two threads deserialize at the same time
|
// put if absent in case two threads deserialize at the same time
|
||||||
// unfortunately we can't put everything in a computeIfAbsent() since we also throw exceptions
|
// unfortunately we can't put everything in a computeIfAbsent() since we also throw exceptions
|
||||||
WRAPPER_BY_RESOURCE_LOCATION.putIfAbsent(finalResourceStateString, foundWrapper);
|
WRAPPER_BY_RESOURCE_LOCATION.putIfAbsent(finalResourceStateString, foundWrapper);
|
||||||
|
|
||||||
|
if (foundWrapper != AIR)
|
||||||
|
{
|
||||||
|
WRAPPER_BY_BLOCK_STATE.putIfAbsent(foundWrapper.blockState, foundWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -896,118 +1068,37 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==============//
|
//================//
|
||||||
// Iris methods //
|
// base overrides //
|
||||||
//==============//
|
//================//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
private EDhApiBlockMaterial calculateEDhApiBlockMaterialId()
|
@Override
|
||||||
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
if (this.blockState == null)
|
if (this == obj)
|
||||||
{
|
{
|
||||||
return EDhApiBlockMaterial.AIR;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (obj == null || this.getClass() != obj.getClass())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
String serialString = this.getSerialString().toLowerCase();
|
BlockStateWrapper that = (BlockStateWrapper) obj;
|
||||||
|
// the serialized value is used so we can test the contents instead of the references
|
||||||
|
return Objects.equals(this.getSerialString(), that.getSerialString());
|
||||||
|
}
|
||||||
|
|
||||||
if (this.blockState.is(BlockTags.LEAVES)
|
@Override
|
||||||
|| serialString.contains("bamboo")
|
public int hashCode() { return this.hashCode; }
|
||||||
|| serialString.contains("cactus")
|
|
||||||
|| serialString.contains("chorus_flower")
|
@Override
|
||||||
|| serialString.contains("mushroom")
|
public String toString() { return this.getSerialString(); }
|
||||||
)
|
|
||||||
{
|
|
||||||
return EDhApiBlockMaterial.LEAVES;
|
|
||||||
}
|
|
||||||
else if (this.blockState.is(Blocks.LAVA))
|
|
||||||
{
|
|
||||||
return EDhApiBlockMaterial.LAVA;
|
|
||||||
}
|
|
||||||
else if (this.isLiquid() || this.blockState.is(Blocks.WATER))
|
|
||||||
{
|
|
||||||
return EDhApiBlockMaterial.WATER;
|
|
||||||
}
|
|
||||||
else if (this.blockState.getSoundType() == SoundType.WOOD
|
|
||||||
|| serialString.contains("root")
|
|
||||||
#if MC_VER >= MC_1_19_4
|
|
||||||
|| this.blockState.getSoundType() == SoundType.CHERRY_WOOD
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return EDhApiBlockMaterial.WOOD;
|
|
||||||
}
|
|
||||||
else if (this.blockState.getSoundType() == SoundType.METAL
|
|
||||||
#if MC_VER >= MC_1_19_2
|
|
||||||
|| this.blockState.getSoundType() == SoundType.COPPER
|
|
||||||
#endif
|
|
||||||
#if MC_VER >= MC_1_20_4
|
|
||||||
|| this.blockState.getSoundType() == SoundType.COPPER_BULB
|
|
||||||
|| this.blockState.getSoundType() == SoundType.COPPER_GRATE
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return EDhApiBlockMaterial.METAL;
|
|
||||||
}
|
|
||||||
else if (
|
|
||||||
serialString.contains("grass_block")
|
|
||||||
|| serialString.contains("grass_slab")
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return EDhApiBlockMaterial.GRASS;
|
|
||||||
}
|
|
||||||
else if (
|
|
||||||
serialString.contains("dirt")
|
|
||||||
|| serialString.contains("gravel")
|
|
||||||
|| serialString.contains("mud")
|
|
||||||
|| serialString.contains("podzol")
|
|
||||||
|| serialString.contains("mycelium")
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return EDhApiBlockMaterial.DIRT;
|
|
||||||
}
|
|
||||||
#if MC_VER >= MC_1_17_1
|
|
||||||
else if (this.blockState.getSoundType() == SoundType.DEEPSLATE
|
|
||||||
|| this.blockState.getSoundType() == SoundType.DEEPSLATE_BRICKS
|
|
||||||
|| this.blockState.getSoundType() == SoundType.DEEPSLATE_TILES
|
|
||||||
|| this.blockState.getSoundType() == SoundType.POLISHED_DEEPSLATE
|
|
||||||
|| serialString.contains("deepslate") )
|
|
||||||
{
|
|
||||||
return EDhApiBlockMaterial.DEEPSLATE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else if (this.serialString.contains("snow"))
|
|
||||||
{
|
|
||||||
return EDhApiBlockMaterial.SNOW;
|
|
||||||
}
|
|
||||||
else if (serialString.contains("sand"))
|
|
||||||
{
|
|
||||||
return EDhApiBlockMaterial.SAND;
|
|
||||||
}
|
|
||||||
else if (serialString.contains("terracotta"))
|
|
||||||
{
|
|
||||||
return EDhApiBlockMaterial.TERRACOTTA;
|
|
||||||
}
|
|
||||||
else if (this.blockState.is(BlockTags.BASE_STONE_NETHER))
|
|
||||||
{
|
|
||||||
return EDhApiBlockMaterial.NETHER_STONE;
|
|
||||||
}
|
|
||||||
else if (serialString.contains("stone")
|
|
||||||
|| serialString.contains("ore"))
|
|
||||||
{
|
|
||||||
return EDhApiBlockMaterial.STONE;
|
|
||||||
}
|
|
||||||
else if (this.blockState.getLightEmission() > 0)
|
|
||||||
{
|
|
||||||
return EDhApiBlockMaterial.ILLUMINATED;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return EDhApiBlockMaterial.UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+117
-49
@@ -19,22 +19,21 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers.block;
|
package com.seibel.distanthorizons.common.wrappers.block;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.interfaces.block.IDhApiBlockStateWrapper;
|
||||||
|
import com.seibel.distanthorizons.api.interfaces.world.IDhApiLevelWrapper;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBlockColorOverrideEvent;
|
||||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||||
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
|
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
|
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
|
||||||
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPosMutable;
|
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPosMutable;
|
||||||
import com.seibel.distanthorizons.core.util.ColorUtil;
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||||
|
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.level.block.*;
|
import net.minecraft.world.level.block.*;
|
||||||
#if MC_VER >= MC_1_19_2
|
|
||||||
import net.minecraft.util.RandomSource;
|
|
||||||
#else
|
|
||||||
import java.util.Random;
|
|
||||||
#endif
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import net.minecraft.world.level.block.state.properties.SlabType;
|
import net.minecraft.world.level.block.state.properties.SlabType;
|
||||||
@@ -45,6 +44,12 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
|
#if MC_VER >= MC_1_19_2
|
||||||
|
import net.minecraft.util.RandomSource;
|
||||||
|
#else
|
||||||
|
import java.util.Random;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MC_VER < MC_1_21_5
|
#if MC_VER < MC_1_21_5
|
||||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
@@ -53,6 +58,8 @@ import net.minecraft.client.renderer.block.model.BakedQuad;
|
|||||||
#else
|
#else
|
||||||
import net.minecraft.client.renderer.block.dispatch.BlockStateModelPart;
|
import net.minecraft.client.renderer.block.dispatch.BlockStateModelPart;
|
||||||
import net.minecraft.client.resources.model.geometry.BakedQuad;
|
import net.minecraft.client.resources.model.geometry.BakedQuad;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.client.color.block.BlockTintSource;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,6 +126,7 @@ public class ClientBlockStateColorCache
|
|||||||
//===========//
|
//===========//
|
||||||
// constants //
|
// constants //
|
||||||
//===========//
|
//===========//
|
||||||
|
//region
|
||||||
|
|
||||||
private static final int MIN_SRGB_BITS = 0x39000000; // 2^(-13)
|
private static final int MIN_SRGB_BITS = 0x39000000; // 2^(-13)
|
||||||
private static final int MAX_SRGB_BITS = 0x3f7fffff; // 1.0 - f32::EPSILON
|
private static final int MAX_SRGB_BITS = 0x3f7fffff; // 1.0 - f32::EPSILON
|
||||||
@@ -182,14 +190,19 @@ public class ClientBlockStateColorCache
|
|||||||
//endregion
|
//endregion
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final ThreadLocal<TintWithoutLevelOverrider> TintWithoutLevelOverrideGetter = ThreadLocal.withInitial(() -> new TintWithoutLevelOverrider());
|
// these are threadlocals since AbstractDhTintGetter use local variables to handle color queries
|
||||||
private static final ThreadLocal<TintGetterOverride> TintOverrideGetter = ThreadLocal.withInitial(() -> new TintGetterOverride());
|
private static final ThreadLocal<TintWithoutLevelOverrider> TintWithoutLevelOverrideGetter = ThreadLocal.withInitial(TintWithoutLevelOverrider::new);
|
||||||
|
private static final ThreadLocal<TintGetterOverride> TintOverrideGetter = ThreadLocal.withInitial(TintGetterOverride::new);
|
||||||
|
private static final ThreadLocal<DhApiBlockColorOverrideEvent.EventParam> ColorOverrideEventParamGetter = ThreadLocal.withInitial(DhApiBlockColorOverrideEvent.EventParam::new);
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=============//
|
//=============//
|
||||||
// constructor //
|
// constructor //
|
||||||
//=============//
|
//=============//
|
||||||
|
//region
|
||||||
|
|
||||||
public ClientBlockStateColorCache(BlockState blockState, IClientLevelWrapper clientLevelWrapper)
|
public ClientBlockStateColorCache(BlockState blockState, IClientLevelWrapper clientLevelWrapper)
|
||||||
{
|
{
|
||||||
@@ -200,6 +213,8 @@ public class ClientBlockStateColorCache
|
|||||||
this.resolveColors();
|
this.resolveColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===================//
|
//===================//
|
||||||
@@ -244,6 +259,8 @@ public class ClientBlockStateColorCache
|
|||||||
if (quads != null
|
if (quads != null
|
||||||
&& !quads.isEmpty()
|
&& !quads.isEmpty()
|
||||||
&& quads.get(0) != null)
|
&& quads.get(0) != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
BakedQuad firstQuad = quads.get(0);
|
BakedQuad firstQuad = quads.get(0);
|
||||||
|
|
||||||
@@ -279,6 +296,20 @@ public class ClientBlockStateColorCache
|
|||||||
EColorMode.getColorMode(this.blockState.getBlock()));
|
EColorMode.getColorMode(this.blockState.getBlock()));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// Shouldn't normally happen, but there was at least
|
||||||
|
// one report of MC's texture being un-loaded
|
||||||
|
// which prevented us from getting the texture.
|
||||||
|
// So we should have some basic backup logic.
|
||||||
|
|
||||||
|
LOGGER.warn("Failed to get texture color for block ["+this.blockStateWrapper.getSerialString()+"] due to: ["+e.getMessage()+"], falling back to particle color.");
|
||||||
|
|
||||||
|
this.needPostTinting = false;
|
||||||
|
this.tintIndex = 0;
|
||||||
|
this.baseColor = this.getParticleIconColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Backup method.
|
// Backup method.
|
||||||
@@ -384,22 +415,14 @@ public class ClientBlockStateColorCache
|
|||||||
int scale = 1;
|
int scale = 1;
|
||||||
if (colorMode == EColorMode.Leaves)
|
if (colorMode == EColorMode.Leaves)
|
||||||
{
|
{
|
||||||
//switch (//FIXME add config option)
|
if (a == 0)
|
||||||
// case BLACK:
|
{
|
||||||
// a = 255; //simulate black background of fast leaves
|
|
||||||
// break;
|
|
||||||
// case IGNORE:
|
|
||||||
if (a == 0) {
|
|
||||||
continue; //same long grass
|
continue; //same long grass
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
a = 255; //just in case there are semi transparent pixels
|
a = 255; //just in case there are semi transparent pixels
|
||||||
}
|
}
|
||||||
// break;
|
|
||||||
// case TRANSPARENT:
|
|
||||||
// break; //do nothing, let it count towards transparency
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (a == 0 && colorMode != EColorMode.Glass)
|
else if (a == 0 && colorMode != EColorMode.Glass)
|
||||||
{
|
{
|
||||||
@@ -504,11 +527,9 @@ public class ClientBlockStateColorCache
|
|||||||
public int getColor(BiomeWrapper biomeWrapper, FullDataSourceV2 fullDataSource, DhBlockPos blockPos)
|
public int getColor(BiomeWrapper biomeWrapper, FullDataSourceV2 fullDataSource, DhBlockPos blockPos)
|
||||||
{
|
{
|
||||||
// only get the tint if the block needs to be tinted
|
// only get the tint if the block needs to be tinted
|
||||||
if (!this.needPostTinting)
|
int tintColor = AbstractDhTintGetter.INVALID_COLOR;
|
||||||
|
if (this.needPostTinting)
|
||||||
{
|
{
|
||||||
return this.baseColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
// don't try tinting blocks that don't support our method of tint getting
|
// don't try tinting blocks that don't support our method of tint getting
|
||||||
if (BROKEN_BLOCK_STATES.contains(this.blockState))
|
if (BROKEN_BLOCK_STATES.contains(this.blockState))
|
||||||
{
|
{
|
||||||
@@ -517,7 +538,6 @@ public class ClientBlockStateColorCache
|
|||||||
|
|
||||||
|
|
||||||
// attempt to get the tint
|
// attempt to get the tint
|
||||||
int tintColor = -1;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// try to use the fast tint getter logic first
|
// try to use the fast tint getter logic first
|
||||||
@@ -538,26 +558,58 @@ public class ClientBlockStateColorCache
|
|||||||
tintColor = Minecraft.getInstance()
|
tintColor = Minecraft.getInstance()
|
||||||
.getBlockColors()
|
.getBlockColors()
|
||||||
.getColor(this.blockState,
|
.getColor(this.blockState,
|
||||||
tintOverride,
|
tintOverride, // tintOverride will save the result of this query to speed up future queries
|
||||||
McObjectConverter.Convert(blockPos),
|
McObjectConverter.Convert(blockPos),
|
||||||
this.tintIndex);
|
this.tintIndex);
|
||||||
#else
|
#else
|
||||||
tintColor = Minecraft.getInstance()
|
BlockTintSource tintSource = Minecraft.getInstance()
|
||||||
.getBlockColors()
|
.getBlockColors()
|
||||||
.getTintSources(this.blockState)
|
.getTintSource(this.blockState, this.tintIndex);
|
||||||
.get(this.tintIndex)
|
// a tint source may be null for blocks that don't actually need tinting
|
||||||
.color(this.blockState);
|
// in that case the base color should be sufficient
|
||||||
#endif
|
// Example: cherry blossom leaves
|
||||||
}
|
if (tintSource != null)
|
||||||
}
|
|
||||||
catch (UnsupportedOperationException e)
|
|
||||||
{
|
{
|
||||||
// this exception generally occurs if the tint requires other blocks besides itself
|
BlockPos mcPos = McObjectConverter.Convert(blockPos);
|
||||||
LOGGER.debug("Unable to use ["+ TintWithoutLevelOverrider.class.getSimpleName()+"] to get the block tint for block: [" + this.blockState + "] and biome: [" + biomeWrapper + "] at pos: " + blockPos + ". Error: [" + e.getMessage() + "]. Attempting to use backup method...", e);
|
tintColor = tintSource.colorInWorld(this.blockState, tintOverride, mcPos);
|
||||||
BLOCK_STATES_THAT_NEED_LEVEL.add(this.blockState);
|
if (tintColor == -1)
|
||||||
|
{
|
||||||
|
tintColor = tintSource.colorAsTerrainParticle(this.blockState, tintOverride, mcPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tintColor == -1)
|
||||||
|
{
|
||||||
|
// no color found, use the base color
|
||||||
|
tintColor = AbstractDhTintGetter.INVALID_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// save this color to speed up future queries
|
||||||
|
TintWithoutLevelOverrider.setStaticColor(this.blockStateWrapper, biomeWrapper, tintColor);
|
||||||
|
// try to get the blended color with this new information
|
||||||
|
tintColor = tintOverride.tryGetBlockTint(new DhBlockPosMutable(blockPos));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
// this exception generally occurs if the tint requires other blocks besides itself
|
||||||
|
LOGGER.debug("Unable to use ["+ TintWithoutLevelOverrider.class.getSimpleName()+"] to get the block tint for block: [" + this.blockState + "] and biome: [" + biomeWrapper + "] at pos: " + blockPos + ". Error: [" + e.getMessage() + "]. Attempting to use backup method...", e);
|
||||||
|
BLOCK_STATES_THAT_NEED_LEVEL.add(this.blockState);
|
||||||
|
#else
|
||||||
|
// only display the error once per block/biome type to reduce log spam
|
||||||
|
if (!BROKEN_BLOCK_STATES.contains(this.blockState))
|
||||||
|
{
|
||||||
|
LOGGER.warn("Failed to get block color for block: [" + this.blockState + "] and biome: [" + biomeWrapper + "] at pos: " + blockPos + ". Error: [" + e.getMessage() + "]. Note: future errors for this block/biome will be ignored.", e);
|
||||||
|
BROKEN_BLOCK_STATES.add(this.blockState);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// level-specific logic is only needed for MC 1.21.11 and older
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
// use the level logic only if requested
|
// use the level logic only if requested
|
||||||
if (BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState))
|
if (BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState))
|
||||||
{
|
{
|
||||||
@@ -570,44 +622,57 @@ public class ClientBlockStateColorCache
|
|||||||
tintColor = tintOverride.tryGetBlockTint(new DhBlockPosMutable(blockPos));
|
tintColor = tintOverride.tryGetBlockTint(new DhBlockPosMutable(blockPos));
|
||||||
if (tintColor == AbstractDhTintGetter.INVALID_COLOR)
|
if (tintColor == AbstractDhTintGetter.INVALID_COLOR)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_21_11
|
|
||||||
tintColor = Minecraft.getInstance()
|
tintColor = Minecraft.getInstance()
|
||||||
.getBlockColors()
|
.getBlockColors()
|
||||||
.getColor(this.blockState,
|
.getColor(this.blockState,
|
||||||
tintOverride,
|
tintOverride,
|
||||||
McObjectConverter.Convert(blockPos),
|
McObjectConverter.Convert(blockPos),
|
||||||
this.tintIndex);
|
this.tintIndex);
|
||||||
#else
|
}
|
||||||
tintColor = Minecraft.getInstance()
|
}
|
||||||
.getBlockColors()
|
|
||||||
.getTintSources(this.blockState)
|
|
||||||
.get(this.tintIndex)
|
|
||||||
.color(this.blockState);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// only display the error once per block/biome type to reduce log spam
|
// only display the error once per block/biome type to reduce log spam
|
||||||
if (!BROKEN_BLOCK_STATES.contains(this.blockState))
|
if (!BROKEN_BLOCK_STATES.contains(this.blockState))
|
||||||
{
|
{
|
||||||
LOGGER.warn("Failed to get block color for block: [" + this.blockState + "] and biome: [" + biomeWrapper + "] at pos: " + blockPos + ". Error: ["+e.getMessage() + "]. Note: future errors for this block/biome will be ignored.", e);
|
LOGGER.warn("Failed to get block color for block: [" + this.blockState + "] and biome: [" + biomeWrapper + "] at pos: " + blockPos + ". Error: [" + e.getMessage() + "]. Note: future errors for this block/biome will be ignored.", e);
|
||||||
BROKEN_BLOCK_STATES.add(this.blockState);
|
BROKEN_BLOCK_STATES.add(this.blockState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int returnColor;
|
||||||
if (tintColor != -1)
|
if (tintColor != AbstractDhTintGetter.INVALID_COLOR)
|
||||||
{
|
{
|
||||||
return ColorUtil.multiplyARGBwithRGB(this.baseColor, tintColor);
|
returnColor = ColorUtil.multiplyARGBwithRGB(this.baseColor, tintColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// unable to get the tinted color, use the base color instead
|
// unable to get the tinted color, use the base color instead
|
||||||
return this.baseColor;
|
returnColor = this.baseColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// only fire an API event if needed
|
||||||
|
// (this is done to reduce GC pressure and speed up color getting)
|
||||||
|
if (this.blockStateWrapper.allowApiColorOverride())
|
||||||
|
{
|
||||||
|
DhApiBlockColorOverrideEvent.EventParam eventParam = ColorOverrideEventParamGetter.get();
|
||||||
|
eventParam.update(
|
||||||
|
this.clientLevelWrapper,
|
||||||
|
this.blockStateWrapper, returnColor,
|
||||||
|
blockPos.getX(), blockPos.getY(), blockPos.getZ()
|
||||||
|
);
|
||||||
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBlockColorOverrideEvent.class, eventParam);
|
||||||
|
|
||||||
|
// let the API user override this color
|
||||||
|
returnColor = eventParam.getColorAsInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -615,6 +680,7 @@ public class ClientBlockStateColorCache
|
|||||||
//================//
|
//================//
|
||||||
// helper classes //
|
// helper classes //
|
||||||
//================//
|
//================//
|
||||||
|
//region
|
||||||
|
|
||||||
private enum EColorMode
|
private enum EColorMode
|
||||||
{
|
{
|
||||||
@@ -646,6 +712,8 @@ public class ClientBlockStateColorCache
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|||||||
#if MC_VER < MC_1_17_1
|
#if MC_VER < MC_1_17_1
|
||||||
#elif MC_VER < MC_1_21_3
|
#elif MC_VER < MC_1_21_3
|
||||||
#else
|
#else
|
||||||
import com.seibel.distanthorizons.core.util.ColorUtil;
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
import net.minecraft.client.renderer.texture.SpriteContents;
|
import net.minecraft.client.renderer.texture.SpriteContents;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
-1121
File diff suppressed because it is too large
Load Diff
+1
@@ -1,5 +1,6 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.gui;
|
package com.seibel.distanthorizons.common.wrappers.gui;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.gui.classicConfig.ClassicConfigGUI;
|
||||||
import com.seibel.distanthorizons.core.config.ConfigHandler;
|
import com.seibel.distanthorizons.core.config.ConfigHandler;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
|
|||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package com.seibel.distanthorizons.common.wrappers.gui;
|
||||||
|
|
||||||
|
import org.lwjgl.util.tinyfd.TinyFileDialogs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should be used instead of the direct call to {@link TinyFileDialogs}
|
||||||
|
* so we can run additional validation and/or string cleanup.
|
||||||
|
* Otherwise, we may get error messages back. <br><br>
|
||||||
|
*
|
||||||
|
* source:
|
||||||
|
* https://sourceforge.net/projects/tinyfiledialogs/
|
||||||
|
*
|
||||||
|
* @see TinyFileDialogs
|
||||||
|
*/
|
||||||
|
public class NativeDialogUtil
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param dialogType the dialog type. One of:<br><table><tr><td>"ok"</td><td>"okcancel"</td><td>"yesno"</td><td>"yesnocancel"</td></tr></table>
|
||||||
|
* @param iconType the icon type. One of:<br><table><tr><td>"info"</td><td>"warning"</td><td>"error"</td><td>"question"</td></tr></table>
|
||||||
|
*/
|
||||||
|
public static void showDialog(String title, String message, String dialogType, String iconType)
|
||||||
|
{
|
||||||
|
// Tinyfd doesn't support the following characters, attempting to display them will cause the message
|
||||||
|
// to be replaced with an error message
|
||||||
|
String unsafeCharsRegex = "['\"`]";
|
||||||
|
|
||||||
|
title = title.replaceAll(unsafeCharsRegex, "");
|
||||||
|
message = message.replaceAll(unsafeCharsRegex, "");
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
TinyFileDialogs.tinyfd_messageBox(title, message, dialogType, iconType, false);
|
||||||
|
#else
|
||||||
|
// https://mfbridge.github.io/tinyfiledialogs/reference/messageBox.html
|
||||||
|
TinyFileDialogs.tinyfd_messageBox(title, message, dialogType, iconType, 1 /* ok/yes */);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+5
-5
@@ -218,11 +218,11 @@ public class TexturedButtonWidget extends Button
|
|||||||
this.getX(), this.getY(),
|
this.getX(), this.getY(),
|
||||||
this.getWidth(), this.getHeight());
|
this.getWidth(), this.getHeight());
|
||||||
#else
|
#else
|
||||||
//matrices.blitSprite(
|
matrices.blitSprite(
|
||||||
// RenderPipelines.GUI_TEXTURED,
|
RenderPipelines.GUI_TEXTURED,
|
||||||
// SPRITES.get(this.active, this.isHoveredOrFocused()),
|
SPRITES.get(this.active, this.isHoveredOrFocused()),
|
||||||
// this.getX(), this.getY(),
|
this.getX(), this.getY(),
|
||||||
// this.getWidth(), this.getHeight());
|
this.getWidth(), this.getHeight());
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
+384
@@ -0,0 +1,384 @@
|
|||||||
|
package com.seibel.distanthorizons.common.wrappers.gui.classicConfig;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.core.config.types.*;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.core.config.types.enums.EConfigCommentTextPosition;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.config.IConfigGui;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.Font;
|
||||||
|
import net.minecraft.client.gui.components.AbstractWidget;
|
||||||
|
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
|
||||||
|
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||||
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
||||||
|
#if MC_VER < MC_1_20_1
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import net.minecraft.client.gui.GuiComponent;
|
||||||
|
#elif MC_VER <= MC_1_21_11
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
#else
|
||||||
|
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER >= MC_1_17_1
|
||||||
|
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_10
|
||||||
|
#else
|
||||||
|
import net.minecraft.resources.Identifier;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.*;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Based upon TinyConfig but is highly modified
|
||||||
|
* https://github.com/Minenash/TinyConfig
|
||||||
|
*
|
||||||
|
* @author coolGi
|
||||||
|
* @author Motschen
|
||||||
|
* @author James Seibel
|
||||||
|
* @version 5-21-2022
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public class ClassicConfigGUI
|
||||||
|
{
|
||||||
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
public static final DhLogger RATE_LIMITED_LOGGER = new DhLoggerBuilder()
|
||||||
|
.maxCountPerSecond(1)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
public static final ConfigCoreInterface CONFIG_CORE_INTERFACE = new ConfigCoreInterface();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//==============//
|
||||||
|
// Initializers //
|
||||||
|
//==============//
|
||||||
|
|
||||||
|
// Some regexes to check if an input is valid
|
||||||
|
public static final Pattern INTEGER_ONLY_REGEX = Pattern.compile("(-?[0-9]*)");
|
||||||
|
public static final Pattern DECIMAL_ONLY_REGEX = Pattern.compile("-?([\\d]+\\.?[\\d]*|[\\d]*\\.?[\\d]+|\\.)");
|
||||||
|
|
||||||
|
public static class ConfigScreenConfigs
|
||||||
|
{
|
||||||
|
// This contains all the configs for the configs
|
||||||
|
public static final int SPACE_FROM_RIGHT_SCREEN = 10;
|
||||||
|
public static final int SPACE_BETWEEN_TEXT_AND_OPTION_FIELD = 8;
|
||||||
|
public static final int BUTTON_WIDTH_SPACING = 5;
|
||||||
|
public static final int RESET_BUTTON_WIDTH = 60;
|
||||||
|
public static final int RESET_BUTTON_HEIGHT = 20;
|
||||||
|
public static final int OPTION_FIELD_WIDTH = 150;
|
||||||
|
public static final int OPTION_FIELD_HEIGHT = 20;
|
||||||
|
public static final int CATEGORY_BUTTON_WIDTH = 200;
|
||||||
|
public static final int CATEGORY_BUTTON_HEIGHT = 20;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//==============//
|
||||||
|
// GUI handling //
|
||||||
|
//==============//
|
||||||
|
|
||||||
|
/** if you want to get this config gui's screen call this */
|
||||||
|
public static Screen getScreen(Screen parent, String category)
|
||||||
|
{ return new DhConfigScreen(parent, category); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//================//
|
||||||
|
// helper classes //
|
||||||
|
//================//
|
||||||
|
|
||||||
|
public static class ConfigListWidget extends ContainerObjectSelectionList<DhButtonEntry>
|
||||||
|
{
|
||||||
|
Font textRenderer;
|
||||||
|
|
||||||
|
public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing)
|
||||||
|
{
|
||||||
|
#if MC_VER < MC_1_20_4
|
||||||
|
super(minecraftClient, canvasWidth, canvasHeight, topMargin, canvasHeight - botMargin, itemSpacing);
|
||||||
|
#else
|
||||||
|
super(minecraftClient, canvasWidth, canvasHeight - (topMargin + botMargin), topMargin, itemSpacing);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
this.centerListVertically = false;
|
||||||
|
this.textRenderer = minecraftClient.font;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addButton(DhConfigScreen gui, AbstractConfigBase dhConfigType, AbstractWidget button, AbstractWidget resetButton, AbstractWidget indexButton, Component text)
|
||||||
|
{ this.addEntry(new DhButtonEntry(gui, dhConfigType, button, text, resetButton, indexButton)); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRowWidth() { return 10_000; }
|
||||||
|
|
||||||
|
public AbstractWidget getHoveredButton(double mouseX, double mouseY)
|
||||||
|
{
|
||||||
|
for (DhButtonEntry buttonEntry : this.children())
|
||||||
|
{
|
||||||
|
AbstractWidget button = buttonEntry.button;
|
||||||
|
if (button != null
|
||||||
|
&& button.visible)
|
||||||
|
{
|
||||||
|
#if MC_VER < MC_1_19_4
|
||||||
|
double minX = button.x;
|
||||||
|
double minY = button.y;
|
||||||
|
#else
|
||||||
|
double minX = button.getX();
|
||||||
|
double minY = button.getY();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
double maxX = minX + button.getWidth();
|
||||||
|
double maxY = minY + button.getHeight();
|
||||||
|
|
||||||
|
if (mouseX >= minX && mouseX < maxX
|
||||||
|
&& mouseY >= minY && mouseY < maxY)
|
||||||
|
{
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class DhButtonEntry extends ContainerObjectSelectionList.Entry<DhButtonEntry>
|
||||||
|
{
|
||||||
|
private static final Font textRenderer = Minecraft.getInstance().font;
|
||||||
|
|
||||||
|
private final AbstractWidget button;
|
||||||
|
|
||||||
|
private final DhConfigScreen gui;
|
||||||
|
|
||||||
|
private final AbstractWidget resetButton;
|
||||||
|
private final AbstractWidget indexButton;
|
||||||
|
private final Component text;
|
||||||
|
private final List<AbstractWidget> children = new ArrayList<>();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private final EConfigCommentTextPosition textPosition;
|
||||||
|
public final AbstractConfigBase dhConfigType;
|
||||||
|
|
||||||
|
public static final Map<AbstractWidget, Component> TEXT_BY_WIDGET = new HashMap<>();
|
||||||
|
public static final Map<AbstractWidget, DhButtonEntry> BUTTON_BY_WIDGET = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public DhButtonEntry(
|
||||||
|
DhConfigScreen gui, AbstractConfigBase dhConfigType,
|
||||||
|
AbstractWidget button, Component text, AbstractWidget resetButton, AbstractWidget indexButton)
|
||||||
|
{
|
||||||
|
TEXT_BY_WIDGET.put(button, text);
|
||||||
|
BUTTON_BY_WIDGET.put(button, this);
|
||||||
|
|
||||||
|
this.gui = gui;
|
||||||
|
this.dhConfigType = dhConfigType;
|
||||||
|
|
||||||
|
this.button = button;
|
||||||
|
this.resetButton = resetButton;
|
||||||
|
this.text = text;
|
||||||
|
this.indexButton = indexButton;
|
||||||
|
|
||||||
|
if (button != null) { this.children.add(button); }
|
||||||
|
if (resetButton != null) { this.children.add(resetButton); }
|
||||||
|
if (indexButton != null) { this.children.add(indexButton); }
|
||||||
|
|
||||||
|
|
||||||
|
EConfigCommentTextPosition textPosition = null;
|
||||||
|
if (this.dhConfigType instanceof ConfigUIComment)
|
||||||
|
{
|
||||||
|
textPosition = ((ConfigUIComment)this.dhConfigType).textPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (textPosition == null)
|
||||||
|
{
|
||||||
|
if (this.button != null)
|
||||||
|
{
|
||||||
|
// if a button is present
|
||||||
|
textPosition = EConfigCommentTextPosition.RIGHT_JUSTIFIED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
textPosition = EConfigCommentTextPosition.CENTERED_OVER_BUTTONS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.textPosition = textPosition;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
#if MC_VER < MC_1_20_1
|
||||||
|
public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta)
|
||||||
|
#elif MC_VER < MC_1_21_9
|
||||||
|
public void render(GuiGraphics matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta)
|
||||||
|
#elif MC_VER <= MC_1_21_11
|
||||||
|
public void renderContent(GuiGraphics matrices, int mouseX, int mouseY, boolean hovered, float tickDelta)
|
||||||
|
#else
|
||||||
|
public void extractContent(GuiGraphicsExtractor matrices, int mouseX, int mouseY, boolean hovered, float tickDelta)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// setting the "y" variable is necessary so each child item
|
||||||
|
// renders at the correct height,
|
||||||
|
// if not set they will render off-screen.
|
||||||
|
#if MC_VER < MC_1_21_9
|
||||||
|
// Y value passed in from method args
|
||||||
|
#else
|
||||||
|
int y = this.getY();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (this.button != null)
|
||||||
|
{
|
||||||
|
SetY(this.button, y);
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
this.button.render(matrices, mouseX, mouseY, tickDelta);
|
||||||
|
#else
|
||||||
|
this.button.extractRenderState(matrices, mouseX, mouseY, tickDelta);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.resetButton != null)
|
||||||
|
{
|
||||||
|
SetY(this.resetButton, y);
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
this.resetButton.render(matrices, mouseX, mouseY, tickDelta);
|
||||||
|
#else
|
||||||
|
this.resetButton.extractRenderState(matrices, mouseX, mouseY, tickDelta);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.indexButton != null)
|
||||||
|
{
|
||||||
|
SetY(this.indexButton, y);
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
this.indexButton.render(matrices, mouseX, mouseY, tickDelta);
|
||||||
|
#else
|
||||||
|
this.indexButton.extractRenderState(matrices, mouseX, mouseY, tickDelta);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.text != null)
|
||||||
|
{
|
||||||
|
int translatedLength = textRenderer.width(this.text);
|
||||||
|
|
||||||
|
int textXPos;
|
||||||
|
if (this.textPosition == EConfigCommentTextPosition.RIGHT_JUSTIFIED)
|
||||||
|
{
|
||||||
|
// text right justified aligned against the buttons
|
||||||
|
textXPos = this.gui.width
|
||||||
|
- translatedLength
|
||||||
|
- ConfigScreenConfigs.SPACE_BETWEEN_TEXT_AND_OPTION_FIELD
|
||||||
|
- ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN
|
||||||
|
- ConfigScreenConfigs.OPTION_FIELD_WIDTH
|
||||||
|
- ConfigScreenConfigs.BUTTON_WIDTH_SPACING
|
||||||
|
- ConfigScreenConfigs.RESET_BUTTON_WIDTH;
|
||||||
|
}
|
||||||
|
else if (this.textPosition == EConfigCommentTextPosition.CENTERED_OVER_BUTTONS)
|
||||||
|
{
|
||||||
|
// have button centered relative to a category button
|
||||||
|
textXPos = this.gui.width
|
||||||
|
- (translatedLength / 2)
|
||||||
|
- (ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH / 2)
|
||||||
|
- ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
||||||
|
}
|
||||||
|
else if (this.textPosition == EConfigCommentTextPosition.CENTER_OF_SCREEN)
|
||||||
|
{
|
||||||
|
// have button centered in the screen
|
||||||
|
textXPos = (this.gui.width / 2)
|
||||||
|
- (translatedLength / 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("No text position render defined for [" + this.textPosition + "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if MC_VER < MC_1_20_1
|
||||||
|
GuiComponent.drawString(matrices, textRenderer,
|
||||||
|
this.text,
|
||||||
|
textXPos, y + 5,
|
||||||
|
0xFFFFFF);
|
||||||
|
#elif MC_VER < MC_1_21_6
|
||||||
|
matrices.drawString(textRenderer,
|
||||||
|
this.text,
|
||||||
|
textXPos, y + 5,
|
||||||
|
0xFFFFFF);
|
||||||
|
#elif MC_VER <= MC_1_21_11
|
||||||
|
matrices.drawString(textRenderer,
|
||||||
|
this.text,
|
||||||
|
textXPos, y + 5,
|
||||||
|
0xFFFFFFFF);
|
||||||
|
#else
|
||||||
|
matrices.text(textRenderer,
|
||||||
|
this.text,
|
||||||
|
textXPos, y + 5,
|
||||||
|
0xFFFFFFFF);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// should prevent crashing the game if there's an issue
|
||||||
|
RATE_LIMITED_LOGGER.error("Unexpected gui rendering issue: ["+e.getMessage()+"]", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull List<? extends GuiEventListener> children()
|
||||||
|
{ return this.children; }
|
||||||
|
|
||||||
|
#if MC_VER >= MC_1_17_1
|
||||||
|
@Override
|
||||||
|
public @NotNull List<? extends NarratableEntry> narratables()
|
||||||
|
{ return this.children; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//================//
|
||||||
|
// event handling //
|
||||||
|
//================//
|
||||||
|
|
||||||
|
public static class ConfigCoreInterface implements IConfigGui
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* in the future it would be good to pass in the current page and other variables,
|
||||||
|
* but for now just knowing when the page is closed is good enough
|
||||||
|
*/
|
||||||
|
public final ArrayList<Runnable> onScreenChangeListenerList = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addOnScreenChangeListener(Runnable newListener) { this.onScreenChangeListenerList.add(newListener); }
|
||||||
|
@Override
|
||||||
|
public void removeOnScreenChangeListener(Runnable oldListener) { this.onScreenChangeListenerList.remove(oldListener); }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+799
@@ -0,0 +1,799 @@
|
|||||||
|
package com.seibel.distanthorizons.common.wrappers.gui.classicConfig;
|
||||||
|
|
||||||
|
import java.util.AbstractMap;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.enums.config.DisallowSelectingViaConfigGui;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.gui.DhScreen;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.gui.config.ConfigGuiInfo;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
|
import com.seibel.distanthorizons.core.config.ConfigHandler;
|
||||||
|
import com.seibel.distanthorizons.core.config.types.*;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.gui.updater.ChangelogScreen;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.core.config.types.enums.EConfigCommentTextPosition;
|
||||||
|
import com.seibel.distanthorizons.core.config.types.enums.EConfigValidity;
|
||||||
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
|
import com.seibel.distanthorizons.core.jar.updater.SelfUpdater;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
import com.seibel.distanthorizons.core.util.AnnotationUtil;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.config.IConfigGui;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.config.ILangWrapper;
|
||||||
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.Font;
|
||||||
|
import net.minecraft.client.gui.components.AbstractWidget;
|
||||||
|
import net.minecraft.client.gui.components.Button;
|
||||||
|
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
|
||||||
|
import net.minecraft.client.gui.components.EditBox;
|
||||||
|
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||||
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
|
||||||
|
#if MC_VER < MC_1_20_1
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import net.minecraft.client.gui.GuiComponent;
|
||||||
|
#elif MC_VER <= MC_1_21_11
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
#else
|
||||||
|
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER >= MC_1_17_1
|
||||||
|
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_10
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
#else
|
||||||
|
import net.minecraft.resources.Identifier;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
import com.mojang.blaze3d.platform.InputConstants;
|
||||||
|
|
||||||
|
import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.*;
|
||||||
|
import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.Translatable;
|
||||||
|
|
||||||
|
class DhConfigScreen extends DhScreen
|
||||||
|
{
|
||||||
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
private static final ILangWrapper LANG_WRAPPER = SingletonInjector.INSTANCE.get(ILangWrapper.class);
|
||||||
|
|
||||||
|
private static final String TRANSLATION_PREFIX = ModInfo.ID + ".config.";
|
||||||
|
|
||||||
|
private static final MinecraftClientWrapper MC_CLIENT = MinecraftClientWrapper.INSTANCE;
|
||||||
|
|
||||||
|
|
||||||
|
private final Screen parent;
|
||||||
|
private final String category;
|
||||||
|
private ClassicConfigGUI.ConfigListWidget configListWidget;
|
||||||
|
private boolean reload = false;
|
||||||
|
|
||||||
|
private Button doneButton;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=============//
|
||||||
|
// constructor //
|
||||||
|
//=============//
|
||||||
|
|
||||||
|
protected DhConfigScreen(Screen parent, String category)
|
||||||
|
{
|
||||||
|
super(Translatable(
|
||||||
|
LANG_WRAPPER.langExists(ModInfo.ID + ".config" + (category.isEmpty() ? "." + category : "") + ".title") ?
|
||||||
|
ModInfo.ID + ".config.title" :
|
||||||
|
ModInfo.ID + ".config" + (category.isEmpty() ? "" : "." + category) + ".title")
|
||||||
|
);
|
||||||
|
this.parent = parent;
|
||||||
|
this.category = category;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() { super.tick(); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//==================//
|
||||||
|
// menu UI creation //
|
||||||
|
//==================//
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init()
|
||||||
|
{
|
||||||
|
super.init();
|
||||||
|
if (!this.reload)
|
||||||
|
{
|
||||||
|
ConfigHandler.INSTANCE.configFileHandler.loadFromFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Changelog button
|
||||||
|
if (Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get()
|
||||||
|
// we only have changelogs for stable builds
|
||||||
|
&& !ModInfo.IS_DEV_BUILD)
|
||||||
|
{
|
||||||
|
this.addBtn(new TexturedButtonWidget(
|
||||||
|
// Where the button is on the screen
|
||||||
|
this.width - 28, this.height - 28,
|
||||||
|
// Width and height of the button
|
||||||
|
20, 20,
|
||||||
|
// texture UV Offset
|
||||||
|
0, 0,
|
||||||
|
// Some texture stuff
|
||||||
|
0,
|
||||||
|
#if MC_VER < MC_1_21_1
|
||||||
|
new ResourceLocation(ModInfo.ID, "textures/gui/changelog.png"),
|
||||||
|
#elif MC_VER <= MC_1_21_10
|
||||||
|
ResourceLocation.fromNamespaceAndPath(ModInfo.ID, "textures/gui/changelog.png"),
|
||||||
|
#else
|
||||||
|
Identifier.fromNamespaceAndPath(ModInfo.ID, "textures/gui/changelog.png"),
|
||||||
|
#endif
|
||||||
|
20, 20,
|
||||||
|
// Create the button and tell it where to go
|
||||||
|
(buttonWidget) -> {
|
||||||
|
ChangelogScreen changelogScreen = new ChangelogScreen(this);
|
||||||
|
if (changelogScreen.usable)
|
||||||
|
{
|
||||||
|
Objects.requireNonNull(this.minecraft).setScreen(changelogScreen);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGGER.warn("Changelog was not able to open");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Add a title to the button
|
||||||
|
Translatable(ModInfo.ID + ".updater.title")
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// back button
|
||||||
|
this.addBtn(MakeBtn(Translatable("distanthorizons.general.back"),
|
||||||
|
(this.width / 2) - 154, this.height - 28,
|
||||||
|
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_HEIGHT,
|
||||||
|
(button) ->
|
||||||
|
{
|
||||||
|
ConfigHandler.INSTANCE.configFileHandler.loadFromFile();
|
||||||
|
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
|
||||||
|
}));
|
||||||
|
|
||||||
|
// done/close button
|
||||||
|
this.doneButton = this.addBtn(
|
||||||
|
MakeBtn(Translatable("distanthorizons.general.done"),
|
||||||
|
(this.width / 2) + 4, this.height - 28,
|
||||||
|
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_HEIGHT,
|
||||||
|
(button) ->
|
||||||
|
{
|
||||||
|
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
|
||||||
|
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
|
||||||
|
}));
|
||||||
|
|
||||||
|
this.configListWidget = new ClassicConfigGUI.ConfigListWidget(this.minecraft, this.width * 2, this.height, 32, 32, 25);
|
||||||
|
|
||||||
|
#if MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+
|
||||||
|
if (this.minecraft != null && this.minecraft.level != null)
|
||||||
|
{
|
||||||
|
this.configListWidget.setRenderBackground(false);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
this.addWidget(this.configListWidget);
|
||||||
|
|
||||||
|
for (AbstractConfigBase<?> configEntry : ConfigHandler.INSTANCE.configBaseList)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (configEntry.getCategory().matches(this.category)
|
||||||
|
&& configEntry.getAppearance().showInGui)
|
||||||
|
{
|
||||||
|
this.addMenuItem(configEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
String message = "ERROR: Failed to show [" + configEntry.getNameAndCategory() + "], error: [" + e.getMessage() + "]";
|
||||||
|
if (configEntry.get() != null)
|
||||||
|
{
|
||||||
|
message += " with the value [" + configEntry.get() + "] with type [" + configEntry.getType() + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.error(message, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassicConfigGUI.CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run());
|
||||||
|
}
|
||||||
|
private void addMenuItem(AbstractConfigBase<?> configEntry)
|
||||||
|
{
|
||||||
|
trySetupConfigEntry(configEntry);
|
||||||
|
|
||||||
|
if (this.tryCreateInputField(configEntry)) return;
|
||||||
|
if (this.tryCreateCategoryButton(configEntry)) return;
|
||||||
|
if (this.tryCreateButton(configEntry)) return;
|
||||||
|
if (this.tryCreateComment(configEntry)) return;
|
||||||
|
if (this.tryCreateSpacer(configEntry)) return;
|
||||||
|
if (this.tryCreateLinkedEntry(configEntry)) return;
|
||||||
|
|
||||||
|
LOGGER.warn("Config [" + configEntry.getNameAndCategory() + "] failed to show. Please try something like changing its type.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void trySetupConfigEntry(AbstractConfigBase<?> configMenuOption)
|
||||||
|
{
|
||||||
|
configMenuOption.guiValue = new ConfigGuiInfo();
|
||||||
|
Class<?> configValueClass = configMenuOption.getType();
|
||||||
|
|
||||||
|
if (configMenuOption instanceof ConfigEntry)
|
||||||
|
{
|
||||||
|
ConfigEntry<?> configEntry = (ConfigEntry<?>) configMenuOption;
|
||||||
|
|
||||||
|
if (configValueClass == Integer.class)
|
||||||
|
{
|
||||||
|
setupTextMenuOption(configEntry, Integer::parseInt, ClassicConfigGUI.INTEGER_ONLY_REGEX, true);
|
||||||
|
}
|
||||||
|
else if (configValueClass == Double.class)
|
||||||
|
{
|
||||||
|
setupTextMenuOption(configEntry, Double::parseDouble, ClassicConfigGUI.DECIMAL_ONLY_REGEX, false);
|
||||||
|
}
|
||||||
|
else if (configValueClass == Float.class)
|
||||||
|
{
|
||||||
|
setupTextMenuOption(configEntry, Float::parseFloat, ClassicConfigGUI.DECIMAL_ONLY_REGEX, false);
|
||||||
|
}
|
||||||
|
else if (configValueClass == String.class || configValueClass == List.class)
|
||||||
|
{
|
||||||
|
// For string or list
|
||||||
|
setupTextMenuOption(configEntry, String::length, null, true);
|
||||||
|
}
|
||||||
|
else if (configValueClass == Boolean.class)
|
||||||
|
{
|
||||||
|
ConfigEntry<Boolean> booleanConfigEntry = (ConfigEntry<Boolean>) configEntry;
|
||||||
|
setupBooleanMenuOption(booleanConfigEntry);
|
||||||
|
}
|
||||||
|
else if (configValueClass.isEnum())
|
||||||
|
{
|
||||||
|
ConfigEntry<Enum<?>> enumConfigEntry = (ConfigEntry<Enum<?>>) configEntry;
|
||||||
|
Class<? extends Enum<?>> configEnumClass = (Class<? extends Enum<?>>) configValueClass;
|
||||||
|
setupEnumMenuOption(enumConfigEntry, configEnumClass);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGGER.error("No definition for config with type: [" + configValueClass.getName() + "], for config: [" + configMenuOption.name + "].");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private static void setupTextMenuOption(AbstractConfigBase<?> configMenuOption, Function<String, Number> parsingFunc, @Nullable Pattern pattern, boolean cast)
|
||||||
|
{
|
||||||
|
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) configMenuOption.guiValue);
|
||||||
|
|
||||||
|
configGuiInfo.tooltipFunction =
|
||||||
|
(editBox, button) ->
|
||||||
|
(stringValue) ->
|
||||||
|
{
|
||||||
|
boolean isNumber = (pattern != null);
|
||||||
|
|
||||||
|
stringValue = stringValue.trim();
|
||||||
|
if (!(stringValue.isEmpty() || !isNumber || pattern.matcher(stringValue).matches()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Number numberValue = configMenuOption.typeIsFloatingPointNumber() ? 0.0 : 0; // different default values are needed so implicit casting works correctly (if not done casting from 0 (an int) to a double will cause an exception)
|
||||||
|
configGuiInfo.errorMessage = null;
|
||||||
|
if (isNumber
|
||||||
|
&& !stringValue.isEmpty()
|
||||||
|
&& !stringValue.equals("-")
|
||||||
|
&& !stringValue.equals("."))
|
||||||
|
{
|
||||||
|
ConfigEntry<Number> numberConfigEntry = (ConfigEntry<Number>) configMenuOption;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
numberValue = parsingFunc.apply(stringValue);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
numberValue = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
EConfigValidity validity = numberConfigEntry.getValidity(numberValue);
|
||||||
|
switch (validity)
|
||||||
|
{
|
||||||
|
case VALID:
|
||||||
|
configGuiInfo.errorMessage = null;
|
||||||
|
break;
|
||||||
|
case NUMBER_TOO_LOW:
|
||||||
|
configGuiInfo.errorMessage = TextOrTranslatable("§cMinimum length is " + numberConfigEntry.getMin());
|
||||||
|
break;
|
||||||
|
case NUMBER_TOO_HIGH:
|
||||||
|
configGuiInfo.errorMessage = TextOrTranslatable("§cMaximum length is " + numberConfigEntry.getMax());
|
||||||
|
break;
|
||||||
|
case INVALID:
|
||||||
|
configGuiInfo.errorMessage = TextOrTranslatable("§cValue is invalid");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
editBox.setTextColor(((ConfigEntry<Number>) configMenuOption).getValidity(numberValue) == EConfigValidity.VALID ? 0xFFFFFFFF : 0xFFFF7777); // white and red
|
||||||
|
|
||||||
|
|
||||||
|
if (configMenuOption.getType() == String.class
|
||||||
|
|| configMenuOption.getType() == List.class)
|
||||||
|
{
|
||||||
|
((ConfigEntry<String>) configMenuOption).uiSetWithoutSaving(stringValue);
|
||||||
|
}
|
||||||
|
else if (((ConfigEntry<Number>) configMenuOption).getValidity(numberValue) == EConfigValidity.VALID)
|
||||||
|
{
|
||||||
|
if (!cast)
|
||||||
|
{
|
||||||
|
((ConfigEntry<Number>) configMenuOption).uiSetWithoutSaving(numberValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
((ConfigEntry<Number>) configMenuOption).uiSetWithoutSaving(numberValue != null ? numberValue.intValue() : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
private static void setupBooleanMenuOption(ConfigEntry<Boolean> booleanConfigEntry)
|
||||||
|
{
|
||||||
|
// For boolean
|
||||||
|
Function<Object, Component> func = value -> Translatable("distanthorizons.general." + ((Boolean) value ? "true" : "false")).withStyle((Boolean) value ? ChatFormatting.GREEN : ChatFormatting.RED);
|
||||||
|
|
||||||
|
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) booleanConfigEntry.guiValue);
|
||||||
|
|
||||||
|
configGuiInfo.buttonOptionMap =
|
||||||
|
new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(
|
||||||
|
(button) ->
|
||||||
|
{
|
||||||
|
button.active = !booleanConfigEntry.apiIsOverriding();
|
||||||
|
|
||||||
|
booleanConfigEntry.uiSetWithoutSaving(!booleanConfigEntry.get());
|
||||||
|
button.setMessage(func.apply(booleanConfigEntry.get()));
|
||||||
|
}, func);
|
||||||
|
}
|
||||||
|
private static void setupEnumMenuOption(ConfigEntry<Enum<?>> enumConfigEntry, Class<? extends Enum<?>> enumClass)
|
||||||
|
{
|
||||||
|
List<Enum<?>> enumList = Arrays.asList(enumClass.getEnumConstants());
|
||||||
|
|
||||||
|
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) enumConfigEntry.guiValue);
|
||||||
|
|
||||||
|
Function<Object, Component> getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString());
|
||||||
|
configGuiInfo.buttonOptionMap =
|
||||||
|
new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(
|
||||||
|
(button) ->
|
||||||
|
{
|
||||||
|
// get the currently selected enum and enum index
|
||||||
|
int startingIndex = enumList.indexOf(enumConfigEntry.get());
|
||||||
|
Enum<?> enumValue = enumList.get(startingIndex);
|
||||||
|
|
||||||
|
boolean shiftPressed =
|
||||||
|
InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_LEFT_SHIFT)
|
||||||
|
|| InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_RIGHT_SHIFT);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// move forward or backwards depending on if the shift key is pressed
|
||||||
|
int index = shiftPressed ? startingIndex - 1 : startingIndex + 1;
|
||||||
|
|
||||||
|
// wrap around to the other side of the array when necessary
|
||||||
|
if (index >= enumList.size())
|
||||||
|
{
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
else if (index < 0)
|
||||||
|
{
|
||||||
|
index = enumList.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// walk through the enums to find the next selectable one
|
||||||
|
while (index != startingIndex)
|
||||||
|
{
|
||||||
|
enumValue = enumList.get(index);
|
||||||
|
if (!AnnotationUtil.doesEnumHaveAnnotation(enumValue, DisallowSelectingViaConfigGui.class))
|
||||||
|
{
|
||||||
|
// this enum shouldn't be selectable via the UI,
|
||||||
|
// skip it
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// move forward or backwards depending on if the shift key is pressed
|
||||||
|
index = shiftPressed ? index - 1 : index + 1;
|
||||||
|
|
||||||
|
// wrap around to the other side of the array when necessary
|
||||||
|
if (index >= enumList.size())
|
||||||
|
{
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
else if (index < 0)
|
||||||
|
{
|
||||||
|
index = enumList.size() - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (index == startingIndex)
|
||||||
|
{
|
||||||
|
// one of the enums should be selectable, this is a programmer error
|
||||||
|
enumValue = enumList.get(startingIndex);
|
||||||
|
LOGGER.warn("Enum [" + enumValue.getClass() + "] doesn't contain any values that should be selectable via the UI, sticking to the currently selected value [" + enumValue + "].");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
enumConfigEntry.uiSetWithoutSaving(enumValue);
|
||||||
|
|
||||||
|
button.active = !enumConfigEntry.apiIsOverriding();
|
||||||
|
|
||||||
|
button.setMessage(getEnumTranslatableFunc.apply(enumConfigEntry.get()));
|
||||||
|
}, getEnumTranslatableFunc);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean tryCreateInputField(AbstractConfigBase<?> configBase)
|
||||||
|
{
|
||||||
|
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) configBase.guiValue);
|
||||||
|
|
||||||
|
if (configBase instanceof ConfigEntry)
|
||||||
|
{
|
||||||
|
ConfigEntry configEntry = (ConfigEntry) configBase;
|
||||||
|
|
||||||
|
|
||||||
|
//==============//
|
||||||
|
// reset button //
|
||||||
|
//==============//
|
||||||
|
|
||||||
|
Button.OnPress btnAction = (button) ->
|
||||||
|
{
|
||||||
|
configEntry.uiSetWithoutSaving(configEntry.getDefaultValue());
|
||||||
|
this.reload = true;
|
||||||
|
Objects.requireNonNull(this.minecraft).setScreen(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
int resetButtonPosX = this.width
|
||||||
|
- ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_WIDTH
|
||||||
|
- ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
||||||
|
int resetButtonPosZ = 0;
|
||||||
|
|
||||||
|
Button resetButton = MakeBtn(
|
||||||
|
Translatable("distanthorizons.general.reset").withStyle(ChatFormatting.RED),
|
||||||
|
resetButtonPosX, resetButtonPosZ,
|
||||||
|
ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_HEIGHT,
|
||||||
|
btnAction);
|
||||||
|
|
||||||
|
if (configEntry.apiIsOverriding())
|
||||||
|
{
|
||||||
|
resetButton.active = false;
|
||||||
|
resetButton.setMessage(Translatable("distanthorizons.general.apiOverride").withStyle(ChatFormatting.DARK_GRAY));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resetButton.active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//==============//
|
||||||
|
// option field //
|
||||||
|
//==============//
|
||||||
|
|
||||||
|
Component textComponent = this.GetTranslatableTextComponentForConfig(configEntry);
|
||||||
|
|
||||||
|
int optionFieldPosX = this.width
|
||||||
|
- ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN
|
||||||
|
- ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_WIDTH
|
||||||
|
- ClassicConfigGUI.ConfigScreenConfigs.BUTTON_WIDTH_SPACING
|
||||||
|
- ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH;
|
||||||
|
int optionFieldPosZ = 0;
|
||||||
|
|
||||||
|
if (configGuiInfo.buttonOptionMap != null)
|
||||||
|
{
|
||||||
|
// enum/multi option input button
|
||||||
|
|
||||||
|
Map.Entry<Button.OnPress, Function<Object, Component>> widget = configGuiInfo.buttonOptionMap;
|
||||||
|
if (configEntry.getType().isEnum())
|
||||||
|
{
|
||||||
|
widget.setValue((value) -> Translatable(TRANSLATION_PREFIX + "enum." + configEntry.getType().getSimpleName() + "." + configEntry.get().toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Button button = MakeBtn(
|
||||||
|
widget.getValue().apply(configEntry.get()),
|
||||||
|
optionFieldPosX, optionFieldPosZ,
|
||||||
|
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||||
|
widget.getKey());
|
||||||
|
|
||||||
|
// deactivate the button if the API is overriding it
|
||||||
|
button.active = !configEntry.apiIsOverriding();
|
||||||
|
|
||||||
|
|
||||||
|
this.configListWidget.addButton(this, configEntry,
|
||||||
|
button,
|
||||||
|
resetButton,
|
||||||
|
null,
|
||||||
|
textComponent);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// text box input
|
||||||
|
|
||||||
|
EditBox widget = new EditBox(this.font,
|
||||||
|
optionFieldPosX, optionFieldPosZ,
|
||||||
|
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||||
|
Translatable(""));
|
||||||
|
widget.setMaxLength(3_000_000); // hopefully 3 million characters should be enough for any normal use-case, lol
|
||||||
|
widget.insertText(String.valueOf(configEntry.get()));
|
||||||
|
|
||||||
|
Predicate<String> processor = configGuiInfo.tooltipFunction.apply(widget, this.doneButton);
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
widget.setFilter(processor);
|
||||||
|
#else
|
||||||
|
widget.setResponder(processor::test);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
this.configListWidget.addButton(this, configEntry, widget, resetButton, null, textComponent);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private boolean tryCreateCategoryButton(AbstractConfigBase<?> configType)
|
||||||
|
{
|
||||||
|
if (configType instanceof ConfigCategory)
|
||||||
|
{
|
||||||
|
ConfigCategory configCategory = (ConfigCategory) configType;
|
||||||
|
|
||||||
|
Component textComponent = this.GetTranslatableTextComponentForConfig(configCategory);
|
||||||
|
|
||||||
|
int categoryPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
||||||
|
int categoryPosZ = this.height - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT; // Note: the posZ value here seems to be ignored
|
||||||
|
|
||||||
|
Button widget = MakeBtn(textComponent,
|
||||||
|
categoryPosX, categoryPosZ,
|
||||||
|
ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||||
|
((button) ->
|
||||||
|
{
|
||||||
|
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
|
||||||
|
Objects.requireNonNull(this.minecraft).setScreen(ClassicConfigGUI.getScreen(this, configCategory.getDestination()));
|
||||||
|
}));
|
||||||
|
this.configListWidget.addButton(this, configType, widget, null, null, null);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private boolean tryCreateButton(AbstractConfigBase<?> configType)
|
||||||
|
{
|
||||||
|
if (configType instanceof ConfigUIButton)
|
||||||
|
{
|
||||||
|
ConfigUIButton configUiButton = (ConfigUIButton) configType;
|
||||||
|
|
||||||
|
Component textComponent = this.GetTranslatableTextComponentForConfig(configUiButton);
|
||||||
|
|
||||||
|
int buttonPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
||||||
|
|
||||||
|
Button widget = MakeBtn(textComponent,
|
||||||
|
buttonPosX, this.height - 28,
|
||||||
|
ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||||
|
(button) -> ((ConfigUIButton) configType).runAction());
|
||||||
|
this.configListWidget.addButton(this, configType, widget, null, null, null);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private boolean tryCreateComment(AbstractConfigBase<?> configType)
|
||||||
|
{
|
||||||
|
if (configType instanceof ConfigUIComment)
|
||||||
|
{
|
||||||
|
ConfigUIComment configUiComment = (ConfigUIComment) configType;
|
||||||
|
|
||||||
|
Component textComponent = this.GetTranslatableTextComponentForConfig(configUiComment);
|
||||||
|
if (configUiComment.parentConfigPath != null)
|
||||||
|
{
|
||||||
|
textComponent = Translatable(TRANSLATION_PREFIX + configUiComment.parentConfigPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.configListWidget.addButton(this, configType, null, null, null, textComponent);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private boolean tryCreateSpacer(AbstractConfigBase<?> configType)
|
||||||
|
{
|
||||||
|
if (configType instanceof ConfigUISpacer)
|
||||||
|
{
|
||||||
|
Button spacerButton = MakeBtn(Translatable("distanthorizons.general.spacer"),
|
||||||
|
10, 10, // having too small of a size causes division by 0 errors in older MC versions (IE 1.20.1)
|
||||||
|
1, 1,
|
||||||
|
(button) -> { });
|
||||||
|
|
||||||
|
spacerButton.visible = false;
|
||||||
|
this.configListWidget.addButton(this, configType, spacerButton, null, null, null);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private boolean tryCreateLinkedEntry(AbstractConfigBase<?> configType)
|
||||||
|
{
|
||||||
|
if (configType instanceof ConfigUiLinkedEntry)
|
||||||
|
{
|
||||||
|
this.addMenuItem(((ConfigUiLinkedEntry) configType).get());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Component GetTranslatableTextComponentForConfig(AbstractConfigBase<?> configType)
|
||||||
|
{ return Translatable(TRANSLATION_PREFIX + configType.getNameAndCategory()); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//===========//
|
||||||
|
// rendering //
|
||||||
|
//===========//
|
||||||
|
|
||||||
|
@Override
|
||||||
|
#if MC_VER < MC_1_20_1
|
||||||
|
public void render(PoseStack matrices, int mouseX, int mouseY, float delta)
|
||||||
|
#elif MC_VER <= MC_1_21_11
|
||||||
|
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
||||||
|
#else
|
||||||
|
public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#if MC_VER < MC_1_20_2 // 1.20.2 now enables this by default in the `this.list.render` function
|
||||||
|
this.renderBackground(matrices);
|
||||||
|
#elif MC_VER <= MC_1_21_11
|
||||||
|
super.render(matrices, mouseX, mouseY, delta);
|
||||||
|
#else
|
||||||
|
super.extractRenderState(matrices, mouseX, mouseY, delta);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Render buttons
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
this.configListWidget.render(matrices, mouseX, mouseY, delta);
|
||||||
|
#else
|
||||||
|
this.configListWidget.extractRenderState(matrices, mouseX, mouseY, delta);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Render config title
|
||||||
|
this.DhDrawCenteredString(matrices, this.font, this.title,
|
||||||
|
this.width / 2, 15,
|
||||||
|
#if MC_VER < MC_1_21_6
|
||||||
|
0xFFFFFF // RGB white
|
||||||
|
#else
|
||||||
|
0xFFFFFFFF // ARGB white
|
||||||
|
#endif );
|
||||||
|
|
||||||
|
|
||||||
|
// render DH version
|
||||||
|
this.DhDrawString(matrices, this.font, TextOrLiteral(ModInfo.VERSION), 2, this.height - 10,
|
||||||
|
#if MC_VER < MC_1_21_6
|
||||||
|
0xAAAAAA // RGB white
|
||||||
|
#else
|
||||||
|
0xFFAAAAAA // ARGB white
|
||||||
|
#endif );
|
||||||
|
|
||||||
|
// If the update is pending, display this message to inform the user that it will apply when the game restarts
|
||||||
|
if (SelfUpdater.deleteOldJarOnJvmShutdown)
|
||||||
|
{
|
||||||
|
this.DhDrawString(matrices, this.font, Translatable(ModInfo.ID + ".updater.waitingForClose"), 4, this.height - 42,
|
||||||
|
#if MC_VER < MC_1_21_6
|
||||||
|
0xFFFFFF // RGB white
|
||||||
|
#else
|
||||||
|
0xFFFFFFFF // ARGB white
|
||||||
|
#endif );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.renderTooltip(matrices, mouseX, mouseY, delta);
|
||||||
|
|
||||||
|
#if MC_VER < MC_1_20_2
|
||||||
|
super.render(matrices, mouseX, mouseY, delta);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if MC_VER < MC_1_20_1
|
||||||
|
private void renderTooltip(PoseStack matrices, int mouseX, int mouseY, float delta)
|
||||||
|
#elif MC_VER <= MC_1_21_11
|
||||||
|
private void renderTooltip(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
||||||
|
#else
|
||||||
|
private void renderTooltip(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
AbstractWidget hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY);
|
||||||
|
if (hoveredWidget == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ClassicConfigGUI.DhButtonEntry button = ClassicConfigGUI.DhButtonEntry.BUTTON_BY_WIDGET.get(hoveredWidget);
|
||||||
|
|
||||||
|
|
||||||
|
// A quick fix for tooltips on linked entries
|
||||||
|
AbstractConfigBase<?> configBase = ConfigUiLinkedEntry.class.isAssignableFrom(button.dhConfigType.getClass()) ?
|
||||||
|
((ConfigUiLinkedEntry) button.dhConfigType).get() :
|
||||||
|
button.dhConfigType;
|
||||||
|
|
||||||
|
boolean apiOverrideActive = false;
|
||||||
|
if (configBase instanceof ConfigEntry)
|
||||||
|
{
|
||||||
|
apiOverrideActive = ((ConfigEntry<?>) configBase).apiIsOverriding();
|
||||||
|
}
|
||||||
|
|
||||||
|
String key = TRANSLATION_PREFIX + (configBase.category.isEmpty() ? "" : configBase.category + ".") + configBase.getName() + ".@tooltip";
|
||||||
|
|
||||||
|
if (apiOverrideActive)
|
||||||
|
{
|
||||||
|
key = "distanthorizons.general.disabledByApi.@tooltip";
|
||||||
|
}
|
||||||
|
|
||||||
|
// display the validation error tooltip if present
|
||||||
|
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) configBase.guiValue);
|
||||||
|
if (configGuiInfo.errorMessage != null)
|
||||||
|
{
|
||||||
|
this.DhRenderTooltip(matrices, this.font, configGuiInfo.errorMessage, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
// display the tooltip if present
|
||||||
|
else if (LANG_WRAPPER.langExists(key))
|
||||||
|
{
|
||||||
|
List<Component> list = new ArrayList<>();
|
||||||
|
String lang = LANG_WRAPPER.getLang(key);
|
||||||
|
for (String langLine : lang.split("\n"))
|
||||||
|
{
|
||||||
|
list.add(TextOrTranslatable(langLine));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.DhRenderComponentTooltip(matrices, this.font, list, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//==========//
|
||||||
|
// shutdown //
|
||||||
|
//==========//
|
||||||
|
|
||||||
|
/** When you close it, it goes to the previous screen and saves */
|
||||||
|
@Override
|
||||||
|
public void onClose()
|
||||||
|
{
|
||||||
|
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
|
||||||
|
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
|
||||||
|
|
||||||
|
ClassicConfigGUI.CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+12
@@ -22,6 +22,7 @@ package com.seibel.distanthorizons.common.wrappers.minecraft;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
import com.mojang.blaze3d.platform.Window;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.gui.NativeDialogUtil;
|
||||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure;
|
import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure;
|
||||||
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
|
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
|
||||||
@@ -370,17 +371,28 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
public void crashMinecraft(String errorMessage, Throwable exception)
|
public void crashMinecraft(String errorMessage, Throwable exception)
|
||||||
{
|
{
|
||||||
LOGGER.fatal(ModInfo.READABLE_NAME + " had the following error: [" + errorMessage + "]. Crashing Minecraft...", exception);
|
LOGGER.fatal(ModInfo.READABLE_NAME + " had the following error: [" + errorMessage + "]. Crashing Minecraft...", exception);
|
||||||
|
|
||||||
|
// Only crash once the renderer has been set up.
|
||||||
|
// If the renderer hasn't been set up yet crashing MC will
|
||||||
|
// cause a Blaze3D/UI error instead of the error we're trying to send.
|
||||||
|
executeOnRenderThread(() ->
|
||||||
|
{
|
||||||
CrashReport report = new CrashReport(errorMessage, exception);
|
CrashReport report = new CrashReport(errorMessage, exception);
|
||||||
#if MC_VER < MC_1_20_4
|
#if MC_VER < MC_1_20_4
|
||||||
Minecraft.crash(report);
|
Minecraft.crash(report);
|
||||||
#else
|
#else
|
||||||
MINECRAFT.delayCrash(report);
|
MINECRAFT.delayCrash(report);
|
||||||
#endif
|
#endif
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executeOnRenderThread(Runnable runnable) { MINECRAFT.execute(runnable); }
|
public void executeOnRenderThread(Runnable runnable) { MINECRAFT.execute(runnable); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showDialog(String title, String message, String dialogType, String iconType)
|
||||||
|
{ NativeDialogUtil.showDialog(title, message, dialogType, iconType); }
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -30,9 +30,10 @@ import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
|||||||
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||||
import com.seibel.distanthorizons.core.enums.EDhDirection;
|
import com.seibel.distanthorizons.core.enums.EDhDirection;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.util.ColorUtil;
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.ILightMapWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.ILightMapWrapper;
|
||||||
|
|
||||||
#if MC_VER < MC_1_17_1
|
#if MC_VER < MC_1_17_1
|
||||||
@@ -57,6 +58,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
|||||||
import com.seibel.distanthorizons.core.util.math.Vec3d;
|
import com.seibel.distanthorizons.core.util.math.Vec3d;
|
||||||
import com.seibel.distanthorizons.core.util.math.Vec3f;
|
import com.seibel.distanthorizons.core.util.math.Vec3f;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
|
||||||
|
|
||||||
import net.minecraft.client.Camera;
|
import net.minecraft.client.Camera;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -97,6 +99,8 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
{
|
{
|
||||||
public static final MinecraftRenderWrapper INSTANCE = new MinecraftRenderWrapper();
|
public static final MinecraftRenderWrapper INSTANCE = new MinecraftRenderWrapper();
|
||||||
|
|
||||||
|
private static final IOptifineAccessor OPTIFINE_ACCESSOR = ModAccessorInjector.INSTANCE.get(IOptifineAccessor.class);
|
||||||
|
|
||||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
private static final Minecraft MC = Minecraft.getInstance();
|
private static final Minecraft MC = Minecraft.getInstance();
|
||||||
|
|
||||||
@@ -364,7 +368,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
public int getTargetFramebuffer()
|
public int getTargetFramebuffer()
|
||||||
{
|
{
|
||||||
// used so we can access the framebuffer shaders end up rendering to
|
// used so we can access the framebuffer shaders end up rendering to
|
||||||
if (AbstractOptifineAccessor.optifinePresent())
|
if (OPTIFINE_ACCESSOR != null)
|
||||||
{
|
{
|
||||||
return this.finalLevelFrameBufferId;
|
return this.finalLevelFrameBufferId;
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-11
@@ -23,27 +23,47 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IProfilerWrap
|
|||||||
|
|
||||||
import net.minecraft.util.profiling.ProfilerFiller;
|
import net.minecraft.util.profiling.ProfilerFiller;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author James Seibel
|
|
||||||
* @version 11-20-2021
|
|
||||||
*/
|
|
||||||
public class ProfilerWrapper implements IProfilerWrapper
|
public class ProfilerWrapper implements IProfilerWrapper
|
||||||
{
|
{
|
||||||
public ProfilerFiller profiler;
|
public ProfilerFiller profiler;
|
||||||
|
|
||||||
public ProfilerWrapper(ProfilerFiller newProfiler) { this.profiler = newProfiler; }
|
public ProfilerWrapper(ProfilerFiller newProfiler) { this.profiler = newProfiler; }
|
||||||
|
|
||||||
|
|
||||||
/** starts a new section inside the currently running section */
|
|
||||||
@Override
|
@Override
|
||||||
public void push(String newSection) { this.profiler.push(newSection); }
|
public IProfileBlock push(String newSection)
|
||||||
|
{
|
||||||
|
this.profiler.push(newSection);
|
||||||
|
return new ProfileBlock(this.profiler);
|
||||||
|
}
|
||||||
|
|
||||||
/** ends the currently running section and starts a new one */
|
|
||||||
@Override
|
@Override
|
||||||
public void popPush(String newSection) { this.profiler.popPush(newSection); }
|
public void popPush(String newSection)
|
||||||
|
{
|
||||||
|
this.profiler.popPush(newSection);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//================//
|
||||||
|
// helper classes //
|
||||||
|
//================//
|
||||||
|
//region
|
||||||
|
|
||||||
|
public static class ProfileBlock implements IProfileBlock
|
||||||
|
{
|
||||||
|
private final ProfilerFiller profiler;
|
||||||
|
public ProfileBlock(ProfilerFiller newProfiler) { this.profiler = newProfiler; }
|
||||||
|
|
||||||
|
|
||||||
/** ends the currently running section */
|
|
||||||
@Override
|
@Override
|
||||||
public void pop() { this.profiler.pop(); }
|
public void close()
|
||||||
|
{
|
||||||
|
this.profiler.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,7 @@ import net.minecraft.world.level.chunk.status.ChunkStatus;
|
|||||||
#if MC_VER < MC_1_21_3
|
#if MC_VER < MC_1_21_3
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
#else
|
#else
|
||||||
import com.seibel.distanthorizons.core.util.ColorUtil;
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_10
|
#if MC_VER <= MC_1_21_10
|
||||||
|
|||||||
+2
-17
@@ -154,22 +154,12 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm
|
|||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
boolean isTerraFirmaCraftPresent = false;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Class.forName("net.dries007.tfc.world.TFCChunkGenerator");
|
|
||||||
isTerraFirmaCraftPresent = true;
|
|
||||||
LOGGER.info("TerraFirmaCraft detected.");
|
|
||||||
}
|
|
||||||
catch (ClassNotFoundException ignore) { }
|
|
||||||
|
|
||||||
|
|
||||||
ImmutableMap.Builder<EDhApiWorldGenerationStep, Integer> builder = ImmutableMap.builder();
|
ImmutableMap.Builder<EDhApiWorldGenerationStep, Integer> builder = ImmutableMap.builder();
|
||||||
builder.put(EDhApiWorldGenerationStep.EMPTY, 1);
|
builder.put(EDhApiWorldGenerationStep.EMPTY, 1);
|
||||||
builder.put(EDhApiWorldGenerationStep.STRUCTURE_START, 0);
|
builder.put(EDhApiWorldGenerationStep.STRUCTURE_START, 0);
|
||||||
builder.put(EDhApiWorldGenerationStep.STRUCTURE_REFERENCE, 0);
|
builder.put(EDhApiWorldGenerationStep.STRUCTURE_REFERENCE, 0);
|
||||||
builder.put(EDhApiWorldGenerationStep.BIOMES, isTerraFirmaCraftPresent ? 1 : 0);
|
builder.put(EDhApiWorldGenerationStep.BIOMES, 0);
|
||||||
builder.put(EDhApiWorldGenerationStep.NOISE, isTerraFirmaCraftPresent ? 1 : 0);
|
builder.put(EDhApiWorldGenerationStep.NOISE, 0);
|
||||||
builder.put(EDhApiWorldGenerationStep.SURFACE, 0);
|
builder.put(EDhApiWorldGenerationStep.SURFACE, 0);
|
||||||
builder.put(EDhApiWorldGenerationStep.CARVERS, 0);
|
builder.put(EDhApiWorldGenerationStep.CARVERS, 0);
|
||||||
builder.put(EDhApiWorldGenerationStep.LIQUID_CARVERS, 0);
|
builder.put(EDhApiWorldGenerationStep.LIQUID_CARVERS, 0);
|
||||||
@@ -205,11 +195,6 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm
|
|||||||
LOGGER.info("TerraForge Chunk Generator detected: [" + generator.getClass() + "], Distant Generation will try its best to support it.");
|
LOGGER.info("TerraForge Chunk Generator detected: [" + generator.getClass() + "], Distant Generation will try its best to support it.");
|
||||||
LOGGER.info("If it does crash, turn Distant Generation off or set it to to [" + EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY + "].");
|
LOGGER.info("If it does crash, turn Distant Generation off or set it to to [" + EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY + "].");
|
||||||
}
|
}
|
||||||
else if (generator.getClass().toString().equals("class net.dries007.tfc.world.TFCChunkGenerator"))
|
|
||||||
{
|
|
||||||
LOGGER.info("TerraFirmaCraft Chunk Generator detected: [" + generator.getClass() + "], Distant Generation will try its best to support it.");
|
|
||||||
LOGGER.info("If it does crash, turn Distant Generation off or set it to to [" + EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY + "].");
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOGGER.warn("Unknown Chunk Generator detected: [" + generator.getClass() + "], Distant Generation May Fail!");
|
LOGGER.warn("Unknown Chunk Generator detected: [" + generator.getClass() + "], Distant Generation May Fail!");
|
||||||
|
|||||||
+21
-5
@@ -12,11 +12,9 @@ import com.seibel.distanthorizons.core.config.Config;
|
|||||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||||
import com.seibel.distanthorizons.core.enums.MinecraftTextFormat;
|
import com.seibel.distanthorizons.core.enums.MinecraftTextFormat;
|
||||||
import com.seibel.distanthorizons.core.generation.DhLightingEngine;
|
import com.seibel.distanthorizons.core.generation.DhLightingEngine;
|
||||||
import com.seibel.distanthorizons.core.level.DhServerLevel;
|
|
||||||
import com.seibel.distanthorizons.core.level.IDhServerLevel;
|
import com.seibel.distanthorizons.core.level.IDhServerLevel;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
|
||||||
import com.seibel.distanthorizons.core.util.ExceptionUtil;
|
import com.seibel.distanthorizons.core.util.ExceptionUtil;
|
||||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||||
import com.seibel.distanthorizons.core.util.TimerUtil;
|
import com.seibel.distanthorizons.core.util.TimerUtil;
|
||||||
@@ -195,12 +193,22 @@ public class InternalServerGenerator
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
ArrayList<CompletableFuture<Void>> releaseFutures = new ArrayList<>();
|
||||||
|
|
||||||
// release all chunks from the server to prevent out of memory issues
|
// release all chunks from the server to prevent out of memory issues
|
||||||
Iterator<ChunkPos> chunkPosIterator = ChunkPosGenStream.getIterator(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.widthInChunks, 0);
|
Iterator<ChunkPos> chunkPosIterator = ChunkPosGenStream.getIterator(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.widthInChunks, 0);
|
||||||
while (chunkPosIterator.hasNext())
|
while (chunkPosIterator.hasNext())
|
||||||
{
|
{
|
||||||
ChunkPos chunkPos = chunkPosIterator.next();
|
ChunkPos chunkPos = chunkPosIterator.next();
|
||||||
this.releaseChunkFromServer(this.params.mcServerLevel, this.params.dhServerLevel, chunkPos);
|
releaseFutures.add(this.releaseChunkFromServerAsync(this.params.mcServerLevel, chunkPos));
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait for all release futures to finish to prevent an issue where DH queues
|
||||||
|
// tickets faster than MC can clear them out
|
||||||
|
for (int i = 0; i < releaseFutures.size(); i++)
|
||||||
|
{
|
||||||
|
CompletableFuture<Void> releaseFuture = releaseFutures.get(i);
|
||||||
|
releaseFuture.join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -286,8 +294,10 @@ public class InternalServerGenerator
|
|||||||
* mitigates out of memory issues in the vanilla chunk system. <br>
|
* mitigates out of memory issues in the vanilla chunk system. <br>
|
||||||
* See: https://github.com/pop4959/Chunky/pull/383
|
* See: https://github.com/pop4959/Chunky/pull/383
|
||||||
*/
|
*/
|
||||||
private void releaseChunkFromServer(ServerLevel level, IDhServerLevel dhLevel, ChunkPos chunkPos)
|
private CompletableFuture<Void> releaseChunkFromServerAsync(ServerLevel level, ChunkPos chunkPos)
|
||||||
{
|
{
|
||||||
|
CompletableFuture<Void> removeTicketFuture = new CompletableFuture<>();
|
||||||
|
|
||||||
level.getChunkSource().chunkMap.mainThreadExecutor.execute(() ->
|
level.getChunkSource().chunkMap.mainThreadExecutor.execute(() ->
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -323,9 +333,15 @@ public class InternalServerGenerator
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LOGGER.warn("Failed to release chunk back to internal server. Error: ["+e.getMessage()+"]", e);
|
LOGGER.warn("Failed to release chunk ["+chunkPos+"] back to internal server. Error: ["+e.getMessage()+"]", e);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
removeTicketFuture.complete(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return removeTicketFuture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
-3
@@ -40,8 +40,6 @@ public final class ThreadWorldGenParams
|
|||||||
public StructureCheck structCheck;
|
public StructureCheck structCheck;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
boolean isValid = true;
|
|
||||||
|
|
||||||
// used for some older MC versions
|
// used for some older MC versions
|
||||||
private static GlobalWorldGenParams previousGlobalWorldGenParams = null;
|
private static GlobalWorldGenParams previousGlobalWorldGenParams = null;
|
||||||
|
|
||||||
@@ -55,7 +53,6 @@ public final class ThreadWorldGenParams
|
|||||||
{
|
{
|
||||||
ThreadWorldGenParams threadParam = LOCAL_PARAM_REF.get();
|
ThreadWorldGenParams threadParam = LOCAL_PARAM_REF.get();
|
||||||
if (threadParam != null
|
if (threadParam != null
|
||||||
&& threadParam.isValid
|
|
||||||
&& threadParam.level == globalParams.mcServerLevel)
|
&& threadParam.level == globalParams.mcServerLevel)
|
||||||
{
|
{
|
||||||
return threadParam;
|
return threadParam;
|
||||||
|
|||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
publish_version()
|
|
||||||
{
|
|
||||||
if [[ "$2" == "all" || "$1" == "$2" ]]
|
|
||||||
then
|
|
||||||
docker run --name=dh-build-$1 --rm -v /${PWD}:/home/build -e MC_VER=$1 dh-eclipse-temurin
|
|
||||||
cp ./fabric/build/libs/*$1.jar ./buildAllJars/fabric/
|
|
||||||
cp ./forge/build/libs/*$1.jar ./buildAllJars/forge/
|
|
||||||
cp ./Merged/*.jar ./buildAllJars/merged/
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$1" ]
|
|
||||||
then
|
|
||||||
echo "Build target is undefined! [all] [1.20.1] [1.19.4] [1.19.2] [1.18.2] [1.17.1] [1.16.5]"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker build --tag=dh-eclipse-temurin -q .
|
|
||||||
|
|
||||||
mkdir -p buildAllJars/fabric
|
|
||||||
mkdir -p buildAllJars/forge
|
|
||||||
mkdir -p buildAllJars/merged
|
|
||||||
publish_version 1.20.1 $1
|
|
||||||
publish_version 1.19.4 $1
|
|
||||||
publish_version 1.19.2 $1
|
|
||||||
publish_version 1.18.2 $1
|
|
||||||
publish_version 1.17.1 $1
|
|
||||||
publish_version 1.16.5 $1
|
|
||||||
+1
-1
Submodule coreSubProjects updated: 71e6b9b58e...b592012ba8
+2
-2
@@ -76,12 +76,12 @@ task deleteResources(type: Delete) {
|
|||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
dependsOn(copyCoreResources)
|
dependsOn(copyCoreResources)
|
||||||
dependsOn(copyCommonLoaderResources)
|
// dependsOn(copyCommonLoaderResources)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named('runClient') {
|
tasks.named('runClient') {
|
||||||
dependsOn(copyCoreResources)
|
dependsOn(copyCoreResources)
|
||||||
dependsOn(copyCommonLoaderResources)
|
// dependsOn(copyCommonLoaderResources)
|
||||||
finalizedBy(deleteResources)
|
finalizedBy(deleteResources)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,13 @@ import java.util.concurrent.AbstractExecutorService;
|
|||||||
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
|
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
#else
|
||||||
|
import net.fabricmc.fabric.api.client.rendering.v1.level.LevelRenderContext;
|
||||||
|
import net.fabricmc.fabric.api.client.rendering.v1.level.LevelRenderEvents;
|
||||||
|
import net.fabricmc.fabric.api.client.rendering.v1.level.LevelTerrainRenderContext;
|
||||||
|
#endif
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.InputConstants;
|
import com.mojang.blaze3d.platform.InputConstants;
|
||||||
|
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
@@ -91,6 +98,7 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
private static final MinecraftClientWrapper MC = MinecraftClientWrapper.INSTANCE;
|
private static final MinecraftClientWrapper MC = MinecraftClientWrapper.INSTANCE;
|
||||||
private static final AbstractPluginPacketSender PACKET_SENDER = (AbstractPluginPacketSender) SingletonInjector.INSTANCE.get(IPluginPacketSender.class);
|
private static final AbstractPluginPacketSender PACKET_SENDER = (AbstractPluginPacketSender) SingletonInjector.INSTANCE.get(IPluginPacketSender.class);
|
||||||
|
|
||||||
|
@Deprecated // just use the static reference
|
||||||
private static final ClientApi clientApi = ClientApi.INSTANCE;
|
private static final ClientApi clientApi = ClientApi.INSTANCE;
|
||||||
|
|
||||||
HashSet<Integer> previouslyPressKeyCodes = new HashSet<>();
|
HashSet<Integer> previouslyPressKeyCodes = new HashSet<>();
|
||||||
@@ -108,17 +116,10 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//========================//
|
|
||||||
// register mod accessors //
|
|
||||||
//========================//
|
|
||||||
|
|
||||||
SodiumAccessor sodiumAccessor = (SodiumAccessor) ModAccessorInjector.INSTANCE.get(ISodiumAccessor.class);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==============//
|
//==============//
|
||||||
// chunk events //
|
// chunk events //
|
||||||
//==============//
|
//==============//
|
||||||
|
//region
|
||||||
|
|
||||||
// ClientChunkLoadEvent
|
// ClientChunkLoadEvent
|
||||||
ClientChunkEvents.CHUNK_LOAD.register((level, chunk) ->
|
ClientChunkEvents.CHUNK_LOAD.register((level, chunk) ->
|
||||||
@@ -214,12 +215,14 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==============//
|
//==============//
|
||||||
// render event //
|
// render event //
|
||||||
//==============//
|
//==============//
|
||||||
|
//region
|
||||||
|
|
||||||
#if MC_VER < MC_1_21_9
|
#if MC_VER < MC_1_21_9
|
||||||
WorldRenderEvents.AFTER_SETUP.register((renderContext) ->
|
WorldRenderEvents.AFTER_SETUP.register((renderContext) ->
|
||||||
@@ -298,6 +301,27 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
#else
|
||||||
|
LevelRenderEvents.AFTER_TRANSLUCENT_TERRAIN.register((LevelRenderContext levelRenderContext) ->
|
||||||
|
{
|
||||||
|
ClientApi.INSTANCE.renderFadeTransparent();
|
||||||
|
});
|
||||||
|
|
||||||
|
LevelRenderEvents.AFTER_OPAQUE_TERRAIN.register((LevelTerrainRenderContext levelTerrainRenderContext) ->
|
||||||
|
{
|
||||||
|
ClientApi.INSTANCE.renderFadeOpaque();
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=================//
|
||||||
|
// keyboard events //
|
||||||
|
//=================//
|
||||||
|
//region
|
||||||
|
|
||||||
// Debug keyboard event
|
// Debug keyboard event
|
||||||
// FIXME: Use better hooks so it doesn't trigger key press events in text boxes
|
// FIXME: Use better hooks so it doesn't trigger key press events in text boxes
|
||||||
@@ -309,11 +333,14 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==================//
|
//==================//
|
||||||
// networking event //
|
// networking event //
|
||||||
//==================//
|
//==================//
|
||||||
|
//region
|
||||||
|
|
||||||
#if MC_VER < MC_1_20_6
|
#if MC_VER < MC_1_20_6
|
||||||
ClientPlayNetworking.registerGlobalReceiver(AbstractPluginPacketSender.WRAPPER_PACKET_RESOURCE, (client, handler, buffer, packetSender) ->
|
ClientPlayNetworking.registerGlobalReceiver(AbstractPluginPacketSender.WRAPPER_PACKET_RESOURCE, (client, handler, buffer, packetSender) ->
|
||||||
@@ -345,6 +372,11 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
ClientApi.INSTANCE.pluginMessageReceived(payload.message());
|
ClientApi.INSTANCE.pluginMessageReceived(payload.message());
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onKeyInput()
|
public void onKeyInput()
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import com.seibel.distanthorizons.core.config.Config;
|
|||||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.util.NativeDialogUtil;
|
import com.seibel.distanthorizons.common.wrappers.gui.NativeDialogUtil;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.*;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.*;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.seibel.distanthorizons.fabric;
|
package com.seibel.distanthorizons.fabric;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.DhApi;
|
import com.seibel.distanthorizons.api.DhApi;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBlockColorOverrideEvent;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBlockStateWrapperCreatedEvent;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiChunkProcessingEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiChunkProcessingEvent;
|
||||||
import com.seibel.distanthorizons.api.methods.events.DhApiEventRegister;
|
import com.seibel.distanthorizons.api.methods.events.DhApiEventRegister;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiLevelLoadEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiLevelLoadEvent;
|
||||||
@@ -16,7 +18,9 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||||
|
import com.seibel.distanthorizons.fabric.testing.TestBlockWrapperCreatedEvent;
|
||||||
import com.seibel.distanthorizons.fabric.testing.TestChunkInputReplacerEvent;
|
import com.seibel.distanthorizons.fabric.testing.TestChunkInputReplacerEvent;
|
||||||
|
import com.seibel.distanthorizons.fabric.testing.TestCustomColorEvent;
|
||||||
import com.seibel.distanthorizons.fabric.testing.TestWorldGenBindingEvent;
|
import com.seibel.distanthorizons.fabric.testing.TestWorldGenBindingEvent;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
@@ -88,12 +92,22 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
|
|||||||
/* Register the mod needed event callbacks */
|
/* Register the mod needed event callbacks */
|
||||||
|
|
||||||
// can be enabled to test overrides/events without having to build a separate API project
|
// can be enabled to test overrides/events without having to build a separate API project
|
||||||
|
{
|
||||||
|
// test custom world gen
|
||||||
if (false)
|
if (false)
|
||||||
{
|
{
|
||||||
DhApiEventRegister.on(DhApiLevelLoadEvent.class, new TestWorldGenBindingEvent());
|
DhApiEventRegister.on(DhApiLevelLoadEvent.class, new TestWorldGenBindingEvent());
|
||||||
DhApi.events.bind(DhApiChunkProcessingEvent.class, new TestChunkInputReplacerEvent());
|
DhApi.events.bind(DhApiChunkProcessingEvent.class, new TestChunkInputReplacerEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test custom colors
|
||||||
|
if (false)
|
||||||
|
{
|
||||||
|
DhApi.events.bind(DhApiBlockColorOverrideEvent.class, new TestCustomColorEvent());
|
||||||
|
DhApi.events.bind(DhApiBlockStateWrapperCreatedEvent.class, new TestBlockWrapperCreatedEvent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ServerWorldLoadEvent
|
// ServerWorldLoadEvent
|
||||||
ServerLifecycleEvents.SERVER_STARTING.register((server) ->
|
ServerLifecycleEvents.SERVER_STARTING.register((server) ->
|
||||||
|
|||||||
+1
-14
@@ -50,8 +50,8 @@ public class MixinChunkSectionsToRender
|
|||||||
//===========//
|
//===========//
|
||||||
// Pre MC 26 //
|
// Pre MC 26 //
|
||||||
//===========//
|
//===========//
|
||||||
//regino
|
|
||||||
#if MC_VER <= MC_1_21_11
|
#if MC_VER <= MC_1_21_11
|
||||||
|
//region
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_10
|
#if MC_VER <= MC_1_21_10
|
||||||
// needs to fire at HEAD with a lower than normal order (less than 1000)
|
// needs to fire at HEAD with a lower than normal order (less than 1000)
|
||||||
@@ -78,7 +78,6 @@ public class MixinChunkSectionsToRender
|
|||||||
ClientApi.INSTANCE.renderFadeTransparent();
|
ClientApi.INSTANCE.renderFadeTransparent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -105,22 +104,10 @@ public class MixinChunkSectionsToRender
|
|||||||
}
|
}
|
||||||
else if (chunkSectionLayerGroup == ChunkSectionLayerGroup.OPAQUE)
|
else if (chunkSectionLayerGroup == ChunkSectionLayerGroup.OPAQUE)
|
||||||
{
|
{
|
||||||
ClientApi.INSTANCE.renderFadeTransparent();
|
|
||||||
ClientApi.INSTANCE.renderLods();
|
ClientApi.INSTANCE.renderLods();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "renderGroup", order = 800)
|
|
||||||
private void renderDeferredLayerReturn(ChunkSectionLayerGroup chunkSectionLayerGroup, GpuSampler gpuSampler, CallbackInfo ci)
|
|
||||||
{
|
|
||||||
ClientApi.RENDER_STATE.canRenderOrThrow();
|
|
||||||
|
|
||||||
if (chunkSectionLayerGroup == ChunkSectionLayerGroup.TRANSLUCENT)
|
|
||||||
{
|
|
||||||
ClientApi.INSTANCE.renderFadeOpaque();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+5
-59
@@ -19,19 +19,13 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.fabric.mixins.client;
|
package com.seibel.distanthorizons.fabric.mixins.client;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.common.commonMixins.MixinVanillaFogCommon;
|
||||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
|
||||||
import net.minecraft.client.Camera;
|
import net.minecraft.client.Camera;
|
||||||
import net.minecraft.world.effect.MobEffects;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
|
|
||||||
#if MC_VER < MC_1_17_1
|
#if MC_VER < MC_1_17_1
|
||||||
import net.minecraft.world.level.material.FluidState;
|
import net.minecraft.world.level.material.FluidState;
|
||||||
@@ -42,7 +36,6 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
#elif MC_VER < MC_1_21_3
|
#elif MC_VER < MC_1_21_3
|
||||||
import net.minecraft.world.level.material.FogType;
|
|
||||||
import net.minecraft.client.renderer.FogRenderer;
|
import net.minecraft.client.renderer.FogRenderer;
|
||||||
import net.minecraft.client.renderer.FogRenderer.FogMode;
|
import net.minecraft.client.renderer.FogRenderer.FogMode;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
@@ -96,11 +89,11 @@ public class MixinFogRenderer
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_21_6
|
#if MC_VER < MC_1_21_6
|
||||||
boolean cancelFog = cancelFog(camera, fogMode);
|
boolean cancelFog = MixinVanillaFogCommon.cancelFog(camera, fogMode);
|
||||||
#elif MC_VER < MC_1_21_6
|
#elif MC_VER < MC_1_21_6
|
||||||
boolean cancelFog = cancelFog(camera);
|
boolean cancelFog = MixinVanillaFogCommon.cancelFog(camera);
|
||||||
#else
|
#else
|
||||||
boolean cancelFog = cancelFog();
|
boolean cancelFog = MixinVanillaFogCommon.cancelFog();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (cancelFog)
|
if (cancelFog)
|
||||||
@@ -142,7 +135,7 @@ public class MixinFogRenderer
|
|||||||
)
|
)
|
||||||
private void onSetRenderDistanceEnd(FogData instance, float value, Operation<Void> original)
|
private void onSetRenderDistanceEnd(FogData instance, float value, Operation<Void> original)
|
||||||
{
|
{
|
||||||
if (cancelFog())
|
if (MixinVanillaFogCommon.cancelFog())
|
||||||
{
|
{
|
||||||
instance.environmentalStart = A_REALLY_REALLY_BIG_VALUE;
|
instance.environmentalStart = A_REALLY_REALLY_BIG_VALUE;
|
||||||
instance.environmentalEnd = A_EVEN_LARGER_VALUE;
|
instance.environmentalEnd = A_EVEN_LARGER_VALUE;
|
||||||
@@ -164,52 +157,5 @@ public class MixinFogRenderer
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@Unique
|
|
||||||
#if MC_VER < MC_1_21_6
|
|
||||||
private static boolean cancelFog(Camera camera, FogMode fogMode)
|
|
||||||
#else
|
|
||||||
private static boolean cancelFog()
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#if MC_VER < MC_1_21_6
|
|
||||||
Entity entity = camera.getEntity();
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
|
||||||
Entity entity = camera.getEntity();
|
|
||||||
#else
|
|
||||||
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
|
||||||
Entity entity = camera.entity();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
boolean cameraNotInFluid = cameraNotInFluid(camera);
|
|
||||||
boolean isSpecialFog = (entity instanceof LivingEntity) && ((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS);
|
|
||||||
|
|
||||||
boolean cancelFog = !isSpecialFog;
|
|
||||||
cancelFog = cancelFog && cameraNotInFluid;
|
|
||||||
#if MC_VER < MC_1_21_6
|
|
||||||
cancelFog = cancelFog && (fogMode == FogMode.FOG_TERRAIN);
|
|
||||||
#endif
|
|
||||||
cancelFog = cancelFog && !SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class).isFogStateSpecial();
|
|
||||||
cancelFog = cancelFog && !Config.Client.Advanced.Graphics.Fog.enableVanillaFog.get();
|
|
||||||
|
|
||||||
return cancelFog;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Unique
|
|
||||||
private static boolean cameraNotInFluid(Camera camera)
|
|
||||||
{
|
|
||||||
#if MC_VER < MC_1_17_1
|
|
||||||
FluidState fluidState = camera.getFluidInCamera();
|
|
||||||
boolean cameraNotInFluid = fluidState.isEmpty();
|
|
||||||
#else
|
|
||||||
FogType fogTypes = camera.getFluidInCamera();
|
|
||||||
boolean cameraNotInFluid = fogTypes == FogType.NONE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return cameraNotInFluid;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+77
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Distant Horizons mod
|
||||||
|
* licensed under the GNU LGPL v3 License.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 James Seibel
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.seibel.distanthorizons.fabric.mixins.client;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(Entity.class)
|
||||||
|
public class MixinGameRenderer {}
|
||||||
|
|
||||||
|
#else
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||||
|
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||||
|
import net.minecraft.client.DeltaTracker;
|
||||||
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
|
import net.minecraft.client.renderer.state.OptionsRenderState;
|
||||||
|
import net.minecraft.client.renderer.state.level.CameraRenderState;
|
||||||
|
import net.minecraft.util.profiling.ProfilerFiller;
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
import org.joml.Matrix4fc;
|
||||||
|
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 org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||||
|
|
||||||
|
@Mixin(GameRenderer.class)
|
||||||
|
public class MixinGameRenderer
|
||||||
|
{
|
||||||
|
// get the modified projection matrix right before it's uploaded to the GPU
|
||||||
|
@Inject(
|
||||||
|
method = "renderLevel",
|
||||||
|
at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lcom/mojang/blaze3d/systems/RenderSystem;setProjectionMatrix(Lcom/mojang/blaze3d/buffers/GpuBufferSlice;Lcom/mojang/blaze3d/ProjectionType;)V",
|
||||||
|
shift = At.Shift.BEFORE
|
||||||
|
),
|
||||||
|
locals = LocalCapture.CAPTURE_FAILHARD
|
||||||
|
)
|
||||||
|
private void renderLevel(
|
||||||
|
final DeltaTracker deltaTracker,
|
||||||
|
final CallbackInfo callback,
|
||||||
|
final float partialTickTime,
|
||||||
|
final float cameraEntityPartialTicks,
|
||||||
|
final LocalPlayer player,
|
||||||
|
final ProfilerFiller profiler,
|
||||||
|
final boolean renderBlockOutline,
|
||||||
|
final OptionsRenderState options,
|
||||||
|
final CameraRenderState camera,
|
||||||
|
final Matrix4fc modelViewMatrix,
|
||||||
|
final Matrix4f projectionMatrix,
|
||||||
|
final PoseStack poseStack)
|
||||||
|
{
|
||||||
|
ClientApi.RENDER_STATE.mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
+3
-24
@@ -50,9 +50,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
||||||
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
|
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
import net.minecraft.client.Camera;
|
||||||
import net.minecraft.client.DeltaTracker;
|
import net.minecraft.client.DeltaTracker;
|
||||||
import net.minecraft.client.renderer.chunk.ChunkSectionsToRender;
|
import net.minecraft.client.renderer.chunk.ChunkSectionsToRender;
|
||||||
|
import org.joml.Matrix4f;
|
||||||
import org.joml.Matrix4fc;
|
import org.joml.Matrix4fc;
|
||||||
import org.joml.Vector4f;
|
import org.joml.Vector4f;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
@@ -60,7 +61,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||||||
#else
|
#else
|
||||||
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
||||||
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
|
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
|
||||||
import net.minecraft.client.DeltaTracker;
|
import net.minecraft.client.DeltaTracker;
|
||||||
import net.minecraft.client.renderer.chunk.ChunkSectionsToRender;
|
import net.minecraft.client.renderer.chunk.ChunkSectionsToRender;
|
||||||
import org.joml.Matrix4fc;
|
import org.joml.Matrix4fc;
|
||||||
@@ -71,6 +71,7 @@ import net.minecraft.client.renderer.state.level.CameraRenderState;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||||
@@ -235,33 +236,11 @@ public class MixinLevelRenderer
|
|||||||
CallbackInfo callback)
|
CallbackInfo callback)
|
||||||
{
|
{
|
||||||
ClientApi.RENDER_STATE.mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrix);
|
ClientApi.RENDER_STATE.mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrix);
|
||||||
ClientApi.RENDER_STATE.mcProjectionMatrix = McObjectConverter.Convert(camera.projectionMatrix);
|
|
||||||
|
|
||||||
ClientApi.RENDER_STATE.partialTickTime = MinecraftRenderWrapper.INSTANCE.getPartialTickTime();
|
ClientApi.RENDER_STATE.partialTickTime = MinecraftRenderWrapper.INSTANCE.getPartialTickTime();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
|
||||||
method = "addMainPass(Lcom/mojang/blaze3d/framegraph/FrameGraphBuilder;Lnet/minecraft/client/renderer/culling/Frustum;Lorg/joml/Matrix4fc;Lcom/mojang/blaze3d/buffers/GpuBufferSlice;ZLnet/minecraft/client/renderer/state/level/LevelRenderState;Lnet/minecraft/client/DeltaTracker;Lnet/minecraft/util/profiling/ProfilerFiller;Lnet/minecraft/client/renderer/chunk/ChunkSectionsToRender;)V",
|
|
||||||
at = @At(
|
|
||||||
value = "RETURN",
|
|
||||||
target = "Lcom/mojang/blaze3d/framegraph/FramePass;executes(Ljava/lang/Runnable;)V",
|
|
||||||
remap = false
|
|
||||||
)
|
|
||||||
)
|
|
||||||
public void addMainPass(
|
|
||||||
CallbackInfo ci)
|
|
||||||
{
|
|
||||||
// only crash during development
|
|
||||||
if (ModInfo.IS_DEV_BUILD)
|
|
||||||
{
|
|
||||||
ClientApi.RENDER_STATE.canRenderOrThrow();
|
|
||||||
}
|
|
||||||
|
|
||||||
ClientApi.INSTANCE.renderLods();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|||||||
+39
-1
@@ -1,5 +1,16 @@
|
|||||||
package com.seibel.distanthorizons.fabric.mixins.client;
|
package com.seibel.distanthorizons.fabric.mixins.client;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_10
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(Entity.class)
|
||||||
|
public class MixinSharedConstants
|
||||||
|
{ /* not present in older MC versions */ }
|
||||||
|
#else
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
import net.minecraft.SharedConstants;
|
import net.minecraft.SharedConstants;
|
||||||
import org.spongepowered.asm.mixin.*;
|
import org.spongepowered.asm.mixin.*;
|
||||||
@@ -16,8 +27,35 @@ public abstract class MixinSharedConstants
|
|||||||
@Inject(method = "<clinit>", at = @At("TAIL"))
|
@Inject(method = "<clinit>", at = @At("TAIL"))
|
||||||
private static void setIsRunningInIde(CallbackInfo ci)
|
private static void setIsRunningInIde(CallbackInfo ci)
|
||||||
{
|
{
|
||||||
// run extra validation for dev builds
|
DhLogger logger = new DhLoggerBuilder().name("SharedConstants").build();
|
||||||
|
|
||||||
|
// setting IS_RUNNING_IN_IDE to true enables
|
||||||
|
// additional validation on Mojang's side which
|
||||||
|
// helps catch errors when developing for Blaze3D
|
||||||
|
|
||||||
|
boolean irisPresent;
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
IS_RUNNING_IN_IDE = ModInfo.IS_DEV_BUILD;
|
IS_RUNNING_IN_IDE = ModInfo.IS_DEV_BUILD;
|
||||||
|
#else
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Iris has a bug for MC 26 and newer where it doesn't have
|
||||||
|
// a "sampler1" bound, causing a renderer crash if
|
||||||
|
// Blaze3D validation is enabled (which is enabled by if
|
||||||
|
// IS_RUNNING_IN_IDE is true)
|
||||||
|
ModInfo.class.getClassLoader().loadClass("net.irisshaders.iris.api.v0.IrisApi");
|
||||||
|
irisPresent = true;
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException ignore)
|
||||||
|
{
|
||||||
|
irisPresent = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
IS_RUNNING_IN_IDE = ModInfo.IS_DEV_BUILD && !irisPresent;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
logger.info("Setting Minecraft's SharedConstants.IS_RUNNING_IN_IDE to ["+IS_RUNNING_IN_IDE+"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
package com.seibel.distanthorizons.fabric.testing;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBlockStateWrapperCreatedEvent;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TestCustomColorEvent
|
||||||
|
*/
|
||||||
|
public class TestBlockWrapperCreatedEvent extends DhApiBlockStateWrapperCreatedEvent
|
||||||
|
{
|
||||||
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void blockStateWrapperCreated(DhApiEventParam<EventParam> event)
|
||||||
|
{
|
||||||
|
EventParam eventParam = event.value;
|
||||||
|
|
||||||
|
// can be enabled to flip the opacity of transparent/opaque blocks
|
||||||
|
if (false)
|
||||||
|
{
|
||||||
|
if (eventParam.getBlockStateWrapper().getOpacity() == LodUtil.BLOCK_FULLY_OPAQUE)
|
||||||
|
{
|
||||||
|
eventParam.setOpacity(LodUtil.BLOCK_FULLY_TRANSPARENT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eventParam.setOpacity(LodUtil.BLOCK_FULLY_OPAQUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// needed for TestCustomColorEvent
|
||||||
|
eventParam.setAllowApiColorOverride(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+86
@@ -0,0 +1,86 @@
|
|||||||
|
package com.seibel.distanthorizons.fabric.testing;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBlockColorOverrideEvent;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||||
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TestBlockWrapperCreatedEvent
|
||||||
|
*/
|
||||||
|
public class TestCustomColorEvent extends DhApiBlockColorOverrideEvent
|
||||||
|
{
|
||||||
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void blockStateWrapperCreated(DhApiEventParam<EventParam> event)
|
||||||
|
{
|
||||||
|
EventParam eventParam = event.value;
|
||||||
|
|
||||||
|
//randomDatapointColors(eventParam);
|
||||||
|
//randomPerBlockColors(eventParam);
|
||||||
|
//blackWhitePositionStripe(eventParam);
|
||||||
|
positionRainbow(eventParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** each datapoint has a random color */
|
||||||
|
private void randomDatapointColors(EventParam eventParam)
|
||||||
|
{
|
||||||
|
// random colors for each datapoint
|
||||||
|
int a = eventParam.getAlpha();
|
||||||
|
int r = eventParam.getRed();
|
||||||
|
int g = eventParam.getGreen();
|
||||||
|
int b = eventParam.getBlue();
|
||||||
|
|
||||||
|
if (eventParam.getBlockStateWrapper().getOpacity() == LodUtil.BLOCK_FULLY_OPAQUE)
|
||||||
|
{
|
||||||
|
eventParam.setColor(255,r,g,b);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eventParam.setColor(60,r,g,b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** each block has a different color */
|
||||||
|
private void randomPerBlockColors(EventParam eventParam)
|
||||||
|
{
|
||||||
|
// random colors per block
|
||||||
|
int r = Math.abs(eventParam.getBlockStateWrapper().hashCode() % 255);
|
||||||
|
int g = Math.abs((eventParam.getBlockStateWrapper().hashCode() << 4) % 255);
|
||||||
|
int b = Math.abs((eventParam.getBlockStateWrapper().hashCode() << 8) % 255);
|
||||||
|
eventParam.setColor(r,g,b);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void blackWhitePositionStripe(EventParam eventParam)
|
||||||
|
{
|
||||||
|
// black-white stripes
|
||||||
|
int r = Math.abs(eventParam.getBlockPosX() % 255);
|
||||||
|
int g = r;
|
||||||
|
int b = r;
|
||||||
|
eventParam.setColor(r,g,b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** rainbow along the X axis repeating every 255 blocks */
|
||||||
|
private void positionRainbow(EventParam eventParam)
|
||||||
|
{
|
||||||
|
float[] ahsv = ColorUtil.argbToAhsv(ColorUtil.RED);
|
||||||
|
float a = ahsv[0];
|
||||||
|
|
||||||
|
int xModPos = Math.abs(eventParam.getBlockPosX() % 510);
|
||||||
|
float h = xModPos < 255 ? xModPos : 510 - xModPos;
|
||||||
|
float s = ahsv[2];
|
||||||
|
float v = ahsv[3];
|
||||||
|
int colorInt = ColorUtil.ahsvToArgb(a,h,s,v);
|
||||||
|
eventParam.setColor(ColorUtil.getRed(colorInt),ColorUtil.getGreen(colorInt),ColorUtil.getBlue(colorInt));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
"client.MixinClientPacketListener",
|
"client.MixinClientPacketListener",
|
||||||
"client.MixinDebugScreenOverlay",
|
"client.MixinDebugScreenOverlay",
|
||||||
"client.MixinFogRenderer",
|
"client.MixinFogRenderer",
|
||||||
|
"client.MixinGameRenderer",
|
||||||
"client.MixinLevelRenderer",
|
"client.MixinLevelRenderer",
|
||||||
"client.MixinChunkSectionsToRender",
|
"client.MixinChunkSectionsToRender",
|
||||||
"client.MixinLightTexture",
|
"client.MixinLightTexture",
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
"icon": "assets/distanthorizons/icon.png",
|
"icon": "assets/distanthorizons/icon.png",
|
||||||
|
|
||||||
"accessWidener": "distanthorizons.accesswidener",
|
"accessWidener": "${accessWidenerVersion}.distanthorizons.accesswidener",
|
||||||
|
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
|
|||||||
+4
-1
@@ -22,6 +22,9 @@ dependencies {
|
|||||||
// TerraFirmaCraft
|
// TerraFirmaCraft
|
||||||
addMod("curse.maven:TerraFirmaCraft-302973:4616004", rootProject.enable_terrafirmacraft)
|
addMod("curse.maven:TerraFirmaCraft-302973:4616004", rootProject.enable_terrafirmacraft)
|
||||||
|
|
||||||
|
// Oculus (Iris port)
|
||||||
|
addMod("maven.modrinth:oculus:${rootProject.oculus_version}", rootProject.enable_oculus)
|
||||||
|
|
||||||
// TODO: Check if this is still needed and if so ensure this code works for MC 26.1+
|
// TODO: Check if this is still needed and if so ensure this code works for MC 26.1+
|
||||||
// (potential) hack fix for MC 1.20.6 and later, force jopt-simple to be exactly 5.0.4 because Mojang ships that version, but some transitive dependencies request 6.0+
|
// (potential) hack fix for MC 1.20.6 and later, force jopt-simple to be exactly 5.0.4 because Mojang ships that version, but some transitive dependencies request 6.0+
|
||||||
def mcParts = rootProject.minecraft_version.split("\\.")
|
def mcParts = rootProject.minecraft_version.split("\\.")
|
||||||
@@ -39,7 +42,7 @@ task deleteResources(type: Delete) {
|
|||||||
|
|
||||||
tasks.register('copyAllResources') {
|
tasks.register('copyAllResources') {
|
||||||
dependsOn(copyCoreResources)
|
dependsOn(copyCoreResources)
|
||||||
dependsOn(copyCommonLoaderResources)
|
// dependsOn(copyCommonLoaderResources)
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
|||||||
+12
-25
@@ -19,10 +19,8 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.forge.mixins.client;
|
package com.seibel.distanthorizons.forge.mixins.client;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.common.commonMixins.MixinVanillaFogCommon;
|
||||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -33,14 +31,6 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||||||
import net.minecraft.client.Camera;
|
import net.minecraft.client.Camera;
|
||||||
import net.minecraft.client.renderer.FogRenderer;
|
import net.minecraft.client.renderer.FogRenderer;
|
||||||
import net.minecraft.client.renderer.FogRenderer.FogMode;
|
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 MC_VER < MC_1_17_1
|
|
||||||
import net.minecraft.world.level.material.FluidState;
|
|
||||||
#else
|
|
||||||
import net.minecraft.world.level.material.FogType;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@Mixin(FogRenderer.class)
|
@Mixin(FogRenderer.class)
|
||||||
public class MixinFogRenderer
|
public class MixinFogRenderer
|
||||||
@@ -55,29 +45,25 @@ public class MixinFogRenderer
|
|||||||
remap = #if MC_VER == MC_1_17_1 || MC_VER == MC_1_18_2 false #else true #endif ) // Remap messiness due to this being weird in forge
|
remap = #if MC_VER == MC_1_17_1 || MC_VER == MC_1_18_2 false #else true #endif ) // Remap messiness due to this being weird in forge
|
||||||
private static void disableSetupFog(Camera camera, FogMode fogMode, float f, boolean bl, float partTick, CallbackInfo callback)
|
private static void disableSetupFog(Camera camera, FogMode fogMode, float f, boolean bl, float partTick, CallbackInfo callback)
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_17_1
|
#if MC_VER < MC_1_21_6
|
||||||
FluidState fluidState = camera.getFluidInCamera();
|
boolean cancelFog = MixinVanillaFogCommon.cancelFog(camera, fogMode);
|
||||||
boolean cameraNotInFluid = fluidState.isEmpty();
|
#elif MC_VER < MC_1_21_6
|
||||||
|
boolean cancelFog = MixinVanillaFogCommon.cancelFog(camera);
|
||||||
#else
|
#else
|
||||||
FogType fogTypes = camera.getFluidInCamera();
|
boolean cancelFog = MixinVanillaFogCommon.cancelFog();
|
||||||
boolean cameraNotInFluid = fogTypes == FogType.NONE;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (cancelFog)
|
||||||
Entity entity = camera.getEntity();
|
|
||||||
boolean isSpecialFog = (entity instanceof LivingEntity) && ((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS);
|
|
||||||
if (!isSpecialFog
|
|
||||||
&& cameraNotInFluid
|
|
||||||
&& fogMode == FogMode.FOG_TERRAIN
|
|
||||||
&& !SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class).isFogStateSpecial()
|
|
||||||
&& !Config.Client.Advanced.Graphics.Fog.enableVanillaFog.get())
|
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_17_1
|
#if MC_VER < MC_1_17_1
|
||||||
RenderSystem.fogStart(A_REALLY_REALLY_BIG_VALUE);
|
RenderSystem.fogStart(A_REALLY_REALLY_BIG_VALUE);
|
||||||
RenderSystem.fogEnd(A_EVEN_LARGER_VALUE);
|
RenderSystem.fogEnd(A_EVEN_LARGER_VALUE);
|
||||||
#else
|
#elif MC_VER < MC_1_21_3
|
||||||
RenderSystem.setShaderFogStart(A_REALLY_REALLY_BIG_VALUE);
|
RenderSystem.setShaderFogStart(A_REALLY_REALLY_BIG_VALUE);
|
||||||
RenderSystem.setShaderFogEnd(A_EVEN_LARGER_VALUE);
|
RenderSystem.setShaderFogEnd(A_EVEN_LARGER_VALUE);
|
||||||
|
#elif MC_VER < MC_1_21_6
|
||||||
|
callback.setReturnValue(FogParameters.NO_FOG);
|
||||||
|
#else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ClientApi.RENDER_STATE.vanillaFogEnabled = false;
|
ClientApi.RENDER_STATE.vanillaFogEnabled = false;
|
||||||
@@ -86,6 +72,7 @@ public class MixinFogRenderer
|
|||||||
{
|
{
|
||||||
ClientApi.RENDER_STATE.vanillaFogEnabled = true;
|
ClientApi.RENDER_STATE.vanillaFogEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-7
@@ -23,35 +23,50 @@ import com.seibel.distanthorizons.core.logging.DhLogger;
|
|||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IIrisAccessor;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IIrisAccessor;
|
||||||
|
|
||||||
|
#if MC_VER == MC_1_20_1
|
||||||
|
import net.irisshaders.iris.Iris;
|
||||||
|
import net.irisshaders.iris.api.v0.IrisApi;
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
|
||||||
public class OculusAccessor implements IIrisAccessor
|
public class OculusAccessor implements IIrisAccessor
|
||||||
{
|
{
|
||||||
protected static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
protected static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
|
|
||||||
public OculusAccessor()
|
public OculusAccessor()
|
||||||
{
|
{ LOGGER.warn("Partial Oculus support enabled. Some DH features may be disabled or behave strangely, use Iris instead if possible."); }
|
||||||
LOGGER.warn("Partial Oculus support enabled. Some DH features may be disabled or behave strangely, use Iris instead if possible.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModName()
|
public String getModName()
|
||||||
{
|
{
|
||||||
return "oculus";
|
#if MC_VER == MC_1_20_1
|
||||||
|
return Iris.MODID;
|
||||||
|
#else
|
||||||
|
return "iris"; // Oculus doesn't support this MC version
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isShaderPackInUse()
|
public boolean isShaderPackInUse()
|
||||||
{
|
{
|
||||||
// assume shaders are always active
|
#if MC_VER == MC_1_20_1
|
||||||
return true;
|
return IrisApi.getInstance().isShaderPackInUse();
|
||||||
|
#else
|
||||||
|
return true; // Oculus doesn't support this MC version
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRenderingShadowPass()
|
public boolean isRenderingShadowPass()
|
||||||
{
|
{
|
||||||
return false;
|
#if MC_VER == MC_1_20_1
|
||||||
|
return IrisApi.getInstance().isRenderingShadowPass();
|
||||||
|
#else
|
||||||
|
return false; // Oculus doesn't support this MC version
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
{
|
{
|
||||||
"pack": {
|
"pack": {
|
||||||
"pack_format": 7,
|
"pack_format": 64,
|
||||||
"supported_formats": {
|
"supported_formats": {
|
||||||
"min_inclusive": 16,
|
"min_inclusive": 64,
|
||||||
"max_inclusive": 90000
|
"max_inclusive": 90000
|
||||||
},
|
},
|
||||||
"description": "Distant Horizons"
|
"description": "Distant Horizons",
|
||||||
|
"min_format": 64,
|
||||||
|
"max_format": 90000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-6
@@ -5,16 +5,17 @@ org.gradle.caching=true
|
|||||||
|
|
||||||
# Mod Info
|
# Mod Info
|
||||||
mod_name=DistantHorizons
|
mod_name=DistantHorizons
|
||||||
mod_version=3.0.0-b-dev
|
api_name=DistantHorizonsApi
|
||||||
api_version=6.0.0
|
mod_version=3.0.3-b
|
||||||
|
api_version=6.1.1
|
||||||
maven_group=com.seibel.distanthorizons
|
maven_group=com.seibel.distanthorizons
|
||||||
mod_readable_name=Distant Horizons
|
mod_readable_name=Distant Horizons
|
||||||
mod_description=This mod generates and renders simplified terrain beyond the normal view distance at a low performance cost. Allowing you to see much farther without turning your game into a slideshow.
|
mod_description=This mod generates and renders simplified terrain beyond the normal view distance at a low performance cost. Allowing you to see much farther without turning your game into a slideshow.
|
||||||
# Note: In forge's mods.toml this is hard coded because Architectury throws an error with setting it as a variable
|
# Note: In forge's mods.toml this is hard coded because Architectury throws an error with setting it as a variable
|
||||||
mod_authors=["James Seibel", "Leonardo Amato", "Cola", "coolGi", "Ran", "Leetom", "pshsh"]
|
mod_authors=["James Seibel", "Leonardo Amato", "Cola", "coolGi", "Ran", "Leetom", "pshsh"]
|
||||||
mod_homepage=https://modrinth.com/mod/distanthorizons
|
mod_homepage=https://modrinth.com/mod/distanthorizons
|
||||||
mod_source=https://gitlab.com/jeseibel/distant-horizons
|
mod_source=https://gitlab.com/distant-horizons-team/distant-horizons/
|
||||||
mod_issues=https://gitlab.com/jeseibel/distant-horizons/-/issues
|
mod_issues=https://gitlab.com/distant-horizons-team/distant-horizons/-/issues
|
||||||
mod_discord=https://discord.gg/xAB8G4cENx
|
mod_discord=https://discord.gg/xAB8G4cENx
|
||||||
|
|
||||||
# Global Plugin Versions
|
# Global Plugin Versions
|
||||||
@@ -46,7 +47,10 @@ versionStr=
|
|||||||
|
|
||||||
# This defines what MC version Intellij will use for the preprocessor
|
# This defines what MC version Intellij will use for the preprocessor
|
||||||
# and what version is used automatically by build and run commands
|
# and what version is used automatically by build and run commands
|
||||||
mcVer=1.26.1
|
mcVer=26.1.2
|
||||||
|
|
||||||
# Defines the maximum amount of memory Minecraft is allowed when run in a development environment
|
# Defines the maximum amount of memory Minecraft is allowed when run in a development environment
|
||||||
#minecraftMemoryJavaArg="-Xmx4G"
|
minecraftMemoryJavaArg=-Xmx6G
|
||||||
|
# can be enabled for use with the Tracy profiler, disabled by default since it causes constant memory growth when running
|
||||||
|
minecraftEnableTracy=false
|
||||||
|
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ task deleteResources(type: Delete) {
|
|||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
dependsOn(copyCoreResources)
|
dependsOn(copyCoreResources)
|
||||||
dependsOn(copyCommonLoaderResources)
|
// dependsOn(copyCommonLoaderResources)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named('runClient') {
|
tasks.named('runClient') {
|
||||||
dependsOn(copyCoreResources)
|
dependsOn(copyCoreResources)
|
||||||
dependsOn(copyCommonLoaderResources)
|
// dependsOn(copyCommonLoaderResources)
|
||||||
finalizedBy(deleteResources)
|
finalizedBy(deleteResources)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -228,8 +228,10 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
{
|
{
|
||||||
#if MC_VER < MC_1_21_9
|
#if MC_VER < MC_1_21_9
|
||||||
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, (ClientLevel)event.getLevel());
|
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, (ClientLevel)event.getLevel());
|
||||||
#else
|
#elif MC_VER <= MC_1_21_11
|
||||||
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, event.getLevelRenderer().level);
|
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, event.getLevelRenderer().level);
|
||||||
|
#else
|
||||||
|
// handled via the same mixin as fabric for consistency
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ClientApi.INSTANCE.renderFadeOpaque();
|
ClientApi.INSTANCE.renderFadeOpaque();
|
||||||
@@ -241,11 +243,11 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
{
|
{
|
||||||
#if MC_VER < MC_1_21_9
|
#if MC_VER < MC_1_21_9
|
||||||
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, (ClientLevel)event.getLevel());
|
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, (ClientLevel)event.getLevel());
|
||||||
#else
|
#elif MC_VER <= MC_1_21_11
|
||||||
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, event.getLevelRenderer().level);
|
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, event.getLevelRenderer().level);
|
||||||
|
#else
|
||||||
|
// handled via the same mixin as fabric for consistency
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ClientApi.INSTANCE.renderDeferredLodsForShaders();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@@ -253,8 +255,10 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
{
|
{
|
||||||
#if MC_VER < MC_1_21_9
|
#if MC_VER < MC_1_21_9
|
||||||
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, (ClientLevel)event.getLevel());
|
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, (ClientLevel)event.getLevel());
|
||||||
#else
|
#elif MC_VER <= MC_1_21_11
|
||||||
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, event.getLevelRenderer().level);
|
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, event.getLevelRenderer().level);
|
||||||
|
#else
|
||||||
|
// handled via the same mixin as fabric for consistency
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+82
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Distant Horizons mod
|
||||||
|
* licensed under the GNU LGPL v3 License.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 James Seibel
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.seibel.distanthorizons.neoforge.mixins.client;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(Entity.class)
|
||||||
|
public class MixinChunkSectionsToRender
|
||||||
|
{ /* rendering before was handled via Fabric API events */ }
|
||||||
|
#else
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.textures.GpuSampler;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.chunk.ChunkSectionLayerGroup;
|
||||||
|
import net.minecraft.client.renderer.chunk.ChunkSectionsToRender;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(ChunkSectionsToRender.class)
|
||||||
|
public class MixinChunkSectionsToRender
|
||||||
|
{
|
||||||
|
|
||||||
|
//============//
|
||||||
|
// post MC 26 //
|
||||||
|
//============//
|
||||||
|
//region
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
#else
|
||||||
|
|
||||||
|
// needs to fire at HEAD with a lower than normal order (less than 1000)
|
||||||
|
// otherwise it will be canceled by Sodium
|
||||||
|
@Inject(at = @At("HEAD"), method = "renderGroup", order = 800)
|
||||||
|
private void renderDeferredLayerHead(ChunkSectionLayerGroup chunkSectionLayerGroup, GpuSampler gpuSampler, CallbackInfo ci)
|
||||||
|
{
|
||||||
|
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, Minecraft.getInstance().levelRenderer.level);
|
||||||
|
|
||||||
|
|
||||||
|
ClientApi.RENDER_STATE.canRenderOrThrow();
|
||||||
|
|
||||||
|
if (chunkSectionLayerGroup == ChunkSectionLayerGroup.TRANSLUCENT)
|
||||||
|
{
|
||||||
|
ClientApi.INSTANCE.renderDeferredLodsForShaders();
|
||||||
|
}
|
||||||
|
else if (chunkSectionLayerGroup == ChunkSectionLayerGroup.OPAQUE)
|
||||||
|
{
|
||||||
|
ClientApi.INSTANCE.renderLods();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
+5
-55
@@ -19,11 +19,8 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.neoforge.mixins.client;
|
package com.seibel.distanthorizons.neoforge.mixins.client;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.common.commonMixins.MixinVanillaFogCommon;
|
||||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@@ -96,11 +93,11 @@ public class MixinFogRenderer
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_21_6
|
#if MC_VER < MC_1_21_6
|
||||||
boolean cancelFog = cancelFog(camera, fogMode);
|
boolean cancelFog = MixinVanillaFogCommon.cancelFog(camera, fogMode);
|
||||||
#elif MC_VER < MC_1_21_6
|
#elif MC_VER < MC_1_21_6
|
||||||
boolean cancelFog = cancelFog(camera);
|
boolean cancelFog = MixinVanillaFogCommon.cancelFog(camera);
|
||||||
#else
|
#else
|
||||||
boolean cancelFog = cancelFog();
|
boolean cancelFog = MixinVanillaFogCommon.cancelFog();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (cancelFog)
|
if (cancelFog)
|
||||||
@@ -142,7 +139,7 @@ public class MixinFogRenderer
|
|||||||
)
|
)
|
||||||
private void onSetRenderDistanceEnd(FogData instance, float value, Operation<Void> original)
|
private void onSetRenderDistanceEnd(FogData instance, float value, Operation<Void> original)
|
||||||
{
|
{
|
||||||
if (cancelFog())
|
if (MixinVanillaFogCommon.cancelFog())
|
||||||
{
|
{
|
||||||
instance.environmentalStart = A_REALLY_REALLY_BIG_VALUE;
|
instance.environmentalStart = A_REALLY_REALLY_BIG_VALUE;
|
||||||
instance.environmentalEnd = A_EVEN_LARGER_VALUE;
|
instance.environmentalEnd = A_EVEN_LARGER_VALUE;
|
||||||
@@ -164,52 +161,5 @@ public class MixinFogRenderer
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@Unique
|
|
||||||
#if MC_VER < MC_1_21_6
|
|
||||||
private static boolean cancelFog(Camera camera, FogMode fogMode)
|
|
||||||
#else
|
|
||||||
private static boolean cancelFog()
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#if MC_VER < MC_1_21_6
|
|
||||||
Entity entity = camera.getEntity();
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
|
||||||
Entity entity = camera.getEntity();
|
|
||||||
#else
|
|
||||||
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
|
||||||
Entity entity = camera.entity();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
boolean cameraNotInFluid = cameraNotInFluid(camera);
|
|
||||||
boolean isSpecialFog = (entity instanceof LivingEntity) && ((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS);
|
|
||||||
|
|
||||||
boolean cancelFog = !isSpecialFog;
|
|
||||||
cancelFog = cancelFog && cameraNotInFluid;
|
|
||||||
#if MC_VER < MC_1_21_6
|
|
||||||
cancelFog = cancelFog && (fogMode == FogMode.FOG_TERRAIN);
|
|
||||||
#endif
|
|
||||||
cancelFog = cancelFog && !SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class).isFogStateSpecial();
|
|
||||||
cancelFog = cancelFog && !Config.Client.Advanced.Graphics.Fog.enableVanillaFog.get();
|
|
||||||
|
|
||||||
return cancelFog;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Unique
|
|
||||||
private static boolean cameraNotInFluid(Camera camera)
|
|
||||||
{
|
|
||||||
#if MC_VER < MC_1_17_1
|
|
||||||
FluidState fluidState = camera.getFluidInCamera();
|
|
||||||
boolean cameraNotInFluid = fluidState.isEmpty();
|
|
||||||
#else
|
|
||||||
FogType fogTypes = camera.getFluidInCamera();
|
|
||||||
boolean cameraNotInFluid = fogTypes == FogType.NONE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return cameraNotInFluid;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+77
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Distant Horizons mod
|
||||||
|
* licensed under the GNU LGPL v3 License.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 James Seibel
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.seibel.distanthorizons.neoforge.mixins.client;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(Entity.class)
|
||||||
|
public class MixinGameRenderer {}
|
||||||
|
|
||||||
|
#else
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||||
|
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||||
|
import net.minecraft.client.DeltaTracker;
|
||||||
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
|
import net.minecraft.client.renderer.state.OptionsRenderState;
|
||||||
|
import net.minecraft.client.renderer.state.level.CameraRenderState;
|
||||||
|
import net.minecraft.util.profiling.ProfilerFiller;
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
import org.joml.Matrix4fc;
|
||||||
|
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 org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||||
|
|
||||||
|
@Mixin(GameRenderer.class)
|
||||||
|
public class MixinGameRenderer
|
||||||
|
{
|
||||||
|
// get the modified projection matrix right before it's uploaded to the GPU
|
||||||
|
@Inject(
|
||||||
|
method = "renderLevel",
|
||||||
|
at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lcom/mojang/blaze3d/systems/RenderSystem;setProjectionMatrix(Lcom/mojang/blaze3d/buffers/GpuBufferSlice;Lcom/mojang/blaze3d/ProjectionType;)V",
|
||||||
|
shift = At.Shift.BEFORE
|
||||||
|
),
|
||||||
|
locals = LocalCapture.CAPTURE_FAILHARD
|
||||||
|
)
|
||||||
|
private void renderLevel(
|
||||||
|
final DeltaTracker deltaTracker,
|
||||||
|
final CallbackInfo callback,
|
||||||
|
final float partialTickTime,
|
||||||
|
final float cameraEntityPartialTicks,
|
||||||
|
final LocalPlayer player,
|
||||||
|
final ProfilerFiller profiler,
|
||||||
|
final boolean renderBlockOutline,
|
||||||
|
final OptionsRenderState options,
|
||||||
|
final CameraRenderState camera,
|
||||||
|
final Matrix4fc modelViewMatrix,
|
||||||
|
final Matrix4f projectionMatrix,
|
||||||
|
final PoseStack poseStack)
|
||||||
|
{
|
||||||
|
ClientApi.RENDER_STATE.mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
+20
-30
@@ -26,7 +26,7 @@ import net.minecraft.client.renderer.LevelRenderer;
|
|||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
|
import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
#else
|
#elif MC_VER <= MC_1_21_11
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.chunk.ChunkSectionsToRender;
|
import net.minecraft.client.renderer.chunk.ChunkSectionsToRender;
|
||||||
@@ -35,6 +35,25 @@ import net.minecraft.client.DeltaTracker;
|
|||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.client.renderer.LevelRenderer;
|
import net.minecraft.client.renderer.LevelRenderer;
|
||||||
|
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
import org.joml.Matrix4fc;
|
||||||
|
import org.joml.Vector4f;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
||||||
|
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
#else
|
||||||
|
import com.mojang.blaze3d.textures.GpuSampler;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.chunk.ChunkSectionLayerGroup;
|
||||||
|
import net.minecraft.client.renderer.chunk.ChunkSectionsToRender;
|
||||||
|
import net.minecraft.client.Camera;
|
||||||
|
import net.minecraft.client.DeltaTracker;
|
||||||
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
|
import net.minecraft.client.renderer.LevelRenderer;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.state.level.CameraRenderState;
|
import net.minecraft.client.renderer.state.level.CameraRenderState;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.joml.Matrix4fc;
|
import org.joml.Matrix4fc;
|
||||||
@@ -201,40 +220,11 @@ public class MixinLevelRenderer
|
|||||||
CallbackInfo callback)
|
CallbackInfo callback)
|
||||||
{
|
{
|
||||||
ClientApi.RENDER_STATE.mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrix);
|
ClientApi.RENDER_STATE.mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrix);
|
||||||
ClientApi.RENDER_STATE.mcProjectionMatrix = McObjectConverter.Convert(camera.projectionMatrix);
|
|
||||||
|
|
||||||
ClientApi.RENDER_STATE.partialTickTime = MinecraftRenderWrapper.INSTANCE.getPartialTickTime();
|
ClientApi.RENDER_STATE.partialTickTime = MinecraftRenderWrapper.INSTANCE.getPartialTickTime();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
|
||||||
method = "addMainPass(Lcom/mojang/blaze3d/framegraph/FrameGraphBuilder;Lnet/minecraft/client/renderer/culling/Frustum;Lorg/joml/Matrix4fc;Lcom/mojang/blaze3d/buffers/GpuBufferSlice;ZLnet/minecraft/client/renderer/state/level/LevelRenderState;Lnet/minecraft/client/DeltaTracker;Lnet/minecraft/util/profiling/ProfilerFiller;Lnet/minecraft/client/renderer/chunk/ChunkSectionsToRender;)V",
|
|
||||||
at = @At(
|
|
||||||
value = "RETURN",
|
|
||||||
target = "Lcom/mojang/blaze3d/framegraph/FramePass;executes(Ljava/lang/Runnable;)V",
|
|
||||||
remap = false
|
|
||||||
)
|
|
||||||
)
|
|
||||||
public void addMainPass(
|
|
||||||
CallbackInfo ci)
|
|
||||||
{
|
|
||||||
// only crash during development
|
|
||||||
if (ModInfo.IS_DEV_BUILD)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ClientApi.RENDER_STATE.canRenderOrThrow();
|
|
||||||
}
|
|
||||||
catch (IllegalStateException e)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ClientApi.INSTANCE.renderLods();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
"client.MixinClientPacketListener",
|
"client.MixinClientPacketListener",
|
||||||
"client.MixinDebugScreenOverlay",
|
"client.MixinDebugScreenOverlay",
|
||||||
"client.MixinFogRenderer",
|
"client.MixinFogRenderer",
|
||||||
|
"client.MixinChunkSectionsToRender",
|
||||||
|
"client.MixinGameRenderer",
|
||||||
"client.MixinLevelRenderer",
|
"client.MixinLevelRenderer",
|
||||||
"client.MixinLightTexture",
|
"client.MixinLightTexture",
|
||||||
"client.MixinMinecraft",
|
"client.MixinMinecraft",
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ forge_version=36.2.39
|
|||||||
|
|
||||||
# Forge mod versions
|
# Forge mod versions
|
||||||
terraforged_version=4044290
|
terraforged_version=4044290
|
||||||
|
oculus_version=
|
||||||
|
|
||||||
# Forge mod run
|
# Forge mod run
|
||||||
# 0 = Don't enable and don't run
|
# 0 = Don't enable and don't run
|
||||||
@@ -62,3 +63,4 @@ forge_version=36.2.39
|
|||||||
enable_starlight_forge=0
|
enable_starlight_forge=0
|
||||||
enable_terraforged=1
|
enable_terraforged=1
|
||||||
enable_terrafirmacraft=0
|
enable_terrafirmacraft=0
|
||||||
|
enable_oculus=0
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ forge_version=37.1.1
|
|||||||
|
|
||||||
# Forge mod versions
|
# Forge mod versions
|
||||||
terraforged_version=
|
terraforged_version=
|
||||||
|
oculus_version=
|
||||||
|
|
||||||
# Forge mod run
|
# Forge mod run
|
||||||
# 0 = Don't enable and don't run
|
# 0 = Don't enable and don't run
|
||||||
@@ -61,3 +62,4 @@ forge_version=37.1.1
|
|||||||
enable_starlight_forge=0
|
enable_starlight_forge=0
|
||||||
enable_terraforged=0
|
enable_terraforged=0
|
||||||
enable_terrafirmacraft=0
|
enable_terrafirmacraft=0
|
||||||
|
enable_oculus=0
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ forge_version=40.2.10
|
|||||||
|
|
||||||
# Forge mod versions
|
# Forge mod versions
|
||||||
terraforged_version=
|
terraforged_version=
|
||||||
|
oculus_version=
|
||||||
|
|
||||||
# Forge mod run
|
# Forge mod run
|
||||||
# 0 = Don't enable and don't run
|
# 0 = Don't enable and don't run
|
||||||
@@ -70,3 +71,4 @@ forge_version=40.2.10
|
|||||||
enable_starlight_forge=0
|
enable_starlight_forge=0
|
||||||
enable_terraforged=0
|
enable_terraforged=0
|
||||||
enable_terrafirmacraft=0
|
enable_terrafirmacraft=0
|
||||||
|
enable_oculus=0
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ forge_version=43.3.2
|
|||||||
|
|
||||||
# Forge mod versions
|
# Forge mod versions
|
||||||
terraforged_version=
|
terraforged_version=
|
||||||
|
oculus_version=
|
||||||
|
|
||||||
# Forge mod run
|
# Forge mod run
|
||||||
# 0 = Don't enable and don't run
|
# 0 = Don't enable and don't run
|
||||||
@@ -60,3 +61,4 @@ forge_version=43.3.2
|
|||||||
enable_starlight_forge=0
|
enable_starlight_forge=0
|
||||||
enable_terraforged=0
|
enable_terraforged=0
|
||||||
enable_terrafirmacraft=0
|
enable_terrafirmacraft=0
|
||||||
|
enable_oculus=0
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ forge_version=45.2.4
|
|||||||
|
|
||||||
# Forge mod versions
|
# Forge mod versions
|
||||||
terraforged_version=
|
terraforged_version=
|
||||||
|
oculus_version=
|
||||||
|
|
||||||
# Forge mod run
|
# Forge mod run
|
||||||
# 0 = Don't enable and don't run
|
# 0 = Don't enable and don't run
|
||||||
@@ -59,3 +60,4 @@ forge_version=45.2.4
|
|||||||
enable_starlight_forge=0
|
enable_starlight_forge=0
|
||||||
enable_terraforged=0
|
enable_terraforged=0
|
||||||
enable_terrafirmacraft=0
|
enable_terrafirmacraft=0
|
||||||
|
enable_oculus=0
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ forge_version=47.2.1
|
|||||||
|
|
||||||
# Forge mod versions
|
# Forge mod versions
|
||||||
terraforged_version=
|
terraforged_version=
|
||||||
|
oculus_version=1.20.1-1.8.0
|
||||||
|
|
||||||
# Forge mod run
|
# Forge mod run
|
||||||
# 0 = Don't enable and don't run
|
# 0 = Don't enable and don't run
|
||||||
@@ -59,3 +60,4 @@ forge_version=47.2.1
|
|||||||
enable_starlight_forge=0
|
enable_starlight_forge=0
|
||||||
enable_terraforged=0
|
enable_terraforged=0
|
||||||
enable_terrafirmacraft=0
|
enable_terrafirmacraft=0
|
||||||
|
enable_oculus=1
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ forge_version=48.0.13
|
|||||||
|
|
||||||
# Forge mod versions
|
# Forge mod versions
|
||||||
terraforged_version=
|
terraforged_version=
|
||||||
|
oculus_version=
|
||||||
|
|
||||||
# Forge mod run
|
# Forge mod run
|
||||||
# 0 = Don't enable and don't run
|
# 0 = Don't enable and don't run
|
||||||
@@ -59,3 +60,4 @@ forge_version=48.0.13
|
|||||||
enable_starlight_forge=0
|
enable_starlight_forge=0
|
||||||
enable_terraforged=0
|
enable_terraforged=0
|
||||||
enable_terrafirmacraft=0
|
enable_terrafirmacraft=0
|
||||||
|
enable_oculus=0
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ neoforge_version=
|
|||||||
|
|
||||||
# Forge mod versions
|
# Forge mod versions
|
||||||
terraforged_version=
|
terraforged_version=
|
||||||
|
oculus_version=
|
||||||
|
|
||||||
# Forge mod run
|
# Forge mod run
|
||||||
# 0 = Don't enable and don't run
|
# 0 = Don't enable and don't run
|
||||||
@@ -60,3 +61,4 @@ neoforge_version=
|
|||||||
enable_starlight_forge=0
|
enable_starlight_forge=0
|
||||||
enable_terraforged=0
|
enable_terraforged=0
|
||||||
enable_terrafirmacraft=0
|
enable_terrafirmacraft=0
|
||||||
|
enable_oculus=0
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ lwjgl_version=3.3.3
|
|||||||
|
|
||||||
# Fabric loader
|
# Fabric loader
|
||||||
fabric_loader_version=0.16.9
|
fabric_loader_version=0.16.9
|
||||||
fabric_api_version=0.115.0+1.21.1
|
fabric_api_version=0.116.11+1.21.1
|
||||||
# Fabric mod versions
|
# Fabric mod versions
|
||||||
modmenu_version=11.0.0-beta.1
|
modmenu_version=11.0.0-beta.1
|
||||||
starlight_version_fabric=
|
starlight_version_fabric=
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ minecraft_version=1.21.3
|
|||||||
parchment_version=1.21:2024.07.28
|
parchment_version=1.21:2024.07.28
|
||||||
compatible_minecraft_versions=["1.21.3"]
|
compatible_minecraft_versions=["1.21.3"]
|
||||||
accessWidenerVersion=1_21_3
|
accessWidenerVersion=1_21_3
|
||||||
builds_for=neoforge,fabric
|
builds_for=fabric,neoforge
|
||||||
# forge is broken due to gradle/build script issues
|
# forge is broken due to gradle/build script issues
|
||||||
|
|
||||||
# Netty
|
# Netty
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ minecraft_version=1.21.4
|
|||||||
parchment_version=1.21:2024.07.28
|
parchment_version=1.21:2024.07.28
|
||||||
compatible_minecraft_versions=["1.21.4"]
|
compatible_minecraft_versions=["1.21.4"]
|
||||||
accessWidenerVersion=1_21_4
|
accessWidenerVersion=1_21_4
|
||||||
builds_for=neoforge,fabric
|
builds_for=fabric,neoforge
|
||||||
# forge is broken due to gradle/build script issues
|
# forge is broken due to gradle/build script issues
|
||||||
|
|
||||||
# Netty
|
# Netty
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
# 1.26.1 version
|
# 26.1.2 version
|
||||||
java_version=25
|
java_version=25
|
||||||
minecraft_version=26.1
|
minecraft_version=26.1.2
|
||||||
parchment_version=1.21:2024.07.28
|
parchment_version=1.21:2024.07.28
|
||||||
compatible_minecraft_versions=["26.1"]
|
# version range should be used instead of individual versions due to how NeoForge handles version loading
|
||||||
accessWidenerVersion=1_26_1
|
compatible_minecraft_versions=["26.1.0", "26.1.2"]
|
||||||
|
accessWidenerVersion=26_1
|
||||||
builds_for=fabric,neoforge
|
builds_for=fabric,neoforge
|
||||||
# forge is broken due to gradle/build script issues
|
# forge is broken due to gradle/build script issues
|
||||||
|
|
||||||
@@ -11,17 +12,17 @@ builds_for=fabric,neoforge
|
|||||||
netty_version=4.1.97.Final
|
netty_version=4.1.97.Final
|
||||||
|
|
||||||
# LWJGL
|
# LWJGL
|
||||||
lwjgl_version=3.3.3
|
lwjgl_version=3.4.1
|
||||||
|
|
||||||
# Fabric loader
|
# Fabric loader
|
||||||
fabric_loader_version=0.18.5
|
fabric_loader_version=0.18.5
|
||||||
fabric_api_version=0.144.3+26.1
|
fabric_api_version=0.145.4+26.1.2
|
||||||
modmenu_version=18.0.0-alpha.8
|
modmenu_version=18.0.0-alpha.8
|
||||||
starlight_version_fabric=
|
starlight_version_fabric=
|
||||||
phosphor_version_fabric=
|
phosphor_version_fabric=
|
||||||
lithium_version=
|
lithium_version=
|
||||||
sodium_version=mc1.21.11-0.8.7-fabric
|
sodium_version=mc26.1.1-0.8.9-fabric
|
||||||
iris_version=1.10.7+26.1-fabric
|
iris_version=1.10.9+26.1-fabric
|
||||||
bclib_version=
|
bclib_version=
|
||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=
|
canvas_version=
|
||||||
@@ -45,7 +46,7 @@ enable_canvas=0
|
|||||||
|
|
||||||
# NeoForge loader
|
# NeoForge loader
|
||||||
forge_version=
|
forge_version=
|
||||||
neoforge_version=1-beta
|
neoforge_version=15-beta
|
||||||
neoforge_version_range=[*,)
|
neoforge_version_range=[*,)
|
||||||
|
|
||||||
# NeoForge mod versions
|
# NeoForge mod versions
|
||||||
Reference in New Issue
Block a user