Compare commits
155 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 077e25d7a8 | |||
| ef84fe97d5 | |||
| fc3653e577 | |||
| d708867c74 | |||
| e6273fa6a4 | |||
| d517279ca2 | |||
| 71284c3e98 | |||
| 85c7dbaf99 | |||
| 7cc21a2b8e | |||
| 2c8d8e2b2e | |||
| d366da4947 | |||
| 02490440ec | |||
| 019ec0e55d | |||
| c8ef38da3c | |||
| b449072a69 | |||
| 35fde21098 | |||
| 10bad0bc84 | |||
| 27492ba093 | |||
| ed6576df4b | |||
| 1c89f9e88a | |||
| 9cdd7fc687 | |||
| 3a5485ea56 | |||
| 955d1df400 | |||
| d39000fa56 | |||
| 231e98efb8 | |||
| 87299de2ab | |||
| 33c9b48bc9 | |||
| 416208c33a | |||
| 7bba8d2862 | |||
| 8b22349d0f | |||
| cd156630a8 | |||
| 769d5739b8 | |||
| 6d29f58ebd | |||
| 2d8027cd28 | |||
| be9547612d | |||
| 67f8ff841d | |||
| 51a7ccc8d0 | |||
| 3fdaa42206 | |||
| 70c783194f | |||
| aec1d2bbe8 | |||
| cabcbef34b | |||
| d952e5400b | |||
| eba908c153 | |||
| 65feda4e04 | |||
| 81e636b1c6 | |||
| 4c4861b2e3 | |||
| 28972421ad | |||
| 3619acbd54 | |||
| c539f1eeef | |||
| 23cf213200 | |||
| a371c6b364 | |||
| d1e58ccf28 | |||
| 0062a28504 | |||
| 9d00a1eb67 | |||
| 7e75640263 | |||
| 32f1cfa634 | |||
| aed5f54710 | |||
| 267fa4acfa | |||
| a4f731da16 | |||
| 8ee9c42848 | |||
| a43335466c | |||
| 1a0b86d056 | |||
| d96cc5c74b | |||
| 54faa2cbdc | |||
| e7e25cb5b7 | |||
| b4afb2f495 | |||
| 2a5e67a461 | |||
| a71dd0b3b8 | |||
| b2d9c2eec6 | |||
| 518262c515 | |||
| 1de5983260 | |||
| 3c5b1eb423 | |||
| 4d195a6378 | |||
| cdbfad060b | |||
| e9eeba944a | |||
| 3c111cd8d6 | |||
| 68c5362024 | |||
| 40ea294663 | |||
| 1b2afcd02c | |||
| 6c5eb09486 | |||
| 221d011b48 | |||
| ad36204dfb | |||
| 70f8599a0e | |||
| 211ec7f3a6 | |||
| 43a75df119 | |||
| 679c6791c7 | |||
| 033616db7a | |||
| 1a09edd8bb | |||
| 0ff7a5cd11 | |||
| 4e0574af35 | |||
| 027dbf35f8 | |||
| a9dc1e232a | |||
| f50cfab3f7 | |||
| 981d9a095d | |||
| d1670673f2 | |||
| 82fa375afc | |||
| 95d0765ccb | |||
| 8f9524a319 | |||
| a680aa97d2 | |||
| 7ca0092501 | |||
| 4d7321941c | |||
| 8d1c5e4b5b | |||
| 1ebcd49601 | |||
| 9ac7753f04 | |||
| 7ca81fe281 | |||
| 1b5762a133 | |||
| e373969b34 | |||
| f16472c415 | |||
| 72169f271f | |||
| b1149bda39 | |||
| 8f838891cb | |||
| e4518cafeb | |||
| 6022161e0c | |||
| dd8b695cdf | |||
| e896be7324 | |||
| 06298418cb | |||
| fdcbbae3b1 | |||
| a719ec5a3e | |||
| 55bf0c04f4 | |||
| 666293f59d | |||
| 4442fda70a | |||
| cf976cef84 | |||
| e2dcbf48af | |||
| 79ba86d8c2 | |||
| 8de6ca33af | |||
| 89faf6e976 | |||
| bc5861ea95 | |||
| cc3a3c451c | |||
| f0956c0cdb | |||
| dcc143c9f8 | |||
| 56603e8076 | |||
| 06922458f1 | |||
| 17b7a6eb89 | |||
| 52b222de50 | |||
| 35d45057ba | |||
| 6a5ba1a607 | |||
| c01c77e11d | |||
| 27a01d4da3 | |||
| 76f3a3cfcb | |||
| 52005d0b19 | |||
| af6f477f15 | |||
| bf2ffd6dfb | |||
| dd6380d49d | |||
| d59fc82cc7 | |||
| 2f62dd2c49 | |||
| 379f8911b5 | |||
| 1a72c30684 | |||
| 6891bdc34e | |||
| c6a7e52a86 | |||
| 951ef5ed72 | |||
| 20f8e59f2b | |||
| 23b35282a9 | |||
| ec8e54d31b | |||
| d538b5c12b | |||
| 4fe24abc51 |
@@ -28,6 +28,3 @@ Merged/
|
||||
|
||||
# file genearated via MC version switching using preprocessor
|
||||
build.properties
|
||||
|
||||
# This accesswidener is generated at runtime ant not needed
|
||||
common/src/main/resources/lod.accesswidener
|
||||
|
||||
+186
-131
@@ -2,45 +2,125 @@
|
||||
image: gradle:eclipse-temurin
|
||||
# The ci should always use an unix/unix-like OS to work
|
||||
|
||||
|
||||
# all stages need to be defined here
|
||||
# Don't build the standalone jar yet because it isn't done yet
|
||||
# - build_standalone
|
||||
stages:
|
||||
- build_19
|
||||
- build_18_2
|
||||
- build_18_1
|
||||
- build_17_1
|
||||
- build_16_5
|
||||
# TODO: Make stages depending on what is in versionProperties
|
||||
- build_1_18_2
|
||||
|
||||
variables:
|
||||
# Pull core when building
|
||||
GIT_SUBMODULE_STRATEGY: recursive
|
||||
|
||||
|
||||
before_script:
|
||||
- echo $CI_JOB_ID
|
||||
# Writing GE_JOB_ID variable to environment file, will need the value in the next stage.
|
||||
- echo GE_JOB_ID=$CI_JOB_ID >> generate_jars.env
|
||||
# 1.18.2 build
|
||||
build_1_18_2:
|
||||
stage: build_1_18_2
|
||||
script:
|
||||
# this both runs the unit tests and assembles the code
|
||||
- ./gradlew build -PmcVer="1.18.2" --gradle-user-home cache/;
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "NightlyBuild_1_18_2-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- fabric/build/libs/*.jar
|
||||
- forge/build/libs/*.jar
|
||||
- quilt/build/libs/*.jar
|
||||
exclude:
|
||||
# TODO: There is a lot of duplicate stuff here, fix it later
|
||||
- fabric/build/libs/*-all.jar
|
||||
- fabric/build/libs/*-sources.jar
|
||||
- forge/build/libs/*-all.jar
|
||||
- forge/build/libs/*-sources.jar
|
||||
- quilt/build/libs/*-all.jar
|
||||
- quilt/build/libs/*-sources.jar
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
|
||||
# The standalone build
|
||||
#build_standalone:
|
||||
# stage: build_standalone
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# ============================== Previos CI for future reference ============================== #
|
||||
## all stages need to be defined here
|
||||
# # Don't build the standalone jar yet because it isn't done yet
|
||||
# # - build_standalone
|
||||
#stages:
|
||||
# - build_19
|
||||
# - build_18_2
|
||||
# - build_18_1
|
||||
# - build_17_1
|
||||
# - build_16_5
|
||||
#
|
||||
#variables:
|
||||
# # Pull core when building
|
||||
# GIT_SUBMODULE_STRATEGY: recursive
|
||||
#
|
||||
#
|
||||
#before_script:
|
||||
# - echo $CI_JOB_ID
|
||||
# # Writing GE_JOB_ID variable to environment file, will need the value in the next stage.
|
||||
# - echo GE_JOB_ID=$CI_JOB_ID >> generate_jars.env
|
||||
#
|
||||
#
|
||||
## The standalone build
|
||||
##build_standalone:
|
||||
## stage: build_standalone
|
||||
## script:
|
||||
## # make sure any previously merged jars are removed before running this job.
|
||||
## # note: if the merged folder doesn't exist "rm -R Merged" will throw an error, which can be ignored
|
||||
## # the "|| true" makes that step always succeed.
|
||||
## - ./gradlew core:build --gradle-user-home cache/;
|
||||
##
|
||||
## # Copy the file with the shortest name to the root DistantHorizons.jar so it can be sent off
|
||||
## - cp $(find core/build/libs/ | awk 'function base(f){sub(".*/", "", f); return f;} {print length(base($0)), $0}'| sort -n | head -2 | grep -P "[0-9][0-9] core/build/libs/*" | #sed -r "s/([0-9][0-9] )//g") DistantHorizons.jar
|
||||
## # build using Java 16
|
||||
## image: eclipse-temurin:16
|
||||
## artifacts:
|
||||
## name: "NightlyBuild_standalone-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
## paths:
|
||||
## # Get the standalone jar
|
||||
## - DistantHorizons.jar
|
||||
## expire_in: 1 day
|
||||
## # even if one build fails, upload the successful jars
|
||||
## when: always
|
||||
## cache:
|
||||
## key: "gradleCache"
|
||||
## policy: pull-push
|
||||
## paths:
|
||||
## - .gradle
|
||||
## - cache/
|
||||
## allow_failure: true
|
||||
#
|
||||
#
|
||||
## 1.16.5 build
|
||||
#build_16_5:
|
||||
# stage: build_16_5
|
||||
# script:
|
||||
# # make sure any previously merged jars are removed before running this job.
|
||||
# # note: if the merged folder doesn't exist "rm -R Merged" will throw an error, which can be ignored
|
||||
# # the "|| true" makes that step always succeed.
|
||||
# - ./gradlew core:build --gradle-user-home cache/;
|
||||
#
|
||||
# # Copy the file with the shortest name to the root DistantHorizons.jar so it can be sent off
|
||||
# - cp $(find core/build/libs/ | awk 'function base(f){sub(".*/", "", f); return f;} {print length(base($0)), $0}'| sort -n | head -2 | grep -P "[0-9][0-9] core/build/libs/*" | #sed -r "s/([0-9][0-9] )//g") DistantHorizons.jar
|
||||
# - ./gradlew test --gradle-user-home cache/;
|
||||
# - ./gradlew build -PmcVer="1.16.5" --gradle-user-home cache/;
|
||||
# # build using Java 16
|
||||
# image: eclipse-temurin:16
|
||||
# artifacts:
|
||||
# name: "NightlyBuild_standalone-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
# name: "Merged_NightlyBuild_1_16_5-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
# paths:
|
||||
# # Get the standalone jar
|
||||
# - DistantHorizons.jar
|
||||
# # relative to the root directory
|
||||
# - Merged
|
||||
# expire_in: 1 day
|
||||
# # even if one build fails, upload the successful jars
|
||||
# when: always
|
||||
@@ -51,119 +131,94 @@ before_script:
|
||||
# - .gradle
|
||||
# - cache/
|
||||
# allow_failure: true
|
||||
#
|
||||
## 1.17.1 build
|
||||
#build_17_1:
|
||||
# stage: build_17_1
|
||||
# script:
|
||||
# - ./gradlew test --gradle-user-home cache/;
|
||||
# - ./gradlew build -PmcVer="1.17.1" --gradle-user-home cache/;
|
||||
# image: eclipse-temurin:16
|
||||
# artifacts:
|
||||
# name: "Merged_NightlyBuild_1_17_1-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
# paths:
|
||||
# - Merged
|
||||
# expire_in: 1 day
|
||||
# when: always
|
||||
# cache:
|
||||
# key: "gradleCache"
|
||||
# policy: pull-push
|
||||
# paths:
|
||||
# - .gradle
|
||||
# - cache/
|
||||
# allow_failure: true
|
||||
#
|
||||
## 1.18.1 build
|
||||
#build_18_1:
|
||||
# stage: build_18_1
|
||||
# script:
|
||||
# - ./gradlew test --gradle-user-home cache/;
|
||||
# - ./gradlew build -PmcVer="1.18.1" --gradle-user-home cache/;
|
||||
# # build using Java 17
|
||||
# image: eclipse-temurin:17
|
||||
# artifacts:
|
||||
# name: "Merged_NightlyBuild_1_18_1-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
# paths:
|
||||
# - Merged
|
||||
# expire_in: 1 day
|
||||
# when: always
|
||||
# cache:
|
||||
# key: "gradleCache"
|
||||
# policy: pull-push
|
||||
# paths:
|
||||
# - .gradle
|
||||
# - cache/
|
||||
# allow_failure: true
|
||||
#
|
||||
## 1.18.2 build
|
||||
#build_18_2:
|
||||
# stage: build_18_2
|
||||
# script:
|
||||
# - ./gradlew test --gradle-user-home cache/;
|
||||
# - ./gradlew build -PmcVer="1.18.2" --gradle-user-home cache/;
|
||||
# image: eclipse-temurin:17
|
||||
# artifacts:
|
||||
# name: "Merged_NightlyBuild_1_18_2-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
# paths:
|
||||
# - Merged
|
||||
# expire_in: 1 day
|
||||
# when: always
|
||||
# cache:
|
||||
# key: "gradleCache"
|
||||
# policy: pull-push
|
||||
# paths:
|
||||
# - .gradle
|
||||
# - cache/
|
||||
# allow_failure: true
|
||||
#
|
||||
## 1.19 build
|
||||
#build_19:
|
||||
# stage: build_19
|
||||
# script:
|
||||
# - ./gradlew test --gradle-user-home cache/;
|
||||
# - ./gradlew build -PmcVer="1.19" --gradle-user-home cache/;
|
||||
# image: eclipse-temurin:17
|
||||
# artifacts:
|
||||
# name: "Merged_NightlyBuild_1_19-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
# paths:
|
||||
# - Merged
|
||||
# expire_in: 1 day
|
||||
# when: always
|
||||
# cache:
|
||||
# key: "gradleCache"
|
||||
# policy: pull-push
|
||||
# paths:
|
||||
# - .gradle
|
||||
# - cache/
|
||||
# allow_failure: true
|
||||
|
||||
|
||||
# 1.16.5 build
|
||||
build_16_5:
|
||||
stage: build_16_5
|
||||
script:
|
||||
# make sure any previously merged jars are removed before running this job.
|
||||
# note: if the merged folder doesn't exist "rm -R Merged" will throw an error, which can be ignored
|
||||
# the "|| true" makes that step always succeed.
|
||||
- ./gradlew test --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer="1.16.5" --gradle-user-home cache/;
|
||||
# build using Java 16
|
||||
image: eclipse-temurin:16
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_16_5-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
# relative to the root directory
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
# even if one build fails, upload the successful jars
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
# 1.17.1 build
|
||||
build_17_1:
|
||||
stage: build_17_1
|
||||
script:
|
||||
- ./gradlew test --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer="1.17.1" --gradle-user-home cache/;
|
||||
image: eclipse-temurin:16
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_17_1-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
# 1.18.1 build
|
||||
build_18_1:
|
||||
stage: build_18_1
|
||||
script:
|
||||
- ./gradlew test --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer="1.18.1" --gradle-user-home cache/;
|
||||
# build using Java 17
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_18_1-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
# 1.18.2 build
|
||||
build_18_2:
|
||||
stage: build_18_2
|
||||
script:
|
||||
- ./gradlew test --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer="1.18.2" --gradle-user-home cache/;
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_18_2-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
# 1.19 build
|
||||
build_19:
|
||||
stage: build_19
|
||||
script:
|
||||
- ./gradlew test --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer="1.19" --gradle-user-home cache/;
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_19-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
|
||||
# unused deployment stage
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
## Chcek off each item in this list before submitting:
|
||||
|
||||
<!--
|
||||
To mark a section as complete either put an "x" in between the square brackets, example: "[x]"
|
||||
Or click the checkbox once the issue has been created.
|
||||
-->
|
||||
|
||||
1. [ ] Check the FAQ to see if your issue has already been reported and has a solution:
|
||||
[Problems-and-solutions](https://gitlab.com/jeseibel/minecraft-lod-mod/-/wikis/2-frequently-asked-questions/2-problems-and-solutions/Problems-and-Solutions)
|
||||
|
||||
2. [ ] Make sure you are not using any mods on the incompatible list:
|
||||
[Mod support FAQ](https://gitlab.com/jeseibel/minecraft-lod-mod/-/wikis/2-frequently-asked-questions/4-mod-support/Mod-Support)
|
||||
|
||||
3. [ ] Check the existing issues to verify that your bug hasn't already been submitted:
|
||||
[Issues](https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/)
|
||||
|
||||
4. [ ] Upload Minecraft's crash report and/or log. \
|
||||
Minecraft crash reports are located in: `.minecraft/crash-reports` \
|
||||
Minecraft logs are located in: `.minecraft/logs`
|
||||
|
||||
5. [ ] Upload your Distant Horizons Config. \
|
||||
The config is found in: `.minecraft/configs/DistantHorizons.toml`
|
||||
|
||||
6. [ ] Fill out the information below:
|
||||
|
||||
* **minecraft version**:
|
||||
|
||||
* **Distant Horizons version**:
|
||||
|
||||
* **Mod loader**:
|
||||
|
||||
* **Installed mods (list the smallest number of mods that you can use to re-create the bug)**:
|
||||
|
||||
* **Describe the bug**:
|
||||
|
||||
* **Steps to reproduce the bug**:
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
Before creating an issue, please select the appropriate template from the dropdown above.
|
||||
|
||||
The template will walk you through submitting a bug, feature, or improvement request.
|
||||
@@ -0,0 +1,5 @@
|
||||
- [ ] Check the existing [feature requests](https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/?sort=updated_desc&state=opened&label_name%5B%5D=Feature) to verify that your feature hasn't already been suggested.
|
||||
|
||||
1. **Describe the feature**:
|
||||
|
||||
2. **Describe why this feature should be added**:
|
||||
@@ -0,0 +1,3 @@
|
||||
1. Check the existing [improvement requests](https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/?sort=updated_desc&state=all&label_name%5B%5D=Improvement) to verify that your improvement hasn't already been suggested.
|
||||
|
||||
2. **Describe the improvement**:
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
# What is Distant Horizons?
|
||||
|
||||
This mod adds a Level Of Detail (LOD) system to Minecraft.\
|
||||
This implementation renders simplified chunks outside the normal render distance\
|
||||
Distant Horizons is a Minecraft mod that adds a Level Of Detail (LOD) system to\
|
||||
render simplified chunks outside the normal render distance\
|
||||
allowing for an increased view distance without harming performance.
|
||||
|
||||
In other words: this mod lets you see farther without turning your game into a slide show.\
|
||||
@@ -16,50 +16,50 @@ If you want to see a quick demo, check out a video covering the mod here:
|
||||
|
||||
<br>
|
||||
|
||||
## Mod and Library Versions
|
||||
## Minecraft and Library Versions
|
||||
|
||||
This branch supports the following versions of Minecraft:
|
||||
|
||||
#### 1.19 (WIP)
|
||||
Supported MC versions: [1.19]\
|
||||
Forge version: 41.0.19\
|
||||
Fabric version: 0.14.7\
|
||||
Fabric API version: 0.55.3+1.19\
|
||||
Modmenu version: 4.0.0
|
||||
> **NOTE: At the moment only 1.18.2 fabric works/build/runs**
|
||||
|
||||
#### 1.18.2
|
||||
Supported MC versions: [1.18.2]\
|
||||
Forge version: 40.0.18\
|
||||
Fabric version: 0.13.3\
|
||||
Fabric API version: 0.48.0+1.18.2\
|
||||
Modmenu version: 3.1.0
|
||||
#### 1.19 (BROKE)
|
||||
Forge: 41.0.19\
|
||||
Fabric: 0.14.7\
|
||||
Fabric API: 0.55.3+1.19\
|
||||
Modmenu: 4.0.0
|
||||
|
||||
#### 1.18.1
|
||||
Supported MC versions: [1.18.1, 1.18]\
|
||||
Forge version: 39.1.2\
|
||||
Fabric version: 0.13.3\
|
||||
Fabric API version: 0.42.6+1.18\
|
||||
Modmenu version: 3.0.1
|
||||
#### 1.18.2 (ONLY FABRIC WORKS)
|
||||
Fabric: 0.14.14\
|
||||
Fabric API: 0.67.1+1.18.2\
|
||||
Forge: 40.0.32\
|
||||
Parchment=2022.11.06\
|
||||
Modmenu: 3.2.5
|
||||
|
||||
#### 1.17.1
|
||||
Supported MC versions: [1.17.1, 1.17]\
|
||||
Forge version: 37.1.1\
|
||||
Fabric version: 0.13.2\
|
||||
Fabric API version: 0.46.1+1.17\
|
||||
Modmenu version: 2.0.14
|
||||
#### 1.18.1, 1.18 (CEASING DEVELOPMENT SOON)
|
||||
Forge: 39.1.2\
|
||||
Fabric: 0.13.3\
|
||||
Fabric API: 0.42.6+1.18\
|
||||
Modmenu: 3.0.1
|
||||
|
||||
#### 1.16.5
|
||||
Supported MC versions: [1.16.5, 1.16.4]\
|
||||
Forge version: 36.2.28\
|
||||
Fabric vetsion: 0.13.2\
|
||||
Fabric API version: 0.42.0+1.16\
|
||||
Modmenu version: 1.16.22
|
||||
#### 1.17.1, 1.17 (BROKE)
|
||||
Forge: 37.1.1\
|
||||
Fabric: 0.13.2\
|
||||
Fabric API: 0.46.1+1.17\
|
||||
Modmenu: 2.0.14
|
||||
|
||||
#### 1.16.5, 1.16.5 (BROKE)
|
||||
Forge: 36.2.28\
|
||||
Fabric: 0.13.2\
|
||||
Fabric API: 0.42.0+1.16\
|
||||
Modmenu: 1.16.22
|
||||
<br><br>
|
||||
|
||||
#### Plugin and Library versions
|
||||
### Plugin and Library versions
|
||||
|
||||
Architectury version: 3.4-SNAPSHOT\
|
||||
Architectury loom version: 0.12.0-SNAPSHOT\
|
||||
Fabric loom: 1.1-snapshot\
|
||||
Forge gradle: 5.1.67\
|
||||
Sponge vanilla gradle: 0.2.1-SNAPSHOT\
|
||||
Sponge mixin gradle: 0.7-SNAPSHOT\
|
||||
Java Compiler plugin: Manifold Preprocessor
|
||||
|
||||
<br>
|
||||
@@ -85,31 +85,42 @@ Java Compiler plugin: Manifold Preprocessor
|
||||
3. Make sure eclipse has the JDK 17 installed. (This is needed so that eclipse can run minecraft)
|
||||
4. Import the project into eclipse
|
||||
|
||||
|
||||
|
||||
## Switching Versions
|
||||
|
||||
To switch between active versions, change `mcVer=1.?` in `gradle.properties` file.
|
||||
To switch between different Minecraft versions, change `mcVer=1.?` in the `gradle.properties` file.
|
||||
|
||||
If running in an IDE, to ensure the IDE noticed the version change, run a gradle command to prompt gradle into updating the libs. (In IntellJ you will also need to do a gradle sync if it didn't happen automatically.)
|
||||
>Note: There may be a `java.nio.file.FileSystemException` thrown when running the command after switching versions. To fix it, either restart your IDE (as your IDE is locking up a file) or use a tool like LockHunter to unlock the linked file(s). (Generally it is a lib file under `common\build\lib`, `forge\build\lib`, or `fabric\build\lib`). If anyone knows how to solve this issue please write a comment on this issue: https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/233
|
||||
If running in an IDE, to ensure the IDE noticed the version change, run any gradle command to refresh gradle. (In IntellJ you will also need to do a gradle sync if it didn't happen automatically.)
|
||||
>Note: There may be a `java.nio.file.FileSystemException` thrown when running the command after switching versions. To fix it, either restart your IDE (as your IDE is probably locking a file) or use a tool like LockHunter to unlock the linked file(s). (Generally it is a lib file under `common\build\lib`, `forge\build\lib`, or `fabric\build\lib`). \
|
||||
> If anyone knows how to solve this issue please let us know here: \
|
||||
> https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/233
|
||||
|
||||
<br>
|
||||
|
||||
## Compiling
|
||||
|
||||
**From the File Explorer:**
|
||||
1. Download and extract the zip of the project
|
||||
2. Download the core from https://gitlab.com/jeseibel/distant-horizons-core and extract into a folder called `core`
|
||||
Prerequisites:
|
||||
- JDK 17 or newer
|
||||
|
||||
From the File Explorer:
|
||||
1. Download and extract the project zip
|
||||
2. Download the core from https://gitlab.com/jeseibel/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`
|
||||
6. The compiled jar file will be in the folder `Merged`
|
||||
5. The compiled jar file will be in the folder `Merged`
|
||||
|
||||
**If in terminal:**
|
||||
From the command line:
|
||||
1. `git clone --recurse-submodules https://gitlab.com/jeseibel/minecraft-lod-mod.git`
|
||||
2. `cd minecraft-lod-mod`
|
||||
3. `./gradlew assemble`
|
||||
4. The compiled jar file will be in the folder `Merged`
|
||||
|
||||
>Note: You can add the arg: `-PmcVer=1.?` to tell gradle to build a selected MC version instead of having to manually modify the `gradle.properties` file.
|
||||
Run tests with: `./gradlew test`
|
||||
|
||||
>Note: You can add the arg: `-PmcVer=?` to tell gradle to build a selected MC version instead of having to modify the `gradle.properties` file. \
|
||||
> Example: `./gradlew assemble -PmcVer=1.18.2`
|
||||
|
||||
|
||||
<Br>
|
||||
|
||||
@@ -117,7 +128,7 @@ If running in an IDE, to ensure the IDE noticed the version change, run a gradle
|
||||
|
||||
`./gradlew --refresh-dependencies` to refresh local dependencies.
|
||||
|
||||
`./gradlew clean` to reset everything (this does not affect your code) and then start the process again.
|
||||
`./gradlew clean` to delete any compiled code.
|
||||
|
||||
|
||||
## Note to self
|
||||
@@ -132,7 +143,7 @@ If your IDE fails to auto-detect the source jars when browsing Minecraft classes
|
||||
|
||||
<br>
|
||||
|
||||
## Useful commands
|
||||
## Other Useful commands
|
||||
|
||||
Run the standalone jar: `./gradlew run`\
|
||||
Build the standalone jar: `./gradlew core:build`\
|
||||
@@ -147,17 +158,17 @@ To build all versions: `./buildAll` (all builds will end up in the `Merged` fold
|
||||
|
||||
## Open Source Acknowledgements
|
||||
|
||||
XZ for Java (data compression)\
|
||||
https://tukaani.org/xz/java.html
|
||||
|
||||
Forgix (To merge multiple mod versions into one jar) [_Used to be_ [_DHJarMerger_](https://github.com/Ran-helo/DHJarMerger)]\
|
||||
https://github.com/PacifistMC/Forgix
|
||||
|
||||
XZ for Java (data compression)\
|
||||
https://tukaani.org/xz/java.html
|
||||
|
||||
Json & Toml for Java (config handling)\
|
||||
https://github.com/TheElectronWill/night-config
|
||||
|
||||
SVG Salamander for SVG's\
|
||||
SVG Salamander for SVG support\
|
||||
https://github.com/blackears/svgSalamander
|
||||
|
||||
FlatLaf for theming (Tempory to test stuff)\
|
||||
FlatLaf for theming (for development testing, may remove later)\
|
||||
https://www.formdev.com/flatlaf/
|
||||
|
||||
+322
-232
@@ -1,16 +1,17 @@
|
||||
plugins {
|
||||
// Plugin to help in developing multi-loader mods
|
||||
id "architectury-plugin" version "3.4-SNAPSHOT"
|
||||
id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false
|
||||
id "java"
|
||||
|
||||
// Plugin to handle dependencies
|
||||
id 'com.github.johnrengelman.shadow' version '7.0.0' apply false
|
||||
id "com.github.johnrengelman.shadow" version '7.1.2' apply false
|
||||
|
||||
// Plugin to create merged jars
|
||||
id "io.github.pacifistmc.forgix" version "1.2.6"
|
||||
|
||||
// Manifold preprocessor
|
||||
id "systems.manifold.manifold-gradle-plugin" version "0.0.2-alpha"
|
||||
|
||||
// Provides mc libraries to core
|
||||
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' apply false
|
||||
// id "org.spongepowered.gradle.vanilla" version '0.2.1-SNAPSHOT' apply false
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -20,25 +21,27 @@ plugins {
|
||||
* @param mcIndex array index of the currently active MC version
|
||||
*/
|
||||
def writeBuildGradlePredefine(List<String> mcVers, int mcIndex) {
|
||||
|
||||
ArrayList<String> redefineList = new ArrayList<String>()
|
||||
for (int i=0; i<mcVers.size(); i++) {
|
||||
String mcStr = mcVers.get(i).replace(".", "_")
|
||||
if (mcIndex<i) {
|
||||
redefineList.add("PRE_MC_"+mcStr)
|
||||
|
||||
for (int i = 0; i < mcVers.size(); i++) {
|
||||
String mcStr = mcVers[i].replace(".", "_")
|
||||
if (mcIndex < i) {
|
||||
redefineList.add("PRE_MC_" + mcStr)
|
||||
}
|
||||
if (mcIndex==i) {
|
||||
redefineList.add("MC_"+mcStr)
|
||||
if (mcIndex == i) {
|
||||
redefineList.add("MC_" + mcStr)
|
||||
}
|
||||
if (mcIndex>=i) {
|
||||
redefineList.add("POST_MC_"+mcStr)
|
||||
if (mcIndex >= i) {
|
||||
redefineList.add("POST_MC_" + mcStr)
|
||||
}
|
||||
}
|
||||
|
||||
// build the list of preprocessors to use
|
||||
// Build the list of preprocessors to use
|
||||
StringBuilder sb = new StringBuilder()
|
||||
|
||||
// check if this is a development build
|
||||
sb.append("# DON'T TOUCH THIS FILE, This is handled by the build script\n")
|
||||
|
||||
// Check if this is a development build
|
||||
if (mod_version.toLowerCase().contains("dev")) {
|
||||
// WARNING: only use this for logging, we don't want to have confusion
|
||||
// when a method doesn't work correctly in the release build.
|
||||
@@ -46,7 +49,7 @@ def writeBuildGradlePredefine(List<String> mcVers, int mcIndex) {
|
||||
sb.append("=\n")
|
||||
}
|
||||
|
||||
// build the MC version preprocessors
|
||||
// Build the MC version preprocessors
|
||||
for (String redefinedVersion : redefineList) {
|
||||
sb.append(redefinedVersion)
|
||||
sb.append("=\n")
|
||||
@@ -54,142 +57,111 @@ def writeBuildGradlePredefine(List<String> mcVers, int mcIndex) {
|
||||
new File(projectDir, "build.properties").text = sb.toString()
|
||||
}
|
||||
|
||||
// Sets up the variables for Manifold in the code
|
||||
def loadProperties() {
|
||||
def defaultMcVersion = "1.19.2"
|
||||
// def defaultMcVersion = "1.19" // For now use 1.18.2 as default until 1.19 is done
|
||||
def mcVersion = ""
|
||||
def mcVers = mcVersions.split(",")
|
||||
int mcIndex = -1
|
||||
println "Avalible MC versions: ${mcVersions}"
|
||||
if (project.hasProperty("mcVer")) {
|
||||
mcVersion = mcVer
|
||||
mcIndex = Arrays.asList(mcVers).indexOf(mcVer)
|
||||
}
|
||||
if (mcIndex == -1) {
|
||||
println "No mcVer set or the set mcVer is invalid! Defaulting to ${defaultMcVersion}."
|
||||
println "Tip: Use -PmcVer='${defaultMcVersion}' in cmd arg to set mcVer."
|
||||
mcVersion = defaultMcVersion
|
||||
mcIndex = Arrays.asList(mcVers).indexOf(defaultMcVersion)
|
||||
assert mcIndex != -1
|
||||
}
|
||||
|
||||
println "Loading properties file at " + mcVersion + ".properties"
|
||||
def props = new Properties()
|
||||
props.load(new FileInputStream("$rootProject.rootDir/"+"$mcVersion"+".properties"))
|
||||
|
||||
props.each { prop ->
|
||||
rootProject.ext.set(prop.key, prop.value)
|
||||
// println "Added prop [key:" + prop.key + ", value:" + prop.value + "]"
|
||||
}
|
||||
writeBuildGradlePredefine(Arrays.asList(mcVers), mcIndex)
|
||||
|
||||
// Stuff for access wideners
|
||||
def mcVersionToAcsessWidenerVersion = [
|
||||
"1.16.5": "1_16",
|
||||
"1.17.1": "1_17",
|
||||
"1.18.1": "1_18",
|
||||
"1.18.2": "1_18",
|
||||
"1.19": "1_19",
|
||||
"1.19.1": "1_19",
|
||||
"1.19.2": "1_19"
|
||||
]
|
||||
// Use this as sometimes multiple versions use the same access wideners
|
||||
rootProject.ext.set("accessWidenerVersion", mcVersionToAcsessWidenerVersion.get(mcVersion))
|
||||
// Transfers the values set in settings.gradle to the rest of the project
|
||||
project.gradle.ext.getProperties().each { prop ->
|
||||
rootProject.ext.set(prop.key, prop.value)
|
||||
// println "Added prop [key:" + prop.key + ", value:" + prop.value + "]"
|
||||
}
|
||||
loadProperties()
|
||||
|
||||
// Sets up the accesswideners
|
||||
def makeAccessWidener() {
|
||||
def accessWidenerFile = project(":common").file("src/main/resources/lod.accesswidener")
|
||||
if (accessWidenerFile.exists()) {
|
||||
delete accessWidenerFile
|
||||
}
|
||||
|
||||
copy {
|
||||
from project(":common").file("src/main/resources/${rootProject.accessWidenerVersion}.lod.accesswidener")
|
||||
into project(":common").file("src/main/resources/")
|
||||
rename "${rootProject.accessWidenerVersion}.lod.accesswidener", "lod.accesswidener"
|
||||
}
|
||||
}
|
||||
makeAccessWidener()
|
||||
// Sets up manifold stuff
|
||||
writeBuildGradlePredefine(rootProject.mcVers, rootProject.mcIndex)
|
||||
|
||||
|
||||
|
||||
|
||||
// Sets up the version string
|
||||
// Sets up the version string (the name we use for our jar)
|
||||
rootProject.versionStr = rootProject.mod_version + "-" + rootProject.minecraft_version // + "-" + new Date().format("yyyy_MM_dd_HH_mm")
|
||||
|
||||
// Merged jar settings
|
||||
// Forgix settings (used for merging jars)
|
||||
forgix {
|
||||
group = "com.seibel.lod"
|
||||
mergedJarName = "DistantHorizons-${rootProject.versionStr}.jar"
|
||||
|
||||
forge {
|
||||
jarLocation = "build/libs/DistantHorizons-${rootProject.versionStr}.jar"
|
||||
jarLocation = "build/libs/DistantHorizons-forge-${rootProject.versionStr}.jar"
|
||||
}
|
||||
|
||||
fabric {
|
||||
jarLocation = "build/libs/DistantHorizons-${rootProject.versionStr}.jar"
|
||||
jarLocation = "build/libs/DistantHorizons-fabric-${rootProject.versionStr}.jar"
|
||||
}
|
||||
|
||||
removeDuplicate "com.seibel.lod.api"
|
||||
removeDuplicate "com.seibel.lod.core"
|
||||
}
|
||||
|
||||
architectury {
|
||||
minecraft = rootProject.minecraft_version
|
||||
}
|
||||
|
||||
subprojects { p ->
|
||||
|
||||
// setup Architectury
|
||||
if (p == project(":core") || p == project(":api")) {
|
||||
// Does the same as "p == project(":common") || p == project(":fabric") || p == project(":quilt") || p == project(":forge") || p == project("WhateverWeAddLaterOn")"
|
||||
// Useful later on so we dont have duplicated code
|
||||
def isMinecraftSubProject = p != project(":core") && p != project(":api")
|
||||
|
||||
|
||||
// Apply plugins
|
||||
apply plugin: "java"
|
||||
apply plugin: "com.github.johnrengelman.shadow"
|
||||
if (isMinecraftSubProject)
|
||||
apply plugin: "systems.manifold.manifold-gradle-plugin"
|
||||
if (p == project(":core"))
|
||||
apply plugin: "application"
|
||||
apply plugin: "org.spongepowered.gradle.vanilla" // Provides minecraft libraries
|
||||
apply plugin: "com.github.johnrengelman.shadow"
|
||||
} else {
|
||||
apply plugin: "com.github.johnrengelman.shadow"
|
||||
apply plugin: "dev.architectury.loom"
|
||||
|
||||
loom {
|
||||
silentMojangMappingsLicense()
|
||||
}
|
||||
// apply plugin: "org.spongepowered.gradle.vanilla" // Provides minecraft libraries
|
||||
|
||||
|
||||
// Set the manifold version (may not be required tough)
|
||||
manifold {
|
||||
manifoldVersion = rootProject.manifold_version
|
||||
}
|
||||
|
||||
|
||||
// set up custom configurations (configurations are a way to handle dependencies)
|
||||
configurations {
|
||||
// extends the shadowJar configuration
|
||||
// extends the shadowJar configuration
|
||||
shadowMe
|
||||
// have implemented dependencies automatically embedded in the final jar
|
||||
implementation.extendsFrom(shadowMe)
|
||||
|
||||
customModule
|
||||
implementation.extendsFrom(customModule)
|
||||
}
|
||||
|
||||
// Set up the minecraft non-dependency for core sub-projects
|
||||
if (p == project(":core") || p == project(":api")) {
|
||||
minecraft {
|
||||
version("${rootProject.minecraft_version}")
|
||||
}
|
||||
|
||||
// Set the standalone jar entrypoint
|
||||
// (This will point to a non-existent class in all sub-projects except "Core")
|
||||
if (isMinecraftSubProject && p != project(":common")) {
|
||||
// Shadow common
|
||||
common
|
||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentForge.extendsFrom common
|
||||
|
||||
if (findProject(":fabricLike") && p != project(":fabricLike")) {
|
||||
// Shadow fabricLike
|
||||
fabricLike
|
||||
shadowFabricLike
|
||||
compileClasspath.extendsFrom fabricLike
|
||||
runtimeClasspath.extendsFrom fabricLike
|
||||
developmentForge.extendsFrom fabricLike
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Let the application plugin know where the main class is
|
||||
// (This will point to a non-existent class in all sub-projects except "Core")
|
||||
if (p == project(":core")) {
|
||||
application {
|
||||
mainClass.set('com.seibel.lod.core.jar.JarMain')
|
||||
mainClass.set("com.seibel.lod.core.jar.JarMain")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
//=====================//
|
||||
// shared dependencies //
|
||||
//=====================//
|
||||
|
||||
|
||||
// Manifold
|
||||
annotationProcessor("systems.manifold:manifold-preprocessor:${rootProject.manifold_version}")
|
||||
if (isMinecraftSubProject)
|
||||
annotationProcessor("systems.manifold:manifold-preprocessor:${rootProject.manifold_version}")
|
||||
|
||||
// Log4j
|
||||
// TODO: Change to shadowMe later to work in the standalone jar
|
||||
implementation("org.apache.logging.log4j:log4j-api:${rootProject.log4j_version}")
|
||||
implementation("org.apache.logging.log4j:log4j-core:${rootProject.log4j_version}")
|
||||
|
||||
// JOML
|
||||
implementation("org.joml:joml:${rootProject.joml_version}")
|
||||
|
||||
// JUnit tests
|
||||
implementation("org.junit.jupiter:junit-jupiter:5.8.2")
|
||||
@@ -198,7 +170,6 @@ subprojects { p ->
|
||||
|
||||
// Compression
|
||||
shadowMe("org.tukaani:xz:1.9")
|
||||
shadowMe("org.apache.commons:commons-compress:1.21")
|
||||
|
||||
// NightConfig (includes Toml & Json)
|
||||
shadowMe("com.electronwill.night-config:toml:${rootProject.nightconfig_version}")
|
||||
@@ -208,8 +179,14 @@ subprojects { p ->
|
||||
shadowMe("com.formdev:flatlaf:${rootProject.flatlaf_version}")
|
||||
|
||||
// SVG
|
||||
shadowMe("com.formdev:flatlaf-extras:${rootProject.flatlaf_version}")
|
||||
shadowMe("com.formdev:svgSalamander:${rootProject.svgSalamander_version}")
|
||||
shadowMe("com.formdev:flatlaf-extras:${rootProject.flatlaf_version}")
|
||||
|
||||
|
||||
// Remember, for lwjgl dependancies that arent included in Minecraft, you need to also need to add it to the ShadowJar thing
|
||||
shadowMe("org.lwjgl:lwjgl-jawt:3.2.2") {
|
||||
exclude group: "org.lwjgl", module: "lwjgl" // This module is imported by Minecraft so exclude it
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -217,104 +194,219 @@ subprojects { p ->
|
||||
// conditional dependencies //
|
||||
//==========================//
|
||||
|
||||
// The logic for buildForge can be made more succinct, but the readability goes way down.
|
||||
def buildForge = true
|
||||
if (gradle.startParameter.taskRequests.size() > 0) {
|
||||
if (gradle.startParameter.taskRequests[0].args.size() > 0) {
|
||||
if (gradle.startParameter.taskRequests[0].args[0].startsWith("fabric:")) {
|
||||
buildForge = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Minecraft dependent sub-projects
|
||||
if (p == project(":common") || (buildForge && p == project(":forge")) || p == project(":fabric")) {
|
||||
// Add Minecraft
|
||||
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
||||
// The following line declares the mojmap mappings & parchment mappings
|
||||
mappings loom.layered() {
|
||||
// Mojmap mappings
|
||||
officialMojangMappings()
|
||||
// Parchment mappings (it adds parameter mappings & javadoc)
|
||||
parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip")
|
||||
}
|
||||
}
|
||||
|
||||
// Add core
|
||||
if (p != project(":api") && p != project(":core")) {
|
||||
implementation(project(":core")) {
|
||||
if (isMinecraftSubProject) {
|
||||
shadowMe(project(":core")) {
|
||||
// Remove Junit test libraries
|
||||
exclude group: "org.junit.jupiter", module: "junit-jupiter"
|
||||
exclude group: "org.junit.jupiter", module: "junit-jupiter-engine"
|
||||
exclude group: "junit", module: "junit"
|
||||
// Removed dependencies
|
||||
transitive false
|
||||
}
|
||||
}
|
||||
|
||||
// Add the api
|
||||
if (p != project(":api")) {
|
||||
implementation(project(":api")) {
|
||||
shadowMe(project(":api")) {
|
||||
// Remove Junit test libraries
|
||||
exclude group: "org.junit.jupiter", module: "junit-jupiter"
|
||||
exclude group: "org.junit.jupiter", module: "junit-jupiter-engine"
|
||||
exclude group: "junit", module: "junit"
|
||||
// Removed dependencies
|
||||
transitive false
|
||||
}
|
||||
}
|
||||
|
||||
// Add common
|
||||
if (isMinecraftSubProject && p != project(":common")) {
|
||||
// Common
|
||||
common(project(path: ":common")) { transitive false }
|
||||
shadowCommon(project(path: ":common")) { transitive false }
|
||||
|
||||
// FabricLike
|
||||
if (findProject(":fabricLike") && p != project(":fabricLike")) {
|
||||
fabricLike(project(path: ":fabricLike")) { transitive false }
|
||||
shadowFabricLike(project(path: ":fabricLike")) { transitive false }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Allows the jar to run standalone
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadowMe]
|
||||
if (isMinecraftSubProject && p != project(":common")) {
|
||||
configurations.push(project.configurations.shadowCommon) // Shadow the common subproject
|
||||
relocate "com.seibel.lod.common", "loaderCommon.${p.name}.com.seibel.lod.common" // Move the loader files to a different location
|
||||
|
||||
if (findProject(":fabricLike") && p != project(":fabricLike")) {
|
||||
configurations.push(project.configurations.shadowFabricLike) // Shadow the fabricLike subproject
|
||||
relocate "com.seibel.lod.fabriclike", "loaderCommon.${p.name}.com.seibel.lod.fabriclike" // Move the loader files to a different location
|
||||
}
|
||||
}
|
||||
def librariesLocation = "distanthorizons.libraries"
|
||||
|
||||
// LWJGL
|
||||
// Only ever shadow the dependencies we use otherwise some stuff would break when running on an external client
|
||||
relocate "org.lwjgl.system.jawt", "${librariesLocation}.lwjgl.system.jawt"
|
||||
|
||||
// Compression
|
||||
relocate "org.tukaani", "${librariesLocation}.tukaani"
|
||||
|
||||
// NightConfig (includes Toml & Json)
|
||||
relocate "com.electronwill.nightconfig", "${librariesLocation}.electronwill.nightconfig"
|
||||
|
||||
// Theming
|
||||
relocate 'com.formdev.flatlaf', 'distanthorizons.libraries.formdev.flatlaf'
|
||||
|
||||
// SVG
|
||||
relocate "com.kitfox.svg", "${librariesLocation}.kitfox.svg"
|
||||
|
||||
mergeServiceFiles()
|
||||
}
|
||||
// Using jar.finalizedBy(shadowJar) causes issues so we do this scuffed bypass
|
||||
jar.dependsOn(shadowJar)
|
||||
|
||||
|
||||
// Put stuff from gradle.properties into the mod info
|
||||
processResources {
|
||||
def resourceTargets = [ // Location of where to inject the properties
|
||||
// Properties for each of the loaders
|
||||
"fabric.mod.json",
|
||||
"quilt.mod.json",
|
||||
"META-INF/mods.toml",
|
||||
|
||||
// The mixins for each of the loaders
|
||||
"DistantHorizons."+ p.name +".fabricLike.mixins.json"
|
||||
]
|
||||
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
|
||||
|
||||
// Fix forge version numbering system as it is weird
|
||||
// For whatever reason forge uses [1.18, 1.18.1, 1.18.2) instead of the standard ["1.18", "1.18.1", "1.18.2"] which make more sense
|
||||
def compatible_forgemc_versions = "${compatible_minecraft_versions}".replaceAll("\"", "").replaceAll("]", ",)")
|
||||
// println compatible_forgemc_versions
|
||||
|
||||
// Quilt's custom contributors system
|
||||
// This has to be like
|
||||
// "Person": "Developer", "Another person": "Developer"
|
||||
def quilt_contributors = []
|
||||
def mod_author_list = mod_authors.replaceAll("\"", "").replace("[", "").replace("]", "").split(",")
|
||||
for (dev in mod_author_list) {
|
||||
quilt_contributors.push("\"${dev.strip()}\": \"Developer\"")
|
||||
}
|
||||
quilt_contributors.reverse()
|
||||
// println quilt_contributors.join(", ")
|
||||
|
||||
// TODOI: Find something we can use so we can basically re-map only when the jar is shadowed and relocated
|
||||
// println p.tasks.findByName('shadowJar')
|
||||
|
||||
|
||||
def replaceProperties = [
|
||||
version : mod_version,
|
||||
mod_name : mod_readable_name,
|
||||
group : maven_group,
|
||||
authors : mod_authors,
|
||||
description : mod_description,
|
||||
homepage : mod_homepage,
|
||||
source : mod_source,
|
||||
issues : mod_issues,
|
||||
discord : mod_discord,
|
||||
minecraft_version : minecraft_version,
|
||||
compatible_minecraft_versions: compatible_minecraft_versions,
|
||||
compatible_forgemc_versions : compatible_forgemc_versions,
|
||||
java_version : java_version,
|
||||
quilt_contributors : "{"+quilt_contributors.join(", ")+"}"
|
||||
]
|
||||
// The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties
|
||||
|
||||
inputs.properties replaceProperties
|
||||
replaceProperties.put "project", project
|
||||
filesMatching(resourceTargets) {
|
||||
expand replaceProperties
|
||||
}
|
||||
|
||||
intoTargets.each { target ->
|
||||
if (file(target).exists()) {
|
||||
copy {
|
||||
from(sourceSets.main.resources) {
|
||||
include resourceTargets
|
||||
expand replaceProperties
|
||||
}
|
||||
into target
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Adds the standalone jar's entrypoint
|
||||
jar {
|
||||
from "LICENSE.txt"
|
||||
manifest {
|
||||
attributes 'Implementation-Title': rootProject.archives_base_name,
|
||||
attributes 'Implementation-Title': rootProject.mod_name,
|
||||
'Implementation-Version': rootProject.mod_version,
|
||||
'Main-Class': 'com.seibel.lod.core.jar.JarMain' // When changing the main of the jar change this line
|
||||
}
|
||||
}
|
||||
|
||||
// this can be un-commented if we ever wanted to make DH modular (AKA use a module-info.java file) again
|
||||
// // Tells gradle where to look for other modules
|
||||
// // Why isn't the classpath added to the modules path by default?
|
||||
// if (p == project(":core")) {
|
||||
// compileJava {
|
||||
// inputs.property('moduleName', 'dhApi')
|
||||
// doFirst {
|
||||
// options.compilerArgs = [
|
||||
// '--module-path', classpath.asPath
|
||||
// ]
|
||||
// classpath = files()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
/*
|
||||
// Tells gradle where to look for other modules
|
||||
// Why isn't the classpath added to the modules path by default?
|
||||
if (p == project(":core")) {
|
||||
compileJava {
|
||||
inputs.property('moduleName', 'dhApi')
|
||||
doFirst {
|
||||
options.compilerArgs = [
|
||||
'--module-path', classpath.asPath
|
||||
]
|
||||
classpath = files()
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Run mergeJars when running build
|
||||
if (p != project(":api") && p != project(":api")) {
|
||||
build.finalizedBy(mergeJars)
|
||||
assemble.finalizedBy(mergeJars)
|
||||
}
|
||||
// TODO: Fix later
|
||||
// if (isMinecraftSubProject) {
|
||||
// build.finalizedBy(mergeJars)
|
||||
// assemble.finalizedBy(mergeJars)
|
||||
// }
|
||||
}
|
||||
|
||||
allprojects { p ->
|
||||
// Does the same as "p == project(":common") || p == project(":fabric") || p == project(":quilt") || p == project(":forge")"
|
||||
// Useful later on so we dont have duplicated code
|
||||
def isMinecraftSubProject = p != project(":core") && p != project(":api")
|
||||
|
||||
|
||||
apply plugin: "java"
|
||||
apply plugin: "architectury-plugin"
|
||||
apply plugin: "maven-publish"
|
||||
|
||||
archivesBaseName = rootProject.archives_base_name
|
||||
version = rootProject.mod_version
|
||||
archivesBaseName = rootProject.mod_name
|
||||
version = project.name + "-" + rootProject.versionStr
|
||||
group = rootProject.maven_group
|
||||
|
||||
|
||||
repositories {
|
||||
// The central repo
|
||||
mavenCentral()
|
||||
|
||||
// Used for Google's Collect library
|
||||
maven { url "https://repo.enonic.com/public/" }
|
||||
|
||||
// For parchment mappings
|
||||
maven { url "https://maven.parchmentmc.org" }
|
||||
|
||||
// For Architectury API
|
||||
maven { url "https://maven.architectury.dev" }
|
||||
|
||||
// used to download and compile dependencies from git repos
|
||||
maven { url 'https://jitpack.io' }
|
||||
// For Git repositories
|
||||
maven { url "https://jitpack.io" }
|
||||
|
||||
// For Manifold Preprocessor
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||
|
||||
// Required for importing Modrinth mods
|
||||
maven {
|
||||
@@ -339,16 +431,22 @@ allprojects { p ->
|
||||
// Required for Mixins & VanillaGradle
|
||||
maven { url "https://repo.spongepowered.org/maven/" }
|
||||
|
||||
// Required for canvas
|
||||
// Required for Canvas (mod)
|
||||
maven { url "https://maven.vram.io/" }
|
||||
|
||||
// These 2 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource
|
||||
// These 3 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/fabric"
|
||||
content {
|
||||
includeGroup "fabric-mod"
|
||||
}
|
||||
}
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/quilt"
|
||||
content {
|
||||
includeGroup "quilt-mod"
|
||||
}
|
||||
}
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/forge"
|
||||
content {
|
||||
@@ -357,67 +455,54 @@ allprojects { p ->
|
||||
}
|
||||
}
|
||||
|
||||
// Adds some dependencies that are in vanilla but not in core
|
||||
if (p == project(":core")) {
|
||||
OperatingSystem os = org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentOperatingSystem;
|
||||
|
||||
// Only uncomment this when testing stuff with lwjgl in the core jar
|
||||
// if (p == project(":core")) {
|
||||
// dependencies {
|
||||
// project.ext.lwjglNatives = "natives-linux"
|
||||
//
|
||||
// implementation platform("org.lwjgl:lwjgl-bom:3.3.0")
|
||||
//
|
||||
// implementation "org.lwjgl:lwjgl"
|
||||
// implementation "org.lwjgl:lwjgl-assimp"
|
||||
// implementation "org.lwjgl:lwjgl-glfw"
|
||||
// implementation "org.lwjgl:lwjgl-openal"
|
||||
// implementation "org.lwjgl:lwjgl-opengl"
|
||||
// implementation "org.lwjgl:lwjgl-stb"
|
||||
// implementation "org.lwjgl:lwjgl-tinyfd"
|
||||
// runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
|
||||
// runtimeOnly "org.lwjgl:lwjgl-assimp::$lwjglNatives"
|
||||
// runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
|
||||
// runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives"
|
||||
// runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
|
||||
// runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives"
|
||||
// runtimeOnly "org.lwjgl:lwjgl-tinyfd::$lwjglNatives"
|
||||
// implementation "org.joml:joml:1.10.2"
|
||||
// }
|
||||
// }
|
||||
// Set the OS lwjgl is using to the current os
|
||||
project.ext.lwjglNatives = "natives-" + os.toFamilyName()
|
||||
|
||||
// Put stuff from gradle.properties into the mod info
|
||||
processResources {
|
||||
def resourceTargets = ["fabric.mod.json", "META-INF/mods.toml"] // Location of where to put
|
||||
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
|
||||
def replaceProperties = [
|
||||
version : mod_version,
|
||||
mod_name : mod_name,
|
||||
authors : mod_authors,
|
||||
description : mod_description,
|
||||
homepage : mod_homepage,
|
||||
source : mod_source,
|
||||
issues : mod_issues,
|
||||
minecraft_version : minecraft_version,
|
||||
compatible_minecraft_versions: compatible_minecraft_versions,
|
||||
java_version : java_version
|
||||
]
|
||||
// The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties
|
||||
//TODO: Make Forge loader version also be relaced with non hardcoded value instead of "[36,42)"
|
||||
dependencies { // All of these dependancies are in Vanilla Minecraft, but we need to depend on it as we arent importing Minecraft in the core
|
||||
// Imports most of lwjgl's libraries (well, only the ones that we need)
|
||||
implementation platform("org.lwjgl:lwjgl-bom:${rootProject.lwjgl_version}") // TODO: Use Minecraft's version for lwjgl_version (which changes each version) instead of a hard defined version for all versions
|
||||
|
||||
inputs.properties replaceProperties
|
||||
replaceProperties.put 'project', project
|
||||
filesMatching(resourceTargets) {
|
||||
expand replaceProperties
|
||||
implementation "org.lwjgl:lwjgl"
|
||||
implementation "org.lwjgl:lwjgl-assimp"
|
||||
implementation "org.lwjgl:lwjgl-glfw"
|
||||
implementation "org.lwjgl:lwjgl-openal"
|
||||
implementation "org.lwjgl:lwjgl-opengl"
|
||||
implementation "org.lwjgl:lwjgl-stb"
|
||||
implementation "org.lwjgl:lwjgl-tinyfd"
|
||||
runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
|
||||
runtimeOnly "org.lwjgl:lwjgl-assimp::$lwjglNatives"
|
||||
runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
|
||||
runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives"
|
||||
runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
|
||||
runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives"
|
||||
runtimeOnly "org.lwjgl:lwjgl-tinyfd::$lwjglNatives"
|
||||
implementation "org.joml:joml:${rootProject.joml_version}"
|
||||
|
||||
|
||||
// Some other dependencies
|
||||
implementation("org.jetbrains:annotations:16.0.2")
|
||||
implementation("com.google.code.findbugs:jsr305:3.0.2")
|
||||
implementation("com.google.common:google-collect:0.5")
|
||||
implementation("com.google.guava:guava:31.1-jre")
|
||||
implementation("it.unimi.dsi:fastutil:8.5.11")
|
||||
}
|
||||
}
|
||||
|
||||
intoTargets.each { target ->
|
||||
if (file(target).exists()) {
|
||||
copy {
|
||||
from(sourceSets.main.resources) {
|
||||
include resourceTargets
|
||||
expand replaceProperties
|
||||
}
|
||||
into target
|
||||
}
|
||||
}
|
||||
|
||||
task copyCommonLoaderResources(type: Copy) {
|
||||
from project(":common").file("src/main/resources/${accessWidenerVersion}.lod.accesswidener")
|
||||
into(file(p.file("build/resources/main")))
|
||||
rename "${accessWidenerVersion}.lod.accesswidener", "lod.accesswidener"
|
||||
|
||||
// Move the fabricLike mixin to its different places for each subproject
|
||||
if (findProject(":fabricLike")) {
|
||||
from project(":fabricLike").file("src/main/resources/DistantHorizons.fabricLike.mixins.json")
|
||||
into(file(p.file("build/resources/main")))
|
||||
rename "DistantHorizons.fabricLike.mixins.json", "DistantHorizons." + p.name + ".fabricLike.mixins.json"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,14 +511,24 @@ allprojects { p ->
|
||||
into p.file("build/resources/main")
|
||||
}
|
||||
|
||||
// TODO: This method doesnt seem to actually remove it from the jar, probably called at incorrect spots
|
||||
task deleteDuplicatedCommonLoaderResources(type: Delete) {
|
||||
// Delete the duplicated fabricLike.mixins.json
|
||||
delete p.file("build/resources/main/DistantHorizons.fabricLike.mixins.json")
|
||||
|
||||
// Delete all the duplicated accesswideners
|
||||
delete fileTree(p.file("build/resources/main")) {
|
||||
include "*.lod.accesswidener"
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
if (p != project(":core")) {
|
||||
if (isMinecraftSubProject) {
|
||||
options.release = rootProject.java_version as Integer
|
||||
options.compilerArgs += ['-Xplugin:Manifold']
|
||||
options.compilerArgs += ["-Xplugin:Manifold"]
|
||||
} else {
|
||||
// options.release = 8; // Core should use Java 8 no matter what
|
||||
// No it shouldn't cause it fails to find minecraft if it uses Java 8
|
||||
options.release = rootProject.java_version as Integer
|
||||
options.release = 8; // Core & Api should use Java 8 no matter what
|
||||
//options.release = rootProject.java_version as Integer // But if you want to test some stuff, then this can be enabled
|
||||
}
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
@@ -441,14 +536,9 @@ allprojects { p ->
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
// Disable running common
|
||||
if (p == project(":common")) {
|
||||
runClient.enabled = false
|
||||
runServer.enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Delete the merged folder when running clean
|
||||
task cleanMergedJars() {
|
||||
def mergedFolder = file("Merged")
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
buildVersion()
|
||||
{
|
||||
./gradlew clean -PmcVer=$1 --no-daemon
|
||||
./gradlew build -PmcVer=$1 --no-daemon
|
||||
}
|
||||
# Loop trough everything in the version properties folder
|
||||
for d in versionProperties/*; do
|
||||
# Get the name of the version that is going to be compiled
|
||||
version=$(echo "$d" | sed "s/versionProperties\///" | sed "s/.properties//")
|
||||
|
||||
buildVersion 1.19
|
||||
buildVersion 1.18.2
|
||||
buildVersion 1.18.1
|
||||
buildVersion 1.17.1
|
||||
buildVersion 1.16.5
|
||||
# Clean out the folders and build it
|
||||
# (We could use "./" to run gradlew, but as it is a shell script im going to be running it with the "sh" command)
|
||||
echo "Cleaning workspace to build $version"
|
||||
sh gradlew clean -PmcVer=$version --no-daemon | true
|
||||
echo "Building $version"
|
||||
sh gradlew build -PmcVer=$version --no-daemon | true
|
||||
# The "| true" at the end of those 2 are just to make sure the script continues even if a build fails
|
||||
done
|
||||
|
||||
+22
-13
@@ -1,16 +1,25 @@
|
||||
@echo off
|
||||
|
||||
SETLOCAL
|
||||
CALL :buildVersion "1.19"
|
||||
CALL :buildVersion "1.18.2"
|
||||
CALL :buildVersion "1.18.1"
|
||||
CALL :buildVersion "1.17.1"
|
||||
CALL :buildVersion "1.16.5"
|
||||
EXIT /B %ERRORLEVEL%
|
||||
echo Windows build all script needs to be rewritten
|
||||
echo I dont use Windows so I cant really make this
|
||||
echo So if someone does use Windows and knows how to script stuff then can you please port the "buildall" script I made for Unix
|
||||
|
||||
:buildVersion
|
||||
@echo on
|
||||
call ./gradlew.bat clean -PmcVer="%~1" --no-daemon
|
||||
call ./gradlew.bat build -PmcVer="%~1" --no-daemon
|
||||
@echo off
|
||||
EXIT /B 0
|
||||
|
||||
|
||||
|
||||
@REM Old BAT script if you need some help with this task
|
||||
|
||||
@REM SETLOCAL
|
||||
@REM CALL :buildVersion "1.19"
|
||||
@REM CALL :buildVersion "1.18.2"
|
||||
@REM CALL :buildVersion "1.18.1"
|
||||
@REM CALL :buildVersion "1.17.1"
|
||||
@REM CALL :buildVersion "1.16.5"
|
||||
@REM EXIT /B %ERRORLEVEL%
|
||||
@REM
|
||||
@REM :buildVersion
|
||||
@REM @echo on
|
||||
@REM call ./gradlew.bat clean -PmcVer="%~1" --no-daemon
|
||||
@REM call ./gradlew.bat build -PmcVer="%~1" --no-daemon
|
||||
@REM @echo off
|
||||
@REM EXIT /B 0
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to make participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all project spaces, and it also applies when
|
||||
an individual is representing the project or its community in public spaces.
|
||||
Examples of representing a project or community include using an official
|
||||
project e-mail address, posting via an official social media account, or acting
|
||||
as an appointed representative at an online or offline event. Representation of
|
||||
a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the team lead James Seibel through Discord at `@BackSun#4157`. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
||||
|
||||
+10
-11
@@ -1,27 +1,26 @@
|
||||
architectury {
|
||||
common(rootProject.enabled_platforms.split(","))
|
||||
plugins {
|
||||
id "org.spongepowered.gradle.vanilla" version "0.2.1-SNAPSHOT"
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = file("src/main/resources/lod.accesswidener")
|
||||
minecraft {
|
||||
accessWideners(project(":common").file("src/main/resources/${accessWidenerVersion}.lod.accesswidener"))
|
||||
version(rootProject.minecraft_version)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
|
||||
// Do NOT use other classes from fabric loader
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
// modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
|
||||
if (minecraft_version == "1.16.5") {
|
||||
modApi("me.shedaniel:architectury:${rootProject.architectury_version}")
|
||||
} else {
|
||||
modApi("dev.architectury:architectury:${rootProject.architectury_version}")
|
||||
}
|
||||
// So mixins can be written in common
|
||||
compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
|
||||
}
|
||||
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenCommon(MavenPublication) {
|
||||
artifactId = rootProject.archives_base_name
|
||||
artifactId = rootProject.mod_readable_name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.seibel.lod.common.networking;
|
||||
|
||||
/*
|
||||
#if MC_1_16_5
|
||||
import me.shedaniel.architectury.networking.NetworkManager;
|
||||
#else
|
||||
@@ -26,6 +27,7 @@ import dev.architectury.networking.NetworkManager;
|
||||
#endif
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Ran
|
||||
@@ -33,6 +35,7 @@ import net.minecraft.network.FriendlyByteBuf;
|
||||
// Comment: What does the 'server' side mean? Dedicated server? Or does it include the internal server?
|
||||
// (I removed the hookup that calls the register method, since I'm not sure what it is doing yet)
|
||||
public class NetworkReceiver {
|
||||
/*
|
||||
public void register_Client() {
|
||||
NetworkManager.registerReceiver(NetworkManager.serverToClient(), Networking.RESOURCE_LOCATION, new ClientReceiver());
|
||||
}
|
||||
@@ -54,4 +57,5 @@ public class NetworkReceiver {
|
||||
com.seibel.lod.common.networking.NetworkHandler.receivePacketClient(Minecraft.getInstance(), buf, context.getPlayer());
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
package com.seibel.lod.common.networking;
|
||||
|
||||
import com.seibel.lod.core.ModInfo;
|
||||
#if MC_1_16_5
|
||||
import me.shedaniel.architectury.networking.NetworkManager;
|
||||
#else
|
||||
import dev.architectury.networking.NetworkManager;
|
||||
#endif
|
||||
//#if MC_1_16_5
|
||||
//import me.shedaniel.architectury.networking.NetworkManager;
|
||||
//#else
|
||||
//import dev.architectury.networking.NetworkManager;
|
||||
//#endif
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
@@ -57,7 +57,7 @@ public class Networking {
|
||||
* @param buf the payload of the packet.
|
||||
*/
|
||||
public static void send(ServerPlayer player, FriendlyByteBuf buf) {
|
||||
NetworkManager.sendToPlayer(player, RESOURCE_LOCATION, buf);
|
||||
// NetworkManager.sendToPlayer(player, RESOURCE_LOCATION, buf);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +67,7 @@ public class Networking {
|
||||
* @throws IllegalStateException if the client is not connected to a server
|
||||
*/
|
||||
public static void send(FriendlyByteBuf buf) throws IllegalStateException {
|
||||
NetworkManager.sendToServer(RESOURCE_LOCATION, buf);
|
||||
// NetworkManager.sendToServer(RESOURCE_LOCATION, buf);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,8 +29,6 @@ import com.seibel.lod.core.ReflectionHandler;
|
||||
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IVersionConstants;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.LodConfigWrapperSingleton;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
|
||||
@@ -48,7 +46,6 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
|
||||
public class DependencySetup {
|
||||
public static void createSharedBindings()
|
||||
{
|
||||
SingletonInjector.INSTANCE.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE); // TODO: Remove
|
||||
SingletonInjector.INSTANCE.bind(ILangWrapper.class, LangWrapper.INSTANCE);
|
||||
SingletonInjector.INSTANCE.bind(IVersionConstants.class, VersionConstants.INSTANCE);
|
||||
SingletonInjector.INSTANCE.bind(IWrapperFactory.class, WrapperFactory.INSTANCE);
|
||||
|
||||
@@ -59,22 +59,41 @@ public class McObjectConverter
|
||||
ELodDirection[] lodDirs = ELodDirection.values();
|
||||
directions = new Direction[lodDirs.length];
|
||||
lodDirections = new ELodDirection[lodDirs.length];
|
||||
for (ELodDirection lodDir : lodDirs) {
|
||||
Direction dir = switch (lodDir.name().toUpperCase()) {
|
||||
case "DOWN" -> Direction.DOWN;
|
||||
case "UP" -> Direction.UP;
|
||||
case "NORTH" -> Direction.NORTH;
|
||||
case "SOUTH" -> Direction.SOUTH;
|
||||
case "WEST" -> Direction.WEST;
|
||||
case "EAST" -> Direction.EAST;
|
||||
default -> null;
|
||||
};
|
||||
if (dir == null) {
|
||||
throw new IllegalArgumentException("Invalid direction on init mapping: " + lodDir);
|
||||
}
|
||||
directions[lodDir.ordinal()] = dir;
|
||||
lodDirections[dir.ordinal()] = lodDir;
|
||||
}
|
||||
for (ELodDirection lodDir : lodDirs)
|
||||
{
|
||||
Direction dir;
|
||||
switch (lodDir.name().toUpperCase())
|
||||
{
|
||||
case "DOWN":
|
||||
dir = Direction.DOWN;
|
||||
break;
|
||||
case "UP":
|
||||
dir = Direction.UP;
|
||||
break;
|
||||
case "NORTH":
|
||||
dir = Direction.NORTH;
|
||||
break;
|
||||
case "SOUTH":
|
||||
dir = Direction.SOUTH;
|
||||
break;
|
||||
case "WEST":
|
||||
dir = Direction.WEST;
|
||||
break;
|
||||
case "EAST":
|
||||
dir = Direction.EAST;
|
||||
break;
|
||||
default:
|
||||
dir = null;
|
||||
break;
|
||||
}
|
||||
|
||||
if (dir == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Invalid direction on init mapping: " + lodDir);
|
||||
}
|
||||
directions[lodDir.ordinal()] = dir;
|
||||
lodDirections[dir.ordinal()] = lodDir;
|
||||
}
|
||||
}
|
||||
|
||||
public static BlockPos Convert(DhBlockPos wrappedPos) {
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.IBlockStateWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IBiomeWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvionmentWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvironmentWrapper;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
@@ -49,7 +49,7 @@ public class WrapperFactory implements IWrapperFactory
|
||||
|
||||
|
||||
@Override
|
||||
public AbstractBatchGenerationEnvionmentWrapper createBatchGenerator(IDhLevel targetLevel)
|
||||
public AbstractBatchGenerationEnvironmentWrapper createBatchGenerator(IDhLevel targetLevel)
|
||||
{
|
||||
if (targetLevel instanceof IDhServerLevel)
|
||||
{
|
||||
@@ -97,16 +97,18 @@ public class WrapperFactory implements IWrapperFactory
|
||||
else if (objectArray.length == 2)
|
||||
{
|
||||
// chunk
|
||||
if (!(objectArray[0] instanceof ChunkAccess chunk))
|
||||
if (!(objectArray[0] instanceof ChunkAccess))
|
||||
{
|
||||
throw new ClassCastException(createChunkWrapperErrorMessage(objectArray));
|
||||
}
|
||||
ChunkAccess chunk = (ChunkAccess) objectArray[0];
|
||||
|
||||
// light source
|
||||
if (!(objectArray[1] instanceof LevelReader lightSource))
|
||||
if (!(objectArray[1] instanceof LevelReader))
|
||||
{
|
||||
throw new ClassCastException(createChunkWrapperErrorMessage(objectArray));
|
||||
}
|
||||
LevelReader lightSource = (LevelReader) objectArray[1];
|
||||
|
||||
|
||||
return new ChunkWrapper(chunk, lightSource, /*A DH wrapped level isn't necessary*/null);
|
||||
|
||||
@@ -94,18 +94,22 @@ public class BiomeWrapper implements IBiomeWrapper
|
||||
public int hashCode() {
|
||||
return Objects.hash(biome);
|
||||
}
|
||||
|
||||
public static IBiomeWrapper deserialize(String str) throws IOException {
|
||||
try {
|
||||
|
||||
public static IBiomeWrapper deserialize(String str) throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
#if PRE_MC_1_18_2 Biome #else
|
||||
Holder<Biome> #endif
|
||||
biome = Biome.CODEC.decode(RegistryOps.create(JsonOps.INSTANCE, Minecraft.getInstance().level.registryAccess()),
|
||||
JsonParser.parseString(str)).get().orThrow().getFirst();
|
||||
return getBiomeWrapper(biome);
|
||||
} catch (Exception e) {
|
||||
throw new IOException("Failed to deserialize biome wrapper", e);
|
||||
}
|
||||
}
|
||||
Holder<Biome> #endif
|
||||
biome = Biome.CODEC.decode(RegistryOps.create(JsonOps.INSTANCE, Minecraft.getInstance().level.registryAccess()),
|
||||
JsonParser.parseString(str)).get().orThrow().getFirst();
|
||||
return getBiomeWrapper(biome);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new IOException("Failed to deserialize biome wrapper", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,12 +37,15 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
if (blockState == null) {
|
||||
return "AIR";
|
||||
}
|
||||
return BlockState.CODEC.encodeStart(JsonOps.COMPRESSED, blockState).get().orThrow().toString();
|
||||
}
|
||||
public String serialize()
|
||||
{
|
||||
if (this.blockState == null)
|
||||
{
|
||||
return "AIR";
|
||||
}
|
||||
|
||||
return BlockState.CODEC.encodeStart(JsonOps.COMPRESSED, this.blockState).get().orThrow().toString();
|
||||
}
|
||||
|
||||
public static BlockStateWrapper deserialize(String str) throws IOException {
|
||||
if (str.equals("AIR")) {
|
||||
|
||||
@@ -20,10 +20,7 @@
|
||||
package com.seibel.lod.common.wrappers.chunk;
|
||||
|
||||
import com.seibel.lod.common.wrappers.block.BlockStateWrapper;
|
||||
import com.seibel.lod.core.pos.DhBlockPos;
|
||||
import com.seibel.lod.core.pos.DhChunkPos;
|
||||
import com.seibel.lod.core.util.LevelPosUtil;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.IBlockStateWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IBiomeWrapper;
|
||||
@@ -44,7 +41,9 @@ import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
// Which nullable should be used???
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
//import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -126,26 +125,6 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChunkPosX(){
|
||||
return chunk.getPos().x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChunkPosZ(){
|
||||
return chunk.getPos().z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegionPosX(){
|
||||
return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().x, LodUtil.REGION_DETAIL_LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegionPosZ(){
|
||||
return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().z, LodUtil.REGION_DETAIL_LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxY(int x, int z) {
|
||||
return chunk.getHeight(Heightmap.Types.WORLD_SURFACE, Math.floorMod(x, 16), Math.floorMod(z, 16));
|
||||
@@ -178,10 +157,16 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
#if PRE_MC_1_18_1
|
||||
return true;
|
||||
#else
|
||||
//if (chunk instanceof LevelChunk) {
|
||||
// return ((LevelChunk) chunk).isClientLightReady();
|
||||
//}
|
||||
return chunk.isLightCorrect();
|
||||
if (chunk instanceof LevelChunk)
|
||||
{
|
||||
// called when connected to a server (and sometimes when in a singleplayer world)
|
||||
return ((LevelChunk) chunk).isClientLightReady() || chunk.isLightCorrect();
|
||||
}
|
||||
else
|
||||
{
|
||||
// called when in a single player world
|
||||
return chunk.isLightCorrect();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.seibel.lod.core.config.*;
|
||||
// Minecraft imports
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.seibel.lod.core.jar.updater.SelfUpdater;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
@@ -113,7 +114,7 @@ public abstract class ClassicConfigGUI {
|
||||
#if PRE_MC_1_19
|
||||
((EntryInfo) info.guiValue).error = ((ConfigEntry) info).isValid(value) == 0 ? null : new AbstractMap.SimpleEntry<>(editBox, new TextComponent(((ConfigEntry) info).isValid(value) == -1 ?
|
||||
#else
|
||||
((EntryInfo) info.guiValue).error = ((ConfigEntry) info).isValid(value) == 0 ? null : new AbstractMap.SimpleEntry<>(editBox, Component.translatable(((ConfigEntry) info).isValid(value) == -1 ?
|
||||
((EntryInfo) info.guiValue).error = ((ConfigEntry) info).isValidMemoryAddress(value) == 0 ? null : new AbstractMap.SimpleEntry<>(editBox, Component.translatable(((ConfigEntry) info).isValidMemoryAddress(value) == -1 ?
|
||||
#endif
|
||||
"§cMinimum " + "length" + (cast ? " is " + (int) ((ConfigEntry) info).getMin() : " is " + ((ConfigEntry) info).getMin()) :
|
||||
"§cMaximum " + "length" + (cast ? " is " + (int) ((ConfigEntry) info).getMax() : " is " + ((ConfigEntry) info).getMax())));
|
||||
@@ -130,7 +131,7 @@ public abstract class ClassicConfigGUI {
|
||||
else
|
||||
((ConfigEntry) info).setWithoutSaving(value.intValue());
|
||||
}
|
||||
// else if (((ConfigEntry) info).isValid() == 0)
|
||||
// else if (((ConfigEntry) info).isValidMemoryAddress() == 0)
|
||||
// {
|
||||
// if (((List<String>) info.get()).size() == ((EntryInfo) info.guiValue).index)
|
||||
// info.set(((List<String>) info.get()).add(""));
|
||||
@@ -271,7 +272,6 @@ public abstract class ClassicConfigGUI {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -279,6 +279,8 @@ public abstract class ClassicConfigGUI {
|
||||
this.renderBackground(matrices); // Renders background
|
||||
this.list.render(matrices, mouseX, mouseY, delta); // Render buttons
|
||||
drawCenteredString(matrices, font, title, width / 2, 15, 0xFFFFFF); // Render title
|
||||
if (SelfUpdater.deleteOldOnClose)
|
||||
drawString(matrices, font, new TranslatableComponent("lod.updater.waitingForClose"), 4, height-38, 0xFFFFFF);
|
||||
|
||||
// Render the tooltip only if it can find a tooltip in the language file
|
||||
for (AbstractConfigType info : ConfigBase.INSTANCE.entries) {
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
package com.seibel.lod.common.wrappers.gui;
|
||||
|
||||
import com.seibel.lod.core.ModInfo;
|
||||
import com.seibel.lod.core.config.ConfigBase;
|
||||
import com.seibel.lod.core.config.gui.ConfigScreen;
|
||||
import com.seibel.lod.core.config.gui.JavaScreenHandlerScreen;
|
||||
import com.seibel.lod.core.config.gui.OpenGLConfigScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
|
||||
public class GetConfigScreen {
|
||||
public static type useScreen = type.Classic;
|
||||
public static enum type {
|
||||
Classic,
|
||||
OpenGL;
|
||||
@Deprecated
|
||||
OpenGL, // This was jsut an attempt, it didn't work out, and we are going to change to javafx soon (as soon as that works)
|
||||
JavaFX;
|
||||
}
|
||||
|
||||
public static Screen getScreen(Screen parent) {
|
||||
if (useScreen == type.Classic) {
|
||||
return ClassicConfigGUI.getScreen(ConfigBase.INSTANCE, parent, "client");
|
||||
} else if (useScreen == type.OpenGL) {
|
||||
return ConfigScreenMC.getScreen(parent, new ConfigScreen());
|
||||
}
|
||||
return null;
|
||||
return switch (useScreen) {
|
||||
case Classic -> ClassicConfigGUI.getScreen(ConfigBase.INSTANCE, parent, "client");
|
||||
case OpenGL -> MinecraftScreen.getScreen(parent, new OpenGLConfigScreen(), ModInfo.ID + ".title");
|
||||
// case JavaFX -> MinecraftScreen.getScreen(parent, new JavaScreenHandlerScreen(new JavaScreenHandlerScreen.ExampleScreen()), ModInfo.ID + ".title");
|
||||
case JavaFX -> MinecraftScreen.getScreen(parent, new JavaScreenHandlerScreen(new ConfigScreen()), ModInfo.ID + ".title");
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
+35
-15
@@ -1,18 +1,19 @@
|
||||
package com.seibel.lod.common.wrappers.gui;
|
||||
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.seibel.lod.core.ModInfo;
|
||||
import com.seibel.lod.core.config.gui.AbstractScreen;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
public class ConfigScreenMC {
|
||||
public static Screen getScreen(Screen parent, AbstractScreen screen) {
|
||||
|
||||
return new ConfigScreenRenderer(parent, screen);
|
||||
public class MinecraftScreen {
|
||||
public static Screen getScreen(Screen parent, AbstractScreen screen, String translationName) {
|
||||
return new ConfigScreenRenderer(parent, screen, translationName);
|
||||
}
|
||||
|
||||
private static class ConfigScreenRenderer extends Screen {
|
||||
@@ -31,17 +32,21 @@ public class ConfigScreenMC {
|
||||
}
|
||||
#endif
|
||||
|
||||
protected ConfigScreenRenderer(Screen parent, AbstractScreen screen) {
|
||||
super(translate(ModInfo.ID + ".config.title"));
|
||||
protected ConfigScreenRenderer(Screen parent, AbstractScreen screen, String translationName) {
|
||||
super(translate(translationName));
|
||||
screen.minecraftWindow = Minecraft.getInstance().getWindow().getWindow();
|
||||
this.parent = parent;
|
||||
this.screen = screen;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
// super.init();
|
||||
screen.width = this.width;
|
||||
screen.height = this.height;
|
||||
super.init(); // Init Minecraft's screen
|
||||
Window mcWindow = this.minecraft.getWindow();
|
||||
screen.width = mcWindow.getWidth();
|
||||
screen.height = mcWindow.getHeight();
|
||||
screen.scaledWidth = this.width;
|
||||
screen.scaledHeight = this.height;
|
||||
screen.init(); // Init our own config screen
|
||||
|
||||
this.list = new ConfigListWidget(this.minecraft, this.width, this.height, 0, this.height, 25); // Select the area to tint
|
||||
@@ -55,8 +60,6 @@ public class ConfigScreenMC {
|
||||
this.renderBackground(matrices); // Render background
|
||||
this.list.render(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker)
|
||||
|
||||
screen.width = this.width; // Is there a way to only call this when the window changes the size
|
||||
screen.height = this.height; // Is there a way to only call this when the window changes the size
|
||||
screen.mouseX = mouseX;
|
||||
screen.mouseY = mouseY;
|
||||
screen.render(delta); // Render everything on the main screen
|
||||
@@ -64,19 +67,36 @@ public class ConfigScreenMC {
|
||||
super.render(matrices, mouseX, mouseY, delta); // Render the vanilla stuff (currently only used for the background and tint)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(Minecraft mc, int width, int height) {
|
||||
super.resize(mc, width, height); // Resize Minecraft's screen
|
||||
Window mcWindow = this.minecraft.getWindow();
|
||||
screen.width = mcWindow.getWidth();
|
||||
screen.height = mcWindow.getHeight();
|
||||
screen.scaledWidth = this.width;
|
||||
screen.scaledHeight = this.height;
|
||||
screen.onResize(); // Resize our screen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
screen.tick();
|
||||
if (screen.close)
|
||||
super.tick(); // Tick Minecraft's screen
|
||||
screen.tick(); // Tick our screen
|
||||
if (screen.close) // If we decide to close the screen, then actually close the screen
|
||||
onClose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose() {
|
||||
screen.onClose();
|
||||
screen.onClose(); // Close our screen
|
||||
Objects.requireNonNull(minecraft).setScreen(this.parent); // Goto the parent screen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFilesDrop(@NotNull List<Path> files) {
|
||||
screen.onFilesDrop(files);
|
||||
}
|
||||
|
||||
// For checking if it should close when you press the escape key
|
||||
@Override
|
||||
public boolean shouldCloseOnEsc() {
|
||||
+13
-13
@@ -117,22 +117,15 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSinglePlayerServer()
|
||||
{
|
||||
return mc.hasSingleplayerServer();
|
||||
}
|
||||
public boolean hasSinglePlayerServer() { return mc.hasSingleplayerServer(); }
|
||||
@Override
|
||||
public boolean clientConnectedToDedicatedServer() { return mc.getCurrentServer() != null && !this.hasSinglePlayerServer(); }
|
||||
|
||||
@Override
|
||||
public String getCurrentServerName()
|
||||
{
|
||||
return mc.getCurrentServer().name;
|
||||
}
|
||||
public String getCurrentServerName() { return mc.getCurrentServer().name; }
|
||||
|
||||
@Override
|
||||
public String getCurrentServerIp()
|
||||
{
|
||||
return mc.getCurrentServer().ip;
|
||||
}
|
||||
public String getCurrentServerIp() { return mc.getCurrentServer().ip; }
|
||||
|
||||
@Override
|
||||
public String getCurrentServerVersion()
|
||||
@@ -182,13 +175,20 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
@Override
|
||||
public ILevelWrapper getWrappedClientWorld()
|
||||
{
|
||||
if (mc.level == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return ClientLevelWrapper.getWrapper(mc.level);
|
||||
}
|
||||
|
||||
/** Please move over to getInstallationDirectory() */
|
||||
@Deprecated
|
||||
@Override
|
||||
public File getGameDirectory()
|
||||
{
|
||||
return mc.gameDirectory;
|
||||
return getInstallationDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+14
@@ -34,6 +34,7 @@ import com.seibel.lod.common.wrappers.misc.LightMapWrapper;
|
||||
import com.seibel.lod.core.dependencyInjection.ModAccessorInjector;
|
||||
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.lod.core.render.glObject.GLProxy;
|
||||
import com.seibel.lod.core.wrapperInterfaces.misc.ILightMapWrapper;
|
||||
|
||||
import com.mojang.math.Vector3f;
|
||||
@@ -68,6 +69,7 @@ import net.minecraft.world.level.material.FogType;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
|
||||
/**
|
||||
@@ -193,6 +195,18 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
@Override
|
||||
public int getScreenWidth()
|
||||
{
|
||||
// alternate ways of getting the window's resolution,
|
||||
// using one of these methods may fix the optifine render resolution bug
|
||||
// TODO: test these once we can run with Optifine again
|
||||
// int[] heightArray = new int[1];
|
||||
// int[] widthArray = new int[1];
|
||||
//
|
||||
// long window = GLProxy.getInstance().minecraftGlContext;
|
||||
// GLFW.glfwGetWindowSize(window, widthArray, heightArray); // option 1
|
||||
// GLFW.glfwGetFramebufferSize(window, widthArray, heightArray); // option 2
|
||||
|
||||
|
||||
|
||||
int width = MC.getWindow().getWidth();
|
||||
if (OPTIFINE_ACCESSOR != null)
|
||||
{
|
||||
|
||||
@@ -18,6 +18,9 @@ import com.seibel.lod.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IServerLevelWrapper;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkSource;
|
||||
@@ -52,15 +55,44 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
||||
ClientBlockDetailMap blockMap = new ClientBlockDetailMap(this);
|
||||
@Nullable
|
||||
@Override
|
||||
public IServerLevelWrapper tryGetServerSideWrapper() {
|
||||
try {
|
||||
return ServerLevelWrapper.getWrapper(MinecraftClientWrapper.INSTANCE.mc.getSingleplayerServer().getPlayerList()
|
||||
.getPlayer(MinecraftClientWrapper.INSTANCE.mc.player.getUUID()).getLevel());
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Failed to get server side wrapper for client level {}.", level);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public IServerLevelWrapper tryGetServerSideWrapper()
|
||||
{
|
||||
try
|
||||
{
|
||||
// commented out because this breaks when traveling between dimensions,
|
||||
// serverPlayer.getLevel() will return the previously loaded level, which causes issues
|
||||
// PlayerList serverPlayerList = MinecraftClientWrapper.INSTANCE.mc.getSingleplayerServer().getPlayerList();
|
||||
// ServerPlayer serverPlayer = serverPlayerList.getPlayer(MinecraftClientWrapper.INSTANCE.mc.player.getUUID());
|
||||
// return ServerLevelWrapper.getWrapper(serverPlayer.getLevel());
|
||||
|
||||
|
||||
Iterable<ServerLevel> serverLevels = MinecraftClientWrapper.INSTANCE.mc.getSingleplayerServer().getAllLevels();
|
||||
|
||||
// attempt to find the server level with the same dimension type
|
||||
// TODO this assumes only one level per dimension type, the SubDimensionLevelMatcher will need to be added for supporting multiple levels per dimension
|
||||
ServerLevelWrapper foundLevelWrapper = null;
|
||||
for (ServerLevel serverLevel : serverLevels)
|
||||
{
|
||||
if (foundLevelWrapper != null)
|
||||
{
|
||||
LOGGER.warn("More than 1 level exists for a given dimension. Defaulting to the first level.");
|
||||
break;
|
||||
}
|
||||
|
||||
if (serverLevel.dimensionType() == this.level.dimensionType())
|
||||
{
|
||||
foundLevelWrapper = ServerLevelWrapper.getWrapper(serverLevel);
|
||||
}
|
||||
}
|
||||
|
||||
return foundLevelWrapper;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error("Failed to get server side wrapper for client level: "+level);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static void cleanCheck() {
|
||||
if (!levelWrapperMap.isEmpty()) {
|
||||
LOGGER.warn("{} client levels havn't been freed!", levelWrapperMap.size());
|
||||
|
||||
@@ -54,10 +54,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public class ServerLevelWrapper implements IServerLevelWrapper
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger(ServerLevelWrapper.class.getSimpleName());
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
private static final ConcurrentHashMap<ServerLevel, ServerLevelWrapper>
|
||||
levelWrapperMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
public static ServerLevelWrapper getWrapper(ServerLevel level)
|
||||
{
|
||||
return levelWrapperMap.computeIfAbsent(level, ServerLevelWrapper::new);
|
||||
@@ -66,12 +66,14 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
||||
{
|
||||
levelWrapperMap.remove(level);
|
||||
}
|
||||
public static void cleanCheck() {
|
||||
if (!levelWrapperMap.isEmpty()) {
|
||||
LOGGER.warn("{} server levels havn't been freed!", levelWrapperMap.size());
|
||||
levelWrapperMap.clear();
|
||||
}
|
||||
}
|
||||
public static void cleanCheck()
|
||||
{
|
||||
if (!levelWrapperMap.isEmpty())
|
||||
{
|
||||
LOGGER.warn(levelWrapperMap.size()+" server levels haven't been freed!");
|
||||
levelWrapperMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
final ServerLevel level;
|
||||
ServerBlockDetailMap blockMap = new ServerBlockDetailMap(this);
|
||||
@@ -82,15 +84,19 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public IClientLevelWrapper tryGetClientSideWrapper() {
|
||||
try {
|
||||
MinecraftClientWrapper client = MinecraftClientWrapper.INSTANCE;
|
||||
return ClientLevelWrapper.getWrapper(client.mc.level);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Failed to get client side wrapper for server level {}.", level);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public IClientLevelWrapper tryGetClientLevelWrapper()
|
||||
{
|
||||
try
|
||||
{
|
||||
MinecraftClientWrapper client = MinecraftClientWrapper.INSTANCE;
|
||||
return ClientLevelWrapper.getWrapper(client.mc.level);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error("Failed to get client side wrapper for server level "+level+".");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getSaveFolder()
|
||||
|
||||
+230
-162
@@ -17,11 +17,10 @@
|
||||
* 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.lod.common.wrappers.worldGeneration;
|
||||
|
||||
import com.seibel.lod.api.enums.worldGeneration.EDhApiDistantGeneratorMode;
|
||||
import com.seibel.lod.api.enums.worldGeneration.EDhApiWorldGenerationStep;
|
||||
import com.seibel.lod.common.wrappers.world.ServerLevelWrapper;
|
||||
import com.seibel.lod.core.level.IDhServerLevel;
|
||||
import com.seibel.lod.core.config.Config;
|
||||
@@ -34,7 +33,7 @@ import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.util.gridList.ArrayGridList;
|
||||
import com.seibel.lod.core.util.objects.LodThreadFactory;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvionmentWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvironmentWrapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -89,8 +88,7 @@ Carver Step: 0.000009923s
|
||||
Feature Step: 0.389072425s
|
||||
Lod Generation: 0.269023348s
|
||||
*/
|
||||
|
||||
public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnvionmentWrapper
|
||||
public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnvironmentWrapper
|
||||
{
|
||||
public static final ConfigBasedSpamLogger PREF_LOGGER =
|
||||
new ConfigBasedSpamLogger(LogManager.getLogger("LodWorldGen"),
|
||||
@@ -101,9 +99,9 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
public static final ConfigBasedLogger LOAD_LOGGER =
|
||||
new ConfigBasedLogger(LogManager.getLogger("LodWorldGen"),
|
||||
() -> Config.Client.Advanced.Debugging.DebugSwitch.logWorldGenLoadEvent.get());
|
||||
|
||||
|
||||
//TODO: Make actual proper support for StarLight
|
||||
|
||||
|
||||
public static class PerfCalculator
|
||||
{
|
||||
private static final String[] TIME_NAMES = {
|
||||
@@ -120,10 +118,10 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
"cleanup",
|
||||
//"lodCreation" (No longer used)
|
||||
};
|
||||
|
||||
|
||||
public static final int SIZE = 50;
|
||||
ArrayList<Rolling> times = new ArrayList<>();
|
||||
|
||||
|
||||
public PerfCalculator()
|
||||
{
|
||||
for(int i = 0; i < 11; i++)
|
||||
@@ -160,7 +158,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
|
||||
//=================Generation Step===================
|
||||
|
||||
public final LinkedList<GenerationEvent> events = new LinkedList<>();
|
||||
public final LinkedList<GenerationEvent> generationEventList = new LinkedList<>();
|
||||
public final GlobalParameters params;
|
||||
public final StepStructureStart stepStructureStart = new StepStructureStart(this);
|
||||
public final StepStructureReference stepStructureReference = new StepStructureReference(this);
|
||||
@@ -178,72 +176,114 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
public int unknownExceptionCount = 0;
|
||||
public long lastExceptionTriggerTime = 0;
|
||||
|
||||
public static final LodThreadFactory threadFactory = new LodThreadFactory("Gen-Worker-Thread", Thread.MIN_PRIORITY);
|
||||
public static final LodThreadFactory threadFactory = new LodThreadFactory("DH-Gen-Worker-Thread", Thread.MIN_PRIORITY);
|
||||
|
||||
public static ThreadLocal<Boolean> isDistantGeneratorThread = new ThreadLocal<>();
|
||||
|
||||
public static boolean isCurrentThreadDistantGeneratorThread() {
|
||||
return (isDistantGeneratorThread.get() != null);
|
||||
}
|
||||
|
||||
static {
|
||||
DependencySetupDoneCheck.getIsCurrentThreadDistantGeneratorThread = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread;
|
||||
}
|
||||
public static boolean isCurrentThreadDistantGeneratorThread() { return (isDistantGeneratorThread.get() != null); }
|
||||
|
||||
public ExecutorService executors = Executors.newFixedThreadPool(
|
||||
Math.max(Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.get().intValue(), 1),
|
||||
threadFactory);
|
||||
|
||||
public <T> T joinSync(CompletableFuture<T> f) {
|
||||
if (!unsafeThreadingRecorded && !f.isDone()) {
|
||||
|
||||
|
||||
|
||||
//==============//
|
||||
// constructors //
|
||||
//==============//
|
||||
|
||||
static
|
||||
{
|
||||
DependencySetupDoneCheck.getIsCurrentThreadDistantGeneratorThread = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread;
|
||||
}
|
||||
|
||||
public BatchGenerationEnvironment(IDhServerLevel serverlevel)
|
||||
{
|
||||
super(serverlevel);
|
||||
EVENT_LOGGER.info("================WORLD_GEN_STEP_INITING=============");
|
||||
|
||||
ChunkGenerator generator = ((ServerLevelWrapper) (serverlevel.getServerLevelWrapper())).getLevel().getChunkSource().getGenerator();
|
||||
if (!(generator instanceof NoiseBasedChunkGenerator ||
|
||||
generator instanceof DebugLevelSource ||
|
||||
generator instanceof FlatLevelSource))
|
||||
{
|
||||
if (generator.getClass().toString().equals("class com.terraforged.mod.chunk.TFChunkGenerator"))
|
||||
{
|
||||
EVENT_LOGGER.info("TerraForge Chunk Generator detected: ["+generator.getClass()+"], Distant Generation will try its best to support it.");
|
||||
EVENT_LOGGER.info("If it does crash, turn Distant Generation off or set it to to "+EDhApiWorldGenerationStep.EMPTY+".");
|
||||
}
|
||||
else
|
||||
{
|
||||
EVENT_LOGGER.warn("Unknown Chunk Generator detected: ["+generator.getClass()+"], Distant Generation May Fail!");
|
||||
EVENT_LOGGER.warn("If it does crash, set Distant Generation to OFF or Generation Mode to None.");
|
||||
}
|
||||
}
|
||||
|
||||
params = new GlobalParameters(serverlevel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public <T> T joinSync(CompletableFuture<T> future)
|
||||
{
|
||||
if (!unsafeThreadingRecorded && !future.isDone())
|
||||
{
|
||||
EVENT_LOGGER.error("Unsafe Threading in Chunk Generator: ", new RuntimeException("Concurrent future"));
|
||||
EVENT_LOGGER.error("To increase stability, it is recommended to set world generation threads count to 1.");
|
||||
unsafeThreadingRecorded = true;
|
||||
}
|
||||
return f.join();
|
||||
|
||||
return future.join();
|
||||
}
|
||||
|
||||
public void resizeThreadPool(int newThreadCount)
|
||||
{
|
||||
executors = Executors.newFixedThreadPool(newThreadCount,
|
||||
new LodThreadFactory("Gen-Worker-Thread", Thread.MIN_PRIORITY));
|
||||
}
|
||||
|
||||
public void resizeThreadPool(int newThreadCount) { executors = Executors.newFixedThreadPool(newThreadCount, new LodThreadFactory("DH-Gen-Worker-Thread", Thread.MIN_PRIORITY)); }
|
||||
|
||||
public void updateAllFutures()
|
||||
{
|
||||
if (unknownExceptionCount > 0) {
|
||||
if (System.nanoTime() - lastExceptionTriggerTime >= EXCEPTION_TIMER_RESET_TIME) {
|
||||
if (unknownExceptionCount > 0)
|
||||
{
|
||||
if (System.nanoTime() - lastExceptionTriggerTime >= EXCEPTION_TIMER_RESET_TIME)
|
||||
{
|
||||
unknownExceptionCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update all current out standing jobs
|
||||
Iterator<GenerationEvent> iter = events.iterator();
|
||||
Iterator<GenerationEvent> iter = generationEventList.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
GenerationEvent event = iter.next();
|
||||
if (event.future.isDone())
|
||||
{
|
||||
if (event.future.isCompletedExceptionally() && !event.future.isCancelled()) {
|
||||
try {
|
||||
if (event.future.isCompletedExceptionally() && !event.future.isCancelled())
|
||||
{
|
||||
try
|
||||
{
|
||||
event.future.get(); // Should throw exception
|
||||
LodUtil.assertNotReach();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
unknownExceptionCount++;
|
||||
lastExceptionTriggerTime = System.nanoTime();
|
||||
EVENT_LOGGER.error("Batching World Generator: Event {} gotten an exception", event);
|
||||
EVENT_LOGGER.error("Exception: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
iter.remove();
|
||||
}
|
||||
else if (event.hasTimeout(TIMEOUT_SECONDS, TimeUnit.SECONDS))
|
||||
{
|
||||
EVENT_LOGGER.error("Batching World Generator: " + event + " timed out and terminated!");
|
||||
EVENT_LOGGER.info("Dump PrefEvent: " + event.timer);
|
||||
try {
|
||||
try
|
||||
{
|
||||
if (!event.terminate())
|
||||
{
|
||||
EVENT_LOGGER.error("Failed to terminate the stuck generation event!");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -251,34 +291,14 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (unknownExceptionCount > EXCEPTION_COUNTER_TRIGGER) {
|
||||
EVENT_LOGGER.error("Too many exceptions in Batching World Generator! Disabling the generator.");
|
||||
unknownExceptionCount = 0;
|
||||
Config.Client.WorldGenerator.enableDistantGeneration.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
public BatchGenerationEnvironment(IDhServerLevel serverlevel)
|
||||
{
|
||||
super(serverlevel);
|
||||
EVENT_LOGGER.info("================WORLD_GEN_STEP_INITING=============");
|
||||
ChunkGenerator generator = ((ServerLevelWrapper) (serverlevel.getServerLevelWrapper())).getLevel().getChunkSource().getGenerator();
|
||||
if (!(generator instanceof NoiseBasedChunkGenerator ||
|
||||
generator instanceof DebugLevelSource ||
|
||||
generator instanceof FlatLevelSource)) {
|
||||
if (generator.getClass().toString().equals("class com.terraforged.mod.chunk.TFChunkGenerator")) {
|
||||
EVENT_LOGGER.info("TerraForge Chunk Generator detected: [{}], Distant Generation will try its best to support it.", generator.getClass());
|
||||
EVENT_LOGGER.info("If it does crash, set Distant Generation to OFF or Generation Mode to None.");
|
||||
} else {
|
||||
EVENT_LOGGER.warn("Unknown Chunk Generator detected: [{}], Distant Generation May Fail!", generator.getClass());
|
||||
EVENT_LOGGER.warn("If it does crash, set Distant Generation to OFF or Generation Mode to None.");
|
||||
}
|
||||
}
|
||||
params = new GlobalParameters(serverlevel);
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public static ChunkAccess loadOrMakeChunk(ChunkPos chunkPos, ServerLevel level, LevelLightEngine lightEngine)
|
||||
{
|
||||
CompoundTag chunkData = null;
|
||||
@@ -294,6 +314,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
{
|
||||
LOAD_LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e);
|
||||
}
|
||||
|
||||
if (chunkData == null)
|
||||
{
|
||||
return new ProtoChunk(chunkPos, UpgradeData.EMPTY
|
||||
@@ -303,38 +324,40 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
}
|
||||
else
|
||||
{
|
||||
try {
|
||||
return ChunkLoader.read(level, lightEngine, chunkPos, chunkData);
|
||||
} catch (Exception e) {
|
||||
try
|
||||
{
|
||||
return ChunkLoader.read(level, lightEngine, chunkPos, chunkData);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOAD_LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e);
|
||||
return new ProtoChunk(chunkPos, UpgradeData.EMPTY
|
||||
#if POST_MC_1_17_1, level #endif
|
||||
#if POST_MC_1_18_1, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null #endif
|
||||
#if POST_MC_1_17_1 , level #endif
|
||||
#if POST_MC_1_18_1 , level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null #endif
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void generateLodFromList(GenerationEvent e)
|
||||
public void generateLodFromList(GenerationEvent genEvent)
|
||||
{
|
||||
EVENT_LOGGER.debug("Lod Generate Event: " + e.minPos);
|
||||
EVENT_LOGGER.debug("Lod Generate Event: "+genEvent.minPos);
|
||||
|
||||
ArrayGridList<ChunkAccess> referencedChunks;
|
||||
ArrayGridList<ChunkAccess> genChunks;
|
||||
EDhApiDistantGeneratorMode generatorDetail;
|
||||
LightedWorldGenRegion region;
|
||||
WorldGenLevelLightEngine lightEngine;
|
||||
LightGetterAdaptor adaptor;
|
||||
int refSize = e.size+2; // +2 for the border referenced chunks
|
||||
int refPosX = e.minPos.x - 1; // -1 for the border referenced chunks
|
||||
int refPosZ = e.minPos.z - 1; // -1 for the border referenced chunks
|
||||
|
||||
|
||||
int refSize = genEvent.size+2; // +2 for the border referenced chunks
|
||||
int refPosX = genEvent.minPos.x - 1; // -1 for the border referenced chunks
|
||||
int refPosZ = genEvent.minPos.z - 1; // -1 for the border referenced chunks
|
||||
|
||||
try
|
||||
{
|
||||
adaptor = new LightGetterAdaptor(params.level);
|
||||
lightEngine = new WorldGenLevelLightEngine(adaptor);
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
|
||||
EmptyChunkGenerator generator = (int x, int z) ->
|
||||
{
|
||||
ChunkPos chunkPos = new ChunkPos(x, z);
|
||||
@@ -347,43 +370,46 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
{
|
||||
// Continue...
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
target = new ProtoChunk(chunkPos, UpgradeData.EMPTY
|
||||
#if POST_MC_1_17_1, params.level #endif
|
||||
#if POST_MC_1_18_1, params.biomes, null #endif
|
||||
#if POST_MC_1_17_1 , params.level #endif
|
||||
#if POST_MC_1_18_1 , params.biomes, null #endif
|
||||
);
|
||||
}
|
||||
return target;
|
||||
};
|
||||
|
||||
referencedChunks = new ArrayGridList<>(refSize,
|
||||
(x,z) -> generator.generate(x + refPosX,z + refPosZ)
|
||||
);
|
||||
e.refreshTimeout();
|
||||
|
||||
referencedChunks = new ArrayGridList<>(refSize, (x,z) -> generator.generate(x + refPosX,z + refPosZ));
|
||||
|
||||
genEvent.refreshTimeout();
|
||||
region = new LightedWorldGenRegion(params.level, lightEngine, referencedChunks,
|
||||
ChunkStatus.STRUCTURE_STARTS, refSize/2, e.lightMode, generator);
|
||||
ChunkStatus.STRUCTURE_STARTS, refSize/2, genEvent.lightMode, generator);
|
||||
adaptor.setRegion(region);
|
||||
e.tParam.makeStructFeat(region, params);
|
||||
genEvent.threadedParam.makeStructFeat(region, params);
|
||||
genChunks = new ArrayGridList<>(referencedChunks, RANGE_TO_RANGE_EMPTY_EXTENSION,
|
||||
referencedChunks.gridSize - RANGE_TO_RANGE_EMPTY_EXTENSION);
|
||||
generateDirect(e, genChunks, e.target, region);
|
||||
e.timer.nextEvent("cleanup");
|
||||
generateDirect(genEvent, genChunks, genEvent.targetGenerationStep, region);
|
||||
genEvent.timer.nextEvent("cleanup");
|
||||
}
|
||||
catch (StepStructureStart.StructStartCorruptedException f)
|
||||
{
|
||||
e.tParam.markAsInvalid();
|
||||
genEvent.threadedParam.markAsInvalid();
|
||||
throw (RuntimeException)f.getCause();
|
||||
}
|
||||
|
||||
for (int oy = 0; oy < genChunks.gridSize; oy++)
|
||||
|
||||
for (int offsetY = 0; offsetY < genChunks.gridSize; offsetY++)
|
||||
{
|
||||
for (int ox = 0; ox < genChunks.gridSize; ox++)
|
||||
for (int offsetX = 0; offsetX < genChunks.gridSize; offsetX++)
|
||||
{
|
||||
ChunkAccess target = genChunks.get(ox, oy);
|
||||
ChunkAccess target = genChunks.get(offsetX, offsetY);
|
||||
ChunkWrapper wrappedChunk = new ChunkWrapper(target, region, null);
|
||||
if (!wrappedChunk.isLightCorrect()) {
|
||||
if (!wrappedChunk.isLightCorrect())
|
||||
{
|
||||
throw new RuntimeException("The generated chunk somehow has isLightCorrect() returning false");
|
||||
}
|
||||
|
||||
|
||||
boolean isFull = target.getStatus() == ChunkStatus.FULL || target instanceof LevelChunk;
|
||||
#if POST_MC_1_18_1
|
||||
boolean isPartial = target.isOldNoiseGeneration();
|
||||
@@ -391,147 +417,189 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
if (isFull)
|
||||
{
|
||||
LOAD_LOGGER.info("Detected full existing chunk at {}", target.getPos());
|
||||
e.resultConsumer.accept(wrappedChunk);
|
||||
genEvent.resultConsumer.accept(wrappedChunk);
|
||||
}
|
||||
#if POST_MC_1_18_1
|
||||
else if (isPartial)
|
||||
{
|
||||
LOAD_LOGGER.info("Detected old existing chunk at {}", target.getPos());
|
||||
e.resultConsumer.accept(wrappedChunk);
|
||||
genEvent.resultConsumer.accept(wrappedChunk);
|
||||
}
|
||||
#endif
|
||||
else if (target.getStatus() == ChunkStatus.EMPTY)
|
||||
{
|
||||
e.resultConsumer.accept(wrappedChunk);
|
||||
genEvent.resultConsumer.accept(wrappedChunk);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.resultConsumer.accept(wrappedChunk);
|
||||
genEvent.resultConsumer.accept(wrappedChunk);
|
||||
}
|
||||
if (e.lightMode == ELightGenerationMode.FANCY || isFull)
|
||||
if (genEvent.lightMode == ELightGenerationMode.FANCY || isFull)
|
||||
{
|
||||
lightEngine.retainData(target.getPos(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
e.timer.complete();
|
||||
e.refreshTimeout();
|
||||
|
||||
genEvent.timer.complete();
|
||||
genEvent.refreshTimeout();
|
||||
if (PREF_LOGGER.canMaybeLog())
|
||||
{
|
||||
e.tParam.perf.recordEvent(e.timer);
|
||||
PREF_LOGGER.infoInc("{}", e.timer);
|
||||
genEvent.threadedParam.perf.recordEvent(genEvent.timer);
|
||||
PREF_LOGGER.infoInc("{}", genEvent.timer);
|
||||
}
|
||||
}
|
||||
|
||||
public void generateDirect(GenerationEvent e, ArrayGridList<ChunkAccess> subRange,
|
||||
Steps step, LightedWorldGenRegion region)
|
||||
public void generateDirect(GenerationEvent genEvent, ArrayGridList<ChunkAccess> chunksToGenerate,
|
||||
EDhApiWorldGenerationStep step, LightedWorldGenRegion region)
|
||||
{
|
||||
try
|
||||
{
|
||||
subRange.forEach((chunk) ->
|
||||
chunksToGenerate.forEach((chunk) ->
|
||||
{
|
||||
if (chunk instanceof ProtoChunk)
|
||||
{
|
||||
((ProtoChunk) chunk).setLightEngine(region.getLightEngine());
|
||||
region.getLightEngine().retainData(chunk.getPos(), true);
|
||||
ProtoChunk protoChunk = ((ProtoChunk) chunk);
|
||||
|
||||
protoChunk.setLightEngine(region.getLightEngine());
|
||||
region.getLightEngine().retainData(protoChunk.getPos(), true);
|
||||
}
|
||||
});
|
||||
if (step == Steps.Empty)
|
||||
|
||||
if (step == EDhApiWorldGenerationStep.EMPTY)
|
||||
{
|
||||
return;
|
||||
e.timer.nextEvent("structStart");
|
||||
stepStructureStart.generateGroup(e.tParam, region, subRange);
|
||||
e.refreshTimeout();
|
||||
if (step == Steps.StructureStart)
|
||||
}
|
||||
|
||||
genEvent.timer.nextEvent("structStart");
|
||||
stepStructureStart.generateGroup(genEvent.threadedParam, region, chunksToGenerate);
|
||||
genEvent.refreshTimeout();
|
||||
if (step == EDhApiWorldGenerationStep.STRUCTURE_START)
|
||||
{
|
||||
return;
|
||||
e.timer.nextEvent("structRef");
|
||||
stepStructureReference.generateGroup(e.tParam, region, subRange);
|
||||
e.refreshTimeout();
|
||||
if (step == Steps.StructureReference)
|
||||
}
|
||||
|
||||
genEvent.timer.nextEvent("structRef");
|
||||
stepStructureReference.generateGroup(genEvent.threadedParam, region, chunksToGenerate);
|
||||
genEvent.refreshTimeout();
|
||||
if (step == EDhApiWorldGenerationStep.STRUCTURE_REFERENCE)
|
||||
{
|
||||
return;
|
||||
e.timer.nextEvent("biome");
|
||||
stepBiomes.generateGroup(e.tParam, region, subRange);
|
||||
e.refreshTimeout();
|
||||
if (step == Steps.Biomes)
|
||||
}
|
||||
|
||||
genEvent.timer.nextEvent("biome");
|
||||
stepBiomes.generateGroup(genEvent.threadedParam, region, chunksToGenerate);
|
||||
genEvent.refreshTimeout();
|
||||
if (step == EDhApiWorldGenerationStep.BIOMES)
|
||||
{
|
||||
return;
|
||||
e.timer.nextEvent("noise");
|
||||
stepNoise.generateGroup(e.tParam, region, subRange);
|
||||
e.refreshTimeout();
|
||||
if (step == Steps.Noise)
|
||||
}
|
||||
|
||||
genEvent.timer.nextEvent("noise");
|
||||
stepNoise.generateGroup(genEvent.threadedParam, region, chunksToGenerate);
|
||||
genEvent.refreshTimeout();
|
||||
if (step == EDhApiWorldGenerationStep.NOISE)
|
||||
{
|
||||
return;
|
||||
e.timer.nextEvent("surface");
|
||||
stepSurface.generateGroup(e.tParam, region, subRange);
|
||||
e.refreshTimeout();
|
||||
if (step == Steps.Surface)
|
||||
}
|
||||
|
||||
genEvent.timer.nextEvent("surface");
|
||||
stepSurface.generateGroup(genEvent.threadedParam, region, chunksToGenerate);
|
||||
genEvent.refreshTimeout();
|
||||
if (step == EDhApiWorldGenerationStep.SURFACE)
|
||||
{
|
||||
return;
|
||||
e.timer.nextEvent("carver");
|
||||
if (step == Steps.Carvers)
|
||||
}
|
||||
|
||||
genEvent.timer.nextEvent("carver");
|
||||
if (step == EDhApiWorldGenerationStep.CARVERS)
|
||||
{
|
||||
return;
|
||||
e.timer.nextEvent("feature");
|
||||
stepFeatures.generateGroup(e.tParam, region, subRange);
|
||||
e.refreshTimeout();
|
||||
}
|
||||
|
||||
genEvent.timer.nextEvent("feature");
|
||||
stepFeatures.generateGroup(genEvent.threadedParam, region, chunksToGenerate);
|
||||
genEvent.refreshTimeout();
|
||||
}
|
||||
finally
|
||||
{
|
||||
e.timer.nextEvent("light");
|
||||
genEvent.timer.nextEvent("light");
|
||||
switch (region.lightMode)
|
||||
{
|
||||
case FANCY:
|
||||
stepLight.generateGroup(region.getLightEngine(), subRange);
|
||||
stepLight.generateGroup(region.getLightEngine(), chunksToGenerate);
|
||||
break;
|
||||
case FAST:
|
||||
subRange.forEach((p) ->
|
||||
chunksToGenerate.forEach((chunk) ->
|
||||
{
|
||||
if (p instanceof ProtoChunk)
|
||||
((ProtoChunk) p).setLightCorrect(true);
|
||||
if (chunk instanceof ProtoChunk)
|
||||
{
|
||||
chunk.setLightCorrect(true); // TODO why are we checking instanceof ProtoChunk?
|
||||
}
|
||||
|
||||
#if POST_MC_1_18_1
|
||||
if (p instanceof LevelChunk) {
|
||||
((LevelChunk) p).setLightCorrect(true);
|
||||
((LevelChunk) p).setClientLightReady(true);
|
||||
if (chunk instanceof LevelChunk)
|
||||
{
|
||||
LevelChunk levelChunk = (LevelChunk) chunk;
|
||||
levelChunk.setLightCorrect(true);
|
||||
levelChunk.setClientLightReady(true);
|
||||
}
|
||||
#endif
|
||||
});
|
||||
break;
|
||||
}
|
||||
e.refreshTimeout();
|
||||
genEvent.refreshTimeout();
|
||||
}
|
||||
}
|
||||
|
||||
public interface EmptyChunkGenerator
|
||||
public interface EmptyChunkGenerator { ChunkAccess generate(int x, int z); }
|
||||
|
||||
@Override
|
||||
public int getEventCount() { return this.generationEventList.size(); }
|
||||
|
||||
@Override
|
||||
public void stop(boolean blocking)
|
||||
{
|
||||
ChunkAccess generate(int x, int z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEventCount() {
|
||||
return events.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(boolean blocking) {
|
||||
EVENT_LOGGER.info("Batch Chunk Generator shutting down...");
|
||||
EVENT_LOGGER.info(BatchGenerationEnvironment.class.getSimpleName()+" shutting down...");
|
||||
|
||||
EVENT_LOGGER.info("Canceling futures...");
|
||||
executors.shutdownNow();
|
||||
Iterator<GenerationEvent> iter = events.iterator();
|
||||
Iterator<GenerationEvent> iter = this.generationEventList.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
GenerationEvent event = iter.next();
|
||||
event.future.cancel(true);
|
||||
iter.remove();
|
||||
}
|
||||
if (blocking) try {
|
||||
if (!executors.awaitTermination(10, TimeUnit.SECONDS)) {
|
||||
EVENT_LOGGER.error("Batch Chunk Generator shutdown failed! Ignoring child threads...");
|
||||
|
||||
EVENT_LOGGER.info("Awaiting termination...");
|
||||
if (blocking)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!executors.awaitTermination(3, TimeUnit.SECONDS))
|
||||
{
|
||||
EVENT_LOGGER.error("Batch Chunk Generator shutdown failed! Ignoring child threads...");
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
EVENT_LOGGER.error("Batch Chunk Generator shutdown failed! Ignoring child threads...", e);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
EVENT_LOGGER.error("Batch Chunk Generator shutdown failed! Ignoring child threads...", e);
|
||||
}
|
||||
|
||||
EVENT_LOGGER.info(BatchGenerationEnvironment.class.getSimpleName()+" shutdown complete.");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> generateChunks(int minX, int minZ, int genSize, Steps targetStep, double runTimeRatio, Consumer<IChunkWrapper> resultConsumer)
|
||||
public CompletableFuture<Void> generateChunks(int minX, int minZ, int genSize, EDhApiWorldGenerationStep targetStep, double runTimeRatio, Consumer<IChunkWrapper> resultConsumer)
|
||||
{
|
||||
//System.out.println("GenerationEvent: "+genSize+"@"+minX+","+minZ+" "+targetStep);
|
||||
|
||||
// TODO: Check event overlap via e.tooClose()
|
||||
GenerationEvent e = GenerationEvent.startEvent(new DhChunkPos(minX, minZ), genSize, this, targetStep, runTimeRatio, resultConsumer);
|
||||
events.add(e);
|
||||
return e.future;
|
||||
GenerationEvent genEvent = GenerationEvent.startEvent(new DhChunkPos(minX, minZ), genSize, this, targetStep, runTimeRatio, resultConsumer);
|
||||
generationEventList.add(genEvent);
|
||||
return genEvent.future;
|
||||
}
|
||||
|
||||
}
|
||||
+73
-56
@@ -16,7 +16,7 @@
|
||||
* 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.lod.common.wrappers.worldGeneration;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
@@ -24,6 +24,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.seibel.lod.api.enums.worldGeneration.EDhApiWorldGenerationStep;
|
||||
import com.seibel.lod.core.util.objects.UncheckedInterruptedException;
|
||||
import com.seibel.lod.core.config.Config;
|
||||
import com.seibel.lod.api.enums.config.ELightGenerationMode;
|
||||
@@ -31,20 +32,19 @@ import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.lod.core.pos.DhChunkPos;
|
||||
import com.seibel.lod.core.util.objects.EventTimer;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvionmentWrapper.Steps;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
//======================= Main Event class======================
|
||||
public final class GenerationEvent
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName());
|
||||
private static int generationFutureDebugIDs = 0;
|
||||
|
||||
final int id;
|
||||
final ThreadedParameters tParam;
|
||||
final ThreadedParameters threadedParam;
|
||||
final DhChunkPos minPos;
|
||||
final int size;
|
||||
final Steps target;
|
||||
final EDhApiWorldGenerationStep targetGenerationStep;
|
||||
final ELightGenerationMode lightMode;
|
||||
final double runTimeRatio;
|
||||
EventTimer timer = null;
|
||||
@@ -52,93 +52,110 @@ public final class GenerationEvent
|
||||
long timeoutTime = -1;
|
||||
public CompletableFuture<Void> future = null;
|
||||
final Consumer<IChunkWrapper> resultConsumer;
|
||||
|
||||
|
||||
|
||||
|
||||
public GenerationEvent(DhChunkPos minPos, int size, BatchGenerationEnvironment generationGroup,
|
||||
Steps target, double runTimeRatio, Consumer<IChunkWrapper> resultConsumer) {
|
||||
inQueueTime = System.nanoTime();
|
||||
EDhApiWorldGenerationStep targetGenerationStep, double runTimeRatio, Consumer<IChunkWrapper> resultConsumer)
|
||||
{
|
||||
this.inQueueTime = System.nanoTime();
|
||||
this.id = generationFutureDebugIDs++;
|
||||
this.minPos = minPos;
|
||||
this.size = size;
|
||||
this.target = target;
|
||||
this.tParam = ThreadedParameters.getOrMake(generationGroup.params);
|
||||
this.targetGenerationStep = targetGenerationStep;
|
||||
this.threadedParam = ThreadedParameters.getOrMake(generationGroup.params);
|
||||
this.lightMode = Config.Client.WorldGenerator.lightGenerationMode.get();
|
||||
this.runTimeRatio = runTimeRatio;
|
||||
this.resultConsumer = resultConsumer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static GenerationEvent startEvent(DhChunkPos minPos, int size, BatchGenerationEnvironment generationGroup,
|
||||
Steps target, double runTimeRatio, Consumer<IChunkWrapper> resultConsumer)
|
||||
EDhApiWorldGenerationStep target, double runTimeRatio, Consumer<IChunkWrapper> resultConsumer)
|
||||
{
|
||||
if (size % 2 == 0) size += 1; // size must be odd for vanilla world gen region to work
|
||||
GenerationEvent event = new GenerationEvent(minPos, size, generationGroup, target, runTimeRatio, resultConsumer);
|
||||
event.future = CompletableFuture.runAsync(() ->
|
||||
if (size % 2 == 0)
|
||||
{
|
||||
size += 1; // size must be odd for vanilla world gen regions to work
|
||||
}
|
||||
|
||||
GenerationEvent generationEvent = new GenerationEvent(minPos, size, generationGroup, target, runTimeRatio, resultConsumer);
|
||||
generationEvent.future = CompletableFuture.runAsync(() ->
|
||||
{
|
||||
long runStartTime = System.nanoTime();
|
||||
generationEvent.timeoutTime = runStartTime;
|
||||
generationEvent.inQueueTime = runStartTime - generationEvent.inQueueTime;
|
||||
generationEvent.timer = new EventTimer("setup");
|
||||
BatchGenerationEnvironment.isDistantGeneratorThread.set(true);
|
||||
try
|
||||
{
|
||||
//LOGGER.info("generating [{}]", event.minPos);
|
||||
generationGroup.generateLodFromList(generationEvent);
|
||||
}
|
||||
finally
|
||||
{
|
||||
BatchGenerationEnvironment.isDistantGeneratorThread.remove();
|
||||
if (!Thread.interrupted() && runTimeRatio < 1.0)
|
||||
{
|
||||
long runStartTime = System.nanoTime();
|
||||
event.timeoutTime = runStartTime;
|
||||
event.inQueueTime = runStartTime - event.inQueueTime;
|
||||
event.timer = new EventTimer("setup");
|
||||
BatchGenerationEnvironment.isDistantGeneratorThread.set(true);
|
||||
try {
|
||||
generationGroup.generateLodFromList(event);
|
||||
} finally {
|
||||
BatchGenerationEnvironment.isDistantGeneratorThread.remove();
|
||||
if (!Thread.interrupted() && runTimeRatio < 1.0) {
|
||||
long endTime = System.nanoTime();
|
||||
try {
|
||||
long deltaMs = TimeUnit.NANOSECONDS.toMillis(endTime - runStartTime);
|
||||
Thread.sleep((long) (deltaMs/runTimeRatio - deltaMs));
|
||||
} catch (InterruptedException ignored) {}
|
||||
}
|
||||
long endTime = System.nanoTime();
|
||||
try
|
||||
{
|
||||
long deltaMs = TimeUnit.NANOSECONDS.toMillis(endTime - runStartTime);
|
||||
Thread.sleep((long) (deltaMs / runTimeRatio - deltaMs));
|
||||
}
|
||||
}, generationGroup.executors);
|
||||
return event;
|
||||
catch (InterruptedException ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}, generationGroup.executors);
|
||||
return generationEvent;
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
return future.isDone();
|
||||
}
|
||||
|
||||
|
||||
public boolean isComplete() { return this.future.isDone(); }
|
||||
|
||||
public boolean hasTimeout(int duration, TimeUnit unit)
|
||||
{
|
||||
if (timeoutTime == -1) return false;
|
||||
if (this.timeoutTime == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
long currentTime = System.nanoTime();
|
||||
long delta = currentTime - timeoutTime;
|
||||
long delta = currentTime - this.timeoutTime;
|
||||
return (delta > TimeUnit.NANOSECONDS.convert(duration, unit));
|
||||
}
|
||||
|
||||
|
||||
public boolean terminate()
|
||||
{
|
||||
LOGGER.info("======================DUMPING ALL THREADS FOR WORLD GEN=======================");
|
||||
BatchGenerationEnvironment.threadFactory.dumpAllThreadStacks();
|
||||
future.cancel(true);
|
||||
return future.isCancelled();
|
||||
this.future.cancel(true);
|
||||
return this.future.isCancelled();
|
||||
}
|
||||
|
||||
public boolean tooClose(int minX, int minZ, int w)
|
||||
public boolean tooClose(int minX, int minZ, int width)
|
||||
{
|
||||
int aMinX = minPos.x;
|
||||
int aMinZ = minPos.z;
|
||||
int aSize = size;
|
||||
int aMinX = this.minPos.x;
|
||||
int aMinZ = this.minPos.z;
|
||||
int aSize = this.size;
|
||||
// Account for required empty chunks in the border
|
||||
aSize += 1;
|
||||
w+= 1;
|
||||
width += 1;
|
||||
// Do a AABB to AABB intersection test
|
||||
return (aMinX + aSize >= minX &&
|
||||
aMinX <= minX + w &&
|
||||
aMinX <= minX + width &&
|
||||
aMinZ + aSize >= minZ &&
|
||||
aMinZ <= minZ + w);
|
||||
aMinZ <= minZ + width);
|
||||
}
|
||||
|
||||
public void refreshTimeout()
|
||||
{
|
||||
timeoutTime = System.nanoTime();
|
||||
this.timeoutTime = System.nanoTime();
|
||||
UncheckedInterruptedException.throwIfInterrupted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return id + ":" + size + "@" + minPos + "(" + target + ")";
|
||||
}
|
||||
public String toString() { return this.id+":"+this.size+"@"+this.minPos+"("+this.targetGenerationStep +")"; }
|
||||
|
||||
}
|
||||
+42
-16
@@ -25,55 +25,81 @@ import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.WorldGenStruct
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
#if POST_MC_1_18_1
|
||||
import net.minecraft.world.level.levelgen.structure.StructureCheck;
|
||||
#endif
|
||||
|
||||
public final class ThreadedParameters
|
||||
{
|
||||
private static final ThreadLocal<ThreadedParameters> localParam = new ThreadLocal<ThreadedParameters>();
|
||||
private static final ThreadLocal<ThreadedParameters> LOCAL_PARAM = new ThreadLocal<>();
|
||||
|
||||
final ServerLevel level;
|
||||
public WorldGenStructFeatManager structFeat = null;
|
||||
#if POST_MC_1_18_1
|
||||
public final StructureCheck structCheck;
|
||||
public StructureCheck structCheck;
|
||||
#endif
|
||||
boolean isValid = true;
|
||||
public final PerfCalculator perf = new PerfCalculator();
|
||||
|
||||
private static GlobalParameters previousGlobalParameters = null;
|
||||
|
||||
|
||||
|
||||
public static ThreadedParameters getOrMake(GlobalParameters param)
|
||||
{
|
||||
ThreadedParameters tParam = localParam.get();
|
||||
ThreadedParameters tParam = LOCAL_PARAM.get();
|
||||
if (tParam != null && tParam.isValid && tParam.level == param.level)
|
||||
{
|
||||
return tParam;
|
||||
}
|
||||
|
||||
tParam = new ThreadedParameters(param);
|
||||
localParam.set(tParam);
|
||||
LOCAL_PARAM.set(tParam);
|
||||
return tParam;
|
||||
}
|
||||
|
||||
public void markAsInvalid()
|
||||
{
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
private ThreadedParameters(GlobalParameters param)
|
||||
{
|
||||
level = param.level;
|
||||
previousGlobalParameters = param;
|
||||
|
||||
this.level = param.level;
|
||||
#if PRE_MC_1_18_1
|
||||
structFeat = new WorldGenStructFeatManager(param.worldGenSettings, level);
|
||||
this.structFeat = new WorldGenStructFeatManager(param.worldGenSettings, level);
|
||||
#elif PRE_MC_1_19
|
||||
structCheck = new StructureCheck(param.chunkScanner, param.registry, param.structures,
|
||||
param.level.dimension(), param.generator, level, param.generator.getBiomeSource(), param.worldSeed,
|
||||
param.fixerUpper);
|
||||
this.structCheck = this.createStructureCheck(param);
|
||||
#else
|
||||
structCheck = new StructureCheck(param.chunkScanner, param.registry, param.structures,
|
||||
this.structCheck = new StructureCheck(param.chunkScanner, param.registry, param.structures,
|
||||
param.level.dimension(), param.generator, param.randomState, level, param.generator.getBiomeSource(), param.worldSeed,
|
||||
param.fixerUpper);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void markAsInvalid() { isValid = false; }
|
||||
|
||||
public void makeStructFeat(WorldGenLevel genLevel, GlobalParameters param)
|
||||
{
|
||||
structFeat = new WorldGenStructFeatManager(param.worldGenSettings, genLevel #if POST_MC_1_18_1, structCheck #endif);
|
||||
}
|
||||
|
||||
|
||||
#if PRE_MC_1_19
|
||||
public void recreateStructureCheck()
|
||||
{
|
||||
if (previousGlobalParameters != null)
|
||||
{
|
||||
this.structCheck = createStructureCheck(previousGlobalParameters);
|
||||
}
|
||||
}
|
||||
private StructureCheck createStructureCheck(GlobalParameters param)
|
||||
{
|
||||
return new StructureCheck(param.chunkScanner, param.registry, param.structures,
|
||||
param.level.dimension(), param.generator, this.level, param.generator.getBiomeSource(), param.worldSeed,
|
||||
param.fixerUpper);
|
||||
}
|
||||
#else
|
||||
public void recreateStructureCheck() { /* do nothing */ }
|
||||
#endif
|
||||
|
||||
}
|
||||
+40
-16
@@ -19,21 +19,24 @@
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public final class StepStructureStart {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final class StepStructureStart
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
private final BatchGenerationEnvironment environment;
|
||||
|
||||
/**
|
||||
@@ -57,14 +60,17 @@ public final class StepStructureStart {
|
||||
}
|
||||
|
||||
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
|
||||
List<ChunkAccess> chunks) {
|
||||
|
||||
ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
|
||||
List<ChunkAccess> chunks)
|
||||
{
|
||||
ArrayList<ChunkAccess> chunksToDo = new ArrayList<>();
|
||||
|
||||
for (ChunkAccess chunk : chunks) {
|
||||
if (chunk.getStatus().isOrAfter(STATUS)) continue;
|
||||
((ProtoChunk) chunk).setStatus(STATUS);
|
||||
chunksToDo.add(chunk);
|
||||
for (ChunkAccess chunk : chunks)
|
||||
{
|
||||
if (!chunk.getStatus().isOrAfter(STATUS))
|
||||
{
|
||||
((ProtoChunk) chunk).setStatus(STATUS);
|
||||
chunksToDo.add(chunk);
|
||||
}
|
||||
}
|
||||
|
||||
#if PRE_MC_1_19
|
||||
@@ -72,7 +78,8 @@ public final class StepStructureStart {
|
||||
#elif POST_MC_1_19
|
||||
if (environment.params.worldGenSettings.generateStructures()) {
|
||||
#endif
|
||||
for (ChunkAccess chunk : chunksToDo) {
|
||||
for (ChunkAccess chunk : chunksToDo)
|
||||
{
|
||||
// System.out.println("StepStructureStart: "+chunk.getPos());
|
||||
#if PRE_MC_1_19
|
||||
environment.params.generator.createStructures(environment.params.registry, tParams.structFeat, chunk, environment.params.structures,
|
||||
@@ -82,14 +89,31 @@ public final class StepStructureStart {
|
||||
environment.params.worldSeed);
|
||||
#endif
|
||||
#if POST_MC_1_18_1
|
||||
try {
|
||||
try
|
||||
{
|
||||
tParams.structCheck.onStructureLoad(chunk.getPos(), chunk.getAllStarts());
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException firstEx)
|
||||
{
|
||||
// There's a rare issue with StructStart where it throws ArrayIndexOutOfBounds
|
||||
// This means the structFeat is corrupted (For some reason) and I need to reset it.
|
||||
// TODO: Figure out in the future why this happens even though I am using new structFeat - OLD
|
||||
// TODO: Is this still a problem?
|
||||
throw new StepStructureStart.StructStartCorruptedException(e);
|
||||
|
||||
// reset the structureStart
|
||||
tParams.recreateStructureCheck();
|
||||
|
||||
try
|
||||
{
|
||||
// try running the structure logic again
|
||||
tParams.structCheck.onStructureLoad(chunk.getPos(), chunk.getAllStarts());
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException secondEx)
|
||||
{
|
||||
// the structure logic failed again, log it and move on
|
||||
LOGGER.error("Unable to create structure starts for "+chunk.getPos()+". This is an error with MC's world generation. Ignoring and continuing generation. Error: "+secondEx.getMessage()); // don't log the full stack trace since it is long and will generally end up in MC's code
|
||||
|
||||
//throw new StepStructureStart.StructStartCorruptedException(secondEx);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public final class StepSurface {
|
||||
|
||||
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
|
||||
List<ChunkAccess> chunks) {
|
||||
ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
|
||||
ArrayList<ChunkAccess> chunksToDo = new ArrayList<>();
|
||||
|
||||
for (ChunkAccess chunk : chunks) {
|
||||
if (chunk.getStatus().isOrAfter(STATUS)) continue;
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"accessWidener": "lod.accesswidener"
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
## Contributing
|
||||
|
||||
Thanks for your interest in contributing to Distant Horizons!
|
||||
|
||||
Check out the [Core Wiki](https://gitlab.com/jeseibel/distant-horizons-core/-/wikis/home) for a rough overview of Distant Horizon's project structure.
|
||||
|
||||
|
||||
|
||||
## Submitting a merge request
|
||||
|
||||
We love merge requests from everyone.
|
||||
|
||||
By sending a merge request, you agree to abide by the Distant Horizons [Contributor Code of Conduct](code_of_conduct.md). \
|
||||
Contributions to this project are under the [lesser GPL v3 license](LICENSE.txt) Copyright James Seibel, so please include the [license header](license_header.txt) at the top of any new code files.
|
||||
|
||||
1. Fork, then clone the repo: \
|
||||
`git clone --recurse-submodules https://gitlab.com/jeseibel/minecraft-lod-mod.git`
|
||||
|
||||
2. Set up your dev environment: \
|
||||
`./gradlew build`
|
||||
|
||||
3. (Optional) Confirm the tests pass: \
|
||||
`./gradlew test`
|
||||
|
||||
4. (Optional) Confirm the game runs with either Forge or Fabric: \
|
||||
`./gradlew forge:runClient` \
|
||||
`./gradlew fabric:runClient`
|
||||
|
||||
5. Make your change(s).
|
||||
6. Add tests (if appropriate).
|
||||
|
||||
7. Confirm the tests pass \
|
||||
`./gradlew test`
|
||||
|
||||
8. Confirm the game runs with both Forge **and** Fabric: \
|
||||
`./gradlew forge:runClient` \
|
||||
`./gradlew fabric:runClient` \
|
||||
When running the game, load or generate a world to confirm Distant Horizons initializes correctly.
|
||||
|
||||
9. Push to your fork, make sure to include the Core submodule, and submit a [new merge request](https://gitlab.com/jeseibel/minecraft-lod-mod/-/merge_requests/new).
|
||||
|
||||
|
||||
|
||||
## General Guidelines
|
||||
|
||||
* Check the existing issue list to verify that a given [bug](https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/?sort=created_date&state=opened&label_name%5B%5D=Bug&first_page_size=100), [feature](https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/?sort=created_date&state=opened&label_name%5B%5D=Feature&first_page_size=100), or [improvement](https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/?sort=created_date&state=opened&label_name%5B%5D=Improvement&first_page_size=100) hasn't already been submitted.
|
||||
* Please open an issue if things aren't working as expected.
|
||||
* Open a merge request to: fix bugs, fix documentations, improve an existing system, or complete a feature.
|
||||
* When contributing:
|
||||
* Put any Minecraft independent code in the [Core](https://gitlab.com/jeseibel/distant-horizons-core) repo when possible.
|
||||
* Comment and format your code so other people can easily understand it.
|
||||
|
||||
+1
-1
Submodule coreSubProjects updated: c3c170d07a...64a1120be2
+52
-61
@@ -1,21 +1,33 @@
|
||||
version = rootProject.versionStr
|
||||
|
||||
architectury {
|
||||
platformSetupLoomIde()
|
||||
fabric()
|
||||
plugins {
|
||||
id "fabric-loom" version "1.1-SNAPSHOT"
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = project(":common").loom.accessWidenerPath
|
||||
accessWidenerPath = project(":common").file("src/main/resources/${accessWidenerVersion}.lod.accesswidener")
|
||||
|
||||
// "runs" isn't required, but when we do need it then it can be useful
|
||||
runs {
|
||||
client {
|
||||
client()
|
||||
setConfigName("Fabric Client")
|
||||
ideConfigGenerated(true)
|
||||
runDir("run")
|
||||
}
|
||||
server {
|
||||
server()
|
||||
setConfigName("Fabric Server")
|
||||
ideConfigGenerated(true)
|
||||
runDir("run")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
remapJar {
|
||||
// Set the input jar for the task, also valid for remapSourcesJar
|
||||
inputFile = project(":fabric").file("build/libs/DistantHorizons-fabric-${rootProject.versionStr}-all.jar")
|
||||
}
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentFabric.extendsFrom common
|
||||
|
||||
// The addModJar basically embeds the mod to the built jar
|
||||
addModJar
|
||||
include.extendsFrom addModJar
|
||||
@@ -30,17 +42,18 @@ def addMod(path, enabled) {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${minecraft_version}"
|
||||
mappings loom.layered() {
|
||||
// Mojmap mappings
|
||||
officialMojangMappings()
|
||||
// Parchment mappings (it adds parameter mappings & javadoc)
|
||||
parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip")
|
||||
}
|
||||
// Fabric loader
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
|
||||
// Architectury API
|
||||
if (minecraft_version == "1.16.5") {
|
||||
addModJar("me.shedaniel:architectury-fabric:${rootProject.architectury_version}")
|
||||
} else {
|
||||
addModJar("dev.architectury:architectury-fabric:${rootProject.architectury_version}")
|
||||
}
|
||||
|
||||
// Fabric API
|
||||
addModJar(fabricApi.module("fabric-events-interaction-v0", rootProject.fabric_api_version))
|
||||
addModJar(fabricApi.module("fabric-lifecycle-events-v1", rootProject.fabric_api_version))
|
||||
addModJar(fabricApi.module("fabric-key-binding-api-v1", rootProject.fabric_api_version))
|
||||
addModJar(fabricApi.module("fabric-resource-loader-v0", rootProject.fabric_api_version))
|
||||
@@ -50,6 +63,8 @@ dependencies {
|
||||
// Mod Menu
|
||||
modImplementation("com.terraformersmc:modmenu:${rootProject.modmenu_version}")
|
||||
|
||||
|
||||
|
||||
// Starlight
|
||||
addMod("curse.maven:starlight-521783:${rootProject.starlight_version_fabric}", rootProject.enable_starlight)
|
||||
|
||||
@@ -91,40 +106,8 @@ dependencies {
|
||||
transitive(false)
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
exclude "architectury.common.json"
|
||||
|
||||
configurations = [project.configurations.shadowCommon, project.configurations.shadowMe, project.configurations.customModule]
|
||||
|
||||
// Compression
|
||||
relocate 'org.tukaani', 'distanthorizons.libraries.tukaani'
|
||||
relocate 'org.apache.commons.compress', 'distanthorizons.libraries.apache.commons.compress'
|
||||
|
||||
// NightConfig (includes Toml & Json)
|
||||
relocate 'com.electronwill.nightconfig', 'distanthorizons.libraries.electronwill.nightconfig'
|
||||
|
||||
// Theming
|
||||
relocate 'com.formdev.flatlaf', 'distanthorizons.libraries.formdev.flatlaf'
|
||||
|
||||
// SVG
|
||||
relocate 'com.kitfox.svg', 'distanthorizons.libraries.kitfox.svg'
|
||||
|
||||
classifier "dev-shadow"
|
||||
mergeServiceFiles()
|
||||
}
|
||||
|
||||
remapJar {
|
||||
injectAccessWidener = true
|
||||
input.set shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
classifier null
|
||||
}
|
||||
|
||||
task deleteResources(type: Delete) {
|
||||
delete file("build/resources/main")
|
||||
@@ -132,34 +115,42 @@ task deleteResources(type: Delete) {
|
||||
|
||||
processResources {
|
||||
dependsOn(copyCoreResources)
|
||||
dependsOn(copyCommonLoaderResources)
|
||||
dependsOn(deleteDuplicatedCommonLoaderResources)
|
||||
}
|
||||
|
||||
runClient {
|
||||
dependsOn(copyCoreResources)
|
||||
dependsOn(copyCommonLoaderResources)
|
||||
dependsOn(deleteDuplicatedCommonLoaderResources)
|
||||
jvmArgs "-XX:-OmitStackTraceInFastThrow"
|
||||
finalizedBy(deleteResources)
|
||||
}
|
||||
|
||||
jar {
|
||||
classifier "dev"
|
||||
}
|
||||
//jar {
|
||||
// classifier "dev"
|
||||
//}
|
||||
|
||||
sourcesJar {
|
||||
def commonSources = project(":common").sourcesJar
|
||||
dependsOn commonSources
|
||||
from commonSources.archiveFile.map { zipTree(it) }
|
||||
|
||||
def fabricLikeSources = project(":fabricLike").sourcesJar
|
||||
dependsOn fabricLikeSources
|
||||
from fabricLikeSources.archiveFile.map { zipTree(it) }
|
||||
}
|
||||
|
||||
components.java {
|
||||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||
skip()
|
||||
}
|
||||
}
|
||||
//components.java {
|
||||
// withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||
// skip()
|
||||
// }
|
||||
//}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenFabric(MavenPublication) {
|
||||
artifactId = rootProject.archives_base_name + "-" + project.name
|
||||
artifactId = rootProject.mod_name + "-" + project.name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
@@ -168,4 +159,4 @@ publishing {
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.seibel.lod;
|
||||
|
||||
import com.seibel.lod.common.wrappers.DependencySetup;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class FabricClientMain implements ClientModInitializer {
|
||||
public static FabricClientProxy client_proxy;
|
||||
public static FabricServerProxy server_proxy;
|
||||
|
||||
|
||||
// Do if implements ClientModInitializer
|
||||
// This loads the mod before minecraft loads which causes a lot of issues
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
DependencySetup.createClientBindings();
|
||||
FabricMain.init();
|
||||
|
||||
server_proxy = new FabricServerProxy(false);
|
||||
server_proxy.registerEvents();
|
||||
client_proxy = new FabricClientProxy();
|
||||
client_proxy.registerEvents();
|
||||
|
||||
ClientLifecycleEvents.CLIENT_STARTED.register((mc) -> FabricMain.postInit());
|
||||
}
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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.lod;
|
||||
|
||||
import com.seibel.lod.common.wrappers.McObjectConverter;
|
||||
import com.seibel.lod.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.lod.core.api.internal.ClientApi;
|
||||
import com.seibel.lod.core.config.Config;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
|
||||
import com.seibel.lod.core.dependencyInjection.ModAccessorInjector;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
import com.seibel.lod.wrappers.modAccessor.SodiumAccessor;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
/**
|
||||
* This handles all events sent to the client,
|
||||
* and is the starting point for most of the mod.
|
||||
*
|
||||
* @author coolGi
|
||||
* @author Ran
|
||||
* @version 11-23-2021
|
||||
*/
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class FabricClientProxy
|
||||
{
|
||||
private final ClientApi clientApi = ClientApi.INSTANCE;
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger("FabricClientProxy");
|
||||
|
||||
/**
|
||||
* Registers Fabric Events
|
||||
* @author Ran
|
||||
*/
|
||||
public void registerEvents() {
|
||||
LOGGER.info("Registering Fabric Client Events");
|
||||
|
||||
|
||||
/* Register the mod needed event callbacks */
|
||||
|
||||
// ClientTickEvent
|
||||
ClientTickEvents.START_CLIENT_TICK.register((client) -> {
|
||||
//LOGGER.info("ClientTickEvent.START_CLIENT_TICK");
|
||||
ClientApi.INSTANCE.clientTickEvent();
|
||||
});
|
||||
|
||||
// ClientLevelLoadEvent - Done in MixinClientPacketListener
|
||||
// ClientLevelUnloadEvent - Done in MixinClientPacketListener
|
||||
|
||||
// ClientChunkLoadEvent
|
||||
// TODO: Is using setClientLightReady one still better?
|
||||
//#if PRE_MC_1_18_1 // in 1.18+, we use mixin hook in setClientLightReady(true)
|
||||
ClientChunkEvents.CHUNK_LOAD.register((level, chunk) ->
|
||||
{
|
||||
ClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper(level);
|
||||
ClientApi.INSTANCE.clientChunkLoadEvent(
|
||||
new ChunkWrapper(chunk, level, wrappedLevel),
|
||||
wrappedLevel
|
||||
);
|
||||
});
|
||||
//#endif
|
||||
// ClientChunkSaveEvent
|
||||
ClientChunkEvents.CHUNK_UNLOAD.register((level, chunk) ->
|
||||
{
|
||||
ClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper(level);
|
||||
ClientApi.INSTANCE.clientChunkSaveEvent(
|
||||
new ChunkWrapper(chunk, level, wrappedLevel),
|
||||
wrappedLevel
|
||||
);
|
||||
});
|
||||
|
||||
// RendererStartupEvent - Done in MixinGameRenderer
|
||||
// RendererShutdownEvent - Done in MixinGameRenderer
|
||||
|
||||
SodiumAccessor sodiumAccessor = (SodiumAccessor) ModAccessorInjector.INSTANCE.get(ISodiumAccessor.class);
|
||||
|
||||
// ClientRenderLevelTerrainEvent
|
||||
WorldRenderEvents.AFTER_SETUP.register((renderContext) -> {
|
||||
if (sodiumAccessor != null) {
|
||||
sodiumAccessor.levelWrapper = ClientLevelWrapper.getWrapper(renderContext.world());
|
||||
sodiumAccessor.mcModelViewMatrix = McObjectConverter.Convert(renderContext.matrixStack().last().pose());
|
||||
sodiumAccessor.mcProjectionMatrix = McObjectConverter.Convert(renderContext.projectionMatrix());
|
||||
sodiumAccessor.partialTicks = renderContext.tickDelta();
|
||||
} else {
|
||||
clientApi.renderLods(ClientLevelWrapper.getWrapper(renderContext.world()),
|
||||
McObjectConverter.Convert(renderContext.matrixStack().last().pose()),
|
||||
McObjectConverter.Convert(renderContext.projectionMatrix()),
|
||||
renderContext.tickDelta());
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Debug keyboard event
|
||||
// FIXME: Use better hooks so it doesn't trigger even in text boxes
|
||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||
if (client.player != null && isValidTime()) onKeyInput();
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isValidTime() {
|
||||
return !(Minecraft.getInstance().screen instanceof TitleScreen);
|
||||
}
|
||||
|
||||
// public void blockChangeEvent(LevelAccessor world, BlockPos pos) {
|
||||
// if (!isValidTime()) return;
|
||||
// IChunkWrapper chunk = new ChunkWrapper(world.getChunk(pos), world);
|
||||
// DimensionTypeWrapper dimType = DimensionTypeWrapper.getDimensionTypeWrapper(world.dimensionType());
|
||||
//
|
||||
// // recreate the LOD where the blocks were changed
|
||||
// // TODO: serverApi.blockChangeEvent(chunk, dimType);
|
||||
// }
|
||||
|
||||
private static final int[] KEY_TO_CHECK_FOR = {GLFW.GLFW_KEY_F6, GLFW.GLFW_KEY_F8};
|
||||
|
||||
HashSet<Integer> previousKeyDown = new HashSet<>();
|
||||
|
||||
public void onKeyInput() {
|
||||
if (Config.Client.Advanced.Debugging.enableDebugKeybindings.get())
|
||||
{
|
||||
HashSet<Integer> currentKeyDown = new HashSet<Integer>();
|
||||
|
||||
// Note: Minecraft's InputConstants is same as GLFW Key values
|
||||
//TODO: Use mixin to hook directly into the GLFW Keyboard event in minecraft KeyboardHandler
|
||||
// Check all keys we need
|
||||
for (int i = GLFW.GLFW_KEY_A; i <= GLFW.GLFW_KEY_Z; i++) {
|
||||
if (InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), i)) {
|
||||
currentKeyDown.add(i);
|
||||
}
|
||||
}
|
||||
for (int i : KEY_TO_CHECK_FOR) {
|
||||
if (InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), i)) {
|
||||
currentKeyDown.add(i);
|
||||
}
|
||||
}
|
||||
// Diff and trigger events
|
||||
for (int c : currentKeyDown) {
|
||||
if (!previousKeyDown.contains(c)) {
|
||||
ClientApi.INSTANCE.keyPressedEvent(c);
|
||||
}
|
||||
}
|
||||
// Update the set
|
||||
previousKeyDown = currentKeyDown;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
package com.seibel.lod;
|
||||
|
||||
import com.seibel.lod.common.networking.Networking;
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.lod.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.lod.common.wrappers.world.ServerLevelWrapper;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.core.api.internal.ServerApi;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* This handles all events sent to the server,
|
||||
* and is the starting point for most of the mod.
|
||||
*
|
||||
* @author Ran
|
||||
* @author Tomlee
|
||||
* @version 5-11-2022
|
||||
*/
|
||||
|
||||
public class FabricServerProxy {
|
||||
private final ServerApi serverApi = ServerApi.INSTANCE;
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger("FabricServerProxy");
|
||||
private final boolean isDedicated;
|
||||
public static Supplier<Boolean> isGenerationThreadChecker = null;
|
||||
|
||||
public FabricServerProxy(boolean isDedicated) {
|
||||
this.isDedicated = isDedicated;
|
||||
}
|
||||
|
||||
private boolean isValidTime() {
|
||||
if (isDedicated) return true;
|
||||
|
||||
//FIXME: This may cause init issue...
|
||||
return !(Minecraft.getInstance().screen instanceof TitleScreen);
|
||||
}
|
||||
private ClientLevelWrapper getLevelWrapper(ClientLevel level) {
|
||||
return ClientLevelWrapper.getWrapper(level);
|
||||
}
|
||||
private ServerLevelWrapper getLevelWrapper(ServerLevel level) {
|
||||
return ServerLevelWrapper.getWrapper(level);
|
||||
}
|
||||
/**
|
||||
* Registers Fabric Events
|
||||
* @author Ran, Tomlee
|
||||
*/
|
||||
public void registerEvents() {
|
||||
LOGGER.info("Registering Fabric Server Events");
|
||||
isGenerationThreadChecker = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread;
|
||||
|
||||
/* Register the mod needed event callbacks */
|
||||
|
||||
// TEST EVENT
|
||||
//ServerTickEvents.END_SERVER_TICK.register(this::tester);
|
||||
|
||||
// ServerTickEvent
|
||||
ServerTickEvents.END_SERVER_TICK.register((server) -> serverApi.serverTickEvent());
|
||||
|
||||
// ServerWorldLoadEvent
|
||||
//TODO: Check if both of this use the correct timed events. (i.e. is it 'ed' or 'ing' one?)
|
||||
ServerLifecycleEvents.SERVER_STARTING.register((server) -> {
|
||||
if (isValidTime()) ServerApi.INSTANCE.serverWorldLoadEvent(isDedicated);
|
||||
});
|
||||
// ServerWorldUnloadEvent
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register((server) -> {
|
||||
if (isValidTime()) ServerApi.INSTANCE.serverWorldUnloadEvent();
|
||||
});
|
||||
|
||||
// ServerLevelLoadEvent
|
||||
ServerWorldEvents.LOAD.register((server, level)
|
||||
-> {
|
||||
if (isValidTime()) ServerApi.INSTANCE.serverLevelLoadEvent(getLevelWrapper(level));
|
||||
});
|
||||
// ServerLevelUnloadEvent
|
||||
ServerWorldEvents.UNLOAD.register((server, level)
|
||||
-> {
|
||||
if (isValidTime()) ServerApi.INSTANCE.serverLevelUnloadEvent(getLevelWrapper(level));
|
||||
});
|
||||
|
||||
// ServerChunkLoadEvent
|
||||
ServerChunkEvents.CHUNK_LOAD.register((server, chunk)
|
||||
-> {
|
||||
ILevelWrapper level = getLevelWrapper((ServerLevel) chunk.getLevel());
|
||||
if (isValidTime()) ServerApi.INSTANCE.serverChunkLoadEvent(
|
||||
new ChunkWrapper(chunk, chunk.getLevel(), level),
|
||||
level);
|
||||
}
|
||||
);
|
||||
// ServerChunkSaveEvent - Done in MixinChunkMap
|
||||
}
|
||||
|
||||
// This just exists here for testing purposes, it'll be removed in the future
|
||||
public void tester(MinecraftServer server) {
|
||||
for (ServerPlayer player : server.getPlayerList().getPlayers()) {
|
||||
FriendlyByteBuf payload = Networking.createNew();
|
||||
payload.writeInt(1);
|
||||
System.out.println("Sending int 1");
|
||||
Networking.send(player, payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.seibel.lod.fabric;
|
||||
|
||||
import com.seibel.lod.common.wrappers.DependencySetup;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class FabricClientMain implements ClientModInitializer
|
||||
{
|
||||
public static FabricClientProxy client_proxy;
|
||||
public static FabricServerProxy server_proxy;
|
||||
|
||||
|
||||
// Do if implements ClientModInitializer
|
||||
// This loads the mod before minecraft loads which causes a lot of issues
|
||||
@Override
|
||||
public void onInitializeClient()
|
||||
{
|
||||
DependencySetup.createClientBindings();
|
||||
FabricMain.init();
|
||||
|
||||
server_proxy = new FabricServerProxy(false);
|
||||
server_proxy.registerEvents();
|
||||
|
||||
client_proxy = new FabricClientProxy();
|
||||
client_proxy.registerEvents();
|
||||
|
||||
ClientLifecycleEvents.CLIENT_STARTED.register((mc) -> FabricMain.postInit());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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.lod.fabric;
|
||||
|
||||
import com.seibel.lod.common.wrappers.McObjectConverter;
|
||||
import com.seibel.lod.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.lod.core.api.internal.ClientApi;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
|
||||
import com.seibel.lod.core.dependencyInjection.ModAccessorInjector;
|
||||
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
import com.seibel.lod.fabric.wrappers.modAccessor.SodiumAccessor;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
|
||||
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
|
||||
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
/**
|
||||
* This handles all events sent to the client,
|
||||
* and is the starting point for most of the mod.
|
||||
*
|
||||
* @author coolGi
|
||||
* @author Ran
|
||||
* @version 11-23-2021
|
||||
*/
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class FabricClientProxy
|
||||
{
|
||||
private final ClientApi clientApi = ClientApi.INSTANCE;
|
||||
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
// TODO we shouldn't be filtering keys on the Forge/Fabric side, only in ClientApi
|
||||
private static final int[] KEY_TO_CHECK_FOR = { GLFW.GLFW_KEY_F6, GLFW.GLFW_KEY_F8, GLFW.GLFW_KEY_P};
|
||||
|
||||
HashSet<Integer> previouslyPressKeyCodes = new HashSet<>();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Registers Fabric Events
|
||||
* @author Ran
|
||||
*/
|
||||
public void registerEvents()
|
||||
{
|
||||
LOGGER.info("Registering Fabric Client Events");
|
||||
|
||||
|
||||
/* Register the mod needed event callbacks */
|
||||
|
||||
// ClientTickEvent
|
||||
ClientTickEvents.START_CLIENT_TICK.register((client) ->
|
||||
{
|
||||
//LOGGER.info("ClientTickEvent.START_CLIENT_TICK");
|
||||
ClientApi.INSTANCE.clientTickEvent();
|
||||
});
|
||||
|
||||
// ClientLevelLoadEvent - Done in MixinClientPacketListener
|
||||
// ClientLevelUnloadEvent - Done in MixinClientPacketListener
|
||||
|
||||
// ClientChunkLoadEvent
|
||||
// TODO: Is using setClientLightReady one still better?
|
||||
//#if PRE_MC_1_18_1 // in 1.18+, we use mixin hook in setClientLightReady(true)
|
||||
ClientChunkEvents.CHUNK_LOAD.register((level, chunk) ->
|
||||
{
|
||||
ClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper(level);
|
||||
ClientApi.INSTANCE.clientChunkLoadEvent(
|
||||
new ChunkWrapper(chunk, level, wrappedLevel),
|
||||
wrappedLevel
|
||||
);
|
||||
});
|
||||
|
||||
// (kinda) block break event
|
||||
AttackBlockCallback.EVENT.register((player, level, interactionHand, blockPos, direction) ->
|
||||
{
|
||||
// if we have access to the server, use the chunk save event instead
|
||||
if (MC.clientConnectedToDedicatedServer())
|
||||
{
|
||||
// Since fabric doesn't have a client-side break-block API event, this is the next best thing
|
||||
ChunkAccess chunk = level.getChunk(blockPos);
|
||||
if (chunk != null)
|
||||
{
|
||||
// LOGGER.info("attack block at blockpos: " + blockPos);
|
||||
|
||||
ClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper((ClientLevel) level);
|
||||
ClientApi.INSTANCE.clientChunkLoadEvent(
|
||||
new ChunkWrapper(chunk, level, wrappedLevel),
|
||||
wrappedLevel
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// don't stop the callback
|
||||
return InteractionResult.PASS;
|
||||
});
|
||||
|
||||
// (kinda) block place event
|
||||
UseBlockCallback.EVENT.register((player, level, hand, hitResult) ->
|
||||
{
|
||||
// if we have access to the server, use the chunk save event instead
|
||||
if (MC.clientConnectedToDedicatedServer())
|
||||
{
|
||||
// Since fabric doesn't have a client-side place-block API event, this is the next best thing
|
||||
if (hitResult.getType() == HitResult.Type.BLOCK
|
||||
&& !hitResult.isInside())
|
||||
{
|
||||
ChunkAccess chunk = level.getChunk(hitResult.getBlockPos());
|
||||
if (chunk != null)
|
||||
{
|
||||
// LOGGER.info("use block at blockpos: " + hitResult.getBlockPos());
|
||||
|
||||
ClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper((ClientLevel) level);
|
||||
ClientApi.INSTANCE.clientChunkLoadEvent(
|
||||
new ChunkWrapper(chunk, level, wrappedLevel),
|
||||
wrappedLevel
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// don't stop the callback
|
||||
return InteractionResult.PASS;
|
||||
});
|
||||
|
||||
//#endif
|
||||
// ClientChunkSaveEvent
|
||||
ClientChunkEvents.CHUNK_UNLOAD.register((level, chunk) ->
|
||||
{
|
||||
ClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper(level);
|
||||
ClientApi.INSTANCE.clientChunkSaveEvent(
|
||||
new ChunkWrapper(chunk, level, wrappedLevel),
|
||||
wrappedLevel
|
||||
);
|
||||
});
|
||||
|
||||
// RendererStartupEvent - Done in MixinGameRenderer
|
||||
// RendererShutdownEvent - Done in MixinGameRenderer
|
||||
|
||||
SodiumAccessor sodiumAccessor = (SodiumAccessor) ModAccessorInjector.INSTANCE.get(ISodiumAccessor.class);
|
||||
|
||||
// ClientRenderLevelTerrainEvent
|
||||
WorldRenderEvents.AFTER_SETUP.register((renderContext) ->
|
||||
{
|
||||
if (sodiumAccessor != null)
|
||||
{
|
||||
sodiumAccessor.levelWrapper = ClientLevelWrapper.getWrapper(renderContext.world());
|
||||
sodiumAccessor.mcModelViewMatrix = McObjectConverter.Convert(renderContext.matrixStack().last().pose());
|
||||
sodiumAccessor.mcProjectionMatrix = McObjectConverter.Convert(renderContext.projectionMatrix());
|
||||
sodiumAccessor.partialTicks = renderContext.tickDelta();
|
||||
}
|
||||
else
|
||||
{
|
||||
clientApi.renderLods(ClientLevelWrapper.getWrapper(renderContext.world()),
|
||||
McObjectConverter.Convert(renderContext.matrixStack().last().pose()),
|
||||
McObjectConverter.Convert(renderContext.projectionMatrix()),
|
||||
renderContext.tickDelta());
|
||||
}
|
||||
});
|
||||
|
||||
// Debug keyboard event
|
||||
// FIXME: Use better hooks so it doesn't trigger even in text boxes
|
||||
ClientTickEvents.END_CLIENT_TICK.register(client ->
|
||||
{
|
||||
if (client.player != null && isValidTime())
|
||||
{
|
||||
onKeyInput();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isValidTime() { return !(Minecraft.getInstance().screen instanceof TitleScreen); }
|
||||
|
||||
// public void blockChangeEvent(LevelAccessor world, BlockPos pos) {
|
||||
// if (!isValidTime()) return;
|
||||
// IChunkWrapper chunk = new ChunkWrapper(world.getChunk(pos), world);
|
||||
// DimensionTypeWrapper dimType = DimensionTypeWrapper.getDimensionTypeWrapper(world.dimensionType());
|
||||
//
|
||||
// // recreate the LOD where the blocks were changed
|
||||
// // TODO: serverApi.blockChangeEvent(chunk, dimType);
|
||||
// }
|
||||
|
||||
public void onKeyInput()
|
||||
{
|
||||
HashSet<Integer> currentKeyDown = new HashSet<>();
|
||||
|
||||
// Note: Minecraft's InputConstants is same as GLFW Key values
|
||||
//TODO: Use mixin to hook directly into the GLFW Keyboard event in minecraft KeyboardHandler
|
||||
// Check all keys we need
|
||||
for (int keyCode = GLFW.GLFW_KEY_A; keyCode <= GLFW.GLFW_KEY_Z; keyCode++)
|
||||
{
|
||||
if (InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), keyCode))
|
||||
{
|
||||
currentKeyDown.add(keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
for (int keyCode : KEY_TO_CHECK_FOR)
|
||||
{
|
||||
if (InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), keyCode))
|
||||
{
|
||||
currentKeyDown.add(keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
// Diff and trigger events
|
||||
for (int keyCode : currentKeyDown)
|
||||
{
|
||||
if (!previouslyPressKeyCodes.contains(keyCode))
|
||||
{
|
||||
ClientApi.INSTANCE.keyPressedEvent(keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the set
|
||||
previouslyPressKeyCodes = currentKeyDown;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.seibel.lod.fabric;
|
||||
|
||||
import com.seibel.lod.common.wrappers.DependencySetup;
|
||||
import com.seibel.lod.common.wrappers.minecraft.MinecraftDedicatedServerWrapper;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import net.fabricmc.api.DedicatedServerModInitializer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@Environment(EnvType.SERVER)
|
||||
public class FabricDedicatedServerMain implements DedicatedServerModInitializer
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger(FabricDedicatedServerMain.class.getSimpleName());
|
||||
|
||||
public static FabricServerProxy server_proxy;
|
||||
public boolean hasPostSetupDone = false;
|
||||
|
||||
@Override
|
||||
public void onInitializeServer() {
|
||||
DependencySetup.createServerBindings();
|
||||
FabricMain.init();
|
||||
|
||||
server_proxy = new FabricServerProxy(true);
|
||||
server_proxy.registerEvents();
|
||||
|
||||
ServerLifecycleEvents.SERVER_STARTING.register((server) -> {
|
||||
if (hasPostSetupDone) return;
|
||||
hasPostSetupDone = true;
|
||||
LodUtil.assertTrue(server instanceof DedicatedServer);
|
||||
MinecraftDedicatedServerWrapper.INSTANCE.dedicatedServer = (DedicatedServer) server;
|
||||
FabricMain.postInit();
|
||||
LOGGER.info("Dedicated server inited at {}", server.getServerDirectory());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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.lod.fabric;
|
||||
|
||||
import com.seibel.lod.api.methods.events.abstractEvents.DhApiAfterDhInitEvent;
|
||||
import com.seibel.lod.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent;
|
||||
import com.seibel.lod.common.LodCommonMain;
|
||||
import com.seibel.lod.core.ModInfo;
|
||||
import com.seibel.lod.core.config.Config;
|
||||
import com.seibel.lod.core.DependencyInjection.ApiEventInjector;
|
||||
import com.seibel.lod.core.dependencyInjection.ModAccessorInjector;
|
||||
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.*;
|
||||
import com.seibel.lod.fabric.wrappers.modAccessor.BCLibAccessor;
|
||||
import com.seibel.lod.fabric.wrappers.modAccessor.OptifineAccessor;
|
||||
import com.seibel.lod.fabric.wrappers.modAccessor.SodiumAccessor;
|
||||
import com.seibel.lod.fabric.wrappers.modAccessor.StarlightAccessor;
|
||||
import com.seibel.lod.fabric.wrappers.FabricDependencySetup;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Initialize and setup the Mod. <br>
|
||||
* If you are looking for the real start of the mod
|
||||
* check out the ClientProxy.
|
||||
*
|
||||
* @author coolGi
|
||||
* @author Ran
|
||||
* @version 9-2-2022
|
||||
*/
|
||||
public class FabricMain
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
public static void postInit() {
|
||||
LOGGER.info("Post-Initializing Mod");
|
||||
FabricDependencySetup.runDelayedSetup();
|
||||
|
||||
if (Config.Client.Graphics.FogQuality.disableVanillaFog.get() && SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("bclib"))
|
||||
ModAccessorInjector.INSTANCE.get(IBCLibAccessor.class).setRenderCustomFog(false); // Remove BCLib's fog
|
||||
|
||||
LOGGER.info("Mod Post-Initialized");
|
||||
}
|
||||
|
||||
|
||||
// This loads the mod after minecraft loads which doesn't causes a lot of issues
|
||||
public static void init()
|
||||
{
|
||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeDhInitEvent.class, null);
|
||||
|
||||
LOGGER.info("Initializing Mod");
|
||||
LodCommonMain.startup(null);
|
||||
FabricDependencySetup.createInitialBindings();
|
||||
LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION);
|
||||
|
||||
if (SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("sodium")) {
|
||||
ModAccessorInjector.INSTANCE.bind(ISodiumAccessor.class, new SodiumAccessor());
|
||||
}
|
||||
if (SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("starlight")) {
|
||||
ModAccessorInjector.INSTANCE.bind(IStarlightAccessor.class, new StarlightAccessor());
|
||||
}
|
||||
if (SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("optifine")) {
|
||||
ModAccessorInjector.INSTANCE.bind(IOptifineAccessor.class, new OptifineAccessor());
|
||||
}
|
||||
if (SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("bclib")) {
|
||||
ModAccessorInjector.INSTANCE.bind(IBCLibAccessor.class, new BCLibAccessor());
|
||||
}
|
||||
LOGGER.info(ModInfo.READABLE_NAME + " Initialized");
|
||||
|
||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterDhInitEvent.class, null);
|
||||
|
||||
// Init config
|
||||
// The reason im initialising in this rather than the post init process is cus im using this for the auto updater
|
||||
LodCommonMain.initConfig();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.seibel.lod.fabric;
|
||||
|
||||
import com.seibel.lod.common.networking.Networking;
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.lod.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.lod.common.wrappers.world.ServerLevelWrapper;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.core.api.internal.ServerApi;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* This handles all events sent to the server,
|
||||
* and is the starting point for most of the mod.
|
||||
*
|
||||
* @author Ran
|
||||
* @author Tomlee
|
||||
* @version 5-11-2022
|
||||
*/
|
||||
public class FabricServerProxy
|
||||
{
|
||||
private static final ServerApi SERVER_API = ServerApi.INSTANCE;
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
private final boolean isDedicated;
|
||||
public static Supplier<Boolean> isGenerationThreadChecker = null;
|
||||
|
||||
|
||||
|
||||
public FabricServerProxy(boolean isDedicated)
|
||||
{
|
||||
this.isDedicated = isDedicated;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private boolean isValidTime()
|
||||
{
|
||||
if (isDedicated)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//FIXME: This may cause init issue...
|
||||
return !(Minecraft.getInstance().screen instanceof TitleScreen);
|
||||
}
|
||||
|
||||
private ClientLevelWrapper getClientLevelWrapper(ClientLevel level) { return ClientLevelWrapper.getWrapper(level); }
|
||||
private ServerLevelWrapper getServerLevelWrapper(ServerLevel level) { return ServerLevelWrapper.getWrapper(level); }
|
||||
|
||||
/** Registers Fabric Events */
|
||||
public void registerEvents()
|
||||
{
|
||||
LOGGER.info("Registering Fabric Server Events");
|
||||
isGenerationThreadChecker = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread;
|
||||
|
||||
/* Register the mod needed event callbacks */
|
||||
|
||||
// TEST EVENT
|
||||
//ServerTickEvents.END_SERVER_TICK.register(this::tester);
|
||||
|
||||
// ServerTickEvent
|
||||
ServerTickEvents.END_SERVER_TICK.register((server) -> SERVER_API.serverTickEvent());
|
||||
|
||||
// ServerWorldLoadEvent
|
||||
//TODO: Check if both of these use the correct timed events. (i.e. is it 'ed' or 'ing' one?)
|
||||
ServerLifecycleEvents.SERVER_STARTING.register((server) ->
|
||||
{
|
||||
if (isValidTime())
|
||||
{
|
||||
ServerApi.INSTANCE.serverLoadEvent(isDedicated);
|
||||
}
|
||||
});
|
||||
// ServerWorldUnloadEvent
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register((server) ->
|
||||
{
|
||||
if (isValidTime())
|
||||
{
|
||||
ServerApi.INSTANCE.serverUnloadEvent();
|
||||
}
|
||||
});
|
||||
|
||||
// ServerLevelLoadEvent
|
||||
ServerWorldEvents.LOAD.register((server, level) ->
|
||||
{
|
||||
if (isValidTime())
|
||||
{
|
||||
ServerApi.INSTANCE.serverLevelLoadEvent(getServerLevelWrapper(level));
|
||||
}
|
||||
});
|
||||
// ServerLevelUnloadEvent
|
||||
ServerWorldEvents.UNLOAD.register((server, level) ->
|
||||
{
|
||||
if (isValidTime())
|
||||
{
|
||||
ServerApi.INSTANCE.serverLevelUnloadEvent(getServerLevelWrapper(level));
|
||||
}
|
||||
});
|
||||
|
||||
// ServerChunkLoadEvent
|
||||
ServerChunkEvents.CHUNK_LOAD.register((server, chunk) ->
|
||||
{
|
||||
ILevelWrapper level = getServerLevelWrapper((ServerLevel) chunk.getLevel());
|
||||
if (isValidTime())
|
||||
{
|
||||
ServerApi.INSTANCE.serverChunkLoadEvent(
|
||||
new ChunkWrapper(chunk, chunk.getLevel(), level),
|
||||
level);
|
||||
}
|
||||
});
|
||||
// ServerChunkSaveEvent - Done in MixinChunkMap
|
||||
}
|
||||
|
||||
// This just exists here for testing purposes, it'll be removed in the future
|
||||
public void tester(MinecraftServer server)
|
||||
{ // I disabled the Networking functions for now so this will not work atm - coolGi
|
||||
for (ServerPlayer player : server.getPlayerList().getPlayers())
|
||||
{
|
||||
FriendlyByteBuf payload = Networking.createNew();
|
||||
payload.writeInt(1);
|
||||
System.out.println("Sending int 1");
|
||||
Networking.send(player, payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod.mixins;
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
|
||||
import com.seibel.lod.core.dependencyInjection.ModAccessorInjector;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
@@ -14,6 +14,7 @@ import java.util.Set;
|
||||
* @author coolGi
|
||||
* @author cortex
|
||||
*/
|
||||
// TODO: Move to common if possible
|
||||
public class FabricMixinPlugin implements IMixinConfigPlugin {
|
||||
|
||||
@Override
|
||||
@@ -23,7 +24,7 @@ public class FabricMixinPlugin implements IMixinConfigPlugin {
|
||||
mixinClassName
|
||||
// What these 2 regex's do is get the mod name that we are checking out of the mixinClassName
|
||||
// Eg. "com.seibel.lod.mixins.mods.sodium.MixinSodiumChunkRenderer" turns into "sodium"
|
||||
.replaceAll("^.*.mods.", "") // Replaces everything before the mods
|
||||
.replaceAll("^.*mods.", "") // Replaces everything before the mods
|
||||
.replaceAll("\\..*$", "") // Replaces everything after the mod name
|
||||
);
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.seibel.lod.fabric.mixins.mods.sodium;
|
||||
|
||||
import com.seibel.lod.core.api.internal.ClientApi;
|
||||
import com.seibel.lod.core.dependencyInjection.ModAccessorInjector;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
import com.seibel.lod.fabric.wrappers.modAccessor.SodiumAccessor;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.CommandList;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkCameraContext;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderList;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderMatrices;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.RegionChunkRenderer;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(RegionChunkRenderer.class)
|
||||
public class MixinSodiumChunkRenderer {
|
||||
@Unique SodiumAccessor accessor = null;
|
||||
@Inject(remap = false, method = "render", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/render/chunk/ShaderChunkRenderer;begin(Lme/jellysquid/mods/sodium/client/render/chunk/passes/BlockRenderPass;)V", shift = At.Shift.AFTER))
|
||||
private void injectDHLoDRendering(ChunkRenderMatrices matrices, CommandList commandList, ChunkRenderList list, BlockRenderPass pass, ChunkCameraContext camera, CallbackInfo ci) {
|
||||
if (accessor == null) {
|
||||
accessor = (SodiumAccessor)ModAccessorInjector.INSTANCE.get(ISodiumAccessor.class);
|
||||
}
|
||||
if (pass.equals(BlockRenderPass.SOLID)) {
|
||||
//TODO: use matrices.modelView() and matrices.projection() instead of
|
||||
// SodiumAccessor.mcModelViewMatrix,
|
||||
// SodiumAccessor.mcProjectionMatrix,
|
||||
ClientApi.INSTANCE.renderLods(accessor.levelWrapper,
|
||||
accessor.mcModelViewMatrix,
|
||||
accessor.mcProjectionMatrix,
|
||||
accessor.partialTicks);
|
||||
}
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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.lod.fabric.mixins.server;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.seibel.lod.fabric.FabricServerProxy;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
import com.seibel.lod.core.util.objects.DummyRunExecutorService;
|
||||
|
||||
import net.minecraft.Util;
|
||||
|
||||
@Mixin(Util.class)
|
||||
public class MixinUtilBackgroundThread
|
||||
{
|
||||
@Inject(method = "backgroundExecutor", at = @At("HEAD"), cancellable = true)
|
||||
private static void overrideUtil$backgroundExecutor(CallbackInfoReturnable<ExecutorService> ci)
|
||||
{
|
||||
if (FabricServerProxy.isGenerationThreadChecker != null && FabricServerProxy.isGenerationThreadChecker.get())
|
||||
{
|
||||
//ApiShared.LOGGER.info("util backgroundExecutor triggered");
|
||||
ci.setReturnValue(new DummyRunExecutorService());
|
||||
}
|
||||
}
|
||||
|
||||
#if POST_MC_1_17_1
|
||||
@Inject(method = "wrapThreadWithTaskName(Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Runnable;",
|
||||
at = @At("HEAD"), cancellable = true)
|
||||
private static void overrideUtil$wrapThreadWithTaskName(String string, Runnable r, CallbackInfoReturnable<Runnable> ci)
|
||||
{
|
||||
if (FabricServerProxy.isGenerationThreadChecker != null && FabricServerProxy.isGenerationThreadChecker.get())
|
||||
{
|
||||
//ApiShared.LOGGER.info("util wrapThreadWithTaskName(Runnable) triggered");
|
||||
ci.setReturnValue(r);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if POST_MC_1_18_1
|
||||
@Inject(method = "wrapThreadWithTaskName(Ljava/lang/String;Ljava/util/function/Supplier;)Ljava/util/function/Supplier;",
|
||||
at = @At("HEAD"), cancellable = true)
|
||||
private static void overrideUtil$wrapThreadWithTaskNameForSupplier(String string, Supplier<?> r, CallbackInfoReturnable<Supplier<?>> ci)
|
||||
{
|
||||
if (FabricServerProxy.isGenerationThreadChecker != null && FabricServerProxy.isGenerationThreadChecker.get())
|
||||
{
|
||||
//ApiShared.LOGGER.info("util wrapThreadWithTaskName(Supplier) triggered");
|
||||
ci.setReturnValue(r);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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.lod.fabric.wrappers;
|
||||
|
||||
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
import com.seibel.lod.fabric.wrappers.modAccessor.ModChecker;
|
||||
import com.seibel.lod.fabriclike.wrappers.FabricLikeDependencySetup;
|
||||
|
||||
/**
|
||||
* Binds all necessary dependencies, so we
|
||||
* can access them in Core. <br>
|
||||
* This needs to be called before any Core classes
|
||||
* are loaded.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @author Ran
|
||||
* @version 3-5-2022
|
||||
*/
|
||||
public class FabricDependencySetup
|
||||
{
|
||||
public static void createInitialBindings() {
|
||||
SingletonInjector.INSTANCE.bind(IModChecker.class, ModChecker.INSTANCE);
|
||||
FabricLikeDependencySetup.createInitialBindings();
|
||||
}
|
||||
|
||||
public static void runDelayedSetup() {
|
||||
FabricLikeDependencySetup.runDelayedSetup();
|
||||
SingletonInjector.INSTANCE.runDelayedSetup();
|
||||
}
|
||||
}
|
||||
+1
-4
@@ -17,18 +17,15 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.wrappers.config;
|
||||
package com.seibel.lod.fabric.wrappers.config;
|
||||
|
||||
import com.seibel.lod.common.wrappers.gui.GetConfigScreen;
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
/**
|
||||
* For making the config show up in modmenu
|
||||
*/
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class ModMenuIntegration implements ModMenuApi {
|
||||
// For the custom config code
|
||||
@Override
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.seibel.lod.fabric.wrappers.modAccessor;
|
||||
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IBCLibAccessor;
|
||||
import ru.bclib.config.ClientConfig;
|
||||
import ru.bclib.config.Configs;
|
||||
import ru.bclib.util.BackgroundInfo;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class BCLibAccessor implements IBCLibAccessor {
|
||||
@Override
|
||||
public String getModName() {
|
||||
return "BCLib";
|
||||
}
|
||||
|
||||
public void setRenderCustomFog(boolean newValue) {
|
||||
// Change the value of CUSTOM_FOG_RENDERING in the bclib client config
|
||||
Configs.CLIENT_CONFIG.set(ClientConfig.CUSTOM_FOG_RENDERING, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getFogColor() {
|
||||
return new Color(BackgroundInfo.fogColorRed, BackgroundInfo.fogColorGreen, BackgroundInfo.fogColorBlue);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.wrappers.modAccessor;
|
||||
package com.seibel.lod.fabric.wrappers.modAccessor;
|
||||
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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.lod.fabric.wrappers.modAccessor;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.seibel.lod.core.pos.DhChunkPos;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.AbstractOptifineAccessor;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
|
||||
|
||||
public class OptifineAccessor extends AbstractOptifineAccessor
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getModName()
|
||||
{
|
||||
return "Optifine-Fabric-1.18.X";
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashSet<DhChunkPos> getNormalRenderedChunks()
|
||||
{
|
||||
// TODO: Impl proper methods here
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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.lod.fabric.wrappers.modAccessor;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.seibel.lod.core.pos.DhChunkPos;
|
||||
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.lod.core.util.math.Mat4f;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
|
||||
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
#if PRE_MC_1_17_1
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
#else
|
||||
import net.minecraft.world.level.LevelHeightAccessor;
|
||||
#endif
|
||||
|
||||
public class SodiumAccessor implements ISodiumAccessor {
|
||||
private final IWrapperFactory factory = SingletonInjector.INSTANCE.get(IWrapperFactory.class);
|
||||
private final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
||||
|
||||
public IClientLevelWrapper levelWrapper;
|
||||
public Mat4f mcModelViewMatrix;
|
||||
public Mat4f mcProjectionMatrix;
|
||||
public float partialTicks;
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
return "Sodium-Fabric";
|
||||
}
|
||||
|
||||
#if POST_MC_1_17_1
|
||||
@Override
|
||||
public HashSet<DhChunkPos> getNormalRenderedChunks() {
|
||||
SodiumWorldRenderer renderer = SodiumWorldRenderer.instance();
|
||||
LevelHeightAccessor height = Minecraft.getInstance().level;
|
||||
|
||||
#if POST_MC_1_18_1
|
||||
// 0b11 = Lighted chunk & loaded chunk
|
||||
return renderer.getChunkTracker().getChunks(0b00).filter(
|
||||
(long l) -> {
|
||||
return true;
|
||||
}).mapToObj(DhChunkPos::new).collect(Collectors.toCollection(HashSet::new));
|
||||
#else
|
||||
// TODO: Maybe use a mixin to make this more efficient, and maybe ignore changes behind the camera
|
||||
return MC_RENDER.getMaximumRenderedChunks().stream().filter((DHChunkPos chunk) -> {
|
||||
return (renderer.isBoxVisible(
|
||||
chunk.getMinBlockX()+1, height.getMinBuildHeight()+1, chunk.getMinBlockZ()+1,
|
||||
chunk.getMinBlockX()+15, height.getMaxBuildHeight()-1, chunk.getMinBlockZ()+15));
|
||||
}).collect(Collectors.toCollection(HashSet::new));
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
@Override
|
||||
public HashSet<DHChunkPos> getNormalRenderedChunks() {
|
||||
SodiumWorldRenderer renderer = SodiumWorldRenderer.getInstance();
|
||||
LevelAccessor height = Minecraft.getInstance().level;
|
||||
// TODO: Maybe use a mixin to make this more efficient
|
||||
return MC_RENDER.getMaximumRenderedChunks().stream().filter((DHChunkPos chunk) -> {
|
||||
FakeChunkEntity AABB = new FakeChunkEntity(chunk.getX(), chunk.getZ(), height.getMaxBuildHeight());
|
||||
return (renderer.isEntityVisible(AABB));
|
||||
}).collect(Collectors.toCollection(HashSet::new));
|
||||
}
|
||||
|
||||
private static class FakeChunkEntity extends Entity {
|
||||
public int cx;
|
||||
public int cz;
|
||||
public int my;
|
||||
public FakeChunkEntity(int chunkX, int chunkZ, int maxHeight) {
|
||||
super(EntityType.AREA_EFFECT_CLOUD, null);
|
||||
cx = chunkX;
|
||||
cz = chunkZ;
|
||||
my = maxHeight;
|
||||
}
|
||||
@Override
|
||||
public AABB getBoundingBoxForCulling() {
|
||||
return new AABB(cx*16+1, 1, cz*16+1,
|
||||
cx*16+15, my-1, cz*16+15);
|
||||
}
|
||||
@Override
|
||||
protected void defineSynchedData() {}
|
||||
@Override
|
||||
protected void readAdditionalSaveData(CompoundTag paramCompoundTag) {}
|
||||
@Override
|
||||
protected void addAdditionalSaveData(CompoundTag paramCompoundTag) {}
|
||||
@Override
|
||||
public Packet<?> getAddEntityPacket() {
|
||||
throw new UnsupportedOperationException("This is a FAKE CHUNK ENTITY... For tricking the Sodium to check a AABB.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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.lod.fabric.wrappers.modAccessor;
|
||||
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IStarlightAccessor;
|
||||
|
||||
|
||||
public class StarlightAccessor implements IStarlightAccessor {
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
return "Starlight-Fabric-1.18.X";
|
||||
}
|
||||
|
||||
public StarlightAccessor() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.seibel.lod.fabric.mixins",
|
||||
"mixins": [
|
||||
"server.MixinUtilBackgroundThread"
|
||||
],
|
||||
"client": [
|
||||
"mods.sodium.MixinSodiumChunkRenderer"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"plugin": "com.seibel.lod.fabric.mixins.FabricMixinPlugin"
|
||||
}
|
||||
@@ -16,22 +16,25 @@
|
||||
"license": "LGPL-3",
|
||||
"icon": "icon.png",
|
||||
|
||||
"accessWidener": "lod.accesswidener",
|
||||
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"client": [
|
||||
"com.seibel.lod.FabricClientMain"
|
||||
"com.seibel.lod.fabric.FabricClientMain"
|
||||
],
|
||||
"server": [
|
||||
"com.seibel.lod.FabricDedicatedServerMain"
|
||||
"com.seibel.lod.fabric.FabricDedicatedServerMain"
|
||||
],
|
||||
|
||||
"modmenu": [
|
||||
"com.seibel.lod.wrappers.config.ModMenuIntegration"
|
||||
"com.seibel.lod.fabric.wrappers.config.ModMenuIntegration"
|
||||
]
|
||||
},
|
||||
|
||||
"mixins": [
|
||||
"DistantHorizons.mixins.json"
|
||||
"DistantHorizons.fabric.fabricLike.mixins.json",
|
||||
"DistantHorizons.fabric.mixins.json"
|
||||
],
|
||||
|
||||
"depends": {
|
||||
@@ -39,7 +42,6 @@
|
||||
"fabric-api-base": "*",
|
||||
"fabric-lifecycle-events-v1": "*",
|
||||
"fabric-key-binding-api-v1": "*",
|
||||
"fabric-key-binding-api-v1": "*",
|
||||
"fabric-resource-loader-v0": "*",
|
||||
"minecraft": $compatible_minecraft_versions,
|
||||
"java": ">=${java_version}"
|
||||
@@ -48,7 +50,7 @@
|
||||
"custom": {
|
||||
"modmenu": {
|
||||
"links": {
|
||||
"modmenu.discord": "https://discord.gg/xAB8G4cENx"
|
||||
"modmenu.discord": "${discord}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// TODO: Once forge is fixed, attempt to move the stuff from this submodule to the common submodule
|
||||
|
||||
|
||||
plugins {
|
||||
id "org.spongepowered.gradle.vanilla" version "0.2.1-SNAPSHOT"
|
||||
}
|
||||
|
||||
minecraft {
|
||||
accessWideners(project(":common").file("src/main/resources/${accessWidenerVersion}.lod.accesswidener"))
|
||||
version(rootProject.minecraft_version)
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
|
||||
// Do NOT use other classes from fabric loader
|
||||
// modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
|
||||
// So mixins can be written in common
|
||||
compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
|
||||
}
|
||||
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenCommon(MavenPublication) {
|
||||
artifactId = rootProject.mod_readable_name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
+19
-13
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.mixins.client;
|
||||
package com.seibel.lod.fabriclike.mixins.client;
|
||||
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.lod.common.wrappers.world.ClientLevelWrapper;
|
||||
@@ -38,23 +38,29 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
*/
|
||||
|
||||
@Mixin(ClientLevel.class)
|
||||
public class MixinClientLevel {
|
||||
//Moved to MixinClientPacketListener
|
||||
public class MixinClientLevel
|
||||
{
|
||||
// //Moved to MixinClientPacketListener
|
||||
// @Inject(method = "<init>", at = @At("TAIL"))
|
||||
// private void loadWorldEvent(ClientPacketListener clientPacketListener, ClientLevel.ClientLevelData clientLevelData, ResourceKey resourceKey,
|
||||
// #if POST_MC_1_18_2 Holder holder, #else DimensionType dimensionType, #endif int i,
|
||||
// #if POST_MC_1_18_1 int j, #endif Supplier supplier, LevelRenderer levelRenderer, boolean bl, long l, CallbackInfo ci) {
|
||||
// SharedApi.LOGGER.info("Loading level: " + WorldWrapper.getWorldWrapper((ClientLevel)(Object)this));
|
||||
// #if POST_MC_1_18_1 int j, #endif Supplier supplier, LevelRenderer levelRenderer, boolean bl, long l, CallbackInfo ci)
|
||||
// {
|
||||
// ClientApi.INSTANCE.clientLevelLoadEvent(WorldWrapper.getWorldWrapper((ClientLevel)(Object)this));
|
||||
// }
|
||||
|
||||
#if POST_MC_1_18_1 // Only the setLightReady is only available after 1.18. This ensure light data is ready.
|
||||
|
||||
#if POST_MC_1_18_1 // Only the setLightReady is only available after 1.18. This ensures the light data is ready.
|
||||
@Inject(method = "setLightReady", at = @At("HEAD"))
|
||||
private void onChunkLightReady(int x, int z, CallbackInfo ci) {
|
||||
ClientLevel l = (ClientLevel) (Object) this;
|
||||
LevelChunk chunk = l.getChunkSource().getChunk(x, z, false);
|
||||
if (chunk!=null&& !chunk.isClientLightReady())
|
||||
ClientApi.INSTANCE.clientChunkLoadEvent(new ChunkWrapper(chunk, l, ClientLevelWrapper.getWrapper(l)), ClientLevelWrapper.getWrapper(l));
|
||||
}
|
||||
private void onChunkLightReady(int x, int z, CallbackInfo ci)
|
||||
{
|
||||
ClientLevel clientLevel = (ClientLevel) (Object) this;
|
||||
LevelChunk chunk = clientLevel.getChunkSource().getChunk(x, z, false);
|
||||
|
||||
if (chunk != null && !chunk.isClientLightReady())
|
||||
{
|
||||
ClientApi.INSTANCE.clientChunkLoadEvent(new ChunkWrapper(chunk, clientLevel, ClientLevelWrapper.getWrapper(clientLevel)), ClientLevelWrapper.getWrapper(clientLevel));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
+29
-25
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod.mixins.client;
|
||||
package com.seibel.lod.fabriclike.mixins.client;
|
||||
|
||||
import com.seibel.lod.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.lod.core.api.internal.ClientApi;
|
||||
@@ -11,10 +11,13 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ClientPacketListener.class)
|
||||
public class MixinClientPacketListener {
|
||||
public class MixinClientPacketListener
|
||||
{
|
||||
@Shadow
|
||||
private ClientLevel level;
|
||||
|
||||
|
||||
|
||||
|
||||
/** THIS EXPLANATION IS WRITTEN BY FABRIC.
|
||||
* An explanation why we unload entities during onGameJoin: (On in our remapping name case, handleLogin(TODO: CHECK))
|
||||
* Proxies such as Waterfall may send another Game Join packet if entity meta rewrite is disabled, so we will cover ourselves.
|
||||
@@ -22,26 +25,27 @@ public class MixinClientPacketListener {
|
||||
* Also anyone can send another GameJoinPacket at any time, so we need to watch out.
|
||||
*/
|
||||
@Inject(method = "handleLogin", at = @At("HEAD"))
|
||||
void onHandleLoginStart(CallbackInfo ci) {
|
||||
if (level != null) ClientApi.INSTANCE.clientLevelUnloadEvent(ClientLevelWrapper.getWrapper(level));
|
||||
}
|
||||
|
||||
@Inject(method = "handleLogin", at = @At("RETURN"))
|
||||
void onHandleLoginEnd(CallbackInfo ci) {
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(ClientLevelWrapper.getWrapper(level));
|
||||
}
|
||||
|
||||
@Inject(method = "handleRespawn", at = @At("HEAD"))
|
||||
void onHandleRespawnStart(CallbackInfo ci) {
|
||||
ClientApi.INSTANCE.clientLevelUnloadEvent(ClientLevelWrapper.getWrapper(level));
|
||||
}
|
||||
@Inject(method = "handleRespawn", at = @At("RETURN"))
|
||||
void onHandleRespawnEnd(CallbackInfo ci) {
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(ClientLevelWrapper.getWrapper(level));
|
||||
}
|
||||
|
||||
@Inject(method = "cleanup", at = @At("HEAD"))
|
||||
void onCleanupStart(CallbackInfo ci) {
|
||||
if (level != null) ClientApi.INSTANCE.clientLevelUnloadEvent(ClientLevelWrapper.getWrapper(level));
|
||||
}
|
||||
void onHandleLoginStart(CallbackInfo ci)
|
||||
{
|
||||
// not the best way to notify Core that we are no longer in the previous world, but it will have to do for now
|
||||
ClientApi.INSTANCE.onClientOnlyDisconnected();
|
||||
}
|
||||
@Inject(method = "handleLogin", at = @At("RETURN"))
|
||||
void onHandleLoginEnd(CallbackInfo ci) { ClientApi.INSTANCE.onClientOnlyConnected(); }
|
||||
|
||||
@Inject(method = "handleRespawn", at = @At("HEAD"))
|
||||
void onHandleRespawnStart(CallbackInfo ci) { ClientApi.INSTANCE.clientLevelUnloadEvent(ClientLevelWrapper.getWrapper(level)); }
|
||||
@Inject(method = "handleRespawn", at = @At("RETURN"))
|
||||
void onHandleRespawnEnd(CallbackInfo ci) { ClientApi.INSTANCE.clientLevelLoadEvent(ClientLevelWrapper.getWrapper(level)); }
|
||||
|
||||
@Inject(method = "cleanup", at = @At("HEAD"))
|
||||
void onCleanupStart(CallbackInfo ci)
|
||||
{
|
||||
// TODO which unload method should be used? do we need both?
|
||||
if (level != null)
|
||||
{
|
||||
ClientApi.INSTANCE.clientLevelUnloadEvent(ClientLevelWrapper.getWrapper(level));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod.mixins.client;
|
||||
package com.seibel.lod.fabriclike.mixins.client;
|
||||
|
||||
import com.seibel.lod.core.logging.f3.F3Screen;
|
||||
import net.minecraft.client.gui.components.DebugScreenOverlay;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.mixins.client;
|
||||
package com.seibel.lod.fabriclike.mixins.client;
|
||||
|
||||
import com.seibel.lod.core.config.Config;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod.mixins.client;
|
||||
package com.seibel.lod.fabriclike.mixins.client;
|
||||
|
||||
import com.seibel.lod.core.api.internal.ClientApi;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.mixins.client;
|
||||
package com.seibel.lod.fabriclike.mixins.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Matrix4f;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod.mixins.client;
|
||||
package com.seibel.lod.fabriclike.mixins.client;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod.mixins.client;
|
||||
package com.seibel.lod.fabriclike.mixins.client;
|
||||
|
||||
import com.seibel.lod.common.wrappers.gui.updater.UpdateModScreen;
|
||||
import com.seibel.lod.core.config.Config;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.mixins.client;
|
||||
package com.seibel.lod.fabriclike.mixins.client;
|
||||
|
||||
import com.seibel.lod.common.wrappers.gui.GetConfigScreen;
|
||||
import com.seibel.lod.common.wrappers.gui.TexturedButtonWidget;
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.seibel.lod.fabriclike.mixins.client;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.platform.TextureUtil;
|
||||
import com.seibel.lod.core.config.Config;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
/**
|
||||
* Sets Minecraft's LOD Bias (looks similar to mipmaps)
|
||||
*
|
||||
* @author coolGi
|
||||
*/
|
||||
@Mixin(TextureUtil.class)
|
||||
public class MixinTextureUtil {
|
||||
@Redirect(method = "Lcom/mojang/blaze3d/platform/TextureUtil;prepareImage(Lcom/mojang/blaze3d/platform/NativeImage$InternalGlFormat;IIII)V",
|
||||
at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;_texParameter(IIF)V", remap=false))
|
||||
private static void setLodBias(int target, int pname, float param) {
|
||||
float biasValue = Config.Client.Graphics.AdvancedGraphics.lodBias.get().floatValue();
|
||||
if (biasValue != 0) {
|
||||
// The target is GL11.GL_TEXTURE_2D
|
||||
// And the pname is GL14.GL_TEXTURE_LOD_BIAS
|
||||
GlStateManager._texParameter(target, pname, biasValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.mixins.events;
|
||||
package com.seibel.lod.fabriclike.mixins.events;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.mixins.events;
|
||||
package com.seibel.lod.fabriclike.mixins.events;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.mixins.server;
|
||||
package com.seibel.lod.fabriclike.mixins.server;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod.mixins.server;
|
||||
package com.seibel.lod.fabriclike.mixins.server;
|
||||
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.lod.common.wrappers.world.ServerLevelWrapper;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.mixins.server.unsafe;
|
||||
package com.seibel.lod.fabriclike.mixins.server.unsafe;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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.lod.fabriclike.wrappers;
|
||||
|
||||
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
|
||||
|
||||
/**
|
||||
* Binds all necessary dependencies, so we
|
||||
* can access them in Core. <br>
|
||||
* This needs to be called before any Core classes
|
||||
* are loaded.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @author Ran
|
||||
* @version 3-5-2022
|
||||
*/
|
||||
public class FabricLikeDependencySetup {
|
||||
public static void createInitialBindings() {}
|
||||
|
||||
public static void runDelayedSetup() {}
|
||||
}
|
||||
+4
-6
@@ -1,12 +1,11 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.seibel.lod.mixins",
|
||||
"package": "com.seibel.lod.fabriclike.mixins",
|
||||
"mixins": [
|
||||
"server.unsafe.MixinThreadingDetector",
|
||||
"server.MixinChunkGenerator",
|
||||
"server.MixinChunkMap",
|
||||
"server.MixinUtilBackgroundThread"
|
||||
"server.MixinChunkMap"
|
||||
],
|
||||
"client": [
|
||||
"client.MixinClientLevel",
|
||||
@@ -18,10 +17,9 @@
|
||||
"client.MixinLightmap",
|
||||
"client.MixinOptionsScreen",
|
||||
"client.MixinMinecraft",
|
||||
"mods.sodium.MixinSodiumChunkRenderer"
|
||||
"client.MixinTextureUtil"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"plugin": "com.seibel.lod.mixins.FabricMixinPlugin"
|
||||
}
|
||||
}
|
||||
+118
-82
@@ -1,99 +1,149 @@
|
||||
version = rootProject.versionStr
|
||||
|
||||
loom {
|
||||
forge {
|
||||
convertAccessWideners.set(true)
|
||||
extraAccessWideners.add("lod.accesswidener")
|
||||
mixinConfigs("DistantHorizons.mixins.json")
|
||||
buildscript {
|
||||
repositories {
|
||||
maven { url = "https://maven.minecraftforge.net" }
|
||||
maven { url = "https://maven.parchmentmc.org" }
|
||||
maven { url = "https://repo.spongepowered.org/repository/maven-public/" }
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
// classpath group: "net.minecraftforge.gradle", name: "ForgeGradle", version: "5.1.61", changing: true
|
||||
classpath group: "net.minecraftforge.gradle", name: "ForgeGradle", version: "5.1.67", changing: true
|
||||
classpath "org.parchmentmc:librarian:1.+"
|
||||
classpath "org.spongepowered:mixingradle:0.7-SNAPSHOT"
|
||||
}
|
||||
}
|
||||
apply plugin: "net.minecraftforge.gradle"
|
||||
apply plugin: "org.parchmentmc.librarian.forgegradle"
|
||||
apply plugin: "org.spongepowered.mixin"
|
||||
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
mixin {
|
||||
add sourceSets.main, "DistantHorizons.refmap.json" // TODO: Create an accessWidener to refmap
|
||||
|
||||
architectury {
|
||||
platformSetupLoomIde()
|
||||
forge()
|
||||
config "DistantHorizons.mixins.json"
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = project(":common").loom.accessWidenerPath
|
||||
minecraft {
|
||||
// mappings channel: "official", version: minecraft_version // Vanilla mappings
|
||||
mappings channel: "parchment", version: "${parchment_version}-${minecraft_version}" // Parchment mappings
|
||||
|
||||
forge {
|
||||
convertAccessWideners = true
|
||||
extraAccessWideners.add loom.accessWidenerPath.get().asFile.name
|
||||
accessTransformer = project(":forge").file("src/main/resources/META-INF/accesstransformer.cfg") // FIXME: Find a libary to use fabric's accessWidener instead of forge's own accesstransformer format
|
||||
|
||||
runs {
|
||||
client {
|
||||
workingDirectory project.file("run")
|
||||
ideaModule "${rootProject.name}.${project.name}.main"
|
||||
taskName "runClient"
|
||||
args "-mixins.config=DistantHorizons.mixins.json"
|
||||
property 'mixin.env.remapRefMap', 'true'
|
||||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
|
||||
mods {
|
||||
modClientRun {
|
||||
source sourceSets.main
|
||||
source project(":common").sourceSets.main
|
||||
source project(":core").sourceSets.main
|
||||
source project(":api").sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Do this once client works
|
||||
// server {
|
||||
// workingDirectory project.file("run")
|
||||
// ideaModule "${rootProject.name}.${project.name}.main"
|
||||
// taskName "runServer"
|
||||
// args "-mixins.config=DistantHorizons.mixins.json"
|
||||
// }
|
||||
|
||||
data {
|
||||
workingDirectory project.file("run")
|
||||
ideaModule "${rootProject.name}.${project.name}.main"
|
||||
args '--mod', "lod", '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
||||
taskName 'Data'
|
||||
args "-mixins.config=DistantHorizons.mixins.json" // To add more mixins, you can just add a comma for another arg
|
||||
property 'mixin.env.remapRefMap', 'true'
|
||||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
|
||||
mods {
|
||||
modClientRun {
|
||||
source sourceSets.main
|
||||
source project(":common").sourceSets.main
|
||||
source project(":core").sourceSets.main
|
||||
source project(":api").sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: Check if the next 7 lines are necessary
|
||||
//sourceSets.main.resources.srcDir "src/generated/resources"
|
||||
//minecraft.runs.all {
|
||||
// lazyToken('minecraft_classpath') {
|
||||
// configurations.library.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator)
|
||||
// configurations.runtimeLibrary.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator)
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//loom {
|
||||
// forge {
|
||||
// convertAccessWideners.set(true)
|
||||
// extraAccessWideners.add("lod.accesswidener")
|
||||
// mixinConfigs("DistantHorizons.mixins.json")
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//loom {
|
||||
// accessWidenerPath = project(":common").loom.accessWidenerPath
|
||||
//
|
||||
// forge {
|
||||
// convertAccessWideners = true
|
||||
// extraAccessWideners.add loom.accessWidenerPath.get().asFile.name
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentForge.extendsFrom common
|
||||
}
|
||||
|
||||
def addMod(path, enabled) {
|
||||
if (enabled == "2")
|
||||
dependencies { modImplementation(path) }
|
||||
dependencies { implementation(path) }
|
||||
else if (enabled == "1")
|
||||
dependencies { modCompileOnly(path) }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Forge loader
|
||||
forge "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}"
|
||||
minecraft "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}"
|
||||
|
||||
// Architectury API
|
||||
if (minecraft_version == "1.16.5") {
|
||||
modImplementation("me.shedaniel:architectury-forge:${rootProject.architectury_version}")
|
||||
} else {
|
||||
modImplementation("dev.architectury:architectury-forge:${rootProject.architectury_version}")
|
||||
}
|
||||
// if (minecraft_version == "1.16.5") {
|
||||
// implementation("me.shedaniel:architectury-forge:${rootProject.architectury_version}")
|
||||
// } else {
|
||||
// implementation("dev.architectury:architectury-forge:${rootProject.architectury_version}")
|
||||
// }
|
||||
|
||||
// Starlight
|
||||
addMod("curse.maven:starlight-forge-526854:${rootProject.starlight_version_forge}", rootProject.enable_starlight_forge)
|
||||
annotationProcessor "org.spongepowered:mixin:0.8.4:processor"
|
||||
// annotationProcessor "org.spongepowered:mixin:0.8.4:processor"
|
||||
|
||||
addMod("curse.maven:TerraForged-363820:${rootProject.terraforged_version}", rootProject.enable_terraforged)
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false }
|
||||
// if (System.getProperty("idea.sync.active") != "true") {
|
||||
// annotationProcessor "org.spongepowered:mixin:0.8.4:processor"
|
||||
// }
|
||||
}
|
||||
|
||||
processResources {
|
||||
dependsOn(copyCoreResources)
|
||||
dependsOn(copyCommonLoaderResources)
|
||||
dependsOn(deleteDuplicatedCommonLoaderResources)
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
exclude "architectury.common.json"
|
||||
//remapJar {
|
||||
// input.set shadowJar.archiveFile
|
||||
// dependsOn shadowJar
|
||||
// classifier null
|
||||
//}
|
||||
|
||||
configurations = [project.configurations.shadowCommon, project.configurations.shadowMe, project.configurations.customModule]
|
||||
|
||||
// Compression
|
||||
relocate 'org.tukaani', 'distanthorizons.libraries.tukaani'
|
||||
relocate 'org.apache.commons.compress', 'distanthorizons.libraries.apache.commons.compress'
|
||||
|
||||
// NightConfig (includes Toml & Json)
|
||||
relocate 'com.electronwill.nightconfig', 'distanthorizons.libraries.electronwill.nightconfig'
|
||||
|
||||
// Theming
|
||||
relocate 'com.formdev.flatlaf', 'distanthorizons.libraries.formdev.flatlaf'
|
||||
|
||||
// svg
|
||||
relocate 'com.kitfox.svg', 'distanthorizons.libraries.kitfox.svg'
|
||||
|
||||
classifier "dev-shadow"
|
||||
mergeServiceFiles()
|
||||
}
|
||||
|
||||
remapJar {
|
||||
input.set shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
classifier null
|
||||
}
|
||||
|
||||
jar {
|
||||
classifier "dev"
|
||||
}
|
||||
|
||||
sourcesJar {
|
||||
def commonSources = project(":common").sourcesJar
|
||||
@@ -101,22 +151,8 @@ sourcesJar {
|
||||
from commonSources.archiveFile.map { zipTree(it) }
|
||||
}
|
||||
|
||||
components.java {
|
||||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||
skip()
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenForge(MavenPublication) {
|
||||
artifactId = rootProject.archives_base_name + "-" + project.name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
//components.java {
|
||||
// withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||
// skip()
|
||||
// }
|
||||
//}
|
||||
@@ -1 +0,0 @@
|
||||
loom.platform=forge
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod;
|
||||
package com.seibel.lod.forge;
|
||||
|
||||
import com.seibel.lod.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.lod.core.api.internal.ClientApi;
|
||||
+38
-31
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod;
|
||||
package com.seibel.lod.forge;
|
||||
|
||||
import com.seibel.lod.api.methods.events.abstractEvents.DhApiAfterDhInitEvent;
|
||||
import com.seibel.lod.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent;
|
||||
@@ -29,13 +29,17 @@ import com.seibel.lod.common.wrappers.minecraft.MinecraftClientWrapper;
|
||||
import com.seibel.lod.core.DependencyInjection.ApiEventInjector;
|
||||
import com.seibel.lod.core.ModInfo;
|
||||
import com.seibel.lod.core.ReflectionHandler;
|
||||
import com.seibel.lod.core.config.Config;
|
||||
import com.seibel.lod.core.dependencyInjection.ModAccessorInjector;
|
||||
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IBCLibAccessor;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
|
||||
import com.seibel.lod.wrappers.ForgeDependencySetup;
|
||||
import com.seibel.lod.forge.wrappers.ForgeDependencySetup;
|
||||
|
||||
import com.seibel.lod.wrappers.modAccessor.OptifineAccessor;
|
||||
import com.seibel.lod.forge.modAccessor.OptifineAccessor;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -84,6 +88,10 @@ public class ForgeMain implements LodForgeMethodCaller
|
||||
|
||||
public ForgeMain()
|
||||
{
|
||||
DependencySetup.createClientBindings();
|
||||
|
||||
// initDedicated(null);
|
||||
// initDedicated(null);
|
||||
// Register the mod initializer (Actual event registration is done in the different proxies)
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::initClient);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::initDedicated);
|
||||
@@ -91,36 +99,18 @@ public class ForgeMain implements LodForgeMethodCaller
|
||||
|
||||
private void initClient(final FMLClientSetupEvent event)
|
||||
{
|
||||
DependencySetup.createClientBindings();
|
||||
initCommon();
|
||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeDhInitEvent.class, null);
|
||||
|
||||
LOGGER.info("Initializing Mod");
|
||||
LodCommonMain.startup(this);
|
||||
ForgeDependencySetup.createInitialBindings();
|
||||
LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION);
|
||||
|
||||
client_proxy = new ForgeClientProxy();
|
||||
MinecraftForge.EVENT_BUS.register(client_proxy);
|
||||
server_proxy = new ForgeServerProxy(false);
|
||||
MinecraftForge.EVENT_BUS.register(server_proxy);
|
||||
|
||||
postInitCommon();
|
||||
}
|
||||
|
||||
private void initDedicated(final FMLDedicatedServerSetupEvent event)
|
||||
{
|
||||
DependencySetup.createServerBindings();
|
||||
initCommon();
|
||||
|
||||
server_proxy = new ForgeServerProxy(true);
|
||||
MinecraftForge.EVENT_BUS.register(server_proxy);
|
||||
|
||||
postInitCommon();
|
||||
}
|
||||
|
||||
private void initCommon()
|
||||
{
|
||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeDhInitEvent.class, null);
|
||||
|
||||
LodCommonMain.startup(this);
|
||||
ForgeDependencySetup.createInitialBindings();
|
||||
LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION);
|
||||
|
||||
if (ReflectionHandler.INSTANCE.optifinePresent()) {
|
||||
ModAccessorInjector.INSTANCE.bind(IOptifineAccessor.class, new OptifineAccessor());
|
||||
}
|
||||
@@ -131,16 +121,33 @@ public class ForgeMain implements LodForgeMethodCaller
|
||||
ModLoadingContext.get().registerExtensionPoint(ConfigGuiHandler.ConfigGuiFactory.class,
|
||||
() -> new ConfigGuiHandler.ConfigGuiFactory((client, parent) -> GetConfigScreen.getScreen(parent)));
|
||||
#endif
|
||||
|
||||
LOGGER.info(ModInfo.READABLE_NAME + " Initialized");
|
||||
|
||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterDhInitEvent.class, null);
|
||||
|
||||
// Init config
|
||||
// The reason im initialising in this rather than the post init process is cus im using this for the auto updater
|
||||
LodCommonMain.initConfig();
|
||||
}
|
||||
|
||||
private void initDedicated(final FMLDedicatedServerSetupEvent event)
|
||||
{
|
||||
// DependencySetup.createServerBindings();
|
||||
// initCommon();
|
||||
|
||||
// server_proxy = new ForgeServerProxy(true);
|
||||
// MinecraftForge.EVENT_BUS.register(server_proxy);
|
||||
//
|
||||
postInitCommon();
|
||||
}
|
||||
|
||||
private void postInitCommon()
|
||||
{
|
||||
LOGGER.info("Post-Initializing Mod");
|
||||
SingletonInjector.INSTANCE.runDelayedSetup();
|
||||
LodCommonMain.initConfig();
|
||||
ForgeDependencySetup.runDelayedSetup();
|
||||
|
||||
LOGGER.info("Mod Post-Initialized");
|
||||
|
||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterDhInitEvent.class, null);
|
||||
}
|
||||
|
||||
private final ModelDataMap dataMap = new ModelDataMap.Builder().build();
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod;
|
||||
package com.seibel.lod.forge;
|
||||
|
||||
import com.seibel.lod.common.networking.Networking;
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
@@ -55,13 +55,13 @@ public class ForgeServerProxy {
|
||||
// ServerWorldLoadEvent
|
||||
@SubscribeEvent
|
||||
private void dedicatedWorldLoadEvent(ServerStartedEvent event) {
|
||||
if (isValidTime()) serverApi.serverWorldLoadEvent(isDedicated);
|
||||
if (isValidTime()) serverApi.serverLoadEvent(isDedicated);
|
||||
}
|
||||
|
||||
// ServerWorldUnloadEvent
|
||||
@SubscribeEvent
|
||||
private void serverWorldUnloadEvent(ServerStoppingEvent event) {
|
||||
if (isValidTime()) serverApi.serverWorldUnloadEvent();
|
||||
if (isValidTime()) serverApi.serverUnloadEvent();
|
||||
}
|
||||
|
||||
// ServerLevelLoadEvent
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod.mixins;
|
||||
package com.seibel.lod.forge.mixins;
|
||||
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
@@ -21,7 +21,7 @@ public class ForgeMixinPlugin implements IMixinConfigPlugin {
|
||||
mixinClassName
|
||||
// What these 2 regex's do is get the mod name that we are checking out of the mixinClassName
|
||||
// Eg. "com.seibel.lod.mixins.mods.sodium.MixinSodiumChunkRenderer" turns into "sodium"
|
||||
.replaceAll("^.*.mods.", "") // Replaces everything before the mods
|
||||
.replaceAll("^.*mods.", "") // Replaces everything before the mods
|
||||
.replaceAll("\\..*$", "") // Replaces everything after the mod name
|
||||
);
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod.mixins.client;
|
||||
package com.seibel.lod.forge.mixins.client;
|
||||
|
||||
import com.seibel.lod.core.logging.f3.F3Screen;
|
||||
import net.minecraft.client.gui.components.DebugScreenOverlay;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.mixins.client;
|
||||
package com.seibel.lod.forge.mixins.client;
|
||||
|
||||
import com.seibel.lod.core.config.Config;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod.mixins.client;
|
||||
package com.seibel.lod.forge.mixins.client;
|
||||
|
||||
import com.seibel.lod.core.api.internal.ClientApi;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.mixins.client;
|
||||
package com.seibel.lod.forge.mixins.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Matrix4f;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod.mixins.client;
|
||||
package com.seibel.lod.forge.mixins.client;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod.mixins.client;
|
||||
package com.seibel.lod.forge.mixins.client;
|
||||
|
||||
import com.seibel.lod.common.wrappers.gui.updater.UpdateModScreen;
|
||||
import com.seibel.lod.core.config.Config;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.mixins.client;
|
||||
package com.seibel.lod.forge.mixins.client;
|
||||
|
||||
import com.seibel.lod.common.wrappers.gui.GetConfigScreen;
|
||||
import com.seibel.lod.common.wrappers.gui.TexturedButtonWidget;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.mixins.server;
|
||||
package com.seibel.lod.forge.mixins.server;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod.mixins.server;
|
||||
package com.seibel.lod.forge.mixins.server;
|
||||
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.mixins.server;
|
||||
package com.seibel.lod.forge.mixins.server;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.function.Supplier;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.mixins.server.unsafe;
|
||||
package com.seibel.lod.forge.mixins.server.unsafe;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
#if POST_MC_1_18_1
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.wrappers.modAccessor;
|
||||
package com.seibel.lod.forge.modAccessor;
|
||||
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.wrappers.modAccessor;
|
||||
package com.seibel.lod.forge.modAccessor;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
+5
-2
@@ -17,11 +17,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.wrappers;
|
||||
package com.seibel.lod.forge.wrappers;
|
||||
|
||||
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
import com.seibel.lod.wrappers.modAccessor.ModChecker;
|
||||
import com.seibel.lod.forge.modAccessor.ModChecker;
|
||||
|
||||
/**
|
||||
* Binds all necessary dependencies so we
|
||||
@@ -40,4 +40,7 @@ public class ForgeDependencySetup
|
||||
SingletonInjector.INSTANCE.bind(IModChecker.class, ModChecker.INSTANCE);
|
||||
}
|
||||
|
||||
public static void runDelayedSetup() {
|
||||
SingletonInjector.INSTANCE.runDelayedSetup();
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.seibel.lod.mixins",
|
||||
"package": "com.seibel.lod.forge.mixins",
|
||||
"mixins": [
|
||||
"server.unsafe.MixinThreadingDetector",
|
||||
"server.MixinUtilBackgroundThread",
|
||||
"server.MixinChunkGenerator",
|
||||
"server.unsafe.MixinThreadingDetector",
|
||||
"server.MixinUtilBackgroundThread",
|
||||
"server.MixinChunkGenerator",
|
||||
"server.MixinTFChunkGenerator"
|
||||
],
|
||||
"client": [
|
||||
"client.MixinDebugScreenOverlay",
|
||||
"client.MixinFogRenderer",
|
||||
"client.MixinGameRenderer",
|
||||
"client.MixinLevelRenderer",
|
||||
"client.MixinLightmap",
|
||||
"client.MixinOptionsScreen"
|
||||
"client.MixinDebugScreenOverlay",
|
||||
"client.MixinFogRenderer",
|
||||
"client.MixinGameRenderer",
|
||||
"client.MixinLevelRenderer",
|
||||
"client.MixinLightmap",
|
||||
"client.MixinOptionsScreen"
|
||||
],
|
||||
"server": [],
|
||||
"plugin": "com.seibel.lod.mixins.ForgeMixinPlugin"
|
||||
"plugin": "com.seibel.lod.forge.mixins.ForgeMixinPlugin"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
public net.minecraft.world.level.lighting.LevelLightEngine f_75802_
|
||||
public net.minecraft.world.level.lighting.LevelLightEngine f_75803_
|
||||
public net.minecraft.client.renderer.LevelRenderer$RenderChunkInfo
|
||||
public net.minecraft.client.renderer.LevelRenderer$RenderChunkInfo f_109839_
|
||||
public net.minecraft.world.level.biome.Biome f_47438_
|
||||
public net.minecraft.world.level.biome.Biome f_47442_
|
||||
public net.minecraft.client.renderer.texture.TextureAtlasSprite$AnimatedTexture
|
||||
public net.minecraft.client.renderer.texture.TextureAtlasSprite$AnimatedTexture m_174764_(I)I
|
||||
public net.minecraft.client.renderer.texture.TextureAtlasSprite$AnimatedTexture m_174759_(I)I
|
||||
public net.minecraft.world.level.levelgen.Heightmap m_64245_(III)V
|
||||
public net.minecraft.world.level.storage.DimensionDataStorage f_78146_
|
||||
public net.minecraft.client.renderer.LevelRenderer f_194307_
|
||||
public-f com.mojang.math.Matrix4f
|
||||
public net.minecraft.client.renderer.texture.TextureAtlasSprite f_118342_
|
||||
public net.minecraft.client.renderer.texture.TextureAtlasSprite f_174723_
|
||||
public net.minecraft.client.renderer.texture.TextureAtlasSprite f_174725_
|
||||
public net.minecraft.client.renderer.texture.TextureAtlasSprite f_174724_
|
||||
public net.minecraft.client.renderer.LevelRenderer$RenderChunkStorage
|
||||
public net.minecraft.client.renderer.GameRenderer m_109141_(Lnet/minecraft/client/Camera;FZ)D
|
||||
public-f net.minecraft.util.ThreadingDetector f_199409_
|
||||
public net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator m_188662_(Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;II)Lnet/minecraft/world/level/chunk/ChunkAccess;
|
||||
public com.mojang.blaze3d.vertex.VertexBuffer f_166859_
|
||||
public com.mojang.blaze3d.vertex.VertexBuffer f_166863_
|
||||
public net.minecraft.server.level.ChunkMap f_140135_
|
||||
public net.minecraft.server.level.ChunkMap m_140427_(Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/nbt/CompoundTag;
|
||||
public net.minecraft.client.renderer.LightTexture f_109870_
|
||||
public net.minecraft.client.renderer.LightTexture f_109871_
|
||||
public net.minecraft.world.level.lighting.LayerLightEngine m_75660_(JLnet/minecraft/world/level/chunk/DataLayer;Z)V
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
modLoader="javafml" #//mandatory
|
||||
loaderVersion="[36,42)" # // mandatory. This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||
loaderVersion="*" # // mandatory. Allow all forge versions as we are definding what Minecraft versions we requre later on
|
||||
license="LGPL"
|
||||
issueTrackerURL="${issues}"
|
||||
|
||||
@@ -24,3 +24,10 @@ issueTrackerURL="${issues}"
|
||||
#// Allow any version to be present (or not) on the server
|
||||
acceptableRemoteVersions="*"
|
||||
|
||||
|
||||
[[dependencies.lod]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="${compatible_forgemc_versions}" # Where we set what version of mc it is avalible for
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
+16
-13
@@ -1,31 +1,34 @@
|
||||
# Gradle stuff
|
||||
org.gradle.jvmargs=-Xmx4096M
|
||||
org.gradle.parallel=true
|
||||
org.gradle.caching=true
|
||||
|
||||
# Mod Info
|
||||
archives_base_name=DistantHorizons
|
||||
mod_version=1.7.0-a-dev
|
||||
mod_name=DistantHorizons
|
||||
mod_version=2.0.0-a-dev
|
||||
maven_group=com.seibel.lod
|
||||
mod_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_authors=["James Seibel", "Leonardo Amato", "Cola", "coolGi", "Ran", "Leetom"]
|
||||
mod_homepage=https://www.curseforge.com/minecraft/mc-mods/distant-horizons
|
||||
mod_source=https://gitlab.com/jeseibel/minecraft-lod-mod/
|
||||
mod_issues=https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues
|
||||
|
||||
# Architectury Version & Info
|
||||
architectury_version=5.7.28
|
||||
enabled_platforms=fabric,forge
|
||||
mod_discord=https://discord.gg/xAB8G4cENx
|
||||
|
||||
# Global Plugin Versions
|
||||
manifold_version=2023.1.0
|
||||
toml_version=3.6.4
|
||||
nightconfig_version=3.6.6
|
||||
flatlaf_version=2.3
|
||||
flatlaf_version=3.0
|
||||
svgSalamander_version=1.1.3
|
||||
manifold_version=2022.1.19
|
||||
mcVersions=1.16.5,1.17.1,1.18.1,1.18.2,1.19,1.19.1,1.19.2
|
||||
|
||||
# Internal Properties (These are set at runtime)
|
||||
log4j_version=2.19.0
|
||||
lwjgl_version=3.2.3
|
||||
joml_version=1.10.2
|
||||
|
||||
# Internal Properties (These are set at runtime for Forgix to merge jar's)
|
||||
versionStr=
|
||||
|
||||
##### This defines what MC version Intellij will use for the preprocessor
|
||||
##### and what version is used automatically by build and run commands
|
||||
# This defines what MC version Intellij will use for the preprocessor
|
||||
# and what version is used automatically by build and run commands
|
||||
mcVer=1.18.2
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
||||
# TODO: Wait for forge to fix gradle 8 support, once it did change gradle to a newer version
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user