From 1d0d67d215417fa7ec998a649ca71204f4608da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Fri, 20 Feb 2026 15:00:13 +0100 Subject: [PATCH 01/68] 1.12.2 buildscript --- build.gradle | 14 +- cleanroom/build.gradle | 233 ++++++++++++++++++ cleanroom/gradle/scripts/helpers.gradle | 96 ++++++++ common/build.gradle | 12 +- .../common/wrappers/VersionConstants.java | 5 +- gradle.properties | 3 +- settings.gradle | 9 + versionProperties/1.12.2.properties | 63 +++++ 8 files changed, 425 insertions(+), 10 deletions(-) create mode 100644 cleanroom/build.gradle create mode 100644 cleanroom/gradle/scripts/helpers.gradle create mode 100644 versionProperties/1.12.2.properties diff --git a/build.gradle b/build.gradle index c9c8b6001..223ed2b78 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,17 @@ import org.apache.tools.zip.ZipOutputStream import java.util.function.Function import java.util.function.Predicate +buildscript { + configurations.configureEach { + resolutionStrategy.eachDependency { details -> + if (details.requested.group == "org.apache.commons" && details.requested.name == "commons-compress") { + + details.useVersion("1.28.0") + details.because("Needed because of Cleanroom. net.minecraftforge:DiffPatch:2.0.7 from dev.architectury.loom pulls ancient commons-compress 1.18") + } + } + } +} plugins { id "java" @@ -25,7 +36,6 @@ plugins { id "dev.architectury.loom" version "1.13-SNAPSHOT" apply false } - /** * Creates the list of preprocessors to use. * @@ -596,8 +606,6 @@ allprojects { p -> // VanillaGradle and Mixins in common maven { url "https://repo.spongepowered.org/maven/" } - // Canvas mod - maven { url "https://maven.vram.io/" } // ModMenu mod maven { url "https://maven.terraformersmc.com/" } diff --git a/cleanroom/build.gradle b/cleanroom/build.gradle new file mode 100644 index 000000000..8883d625e --- /dev/null +++ b/cleanroom/build.gradle @@ -0,0 +1,233 @@ +plugins { + id 'java' + id 'java-library' + id 'maven-publish' + id 'com.gradleup.shadow' version '9.2.2' + id 'xyz.wagyourtail.unimined' version '1.4.9-kappa' + id 'net.kyori.blossom' version '2.1.0' +} + +apply from: 'gradle/scripts/helpers.gradle' + +// Early Assertions +assertProperty 'mod_version' +assertProperty 'maven_group' +assertProperty 'mod_id' +assertProperty 'mod_name' + +version = propertyString('mod_version') +group = propertyString('maven_group') + +//base { +// archivesName.set(propertyString('mod_id')) +//} + + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } + //propertyBool('generate_sources_jar') + if (true) { + withSourcesJar() + } + //propertyBool('generate_javadocs_jar') + if (false) { + withJavadocJar() + } +} + +configurations { + embed + contain + implementation.extendsFrom(embed) + implementation.extendsFrom(contain) + modCompileOnly + compileOnly.extendsFrom(modCompileOnly) + modRuntimeOnly + runtimeOnly.extendsFrom(modRuntimeOnly) +} + +unimined.minecraft { + version "1.12.2" + + mappings { + mcp("stable", "39-1.12") + } + + cleanroom { + loader "0.3.31-alpha" + runs.auth.username = "Developer" + runs.all { + systemProperty("crl.dev.mixin", "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json") + def extraArgs = '' + if (extraArgs != null && !extraArgs.trim().isEmpty()) { + jvmArgs += extraArgs.split { "\\s+" }.toList() + } + if (propertyBool('enable_foundation_debug')) { + systemProperty("foundation.dump", "true") + systemProperty("foundation.verbose", "true") + } + //propertyBool('is_coremod') + if (true) { + //coremod_plugin_class_name + systemProperty("fml.coreMods.load", propertyString('com.seibel.distanthorizons.forge.DistantHorizonsLoadingPlugin')) + } + return + } + } + + defaultRemapJar = false + + if (propertyBool('enable_shadow')) { + remap(tasks.shadowJar) { + mixinRemap { + enableBaseMixin() + enableMixinExtra() + disableRefmap() + } + } + } else { + remap(tasks.jar) { + mixinRemap { + enableBaseMixin() + enableMixinExtra() + disableRefmap() + } + } + } + + mods { + remap(configurations.modCompileOnly) + remap(configurations.modRuntimeOnly) + } +} + +dependencies { + //propertyBool('enable_junit_testing') + if (true) { + testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + } +} + +processResources { + + inputs.property 'mod_id', propertyString('mod_id') + inputs.property 'mod_name', propertyString('mod_name') + inputs.property 'mod_version', propertyString('mod_version') + inputs.property 'mod_description', propertyString('mod_description') + inputs.property 'mod_authors', "${propertyStringList('mod_authors', ',').join(', ')}" + inputs.property 'mod_credits', propertyString('mod_credits') + inputs.property 'mod_url', propertyString('mod_url') + inputs.property 'mod_update_json', propertyString('mod_update_json') + inputs.property 'mod_logo_path', propertyString('mod_logo_path') + + def filterList = ['mcmod.info', 'pack.mcmeta'] + + filesMatching(filterList) { fcd -> + fcd.expand( + 'mod_id': propertyString('mod_id'), + 'mod_name': propertyString('mod_name'), + 'mod_version': propertyString('mod_version'), + 'mod_description': propertyString('mod_description'), + 'mod_authors': "${propertyStringList('mod_authors', ',').join(', ')}", + 'mod_credits': propertyString('mod_credits'), + 'mod_url': propertyString('mod_url'), + 'mod_update_json': propertyString('mod_update_json'), + 'mod_logo_path': propertyString('mod_logo_path'), + ) + } + + rename '(.+_at.cfg)', 'META-INF/$1' +} + +sourceSets { + main { + blossom { + javaSources { + property('mod_id', propertyString('mod_id')) + property('mod_name', propertyString('mod_name')) + property('mod_version', propertyString('mod_version')) + property('package', "${maven_group}.${mod_id}") + } + } + } +} + +if (!propertyBool('enable_shadow')) { + shadowJar.enabled = false +} + +jar { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + if (configurations.contain.size() > 0) { + into('/') { + from configurations.contain + } + } + doFirst { + manifest { + def attribute_map = [:] + attribute_map['ModType'] = "CRL" + attribute_map['MixinConfigs'] = "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json" + if (configurations.contain.size() > 0) { + attribute_map['ContainedDeps'] = configurations.contain.collect { it.name }.join(' ') + attribute_map['NonModDeps'] = true + } + //propertyBool('is_coremod') + if (true) { + //coremod_plugin_class_name + attribute_map['FMLCorePlugin'] = propertyString('com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin') + //coremod_includes_mod + if (true) { + attribute_map['FMLCorePluginContainsFMLMod'] = true + } + } + if (propertyBool('use_access_transformer')) { + attribute_map['FMLAT'] = propertyString('access_transformer_locations') + } + attributes(attribute_map) + } + } + if (propertyBool('enable_shadow')) { + finalizedBy(tasks.named("remapShadowJar")) + } else { + finalizedBy(tasks.named("remapJar")) + } +} + + +shadowJar { + configurations = [project.configurations.shadow] + archiveClassifier = "shadow" +} + +remapJar { + doFirst { + logging.captureStandardOutput LogLevel.INFO + } + doLast { + logging.captureStandardOutput LogLevel.QUIET + } +} + +compileTestJava { + sourceCompatibility = targetCompatibility = JavaVersion.VERSION_21 +} + +test { + useJUnitPlatform() + javaLauncher.set(javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(21) + }) + if (propertyBool('show_testing_output')) { + testLogging { + showStandardStreams = true + } + } +} + +tasks.withType(JavaCompile).configureEach { + options.encoding = 'UTF-8' +} \ No newline at end of file diff --git a/cleanroom/gradle/scripts/helpers.gradle b/cleanroom/gradle/scripts/helpers.gradle new file mode 100644 index 000000000..0b3f2ee7f --- /dev/null +++ b/cleanroom/gradle/scripts/helpers.gradle @@ -0,0 +1,96 @@ +import groovy.text.SimpleTemplateEngine +import org.codehaus.groovy.runtime.MethodClosure + +ext.propertyString = this.&propertyString as MethodClosure +ext.propertyBool = this.&propertyBool as MethodClosure +ext.propertyStringList = this.&propertyStringList as MethodClosure +ext.interpolate = this.&interpolate as MethodClosure +ext.assertProperty = this.&assertProperty as MethodClosure +ext.assertSubProperties = this.&assertSubProperties as MethodClosure +ext.setDefaultProperty = this.&setDefaultProperty as MethodClosure +ext.assertEnvironmentVariable = this.&assertEnvironmentVariable as MethodClosure + +String propertyString(String key) { + return $property(key).toString() +} + +boolean propertyBool(String key) { + return propertyString(key).toBoolean() +} + +Collection propertyStringList(String key) { + return propertyStringList(key, ' ') +} + +Collection propertyStringList(String key, String delimit) { + return propertyString(key).split(delimit).findAll { !it.isEmpty() } +} + +private Object $property(String key) { + def value = project.findProperty(key) + if (value instanceof String) { + return interpolate(value) + } + return value +} + +String interpolate(String value) { + if (value.startsWith('${{') && value.endsWith('}}')) { + value = value.substring(3, value.length() - 2) + Binding newBinding = new Binding(this.binding.getVariables()) + newBinding.setProperty('it', this) + return new GroovyShell(this.getClass().getClassLoader(), newBinding).evaluate(value) + } + if (value.contains('${')) { + return new SimpleTemplateEngine().createTemplate(value).make(project.properties).toString() + } + return value +} + +void assertProperty(String propertyName) { + def property = property(propertyName) + if (property == null) { + throw new GradleException("Property ${propertyName} is not defined!") + } + if (property.isEmpty()) { + throw new GradleException("Property ${propertyName} is empty!") + } +} + +void assertSubProperties(String propertyName, String... subPropertyNames) { + assertProperty(propertyName) + if (propertyBool(propertyName)) { + for (String subPropertyName : subPropertyNames) { + assertProperty(subPropertyName) + } + } +} + +void setDefaultProperty(String propertyName, boolean warn, defaultValue) { + def property = property(propertyName) + def exists = true + if (property == null) { + exists = false + if (warn) { + project.logger.log(LogLevel.WARN, "Property ${propertyName} is not defined!") + } + } else if (property.isEmpty()) { + exists = false + if (warn) { + project.logger.log(LogLevel.WARN, "Property ${propertyName} is empty!") + } + } + if (!exists) { + project.setProperty(propertyName, defaultValue.toString()) + } +} + +void assertEnvironmentVariable(String propertyName) { + def property = System.getenv(propertyName) + if (property == null) { + throw new GradleException("System Environment Variable $propertyName is not defined!") + } + if (property.isEmpty()) { + throw new GradleException("Property $propertyName is empty!") + } +} diff --git a/common/build.gradle b/common/build.gradle index 40870f24e..c70889d3f 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -10,13 +10,15 @@ buildscript { } } -plugins { - id "org.spongepowered.gradle.vanilla" version "0.2.1-SNAPSHOT" +if (rootProject.minecraft_version != "1.12.2") { + apply plugin: "org.spongepowered.gradle.vanilla" version "0.2.1-SNAPSHOT" } -minecraft { - accessWideners(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")) - version(rootProject.minecraft_version) +if (rootProject.minecraft_version != "1.12.2") { + minecraft { + accessWideners(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")) + version(rootProject.minecraft_version) + } } dependencies { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/VersionConstants.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/VersionConstants.java index dada9d870..2c265107f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/VersionConstants.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/VersionConstants.java @@ -43,7 +43,10 @@ public class VersionConstants implements IVersionConstants // it can't load client classes when running as a dedicated server, // which was how we were dynamically accessing the MC version string - #if MC_VER == MC_1_16_5 + #if MC_VER == MC_1_12_2 + return "1.12.2"; + + #elif MC_VER == MC_1_16_5 return "1.16.5"; #elif MC_VER == MC_1_17_1 diff --git a/gradle.properties b/gradle.properties index 0971562b1..850de47ff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,7 @@ mod_version=2.4.6-b-dev api_version=5.1.0 maven_group=com.seibel.distanthorizons mod_readable_name=Distant Horizons +mod_id=distanthorizons mod_description=This mod generates and renders simplified terrain beyond the normal view distance at a low performance cost. Allowing you to see much farther without turning your game into a slideshow. # Note: In forge's mods.toml this is hard coded because Architectury throws an error with setting it as a variable mod_authors=["James Seibel", "Leonardo Amato", "Cola", "coolGi", "Ran", "Leetom", "pshsh"] @@ -51,7 +52,7 @@ versionStr= # This defines what MC version Intellij will use for the preprocessor # and what version is used automatically by build and run commands -mcVer=1.21.11 +mcVer=1.12.2 # Defines the maximum amount of memory Minecraft is allowed when run in a development environment #minecraftMemoryJavaArg="-Xmx4G" diff --git a/settings.gradle b/settings.gradle index 41c8850ea..b32afe12d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -32,6 +32,15 @@ pluginManagement { name "ParchmentMC" url "https://maven.parchmentmc.org" } + maven { + url = "https://maven.wagyourtail.xyz/releases" + } + maven { + url = "https://maven.outlands.top/releases" + } + maven { + url = "https://maven.wagyourtail.xyz/snapshots" + } mavenCentral() gradlePluginPortal() diff --git a/versionProperties/1.12.2.properties b/versionProperties/1.12.2.properties new file mode 100644 index 000000000..98a524823 --- /dev/null +++ b/versionProperties/1.12.2.properties @@ -0,0 +1,63 @@ +# 1.12.2 version +java_version=21 +minecraft_version=1.12.2 +parchment_version= +compatible_minecraft_versions=["1.12.2"] +accessWidenerVersion= +builds_for=cleanroom +embed_joml=true + +# Netty +netty_version=4.2.9.Final + +# LWJGL +lwjgl_version=3.3.6 + +# Fabric loader +fabric_loader_version= +fabric_api_version= +# Fabric mod versions +modmenu_version= +starlight_version_fabric= +phosphor_version_fabric= +lithium_version= +sodium_version= +iris_version= +bclib_version= +immersive_portals_version= +canvas_version= + +# iris - needs 1.7.4+ to support the DH API +fabric_incompatibility_list={ "iris": "*" } +fabric_recommend_list={} + +# Fabric mod run +# 0 = Don't enable and don't run +# 1 = Can be referenced in code but doesn't run +# 2 = Can be referenced in code and runs in client +enable_mod_menu=0 +enable_starlight=0 +enable_phosphor=0 +enable_lithium=0 +enable_sodium=0 +enable_iris=0 +# not available via github, use curse.maven if necessary +enable_bclib=0 +enable_immersive_portals=0 +enable_canvas=0 + +# Forge loader +forge_version= +# Neo not used but the variable still needs to be defined to make gradle happy +neoforge_version_range=[*,) + +# Forge mod versions +terraforged_version= + +# Forge mod run +# 0 = Don't enable and don't run +# 1 = Can be referenced in code but doesn't run +# 2 = Can be referenced in code and runs in client +enable_starlight_forge=0 +enable_terraforged=0 +enable_terrafirmacraft=0 From c5adc3f72a6a09c57758eb044cf1687bd4b8a71d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Wed, 11 Mar 2026 09:20:32 +0100 Subject: [PATCH 02/68] 1.12.2 working in dev --- build.gradle | 20 +- cleanroom/build.gradle | 70 +- .../cleanroom/CleanroomClientProxy.java | 245 +++++++ .../cleanroom/CleanroomMain.java | 129 ++++ .../CleanroomPluginPacketSender.java | 96 +++ .../cleanroom/CleanroomServerProxy.java | 149 ++++ .../DistantHorizonsConfigPlugin.java | 37 + .../DistantHorizonsLoadingPlugin.java | 33 + .../mixins/client/MixinEntityRenderer.java | 71 ++ .../client/MixinNetHandlerPlayClient.java | 27 + .../mixins/client/MixinOptionsScreen.java | 83 +++ .../mixins/client/MixinRenderGlobal.java | 62 ++ .../common/MixinChunkProviderServer.java | 26 + .../mixins/server/MixinEntityPlayerMP.java | 49 ++ .../cleanroom/modAccessor/ModChecker.java | 52 ++ .../resources/1_12_2_distanthorizons_at.cfg | 3 + .../assets/distanthorizons/lang/en_us.lang | 647 ++++++++++++++++++ .../textures/clouds-original.png | Bin 0 -> 6214 bytes .../distanthorizons/textures/clouds.png | Bin 0 -> 553 bytes .../distanthorizons/textures/gui/button.png | Bin 0 -> 3198 bytes .../textures/gui/changelog.png | Bin 0 -> 299 bytes .../textures/jar/themeDark.svg | 40 ++ .../textures/jar/themeLight.svg | 76 ++ .../assets/distanthorizons/textures/null.svg | 10 + .../distanthorizons/textures/test-grid.png | Bin 0 -> 1103 bytes .../distanthorizons.default.mixin.json | 19 + .../resources/distanthorizons.mod.mixin.json | 11 + .../src/main/resources/shaders/apply.frag | 33 + .../main/resources/shaders/debug/frag.frag | 10 + .../main/resources/shaders/debug/vert.vert | 10 + .../main/resources/shaders/fade/apply.frag | 14 + .../main/resources/shaders/fade/dhFade.frag | 65 ++ .../resources/shaders/fade/vanillaFade.frag | 91 +++ .../main/resources/shaders/flat_shaded.frag | 123 ++++ .../src/main/resources/shaders/fog/apply.frag | 27 + .../src/main/resources/shaders/fog/fog.frag | 297 ++++++++ .../shaders/genericObject/direct/frag.frag | 10 + .../shaders/genericObject/direct/vert.vert | 41 ++ .../shaders/genericObject/instanced/frag.frag | 10 + .../shaders/genericObject/instanced/vert.vert | 66 ++ .../main/resources/shaders/noise/noise.frag | 74 ++ .../src/main/resources/shaders/quadApply.vert | 15 + .../src/main/resources/shaders/ssao/ao.frag | 130 ++++ .../main/resources/shaders/ssao/apply.frag | 78 +++ .../src/main/resources/shaders/standard.vert | 79 +++ .../src/main/resources/shaders/test/dark.frag | 9 + .../src/main/resources/shaders/test/frag.frag | 9 + .../src/main/resources/shaders/test/vert.vert | 11 + .../0010-sqlite-createInitialDataTables.sql | 37 + ...20-sqlite-createFullDataSourceV2Tables.sql | 33 + .../0030-sqlite-changeTableJournaling.sql | 9 + .../0031-sqlite-useSqliteWalJournaling.sql | 8 + .../0040-sqlite-removeRenderCache.sql | 4 + .../0050-sqlite-addApplyToParentIndex.sql | 3 + .../0060-sqlite-createChunkHashTable.sql | 13 + .../0070-sqlite-createBeaconBeamTable.sql | 16 + .../0080-sqlite-addApplyToChildrenColumn.sql | 9 + ...0090-sqlite-addAdjacentFullDataColumns.sql | 12 + ...100-sqlite-deleteLowDetailDataForRegen.sql | 13 + .../src/main/resources/sqlScripts/readme.md | 51 ++ .../main/resources/sqlScripts/scriptList.txt | 12 + .../common/AbstractModInitializer.java | 19 +- .../common/AbstractPluginPacketSender.java | 19 +- .../common/commands/AbstractCommand.java | 2 + .../common/commands/CommandInitializer.java | 2 + .../common/commands/ConfigCommand.java | 4 +- .../common/commands/CrashCommand.java | 2 + .../common/commands/DebugCommand.java | 2 + .../common/commands/PregenCommand.java | 2 + .../commonMixins/DhUpdateScreenBase.java | 10 +- .../commonMixins/MixinChunkMapCommon.java | 21 +- .../common/util/ProxyUtil.java | 15 +- .../common/wrappers/McObjectConverter.java | 40 +- .../common/wrappers/WrapperFactory.java | 39 +- .../wrappers/block/AbstractDhTintGetter.java | 7 +- .../common/wrappers/block/BiomeWrapper.java | 34 +- .../wrappers/block/BlockStateWrapper.java | 130 +++- .../block/ClientBlockStateColorCache.java | 152 +++- .../block/TextureAtlasSpriteWrapper.java | 5 +- .../wrappers/block/TintGetterOverride.java | 3 +- .../block/TintWithoutLevelOverrider.java | 3 +- .../common/wrappers/chunk/ChunkWrapper.java | 98 ++- .../common/wrappers/gui/ClassicConfigGUI.java | 438 +++++++++--- .../common/wrappers/gui/DhScreen.java | 57 +- .../common/wrappers/gui/GetConfigScreen.java | 6 +- .../common/wrappers/gui/GuiHelper.java | 58 +- .../common/wrappers/gui/LangWrapper.java | 13 +- .../common/wrappers/gui/MinecraftScreen.java | 98 ++- .../common/wrappers/gui/OnPressed.java | 8 + .../wrappers/gui/TexturedButtonWidget.java | 69 +- .../wrappers/gui/config/ConfigGuiInfo.java | 14 +- .../wrappers/gui/updater/ChangelogScreen.java | 5 +- .../wrappers/gui/updater/UpdateModScreen.java | 5 +- .../level/KeyedClientLevelManager.java | 6 +- .../level/ServerKeyedClientLevelWrapper.java | 6 +- .../minecraft/MinecraftClientWrapper.java | 99 ++- .../minecraft/MinecraftGLWrapper.java | 95 ++- .../minecraft/MinecraftRenderWrapper.java | 104 ++- .../minecraft/MinecraftServerWrapper.java | 6 +- .../wrappers/minecraft/ProfilerWrapper.java | 14 +- .../wrappers/misc/IMixinServerPlayer.java | 7 +- .../common/wrappers/misc/LightMapWrapper.java | 26 +- .../wrappers/misc/MutableBlockPosWrapper.java | 4 + .../wrappers/misc/ServerPlayerWrapper.java | 48 +- .../wrappers/world/ClientLevelWrapper.java | 82 ++- .../wrappers/world/DimensionTypeWrapper.java | 38 +- .../wrappers/world/ServerLevelWrapper.java | 64 +- .../BatchGenerationEnvironment.java | 26 +- .../worldGeneration/ChunkPosGenStream.java | 4 + .../worldGeneration/GenerationEvent.java | 8 +- .../InternalServerGenerator.java | 106 ++- .../ChunkCompoundTagParser.java | 2 + .../chunkFileHandling/ChunkFileReader.java | 2 + .../chunkFileHandling/CompoundTagUtil.java | 2 + .../mimicObject/DhLitWorldGenRegion.java | 4 +- .../mimicObject/DummyLightEngine.java | 4 +- .../mimicObject/LightGetterAdaptor.java | 4 +- .../RegionFileStorageExternalCache.java | 2 + .../params/GlobalWorldGenParams.java | 47 +- .../params/ThreadWorldGenParams.java | 4 +- .../step/AbstractWorldGenStep.java | 2 + .../worldGeneration/step/StepBiomes.java | 4 +- .../worldGeneration/step/StepFeatures.java | 4 +- .../worldGeneration/step/StepNoise.java | 4 +- .../step/StepStructureReference.java | 4 +- .../step/StepStructureStart.java | 4 +- .../worldGeneration/step/StepSurface.java | 4 +- settings.gradle | 1 + 128 files changed, 5096 insertions(+), 502 deletions(-) create mode 100644 cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomClientProxy.java create mode 100644 cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomMain.java create mode 100644 cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomPluginPacketSender.java create mode 100644 cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java create mode 100644 cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/DistantHorizonsConfigPlugin.java create mode 100644 cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/DistantHorizonsLoadingPlugin.java create mode 100644 cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinEntityRenderer.java create mode 100644 cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinNetHandlerPlayClient.java create mode 100644 cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinOptionsScreen.java create mode 100644 cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinRenderGlobal.java create mode 100644 cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/common/MixinChunkProviderServer.java create mode 100644 cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/server/MixinEntityPlayerMP.java create mode 100644 cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/modAccessor/ModChecker.java create mode 100644 cleanroom/src/main/resources/1_12_2_distanthorizons_at.cfg create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/lang/en_us.lang create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/textures/clouds-original.png create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/textures/clouds.png create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/textures/gui/button.png create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/textures/gui/changelog.png create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/textures/jar/themeDark.svg create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/textures/jar/themeLight.svg create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/textures/null.svg create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/textures/test-grid.png create mode 100644 cleanroom/src/main/resources/distanthorizons.default.mixin.json create mode 100644 cleanroom/src/main/resources/distanthorizons.mod.mixin.json create mode 100644 cleanroom/src/main/resources/shaders/apply.frag create mode 100644 cleanroom/src/main/resources/shaders/debug/frag.frag create mode 100644 cleanroom/src/main/resources/shaders/debug/vert.vert create mode 100644 cleanroom/src/main/resources/shaders/fade/apply.frag create mode 100644 cleanroom/src/main/resources/shaders/fade/dhFade.frag create mode 100644 cleanroom/src/main/resources/shaders/fade/vanillaFade.frag create mode 100644 cleanroom/src/main/resources/shaders/flat_shaded.frag create mode 100644 cleanroom/src/main/resources/shaders/fog/apply.frag create mode 100644 cleanroom/src/main/resources/shaders/fog/fog.frag create mode 100644 cleanroom/src/main/resources/shaders/genericObject/direct/frag.frag create mode 100644 cleanroom/src/main/resources/shaders/genericObject/direct/vert.vert create mode 100644 cleanroom/src/main/resources/shaders/genericObject/instanced/frag.frag create mode 100644 cleanroom/src/main/resources/shaders/genericObject/instanced/vert.vert create mode 100644 cleanroom/src/main/resources/shaders/noise/noise.frag create mode 100644 cleanroom/src/main/resources/shaders/quadApply.vert create mode 100644 cleanroom/src/main/resources/shaders/ssao/ao.frag create mode 100644 cleanroom/src/main/resources/shaders/ssao/apply.frag create mode 100644 cleanroom/src/main/resources/shaders/standard.vert create mode 100644 cleanroom/src/main/resources/shaders/test/dark.frag create mode 100644 cleanroom/src/main/resources/shaders/test/frag.frag create mode 100644 cleanroom/src/main/resources/shaders/test/vert.vert create mode 100644 cleanroom/src/main/resources/sqlScripts/0010-sqlite-createInitialDataTables.sql create mode 100644 cleanroom/src/main/resources/sqlScripts/0020-sqlite-createFullDataSourceV2Tables.sql create mode 100644 cleanroom/src/main/resources/sqlScripts/0030-sqlite-changeTableJournaling.sql create mode 100644 cleanroom/src/main/resources/sqlScripts/0031-sqlite-useSqliteWalJournaling.sql create mode 100644 cleanroom/src/main/resources/sqlScripts/0040-sqlite-removeRenderCache.sql create mode 100644 cleanroom/src/main/resources/sqlScripts/0050-sqlite-addApplyToParentIndex.sql create mode 100644 cleanroom/src/main/resources/sqlScripts/0060-sqlite-createChunkHashTable.sql create mode 100644 cleanroom/src/main/resources/sqlScripts/0070-sqlite-createBeaconBeamTable.sql create mode 100644 cleanroom/src/main/resources/sqlScripts/0080-sqlite-addApplyToChildrenColumn.sql create mode 100644 cleanroom/src/main/resources/sqlScripts/0090-sqlite-addAdjacentFullDataColumns.sql create mode 100644 cleanroom/src/main/resources/sqlScripts/0100-sqlite-deleteLowDetailDataForRegen.sql create mode 100644 cleanroom/src/main/resources/sqlScripts/readme.md create mode 100644 cleanroom/src/main/resources/sqlScripts/scriptList.txt create mode 100644 common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/OnPressed.java diff --git a/build.gradle b/build.gradle index 223ed2b78..a76f47374 100644 --- a/build.gradle +++ b/build.gradle @@ -12,10 +12,10 @@ buildscript { configurations.configureEach { resolutionStrategy.eachDependency { details -> if (details.requested.group == "org.apache.commons" && details.requested.name == "commons-compress") { - details.useVersion("1.28.0") details.because("Needed because of Cleanroom. net.minecraftforge:DiffPatch:2.0.7 from dev.architectury.loom pulls ancient commons-compress 1.18") } + } } } @@ -33,7 +33,9 @@ plugins { id "systems.manifold.manifold-gradle-plugin" version "0.0.2-alpha" // Architectury is used here only as a replacement for forge's own loom - id "dev.architectury.loom" version "1.13-SNAPSHOT" apply false + id "dev.architectury.loom" version "1.0-SNAPSHOT" apply false + + id 'xyz.wagyourtail.unimined' version '1.4.10-kappa' apply false } /** @@ -160,6 +162,20 @@ subprojects { p -> apply plugin: "com.github.johnrengelman.shadow" if (isMinecraftSubProject) apply plugin: "systems.manifold.manifold-gradle-plugin" + + + if (rootProject.minecraft_version == "1.12.2" && p == project(":common")) { + p.afterEvaluate { + def cleanroomProject = project(":cleanroom") + cleanroomProject.afterEvaluate { + p.dependencies { + compileOnly p.files(cleanroomProject.configurations.minecraftLibraries.files) + compileOnly p.files(cleanroomProject.configurations.forgeRuntimeLibrary.files) + compileOnly p.files(cleanroomProject.configurations.minecraft.files) + } + } + } + } // Apply forge's loom if ((findProject(":forge") && p == project(":forge")) || diff --git a/cleanroom/build.gradle b/cleanroom/build.gradle index 8883d625e..acc649268 100644 --- a/cleanroom/build.gradle +++ b/cleanroom/build.gradle @@ -3,8 +3,8 @@ plugins { id 'java-library' id 'maven-publish' id 'com.gradleup.shadow' version '9.2.2' - id 'xyz.wagyourtail.unimined' version '1.4.9-kappa' - id 'net.kyori.blossom' version '2.1.0' + id 'xyz.wagyourtail.unimined' version '1.4.10-kappa' + id 'net.kyori.blossom' version '2.1.0' } apply from: 'gradle/scripts/helpers.gradle' @@ -56,7 +56,11 @@ unimined.minecraft { } cleanroom { - loader "0.3.31-alpha" + //propertyBool('use_access_transformer') + if (true) { + accessTransformer "${rootProject.projectDir}/cleanroom/src/main/resources/1_12_2_distanthorizons_at.cfg" + } + loader "0.4.4-alpha" runs.auth.username = "Developer" runs.all { systemProperty("crl.dev.mixin", "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json") @@ -64,15 +68,47 @@ unimined.minecraft { if (extraArgs != null && !extraArgs.trim().isEmpty()) { jvmArgs += extraArgs.split { "\\s+" }.toList() } - if (propertyBool('enable_foundation_debug')) { + + println "Classpath size BEFORE: ${classpath.files.size()}" + + classpath = classpath.filter { file -> + def remove = + file.path.contains("DistantHorizons-common") || + file.path.contains("DistantHorizons-core") || + file.path.contains("DistantHorizons-api") + + if (remove) { + println "Removing from classpath: $file" + } + + return !remove + } + + println "Classpath size AFTER: ${classpath.files.size()}" + + def extraPath = [ + sourceSets.main.output.classesDirs.asPath, + sourceSets.main.output.resourcesDir.absolutePath, + rootProject.project(':common').sourceSets.main.output.classesDirs.asPath, + rootProject.project(':core').sourceSets.main.output.classesDirs.asPath, + rootProject.project(':api').sourceSets.main.output.classesDirs.asPath, + ].join(File.pathSeparator) + + jvmArgs -= ("-Dcrl.dev.extrapath=") + jvmArgs += ("-Dcrl.dev.extrapath=${extraPath}") + + if (false) { systemProperty("foundation.dump", "true") systemProperty("foundation.verbose", "true") } //propertyBool('is_coremod') if (true) { //coremod_plugin_class_name - systemProperty("fml.coreMods.load", propertyString('com.seibel.distanthorizons.forge.DistantHorizonsLoadingPlugin')) + //forge for now bcs it will crash but correct is .cleanroom + systemProperty("fml.coreMods.load", "com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin") } + + return } } @@ -104,11 +140,7 @@ unimined.minecraft { } dependencies { - //propertyBool('enable_junit_testing') - if (true) { - testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1' - testRuntimeOnly 'org.junit.platform:junit-platform-launcher' - } + compileOnly "com.cleanroommc:sponge-mixin:0.20.12+mixin.0.8.7" } processResources { @@ -167,6 +199,13 @@ jar { } } doFirst { + archiveClassifier = 'dev' + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + if (configurations.contain.size() > 0) { + into('/') { + from configurations.contain + } + } manifest { def attribute_map = [:] attribute_map['ModType'] = "CRL" @@ -178,14 +217,15 @@ jar { //propertyBool('is_coremod') if (true) { //coremod_plugin_class_name - attribute_map['FMLCorePlugin'] = propertyString('com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin') + attribute_map['FMLCorePlugin'] = "com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin" //coremod_includes_mod if (true) { attribute_map['FMLCorePluginContainsFMLMod'] = true } } - if (propertyBool('use_access_transformer')) { - attribute_map['FMLAT'] = propertyString('access_transformer_locations') + //propertyBool('use_access_transformer') + if (true) { + attribute_map['FMLAT'] = "1_12_2_distanthorizons_at.cfg" } attributes(attribute_map) } @@ -197,7 +237,6 @@ jar { } } - shadowJar { configurations = [project.configurations.shadow] archiveClassifier = "shadow" @@ -221,7 +260,8 @@ test { javaLauncher.set(javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(21) }) - if (propertyBool('show_testing_output')) { + //propertyBool('show_testing_output') + if (false) { testLogging { showStandardStreams = true } diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomClientProxy.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomClientProxy.java new file mode 100644 index 000000000..5e905be9a --- /dev/null +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomClientProxy.java @@ -0,0 +1,245 @@ +/* + * This file is part of the Distant Horizons mod + * licensed under the GNU LGPL v3 License. + * + * Copyright (C) 2020 James Seibel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.seibel.distanthorizons.cleanroom; + +import com.seibel.distanthorizons.common.AbstractModInitializer; +import com.seibel.distanthorizons.common.util.ProxyUtil; +import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; +import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper; +import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper; +import com.seibel.distanthorizons.core.api.internal.ClientApi; +import com.seibel.distanthorizons.core.api.internal.ServerApi; +import com.seibel.distanthorizons.core.api.internal.SharedApi; +import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; +import com.seibel.distanthorizons.core.logging.DhLogger; +import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; +import com.seibel.distanthorizons.core.logging.f3.F3Screen; +import com.seibel.distanthorizons.core.network.messages.AbstractNetworkMessage; +import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil; +import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper; + +import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; +import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender; +import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper; +import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; +import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.event.world.ChunkEvent; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.InputEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.jetbrains.annotations.NotNull; +import org.lwjgl.glfw.GLFW; +import org.lwjgl.opengl.GL32; + +import java.util.concurrent.AbstractExecutorService; + +/** + * This handles all events sent to the client, + * and is the starting point for most of the mod. + * + * @author James_Seibel + * @version 2023-7-27 + */ +public class CleanroomClientProxy implements AbstractModInitializer.IEventProxy +{ + private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class); + private static final CleanroomPluginPacketSender PACKET_SENDER = (CleanroomPluginPacketSender) SingletonInjector.INSTANCE.get(IPluginPacketSender.class); + private static final DhLogger LOGGER = new DhLoggerBuilder().build(); + + private static World GetEventLevel(WorldEvent e) { return e.getWorld(); } + + + @Override + public void registerEvents() + { + MinecraftForge.EVENT_BUS.register(this); + + // handles singleplayer, LAN, and connecting to a server + PACKET_SENDER.setPacketHandler((IServerPlayerWrapper player, @NotNull AbstractNetworkMessage message) -> + { + ClientApi.INSTANCE.pluginMessageReceived(message); + ServerApi.INSTANCE.pluginMessageReceived(player, message); + }); + } + + + + //==============// + // world events // + //==============// + + @SubscribeEvent + public void clientLevelLoadEvent(WorldEvent.Load event) + { + LOGGER.info("level load"); + + World level = event.getWorld(); + if (!(level instanceof WorldClient clientLevel)) + { + return; + } + + IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel, true); + ClientApi.INSTANCE.clientLevelLoadEvent(clientLevelWrapper); + } + + @SubscribeEvent + public void clientLevelUnloadEvent(WorldEvent.Unload event) + { + LOGGER.info("level unload"); + + World level = event.getWorld(); + if (!(level instanceof WorldClient clientLevel)) + { + return; + } + + IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel); + ClientApi.INSTANCE.clientLevelUnloadEvent(clientLevelWrapper); + } + + + + //==============// + // chunk events // + //==============// + + @SubscribeEvent + public void rightClickBlockEvent(PlayerInteractEvent.RightClickBlock event) + { + if (MC.clientConnectedToDedicatedServer()) + { + World level = event.getWorld(); + + ILevelWrapper wrappedLevel = ProxyUtil.getLevelWrapper(level); + if (SharedApi.isChunkAtBlockPosAlreadyUpdating(wrappedLevel, event.getPos().getX(), event.getPos().getZ())) + { + return; + } + + AbstractExecutorService executor = ThreadPoolUtil.getFileHandlerExecutor(); + if (executor != null) + { + executor.execute(() -> + { + Chunk chunk = level.getChunk(event.getPos()); + SharedApi.INSTANCE.applyChunkUpdate(new ChunkWrapper(chunk, wrappedLevel), wrappedLevel); + }); + } + } + } + @SubscribeEvent + public void leftClickBlockEvent(PlayerInteractEvent.LeftClickBlock event) + { + if (MC.clientConnectedToDedicatedServer()) + { + World level = event.getWorld(); + + ILevelWrapper wrappedLevel = ProxyUtil.getLevelWrapper(level); + if (SharedApi.isChunkAtBlockPosAlreadyUpdating(wrappedLevel, event.getPos().getX(), event.getPos().getZ())) + { + return; + } + + AbstractExecutorService executor = ThreadPoolUtil.getFileHandlerExecutor(); + if (executor != null) + { + executor.execute(() -> + { + Chunk chunk = level.getChunk(event.getPos()); + SharedApi.INSTANCE.applyChunkUpdate(new ChunkWrapper(chunk, wrappedLevel), wrappedLevel); + }); + } + } + } + + @SubscribeEvent + public void clientChunkLoadEvent(ChunkEvent.Load event) + { + if (MC.clientConnectedToDedicatedServer()) + { + ILevelWrapper wrappedLevel = ProxyUtil.getLevelWrapper(GetEventLevel(event)); + IChunkWrapper chunkWrapper = new ChunkWrapper(event.getChunk(), wrappedLevel); + SharedApi.INSTANCE.applyChunkUpdate(chunkWrapper, wrappedLevel); + } + } + + + + //==============// + // key bindings // + //==============// + + @SubscribeEvent + public void registerKeyBindings(InputEvent.KeyInputEvent event) + { + /* if (Minecraft.getMinecraft().player == null) + { + return; + } + if (event.getAction() != GLFW.GLFW_PRESS) + { + return; + } + + ClientApi.INSTANCE.keyPressedEvent(event.getKey());*/ + } + + + //===========// + // rendering // + //===========// + + @SubscribeEvent + public void afterLevelRenderEvent(TickEvent.RenderTickEvent event) + { + if (event.type.equals(TickEvent.RenderTickEvent.Type.RENDER)) + { + try + { + // should generally only need to be set once per game session + // allows DH to render directly to Optifine's level frame buffer, + // allowing better shader support + MinecraftRenderWrapper.INSTANCE.finalLevelFrameBufferId = GL32.glGetInteger(GL32.GL_FRAMEBUFFER_BINDING); + } + catch (Exception | Error e) + { + LOGGER.error("Unexpected error in afterLevelRenderEvent: "+e.getMessage(), e); + } + } + } + + @SubscribeEvent + public void onRenderOverlay(RenderGameOverlayEvent.Text event) { + Minecraft mc = Minecraft.getMinecraft(); + if (event.isCanceled() || !mc.gameSettings.showDebugInfo) return; + + F3Screen.addStringToDisplay(event.getRight()); + } + +} diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomMain.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomMain.java new file mode 100644 index 000000000..fb88ba257 --- /dev/null +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomMain.java @@ -0,0 +1,129 @@ +/* + * This file is part of the Distant Horizons mod + * licensed under the GNU LGPL v3 License. + * + * Copyright (C) 2020 James Seibel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.seibel.distanthorizons.cleanroom; + +import com.seibel.distanthorizons.cleanroom.modAccessor.ModChecker; +import com.seibel.distanthorizons.common.AbstractModInitializer; +import com.seibel.distanthorizons.core.api.internal.ServerApi; +import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; +import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender; +import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker; +import com.seibel.distanthorizons.coreapi.ModInfo; +import net.minecraft.server.MinecraftServer; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLServerAboutToStartEvent; +import net.minecraftforge.fml.common.event.FMLServerStoppingEvent; + + +import java.util.function.Consumer; + +/** + * Initialize and setup the Mod.
+ * If you are looking for the real start of the mod + * check out the ClientProxy. + */ +@Mod(modid = ModInfo.ID, name = ModInfo.NAME, version = ModInfo.VERSION) +public class CleanroomMain extends AbstractModInitializer +{ + @Mod.Instance + public static CleanroomMain instance; + + @Mod.EventHandler + public void init(FMLInitializationEvent event) + { + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) + { + this.onInitializeClient(); + } + else + { + this.onInitializeServer(); + } + } + + @Override + protected void createInitialSharedBindings() + { + SingletonInjector.INSTANCE.bind(IModChecker.class, ModChecker.INSTANCE); + SingletonInjector.INSTANCE.bind(IPluginPacketSender.class, new CleanroomPluginPacketSender()); + } + @Override + protected void createInitialClientBindings() { /* no additional setup needed currently */ } + + @Override + protected IEventProxy createClientProxy() { return new CleanroomClientProxy(); } + + @Override + protected IEventProxy createServerProxy(boolean isDedicated) { return new CleanroomServerProxy(isDedicated); } + + @Override + protected void initializeModCompat() + { + + } + +/* @Override + protected void subscribeRegisterCommandsEvent(Consumer> eventHandler) + { MinecraftForge.EVENT_BUS.addListener((RegisterCommandsEvent e) -> { eventHandler.accept(e.getDispatcher()); }); }*/ + + @Override + protected void subscribeClientStartedEvent(Runnable eventHandler) + { + // Just run the event handler, since there are no proper ClientLifecycleEvent for the client + // to signify readiness other than FmlClientSetupEvent + eventHandler.run(); + } + + @Mod.EventHandler + public void onServerAboutToStart(FMLServerAboutToStartEvent event) + { + if (eventHandlerStartServer != null) + { + eventHandlerStartServer.accept(event.getServer()); + } + } + + Consumer eventHandlerStartServer; + + @Override + protected void subscribeServerStartingEvent(Consumer eventHandler) + { + eventHandlerStartServer = eventHandler; + } + + @Override + protected void runDelayedSetup() { SingletonInjector.INSTANCE.runDelayedSetup(); } + + // ServerWorldLoadEvent + @Mod.EventHandler + public void dedicatedWorldLoadEvent(FMLServerAboutToStartEvent event) + { + ServerApi.INSTANCE.serverLoadEvent(event.getServer().isDedicatedServer()); + } + + // ServerWorldUnloadEvent + @Mod.EventHandler + public void serverWorldUnloadEvent(FMLServerStoppingEvent event) + { + ServerApi.INSTANCE.serverUnloadEvent(); + } +} diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomPluginPacketSender.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomPluginPacketSender.java new file mode 100644 index 000000000..d710e835b --- /dev/null +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomPluginPacketSender.java @@ -0,0 +1,96 @@ +package com.seibel.distanthorizons.cleanroom; + +import com.seibel.distanthorizons.common.AbstractPluginPacketSender; +import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper; +import com.seibel.distanthorizons.core.network.messages.AbstractNetworkMessage; +import com.seibel.distanthorizons.core.network.messages.MessageRegistry; +import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraftforge.fml.common.network.NetworkRegistry; +import net.minecraftforge.fml.common.network.simpleimpl.IMessage; +import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; +import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; +import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; +import net.minecraftforge.fml.relauncher.Side; + +import java.util.function.BiConsumer; +import java.util.function.Consumer; + +public class CleanroomPluginPacketSender extends AbstractPluginPacketSender +{ + public static final SimpleNetworkWrapper PLUGIN_CHANNEL = + NetworkRegistry.INSTANCE.newSimpleChannel( + AbstractPluginPacketSender.WRAPPER_PACKET_RESOURCE + ); + + public static void setPacketHandler(Consumer consumer) + { + setPacketHandler((player, message) -> consumer.accept(message)); + } + static BiConsumer consumerPacket; + public static void setPacketHandler(BiConsumer consumer) + { + PLUGIN_CHANNEL.registerMessage(MessageWrapper.Handler.class, MessageWrapper.class, 0, Side.CLIENT); + PLUGIN_CHANNEL.registerMessage(MessageWrapper.Handler.class, MessageWrapper.class, 0, Side.SERVER); + consumerPacket = consumer; + } + + @Override + public void sendToServer(AbstractNetworkMessage message) + { + PLUGIN_CHANNEL.sendToServer(new MessageWrapper(message)); + } + + @Override + public void sendToClient(EntityPlayerMP serverPlayer, AbstractNetworkMessage message) + { + PLUGIN_CHANNEL.sendTo(new MessageWrapper(message), serverPlayer); + } + + // Forge doesn't support using abstract classes + @SuppressWarnings({"ClassCanBeRecord", "RedundantSuppression"}) + public static class MessageWrapper implements IMessage + { + public AbstractNetworkMessage message; + + public MessageWrapper(AbstractNetworkMessage message) { this.message = message; } + + public MessageWrapper() + { + // For reflection + } + + @Override + public void fromBytes(ByteBuf buf) { + int messageId = buf.readByte(); + message = MessageRegistry.INSTANCE.createMessage(messageId); + message.decode(buf); + } + + @Override + public void toBytes(ByteBuf buf) { + buf.writeByte(MessageRegistry.INSTANCE.getMessageId(message)); + message.encode(buf); + } + + public static class Handler implements IMessageHandler + { + @Override + public IMessage onMessage(MessageWrapper wrapper, MessageContext context) { + if (wrapper.message != null) + { + if (context.side == Side.SERVER) + { + consumerPacket.accept(ServerPlayerWrapper.getWrapper(context.getServerHandler().player), wrapper.message); + } + else { + consumerPacket.accept(null, wrapper.message); + } + } + return null; // No response needed + } + } + } + +} diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java new file mode 100644 index 000000000..fc132932f --- /dev/null +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java @@ -0,0 +1,149 @@ +package com.seibel.distanthorizons.cleanroom; + +import com.seibel.distanthorizons.common.AbstractModInitializer; +import com.seibel.distanthorizons.common.util.ProxyUtil; +import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; +import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper; +import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; +import com.seibel.distanthorizons.common.wrappers.worldGeneration.InternalServerGenerator; +import com.seibel.distanthorizons.core.api.internal.ServerApi; +import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; +import com.seibel.distanthorizons.core.logging.DhLogger; +import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; +import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper; +import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender; +import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.ForgeChunkManager; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.world.ChunkDataEvent; +import net.minecraftforge.event.world.ChunkEvent; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.event.FMLServerAboutToStartEvent; +import net.minecraftforge.fml.common.event.FMLServerStoppingEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.PlayerEvent; + +import java.lang.reflect.Field; + +public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy +{ + private static final CleanroomPluginPacketSender PACKET_SENDER = (CleanroomPluginPacketSender) SingletonInjector.INSTANCE.get(IPluginPacketSender.class); + private static World GetEventLevel(WorldEvent e) { return e.getWorld(); } + + private static final DhLogger LOGGER = new DhLoggerBuilder().build(); + private final ServerApi serverApi = ServerApi.INSTANCE; + private final boolean isDedicated; + + + + @Override + public void registerEvents() + { + MinecraftForge.EVENT_BUS.register(this); + if (this.isDedicated) + { + PACKET_SENDER.setPacketHandler(ServerApi.INSTANCE::pluginMessageReceived); + } + } + + + + //=============// + // constructor // + //=============// + + public CleanroomServerProxy(boolean isDedicated) { this.isDedicated = isDedicated; } + + + + //========// + // events // + //========// + + // ServerLevelLoadEvent + @SubscribeEvent + public void serverLevelLoadEvent(WorldEvent.Load event) + { + if (GetEventLevel(event) instanceof WorldServer) + { + this.serverApi.serverLevelLoadEvent(getServerLevelWrapper((WorldServer) GetEventLevel(event))); + InternalServerGenerator.DH_SERVER_GEN_TICKET = ForgeChunkManager.requestTicket(CleanroomMain.instance, event.getWorld(), ForgeChunkManager.Type.NORMAL); + //increase chunk limit + try + { + Field maxDepthField = InternalServerGenerator.DH_SERVER_GEN_TICKET.getClass().getDeclaredField("maxDepth"); + maxDepthField.setAccessible(true); + maxDepthField.setInt(InternalServerGenerator.DH_SERVER_GEN_TICKET, 1000); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } + + // ServerLevelUnloadEvent + @SubscribeEvent + public void serverLevelUnloadEvent(WorldEvent.Unload event) + { + if (GetEventLevel(event) instanceof WorldServer) + { + this.serverApi.serverLevelUnloadEvent(getServerLevelWrapper((WorldServer) GetEventLevel(event))); + } + } + + @SubscribeEvent + public void serverChunkLoadEvent(ChunkEvent.Load event) + { + ILevelWrapper levelWrapper = ProxyUtil.getLevelWrapper(GetEventLevel(event)); + IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), levelWrapper); + this.serverApi.serverChunkLoadEvent(chunk, levelWrapper); + } + + @SubscribeEvent + public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event) + { this.serverApi.serverPlayerJoinEvent(getServerPlayerWrapper(event)); } + @SubscribeEvent + public void playerLoggedOutEvent(PlayerEvent.PlayerLoggedOutEvent event) + { this.serverApi.serverPlayerDisconnectEvent(getServerPlayerWrapper(event)); } + @SubscribeEvent + public void playerChangedDimensionEvent(PlayerEvent.PlayerChangedDimensionEvent event) + { + this.serverApi.serverPlayerLevelChangeEvent( + getServerPlayerWrapper(event), + getServerLevelWrapper(event.fromDim, event), + getServerLevelWrapper(event.toDim, event) + ); + } + + + + //================// + // helper methods // + //================// + + private static ServerLevelWrapper getServerLevelWrapper(WorldServer level) { return ServerLevelWrapper.getWrapper(level); } + + + private static ServerLevelWrapper getServerLevelWrapper(int dimensionId, PlayerEvent event) + { + MinecraftServer server = event.player.getServer(); + if (server == null) + { + LOGGER.error("getServerLevelWrapper: server is null for player {}", event.player.getName()); + return null; + } + return getServerLevelWrapper(server.getWorld(dimensionId)); + } + + private static ServerPlayerWrapper getServerPlayerWrapper(PlayerEvent event) + { + return ServerPlayerWrapper.getWrapper((EntityPlayerMP) event.player); + } + +} diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/DistantHorizonsConfigPlugin.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/DistantHorizonsConfigPlugin.java new file mode 100644 index 000000000..25cc537ff --- /dev/null +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/DistantHorizonsConfigPlugin.java @@ -0,0 +1,37 @@ +package com.seibel.distanthorizons.cleanroom; + +import net.minecraftforge.fml.common.Loader; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Set; + +public class DistantHorizonsConfigPlugin implements IMixinConfigPlugin +{ + private static final Logger LOGGER = LogManager.getLogger(); + + @Override + public void onLoad(String mixinPackage) + { } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) + { +/* return switch (mixinClassName.split("\\.")[5]) { + case "mist" -> Loader.isModLoaded("mist"); + default -> true; + };*/ + return true; + } + + @Override public String getRefMapperConfig() { return null; } + @Override public void acceptTargets(Set myTargets, Set otherTargets) { } + @Override public List getMixins() { return null; } + @Override public void preApply(String targetClassName, ClassNode classNode, String mixinClassName, IMixinInfo mixinInfo) { } + @Override public void postApply(String targetClassName, ClassNode classNode, String mixinClassName, IMixinInfo mixinInfo) { } + +} diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/DistantHorizonsLoadingPlugin.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/DistantHorizonsLoadingPlugin.java new file mode 100644 index 000000000..d5192755f --- /dev/null +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/DistantHorizonsLoadingPlugin.java @@ -0,0 +1,33 @@ +package com.seibel.distanthorizons.cleanroom; + +import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; +import org.jetbrains.annotations.Nullable; + +import java.util.Map; + +public class DistantHorizonsLoadingPlugin implements IFMLLoadingPlugin +{ + @Override + public @Nullable String[] getASMTransformerClass() + { + return new String[0]; + } + @Override + public @Nullable String getModContainerClass() + { + return null; + } + @Override + public @Nullable String getSetupClass() + { + return null; + } + @Override + public void injectData(Map data) { } + @Override + public @Nullable String getAccessTransformerClass() + { + return null; + } + +} diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinEntityRenderer.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinEntityRenderer.java new file mode 100644 index 000000000..e5aeea3f5 --- /dev/null +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinEntityRenderer.java @@ -0,0 +1,71 @@ +package com.seibel.distanthorizons.cleanroom.mixins.client; + +import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper; +import com.seibel.distanthorizons.core.api.internal.ClientApi; +import com.seibel.distanthorizons.core.config.Config; +import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; +import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; +import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; +import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.init.MobEffects; +import org.apache.logging.log4j.Logger; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(EntityRenderer.class) +public class MixinEntityRenderer +{ + @Shadow + @Final + private DynamicTexture lightmapTexture; + + @Shadow @Final private Minecraft mc; + @Shadow @Final private static Logger LOGGER; + private static final float A_REALLY_REALLY_BIG_VALUE = 420694206942069.F; + private static final float A_EVEN_LARGER_VALUE = 42069420694206942069.F; + + @Inject(at = @At("TAIL"), method = "updateLightmap") + public void onUpdateLightmap(float patrialTicks, CallbackInfo ci) + { + IMinecraftClientWrapper mc = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class); + if (mc == null || mc.getWrappedClientLevel() == null) + { + return; + } + + IClientLevelWrapper clientLevel = mc.getWrappedClientLevel(); + MinecraftRenderWrapper renderWrapper = (MinecraftRenderWrapper)SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class); + renderWrapper.setLightmapId(lightmapTexture.getGlTextureId(), clientLevel); + } + + @Inject(at = @At("RETURN"), method = "setupFog") + private void disableSetupFog(int startCoords, float partialTicks, CallbackInfo ci) + { + boolean cameraNotInFluid = mc.getRenderViewEntity() != null && !mc.world.getBlockState(mc.getRenderViewEntity().getPosition()).getMaterial().isLiquid(); + + boolean isSpecialFog = mc.player.isPotionActive(MobEffects.BLINDNESS); + + if (!isSpecialFog + && cameraNotInFluid + && startCoords == 0 // 0 = terrain fog + && !SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class).isFogStateSpecial() + && !Config.Client.Advanced.Graphics.Fog.enableVanillaFog.get()) + { + GlStateManager.setFogStart(A_REALLY_REALLY_BIG_VALUE); + GlStateManager.setFogEnd(A_EVEN_LARGER_VALUE); + ClientApi.RENDER_STATE.vanillaFogEnabled = false; + } + else + { + ClientApi.RENDER_STATE.vanillaFogEnabled = true; + } + } +} diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinNetHandlerPlayClient.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinNetHandlerPlayClient.java new file mode 100644 index 000000000..057a638df --- /dev/null +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinNetHandlerPlayClient.java @@ -0,0 +1,27 @@ +package com.seibel.distanthorizons.cleanroom.mixins.client; + +import com.seibel.distanthorizons.core.api.internal.ClientApi; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.network.play.server.SPacketJoinGame; +import net.minecraft.util.text.ITextComponent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(NetHandlerPlayClient.class) +public class MixinNetHandlerPlayClient +{ + @Inject(method = "handleJoinGame", at = @At("RETURN")) + private void onHandleJoinGameEnd(SPacketJoinGame packet, CallbackInfo ci) + { + ClientApi.INSTANCE.onClientOnlyConnected(); + } + + @Inject(method = "onDisconnect", at = @At("RETURN")) + private void onDisconnect(ITextComponent reason, CallbackInfo ci) + { + ClientApi.INSTANCE.onClientOnlyDisconnected(); + } + +} diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinOptionsScreen.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinOptionsScreen.java new file mode 100644 index 000000000..9cf4ca730 --- /dev/null +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinOptionsScreen.java @@ -0,0 +1,83 @@ +/* + * This file is part of the Distant Horizons mod + * licensed under the GNU LGPL v3 License. + * + * Copyright (C) 2020 James Seibel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.seibel.distanthorizons.cleanroom.mixins.client; + +import com.seibel.distanthorizons.common.wrappers.gui.GetConfigScreen; +import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget; +import com.seibel.distanthorizons.core.config.Config; +import com.seibel.distanthorizons.coreapi.ModInfo; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiOptions; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.util.ResourceLocation; +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; + +/** + * Adds a button to the menu to goto the config + * + * @author coolGi + * @version 12-02-2021 + */ +@Mixin(GuiOptions.class) +public class MixinOptionsScreen extends GuiScreen +{ + // Get the texture for the button + @Unique private static final ResourceLocation ICON_TEXTURE = new ResourceLocation(ModInfo.ID, "textures/gui/button.png"); + + @Unique private static final int button_id = 99; + + @Inject(at = @At("HEAD"), method = "initGui") + private void lodconfig$init(CallbackInfo ci) + { + if (Config.Client.showDhOptionsButtonInMinecraftUi.get()) + this.buttonList.add( + (new TexturedButtonWidget( + button_id, + // Where the button is on the screen + this.width / 2 - 180, this.height / 6 - 12, + // Width and height of the button + 20, 20, + // Offset + 0, 0, + // Some textuary stuff + 20, ICON_TEXTURE, 20, 40, + // Create the button and tell it where to go + // For now it goes to the client option by default + // Add a title to the button + "DH" /* ModInfo.ID + ".title" */))); + + } + + @Inject(at = @At("HEAD"), method = "actionPerformed", cancellable = true) + private void lodconfig$actionPerformed(GuiButton button, CallbackInfo ci) + { + if (button.id == button_id) + { + Minecraft.getMinecraft().displayGuiScreen(GetConfigScreen.getScreen(this)); + ci.cancel(); + } + } + +} diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinRenderGlobal.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinRenderGlobal.java new file mode 100644 index 000000000..434f766fa --- /dev/null +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinRenderGlobal.java @@ -0,0 +1,62 @@ +package com.seibel.distanthorizons.cleanroom.mixins.client; + +import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper; +import com.seibel.distanthorizons.core.api.internal.ClientApi; +import com.seibel.distanthorizons.core.util.math.Mat4f; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.RenderGlobal; +import net.minecraft.entity.Entity; +import net.minecraft.util.BlockRenderLayer; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL15; +import org.lwjgl.opengl.GL20; +import org.lwjgl.opengl.GL30; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(RenderGlobal.class) +public class MixinRenderGlobal +{ + @Shadow private WorldClient world; + + @Inject(method = "renderBlockLayer(Lnet/minecraft/util/BlockRenderLayer;DILnet/minecraft/entity/Entity;)I", at = @At("HEAD")) + private void renderChunkLayer(BlockRenderLayer blockLayerIn, double partialTicks, int pass, Entity entityIn, CallbackInfoReturnable cir) + { + if (blockLayerIn == BlockRenderLayer.SOLID) + { + float[] mcProjMatrixRaw = new float[16]; + GL11.glGetFloatv(GL11.GL_PROJECTION_MATRIX, mcProjMatrixRaw); + ClientApi.RENDER_STATE.mcProjectionMatrix = new Mat4f(mcProjMatrixRaw); + ClientApi.RENDER_STATE.mcProjectionMatrix.transpose(); + + float[] mcModelViewRaw = new float[16]; + GL11.glGetFloatv(GL11.GL_MODELVIEW_MATRIX, mcModelViewRaw); + ClientApi.RENDER_STATE.mcModelViewMatrix = new Mat4f(mcModelViewRaw); + ClientApi.RENDER_STATE.mcModelViewMatrix.transpose(); + + ClientApi.RENDER_STATE.partialTickTime = (float) partialTicks; + ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, this.world); + + int blendSrc = GL11.glGetInteger(GL11.GL_BLEND_SRC); + int blendDst = GL11.glGetInteger(GL11.GL_BLEND_DST); + int boundTexture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); + + ClientApi.INSTANCE.renderLods(); + + GL30.glBindVertexArray(0); + GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); + GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); + GL20.glUseProgram(0); + + //Restore vanilla states + GlStateManager.depthFunc(GL11.GL_LEQUAL); + GlStateManager.bindTexture(boundTexture); + GlStateManager.tryBlendFuncSeparate(blendSrc, blendDst, GL11.GL_ONE, GL11.GL_ZERO); + + } + } +} \ No newline at end of file diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/common/MixinChunkProviderServer.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/common/MixinChunkProviderServer.java new file mode 100644 index 000000000..df2f04ca6 --- /dev/null +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/common/MixinChunkProviderServer.java @@ -0,0 +1,26 @@ +package com.seibel.distanthorizons.cleanroom.mixins.common; + +import com.seibel.distanthorizons.common.commonMixins.MixinChunkMapCommon; +import net.minecraft.world.WorldServer; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.gen.ChunkProviderServer; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ChunkProviderServer.class) +public class MixinChunkProviderServer +{ + @Shadow + @Final + public WorldServer world; + + @Inject(method = "saveChunkData", at = @At("RETURN")) + private void onSaveChunkData(Chunk chunk, CallbackInfo ci) + { + MixinChunkMapCommon.onChunkSave(world, chunk); + } +} diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/server/MixinEntityPlayerMP.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/server/MixinEntityPlayerMP.java new file mode 100644 index 000000000..d4d85b389 --- /dev/null +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/server/MixinEntityPlayerMP.java @@ -0,0 +1,49 @@ +package com.seibel.distanthorizons.cleanroom.mixins.server; + +import com.seibel.distanthorizons.common.wrappers.misc.IMixinServerPlayer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.util.ITeleporter; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(EntityPlayerMP.class) +public abstract class MixinEntityPlayerMP implements IMixinServerPlayer +{ + @Shadow + @Final + public MinecraftServer server; + + @Unique + @Nullable + private volatile WorldServer distantHorizons$dimensionChangeDestination; + + @Override + @Nullable + public WorldServer distantHorizons$getDimensionChangeDestination() + { + return this.distantHorizons$dimensionChangeDestination; + } + + @Inject(at = @At("HEAD"), method = "changeDimension(ILnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/entity/Entity;") + public void setDimensionChangeDestination(int destinationDimensionID, ITeleporter teleporter, CallbackInfoReturnable cir) + { + this.distantHorizons$dimensionChangeDestination = this.server.getWorld(destinationDimensionID); + } + + @Inject(at = @At("RETURN"), method = "clearInvulnerableDimensionChange") + public void clearDimensionChangeDestination(CallbackInfo ci) + { + this.distantHorizons$dimensionChangeDestination = null; + } + +} diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/modAccessor/ModChecker.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/modAccessor/ModChecker.java new file mode 100644 index 000000000..970082aa6 --- /dev/null +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/modAccessor/ModChecker.java @@ -0,0 +1,52 @@ +/* + * This file is part of the Distant Horizons mod + * licensed under the GNU LGPL v3 License. + * + * Copyright (C) 2020 James Seibel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.seibel.distanthorizons.cleanroom.modAccessor; + +import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; + +import java.io.File; +import java.util.Optional; +import java.util.stream.Stream; + +public class ModChecker implements IModChecker +{ + public static final ModChecker INSTANCE = new ModChecker(); + + @Override + public boolean isModLoaded(String modid) + { + return Loader.isModLoaded(modid); + } + + @Override + public File modLocation(String modid) + { + Stream foundStream = Loader.instance().getModList().stream().filter(x -> x.getModId().equals(modid)); + Optional container = foundStream.findFirst(); + if (!container.isPresent()) + { + throw new RuntimeException("Mod not found: " + modid); + } + return container.get().getSource(); + } + +} diff --git a/cleanroom/src/main/resources/1_12_2_distanthorizons_at.cfg b/cleanroom/src/main/resources/1_12_2_distanthorizons_at.cfg new file mode 100644 index 000000000..148f0fb86 --- /dev/null +++ b/cleanroom/src/main/resources/1_12_2_distanthorizons_at.cfg @@ -0,0 +1,3 @@ +public net.minecraft.client.renderer.EntityRenderer getFOVModifier(FZ)F +public net.minecraft.client.renderer.ActiveRenderInfo MODELVIEW +public net.minecraft.client.renderer.ActiveRenderInfo PROJECTION \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/lang/en_us.lang b/cleanroom/src/main/resources/assets/distanthorizons/lang/en_us.lang new file mode 100644 index 000000000..1ebba1da3 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/lang/en_us.lang @@ -0,0 +1,647 @@ +#PARSE_ESCAPES +distanthorizons.title=Distant Horizons + + + +distanthorizons.general.true=True +distanthorizons.general.false=False +distanthorizons.general.yes=Yes +distanthorizons.general.no=No +distanthorizons.general.back=Back +distanthorizons.general.next=Next +distanthorizons.general.done=Done +distanthorizons.general.cancel=Cancel +distanthorizons.general.reset=Reset +distanthorizons.general.spacer= +distanthorizons.general.apiOverride=API LOCK +distanthorizons.general.disabledByApi.@tooltip=This option is controlled by another mod via DH's API \nso it cannot be changed via the UI or config file. + + + + +distanthorizons.updater.title=Distant Horizons auto updater +distanthorizons.updater.text1=§lNew update available! +distanthorizons.updater.text2=§fDo you want to update from %s§f to %s§f? +distanthorizons.updater.later=Not now +distanthorizons.updater.never=Don't show again +distanthorizons.updater.update=Update +distanthorizons.updater.update.@tooltip=Updates the mod this one time\n(Updates when game is closed) +distanthorizons.updater.silent=Always silent update +distanthorizons.updater.silent.@tooltip=Every time an update is available, it would update\n(§6WARNING§r: This wont prompt you when updating) +distanthorizons.updater.waitingForClose=Distant Horizons will finish updating once the game restarts + + + + +distanthorizons.config.title=Distant Horizons config +distanthorizons.config.client=Client + +distanthorizons.config.client.quickEnableRendering=Enable Rendering +distanthorizons.config.client.quickEnableRendering.@tooltip=Determines if Distant Horizons Renders LODs. + +distanthorizons.config.client.quickShowWorldGenProgress=Show LOD Gen/Import Progress +distanthorizons.config.client.quickShowWorldGenProgress.@tooltip=If true then the world gen/importing progress will be displayed on the screen when running. + +distanthorizons.config.client.qualityPresetSetting=Quality Preset +distanthorizons.config.client.qualityPresetSetting.@tooltip=Modifies a number of graphical settings to quickly change Distant Horizons' rendering quality. \n\nLower this setting if your GPU is at max usage or you are having framerate issues. +distanthorizons.config.client.threadPresetSetting=CPU Load +distanthorizons.config.client.threadPresetSetting.@tooltip=Modifies how many threads Distant Horizons' will use. \n\nIncreasing this setting will improve the Distant Generator speed and LOD loading speed, \nbut will also increase CPU/memory usage and may introduce stuttering. \n\nNote: This is a CPU relative setting. \nIt should put an equal amount of strain on a 2 core CPU as a 64 core CPU. + +distanthorizons.config.client.optionsButton=Show The Options Button +distanthorizons.config.client.optionsButton.@tooltip=Show the config button to the left of the fov button + + + +distanthorizons.config.client.advanced=Advanced options + +distanthorizons.config.client.advanced.graphics=Graphics +distanthorizons.config.client.advanced.worldGenerator=World Generator +distanthorizons.config.client.advanced.server=Server +distanthorizons.config.client.advanced.lodBuilding=LOD Building +distanthorizons.config.client.advanced.multiThreading=Multi-Threading +distanthorizons.config.client.advanced.logging=Logging + + + +distanthorizons.config.client.advanced.graphics.quality=Quality + +distanthorizons.config.client.advanced.graphics.quality.lodChunkRenderDistanceRadius=LOD Chunk Render Distance Radius +distanthorizons.config.client.advanced.graphics.quality.lodChunkRenderDistanceRadius.@tooltip=Distant Horizons' render distance, measured in chunks. \n\nNote: this is a best effort number. \nThe render distance may be above or below this number \ndepending on your other graphic settings. +distanthorizons.config.client.advanced.graphics.quality.horizontalQuality=LOD Dropoff Distance +distanthorizons.config.client.advanced.graphics.quality.horizontalQuality.@tooltip=How far apart drops in quality are.\n\nHigher settings will increase the distance between drops\nbut will increase memory and GPU usage. +distanthorizons.config.client.advanced.graphics.quality.maxHorizontalResolution=Max Horizontal Resolution +distanthorizons.config.client.advanced.graphics.quality.maxHorizontalResolution.@tooltip=The maximum detail LODs are rendered at.\n\n§6Fastest:§r Chunk\n§6Fanciest:§r Block +distanthorizons.config.client.advanced.graphics.quality.verticalQuality=Vertical Quality +distanthorizons.config.client.advanced.graphics.quality.verticalQuality.@tooltip=How well LODs represent overhangs, caves, cliffsides, etc.\n\nHigher options will increase memory and GPU usage. +distanthorizons.config.client.advanced.graphics.quality.horizontalScale=Horizontal Scale +distanthorizons.config.client.advanced.graphics.quality.horizontalScale.@tooltip=How quickly LODs drop off in quality.\n\nLarger numbers will improve how distant terrain looks\nbut will increase memory and GPU usage. +distanthorizons.config.client.advanced.graphics.quality.transparency=Transparency +distanthorizons.config.client.advanced.graphics.quality.blocksToIgnore=Blocks To Ignore +distanthorizons.config.client.advanced.graphics.quality.blocksToIgnore.@tooltip=Defines the types of blocks to ignore when generating LODs. +distanthorizons.config.client.advanced.graphics.quality.tintWithAvoidedBlocks=Tint With Avoided Blocks +distanthorizons.config.client.advanced.graphics.quality.tintWithAvoidedBlocks.@tooltip=§4Note: makes snow, carpet, and trapdoors look really bad§r\nShould the blocks underneath avoided blocks gain the color of the avoided block?\n§6True:§r a red flower on grass will tint the grass below it red\n§6False:§r skipped blocks will not change color of surface below them +distanthorizons.config.client.advanced.graphics.quality.lodShading=LOD Shading +distanthorizons.config.client.advanced.graphics.quality.lodShading.@tooltip=Defines how LODs should be shaded. \nCan be used to improve shader compatibility. +distanthorizons.config.client.advanced.graphics.quality.grassSideRendering=Grass Side Rendering +distanthorizons.config.client.advanced.graphics.quality.grassSideRendering.@tooltip=How should the sides and bottom of grass block LODs render? +distanthorizons.config.client.advanced.graphics.quality.ditherDhFade=Fade Nearby DH LODs +distanthorizons.config.client.advanced.graphics.quality.ditherDhFade.@tooltip=If true LODs will fade away as you get closer to them. \nIf false LODs will cut off abruptly at a set distance from the camera. \nThis setting is affected by the vanilla overdraw prevention config. +distanthorizons.config.client.advanced.graphics.quality.vanillaFadeMode=Vanilla Fade Mode +distanthorizons.config.client.advanced.graphics.quality.vanillaFadeMode.@tooltip=How should vanilla Minecraft fade into Distant Horizons LODs? \n\nNONE: Fastest, there will be a pronounced border between DH and MC rendering. \nSINGLE_PASS: Fades after MC's transparent pass, opaque blocks underwater won't be faded. \nDOUBLE_PASS: Slowest, fades after both MC's opaque and transparent passes, provides the smoothest transition. +distanthorizons.config.client.advanced.graphics.quality.dhFadeFarClipPlane=Fade Before Far Clip Plane +distanthorizons.config.client.advanced.graphics.quality.dhFadeFarClipPlane.@tooltip=Should DH fade out before reaching the far plane? \nThis is helpful to prevent DH clouds from cutting off in the distance. +distanthorizons.config.client.advanced.graphics.quality.brightnessMultiplier=Brightness Multiplier +distanthorizons.config.client.advanced.graphics.quality.brightnessMultiplier.@tooltip=How bright LOD colors are.\n\n0 = black \n1 = normal \n2 = near white +distanthorizons.config.client.advanced.graphics.quality.saturationMultiplier=Saturation Multiplier +distanthorizons.config.client.advanced.graphics.quality.saturationMultiplier.@tooltip=How saturated LOD colors are.\n\n0 = black and white \n1 = normal \n2 = vibrant +distanthorizons.config.client.advanced.graphics.quality.lodBiomeBlending=Biome Blending +distanthorizons.config.client.advanced.graphics.quality.lodBiomeBlending.@tooltip=This is the same as vanilla Biome Blending settings for LOD area. \n\nNote that anything other than '0' will greatly effect Lod building time\nand increase triangle count. The cost on chunk generation speed is also \nquite large if set to too high.\n\n'0' equals to Vanilla Biome Blending of '1x1', \n'1' equals to Vanilla Biome Blending of '3x3', \n'2' equals to Vanilla Biome Blending of '5x5'... \n + + + +distanthorizons.config.client.advanced.graphics.ssao=Ambient Occlusion + +distanthorizons.config.client.advanced.graphics.ssao.enableSsao=Enable Ambient Occlusion +distanthorizons.config.client.advanced.graphics.ssao.enableSsao.@tooltip=Ambient Occlusion adds depth to the lighting of blocks. +distanthorizons.config.client.advanced.graphics.ssao.sampleCount=Sample Count +distanthorizons.config.client.advanced.graphics.ssao.sampleCount.@tooltip=Determines how many points in space are sampled for the occlusion test. \nHigher numbers will improve quality and reduce banding, but will increase GPU load. +distanthorizons.config.client.advanced.graphics.ssao.radius=Radius +distanthorizons.config.client.advanced.graphics.ssao.radius.@tooltip=Determines the radius Screen Space Ambient Occlusion is applied, measured in blocks. +distanthorizons.config.client.advanced.graphics.ssao.strength=Strength +distanthorizons.config.client.advanced.graphics.ssao.strength.@tooltip=Determines how dark the Screen Space Ambient Occlusion effect will be. +distanthorizons.config.client.advanced.graphics.ssao.bias=Bias +distanthorizons.config.client.advanced.graphics.ssao.bias.@tooltip=Increasing the value can reduce banding at the cost of reducing the strength of the effect. +distanthorizons.config.client.advanced.graphics.ssao.minLight=Min Light +distanthorizons.config.client.advanced.graphics.ssao.minLight.@tooltip=Determines how dark the occlusion shadows can be. \n0 = totally black at the corners \n1 = no shadow +distanthorizons.config.client.advanced.graphics.ssao.blurRadius=Blur Radius +distanthorizons.config.client.advanced.graphics.ssao.blurRadius.@tooltip=The radius, measured in pixels, that blurring is calculated for the SSAO. \nHigher numbers will reduce banding at the cost of GPU performance. +distanthorizons.config.client.advanced.graphics.ssao.fadeDistanceInBlocks=Fade Distance +distanthorizons.config.client.advanced.graphics.ssao.fadeDistanceInBlocks.@tooltip=The distance in blocks from the camera where the SSAO will fade out to. \nThis is done to prevent banding and noise at extreme distances. + + + +distanthorizons.config.client.advanced.graphics.genericRendering=Generic Object Rendering +distanthorizons.config.client.advanced.graphics.genericRendering.enableGenericRendering=Enable Rendering +distanthorizons.config.client.advanced.graphics.genericRendering.enableGenericRendering.@tooltip=If true non terrain objects will be rendered in DH's terrain. \nThis includes beacon beams and clouds. +distanthorizons.config.client.advanced.graphics.genericRendering.enableBeaconRendering=Enable Beacon Rendering +distanthorizons.config.client.advanced.graphics.genericRendering.beaconRenderHeight=Beacon render height +distanthorizons.config.client.advanced.graphics.genericRendering.beaconRenderHeight.@tooltip=Sets the maximum height at which beacons will render. \nThis will only affect new beacons coming into LOD render distance. \nBeacons currently visible in LOD chunks will not be affected. +distanthorizons.config.client.advanced.graphics.genericRendering.expandDistantBeacons=Expand Distant Beacons +distanthorizons.config.client.advanced.graphics.genericRendering.expandDistantBeacons.@tooltip=If true LOD beacon beams will be rendered wider at extreme distances, \nmaking them easier to see. \nIf false all LOD beacon beams will only ever be 1 block wide. +distanthorizons.config.client.advanced.graphics.genericRendering.enableBeaconRendering.@tooltip=If true LOD beacon beams will be rendered. +distanthorizons.config.client.advanced.graphics.genericRendering.enableCloudRendering=Enable Cloud Rendering +distanthorizons.config.client.advanced.graphics.genericRendering.enableCloudRendering.@tooltip=If true LOD clouds will be rendered. +distanthorizons.config.client.advanced.graphics.genericRendering.dimensionEnabledCloudRenderingCsv=Enable Cloud Rendering +distanthorizons.config.client.advanced.graphics.genericRendering.dimensionEnabledCloudRenderingCsv.@tooltip=A comma separated separated list of dimension resource locations where DH clouds will render. \n\nExample: \minecraft:overworld,minecraft:the_end\ \n\nChanges will only be seen when the world is re-loaded. +distanthorizons.config.client.advanced.graphics.genericRendering.enableUnexploredFogRendering=Enable Unexplored Fog Rendering +distanthorizons.config.client.advanced.graphics.genericRendering.enableUnexploredFogRendering.@tooltip=If true unexplored/ungenerated LODs will be rendered as large dark gray boxes. +distanthorizons.config.client.advanced.graphics.genericRendering.enableInstancedRendering=Enable Instanced Rendering +distanthorizons.config.client.advanced.graphics.genericRendering.enableInstancedRendering.@tooltip=Can be disabled to use much slower but more compatible direct rendering. \nDisabling this can be used to fix some crashes on Mac. + + + +distanthorizons.config.client.advanced.graphics.fog=Fog + +distanthorizons.config.client.advanced.graphics.fog.enableDhFog=Enable Distant Horizons Fog +distanthorizons.config.client.advanced.graphics.fog.enableDhFog.@tooltip=Determines if fog is drawn on DH LODs. +distanthorizons.config.client.advanced.graphics.fog.colorMode=Fog Color Mode +distanthorizons.config.client.advanced.graphics.fog.colorMode.@tooltip=The color of the fog on LODs. +distanthorizons.config.client.advanced.graphics.fog.enableVanillaFog=Enable Vanilla Fog +distanthorizons.config.client.advanced.graphics.fog.enableVanillaFog.@tooltip=§6True:§r Minecraft renders fog like normal.\n§6False:§r disables Minecraft's fog on vanilla chunks.\n\nMay cause issues with other mods that edit fog. +distanthorizons.config.client.advanced.graphics.fog.advancedFog=Advanced Fog Options + +distanthorizons.config.client.advanced.graphics.fog.farFogStart=Fog Start +distanthorizons.config.client.advanced.graphics.fog.farFogStart.@tooltip=Where should the fog start? \n\n'0.0': Fog start at player's position.\n'1.0': The fog-start's circle fit just in the lod render distance square.\n'1.414': The lod render distance square fit just in the fog-start's circle.\n +distanthorizons.config.client.advanced.graphics.fog.farFogEnd=Fog End +distanthorizons.config.client.advanced.graphics.fog.farFogEnd.@tooltip=Where should the fog end? \n\n'0.0': Fog end at player's position.\n'1.0': The fog-end's circle fit just in the lod render distance square.\n'1.414': The lod render distance square fit just in the fog-end's circle.\n +distanthorizons.config.client.advanced.graphics.fog.farFogMin=Fog Min +distanthorizons.config.client.advanced.graphics.fog.farFogMin.@tooltip=What is the minimum fog thickness? \n\n'0.0': No fog at all.\n'1.0': Fully fog color.\n +distanthorizons.config.client.advanced.graphics.fog.farFogMax=Fog Max +distanthorizons.config.client.advanced.graphics.fog.farFogMax.@tooltip=What is the maximum fog thickness? \n\n'0.0': No fog at all.\n'1.0': Fully fog color.\n +distanthorizons.config.client.advanced.graphics.fog.farFogFalloff=Fog Falloff +distanthorizons.config.client.advanced.graphics.fog.farFogFalloff.@tooltip=How should the fog thickness should be calculated? \n\nLINEAR: Linear based on distance (will ignore 'density')\nEXPONENTIAL: 1/(e^(distance*density)) \nEXPONENTIAL_SQUARED: 1/(e^((distance*density)^2)) \n +distanthorizons.config.client.advanced.graphics.fog.farFogDensity=Fog Density +distanthorizons.config.client.advanced.graphics.fog.farFogDensity.@tooltip=What is the fog's density? + + + +distanthorizons.config.client.advanced.graphics.fog.heightFog=Height Fog Options + +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMixMode=Height Fog Mix Mode +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMixMode.@tooltip=Defines how height effects fog. \nWhen in doubt start with SPHERICAL, ADDITION, or MAX. \n\nSPHERICAL: Fog is calculated based on camera distance. \nCYLINDRICAL: Ignore height, fog is calculated based on horizontal distance. \nMAX: max(heightFog, farFog) \nADDITION: heightFog + farFog \nMULTIPLY: heightFog * farFog \nINVERSE_MULTIPLY: 1 - (1-heightFog) * (1-farFog) \nLIMITED_ADDITION: farFog + max(farFog, heightFog) \nMULTIPLY_ADDITION: farFog + farFog * heightFog \nINVERSE_MULTIPLY_ADDITION: farFog + 1 - (1-heightFog) * (1-farFog) \nAVERAGE: farFog*0.5 + heightFog*0.5 +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogDirection=Height Fog Direction +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogDirection.@tooltip=Where should the height fog be located? \n\nABOVE_CAMERA: Height fog starts from camera to the sky \nBELOW_CAMERA: Height fog starts from camera to the void \nABOVE_AND_BELOW_CAMERA: Height fog starts from camera to both the sky and the void \nABOVE_SET_HEIGHT: Height fog starts from a set height to the sky \nBELOW_SET_HEIGHT: Height fog starts from a set height to the void \nABOVE_AND_BELOW_SET_HEIGHT: Height fog starts from a set height to both the sky and the void \n +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogBaseHeight=Height Fog Base Height +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogBaseHeight.@tooltip=If the height fog is calculated around a set height, what is that height position? +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogStart=Height Fog Start +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogStart.@tooltip=How far the start of height fog should offset? \n\n'0.0': Fog start with no offset.\n'1.0': Fog start with offset of the entire world's height. (Include depth)\n +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogEnd=Height Fog End +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogEnd.@tooltip=How far the end of height fog should offset? \n\n'0.0': Fog end with no offset.\n'1.0': Fog end with offset of the entire world's height. (Include depth)\n +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMin=Height Fog Min +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMin.@tooltip=What is the minimum fog thickness? \n\n'0.0': No fog at all.\n'1.0': Fully fog color.\n +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMax=Height Fog Max +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMax.@tooltip=What is the maximum fog thickness? \n\n'0.0': No fog at all.\n'1.0': Fully fog color.\n +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogFalloff=Height Fog Falloff +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogFalloff.@tooltip=How should the height fog thickness should be calculated? \n\nLINEAR: Linear based on height (will ignore 'density')\nEXPONENTIAL: 1/(e^(height*density)) \nEXPONENTIAL_SQUARED: 1/(e^((height*density)^2)) \n +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogDensity=Height Fog Density +distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogDensity.@tooltip=What is the height fog's density? + + + +distanthorizons.config.client.advanced.graphics.noiseTexture=Noise Texture + +distanthorizons.config.client.advanced.graphics.noiseTexture.enableNoiseTexture=Enable Noise Texture +distanthorizons.config.client.advanced.graphics.noiseTexture.enableNoiseTexture.@tooltip=If enabled a noise texture will be applied to LODs to simulate textures. +distanthorizons.config.client.advanced.graphics.noiseTexture.noiseSteps=Noise Steps +distanthorizons.config.client.advanced.graphics.noiseTexture.noiseSteps.@tooltip=Determines how many steps of noise should be applied to the LODs. +distanthorizons.config.client.advanced.graphics.noiseTexture.noiseIntensity=Noise Intensity +distanthorizons.config.client.advanced.graphics.noiseTexture.noiseIntensity.@tooltip=Determines how intense the noise texture is. +distanthorizons.config.client.advanced.graphics.noiseTexture.noiseDropoff=Noise Dropoff +distanthorizons.config.client.advanced.graphics.noiseTexture.noiseDropoff.@tooltip=Defines how far should the noise texture render before it fades away. (in blocks). \nSet to 0 to disable noise from fading away. + + + +distanthorizons.config.client.advanced.graphics.culling=Culling + +distanthorizons.config.client.advanced.graphics.culling.overdrawPrevention=Overdraw Prevention +distanthorizons.config.client.advanced.graphics.culling.overdrawPrevention.@tooltip=Determines how far from the camera Distant Horizons will start rendering. \nMeasured as a percentage of the vanilla render distance.\n-1 = Auto, overdraw will change based on the vanilla render distance.\n\nHigher values will prevent LODs from rendering behind vanilla blocks at a higher distance,\nbut may cause holes to appear in the LODs. \nHoles are most likely to appear when flying through unloaded terrain. \n\nIncreasing the vanilla render distance increases the effectiveness of this setting. +distanthorizons.config.client.advanced.graphics.culling.reduceOverdrawWithFastMovement=Reduce Overdraw With Fast Movement +distanthorizons.config.client.advanced.graphics.culling.reduceOverdrawWithFastMovement.@tooltip=If set to true the overdraw prevention radius will get closer \nto the camera when flying/moving quickly. \n\nThis helps reduce issues where Minecraft can't load or \ngenerate chunks fast enough to keep up with DH. +distanthorizons.config.client.advanced.graphics.culling.enableCaveCulling=Cave Culling +distanthorizons.config.client.advanced.graphics.culling.enableCaveCulling.@tooltip=If enabled caves will be culled \n\nAdditional Info: Currently this cull all faces \n with skylight value of 0 under the cave culling height in dimensions that \n do not have a ceiling. \n +distanthorizons.config.client.advanced.graphics.culling.caveCullingHeight=Cave Culling Height +distanthorizons.config.client.advanced.graphics.culling.caveCullingHeight.@tooltip=At what Y value should cave culling start? +distanthorizons.config.client.advanced.graphics.culling.disableBeaconDistanceCulling=Enable Beacon Distance Culling +distanthorizons.config.client.advanced.graphics.culling.disableBeaconDistanceCulling.@tooltip=If true beacons near the camera won't be drawn to prevent vanilla overdraw. \nIf false all beacons will be rendered. +distanthorizons.config.client.advanced.graphics.culling.disableFrustumCulling=Disable Frustum Culling +distanthorizons.config.client.advanced.graphics.culling.disableFrustumCulling.@tooltip=If false LODs outside the player's camera \naren't drawn, increasing GPU performance. \n\nIf true all LODs are drawn, even those behind \nthe player's camera, decreasing GPU performance. \n\nDisable this if you see LODs disappearing at the corners of your vision. +distanthorizons.config.client.advanced.graphics.culling.disableShadowPassFrustumCulling=Disable Shadow Pass Frustum Culling +distanthorizons.config.client.advanced.graphics.culling.disableShadowPassFrustumCulling.@tooltip=Identical to the other frustum culling option except that it is \nonly used when a shader mod is present using the DH API \nand the shadow pass is being rendered. \n\nDisable this if shadows render incorrectly. +distanthorizons.config.client.advanced.graphics.culling.ignoredRenderBlockCsv=Ignored Block CSV +distanthorizons.config.client.advanced.graphics.culling.ignoredRenderBlockCsv.@tooltip=A comma separated list of block resource locations that won't be rendered by DH. \nNote: air is always included in this list. +distanthorizons.config.client.advanced.graphics.culling.ignoredRenderCaveBlockCsv=Ignored Cave Block CSV +distanthorizons.config.client.advanced.graphics.culling.ignoredRenderCaveBlockCsv.@tooltip=A comma separated list of block resource locations that shouldn't be rendered \nif they are in a 0 sky light underground area. \nNote: air is always included in this list. + +distanthorizons.config.client.advanced.graphics.overrideVanillaGraphicsSettings=Override Vanilla Settings +distanthorizons.config.client.advanced.graphics.overrideVanillaGraphicsSettings.@tooltip=If true some vanilla graphics settings will be automatically changed \nduring DH setup to provide a better experience. \n\nIE disabling vanilla clouds (which render on top of DH LODs), \nand chunk fading (DH already fades MC chunks). + + + +distanthorizons.config.client.advanced.graphics.experimental=Experimental + +distanthorizons.config.client.advanced.graphics.experimental.earthCurveRatio=Earth Curve Ratio +distanthorizons.config.client.advanced.graphics.experimental.earthCurveRatio.@tooltip=A value of 1 is equivalent to the curvature of Earth in real life. \nThe minimum accepted value is 50 and the maximum value is 5000. \nEverything between 1 and 49 will be rounded up to 50. +distanthorizons.config.client.advanced.graphics.experimental.ignoredDimensionCsv=Ignored Dimension CSV +distanthorizons.config.client.advanced.graphics.experimental.ignoredDimensionCsv.@tooltip=A comma separated list of dimension resource locations where DH won't render. Example: \minecraft:the_nether,minecraft:the_end\ \n\nNote: \nSome DH settings will be disabled and/or changed to improve \nvisuals when DH rendering is disabled. + + + +distanthorizons.config.client.advanced.autoUpdater=Auto Updater + +distanthorizons.config.client.advanced.autoUpdater.enableAutoUpdater=Enable automatic updates +distanthorizons.config.client.advanced.autoUpdater.enableSilentUpdates=Enable Silent Updates +distanthorizons.config.client.advanced.autoUpdater.enableSilentUpdates.@tooltip=Automatically updates the mod when an update is available +distanthorizons.config.client.advanced.autoUpdater.updateBranch=Update Branch +distanthorizons.config.client.advanced.autoUpdater.updateBranch.@tooltip=Where to download the latest update from. \n\nAuto: Downloads either stable or nightly builds based on the current jar. \nStable: Stable builds from Modrinth. \nNightly: Nightly builds from Gitlab. + + + +distanthorizons.config.client.advanced.multiplayer=Multiplayer + +distanthorizons.config.client.advanced.multiplayer.serverFolderNameMode=Server Folder Mode +distanthorizons.config.client.advanced.multiplayer.serverFolderNameMode.@tooltip=Determines the folder format for local multiplayer data.\n\n§6Name Only:§r\nUses the server browser name. Ex: \Minecraft Server\\n§6IP Only:§r\n\192.168.1.40\\n§6Name IP:§r\n\Minecraft Server, IP 192.168.1.40\\n§6Name, IP, Port:§r\n\Minecraft Server, IP 192.168.1.40:25565\\n§6Name, IP, Port, MC Version:§r\n\Minecraft Server, IP 192.168.1.40:25565, GameVersion 1.18.1\\n\n§c§lCaution:§r changing while connected to a multiplayer server may cause glitches. + + + + +distanthorizons.config.client.advanced.debugging=Debug + +distanthorizons.config.client.advanced.debugging.rendererMode=Renderer Mode +distanthorizons.config.client.advanced.debugging.debugRendering=Debug Rendering +distanthorizons.config.client.advanced.debugging.lodOnlyMode=Only Render LODs +distanthorizons.config.client.advanced.debugging.lodOnlyMode.@tooltip=If enabled this will disable (most) vanilla Minecraft rendering. \n\nNOTE: Do not report any issues when this mode is on! \nThis setting is only for fun and debugging. \nMod compatibility is not guaranteed. +distanthorizons.config.client.advanced.debugging.renderWireframe=Render Wireframe +distanthorizons.config.client.advanced.debugging.renderWireframe.@tooltip=If enabled the LODs will render as wireframe. +distanthorizons.config.client.advanced.debugging.enableDebugKeybindings=Enable debug keybindings +distanthorizons.config.client.advanced.debugging.enableDebugKeybindings.@tooltip=If true several keys can be used to toggle debug states. \nF6 - enable/disable LOD rendering \nF7 - enable/disable LOD only rendering \nF8 - cycle through the different debug rendering modes +distanthorizons.config.client.advanced.debugging.enableWhiteWorld=Enable white world +distanthorizons.config.client.advanced.debugging.enableWhiteWorld.@tooltip=If enabled, vertex color will not be passed.\nUseful for debugging shaders. +distanthorizons.config.client.advanced.debugging.showOverlappingQuadErrors=Show overlapping quad errors +distanthorizons.config.client.advanced.debugging.showOverlappingQuadErrors.@tooltip=If true overlapping quads will be rendered as bright red for easy identification. \nIf false the quads will be rendered normally. +distanthorizons.config.client.advanced.debugging.logBufferGarbageCollection=Log Buffer Garbage Collection +distanthorizons.config.client.advanced.debugging.logBufferGarbageCollection.@tooltip=If true OpenGL Buffer garbage collection will be logged \nthis also includes the number of live buffers. +distanthorizons.config.client.advanced.debugging.allowUnsafeValues=Allow Unsafe UI Values +distanthorizons.config.client.advanced.debugging.allowUnsafeValues.@tooltip=If enabled, very limited config input validation will be performed. \n\nWarning: enabling this can cause instability or crashing, use at your own risk. \nNote: this option isn't saved between sessions. + + + + +distanthorizons.config.client.advanced.debugging.debugWireframe=Debug Wireframe + +distanthorizons.config.client.advanced.debugging.debugWireframe.enableRendering=Enable Debug Wireframe Rendering +distanthorizons.config.client.advanced.debugging.debugWireframe.enableRendering.@tooltip=If enabled, various wireframes for debugging internal functions will be drawn. +distanthorizons.config.client.advanced.debugging.debugWireframe.showWorldGenQueue=Show World Gen Queue +distanthorizons.config.client.advanced.debugging.debugWireframe.showNetworkSyncOnLoadQueue=Show Network Sync On Load Queue +distanthorizons.config.client.advanced.debugging.debugWireframe.showRenderSectionStatus=Show Render Section Status +distanthorizons.config.client.advanced.debugging.debugWireframe.showRenderSectionToggling=Show Render Section Toggling +distanthorizons.config.client.advanced.debugging.debugWireframe.showQuadTreeRenderStatus=Show Quad Tree Render Status +distanthorizons.config.client.advanced.debugging.debugWireframe.showFullDataUpdateStatus=Show Full Data Update Status + + + +distanthorizons.config.client.advanced.debugging.openGl=Open GL + +distanthorizons.config.client.advanced.debugging.openGl.overrideVanillaGLLogger=Override Vanilla GL Logger +distanthorizons.config.client.advanced.debugging.openGl.overrideVanillaGLLogger.@tooltip=Defines how OpenGL errors are handled. \nRequires rebooting Minecraft to change. \nWill catch OpenGL errors thrown by other mods. +distanthorizons.config.client.advanced.debugging.openGl.onlyLogGlErrorsOnce=Only Log GL Errors Once +distanthorizons.config.client.advanced.debugging.openGl.onlyLogGlErrorsOnce.@tooltip=If true each Open GL error will only be logged once. \nTEnabling this may cause some error logs to be missed. \nDoes nothing if overrideVanillaGLLogger is set to false. \n\nGenerally this can be kept as 'true' to prevent log spam. \nHowever, Please set this to 'false' if a developer needs your log to debug a GL issue. \n +distanthorizons.config.client.advanced.debugging.openGl.glErrorHandlingMode=OpenGL Error Handling Mode +distanthorizons.config.client.advanced.debugging.openGl.glErrorHandlingMode.@tooltip=Defines how OpenGL errors are handled. \n Requires rebooting Minecraft to apply. \nMay incorrectly catch OpenGL errors thrown by other mods. +distanthorizons.config.client.advanced.debugging.openGl.validateBufferIdsBeforeRendering=Validate Buffer IDs Before Rendering +distanthorizons.config.client.advanced.debugging.openGl.validateBufferIdsBeforeRendering.@tooltip=Massively reduces FPS. \nShould only be used if mysterious EXCEPTION_ACCESS_VIOLATION crashes are happening in DH's rendering code and you're attempting to troubleshoot it. +distanthorizons.config.client.advanced.debugging.openGl.glUploadMode=Uploade Mode +distanthorizons.config.client.advanced.debugging.openGl.glUploadMode.@tooltip=Only for debugging + + + +distanthorizons.config.client.advanced.debugging.columnBuilderDebugging=Render Column Builder + +distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugEnable=Enable Column Builder Limiting +distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugDetailLevel=Column Builder Limit - Detail Level +distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugXPos=Column Builder Limit - X Pos +distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugZPos=Column Builder Limit - Z Pos +distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugXRow=Column Builder Limit - X Row +distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugZRow=Column Builder Limit - Z Row +distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugColumnIndex=Column Builder Limit - Col Index + + + +distanthorizons.config.client.advanced.debugging.f3Screen=F3 Screen + +distanthorizons.config.client.advanced.debugging.f3Screen.showPlayerPos=Show Player Pos +distanthorizons.config.client.advanced.debugging.f3Screen.playerPosSectionDetailLevel=Player Section Pos Detail Level +distanthorizons.config.client.advanced.debugging.f3Screen.showThreadPools=Show Thread Pools +distanthorizons.config.client.advanced.debugging.f3Screen.showCombinedObjectPools=Show Combined Object Pools +distanthorizons.config.client.advanced.debugging.f3Screen.showSeparatedObjectPools=Show Separated Object Pools +distanthorizons.config.client.advanced.debugging.f3Screen.showQueuedChunkUpdateCount=Show Queued Chunk Update Count +distanthorizons.config.client.advanced.debugging.f3Screen.showLevelStatus=Show Level Status +distanthorizons.config.client.advanced.debugging.f3Screen.onlyShowRenderingLevels=Only Show Rendering Levels + + + +distanthorizons.config.client.advanced.debugging.exampleConfigScreen=Debug Config Screen + +distanthorizons.config.client.advanced.debugging.exampleConfigScreen.debugConfigScreenNote=This screen is to debug features of the config screen +distanthorizons.config.client.advanced.debugging.exampleConfigScreen.boolTest=Boolean test +distanthorizons.config.client.advanced.debugging.exampleConfigScreen.byteTest=Byte test +distanthorizons.config.client.advanced.debugging.exampleConfigScreen.intTest=Integer test +distanthorizons.config.client.advanced.debugging.exampleConfigScreen.doubleTest=Double test +distanthorizons.config.client.advanced.debugging.exampleConfigScreen.shortTest=Short test +distanthorizons.config.client.advanced.debugging.exampleConfigScreen.longTest=Long test +distanthorizons.config.client.advanced.debugging.exampleConfigScreen.floatTest=Float test +distanthorizons.config.client.advanced.debugging.exampleConfigScreen.stringTest=String test +distanthorizons.config.client.advanced.debugging.exampleConfigScreen.uiButtonTest=UI Button test +distanthorizons.config.client.advanced.debugging.exampleConfigScreen.listTest=List (ArrayList) test +distanthorizons.config.client.advanced.debugging.exampleConfigScreen.mapTest=Map (HashMap) test +distanthorizons.config.client.advanced.debugging.exampleConfigScreen.categoryTest=Category test +distanthorizons.config.client.advanced.debugging.exampleConfigScreen.linkableTest=Linkable test +distanthorizons.config.client.advanced.debugging.exampleConfigScreen.linkableTest.@tooltip=The value of this should be the same as in Category Test + + + + + +distanthorizons.config.common=Common + + +distanthorizons.config.common.worldGenerator=World Generator + +distanthorizons.config.common.worldGenerator.enableDistantGeneration=Enable Distant Generation +distanthorizons.config.common.worldGenerator.enableDistantGeneration.@tooltip=§6True:§r in single player LODs will be created outside the vanilla render distance.\nDepending on the Generator Mode pre-existing chunks will be important and/o\nmissing chunks will be generated.\nNote: this can use a large amount of CPU.\n\n§6False:§r LODs will only generate within the vanilla render distance. +distanthorizons.config.common.worldGenerator.distantGeneratorMode=Distance Generator Mode +distanthorizons.config.common.worldGenerator.distantGeneratorMode.@tooltip=How complicated the generation should be when generating LODs outside the vanilla render distance. +distanthorizons.config.common.worldGenerator.showGenerationProgress=Show Generation Progress +distanthorizons.config.common.worldGenerator.showGenerationProgress.@tooltip=Determines how should distant generator progress be displayed. +distanthorizons.config.common.worldGenerator.generationProgressDisplayIntervalInSeconds=Progress Display Interval In Seconds +distanthorizons.config.common.worldGenerator.generationProgressDisplayIntervalInSeconds.@tooltip=Determines how long between progress update displays. +distanthorizons.config.common.worldGenerator.generationProgressDisableMessageDisplayTimeInSeconds=Seconds To Show Progress Hiding Instructions +distanthorizons.config.common.worldGenerator.generationProgressDisableMessageDisplayTimeInSeconds.@tooltip=For how many seconds should instructions for disabling the distant generator progress be displayed? \nSetting this to 0 hides the instructional message so the world gen progress is shown immediately when it starts. +distanthorizons.config.common.worldGenerator.generationProgressIncludeChunksPerSecond=Show Generation Speed in Chunks/Second +distanthorizons.config.common.worldGenerator.generationProgressIncludeChunksPerSecond.@tooltip=When logging generation progress also include the rate at which chunks \nare being generated. \nThis can be useful for troubleshooting performance. + + +distanthorizons.config.common.lodBuilding=Lod Building + +distanthorizons.config.common.lodBuilding.disableUnchangedChunkCheck=Disable Unchanged Chunk Check +distanthorizons.config.common.lodBuilding.disableUnchangedChunkCheck.@tooltip=Disabling this check may fix issues where LODs aren't updated after\nblocks have been changed.\n +distanthorizons.config.common.lodBuilding.pullLightingForPregeneratedChunks=Pull Lighting For Pre-generated Chunks +distanthorizons.config.common.lodBuilding.pullLightingForPregeneratedChunks.@tooltip=If true LOD generation for pre-existing chunks will attempt to pull the lighting data \nsaved in Minecraft's Region files. \nIf false DH will pull in chunks without lighting and re-light them. \n\nSetting this to true will result in faster LOD generation \nfor already generated worlds, but is broken by most lighting mods. \n\nSet this to false if LODs are black. +distanthorizons.config.common.lodBuilding.assumePreExistingChunksAreFinished=Assume Pre-Existing Chunks Are Finished +distanthorizons.config.common.lodBuilding.assumePreExistingChunksAreFinished.@tooltip=Setting this to true may solve some issues when using DH with a pre-generated world. +distanthorizons.config.common.lodBuilding.dataCompression=Data Compression +distanthorizons.config.common.lodBuilding.dataCompression.@tooltip=What algorithm should be used to compress new LOD data? \nThis setting will only affect new or updated LOD data, \nany data already generated when this setting is changed will be \nunaffected until it needs to be re-written to the database. \n\nFastest: LZ4 \nHighest Compression: LZMA2 +distanthorizons.config.common.lodBuilding.worldCompression=Lossy World Compression +distanthorizons.config.common.lodBuilding.worldCompression.@tooltip=How should block data be compressed when creating LOD data? \nThis setting will only affect new or updated LOD data, \nany data already generated when this setting is changed will be \nunaffected until it is modified or re-loaded. \n\nMost Accurate: Merge Same Blocks \nHighest Compression: Visually Equal +distanthorizons.config.common.lodBuilding.recalculateChunkHeightmaps=Recalculate Chunk Heightmaps +distanthorizons.config.common.lodBuilding.recalculateChunkHeightmaps.@tooltip=True: Recalculate chunk height maps before chunks can be used by DH. This can fix problems with worlds created by external tools. \nFalse: Assume any height maps handled by Minecraft are correct. \n\nFastest: False\nMost Compatible: True +distanthorizons.config.common.lodBuilding.showMigrationChatWarning=Log Migration In Chat + + +distanthorizons.config.common.lodBuilding.experimental=Experimental + +distanthorizons.config.common.lodBuilding.experimental.upsampleLowerDetailLodsToFillHoles=Upsample Lower Detail LODs To Fill Holes +distanthorizons.config.common.lodBuilding.experimental.upsampleLowerDetailLodsToFillHoles.@tooltip=When active DH will attempt to fill missing LOD data \nwith any data that is present in the tree, preventing holes when moving \nwhen a N-sized generator (or server) is active. \n\n§6EXPERIMENTAL§r Will increase harddrive use and may cause rendering issues. \nSee the config file for more details. + + + + +distanthorizons.config.common.multiThreading=Multi-Threading + +distanthorizons.config.common.multiThreading.numberOfThreads=NO. of threads +distanthorizons.config.common.multiThreading.numberOfThreads.@tooltip=How many threads DH will use. +distanthorizons.config.common.multiThreading.threadRunTimeRatio=Runtime % for threads +distanthorizons.config.common.multiThreading.threadPriority=Thread Priority +distanthorizons.config.common.multiThreading.threadPriority.@tooltip=What Java thread priority should DH's primary thread pools run with?\n\nYou probably don't need to change this unless you are also \nrunning C2ME and are seeing thread starvation in either C2ME or DH. + + + +distanthorizons.config.common.logging=Logging +distanthorizons.config.common.logging.@tooltip=Controls how logging should be handled. + +distanthorizons.config.common.logging.globalFileMaxLevel=Global File Max +distanthorizons.config.common.logging.globalChatMaxLevel=Global Chat Max + +distanthorizons.config.common.logging.logWorldGenEventToFile=World Gen Events - File +distanthorizons.config.common.logging.logWorldGenPerformanceToFile=World Gen Performance - File +distanthorizons.config.common.logging.logWorldGenChunkLoadEventToFile=World Gen Load Events - File +distanthorizons.config.common.logging.logRendererEventToFile=Renderer Events - File +distanthorizons.config.common.logging.logRendererGLEventToFile=OpenGL Events - File +distanthorizons.config.common.logging.logRendererGLEventToChat=OpenGL Events - Chat +distanthorizons.config.common.logging.logNetworkEventToFile=Network Events - File +distanthorizons.config.common.logging.logConnectionConfigChangesToFile=Network Connection Config Changes - File + +distanthorizons.config.common.logging.warning=Warnings +distanthorizons.config.common.logging.warning.showLowMemoryWarningOnStartup=Show Low Memory Warning On Startup +distanthorizons.config.common.logging.warning.showPoolInsufficientMemoryWarning=Show Pool Insufficient Memory Warning +distanthorizons.config.common.logging.warning.showPoolInsufficientMemoryWarning.@tooltip=If DH detects that pooled objects are being garbage collected this will send a chat warning. +distanthorizons.config.common.logging.warning.showHighVanillaRenderDistanceWarning=Show High Vanilla Render Distance Warning +distanthorizons.config.common.logging.warning.showReplayWarningOnStartup=Show Replay Warning +distanthorizons.config.common.logging.warning.showUpdateQueueOverloadedChatWarning=Show Update Queue Overloaded Warning +distanthorizons.config.common.logging.warning.showSlowWorldGenSettingWarnings=Show Slow World Gen Warnings +distanthorizons.config.common.logging.warning.showModCompatibilityWarningsOnStartup=Show Mod Compatibility Warnings +distanthorizons.config.common.logging.warning.showGarbageCollectorWarning=Show Garbage Collector Warning +distanthorizons.config.common.logging.warning.logGarbageCollectorWarning=Log Garbage Collector Warning + + + + + +distanthorizons.config.server=Server + + +distanthorizons.config.server.sendLevelKeys=Send Level Keys +distanthorizons.config.server.sendLevelKeys.@tooltip=Makes the server send level keys for each world.\nDisable this if you use alternative ways to send level keys. + +distanthorizons.config.server.levelKeyPrefix=Level Key Prefix +distanthorizons.config.server.levelKeyPrefix.@tooltip=Prefix of the level keys sent to the clients.\nIf the mod is running behind a proxy, each backend should use a unique value.\nIf this value is empty, level key will be based on the server's seed hash. + +distanthorizons.config.server.enableServerGeneration=Enable Server Generation +distanthorizons.config.server.enableServerGeneration.@tooltip=When enabled, Distant Horizons will attempt to download missing LODs from the server.\n\nNote: the server must have Distant Generation enabled for it to work. + +distanthorizons.config.server.generationRequestRateLimit=Rate Limit for Generation Requests +distanthorizons.config.server.generationRequestRateLimit.@tooltip=How many LOD generation requests per second should a client send?\nAlso limits the number of client requests allowed to stay in the server's queue. + +distanthorizons.config.server.maxGenerationRequestDistance=Max Generation Request Distance +distanthorizons.config.server.maxGenerationRequestDistance.@tooltip=Defines the distance allowed to generate around the player. + +distanthorizons.config.server.enableRealTimeUpdates=Enable Real-time Updates +distanthorizons.config.server.enableRealTimeUpdates.@tooltip=If true, clients will receive real-time LOD updates for chunks outside the client's render distance. + +distanthorizons.config.server.realTimeUpdateDistanceRadiusInChunks=Real-time Update Radius in Chunks +distanthorizons.config.server.realTimeUpdateDistanceRadiusInChunks.@tooltip=Defines the distance the player will receive updates around. + +distanthorizons.config.server.synchronizeOnLoad=Synchronize LODs on Load +distanthorizons.config.server.synchronizeOnLoad.@tooltip=If true, clients will receive updated LODs when joining or loading new LODs. + +distanthorizons.config.server.syncOnLoadRateLimit=Rate Limit for Sync on Load +distanthorizons.config.server.syncOnLoadRateLimit.@tooltip=How many LOD sync requests per second should a client send?\nAlso limits the number of client's requests allowed to stay in the server's queue. + +distanthorizons.config.server.maxSyncOnLoadRequestDistance=Max Sync on Load Request Distance +distanthorizons.config.server.maxSyncOnLoadRequestDistance.@tooltip=Defines the distance allowed to be synchronized around the player.\nShould be the same or larger than maxGenerationRequestDistance in most cases. + +distanthorizons.config.server.playerBandwidthLimit=Per-player Bandwidth Limit, KB/s +distanthorizons.config.server.playerBandwidthLimit.@tooltip=Maximum per-player speed for uploading LODs to the clients, in KB/s.\nValue of 0 disables the limit. +distanthorizons.config.server.globalBandwidthLimit=Global Bandwidth Limit, KB/s +distanthorizons.config.server.globalBandwidthLimit.@tooltip=Maximum global speed for uploading LODs to the clients, in KB/s.\nValue of 0 disables the limit. +distanthorizons.config.server.enableAdaptiveTransferSpeed=Enable Adaptive Transfer Speed +distanthorizons.config.server.enableAdaptiveTransferSpeed.@tooltip=Enables adaptive transfer speed based on client performance.\nIf true, DH will automatically adjust transfer rate to minimize connection lag.\nIf false, transfer speed will remain fixed. + + +distanthorizons.config.server.experimental=Experimental + +distanthorizons.config.server.experimental.enableNSizedGeneration=Enable N-sized generation +distanthorizons.config.server.experimental.enableNSizedGeneration.@tooltip=When enabled on the client, this allows loading lower detail levels as needed to speed up terrain generation.\nThis must also be enabled on the server; otherwise, it will have no effect.\nFor better performance when switching LOD detail levels, enabling [upsampleLowerDetailLodsToFillHoles] is recommended. + + + + + + + + + + + + +distanthorizons.config.enum.EDhApiQualityPreset.CUSTOM=Custom +distanthorizons.config.enum.EDhApiQualityPreset.MINIMUM=1. Minimum +distanthorizons.config.enum.EDhApiQualityPreset.LOW=2. Low +distanthorizons.config.enum.EDhApiQualityPreset.MEDIUM=3. Medium +distanthorizons.config.enum.EDhApiQualityPreset.HIGH=4. High +distanthorizons.config.enum.EDhApiQualityPreset.EXTREME=5. Extreme + +distanthorizons.config.enum.EDhApiThreadPreset.CUSTOM=Custom +distanthorizons.config.enum.EDhApiThreadPreset.MINIMAL_IMPACT=1. Minimal Impact +distanthorizons.config.enum.EDhApiThreadPreset.LOW_IMPACT=2. Low Impact +distanthorizons.config.enum.EDhApiThreadPreset.BALANCED=3. Balanced +distanthorizons.config.enum.EDhApiThreadPreset.AGGRESSIVE=4. Aggressive +distanthorizons.config.enum.EDhApiThreadPreset.I_PAID_FOR_THE_WHOLE_CPU=5. I Paid For The Whole CPU + +distanthorizons.config.enum.EDhApiMaxHorizontalResolution.BLOCK=1. Block +distanthorizons.config.enum.EDhApiMaxHorizontalResolution.TWO_BLOCKS=2. 2 blocks +distanthorizons.config.enum.EDhApiMaxHorizontalResolution.FOUR_BLOCKS=3. 4 blocks +distanthorizons.config.enum.EDhApiMaxHorizontalResolution.HALF_CHUNK=4. Half a chunk +distanthorizons.config.enum.EDhApiMaxHorizontalResolution.CHUNK=5. Chunk + +distanthorizons.config.enum.EDhApiMcRenderingFadeMode.NONE=None +distanthorizons.config.enum.EDhApiMcRenderingFadeMode.SINGLE_PASS=Single Pass +distanthorizons.config.enum.EDhApiMcRenderingFadeMode.DOUBLE_PASS=Double Pass + +distanthorizons.config.enum.EDhApiVerticalQuality.HEIGHT_MAP=1. Height Map +distanthorizons.config.enum.EDhApiVerticalQuality.LOW=2. Low +distanthorizons.config.enum.EDhApiVerticalQuality.MEDIUM=3. Medium +distanthorizons.config.enum.EDhApiVerticalQuality.HIGH=4. High +distanthorizons.config.enum.EDhApiVerticalQuality.VERY_HIGH=5. Very High +distanthorizons.config.enum.EDhApiVerticalQuality.EXTREME=6. Extreme +distanthorizons.config.enum.EDhApiVerticalQuality.PIXEL_ART=7. Pixel Art + +distanthorizons.config.enum.EDhApiHorizontalQuality.LOWEST=Lowest +distanthorizons.config.enum.EDhApiHorizontalQuality.LOW=Low +distanthorizons.config.enum.EDhApiHorizontalQuality.MEDIUM=Medium +distanthorizons.config.enum.EDhApiHorizontalQuality.HIGH=High +distanthorizons.config.enum.EDhApiHorizontalQuality.EXTREME=Extreme + +distanthorizons.config.enum.EDhApiTransparency.DISABLED=Disabled +distanthorizons.config.enum.EDhApiTransparency.FAKE=Fake +distanthorizons.config.enum.EDhApiTransparency.COMPLETE=Complete + +distanthorizons.config.enum.EDhApiFogDrawMode.USE_OPTIFINE_SETTING=Use modded settings +distanthorizons.config.enum.EDhApiFogDrawMode.FOG_ENABLED=Enabled +distanthorizons.config.enum.EDhApiFogDrawMode.FOG_DISABLED=Disabled + +distanthorizons.config.enum.EDhApiFogColorMode.USE_WORLD_FOG_COLOR=Use world fog +distanthorizons.config.enum.EDhApiFogColorMode.USE_SKY_COLOR=Use sky color + +distanthorizons.config.enum.EDhApiFogFalloff.LINEAR=Linear +distanthorizons.config.enum.EDhApiFogFalloff.EXPONENTIAL=Exponential +distanthorizons.config.enum.EDhApiFogFalloff.EXPONENTIAL_SQUARED=Exponential squared + +distanthorizons.config.enum.EDhApiHeightFogMixMode.SPHERICAL=Spherical +distanthorizons.config.enum.EDhApiHeightFogMixMode.CYLINDRICAL=Cylindrical +distanthorizons.config.enum.EDhApiHeightFogMixMode.ADDITION=Addition +distanthorizons.config.enum.EDhApiHeightFogMixMode.MAX=Max +distanthorizons.config.enum.EDhApiHeightFogMixMode.MULTIPLY=Multiply +distanthorizons.config.enum.EDhApiHeightFogMixMode.INVERSE_MULTIPLY=Inverse Multiply +distanthorizons.config.enum.EDhApiHeightFogMixMode.LIMITED_ADDITION=Limited Addition +distanthorizons.config.enum.EDhApiHeightFogMixMode.MULTIPLY_ADDITION=Multiply Addition +distanthorizons.config.enum.EDhApiHeightFogMixMode.INVERSE_MULTIPLY_ADDITION=Inverse Multiply Addition +distanthorizons.config.enum.EDhApiHeightFogMixMode.AVERAGE=Average + +distanthorizons.config.enum.EDhApiHeightFogDirection.ABOVE_CAMERA=Above Camera +distanthorizons.config.enum.EDhApiHeightFogDirection.BELOW_CAMERA=Below Camera +distanthorizons.config.enum.EDhApiHeightFogDirection.ABOVE_AND_BELOW_CAMERA=Above And Below Camera +distanthorizons.config.enum.EDhApiHeightFogDirection.ABOVE_SET_HEIGHT=Above Set Height +distanthorizons.config.enum.EDhApiHeightFogDirection.BELOW_SET_HEIGHT=Below Set Height +distanthorizons.config.enum.EDhApiHeightFogDirection.ABOVE_AND_BELOW_SET_HEIGHT=Above And Below Set Height + +distanthorizons.config.enum.EDhApiVanillaOverdraw.NEVER=Never +distanthorizons.config.enum.EDhApiVanillaOverdraw.DYNAMIC=Dynamic +distanthorizons.config.enum.EDhApiVanillaOverdraw.ALWAYS=Always + +distanthorizons.config.enum.EDhApiDistantGeneratorMode.NONE=1. Existing Only +distanthorizons.config.enum.EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY=2. Pre-Existing Chunks only +distanthorizons.config.enum.EDhApiDistantGeneratorMode.BIOME_ONLY=3. Biome only +distanthorizons.config.enum.EDhApiDistantGeneratorMode.BIOME_ONLY_SIMULATE_HEIGHT=4. Biome only simulate height +distanthorizons.config.enum.EDhApiDistantGeneratorMode.SURFACE=5. Surface +distanthorizons.config.enum.EDhApiDistantGeneratorMode.FEATURES=6. Features +distanthorizons.config.enum.EDhApiDistantGeneratorMode.INTERNAL_SERVER=7. Full - Save Chunks + +distanthorizons.config.enum.EDhApiDistantGeneratorProgressDisplayLocation.OVERLAY=Overlay +distanthorizons.config.enum.EDhApiDistantGeneratorProgressDisplayLocation.CHAT=Chat +distanthorizons.config.enum.EDhApiDistantGeneratorProgressDisplayLocation.LOG=Log +distanthorizons.config.enum.EDhApiDistantGeneratorProgressDisplayLocation.DISABLED=Disabled + +distanthorizons.config.enum.EDhApiDataCompressionMode.UNCOMPRESSED=Uncompressed +distanthorizons.config.enum.EDhApiDataCompressionMode.LZ4=Fastest/Big - LZ4 +distanthorizons.config.enum.EDhApiDataCompressionMode.Z_STD_BLOCK=Fastest/Small - Z_STD - Block +distanthorizons.config.enum.EDhApiDataCompressionMode.Z_STD_STREAM=Fast/Small - Z_STD - Stream +distanthorizons.config.enum.EDhApiDataCompressionMode.LZMA2=Slow/Smallest - LZMA2 + +distanthorizons.config.enum.EDhApiWorldCompressionMode.MERGE_SAME_BLOCKS=1. Merge Same Blocks +distanthorizons.config.enum.EDhApiWorldCompressionMode.VISUALLY_EQUAL=2. Visually Equal + +distanthorizons.config.enum.EDhApiBlocksToAvoid.NONE=None +distanthorizons.config.enum.EDhApiBlocksToAvoid.NON_COLLIDING=Non-Colliding + +distanthorizons.config.enum.EDhApiServerFolderNameMode.NAME_ONLY=Name Only +distanthorizons.config.enum.EDhApiServerFolderNameMode.IP_ONLY=IP Only +distanthorizons.config.enum.EDhApiServerFolderNameMode.NAME_IP=Name and IP +distanthorizons.config.enum.EDhApiServerFolderNameMode.NAME_IP_PORT=Name, IP, Port +distanthorizons.config.enum.EDhApiServerFolderNameMode.NAME_IP_PORT_MC_VERSION=Name, IP, Port, MC version + +distanthorizons.config.enum.EDhApiRendererMode.DEFAULT=Default +distanthorizons.config.enum.EDhApiRendererMode.DEBUG=Debug +distanthorizons.config.enum.EDhApiRendererMode.DISABLED=Disabled + +distanthorizons.config.enum.EDhApiDebugRendering.OFF=Off +distanthorizons.config.enum.EDhApiDebugRendering.SHOW_DETAIL=Show detail +distanthorizons.config.enum.EDhApiDebugRendering.SHOW_GENMODE=Show generation mode +distanthorizons.config.enum.EDhApiDebugRendering.SHOW_BLOCK_MATERIAL=Show Material +distanthorizons.config.enum.EDhApiDebugRendering.SHOW_OVERLAPPING_QUADS=Show overlapping quads +distanthorizons.config.enum.EDhApiDebugRendering.SHOW_RENDER_SOURCE_FLAG=Show render source flag + +distanthorizons.config.enum.EDhApiGLErrorHandlingMode.IGNORE=Ignore +distanthorizons.config.enum.EDhApiGLErrorHandlingMode.LOG=Log +distanthorizons.config.enum.EDhApiGLErrorHandlingMode.LOG_THROW=Log-Throw + +distanthorizons.config.enum.EDhApiGlProfileMode.CORE=Core +distanthorizons.config.enum.EDhApiGlProfileMode.COMPAT=Compat +distanthorizons.config.enum.EDhApiGlProfileMode.ANY=Any + +distanthorizons.config.enum.EDhApiLoggerLevel.ALL=1. All +distanthorizons.config.enum.EDhApiLoggerLevel.DEBUG=2. Debug +distanthorizons.config.enum.EDhApiLoggerLevel.INFO=3. Info +distanthorizons.config.enum.EDhApiLoggerLevel.WARN=4. Warn +distanthorizons.config.enum.EDhApiLoggerLevel.ERROR=5. Error +distanthorizons.config.enum.EDhApiLoggerLevel.DISABLED=6. Disabled + + +distanthorizons.config.enum.EDhApiGpuUploadMethod.AUTO=Auto +distanthorizons.config.enum.EDhApiGpuUploadMethod.NONE=None +distanthorizons.config.enum.EDhApiGpuUploadMethod.BUFFER_STORAGE=Buffer storage +distanthorizons.config.enum.EDhApiGpuUploadMethod.SUB_DATA=Sub data +distanthorizons.config.enum.EDhApiGpuUploadMethod.BUFFER_MAPPING=Buffer mapping +distanthorizons.config.enum.EDhApiGpuUploadMethod.DATA=Data + +distanthorizons.config.enum.EDhApiLodShading.AUTO=Auto +distanthorizons.config.enum.EDhApiLodShading.ENABLED=Enabled +distanthorizons.config.enum.EDhApiLodShading.DISABLED=Disabled + +distanthorizons.config.enum.EDhApiUpdateBranch.STABLE=Stable +distanthorizons.config.enum.EDhApiUpdateBranch.NIGHTLY=Nightly +distanthorizons.config.enum.EDhApiUpdateBranch.AUTO=Auto + +distanthorizons.config.enum.EDhApiGrassSideRendering.AS_GRASS=As Grass +distanthorizons.config.enum.EDhApiGrassSideRendering.FADE_TO_DIRT=Fade To Dirt +distanthorizons.config.enum.EDhApiGrassSideRendering.AS_DIRT=As Dirt + diff --git a/cleanroom/src/main/resources/assets/distanthorizons/textures/clouds-original.png b/cleanroom/src/main/resources/assets/distanthorizons/textures/clouds-original.png new file mode 100644 index 0000000000000000000000000000000000000000..825f4814e3fab7899db0e991087484a908873d5f GIT binary patch literal 6214 zcmV-M7`f+(P)Px#1ZP1_K>z@;j|==^1poj522e~?MF0Q*|NsA`*`M72000SaNLh0L01m?j~gZYoErBeyQB=cj_p-0I=rLVQ)}o zX;6sM?D;ZSxmyPL8$XLp<>oVCn8;hlxgU}{YnO7-aJ30Pm&!L>086(&v>*ZaTTf2i z1WW_;x2ojbp#vBqFaZ7H{i6U}4m=>X-|>M`YbH}SX^ zabDL|LB5VokLw92$f8Yu10&lKPTR-LAJj=I00NoF6#!)IU|mX`zAnTf0H&Kojqi^P zo~64l0jJ+={zqwg%;;kjr0 zVm@IVRo_rz8+n0MzzP6+b9E?iL@_)fLSMSVNQv-^{c7~E7)f;mr?C5KvQJiiX5RYE4Y~7NwGfkD z(=8-W%v*mU3Gw_}0B7Qe*RU(*{3vO09*%yfMrp#ojrS1~Y0S8UF4vLSodmr5JhwU3 zF*K1lbNlN@dkQ-`DsVU<(}KX5&sESk{~E573K^_MCAx9^AR~8`e%2WIMwt*Y`35&^ zqy`|(3#UynNOYkJRjxixl7=CqyJ^WMDyj~EluN{A9h^5u_^g=-L0iiY^2COhD7GX; zg^xdfQvy_7d+keHmsnnMa*hk z08L&@b&LxDH(Up>5OD8o+!|R?>TZ7ZII|Zq3iC&rrZ_CNU-$H@UnnI8%W(GL-D(&b z`^7osCJEP$=|r+#YNB7SL+Zn{z$NXjtTk7f>{pI#v8HZGE%L7cafSjfA!Pp0=Oaxm z_0~J-@UYgMv`9WzG7ayF^glC?)&ZyiKrm10bi<*G39oZvFxB_c3H1pLFKz` z+oh9&vW{PxNJm}fdBHbk5I;1>1NDL(fs{Oz#cBG()m|f?OlDFw4r)=x0l33b2Y(>Y zU_%B#$fqbPW#zLH7$(QlB!b21+fRonRsd=j!u`CF*eNH6&c%b~IwZSx+o*OaB1i&P zybiJjM71#=P4u!x6vXr=+PogxCYDHbvd50KU9L1SR+)fSd}?X@0bnJ7XdUvl(bHTe zor>a5_DJT0)m7R5XH1SljMhOg*NgH@QHNNn6lyC=xK#}zYY^*8HSWa(N>)w@X!E-M zA**Aem)lbp8Y@^AvYN3&oa3by<@Y&9iJ*_VJbKoWY)m0Y;vWa;!ZFCt&$1)KZXSRO zca4Z+XthwXkIOHEA8T0^z!aweSY0%8r7wvUu&(AnM0TrK>lQ{MxHNq3~1wP0KZG0G(Ir%h1M>Nyfv_PIJ|b5_eFwQtyTbSk_G!s04nwx z3zHEV(JW=5bUU(#YJ!mx+O+9zQL4K=);kOr+&%#mK0yd7h|)KYjBAHM=F2i2NZoKD zSJ(isZ{zh~z&`O?+QWGidfDVyiV)TXDS*XF)?706D(00O18i)u<4HJMdUf)Y_k9_)9QKcxVHV!ybkmz3gMQfI_ZouVwS6(1TR&KO3*5 zQMvyr0iGMQtks=$eDx;NNW02W+Ljj<is)bzMZqxsuudC`9hv(WF1+8(z0iaH}N9 zHZk_C2CRMetilPHSKwx8YXPv;#?c6K9iVkqbz}w)r0&LO5vuX0`e7}y-0Q|u0?-*m z_))>`SyAms*l!`q3IO>Q@N&4&FRDQRbe=9lb&f@kDpuTBx$S%~AbuHsO zcTF`w0kE54No`Lm8kaPufL<3+NNZV61hcWf+oqhXjT$27d28AsT#9Qg6x6-+?3OQ^ zkB5HpeiTO%7BhpKAU)noxTu-{rrZ?P{hd=M!OKLIyeuj5iJG!^7~e~7FLy#MZa}Lj z$34e^UBc|!{uPq*w%q=4x6)xVgHwB3c2OEaEhDk;WJ-FBn2G(-lAn3vv2GHAOqN{Js{+d8?CCPJa3PK&vm)pN@Q<9 zw{-O+LOb^!CtdoVsjNo;xF7vVxhzNMnCC6VpV(v5Aie<^7d;7#dTQM!S^?A@n)>G>osf?h6%p%3mpmU=)9~h-x6n?Xk5B~Ry|7gee2Fb$qbc%; zlb8>2d8J$3eja}mT+Z$}%WOIW7H|Sf(khkWJZ`senVvLByCntA2QL;E%_e?+tD2O` z$RTL|?uZ}){0qgkVw?ZB*5+8#uUOP3rLK`@$*ATv z(GQti8(JOO^6eNxcg~P)2c(C$AqG7o!JGl$%?Swta!+?Op#ac&yPfK3zGNYH!t`|w zbX8eG#JXb2s8kVMo{_(>kA&vlGWcyiB7sy$Wf2Hm09Xdd5l3!5a|rSRK%rW55#IHN z03h-vaqk}9D7Ca>XLtJOhhy-#KFgjdZ8(kgWSmt(a?3FiDN${KwRXb}GbD9lD#u8u z2i}_z#19#SN|LR4v|&8i@aBFP^0@_N4{BuRcQ5BtJIBCraP9oHDvLjgbvom_1R$Rd zGHIBQMc28fjHJ%fn9mp++yrz63qy?Np>gPkx*$Coht1KQ@FFumdWghJ*i1)`knon! zTEsTslzSBlQss4a5oC!V;>{oEG3Qhn}eSq$Xv7`jEGT8GV zXb|7%g#$hOoKYdv)tfPd#Q*Q7I`Uy1@Hy{AU!*i`2HwXa!re*Q8lpRI&sr^ z<3bEPG$N?c5ghXv4`ryia^OpV(HZQYIRBf!1WVG=93%;g5TfbL<az5f3v!Kgl7-%s9IgXB;hF&<6xS_vHcG7vyvRj_siUH@|rN z6Y@#7v7>qaG$qehNO_uzK=~zs@6yO~JK82iOkNDE)&cuxY@>?!DLq+g!`d@2sM;8j zyf~~i!Mj*S{-h?R$Qq}NKx%#0idMWBGjGpb-%^SV00sae)Wl8!*iM($9;XH9a5Eex zzx@q>7X|F$bPs&;^HGOK99i0Y0pR;wKM|C~4GLB10+da+Q=LW9s5sLf>q`qEa9{ms zY~w+B01e4 z*n4Fvk4ho&ZvFP&2mPWS;iHTlEhwZYz)R9A3uC*}uK?J1+>3o$>4q&+r`mxCsEP8Z zXYz))GY`oWk&s?!fj%V=*;3UxCrH%l?MTUh?$n3mz`_-Q_=22}v|R}C*H%x2a?K=* zD6D4H0-fJ&4Ls18yDw{r6i4A{0`S*9nK{!9K-HllNx2X0Nf~w0$)r>UwO2TyGjAH* z0l->u&ht=@yteR;OCK^R&L@p|J~VV>?+FZ7{7^@@7JG%2F4imOGO>PF$7i-E zYeTQD=p=bL@IqY%-+ZkIR(}1}PEC=Z`d15!u|iq_+GBsu)|~NkOQ};KQCtvf>fgI` z_-!{&;=on01HcPBYh!1yh+wiT*R^s1<(%sEbhzK$s>U~_$in=nA44}uc~R|W4Hi>6>CXa1B`FD@vq{D@gZaV25d0?YTR-T;$t;<+t&vk- zE!i4J^`Csma-Y0}te4?KWfI4)YMF9AGz{EdT@vr4xDaZId0Z3}m$$I=7Er82r_UdA z+6>SMMV5f#%ABwUL*vLMRBNitrhf_tYL}GKHB!pl1kj5;T;||==(C)Dy2C2~WorGE z8jn?&+hW-T>|QLq0)rL%=Q$2*pu_gC?}g{(=>-I8t3J~K+lQ2I>Z#MwY7eqfW<-w$ zg4i4fC;dIFuS&`O@~y);34oOJRN|>aG57&ln`mNT&2THzAyZsCJ+T4c@Mm3(^h@bB zzgvU*`0GcK7t$NJze6W==6skJ1nwj>C&kNq^Hu=*lg~Sqcn2WeYRi{5%y__p&$+Jw zkUehHSBVsGN;Vi&eUhG?YngMu)LdVO7w*vCA(R>%6>);i%k?u0*>#HW2mt$IRnb5L zqVk=S+KfVke#i?fQwRK@0jB+;YwbUJw5m@i7DL{=Xrmz0e#8`Y)un#uYe+i@On#@3u7b(^VJkOQi|r3Euv#R zeIvrnu^O*&h%-@|ML|sG6?LbPVs~T!cGV4@=bdpxL{(wzjd0c?;#nI6+vEv)wQ0Kn zKxpr?%y|Xays$a5`WJeS+P7p_ClR{53P@AHye%Bl@zo?6FS`P`J~0pzHkQHIDnGd! zdm$B4pOn@lwX3Nnxc&<9pq7sheWS7*Im(X-WH*n8HRx>ihYn+nc1tFw9Ctqt0O-fkHuGM_*9p|ON|%hYzAxy;6FatpF2qa$kWX_ z6xof`iasz-2%ei?0q}fr6rl3ncmsN=V)}PWl+!-Bcy@dneS;|{eS{drvv+Nj7pCuL z&?Fe&C4d_MSzWEFXyB}QN9kj8^*IH@*Jl}&_Ch7$Y>&$%iWY-4LbqyX%=-FIByh^8 zY9C5QG)-wOc(*640McLAeJ|Fc#d1Y;Qdt>6OK9$UW9_443HN>doI6SDoc5tqy?gd^ zl7D`$UTXI@0#v%{-D_abIE>uOEV}i_J@JH~o+)?{t#z6}*d7$&L{%jYX8>rZX-h0c zj|)_eGZC=FJAEFDA{vJ3%ByXVOOeJ>Y&oG=$0n)S4FL8pFl+!AO=6s6BDF%R)ybim zl4Yum&kr^L$A({ywOG~C9T7t4BWC+I0I}A*^(Ko$nc(u0)WwIjvV{8Yt7*1n_tHA8 zmrp-7+Vo_`4A6wZ^enfq6PJ)*F7a-7YBYHS%t_OlpRweK@?hBd0&?W964+K;)Vy_> zuO3`yhaM`g$=N}7(#zoDIAXIbo3`||`auHMaJn!CPcf5sxljN}B;^|AD_8mD%{HR^ z#+<|*HS8t7M|>;b>OWJ1P1dybrWHQYf@}I)ByAJO=t;>9a156p83}G?0T*>$@^XpZ)+Z z{cKv+^#=gBapew*36{rR050JIK5Hw7kZd%xV@Y6SV; zVbgLWtO_KWEt8;~RhXq+oM0t%AdD0IsYM(uYqx1z8ZPhN;yjP#at{w0;P5TG$&5(z z#4}R41M5$Ge;_BiBnLpRO~oG`JCv5prF=jL7XIzM*k z?;qiyz7h)nLtp{ETPtbtS9Ed}eC&sHPNM&YGTT7C?+ie1;I{CceK%DuQ&}$DmVTEW z@_bD-cLsZ7wAyWp`4TsZpXYxL0Mgof3Mao_mRR*+HKhwEIpQigT{<6O zwL^6@BdthMA${8FB=l@tach~r7;I4i$p0bE9(W{a-Nx`>yCxDrC?AF!YcE1=ydCwK zPfcLiic>|AE&#C9$Y1Aj7 z&SNT@knU4!X2h=*Pb)LUPx#1ZP1_K>z@;j|==^1poj522e~?MF0Q*|NsA`*`M72000SaNLh0L01m$Z01m$a zI0aKA00053Nkl!Lk-ZJ2bOdQ*{9_o1Aa<*5fm2b<%Kv-b|YP$8s;Q8#k#Jr zoQ@wJgQ@>K1O3&4I4{xr5$TJO(c|p^DDR>LGINT?EQ#Dh zj&S9)m##s6bI`lsX2Ph`dsk9HCYoioJ|D zLRfLUi8MtQGup?-8Xk(9knGx-%!JpKk;#&84w`-%dG04AK}%qNY=Er6F%T0$8;_xi zw&9BF6dH6GRbih@w)2HxzStO&>uS)ve<0AYj>5AR{$W90N^4L=L-RlQUJ&DC0@ZjPh;=*jPLSYvv5M~MFBAl0-BNIsH z15C~g000{K(ZT*WKal6<?_01!^k@7iDG<<3=fuAC~28EsPoqkpK{9G%|Vj005J}`Hw&=0RYXHq~ibpyyzHQsFW8>#s~laM4*8xut5h5 z!4#~(4xGUqyucR%VFpA%3?#rj5JCpzfE)^;7?wd9RKPme1hudO8lVxH;SjXJF*pt9 z;1XPc>u?taU>Kgl7`%oF1VP9M6Ja4bh!J9r*dopd7nzO(B4J20l7OTj>4+3jBE`sZ zqynizYLQ(?Bl0bB6giDtK>Co|$RIL`{EECsF_eL_Q3KQhbwIhO9~z3rpmWi5G!I>X zmZEFX8nhlgfVQHi(M#xcbO3#dj$?q)F%D*o*1Pf{>6$SWH+$s3q(pv=X`qR|$iJF~TPzlc-O$C3+J1 z#CT#lv5;6stS0Uu9wDA3UMCI{Uz12A4#|?_P6{CkNG+sOq(0IRX`DyT~9-sA|ffUF>wk++Z!kWZ5P$;0Hg6gtI-;!FvmBvPc55=u2?Kjj3apE5$3psG>L zsh-pbs)#zDT1jo7c2F-(3)vyY4>O^>2$gY-Gd%Qm(Z8e zYv>2*=jns=cMJ`N4THx>VkjAF8G9M07`GWOnM|ey)0dgZR4~^v8<}UA514ONSSt1^ zd=-((5|uiYR+WC0=c-gyb5%dpd8!Lkt5pxHURHgkMpd&=fR^vEcAI*_=wwAG2sV%zY%w@v@XU~7=xdm1xY6*0;iwVIXu6TaXrs|dqbIl~ z?uTdNHFy_3W~^@g_pF#!K2~{F^;XxcN!DEJEbDF7 zS8PxlSDOr*I-AS3sI8l=#CDr)-xT5$k15hA^;2%zG3@;83hbKf2JJcaVfH2VZT8O{ z%p4LO);n}Nd~$Sk%yw*Wyz8XlG{dRHsl(}4XB%gsbDi@w7p6;)%MzD%mlsoQr;4X; zpL)xc%+^yMd)ZNTI#eJ*$O)i@o$z8)e??LqN_gLa_%;TM>o2SC_ zkmoO6c3xRt`@J4dvz#WL)-Y|z+r(Soy~}%GIzByR`p)SCKE^%*pL(B%zNWq+-#xw~ ze%5}Oeh2)X`#bu}{g3#+;d$~F@lFL`0l@*~0lk45fwKc^10MvL1f>Tx1&sx}1}_Xg z6+#RN4Ot&@lW)Km@*DYMGu&q^n$Z=?2%QyL8~QNJCQKgI5srq>2;UHXZ>IT7>CCnW zh~P(Th`1kV8JQRPeH1AwGO8}>QM6NZadh`A)~w`N`)9q5@sFvDxjWlxwsLl7tZHmh zY-8-3xPZ8-xPf?w_(k!T5_A(J3GIpG#Ms0=iQ{tu=WLoYoaCBRmULsT<=mpV7v|~C z%bs^USv6UZd^m-e5|^?+<%1wXP%juy<)>~<9TW0|n}ttBzM_qyQL(qUN<5P0omQ3h zINdvaL;7fjPeygdGYL;pD|wL_lDQ-EO;$wK-mK5raoH_7l$?~Dqf!lNmb5F^Ft;eT zPi8AClMUo~=55LwlZVRpxOiFd;3B_8yA~shQx|tGF!j;$toK>JuS&gYLDkTP@C~gS@r~shUu{a>bfJ1` z^^VQ7&C1OKHDNXFTgC{M|V%fo{xK_dk6MK@9S!GZ*1JJzrV5xZBjOk z9!NTH<(q(S+MDf~ceQX@Dh|Ry<-sT4rhI$jQ0Sq~!`#Eo-%($2E^vo}is5J@NVEf|KK?WT&2;PCq@=ncR8z zO#GQ^T~S@VXG71PKNocFOt)Y6$@AXlk6rM*aP%VgV%sIRORYVwJx6|U{ozQjTW{-S z_si{9Jg#)~P3t?+@6&(!YQWWV*Z9{iU7vZq@5byKw{9lg9JnRA_4s!7?H6|n?o8ZW zdXIRo{Jz@#>IeD{>VLHUv1Pz*;P_y`V9&!@5AO~Mho1hF|I>%z(nrik)gwkDjgOrl z9~%uCz4Bzvli{bbrxVZ0epdf^>vOB;-~HnIOV3#R*zgPai_gEVd8zYq@2jb=I>#f& zAH2?aJ@Kaet-A=E_D&uc3__ldcM(ExaQ?*T?GxJx0T??0T<)i5 zxTrhpHF1u^(xd>TlykdubC~eu!9dfL?)4du7Y)T;R!WBc%dOUipPJ>!h(By8W#s$5 z_M#9%`#rbIS%J$)0amZ7c<&ze$OgdeyL_B}08qcLE56~;FcGgbB_2@3mkP`Z$b)Ht z>q@Di+jmnhXZdDIJezX4ywY%tKO1A!0c#j@264vr57>VQRHjW)K%t#tnkGRIP^nZ9 zLSULE)9IASWCDQey3}g5M11B>>2|w`a~zhY%$?F`B*%Xq3^Yx#EQ@x#t=P*-$p+$L#NXLpw((AzQr0VO^F8-@udQ@0`g#5;JQ+3=r~U5 kt<807*qoM6N<$g7sq-^lnk5hS=4k__`PV-Ol@H(5E z00ciieB(X5tMqiitAp7JXBgPn*xD*Ls~i6L{rk7Qu(5X7bivdIn_Ax%m|bb@X^H8$ zY*utwa5cB_9E)VBY@Kv9_W$d3`wwSw kvah!}H^+#JO_71&4y)@69i^a$K;JTWy85}Sb4q9e0JKMJwEzGB literal 0 HcmV?d00001 diff --git a/cleanroom/src/main/resources/assets/distanthorizons/textures/jar/themeDark.svg b/cleanroom/src/main/resources/assets/distanthorizons/textures/jar/themeDark.svg new file mode 100644 index 000000000..a4b041582 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/textures/jar/themeDark.svg @@ -0,0 +1,40 @@ + + + + + + diff --git a/cleanroom/src/main/resources/assets/distanthorizons/textures/jar/themeLight.svg b/cleanroom/src/main/resources/assets/distanthorizons/textures/jar/themeLight.svg new file mode 100644 index 000000000..4864825d9 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/textures/jar/themeLight.svg @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + diff --git a/cleanroom/src/main/resources/assets/distanthorizons/textures/null.svg b/cleanroom/src/main/resources/assets/distanthorizons/textures/null.svg new file mode 100644 index 000000000..0a575ac81 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/textures/null.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/cleanroom/src/main/resources/assets/distanthorizons/textures/test-grid.png b/cleanroom/src/main/resources/assets/distanthorizons/textures/test-grid.png new file mode 100644 index 0000000000000000000000000000000000000000..f5dde4aa3ae7e237e006d219ec70914b911e2df4 GIT binary patch literal 1103 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58CaNs)Vi3hp&(vykh>GZx^prwfgF}}M_)$< zhK>E)e-c@Ne6|3e5ZC|z{{xw!hc4FvDb50q$YKTtzJnmlxMO1WTLuQ^OP(%{Ar-gY z-esJ&Sb>M_!4tNVfAx2-&ERGf(un$9R(JpQ+=U50uQY7gpm%rQ#$B^x=JErLf`AXD z4HwQb{3>nu;Kl0n@%PULfhEhjl;Yx(JUG@6!!NL1G$(KuPeGHxD|Qcm#trNR=N*38?BP-{zu(&! z%ge?%L6!V0VuUcA<4-|@EQL0Zc8S7|O!;*-s73#{YVZs>1IV^?8Z z5SYLv@P0p!g{?fyrC?eirvns*VDR8P%Op9l&;%L*Tzy?+WEg1+B1lVn+V=B}=Kd&=z~js22b@tgs- z!%xQutY>~Sub{}I{MU+zcWh^#fl>k-T;sp9Uy%*YWnlPW%1{}+T{Ccvf`xR#bas*a z30%`%&#~QDdG`@-(9u-EU`A2v@g4As%B;VZU2nx?Df&jd-RkGcZI3Q{WHUNH z-t>O|KE^vM8#c+8{;T6MwQeL`{Fu4ZFpA5*+3KXy7+Awum>v6`(@09RBIr)Vo|VXc^+#~hd5 zVdc=vV8fLm|FE#_Nw9<0%{q^&=j`d zu7XeT>3eT2_JrG%>+b)V#kga0&-1+wjo}P`|3+&oq_w5I|9@|xbj!PcH@P_KMbD-- lq}jP0MGA^PU%xWD{AcjJd? uMaxLevelHeight) + { + fragColor = vec4(combinedMcDhColor.rgb, 0.0); + } + // a fragment depth of "1" means the fragment wasn't drawn to, + // we only want to fade vanilla rendered objects, not to the sky or LODs + else if (mcFragmentDepth < 1.0) + { + // fade based on distance from the camera + vec3 mcVertexWorldPos = calcViewPosition(mcFragmentDepth, uMcInvMvmProj); + float mcFragmentDistance = length(mcVertexWorldPos.xzy); + + + // Smoothly transition between combinedMcDhColor and uDhColorTexture + // as the depth increases from the camera + float fadeStep = smoothstep(uStartFadeBlockDistance, uEndFadeBlockDistance, mcFragmentDistance); + fragColor = mix(combinedMcDhColor, dhColor, fadeStep); + fragColor.a = 1.0; + } + else + { + fragColor = vec4(combinedMcDhColor.rgb, 0.0); + } +} + diff --git a/cleanroom/src/main/resources/shaders/flat_shaded.frag b/cleanroom/src/main/resources/shaders/flat_shaded.frag new file mode 100644 index 000000000..d24ba9672 --- /dev/null +++ b/cleanroom/src/main/resources/shaders/flat_shaded.frag @@ -0,0 +1,123 @@ +#version 150 + +in vec4 vertexColor; +in vec3 vertexWorldPos; +in vec4 vPos; +in vec4 gl_FragCoord; + +out vec4 fragColor; + + +// Fade/Clip Uniforms +uniform float uClipDistance = 0.0; + +// Noise Uniforms +uniform bool uNoiseEnabled; +uniform int uNoiseSteps; +uniform float uNoiseIntensity; +uniform int uNoiseDropoff; +uniform bool uDitherDhRendering; + + +// The random functions for diffrent dimentions +float rand(float co) { return fract(sin(co*(91.3458)) * 47453.5453); } +float rand(vec2 co) { return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } +float rand(vec3 co) { return rand(co.xy + rand(co.z)); } + +// Puts steps in a float +// EG. setting stepSize to 4 then this would be the result of this function +// In: 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, ..., 1.1, 1.2, 1.3 +// Out: 0.0, 0.0, 0.0, 0.25, 0.25, 0.5, 0.5, ..., 1.0, 1.0, 1.25 +vec3 quantize(vec3 val, int stepSize) +{ + return floor(val * stepSize) / stepSize; +} + +void applyNoise(inout vec4 fragColor, const in float viewDist) +{ + vec3 vertexNormal = normalize(cross(dFdy(vPos.xyz), dFdx(vPos.xyz))); + // This bit of code is required to fix the vertex position problem cus of floats in the verted world position varuable + vec3 fixedVPos = vPos.xyz + vertexNormal * 0.001; + + float noiseAmplification = uNoiseIntensity; + float lum = (fragColor.r + fragColor.g + fragColor.b) / 3.0; + noiseAmplification = (1.0 - pow(lum * 2.0 - 1.0, 2.0)) * noiseAmplification; // Lessen the effect on depending on how dark the object is, equasion for this is -(2x-1)^{2}+1 + noiseAmplification *= fragColor.a; // The effect would lessen on transparent objects + + // Random value for each position + float randomValue = rand(quantize(fixedVPos, uNoiseSteps)) + * 2.0 * noiseAmplification - noiseAmplification; + + // Modifies the color + // A value of 0 on the randomValue will result in the original color, while a value of 1 will result in a fully bright color + vec3 newCol = fragColor.rgb + (1.0 - fragColor.rgb) * randomValue; + newCol = clamp(newCol, 0.0, 1.0); + + if (uNoiseDropoff != 0) { + float distF = min(viewDist / uNoiseDropoff, 1.0); + newCol = mix(newCol, fragColor.rgb, distF); // The further away it gets, the less noise gets applied + } + + fragColor.rgb = newCol; +} + +/** returns a normalized value between 0.0 and 1.0 */ +float bayerMatrix4x4(vec2 st) +{ + int x = int(mod(st.x, 4.0)); + int y = int(mod(st.y, 4.0)); + + // Flattened 4x4 Bayer matrix + float bayer4x4[16] = float[16]( + 0.0, 8.0, 2.0, 10.0, + 12.0, 4.0, 14.0, 6.0, + 3.0, 11.0, 1.0, 9.0, + 15.0, 7.0, 13.0, 5.0 + ); + + // Calculate the 1D index from the 2D coordinates + int index = y * 4 + x; + + // Return the Bayer value normalized between 0.0 and 1.0 + return bayer4x4[index] / 16.0; +} + + + +void main() +{ + fragColor = vertexColor; + + float viewDist = length(vertexWorldPos); + + if (uDitherDhRendering) + { + // Dither out the fragment based on distance and noise. + // Dithering is used since it works for both opaque and transparent rendering + + // noise increases as the distance increases + // the fragCoord is used since it is stable and small so the dithering is cleaner + float worldNoise = bayerMatrix4x4(gl_FragCoord.xy); + // minor fudge factor to make sure all pixels fade out + // if not included 1 in 16 pixels would never fade away + worldNoise += 0.001; + + float fadeStep = smoothstep(uClipDistance, uClipDistance * 1.5, viewDist); + if (fadeStep <= worldNoise) + { + discard; + } + } + else + { + if (viewDist < uClipDistance && uClipDistance > 0.0) + { + discard; + } + } + + if (uNoiseEnabled) + { + applyNoise(fragColor, viewDist); + } +} diff --git a/cleanroom/src/main/resources/shaders/fog/apply.frag b/cleanroom/src/main/resources/shaders/fog/apply.frag new file mode 100644 index 000000000..e74a053e5 --- /dev/null +++ b/cleanroom/src/main/resources/shaders/fog/apply.frag @@ -0,0 +1,27 @@ +#version 150 core + +in vec2 TexCoord; + +out vec4 fragColor; + +uniform sampler2D uColorTexture; +uniform sampler2D uDepthTexture; + + +/** + * Fog application shader + * + * This merges the rendered fog onto DH's rendered LODs + */ +void main() +{ + fragColor = vec4(0.0); + + // a fragment depth of "1" means the fragment wasn't drawn to, + // only update fragments that were drawn to + float fragmentDepth = textureLod(uDepthTexture, TexCoord, 0).r; + if (fragmentDepth != 1) + { + fragColor = texture(uColorTexture, TexCoord); + } +} diff --git a/cleanroom/src/main/resources/shaders/fog/fog.frag b/cleanroom/src/main/resources/shaders/fog/fog.frag new file mode 100644 index 000000000..d34336cf9 --- /dev/null +++ b/cleanroom/src/main/resources/shaders/fog/fog.frag @@ -0,0 +1,297 @@ +#version 150 core + +in vec2 TexCoord; + +out vec4 fragColor; + + + +uniform sampler2D uDepthMap; +// inverted model view matrix and projection matrix +uniform mat4 uInvMvmProj; + +// fog uniforms +uniform vec4 uFogColor; +uniform float uFogScale; +uniform float uFogVerticalScale; +uniform int uFogDebugMode; +uniform int uFogFalloffType; + +// fog config +uniform float uFarFogStart; +uniform float uFarFogLength; +uniform float uFarFogMin; +uniform float uFarFogRange; +uniform float uFarFogDensity; + +// height fog config +uniform float uHeightFogStart; +uniform float uHeightFogLength; +uniform float uHeightFogMin; +uniform float uHeightFogRange; +uniform float uHeightFogDensity; + + +uniform bool uHeightFogEnabled; +uniform int uHeightFogFalloffType; +uniform bool uHeightBasedOnCamera; +uniform float uHeightFogBaseHeight; +uniform bool uHeightFogAppliesUp; +uniform bool uHeightFogAppliesDown; +uniform bool uUseSphericalFog; +uniform int uHeightFogMixingMode; +uniform float uCameraBlockYPos; + + + +//====================// +// method definitions // +//====================// + +vec3 calcViewPosition(float fragmentDepth); + +float getFarFogThickness(float dist); +float getHeightFogThickness(float dist); +float calculateHeightFogDepth(float worldYPos); +float mixFogThickness(float far, float height); + +float linearFog(float worldDist, float fogStart, float fogLength, float fogMin, float fogRange); +float exponentialFog(float x, float fogStart, float fogLength, float fogMin, float fogRange, float fogDensity); +float exponentialSquaredFog(float x, float fogStart, float fogLength, float fogMin, float fogRange, float fogDensity); + + + +//======// +// main // +//======// + +/** + * Fragment shader for fog. + * This should be run last so it applies above other affects like Ambient Occlusioning + */ +void main() +{ + float fragmentDepth = texture(uDepthMap, TexCoord).r; + fragColor = vec4(uFogColor.rgb, 0.0); + + // a fragment depth of "1" means the fragment wasn't drawn to, + // we only want to apply Fog to LODs, not to the sky outside the LODs + if (fragmentDepth < 1.0) + { + int fogDebugMode = uFogDebugMode; + if (fogDebugMode == 0) + { + // render fog based on distance from the camera + vec3 vertexWorldPos = calcViewPosition(fragmentDepth); + + float horizontalWorldDistance = length(vertexWorldPos.xz) * uFogScale; + float worldDistance = length(vertexWorldPos.xyz) * uFogScale; + float activeDistance = uUseSphericalFog ? worldDistance : horizontalWorldDistance; + + + // far fog + float farFogThickness = getFarFogThickness(activeDistance); + + // height fog + float heightFogDepth = calculateHeightFogDepth(vertexWorldPos.y); + float heightFogThickness = getHeightFogThickness(heightFogDepth); + + // combined fog + float mixedFogThickness = mixFogThickness(farFogThickness, heightFogThickness); + fragColor.a = clamp(mixedFogThickness, 0.0, 1.0); + } + else if (fogDebugMode == 1) + { + // test code + + // render everything with the fog color + fragColor.a = 1.0; + } + else + { + // test code. + + // this can be fired by manually changing the fullFogMode to a (normally) + // invalid value (like 7). + // By having a separate if statement defined by + // a uniform we don't have to worry about GLSL optimizing away different + // options when testing, causing a bunch of headaches if we just want to render the screen red. + + float depthValue = textureLod(uDepthMap, TexCoord, 0).r; + fragColor.rgb = vec3(depthValue); // Convert depth value to grayscale color + fragColor.a = 1.0; + } + } +} + + + +//================// +// helper methods // +//================// + +vec3 calcViewPosition(float fragmentDepth) +{ + vec4 ndc = vec4(TexCoord.xy, fragmentDepth, 1.0); + ndc.xyz = ndc.xyz * 2.0 - 1.0; + + vec4 eyeCoord = uInvMvmProj * ndc; + return eyeCoord.xyz / eyeCoord.w; +} + + + +//=========// +// far fog // +//=========// + +float getFarFogThickness(float dist) +{ + if (uFogFalloffType == 0) // LINEAR + { + return linearFog(dist, uFarFogStart, uFarFogLength, uFarFogMin, uFarFogRange); + } + else if (uFogFalloffType == 1) // EXPONENTIAL + { + return exponentialFog(dist, uFarFogStart, uFarFogLength, uFarFogMin, uFarFogRange, uFarFogDensity); + } + else // EXPONENTIAL_SQUARED + { + return exponentialSquaredFog(dist, uFarFogStart, uFarFogLength, uFarFogMin, uFarFogRange, uFarFogDensity); + } +} + +float getHeightFogThickness(float dist) +{ + if (!uHeightFogEnabled) + { + return 0.0; + } + + if (uHeightFogFalloffType == 0) // LINEAR + { + return linearFog(dist, uHeightFogStart, uHeightFogLength, uHeightFogMin, uHeightFogRange); + } + else if (uHeightFogFalloffType == 1) // EXPONENTIAL + { + return exponentialFog(dist, uHeightFogStart, uHeightFogLength, uHeightFogMin, uHeightFogRange, uHeightFogDensity); + } + else // EXPONENTIAL_SQUARED + { + return exponentialSquaredFog(dist, uHeightFogStart, uHeightFogLength, uHeightFogMin, uHeightFogRange, uHeightFogDensity); + } +} + +float linearFog(float worldDist, float fogStart, float fogLength, float fogMin, float fogRange) +{ + worldDist = (worldDist - fogStart) / fogLength; + worldDist = clamp(worldDist, 0.0, 1.0); + return fogMin + fogRange * worldDist; +} + +float exponentialFog( + float x, float fogStart, float fogLength, + float fogMin, float fogRange, float fogDensity) +{ + x = max((x-fogStart)/fogLength, 0.0) * fogDensity; + return fogMin + fogRange - fogRange/exp(x); +} + +float exponentialSquaredFog( + float x, float fogStart, float fogLength, + float fogMin, float fogRange, float fogDensity) +{ + x = max((x-fogStart)/fogLength, 0.0) * fogDensity; + return fogMin + fogRange - fogRange/exp(x*x); +} + + + +//============// +// height fog // +//============// + +/** 1 = full fog, 0 = no fog */ +float calculateHeightFogDepth(float worldYPos) +{ + // worldYPos -65 - 384 + + + //worldYPos = worldYPos * -1; // negative, fog below height; positive, fog above height + //return worldYPos * uFogVerticalScale; // "* uFogVerticalScale" is done to convert world position to a percent of the world height; + + if (!uHeightFogEnabled) + { + // ignore the height + return 0.0; + } + + + if (!uHeightBasedOnCamera) + { + worldYPos -= (uHeightFogBaseHeight - uCameraBlockYPos); + } + + + if (uHeightFogAppliesDown && uHeightFogAppliesUp) + { + return abs(worldYPos) * uFogVerticalScale; + } + else if (uHeightFogAppliesDown) + { + // apploy fog below given height + return -worldYPos * uFogVerticalScale; + } + else if (uHeightFogAppliesUp) + { + // apply fog above given height + return worldYPos * uFogVerticalScale; + } + else + { + // shouldn't happen, + return 0.0; + } + +} + +float mixFogThickness(float far, float height) +{ + switch (uHeightFogMixingMode) + { + case 0: // BASIC + case 1: // IGNORE_HEIGHT + return far; + + case 2: // MAX + return max(far, height); + + case 3: // ADDITION + return (far + height); + + case 4: // MULTIPLY + return far * height; + + case 5: // INVERSE_MULTIPLY + return (1.0 - (1.0-far)*(1.0-height)); + + case 6: // LIMITED_ADDITION + return (far + max(far, height)); + + case 7: // MULTIPLY_ADDITION + return (far + far*height); + + case 8: // INVERSE_MULTIPLY_ADDITION + return (far + 1.0 - (1.0-far)*(1.0-height)); + + case 9: // AVERAGE + return (far*0.5 + height*0.5); + } + + // shouldn't happen, but default to BASIC / IGNORE_HEIGHT + // if an invalid option is selected + return far; +} + + + diff --git a/cleanroom/src/main/resources/shaders/genericObject/direct/frag.frag b/cleanroom/src/main/resources/shaders/genericObject/direct/frag.frag new file mode 100644 index 000000000..c3d2ac8c4 --- /dev/null +++ b/cleanroom/src/main/resources/shaders/genericObject/direct/frag.frag @@ -0,0 +1,10 @@ +#version 150 core + +in vec4 fColor; + +out vec4 fragColor; + +void main() +{ + fragColor = fColor; +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/shaders/genericObject/direct/vert.vert b/cleanroom/src/main/resources/shaders/genericObject/direct/vert.vert new file mode 100644 index 000000000..55cf5cad7 --- /dev/null +++ b/cleanroom/src/main/resources/shaders/genericObject/direct/vert.vert @@ -0,0 +1,41 @@ +#version 150 core + +uniform mat4 uTransform; +uniform vec4 uColor; +uniform int uSkyLight; +uniform int uBlockLight; +uniform sampler2D uLightMap; + +uniform float uNorthShading; +uniform float uSouthShading; +uniform float uEastShading; +uniform float uWestShading; +uniform float uTopShading; +uniform float uBottomShading; + + +in vec3 vPosition; + +out vec4 fColor; + +void main() +{ + gl_Position = uTransform * vec4(vPosition, 1.0); + + + float blockLight = (float(uBlockLight)+0.5) / 16.0; + float skyLight = (float(uSkyLight)+0.5) / 16.0; + vec4 lightColor = vec4(texture(uLightMap, vec2(blockLight, skyLight)).xyz, 1.0); + + + fColor = lightColor * uColor; + + // apply directional shading + if (gl_VertexID >= 0 && gl_VertexID < 4) { fColor.rgb *= uNorthShading; } + else if (gl_VertexID >= 4 && gl_VertexID < 8) { fColor.rgb *= uSouthShading; } + else if (gl_VertexID >= 8 && gl_VertexID < 12) { fColor.rgb *= uWestShading; } + else if (gl_VertexID >= 12 && gl_VertexID < 16) { fColor.rgb *= uEastShading; } + else if (gl_VertexID >= 16 && gl_VertexID < 20) { fColor.rgb *= uBottomShading; } + else if (gl_VertexID >= 20 && gl_VertexID < 24) { fColor.rgb *= uTopShading; } + +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/shaders/genericObject/instanced/frag.frag b/cleanroom/src/main/resources/shaders/genericObject/instanced/frag.frag new file mode 100644 index 000000000..c3d2ac8c4 --- /dev/null +++ b/cleanroom/src/main/resources/shaders/genericObject/instanced/frag.frag @@ -0,0 +1,10 @@ +#version 150 core + +in vec4 fColor; + +out vec4 fragColor; + +void main() +{ + fragColor = fColor; +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/shaders/genericObject/instanced/vert.vert b/cleanroom/src/main/resources/shaders/genericObject/instanced/vert.vert new file mode 100644 index 000000000..a7d9a6a96 --- /dev/null +++ b/cleanroom/src/main/resources/shaders/genericObject/instanced/vert.vert @@ -0,0 +1,66 @@ +#version 330 core + +layout (location = 1) in vec4 aColor; +layout (location = 2) in vec3 aScale; +layout (location = 3) in ivec3 aTranslateChunk; +layout (location = 4) in vec3 aTranslateSubChunk; +layout (location = 5) in int aMaterial; + +uniform ivec3 uOffsetChunk; +uniform vec3 uOffsetSubChunk; +uniform ivec3 uCameraPosChunk; +uniform vec3 uCameraPosSubChunk; + +uniform mat4 uProjectionMvm; +uniform int uSkyLight; +uniform int uBlockLight; +uniform sampler2D uLightMap; + +uniform float uNorthShading; +uniform float uSouthShading; +uniform float uEastShading; +uniform float uWestShading; +uniform float uTopShading; +uniform float uBottomShading; + + +in vec3 vPosition; + +out vec4 fColor; + +void main() +{ + // aTranslate - moves the vertex to the boxGroup's relative position + // uOffset - moves the vertex to the boxGroup's world position + // uCameraPos - moves the vertex into camera space + vec3 trans = (aTranslateChunk + uOffsetChunk - uCameraPosChunk) * 16.0f; + // separate float and int values are to fix percission loss at extreme distances from the origin (IE 10,000,000+) + // luckily large translate values minus large cameraPos generally equal values that cleanly fit in a float + trans += (aTranslateSubChunk + uOffsetSubChunk - uCameraPosSubChunk); + + // combination translation and scaling matrix + mat4 transform = mat4( + aScale.x, 0.0, 0.0, 0.0, + 0.0, aScale.y, 0.0, 0.0, + 0.0, 0.0, aScale.z, 0.0, + trans.x, trans.y, trans.z, 1.0 + ); + + gl_Position = uProjectionMvm * transform * vec4(vPosition, 1.0); + + float blockLight = (float(uBlockLight)+0.5) / 16.0; + float skyLight = (float(uSkyLight)+0.5) / 16.0; + vec4 lightColor = vec4(texture(uLightMap, vec2(blockLight, skyLight)).xyz, 1.0); + + + fColor = lightColor * aColor; + + // apply directional shading + if (gl_VertexID >= 0 && gl_VertexID < 4) { fColor.rgb *= uNorthShading; } + else if (gl_VertexID >= 4 && gl_VertexID < 8) { fColor.rgb *= uSouthShading; } + else if (gl_VertexID >= 8 && gl_VertexID < 12) { fColor.rgb *= uWestShading; } + else if (gl_VertexID >= 12 && gl_VertexID < 16) { fColor.rgb *= uEastShading; } + else if (gl_VertexID >= 16 && gl_VertexID < 20) { fColor.rgb *= uBottomShading; } + else if (gl_VertexID >= 20 && gl_VertexID < 24) { fColor.rgb *= uTopShading; } + +} diff --git a/cleanroom/src/main/resources/shaders/noise/noise.frag b/cleanroom/src/main/resources/shaders/noise/noise.frag new file mode 100644 index 000000000..6d39b6253 --- /dev/null +++ b/cleanroom/src/main/resources/shaders/noise/noise.frag @@ -0,0 +1,74 @@ +#version 150 core + +in vec4 vertexColor; +in vec4 vPos; +in vec3 vertexWorldPos; +out vec4 fragColor; + +uniform float distanceScale; + +uniform int uNoiseSteps; +uniform float uNoiseIntensity; +uniform float uNoiseDropoff; + + + +// The random functions for diffrent dimentions +float rand(float co) { return fract(sin(co*(91.3458)) * 47453.5453); } +float rand(vec2 co){ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } +float rand(vec3 co){ return rand(co.xy+rand(co.z)); } + +// Puts steps in a float +// EG. setting stepSize to 4 then this would be the result of this function +// In: 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, ..., 1.1, 1.2, 1.3 +// Out: 0.0, 0.0, 0.0, 0.25, 0.25, 0.5, 0.5, ..., 1.0, 1.0, 1.25 +float quantize(float val, int stepSize) { + return floor(val*stepSize)/stepSize; +} + +vec3 quantize(vec3 val, int stepSize) { + return floor(val*stepSize)/stepSize; +} + + +/** + * Fragment shader for adding noise to lods. + * This should be passed close to first as it affects the base color of the lod + * + * version: 2023-6-21 + */ +void main() { + // This bit of code is required to fix the vertex position problem cus of floats in the verted world position varuable + vec3 vertexNormal = normalize(cross(dFdx(vPos.xyz), dFdy(vPos.xyz))); + vec3 fixedVPos = vPos.xyz - vertexNormal * 0.001; + + + float noiseAmplification = uNoiseIntensity; + noiseAmplification = (-1 * pow(2*((vertexColor.x + vertexColor.y + vertexColor.z) / 3) - 1, 2) + 1) * noiseAmplification; // Lessen the effect on depending on how dark the object is, equasion for this is -(2x-1)^{2}+1 + noiseAmplification *= vertexColor.w; // The effect would lessen on transparent objects + + // Random value for each position + float randomValue = rand(quantize(fixedVPos.xyz, uNoiseSteps)) + * 2.0 * noiseAmplification - noiseAmplification; + + + // Modifies the color + // A value of 0 on the randomValue will result in the original color, while a value of 1 will result in a fully bright color + vec3 newCol = (1.0 - vertexColor.rgb) * randomValue; + + // Clamps it and turns it back into a vec4 + float distA = length(vertexWorldPos) * distanceScale * uNoiseDropoff; + fragColor = clamp(vec4(newCol.rgb, distA), 0.0, 1.0); // The further away it gets, the less noise gets applied + + // The further away it gets, the less noise gets applied + fragColor = vec4(0.0, 0.0, 0.0, randomValue); + + // For testing +// if (vertexColor.r != 69420.) { +// fragColor = vec4( +// mod(fixedVPos.x, 1), +// mod(fixedVPos.y, 1), +// mod(fixedVPos.z, 1), +// 1f); +// } +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/shaders/quadApply.vert b/cleanroom/src/main/resources/shaders/quadApply.vert new file mode 100644 index 000000000..3f614c123 --- /dev/null +++ b/cleanroom/src/main/resources/shaders/quadApply.vert @@ -0,0 +1,15 @@ +#version 150 core + +in vec2 vPosition; + +out vec2 TexCoord; + +/** + * This is specifically used by application shaders. + * IE post process or pixel transfer shaders, anything that is rendered using a single rectangle. + */ +void main() +{ + gl_Position = vec4(vPosition, 1.0, 1.0); + TexCoord = vPosition.xy * 0.5 + 0.5; +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/shaders/ssao/ao.frag b/cleanroom/src/main/resources/shaders/ssao/ao.frag new file mode 100644 index 000000000..d4e475348 --- /dev/null +++ b/cleanroom/src/main/resources/shaders/ssao/ao.frag @@ -0,0 +1,130 @@ +#version 150 core +#extension GL_ARB_derivative_control : enable + +#define SAMPLE_MAX 64 + +#define saturate(x) (clamp((x), 0.0, 1.0)) + +in vec2 TexCoord; + +out vec4 fragColor; + +uniform sampler2D uDepthMap; +uniform int uSampleCount; +uniform float uRadius; +uniform float uStrength; +uniform float uMinLight; +uniform float uBias; +uniform mat4 uInvProj; +uniform mat4 uProj; +uniform float uFadeDistanceInBlocks; + +const float EPSILON = 1.e-6; +const float GOLDEN_ANGLE = 2.39996323; +const vec3 MAGIC = vec3(0.06711056, 0.00583715, 52.9829189); +const float PI = 3.1415926538; +const float TAU = PI * 2.0; + + +vec3 unproject(vec4 pos) +{ + return pos.xyz / pos.w; +} + +float InterleavedGradientNoise(const in vec2 pixel) +{ + float x = dot(pixel, MAGIC.xy); + return fract(MAGIC.z * fract(x)); +} + +vec3 calcViewPosition(const in vec3 clipPos) +{ + vec4 viewPos = uInvProj * vec4(clipPos * 2.0 - 1.0, 1.0); + return viewPos.xyz / viewPos.w; +} + +float GetSpiralOcclusion(const in vec2 uv, const in vec3 viewPos, const in vec3 viewNormal) +{ + float dither = InterleavedGradientNoise(gl_FragCoord.xy); + float rotatePhase = dither * TAU; + float rStep = uRadius / uSampleCount; + + vec2 offset; + + float ao = 0.0; + int sampleCount = 0; + float radius = rStep; + for (int i = 0; i < clamp(uSampleCount, 1, SAMPLE_MAX); i++) { + vec2 offset = vec2( + sin(rotatePhase), + cos(rotatePhase) + ) * radius; + + radius += rStep; + rotatePhase += GOLDEN_ANGLE; + + vec3 sampleViewPos = viewPos + vec3(offset, -0.1); + vec3 sampleClipPos = unproject(uProj * vec4(sampleViewPos, 1.0)) * 0.5 + 0.5; + sampleClipPos = saturate(sampleClipPos); + + float sampleClipDepth = textureLod(uDepthMap, sampleClipPos.xy, 0.0).r; + if (sampleClipDepth >= 1.0 - EPSILON) continue; + + sampleClipPos.z = sampleClipDepth; + sampleViewPos = unproject(uInvProj * vec4(sampleClipPos * 2.0 - 1.0, 1.0)); + + vec3 diff = sampleViewPos - viewPos; + float sampleDist = length(diff); + vec3 sampleNormal = diff / sampleDist; + + float sampleNoLm = max(dot(viewNormal, sampleNormal) - uBias, 0.0); + float aoF = 1.0 - saturate(sampleDist / uRadius); + ao += sampleNoLm * aoF; + sampleCount++; + } + + ao /= max(sampleCount, 1); + ao = smoothstep(0.0, uStrength, ao); + + return ao * (1.0 - uMinLight); +} + + +void main() +{ + float fragmentDepth = textureLod(uDepthMap, TexCoord, 0).r; + float occlusion = 0.0; + + // Do not apply to sky + if (fragmentDepth < 1.0) + { + vec3 viewPos = calcViewPosition(vec3(TexCoord, fragmentDepth)); + + // fading is done to prevent banding/noise + // at super far distance + float distanceFromCamera = length(viewPos); + float fadeDistance = uFadeDistanceInBlocks; + if (distanceFromCamera < fadeDistance) + { + #ifdef GL_ARB_derivative_control + // Get higher precision derivatives when available + vec3 viewNormal = cross(dFdxFine(viewPos.xyz), dFdyFine(viewPos.xyz)); + #else + vec3 viewNormal = cross(dFdx(viewPos.xyz), dFdy(viewPos.xyz)); + #endif + + viewNormal = normalize(viewNormal); + occlusion = GetSpiralOcclusion(TexCoord, viewPos, viewNormal); + + // linearly fade with distance + occlusion *= (fadeDistance - distanceFromCamera) / fadeDistance; + } + else + { + // we're out of range, no need to do any SSAO calculations + occlusion = 0.0; + } + } + + fragColor = vec4(vec3(1.0 - occlusion), 1.0); +} diff --git a/cleanroom/src/main/resources/shaders/ssao/apply.frag b/cleanroom/src/main/resources/shaders/ssao/apply.frag new file mode 100644 index 000000000..28d8c8869 --- /dev/null +++ b/cleanroom/src/main/resources/shaders/ssao/apply.frag @@ -0,0 +1,78 @@ +#version 150 core + +in vec2 TexCoord; + +out vec4 fragColor; + +uniform sampler2D gSSAOMap; +uniform sampler2D gDepthMap; +uniform vec2 gViewSize; +uniform int gBlurRadius; +uniform float gNear; +uniform float gFar; + + +float linearizeDepth(const in float depth) { + return (gNear * gFar) / (depth * (gNear - gFar) + gFar); +} + +float Gaussian(const in float sigma, const in float x) { + return exp(-(x*x) / (2.0 * (sigma*sigma))); +} + +float BilateralGaussianBlur(const in vec2 texcoord, const in float linearDepth, const in float g_sigmaV) { + float g_sigmaX = 1.6; + float g_sigmaY = 1.6; + + int radius = clamp(gBlurRadius, 1, 3); + + vec2 pixelSize = 1.0 / gViewSize; + + float accum = 0.0; + float total = 0.0; + for (int iy = -radius; iy <= radius; iy++) { + float fy = Gaussian(g_sigmaY, iy); + + for (int ix = -radius; ix <= radius; ix++) { + float fx = Gaussian(g_sigmaX, ix); + + vec2 sampleTex = texcoord + ivec2(ix, iy) * pixelSize; + float sampleValue = textureLod(gSSAOMap, sampleTex, 0).r; + float sampleDepth = textureLod(gDepthMap, sampleTex, 0).r; + float sampleLinearDepth = linearizeDepth(sampleDepth); + + float depthDiff = abs(sampleLinearDepth - linearDepth); + float fv = Gaussian(g_sigmaV, depthDiff); + + float weight = fx*fy*fv; + accum += weight * sampleValue; + total += weight; + } + } + + if (total <= 1.e-4) return 1.0; + return accum / total; +} + + +void main() +{ + fragColor = vec4(1.0); + + float fragmentDepth = textureLod(gDepthMap, TexCoord, 0).r; + + // a fragment depth of "1" means the fragment wasn't drawn to, + // we only want to apply SSAO to LODs, not to the sky outside the LODs + if (fragmentDepth < 1) + { + if (gBlurRadius > 0) + { + float fragmentDepthLinear = linearizeDepth(fragmentDepth); + fragColor.a = BilateralGaussianBlur(TexCoord, fragmentDepthLinear, 1.6); + } + else + { + fragColor.a = texelFetch(gSSAOMap, ivec2(gl_FragCoord.xy), 0).r; + } + } +} diff --git a/cleanroom/src/main/resources/shaders/standard.vert b/cleanroom/src/main/resources/shaders/standard.vert new file mode 100644 index 000000000..f948f1708 --- /dev/null +++ b/cleanroom/src/main/resources/shaders/standard.vert @@ -0,0 +1,79 @@ +#version 150 core + +in uvec4 vPosition; +out vec4 vPos; +in vec4 color; + +out vec4 vertexColor; +out vec3 vertexWorldPos; +out float vertexYPos; + +uniform bool uIsWhiteWorld; + +uniform mat4 uCombinedMatrix; +uniform vec3 uModelOffset; +uniform float uWorldYOffset; + +uniform sampler2D uLightMap; +uniform float uMircoOffset; + +uniform float uEarthRadius; + +/** + * Vertex Shader + * + * author: James Seibel + * author: TomTheFurry + * author: stduhpf + * updated: coolGi + * + * version: 2025-12-22 + */ +void main() +{ + vPos = vPosition; // This is so it can be passed to the fragment shader + + vertexWorldPos = vPosition.xyz + uModelOffset; + + vertexYPos = vPosition.y + uWorldYOffset; + + uint meta = vPosition.a; + + uint mirco = (meta & 0xFF00u) >> 8u; // mirco offset which is a xyz 2bit value + // 0b00 = no offset + // 0b01 = positive offset + // 0b11 = negative offset + // format is: 0b00zzyyxx + float mx = (mirco & 1u)!=0u ? uMircoOffset : 0.0; + mx = (mirco & 2u)!=0u ? -mx : mx; + //float my = (mirco & 4u)!=0u ? uMircoOffset : 0.0; + //my = (mirco & 8u)!=0u ? -my : my; + float mz = (mirco & 16u)!=0u ? uMircoOffset : 0.0; + mz = (mirco & 32u)!=0u ? -mz : mz; + + vertexWorldPos.x += mx; + //vertexWorldPos.y += my; + vertexWorldPos.z += mz; + + // apply the earth curvature if needed + if (uEarthRadius < -1.0f || uEarthRadius > 1.0f) + { + // vertex transformation logic - stduhpf + float localRadius = uEarthRadius + vertexYPos; + float phi = length(vertexWorldPos.xz) / localRadius; + vertexWorldPos.y += (cos(phi) - 1.0) * localRadius; + vertexWorldPos.xz = vertexWorldPos.xz * sin(phi) / phi; + } + + uint lights = meta & 0xFFu; + float skyLight = (float(lights/16u)+0.5) / 16.0; + float blockLight = (mod(float(lights), 16.0)+0.5) / 16.0; + vertexColor = vec4(texture(uLightMap, vec2(skyLight, blockLight)).xyz, 1.0); + + if (!uIsWhiteWorld) + { + vertexColor *= color; + } + + gl_Position = uCombinedMatrix * vec4(vertexWorldPos, 1.0); +} diff --git a/cleanroom/src/main/resources/shaders/test/dark.frag b/cleanroom/src/main/resources/shaders/test/dark.frag new file mode 100644 index 000000000..ab99d05ce --- /dev/null +++ b/cleanroom/src/main/resources/shaders/test/dark.frag @@ -0,0 +1,9 @@ +#version 150 core + +out vec4 fragColor; + +// A test shader that makes everything darker +void main() +{ + fragColor = vec4(0., 0., 1., 0.5); +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/shaders/test/frag.frag b/cleanroom/src/main/resources/shaders/test/frag.frag new file mode 100644 index 000000000..2a8a4d685 --- /dev/null +++ b/cleanroom/src/main/resources/shaders/test/frag.frag @@ -0,0 +1,9 @@ +#version 150 core + +in vec4 fColor; +out vec4 fragColor; + +void main() +{ + fragColor = fColor; +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/shaders/test/vert.vert b/cleanroom/src/main/resources/shaders/test/vert.vert new file mode 100644 index 000000000..12a66443f --- /dev/null +++ b/cleanroom/src/main/resources/shaders/test/vert.vert @@ -0,0 +1,11 @@ +#version 150 core + +in vec2 vPosition; +in vec4 color; + +out vec4 fColor; +void main() +{ + gl_Position = vec4(vPosition, 0.0, 1.0); + fColor = color; +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/sqlScripts/0010-sqlite-createInitialDataTables.sql b/cleanroom/src/main/resources/sqlScripts/0010-sqlite-createInitialDataTables.sql new file mode 100644 index 000000000..2ed1c771a --- /dev/null +++ b/cleanroom/src/main/resources/sqlScripts/0010-sqlite-createInitialDataTables.sql @@ -0,0 +1,37 @@ + +CREATE TABLE DhFullData( + DhSectionPos TEXT NOT NULL PRIMARY KEY + + -- meta data + ,DataDetailLevel TINYINT NULL + ,Checksum INT NULL + ,DataVersion BIGINT NULL + ,WorldGenStep NVARCHAR(32) NULL + ,DataType NVARCHAR(48) NULL + ,BinaryDataFormatVersion TINYINT NULL + + ,Data BLOB NULL + + ,CreatedDateTime DATETIME NOT NULL default CURRENT_TIMESTAMP -- in UTC + ,LastModifiedDateTime DATETIME NOT NULL default CURRENT_TIMESTAMP -- in UTC +); + +-- Note: each statement must be separated by the following batch comment line otherwise Java won't run anything after the first query +--batch-- + +CREATE TABLE DhRenderData( + DhSectionPos TEXT NOT NULL PRIMARY KEY + + -- meta data + ,DataDetailLevel TINYINT NULL + ,Checksum INT NULL + ,DataVersion BIGINT NULL + ,WorldGenStep NVARCHAR(32) NULL + ,DataType NVARCHAR(48) NULL + ,BinaryDataFormatVersion TINYINT NULL + + ,Data BLOB NULL + + ,CreatedDateTime DATETIME NOT NULL default CURRENT_TIMESTAMP -- in UTC + ,LastModifiedDateTime DATETIME NOT NULL default CURRENT_TIMESTAMP -- in UTC +); diff --git a/cleanroom/src/main/resources/sqlScripts/0020-sqlite-createFullDataSourceV2Tables.sql b/cleanroom/src/main/resources/sqlScripts/0020-sqlite-createFullDataSourceV2Tables.sql new file mode 100644 index 000000000..150b788cf --- /dev/null +++ b/cleanroom/src/main/resources/sqlScripts/0020-sqlite-createFullDataSourceV2Tables.sql @@ -0,0 +1,33 @@ + +ALTER TABLE DhFullData RENAME TO Legacy_FullData_V1; + +--batch-- + +ALTER TABLE Legacy_FullData_V1 ADD COLUMN MigrationFailed BIT NOT NULL DEFAULT 0; + +--batch-- + +CREATE TABLE FullData ( + -- compound primary key + DetailLevel TINYINT NOT NULL -- LOD detail level, not section detail level IE 0, 1, 2 not 6, 7, 8 + ,PosX INT NOT NULL + ,PosZ INT NOT NULL + + ,MinY INT NOT NULL + ,DataChecksum INT NOT NULL + + ,Data BLOB NULL + ,ColumnGenerationStep BLOB NULL + ,ColumnWorldCompressionMode BLOB NULL + ,Mapping BLOB NULL + + ,DataFormatVersion TINYINT NULL + ,CompressionMode TINYINT NULL + + ,ApplyToParent BIT NULL + + ,LastModifiedUnixDateTime BIGINT NOT NULL -- in GMT 0 + ,CreatedUnixDateTime BIGINT NOT NULL -- in GMT 0 + + ,PRIMARY KEY (DetailLevel, PosX, PosZ) +); diff --git a/cleanroom/src/main/resources/sqlScripts/0030-sqlite-changeTableJournaling.sql b/cleanroom/src/main/resources/sqlScripts/0030-sqlite-changeTableJournaling.sql new file mode 100644 index 000000000..6dd0b6898 --- /dev/null +++ b/cleanroom/src/main/resources/sqlScripts/0030-sqlite-changeTableJournaling.sql @@ -0,0 +1,9 @@ + +-- this PRAGMA will automatically commit, so we have to disable +-- DH's automatic transactions, otherwise the connection will throw an error + +--No Transactions-- + +-- James ran into some issues where Windows had trouble deleting the Journal file, +-- using TRUNCATE should fix that issue +PRAGMA journal_mode = TRUNCATE; diff --git a/cleanroom/src/main/resources/sqlScripts/0031-sqlite-useSqliteWalJournaling.sql b/cleanroom/src/main/resources/sqlScripts/0031-sqlite-useSqliteWalJournaling.sql new file mode 100644 index 000000000..1c48df1c7 --- /dev/null +++ b/cleanroom/src/main/resources/sqlScripts/0031-sqlite-useSqliteWalJournaling.sql @@ -0,0 +1,8 @@ + +-- these PRAGMA's will automatically commit, so we have to disable +-- DH's automatic transactions, otherwise the connection will throw an error + +--No Transactions-- + +pragma journal_mode = WAL; +pragma synchronous = NORMAL; diff --git a/cleanroom/src/main/resources/sqlScripts/0040-sqlite-removeRenderCache.sql b/cleanroom/src/main/resources/sqlScripts/0040-sqlite-removeRenderCache.sql new file mode 100644 index 000000000..8e7aef49a --- /dev/null +++ b/cleanroom/src/main/resources/sqlScripts/0040-sqlite-removeRenderCache.sql @@ -0,0 +1,4 @@ + +-- The render cache was discovered to not speed up LOD loading, +-- so to reduce DB file size it was removed. +drop table DhRenderData; diff --git a/cleanroom/src/main/resources/sqlScripts/0050-sqlite-addApplyToParentIndex.sql b/cleanroom/src/main/resources/sqlScripts/0050-sqlite-addApplyToParentIndex.sql new file mode 100644 index 000000000..3f8fb5e93 --- /dev/null +++ b/cleanroom/src/main/resources/sqlScripts/0050-sqlite-addApplyToParentIndex.sql @@ -0,0 +1,3 @@ + +-- significantly speeds up parent update handling +create index FullDataUpdatedIndex on FullData (ApplyToParent) where ApplyToParent = 1 diff --git a/cleanroom/src/main/resources/sqlScripts/0060-sqlite-createChunkHashTable.sql b/cleanroom/src/main/resources/sqlScripts/0060-sqlite-createChunkHashTable.sql new file mode 100644 index 000000000..7bd6f54d7 --- /dev/null +++ b/cleanroom/src/main/resources/sqlScripts/0060-sqlite-createChunkHashTable.sql @@ -0,0 +1,13 @@ + +CREATE TABLE ChunkHash( + -- compound primary key + ChunkPosX INT NOT NULL + ,ChunkPosZ INT NOT NULL + + ,ChunkHash INT NOT NULL + + ,LastModifiedUnixDateTime BIGINT NOT NULL -- in GMT 0 + ,CreatedUnixDateTime BIGINT NOT NULL -- in GMT 0 + + ,PRIMARY KEY (ChunkPosX, ChunkPosZ) +); diff --git a/cleanroom/src/main/resources/sqlScripts/0070-sqlite-createBeaconBeamTable.sql b/cleanroom/src/main/resources/sqlScripts/0070-sqlite-createBeaconBeamTable.sql new file mode 100644 index 000000000..48a5040a6 --- /dev/null +++ b/cleanroom/src/main/resources/sqlScripts/0070-sqlite-createBeaconBeamTable.sql @@ -0,0 +1,16 @@ + +CREATE TABLE BeaconBeam( + -- compound primary key + BlockPosX INT NOT NULL + ,BlockPosY INT NOT NULL + ,BlockPosZ INT NOT NULL + + ,ColorR INT NOT NULL + ,ColorG INT NOT NULL + ,ColorB INT NOT NULL + + ,LastModifiedUnixDateTime BIGINT NOT NULL -- in GMT 0 + ,CreatedUnixDateTime BIGINT NOT NULL -- in GMT 0 + + ,PRIMARY KEY (BlockPosX, BlockPosY, BlockPosZ) +); diff --git a/cleanroom/src/main/resources/sqlScripts/0080-sqlite-addApplyToChildrenColumn.sql b/cleanroom/src/main/resources/sqlScripts/0080-sqlite-addApplyToChildrenColumn.sql new file mode 100644 index 000000000..d514aeee2 --- /dev/null +++ b/cleanroom/src/main/resources/sqlScripts/0080-sqlite-addApplyToChildrenColumn.sql @@ -0,0 +1,9 @@ + +-- Applying to children is needed to fix a bug with N-sized generation. +-- If we don't fill the whole tree with data, it's possible to render empty/incomplete LODs, which looks bad. +alter table FullData add column ApplyToChildren BIT NULL; + +--batch-- + +-- significantly speeds up update handling +create index FullDataApplyToChildrenIndex on FullData (ApplyToChildren) where ApplyToChildren = 1; diff --git a/cleanroom/src/main/resources/sqlScripts/0090-sqlite-addAdjacentFullDataColumns.sql b/cleanroom/src/main/resources/sqlScripts/0090-sqlite-addAdjacentFullDataColumns.sql new file mode 100644 index 000000000..091560537 --- /dev/null +++ b/cleanroom/src/main/resources/sqlScripts/0090-sqlite-addAdjacentFullDataColumns.sql @@ -0,0 +1,12 @@ + +-- storing adjacent data (IE a single line of data on the +X/-X/+Z/-Z axis) +-- allows for significantly reduced render loading times since we only have to +-- handle part of the adjacent data source vs all of it + +alter table FullData add column NorthAdjData BLOB NULL; +--batch-- +alter table FullData add column SouthAdjData BLOB NULL; +--batch-- +alter table FullData add column EastAdjData BLOB NULL; +--batch-- +alter table FullData add column WestAdjData BLOB NULL; \ No newline at end of file diff --git a/cleanroom/src/main/resources/sqlScripts/0100-sqlite-deleteLowDetailDataForRegen.sql b/cleanroom/src/main/resources/sqlScripts/0100-sqlite-deleteLowDetailDataForRegen.sql new file mode 100644 index 000000000..bfb1517c9 --- /dev/null +++ b/cleanroom/src/main/resources/sqlScripts/0100-sqlite-deleteLowDetailDataForRegen.sql @@ -0,0 +1,13 @@ + +-- This is done to fix a bug where a lot of unnecessary +-- ID mapping data is saved, which significantly reduces +-- loading/deserializing/decompression time + + +-- delete all data above 0 (max detail) +-- so it can be re-created +delete from FullData where DetailLevel > 0; +--batch-- + +-- re-downsample all LOD data +update FullData set ApplyToParent = 1; diff --git a/cleanroom/src/main/resources/sqlScripts/readme.md b/cleanroom/src/main/resources/sqlScripts/readme.md new file mode 100644 index 000000000..683e39c0f --- /dev/null +++ b/cleanroom/src/main/resources/sqlScripts/readme.md @@ -0,0 +1,51 @@ + +### All Sql scripts should be run exactly once per database and old scripts shouldn't be changed. Any necessary schema changes should be done by creating new scripts that modify the existing database. + +This system is roughly based on the DbUp library from .NET, for information about DbUp and it's general philosophy please refer to the following doc: +https://dbup.readthedocs.io/en/latest/philosophy-behind-dbup/ + +
+ +### Adding New Scripts: +New scripts must be added to the "scriptList.txt" file, otherwise they will not be run.
+(If anyone has a good way to automatically pull all resource files ending in `.sql` instead, please let us know.) + +
+ +### File Naming: +- The first 3 numbers are major scripts. +- The 4th number is for minor/related scripts or if a bug fix needs to be applied between scripts. +- flavor of database the script is for (for now this is just sqlite) +- description of the script + +
+ +### Mutli-query Scripts: +When creating a script with multiple queries the queries must be separated with the SQL comment `--batch--` otherwise only the first query will be executed. + +Example: +```roomsql +CREATE TABLE TableOne( + DhSectionPos TEXT NOT NULL PRIMARY KEY + ,Data BLOB NULL +); + +--batch-- + +CREATE TABLE TableTwo( + DhSectionPos TEXT NOT NULL PRIMARY KEY + ,Data BLOB NULL +); +``` + +### PRAGMA Auto Commits + +Certain queries will auto commit after running, specifically certain `PRAGMA` commands. In that case we have to disable DH's automatic transactions by putting `--No Transactions--` somewhere in the file. Otherwise, when the system attempts to commit, it will fail due to the PRAGMA having already committed itself. + +Due to how these commands work it's best to only have a single command in the file to prevent confusion and potential database corruption. + +```roomsql +--No Transactions-- + +PRAGMA journal_mode = TRUNCATE; +``` diff --git a/cleanroom/src/main/resources/sqlScripts/scriptList.txt b/cleanroom/src/main/resources/sqlScripts/scriptList.txt new file mode 100644 index 000000000..b64a0d320 --- /dev/null +++ b/cleanroom/src/main/resources/sqlScripts/scriptList.txt @@ -0,0 +1,12 @@ + +0010-sqlite-createInitialDataTables.sql +0020-sqlite-createFullDataSourceV2Tables.sql +0030-sqlite-changeTableJournaling.sql +0031-sqlite-useSqliteWalJournaling.sql +0040-sqlite-removeRenderCache.sql +0050-sqlite-addApplyToParentIndex.sql +0060-sqlite-createChunkHashTable.sql +0070-sqlite-createBeaconBeamTable.sql +0080-sqlite-addApplyToChildrenColumn.sql +0090-sqlite-addAdjacentFullDataColumns.sql +0100-sqlite-deleteLowDetailDataForRegen.sql diff --git a/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java b/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java index e41c5174f..659a30c8c 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java @@ -1,9 +1,8 @@ package com.seibel.distanthorizons.common; -import com.mojang.brigadier.CommandDispatcher; import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent; import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent; -import com.seibel.distanthorizons.common.commands.CommandInitializer; +//import com.seibel.distanthorizons.common.commands.CommandInitializer; import com.seibel.distanthorizons.common.wrappers.DependencySetup; import com.seibel.distanthorizons.common.wrappers.gui.DhDebugScreenEntry; import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftServerWrapper; @@ -22,7 +21,11 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModAccesso import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker; import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector; import com.seibel.distanthorizons.coreapi.ModInfo; +#if MC_VER <= MC_1_12_2 +#else +import com.mojang.brigadier.CommandDispatcher; import net.minecraft.commands.CommandSourceStack; +#endif import net.minecraft.server.MinecraftServer; import net.minecraft.server.dedicated.DedicatedServer; import com.seibel.distanthorizons.core.logging.DhLogger; @@ -38,7 +41,7 @@ public abstract class AbstractModInitializer { protected static final DhLogger LOGGER = new DhLoggerBuilder().build(); - private CommandInitializer commandInitializer; + //private CommandInitializer commandInitializer; @@ -52,7 +55,7 @@ public abstract class AbstractModInitializer protected abstract IEventProxy createServerProxy(boolean isDedicated); protected abstract void initializeModCompat(); - protected abstract void subscribeRegisterCommandsEvent(Consumer> eventHandler); + //protected abstract void subscribeRegisterCommandsEvent(Consumer> eventHandler); protected abstract void subscribeClientStartedEvent(Runnable eventHandler); protected abstract void subscribeServerStartingEvent(Consumer eventHandler); @@ -115,8 +118,8 @@ public abstract class AbstractModInitializer this.initializeModCompat(); LOGGER.info(ModInfo.READABLE_NAME + " server Initialized, adding event subscribers..."); - this.commandInitializer = new CommandInitializer(); - this.subscribeRegisterCommandsEvent(dispatcher -> { this.commandInitializer.initCommands(dispatcher); }); + //this.commandInitializer = new CommandInitializer(); + //this.subscribeRegisterCommandsEvent(dispatcher -> { this.commandInitializer.initCommands(dispatcher); }); this.subscribeServerStartingEvent(server -> { @@ -124,11 +127,11 @@ public abstract class AbstractModInitializer this.initConfig(); this.postInit(); - this.commandInitializer.onServerReady(); + //this.commandInitializer.onServerReady(); this.checkForUpdates(); - LOGGER.info(ModInfo.READABLE_NAME + " server Initialized at " + server.getServerDirectory()); + LOGGER.info(ModInfo.READABLE_NAME + " server Initialized at " + server.#if MC_VER <= MC_1_12_2 getDataDirectory() #else getServerDirectory() #endif); }); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/AbstractPluginPacketSender.java b/common/src/main/java/com/seibel/distanthorizons/common/AbstractPluginPacketSender.java index dd2b400dc..cca81dfbf 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/AbstractPluginPacketSender.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/AbstractPluginPacketSender.java @@ -12,10 +12,17 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSende import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper; import com.seibel.distanthorizons.coreapi.ModInfo; import io.netty.buffer.ByteBufUtil; +#if MC_VER <= MC_1_12_2 +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.PacketBuffer; +#else import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerPlayer; +#endif -#if MC_VER <= MC_1_21_10 +#if MC_VER <= MC_1_12_2 +import net.minecraft.util.ResourceLocation; +#elif MC_VER <= MC_1_21_10 import net.minecraft.resources.ResourceLocation; #else import net.minecraft.resources.Identifier; @@ -31,7 +38,7 @@ public abstract class AbstractPluginPacketSender implements IPluginPacketSender .build(); #if MC_VER <= MC_1_20_6 - public static final ResourceLocation WRAPPER_PACKET_RESOURCE = new ResourceLocation(ModInfo.RESOURCE_NAMESPACE, ModInfo.WRAPPER_PACKET_PATH); + public static final String WRAPPER_PACKET_RESOURCE = ModInfo.RESOURCE_NAMESPACE + ModInfo.WRAPPER_PACKET_PATH; #elif MC_VER <= MC_1_21_10 public static final ResourceLocation WRAPPER_PACKET_RESOURCE = ResourceLocation.fromNamespaceAndPath(ModInfo.RESOURCE_NAMESPACE, ModInfo.WRAPPER_PACKET_PATH); #else @@ -52,14 +59,14 @@ public abstract class AbstractPluginPacketSender implements IPluginPacketSender @Override public final void sendToClient(IServerPlayerWrapper serverPlayer, AbstractNetworkMessage message) { - this.sendToClient((ServerPlayer) serverPlayer.getWrappedMcObject(), message); + this.sendToClient(#if MC_VER <= MC_1_12_2 (EntityPlayerMP) #else (ServerPlayer) #endif serverPlayer.getWrappedMcObject(), message); } - public abstract void sendToClient(ServerPlayer serverPlayer, AbstractNetworkMessage message); + public abstract void sendToClient(#if MC_VER <= MC_1_12_2 EntityPlayerMP #else ServerPlayer #endif serverPlayer, AbstractNetworkMessage message); @Override public abstract void sendToServer(AbstractNetworkMessage message); - public AbstractNetworkMessage decodeMessage(FriendlyByteBuf in) + public AbstractNetworkMessage decodeMessage(#if MC_VER <= MC_1_12_2 PacketBuffer #else FriendlyByteBuf #endif in) { AbstractNetworkMessage message = null; @@ -100,7 +107,7 @@ public abstract class AbstractPluginPacketSender implements IPluginPacketSender } } - public void encodeMessage(FriendlyByteBuf out, AbstractNetworkMessage message) + public void encodeMessage(#if MC_VER <= MC_1_12_2 PacketBuffer #else FriendlyByteBuf #endif out, AbstractNetworkMessage message) { // This is intentionally unhandled, because errors related to this are unlikely to appear in wild Objects.requireNonNull(message); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/AbstractCommand.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/AbstractCommand.java index 01e177ef2..43da2ede3 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/AbstractCommand.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/AbstractCommand.java @@ -1,5 +1,6 @@ package com.seibel.distanthorizons.common.commands; +#if MC_VER > MC_1_12_2 import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.context.CommandContext; import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper; @@ -100,3 +101,4 @@ public abstract class AbstractCommand } } +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/CommandInitializer.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/CommandInitializer.java index dc29975a9..d4215df85 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/CommandInitializer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/CommandInitializer.java @@ -1,5 +1,6 @@ package com.seibel.distanthorizons.common.commands; +#if MC_VER > MC_1_12_2 import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.commands.CommandSourceStack; @@ -82,3 +83,4 @@ public class CommandInitializer } } +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/ConfigCommand.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/ConfigCommand.java index 33af0e792..1be2a2542 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/ConfigCommand.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/ConfigCommand.java @@ -1,5 +1,6 @@ package com.seibel.distanthorizons.common.commands; +#if MC_VER > MC_1_12_2 import com.mojang.brigadier.arguments.*; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.context.CommandContext; @@ -151,4 +152,5 @@ public class ConfigCommand extends AbstractCommand } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/CrashCommand.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/CrashCommand.java index 7c6f09d71..d967234b0 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/CrashCommand.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/CrashCommand.java @@ -1,5 +1,6 @@ package com.seibel.distanthorizons.common.commands; +#if MC_VER > MC_1_12_2 import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.seibel.distanthorizons.core.api.internal.SharedApi; import com.seibel.distanthorizons.core.multiplayer.server.ServerPlayerState; @@ -42,3 +43,4 @@ public class CrashCommand extends AbstractCommand } } +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/DebugCommand.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/DebugCommand.java index 88b1c8311..3c92ef3ba 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/DebugCommand.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/DebugCommand.java @@ -1,5 +1,6 @@ package com.seibel.distanthorizons.common.commands; +#if MC_VER > MC_1_12_2 import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.seibel.distanthorizons.core.logging.f3.F3Screen; import net.minecraft.commands.CommandSourceStack; @@ -23,3 +24,4 @@ public class DebugCommand extends AbstractCommand } } +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/PregenCommand.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/PregenCommand.java index 32a698306..a4e259b72 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/PregenCommand.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/PregenCommand.java @@ -1,5 +1,6 @@ package com.seibel.distanthorizons.common.commands; +#if MC_VER > MC_1_12_2 import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -105,3 +106,4 @@ public class PregenCommand extends AbstractCommand } } +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/DhUpdateScreenBase.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/DhUpdateScreenBase.java index e40507521..98293d7c3 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/DhUpdateScreenBase.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/DhUpdateScreenBase.java @@ -1,5 +1,6 @@ package com.seibel.distanthorizons.common.commonMixins; +#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch; import com.seibel.distanthorizons.common.wrappers.gui.updater.UpdateModScreen; import com.seibel.distanthorizons.core.config.Config; @@ -11,16 +12,18 @@ import com.seibel.distanthorizons.core.logging.DhLogger; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.TitleScreen; +#if MC_VER <= MC_1_12_2 +#else +import net.minecraft.client.gui.screens.TitleScreen; +#endif import java.util.ArrayList; public class DhUpdateScreenBase { private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - private static final Minecraft MC = Minecraft.getInstance(); - + private static final Minecraft MC = Minecraft #if MC_VER <= MC_1_12_2 .getMinecraft() #else .getInstance() #endif; public static void tryShowUpdateScreenAndRunAutoUpdateStartup(Runnable runnable) @@ -86,3 +89,4 @@ public class DhUpdateScreenBase } } +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java index 2f09ccbbe..9ed97342d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java @@ -5,14 +5,20 @@ import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; import com.seibel.distanthorizons.core.api.internal.ServerApi; import com.seibel.distanthorizons.core.api.internal.SharedApi; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper; +#if MC_VER <= MC_1_12_2 +import net.minecraft.world.WorldServer; +import net.minecraft.world.chunk.Chunk; +#else import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.chunk.ChunkAccess; +#endif + import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; public class MixinChunkMapCommon { - public static void onChunkSave(ServerLevel level, ChunkAccess chunk, CallbackInfoReturnable ci) + public static void onChunkSave(#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif level, #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk #if MC_VER > MC_1_12_2, CallbackInfoReturnable ci #endif) { IServerLevelWrapper levelWrapper = ServerLevelWrapper.getWrapper(level); @@ -25,7 +31,7 @@ public class MixinChunkMapCommon // is this chunk being saved to disk? - boolean savingChunkToDisk = ci.getReturnValue(); + boolean savingChunkToDisk = #if MC_VER <= MC_1_12_2 true #else ci.getReturnValue() #endif; // true means a chunk was saved to disk if (!savingChunkToDisk) { @@ -38,7 +44,12 @@ public class MixinChunkMapCommon // MC has a tendency to try saving incomplete or corrupted chunks (which show up as empty or black chunks) // this logic should prevent that from happening - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + #if MC_VER <= MC_1_12_2 + if (!chunk.isTerrainPopulated() || !chunk.isLightPopulated()) + { + return; + } + #elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 if (chunk.isUnsaved() || chunk.getUpgradeData() != null || !chunk.isLightCorrect()) { return; @@ -55,8 +66,8 @@ public class MixinChunkMapCommon // biome validation // // some chunks may be missing their biomes, which cause issues when attempting to save them - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 - if (chunk.getBiomes() == null) + #if MC_VER <= MC_1_17_1 + if (chunk.#if MC_VER <= MC_1_12_2 getBiomeArray() #else getBiomes() #endif == null) { return; } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/util/ProxyUtil.java b/common/src/main/java/com/seibel/distanthorizons/common/util/ProxyUtil.java index b603288b3..336ed4e8d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/util/ProxyUtil.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/util/ProxyUtil.java @@ -22,23 +22,28 @@ package com.seibel.distanthorizons.common.util; import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper; import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +#else import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.LevelAccessor; - +#endif public class ProxyUtil { - public static ILevelWrapper getLevelWrapper(LevelAccessor level) + public static ILevelWrapper getLevelWrapper(#if MC_VER <= MC_1_12_2 World #else LevelAccessor #endif level) { ILevelWrapper levelWrapper; - if (level instanceof ServerLevel) + if (level instanceof #if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif) { - levelWrapper = ServerLevelWrapper.getWrapper((ServerLevel) level); + levelWrapper = ServerLevelWrapper.getWrapper(#if MC_VER <= MC_1_12_2 (WorldServer) #else (ServerLevel) #endif level); } else { - levelWrapper = ClientLevelWrapper.getWrapper((ClientLevel) level); + levelWrapper = ClientLevelWrapper.getWrapper(#if MC_VER <= MC_1_12_2 (WorldClient) #else (ClientLevel) #endif level); } return levelWrapper; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java index 4eba1f648..83930afec 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java @@ -26,9 +26,15 @@ import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos; import com.seibel.distanthorizons.core.pos.DhChunkPos; import com.seibel.distanthorizons.core.util.math.Mat4f; +#if MC_VER <= MC_1_12_2 +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +#else import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.level.ChunkPos; +#endif /** * This class converts to and from Minecraft objects (Ex: Matrix4f) @@ -47,7 +53,8 @@ public class McObjectConverter /** 4x4 float matrix converter */ public static Mat4f Convert( - #if MC_VER < MC_1_19_4 com.mojang.math.Matrix4f + #if MC_VER <= MC_1_12_2 org.joml.Matrix4f + #elif MC_VER < MC_1_19_4 com.mojang.math.Matrix4f #elif MC_VER < MC_1_21_6 org.joml.Matrix4f #else org.joml.Matrix4fc #endif @@ -56,21 +63,24 @@ public class McObjectConverter FloatBuffer buffer = FloatBuffer.allocate(16); storeMatrix(mcMatrix, buffer); Mat4f matrix = new Mat4f(buffer); - #if MC_VER < MC_1_19_4 + #if MC_VER < MC_1_19_4 && MC_VER > MC_1_12_2 matrix.transpose(); // In 1.19.3 and later, we no longer need to transpose it #endif return matrix; } /** Taken from Minecraft's com.mojang.math.Matrix4f class from 1.18.2 */ private static void storeMatrix( - #if MC_VER < MC_1_19_4 com.mojang.math.Matrix4f + #if MC_VER <= MC_1_12_2 org.joml.Matrix4f + #elif MC_VER < MC_1_19_4 com.mojang.math.Matrix4f #elif MC_VER < MC_1_21_6 org.joml.Matrix4f #else org.joml.Matrix4fc #endif matrix, FloatBuffer buffer) { - #if MC_VER < MC_1_19_4 + #if MC_VER <= MC_1_12_2 + matrix.get(buffer); + #elif MC_VER < MC_1_19_4 matrix.store(buffer); #else // Mojang starts to use joml's Matrix4f libary in 1.19.3 so we copy their store method and use it here if its newer than 1.19.3 @@ -94,35 +104,35 @@ public class McObjectConverter } - static final Direction[] directions; + static final #if MC_VER <= MC_1_12_2 EnumFacing[] #else Direction[] #endif directions; static final EDhDirection[] lodDirections; static { EDhDirection[] lodDirs = EDhDirection.values(); - directions = new Direction[lodDirs.length]; + directions = new #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif[lodDirs.length]; lodDirections = new EDhDirection[lodDirs.length]; for (EDhDirection lodDir : lodDirs) { - Direction dir; + #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif dir; switch (lodDir.name().toUpperCase()) { case "DOWN": - dir = Direction.DOWN; + dir = #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.DOWN; break; case "UP": - dir = Direction.UP; + dir = #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.UP; break; case "NORTH": - dir = Direction.NORTH; + dir = #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.NORTH; break; case "SOUTH": - dir = Direction.SOUTH; + dir = #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.SOUTH; break; case "WEST": - dir = Direction.WEST; + dir = #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.WEST; break; case "EAST": - dir = Direction.EAST; + dir = #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.EAST; break; default: dir = null; @@ -141,7 +151,7 @@ public class McObjectConverter public static BlockPos Convert(DhBlockPos wrappedPos) { return new BlockPos(wrappedPos.getX(), wrappedPos.getY(), wrappedPos.getZ()); } public static ChunkPos Convert(DhChunkPos wrappedPos) { return new ChunkPos(wrappedPos.getX(), wrappedPos.getZ()); } - public static Direction Convert(EDhDirection lodDirection) { return directions[lodDirection.ordinal()]; } - public static EDhDirection Convert(Direction direction) { return lodDirections[direction.ordinal()]; } + public static #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif Convert(EDhDirection lodDirection) { return directions[lodDirection.ordinal()]; } + public static EDhDirection Convert(#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif direction) { return lodDirections[direction.ordinal()]; } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java index b217242ff..d91359bdb 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java @@ -29,7 +29,7 @@ import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper; import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; -import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment; +//import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment; import com.seibel.distanthorizons.core.level.IDhLevel; import com.seibel.distanthorizons.core.level.IDhServerLevel; import com.seibel.distanthorizons.core.util.LodUtil; @@ -40,16 +40,26 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.worldGeneration.IBatchGeneratorEnvironmentWrapper; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; -import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.chunk.Chunk; #if MC_VER > MC_1_17_1 import net.minecraft.core.Holder; #endif + +#if MC_VER <= MC_1_12_2 +#else +import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.ChunkAccess; +#endif import java.io.IOException; import java.util.HashSet; @@ -72,7 +82,8 @@ public class WrapperFactory implements IWrapperFactory { if (targetLevel instanceof IDhServerLevel) { - return new BatchGenerationEnvironment((IDhServerLevel) targetLevel); + //return new BatchGenerationEnvironment((IDhServerLevel) targetLevel); + return null; } else { @@ -162,25 +173,25 @@ public class WrapperFactory implements IWrapperFactory // correct number of parameters from the API // chunk - if (!(objectArray[0] instanceof ChunkAccess)) + if (!(objectArray[0] instanceof #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif)) { throw new ClassCastException(createChunkWrapperErrorMessage(objectArray)); } - ChunkAccess chunk = (ChunkAccess) objectArray[0]; + #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk = (#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif) objectArray[0]; // level / light source - if (!(objectArray[1] instanceof Level)) + if (!(objectArray[1] instanceof #if MC_VER <= MC_1_12_2 World #else Level #endif)) { throw new ClassCastException(createChunkWrapperErrorMessage(objectArray)); } // the level is needed for the DH level wrapper... - Level level = (Level) objectArray[1]; + #if MC_VER <= MC_1_12_2 World #else Level #endif level = (#if MC_VER <= MC_1_12_2 World #else Level #endif) objectArray[1]; // level wrapper - ILevelWrapper levelWrapper = level.isClientSide() - ? ClientLevelWrapper.getWrapper((ClientLevel)level) - : ServerLevelWrapper.getWrapper((ServerLevel)level); + ILevelWrapper levelWrapper = #if MC_VER <= MC_1_12_2 !level.isRemote #else level.isClientSide() #endif + ? ClientLevelWrapper.getWrapper((#if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif)level) + : ServerLevelWrapper.getWrapper((#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif)level); return new ChunkWrapper(chunk, levelWrapper); @@ -203,7 +214,7 @@ public class WrapperFactory implements IWrapperFactory //#if MC_VER <= MC_1_XX_X expectedClassNames = new String[] { - ChunkAccess.class.getName(), + #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif.class.getName(), "[ServerLevel] or [ClientLevel]" // Classes are not referenced by names to avoid exception when one of them is missing }; //#endif @@ -288,12 +299,12 @@ public class WrapperFactory implements IWrapperFactory { throw new ClassCastException(createBlockStateWrapperErrorMessage(objectArray)); } - if (!(objectArray[0] instanceof BlockState)) + if (!(objectArray[0] instanceof #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif)) { throw new ClassCastException(createBlockStateWrapperErrorMessage(objectArray)); } - BlockState blockState = (BlockState) objectArray[0]; + #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState = (#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif) objectArray[0]; return BlockStateWrapper.fromBlockState(blockState, coreLevelWrapper); //#endif } @@ -305,7 +316,7 @@ public class WrapperFactory implements IWrapperFactory { String[] expectedClassNames; - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + #if MC_VER <= MC_1_17_1 expectedClassNames = new String[] { Biome.class.getName() }; #else expectedClassNames = new String[] { Holder.class.getName()+"<"+Biome.class.getName()+">" }; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/AbstractDhTintGetter.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/AbstractDhTintGetter.java index 1d7ccb579..2bd83c088 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/AbstractDhTintGetter.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/AbstractDhTintGetter.java @@ -1,5 +1,5 @@ package com.seibel.distanthorizons.common.wrappers.block; - +#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.dataObjects.BlockBiomeWrapperPair; import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; @@ -12,11 +12,15 @@ import com.seibel.distanthorizons.core.util.FullDataPointUtil; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import it.unimi.dsi.fastutil.longs.LongArrayList; import net.minecraft.client.Minecraft; +#if MC_VER <= MC_1_12_2 +import net.minecraft.world.biome.Biome; +#else import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.ColorResolver; import net.minecraft.world.level.biome.Biome; +#endif import java.io.IOException; import java.util.concurrent.ConcurrentHashMap; @@ -335,3 +339,4 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter } +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java index 1253f9131..89d9cd968 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java @@ -28,7 +28,6 @@ import java.util.concurrent.ConcurrentMap; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; -import net.minecraft.world.level.Level; import com.seibel.distanthorizons.core.logging.DhLogger; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper; @@ -40,18 +39,28 @@ import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.data.BuiltinRegistries; -#else +#elif MC_VER > MC_1_12_2 import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; #endif -#if MC_VER <= MC_1_21_10 +#if MC_VER > MC_1_12_2 +import net.minecraft.world.level.Level; +#endif + +#if MC_VER <= MC_1_12_2 +import net.minecraft.util.ResourceLocation; +#elif MC_VER <= MC_1_21_10 import net.minecraft.resources.ResourceLocation; #else import net.minecraft.resources.Identifier; #endif +#if MC_VER <= MC_1_12_2 +import net.minecraft.world.biome.Biome; +#else import net.minecraft.world.level.biome.Biome; +#endif #if MC_VER >= MC_1_18_2 import net.minecraft.world.level.biome.Biomes; @@ -218,8 +227,10 @@ public class BiomeWrapper implements IBiomeWrapper // generate the serial string // + #if MC_VER > MC_1_12_2 Level level = (Level)levelWrapper.getWrappedMcObject(); net.minecraft.core.RegistryAccess registryAccess = level.registryAccess(); + #endif #if MC_VER < MC_1_21_11 ResourceLocation resourceLocation; @@ -227,7 +238,9 @@ public class BiomeWrapper implements IBiomeWrapper Identifier resourceLocation; #endif - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + #if MC_VER <= MC_1_12_2 + resourceLocation = this.biome.getRegistryName(); + #elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome); #elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2 resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome.value()); @@ -240,7 +253,7 @@ public class BiomeWrapper implements IBiomeWrapper if (resourceLocation == null) { String biomeName; - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 || MC_VER == MC_1_12_2 biomeName = this.biome.toString(); #else biomeName = this.biome.value().toString(); @@ -291,10 +304,12 @@ public class BiomeWrapper implements IBiomeWrapper { try { + #if MC_VER > MC_1_12_2 Level level = (Level) levelWrapper.getWrappedMcObject(); net.minecraft.core.RegistryAccess registryAccess = level.registryAccess(); + #endif - BiomeDeserializeResult deserializeResult = deserializeBiome(resourceLocationString, registryAccess); + BiomeDeserializeResult deserializeResult = deserializeBiome(resourceLocationString #if MC_VER > MC_1_12_2, registryAccess #endif); @@ -323,7 +338,7 @@ public class BiomeWrapper implements IBiomeWrapper } } - public static BiomeDeserializeResult deserializeBiome(String resourceLocationString, net.minecraft.core.RegistryAccess registryAccess) throws IOException + public static BiomeDeserializeResult deserializeBiome(String resourceLocationString #if MC_VER > MC_1_12_2, net.minecraft.core.RegistryAccess registryAccess #endif) throws IOException { // parse the resource location int separatorIndex = resourceLocationString.indexOf(":"); @@ -354,7 +369,10 @@ public class BiomeWrapper implements IBiomeWrapper boolean success; - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + #if MC_VER == MC_1_12_2 + Biome biome = Biome.REGISTRY.getObject(resourceLocation); + success = (biome != null); + #elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 Biome biome = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).get(resourceLocation); success = (biome != null); #elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2 diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index 8f08e87c8..3161ae83e 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -29,12 +29,23 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrappe import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; +#if MC_VER <= MC_1_12_2 +import net.minecraft.block.Block; +import net.minecraft.block.BlockLeaves; +import net.minecraft.block.SoundType; +import net.minecraft.init.Blocks; +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.state.IBlockState; +import net.minecraft.block.properties.IProperty; +#else import net.minecraft.tags.BlockTags; import net.minecraft.world.level.block.BeaconBeamBlock; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.Property; +#endif import com.seibel.distanthorizons.core.logging.DhLogger; import java.awt.*; @@ -44,6 +55,7 @@ import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; +import net.minecraftforge.fluids.IFluidBlock; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -58,7 +70,7 @@ import net.minecraft.world.level.Level; import net.minecraft.core.BlockPos; import net.minecraft.core.Registry; import net.minecraft.world.level.EmptyBlockGetter; -#else +#elif MC_VER > MC_1_12_2 import net.minecraft.tags.TagKey; import net.minecraft.world.level.Level; import net.minecraft.core.BlockPos; @@ -67,7 +79,9 @@ import net.minecraft.world.level.EmptyBlockGetter; import net.minecraft.core.Holder; #endif -#if MC_VER <= MC_1_21_10 +#if MC_VER <= MC_1_12_2 +import net.minecraft.util.ResourceLocation; +#elif MC_VER <= MC_1_21_10 import net.minecraft.resources.ResourceLocation; #else import net.minecraft.resources.Identifier; @@ -84,11 +98,10 @@ public class BlockStateWrapper implements IBlockStateWrapper // must be defined before AIR, otherwise a null pointer will be thrown private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - public static final ConcurrentHashMap WRAPPER_BY_BLOCK_STATE = new ConcurrentHashMap<>(); + public static final ConcurrentHashMap<#if MC_VER >= MC_1_12_2 IBlockState #else BlockState #endif, BlockStateWrapper> WRAPPER_BY_BLOCK_STATE = new ConcurrentHashMap<>(); public static final ConcurrentHashMap WRAPPER_BY_RESOURCE_LOCATION = new ConcurrentHashMap<>(); public static final String AIR_STRING = "AIR"; - public static final BlockStateWrapper AIR = new BlockStateWrapper(null, null); public static final String DIRT_RESOURCE_LOCATION_STRING = "minecraft:dirt"; public static final String WATER_RESOURCE_LOCATION_STRING = "minecraft:water"; @@ -102,6 +115,8 @@ public class BlockStateWrapper implements IBlockStateWrapper "netherite_block" ); + public static final BlockStateWrapper AIR = new BlockStateWrapper(null, null); + public static ObjectOpenHashSet rendererIgnoredBlocks = null; public static ObjectOpenHashSet rendererIgnoredCaveBlocks = null; @@ -117,7 +132,7 @@ public class BlockStateWrapper implements IBlockStateWrapper // properties // @Nullable - public final BlockState blockState; + public final #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState; /** technically final, but since it requires a method call to generate it can't be marked as such */ private String serialString; private final int hashCode; @@ -140,9 +155,9 @@ public class BlockStateWrapper implements IBlockStateWrapper //==============// //region - public static BlockStateWrapper fromBlockState(BlockState blockState, ILevelWrapper levelWrapper) + public static BlockStateWrapper fromBlockState(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, ILevelWrapper levelWrapper) { - if (blockState == null || blockState.isAir()) + if (blockState == null || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.AIR #else blockState.isAir() #endif) { return AIR; } @@ -160,14 +175,21 @@ public class BlockStateWrapper implements IBlockStateWrapper } } + #if MC_VER <= MC_1_12_2 + /** + * Can be faster than {@link BlockStateWrapper#fromBlockState(IBlockState, ILevelWrapper)} + * in cases where the same block state is expected to be referenced multiple times. + */ + #else /** * Can be faster than {@link BlockStateWrapper#fromBlockState(BlockState, ILevelWrapper)} * in cases where the same block state is expected to be referenced multiple times. */ - public static BlockStateWrapper fromBlockState(BlockState blockState, ILevelWrapper levelWrapper, IBlockStateWrapper guess) + #endif + public static BlockStateWrapper fromBlockState(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, ILevelWrapper levelWrapper, IBlockStateWrapper guess) { - BlockState guessBlockState = (guess == null || guess.isAir()) ? null : (BlockState) guess.getWrappedMcObject(); - BlockState inputBlockState = (blockState == null || blockState.isAir()) ? null : blockState; + #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif guessBlockState = (guess == null || guess.isAir()) ? null : (#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif) guess.getWrappedMcObject(); + #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif inputBlockState = (blockState == null || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.AIR #else blockState.isAir() #endif) ? null : blockState; if (guess instanceof BlockStateWrapper && guessBlockState == inputBlockState) @@ -180,7 +202,7 @@ public class BlockStateWrapper implements IBlockStateWrapper } } - private BlockStateWrapper(@Nullable BlockState blockState, ILevelWrapper levelWrapper) + private BlockStateWrapper(@Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, ILevelWrapper levelWrapper) { this.blockState = blockState; this.serialString = this.serialize(levelWrapper); @@ -225,12 +247,14 @@ public class BlockStateWrapper implements IBlockStateWrapper // beacon tint color Color beaconTintColor = null; + // 1.12.2 doesn't have block for beacon beam + #if MC_VER > MC_1_12_2 if (this.blockState != null // beacon blocks also show up here, but since they block the beacon beam we don't want their color && !this.isBeaconBlock) { Block block = this.blockState.getBlock(); - if (block instanceof BeaconBeamBlock) + if (block instanceof BeaconBeamBlock ) { int colorInt; #if MC_VER <= MC_1_19_4 @@ -242,6 +266,7 @@ public class BlockStateWrapper implements IBlockStateWrapper beaconTintColor = ColorUtil.toColorObjRGB(colorInt); } } + #endif this.beaconTintColor = beaconTintColor; @@ -287,7 +312,9 @@ public class BlockStateWrapper implements IBlockStateWrapper int mcColor = 0; if (this.blockState != null) { - #if MC_VER < MC_1_20_1 + #if MC_VER <= MC_1_12_2 + mcColor = this.blockState.getMaterial().getMaterialMapColor().colorValue; + #elif MC_VER < MC_1_20_1 mcColor = this.blockState.getMaterial().getColor().col; #else mcColor = this.blockState.getMapColor(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).col; @@ -402,8 +429,12 @@ public class BlockStateWrapper implements IBlockStateWrapper if (defaultBlockStateToIgnore != AIR) { // add all possible blockstates (to account for light blocks with different light values and such) + #if MC_VER <= MC_1_12_2 + List blockStatesToIgnore = defaultBlockStateToIgnore.blockState.getBlock().getBlockState().getValidStates(); + #else List blockStatesToIgnore = defaultBlockStateToIgnore.blockState.getBlock().getStateDefinition().getPossibleStates(); - for (BlockState blockState : blockStatesToIgnore) + #endif + for (#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState : blockStatesToIgnore) { BlockStateWrapper newBlockToIgnore = BlockStateWrapper.fromBlockState(blockState, levelWrapper); blockStateWrappers.add(newBlockToIgnore); @@ -484,7 +515,11 @@ public class BlockStateWrapper implements IBlockStateWrapper boolean canOcclude = false; if (this.blockState != null) { - canOcclude = this.blockState.canOcclude(); + #if MC_VER <= MC_1_12_2 + canOcclude = this.blockState.isOpaqueCube(); + #else + canOcclude = this.blockState.canOcclude(); + #endif } return canOcclude; @@ -495,7 +530,9 @@ public class BlockStateWrapper implements IBlockStateWrapper boolean propagatesSkyLightDown = true; if (this.blockState != null) { - #if MC_VER < MC_1_21_3 + #if MC_VER <= MC_1_12_2 + propagatesSkyLightDown = !this.blockState.isOpaqueCube() && !(this.blockState.getBlock() instanceof BlockLiquid); + #elif MC_VER < MC_1_21_3 propagatesSkyLightDown = this.blockState.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO); #else propagatesSkyLightDown = this.blockState.propagatesSkylightDown(); @@ -509,7 +546,7 @@ public class BlockStateWrapper implements IBlockStateWrapper @Override - public int getLightEmission() { return (this.blockState != null) ? this.blockState.getLightEmission() : 0; } + public int getLightEmission() { return (this.blockState != null) ? #if MC_VER <= MC_1_12_2 this.blockState.getLightValue() #else this.blockState.getLightEmission() #endif : 0; } @Override public String getSerialString() { return this.serialString; } @@ -541,7 +578,7 @@ public class BlockStateWrapper implements IBlockStateWrapper @Override public boolean isAir() { return this.isAir(this.blockState); } - public boolean isAir(BlockState blockState) { return blockState == null || blockState.isAir(); } + public boolean isAir(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState) { return blockState == null || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.AIR #else blockState.isAir() #endif; } private Boolean blockIsSolid = null; @Override @@ -578,7 +615,9 @@ public class BlockStateWrapper implements IBlockStateWrapper return false; } - #if MC_VER < MC_1_20_1 + #if MC_VER <= MC_1_12_2 + return this.blockState.getMaterial().isLiquid() || this.blockState.getBlock() instanceof IFluidBlock; + #elif MC_VER < MC_1_20_1 return this.blockState.getMaterial().isLiquid() || !this.blockState.getFluidState().isEmpty(); #else return !this.blockState.getFluidState().isEmpty(); @@ -635,7 +674,9 @@ public class BlockStateWrapper implements IBlockStateWrapper Identifier resourceLocation; #endif - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + #if MC_VER <= MC_1_12_2 + resourceLocation = this.blockState.getBlock().getRegistryName(); + #elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 resourceLocation = Registry.BLOCK.getKey(this.blockState.getBlock()); #elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2 resourceLocation = registryAccess.registryOrThrow(Registry.BLOCK_REGISTRY).getKey(this.blockState.getBlock()); @@ -734,7 +775,9 @@ public class BlockStateWrapper implements IBlockStateWrapper #endif Block block; - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + #if MC_VER <= MC_1_12_2 + block = Block.REGISTRY.getObject(resourceLocation); + #elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 block = Registry.BLOCK.get(resourceLocation); #elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2 net.minecraft.core.RegistryAccess registryAccess = level.registryAccess(); @@ -763,11 +806,15 @@ public class BlockStateWrapper implements IBlockStateWrapper // attempt to find the blockstate from all possibilities - BlockState foundState = null; + #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif foundState = null; if (blockStatePropertiesString != null) { + #if MC_VER <= MC_1_12_2 + List possibleStateList = block.getBlockState().getValidStates(); + #else List possibleStateList = block.getStateDefinition().getPossibleStates(); - for (BlockState possibleState : possibleStateList) + #endif + for (#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif possibleState : possibleStateList) { String possibleStatePropertiesString = serializeBlockStateProperties(possibleState); if (possibleStatePropertiesString.equals(blockStatePropertiesString)) @@ -791,7 +838,7 @@ public class BlockStateWrapper implements IBlockStateWrapper } } - foundState = block.defaultBlockState(); + foundState = #if MC_VER <= MC_1_12_2 block.getDefaultState() #else block.defaultBlockState() #endif; } foundWrapper = new BlockStateWrapper(foundState, levelWrapper); @@ -811,26 +858,36 @@ public class BlockStateWrapper implements IBlockStateWrapper } /** used to compare and save BlockStates based on their properties */ - private static String serializeBlockStateProperties(BlockState blockState) + private static String serializeBlockStateProperties(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState) { // get the property list for this block (doesn't contain this block state's values, just the names and possible values) - java.util.Collection> blockPropertyCollection = blockState.getProperties(); + #if MC_VER <= MC_1_12_2 + java.util.Collection> blockPropertyCollection = blockState.getPropertyKeys(); + #else + java.util.Collection> blockPropertyCollection = blockState.getProperties();; + #endif // alphabetically sort the list so they are always in the same order - List> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection); + + List<#if MC_VER <= MC_1_12_2 IProperty #else Property #endif> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection); + sortedBlockPropteryList.sort((a, b) -> a.getName().compareTo(b.getName())); - StringBuilder stringBuilder = new StringBuilder(); - for (net.minecraft.world.level.block.state.properties.Property property : sortedBlockPropteryList) + for (#if MC_VER <= MC_1_12_2 IProperty #else Property #endif property : sortedBlockPropteryList) { String propertyName = property.getName(); String value = "NULL"; + + #if MC_VER <= MC_1_12_2 + value = blockState.getValue(property).toString(); + #else if (blockState.hasProperty(property)) { value = blockState.getValue(property).toString(); } + #endif stringBuilder.append("{"); stringBuilder.append(propertyName).append(RESOURCE_LOCATION_SEPARATOR).append(value); @@ -858,8 +915,7 @@ public class BlockStateWrapper implements IBlockStateWrapper String serialString = this.getSerialString().toLowerCase(); - - if (this.blockState.is(BlockTags.LEAVES) + if (#if MC_VER <= MC_1_12_2 this.blockState.getBlock() instanceof BlockLeaves #else this.blockState.is(BlockTags.LEAVES) #endif || serialString.contains("bamboo") || serialString.contains("cactus") || serialString.contains("chorus_flower") @@ -868,15 +924,15 @@ public class BlockStateWrapper implements IBlockStateWrapper { return EDhApiBlockMaterial.LEAVES; } - else if (this.blockState.is(Blocks.LAVA)) + else if (#if MC_VER <= MC_1_12_2 this.blockState.getBlock() == Blocks.LAVA || this.blockState.getBlock() == Blocks.FLOWING_LAVA #else this.blockState.is(Blocks.LAVA) #endif) { return EDhApiBlockMaterial.LAVA; } - else if (this.isLiquid() || this.blockState.is(Blocks.WATER)) + else if (this.isLiquid() || #if MC_VER <= MC_1_12_2 this.blockState.getBlock() == Blocks.WATER || this.blockState.getBlock() == Blocks.FLOWING_WATER #else this.blockState.is(Blocks.WATER) #endif) { return EDhApiBlockMaterial.WATER; } - else if (this.blockState.getSoundType() == SoundType.WOOD + else if (#if MC_VER <= MC_1_12_2 this.blockState.getBlock().getSoundType() #else this.blockState.getSoundType() #endif == SoundType.WOOD || serialString.contains("root") #if MC_VER >= MC_1_19_4 || this.blockState.getSoundType() == SoundType.CHERRY_WOOD @@ -885,7 +941,7 @@ public class BlockStateWrapper implements IBlockStateWrapper { return EDhApiBlockMaterial.WOOD; } - else if (this.blockState.getSoundType() == SoundType.METAL + else if (#if MC_VER <= MC_1_12_2 this.blockState.getBlock().getSoundType() #else this.blockState.getSoundType() #endif == SoundType.METAL #if MC_VER >= MC_1_19_2 || this.blockState.getSoundType() == SoundType.COPPER #endif @@ -936,7 +992,7 @@ public class BlockStateWrapper implements IBlockStateWrapper { return EDhApiBlockMaterial.TERRACOTTA; } - else if (this.blockState.is(BlockTags.BASE_STONE_NETHER)) + else if (#if MC_VER <= MC_1_12_2 this.blockState.getBlock() == Blocks.NETHERRACK #else this.blockState.is(BlockTags.BASE_STONE_NETHER) #endif) { return EDhApiBlockMaterial.NETHER_STONE; } @@ -945,7 +1001,7 @@ public class BlockStateWrapper implements IBlockStateWrapper { return EDhApiBlockMaterial.STONE; } - else if (this.blockState.getLightEmission() > 0) + else if (#if MC_VER <= MC_1_12_2 this.blockState.getLightValue() #else this.blockState.getLightEmission() #endif > 0) { return EDhApiBlockMaterial.ILLUMINATED; } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java index 6f0108895..a2f188271 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java @@ -26,24 +26,33 @@ import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos; import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPosMutable; import com.seibel.distanthorizons.core.util.ColorUtil; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; + import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +#if MC_VER <= MC_1_12_2 +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.util.EnumFacing; +import net.minecraft.block.BlockRotatedPillar; +import net.minecraft.block.*; +#else import net.minecraft.core.Direction; import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.SlabType; +#endif #if MC_VER >= MC_1_19_2 import net.minecraft.util.RandomSource; #else -import java.util.Random; +import java.util.*; #endif -import net.minecraft.world.level.block.state.BlockState; import com.seibel.distanthorizons.core.logging.DhLogger; -import net.minecraft.world.level.block.state.properties.SlabType; +import net.minecraft.util.math.BlockPos; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; import java.util.concurrent.locks.ReentrantLock; #if MC_VER < MC_1_21_5 @@ -51,6 +60,15 @@ import java.util.concurrent.locks.ReentrantLock; import net.minecraft.client.renderer.block.model.BlockModelPart; #endif +#if MC_VER <= MC_1_12_2 +/** + * This stores and calculates the colors + * the given {@link IBlockState} should have based + * on the given {@link IClientLevelWrapper}. + * + * @see ColorUtil + */ +#else /** * This stores and calculates the colors * the given {@link BlockState} should have based @@ -58,14 +76,15 @@ import net.minecraft.client.renderer.block.model.BlockModelPart; * * @see ColorUtil */ +#endif public class ClientBlockStateColorCache { private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - private static final Minecraft MC = Minecraft.getInstance(); + private static final Minecraft MC = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif; - private static final HashSet BLOCK_STATES_THAT_NEED_LEVEL = new HashSet<>(); - private static final HashSet BROKEN_BLOCK_STATES = new HashSet<>(); + private static final HashSet<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif> BLOCK_STATES_THAT_NEED_LEVEL = new HashSet<>(); + private static final HashSet<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif> BROKEN_BLOCK_STATES = new HashSet<>(); /** * Methods using MC's "RandomSource" object aren't thread safe
@@ -79,15 +98,15 @@ public class ClientBlockStateColorCache /** This is the order each direction on a block is processed when attempting to get the texture/color */ - private static final @Nullable Direction[] COLOR_RESOLUTION_DIRECTION_ORDER = - { - Direction.UP, + private static final @Nullable #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif[] COLOR_RESOLUTION_DIRECTION_ORDER = + { + #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.UP, null, // null represents "unculled" faces, IE the top of farmland - Direction.NORTH, - Direction.EAST, - Direction.WEST, - Direction.SOUTH, - Direction.DOWN + #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.NORTH, + #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.EAST, + #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.WEST, + #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.SOUTH, + #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.DOWN }; private static final int FLOWER_COLOR_SCALE = 5; @@ -102,7 +121,7 @@ public class ClientBlockStateColorCache #endif private final IClientLevelWrapper clientLevelWrapper; - private final BlockState blockState; + private final #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState; private final BlockStateWrapper blockStateWrapper; private boolean isColorResolved = false; @@ -174,8 +193,10 @@ public class ClientBlockStateColorCache 0.93011117f, 0.9386859f, 0.9473069f, 0.9559735f, 0.9646866f, 0.9734455f, 0.98225087f, 0.9911022f, 1.0f }; + #if MC_VER > MC_1_12_2 private static final ThreadLocal TintWithoutLevelOverrideGetter = ThreadLocal.withInitial(() -> new TintWithoutLevelOverrider()); private static final ThreadLocal TintOverrideGetter = ThreadLocal.withInitial(() -> new TintGetterOverride()); + #endif @@ -183,7 +204,7 @@ public class ClientBlockStateColorCache // constructor // //=============// - public ClientBlockStateColorCache(BlockState blockState, IClientLevelWrapper clientLevelWrapper) + public ClientBlockStateColorCache(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, IClientLevelWrapper clientLevelWrapper) { this.blockState = blockState; this.blockStateWrapper = BlockStateWrapper.fromBlockState(blockState, clientLevelWrapper); @@ -210,17 +231,17 @@ public class ClientBlockStateColorCache // getQuads() isn't thread safe so we need to put this logic in a lock RESOLVE_LOCK.lock(); - if (this.blockState.getFluidState().isEmpty()) + if (#if MC_VER <= MC_1_12_2 !this.blockState.getMaterial().isLiquid() #else this.blockState.getFluidState().isEmpty() #endif) { // look for the first non-empty direction List quads = null; - for (Direction direction : COLOR_RESOLUTION_DIRECTION_ORDER) + for (#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif direction : COLOR_RESOLUTION_DIRECTION_ORDER) { quads = this.getQuadsForDirection(direction); if (quads != null && !quads.isEmpty() && !( - this.blockState.getBlock() instanceof RotatedPillarBlock - && direction == Direction.UP + this.blockState.getBlock() instanceof #if MC_VER <= MC_1_12_2 BlockRotatedPillar #else RotatedPillarBlock #endif + && direction == #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.UP ) ) { @@ -239,7 +260,7 @@ public class ClientBlockStateColorCache { BakedQuad firstQuad = quads.get(0); - this.needPostTinting = firstQuad.isTinted(); + this.needPostTinting = firstQuad.#if MC_VER <= MC_1_12_2 hasTintIndex() #else isTinted() #endif; #if MC_VER <= MC_1_21_4 this.tintIndex = firstQuad.getTintIndex(); #else @@ -248,7 +269,7 @@ public class ClientBlockStateColorCache #if MC_VER < MC_1_17_1 this.baseColor = calculateColorFromTexture( - firstQuad.sprite, + firstQuad.#if MC_VER <= MC_1_12_2 getSprite() #else sprite #endif, EColorMode.getColorMode(this.blockState.getBlock())); #elif MC_VER < MC_1_21_5 this.baseColor = calculateColorFromTexture( @@ -288,20 +309,31 @@ public class ClientBlockStateColorCache @Nullable private List getUnculledQuads() { return this.getQuadsForDirection(null); } @Nullable - private List getQuadsForDirection(@Nullable Direction direction) + private List getQuadsForDirection(@Nullable #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif direction) { - BlockState effectiveBlockState = this.blockState; + #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif effectiveBlockState = this.blockState; // if this block is a slab, use it's double variant so we can get the top face, // otherwise the color will use the side, which isn't as accurate + // 1.12.2 doesn't have SlabType as property + #if MC_VER > MC_1_12_2 if (this.blockState.getBlock() instanceof SlabBlock) { - effectiveBlockState = this.blockState.setValue( SlabBlock.TYPE, SlabType.DOUBLE ); + effectiveBlockState = this.blockState.setValue(SlabBlock.TYPE, SlabType.DOUBLE); } + #endif List quads; - #if MC_VER < MC_1_21_5 + #if MC_VER <= MC_1_12_2 + try { + quads = MC.getBlockRendererDispatcher().getModelForState(effectiveBlockState).getQuads(effectiveBlockState, direction, RANDOM.nextLong()); + } + catch (Exception e) + { + quads = Collections.emptyList(); + } + #elif MC_VER < MC_1_21_5 quads = MC.getModelManager().getBlockModelShaper(). getBlockModel(effectiveBlockState).getQuads(effectiveBlockState, direction, RANDOM); #else @@ -347,10 +379,18 @@ public class ClientBlockStateColorCache //_ OpenGL RGBA format Java Order: 0xAA BB GG RR tempColor = TextureAtlasSpriteWrapper.getPixelRGBA(texture, 0, u, v); + #if MC_VER <= MC_1_12_2 + int b = (tempColor & 0x000000FF); + int g = (tempColor & 0x0000FF00) >>> 8; + int r = (tempColor & 0x00FF0000) >>> 16; + int a = (tempColor & 0xFF000000) >>> 24; + #else int r = (tempColor & 0x000000FF); int g = (tempColor & 0x0000FF00) >>> 8; int b = (tempColor & 0x00FF0000) >>> 16; int a = (tempColor & 0xFF000000) >>> 24; + #endif + int scale = 1; if (colorMode == EColorMode.Leaves) { @@ -415,7 +455,9 @@ public class ClientBlockStateColorCache } private static int getTextureWidth(TextureAtlasSprite texture) { - #if MC_VER < MC_1_19_4 + #if MC_VER <= MC_1_12_2 + return texture.getIconWidth(); + #elif MC_VER < MC_1_19_4 return texture.getWidth(); #else return texture.contents().width(); @@ -423,7 +465,9 @@ public class ClientBlockStateColorCache } private static int getTextureHeight(TextureAtlasSprite texture) { - #if MC_VER < MC_1_19_4 + #if MC_VER <= MC_1_12_2 + return texture.getIconHeight(); + #elif MC_VER < MC_1_19_4 return texture.getHeight(); #else return texture.contents().height(); @@ -457,8 +501,12 @@ public class ClientBlockStateColorCache private int getParticleIconColor() { return calculateColorFromTexture( - Minecraft.getInstance().getModelManager().getBlockModelShaper().getParticleIcon(this.blockState), - EColorMode.getColorMode(this.blockState.getBlock())); + #if MC_VER <= MC_1_12_2 + Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(this.blockState), + #else + Minecraft.getInstance().getModelManager().getBlockModelShaper().getParticleIcon(this.blockState), + #endif + EColorMode.getColorMode(this.blockState.getBlock())); } @@ -486,6 +534,37 @@ public class ClientBlockStateColorCache int tintColor = -1; try { + // 1.12.2 doesn't have BlockAndTintGetter -> get tintColor from biome + #if MC_VER <= MC_1_12_2 + WorldClient world = (WorldClient) this.clientLevelWrapper.getWrappedMcObject(); + BlockPos mcPos = new BlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + Block block = this.blockState.getBlock(); + if (block instanceof BlockGrass || block instanceof BlockBush) + { + tintColor = biomeWrapper.biome.getGrassColorAtPos(mcPos); + } + else if (block instanceof BlockLeaves) + { + tintColor = biomeWrapper.biome.getFoliageColorAtPos(mcPos); + } + else if (block instanceof BlockLiquid) // We don't want lava to fall into the else block + { + if(block == Blocks.WATER || block == Blocks.FLOWING_WATER) + { + tintColor = biomeWrapper.biome.getWaterColor(); + } + } + else + { + BlockColors blockColors = Minecraft.getMinecraft().getBlockColors(); + tintColor = blockColors.colorMultiplier(blockState, world, mcPos, this.tintIndex); + + if (tintColor == -1) + { + tintColor = blockColors.getColor(blockState, world, mcPos); + } + } + #else // try to use the fast tint getter logic first if (!BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState)) { @@ -536,6 +615,7 @@ public class ClientBlockStateColorCache this.tintIndex); } } + #endif } catch (Exception e) { @@ -576,15 +656,15 @@ public class ClientBlockStateColorCache static EColorMode getColorMode(Block block) { - if (block instanceof LeavesBlock) + if (block instanceof #if MC_VER <= MC_1_12_2 BlockLeaves #else LeavesBlock #endif) { return Leaves; } - if (block instanceof FlowerBlock) + if (block instanceof #if MC_VER <= MC_1_12_2 BlockFlower #else FlowerBlock #endif) { return Flower; } - if (block.toString().contains("glass")) + if (block.toString().toLowerCase().contains("glass")) { return Glass; } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TextureAtlasSpriteWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TextureAtlasSpriteWrapper.java index 6d89fb043..26d73cfc4 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TextureAtlasSpriteWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TextureAtlasSpriteWrapper.java @@ -37,7 +37,10 @@ public class TextureAtlasSpriteWrapper { public static int getPixelRGBA(TextureAtlasSprite sprite, int frameIndex, int x, int y) { - #if MC_VER < MC_1_17_1 + #if MC_VER <= MC_1_12_2 + int[][] frameData = sprite.getFrameTextureData(frameIndex); + return frameData[0][y * sprite.getIconWidth() + x]; + #elif MC_VER < MC_1_17_1 return sprite.mainImage[0].getPixelRGBA( x + sprite.framesX[frameIndex] * sprite.getWidth(), y + sprite.framesY[frameIndex] * sprite.getHeight()); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintGetterOverride.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintGetterOverride.java index f55d1a59e..dc2a16ace 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintGetterOverride.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintGetterOverride.java @@ -18,7 +18,7 @@ */ package com.seibel.distanthorizons.common.wrappers.block; - +#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import net.minecraft.core.BlockPos; @@ -180,3 +180,4 @@ public class TintGetterOverride extends AbstractDhTintGetter } +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintWithoutLevelOverrider.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintWithoutLevelOverrider.java index a613bed4f..e39475d35 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintWithoutLevelOverrider.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintWithoutLevelOverrider.java @@ -18,7 +18,7 @@ */ package com.seibel.distanthorizons.common.wrappers.block; - +#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import net.minecraft.core.BlockPos; @@ -88,3 +88,4 @@ public class TintWithoutLevelOverrider extends AbstractDhTintGetter #endif } +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java index 9a6e13199..47bc58009 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java @@ -33,10 +33,18 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IMutableBlockPosWr import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; +#if MC_VER <= MC_1_12_2 +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.storage.ExtendedBlockStorage; +#else import net.minecraft.core.BlockPos; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ProtoChunk; import net.minecraft.world.level.levelgen.Heightmap; +#endif import com.seibel.distanthorizons.core.logging.DhLogger; @@ -67,9 +75,9 @@ import net.minecraft.world.level.chunk.LevelChunkSection; import net.minecraft.world.level.chunk.LevelChunkSection; #endif -#if MC_VER <= MC_1_20_4 +#if MC_VER <= MC_1_20_4 && MC_VER > MC_1_12_2 import net.minecraft.world.level.chunk.ChunkStatus; -#else +#elif MC_VER > MC_1_12_2 import net.minecraft.world.level.chunk.status.ChunkStatus; #endif @@ -87,7 +95,7 @@ public class ChunkWrapper implements IChunkWrapper private static boolean heightmapThreadWarningLogged = false; - private final ChunkAccess chunk; + private final #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk; private final DhChunkPos chunkPos; private final ILevelWrapper wrappedLevel; @@ -118,7 +126,7 @@ public class ChunkWrapper implements IChunkWrapper * fast since it will be called frequently on the MC * server thread and a slow method will cause server lag. */ - public ChunkWrapper(ChunkAccess chunk, ILevelWrapper wrappedLevel) + public ChunkWrapper(#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk, ILevelWrapper wrappedLevel) { this.chunk = chunk; this.wrappedLevel = wrappedLevel; @@ -136,7 +144,7 @@ public class ChunkWrapper implements IChunkWrapper @Override public int getHeight() { return getHeight(this.chunk); } - public static int getHeight(ChunkAccess chunk) + public static int getHeight(#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk) { #if MC_VER < MC_1_17_1 return 255; @@ -147,7 +155,7 @@ public class ChunkWrapper implements IChunkWrapper @Override public int getInclusiveMinBuildHeight() { return getInclusiveMinBuildHeight(this.chunk); } - public static int getInclusiveMinBuildHeight(ChunkAccess chunk) + public static int getInclusiveMinBuildHeight(#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk) { #if MC_VER < MC_1_17_1 return 0; @@ -160,9 +168,11 @@ public class ChunkWrapper implements IChunkWrapper @Override public int getExclusiveMaxBuildHeight() { return getExclusiveMaxBuildHeight(this.chunk); } - public static int getExclusiveMaxBuildHeight(ChunkAccess chunk) + public static int getExclusiveMaxBuildHeight(#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk) { - #if MC_VER < MC_1_21_3 + #if MC_VER <= MC_1_12_2 + return 256; + #elif MC_VER < MC_1_21_3 return chunk.getMaxBuildHeight(); #else // +1 since Minecraft made the max value inclusive @@ -183,7 +193,11 @@ public class ChunkWrapper implements IChunkWrapper this.minNonEmptyHeight = this.getInclusiveMinBuildHeight(); // determine the lowest empty section (bottom up) + #if MC_VER <= MC_1_12_2 + ExtendedBlockStorage[] sections = this.chunk.getBlockStorageArray(); + #else LevelChunkSection[] sections = this.chunk.getSections(); + #endif for (int index = 0; index < sections.length; index++) { if (sections[index] == null) @@ -215,7 +229,11 @@ public class ChunkWrapper implements IChunkWrapper this.maxNonEmptyHeight = this.getExclusiveMaxBuildHeight(); // determine the highest empty section (top down) + #if MC_VER <= MC_1_12_2 + ExtendedBlockStorage[] sections = this.chunk.getBlockStorageArray(); + #else LevelChunkSection[] sections = this.chunk.getSections(); + #endif for (int index = sections.length-1; index >= 0; index--) { // update at each position to fix using the max height if the chunk is empty @@ -235,11 +253,9 @@ public class ChunkWrapper implements IChunkWrapper return this.maxNonEmptyHeight; } - private static boolean isChunkSectionEmpty(LevelChunkSection section) + private static boolean isChunkSectionEmpty(#if MC_VER <= MC_1_12_2 ExtendedBlockStorage #else LevelChunkSection #endif section) { - #if MC_VER == MC_1_16_5 - return section.isEmpty(); - #elif MC_VER == MC_1_17_1 + #if MC_VER <= MC_1_17_1 return section.isEmpty(); #else return section.hasOnlyAir(); @@ -317,7 +333,11 @@ public class ChunkWrapper implements IChunkWrapper // will be null if we want to use MC heightmaps if (this.solidHeightMap == null) { + #if MC_VER <= MC_1_12_2 + return this.chunk.getHeightValue(xRel, zRel); + #else return this.chunk.getOrCreateHeightmapUnprimed(Heightmap.Types.WORLD_SURFACE).getFirstAvailable(xRel, zRel); + #endif } else { @@ -332,19 +352,26 @@ public class ChunkWrapper implements IChunkWrapper if (this.lightBlockingHeightMap == null) { + #if MC_VER <= MC_1_12_2 + return this.chunk.getHeightValue(xRel, zRel); + #else return this.chunk.getOrCreateHeightmapUnprimed(Heightmap.Types.MOTION_BLOCKING).getFirstAvailable(xRel, zRel); + #endif } else { return this.lightBlockingHeightMap[xRel][zRel]; - } + } } @Override public IBiomeWrapper getBiome(int relX, int relY, int relZ) { - #if MC_VER < MC_1_17_1 + #if MC_VER <= MC_1_12_2 + World world = (World) this.wrappedLevel.getWrappedMcObject(); + return BiomeWrapper.getBiomeWrapper(this.chunk.getBiome(new BlockPos(relX, relY, relZ), world.getBiomeProvider()), wrappedLevel); + #elif MC_VER < MC_1_17_1 return BiomeWrapper.getBiomeWrapper(this.chunk.getBiomes().getNoiseBiome( relX >> 2, relY >> 2, relZ >> 2), this.wrappedLevel); @@ -352,10 +379,6 @@ public class ChunkWrapper implements IChunkWrapper return BiomeWrapper.getBiomeWrapper(this.chunk.getBiomes().getNoiseBiome( QuartPos.fromBlock(relX), QuartPos.fromBlock(relY), QuartPos.fromBlock(relZ)), this.wrappedLevel); - #elif MC_VER < MC_1_18_2 - return BiomeWrapper.getBiomeWrapper(this.chunk.getNoiseBiome( - QuartPos.fromBlock(relX), QuartPos.fromBlock(relY), QuartPos.fromBlock(relZ)), - this.wrappedLevel); #else //Now returns a Holder instead of Biome return BiomeWrapper.getBiomeWrapper(this.chunk.getNoiseBiome( @@ -371,9 +394,13 @@ public class ChunkWrapper implements IChunkWrapper BlockPos.MutableBlockPos blockPos = MUTABLE_BLOCK_POS_REF.get(); + #if MC_VER <= MC_1_12_2 + blockPos.setPos(relX, relY, relZ); + #else blockPos.setX(relX); blockPos.setY(relY); blockPos.setZ(relZ); + #endif try { @@ -396,9 +423,13 @@ public class ChunkWrapper implements IChunkWrapper this.throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(relX, relY, relZ); BlockPos.MutableBlockPos pos = (BlockPos.MutableBlockPos)mcBlockPos.getWrappedMcObject(); + #if MC_VER <= MC_1_12_2 + pos.setPos(relX, relY, relZ); + #else pos.setX(relX); pos.setY(relY); pos.setZ(relZ); + #endif try { @@ -508,8 +539,9 @@ public class ChunkWrapper implements IChunkWrapper @Override public DhChunkPos getChunkPos() { return this.chunkPos; } - public ChunkAccess getChunk() { return this.chunk; } + public #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif getChunk() { return this.chunk; } + #if MC_VER > MC_1_12_2 public void trySetStatus(ChunkStatus status) { trySetStatus(this.getChunk(), status); } /** does nothing if the chunk object doesn't support setting it's status */ public static void trySetStatus(ChunkAccess chunk, ChunkStatus status) @@ -533,15 +565,16 @@ public class ChunkWrapper implements IChunkWrapper return chunk.getPersistedStatus(); #endif } + #endif @Override - public int getMaxBlockX() { return this.chunk.getPos().getMaxBlockX(); } + public int getMaxBlockX() { return this.chunk.getPos().#if MC_VER <= MC_1_12_2 getXEnd() #else getMaxBlockX() #endif; } @Override - public int getMaxBlockZ() { return this.chunk.getPos().getMaxBlockZ(); } + public int getMaxBlockZ() { return this.chunk.getPos().#if MC_VER <= MC_1_12_2 getZEnd() #else getMaxBlockZ() #endif; } @Override - public int getMinBlockX() { return this.chunk.getPos().getMinBlockX(); } + public int getMinBlockX() { return this.chunk.getPos().#if MC_VER <= MC_1_12_2 getXStart() #else getMinBlockX() #endif; } @Override - public int getMinBlockZ() { return this.chunk.getPos().getMinBlockZ(); } + public int getMinBlockZ() { return this.chunk.getPos().#if MC_VER <= MC_1_12_2 getZStart() #else getMinBlockZ() #endif; } @@ -624,8 +657,23 @@ public class ChunkWrapper implements IChunkWrapper { this.blockLightPosList = new ArrayList<>(); - - #if MC_VER < MC_1_20_1 + //1.12.2 doesn't store lights we must bruteforce it + #if MC_VER <= MC_1_12_2 + for (int x = 0; x < 16; x++) + { + for (int z = 0; z < 16; z++) + { + for (int y = 0; y < 256; y++) + { + IBlockState blockState = this.chunk.getBlockState(x, y, z); + if (blockState.getLightValue() > 0) + { + this.blockLightPosList.add(new DhBlockPos(this.chunk.getPos().getXStart() + x, y, this.chunk.getPos().getZStart() + z)); + } + } + } + } + #elif MC_VER < MC_1_20_1 this.chunk.getLights().forEach((blockPos) -> { this.blockLightPosList.add(new DhBlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ())); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java index 77fc61e2a..9d966686e 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java @@ -17,7 +17,6 @@ import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapp import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.config.ConfigHandler; import com.seibel.distanthorizons.core.config.types.*; -import com.seibel.distanthorizons.common.wrappers.gui.updater.ChangelogScreen; import com.seibel.distanthorizons.core.config.types.enums.EConfigCommentTextPosition; import com.seibel.distanthorizons.core.config.types.enums.EConfigValidity; @@ -28,6 +27,14 @@ import com.seibel.distanthorizons.core.util.AnnotationUtil; import com.seibel.distanthorizons.core.wrapperInterfaces.config.IConfigGui; import com.seibel.distanthorizons.core.wrapperInterfaces.config.ILangWrapper; import com.seibel.distanthorizons.coreapi.ModInfo; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.*; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.Style; +import net.minecraft.util.text.TextFormatting; +#else +import com.seibel.distanthorizons.common.wrappers.gui.updater.ChangelogScreen; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; @@ -38,12 +45,14 @@ import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; +import com.mojang.blaze3d.platform.InputConstants; +#endif import com.seibel.distanthorizons.core.logging.DhLogger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; - -#if MC_VER < MC_1_20_1 +#if MC_VER <= MC_1_12_2 +#elif MC_VER < MC_1_20_1 import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.GuiComponent; #else @@ -54,15 +63,14 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.narration.NarratableEntry; #endif -#if MC_VER <= MC_1_21_10 +#if MC_VER <= MC_1_12_2 +import net.minecraft.util.ResourceLocation; +#elif MC_VER <= MC_1_21_10 import net.minecraft.resources.ResourceLocation; #else import net.minecraft.resources.Identifier; #endif -import org.lwjgl.glfw.GLFW; -import com.mojang.blaze3d.platform.InputConstants; - import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.*; import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.Translatable; @@ -122,7 +130,7 @@ public class ClassicConfigGUI //==============// /** if you want to get this config gui's screen call this */ - public static Screen getScreen(Screen parent, String category) + public static #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif getScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, String category) { return new DhConfigScreen(parent, category); } private static class DhConfigScreen extends DhScreen @@ -132,12 +140,12 @@ public class ClassicConfigGUI private static final String TRANSLATION_PREFIX = ModInfo.ID + ".config."; - private final Screen parent; + private final #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent; private final String category; private ConfigListWidget configListWidget; private boolean reload = false; - private Button doneButton; + private #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif doneButton; @@ -145,7 +153,7 @@ public class ClassicConfigGUI // constructor // //=============// - protected DhConfigScreen(Screen parent, String category) + protected DhConfigScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, String category) { super(Translatable( LANG_WRAPPER.langExists(ModInfo.ID + ".config" + (category.isEmpty() ? "." + category : "") + ".title") ? @@ -158,7 +166,11 @@ public class ClassicConfigGUI @Override + #if MC_VER <= MC_1_12_2 + public void updateScreen() { super.updateScreen(); } + #else public void tick() { super.tick(); } + #endif @@ -167,15 +179,20 @@ public class ClassicConfigGUI //==================// @Override + #if MC_VER <= MC_1_12_2 + public void initGui() + #else protected void init() + #endif { - super.init(); + super.#if MC_VER <= MC_1_12_2 initGui(); #else init(); #endif if (!this.reload) { ConfigHandler.INSTANCE.configFileHandler.loadFromFile(); } // Changelog button + #if MC_VER > MC_1_12_2 if (Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get() // we only have changelogs for stable builds && !ModInfo.IS_DEV_BUILD) @@ -213,6 +230,7 @@ public class ClassicConfigGUI Translatable(ModInfo.ID + ".updater.title") )); } + #endif // back button @@ -222,7 +240,11 @@ public class ClassicConfigGUI (button) -> { ConfigHandler.INSTANCE.configFileHandler.loadFromFile(); + #if MC_VER <= MC_1_12_2 + Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); + #else Objects.requireNonNull(this.minecraft).setScreen(this.parent); + #endif })); // done/close button @@ -233,19 +255,25 @@ public class ClassicConfigGUI (button) -> { ConfigHandler.INSTANCE.configFileHandler.saveToFile(); + #if MC_VER <= MC_1_12_2 + Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); + #else Objects.requireNonNull(this.minecraft).setScreen(this.parent); + #endif })); - this.configListWidget = new ConfigListWidget(this.minecraft, this.width * 2, this.height, 32, 32, 25); + this.configListWidget = new ConfigListWidget(#if MC_VER <= MC_1_12_2 this.mc #else this.minecraft #endif, this.width * 2, this.height, 32, 32, 25); + #if MC_VER > MC_1_12_2 #if MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+ if (this.minecraft != null && this.minecraft.level != null) { this.configListWidget.setRenderBackground(false); } #endif - + this.addWidget(this.configListWidget); + #endif for (AbstractConfigBase configEntry : ConfigHandler.INSTANCE.configBaseList) { @@ -408,10 +436,25 @@ public class ClassicConfigGUI private static void setupBooleanMenuOption(ConfigEntry booleanConfigEntry) { // For boolean + #if MC_VER <= MC_1_12_2 + Function func = value -> Translatable("distanthorizons.general."+((Boolean) value ? "true" : "false")).setStyle(new Style().setColor((Boolean) value ? TextFormatting.GREEN : TextFormatting.RED)); + #else Function func = value -> Translatable("distanthorizons.general."+((Boolean) value ? "true" : "false")).withStyle((Boolean) value ? ChatFormatting.GREEN : ChatFormatting.RED); + #endif final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) booleanConfigEntry.guiValue); + #if MC_VER <= MC_1_12_2 + configGuiInfo.buttonOptionMap = + new AbstractMap.SimpleEntry>( + (button) -> + { + button.enabled = !booleanConfigEntry.apiIsOverriding(); + + booleanConfigEntry.uiSetWithoutSaving(!booleanConfigEntry.get()); + button.displayString = func.apply(booleanConfigEntry.get()).getFormattedText(); + }, func); + #else configGuiInfo.buttonOptionMap = new AbstractMap.SimpleEntry>( (button) -> @@ -421,6 +464,7 @@ public class ClassicConfigGUI booleanConfigEntry.uiSetWithoutSaving(!booleanConfigEntry.get()); button.setMessage(func.apply(booleanConfigEntry.get())); }, func); + #endif } private static void setupEnumMenuOption(ConfigEntry> enumConfigEntry, Class> enumClass) { @@ -428,20 +472,20 @@ public class ClassicConfigGUI final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) enumConfigEntry.guiValue); - Function getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString()); + Function getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString()); configGuiInfo.buttonOptionMap = - new AbstractMap.SimpleEntry>( + new AbstractMap.SimpleEntry<#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif, Function>( (button) -> { // get the currently selected enum and enum index int startingIndex = enumList.indexOf(enumConfigEntry.get()); Enum enumValue = enumList.get(startingIndex); - boolean shiftPressed = - InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_LEFT_SHIFT) - || InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_RIGHT_SHIFT); - - + #if MC_VER <= MC_1_12_2 + boolean shiftPressed = GuiScreen.isShiftKeyDown(); + #else + boolean shiftPressed = InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_LEFT_SHIFT) || InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_RIGHT_SHIFT); + #endif // move forward or backwards depending on if the shift key is pressed int index = shiftPressed ? startingIndex-1 : startingIndex+1; @@ -483,9 +527,13 @@ public class ClassicConfigGUI enumConfigEntry.uiSetWithoutSaving(enumValue); + #if MC_VER <= MC_1_12_2 + button.enabled = !enumConfigEntry.apiIsOverriding(); + button.displayString = getEnumTranslatableFunc.apply(enumConfigEntry.get()).getFormattedText(); + #else button.active = !enumConfigEntry.apiIsOverriding(); - button.setMessage(getEnumTranslatableFunc.apply(enumConfigEntry.get())); + #endif }, getEnumTranslatableFunc); } @@ -502,11 +550,15 @@ public class ClassicConfigGUI // reset button // //==============// - Button.OnPress btnAction = (button) -> + #if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif btnAction = (button) -> { configEntry.uiSetWithoutSaving(configEntry.getDefaultValue()); this.reload = true; - Objects.requireNonNull(this.minecraft).setScreen(this); + #if MC_VER <= MC_1_12_2 + Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); + #else + Objects.requireNonNull(this.minecraft).setScreen(this.parent); + #endif }; int resetButtonPosX = this.width @@ -514,20 +566,29 @@ public class ClassicConfigGUI - ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN; int resetButtonPosZ = 0; - Button resetButton = MakeBtn( + #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif resetButton = MakeBtn( + #if MC_VER <= MC_1_12_2 + Translatable("distanthorizons.general.reset").setStyle(new Style().setColor(TextFormatting.RED)), + #else Translatable("distanthorizons.general.reset").withStyle(ChatFormatting.RED), + #endif resetButtonPosX, resetButtonPosZ, ConfigScreenConfigs.RESET_BUTTON_WIDTH, ConfigScreenConfigs.RESET_BUTTON_HEIGHT, btnAction); if (configEntry.apiIsOverriding()) { + #if MC_VER <= MC_1_12_2 + resetButton.enabled = false; + resetButton.displayString = Translatable("distanthorizons.general.apiOverride").setStyle(new Style().setColor(TextFormatting.DARK_GRAY)).getFormattedText(); + #else resetButton.active = false; resetButton.setMessage(Translatable("distanthorizons.general.apiOverride").withStyle(ChatFormatting.DARK_GRAY)); + #endif } else { - resetButton.active = true; + resetButton.#if MC_VER <= MC_1_12_2 enabled #else active #endif = true; } @@ -536,7 +597,7 @@ public class ClassicConfigGUI // option field // //==============// - Component textComponent = this.GetTranslatableTextComponentForConfig(configEntry); + #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configEntry); int optionFieldPosX = this.width - ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN @@ -549,20 +610,20 @@ public class ClassicConfigGUI { // enum/multi option input button - Map.Entry> widget = configGuiInfo.buttonOptionMap; + Map.Entry<#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif, Function> widget = configGuiInfo.buttonOptionMap; if (configEntry.getType().isEnum()) { widget.setValue((value) -> Translatable(TRANSLATION_PREFIX + "enum." + configEntry.getType().getSimpleName() + "." + configEntry.get().toString())); } - Button button = MakeBtn( + #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif button = MakeBtn( widget.getValue().apply(configEntry.get()), optionFieldPosX, optionFieldPosZ, ConfigScreenConfigs.OPTION_FIELD_WIDTH, ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, widget.getKey()); // deactivate the button if the API is overriding it - button.active = !configEntry.apiIsOverriding(); + button.#if MC_VER <= MC_1_12_2 enabled #else active #endif = !configEntry.apiIsOverriding(); this.configListWidget.addButton(this, configEntry, @@ -577,15 +638,17 @@ public class ClassicConfigGUI { // text box input - EditBox widget = new EditBox(this.font, + #if MC_VER <= MC_1_12_2 GuiTextField #else EditBox #endif widget = new #if MC_VER <= MC_1_12_2 GuiTextField #else EditBox #endif( + #if MC_VER <= MC_1_12_2 0, #endif + #if MC_VER <= MC_1_12_2 this.fontRenderer #else this.font #endif, optionFieldPosX, optionFieldPosZ, - ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, - Translatable("")); - widget.setMaxLength(3_000_000); // hopefully 3 million characters should be enough for any normal use-case, lol - widget.insertText(String.valueOf(configEntry.get())); + ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT + #if MC_VER > MC_1_12_2 ,Translatable("") #endif ); + widget.#if MC_VER <= MC_1_12_2 setMaxStringLength(3_000_000); #else setMaxLength(3_000_000); #endif // hopefully 3 million characters should be enough for any normal use-case, lol + widget.#if MC_VER <= MC_1_12_2 setText #else insertText #endif (String.valueOf(configEntry.get())); Predicate processor = configGuiInfo.tooltipFunction.apply(widget, this.doneButton); - widget.setFilter(processor); + widget.#if MC_VER <= MC_1_12_2 setValidator(processor::test); #else setFilter(processor); #endif this.configListWidget.addButton(this, configEntry, widget, resetButton, null, textComponent); @@ -601,18 +664,22 @@ public class ClassicConfigGUI { ConfigCategory configCategory = (ConfigCategory) configType; - Component textComponent = this.GetTranslatableTextComponentForConfig(configCategory); + #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configCategory); int categoryPosX = this.width - ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN; int categoryPosZ = this.height - ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT; // Note: the posZ value here seems to be ignored - Button widget = MakeBtn(textComponent, + #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif widget = MakeBtn(textComponent, categoryPosX, categoryPosZ, ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, ((button) -> { ConfigHandler.INSTANCE.configFileHandler.saveToFile(); + #if MC_VER <= MC_1_12_2 + Objects.requireNonNull(this.mc).displayGuiScreen(ClassicConfigGUI.getScreen(this, configCategory.getDestination())); + #else Objects.requireNonNull(this.minecraft).setScreen(ClassicConfigGUI.getScreen(this, configCategory.getDestination())); + #endif })); this.configListWidget.addButton(this, configType, widget, null, null, null); @@ -627,11 +694,11 @@ public class ClassicConfigGUI { ConfigUIButton configUiButton = (ConfigUIButton) configType; - Component textComponent = this.GetTranslatableTextComponentForConfig(configUiButton); + #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configUiButton); int buttonPosX = this.width - ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN; - Button widget = MakeBtn(textComponent, + #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif widget = MakeBtn(textComponent, buttonPosX, this.height - 28, ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, (button) -> ((ConfigUIButton) configType).runAction()); @@ -648,7 +715,7 @@ public class ClassicConfigGUI { ConfigUIComment configUiComment = (ConfigUIComment) configType; - Component textComponent = this.GetTranslatableTextComponentForConfig(configUiComment); + #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configUiComment); if (configUiComment.parentConfigPath != null) { textComponent = Translatable(TRANSLATION_PREFIX + configUiComment.parentConfigPath); @@ -665,7 +732,7 @@ public class ClassicConfigGUI { if (configType instanceof ConfigUISpacer) { - Button spacerButton = MakeBtn(Translatable("distanthorizons.general.spacer"), + #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif spacerButton = MakeBtn(Translatable("distanthorizons.general.spacer"), 10, 10, // having too small of a size causes division by 0 errors in older MC versions (IE 1.20.1) 1, 1, (button) -> {}); @@ -690,7 +757,7 @@ public class ClassicConfigGUI return false; } - private Component GetTranslatableTextComponentForConfig(AbstractConfigBase configType) + private #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif GetTranslatableTextComponentForConfig(AbstractConfigBase configType) { return Translatable(TRANSLATION_PREFIX + configType.getNameAndCategory());} @@ -700,23 +767,31 @@ public class ClassicConfigGUI //===========// @Override - #if MC_VER < MC_1_20_1 + #if MC_VER <= MC_1_12_2 + public void drawScreen(int mouseX, int mouseY, float delta) + #elif MC_VER < MC_1_20_1 public void render(PoseStack matrices, int mouseX, int mouseY, float delta) #else public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta) #endif { - #if MC_VER < MC_1_20_2 // 1.20.2 now enables this by default in the `this.list.render` function + #if MC_VER <= MC_1_12_2 + this.drawDefaultBackground(); + #elif MC_VER < MC_1_20_2 // 1.20.2 now enables this by default in the `this.list.render` function this.renderBackground(matrices); // Renders background #else super.render(matrices, mouseX, mouseY, delta); #endif - this.configListWidget.render(matrices, mouseX, mouseY, delta); // Render buttons + this.configListWidget.render(#if MC_VER > MC_1_12_2 matrices,#endif mouseX, mouseY, delta); // Render buttons // Render config title - this.DhDrawCenteredString(matrices, this.font, this.title, + this.DhDrawCenteredString( + #if MC_VER > MC_1_12_2 + matrices, this.font, + #endif + this.title, this.width / 2, 15, #if MC_VER < MC_1_21_6 0xFFFFFF // RGB white @@ -726,7 +801,11 @@ public class ClassicConfigGUI // render DH version - this.DhDrawString(matrices, this.font, TextOrLiteral(ModInfo.VERSION), 2, this.height - 10, + this.DhDrawString( + #if MC_VER > MC_1_12_2 + matrices, this.font, + #endif + TextOrLiteral(ModInfo.VERSION), 2, this.height - 10, #if MC_VER < MC_1_21_6 0xAAAAAA // RGB white #else @@ -736,7 +815,11 @@ public class ClassicConfigGUI // If the update is pending, display this message to inform the user that it will apply when the game restarts if (SelfUpdater.deleteOldJarOnJvmShutdown) { - this.DhDrawString(matrices, this.font, Translatable(ModInfo.ID + ".updater.waitingForClose"), 4, this.height - 42, + this.DhDrawString( + #if MC_VER > MC_1_12_2 + matrices, this.font, + #endif + Translatable(ModInfo.ID + ".updater.waitingForClose"), 4, this.height - 42, #if MC_VER < MC_1_21_6 0xFFFFFF // RGB white #else @@ -745,20 +828,28 @@ public class ClassicConfigGUI } - this.renderTooltip(matrices, mouseX, mouseY, delta); + this.renderTooltip( + #if MC_VER > MC_1_12_2 + matrices, + #endif + mouseX, mouseY, delta); - #if MC_VER < MC_1_20_2 + #if MC_VER <= MC_1_12_2 + super.drawScreen(mouseX, mouseY, delta); + #elif MC_VER < MC_1_20_2 super.render(matrices, mouseX, mouseY, delta); #endif } - #if MC_VER < MC_1_20_1 + #if MC_VER <= MC_1_12_2 + private void renderTooltip(int mouseX, int mouseY, float delta) + #elif MC_VER < MC_1_20_1 private void renderTooltip(PoseStack matrices, int mouseX, int mouseY, float delta) #else private void renderTooltip(GuiGraphics matrices, int mouseX, int mouseY, float delta) #endif { - AbstractWidget hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY); + #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY); if (hoveredWidget == null) { return; @@ -790,23 +881,83 @@ public class ClassicConfigGUI final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) configBase.guiValue); if (configGuiInfo.errorMessage != null) { - this.DhRenderTooltip(matrices, this.font, configGuiInfo.errorMessage, mouseX, mouseY); + this.DhRenderTooltip( + #if MC_VER > MC_1_12_2 + matrices, this.font, + #endif + configGuiInfo.errorMessage, mouseX, mouseY); } // display the tooltip if present else if (LANG_WRAPPER.langExists(key)) { - List list = new ArrayList<>(); + List<#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif> list = new ArrayList<>(); String lang = LANG_WRAPPER.getLang(key); for (String langLine : lang.split("\n")) { list.add(TextOrTranslatable(langLine)); } - this.DhRenderComponentTooltip(matrices, this.font, list, mouseX, mouseY); + this.DhRenderComponentTooltip( + #if MC_VER > MC_1_12_2 + matrices, this.font, + #endif + list, mouseX, mouseY); } } + //==========// + // input // + //==========// + #if MC_VER <= MC_1_12_2 + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws java.io.IOException + { + super.mouseClicked(mouseX, mouseY, mouseButton); + + for (ClassicConfigGUI.DhButtonEntry entry : this.configListWidget.children) + { + if (entry.button instanceof GuiButton btn && btn.visible) + { + if (mouseX >= btn.x && mouseX < btn.x + btn.width + && mouseY >= btn.y && mouseY < btn.y + btn.height) + { + btn.mousePressed(this.mc, mouseX, mouseY); + OnPressed handler = GuiHelper.HANDLER_BY_BUTTON.get(btn); + if (handler != null) handler.pressed(btn); + } + } + else if (entry.button instanceof GuiTextField field && field.getVisible()) + { + field.mouseClicked(mouseX, mouseY, mouseButton); + } + + if (entry.resetButton instanceof GuiButton reset && reset.visible) + { + if (mouseX >= reset.x && mouseX < reset.x + reset.width + && mouseY >= reset.y && mouseY < reset.y + reset.height) + { + reset.mousePressed(this.mc, mouseX, mouseY); + OnPressed handler = GuiHelper.HANDLER_BY_BUTTON.get(reset); + if (handler != null) handler.pressed(reset); + } + } + } + } + + @Override + protected void keyTyped(char typedChar, int keyCode) throws java.io.IOException + { + super.keyTyped(typedChar, keyCode); + for (ClassicConfigGUI.DhButtonEntry entry : this.configListWidget.children) + { + if (entry.button instanceof GuiTextField field) + { + field.textboxKeyTyped(typedChar, keyCode); + } + } + } +#endif //==========// // shutdown // @@ -814,11 +965,16 @@ public class ClassicConfigGUI /** When you close it, it goes to the previous screen and saves */ @Override + #if MC_VER <= MC_1_12_2 + public void onGuiClosed() + #else public void onClose() + #endif { ConfigHandler.INSTANCE.configFileHandler.saveToFile(); + #if MC_VER > MC_1_12_2 Objects.requireNonNull(this.minecraft).setScreen(this.parent); - + #endif CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run()); } @@ -831,12 +987,17 @@ public class ClassicConfigGUI // helper classes // //================// - public static class ConfigListWidget extends ContainerObjectSelectionList + public static class ConfigListWidget #if MC_VER > MC_1_12_2 extends ContainerObjectSelectionList #endif { + #if MC_VER <= MC_1_12_2 + private List children = new ArrayList<>(); + #else Font textRenderer; + #endif public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing) { + #if MC_VER > MC_1_12_2 #if MC_VER < MC_1_20_4 super(minecraftClient, canvasWidth, canvasHeight, topMargin, canvasHeight - botMargin, itemSpacing); #else @@ -845,72 +1006,122 @@ public class ClassicConfigGUI this.centerListVertically = false; this.textRenderer = minecraftClient.font; + #endif } + #if MC_VER <= MC_1_12_2 + public void addButton(DhConfigScreen gui, AbstractConfigBase dhConfigType, Gui button, GuiButton resetButton, GuiButton indexButton, ITextComponent text) + #else public void addButton(DhConfigScreen gui, AbstractConfigBase dhConfigType, AbstractWidget button, AbstractWidget resetButton, AbstractWidget indexButton, Component text) - { this.addEntry(new DhButtonEntry(gui, dhConfigType, button, text, resetButton, indexButton)); } + #endif + { this.#if MC_VER <= MC_1_12_2 children.add #else addEntry #endif(new DhButtonEntry(gui, dhConfigType, button, text, resetButton, indexButton)); } + #if MC_VER > MC_1_12_2 @Override public int getRowWidth() { return 10_000; } + #endif - public AbstractWidget getHoveredButton(double mouseX, double mouseY) + public #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif getHoveredButton(double mouseX, double mouseY) { - for (DhButtonEntry buttonEntry : this.children()) + for (DhButtonEntry buttonEntry : this.children#if MC_VER > MC_1_12_2() #endif) { - AbstractWidget button = buttonEntry.button; - if (button != null - && button.visible) + #if MC_VER <= MC_1_12_2 + Gui gui = buttonEntry.button; + if (gui == null) continue; + + double minX, minY, maxX, maxY; + + if (gui instanceof GuiButton button) { - #if MC_VER < MC_1_19_4 - double minX = button.x; - double minY = button.y; - #else - double minX = button.getX(); - double minY = button.getY(); - #endif - - double maxX = minX + button.getWidth(); - double maxY = minY + button.getHeight(); - - if (mouseX >= minX && mouseX < maxX - && mouseY >= minY && mouseY < maxY) - { - return button; - } + if (!button.visible) continue; + minX = button.x; + minY = button.y; + maxX = minX + button.width; + maxY = minY + button.height; } + else if (gui instanceof GuiTextField field) + { + if (!field.getVisible()) continue; + minX = field.x; + minY = field.y; + maxX = minX + field.width; + maxY = minY + field.height; + } + else + { + continue; + } + + if (mouseX >= minX && mouseX < maxX && mouseY >= minY && mouseY < maxY) + { + return gui; + } + #else + AbstractWidget button = (AbstractWidget) buttonEntry.button; + if (button == null || !button.visible) continue; + + #if MC_VER < MC_1_19_4 + double minX = button.x; + double minY = button.y; + #else + double minX = button.getX(); + double minY = button.getY(); + #endif + + double maxX = minX + button.getWidth(); + double maxY = minY + button.getHeight(); + + if (mouseX >= minX && mouseX < maxX && mouseY >= minY && mouseY < maxY) + { + return button; + } + #endif } return null; } + #if MC_VER <= MC_1_12_2 + public void render(int mouseX, int mouseY, float delta) { + int y = 40; + for (DhButtonEntry buttonEntry : this.children) + { + buttonEntry.render(y, 0, mouseX, mouseY, delta); + y += 25; + } + } + #endif + } - public static class DhButtonEntry extends ContainerObjectSelectionList.Entry + public static class DhButtonEntry #if MC_VER > MC_1_12_2 extends ContainerObjectSelectionList.Entry #endif { - private static final Font textRenderer = Minecraft.getInstance().font; + private static final #if MC_VER <= MC_1_12_2 FontRenderer #else Font #endif textRenderer = Minecraft. #if MC_VER <= MC_1_12_2 getMinecraft().fontRenderer; #else .getInstance().font; #endif - private final AbstractWidget button; + private final #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif button; private final DhConfigScreen gui; private final AbstractConfigBase dhConfigType; - private final AbstractWidget resetButton; - private final AbstractWidget indexButton; - private final Component text; - private final List children = new ArrayList<>(); + private final #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif resetButton; + private final #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif indexButton; + private final #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif text; + private final List<#if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif> children = new ArrayList<>(); @NotNull private final EConfigCommentTextPosition textPosition; - public static final Map TEXT_BY_WIDGET = new HashMap<>(); - public static final Map BUTTON_BY_WIDGET = new HashMap<>(); + public static final Map< #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif, #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif> TEXT_BY_WIDGET = new HashMap<>(); + public static final Map< #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif, DhButtonEntry> BUTTON_BY_WIDGET = new HashMap<>(); - public DhButtonEntry( - DhConfigScreen gui, AbstractConfigBase dhConfigType, - AbstractWidget button, Component text, AbstractWidget resetButton, AbstractWidget indexButton) + #if MC_VER <= MC_1_12_2 + public DhButtonEntry(DhConfigScreen gui, AbstractConfigBase dhConfigType, Gui button, ITextComponent text, GuiButton resetButton, GuiButton indexButton) + #else + public DhButtonEntry(DhConfigScreen gui, AbstractConfigBase dhConfigType, AbstractWidget button, Component text, AbstractWidget resetButton, AbstractWidget indexButton) + #endif { TEXT_BY_WIDGET.put(button, text); BUTTON_BY_WIDGET.put(button, this); @@ -951,13 +1162,16 @@ public class ClassicConfigGUI } - + #if MC_VER <= MC_1_12_2 + public void render(int y, int x, int mouseX, int mouseY, float tickDelta) + #elif MC_VER < MC_1_20_1 @Override - #if MC_VER < MC_1_20_1 public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) #elif MC_VER < MC_1_21_9 + @Override public void render(GuiGraphics matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) #else + @Override public void renderContent(GuiGraphics matrices, int mouseX, int mouseY, boolean hovered, float tickDelta) #endif { @@ -976,25 +1190,50 @@ public class ClassicConfigGUI if (this.button != null) { + #if MC_VER <= MC_1_12_2 + if (this.button instanceof GuiButton guiButton) + { + SetY(guiButton, y); + guiButton.drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta); + } + if (this.button instanceof GuiTextField guiTextField) + { + SetY(guiTextField, y); + guiTextField.drawTextBox(); + } + #else SetY(this.button, y); this.button.render(matrices, mouseX, mouseY, tickDelta); + #endif } if (this.resetButton != null) { - SetY(this.resetButton, y); + SetY(#if MC_VER <= MC_1_12_2 (GuiButton) #endif this.resetButton, y); + #if MC_VER <= MC_1_12_2 + ((GuiButton) this.resetButton).drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta); + #else this.resetButton.render(matrices, mouseX, mouseY, tickDelta); + #endif } if (this.indexButton != null) { - SetY(this.indexButton, y); + SetY(#if MC_VER <= MC_1_12_2 (GuiButton) #endif this.indexButton, y); + #if MC_VER <= MC_1_12_2 + ((GuiButton) this.indexButton).drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta); + #else this.indexButton.render(matrices, mouseX, mouseY, tickDelta); + #endif } if (this.text != null) { + #if MC_VER <= MC_1_12_2 + int translatedLength = textRenderer.getStringWidth(this.text.getFormattedText()); + #else int translatedLength = textRenderer.width(this.text); + #endif int textXPos; if (this.textPosition == EConfigCommentTextPosition.RIGHT_JUSTIFIED) @@ -1027,8 +1266,9 @@ public class ClassicConfigGUI throw new UnsupportedOperationException("No text position render defined for [" + this.textPosition + "]"); } - - #if MC_VER < MC_1_20_1 + #if MC_VER <= MC_1_12_2 + textRenderer.drawString(this.text.getFormattedText(), textXPos, y + 5,0xFFFFFF); + #elif MC_VER < MC_1_20_1 GuiComponent.drawString(matrices, textRenderer, this.text, textXPos, y + 5, @@ -1053,9 +1293,11 @@ public class ClassicConfigGUI } } + #if MC_VER > MC_1_12_2 @Override public @NotNull List children() { return this.children; } + #endif #if MC_VER >= MC_1_17_1 @Override diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java index 34ce892b1..d8cd36be1 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java @@ -1,5 +1,10 @@ package com.seibel.distanthorizons.common.wrappers.gui; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.util.text.ITextComponent; +#else import net.minecraft.client.gui.Font; #if MC_VER < MC_1_20_1 import com.mojang.blaze3d.vertex.PoseStack; @@ -9,29 +14,67 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; +#endif import java.util.List; -public class DhScreen extends Screen +public class DhScreen extends #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif { - - protected DhScreen(Component $$0) + #if MC_VER <= MC_1_12_2 + protected ITextComponent title; + protected DhScreen(ITextComponent title) { - super($$0); + this.title = title; } + #else + protected DhScreen(Component title) + { + super(title); + } + #endif // addRenderableWidget in 1.17 and over // addButton in 1.16 and below - protected Button addBtn(Button button) + protected #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif addBtn(#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif button) { - #if MC_VER < MC_1_17_1 + #if MC_VER <= MC_1_12_2 + this.buttonList.add(button); + return button; + #elif MC_VER < MC_1_17_1 return this.addButton(button); #else return this.addRenderableWidget(button); #endif } - #if MC_VER < MC_1_20_1 + #if MC_VER <= MC_1_12_2 + + @Override + protected void actionPerformed(GuiButton button) + { + OnPressed handler = GuiHelper.HANDLER_BY_BUTTON.get(button); + if (handler != null) + { + handler.pressed(button); + } + } + + protected void DhDrawCenteredString(ITextComponent text, int x, int y, int color) { + drawCenteredString(fontRenderer, text.getFormattedText(), x, y, color); + } + + protected void DhDrawString(ITextComponent text, int x, int y, int color) { + drawString(fontRenderer, text.getFormattedText(), x, y, color); + } + + protected void DhRenderComponentTooltip(List list, int x, int y) { + drawHoveringText(list.stream().map(ITextComponent::getFormattedText).toList(), x, y, fontRenderer); + } + + protected void DhRenderTooltip(ITextComponent text, int x, int y) { + drawHoveringText(List.of(text.getFormattedText()), x, y, fontRenderer); + } + #elif MC_VER < MC_1_20_1 protected void DhDrawCenteredString(PoseStack guiStack, Font font, Component text, int x, int y, int color) { drawCenteredString(guiStack, font, text, x, y, color); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GetConfigScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GetConfigScreen.java index 777e1b943..1e4ed0390 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GetConfigScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GetConfigScreen.java @@ -3,14 +3,18 @@ package com.seibel.distanthorizons.common.wrappers.gui; import com.seibel.distanthorizons.core.config.ConfigHandler; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.coreapi.ModInfo; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.gui.GuiScreen; +#else import net.minecraft.client.gui.screens.Screen; +#endif import com.seibel.distanthorizons.core.logging.DhLogger; public class GetConfigScreen { protected static final DhLogger LOGGER = new DhLoggerBuilder().build(); - public static Screen getScreen(Screen parent) + public static #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif getScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent) { if (ModInfo.IS_DEV_BUILD) { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GuiHelper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GuiHelper.java index 46fe7010d..b748a6d77 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GuiHelper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GuiHelper.java @@ -1,11 +1,21 @@ package com.seibel.distanthorizons.common.wrappers.gui; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextComponentTranslation; +import java.util.HashMap; +import java.util.Map; +#else import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; +#endif -#if MC_VER < MC_1_19_2 +#if MC_VER < MC_1_19_2 && MC_VER > MC_1_12_2 import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; #endif @@ -15,43 +25,58 @@ public class GuiHelper /** * Helper static methods for versional compat */ - public static Button MakeBtn(Component base, int posX, int posZ, int width, int height, Button.OnPress action) + #if MC_VER <= MC_1_12_2 + public static final Map HANDLER_BY_BUTTON = new HashMap<>(); + #endif + + public static #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif MakeBtn(#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif base, int posX, int posZ, int width, int height, + #if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif action) { - #if MC_VER < MC_1_19_4 + #if MC_VER <= MC_1_12_2 + GuiButton button = new GuiButton(HANDLER_BY_BUTTON.size(), posX, posZ, width, height, base.getFormattedText()); + HANDLER_BY_BUTTON.put(button, action); + return button; + #elif MC_VER < MC_1_19_4 return new Button(posX, posZ, width, height, base, action); #else return Button.builder(base, action).bounds(posX, posZ, width, height).build(); #endif } - public static MutableComponent TextOrLiteral(String text) + public static #if MC_VER <= MC_1_12_2 ITextComponent #else MutableComponent #endif TextOrLiteral(String text) { - #if MC_VER < MC_1_19_2 + #if MC_VER <= MC_1_12_2 + return new TextComponentString(text); + #elif MC_VER < MC_1_19_2 return new TextComponent(text); #else return Component.literal(text); #endif } - public static MutableComponent TextOrTranslatable(String text) + public static #if MC_VER <= MC_1_12_2 ITextComponent #else MutableComponent #endif TextOrTranslatable(String text) { - #if MC_VER < MC_1_19_2 + #if MC_VER <= MC_1_12_2 + return new TextComponentString(text); + #elif MC_VER < MC_1_19_2 return new TextComponent(text); #else return Component.translatable(text); #endif } - public static MutableComponent Translatable(String text, Object... args) + public static #if MC_VER <= MC_1_12_2 ITextComponent #else MutableComponent #endif Translatable(String text, Object... args) { - #if MC_VER < MC_1_19_2 + #if MC_VER <= MC_1_12_2 + return new TextComponentTranslation(text, args); + #elif MC_VER < MC_1_19_2 return new TranslatableComponent(text, args); #else return Component.translatable(text, args); #endif } - public static void SetX(AbstractWidget w, int x) + public static void SetX(#if MC_VER <= MC_1_12_2 GuiButton #else AbstractWidget #endif w, int x) { #if MC_VER < MC_1_19_4 w.x = x; @@ -60,7 +85,18 @@ public class GuiHelper #endif } - public static void SetY(AbstractWidget w, int y) + #if MC_VER <= MC_1_12_2 + public static void SetY(GuiTextField w, int y) + { + #if MC_VER < MC_1_19_4 + w.y = y; + #else + w.setY(y); + #endif + } + #endif + + public static void SetY(#if MC_VER <= MC_1_12_2 GuiButton #else AbstractWidget #endif w, int y) { #if MC_VER < MC_1_19_4 w.y = y; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/LangWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/LangWrapper.java index 7f14108fd..eb3f611ed 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/LangWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/LangWrapper.java @@ -1,21 +1,32 @@ package com.seibel.distanthorizons.common.wrappers.gui; import com.seibel.distanthorizons.core.wrapperInterfaces.config.ILangWrapper; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.resources.I18n; +#else import net.minecraft.client.resources.language.I18n; - +#endif public class LangWrapper implements ILangWrapper { public static final LangWrapper INSTANCE = new LangWrapper(); @Override public boolean langExists(String str) { + #if MC_VER <= MC_1_12_2 + return I18n.hasKey(str); + #else return I18n.exists(str); + #endif } @Override public String getLang(String str) { + #if MC_VER <= MC_1_12_2 + return I18n.format(str); + #else return I18n.get(str); + #endif } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java index 7b35a173f..1a6dffca5 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java @@ -1,14 +1,19 @@ package com.seibel.distanthorizons.common.wrappers.gui; - +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.gui.GuiScreen; +import org.lwjglx.opengl.Display; +#else +import net.minecraft.client.gui.components.ContainerObjectSelectionList; +import net.minecraft.client.gui.screens.Screen; import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.vertex.PoseStack; +#endif import com.seibel.distanthorizons.core.config.gui.AbstractScreen; import net.minecraft.client.Minecraft; #if MC_VER >= MC_1_20_1 import net.minecraft.client.gui.GuiGraphics; #endif -import net.minecraft.client.gui.components.ContainerObjectSelectionList; -import net.minecraft.client.gui.screens.Screen; + import org.jetbrains.annotations.NotNull; import java.nio.file.Path; @@ -16,19 +21,21 @@ import java.util.*; public class MinecraftScreen { - public static Screen getScreen(Screen parent, AbstractScreen screen, String translationName) + public static #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif getScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, AbstractScreen screen, String translationName) { return new ConfigScreenRenderer(parent, screen, translationName); } private static class ConfigScreenRenderer extends DhScreen { - private final Screen parent; + private final #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent; private ConfigListWidget configListWidget; private AbstractScreen screen; - - #if MC_VER < MC_1_19_2 + #if MC_VER <= MC_1_12_2 + public static net.minecraft.util.text.TextComponentTranslation translate(String str, Object... args) + { return new net.minecraft.util.text.TextComponentTranslation(str, args); } + #elif MC_VER < MC_1_19_2 public static net.minecraft.network.chat.TranslatableComponent translate(String str, Object... args) { return new net.minecraft.network.chat.TranslatableComponent(str, args); } #else @@ -36,10 +43,12 @@ public class MinecraftScreen { return net.minecraft.network.chat.Component.translatable(str, args); } #endif - protected ConfigScreenRenderer(Screen parent, AbstractScreen screen, String translationName) + protected ConfigScreenRenderer(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, AbstractScreen screen, String translationName) { super(translate(translationName)); - #if MC_VER < MC_1_21_9 + #if MC_VER <= MC_1_12_2 + screen.minecraftWindow = Display.getWindow(); + #elif MC_VER < MC_1_21_9 screen.minecraftWindow = Minecraft.getInstance().getWindow().getWindow(); #else screen.minecraftWindow = Minecraft.getInstance().getWindow().handle(); @@ -49,18 +58,28 @@ public class MinecraftScreen } @Override + #if MC_VER <= MC_1_12_2 + public void initGui() + #else protected void init() + #endif { - super.init(); // Init Minecraft's screen + super.#if MC_VER <= MC_1_12_2 initGui(); #else init(); #endif // Init Minecraft's screen + #if MC_VER <= MC_1_12_2 + this.screen.width = Display.getWidth(); + this.screen.height = Display.getHeight(); + #else Window mcWindow = this.minecraft.getWindow(); this.screen.width = mcWindow.getWidth(); this.screen.height = mcWindow.getHeight(); + #endif this.screen.scaledWidth = this.width; this.screen.scaledHeight = this.height; this.screen.init(); // Init our own config screen - this.configListWidget = new ConfigListWidget(this.minecraft, this.width, this.height, 0, 0, 25); // Select the area to tint + this.configListWidget = new ConfigListWidget(#if MC_VER <= MC_1_12_2 this.mc #else this.minecraft #endif, this.width, this.height, 0, 0, 25); // Select the area to tint + #if MC_VER > MC_1_12_2 #if MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+ if (this.minecraft != null && this.minecraft.level != null) // Check if in game { @@ -69,16 +88,21 @@ public class MinecraftScreen #endif this.addWidget(this.configListWidget); // Add the tint to the things to be rendered + #endif } @Override - #if MC_VER < MC_1_20_1 + #if MC_VER <= MC_1_12_2 + public void drawScreen(int mouseX, int mouseY, float delta) + #elif MC_VER < MC_1_20_1 public void render(PoseStack matrices, int mouseX, int mouseY, float delta) #else public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta) #endif { - #if MC_VER < MC_1_20_2 + #if MC_VER <= MC_1_12_2 + this.drawDefaultBackground(); + #elif MC_VER < MC_1_20_2 this.renderBackground(matrices); // Render background #elif MC_VER < MC_1_21_6 this.renderBackground(matrices, mouseX, mouseY, delta); // Render background @@ -86,57 +110,89 @@ public class MinecraftScreen // background blur is already being rendered, rendering again causes the game to crash #endif + #if MC_VER > MC_1_12_2 this.configListWidget.render(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker) + #endif this.screen.mouseX = mouseX; this.screen.mouseY = mouseY; this.screen.render(delta); // Render everything on the main screen + #if MC_VER <= MC_1_12_2 + super.drawScreen(mouseX, mouseY, delta); + #else super.render(matrices, mouseX, mouseY, delta); // Render the vanilla stuff (currently only used for the background and tint) + #endif } + @Override #if MC_VER <= MC_1_21_10 - @Override + #if MC_VER <= MC_1_12_2 + public void setWorldAndResolution(Minecraft mc, int width, int height) + #else public void resize(Minecraft mc, int width, int height) + #endif #else - @Override public void resize(int width, int height) #endif { // Resize Minecraft's screen - #if MC_VER <= MC_1_21_10 + #if MC_VER <= MC_1_12_2 + super.setWorldAndResolution(mc, width, height); + #elif MC_VER <= MC_1_21_10 super.resize(mc, width, height); #else super.resize(width, height); #endif - + #if MC_VER <= MC_1_12_2 + this.screen.width = Display.getWidth(); + this.screen.height = Display.getHeight(); + #else Window mcWindow = this.minecraft.getWindow(); this.screen.width = mcWindow.getWidth(); this.screen.height = mcWindow.getHeight(); + #endif this.screen.scaledWidth = this.width; this.screen.scaledHeight = this.height; this.screen.onResize(); // Resize our screen } @Override + #if MC_VER <= MC_1_12_2 + public void updateScreen() + #else public void tick() + #endif { - super.tick(); // Tick Minecraft's screen + super.#if MC_VER <= MC_1_12_2 updateScreen(); #else tick(); #endif // Tick Minecraft's screen this.screen.tick(); // Tick our screen if (this.screen.close) // If we decide to close the screen, then actually close the screen { + #if MC_VER <= MC_1_12_2 + this.onGuiClosed(); + #else this.onClose(); + #endif } } @Override + #if MC_VER <= MC_1_12_2 + public void onGuiClosed() + #else public void onClose() + #endif { this.screen.onClose(); // Close our screen + #if MC_VER <= MC_1_12_2 + Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); + #else Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Goto the parent screen + #endif } + #if MC_VER > MC_1_12_2 @Override public void onFilesDrop(@NotNull List files) { this.screen.onFilesDrop(files); } @@ -145,19 +201,21 @@ public class MinecraftScreen @Override public boolean shouldCloseOnEsc() { return this.screen.shouldCloseOnEsc; } - + #endif } - public static class ConfigListWidget extends ContainerObjectSelectionList + public static class ConfigListWidget #if MC_VER > MC_1_12_2 extends ContainerObjectSelectionList #endif { public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing) { + #if MC_VER > MC_1_12_2 #if MC_VER < MC_1_20_4 super(minecraftClient, canvasWidth, canvasHeight, topMargin, canvasHeight - botMargin, itemSpacing); #else super(minecraftClient, canvasWidth, canvasHeight - (topMargin + botMargin), topMargin, itemSpacing); #endif this.centerListVertically = false; + #endif } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/OnPressed.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/OnPressed.java new file mode 100644 index 000000000..41bc58650 --- /dev/null +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/OnPressed.java @@ -0,0 +1,8 @@ +package com.seibel.distanthorizons.common.wrappers.gui; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.gui.GuiButton; + +public interface OnPressed { + void pressed(GuiButton button); +} +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java index a00e5b4ad..f914fefa6 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java @@ -18,14 +18,20 @@ */ package com.seibel.distanthorizons.common.wrappers.gui; - +#if MC_VER > MC_1_12_2 import net.minecraft.network.chat.Component; +#endif #if MC_VER >= MC_1_17_1 import net.minecraft.client.gui.components.Button; #endif -#if MC_VER < MC_1_17_1 +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.ResourceLocation; +#elif MC_VER < MC_1_17_1 import net.minecraft.client.gui.components.ImageButton; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; @@ -50,7 +56,9 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.RenderPipelines; #endif -#if MC_VER <= MC_1_21_10 +#if MC_VER <= MC_1_12_2 +import net.minecraft.util.ResourceLocation; +#elif MC_VER <= MC_1_21_10 import net.minecraft.resources.ResourceLocation; #else import net.minecraft.resources.Identifier; @@ -63,14 +71,14 @@ import net.minecraft.resources.Identifier; * @version 2023-10-03 */ #if MC_VER < MC_1_20_2 -public class TexturedButtonWidget extends ImageButton +public class TexturedButtonWidget extends #if MC_VER <= MC_1_12_2 GuiButton #else ImageButton #endif #else public class TexturedButtonWidget extends Button #endif { public final boolean renderBackground; - #if MC_VER >= MC_1_20_2 + #if MC_VER >= MC_1_20_2 || MC_VER <= MC_1_12_2 private final int u; private final int v; private final int hoveredVOffset; @@ -87,27 +95,40 @@ public class TexturedButtonWidget extends Button public TexturedButtonWidget( - int x, int y, int width, int height, int u, int v, int hoveredVOffset, + #if MC_VER <= MC_1_12_2 int id ,#endif int x, int y, int width, int height, int u, int v, int hoveredVOffset, #if MC_VER <= MC_1_21_10 ResourceLocation textureResourceLocation, #else Identifier textureResourceLocation, #endif - int textureWidth, int textureHeight, OnPress pressAction, Component text) + int textureWidth, int textureHeight, #if MC_VER > MC_1_12_2 OnPress pressAction,#endif #if MC_VER <= MC_1_12_2 String #else Component #endif text) { - this(x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, pressAction, text, true); + this( + #if MC_VER <= MC_1_12_2 + id, + #endif + x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, + #if MC_VER > MC_1_12_2 + pressAction, + #endif + text, true + ); } public TexturedButtonWidget( - int x, int y, int width, int height, int u, int v, int hoveredVOffset, + #if MC_VER <= MC_1_12_2 int id ,#endif int x, int y, int width, int height, int u, int v, int hoveredVOffset, #if MC_VER <= MC_1_21_10 ResourceLocation textureResourceLocation, #else Identifier textureResourceLocation, - #endif - int textureWidth, int textureHeight, OnPress pressAction, Component text, - boolean renderBackground) + #endif + int textureWidth, int textureHeight, #if MC_VER > MC_1_12_2 OnPress pressAction,#endif #if MC_VER <= MC_1_12_2 String #else Component #endif text, boolean renderBackground) { - #if MC_VER < MC_1_20_2 + #if MC_VER < MC_1_20_2 && MC_VER > MC_1_12_2 super(x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, pressAction, text); #else + + #if MC_VER <= MC_1_12_2 + super(id, x, y, width, height, text); + #else // We don't pass in the text option since it will render (we normally pass it in for narration) super(x, y, width, height, Component.empty(), pressAction, DEFAULT_NARRATION); + #endif this.u = u; this.v = v; @@ -122,7 +143,27 @@ public class TexturedButtonWidget extends Button this.renderBackground = renderBackground; } - #if MC_VER < MC_1_20_2 + #if MC_VER <= MC_1_12_2 + @Override + public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) { + if (this.visible) { + //Render vanilla background + mc.getTextureManager().bindTexture(BUTTON_TEXTURES); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; + int i = this.getHoverState(this.hovered); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); + this.drawTexturedModalRect(this.x, this.y, 0, 46 + i * 20, this.width / 2, this.height); + this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height); + + //Render DH texture + mc.getTextureManager().bindTexture(textureResourceLocation); + drawModalRectWithCustomSizedTexture(this.x, this.y, this.u, (hoveredVOffset * (i - 1)), this.width, this.height, this.textureWidth, this.textureHeight); + } + } + #elif MC_VER < MC_1_20_2 #if MC_VER < MC_1_19_4 @Override public void renderButton(PoseStack matrices, int mouseX, int mouseY, float delta) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/config/ConfigGuiInfo.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/config/ConfigGuiInfo.java index ad29c4a0c..1d20765aa 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/config/ConfigGuiInfo.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/config/ConfigGuiInfo.java @@ -1,10 +1,17 @@ package com.seibel.distanthorizons.common.wrappers.gui.config; +import com.seibel.distanthorizons.common.wrappers.gui.OnPressed; import com.seibel.distanthorizons.core.config.gui.IConfigGuiInfo; import com.seibel.distanthorizons.core.config.types.AbstractConfigBase; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.util.text.ITextComponent; +#else import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.EditBox; import net.minecraft.network.chat.Component; +#endif import org.jetbrains.annotations.Nullable; import java.util.AbstractMap; @@ -23,11 +30,12 @@ public class ConfigGuiInfo implements IConfigGuiInfo * Used to display validation errors. * Null if no error is present. */ + @Nullable - public Component errorMessage; + public #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif errorMessage; - public BiFunction> tooltipFunction; + public BiFunction<#if MC_VER <= MC_1_12_2 GuiTextField #else EditBox #endif,#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif, Predicate> tooltipFunction; /** determines which options the button will show */ - public AbstractMap.SimpleEntry> buttonOptionMap; + public AbstractMap.SimpleEntry<#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif, Function> buttonOptionMap; } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java index d234b960c..54f0e3409 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java @@ -1,5 +1,5 @@ package com.seibel.distanthorizons.common.wrappers.gui.updater; - +#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.common.wrappers.gui.DhScreen; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; @@ -282,4 +282,5 @@ public class ChangelogScreen extends DhScreen } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java index 5fe7872e5..b87d3e01a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java @@ -1,5 +1,5 @@ package com.seibel.distanthorizons.common.wrappers.gui.updater; - +#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch; import com.seibel.distanthorizons.common.wrappers.gui.DhScreen; import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget; @@ -213,4 +213,5 @@ public class UpdateModScreen extends DhScreen Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Go to the parent screen } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/KeyedClientLevelManager.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/KeyedClientLevelManager.java index 0f0ecc4c3..0b2e20b6d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/KeyedClientLevelManager.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/KeyedClientLevelManager.java @@ -3,7 +3,11 @@ package com.seibel.distanthorizons.common.wrappers.level; import com.seibel.distanthorizons.core.level.IServerKeyedClientLevel; import com.seibel.distanthorizons.core.level.IKeyedClientLevelManager; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.multiplayer.WorldClient; +#else import net.minecraft.client.multiplayer.ClientLevel; +#endif import org.jetbrains.annotations.Nullable; public class KeyedClientLevelManager implements IKeyedClientLevelManager @@ -38,7 +42,7 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager @Override public IServerKeyedClientLevel setServerKeyedLevel(IClientLevelWrapper clientLevel, String serverKey, String levelKey) { - IServerKeyedClientLevel keyedLevel = new ServerKeyedClientLevelWrapper((ClientLevel) clientLevel.getWrappedMcObject(), serverKey, levelKey); + IServerKeyedClientLevel keyedLevel = new ServerKeyedClientLevelWrapper(#if MC_VER <= MC_1_12_2 (WorldClient) #else (ClientLevel) #endif clientLevel.getWrappedMcObject(), serverKey, levelKey); this.serverKeyedLevel = keyedLevel; this.enabled = true; return keyedLevel; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/ServerKeyedClientLevelWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/ServerKeyedClientLevelWrapper.java index f6c661be3..4d41e1004 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/ServerKeyedClientLevelWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/ServerKeyedClientLevelWrapper.java @@ -2,7 +2,11 @@ package com.seibel.distanthorizons.common.wrappers.level; import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper; import com.seibel.distanthorizons.core.level.IServerKeyedClientLevel; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.multiplayer.WorldClient; +#else import net.minecraft.client.multiplayer.ClientLevel; +#endif public class ServerKeyedClientLevelWrapper extends ClientLevelWrapper implements IServerKeyedClientLevel { @@ -18,7 +22,7 @@ public class ServerKeyedClientLevelWrapper extends ClientLevelWrapper implements // constructor // //=============// - public ServerKeyedClientLevelWrapper(ClientLevel level, String serverKey, String serverLevelKey) + public ServerKeyedClientLevelWrapper(#if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level, String serverKey, String serverLevelKey) { super(level); this.serverKey = serverKey; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java index 5227fbb3a..0e997a989 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java @@ -21,7 +21,6 @@ package com.seibel.distanthorizons.common.wrappers.minecraft; import java.io.File; -import com.mojang.blaze3d.platform.Window; import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper; import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure; import com.seibel.distanthorizons.core.render.glObject.GLProxy; @@ -35,19 +34,30 @@ import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos; import com.seibel.distanthorizons.core.pos.DhChunkPos; import com.seibel.distanthorizons.core.logging.DhLogger; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.crash.CrashReport; +import net.minecraft.profiler.Profiler; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.text.TextComponentString; +#else import net.minecraft.CrashReport; import net.minecraft.client.CloudStatus; -import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.player.LocalPlayer; import net.minecraft.core.BlockPos; import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.world.level.ChunkPos; +import com.mojang.blaze3d.platform.Window; +#endif import org.jetbrains.annotations.Nullable; -#if MC_VER < MC_1_19_2 +#if MC_VER < MC_1_19_2 && MC_VER > MC_1_12_2 import net.minecraft.network.chat.TextComponent; #endif @@ -56,7 +66,7 @@ import net.minecraft.network.chat.TextComponent; import net.minecraft.util.profiling.Profiler; #endif -#if MC_VER <= MC_1_21_10 +#if MC_VER <= MC_1_21_10 && MC_VER > MC_1_12_2 import net.minecraft.client.GraphicsStatus; #else #endif @@ -69,7 +79,7 @@ import net.minecraft.client.GraphicsStatus; public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecraftSharedWrapper { private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - private static final Minecraft MINECRAFT = Minecraft.getInstance(); + private static final Minecraft MINECRAFT = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif; public static final MinecraftClientWrapper INSTANCE = new MinecraftClientWrapper(); @@ -84,17 +94,17 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra //region @Override - public boolean hasSinglePlayerServer() { return MINECRAFT.hasSingleplayerServer(); } + public boolean hasSinglePlayerServer() { return MINECRAFT.#if MC_VER <= MC_1_12_2 isSingleplayer() #else hasSingleplayerServer() #endif; } @Override public boolean clientConnectedToDedicatedServer() { - return MINECRAFT.getCurrentServer() != null + return MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif != null && !this.hasSinglePlayerServer(); } @Override public boolean connectedToReplay() { - return MINECRAFT.getCurrentServer() == null + return MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif == null && !this.hasSinglePlayerServer() ; } @@ -107,8 +117,8 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra } else { - ServerData server = MINECRAFT.getCurrentServer(); - return (server != null) ? server.name : "NULL"; + ServerData server = MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif; + return (server != null) ? server.#if MC_VER <= MC_1_12_2 serverName #else name #endif : "NULL"; } } @Override @@ -120,15 +130,15 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra } else { - ServerData server = MINECRAFT.getCurrentServer(); - return (server != null) ? server.ip : "NA"; + ServerData server = MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif; + return (server != null) ? server.#if MC_VER <= MC_1_12_2 serverIP #else ip #endif : "NA"; } } @Override public String getCurrentServerVersion() { - ServerData server = MINECRAFT.getCurrentServer(); - return (server != null) ? server.version.getString() : "UNKOWN"; + ServerData server = MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif; + return (server != null) ? server.#if MC_VER <= MC_1_12_2 gameVersion #else version.getString() #endif : "UNKOWN"; } //endregion @@ -140,7 +150,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra //=================// //region - public LocalPlayer getPlayer() { return MINECRAFT.player; } + public #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif getPlayer() { return MINECRAFT.player; } @Override public boolean playerExists() { return MINECRAFT.player != null; } @@ -148,26 +158,28 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra @Override public DhBlockPos getPlayerBlockPos() { - LocalPlayer player = this.getPlayer(); + #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer(); if (player == null) { return new DhBlockPos(0, 0, 0); } - BlockPos playerPos = player.blockPosition(); + BlockPos playerPos = player.#if MC_VER <= MC_1_12_2 getPosition() #else blockPosition() #endif; return new DhBlockPos(playerPos.getX(), playerPos.getY(), playerPos.getZ()); } @Override public DhChunkPos getPlayerChunkPos() { - LocalPlayer player = this.getPlayer(); + #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer(); if (player == null) { return new DhChunkPos(0, 0); } - #if MC_VER < MC_1_17_1 + #if MC_VER <= MC_1_12_2 + ChunkPos playerPos = new ChunkPos(player.getPosition()); + #elif MC_VER < MC_1_17_1 ChunkPos playerPos = new ChunkPos(player.blockPosition()); #else ChunkPos playerPos = player.chunkPosition(); @@ -192,7 +204,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra @Nullable public IClientLevelWrapper getWrappedClientLevel(boolean bypassLevelKeyManager) { - ClientLevel level = MINECRAFT.level; + #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level = MINECRAFT.#if MC_VER <= MC_1_12_2 world #else level #endif; if (level == null) { return null; @@ -213,13 +225,15 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra @Override public void sendChatMessage(String string) { - LocalPlayer player = this.getPlayer(); + #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer(); if (player == null) { return; } - #if MC_VER < MC_1_19_2 + #if MC_VER <= MC_1_12_2 + player.sendMessage(new TextComponentString(string)); + #elif MC_VER < MC_1_19_2 player.sendMessage(new TextComponent(string), getPlayer().getUUID()); #elif MC_VER < MC_1_21_9 player.displayClientMessage(net.minecraft.network.chat.Component.translatable(string), /*isOverlay*/false); @@ -235,13 +249,15 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra @Override public void sendOverlayMessage(String string) { - LocalPlayer player = this.getPlayer(); + #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer(); if (player == null) { return; } - #if MC_VER < MC_1_19_2 + #if MC_VER <= MC_1_12_2 + MINECRAFT.ingameGUI.setOverlayMessage(string, /*animateColor*/false); + #elif MC_VER < MC_1_19_2 player.displayClientMessage(new TextComponent(string), /*isOverlay*/true); #else player.displayClientMessage(net.minecraft.network.chat.Component.translatable(string), /*isOverlay*/true); @@ -261,7 +277,9 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra { LOGGER.info("Disabling vanilla clouds... This is done to prevent vanilla clouds from rendering on top of Distant Horizons LODs."); - #if MC_VER <= MC_1_18_2 + #if MC_VER <= MC_1_12_2 + MINECRAFT.gameSettings.clouds = 0; + #elif MC_VER <= MC_1_18_2 MINECRAFT.options.renderClouds = CloudStatus.OFF; #else MINECRAFT.options.cloudStatus().set(CloudStatus.OFF); @@ -282,8 +300,9 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra public void disableFabulousTransparency() { String reasoning = "This is done to fix vanilla chunks (specifically water blocks) not fading into Distant Horizons LODs when DH's 'Vanilla Fade' option is enabled."; - - #if MC_VER <= MC_1_18_2 + #if MC_VER <= MC_1_12_2 + // fabulous graphics was added in MC 1.16 + #elif MC_VER <= MC_1_18_2 LOGGER.info("Disabling fabulous graphics... "+reasoning); GraphicsStatus oldGraphicsStatus = MINECRAFT.options.graphicsMode; @@ -319,6 +338,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra * no override and not included in {@link IMinecraftClientWrapper} * since this would only be used in common/client, not core. */ + #if MC_VER > MC_1_12_2 public #if MC_VER < MC_1_21_9 long #else Window @@ -332,12 +352,15 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra return MINECRAFT.getWindow(); #endif } + #endif @Override public IProfilerWrapper getProfiler() { - ProfilerFiller profiler; - #if MC_VER < MC_1_21_3 + #if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif profiler; + #if MC_VER <= MC_1_12_2 + profiler = MINECRAFT.profiler; + #elif MC_VER < MC_1_21_3 profiler = MINECRAFT.getProfiler(); #else profiler = Profiler.get(); @@ -360,7 +383,9 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra { LOGGER.fatal(ModInfo.READABLE_NAME + " had the following error: [" + errorMessage + "]. Crashing Minecraft...", exception); CrashReport report = new CrashReport(errorMessage, exception); - #if MC_VER < MC_1_20_4 + #if MC_VER <= MC_1_12_2 + MINECRAFT.crashed(report); + #elif MC_VER < MC_1_20_4 Minecraft.crash(report); #else MINECRAFT.delayCrash(report); @@ -368,7 +393,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra } @Override - public void executeOnRenderThread(Runnable runnable) { MINECRAFT.execute(runnable); } + public void executeOnRenderThread(Runnable runnable) { MINECRAFT.#if MC_VER <= MC_1_12_2 addScheduledTask #else execute #endif(runnable); } //endregion @@ -380,7 +405,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra //region @Override - public Object getOptionsObject() { return MINECRAFT.options; } + public Object getOptionsObject() { return MINECRAFT.#if MC_VER <= MC_1_12_2 gameSettings #else options #endif; } //endregion @@ -395,19 +420,23 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra public boolean isDedicatedServer() { return false; } @Override - public File getInstallationDirectory() { return MINECRAFT.gameDirectory; } + public File getInstallationDirectory() { return MINECRAFT.#if MC_VER <= MC_1_12_2 gameDir #else gameDirectory #endif; } @Override public int getPlayerCount() { // can be null if the server hasn't finished booting up yet - if (MINECRAFT.getSingleplayerServer() == null) + if (MINECRAFT.#if MC_VER <= MC_1_12_2 getIntegratedServer() #else getSingleplayerServer() #endif == null) { return 1; } else { + #if MC_VER <= MC_1_12_2 + return MINECRAFT.getIntegratedServer().getCurrentPlayerCount(); + #else return MINECRAFT.getSingleplayerServer().getPlayerCount(); + #endif } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftGLWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftGLWrapper.java index 02eeed0e3..00192d5c2 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftGLWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftGLWrapper.java @@ -19,7 +19,9 @@ package com.seibel.distanthorizons.common.wrappers.minecraft; -#if MC_VER < MC_1_21_5 +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.renderer.GlStateManager; +#elif MC_VER < MC_1_21_5 import com.mojang.blaze3d.platform.GlStateManager; #else import com.mojang.blaze3d.opengl.GlStateManager; @@ -72,14 +74,18 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper public void enableScissorTest() { GL32.glEnable(GL32.GL_SCISSOR_TEST); + #if MC_VER > MC_1_12_2 GlStateManager._enableScissorTest(); + #endif } /** @see GL32#GL_SCISSOR_TEST */ @Override public void disableScissorTest() { GL32.glDisable(GL32.GL_SCISSOR_TEST); - GlStateManager._disableScissorTest(); + #if MC_VER > MC_1_12_2 + GlStateManager._disableScissorTest(); + #endif } @@ -98,14 +104,22 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper public void enableDepthTest() { GL32.glEnable(GL32.GL_DEPTH_TEST); + #if MC_VER <= MC_1_12_2 + GlStateManager.enableDepth(); + #else GlStateManager._enableDepthTest(); + #endif } /** @see GL32#GL_DEPTH_TEST */ @Override public void disableDepthTest() { GL32.glDisable(GL32.GL_DEPTH_TEST); + #if MC_VER <= MC_1_12_2 + GlStateManager.disableDepth(); + #else GlStateManager._disableDepthTest(); + #endif } /** @see GL32#glDepthFunc(int) */ @@ -113,7 +127,11 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper public void glDepthFunc(int func) { GL32.glDepthFunc(func); + #if MC_VER <= MC_1_12_2 + GlStateManager.depthFunc(func); + #else GlStateManager._depthFunc(func); + #endif } /** @see GL32#glDepthMask(boolean) */ @@ -121,14 +139,22 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper public void enableDepthMask() { GL32.glDepthMask(true); - GlStateManager._depthMask(true); + #if MC_VER <= MC_1_12_2 + GlStateManager.depthMask(true); + #else + GlStateManager._depthMask(true); + #endif } /** @see GL32#glDepthMask(boolean) */ @Override public void disableDepthMask() { GL32.glDepthMask(false); + #if MC_VER <= MC_1_12_2 + GlStateManager.depthMask(false); + #else GlStateManager._depthMask(false); + #endif } @@ -139,14 +165,22 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper public void enableBlend() { GL32.glEnable(GL32.GL_BLEND); + #if MC_VER <= MC_1_12_2 + GlStateManager.enableBlend(); + #else GlStateManager._enableBlend(); + #endif } /** @see GL32#GL_BLEND */ @Override public void disableBlend() { GL32.glDisable(GL32.GL_BLEND); + #if MC_VER <= MC_1_12_2 + GlStateManager.disableBlend(); + #else GlStateManager._disableBlend(); + #endif } /** @see GL32#glBlendFunc */ @@ -154,8 +188,9 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper public void glBlendFunc(int sfactor, int dfactor) { GL32.glBlendFunc(sfactor, dfactor); - - #if MC_VER < MC_1_21_5 + #if MC_VER <= MC_1_12_2 + GlStateManager.blendFunc(sfactor, dfactor); + #elif MC_VER < MC_1_21_5 GlStateManager._blendFunc(sfactor, dfactor); #endif } @@ -164,7 +199,11 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper public void glBlendFuncSeparate(int sfactorRGB, int dfactorRGB, int sfactorAlpha, int dfactorAlpha) { GL32.glBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); - GlStateManager._blendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); + #if MC_VER <= MC_1_12_2 + GlStateManager.tryBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); + #else + GlStateManager._blendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); + #endif } @@ -175,7 +214,9 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper public void glBindFramebuffer(int target, int framebuffer) { GL32.glBindFramebuffer(target, framebuffer); - GlStateManager._glBindFramebuffer(target, framebuffer); + #if MC_VER > MC_1_12_2 + GlStateManager._glBindFramebuffer(target, framebuffer); + #endif } @@ -222,14 +263,22 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper public void enableFaceCulling() { GL32.glEnable(GL32.GL_CULL_FACE); - GlStateManager._enableCull(); + #if MC_VER <= MC_1_12_2 + GlStateManager.enableCull(); + #else + GlStateManager._enableCull(); + #endif } /** @see GL32#GL_CULL_FACE */ @Override public void disableFaceCulling() { GL32.glDisable(GL32.GL_CULL_FACE); - GlStateManager._disableCull(); + #if MC_VER <= MC_1_12_2 + GlStateManager.disableCull(); + #else + GlStateManager._disableCull(); + #endif } @@ -237,17 +286,35 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper /** @see GL32#glGenTextures() */ @Override - public int glGenTextures() { return GlStateManager._genTexture(); } + public int glGenTextures() + { + #if MC_VER <= MC_1_12_2 + return GlStateManager.generateTexture(); + #else + return GlStateManager._genTexture(); + #endif + } /** @see GL32#glDeleteTextures(int) */ @Override - public void glDeleteTextures(int texture) { GlStateManager._deleteTexture(texture); } + public void glDeleteTextures(int texture) + { + #if MC_VER <= MC_1_12_2 + GlStateManager.deleteTexture(texture); + #else + GlStateManager._deleteTexture(texture); + #endif + } /** @see GL32#glActiveTexture(int) */ @Override public void glActiveTexture(int textureId) - { + { GL32.glActiveTexture(textureId); + #if MC_VER <= MC_1_12_2 + GlStateManager.setActiveTexture(textureId); + #else GlStateManager._activeTexture(textureId); + #endif } @Override public int getActiveTexture() { return GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D); } @@ -260,7 +327,11 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper public void glBindTexture(int texture) { GL32.glBindTexture(GL32.GL_TEXTURE_2D, texture); + #if MC_VER <= MC_1_12_2 + GlStateManager.bindTexture(texture); + #else GlStateManager._bindTexture(texture); + #endif } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java index f038fffa4..d09fa4b9f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java @@ -23,8 +23,6 @@ import java.awt.Color; import java.lang.invoke.MethodHandles; import java.util.concurrent.ConcurrentHashMap; -import com.mojang.blaze3d.pipeline.RenderTarget; -import com.mojang.blaze3d.platform.NativeImage; import com.seibel.distanthorizons.api.enums.config.EDhApiLodShading; import com.seibel.distanthorizons.common.wrappers.McObjectConverter; import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper; @@ -59,6 +57,14 @@ import com.seibel.distanthorizons.core.util.math.Vec3d; import com.seibel.distanthorizons.core.util.math.Vec3f; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.MobEffects; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fluids.IFluidBlock; +#else import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; @@ -66,11 +72,17 @@ import net.minecraft.core.Direction; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.phys.Vec3; +import com.mojang.blaze3d.pipeline.RenderTarget; +import com.mojang.blaze3d.platform.NativeImage; +#endif + import com.seibel.distanthorizons.core.logging.DhLogger; import org.jetbrains.annotations.NotNull; import org.joml.Vector4f; -#if MC_VER < MC_1_17_1 +#if MC_VER <= MC_1_12_2 +import org.lwjgl.opengl.GL15; +#elif MC_VER < MC_1_17_1 import net.minecraft.tags.FluidTags; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.material.FluidState; @@ -98,7 +110,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper public static final MinecraftRenderWrapper INSTANCE = new MinecraftRenderWrapper(); private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - private static final Minecraft MC = Minecraft.getInstance(); + private static final Minecraft MC = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif; /** * In the case of immersive portals multiple levels may be active at once, causing conflicting lightmaps.
@@ -129,7 +141,10 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public Vec3f getLookAtVector() { - #if MC_VER <= MC_1_21_10 + #if MC_VER <= MC_1_12_2 + net.minecraft.util.math.Vec3d lookVector = (MC.getRenderViewEntity().getLook(MC.getRenderPartialTicks())); + return new Vec3f((float) lookVector.x, (float) lookVector.y, (float) lookVector.z); + #elif MC_VER <= MC_1_21_10 Camera camera = MC.gameRenderer.getMainCamera(); return new Vec3f(camera.getLookVector().x(), camera.getLookVector().y(), camera.getLookVector().z()); #else @@ -149,37 +164,48 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper { return false; } - else if (MC.player.getActiveEffectsMap() == null) + else if (MC.player.#if MC_VER <= MC_1_12_2 getActivePotionMap() #else getActiveEffectsMap() #endif == null) { return false; } else { + #if MC_VER <= MC_1_12_2 + return MC.player.getActivePotionEffect(MobEffects.BLINDNESS) != null; + #else return MC.player.getActiveEffectsMap().get(MobEffects.BLINDNESS) != null #if MC_VER >= MC_1_19_2 || MC.player.getActiveEffectsMap().get(MobEffects.DARKNESS) != null // Deep dark effect #endif ; + #endif } } @Override public Vec3d getCameraExactPosition() { + #if MC_VER <= MC_1_12_2 + RenderManager rm = MC.getRenderManager(); + return new Vec3d(rm.viewerPosX, rm.viewerPosY, rm.viewerPosZ); + #else Camera camera = MC.gameRenderer.getMainCamera(); #if MC_VER <= MC_1_21_10 Vec3 projectedView = camera.getPosition(); #else Vec3 projectedView = camera.position(); #endif - return new Vec3d(projectedView.x, projectedView.y, projectedView.z); + #endif + } @Override public float getPartialTickTime() { - #if MC_VER < MC_1_21_1 + #if MC_VER <= MC_1_12_2 + return MC.getRenderPartialTicks(); + #elif MC_VER < MC_1_21_1 return MC.getFrameTime(); #elif MC_VER < MC_1_21_3 return MC.getTimer().getRealtimeDeltaTicks(); @@ -272,11 +298,19 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public Color getSkyColor() { + #if MC_VER <= MC_1_12_2 + if (MC.world.provider.hasSkyLight()) + #else if (MC.level.dimensionType().hasSkyLight()) + #endif { #if MC_VER < MC_1_17_1 float frameTime = this.getPartialTickTime(); + #if MC_VER <= MC_1_12_2 + net.minecraft.util.math.Vec3d colorValues = MC.world.getSkyColor(MC.getRenderViewEntity(), frameTime); + #else Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getBlockPosition(), frameTime); + #endif return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z); #elif MC_VER < MC_1_21_3 float frameTime = this.getPartialTickTime(); @@ -298,13 +332,22 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper } @Override - public double getFov(float partialTicks) { return MC.gameRenderer.getFov(MC.gameRenderer.getMainCamera(), partialTicks, true); } + public double getFov(float partialTicks) + { + #if MC_VER <= MC_1_12_2 + return MC.entityRenderer.getFOVModifier(partialTicks, true); + #else + return MC.gameRenderer.getFov(MC.gameRenderer.getMainCamera(), partialTicks, true); + #endif + } /** Measured in chunks */ @Override public int getRenderDistance() { - #if MC_VER <= MC_1_17_1 + #if MC_VER <= MC_1_12_2 + return MC.gameSettings.renderDistanceChunks; + #elif MC_VER <= MC_1_17_1 return MC.options.renderDistance; #else return MC.options.getEffectiveRenderDistance(); @@ -314,14 +357,18 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public int getFrameLimit() { - #if MC_VER <= MC_1_18_2 + #if MC_VER <= MC_1_12_2 + return MC.gameSettings.limitFramerate; + #elif MC_VER <= MC_1_18_2 return MC.options.framerateLimit; #else return MC.options.framerateLimit().get(); #endif } + #if MC_VER > MC_1_12_2 protected RenderTarget getRenderTarget() { return MC.getMainRenderTarget(); } + #endif @Override public boolean mcRendersToFrameBuffer() @@ -352,7 +399,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper return this.finalLevelFrameBufferId; } - #if MC_VER < MC_1_21_5 + #if MC_VER <= MC_1_12_2 + return MC.getFramebuffer().framebufferObject; + #elif MC_VER < MC_1_21_5 return this.getRenderTarget().frameBufferId; #else // MC renders to a texture and then directly to the default FBO now @@ -367,7 +416,10 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public int getDepthTextureId() { - #if MC_VER < MC_1_21_5 + #if MC_VER <= MC_1_12_2 + //1.12.2 is using renderbuffer instead of framebuffer for depth texture + return -1; + #elif MC_VER < MC_1_21_5 return this.getRenderTarget().getDepthTextureId(); #else try @@ -397,7 +449,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public int getColorTextureId() { - #if MC_VER < MC_1_21_5 + #if MC_VER <= MC_1_12_2 + return MC.getFramebuffer().framebufferTexture; + #elif MC_VER < MC_1_21_5 return this.getRenderTarget().getColorTextureId(); #else try @@ -427,7 +481,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public int getTargetFramebufferViewportWidth() { - #if MC_VER < MC_1_21_9 + #if MC_VER <= MC_1_12_2 + return MC.getFramebuffer().framebufferWidth; + #elif MC_VER < MC_1_21_9 return this.getRenderTarget().viewWidth; #else return this.getRenderTarget().width; @@ -437,7 +493,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public int getTargetFramebufferViewportHeight() { - #if MC_VER < MC_1_21_9 + #if MC_VER <= MC_1_12_2 + return MC.getFramebuffer().framebufferHeight; + #elif MC_VER < MC_1_21_9 return this.getRenderTarget().viewHeight; #else return this.getRenderTarget().height; @@ -450,7 +508,11 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public boolean isFogStateSpecial() { - #if MC_VER < MC_1_17_1 + #if MC_VER <= MC_1_12_2 + BlockPos blockPos = new BlockPos(MC.getRenderViewEntity().getPositionEyes(MC.getRenderPartialTicks())); + IBlockState fluidState = MC.getRenderViewEntity().world.getBlockState(blockPos); + return this.playerHasBlindingEffect() || fluidState.getMaterial().isLiquid() || fluidState.getBlock() instanceof IFluidBlock; + #elif MC_VER < MC_1_17_1 Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera(); FluidState fluidState = camera.getFluidInCamera(); Entity entity = camera.getEntity(); @@ -468,6 +530,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper * It's better to use {@link MinecraftRenderWrapper#setLightmapId(int, IClientLevelWrapper)} if possible, * however old MC versions don't support it. */ + #if MC_VER > MC_1_12_2 public void updateLightmap(NativeImage lightPixels, IClientLevelWrapper level) { // Using ClientLevelWrapper as the key would be better, but we don't have a consistent way to create the same @@ -478,6 +541,8 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper LightMapWrapper wrapper = this.lightmapByDimensionType.computeIfAbsent(dimensionType, (dimType) -> new LightMapWrapper()); wrapper.uploadLightmap(lightPixels); } + #endif + public void setLightmapId(int tetxureId, IClientLevelWrapper level) { // Using ClientLevelWrapper as the key would be better, but we don't have a consistent way to create the same @@ -497,6 +562,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper { default: case AUTO: + #if MC_VER <= MC_1_12_2 + // 1.12.2 has no getShade, fall through to ENABLED + #else if (MC.level != null) { Direction mcDir = McObjectConverter.Convert(lodDirection); @@ -506,7 +574,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper { return 0.0f; } - + #endif case ENABLED: switch (lodDirection) { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftServerWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftServerWrapper.java index b9adca4ee..6012898f6 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftServerWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftServerWrapper.java @@ -39,7 +39,9 @@ public class MinecraftServerWrapper implements IMinecraftSharedWrapper throw new IllegalStateException("Trying to get Installation Direction before dedicated server completed initialization!"); } - #if MC_VER < MC_1_21_1 + #if MC_VER <= MC_1_12_2 + return this.dedicatedServer.getDataDirectory(); + #elif MC_VER < MC_1_21_1 return this.dedicatedServer.getServerDirectory(); #else return this.dedicatedServer.getServerDirectory().toFile(); @@ -54,7 +56,7 @@ public class MinecraftServerWrapper implements IMinecraftSharedWrapper throw new IllegalStateException("Trying to get player count before dedicated server completed initialization!"); } - return this.dedicatedServer.getPlayerCount(); + return this.dedicatedServer.#if MC_VER <= MC_1_12_2 getCurrentPlayerCount() #else getPlayerCount() #endif; } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/ProfilerWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/ProfilerWrapper.java index 3770e964f..9f15dbfaa 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/ProfilerWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/ProfilerWrapper.java @@ -21,7 +21,11 @@ package com.seibel.distanthorizons.common.wrappers.minecraft; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IProfilerWrapper; +#if MC_VER <= MC_1_12_2 +import net.minecraft.profiler.Profiler; +#else import net.minecraft.util.profiling.ProfilerFiller; +#endif /** * @author James Seibel @@ -29,21 +33,21 @@ import net.minecraft.util.profiling.ProfilerFiller; */ public class ProfilerWrapper implements IProfilerWrapper { - public ProfilerFiller profiler; + public #if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif profiler; - public ProfilerWrapper(ProfilerFiller newProfiler) { this.profiler = newProfiler; } + public ProfilerWrapper(#if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif newProfiler) { this.profiler = newProfiler; } /** starts a new section inside the currently running section */ @Override - public void push(String newSection) { this.profiler.push(newSection); } + public void push(String newSection) { this.profiler.#if MC_VER <= MC_1_12_2 startSection(newSection) #else push(newSection) #endif; } /** ends the currently running section and starts a new one */ @Override - public void popPush(String newSection) { this.profiler.popPush(newSection); } + public void popPush(String newSection) { this.profiler.#if MC_VER <= MC_1_12_2 endStartSection(newSection) #else popPush(newSection) #endif; } /** ends the currently running section */ @Override - public void pop() { this.profiler.pop(); } + public void pop() { this.profiler.#if MC_VER <= MC_1_12_2 endSection() #else pop() #endif; } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/IMixinServerPlayer.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/IMixinServerPlayer.java index 2e2783843..88b574c7c 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/IMixinServerPlayer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/IMixinServerPlayer.java @@ -1,12 +1,17 @@ package com.seibel.distanthorizons.common.wrappers.misc; +#if MC_VER <= MC_1_12_2 +import net.minecraft.world.WorldServer; +#else import net.minecraft.server.level.ServerLevel; +#endif + import org.jetbrains.annotations.Nullable; public interface IMixinServerPlayer { @Nullable - ServerLevel distantHorizons$getDimensionChangeDestination(); + #if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif distantHorizons$getDimensionChangeDestination(); #if MC_VER == MC_1_16_5 void distantHorizons$setDimensionChangeDestination(ServerLevel dimensionChangeDestination); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/LightMapWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/LightMapWrapper.java index 5569a5006..6f4d42c19 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/LightMapWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/LightMapWrapper.java @@ -19,7 +19,9 @@ package com.seibel.distanthorizons.common.wrappers.misc; +#if MC_VER > MC_1_12_2 import com.mojang.blaze3d.platform.NativeImage; +#endif import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftGLWrapper; @@ -38,7 +40,10 @@ public class LightMapWrapper implements ILightMapWrapper private static final DhLogger LOGGER = new DhLoggerBuilder().build(); private int textureId = 0; - + #if MC_VER <= MC_1_12_2 + private int lastTextureId = 0; + private int lastTextureUnit = GL32.GL_TEXTURE0; + #endif //==============// @@ -57,6 +62,7 @@ public class LightMapWrapper implements ILightMapWrapper //==================// //region + #if MC_VER > MC_1_12_2 public void uploadLightmap(NativeImage image) { #if MC_VER < MC_1_21_3 @@ -92,6 +98,7 @@ public class LightMapWrapper implements ILightMapWrapper throw new UnsupportedOperationException("setLightmapId should be used for MC versions after 1.21.3"); #endif } + #endif public void setLightmapId(int minecraftLightmapTextureId) { @@ -111,12 +118,27 @@ public class LightMapWrapper implements ILightMapWrapper @Override public void bind() { + #if MC_VER <= MC_1_12_2 + //1.12.2 If we don't bind MC texture back vanilla rendering will break + lastTextureUnit = GL32.glGetInteger(GL32.GL_ACTIVE_TEXTURE); GLMC.glActiveTexture(GL32.GL_TEXTURE0 + ILightMapWrapper.BOUND_INDEX); + lastTextureId = GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D); + #else + GLMC.glActiveTexture(GL32.GL_TEXTURE0 + ILightMapWrapper.BOUND_INDEX); + #endif GLMC.glBindTexture(this.textureId); } @Override - public void unbind() { GLMC.glBindTexture(0); } + public void unbind() + { + #if MC_VER <= MC_1_12_2 + GLMC.glBindTexture(lastTextureId); + GLMC.glActiveTexture(lastTextureUnit); + #else + GLMC.glBindTexture(0); + #endif + } //endregion diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/MutableBlockPosWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/MutableBlockPosWrapper.java index d8de52924..acd0276cd 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/MutableBlockPosWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/MutableBlockPosWrapper.java @@ -1,7 +1,11 @@ package com.seibel.distanthorizons.common.wrappers.misc; import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IMutableBlockPosWrapper; +#if MC_VER <= MC_1_12_2 +import net.minecraft.util.math.BlockPos; +#else import net.minecraft.core.BlockPos; +#endif public class MutableBlockPosWrapper implements IMutableBlockPosWrapper { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/ServerPlayerWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/ServerPlayerWrapper.java index 8677000ad..7fc168557 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/ServerPlayerWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/ServerPlayerWrapper.java @@ -6,23 +6,39 @@ import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper; import com.seibel.distanthorizons.core.util.math.Vec3d; +#if MC_VER <= MC_1_12_2 +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.WorldServer; +#else import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.ServerGamePacketListenerImpl; import net.minecraft.world.phys.Vec3; +#endif import java.net.SocketAddress; import java.util.concurrent.ConcurrentMap; +#if MC_VER <= MC_1_12_2 + +/** + * This wrapper transparently ensures that the underlying {@link EntityPlayerMP} is always valid, + * unless the player has disconnected. + */ +#else /** * This wrapper transparently ensures that the underlying {@link ServerPlayer} is always valid, * unless the player has disconnected. */ +#endif public class ServerPlayerWrapper implements IServerPlayerWrapper { - private static final ConcurrentMap serverPlayerWrapperMap = new MapMaker().weakKeys().weakValues().makeMap(); + private static final ConcurrentMap<#if MC_VER <= MC_1_12_2 NetHandlerPlayServer #else ServerGamePacketListenerImpl #endif , ServerPlayerWrapper> serverPlayerWrapperMap = new MapMaker().weakKeys().weakValues().makeMap(); - private final ServerGamePacketListenerImpl connection; + private final #if MC_VER <= MC_1_12_2 NetHandlerPlayServer #else ServerGamePacketListenerImpl #endif connection; @@ -30,10 +46,10 @@ public class ServerPlayerWrapper implements IServerPlayerWrapper // constructor // //=============// - public static ServerPlayerWrapper getWrapper(ServerPlayer serverPlayer) + public static ServerPlayerWrapper getWrapper(#if MC_VER <= MC_1_12_2 EntityPlayerMP #else ServerPlayer #endif serverPlayer) { return serverPlayerWrapperMap.computeIfAbsent(serverPlayer.connection, ignored -> new ServerPlayerWrapper(serverPlayer.connection)); } - private ServerPlayerWrapper(ServerGamePacketListenerImpl connection) { this.connection = connection; } + private ServerPlayerWrapper(#if MC_VER <= MC_1_12_2 NetHandlerPlayServer #else ServerGamePacketListenerImpl #endif connection) { this.connection = connection; } @@ -41,18 +57,29 @@ public class ServerPlayerWrapper implements IServerPlayerWrapper // getters // //=========// - private ServerPlayer getServerPlayer() { return this.connection.player; } + private #if MC_VER <= MC_1_12_2 EntityPlayerMP #else ServerPlayer #endif getServerPlayer() { return this.connection.player; } @Override - public String getName() { return this.getServerPlayer().getName().getString(); } + public String getName() { return this.getServerPlayer().getName()#if MC_VER > MC_1_12_2 .getString() #endif ; } @Override public IServerLevelWrapper getLevel() { - ServerLevel level = ((IMixinServerPlayer) this.getServerPlayer()).distantHorizons$getDimensionChangeDestination(); + #if MC_VER <= MC_1_12_2 + WorldServer level = null; + if (this.getServerPlayer() instanceof IMixinServerPlayer mixinPlayer) + { + level = mixinPlayer.distantHorizons$getDimensionChangeDestination(); + } + #else + ServerLevel level = ((IMixinServerPlayer) this.getServerPlayer()).distantHorizons$getDimensionChangeDestination(); + #endif if (level == null) { - #if MC_VER < MC_1_20_1 + #if MC_VER <= MC_1_12_2 + MinecraftServer server = this.getServerPlayer().getServer(); + level = (server != null) ? server.getWorld(this.getServerPlayer().dimension) : this.getServerPlayer().getServerWorld(); + #elif MC_VER < MC_1_20_1 level = this.getServerPlayer().getLevel(); #elif MC_VER < MC_1_21_6 level = this.getServerPlayer().serverLevel(); @@ -67,8 +94,13 @@ public class ServerPlayerWrapper implements IServerPlayerWrapper @Override public Vec3d getPosition() { + #if MC_VER <= MC_1_12_2 + BlockPos position = this.getServerPlayer().getPosition(); + return new Vec3d(position.getX(), position.getY(), position.getZ()); + #else Vec3 position = this.getServerPlayer().position(); return new Vec3d(position.x, position.y, position.z); + #endif } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java index 14d20b086..b3c3618d1 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java @@ -19,13 +19,21 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IDimensionTypeWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; +#if MC_VER <= MC_1_12_2 +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.WorldServer; +import net.minecraft.client.multiplayer.WorldClient; +#else import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.ChunkAccess; +#endif import com.seibel.distanthorizons.core.logging.DhLogger; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -39,13 +47,15 @@ import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; -#if MC_VER <= MC_1_20_4 +#if MC_VER <= MC_1_12_2 +#elif MC_VER <= MC_1_20_4 import net.minecraft.world.level.chunk.ChunkStatus; #else import net.minecraft.world.level.chunk.status.ChunkStatus; #endif -#if MC_VER < MC_1_21_3 +#if MC_VER <= MC_1_12_2 +#elif MC_VER < MC_1_21_3 import net.minecraft.world.phys.Vec3; #else import com.seibel.distanthorizons.core.util.ColorUtil; @@ -65,16 +75,16 @@ public class ClientLevelWrapper implements IClientLevelWrapper * where, upon world closure, some levels aren't shutdown/removed properly * and/or for servers were the level object isn't consistent */ - private static final Map> LEVEL_WRAPPER_REF_BY_CLIENT_LEVEL = Collections.synchronizedMap(new WeakHashMap<>()); + private static final Map<#if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif, WeakReference> LEVEL_WRAPPER_REF_BY_CLIENT_LEVEL = Collections.synchronizedMap(new WeakHashMap<>()); private static final IKeyedClientLevelManager KEYED_CLIENT_LEVEL_MANAGER = SingletonInjector.INSTANCE.get(IKeyedClientLevelManager.class); - private static final Minecraft MINECRAFT = Minecraft.getInstance(); + private static final Minecraft MINECRAFT = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif; - private final ClientLevel level; - private final ConcurrentHashMap blockColorCacheByBlockState = new ConcurrentHashMap<>(); + private final #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level; + private final ConcurrentHashMap<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, ClientBlockStateColorCache> blockColorCacheByBlockState = new ConcurrentHashMap<>(); /** cached method reference to reduce GC overhead */ - private final Function createCachedBlockColorCacheFunc = (blockState) -> new ClientBlockStateColorCache(blockState, this); + private final Function<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, ClientBlockStateColorCache> createCachedBlockColorCacheFunc = (blockState) -> new ClientBlockStateColorCache(blockState, this); private boolean cloudColorFailLogged = false; @@ -89,7 +99,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper //=============// //region - protected ClientLevelWrapper(ClientLevel level) { this.level = level; } + protected ClientLevelWrapper(#if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level) { this.level = level; } //endregion @@ -105,7 +115,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper * IE rendering. */ @Nullable - public static IClientLevelWrapper getWrapperIfDifferent(@Nullable IClientLevelWrapper levelWrapper, @NotNull ClientLevel level) + public static IClientLevelWrapper getWrapperIfDifferent(@Nullable IClientLevelWrapper levelWrapper, @NotNull #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level) { if (KEYED_CLIENT_LEVEL_MANAGER.isEnabled() && KEYED_CLIENT_LEVEL_MANAGER.getServerKeyedLevel() != levelWrapper) { @@ -123,10 +133,10 @@ public class ClientLevelWrapper implements IClientLevelWrapper } @Nullable - public static IClientLevelWrapper getWrapper(@NotNull ClientLevel level) { return getWrapper(level, false); } + public static IClientLevelWrapper getWrapper(@NotNull #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level) { return getWrapper(level, false); } @Nullable - public static IClientLevelWrapper getWrapper(@Nullable ClientLevel level, boolean bypassLevelKeyManager) + public static IClientLevelWrapper getWrapper(@Nullable #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level, boolean bypassLevelKeyManager) { if (!bypassLevelKeyManager) { @@ -177,19 +187,27 @@ public class ClientLevelWrapper implements IClientLevelWrapper try { // this method only makes sense if we are running a single-player server - if (MINECRAFT.getSingleplayerServer() == null) + if (MINECRAFT.#if MC_VER <= MC_1_12_2 getIntegratedServer() #else getSingleplayerServer() #endif == null) { return null; } - Iterable serverLevels = MINECRAFT.getSingleplayerServer().getAllLevels(); + #if MC_VER <= MC_1_12_2 + WorldServer[] serverLevels = MINECRAFT.getIntegratedServer().worlds; + #else + Iterable<#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif> serverLevels = MINECRAFT.getSingleplayerServer().getAllLevels(); + #endif // attempt to find the server level with the same dimension type // Note: this assumes only one level per dimension type, multiverse servers may not behave correctly ServerLevelWrapper foundLevelWrapper = null; - for (ServerLevel serverLevel : serverLevels) + for (#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif serverLevel : serverLevels) { + #if MC_VER <= MC_1_12_2 + if (serverLevel.provider.getDimension() == this.level.provider.getDimension()) + #else if (serverLevel.dimension() == this.level.dimension()) + #endif { foundLevelWrapper = ServerLevelWrapper.getWrapper(serverLevel); break; @@ -262,7 +280,9 @@ public class ClientLevelWrapper implements IClientLevelWrapper return this.dimensionTypeWrapper; } - #if MC_VER <= MC_1_21_10 + #if MC_VER <= MC_1_12_2 + this.dimensionTypeWrapper = DimensionTypeWrapper.getDimensionTypeWrapper(this.level.provider.getDimensionType()); + #elif MC_VER <= MC_1_21_10 this.dimensionTypeWrapper = DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType()); #else this.dimensionTypeWrapper = DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType(), this.getDimensionName()); @@ -281,8 +301,9 @@ public class ClientLevelWrapper implements IClientLevelWrapper return this.dimensionName; } - - #if MC_VER <= MC_1_21_10 + #if MC_VER <= MC_1_12_2 + this.dimensionName = this.level.provider.getDimensionType().getName(); + #elif MC_VER <= MC_1_21_10 this.dimensionName = this.level.dimension().location().toString(); #else this.dimensionName = this.level.dimension().identifier().toString(); @@ -291,7 +312,14 @@ public class ClientLevelWrapper implements IClientLevelWrapper } @Override - public long getHashedSeed() { return this.level.getBiomeManager().biomeZoomSeed; } + public long getHashedSeed() + { + #if MC_VER <= MC_1_12_2 + return this.level.getSeed(); + #else + return this.level.getBiomeManager().biomeZoomSeed; + #endif + } @Override public String getDhIdentifier() { return this.getHashedSeedEncoded() + "@" + this.getDimensionName(); } @@ -299,7 +327,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper @Override public EDhApiLevelType getLevelType() { return EDhApiLevelType.CLIENT_LEVEL; } - public ClientLevel getLevel() { return this.level; } + public #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif getLevel() { return this.level; } private Boolean dimHasCeiling = null; @Override @@ -312,8 +340,12 @@ public class ClientLevelWrapper implements IClientLevelWrapper return this.dimHasCeiling; } - + #if MC_VER <= MC_1_12_2 + // 1.12.2 has no hasCeiling() - only the nether has a ceiling in vanilla + this.dimHasCeiling = this.level.provider.isNether(); + #else this.dimHasCeiling = this.level.dimensionType().hasCeiling(); + #endif return this.dimHasCeiling; } @@ -328,7 +360,11 @@ public class ClientLevelWrapper implements IClientLevelWrapper return this.dimHasSkyLight; } + #if MC_VER <= MC_1_12_2 + this.dimHasSkyLight = this.level.provider.hasSkyLight(); + #else this.dimHasSkyLight = this.level.dimensionType().hasSkyLight(); + #endif return this.dimHasSkyLight; } @@ -370,7 +406,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper } @Override - public ClientLevel getWrappedMcObject() { return this.level; } + public #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif getWrappedMcObject() { return this.level; } @Override public void onUnload() @@ -419,10 +455,10 @@ public class ClientLevelWrapper implements IClientLevelWrapper public Color getCloudColor(float tickDelta) { #if MC_VER < MC_1_21_3 - Vec3 colorVec3 = null; + #if MC_VER <= MC_1_12_2 Vec3d #else Vec3 #endif colorVec3 = null; try { - colorVec3 = this.level.getCloudColor(tickDelta); + colorVec3 = this.level.#if MC_VER <= MC_1_12_2 getCloudColour #else getCloudColor #endif (tickDelta); return new Color((float)colorVec3.x, (float)colorVec3.y, (float)colorVec3.z); } catch (Exception e) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/DimensionTypeWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/DimensionTypeWrapper.java index 8a77a092e..1f5ce1b8b 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/DimensionTypeWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/DimensionTypeWrapper.java @@ -24,7 +24,11 @@ import java.util.concurrent.ConcurrentMap; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IDimensionTypeWrapper; +#if MC_VER <= MC_1_12_2 +import net.minecraft.world.DimensionType; +#else import net.minecraft.world.level.dimension.DimensionType; +#endif public class DimensionTypeWrapper implements IDimensionTypeWrapper { @@ -86,7 +90,9 @@ public class DimensionTypeWrapper implements IDimensionTypeWrapper } private static String determineName(DimensionType dimensionType) { - #if MC_VER <= MC_1_16_5 + #if MC_VER <= MC_1_12_2 + return dimensionType.getName(); + #elif MC_VER <= MC_1_16_5 // effectsLocation() is marked as client only, so using the backing field directly return dimensionType.effectsLocation.getPath(); #elif MC_VER <= MC_1_21_10 @@ -108,10 +114,26 @@ public class DimensionTypeWrapper implements IDimensionTypeWrapper public String getName() { return this.name; } @Override - public boolean hasCeiling() { return this.dimensionType.hasCeiling(); } + public boolean hasCeiling() + { + #if MC_VER <= MC_1_12_2 + // 1.12.2 has no hasCeiling() - only the nether has a ceiling in vanilla + return this.dimensionType.getId() == -1; + #else + return this.dimensionType.hasCeiling(); + #endif + } @Override - public boolean hasSkyLight() { return this.dimensionType.hasSkyLight(); } + public boolean hasSkyLight() + { + #if MC_VER <= MC_1_12_2 + // 1.12.2 DimensionType doesn't store hasSkyLight, it's in the WorldProvider instead + return this.dimensionType != DimensionType.NETHER; + #else + return this.dimensionType.hasSkyLight(); + #endif + } @Override public Object getWrappedMcObject() { return this.dimensionType; } @@ -120,7 +142,15 @@ public class DimensionTypeWrapper implements IDimensionTypeWrapper public boolean isTheEnd() { return this.getName().equalsIgnoreCase("the_end"); } @Override - public double getCoordinateScale() { return this.dimensionType.coordinateScale(); } + public double getCoordinateScale() + { + #if MC_VER <= MC_1_12_2 + // 1.12.2 DimensionType doesn't store coordinate scale, it's in the WorldProvider instead + return this.dimensionType == net.minecraft.world.DimensionType.NETHER ? 8.0 : 1.0; + #else + return this.dimensionType.coordinateScale(); + #endif + } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ServerLevelWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ServerLevelWrapper.java index bf548285d..31a5a964f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ServerLevelWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ServerLevelWrapper.java @@ -38,18 +38,24 @@ import com.seibel.distanthorizons.core.world.EWorldEnvironment; import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper; +#if MC_VER <= MC_1_12_2 + +#else import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.Level; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkSource; +#endif -#if MC_VER <= MC_1_20_4 +#if MC_VER <= MC_1_12_2 +#elif MC_VER <= MC_1_20_4 import net.minecraft.world.level.chunk.ChunkStatus; #else import net.minecraft.world.level.chunk.status.ChunkStatus; #endif import com.seibel.distanthorizons.core.logging.DhLogger; +import net.minecraft.world.WorldServer; import org.jetbrains.annotations.Nullable; public class ServerLevelWrapper implements IServerLevelWrapper @@ -59,9 +65,9 @@ public class ServerLevelWrapper implements IServerLevelWrapper * weak references are to prevent rare issues * where, upon world closure, some levels aren't shutdown/removed properly */ - private static final Map> LEVEL_WRAPPER_REF_BY_SERVER_LEVEL = Collections.synchronizedMap(new WeakHashMap<>()); + private static final Map<#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif, WeakReference> LEVEL_WRAPPER_REF_BY_SERVER_LEVEL = Collections.synchronizedMap(new WeakHashMap<>()); - private final ServerLevel level; + private final #if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif level; private IDhLevel dhLevel; /** @@ -76,7 +82,7 @@ public class ServerLevelWrapper implements IServerLevelWrapper // constructors // //==============// - public static ServerLevelWrapper getWrapper(ServerLevel level) + public static ServerLevelWrapper getWrapper(#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif level) { return LEVEL_WRAPPER_REF_BY_SERVER_LEVEL.compute(level, (newLevel, levelRef) -> { @@ -93,7 +99,7 @@ public class ServerLevelWrapper implements IServerLevelWrapper }).get(); } - public ServerLevelWrapper(ServerLevel level) + public ServerLevelWrapper(#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif level) { this.level = level; this.KeyedLevelDimensionName = this.createKeyedLevelDimensionName(); @@ -108,7 +114,9 @@ public class ServerLevelWrapper implements IServerLevelWrapper @Override public File getMcSaveFolder() { - #if MC_VER < MC_1_21_3 + #if MC_VER <= MC_1_12_2 + return new File(this.level.getChunkSaveLocation(), "data"); + #elif MC_VER < MC_1_21_3 return this.level.getChunkSource().getDataStorage().dataFolder; #else return this.level.getChunkSource().getDataStorage().dataFolder.toFile(); @@ -157,7 +165,9 @@ public class ServerLevelWrapper implements IServerLevelWrapper { // We use the overworld since it's the only dimension that is stored in the server root folder - #if MC_VER >= MC_1_21_3 + #if MC_VER <= MC_1_12_2 + return this.level.getMinecraftServer().getWorld(0).getSaveHandler().getWorldDirectory().getParentFile().getName(); + #elif MC_VER >= MC_1_21_3 return this.level.getServer().getLevel(Level.OVERWORLD).getChunkSource().getDataStorage().dataFolder.getParent().getFileName().toString(); #else // <= 1.21.3 return this.level.getServer().getLevel(Level.OVERWORLD).getChunkSource().getDataStorage().dataFolder.getParentFile().getName(); @@ -174,7 +184,9 @@ public class ServerLevelWrapper implements IServerLevelWrapper @Override public DimensionTypeWrapper getDimensionType() { - #if MC_VER <= MC_1_21_10 + #if MC_VER <= MC_1_12_2 + return DimensionTypeWrapper.getDimensionTypeWrapper(this.level.provider.getDimensionType()); + #elif MC_VER <= MC_1_21_10 return DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType()); #else return DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType(), this.getDimensionName()); @@ -184,7 +196,9 @@ public class ServerLevelWrapper implements IServerLevelWrapper @Override public String getDimensionName() { - #if MC_VER <= MC_1_21_10 + #if MC_VER <= MC_1_12_2 + return this.level.provider.getDimensionType().getName(); + #elif MC_VER <= MC_1_21_10 return this.level.dimension().location().toString(); #else return this.level.dimension().identifier().toString(); @@ -192,7 +206,14 @@ public class ServerLevelWrapper implements IServerLevelWrapper } @Override - public long getHashedSeed() { return this.level.getBiomeManager().biomeZoomSeed; } + public long getHashedSeed() + { + #if MC_VER <= MC_1_12_2 + return this.level.getSeed(); + #else + return this.level.getBiomeManager().biomeZoomSeed; + #endif + } @Override public String getDhIdentifier() { return this.getDimensionName(); } @@ -200,13 +221,28 @@ public class ServerLevelWrapper implements IServerLevelWrapper @Override public EDhApiLevelType getLevelType() { return EDhApiLevelType.SERVER_LEVEL; } - public ServerLevel getLevel() { return this.level; } + public #if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif getLevel() { return this.level; } @Override - public boolean hasCeiling() { return this.level.dimensionType().hasCeiling(); } + public boolean hasCeiling() + { + #if MC_VER <= MC_1_12_2 + // 1.12.2 has no hasCeiling() - only the nether has a ceiling in vanilla + return this.level.provider.isNether(); + #else + return this.level.dimensionType().hasCeiling(); + #endif + } @Override - public boolean hasSkyLight() { return this.level.dimensionType().hasSkyLight(); } + public boolean hasSkyLight() + { + #if MC_VER <= MC_1_12_2 + return this.level.provider.hasSkyLight(); + #else + return this.level.dimensionType().hasSkyLight(); + #endif + } @Override public int getMaxHeight() { return this.level.getHeight(); } @@ -224,7 +260,7 @@ public class ServerLevelWrapper implements IServerLevelWrapper } @Override - public ServerLevel getWrappedMcObject() { return this.level; } + public #if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif getWrappedMcObject() { return this.level; } @Override public void onUnload() { LEVEL_WRAPPER_REF_BY_SERVER_LEVEL.remove(this.level); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 3928866e3..4ae876413 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -25,7 +25,9 @@ import com.seibel.distanthorizons.api.DhApi; import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode; import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep; import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; +#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.common.wrappers.worldGeneration.chunkFileHandling.ChunkFileReader; +#endif import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.*; import com.seibel.distanthorizons.common.wrappers.worldGeneration.params.GlobalWorldGenParams; import com.seibel.distanthorizons.core.api.internal.SharedApi; @@ -55,18 +57,24 @@ import java.util.function.Consumer; import com.seibel.distanthorizons.coreapi.ModInfo; import org.jetbrains.annotations.NotNull; +#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepBiomes; import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepFeatures; import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepNoise; import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepStructureReference; import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepStructureStart; import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepSurface; +#endif +#if MC_VER <= MC_1_12_2 +#else import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.chunk.*; import net.minecraft.world.level.levelgen.DebugLevelSource; import net.minecraft.world.level.levelgen.FlatLevelSource; import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; +#endif + #if MC_VER <= MC_1_17_1 #elif MC_VER <= MC_1_19_2 @@ -78,8 +86,8 @@ import net.minecraft.core.registries.Registries; #else #endif - -#if MC_VER <= MC_1_20_4 +#if MC_VER <= MC_1_12_2 +#elif MC_VER <= MC_1_20_4 import net.minecraft.world.level.chunk.ChunkStatus; #else import net.minecraft.world.level.chunk.status.ChunkStatus; @@ -118,7 +126,10 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm private final IDhServerLevel dhServerLevel; public final InternalServerGenerator internalServerGenerator; + + #if MC_VER > MC_1_12_2 public final ChunkFileReader chunkFileReader; + #endif private final Timer chunkSaveIgnoreTimer = TimerUtil.CreateTimer("ChunkSaveIgnoreTimer"); @@ -127,12 +138,14 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm public final LinkedBlockingQueue generationEventQueue = new LinkedBlockingQueue<>(); public final GlobalWorldGenParams globalParams; + #if MC_VER > MC_1_12_2 public final StepStructureStart stepStructureStart = new StepStructureStart(this); public final StepStructureReference stepStructureReference = new StepStructureReference(this); public final StepBiomes stepBiomes = new StepBiomes(this); public final StepNoise stepNoise = new StepNoise(this); public final StepSurface stepSurface = new StepSurface(this); public final StepFeatures stepFeatures = new StepFeatures(this); + #endif public boolean unsafeThreadingRecorded = false; public boolean generatedChunkWithoutBiomeWarningLogged = false; @@ -186,6 +199,7 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm this.dhServerLevel = dhServerLevel; this.globalParams = new GlobalWorldGenParams(dhServerLevel); this.internalServerGenerator = new InternalServerGenerator(this.globalParams, this.dhServerLevel); + #if MC_VER > MC_1_12_2 this.chunkFileReader = new ChunkFileReader(this.globalParams); ChunkGenerator generator = ((ServerLevelWrapper) (dhServerLevel.getServerLevelWrapper())).getLevel().getChunkSource().getGenerator(); @@ -211,6 +225,7 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm LOGGER.warn("If it does crash, disable Distant Generation or set the Generation Mode to [" + EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY + "]."); } } + #endif } @@ -318,7 +333,9 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm //================// // variable setup // //================// - + #if MC_VER <= MC_1_12_2 + this.internalServerGenerator.generateChunksViaInternalServer(genEvent); + #else int borderSize = MAX_WORLD_GEN_CHUNK_BORDER_NEEDED; // genEvent.size - 1 converts the even width size to an odd number for MC compatability int refSize = (genEvent.widthInChunks - 1) + (borderSize * 2); @@ -564,6 +581,7 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm { LOGGER.error("Unexpected error during world gen for min chunk pos ["+genEvent.minPos+"], error: ["+e.getMessage()+"].", e); } + #endif } @@ -819,4 +837,4 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm -} \ No newline at end of file +} diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/ChunkPosGenStream.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/ChunkPosGenStream.java index a4e92348c..1ce3e7ee0 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/ChunkPosGenStream.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/ChunkPosGenStream.java @@ -1,6 +1,10 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration; +#if MC_VER <= MC_1_12_2 +import net.minecraft.util.math.ChunkPos; +#else import net.minecraft.world.level.ChunkPos; +#endif import java.util.Iterator; import java.util.Spliterator; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/GenerationEvent.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/GenerationEvent.java index 603318235..ded0c34aa 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/GenerationEvent.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/GenerationEvent.java @@ -25,7 +25,9 @@ import java.util.function.Consumer; import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode; import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep; +#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.common.wrappers.worldGeneration.params.ThreadWorldGenParams; +#endif import com.seibel.distanthorizons.core.util.ExceptionUtil; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.pos.DhChunkPos; @@ -43,7 +45,9 @@ public final class GenerationEvent /** can be used for troubleshooting */ public final int id; + #if MC_VER > MC_1_12_2 public final ThreadWorldGenParams threadedParam; + #endif public final DhChunkPos minPos; public final int widthInChunks; public final EDhApiWorldGenerationStep targetGenerationStep; @@ -67,7 +71,9 @@ public final class GenerationEvent this.widthInChunks = widthInChunks; this.targetGenerationStep = targetGenerationStep; this.generatorMode = generatorMode; + #if MC_VER > MC_1_12_2 this.threadedParam = ThreadWorldGenParams.getOrMake(generationGroup.globalParams); + #endif this.future = new CompletableFuture<>(); this.resultConsumer = resultConsumer; } @@ -168,4 +174,4 @@ public final class GenerationEvent -} \ No newline at end of file +} diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java index 1ef75ed45..abd35c733 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java @@ -22,6 +22,15 @@ import com.seibel.distanthorizons.core.util.TimerUtil; import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IC2meAccessor; import com.seibel.distanthorizons.coreapi.ModInfo; + + +#if MC_VER <= MC_1_12_2 +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.WorldServer; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.gen.ChunkProviderServer; +import net.minecraftforge.common.ForgeChunkManager; +#else import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.TicketType; @@ -33,6 +42,7 @@ import net.minecraft.world.level.chunk.ChunkStatus; #else import net.minecraft.world.level.chunk.status.ChunkStatus; #endif +#endif import java.util.*; import java.util.concurrent.CompletableFuture; @@ -62,7 +72,9 @@ public class InternalServerGenerator */ private static final int MS_TO_IGNORE_CHUNK_AFTER_COMPLETION = 5_000; - #if MC_VER < MC_1_21_5 + #if MC_VER <= MC_1_12_2 + public static ForgeChunkManager.Ticket DH_SERVER_GEN_TICKET = null; + #elif MC_VER < MC_1_21_5 private static final TicketType DH_SERVER_GEN_TICKET = TicketType.create("dh_server_gen_ticket", Comparator.comparingLong(ChunkPos::toLong)); #elif MC_VER < MC_1_21_9 private static final TicketType DH_SERVER_GEN_TICKET = new TicketType(/* timeout, 0 = disabled*/0L, /* persist */ false, TicketType.TicketUse.LOADING); @@ -105,14 +117,14 @@ public class InternalServerGenerator // create gen requests // //=====================// - ArrayList> getChunkFutureList = new ArrayList<>(); + ArrayList> getChunkFutureList = new ArrayList<>(); { Iterator chunkPosIterator = ChunkPosGenStream.getIterator(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.widthInChunks, 0); while (chunkPosIterator.hasNext()) { ChunkPos chunkPos = chunkPosIterator.next(); - CompletableFuture requestChunkFuture = + CompletableFuture<#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif> requestChunkFuture = this.requestChunkFromServerAsync(chunkPos) // log errors if necessary .whenCompleteAsync( @@ -155,8 +167,8 @@ public class InternalServerGenerator ArrayList chunkWrappers = new ArrayList<>(); for (int i = 0; i < getChunkFutureList.size(); i++) { - CompletableFuture getChunkFuture = getChunkFutureList.get(i); - ChunkAccess chunk = getChunkFuture.join(); + CompletableFuture<#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif> getChunkFuture = getChunkFutureList.get(i); + #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk = getChunkFuture.join(); if (chunk != null) { ChunkWrapper chunkWrapper = new ChunkWrapper(chunk, this.dhServerLevel.getLevelWrapper()); @@ -230,8 +242,50 @@ public class InternalServerGenerator LOGGER.warn(c2meWarning); } } - private CompletableFuture requestChunkFromServerAsync(ChunkPos chunkPos) + private CompletableFuture<#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif> requestChunkFromServerAsync(ChunkPos chunkPos) { + #if MC_VER <= MC_1_12_2 + WorldServer level = this.params.mcServerLevel; + + ChunkUpdateQueueManager updateManager = WorldChunkUpdateManager.INSTANCE.getByLevelWrapper(this.params.dhServerLevel.getServerLevelWrapper()); + if (updateManager != null) + { + updateManager.addPosToIgnore(new DhChunkPos(chunkPos.x, chunkPos.z)); + } + + CompletableFuture future = new CompletableFuture<>(); + level.getMinecraftServer().addScheduledTask(() -> + { + try + { + ChunkProviderServer provider = (ChunkProviderServer) level.getChunkProvider(); + + // load neighbours first so the target chunk can fully populate + for (int i = -1; i <= 1; i++) + { + for (int j = -1; j <= 1; j++) + { + if (i != 0 || j != 0) + { + if (!provider.isChunkGeneratedAt(chunkPos.x + i, chunkPos.z + j)) + { + provider.provideChunk(chunkPos.x + i, chunkPos.z + j); + } + } + } + } + + ForgeChunkManager.forceChunk(DH_SERVER_GEN_TICKET, chunkPos); + Chunk chunk = provider.provideChunk(chunkPos.x, chunkPos.z); + future.complete(chunk); + } + catch (Exception e) + { + future.completeExceptionally(e); + } + }); + return future; + #else return CompletableFuture.supplyAsync(() -> { ServerLevel level = this.params.mcServerLevel; @@ -242,7 +296,7 @@ public class InternalServerGenerator { updateManager.addPosToIgnore(new DhChunkPos(chunkPos.x, chunkPos.z)); } - + #if MC_VER < MC_1_21_5 int chunkLevel = 33; // 33 is equivalent to FULL Chunk level.getChunkSource().distanceManager.addTicket(DH_SERVER_GEN_TICKET, chunkPos, chunkLevel, chunkPos); @@ -272,13 +326,46 @@ public class InternalServerGenerator }, this.params.mcServerLevel.getChunkSource().chunkMap.mainThreadExecutor) .thenCompose(Function.identity()); + #endif } /** * mitigates out of memory issues in the vanilla chunk system.
* See: https://github.com/pop4959/Chunky/pull/383 */ - private void releaseChunkFromServer(ServerLevel level, IDhServerLevel dhLevel, ChunkPos chunkPos) + private void releaseChunkFromServer(#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif level, IDhServerLevel dhLevel, ChunkPos chunkPos) { + #if MC_VER <= MC_1_12_2 + level.getMinecraftServer().addScheduledTask(() -> + { + try + { + ForgeChunkManager.unforceChunk(DH_SERVER_GEN_TICKET, chunkPos); + + // give MC a few seconds to save the chunk before + // we can process update events there again + this.chunkSaveIgnoreTimer.schedule(new TimerTask() + { + @Override + public void run() + { + ChunkUpdateQueueManager updateManager = WorldChunkUpdateManager.INSTANCE.getByLevelWrapper(dhLevel.getServerLevelWrapper()); + if (updateManager != null) + { + updateManager.addPosToIgnore(new DhChunkPos(chunkPos.x, chunkPos.z)); + } + else + { + LOGGER.warn("Unable to find chunk update manager for server level ["+dhLevel+"], chunk updates may fail."); + } + } + }, MS_TO_IGNORE_CHUNK_AFTER_COMPLETION); + } + catch (Exception e) + { + LOGGER.warn("Failed to release chunk back to internal server. Error: ["+e.getMessage()+"]", e); + } + }); + #else level.getChunkSource().chunkMap.mainThreadExecutor.execute(() -> { try @@ -323,8 +410,9 @@ public class InternalServerGenerator LOGGER.warn("Failed to release chunk back to internal server. Error: ["+e.getMessage()+"]", e); } }); + #endif } -} +} \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/chunkFileHandling/ChunkCompoundTagParser.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/chunkFileHandling/ChunkCompoundTagParser.java index 4ffef0959..f771ac8ff 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/chunkFileHandling/ChunkCompoundTagParser.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/chunkFileHandling/ChunkCompoundTagParser.java @@ -19,6 +19,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.chunkFileHandling; +#if MC_VER > MC_1_12_2 import com.mojang.serialization.Codec; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; @@ -743,3 +744,4 @@ public class ChunkCompoundTagParser } +#endif diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/chunkFileHandling/ChunkFileReader.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/chunkFileHandling/ChunkFileReader.java index 3ea80ceec..63a4f072e 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/chunkFileHandling/ChunkFileReader.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/chunkFileHandling/ChunkFileReader.java @@ -1,5 +1,6 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.chunkFileHandling; +#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import com.seibel.distanthorizons.common.wrappers.worldGeneration.params.GlobalWorldGenParams; import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.RegionFileStorageExternalCache; @@ -341,3 +342,4 @@ public class ChunkFileReader implements AutoCloseable } +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/chunkFileHandling/CompoundTagUtil.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/chunkFileHandling/CompoundTagUtil.java index f175815c8..2dd870807 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/chunkFileHandling/CompoundTagUtil.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/chunkFileHandling/CompoundTagUtil.java @@ -1,5 +1,6 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.chunkFileHandling; +#if MC_VER > MC_1_12_2 import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import org.jetbrains.annotations.Nullable; @@ -146,3 +147,4 @@ public class CompoundTagUtil } +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java index dcd9a36a0..88dcd3c4a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java @@ -19,6 +19,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject; +#if MC_VER > MC_1_12_2 import java.lang.invoke.MethodHandles; import java.util.List; import java.util.concurrent.locks.ReentrantLock; @@ -470,4 +471,5 @@ public class DhLitWorldGenRegion extends WorldGenRegion return (k / j & 0xFF) << 16 | (l / j & 0xFF) << 8 | m / j & 0xFF; } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DummyLightEngine.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DummyLightEngine.java index 822e66d2c..069be50c8 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DummyLightEngine.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DummyLightEngine.java @@ -19,6 +19,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject; +#if MC_VER > MC_1_12_2 import net.minecraft.world.level.lighting.*; import org.jetbrains.annotations.Nullable; @@ -96,4 +97,5 @@ public class DummyLightEngine extends LevelLightEngine public int getMaxLightSection() { throw new UnsupportedOperationException("This should never be used!"); } #endif -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/LightGetterAdaptor.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/LightGetterAdaptor.java index c6032ea00..ebe77cbe8 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/LightGetterAdaptor.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/LightGetterAdaptor.java @@ -19,6 +19,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject; +#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector; import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IStarlightAccessor; @@ -79,4 +80,5 @@ public class LightGetterAdaptor implements LightChunkGetter return heightGetter; } #endif -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java index d7b2df37d..498c5a0f7 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java @@ -1,5 +1,6 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject; +#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.common.wrappers.worldGeneration.chunkFileHandling.ChunkFileReader; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import net.minecraft.nbt.CompoundTag; @@ -245,3 +246,4 @@ public class RegionFileStorageExternalCache implements AutoCloseable } } +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/params/GlobalWorldGenParams.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/params/GlobalWorldGenParams.java index 2f5b729d0..9ebec01c4 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/params/GlobalWorldGenParams.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/params/GlobalWorldGenParams.java @@ -19,10 +19,17 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.params; -import com.mojang.datafixers.DataFixer; import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; import com.seibel.distanthorizons.core.level.IDhServerLevel; + +#if MC_VER <= MC_1_12_2 +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.datafix.DataFixer; +import net.minecraft.world.WorldServer; +import net.minecraft.world.gen.IChunkGenerator; +#else +import com.mojang.datafixers.DataFixer; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.server.MinecraftServer; @@ -56,30 +63,39 @@ import net.minecraft.world.level.levelgen.WorldGenSettings; #else import net.minecraft.world.level.levelgen.WorldOptions; #endif +#endif +#if MC_VER > MC_1_12_2 /** * Handles parameters that are relevant for the entire MC world. * * @see ThreadWorldGenParams */ +#endif + public final class GlobalWorldGenParams { - public final ChunkGenerator generator; + public final #if MC_VER <= MC_1_12_2 IChunkGenerator #else ChunkGenerator #endif generator; public final IDhServerLevel dhServerLevel; - public final ServerLevel mcServerLevel; + public final #if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif mcServerLevel; + #if MC_VER > MC_1_12_2 public final Registry biomes; public final RegistryAccess registry; + #endif + public final long worldSeed; public final DataFixer dataFixer; - #if MC_VER < MC_1_19_2 + #if MC_VER <= MC_1_12_2 + #elif MC_VER < MC_1_19_2 public final StructureManager structures; #else public final StructureTemplateManager structures; public final RandomState randomState; #endif - #if MC_VER < MC_1_19_4 + #if MC_VER <= MC_1_12_2 + #elif MC_VER < MC_1_19_4 public final WorldGenSettings worldGenSettings; #else public final WorldOptions worldOptions; @@ -99,13 +115,17 @@ public final class GlobalWorldGenParams public GlobalWorldGenParams(IDhServerLevel dhServerLevel) { this.dhServerLevel = dhServerLevel; - this.mcServerLevel = ((ServerLevelWrapper) dhServerLevel.getServerLevelWrapper()).getWrappedMcObject(); - MinecraftServer server = this.mcServerLevel.getServer(); + + MinecraftServer server = this.mcServerLevel.#if MC_VER <= MC_1_12_2 getMinecraftServer() #else getServer() #endif; + #if MC_VER > MC_1_12_2 WorldData worldData = server.getWorldData(); this.registry = server.registryAccess(); + #endif - #if MC_VER < MC_1_19_4 + #if MC_VER <= MC_1_12_2 + this.worldSeed = mcServerLevel.getSeed(); + #elif MC_VER < MC_1_19_4 this.worldGenSettings = worldData.worldGenSettings(); this.biomes = registry.registryOrThrow(Registry.BIOME_REGISTRY); this.worldSeed = worldGenSettings.seed(); @@ -119,15 +139,24 @@ public final class GlobalWorldGenParams this.worldSeed = this.worldOptions.seed(); #endif + #if MC_VER >= MC_1_18_2 this.biomeManager = new BiomeManager(this.mcServerLevel, BiomeManager.obfuscateSeed(this.worldSeed)); this.chunkScanner = this.mcServerLevel.getChunkSource().chunkScanner(); #endif + #if MC_VER <= MC_1_12_2 + this.generator = this.mcServerLevel.getChunkProvider().chunkGenerator; + #else this.structures = server.getStructureManager(); this.generator = this.mcServerLevel.getChunkSource().getGenerator(); - this.dataFixer = server.getFixerUpper(); + #endif + #if MC_VER <= MC_1_12_2 + this.dataFixer = server != null ? server.getDataFixer() : null; + #else + this.dataFixer = server.getFixerUpper(); + #endif #if MC_VER >= MC_1_19_2 this.randomState = this.mcServerLevel.getChunkSource().randomState(); #endif diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/params/ThreadWorldGenParams.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/params/ThreadWorldGenParams.java index 00944a550..44f8468bd 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/params/ThreadWorldGenParams.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/params/ThreadWorldGenParams.java @@ -20,6 +20,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.params; +#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.WorldGenStructFeatManager; import net.minecraft.server.level.ServerLevel; @@ -121,4 +122,5 @@ public final class ThreadWorldGenParams -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/AbstractWorldGenStep.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/AbstractWorldGenStep.java index 4cf169062..161062d42 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/AbstractWorldGenStep.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/AbstractWorldGenStep.java @@ -1,5 +1,6 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.step; +#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import com.seibel.distanthorizons.common.wrappers.worldGeneration.params.ThreadWorldGenParams; import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.DhLitWorldGenRegion; @@ -52,3 +53,4 @@ public abstract class AbstractWorldGenStep } +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepBiomes.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepBiomes.java index 411d95be7..b4714115e 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepBiomes.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepBiomes.java @@ -19,6 +19,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.step; +#if MC_VER > MC_1_12_2 import java.util.ArrayList; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; @@ -114,4 +115,5 @@ public final class StepBiomes extends AbstractWorldGenStep } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepFeatures.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepFeatures.java index 936f99b4b..b759ae4ce 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepFeatures.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepFeatures.java @@ -19,6 +19,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.step; +#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment; import com.seibel.distanthorizons.common.wrappers.worldGeneration.params.ThreadWorldGenParams; @@ -118,4 +119,5 @@ public final class StepFeatures extends AbstractWorldGenStep } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepNoise.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepNoise.java index fd3b4677f..3bf62282f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepNoise.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepNoise.java @@ -19,6 +19,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.step; +#if MC_VER > MC_1_12_2 import java.util.ArrayList; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; @@ -106,4 +107,5 @@ public final class StepNoise extends AbstractWorldGenStep } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureReference.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureReference.java index 5fd9e7dfc..3e6bbd8ed 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureReference.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureReference.java @@ -19,6 +19,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.step; +#if MC_VER > MC_1_12_2 import java.util.ArrayList; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; @@ -72,4 +73,5 @@ public final class StepStructureReference extends AbstractWorldGenStep } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureStart.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureStart.java index ef70ea69b..1208bfa9f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureStart.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureStart.java @@ -19,6 +19,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.step; +#if MC_VER > MC_1_12_2 import java.util.ArrayList; import java.util.concurrent.locks.ReentrantLock; @@ -142,4 +143,5 @@ public final class StepStructureStart extends AbstractWorldGenStep } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepSurface.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepSurface.java index 839723999..316785d1e 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepSurface.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepSurface.java @@ -19,6 +19,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.step; +#if MC_VER > MC_1_12_2 import java.util.ArrayList; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; @@ -81,4 +82,5 @@ public final class StepSurface extends AbstractWorldGenStep -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index b32afe12d..51b30aacf 100644 --- a/settings.gradle +++ b/settings.gradle @@ -41,6 +41,7 @@ pluginManagement { maven { url = "https://maven.wagyourtail.xyz/snapshots" } + mavenCentral() gradlePluginPortal() From 8991338be164c0da16587899a9d8961caa91bb58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Sun, 15 Mar 2026 15:42:08 +0100 Subject: [PATCH 03/68] [1.12.2] add support for 3.0.0b --- build.gradle | 5 +- cleanroom/build.gradle | 51 +-- .../cleanroom/CleanroomClientProxy.java | 10 +- .../cleanroom/CleanroomMain.java | 24 +- .../cleanroom/CleanroomServerProxy.java | 36 ++- .../common/MixinChunkProviderServer.java | 26 -- .../shaders/apply/blaze/frag.fsh | 27 ++ .../shaders/apply/blaze/vert.vsh | 15 + .../shaders/copy/blaze/frag.fsh | 13 + .../shaders/copy/blaze/vert.vsh | 12 + .../shaders/debug/blaze/frag.fsh | 14 + .../shaders/debug/blaze/vert.vsh | 14 + .../shaders/debug/gl}/frag.frag | 0 .../shaders/debug/gl}/vert.vert | 0 .../shaders/fade/blaze/dh_fade.fsh | 67 ++++ .../shaders/fade/blaze/vanilla_fade.fsh | 95 ++++++ .../shaders/fade/blaze/vert.vsh | 15 + .../shaders/fade/gl}/apply.frag | 0 .../shaders/fade/gl}/dhFade.frag | 0 .../shaders/fade/gl}/vanillaFade.frag | 0 .../shaders/fog/blaze/frag.fsh | 299 ++++++++++++++++++ .../shaders/fog/blaze/vert.vsh} | 0 .../shaders/fog/gl}/apply.frag | 0 .../distanthorizons/shaders/fog/gl}/fog.frag | 0 .../shaders/generic/blaze/frag.fsh} | 0 .../shaders/generic/blaze/vert.vsh | 101 ++++++ .../shaders/generic/gl/direct}/frag.frag | 0 .../shaders/generic/gl}/direct/vert.vert | 0 .../shaders/generic/gl/instanced/frag.frag | 10 + .../shaders/generic/gl}/instanced/vert.vert | 0 .../shaders/lod/blaze/frag.fsh | 125 ++++++++ .../shaders/lod/blaze/vert.vsh | 81 +++++ .../shaders/shared/gl}/apply.frag | 0 .../shaders/shared/gl}/flat_shaded.frag | 0 .../shaders/shared/gl/quadApply.vert | 15 + .../shaders/shared/gl}/standard.vert | 2 +- .../shaders/ssao/blaze/apply.fsh | 86 +++++ .../shaders/ssao/blaze/frag.fsh | 137 ++++++++ .../shaders/ssao/blaze/vert.vsh | 15 + .../distanthorizons/shaders/ssao/gl}/ao.frag | 0 .../shaders/ssao/gl}/apply.frag | 0 .../shaders/test/blaze/frag.fsh | 10 + .../shaders/test/blaze/vert.vsh | 13 + .../shaders/test/gl}/frag.frag | 0 .../shaders/test/gl}/vert.vert | 0 .../distanthorizons.default.mixin.json | 4 +- cleanroom/src/main/resources/mcmod.info | 12 + cleanroom/src/main/resources/pack.mcmeta | 6 + .../main/resources/shaders/noise/noise.frag | 74 ----- .../src/main/resources/shaders/test/dark.frag | 9 - common/build.gradle | 2 +- .../common/AbstractModInitializer.java | 12 +- .../common/AbstractPluginPacketSender.java | 6 +- .../common/commands/CommandInitializer.java | 82 ++++- .../common/commands/ConfigCommand.java | 88 +++++- .../common/commands/CrashCommand.java | 52 ++- .../common/commands/DebugCommand.java | 39 ++- .../common/commands/PregenCommand.java | 135 +++++++- .../commonMixins/MixinChunkMapCommon.java | 2 +- .../openGl/GlDhTerrainShaderProgram.java | 12 +- .../common/wrappers/WrapperFactory.java | 14 +- .../wrappers/block/BlockStateWrapper.java | 4 +- .../block/ClientBlockStateColorCache.java | 15 +- .../common/wrappers/gui/ClassicConfigGUI.java | 3 +- .../wrappers/gui/config/ConfigGuiInfo.java | 2 +- .../minecraft/MinecraftClientWrapper.java | 4 +- .../common/wrappers/misc/LightMapWrapper.java | 35 +- .../wrappers/world/ClientLevelWrapper.java | 5 +- .../wrappers/world/ServerLevelWrapper.java | 3 +- .../BatchGenerationEnvironment.java | 18 +- .../InternalServerGenerator.java | 11 +- .../WorldGenStructFeatManager.java | 2 + settings.gradle | 12 + 73 files changed, 1712 insertions(+), 269 deletions(-) delete mode 100644 cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/common/MixinChunkProviderServer.java create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/apply/blaze/frag.fsh create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/apply/blaze/vert.vsh create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/copy/blaze/frag.fsh create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/copy/blaze/vert.vsh create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/blaze/frag.fsh create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/blaze/vert.vsh rename cleanroom/src/main/resources/{shaders/debug => assets/distanthorizons/shaders/debug/gl}/frag.frag (100%) rename cleanroom/src/main/resources/{shaders/debug => assets/distanthorizons/shaders/debug/gl}/vert.vert (100%) create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/dh_fade.fsh create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/vanilla_fade.fsh create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/vert.vsh rename cleanroom/src/main/resources/{shaders/fade => assets/distanthorizons/shaders/fade/gl}/apply.frag (100%) rename cleanroom/src/main/resources/{shaders/fade => assets/distanthorizons/shaders/fade/gl}/dhFade.frag (100%) rename cleanroom/src/main/resources/{shaders/fade => assets/distanthorizons/shaders/fade/gl}/vanillaFade.frag (100%) create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/blaze/frag.fsh rename cleanroom/src/main/resources/{shaders/quadApply.vert => assets/distanthorizons/shaders/fog/blaze/vert.vsh} (100%) rename cleanroom/src/main/resources/{shaders/fog => assets/distanthorizons/shaders/fog/gl}/apply.frag (100%) rename cleanroom/src/main/resources/{shaders/fog => assets/distanthorizons/shaders/fog/gl}/fog.frag (100%) rename cleanroom/src/main/resources/{shaders/genericObject/direct/frag.frag => assets/distanthorizons/shaders/generic/blaze/frag.fsh} (100%) create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/blaze/vert.vsh rename cleanroom/src/main/resources/{shaders/genericObject/instanced => assets/distanthorizons/shaders/generic/gl/direct}/frag.frag (100%) rename cleanroom/src/main/resources/{shaders/genericObject => assets/distanthorizons/shaders/generic/gl}/direct/vert.vert (100%) create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/instanced/frag.frag rename cleanroom/src/main/resources/{shaders/genericObject => assets/distanthorizons/shaders/generic/gl}/instanced/vert.vert (100%) create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/lod/blaze/frag.fsh create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/lod/blaze/vert.vsh rename cleanroom/src/main/resources/{shaders => assets/distanthorizons/shaders/shared/gl}/apply.frag (100%) rename cleanroom/src/main/resources/{shaders => assets/distanthorizons/shaders/shared/gl}/flat_shaded.frag (100%) create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/quadApply.vert rename cleanroom/src/main/resources/{shaders => assets/distanthorizons/shaders/shared/gl}/standard.vert (100%) create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/apply.fsh create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/frag.fsh create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/vert.vsh rename cleanroom/src/main/resources/{shaders/ssao => assets/distanthorizons/shaders/ssao/gl}/ao.frag (100%) rename cleanroom/src/main/resources/{shaders/ssao => assets/distanthorizons/shaders/ssao/gl}/apply.frag (100%) create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/test/blaze/frag.fsh create mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/test/blaze/vert.vsh rename cleanroom/src/main/resources/{shaders/test => assets/distanthorizons/shaders/test/gl}/frag.frag (100%) rename cleanroom/src/main/resources/{shaders/test => assets/distanthorizons/shaders/test/gl}/vert.vert (100%) create mode 100644 cleanroom/src/main/resources/mcmod.info create mode 100644 cleanroom/src/main/resources/pack.mcmeta delete mode 100644 cleanroom/src/main/resources/shaders/noise/noise.frag delete mode 100644 cleanroom/src/main/resources/shaders/test/dark.frag diff --git a/build.gradle b/build.gradle index ddef385ef..915988bd4 100644 --- a/build.gradle +++ b/build.gradle @@ -33,9 +33,11 @@ plugins { id "systems.manifold.manifold-gradle-plugin" version "0.0.2-alpha" // Architectury is used here only as a replacement for forge's own loom - id "dev.architectury.loom" version "1.0-SNAPSHOT" apply false + id "dev.architectury.loom" version "1.13-SNAPSHOT" apply false id 'xyz.wagyourtail.unimined' version '1.4.10-kappa' apply false + + id 'org.spongepowered.gradle.vanilla' version '0.2.1-20240507.024226-82' apply false } /** @@ -212,6 +214,7 @@ subprojects { p -> implementation.extendsFrom(forgeShadowMe) shadowMe.extendsFrom(forgeShadowMe) forgeRuntimeLibrary.extendsFrom(forgeShadowMe) + shadow.extendsFrom(forgeShadowMe) if (isMinecraftSubProject && p != project(":common")) { diff --git a/cleanroom/build.gradle b/cleanroom/build.gradle index acc649268..3191c347c 100644 --- a/cleanroom/build.gradle +++ b/cleanroom/build.gradle @@ -48,6 +48,8 @@ configurations { runtimeOnly.extendsFrom(modRuntimeOnly) } +String remapTaskName = "remapShadowJar" + unimined.minecraft { version "1.12.2" @@ -64,10 +66,12 @@ unimined.minecraft { runs.auth.username = "Developer" runs.all { systemProperty("crl.dev.mixin", "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json") - def extraArgs = '' - if (extraArgs != null && !extraArgs.trim().isEmpty()) { - jvmArgs += extraArgs.split { "\\s+" }.toList() - } + jvmArgs += ['-Xmx4G'] + jvmArgs += [ + '-XX:+UseZGC', + '-XX:-UseG1GC' + ] + jvmArgs += ['-XX:+ZGenerational'] println "Classpath size BEFORE: ${classpath.files.size()}" @@ -115,7 +119,8 @@ unimined.minecraft { defaultRemapJar = false - if (propertyBool('enable_shadow')) { + //propertyBool('enable_shadow') + if (true) { remap(tasks.shadowJar) { mixinRemap { enableBaseMixin() @@ -149,11 +154,11 @@ processResources { inputs.property 'mod_name', propertyString('mod_name') inputs.property 'mod_version', propertyString('mod_version') inputs.property 'mod_description', propertyString('mod_description') - inputs.property 'mod_authors', "${propertyStringList('mod_authors', ',').join(', ')}" + inputs.property 'mod_authors', propertyString('mod_authors').replace('[', '').replace(']', '').split(',').collect { it.trim().replace('"', '') }.join('", "') inputs.property 'mod_credits', propertyString('mod_credits') - inputs.property 'mod_url', propertyString('mod_url') + inputs.property 'mod_url', propertyString('mod_homepage') inputs.property 'mod_update_json', propertyString('mod_update_json') - inputs.property 'mod_logo_path', propertyString('mod_logo_path') + inputs.property 'mod_logo_path', "assets/distanthorizons/icon.png" def filterList = ['mcmod.info', 'pack.mcmeta'] @@ -163,11 +168,11 @@ processResources { 'mod_name': propertyString('mod_name'), 'mod_version': propertyString('mod_version'), 'mod_description': propertyString('mod_description'), - 'mod_authors': "${propertyStringList('mod_authors', ',').join(', ')}", + 'mod_authors': propertyString('mod_authors').replace('[', '').replace(']', '').split(',').collect { it.trim().replace('"', '') }.join('", "'), 'mod_credits': propertyString('mod_credits'), - 'mod_url': propertyString('mod_url'), + 'mod_url': propertyString('mod_homepage'), 'mod_update_json': propertyString('mod_update_json'), - 'mod_logo_path': propertyString('mod_logo_path'), + 'mod_logo_path': "assets/distanthorizons/icon.png", ) } @@ -186,8 +191,8 @@ sourceSets { } } } - -if (!propertyBool('enable_shadow')) { +//propertyBool('enable_shadow') +if (!true) { shadowJar.enabled = false } @@ -230,19 +235,25 @@ jar { attributes(attribute_map) } } - if (propertyBool('enable_shadow')) { - finalizedBy(tasks.named("remapShadowJar")) - } else { - finalizedBy(tasks.named("remapJar")) - } + finalizedBy(tasks.named(remapTaskName).get()) } shadowJar { - configurations = [project.configurations.shadow] + configurations = [project.configurations.shadowMe, project.configurations.shadowCommon] archiveClassifier = "shadow" + + manifest { + def attribute_map = [:] + attribute_map['ModType'] = "CRL" + attribute_map['MixinConfigs'] = "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json" + attribute_map['FMLCorePlugin'] = "com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin" + attribute_map['FMLCorePluginContainsFMLMod'] = true + attribute_map['FMLAT'] = "1_12_2_distanthorizons_at.cfg" + attributes(attribute_map) + } } -remapJar { +tasks.named(remapTaskName).configure { doFirst { logging.captureStandardOutput LogLevel.INFO } diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomClientProxy.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomClientProxy.java index 5e905be9a..a86188d6d 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomClientProxy.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomClientProxy.java @@ -49,6 +49,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -78,13 +79,8 @@ public class CleanroomClientProxy implements AbstractModInitializer.IEventProxy public void registerEvents() { MinecraftForge.EVENT_BUS.register(this); - - // handles singleplayer, LAN, and connecting to a server - PACKET_SENDER.setPacketHandler((IServerPlayerWrapper player, @NotNull AbstractNetworkMessage message) -> - { - ClientApi.INSTANCE.pluginMessageReceived(message); - ServerApi.INSTANCE.pluginMessageReceived(player, message); - }); + MinecraftForge.EVENT_BUS.register(FMLCommonHandler.instance()); + CleanroomPluginPacketSender.setPacketHandler(ClientApi.INSTANCE::pluginMessageReceived); } diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomMain.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomMain.java index fb88ba257..3055d707b 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomMain.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomMain.java @@ -21,19 +21,24 @@ package com.seibel.distanthorizons.cleanroom; import com.seibel.distanthorizons.cleanroom.modAccessor.ModChecker; import com.seibel.distanthorizons.common.AbstractModInitializer; +import com.seibel.distanthorizons.common.commands.CommandInitializer; +import com.seibel.distanthorizons.common.wrappers.worldGeneration.InternalServerGenerator; import com.seibel.distanthorizons.core.api.internal.ServerApi; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender; import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker; import com.seibel.distanthorizons.coreapi.ModInfo; import net.minecraft.server.MinecraftServer; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLServerAboutToStartEvent; -import net.minecraftforge.fml.common.event.FMLServerStoppingEvent; +import net.minecraftforge.fml.common.event.*; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.core.config.Configurator; +import java.util.List; import java.util.function.Consumer; /** @@ -47,6 +52,13 @@ public class CleanroomMain extends AbstractModInitializer @Mod.Instance public static CleanroomMain instance; + @Mod.EventHandler + public void preinit(FMLPreInitializationEvent event) + { + Configurator.setLevel("org.sqlite", Level.INFO); + ForgeChunkManager.setForcedChunkLoadingCallback(CleanroomMain.instance, (tickets, world) -> { }); + } + @Mod.EventHandler public void init(FMLInitializationEvent event) { @@ -93,6 +105,12 @@ public class CleanroomMain extends AbstractModInitializer eventHandler.run(); } + @Mod.EventHandler + public void onServerStarting(FMLServerStartingEvent event) + { + event.registerServerCommand(CommandInitializer.initCommands()); + } + @Mod.EventHandler public void onServerAboutToStart(FMLServerAboutToStartEvent event) { diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java index fc132932f..011517e97 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java @@ -1,6 +1,8 @@ package com.seibel.distanthorizons.cleanroom; import com.seibel.distanthorizons.common.AbstractModInitializer; +import com.seibel.distanthorizons.common.commands.CommandInitializer; +import com.seibel.distanthorizons.common.commonMixins.MixinChunkMapCommon; import com.seibel.distanthorizons.common.util.ProxyUtil; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper; @@ -22,14 +24,18 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.ChunkDataEvent; import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLServerAboutToStartEvent; +import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.fml.common.event.FMLServerStoppingEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent; import java.lang.reflect.Field; +import static com.seibel.distanthorizons.cleanroom.CleanroomMain.instance; + public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy { private static final CleanroomPluginPacketSender PACKET_SENDER = (CleanroomPluginPacketSender) SingletonInjector.INSTANCE.get(IPluginPacketSender.class); @@ -45,6 +51,7 @@ public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy public void registerEvents() { MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); if (this.isDedicated) { PACKET_SENDER.setPacketHandler(ServerApi.INSTANCE::pluginMessageReceived); @@ -65,25 +72,15 @@ public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy // events // //========// + // ServerLevelLoadEvent @SubscribeEvent public void serverLevelLoadEvent(WorldEvent.Load event) { if (GetEventLevel(event) instanceof WorldServer) { + InternalServerGenerator.DH_SERVER_GEN_TICKET_MAP.put(event.getWorld(), ForgeChunkManager.requestTicket(instance, event.getWorld(), ForgeChunkManager.Type.NORMAL)); this.serverApi.serverLevelLoadEvent(getServerLevelWrapper((WorldServer) GetEventLevel(event))); - InternalServerGenerator.DH_SERVER_GEN_TICKET = ForgeChunkManager.requestTicket(CleanroomMain.instance, event.getWorld(), ForgeChunkManager.Type.NORMAL); - //increase chunk limit - try - { - Field maxDepthField = InternalServerGenerator.DH_SERVER_GEN_TICKET.getClass().getDeclaredField("maxDepth"); - maxDepthField.setAccessible(true); - maxDepthField.setInt(InternalServerGenerator.DH_SERVER_GEN_TICKET, 1000); - } - catch (Exception e) - { - e.printStackTrace(); - } } } @@ -105,6 +102,15 @@ public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy this.serverApi.serverChunkLoadEvent(chunk, levelWrapper); } + @SubscribeEvent + public void serverChunkSaveEvent(ChunkDataEvent.Save event) + { + if (event.getWorld() instanceof WorldServer worldServer) + { + MixinChunkMapCommon.onChunkSave(worldServer, event.getChunk()); + } + } + @SubscribeEvent public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event) { this.serverApi.serverPlayerJoinEvent(getServerPlayerWrapper(event)); } @@ -115,9 +121,9 @@ public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy public void playerChangedDimensionEvent(PlayerEvent.PlayerChangedDimensionEvent event) { this.serverApi.serverPlayerLevelChangeEvent( - getServerPlayerWrapper(event), - getServerLevelWrapper(event.fromDim, event), - getServerLevelWrapper(event.toDim, event) + getServerPlayerWrapper(event), + getServerLevelWrapper(event.fromDim, event), + getServerLevelWrapper(event.toDim, event) ); } diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/common/MixinChunkProviderServer.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/common/MixinChunkProviderServer.java deleted file mode 100644 index df2f04ca6..000000000 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/common/MixinChunkProviderServer.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.seibel.distanthorizons.cleanroom.mixins.common; - -import com.seibel.distanthorizons.common.commonMixins.MixinChunkMapCommon; -import net.minecraft.world.WorldServer; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.gen.ChunkProviderServer; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(ChunkProviderServer.class) -public class MixinChunkProviderServer -{ - @Shadow - @Final - public WorldServer world; - - @Inject(method = "saveChunkData", at = @At("RETURN")) - private void onSaveChunkData(Chunk chunk, CallbackInfo ci) - { - MixinChunkMapCommon.onChunkSave(world, chunk); - } -} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/apply/blaze/frag.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/apply/blaze/frag.fsh new file mode 100644 index 000000000..2b0745aec --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/apply/blaze/frag.fsh @@ -0,0 +1,27 @@ +#version 150 core + +in vec2 TexCoord; + +out vec4 fragColor; + +uniform sampler2D uSourceColorTexture; +uniform sampler2D uSourceDepthTexture; + +// DH apply frag +void main() +{ + fragColor = vec4(0.0); + + // a fragment depth of "1" means the fragment wasn't drawn to, + // only update fragments that were drawn to + float fragmentDepth = texture(uSourceDepthTexture, TexCoord).r; + if (fragmentDepth != 1) + { + fragColor = texture(uSourceColorTexture, TexCoord); + } + else + { + // use the original MC texture if no LODs were drawn to this fragment + discard; + } +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/apply/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/apply/blaze/vert.vsh new file mode 100644 index 000000000..f58a25234 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/apply/blaze/vert.vsh @@ -0,0 +1,15 @@ +#version 150 core + +in vec2 vPosition; + +out vec2 TexCoord; + +/** + * This is specifically used by application shaders. + * IE post process or pixel transfer shaders, anything that is rendered using a single rectangle. + */ +void main() +{ + gl_Position = vec4(vPosition, 0.0, 1.0); + TexCoord = vPosition.xy * 0.5 + 0.5; +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/copy/blaze/frag.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/copy/blaze/frag.fsh new file mode 100644 index 000000000..9cbaf97f2 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/copy/blaze/frag.fsh @@ -0,0 +1,13 @@ +#version 150 core + +in vec2 TexCoord; + +out vec4 fragColor; + +uniform sampler2D uCopyTexture; + +// DH copy frag +void main() +{ + fragColor = texture(uCopyTexture, TexCoord); +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/copy/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/copy/blaze/vert.vsh new file mode 100644 index 000000000..d9b009b3b --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/copy/blaze/vert.vsh @@ -0,0 +1,12 @@ +#version 150 core + +in vec2 vPosition; + +out vec2 TexCoord; + +// DH copy +void main() +{ + gl_Position = vec4(vPosition, 0.0, 1.0); + TexCoord = vPosition.xy * 0.5 + 0.5; +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/blaze/frag.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/blaze/frag.fsh new file mode 100644 index 000000000..253b92fd5 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/blaze/frag.fsh @@ -0,0 +1,14 @@ +#version 150 core + +layout (std140) uniform uniformBlock +{ + mat4 uTransform; + vec4 uColor; +}; + +out vec4 fragColor; + +void main() +{ + fragColor = uColor; +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/blaze/vert.vsh new file mode 100644 index 000000000..7ff5df869 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/blaze/vert.vsh @@ -0,0 +1,14 @@ +#version 150 core + +layout (std140) uniform uniformBlock +{ + mat4 uTransform; + vec4 uColor; +}; + +in vec3 vPosition; + +void main() +{ + gl_Position = uTransform * vec4(vPosition, 1.0); +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/shaders/debug/frag.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/gl/frag.frag similarity index 100% rename from cleanroom/src/main/resources/shaders/debug/frag.frag rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/gl/frag.frag diff --git a/cleanroom/src/main/resources/shaders/debug/vert.vert b/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/gl/vert.vert similarity index 100% rename from cleanroom/src/main/resources/shaders/debug/vert.vert rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/gl/vert.vert diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/dh_fade.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/dh_fade.fsh new file mode 100644 index 000000000..a88b324c5 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/dh_fade.fsh @@ -0,0 +1,67 @@ +#version 150 core + +in vec2 TexCoord; + +out vec4 fragColor; + +layout (std140) uniform fragUniformBlock +{ + float uStartFadeBlockDistance; + float uEndFadeBlockDistance; + + // inverted model view matrix and projection matrix + mat4 uDhInvMvmProj; +}; + +uniform sampler2D uMcColorTexture; +uniform sampler2D uDhDepthTexture; +uniform sampler2D uDhColorTexture; + + +vec3 calcViewPosition(float fragmentDepth, mat4 invMvmProj) +{ + // normalized device coordinates + vec4 ndc = vec4(TexCoord.xy, fragmentDepth, 1.0); + ndc.xyz = ndc.xyz * 2.0 - 1.0; + + vec4 eyeCoord = invMvmProj * ndc; + return eyeCoord.xyz / eyeCoord.w; +} + +/** + * Used to fade out vanilla chunks so the transition + * between DH and vanilla is smoother. + */ +void main() +{ + // includes both the vanilla chunks as well as DH + vec4 combinedMcDhColor = texture(uMcColorTexture, TexCoord); + // just the DH render pass + vec4 dhColor = texture(uDhColorTexture, TexCoord); + + + + // the DH texture will have white if nothing was written to that pixel. + if (dhColor == vec4(1)) + { + // if not done vanilla clouds will render incorrectly at night + dhColor = combinedMcDhColor; + } + + + float dhFragmentDepth = texture(uDhDepthTexture, TexCoord).r; + vec3 dhVertexWorldPos = calcViewPosition(dhFragmentDepth, uDhInvMvmProj); + float dhFragmentDistance = length(dhVertexWorldPos.xzy); + + + float startFade = uEndFadeBlockDistance; + float endFade = uStartFadeBlockDistance; + + // Smoothly transition between combinedMcDhColor and uDhColorTexture + // as the depth increases from the camera + float fadeStep = smoothstep(startFade, endFade, dhFragmentDistance); + fragColor = mix(combinedMcDhColor, dhColor, fadeStep); + fragColor.a = 1.0; + +} + diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/vanilla_fade.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/vanilla_fade.fsh new file mode 100644 index 000000000..da8d123ae --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/vanilla_fade.fsh @@ -0,0 +1,95 @@ +#version 150 core + +in vec2 TexCoord; + +out vec4 fragColor; + +uniform sampler2D uMcDepthTexture; +uniform sampler2D uCombinedMcDhColorTexture; + +uniform sampler2D uDhDepthTexture; +uniform sampler2D uDhColorTexture; + +layout (std140) uniform fragUniformBlock +{ + bool uOnlyRenderLods; + + float uStartFadeBlockDistance; + float uEndFadeBlockDistance; + float uMaxLevelHeight; + + // inverted model view matrix and projection matrix + mat4 uDhInvMvmProj; + mat4 uMcInvMvmProj; +}; + + + +vec3 calcViewPosition(float fragmentDepth, mat4 invMvmProj) +{ + // normalized device coordinates + vec4 ndc = vec4(TexCoord.xy, fragmentDepth, 1.0); + ndc.xyz = ndc.xyz * 2.0 - 1.0; + + vec4 eyeCoord = invMvmProj * ndc; + return eyeCoord.xyz / eyeCoord.w; +} + +/** + * Used to fade out vanilla chunks so the transition + * between DH and vanilla is smoother. + */ +void main() +{ + // includes both the vanilla chunks as well as DH + vec4 combinedMcDhColor = texture(uCombinedMcDhColorTexture, TexCoord); + // just the DH render pass + vec4 dhColor = texture(uDhColorTexture, TexCoord); + + // completely remove the MC render pass to only show LODs + // useful for debugging/troubleshooting, but doesn't improve performance since MC is still rendering + if (uOnlyRenderLods) + { + fragColor = dhColor; + return; + } + + + // ignore anything that DH hasn't drawn to + // We don't use DH's depth here because it would prevent the fade from running before DH has loaded + if (dhColor == vec4(1)) + { + // if not done vanilla clouds will render incorrectly at night + dhColor = combinedMcDhColor; + } + + float mcFragmentDepth = texture(uMcDepthTexture, TexCoord).r; + float dhFragmentDepth = texture(uDhDepthTexture, TexCoord).r; + vec3 dhVertexWorldPos = calcViewPosition(dhFragmentDepth, uDhInvMvmProj); + + // this is a work around to prevent MC clouds rendering behind DH clouds + if (dhVertexWorldPos.y > uMaxLevelHeight) + { + fragColor = vec4(combinedMcDhColor.rgb, 0.0); + } + // a fragment depth of "1" means the fragment wasn't drawn to, + // we only want to fade vanilla rendered objects, not to the sky or LODs + else if (mcFragmentDepth < 1.0) + { + // fade based on distance from the camera + vec3 mcVertexWorldPos = calcViewPosition(mcFragmentDepth, uMcInvMvmProj); + float mcFragmentDistance = length(mcVertexWorldPos.xzy); + + + // Smoothly transition between combinedMcDhColor and uDhColorTexture + // as the depth increases from the camera + float fadeStep = smoothstep(uStartFadeBlockDistance, uEndFadeBlockDistance, mcFragmentDistance); + fragColor = mix(combinedMcDhColor, dhColor, fadeStep); + fragColor.a = 1.0; + } + else + { + fragColor = vec4(combinedMcDhColor.rgb, 0.0); + } +} + diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/vert.vsh new file mode 100644 index 000000000..d7f46cf36 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/vert.vsh @@ -0,0 +1,15 @@ +#version 150 core + +in vec2 vPosition; +in vec4 vColor; + +out vec4 fColor; +out vec2 TexCoord; + +// DH vert fade test +void main() +{ + gl_Position = vec4(vPosition, 0.0, 1.0); + fColor = vec4(vPosition, 0.0, 1.0); + TexCoord = vPosition.xy * 0.5 + 0.5; +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/shaders/fade/apply.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/apply.frag similarity index 100% rename from cleanroom/src/main/resources/shaders/fade/apply.frag rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/apply.frag diff --git a/cleanroom/src/main/resources/shaders/fade/dhFade.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/dhFade.frag similarity index 100% rename from cleanroom/src/main/resources/shaders/fade/dhFade.frag rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/dhFade.frag diff --git a/cleanroom/src/main/resources/shaders/fade/vanillaFade.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/vanillaFade.frag similarity index 100% rename from cleanroom/src/main/resources/shaders/fade/vanillaFade.frag rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/vanillaFade.frag diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/blaze/frag.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/blaze/frag.fsh new file mode 100644 index 000000000..9b0614970 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/blaze/frag.fsh @@ -0,0 +1,299 @@ +#version 150 core + +in vec2 TexCoord; + +out vec4 fragColor; + +layout (std140) uniform fragUniformBlock +{ + // fog uniforms + vec4 uFogColor; + float uFogScale; + float uFogVerticalScale; + int uFogDebugMode; + int uFogFalloffType; + + // fog config + float uFarFogStart; + float uFarFogLength; + float uFarFogMin; + float uFarFogRange; + float uFarFogDensity; + + // height fog config + float uHeightFogStart; + float uHeightFogLength; + float uHeightFogMin; + float uHeightFogRange; + float uHeightFogDensity; + + // ??? + bool uHeightFogEnabled; + int uHeightFogFalloffType; + bool uHeightBasedOnCamera; + float uHeightFogBaseHeight; + bool uHeightFogAppliesUp; + bool uHeightFogAppliesDown; + bool uUseSphericalFog; + int uHeightFogMixingMode; + float uCameraBlockYPos; + + // inverted model view matrix and projection matrix + mat4 uInvMvmProj; +}; + +uniform sampler2D uDhDepthTexture; + + + +//====================// +// method definitions // +//====================// + +vec3 calcViewPosition(float fragmentDepth); + +float getFarFogThickness(float dist); +float getHeightFogThickness(float dist); +float calculateHeightFogDepth(float worldYPos); +float mixFogThickness(float far, float height); + +float linearFog(float worldDist, float fogStart, float fogLength, float fogMin, float fogRange); +float exponentialFog(float x, float fogStart, float fogLength, float fogMin, float fogRange, float fogDensity); +float exponentialSquaredFog(float x, float fogStart, float fogLength, float fogMin, float fogRange, float fogDensity); + + + +//======// +// main // +//======// + +/** + * Fragment shader for fog. + * This should be run last so it applies above other affects like Ambient Occlusioning + */ +void main() +{ + float fragmentDepth = texture(uDhDepthTexture, TexCoord).r; + fragColor = vec4(uFogColor.rgb, 0.0); + + // a fragment depth of "1" means the fragment wasn't drawn to, + // we only want to apply Fog to LODs, not to the sky outside the LODs + if (fragmentDepth < 1.0) + { + int fogDebugMode = uFogDebugMode; + if (fogDebugMode == 0) + { + // render fog based on distance from the camera + vec3 vertexWorldPos = calcViewPosition(fragmentDepth); + + float horizontalWorldDistance = length(vertexWorldPos.xz) * uFogScale; + float worldDistance = length(vertexWorldPos.xyz) * uFogScale; + float activeDistance = uUseSphericalFog ? worldDistance : horizontalWorldDistance; + + + // far fog + float farFogThickness = getFarFogThickness(activeDistance); + + // height fog + float heightFogDepth = calculateHeightFogDepth(vertexWorldPos.y); + float heightFogThickness = getHeightFogThickness(heightFogDepth); + + // combined fog + float mixedFogThickness = mixFogThickness(farFogThickness, heightFogThickness); + fragColor.a = clamp(mixedFogThickness, 0.0, 1.0); + } + else if (fogDebugMode == 1) + { + // test code + + // render everything with the fog color + fragColor.a = 1.0; + } + else + { + // test code. + + // this can be fired by manually changing the fullFogMode to a (normally) + // invalid value (like 7). + // By having a separate if statement defined by + // a uniform we don't have to worry about GLSL optimizing away different + // options when testing, causing a bunch of headaches if we just want to render the screen red. + + float depthValue = textureLod(uDhDepthTexture, TexCoord, 0).r; + fragColor.rgb = vec3(depthValue); // Convert depth value to grayscale color + fragColor.a = 1.0; + } + } +} + + + +//================// +// helper methods // +//================// + +vec3 calcViewPosition(float fragmentDepth) +{ + vec4 ndc = vec4(TexCoord.xy, fragmentDepth, 1.0); + ndc.xyz = ndc.xyz * 2.0 - 1.0; + + vec4 eyeCoord = uInvMvmProj * ndc; + return eyeCoord.xyz / eyeCoord.w; +} + + + +//=========// +// far fog // +//=========// + +float getFarFogThickness(float dist) +{ + if (uFogFalloffType == 0) // LINEAR + { + return linearFog(dist, uFarFogStart, uFarFogLength, uFarFogMin, uFarFogRange); + } + else if (uFogFalloffType == 1) // EXPONENTIAL + { + return exponentialFog(dist, uFarFogStart, uFarFogLength, uFarFogMin, uFarFogRange, uFarFogDensity); + } + else // EXPONENTIAL_SQUARED + { + return exponentialSquaredFog(dist, uFarFogStart, uFarFogLength, uFarFogMin, uFarFogRange, uFarFogDensity); + } +} + +float getHeightFogThickness(float dist) +{ + if (!uHeightFogEnabled) + { + return 0.0; + } + + if (uHeightFogFalloffType == 0) // LINEAR + { + return linearFog(dist, uHeightFogStart, uHeightFogLength, uHeightFogMin, uHeightFogRange); + } + else if (uHeightFogFalloffType == 1) // EXPONENTIAL + { + return exponentialFog(dist, uHeightFogStart, uHeightFogLength, uHeightFogMin, uHeightFogRange, uHeightFogDensity); + } + else // EXPONENTIAL_SQUARED + { + return exponentialSquaredFog(dist, uHeightFogStart, uHeightFogLength, uHeightFogMin, uHeightFogRange, uHeightFogDensity); + } +} + +float linearFog(float worldDist, float fogStart, float fogLength, float fogMin, float fogRange) +{ + worldDist = (worldDist - fogStart) / fogLength; + worldDist = clamp(worldDist, 0.0, 1.0); + return fogMin + fogRange * worldDist; +} + +float exponentialFog( + float x, float fogStart, float fogLength, + float fogMin, float fogRange, float fogDensity) +{ + x = max((x-fogStart)/fogLength, 0.0) * fogDensity; + return fogMin + fogRange - fogRange/exp(x); +} + +float exponentialSquaredFog( + float x, float fogStart, float fogLength, + float fogMin, float fogRange, float fogDensity) +{ + x = max((x-fogStart)/fogLength, 0.0) * fogDensity; + return fogMin + fogRange - fogRange/exp(x*x); +} + + + +//============// +// height fog // +//============// + +/** 1 = full fog, 0 = no fog */ +float calculateHeightFogDepth(float worldYPos) +{ + // worldYPos -65 - 384 + + + //worldYPos = worldYPos * -1; // negative, fog below height; positive, fog above height + //return worldYPos * uFogVerticalScale; // "* uFogVerticalScale" is done to convert world position to a percent of the world height; + + if (!uHeightFogEnabled) + { + // ignore the height + return 0.0; + } + + + if (!uHeightBasedOnCamera) + { + worldYPos -= (uHeightFogBaseHeight - uCameraBlockYPos); + } + + + if (uHeightFogAppliesDown && uHeightFogAppliesUp) + { + return abs(worldYPos) * uFogVerticalScale; + } + else if (uHeightFogAppliesDown) + { + // apploy fog below given height + return -worldYPos * uFogVerticalScale; + } + else if (uHeightFogAppliesUp) + { + // apply fog above given height + return worldYPos * uFogVerticalScale; + } + else + { + // shouldn't happen, + return 0.0; + } + +} + +float mixFogThickness(float far, float height) +{ + switch (uHeightFogMixingMode) + { + case 0: // BASIC + case 1: // IGNORE_HEIGHT + return far; + + case 2: // MAX + return max(far, height); + + case 3: // ADDITION + return (far + height); + + case 4: // MULTIPLY + return far * height; + + case 5: // INVERSE_MULTIPLY + return (1.0 - (1.0-far)*(1.0-height)); + + case 6: // LIMITED_ADDITION + return (far + max(far, height)); + + case 7: // MULTIPLY_ADDITION + return (far + far*height); + + case 8: // INVERSE_MULTIPLY_ADDITION + return (far + 1.0 - (1.0-far)*(1.0-height)); + + case 9: // AVERAGE + return (far*0.5 + height*0.5); + } + + // shouldn't happen, but default to BASIC / IGNORE_HEIGHT + // if an invalid option is selected + return far; +} + + + diff --git a/cleanroom/src/main/resources/shaders/quadApply.vert b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/blaze/vert.vsh similarity index 100% rename from cleanroom/src/main/resources/shaders/quadApply.vert rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/blaze/vert.vsh diff --git a/cleanroom/src/main/resources/shaders/fog/apply.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/gl/apply.frag similarity index 100% rename from cleanroom/src/main/resources/shaders/fog/apply.frag rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/gl/apply.frag diff --git a/cleanroom/src/main/resources/shaders/fog/fog.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/gl/fog.frag similarity index 100% rename from cleanroom/src/main/resources/shaders/fog/fog.frag rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/gl/fog.frag diff --git a/cleanroom/src/main/resources/shaders/genericObject/direct/frag.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/blaze/frag.fsh similarity index 100% rename from cleanroom/src/main/resources/shaders/genericObject/direct/frag.frag rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/blaze/frag.fsh diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/blaze/vert.vsh new file mode 100644 index 000000000..68931fe9a --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/blaze/vert.vsh @@ -0,0 +1,101 @@ +#version 330 core + +//layout (location = 1) in vec4 aColor; // RGBA_FLOAT_COLOR +//layout (location = 2) in vec3 aScale; // VEC3_SCALE +//layout (location = 3) in ivec3 aTranslateChunk; // IVEC3_SCALE +//layout (location = 4) in vec3 aTranslateSubChunk; // VEC3_SCALE +//layout (location = 5) in int aMaterial; // IRIS_MATERIAL + +//uniform sampler2D /*vec4*/ uColorMap; +//uniform sampler2D /*vec3*/ uScaleMap; +//uniform sampler2D /*int*/ uTranslateChunkXMap; +//uniform sampler2D /*int*/ uTranslateChunkYMap; +//uniform sampler2D /*int*/ uTranslateChunkZMap; +//uniform sampler2D /*vec3*/ uTranslateSubChunkMap; +//uniform sampler2D /*int*/ uMaterialMap; +// +//in vec3 vPosition; + +in vec3 vPosition; +in vec4 aColor; // RGBA_FLOAT_COLOR +in int aMaterial; // IRIS_MATERIAL + +layout (std140) uniform vertUniformBlock +{ + ivec3 uOffsetChunk; + vec3 uOffsetSubChunk; + ivec3 uCameraPosChunk; + vec3 uCameraPosSubChunk; + + mat4 uProjectionMvm; + int uSkyLight; + int uBlockLight; + + float uNorthShading; + float uSouthShading; + float uEastShading; + float uWestShading; + float uTopShading; + float uBottomShading; +}; + +uniform sampler2D uLightMap; + +out vec4 fColor; + +void main() +{ + vec3 aScale = vec3(1); + + if (aMaterial == 999) + { + aScale = vec3(2); + } + +// vec4 aColor = texelFetch(uColorMap, ivec2(gl_InstanceID,0), 0); +// vec3 aScale = texelFetch(uScaleMap, ivec2(gl_InstanceID,0), 0).xyz; +// +// float chunkX = int(texelFetch(uTranslateChunkXMap, ivec2(gl_InstanceID,0), 0).x); +// float chunkY = int(texelFetch(uTranslateChunkYMap, ivec2(gl_InstanceID,0), 0).x); +// float chunkZ = int(texelFetch(uTranslateChunkZMap, ivec2(gl_InstanceID,0), 0).x); +// ivec3 aTranslateChunk = ivec3(chunkX, chunkY, chunkZ); +// +// vec3 aTranslateSubChunk = texelFetch(uTranslateSubChunkMap, ivec2(gl_InstanceID,0), 0).xyz; +// int aMaterial = int(texelFetch(uMaterialMap, ivec2(gl_InstanceID,0), 0).x); + + // aTranslate - moves the vertex to the boxGroup's relative position + // uOffset - moves the vertex to the boxGroup's world position + // uCameraPos - moves the vertex into camera space + vec3 trans = (uOffsetChunk - uCameraPosChunk) * 16.0f; + // separate float and int values are to fix percission loss at extreme distances from the origin (IE 10,000,000+) + // luckily large translate values minus large cameraPos generally equal values that cleanly fit in a float + trans += (uOffsetSubChunk - uCameraPosSubChunk); + + // combination translation and scaling matrix + mat4 transform = mat4( + aScale.x, 0.0, 0.0, 0.0, + 0.0, aScale.y, 0.0, 0.0, + 0.0, 0.0, aScale.z, 0.0, + trans.x, trans.y, trans.z, 1.0 + ); + + gl_Position = uProjectionMvm * transform * vec4(vPosition, 1.0); + + float blockLight = (float(uBlockLight)+0.5) / 16.0; + float skyLight = (float(uSkyLight)+0.5) / 16.0; + vec4 lightColor = vec4(texture(uLightMap, vec2(blockLight, skyLight)).xyz, 1.0); + + + fColor = lightColor * aColor; + + int vertexIndex = gl_VertexID % 24; + + // apply directional shading + if (vertexIndex >= 0 && vertexIndex < 4) { fColor.rgb *= uNorthShading; } + else if (vertexIndex >= 4 && vertexIndex < 8) { fColor.rgb *= uSouthShading; } + else if (vertexIndex >= 8 && vertexIndex < 12) { fColor.rgb *= uWestShading; } + else if (vertexIndex >= 12 && vertexIndex < 16) { fColor.rgb *= uEastShading; } + else if (vertexIndex >= 16 && vertexIndex < 20) { fColor.rgb *= uBottomShading; } + else if (vertexIndex >= 20 && vertexIndex < 24) { fColor.rgb *= uTopShading; } + +} diff --git a/cleanroom/src/main/resources/shaders/genericObject/instanced/frag.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/direct/frag.frag similarity index 100% rename from cleanroom/src/main/resources/shaders/genericObject/instanced/frag.frag rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/direct/frag.frag diff --git a/cleanroom/src/main/resources/shaders/genericObject/direct/vert.vert b/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/direct/vert.vert similarity index 100% rename from cleanroom/src/main/resources/shaders/genericObject/direct/vert.vert rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/direct/vert.vert diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/instanced/frag.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/instanced/frag.frag new file mode 100644 index 000000000..c3d2ac8c4 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/instanced/frag.frag @@ -0,0 +1,10 @@ +#version 150 core + +in vec4 fColor; + +out vec4 fragColor; + +void main() +{ + fragColor = fColor; +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/shaders/genericObject/instanced/vert.vert b/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/instanced/vert.vert similarity index 100% rename from cleanroom/src/main/resources/shaders/genericObject/instanced/vert.vert rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/instanced/vert.vert diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/lod/blaze/frag.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/lod/blaze/frag.fsh new file mode 100644 index 000000000..86be28a6b --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/lod/blaze/frag.fsh @@ -0,0 +1,125 @@ +#version 150 + +in vec4 vertexColor; +in vec3 vertexWorldPos; +in vec3 vPos; +in vec4 gl_FragCoord; + +out vec4 fragColor; + +layout (std140) uniform fragUniformBlock +{ + // Fade/Clip Uniforms + float uClipDistance; + + // Noise Uniforms + float uNoiseIntensity; + int uNoiseSteps; + int uNoiseDropoff; + bool uDitherDhRendering; + bool uNoiseEnabled; +}; + + +// The random functions for diffrent dimentions +float rand(float co) { return fract(sin(co*(91.3458)) * 47453.5453); } +float rand(vec2 co) { return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } +float rand(vec3 co) { return rand(co.xy + rand(co.z)); } + +// Puts steps in a float +// EG. setting stepSize to 4 then this would be the result of this function +// In: 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, ..., 1.1, 1.2, 1.3 +// Out: 0.0, 0.0, 0.0, 0.25, 0.25, 0.5, 0.5, ..., 1.0, 1.0, 1.25 +vec3 quantize(vec3 val, int stepSize) +{ + return floor(val * stepSize) / stepSize; +} + +void applyNoise(inout vec4 fragColor, const in float viewDist) +{ + vec3 vertexNormal = normalize(cross(dFdy(vPos.xyz), dFdx(vPos.xyz))); + // This bit of code is required to fix the vertex position problem cus of floats in the verted world position varuable + vec3 fixedVPos = vPos.xyz + vertexNormal * 0.001; + + float noiseAmplification = uNoiseIntensity; + float lum = (fragColor.r + fragColor.g + fragColor.b) / 3.0; + noiseAmplification = (1.0 - pow(lum * 2.0 - 1.0, 2.0)) * noiseAmplification; // Lessen the effect on depending on how dark the object is, equasion for this is -(2x-1)^{2}+1 + noiseAmplification *= fragColor.a; // The effect would lessen on transparent objects + + // Random value for each position + float randomValue = rand(quantize(fixedVPos, uNoiseSteps)) + * 2.0 * noiseAmplification - noiseAmplification; + + // Modifies the color + // A value of 0 on the randomValue will result in the original color, while a value of 1 will result in a fully bright color + vec3 newCol = fragColor.rgb + (1.0 - fragColor.rgb) * randomValue; + newCol = clamp(newCol, 0.0, 1.0); + + if (uNoiseDropoff != 0) { + float distF = min(viewDist / uNoiseDropoff, 1.0); + newCol = mix(newCol, fragColor.rgb, distF); // The further away it gets, the less noise gets applied + } + + fragColor.rgb = newCol; +} + +/** returns a normalized value between 0.0 and 1.0 */ +float bayerMatrix4x4(vec2 st) +{ + int x = int(mod(st.x, 4.0)); + int y = int(mod(st.y, 4.0)); + + // Flattened 4x4 Bayer matrix + float bayer4x4[16] = float[16]( + 0.0, 8.0, 2.0, 10.0, + 12.0, 4.0, 14.0, 6.0, + 3.0, 11.0, 1.0, 9.0, + 15.0, 7.0, 13.0, 5.0 + ); + + // Calculate the 1D index from the 2D coordinates + int index = y * 4 + x; + + // Return the Bayer value normalized between 0.0 and 1.0 + return bayer4x4[index] / 16.0; +} + + + +void main() +{ + fragColor = vertexColor; + + float viewDist = length(vertexWorldPos); + + if (uDitherDhRendering) + { + // Dither out the fragment based on distance and noise. + // Dithering is used since it works for both opaque and transparent rendering + + // noise increases as the distance increases + // the fragCoord is used since it is stable and small so the dithering is cleaner + float worldNoise = bayerMatrix4x4(gl_FragCoord.xy); + // minor fudge factor to make sure all pixels fade out + // if not included 1 in 16 pixels would never fade away + worldNoise += 0.001; + + float fadeStep = smoothstep(uClipDistance, uClipDistance * 1.5, viewDist); + if (fadeStep <= worldNoise) + { + discard; + } + } + else + { + if (viewDist < uClipDistance && uClipDistance > 0.0) + { + discard; + } + } + + if (uNoiseEnabled) + { + applyNoise(fragColor, viewDist); + } +} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/lod/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/lod/blaze/vert.vsh new file mode 100644 index 000000000..e2eed781e --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/lod/blaze/vert.vsh @@ -0,0 +1,81 @@ +#version 150 + +in uvec3 vPosition; +in uint meta; // contains light and micro-offset data +in vec4 vColor; +in int irisMaterial; +in int irisNormal; + +out vec3 vPos; +out vec4 vertexColor; +out vec3 vertexWorldPos; +out float vertexYPos; + +layout (std140) uniform vertUniqueUniformBlock +{ + vec3 uModelOffset; +}; + +layout (std140) uniform vertSharedUniformBlock +{ + bool uIsWhiteWorld; + + float uWorldYOffset; + float uMircoOffset; + float uEarthRadius; + + vec3 uCameraPos; + mat4 uCombinedMatrix; +}; + +uniform sampler2D uLightMap; + +/** + * LOD terrain Vertex Shader + */ +void main() +{ + vPos = vPosition; // This is so it can be passed to the fragment shader + + vertexWorldPos = vPosition.xyz + (uModelOffset - uCameraPos); + + vertexYPos = vPosition.y + uWorldYOffset; + + uint mirco = (meta & 0xFF00u) >> 8u; // mirco offset which is a xyz 2bit value + // 0b00 = no offset + // 0b01 = positive offset + // 0b11 = negative offset + // format is: 0b00zzyyxx + float mx = (mirco & 1u)!=0u ? uMircoOffset : 0.0; + mx = (mirco & 2u)!=0u ? -mx : mx; + //float my = (mirco & 4u)!=0u ? uMircoOffset : 0.0; + //my = (mirco & 8u)!=0u ? -my : my; + float mz = (mirco & 16u)!=0u ? uMircoOffset : 0.0; + mz = (mirco & 32u)!=0u ? -mz : mz; + + vertexWorldPos.x += mx; + //vertexWorldPos.y += my; + vertexWorldPos.z += mz; + + // apply the earth curvature if needed + if (uEarthRadius < -1.0f || uEarthRadius > 1.0f) + { + // vertex transformation logic - stduhpf + float localRadius = uEarthRadius + vertexYPos; + float phi = length(vertexWorldPos.xz) / localRadius; + vertexWorldPos.y += (cos(phi) - 1.0) * localRadius; + vertexWorldPos.xz = vertexWorldPos.xz * sin(phi) / phi; + } + + uint lights = meta & 0xFFu; + float skyLight = (float(lights/16u)+0.5) / 16.0; + float blockLight = (mod(float(lights), 16.0)+0.5) / 16.0; + vertexColor = vec4(texture(uLightMap, vec2(skyLight, blockLight)).xyz, 1.0); + + if (!uIsWhiteWorld) + { + vertexColor *= vColor; + } + + gl_Position = uCombinedMatrix * vec4(vertexWorldPos, 1.0); +} diff --git a/cleanroom/src/main/resources/shaders/apply.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/apply.frag similarity index 100% rename from cleanroom/src/main/resources/shaders/apply.frag rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/apply.frag diff --git a/cleanroom/src/main/resources/shaders/flat_shaded.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/flat_shaded.frag similarity index 100% rename from cleanroom/src/main/resources/shaders/flat_shaded.frag rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/flat_shaded.frag diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/quadApply.vert b/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/quadApply.vert new file mode 100644 index 000000000..3f614c123 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/quadApply.vert @@ -0,0 +1,15 @@ +#version 150 core + +in vec2 vPosition; + +out vec2 TexCoord; + +/** + * This is specifically used by application shaders. + * IE post process or pixel transfer shaders, anything that is rendered using a single rectangle. + */ +void main() +{ + gl_Position = vec4(vPosition, 1.0, 1.0); + TexCoord = vPosition.xy * 0.5 + 0.5; +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/shaders/standard.vert b/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/standard.vert similarity index 100% rename from cleanroom/src/main/resources/shaders/standard.vert rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/standard.vert index f948f1708..1117af78e 100644 --- a/cleanroom/src/main/resources/shaders/standard.vert +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/standard.vert @@ -1,9 +1,9 @@ #version 150 core in uvec4 vPosition; -out vec4 vPos; in vec4 color; +out vec4 vPos; out vec4 vertexColor; out vec3 vertexWorldPos; out float vertexYPos; diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/apply.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/apply.fsh new file mode 100644 index 000000000..ecc9ba828 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/apply.fsh @@ -0,0 +1,86 @@ +#version 150 core + +in vec2 TexCoord; + +out vec4 fragColor; + +uniform sampler2D uSourceColorTexture; +uniform sampler2D uSourceDepthTexture; + +layout (std140) uniform applyFragUniformBlock +{ + vec2 uViewSize; + int uBlurRadius; + float uNearClipPlane; // in blocks + float uFarClipPlane; // in blocks +}; + + +float linearizeDepth(const in float depth) { return (uNearClipPlane * uFarClipPlane) / (depth * (uNearClipPlane - uFarClipPlane) + uFarClipPlane); } + +float Gaussian(const in float sigma, const in float x) { return exp(-(x*x) / (2.0 * (sigma*sigma))); } + +float BilateralGaussianBlur(const in vec2 texcoord, const in float linearDepth, const in float g_sigmaV) +{ + float g_sigmaX = 1.6; + float g_sigmaY = 1.6; + + int radius = clamp(uBlurRadius, 1, 3); + + vec2 pixelSize = 1.0 / uViewSize; + + float accum = 0.0; + float total = 0.0; + for (int iy = -radius; iy <= radius; iy++) + { + float fy = Gaussian(g_sigmaY, iy); + + for (int ix = -radius; ix <= radius; ix++) + { + float fx = Gaussian(g_sigmaX, ix); + + vec2 sampleTexCoord = texcoord + ivec2(ix, iy) * pixelSize; + + float sampleValue = textureLod(uSourceColorTexture, sampleTexCoord, 0).r; + + float sampleDepth = textureLod(uSourceDepthTexture, sampleTexCoord, 0).r; + float sampleLinearDepth = linearizeDepth(sampleDepth); + + float depthDiff = abs(sampleLinearDepth - linearDepth); + float fv = Gaussian(g_sigmaV, depthDiff); + + float weight = fx*fy*fv; + accum += weight * sampleValue; + total += weight; + } + } + + if (total <= 1.e-4) + { + return 1.0; + } + return accum / total; +} + + +void main() +{ + fragColor = vec4(1.0); + + float fragmentDepth = textureLod(uSourceDepthTexture, TexCoord, 0).r; + + // a fragment depth of "1" means the fragment wasn't drawn to, + // we only want to apply SSAO to LODs, not to the sky outside the LODs + if (fragmentDepth < 1) + { + if (uBlurRadius > 0) + { + float fragmentDepthLinear = linearizeDepth(fragmentDepth); + fragColor.a = BilateralGaussianBlur(TexCoord, fragmentDepthLinear, 1.6); + } + else + { + fragColor.a = texelFetch(uSourceColorTexture, ivec2(gl_FragCoord.xy), 0).r; + } + } +} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/frag.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/frag.fsh new file mode 100644 index 000000000..517523342 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/frag.fsh @@ -0,0 +1,137 @@ +#version 150 core +#extension GL_ARB_derivative_control : enable + +#define SAMPLE_MAX 64 + +#define saturate(x) (clamp((x), 0.0, 1.0)) + +in vec2 TexCoord; + +out vec4 fragColor; + + +layout (std140) uniform fragUniformBlock +{ + int uSampleCount; + + float uRadius; + float uStrength; + float uMinLight; + float uBias; + float uFadeDistanceInBlocks; + + mat4 uInvProj; + mat4 uProj; +}; + +uniform sampler2D uDhDepthTexture; + +const float EPSILON = 1.e-6; +const float GOLDEN_ANGLE = 2.39996323; +const vec3 MAGIC = vec3(0.06711056, 0.00583715, 52.9829189); +const float PI = 3.1415926538; +const float TAU = PI * 2.0; + + +vec3 unproject(vec4 pos) +{ + return pos.xyz / pos.w; +} + +float InterleavedGradientNoise(const in vec2 pixel) +{ + float x = dot(pixel, MAGIC.xy); + return fract(MAGIC.z * fract(x)); +} + +vec3 calcViewPosition(const in vec3 clipPos) +{ + vec4 viewPos = uInvProj * vec4(clipPos * 2.0 - 1.0, 1.0); + return viewPos.xyz / viewPos.w; +} + +float GetSpiralOcclusion(const in vec2 uv, const in vec3 viewPos, const in vec3 viewNormal) +{ + float dither = InterleavedGradientNoise(gl_FragCoord.xy); + float rotatePhase = dither * TAU; + float rStep = uRadius / uSampleCount; + + vec2 offset; + + float ao = 0.0; + int sampleCount = 0; + float radius = rStep; + for (int i = 0; i < clamp(uSampleCount, 1, SAMPLE_MAX); i++) { + vec2 offset = vec2( + sin(rotatePhase), + cos(rotatePhase) + ) * radius; + + radius += rStep; + rotatePhase += GOLDEN_ANGLE; + + vec3 sampleViewPos = viewPos + vec3(offset, -0.1); + vec3 sampleClipPos = unproject(uProj * vec4(sampleViewPos, 1.0)) * 0.5 + 0.5; + sampleClipPos = saturate(sampleClipPos); + + float sampleClipDepth = textureLod(uDhDepthTexture, sampleClipPos.xy, 0.0).r; + if (sampleClipDepth >= 1.0 - EPSILON) continue; + + sampleClipPos.z = sampleClipDepth; + sampleViewPos = unproject(uInvProj * vec4(sampleClipPos * 2.0 - 1.0, 1.0)); + + vec3 diff = sampleViewPos - viewPos; + float sampleDist = length(diff); + vec3 sampleNormal = diff / sampleDist; + + float sampleNoLm = max(dot(viewNormal, sampleNormal) - uBias, 0.0); + float aoF = 1.0 - saturate(sampleDist / uRadius); + ao += sampleNoLm * aoF; + sampleCount++; + } + + ao /= max(sampleCount, 1); + ao = smoothstep(0.0, uStrength, ao); + + return ao * (1.0 - uMinLight); +} + + +void main() +{ + float fragmentDepth = textureLod(uDhDepthTexture, TexCoord, 0).r; + float occlusion = 0.0; + + // Do not apply to sky + if (fragmentDepth < 1.0) + { + vec3 viewPos = calcViewPosition(vec3(TexCoord, fragmentDepth)); + + // fading is done to prevent banding/noise + // at super far distance + float distanceFromCamera = length(viewPos); + float fadeDistance = uFadeDistanceInBlocks; + if (distanceFromCamera < fadeDistance) + { + #ifdef GL_ARB_derivative_control + // Get higher precision derivatives when available + vec3 viewNormal = cross(dFdxFine(viewPos.xyz), dFdyFine(viewPos.xyz)); + #else + vec3 viewNormal = cross(dFdx(viewPos.xyz), dFdy(viewPos.xyz)); + #endif + + viewNormal = normalize(viewNormal); + occlusion = GetSpiralOcclusion(TexCoord, viewPos, viewNormal); + + // linearly fade with distance + occlusion *= (fadeDistance - distanceFromCamera) / fadeDistance; + } + else + { + // we're out of range, no need to do any SSAO calculations + occlusion = 0.0; + } + } + + fragColor = vec4(vec3(1.0 - occlusion), 1.0); +} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/vert.vsh new file mode 100644 index 000000000..3f614c123 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/vert.vsh @@ -0,0 +1,15 @@ +#version 150 core + +in vec2 vPosition; + +out vec2 TexCoord; + +/** + * This is specifically used by application shaders. + * IE post process or pixel transfer shaders, anything that is rendered using a single rectangle. + */ +void main() +{ + gl_Position = vec4(vPosition, 1.0, 1.0); + TexCoord = vPosition.xy * 0.5 + 0.5; +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/shaders/ssao/ao.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/gl/ao.frag similarity index 100% rename from cleanroom/src/main/resources/shaders/ssao/ao.frag rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/gl/ao.frag diff --git a/cleanroom/src/main/resources/shaders/ssao/apply.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/gl/apply.frag similarity index 100% rename from cleanroom/src/main/resources/shaders/ssao/apply.frag rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/gl/apply.frag diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/blaze/frag.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/blaze/frag.fsh new file mode 100644 index 000000000..3fd25f9db --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/blaze/frag.fsh @@ -0,0 +1,10 @@ +#version 150 core + +in vec4 fColor; +out vec4 fragColor; + +// DH frag test +void main() +{ + fragColor = fColor; +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/blaze/vert.vsh new file mode 100644 index 000000000..2887fea56 --- /dev/null +++ b/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/blaze/vert.vsh @@ -0,0 +1,13 @@ +#version 150 core + +in vec2 vPosition; +in vec4 vColor; + +out vec4 fColor; + +// DH vert test +void main() +{ + gl_Position = vec4(vPosition, 0.0, 1.0); + fColor = vColor; +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/shaders/test/frag.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/gl/frag.frag similarity index 100% rename from cleanroom/src/main/resources/shaders/test/frag.frag rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/test/gl/frag.frag diff --git a/cleanroom/src/main/resources/shaders/test/vert.vert b/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/gl/vert.vert similarity index 100% rename from cleanroom/src/main/resources/shaders/test/vert.vert rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/test/gl/vert.vert diff --git a/cleanroom/src/main/resources/distanthorizons.default.mixin.json b/cleanroom/src/main/resources/distanthorizons.default.mixin.json index c83a3c94d..3a766233c 100644 --- a/cleanroom/src/main/resources/distanthorizons.default.mixin.json +++ b/cleanroom/src/main/resources/distanthorizons.default.mixin.json @@ -3,9 +3,7 @@ "package": "com.seibel.distanthorizons.cleanroom.mixins", "compatibilityLevel": "JAVA_8", "target": "@env(DEFAULT)", - "mixins": [ - "common.MixinChunkProviderServer" - ], + "mixins": [], "minVersion": "0.8.7", "server": [ "server.MixinEntityPlayerMP" diff --git a/cleanroom/src/main/resources/mcmod.info b/cleanroom/src/main/resources/mcmod.info new file mode 100644 index 000000000..ab8c3f26b --- /dev/null +++ b/cleanroom/src/main/resources/mcmod.info @@ -0,0 +1,12 @@ +[{ + "modid": "${mod_id}", + "name": "${mod_name}", + "version": "${mod_version}", + "mcversion": "1.12.2", + "description": "${mod_description}", + "authorList": ["${mod_authors}"], + "credits": "${mod_credits}", + "url": "${mod_url}", + "updateJSON": "${mod_update_json}", + "logoFile": "${mod_logo_path}" +}] \ No newline at end of file diff --git a/cleanroom/src/main/resources/pack.mcmeta b/cleanroom/src/main/resources/pack.mcmeta new file mode 100644 index 000000000..daa17a8dc --- /dev/null +++ b/cleanroom/src/main/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "${mod_name} Resources", + "pack_format": 3 + } +} \ No newline at end of file diff --git a/cleanroom/src/main/resources/shaders/noise/noise.frag b/cleanroom/src/main/resources/shaders/noise/noise.frag deleted file mode 100644 index 6d39b6253..000000000 --- a/cleanroom/src/main/resources/shaders/noise/noise.frag +++ /dev/null @@ -1,74 +0,0 @@ -#version 150 core - -in vec4 vertexColor; -in vec4 vPos; -in vec3 vertexWorldPos; -out vec4 fragColor; - -uniform float distanceScale; - -uniform int uNoiseSteps; -uniform float uNoiseIntensity; -uniform float uNoiseDropoff; - - - -// The random functions for diffrent dimentions -float rand(float co) { return fract(sin(co*(91.3458)) * 47453.5453); } -float rand(vec2 co){ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } -float rand(vec3 co){ return rand(co.xy+rand(co.z)); } - -// Puts steps in a float -// EG. setting stepSize to 4 then this would be the result of this function -// In: 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, ..., 1.1, 1.2, 1.3 -// Out: 0.0, 0.0, 0.0, 0.25, 0.25, 0.5, 0.5, ..., 1.0, 1.0, 1.25 -float quantize(float val, int stepSize) { - return floor(val*stepSize)/stepSize; -} - -vec3 quantize(vec3 val, int stepSize) { - return floor(val*stepSize)/stepSize; -} - - -/** - * Fragment shader for adding noise to lods. - * This should be passed close to first as it affects the base color of the lod - * - * version: 2023-6-21 - */ -void main() { - // This bit of code is required to fix the vertex position problem cus of floats in the verted world position varuable - vec3 vertexNormal = normalize(cross(dFdx(vPos.xyz), dFdy(vPos.xyz))); - vec3 fixedVPos = vPos.xyz - vertexNormal * 0.001; - - - float noiseAmplification = uNoiseIntensity; - noiseAmplification = (-1 * pow(2*((vertexColor.x + vertexColor.y + vertexColor.z) / 3) - 1, 2) + 1) * noiseAmplification; // Lessen the effect on depending on how dark the object is, equasion for this is -(2x-1)^{2}+1 - noiseAmplification *= vertexColor.w; // The effect would lessen on transparent objects - - // Random value for each position - float randomValue = rand(quantize(fixedVPos.xyz, uNoiseSteps)) - * 2.0 * noiseAmplification - noiseAmplification; - - - // Modifies the color - // A value of 0 on the randomValue will result in the original color, while a value of 1 will result in a fully bright color - vec3 newCol = (1.0 - vertexColor.rgb) * randomValue; - - // Clamps it and turns it back into a vec4 - float distA = length(vertexWorldPos) * distanceScale * uNoiseDropoff; - fragColor = clamp(vec4(newCol.rgb, distA), 0.0, 1.0); // The further away it gets, the less noise gets applied - - // The further away it gets, the less noise gets applied - fragColor = vec4(0.0, 0.0, 0.0, randomValue); - - // For testing -// if (vertexColor.r != 69420.) { -// fragColor = vec4( -// mod(fixedVPos.x, 1), -// mod(fixedVPos.y, 1), -// mod(fixedVPos.z, 1), -// 1f); -// } -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/shaders/test/dark.frag b/cleanroom/src/main/resources/shaders/test/dark.frag deleted file mode 100644 index ab99d05ce..000000000 --- a/cleanroom/src/main/resources/shaders/test/dark.frag +++ /dev/null @@ -1,9 +0,0 @@ -#version 150 core - -out vec4 fragColor; - -// A test shader that makes everything darker -void main() -{ - fragColor = vec4(0., 0., 1., 0.5); -} \ No newline at end of file diff --git a/common/build.gradle b/common/build.gradle index c70889d3f..a2fea2fdd 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -11,7 +11,7 @@ buildscript { } if (rootProject.minecraft_version != "1.12.2") { - apply plugin: "org.spongepowered.gradle.vanilla" version "0.2.1-SNAPSHOT" + apply plugin: "org.spongepowered.gradle.vanilla" } if (rootProject.minecraft_version != "1.12.2") { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java b/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java index 6c5434815..163969f17 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java @@ -1,6 +1,5 @@ package com.seibel.distanthorizons.common; -import com.mojang.brigadier.CommandDispatcher; import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi; import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent; import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent; @@ -27,7 +26,10 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModAccesso import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker; import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector; import com.seibel.distanthorizons.coreapi.ModInfo; +#if MC_VER > MC_1_12_2 +import com.mojang.brigadier.CommandDispatcher; import net.minecraft.commands.CommandSourceStack; +#endif import net.minecraft.server.MinecraftServer; import net.minecraft.server.dedicated.DedicatedServer; import com.seibel.distanthorizons.core.logging.DhLogger; @@ -58,7 +60,9 @@ public abstract class AbstractModInitializer protected abstract IEventProxy createServerProxy(boolean isDedicated); protected abstract void initializeModCompat(); + #if MC_VER > MC_1_12_2 protected abstract void subscribeRegisterCommandsEvent(Consumer> eventHandler); + #endif protected abstract void subscribeClientStartedEvent(Runnable eventHandler); protected abstract void subscribeServerStartingEvent(Consumer eventHandler); @@ -125,8 +129,10 @@ public abstract class AbstractModInitializer this.initializeModCompat(); LOGGER.info(ModInfo.READABLE_NAME + " server Initialized, adding event subscribers..."); + #if MC_VER > MC_1_12_2 this.commandInitializer = new CommandInitializer(); this.subscribeRegisterCommandsEvent(dispatcher -> { this.commandInitializer.initCommands(dispatcher); }); + #endif this.subscribeServerStartingEvent(server -> { @@ -134,11 +140,13 @@ public abstract class AbstractModInitializer this.initConfig(); this.postInit(); + #if MC_VER > MC_1_12_2 this.commandInitializer.onServerReady(); + #endif this.checkForUpdates(); - LOGGER.info(ModInfo.READABLE_NAME + " server Initialized at " + server.getServerDirectory()); + LOGGER.info(ModInfo.READABLE_NAME + " server Initialized at " + server.#if MC_VER <= MC_1_12_2 getDataDirectory() #else getServerDirectory() #endif); }); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/AbstractPluginPacketSender.java b/common/src/main/java/com/seibel/distanthorizons/common/AbstractPluginPacketSender.java index cca81dfbf..a4b5d6235 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/AbstractPluginPacketSender.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/AbstractPluginPacketSender.java @@ -37,8 +37,10 @@ public abstract class AbstractPluginPacketSender implements IPluginPacketSender .fileLevelConfig(Config.Common.Logging.logNetworkEventToFile) .build(); - #if MC_VER <= MC_1_20_6 - public static final String WRAPPER_PACKET_RESOURCE = ModInfo.RESOURCE_NAMESPACE + ModInfo.WRAPPER_PACKET_PATH; + #if MC_VER <= MC_1_12_2 + public static final String WRAPPER_PACKET_RESOURCE = "channelDH"; // resource_namespace + packet_path > 20 characters + #elif MC_VER <= MC_1_20_6 + public static final ResourceLocation WRAPPER_PACKET_RESOURCE = new ResourceLocation(ModInfo.RESOURCE_NAMESPACE, ModInfo.WRAPPER_PACKET_PATH); #elif MC_VER <= MC_1_21_10 public static final ResourceLocation WRAPPER_PACKET_RESOURCE = ResourceLocation.fromNamespaceAndPath(ModInfo.RESOURCE_NAMESPACE, ModInfo.WRAPPER_PACKET_PATH); #else diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/CommandInitializer.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/CommandInitializer.java index d4215df85..fd3db3273 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/CommandInitializer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/CommandInitializer.java @@ -1,13 +1,26 @@ package com.seibel.distanthorizons.common.commands; - -#if MC_VER > MC_1_12_2 +#if MC_VER <= MC_1_12_2 +import com.seibel.distanthorizons.core.config.ConfigHandler; +import com.seibel.distanthorizons.core.config.types.AbstractConfigBase; +import com.seibel.distanthorizons.core.config.types.ConfigEntry; +import com.seibel.distanthorizons.core.logging.f3.F3Screen; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.text.TextComponentString; +#else import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.commands.CommandSourceStack; +import static net.minecraft.commands.Commands.literal; +#endif import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; +import java.util.List; + import static com.seibel.distanthorizons.core.network.messages.MessageRegistry.DEBUG_CODEC_CRASH_MESSAGE; -import static net.minecraft.commands.Commands.literal; #if MC_VER <= MC_1_21_10 #else @@ -25,7 +38,65 @@ public class CommandInitializer private static final PermissionCheck COMMAND_PERMISSION_CHECK = new PermissionCheck.Require(Permissions.COMMANDS_OWNER); #endif - + #if MC_VER <= MC_1_12_2 + public static ICommand initCommands() + { + return new CommandBase() + { + @Override + public String getName() { return "dh"; } + + @Override + public String getUsage(ICommandSender sender) { return "/dh "; } + + @Override + public void execute(MinecraftServer server, ICommandSender sender, String[] args) + { + if (args.length == 0) + { + if (DEBUG_CODEC_CRASH_MESSAGE) + { + sender.sendMessage(new TextComponentString("Usage: /dh ")); + } + else + { + sender.sendMessage(new TextComponentString("Usage: /dh MC_1_12_2 -import com.mojang.brigadier.arguments.*; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.context.CommandContext; import com.seibel.distanthorizons.core.config.ConfigHandler; import com.seibel.distanthorizons.core.config.types.AbstractConfigBase; import com.seibel.distanthorizons.core.config.types.ConfigEntry; + +#if MC_VER <= MC_1_12_2 +import net.minecraft.command.ICommandSender; +import net.minecraft.util.text.TextComponentString; +#else +import com.mojang.brigadier.arguments.*; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.mojang.brigadier.context.CommandContext; import net.minecraft.commands.CommandSourceStack; +import static com.mojang.brigadier.arguments.DoubleArgumentType.doubleArg; +import static com.mojang.brigadier.arguments.IntegerArgumentType.integer; +import static net.minecraft.commands.Commands.argument; +import static net.minecraft.commands.Commands.literal; +#endif + + import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -17,16 +28,73 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.function.ToIntBiFunction; -import static com.mojang.brigadier.arguments.DoubleArgumentType.doubleArg; -import static com.mojang.brigadier.arguments.IntegerArgumentType.integer; -import static net.minecraft.commands.Commands.argument; -import static net.minecraft.commands.Commands.literal; + /** * Command for managing config. */ -public class ConfigCommand extends AbstractCommand +public class ConfigCommand #if MC_VER > MC_1_12_2 extends AbstractCommand #endif { + #if MC_VER <= MC_1_12_2 + @SuppressWarnings({"unchecked", "rawtypes"}) + private static void setConfigValue(ConfigEntry configEntry, String value) + { + Class type = configEntry.getType(); + + if (type == Boolean.class) ((ConfigEntry) configEntry).set(Boolean.parseBoolean(value)); + else if (type == Integer.class) ((ConfigEntry) configEntry).set(Integer.parseInt(value)); + else if (type == Double.class) ((ConfigEntry) configEntry).set(Double.parseDouble(value)); + else if (type == Float.class) ((ConfigEntry) configEntry).set(Float.parseFloat(value)); + else if (type == Long.class) ((ConfigEntry) configEntry).set(Long.parseLong(value)); + else if (type == String.class) ((ConfigEntry) configEntry).set(value); + else if (type.isEnum()) ((ConfigEntry) configEntry).set(Enum.valueOf((Class) type, value)); + else throw new RuntimeException("Unsupported config type: " + type.getSimpleName()); + } + public void execute(ICommandSender sender, String[] args) + { + if (args.length < 2) + { + sender.sendMessage(new TextComponentString("Usage: /dh config [value]")); + return; + } + + String configName = args[1]; + AbstractConfigBase found = null; + for (AbstractConfigBase entry : ConfigHandler.INSTANCE.configBaseList) + { + if (entry instanceof ConfigEntry && configName.equals(((ConfigEntry) entry).getChatCommandName())) + { + found = entry; + break; + } + } + + if (found == null) + { + sender.sendMessage(new TextComponentString("Unknown config: " + configName)); + return; + } + + ConfigEntry configEntry = (ConfigEntry) found; + if (args.length == 2) + { + sender.sendMessage(new TextComponentString("Current value of " + configName + " is " + configEntry.get())); + } + else + { + String value = args[2]; + try + { + setConfigValue(configEntry, value); + sender.sendMessage(new TextComponentString("Changed " + configName + " to " + value)); + } + catch (Exception e) + { + sender.sendMessage(new TextComponentString("Invalid value: " + value)); + } + } + } + #else private static final List> commandArguments = Arrays.asList( new CommandArgumentData<>(Integer.class, configEntry -> integer(configEntry.getMin(), configEntry.getMax()), IntegerArgumentType::getInteger), new CommandArgumentData<>(Double.class, configEntry -> doubleArg(configEntry.getMin(), configEntry.getMax()), DoubleArgumentType::getDouble), @@ -151,6 +219,6 @@ public class ConfigCommand extends AbstractCommand } } + #endif } -#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/CrashCommand.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/CrashCommand.java index d967234b0..ec6007c82 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/CrashCommand.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/CrashCommand.java @@ -1,16 +1,60 @@ package com.seibel.distanthorizons.common.commands; -#if MC_VER > MC_1_12_2 -import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.seibel.distanthorizons.core.api.internal.SharedApi; import com.seibel.distanthorizons.core.multiplayer.server.ServerPlayerState; import com.seibel.distanthorizons.core.network.messages.base.CodecCrashMessage; + +#if MC_VER <= MC_1_12_2 +import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.text.TextComponentString; +#else import net.minecraft.commands.CommandSourceStack; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; import static net.minecraft.commands.Commands.literal; +#endif -public class CrashCommand extends AbstractCommand + +public class CrashCommand #if MC_VER < MC_1_12_2 extends AbstractCommand #endif { + #if MC_VER <= MC_1_12_2 + public void execute(ICommandSender sender, String[] args) + { + if (!(sender instanceof EntityPlayerMP)) + { + sender.sendMessage(new TextComponentString("This command can only be run by a player")); + return; + } + + if (args.length < 2) + { + sender.sendMessage(new TextComponentString("Usage: /dh crash ")); + return; + } + + if (SharedApi.tryGetDhServerWorld() == null) return; + + ServerPlayerState serverPlayerState = SharedApi.tryGetDhServerWorld() + .getServerPlayerStateManager() + .getConnectedPlayer(ServerPlayerWrapper.getWrapper((EntityPlayerMP) sender)); + + if (serverPlayerState == null) return; + + switch (args[1]) + { + case "encode": + serverPlayerState.networkSession.sendMessage(new CodecCrashMessage(CodecCrashMessage.ECrashPhase.ENCODE)); + break; + case "decode": + serverPlayerState.networkSession.sendMessage(new CodecCrashMessage(CodecCrashMessage.ECrashPhase.DECODE)); + break; + default: + sender.sendMessage(new TextComponentString("Usage: /dh crash ")); + } + } + #else @Override public LiteralArgumentBuilder buildCommand() { @@ -41,6 +85,6 @@ public class CrashCommand extends AbstractCommand return 1; })); } + #endif } -#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/DebugCommand.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/DebugCommand.java index 3c92ef3ba..7752dd066 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/DebugCommand.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/DebugCommand.java @@ -1,27 +1,44 @@ package com.seibel.distanthorizons.common.commands; -#if MC_VER > MC_1_12_2 -import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.seibel.distanthorizons.core.logging.f3.F3Screen; + +#if MC_VER <= MC_1_12_2 +import net.minecraft.command.ICommandSender; +import net.minecraft.util.text.TextComponentString; +#else +import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.commands.CommandSourceStack; +import static net.minecraft.commands.Commands.literal; +#endif + import java.util.ArrayList; import java.util.List; -import static net.minecraft.commands.Commands.literal; -public class DebugCommand extends AbstractCommand +public class DebugCommand #if MC_VER > MC_1_12_2 extends AbstractCommand #endif { + private static String getDebugString() + { + List lines = new ArrayList<>(); + F3Screen.addStringToDisplay(lines); + return String.join("\n", lines); + } + + #if MC_VER > MC_1_12_2 @Override public LiteralArgumentBuilder buildCommand() { - return literal("debug") - .executes(c -> { - List lines = new ArrayList<>(); - F3Screen.addStringToDisplay(lines); - return this.sendSuccessResponse(c, String.join("\n", lines), false); - }); + return literal("debug") + .executes(c -> { + return this.sendSuccessResponse(c, getDebugString(), false); + }); } + #else + public void execute(ICommandSender sender) + { + sender.sendMessage(new TextComponentString(getDebugString())); + } + #endif } -#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/PregenCommand.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/PregenCommand.java index a4e259b72..a261bda2d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/PregenCommand.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/PregenCommand.java @@ -1,30 +1,144 @@ package com.seibel.distanthorizons.common.commands; -#if MC_VER > MC_1_12_2 +import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; +import com.seibel.distanthorizons.core.config.Config; +import com.seibel.distanthorizons.core.generation.PregenManager; +import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos2D; +#if MC_VER <= MC_1_12_2 +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.Entity; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.world.WorldServer; +#else import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; -import com.seibel.distanthorizons.core.generation.PregenManager; -import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos2D; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.DimensionArgument; import net.minecraft.commands.arguments.coordinates.ColumnPosArgument; import net.minecraft.server.level.ColumnPos; import net.minecraft.server.level.ServerLevel; -import java.util.concurrent.CancellationException; -import java.util.concurrent.CompletableFuture; - import static com.mojang.brigadier.arguments.IntegerArgumentType.getInteger; import static com.mojang.brigadier.arguments.IntegerArgumentType.integer; import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; +#endif -public class PregenCommand extends AbstractCommand +import java.util.concurrent.CancellationException; +import java.util.concurrent.CompletableFuture; + + +public class PregenCommand #if MC_VER > MC_1_12_2 extends AbstractCommand #endif { - private final PregenManager pregenManager = new PregenManager(); + #if MC_VER <= MC_1_12_2 + private static final PregenManager pregenManager = new PregenManager(); + #else + private final PregenManager pregenManager = new PregenManager(); + #endif + #if MC_VER <= MC_1_12_2 + public void execute(MinecraftServer server, ICommandSender sender, String[] args) + { + if (args.length < 2) + { + sender.sendMessage(new TextComponentString("Usage: /dh pregen ")); + return; + } + + switch (args[1]) + { + case "status": + { + String statusString = this.pregenManager.getStatusString(); + sender.sendMessage(new TextComponentString( + statusString != null ? statusString : "Pregen is not running")); + break; + } + case "start": + { + if (args.length < 5) + { + sender.sendMessage(new TextComponentString("Usage: /dh pregen start ")); + return; + } + + if (!Config.Common.WorldGenerator.enableDistantGeneration.get()) + { + sender.sendMessage(new TextComponentString("Warning: Distant generation is disabled. Enable it in config for pregen to work.")); + return; + } + + try + { + String dimensionName = args[2]; + int x = Integer.parseInt(args[3]); + int z = Integer.parseInt(args[4]); + int chunkRadius = args.length >= 6 ? Integer.parseInt(args[5]) : 32; + + // find the world by dimension name + WorldServer world = null; + for (WorldServer w : server.worlds) + { + if (w.provider.getDimensionType().getName().equals(dimensionName)) + { + world = w; + break; + } + } + + if (world == null) + { + sender.sendMessage(new TextComponentString("Unknown dimension: " + dimensionName)); + return; + } + + sender.sendMessage(new TextComponentString("Starting pregen. Progress will be in the server console.")); + + final ICommandSender finalSender = sender; + CompletableFuture future = this.pregenManager.startPregen( + ServerLevelWrapper.getWrapper(world), + new DhBlockPos2D(x, z), + chunkRadius + ); + + future.whenComplete((result, throwable) -> { + if (throwable instanceof CancellationException) + { + finalSender.sendMessage(new TextComponentString("Pregen is cancelled")); + return; + } + else if (throwable != null) + { + finalSender.sendMessage(new TextComponentString("Pregen failed: " + throwable.getMessage())); + return; + } + finalSender.sendMessage(new TextComponentString("Pregen is complete")); + }); + } + catch (NumberFormatException e) + { + sender.sendMessage(new TextComponentString("Invalid number format")); + } + break; + } + case "stop": + { + CompletableFuture runningPregen = this.pregenManager.getRunningPregen(); + if (runningPregen == null) + { + sender.sendMessage(new TextComponentString("Pregen is not running")); + return; + } + runningPregen.cancel(true); + break; + } + default: + sender.sendMessage(new TextComponentString("Unknown subcommand: " + args[1])); + } + } + #else @Override public LiteralArgumentBuilder buildCommand() { @@ -104,6 +218,5 @@ public class PregenCommand extends AbstractCommand runningPregen.cancel(true); return 1; } - + #endif } -#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java index 9ed97342d..ad316a03d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java @@ -84,7 +84,7 @@ public class MixinChunkMapCommon #endif - + //System.out.println("SUBMITTING: " + chunk.getPos()); // submit the update event ServerApi.INSTANCE.serverChunkSaveEvent( new ChunkWrapper(chunk, levelWrapper), diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/GlDhTerrainShaderProgram.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/GlDhTerrainShaderProgram.java index 2d051735a..df56b35c4 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/GlDhTerrainShaderProgram.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/GlDhTerrainShaderProgram.java @@ -69,9 +69,10 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS private static final IIrisAccessor IRIS_ACCESSOR = ModAccessorInjector.INSTANCE.get(IIrisAccessor.class); + private boolean init = false; public GlQuadElementBuffer quadIBO = null; - public final GlAbstractVertexAttribute vao; + public GlAbstractVertexAttribute vao; // uniforms // //region @@ -113,6 +114,11 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS "assets/distanthorizons/shaders/shared/gl/flat_shaded.frag", new String[]{"vPosition", "color"} ); + } + + public void init() + { + if (this.init) return; this.uCombinedMatrix = this.getUniformLocation("uCombinedMatrix"); this.uModelOffset = this.getUniformLocation("uModelOffset"); @@ -165,6 +171,9 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS throw e; } + this.vao.unbind(); + + this.init = true; } //endregion @@ -179,6 +188,7 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS @Override public void bind() { + this.init(); super.bind(); this.vao.bind(); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java index 73fafbbe3..c314b5881 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java @@ -46,17 +46,18 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.worldGeneration.IBatchGeneratorEnvironmentWrapper; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; + +#if MC_VER > MC_1_17_1 +import net.minecraft.core.Holder; +#endif + +#if MC_VER <= MC_1_12_2 import net.minecraft.block.state.IBlockState; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.Chunk; -#if MC_VER > MC_1_17_1 -import net.minecraft.core.Holder; -#endif - -#if MC_VER <= MC_1_12_2 #else import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.server.level.ServerLevel; @@ -110,8 +111,7 @@ public class WrapperFactory implements IWrapperFactory { if (targetLevel instanceof IDhServerLevel) { - //return new BatchGenerationEnvironment((IDhServerLevel) targetLevel); - return null; + return new BatchGenerationEnvironment((IDhServerLevel) targetLevel); } else { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index 2b1a6b597..a1f06f2d3 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -37,6 +37,7 @@ import net.minecraft.init.Blocks; import net.minecraft.block.BlockLiquid; import net.minecraft.block.state.IBlockState; import net.minecraft.block.properties.IProperty; +import net.minecraftforge.fluids.IFluidBlock; #else import net.minecraft.tags.BlockTags; import net.minecraft.world.level.block.BeaconBeamBlock; @@ -55,7 +56,6 @@ import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; -import net.minecraftforge.fluids.IFluidBlock; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -98,7 +98,7 @@ public class BlockStateWrapper implements IBlockStateWrapper // must be defined before AIR, otherwise a null pointer will be thrown private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - public static final ConcurrentHashMap<#if MC_VER >= MC_1_12_2 IBlockState #else BlockState #endif, BlockStateWrapper> WRAPPER_BY_BLOCK_STATE = new ConcurrentHashMap<>(); + public static final ConcurrentHashMap<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, BlockStateWrapper> WRAPPER_BY_BLOCK_STATE = new ConcurrentHashMap<>(); public static final ConcurrentHashMap WRAPPER_BY_RESOURCE_LOCATION = new ConcurrentHashMap<>(); public static final String AIR_STRING = "AIR"; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java index a2f188271..991c30d87 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java @@ -28,16 +28,17 @@ import com.seibel.distanthorizons.core.util.ColorUtil; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.block.model.BakedQuad; #if MC_VER <= MC_1_12_2 import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; import net.minecraft.block.BlockRotatedPillar; import net.minecraft.block.*; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.renderer.color.BlockColors; +import net.minecraft.util.math.BlockPos; #else import net.minecraft.core.Direction; import net.minecraft.world.level.block.*; @@ -47,10 +48,14 @@ import net.minecraft.world.level.block.state.properties.SlabType; #if MC_VER >= MC_1_19_2 import net.minecraft.util.RandomSource; #else -import java.util.*; +import java.util.Random; #endif + +import java.util.Collections; +import java.util.HashSet; +import java.util.List; + import com.seibel.distanthorizons.core.logging.DhLogger; -import net.minecraft.util.math.BlockPos; import org.jetbrains.annotations.Nullable; import java.util.concurrent.locks.ReentrantLock; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java index 9d966686e..24f3adadd 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java @@ -46,6 +46,7 @@ import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import com.mojang.blaze3d.platform.InputConstants; +import org.lwjgl.glfw.GLFW; #endif import com.seibel.distanthorizons.core.logging.DhLogger; import org.jetbrains.annotations.NotNull; @@ -1097,7 +1098,7 @@ public class ClassicConfigGUI public static class DhButtonEntry #if MC_VER > MC_1_12_2 extends ContainerObjectSelectionList.Entry #endif { - private static final #if MC_VER <= MC_1_12_2 FontRenderer #else Font #endif textRenderer = Minecraft. #if MC_VER <= MC_1_12_2 getMinecraft().fontRenderer; #else .getInstance().font; #endif + private static final #if MC_VER <= MC_1_12_2 FontRenderer #else Font #endif textRenderer = Minecraft. #if MC_VER <= MC_1_12_2 getMinecraft().fontRenderer; #else getInstance().font; #endif private final #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif button; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/config/ConfigGuiInfo.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/config/ConfigGuiInfo.java index 1d20765aa..3638da5ed 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/config/ConfigGuiInfo.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/config/ConfigGuiInfo.java @@ -1,9 +1,9 @@ package com.seibel.distanthorizons.common.wrappers.gui.config; -import com.seibel.distanthorizons.common.wrappers.gui.OnPressed; import com.seibel.distanthorizons.core.config.gui.IConfigGuiInfo; import com.seibel.distanthorizons.core.config.types.AbstractConfigBase; #if MC_VER <= MC_1_12_2 +import com.seibel.distanthorizons.common.wrappers.gui.OnPressed; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; import net.minecraft.util.text.ITextComponent; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java index ebf404981..ad99bc520 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java @@ -34,10 +34,10 @@ import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos; import com.seibel.distanthorizons.core.pos.DhChunkPos; import com.seibel.distanthorizons.core.logging.DhLogger; -#if MC_VER <= MC_1_12_2 -import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ServerData; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.crash.CrashReport; import net.minecraft.profiler.Profiler; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/LightMapWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/LightMapWrapper.java index 52d618493..22e6edd57 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/LightMapWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/LightMapWrapper.java @@ -23,6 +23,7 @@ package com.seibel.distanthorizons.common.wrappers.misc; import com.mojang.blaze3d.platform.NativeImage; import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper; #endif +import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper; import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; @@ -35,7 +36,7 @@ import java.nio.ByteBuffer; #else #endif -#if MC_VER <= MC_1_21_10 && MC_VER > MC_1_12_2 +#if MC_VER <= MC_1_21_10 #else import com.mojang.blaze3d.textures.GpuTexture; #endif @@ -52,12 +53,7 @@ public class LightMapWrapper implements ILightMapWrapper public static final int GL_BOUND_INDEX = 0; private int textureId = 0; - #if MC_VER <= MC_1_12_2 - private int lastTextureId = 0; - private int lastTextureUnit = GL32.GL_TEXTURE0; - #endif - #if MC_VER <= MC_1_21_10 #else private GpuTexture gpuTexture = null; @@ -126,7 +122,7 @@ public class LightMapWrapper implements ILightMapWrapper this.textureId = minecraftLightmapTextureId; } - #if MC_VER <= MC_1_21_10 && MC_VER > MC_1_12_2 + #if MC_VER <= MC_1_21_10 #else public void setLightmapGpuTexture(GpuTexture gpuTexture) { @@ -145,31 +141,6 @@ public class LightMapWrapper implements ILightMapWrapper //==============// //region - @Override - public void bind() - { - #if MC_VER <= MC_1_12_2 - //1.12.2 If we don't bind MC texture back vanilla rendering will break - lastTextureUnit = GL32.glGetInteger(GL32.GL_ACTIVE_TEXTURE); - GLMC.glActiveTexture(GL32.GL_TEXTURE0 + ILightMapWrapper.BOUND_INDEX); - lastTextureId = GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D); - #else - GLMC.glActiveTexture(GL32.GL_TEXTURE0 + ILightMapWrapper.BOUND_INDEX); - #endif - GLMC.glBindTexture(this.textureId); - } - - @Override - public void unbind() - { - #if MC_VER <= MC_1_12_2 - GLMC.glBindTexture(lastTextureId); - GLMC.glActiveTexture(lastTextureUnit); - #else - GLMC.glBindTexture(0); - #endif - } - public BlazeTextureViewWrapper getTextureViewWrapper() { return this.lightmapTextureWrapper; } public int getOpenGlId() { return this.textureId; } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java index b3c3618d1..05e6eeb7f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java @@ -19,12 +19,13 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IDimensionTypeWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper; -import net.minecraft.block.state.IBlockState; + import net.minecraft.client.Minecraft; #if MC_VER <= MC_1_12_2 import net.minecraft.util.math.Vec3d; import net.minecraft.world.WorldServer; import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.block.state.IBlockState; #else import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.BlockPos; @@ -542,6 +543,4 @@ public class ClientLevelWrapper implements IClientLevelWrapper //endregion - - } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ServerLevelWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ServerLevelWrapper.java index 31a5a964f..1a939a44a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ServerLevelWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ServerLevelWrapper.java @@ -39,7 +39,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper; #if MC_VER <= MC_1_12_2 - +import net.minecraft.world.WorldServer; #else import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.Level; @@ -55,7 +55,6 @@ import net.minecraft.world.level.chunk.status.ChunkStatus; #endif import com.seibel.distanthorizons.core.logging.DhLogger; -import net.minecraft.world.WorldServer; import org.jetbrains.annotations.Nullable; public class ServerLevelWrapper implements IServerLevelWrapper diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 4ae876413..ad70191f1 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -27,8 +27,8 @@ import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGeneratio import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; #if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.common.wrappers.worldGeneration.chunkFileHandling.ChunkFileReader; -#endif import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.*; +#endif import com.seibel.distanthorizons.common.wrappers.worldGeneration.params.GlobalWorldGenParams; import com.seibel.distanthorizons.core.api.internal.SharedApi; import com.seibel.distanthorizons.core.api.internal.chunkUpdating.ChunkUpdateQueueManager; @@ -67,6 +67,8 @@ import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepSurfa #endif #if MC_VER <= MC_1_12_2 +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.ForgeChunkManager; #else import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.chunk.*; @@ -588,6 +590,7 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm // direct generation // + #if MC_VER > MC_1_12_2 public void generateDirect( GenerationEvent genEvent, ArrayGridList chunkWrappersToGenerate, DhLitWorldGenRegion region) throws InterruptedException @@ -759,7 +762,7 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm } private static ArrayGridList GetCutoutFrom(ArrayGridList total, int border) { return new ArrayGridList<>(total, border, total.gridSize - border); } private static ArrayGridList GetCutoutFrom(ArrayGridList total, EDhApiWorldGenerationStep step) { return GetCutoutFrom(total, WORLD_GEN_CHUNK_BORDER_NEEDED_BY_GEN_STEP.get(step)); } - + #endif // queue task // @@ -800,8 +803,13 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm } + #if MC_VER <= MC_1_12_2 + WorldServer worldServer = (WorldServer) this.dhServerLevel.getServerLevelWrapper().getWrappedMcObject(); + InternalServerGenerator.DH_SERVER_GEN_TICKET_MAP.remove(worldServer); + ForgeChunkManager.releaseTicket(InternalServerGenerator.DH_SERVER_GEN_TICKET_MAP.get(worldServer)); + #else this.chunkFileReader.close(); - + #endif } @@ -829,12 +837,12 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm // helper classes // //================// + #if MC_VER > MC_1_12_2 @FunctionalInterface public interface IEmptyChunkRetrievalFunc { ChunkAccess getChunk(int chunkPosX, int chunkPosZ); } - - + #endif } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java index abd35c733..3bbb22808 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java @@ -26,6 +26,7 @@ import com.seibel.distanthorizons.coreapi.ModInfo; #if MC_VER <= MC_1_12_2 import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.gen.ChunkProviderServer; @@ -73,7 +74,8 @@ public class InternalServerGenerator private static final int MS_TO_IGNORE_CHUNK_AFTER_COMPLETION = 5_000; #if MC_VER <= MC_1_12_2 - public static ForgeChunkManager.Ticket DH_SERVER_GEN_TICKET = null; + public static Map DH_SERVER_GEN_TICKET_MAP = new HashMap<>(); + private final ForgeChunkManager.Ticket DH_SERVER_GEN_TICKET; #elif MC_VER < MC_1_21_5 private static final TicketType DH_SERVER_GEN_TICKET = TicketType.create("dh_server_gen_ticket", Comparator.comparingLong(ChunkPos::toLong)); #elif MC_VER < MC_1_21_9 @@ -99,6 +101,13 @@ public class InternalServerGenerator { this.params = params; this.dhServerLevel = dhServerLevel; + #if MC_VER <= MC_1_12_2 + this.DH_SERVER_GEN_TICKET = DH_SERVER_GEN_TICKET_MAP.get((WorldServer) this.dhServerLevel.getServerLevelWrapper().getWrappedMcObject()); + if (this.DH_SERVER_GEN_TICKET == null) + { + LOGGER.error("DH_SERVER_GEN_TICKET is null for level: " + dhServerLevel.getServerLevelWrapper().getDimensionName()); + } + #endif } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java index 558b232c9..e92e280bf 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java @@ -19,6 +19,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject; +#if MC_VER > MC_1_12_2 import java.util.Iterator; import java.util.List; import java.util.Map; @@ -274,3 +275,4 @@ public class WorldGenStructFeatManager extends #if MC_VER < MC_1_19_2 StructureF #endif #endif } +#endif \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 51b30aacf..c52ffc70c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,16 @@ pluginManagement { + + resolutionStrategy { + eachPlugin { + if (requested.id.id == "dev.architectury.loom") { + def mcVer = settings.startParameter.projectProperties.get("mcVer") ?: settings.providers.gradleProperty("mcVer").getOrElse("1.20.1") + if (mcVer == "1.12.2") { + useVersion("1.0-SNAPSHOT") + } + } + } + } + repositories { maven { name "Fabric" From 3df5c04759734d04531d0e4ce1e9c26a371a1260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Sun, 15 Mar 2026 22:10:03 +0100 Subject: [PATCH 04/68] Fix issue when MC framebuffer is using renderbuffer for depth --- .../common/render/openGl/glObject/GLState.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/GLState.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/GLState.java index 6107a7a24..b66c410b7 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/GLState.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/GLState.java @@ -97,7 +97,9 @@ public class GLState implements AutoCloseable { this.frameBufferTexture0 = GL32.glGetFramebufferAttachmentParameteri(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME); this.frameBufferTexture1 = GL32.glGetFramebufferAttachmentParameteri(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT1, GL32.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME); - this.frameBufferDepthTexture = GL32.glGetFramebufferAttachmentParameteri(GL32.GL_FRAMEBUFFER, GL32.GL_DEPTH_ATTACHMENT, GL32.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME); + + int depthType = GL32.glGetFramebufferAttachmentParameteri(GL32.GL_FRAMEBUFFER, GL32.GL_DEPTH_ATTACHMENT, GL32.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE); + this.frameBufferDepthTexture = (depthType == GL32.GL_TEXTURE) ? GL32.glGetFramebufferAttachmentParameteri(GL32.GL_FRAMEBUFFER, GL32.GL_DEPTH_ATTACHMENT, GL32.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) : 0; } else { @@ -179,9 +181,14 @@ public class GLState implements AutoCloseable // attempting to set textures on the default frame buffer (ID 0) will throw errors if (frameBufferSet) { - GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_TEXTURE_2D, this.frameBufferTexture0, 0); - GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT1, GL32.GL_TEXTURE_2D, this.frameBufferTexture1, 0); - GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_DEPTH_ATTACHMENT, GL32.GL_TEXTURE_2D, this.frameBufferDepthTexture, 0); + if (GL32.glIsTexture(this.frameBufferTexture0)) + GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_TEXTURE_2D, this.frameBufferTexture0, 0); + + if (this.frameBufferTexture1 != 0 && GL32.glIsTexture(this.frameBufferTexture1)) + GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT1, GL32.GL_TEXTURE_2D, this.frameBufferTexture1, 0); + + if (GL32.glIsTexture(this.frameBufferDepthTexture)) + GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_DEPTH_ATTACHMENT, GL32.GL_TEXTURE_2D, this.frameBufferDepthTexture, 0); } GL32.glBindVertexArray(GL32.glIsVertexArray(this.vao) ? this.vao : 0); From 73c718c676918c969f5647fa514a9fb43443d2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Sun, 15 Mar 2026 22:13:07 +0100 Subject: [PATCH 05/68] [1.12.2] improve config gui to match other versions --- .../common/wrappers/gui/ClassicConfigGUI.java | 142 +++++++++++------- .../common/wrappers/gui/MinecraftScreen.java | 26 +++- 2 files changed, 108 insertions(+), 60 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java index 79a7594da..b7c365ff5 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java @@ -30,6 +30,7 @@ import com.seibel.distanthorizons.coreapi.ModInfo; #if MC_VER <= MC_1_12_2 import net.minecraft.client.Minecraft; import net.minecraft.client.gui.*; +import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.Style; import net.minecraft.util.text.TextFormatting; @@ -554,7 +555,7 @@ public class ClassicConfigGUI configEntry.uiSetWithoutSaving(configEntry.getDefaultValue()); this.reload = true; #if MC_VER <= MC_1_12_2 - Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); + Objects.requireNonNull(this.mc).displayGuiScreen(ClassicConfigGUI.getScreen(this.parent, this.category)); #else Objects.requireNonNull(this.minecraft).setScreen(this.parent); #endif @@ -782,8 +783,11 @@ public class ClassicConfigGUI super.render(matrices, mouseX, mouseY, delta); #endif - this.configListWidget.render(#if MC_VER > MC_1_12_2 matrices,#endif mouseX, mouseY, delta); // Render buttons - + #if MC_VER <= MC_1_12_2 + this.configListWidget.drawScreen(mouseX, mouseY, delta); // Render buttons + #else + this.configListWidget.render(matrices, mouseX, mouseY, delta); // Render buttons + #endif // Render config title this.DhDrawCenteredString( @@ -826,18 +830,13 @@ public class ClassicConfigGUI #endif); } - - this.renderTooltip( - #if MC_VER > MC_1_12_2 - matrices, - #endif - mouseX, mouseY, delta); - #if MC_VER <= MC_1_12_2 super.drawScreen(mouseX, mouseY, delta); #elif MC_VER < MC_1_20_2 super.render(matrices, mouseX, mouseY, delta); #endif + + this.renderTooltip(#if MC_VER > MC_1_12_2 matrices,#endif mouseX, mouseY, delta); } #if MC_VER <= MC_1_12_2 @@ -914,31 +913,32 @@ public class ClassicConfigGUI { super.mouseClicked(mouseX, mouseY, mouseButton); - for (ClassicConfigGUI.DhButtonEntry entry : this.configListWidget.children) + if (mouseY >= this.configListWidget.top && mouseY <= this.configListWidget.bottom) { - if (entry.button instanceof GuiButton btn && btn.visible) + for (ClassicConfigGUI.DhButtonEntry entry : this.configListWidget.children) { - if (mouseX >= btn.x && mouseX < btn.x + btn.width - && mouseY >= btn.y && mouseY < btn.y + btn.height) + if (entry.button instanceof GuiButton btn && btn.visible) { - btn.mousePressed(this.mc, mouseX, mouseY); - OnPressed handler = GuiHelper.HANDLER_BY_BUTTON.get(btn); - if (handler != null) handler.pressed(btn); + if (btn.mousePressed(this.mc, mouseX, mouseY)) + { + btn.playPressSound(this.mc.getSoundHandler()); + OnPressed handler = GuiHelper.HANDLER_BY_BUTTON.get(btn); + if (handler != null) handler.pressed(btn); + } } - } - else if (entry.button instanceof GuiTextField field && field.getVisible()) - { - field.mouseClicked(mouseX, mouseY, mouseButton); - } - - if (entry.resetButton instanceof GuiButton reset && reset.visible) - { - if (mouseX >= reset.x && mouseX < reset.x + reset.width - && mouseY >= reset.y && mouseY < reset.y + reset.height) + else if (entry.button instanceof GuiTextField field && field.getVisible()) { - reset.mousePressed(this.mc, mouseX, mouseY); - OnPressed handler = GuiHelper.HANDLER_BY_BUTTON.get(reset); - if (handler != null) handler.pressed(reset); + field.mouseClicked(mouseX, mouseY, mouseButton); + } + + if (entry.resetButton instanceof GuiButton reset && reset.visible) + { + if (reset.mousePressed(this.mc, mouseX, mouseY)) + { + reset.playPressSound(this.mc.getSoundHandler()); + OnPressed handler = GuiHelper.HANDLER_BY_BUTTON.get(reset); + if (handler != null) handler.pressed(reset); + } } } } @@ -956,7 +956,15 @@ public class ClassicConfigGUI } } } -#endif + + @Override + public void handleMouseInput() throws java.io.IOException + { + super.handleMouseInput(); + this.configListWidget.handleMouseInput(); + } + + #endif //==========// // shutdown // @@ -986,17 +994,16 @@ public class ClassicConfigGUI // helper classes // //================// - public static class ConfigListWidget #if MC_VER > MC_1_12_2 extends ContainerObjectSelectionList #endif + public static class ConfigListWidget extends #if MC_VER <= MC_1_12_2 GuiListExtended #else ContainerObjectSelectionList #endif { #if MC_VER <= MC_1_12_2 private List children = new ArrayList<>(); - #else - Font textRenderer; #endif + #if MC_VER <= MC_1_12_2 FontRenderer #else Font #endif textRenderer; + public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing) { - #if MC_VER > MC_1_12_2 #if MC_VER < MC_1_20_4 super(minecraftClient, canvasWidth, canvasHeight, topMargin, canvasHeight - botMargin, itemSpacing); #else @@ -1004,10 +1011,34 @@ public class ClassicConfigGUI #endif this.centerListVertically = false; - this.textRenderer = minecraftClient.font; - #endif + this.textRenderer = minecraftClient.#if MC_VER <= MC_1_12_2 fontRenderer #else font #endif; } + #if MC_VER<= MC_1_12_2 + @Override + protected int getSize() + { + return this.children.size(); + } + + @Override + public IGuiListEntry getListEntry(int index) + { + return this.children.get(index); + } + + @Override + protected void drawContainerBackground(Tessellator tessellator) + { + if (this.mc.world != null) + { + return; // in-game don't draw dirt background + } + super.drawContainerBackground(tessellator); + } + + #endif + #if MC_VER <= MC_1_12_2 public void addButton(DhConfigScreen gui, AbstractConfigBase dhConfigType, Gui button, GuiButton resetButton, GuiButton indexButton, ITextComponent text) #else @@ -1015,10 +1046,8 @@ public class ClassicConfigGUI #endif { this.#if MC_VER <= MC_1_12_2 children.add #else addEntry #endif(new DhButtonEntry(gui, dhConfigType, button, text, resetButton, indexButton)); } - #if MC_VER > MC_1_12_2 @Override - public int getRowWidth() { return 10_000; } - #endif + public int #if MC_VER <= MC_1_12_2 getListWidth() #else getRowWidth() #endif { return 10_000; } public #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif getHoveredButton(double mouseX, double mouseY) { @@ -1074,27 +1103,16 @@ public class ClassicConfigGUI { return button; } - #endif + #endif } return null; } - #if MC_VER <= MC_1_12_2 - public void render(int mouseX, int mouseY, float delta) { - int y = 40; - for (DhButtonEntry buttonEntry : this.children) - { - buttonEntry.render(y, 0, mouseX, mouseY, delta); - y += 25; - } - } - #endif - } - public static class DhButtonEntry #if MC_VER > MC_1_12_2 extends ContainerObjectSelectionList.Entry #endif + public static class DhButtonEntry #if MC_VER <= MC_1_12_2 implements GuiListExtended.IGuiListEntry #else extends ContainerObjectSelectionList.Entry #endif { private static final #if MC_VER <= MC_1_12_2 FontRenderer #else Font #endif textRenderer = Minecraft. #if MC_VER <= MC_1_12_2 getMinecraft().fontRenderer; #else getInstance().font; #endif @@ -1160,9 +1178,9 @@ public class ClassicConfigGUI } - #if MC_VER <= MC_1_12_2 - public void render(int y, int x, int mouseX, int mouseY, float tickDelta) + @Override + public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float tickDelta) #elif MC_VER < MC_1_20_1 @Override public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) @@ -1292,6 +1310,20 @@ public class ClassicConfigGUI } } + #if MC_VER <= MC_1_12_2 + @Override + public void updatePosition(int slotIndex, int x, int y, float partialTicks) { } + + @Override + public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY) + { + return false; // handled in DhConfigScreen.mouseClicked + } + + @Override + public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) { } + #endif + #if MC_VER > MC_1_12_2 @Override public @NotNull List children() diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java index 1a6dffca5..6f1fe3c53 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java @@ -1,6 +1,8 @@ package com.seibel.distanthorizons.common.wrappers.gui; #if MC_VER <= MC_1_12_2 +import net.minecraft.client.gui.GuiListExtended; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiSlot; import org.lwjglx.opengl.Display; #else import net.minecraft.client.gui.components.ContainerObjectSelectionList; @@ -101,7 +103,7 @@ public class MinecraftScreen #endif { #if MC_VER <= MC_1_12_2 - this.drawDefaultBackground(); + //this.drawDefaultBackground(); // seems to do nothing #elif MC_VER < MC_1_20_2 this.renderBackground(matrices); // Render background #elif MC_VER < MC_1_21_6 @@ -110,7 +112,9 @@ public class MinecraftScreen // background blur is already being rendered, rendering again causes the game to crash #endif - #if MC_VER > MC_1_12_2 + #if MC_VER <= MC_1_12_2 + //this.configListWidget.drawScreen(mouseX, mouseY, delta); // seems to do nothing + #else this.configListWidget.render(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker) #endif @@ -204,20 +208,32 @@ public class MinecraftScreen #endif } - public static class ConfigListWidget #if MC_VER > MC_1_12_2 extends ContainerObjectSelectionList #endif + public static class ConfigListWidget extends #if MC_VER <= MC_1_12_2 GuiListExtended #else ContainerObjectSelectionList #endif { public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing) { - #if MC_VER > MC_1_12_2 #if MC_VER < MC_1_20_4 super(minecraftClient, canvasWidth, canvasHeight, topMargin, canvasHeight - botMargin, itemSpacing); #else super(minecraftClient, canvasWidth, canvasHeight - (topMargin + botMargin), topMargin, itemSpacing); #endif this.centerListVertically = false; - #endif } + #if MC_VER <= MC_1_12_2 + @Override + protected int getSize() + { + return 0; + } + @Override + public IGuiListEntry getListEntry(int index) + { + return null; + } + #endif + + } } From 266d463873106fdfa0d2218c79dbfad9b8fa3ccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Sun, 15 Mar 2026 23:14:54 +0100 Subject: [PATCH 06/68] fix compile errors --- .../seibel/distanthorizons/common/AbstractModInitializer.java | 2 +- .../seibel/distanthorizons/common/commands/CrashCommand.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java b/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java index 32137048c..fafc48283 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java @@ -149,7 +149,7 @@ public abstract class AbstractModInitializer this.checkForUpdates(); - LOGGER.info(ModInfo.READABLE_NAME + " server Initialized at " + server.getServerDirectory()); + LOGGER.info(ModInfo.READABLE_NAME + " server Initialized at " + server. #if MC_VER <= MC_1_12_2 getDataDirectory() #else getServerDirectory() #endif); }); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/CrashCommand.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/CrashCommand.java index ec6007c82..4c064aca6 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/CrashCommand.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/CrashCommand.java @@ -17,7 +17,7 @@ import static net.minecraft.commands.Commands.literal; #endif -public class CrashCommand #if MC_VER < MC_1_12_2 extends AbstractCommand #endif +public class CrashCommand #if MC_VER > MC_1_12_2 extends AbstractCommand #endif { #if MC_VER <= MC_1_12_2 public void execute(ICommandSender sender, String[] args) From c75595a5e27b57a61dce759c0536fe5fcc43b8f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Sun, 15 Mar 2026 23:17:12 +0100 Subject: [PATCH 07/68] [1.12.2] implement pregen command --- .../common/commands/CommandInitializer.java | 14 +- .../common/commands/PregenCommand.java | 122 ++++++++++++++++-- 2 files changed, 121 insertions(+), 15 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/CommandInitializer.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/CommandInitializer.java index fd3db3273..42a1739b5 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/CommandInitializer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/CommandInitializer.java @@ -47,7 +47,7 @@ public class CommandInitializer public String getName() { return "dh"; } @Override - public String getUsage(ICommandSender sender) { return "/dh "; } + public String getUsage(ICommandSender sender) { return "/dh "; } @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) @@ -56,11 +56,11 @@ public class CommandInitializer { if (DEBUG_CODEC_CRASH_MESSAGE) { - sender.sendMessage(new TextComponentString("Usage: /dh ")); + sender.sendMessage(new TextComponentString("Usage: /dh ")); } else { - sender.sendMessage(new TextComponentString("Usage: /dh MC_1_12_2 extends AbstractCommand #endif { private PregenManager getPregenManager() { @@ -31,6 +40,101 @@ public class PregenCommand extends AbstractCommand return world.getPregenManager(); } + #if MC_VER <= MC_1_12_2 + public void execute(MinecraftServer server, ICommandSender sender, String[] args) + { + if (args.length < 2) + { + sender.sendMessage(new TextComponentString("Usage: /dh pregen ")); + return; + } + + switch (args[1]) + { + case "status": + { + String statusString = this.getPregenManager().getStatusString(); + sender.sendMessage(new TextComponentString( + statusString != null ? statusString : "Pregen is not running")); + break; + } + case "start": + { + if (args.length < 5) + { + sender.sendMessage(new TextComponentString("Usage: /dh pregen start ")); + return; + } + + try + { + String dimensionName = args[2]; + int x = Integer.parseInt(args[3]); + int z = Integer.parseInt(args[4]); + int chunkRadius = args.length >= 6 ? Integer.parseInt(args[5]) : 32; + + // find the world by dimension name + WorldServer world = null; + for (WorldServer w : server.worlds) + { + if (w.provider.getDimensionType().getName().equals(dimensionName)) + { + world = w; + break; + } + } + + if (world == null) + { + sender.sendMessage(new TextComponentString("Unknown dimension: " + dimensionName)); + return; + } + + sender.sendMessage(new TextComponentString("Starting pregen. Progress will be in the server console.")); + + final ICommandSender finalSender = sender; + CompletableFuture future = this.getPregenManager().startPregen( + ServerLevelWrapper.getWrapper(world), + new DhBlockPos2D(x, z), + chunkRadius + ); + + future.whenComplete((result, throwable) -> { + if (throwable instanceof CancellationException) + { + finalSender.sendMessage(new TextComponentString("Pregen is cancelled")); + return; + } + else if (throwable != null) + { + finalSender.sendMessage(new TextComponentString("Pregen failed: " + throwable.getMessage())); + return; + } + finalSender.sendMessage(new TextComponentString("Pregen is complete")); + }); + } + catch (NumberFormatException e) + { + sender.sendMessage(new TextComponentString("Invalid number format")); + } + break; + } + case "stop": + { + CompletableFuture runningPregen = this.getPregenManager().getRunningPregen(); + if (runningPregen == null) + { + sender.sendMessage(new TextComponentString("Pregen is not running")); + return; + } + runningPregen.cancel(true); + break; + } + default: + sender.sendMessage(new TextComponentString("Unknown subcommand: " + args[1])); + } + } + #else @Override public LiteralArgumentBuilder buildCommand() { @@ -110,5 +214,5 @@ public class PregenCommand extends AbstractCommand runningPregen.cancel(true); return 1; } - + #endif } From 4f9d4e2a14d8a064591e3f97bc7e064a2d6cad38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Sun, 15 Mar 2026 23:31:13 +0100 Subject: [PATCH 08/68] Fix compile error --- .../wrappers/worldGeneration/BatchGenerationEnvironment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 9148036f4..4fa0281fe 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -93,8 +93,9 @@ import net.minecraft.core.registries.Registries; import net.minecraft.world.level.chunk.ChunkStatus; #else import net.minecraft.world.level.chunk.status.ChunkStatus; -import org.jetbrains.annotations.Nullable; #endif +import org.jetbrains.annotations.Nullable; + public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironmentWrapper { From 059293ebe0ea15999a53dd407660c98415882879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Sun, 15 Mar 2026 23:31:35 +0100 Subject: [PATCH 09/68] Add missing shaders into cleanroom project --- .../distanthorizons/shaders/fade/gl/{dhFade.frag => dh_fade.frag} | 0 .../shaders/fade/gl/{vanillaFade.frag => vanilla_fade.frag} | 0 .../shaders/shared/gl/{quadApply.vert => quad_apply.vert} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/{dhFade.frag => dh_fade.frag} (100%) rename cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/{vanillaFade.frag => vanilla_fade.frag} (100%) rename cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/{quadApply.vert => quad_apply.vert} (100%) diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/dhFade.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/dh_fade.frag similarity index 100% rename from cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/dhFade.frag rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/dh_fade.frag diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/vanillaFade.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/vanilla_fade.frag similarity index 100% rename from cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/vanillaFade.frag rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/vanilla_fade.frag diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/quadApply.vert b/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/quad_apply.vert similarity index 100% rename from cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/quadApply.vert rename to cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/quad_apply.vert From 7e1e5a56e2e62b55c72cac2628dc5aa582aceb87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Sun, 15 Mar 2026 23:41:13 +0100 Subject: [PATCH 10/68] Set back 1.21.11 as default mcVer --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 1ff806ea4..7cc0dc5db 100644 --- a/gradle.properties +++ b/gradle.properties @@ -52,7 +52,7 @@ versionStr= # This defines what MC version Intellij will use for the preprocessor # and what version is used automatically by build and run commands -mcVer=1.12.2 +mcVer=1.21.11 # Defines the maximum amount of memory Minecraft is allowed when run in a development environment #minecraftMemoryJavaArg="-Xmx4G" From 9fea29cbb69a8f7640070a074bf55e5ab131259e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Tue, 17 Mar 2026 15:46:00 +0100 Subject: [PATCH 11/68] Put canvas back --- build.gradle | 4 ++++ .../common/wrappers/block/ClientBlockStateColorCache.java | 1 + settings.gradle | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 915988bd4..78bb4b2ce 100644 --- a/build.gradle +++ b/build.gradle @@ -35,6 +35,7 @@ plugins { // Architectury is used here only as a replacement for forge's own loom id "dev.architectury.loom" version "1.13-SNAPSHOT" apply false + // Plugin used for 1.12.2 id 'xyz.wagyourtail.unimined' version '1.4.10-kappa' apply false id 'org.spongepowered.gradle.vanilla' version '0.2.1-20240507.024226-82' apply false @@ -615,6 +616,9 @@ allprojects { p -> // VanillaGradle and Mixins in common maven { url "https://repo.spongepowered.org/maven/" } + + // Canvas mod + maven { url "https://maven.vram.io/" } // ModMenu mod maven { url "https://maven.terraformersmc.com/" } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java index 991c30d87..9211811a0 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java @@ -54,6 +54,7 @@ import java.util.Random; import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.ArrayList; import com.seibel.distanthorizons.core.logging.DhLogger; import org.jetbrains.annotations.Nullable; diff --git a/settings.gradle b/settings.gradle index c52ffc70c..b87d2bdf5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,7 +3,7 @@ pluginManagement { resolutionStrategy { eachPlugin { if (requested.id.id == "dev.architectury.loom") { - def mcVer = settings.startParameter.projectProperties.get("mcVer") ?: settings.providers.gradleProperty("mcVer").getOrElse("1.20.1") + def mcVer = settings.startParameter.projectProperties.get("mcVer") ?: settings.providers.gradleProperty("mcVer").getOrElse("1.21.11") if (mcVer == "1.12.2") { useVersion("1.0-SNAPSHOT") } From a59e7500ab96832fcd5a64db9b6a2d701b818d69 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Mon, 27 Apr 2026 07:27:07 -0500 Subject: [PATCH 12/68] Fix wyncraft getting stuck at low LOD quality --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index 7b0c66e3a..7b252b173 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 7b0c66e3aef9c980c486be8c5de945923a889406 +Subproject commit 7b252b173bb51f53bbdee87bfa6a5d327d1ce88a From 4d17f7aecfd78d395ea29e843a713dd7a2dd13fd Mon Sep 17 00:00:00 2001 From: James Seibel Date: Mon, 27 Apr 2026 07:48:11 -0500 Subject: [PATCH 13/68] fix null pointer on dedicated server shutdown --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index 7b252b173..4d0ed2a6d 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 7b252b173bb51f53bbdee87bfa6a5d327d1ce88a +Subproject commit 4d0ed2a6dc2b1a083b1e8b2cbbe2b710e57f64ec From cd7a130ee413c1f3612b90a059ee53064bdd9967 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 28 Apr 2026 07:09:26 -0500 Subject: [PATCH 14/68] use camera pos for detail calculations --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index 4d0ed2a6d..ec7276206 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 4d0ed2a6dc2b1a083b1e8b2cbbe2b710e57f64ec +Subproject commit ec72762067e183e027a67728dce64d0fbc3aaab8 From 67f4615b34e11a455c7a646836ba05634ce5f553 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 28 Apr 2026 07:46:53 -0500 Subject: [PATCH 15/68] add backup to texture color getting --- .../block/ClientBlockStateColorCache.java | 102 ++++++++++-------- 1 file changed, 55 insertions(+), 47 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java index ee776f4b8..20a42bb75 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java @@ -260,39 +260,55 @@ public class ClientBlockStateColorCache && !quads.isEmpty() && quads.get(0) != null) { - BakedQuad firstQuad = quads.get(0); + try + { + BakedQuad firstQuad = quads.get(0); - #if MC_VER <= MC_1_21_11 - this.needPostTinting = firstQuad.isTinted(); - #else - this.needPostTinting = firstQuad.materialInfo().isTinted(); - #endif + #if MC_VER <= MC_1_21_11 + this.needPostTinting = firstQuad.isTinted(); + #else + this.needPostTinting = firstQuad.materialInfo().isTinted(); + #endif - #if MC_VER <= MC_1_21_4 - this.tintIndex = firstQuad.getTintIndex(); - #elif MC_VER <= MC_1_21_11 - this.tintIndex = firstQuad.tintIndex(); - #else - this.tintIndex = firstQuad.materialInfo().tintIndex(); - #endif - - #if MC_VER < MC_1_17_1 - this.baseColor = calculateColorFromTexture( - firstQuad.sprite, - EColorMode.getColorMode(this.blockState.getBlock())); - #elif MC_VER < MC_1_21_5 - this.baseColor = calculateColorFromTexture( - firstQuad.getSprite(), - EColorMode.getColorMode(this.blockState.getBlock())); - #elif MC_VER <= MC_1_21_11 - this.baseColor = calculateColorFromTexture( - firstQuad.sprite(), - EColorMode.getColorMode(this.blockState.getBlock())); - #else - this.baseColor = calculateColorFromTexture( - firstQuad.materialInfo().sprite(), - EColorMode.getColorMode(this.blockState.getBlock())); - #endif + #if MC_VER <= MC_1_21_4 + this.tintIndex = firstQuad.getTintIndex(); + #elif MC_VER <= MC_1_21_11 + this.tintIndex = firstQuad.tintIndex(); + #else + this.tintIndex = firstQuad.materialInfo().tintIndex(); + #endif + + #if MC_VER < MC_1_17_1 + this.baseColor = calculateColorFromTexture( + firstQuad.sprite, + EColorMode.getColorMode(this.blockState.getBlock())); + #elif MC_VER < MC_1_21_5 + this.baseColor = calculateColorFromTexture( + firstQuad.getSprite(), + EColorMode.getColorMode(this.blockState.getBlock())); + #elif MC_VER <= MC_1_21_11 + this.baseColor = calculateColorFromTexture( + firstQuad.sprite(), + EColorMode.getColorMode(this.blockState.getBlock())); + #else + this.baseColor = calculateColorFromTexture( + firstQuad.materialInfo().sprite(), + EColorMode.getColorMode(this.blockState.getBlock())); + #endif + } + catch (Exception e) + { + // Shouldn't normally happen, but there was at least + // one report of MC's texture being un-loaded + // which prevented us from getting the texture. + // So we should have some basic backup logic. + + LOGGER.warn("Failed to get texture color for block ["+this.blockStateWrapper.getSerialString()+"] due to: ["+e.getMessage()+"], falling back to particle color."); + + this.needPostTinting = false; + this.tintIndex = 0; + this.baseColor = this.getParticleIconColor(); + } } else { @@ -399,22 +415,14 @@ public class ClientBlockStateColorCache int scale = 1; if (colorMode == EColorMode.Leaves) { - //switch (//FIXME add config option) - // case BLACK: - // a = 255; //simulate black background of fast leaves - // break; - // case IGNORE: - if (a == 0) { - continue; //same long grass - } - else - { - a = 255; //just in case there are semi transparent pixels - } - // break; - // case TRANSPARENT: - // break; //do nothing, let it count towards transparency - + if (a == 0) + { + continue; //same long grass + } + else + { + a = 255; //just in case there are semi transparent pixels + } } else if (a == 0 && colorMode != EColorMode.Glass) { From de9d8b0d2ec713edf81dc7d8c2eed067dc5f65a4 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 28 Apr 2026 21:15:07 -0500 Subject: [PATCH 16/68] Optimize BlockStateWrapper getter --- .../wrappers/block/BlockStateWrapper.java | 49 ++++++++++++++----- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index aa3650518..f55fda2e6 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -167,20 +167,46 @@ public class BlockStateWrapper implements IBlockStateWrapper return AIR; } - // create a wrapper specifically for the API event to use - BlockStateWrapper apiWrapper = new BlockStateWrapper(blockState, levelWrapper, null); - DhApiBlockStateWrapperCreatedEvent.EventParam eventParam = new DhApiBlockStateWrapperCreatedEvent.EventParam(apiWrapper); - ApiEventInjector.INSTANCE.fireAllEvents(DhApiBlockStateWrapperCreatedEvent.class, eventParam); - - if (!eventParam.getOverridesSet()) + // pooling wrappers significantly improves chunk->LOD processing speed + // and also reduces GC pressure + BlockStateWrapper existingWrapper = WRAPPER_BY_BLOCK_STATE.get(blockState); + if (existingWrapper != null) { - // no changes needed, use the existing object - return apiWrapper; + return existingWrapper; } - // create a new wrapper using whatever overrides the API user set - BlockStateWrapper returnWrapper = new BlockStateWrapper(blockState, levelWrapper, eventParam); - return returnWrapper; + + + // synchronized so the API event only fires once per block + synchronized (WRAPPER_BY_BLOCK_STATE) + { + // if another thread already finished this block, use that wrapper + existingWrapper = WRAPPER_BY_BLOCK_STATE.get(blockState); + if (existingWrapper != null) + { + return existingWrapper; + } + + + // create a wrapper specifically for the API event to use + BlockStateWrapper apiWrapper = new BlockStateWrapper(blockState, levelWrapper, null); + DhApiBlockStateWrapperCreatedEvent.EventParam eventParam = new DhApiBlockStateWrapperCreatedEvent.EventParam(apiWrapper); + ApiEventInjector.INSTANCE.fireAllEvents(DhApiBlockStateWrapperCreatedEvent.class, eventParam); + + if (!eventParam.getOverridesSet()) + { + // no API changes needed, use the existing object + WRAPPER_BY_BLOCK_STATE.putIfAbsent(blockState, apiWrapper); + return apiWrapper; + } + else + { + // create a new wrapper using whatever overrides the API user set + BlockStateWrapper returnWrapper = new BlockStateWrapper(blockState, levelWrapper, eventParam); + WRAPPER_BY_BLOCK_STATE.putIfAbsent(blockState, returnWrapper); + return returnWrapper; + } + } } private BlockStateWrapper( @Nullable BlockState blockState, ILevelWrapper levelWrapper, @@ -1000,6 +1026,7 @@ public class BlockStateWrapper implements IBlockStateWrapper // put if absent in case two threads deserialize at the same time // unfortunately we can't put everything in a computeIfAbsent() since we also throw exceptions WRAPPER_BY_RESOURCE_LOCATION.putIfAbsent(finalResourceStateString, foundWrapper); + WRAPPER_BY_BLOCK_STATE.putIfAbsent(foundWrapper.blockState, foundWrapper); } } From 9c2d243ad40c05170907e8cef2fc594a53f76c1e Mon Sep 17 00:00:00 2001 From: James Seibel Date: Wed, 29 Apr 2026 07:35:24 -0500 Subject: [PATCH 17/68] Add position finder debug config --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index ec7276206..3ef8bd7e2 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit ec72762067e183e027a67728dce64d0fbc3aaab8 +Subproject commit 3ef8bd7e20af02d42ea4f470d67147257f6c617e From 4067264e722ae0755c287cf713f9ab70080d7089 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Wed, 29 Apr 2026 07:45:29 -0500 Subject: [PATCH 18/68] Merge branch 'distant-horizons-fix' --- .../openGl/glObject/buffer/GLBuffer.java | 104 +++++++++++++++++- 1 file changed, 100 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java index bcde6edbf..6d16bfb5d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java @@ -23,6 +23,7 @@ import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod; import com.seibel.distanthorizons.common.render.openGl.glObject.GLProxy; import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper; import com.seibel.distanthorizons.core.config.Config; +import com.seibel.distanthorizons.core.jar.EPlatform; import com.seibel.distanthorizons.core.logging.DhLogger; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler; @@ -52,6 +53,20 @@ public class GLBuffer implements AutoCloseable public static final double BUFFER_EXPANSION_MULTIPLIER = 1.3; public static final double BUFFER_SHRINK_TRIGGER = BUFFER_EXPANSION_MULTIPLIER * BUFFER_EXPANSION_MULTIPLIER; + + /** + * On macOS the legacy OpenGL -> Metal bridge crashes with SIGBUS in + * {@code _platform_memmove} when {@code glBufferData} or {@code glBufferSubData} + * are called with a large ByteBuffer in one shot. To work around it, we split + * the upload into smaller sub-data calls that each fit comfortably inside the + * driver's internal staging path.
+ * 256 KiB tuned empirically against macOS 26.5 — a 1 MiB chunk still + * tripped the same {@code _platform_memmove} crash inside + * {@code glBufferSubData_Exec}, but 256 KiB consistently survives. + */ + public static final int MAC_UPLOAD_CHUNK_BYTES = 256 * 1024; + /** Threshold above which the chunked path kicks in on macOS. */ + public static final int MAC_UPLOAD_CHUNK_THRESHOLD = MAC_UPLOAD_CHUNK_BYTES; /** the number of active buffers, can be used for debugging */ public static AtomicInteger bufferCount = new AtomicInteger(0); @@ -322,7 +337,22 @@ public class GLBuffer implements AutoCloseable LodUtil.assertTrue(!this.bufferStorage, "Buffer is bufferStorage but its trying to use bufferData upload method!"); int bbSize = bb.limit() - bb.position(); - GL32.glBufferData(this.getBufferBindingTarget(), bb, bufferDataHint); + int target = this.getBufferBindingTarget(); + + if (shouldUploadToGpuInChunks(bbSize)) + { + // Two-step path used on macOS to dodge the Apple OpenGL -> Metal + // memmove SIGBUS triggered by uploading a large ByteBuffer in one + // glBufferData call: + // 1) allocate-only with the size overload (no memcpy) + // 2) fill the buffer through chunked glBufferSubData calls + GL32.glBufferData(target, (long) bbSize, bufferDataHint); + subDataUploadInChunks(target, 0, bb, MAC_UPLOAD_CHUNK_BYTES); + } + else + { + GL32.glBufferData(target, bb, bufferDataHint); + } this.size = bbSize; } /** Requires the buffer to be bound */ @@ -331,14 +361,28 @@ public class GLBuffer implements AutoCloseable LodUtil.assertTrue(!this.bufferStorage, "Buffer is bufferStorage but its trying to use subData upload method!"); int bbSize = bb.limit() - bb.position(); + int target = this.getBufferBindingTarget(); if (this.size < bbSize || this.size > bbSize * BUFFER_SHRINK_TRIGGER) { int newSize = (int) (bbSize * BUFFER_EXPANSION_MULTIPLIER); - if (newSize > maxExpansionSize) newSize = maxExpansionSize; - GL32.glBufferData(this.getBufferBindingTarget(), newSize, bufferDataHint); + if (newSize > maxExpansionSize) + { + newSize = maxExpansionSize; + } + + // allocate-only — no memcpy, safe on macOS regardless of size + GL32.glBufferData(target, (long) newSize, bufferDataHint); this.size = newSize; } - GL32.glBufferSubData(this.getBufferBindingTarget(), 0, bb); + + if (shouldUploadToGpuInChunks(bbSize)) + { + subDataUploadInChunks(target, 0, bb, MAC_UPLOAD_CHUNK_BYTES); + } + else + { + GL32.glBufferSubData(target, 0, bb); + } } //endregion @@ -396,6 +440,58 @@ public class GLBuffer implements AutoCloseable } } + /** + * macOS-only mitigation for the SIGBUS in + * {@code libsystem_platform.dylib _platform_memmove} that happens when the + * Apple OpenGL -> Metal translation layer copies a single large ByteBuffer + * out of LWJGL into driver memory. Splitting the copy into + * {@link #MAC_UPLOAD_CHUNK_BYTES} slices keeps every memmove inside a size + * the bridge handles reliably. + */ + private static boolean shouldUploadToGpuInChunks(int byteCount) + { + return EPlatform.get() == EPlatform.MACOS + && byteCount > MAC_UPLOAD_CHUNK_THRESHOLD; + } + + /** + * Uploads {@code bb} into the currently bound buffer at {@code baseOffset} + * using a sequence of {@link GL32#glBufferSubData(int, long, ByteBuffer)} + * calls of at most {@code chunkBytes} each. The buffer's position/limit are + * restored before returning. + */ + private static void subDataUploadInChunks(int target, int baseOffset, ByteBuffer bb, int chunkBytes) + { + final int origPos = bb.position(); + final int origLimit = bb.limit(); + try + { + final int total = origLimit - origPos; + int uploaded = 0; + while (uploaded < total) + { + int chunk = Math.min(chunkBytes, total - uploaded); + bb.position(origPos + uploaded); + bb.limit(origPos + uploaded + chunk); + GL32.glBufferSubData(target, (long) (baseOffset + uploaded), bb); + uploaded += chunk; + // Force the driver to drain its command queue between chunks + // so the OpenGL -> Metal bridge processes (and frees) each + // staging copy before the next sub-data call piles another + // memmove on top of it. + if (uploaded < total) + { + GL32.glFlush(); + } + } + } + finally + { + bb.limit(origLimit); + bb.position(origPos); + } + } + //endregion From ca00125960786bbeb231155fef50fa33d8c88927 Mon Sep 17 00:00:00 2001 From: Ran-Mewo <43445785+Ran-Mewo@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:28:29 +1000 Subject: [PATCH 19/68] exclude FabricMC groups from Sponge repository in dh-loader.gradle --- buildSrc/src/main/groovy/dh-loader.gradle | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/groovy/dh-loader.gradle b/buildSrc/src/main/groovy/dh-loader.gradle index 838e869ce..dfa620754 100644 --- a/buildSrc/src/main/groovy/dh-loader.gradle +++ b/buildSrc/src/main/groovy/dh-loader.gradle @@ -54,7 +54,10 @@ repositories { url "https://www.cursemaven.com" content { includeGroup "curse.maven" } } - maven { url "https://repo.spongepowered.org/maven/" } + maven { + url "https://repo.spongepowered.org/maven/" + content { excludeGroupByRegex "net\\.fabricmc(\\..*)?" } + } maven { url "https://maven.terraformersmc.com/" } maven { url "https://maven.neoforged.net/releases/" } flatDir { From ee215481517f464d65ac02d89f72ac2631c6e901 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Fri, 1 May 2026 07:42:53 -0500 Subject: [PATCH 20/68] comment on why sponge maven can't have fabric --- buildSrc/src/main/groovy/dh-loader.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildSrc/src/main/groovy/dh-loader.gradle b/buildSrc/src/main/groovy/dh-loader.gradle index dfa620754..f79589b87 100644 --- a/buildSrc/src/main/groovy/dh-loader.gradle +++ b/buildSrc/src/main/groovy/dh-loader.gradle @@ -56,6 +56,8 @@ repositories { } maven { url "https://repo.spongepowered.org/maven/" + // exclusion is needed since sponge has a deprecated version of fabric + // that gradle would prefer to get over the up-to-date version modrinth provides content { excludeGroupByRegex "net\\.fabricmc(\\..*)?" } } maven { url "https://maven.terraformersmc.com/" } From 5f7dbb8662ca37179273cac6b4d4a08ca10f630f Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 2 May 2026 08:00:14 -0500 Subject: [PATCH 21/68] Fix neoforge debugging --- buildSrc/src/main/groovy/dh-loader.gradle | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/buildSrc/src/main/groovy/dh-loader.gradle b/buildSrc/src/main/groovy/dh-loader.gradle index f79589b87..59ee54ad4 100644 --- a/buildSrc/src/main/groovy/dh-loader.gradle +++ b/buildSrc/src/main/groovy/dh-loader.gradle @@ -366,6 +366,23 @@ if (isNotCommonProject) { !arg.startsWith("-XX:MaxGCPauseMillis") } runTask.jvmArgs = filteredArgs + + // fix (Neo)forge debug running + doFirst { + def modsDir = rootProject.file("run/${isClient ? 'client' : 'server'}/mods") + modsDir.mkdirs() + + // Remove any stale DH jars before copying the fresh one + modsDir.listFiles()?.each { file -> + if (file.name.startsWith(rootProject.mod_name)) file.delete() + } + + // Copy shadow jar into mods folder so (Neo)Forge discovers it properly + copy { + from shadowJar.archiveFile + into modsDir + } + } // JVM args runTask.jvmArgs( From c7ae7f155e037ce27213752a1993945ed4fa22be Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 2 May 2026 10:00:24 -0500 Subject: [PATCH 22/68] move fog common mixin code to common --- .../commonMixins/MixinVanillaFogCommon.java | 125 ++++++++++++++++++ .../mixins/client/MixinFogRenderer.java | 62 +-------- .../mixins/client/MixinFogRenderer.java | 58 +------- 3 files changed, 133 insertions(+), 112 deletions(-) create mode 100644 common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java new file mode 100644 index 000000000..5888b572c --- /dev/null +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java @@ -0,0 +1,125 @@ +package com.seibel.distanthorizons.common.commonMixins; + +import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper; +import com.seibel.distanthorizons.core.api.internal.ClientApi; +import com.seibel.distanthorizons.core.config.Config; +import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector; +import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; +import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; +import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; +import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IImmersivePortalsAccessor; +import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; + +import net.minecraft.client.Camera; +import net.minecraft.client.renderer.FogRenderer; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.level.material.FogType; + + +import net.minecraft.client.Camera; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; + +#if MC_VER < MC_1_17_1 +import net.minecraft.world.level.material.FluidState; +import net.minecraft.client.renderer.FogRenderer; +import net.minecraft.client.renderer.FogRenderer.FogMode; +import com.mojang.blaze3d.systems.RenderSystem; + +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +#elif MC_VER < MC_1_21_3 +import net.minecraft.world.level.material.FogType; +import net.minecraft.client.renderer.FogRenderer; +import net.minecraft.client.renderer.FogRenderer.FogMode; +import com.mojang.blaze3d.systems.RenderSystem; + +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +#elif MC_VER < MC_1_21_6 +import net.minecraft.world.level.material.FogType; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.mojang.blaze3d.shaders.FogShape; +import net.minecraft.client.renderer.FogRenderer; +import net.minecraft.client.renderer.FogRenderer.FogMode; +import net.minecraft.client.renderer.FogParameters; +import org.joml.Vector4f; +import com.mojang.blaze3d.systems.RenderSystem; + +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +#else +import net.minecraft.world.level.material.FogType; +import net.minecraft.client.renderer.fog.FogRenderer; +import net.minecraft.client.renderer.fog.FogData; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +#endif + + +public class MixinVanillaFogCommon +{ + + + #if MC_VER < MC_1_21_6 + public static boolean cancelFog(Camera camera, FogRenderer.FogMode fogMode) + #else + public static boolean cancelFog() + #endif + { + + + #if MC_VER < MC_1_21_6 + Entity entity = camera.getEntity(); + #elif MC_VER <= MC_1_21_10 + Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera(); + Entity entity = camera.getEntity(); + #else + Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera(); + Entity entity = camera.entity(); + #endif + + + boolean cameraNotInFluid = cameraNotInFluid(camera); + boolean isSpecialFog = (entity instanceof LivingEntity) && ((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS); + + boolean cancelFog = !isSpecialFog; + cancelFog = cancelFog && cameraNotInFluid; + #if MC_VER < MC_1_21_6 + cancelFog = cancelFog && (fogMode == FogRenderer.FogMode.FOG_TERRAIN); + #endif + + cancelFog = cancelFog && !SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class).isFogStateSpecial(); + cancelFog = cancelFog && !Config.Client.Advanced.Graphics.Fog.enableVanillaFog.get(); + + + + IImmersivePortalsAccessor immersivePortals = ModAccessorInjector.INSTANCE.get(IImmersivePortalsAccessor.class); + if (immersivePortals != null + && immersivePortals.isRenderingPortal()) + { + cancelFog = false; + } + + return cancelFog; + } + + private static boolean cameraNotInFluid(Camera camera) + { + #if MC_VER < MC_1_17_1 + FluidState fluidState = camera.getFluidInCamera(); + boolean cameraNotInFluid = fluidState.isEmpty(); + #else + FogType fogTypes = camera.getFluidInCamera(); + boolean cameraNotInFluid = fogTypes == FogType.NONE; + #endif + + return cameraNotInFluid; + } + + +} diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinFogRenderer.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinFogRenderer.java index d5c433ae5..7136e5f4c 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinFogRenderer.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinFogRenderer.java @@ -19,19 +19,13 @@ package com.seibel.distanthorizons.fabric.mixins.client; +import com.seibel.distanthorizons.common.commonMixins.MixinVanillaFogCommon; import com.seibel.distanthorizons.core.api.internal.ClientApi; -import com.seibel.distanthorizons.core.config.Config; -import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; -import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; -import net.minecraft.client.Minecraft; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import net.minecraft.client.Camera; -import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; #if MC_VER < MC_1_17_1 import net.minecraft.world.level.material.FluidState; @@ -42,7 +36,6 @@ import com.mojang.blaze3d.systems.RenderSystem; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; #elif MC_VER < MC_1_21_3 -import net.minecraft.world.level.material.FogType; import net.minecraft.client.renderer.FogRenderer; import net.minecraft.client.renderer.FogRenderer.FogMode; import com.mojang.blaze3d.systems.RenderSystem; @@ -96,11 +89,11 @@ public class MixinFogRenderer #endif { #if MC_VER < MC_1_21_6 - boolean cancelFog = cancelFog(camera, fogMode); + boolean cancelFog = MixinVanillaFogCommon.cancelFog(camera, fogMode); #elif MC_VER < MC_1_21_6 - boolean cancelFog = cancelFog(camera); + boolean cancelFog = MixinVanillaFogCommon.cancelFog(camera); #else - boolean cancelFog = cancelFog(); + boolean cancelFog = MixinVanillaFogCommon.cancelFog(); #endif if (cancelFog) @@ -164,52 +157,5 @@ public class MixinFogRenderer #endif - @Unique - #if MC_VER < MC_1_21_6 - private static boolean cancelFog(Camera camera, FogMode fogMode) - #else - private static boolean cancelFog() - #endif - { - #if MC_VER < MC_1_21_6 - Entity entity = camera.getEntity(); - #elif MC_VER <= MC_1_21_10 - Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera(); - Entity entity = camera.getEntity(); - #else - Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera(); - Entity entity = camera.entity(); - #endif - - - boolean cameraNotInFluid = cameraNotInFluid(camera); - boolean isSpecialFog = (entity instanceof LivingEntity) && ((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS); - - boolean cancelFog = !isSpecialFog; - cancelFog = cancelFog && cameraNotInFluid; - #if MC_VER < MC_1_21_6 - cancelFog = cancelFog && (fogMode == FogMode.FOG_TERRAIN); - #endif - cancelFog = cancelFog && !SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class).isFogStateSpecial(); - cancelFog = cancelFog && !Config.Client.Advanced.Graphics.Fog.enableVanillaFog.get(); - - return cancelFog; - } - - @Unique - private static boolean cameraNotInFluid(Camera camera) - { - #if MC_VER < MC_1_17_1 - FluidState fluidState = camera.getFluidInCamera(); - boolean cameraNotInFluid = fluidState.isEmpty(); - #else - FogType fogTypes = camera.getFluidInCamera(); - boolean cameraNotInFluid = fogTypes == FogType.NONE; - #endif - - return cameraNotInFluid; - } - - } diff --git a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinFogRenderer.java b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinFogRenderer.java index ce00aa4e7..7437d78a3 100644 --- a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinFogRenderer.java +++ b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinFogRenderer.java @@ -19,11 +19,8 @@ package com.seibel.distanthorizons.neoforge.mixins.client; +import com.seibel.distanthorizons.common.commonMixins.MixinVanillaFogCommon; import com.seibel.distanthorizons.core.api.internal.ClientApi; -import com.seibel.distanthorizons.core.config.Config; -import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; -import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; -import net.minecraft.client.Minecraft; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -96,11 +93,11 @@ public class MixinFogRenderer #endif { #if MC_VER < MC_1_21_6 - boolean cancelFog = cancelFog(camera, fogMode); + boolean cancelFog = MixinVanillaFogCommon.cancelFog(camera, fogMode); #elif MC_VER < MC_1_21_6 - boolean cancelFog = cancelFog(camera); + boolean cancelFog = MixinVanillaFogCommon.cancelFog(camera); #else - boolean cancelFog = cancelFog(); + boolean cancelFog = MixinVanillaFogCommon.cancelFog(); #endif if (cancelFog) @@ -164,52 +161,5 @@ public class MixinFogRenderer #endif - @Unique - #if MC_VER < MC_1_21_6 - private static boolean cancelFog(Camera camera, FogMode fogMode) - #else - private static boolean cancelFog() - #endif - { - #if MC_VER < MC_1_21_6 - Entity entity = camera.getEntity(); - #elif MC_VER <= MC_1_21_10 - Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera(); - Entity entity = camera.getEntity(); - #else - Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera(); - Entity entity = camera.entity(); - #endif - - - boolean cameraNotInFluid = cameraNotInFluid(camera); - boolean isSpecialFog = (entity instanceof LivingEntity) && ((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS); - - boolean cancelFog = !isSpecialFog; - cancelFog = cancelFog && cameraNotInFluid; - #if MC_VER < MC_1_21_6 - cancelFog = cancelFog && (fogMode == FogMode.FOG_TERRAIN); - #endif - cancelFog = cancelFog && !SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class).isFogStateSpecial(); - cancelFog = cancelFog && !Config.Client.Advanced.Graphics.Fog.enableVanillaFog.get(); - - return cancelFog; - } - - @Unique - private static boolean cameraNotInFluid(Camera camera) - { - #if MC_VER < MC_1_17_1 - FluidState fluidState = camera.getFluidInCamera(); - boolean cameraNotInFluid = fluidState.isEmpty(); - #else - FogType fogTypes = camera.getFluidInCamera(); - boolean cameraNotInFluid = fogTypes == FogType.NONE; - #endif - - return cameraNotInFluid; - } - - } From 329dbe95851b303e2e1409dc0a2c47a0c9e56047 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 2 May 2026 10:43:41 -0500 Subject: [PATCH 23/68] Fix block wrapper null pointer --- .../common/wrappers/block/BlockStateWrapper.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index f55fda2e6..f20398970 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -1026,7 +1026,11 @@ public class BlockStateWrapper implements IBlockStateWrapper // put if absent in case two threads deserialize at the same time // unfortunately we can't put everything in a computeIfAbsent() since we also throw exceptions WRAPPER_BY_RESOURCE_LOCATION.putIfAbsent(finalResourceStateString, foundWrapper); - WRAPPER_BY_BLOCK_STATE.putIfAbsent(foundWrapper.blockState, foundWrapper); + + if (foundWrapper != AIR) + { + WRAPPER_BY_BLOCK_STATE.putIfAbsent(foundWrapper.blockState, foundWrapper); + } } } From b5d833fa3d7b84d2fc5dc74cbbebca4b5ca3e29e Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 2 May 2026 10:57:37 -0500 Subject: [PATCH 24/68] simplify mixin fog common code --- .../commonMixins/MixinVanillaFogCommon.java | 10 ----- .../forge/mixins/client/MixinFogRenderer.java | 37 ++++++------------- 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java index 5888b572c..5a8a06149 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java @@ -7,7 +7,6 @@ import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; -import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IImmersivePortalsAccessor; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import net.minecraft.client.Camera; @@ -15,7 +14,6 @@ import net.minecraft.client.renderer.FogRenderer; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.level.material.FogType; import net.minecraft.client.Camera; @@ -97,14 +95,6 @@ public class MixinVanillaFogCommon cancelFog = cancelFog && !Config.Client.Advanced.Graphics.Fog.enableVanillaFog.get(); - - IImmersivePortalsAccessor immersivePortals = ModAccessorInjector.INSTANCE.get(IImmersivePortalsAccessor.class); - if (immersivePortals != null - && immersivePortals.isRenderingPortal()) - { - cancelFog = false; - } - return cancelFog; } diff --git a/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinFogRenderer.java b/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinFogRenderer.java index 7899d4a14..589d50bdf 100644 --- a/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinFogRenderer.java +++ b/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinFogRenderer.java @@ -19,10 +19,8 @@ package com.seibel.distanthorizons.forge.mixins.client; +import com.seibel.distanthorizons.common.commonMixins.MixinVanillaFogCommon; import com.seibel.distanthorizons.core.api.internal.ClientApi; -import com.seibel.distanthorizons.core.config.Config; -import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; -import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -33,14 +31,6 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Camera; import net.minecraft.client.renderer.FogRenderer; import net.minecraft.client.renderer.FogRenderer.FogMode; -import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -#if MC_VER < MC_1_17_1 -import net.minecraft.world.level.material.FluidState; -#else -import net.minecraft.world.level.material.FogType; -#endif @Mixin(FogRenderer.class) public class MixinFogRenderer @@ -55,29 +45,25 @@ public class MixinFogRenderer remap = #if MC_VER == MC_1_17_1 || MC_VER == MC_1_18_2 false #else true #endif ) // Remap messiness due to this being weird in forge private static void disableSetupFog(Camera camera, FogMode fogMode, float f, boolean bl, float partTick, CallbackInfo callback) { - #if MC_VER < MC_1_17_1 - FluidState fluidState = camera.getFluidInCamera(); - boolean cameraNotInFluid = fluidState.isEmpty(); + #if MC_VER < MC_1_21_6 + boolean cancelFog = MixinVanillaFogCommon.cancelFog(camera, fogMode); + #elif MC_VER < MC_1_21_6 + boolean cancelFog = MixinVanillaFogCommon.cancelFog(camera); #else - FogType fogTypes = camera.getFluidInCamera(); - boolean cameraNotInFluid = fogTypes == FogType.NONE; + boolean cancelFog = MixinVanillaFogCommon.cancelFog(); #endif - - Entity entity = camera.getEntity(); - boolean isSpecialFog = (entity instanceof LivingEntity) && ((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS); - if (!isSpecialFog - && cameraNotInFluid - && fogMode == FogMode.FOG_TERRAIN - && !SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class).isFogStateSpecial() - && !Config.Client.Advanced.Graphics.Fog.enableVanillaFog.get()) + if (cancelFog) { #if MC_VER < MC_1_17_1 RenderSystem.fogStart(A_REALLY_REALLY_BIG_VALUE); RenderSystem.fogEnd(A_EVEN_LARGER_VALUE); - #else + #elif MC_VER < MC_1_21_3 RenderSystem.setShaderFogStart(A_REALLY_REALLY_BIG_VALUE); RenderSystem.setShaderFogEnd(A_EVEN_LARGER_VALUE); + #elif MC_VER < MC_1_21_6 + callback.setReturnValue(FogParameters.NO_FOG); + #else #endif ClientApi.RENDER_STATE.vanillaFogEnabled = false; @@ -86,6 +72,7 @@ public class MixinFogRenderer { ClientApi.RENDER_STATE.vanillaFogEnabled = true; } + } } From cf0935871094a8cd8d882faff4ce92934a486a94 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 2 May 2026 11:04:10 -0500 Subject: [PATCH 25/68] fix fog common mixin compiling --- .../common/commonMixins/MixinVanillaFogCommon.java | 7 +------ coreSubProjects | 2 +- .../fabric/mixins/client/MixinFogRenderer.java | 2 +- .../neoforge/mixins/client/MixinFogRenderer.java | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java index 5a8a06149..fc4938e28 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java @@ -9,8 +9,8 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftCli import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; +import net.minecraft.client.Minecraft; import net.minecraft.client.Camera; -import net.minecraft.client.renderer.FogRenderer; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; @@ -51,11 +51,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; #else import net.minecraft.world.level.material.FogType; -import net.minecraft.client.renderer.fog.FogRenderer; -import net.minecraft.client.renderer.fog.FogData; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; #endif diff --git a/coreSubProjects b/coreSubProjects index 3ef8bd7e2..c4f4935fd 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 3ef8bd7e20af02d42ea4f470d67147257f6c617e +Subproject commit c4f4935fddb076296d9d30baaf0d5cec1e268090 diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinFogRenderer.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinFogRenderer.java index 7136e5f4c..31fb7615a 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinFogRenderer.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinFogRenderer.java @@ -135,7 +135,7 @@ public class MixinFogRenderer ) private void onSetRenderDistanceEnd(FogData instance, float value, Operation original) { - if (cancelFog()) + if (MixinVanillaFogCommon.cancelFog()) { instance.environmentalStart = A_REALLY_REALLY_BIG_VALUE; instance.environmentalEnd = A_EVEN_LARGER_VALUE; diff --git a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinFogRenderer.java b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinFogRenderer.java index 7437d78a3..72aa56096 100644 --- a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinFogRenderer.java +++ b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinFogRenderer.java @@ -139,7 +139,7 @@ public class MixinFogRenderer ) private void onSetRenderDistanceEnd(FogData instance, float value, Operation original) { - if (cancelFog()) + if (MixinVanillaFogCommon.cancelFog()) { instance.environmentalStart = A_REALLY_REALLY_BIG_VALUE; instance.environmentalEnd = A_EVEN_LARGER_VALUE; From 0272f8c57f44c28d2309b65df4d39f0ea5746ca7 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 2 May 2026 11:43:13 -0500 Subject: [PATCH 26/68] remove unused manual build scripts --- .dockerignore | 19 ------------------- Dockerfile | 12 ------------ compile.sh | 31 ------------------------------- 3 files changed, 62 deletions(-) delete mode 100644 .dockerignore delete mode 100644 Dockerfile delete mode 100644 compile.sh diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index a190fb110..000000000 --- a/.dockerignore +++ /dev/null @@ -1,19 +0,0 @@ -**/.git -**/.gitlab -**/.cache - -buildAllJars - -**/_Misc Files -*.bat -*.md -*.sh -*.txt - -coreSubProjects/*.md -coreSubProjects/*.txt - -**/.gitignore -**/.gitattributes -**/.gitlab-cy.yml -**/.gitmodules diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 3044ee64e..000000000 --- a/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM eclipse-temurin:25-jdk - -WORKDIR /home/build/ -COPY ./gradlew . -RUN chmod +x ./gradlew -CMD echo "\r========== [CLEAN: $MC_VER] ==========" && \ - ./gradlew clean -PmcVer="$MC_VER" --gradle-user-home .gradle-cache/ && \ - echo "\r========== [BUILD: $MC_VER] ==========" && \ - ./gradlew build -PmcVer="$MC_VER" --gradle-user-home .gradle-cache/ && \ - echo "\r========== [MERGE: $MC_VER] ==========" && \ - ./gradlew mergeJars -PmcVer="$MC_VER" --gradle-user-home .gradle-cache/ && \ - echo "\r========== [DONE: $MC_VER] ==========" diff --git a/compile.sh b/compile.sh deleted file mode 100644 index 9cc9a628b..000000000 --- a/compile.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -publish_version() -{ - if [[ "$2" == "all" || "$1" == "$2" ]] - then - docker run --name=dh-build-$1 --rm -v /${PWD}:/home/build -e MC_VER=$1 dh-eclipse-temurin - cp ./fabric/build/libs/*$1.jar ./buildAllJars/fabric/ - cp ./forge/build/libs/*$1.jar ./buildAllJars/forge/ - cp ./Merged/*.jar ./buildAllJars/merged/ - fi -} - - -if [ -z "$1" ] -then - echo "Build target is undefined! [all] [1.20.1] [1.19.4] [1.19.2] [1.18.2] [1.17.1] [1.16.5]" - exit 1 -fi - -docker build --tag=dh-eclipse-temurin -q . - -mkdir -p buildAllJars/fabric -mkdir -p buildAllJars/forge -mkdir -p buildAllJars/merged -publish_version 1.20.1 $1 -publish_version 1.19.4 $1 -publish_version 1.19.2 $1 -publish_version 1.18.2 $1 -publish_version 1.17.1 $1 -publish_version 1.16.5 $1 From 1a1eaca280ba8db3e002b92f2fcc348f140ac881 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 2 May 2026 11:44:09 -0500 Subject: [PATCH 27/68] Attempt to merge CI changes --- .gitignore | 2 +- .gitlab-ci.yml | 68 +++++++++++++++++++++++++++++++++---------------- coreSubProjects | 2 +- 3 files changed, 48 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 71dbf2226..6722c133f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ run/ out/ *.iml .gradle/ -.gradle-cache/ +.gradle-*/ output/ bin/ libs/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 540b56661..303a2070e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,14 +15,9 @@ variables: # These can be extended so code is a bit less duplicated .build_java: - #image: eclipse-temurin:17 - cache: - key: "gradleCache_$CI_JOB_NAME_SLUG" - policy: pull-push - paths: - - .gradle - - cache/ - allow_failure: true + before_script: + - GRADLE_USER_HOME="$(pwd)/.gradle" + - export GRADLE_USER_HOME retry: max: 2 when: @@ -32,6 +27,8 @@ variables: build: stage: build + needs: [] + dependencies: [] parallel: matrix: - MC_VER: [ @@ -45,8 +42,7 @@ build: ] script: # this both runs the unit tests and assembles the code - - ./gradlew clean -PmcVer="${MC_VER}" -PinfoGitCommit="${CI_COMMIT_SHA}" -PinfoGitBranch="${CI_COMMIT_BRANCH}" -PinfoBuildSource="GitLab CI (${CI_PIPELINE_ID})" --gradle-user-home cache/; - - ./gradlew build -PmcVer="${MC_VER}" -PinfoGitCommit="${CI_COMMIT_SHA}" -PinfoGitBranch="${CI_COMMIT_BRANCH}" -PinfoBuildSource="GitLab CI (${CI_PIPELINE_ID})" --gradle-user-home cache/; + - gradle build -PmcVer="${MC_VER}" -PinfoGitCommit="${CI_COMMIT_SHA}" -PinfoGitBranch="${CI_COMMIT_BRANCH}" -PinfoBuildSource="GitLab CI (${CI_PIPELINE_ID})" - cp ./fabric/build/libs/* ./forge/build/libs/* ./neoforge/build/libs/* ./build/forgix/* . || true artifacts: name: "NightlyBuild_${MC_VER}-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" @@ -58,18 +54,27 @@ build: - ./*-sources.jar expire_in: 14 days when: always - extends: .build_java + cache: + key: gradle-${MC_VER} + policy: pull-push + paths: + - .gradle/caches/ + - .gradle/notifications/ + - coreSubProjects/api/build + - coreSubProjects/core/build + - build + allow_failure: true + api: stage: api needs: [] + dependencies: [] script: - # this should only run for the API - - ./gradlew api:clean --gradle-user-home cache/; # this also runs unit tests - - ./gradlew api:build --gradle-user-home cache/; - - ./gradlew api:addSourcesToCompiledJar --gradle-user-home cache/; + - gradle api:build + - gradle api:addSourcesToCompiledJar - cp ./coreSubProjects/api/build/libs/merged/* . artifacts: name: "NightlyBuild_Api-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" @@ -81,23 +86,42 @@ api: - ./*-sources.jar expire_in: 1 day when: always - extends: .build_java + cache: + key: gradle-api + policy: pull-push + paths: + - .gradle/caches/ + - .gradle/notifications/ + - coreSubProjects/api/build + - coreSubProjects/core/build + - build + allow_failure: true + # generate and publish API javadocs pages: stage: pages needs: [] + dependencies: [] script: - # this should only run for the API - - ./gradlew api:clean --gradle-user-home cache/; # this also runs unit tests - - ./gradlew api:build --gradle-user-home cache/; - - ./gradlew api:javadoc --gradle-user-home cache/; + - gradle api:build + - gradle api:javadoc - mkdir public - cp -r $CI_PROJECT_DIR/coreSubProjects/api/build/docs/javadoc/. public artifacts: paths: - public - allow_failure: false - extends: .build_java + # allow_failure: false + cache: + key: gradle-pages + policy: pull-push + paths: + - .gradle/caches/ + - .gradle/notifications/ + - coreSubProjects/api/build + - coreSubProjects/core/build + - build + allow_failure: true + diff --git a/coreSubProjects b/coreSubProjects index c4f4935fd..726da953b 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit c4f4935fddb076296d9d30baaf0d5cec1e268090 +Subproject commit 726da953bd75e5472339c5bc499975ed4f2bec2f From ab6a5dad2bb95de18fae1ae32e7fbc5c5b471bab Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 2 May 2026 11:45:29 -0500 Subject: [PATCH 28/68] Revert "Attempt to merge CI changes" This reverts commit 1a1eaca280ba8db3e002b92f2fcc348f140ac881. --- .gitignore | 2 +- .gitlab-ci.yml | 68 ++++++++++++++++--------------------------------- coreSubProjects | 2 +- 3 files changed, 24 insertions(+), 48 deletions(-) diff --git a/.gitignore b/.gitignore index 6722c133f..71dbf2226 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ run/ out/ *.iml .gradle/ -.gradle-*/ +.gradle-cache/ output/ bin/ libs/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 303a2070e..540b56661 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,9 +15,14 @@ variables: # These can be extended so code is a bit less duplicated .build_java: - before_script: - - GRADLE_USER_HOME="$(pwd)/.gradle" - - export GRADLE_USER_HOME + #image: eclipse-temurin:17 + cache: + key: "gradleCache_$CI_JOB_NAME_SLUG" + policy: pull-push + paths: + - .gradle + - cache/ + allow_failure: true retry: max: 2 when: @@ -27,8 +32,6 @@ variables: build: stage: build - needs: [] - dependencies: [] parallel: matrix: - MC_VER: [ @@ -42,7 +45,8 @@ build: ] script: # this both runs the unit tests and assembles the code - - gradle build -PmcVer="${MC_VER}" -PinfoGitCommit="${CI_COMMIT_SHA}" -PinfoGitBranch="${CI_COMMIT_BRANCH}" -PinfoBuildSource="GitLab CI (${CI_PIPELINE_ID})" + - ./gradlew clean -PmcVer="${MC_VER}" -PinfoGitCommit="${CI_COMMIT_SHA}" -PinfoGitBranch="${CI_COMMIT_BRANCH}" -PinfoBuildSource="GitLab CI (${CI_PIPELINE_ID})" --gradle-user-home cache/; + - ./gradlew build -PmcVer="${MC_VER}" -PinfoGitCommit="${CI_COMMIT_SHA}" -PinfoGitBranch="${CI_COMMIT_BRANCH}" -PinfoBuildSource="GitLab CI (${CI_PIPELINE_ID})" --gradle-user-home cache/; - cp ./fabric/build/libs/* ./forge/build/libs/* ./neoforge/build/libs/* ./build/forgix/* . || true artifacts: name: "NightlyBuild_${MC_VER}-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" @@ -54,27 +58,18 @@ build: - ./*-sources.jar expire_in: 14 days when: always - cache: - key: gradle-${MC_VER} - policy: pull-push - paths: - - .gradle/caches/ - - .gradle/notifications/ - - coreSubProjects/api/build - - coreSubProjects/core/build - - build - allow_failure: true - + extends: .build_java api: stage: api needs: [] - dependencies: [] script: + # this should only run for the API + - ./gradlew api:clean --gradle-user-home cache/; # this also runs unit tests - - gradle api:build - - gradle api:addSourcesToCompiledJar + - ./gradlew api:build --gradle-user-home cache/; + - ./gradlew api:addSourcesToCompiledJar --gradle-user-home cache/; - cp ./coreSubProjects/api/build/libs/merged/* . artifacts: name: "NightlyBuild_Api-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" @@ -86,42 +81,23 @@ api: - ./*-sources.jar expire_in: 1 day when: always - cache: - key: gradle-api - policy: pull-push - paths: - - .gradle/caches/ - - .gradle/notifications/ - - coreSubProjects/api/build - - coreSubProjects/core/build - - build - allow_failure: true - + extends: .build_java # generate and publish API javadocs pages: stage: pages needs: [] - dependencies: [] script: + # this should only run for the API + - ./gradlew api:clean --gradle-user-home cache/; # this also runs unit tests - - gradle api:build - - gradle api:javadoc + - ./gradlew api:build --gradle-user-home cache/; + - ./gradlew api:javadoc --gradle-user-home cache/; - mkdir public - cp -r $CI_PROJECT_DIR/coreSubProjects/api/build/docs/javadoc/. public artifacts: paths: - public - # allow_failure: false - cache: - key: gradle-pages - policy: pull-push - paths: - - .gradle/caches/ - - .gradle/notifications/ - - coreSubProjects/api/build - - coreSubProjects/core/build - - build - allow_failure: true - + allow_failure: false + extends: .build_java diff --git a/coreSubProjects b/coreSubProjects index 726da953b..c4f4935fd 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 726da953bd75e5472339c5bc499975ed4f2bec2f +Subproject commit c4f4935fddb076296d9d30baaf0d5cec1e268090 From 852ea75449c9d3c07c4ae63f5ef2cd1c7492b233 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 2 May 2026 11:45:54 -0500 Subject: [PATCH 29/68] Update coreSubProjects --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index c4f4935fd..726da953b 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit c4f4935fddb076296d9d30baaf0d5cec1e268090 +Subproject commit 726da953bd75e5472339c5bc499975ed4f2bec2f From ae0f3c2b3bd21f8e2251602efd41da178b0744ea Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 2 May 2026 12:43:43 -0500 Subject: [PATCH 30/68] Add oculus api implementation --- forge/build.gradle | 7 +++-- .../wrappers/modAccessor/OculusAccessor.java | 29 ++++++++++++++----- versionProperties/1.16.5.properties | 2 ++ versionProperties/1.17.1.properties | 2 ++ versionProperties/1.18.2.properties | 4 ++- versionProperties/1.19.2.properties | 2 ++ versionProperties/1.19.4.properties | 2 ++ versionProperties/1.20.1.properties | 2 ++ versionProperties/1.20.2.properties | 2 ++ versionProperties/1.20.4.properties | 2 ++ 10 files changed, 44 insertions(+), 10 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index 33ba45e15..39913fb5b 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -18,10 +18,13 @@ def addMod(path, enabled) { dependencies { // TerraForged addMod("curse.maven:TerraForged-363820:${rootProject.terraforged_version}", rootProject.enable_terraforged) - + // TerraFirmaCraft addMod("curse.maven:TerraFirmaCraft-302973:4616004", rootProject.enable_terrafirmacraft) - + + // Oculus (Iris port) + addMod("maven.modrinth:oculus:${rootProject.oculus_version}", rootProject.enable_oculus) + // TODO: Check if this is still needed and if so ensure this code works for MC 26.1+ // (potential) hack fix for MC 1.20.6 and later, force jopt-simple to be exactly 5.0.4 because Mojang ships that version, but some transitive dependencies request 6.0+ def mcParts = rootProject.minecraft_version.split("\\.") diff --git a/forge/src/main/java/com/seibel/distanthorizons/forge/wrappers/modAccessor/OculusAccessor.java b/forge/src/main/java/com/seibel/distanthorizons/forge/wrappers/modAccessor/OculusAccessor.java index e0a031b66..adadd2ad8 100644 --- a/forge/src/main/java/com/seibel/distanthorizons/forge/wrappers/modAccessor/OculusAccessor.java +++ b/forge/src/main/java/com/seibel/distanthorizons/forge/wrappers/modAccessor/OculusAccessor.java @@ -23,35 +23,50 @@ import com.seibel.distanthorizons.core.logging.DhLogger; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IIrisAccessor; +#if MC_VER == MC_1_20_1 +import net.irisshaders.iris.Iris; +import net.irisshaders.iris.api.v0.IrisApi; +#else +#endif + public class OculusAccessor implements IIrisAccessor { protected static final DhLogger LOGGER = new DhLoggerBuilder().build(); public OculusAccessor() - { - LOGGER.warn("Partial Oculus support enabled. Some DH features may be disabled or behave strangely, use Iris instead if possible."); - } + { LOGGER.warn("Partial Oculus support enabled. Some DH features may be disabled or behave strangely, use Iris instead if possible."); } @Override public String getModName() { - return "oculus"; + #if MC_VER == MC_1_20_1 + return Iris.MODID; + #else + return "iris"; // Oculus doesn't support this MC version + #endif } @Override public boolean isShaderPackInUse() { - // assume shaders are always active - return true; + #if MC_VER == MC_1_20_1 + return IrisApi.getInstance().isShaderPackInUse(); + #else + return true; // Oculus doesn't support this MC version + #endif } @Override public boolean isRenderingShadowPass() { - return false; + #if MC_VER == MC_1_20_1 + return IrisApi.getInstance().isRenderingShadowPass(); + #else + return false; // Oculus doesn't support this MC version + #endif } } diff --git a/versionProperties/1.16.5.properties b/versionProperties/1.16.5.properties index c749e2131..63850b9fb 100644 --- a/versionProperties/1.16.5.properties +++ b/versionProperties/1.16.5.properties @@ -54,6 +54,7 @@ forge_version=36.2.39 # Forge mod versions terraforged_version=4044290 + oculus_version= # Forge mod run # 0 = Don't enable and don't run @@ -62,3 +63,4 @@ forge_version=36.2.39 enable_starlight_forge=0 enable_terraforged=1 enable_terrafirmacraft=0 + enable_oculus=0 diff --git a/versionProperties/1.17.1.properties b/versionProperties/1.17.1.properties index 7414adc27..641d1b160 100644 --- a/versionProperties/1.17.1.properties +++ b/versionProperties/1.17.1.properties @@ -53,6 +53,7 @@ forge_version=37.1.1 # Forge mod versions terraforged_version= + oculus_version= # Forge mod run # 0 = Don't enable and don't run @@ -61,3 +62,4 @@ forge_version=37.1.1 enable_starlight_forge=0 enable_terraforged=0 enable_terrafirmacraft=0 + enable_oculus=0 diff --git a/versionProperties/1.18.2.properties b/versionProperties/1.18.2.properties index d745c474f..31ae756cb 100644 --- a/versionProperties/1.18.2.properties +++ b/versionProperties/1.18.2.properties @@ -62,6 +62,7 @@ forge_version=40.2.10 # Forge mod versions terraforged_version= + oculus_version= # Forge mod run # 0 = Don't enable and don't run @@ -69,4 +70,5 @@ forge_version=40.2.10 # 2 = Can be referenced in code and runs in client enable_starlight_forge=0 enable_terraforged=0 - enable_terrafirmacraft=0 \ No newline at end of file + enable_terrafirmacraft=0 + enable_oculus=0 diff --git a/versionProperties/1.19.2.properties b/versionProperties/1.19.2.properties index e50c5e617..2761724fc 100644 --- a/versionProperties/1.19.2.properties +++ b/versionProperties/1.19.2.properties @@ -52,6 +52,7 @@ forge_version=43.3.2 # Forge mod versions terraforged_version= + oculus_version= # Forge mod run # 0 = Don't enable and don't run @@ -60,3 +61,4 @@ forge_version=43.3.2 enable_starlight_forge=0 enable_terraforged=0 enable_terrafirmacraft=0 + enable_oculus=0 diff --git a/versionProperties/1.19.4.properties b/versionProperties/1.19.4.properties index 3945a43f9..ca7a31037 100644 --- a/versionProperties/1.19.4.properties +++ b/versionProperties/1.19.4.properties @@ -51,6 +51,7 @@ forge_version=45.2.4 # Forge mod versions terraforged_version= + oculus_version= # Forge mod run # 0 = Don't enable and don't run @@ -59,3 +60,4 @@ forge_version=45.2.4 enable_starlight_forge=0 enable_terraforged=0 enable_terrafirmacraft=0 + enable_oculus=0 diff --git a/versionProperties/1.20.1.properties b/versionProperties/1.20.1.properties index af43eb93b..d5e08040f 100644 --- a/versionProperties/1.20.1.properties +++ b/versionProperties/1.20.1.properties @@ -51,6 +51,7 @@ forge_version=47.2.1 # Forge mod versions terraforged_version= + oculus_version=1.20.1-1.8.0 # Forge mod run # 0 = Don't enable and don't run @@ -59,3 +60,4 @@ forge_version=47.2.1 enable_starlight_forge=0 enable_terraforged=0 enable_terrafirmacraft=0 + enable_oculus=1 diff --git a/versionProperties/1.20.2.properties b/versionProperties/1.20.2.properties index 1adff5e3b..3cc8c641b 100644 --- a/versionProperties/1.20.2.properties +++ b/versionProperties/1.20.2.properties @@ -51,6 +51,7 @@ forge_version=48.0.13 # Forge mod versions terraforged_version= + oculus_version= # Forge mod run # 0 = Don't enable and don't run @@ -59,3 +60,4 @@ forge_version=48.0.13 enable_starlight_forge=0 enable_terraforged=0 enable_terrafirmacraft=0 + enable_oculus=0 diff --git a/versionProperties/1.20.4.properties b/versionProperties/1.20.4.properties index 7d74fe957..907afb57d 100644 --- a/versionProperties/1.20.4.properties +++ b/versionProperties/1.20.4.properties @@ -52,6 +52,7 @@ neoforge_version= # Forge mod versions terraforged_version= + oculus_version= # Forge mod run # 0 = Don't enable and don't run @@ -60,3 +61,4 @@ neoforge_version= enable_starlight_forge=0 enable_terraforged=0 enable_terrafirmacraft=0 + enable_oculus=0 From a29e225a80e047c3c9c0f21a73daaf49bf3e7d48 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 2 May 2026 15:14:33 -0500 Subject: [PATCH 31/68] Fix LOD shading applying incorrectly with Iris --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index 726da953b..aaa5e958f 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 726da953bd75e5472339c5bc499975ed4f2bec2f +Subproject commit aaa5e958f04b5808a4943c1ab0222f69bbd01ba3 From c9267d61a85effaffecf5edcd8942bfe276f9f78 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 2 May 2026 15:21:44 -0500 Subject: [PATCH 32/68] allow toggling tracy via gradle.properties --- buildSrc/src/main/groovy/dh-loader.gradle | 15 ++++++++++++--- gradle.properties | 3 +++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/groovy/dh-loader.gradle b/buildSrc/src/main/groovy/dh-loader.gradle index 59ee54ad4..09268cf07 100644 --- a/buildSrc/src/main/groovy/dh-loader.gradle +++ b/buildSrc/src/main/groovy/dh-loader.gradle @@ -393,7 +393,8 @@ if (isNotCommonProject) { //"-XX:+ZGenerational", rootProject.minecraftMemoryJavaArg, ) - if (isClient) { + if (isClient) + { runTask.jvmArgs( "-Dminecraft.api.auth.host=https://nope.invalid", "-Dminecraft.api.account.host=https://nope.invalid", @@ -404,9 +405,17 @@ if (isNotCommonProject) { // use a consistent username for easier debugging in a given world (vs randomly teleporting to a new user each time the game boots) "--username", "Dev", // "--renderDebugLabels" is a Mojang command to show render names in RenderDoc - "--renderDebugLabels", + "--renderDebugLabels" + ) + + // enabling tracy causes constant memory growth so it isn't always desired + if (rootProject.minecraftEnableTracy == "true") + { // "--tracy" is a Mojang command to allow individual frames to be debugged using Tracy https://github.com/wolfpld/tracy/releases/tag/v0.13.1 - "--tracy") + runTask.args("--tracy") + } + + } } } diff --git a/gradle.properties b/gradle.properties index 9ca5b4bc9..e0e78d7b0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -51,3 +51,6 @@ mcVer=26.1.2 # Defines the maximum amount of memory Minecraft is allowed when run in a development environment minecraftMemoryJavaArg=-Xmx6G +# can be enabled for use with the Tracy profiler, disabled by default since it causes constant memory growth when running +minecraftEnableTracy=false + From 9feb20eff84d3729f58e2901228ebaef592c9a4d Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 2 May 2026 21:18:01 -0500 Subject: [PATCH 33/68] remove unnecessary warning in GLBuffer --- .../render/openGl/glObject/buffer/GLBuffer.java | 17 +++-------------- coreSubProjects | 2 +- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java index 6d16bfb5d..3ff8cd5b9 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java @@ -214,22 +214,11 @@ public class GLBuffer implements AutoCloseable } bufferCount.decrementAndGet(); + GLMC.glDeleteBuffers(id); - // destroy the buffer if it exists, - // the buffer may not exist if the destroy method is called twice - if (GL32.glIsBuffer(id)) + if (Config.Client.Advanced.Debugging.logBufferGarbageCollection.get()) { - GLMC.glDeleteBuffers(id); - - if (Config.Client.Advanced.Debugging.logBufferGarbageCollection.get()) - { - LOGGER.info("destroyed buffer [" + id + "], remaining: [" + BUFFER_ID_TO_PHANTOM.size() + "]"); - } - } - else - { - // shouldn't happen, but just in case - LOGGER.warn("Attempted to destroy a non buffer object with ID ["+id+"]."); + LOGGER.info("destroyed buffer [" + id + "], remaining: [" + BUFFER_ID_TO_PHANTOM.size() + "], cause: ["+cause+"]."); } } diff --git a/coreSubProjects b/coreSubProjects index aaa5e958f..69941fb7f 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit aaa5e958f04b5808a4943c1ab0222f69bbd01ba3 +Subproject commit 69941fb7f8e19c3f5f25f6055dbaa822d6a7d942 From 5df0a60b06cb95e45507e0a539596b54c88bb103 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 2 May 2026 21:18:24 -0500 Subject: [PATCH 34/68] add extra optional GLBuffer phantom logging --- .../openGl/glObject/buffer/GLBuffer.java | 114 +++++++++++++++--- 1 file changed, 100 insertions(+), 14 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java index 3ff8cd5b9..5db900d1a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java @@ -26,9 +26,13 @@ import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.jar.EPlatform; import com.seibel.distanthorizons.core.logging.DhLogger; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; +import com.seibel.distanthorizons.core.logging.f3.F3Screen; import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler; import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.util.ThreadUtil; +import com.seibel.distanthorizons.core.util.objects.Pair; +import com.seibel.distanthorizons.core.util.objects.pooling.PhantomLoggingHelper; +import com.seibel.distanthorizons.coreapi.util.StringUtil; import org.lwjgl.opengl.GL32; import org.lwjgl.opengl.GL44; @@ -36,6 +40,8 @@ import java.lang.ref.PhantomReference; import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.atomic.AtomicInteger; @@ -51,6 +57,18 @@ public class GLBuffer implements AutoCloseable private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE; + /** if enabled the number of GC'ed buffers will be logged */ + private static final boolean LOG_PHANTOM_RECOVERY = false; + /** + * If enabled the GC'ed buffers allocation/upload stacks will be logged. + * Note: due to how the buffers are often run on the render thread, + * these stacks will likely only be of limited use. + * For more robust debugging it would likely be best to somehow track + * the stacks of where these calls are happening before they're queued + * for the render thread. + */ + private static final boolean LOG_PHANTOM_ALLOCATION_STACKS = false; + public static final double BUFFER_EXPANSION_MULTIPLIER = 1.3; public static final double BUFFER_SHRINK_TRIGGER = BUFFER_EXPANSION_MULTIPLIER * BUFFER_EXPANSION_MULTIPLIER; @@ -73,6 +91,7 @@ public class GLBuffer implements AutoCloseable private static final int PHANTOM_REF_CHECK_TIME_IN_MS = 5 * 1000; private static final ConcurrentHashMap, Integer> PHANTOM_TO_BUFFER_ID = new ConcurrentHashMap<>(); private static final ConcurrentHashMap> BUFFER_ID_TO_PHANTOM = new ConcurrentHashMap<>(); + private static final ConcurrentHashMap BUFFER_ID_TO_ALLOCATION_STRING = new ConcurrentHashMap<>(); private static final ReferenceQueue PHANTOM_REFERENCE_QUEUE = new ReferenceQueue<>(); private static final ThreadPoolExecutor CLEANUP_THREAD = ThreadUtil.makeSingleDaemonThreadPool("GLBuffer Cleanup"); @@ -143,8 +162,9 @@ public class GLBuffer implements AutoCloseable long writeStamp = renderStampLock.writeLock(); try { - int oldId = this.id; + final int oldId = this.id; this.id = GLMC.glGenBuffers(); + //LOGGER.info("created [" + newId + "]."); // destroy the old buffer // after the new one has been created @@ -154,7 +174,7 @@ public class GLBuffer implements AutoCloseable { // this ID doesn't need to be tracked anymore tryRemoveBufferIdFromPhantom(oldId); - destroyBufferIdNow(oldId); + destroyBufferIdNow(oldId, "destroyOldAndCreate"); } @@ -164,6 +184,8 @@ public class GLBuffer implements AutoCloseable PhantomReference phantom = new PhantomReference<>(this, PHANTOM_REFERENCE_QUEUE); PHANTOM_TO_BUFFER_ID.put(phantom, this.id); BUFFER_ID_TO_PHANTOM.put(this.id, phantom); + + this.updateAllocationStackTrace(); } finally { @@ -196,7 +218,8 @@ public class GLBuffer implements AutoCloseable this.id = 0; this.size = 0; - RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("GLBuffer destroyAsync", () -> { destroyBufferIdNow(idToDelete); }); + //LOGGER.info("async destroy [" + idToDelete + "]."); + RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("GLBuffer destroyAsync", () -> { destroyBufferIdNow(idToDelete, "destroyAsync"); }); } finally { @@ -204,12 +227,12 @@ public class GLBuffer implements AutoCloseable } } - private static void destroyBufferIdNow(int id) + private static void destroyBufferIdNow(int id, String cause) { // only delete valid buffers if (id == 0) { - LOGGER.warn("Attempted to destroy a buffer with ID 0, VRAM memory leaks may occur."); + LOGGER.warn("Attempted to destroy a buffer with ID 0, VRAM memory leaks may occur, cause: ["+cause+"]."); return; } @@ -225,17 +248,22 @@ public class GLBuffer implements AutoCloseable /** should be called before {@link GLBuffer#destroyBufferIdNow} */ private static void tryRemoveBufferIdFromPhantom(int id) { - if (BUFFER_ID_TO_PHANTOM.containsKey(id)) + // will contain nothing if stack tracking isn't enabled + BUFFER_ID_TO_ALLOCATION_STRING.remove(id); + + PhantomReference phantom = BUFFER_ID_TO_PHANTOM.remove(id); + if (phantom != null) { - Reference phantom = BUFFER_ID_TO_PHANTOM.get(id); - // if we are manually closing this buffer, we don't want the phantom reference to accidentally close it again // this can cause a race condition were we accidentally delete an in-use buffer and cause NVIDIA // to throw an EXCEPTION_ACCESS_VIOLATION when we attempt to render it phantom.clear(); - PHANTOM_TO_BUFFER_ID.remove(phantom); - BUFFER_ID_TO_PHANTOM.remove(id); + Integer phantomId = PHANTOM_TO_BUFFER_ID.remove(phantom); + if (phantomId == null) + { + LOGGER.warn("No Phantom->ID binding stored for ID ["+id+"]"); + } } else { @@ -343,6 +371,8 @@ public class GLBuffer implements AutoCloseable GL32.glBufferData(target, bb, bufferDataHint); } this.size = bbSize; + + this.updateAllocationStackTrace(); } /** Requires the buffer to be bound */ protected void uploadSubData(ByteBuffer bb, int maxExpansionSize, int bufferDataHint) @@ -372,6 +402,8 @@ public class GLBuffer implements AutoCloseable { GL32.glBufferSubData(target, 0, bb); } + + this.updateAllocationStackTrace(); } //endregion @@ -481,6 +513,22 @@ public class GLBuffer implements AutoCloseable } } + /** + * used to help track down leaks where the buffer isn't properly closed + * Note: this probably needs extending to accept a stack trace from outside where it's being called + * since it's often called on the render thread in an un-helpful location. + */ + public void updateAllocationStackTrace() + { + if (LOG_PHANTOM_ALLOCATION_STACKS) + { + StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); + StackTraceElement[] trimmedElements = Arrays.copyOfRange(stackTraceElements, 4, stackTraceElements.length); + String stack = StringUtil.join("\n", trimmedElements).intern(); + BUFFER_ID_TO_ALLOCATION_STRING.put(this.id, stack); + } + } + //endregion @@ -492,8 +540,13 @@ public class GLBuffer implements AutoCloseable private static void runPhantomReferenceCleanupLoop() { + // these arrays are stored here so they don't have to be re-allocated each loop + ArrayList> allocationStackTraceCountPairList = new ArrayList<>(); + while (true) { + allocationStackTraceCountPairList.clear(); + try { try @@ -502,20 +555,53 @@ public class GLBuffer implements AutoCloseable } catch (InterruptedException ignore) { } + int collectedCount = 0; Reference phantomRef = PHANTOM_REFERENCE_QUEUE.poll(); while (phantomRef != null) { // destroy the buffer if it hasn't been cleared yet - if (PHANTOM_TO_BUFFER_ID.containsKey(phantomRef)) + Integer idRef = PHANTOM_TO_BUFFER_ID.remove((PhantomReference)phantomRef); // cast to make IntelliJ happy + if (idRef != null) { - int id = PHANTOM_TO_BUFFER_ID.get(phantomRef); - RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("GLBuffer phantom destroy", () -> { destroyBufferIdNow(id); }); - //LOGGER.warn("Buffer Phantom collected, ID: ["+id+"]"); + BUFFER_ID_TO_PHANTOM.remove(idRef); + final int id = idRef; + RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("GLBuffer phantom destroy", () -> { destroyBufferIdNow(id, "runPhantomReferenceCleanupLoop"); }); + //LOGGER.info("Buffer Phantom collected, ID: ["+id+"]"); + + if (LOG_PHANTOM_ALLOCATION_STACKS) // stack trace shouldn't be null, but just in case + { + String stack = BUFFER_ID_TO_ALLOCATION_STRING.get(idRef); + PhantomLoggingHelper.putAndIncrementTrackingString(stack, allocationStackTraceCountPairList); + } + } + else + { + LOGGER.warn("Failed to find Buffer ID for phantom reference: ["+phantomRef+"]"); } + + collectedCount++; phantomRef = PHANTOM_REFERENCE_QUEUE.poll(); } + + + + if (LOG_PHANTOM_RECOVERY) + { + // we only want to log when something has been returned + if (collectedCount != 0) + { + LOGGER.warn("GLBuffer phantom recovered: ["+ F3Screen.NUMBER_FORMAT.format(collectedCount)+"]."); + + // log stack traces if present + if (LOG_PHANTOM_ALLOCATION_STACKS) + { + PhantomLoggingHelper.LogAllocationStackTracePairCounts(LOGGER, allocationStackTraceCountPairList); + } + } + } + } catch (Exception e) { From ef98dbd5fd6a5c69dcb1b53998800b4255e1e5a1 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 2 May 2026 21:26:33 -0500 Subject: [PATCH 35/68] color override API tests --- .../fabric/FabricServerProxy.java | 22 ++++- .../testing/TestBlockWrapperCreatedEvent.java | 43 ++++++++++ .../fabric/testing/TestCustomColorEvent.java | 86 +++++++++++++++++++ 3 files changed, 147 insertions(+), 4 deletions(-) create mode 100644 fabric/src/main/java/com/seibel/distanthorizons/fabric/testing/TestBlockWrapperCreatedEvent.java create mode 100644 fabric/src/main/java/com/seibel/distanthorizons/fabric/testing/TestCustomColorEvent.java diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricServerProxy.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricServerProxy.java index cf0568fb5..3781fd8c8 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricServerProxy.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricServerProxy.java @@ -1,6 +1,8 @@ package com.seibel.distanthorizons.fabric; import com.seibel.distanthorizons.api.DhApi; +import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBlockColorOverrideEvent; +import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBlockStateWrapperCreatedEvent; import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiChunkProcessingEvent; import com.seibel.distanthorizons.api.methods.events.DhApiEventRegister; import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiLevelLoadEvent; @@ -16,7 +18,9 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; +import com.seibel.distanthorizons.fabric.testing.TestBlockWrapperCreatedEvent; import com.seibel.distanthorizons.fabric.testing.TestChunkInputReplacerEvent; +import com.seibel.distanthorizons.fabric.testing.TestCustomColorEvent; import com.seibel.distanthorizons.fabric.testing.TestWorldGenBindingEvent; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; @@ -87,11 +91,21 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy /* Register the mod needed event callbacks */ - // can be enabled to test overrides/events without having to build a separate API project - if (false) + // can be enabled to test overrides/events without having to build a separate API project { - DhApiEventRegister.on(DhApiLevelLoadEvent.class, new TestWorldGenBindingEvent()); - DhApi.events.bind(DhApiChunkProcessingEvent.class, new TestChunkInputReplacerEvent()); + // test custom world gen + if (false) + { + DhApiEventRegister.on(DhApiLevelLoadEvent.class, new TestWorldGenBindingEvent()); + DhApi.events.bind(DhApiChunkProcessingEvent.class, new TestChunkInputReplacerEvent()); + } + + // test custom colors + if (false) + { + DhApi.events.bind(DhApiBlockColorOverrideEvent.class, new TestCustomColorEvent()); + DhApi.events.bind(DhApiBlockStateWrapperCreatedEvent.class, new TestBlockWrapperCreatedEvent()); + } } diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/testing/TestBlockWrapperCreatedEvent.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/testing/TestBlockWrapperCreatedEvent.java new file mode 100644 index 000000000..d703fff5b --- /dev/null +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/testing/TestBlockWrapperCreatedEvent.java @@ -0,0 +1,43 @@ +package com.seibel.distanthorizons.fabric.testing; + +import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBlockStateWrapperCreatedEvent; +import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam; +import com.seibel.distanthorizons.core.logging.DhLogger; +import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; +import com.seibel.distanthorizons.core.util.LodUtil; + +import java.util.Random; + +/** + * @see TestCustomColorEvent + */ +public class TestBlockWrapperCreatedEvent extends DhApiBlockStateWrapperCreatedEvent +{ + private static final DhLogger LOGGER = new DhLoggerBuilder().build(); + + + + + @Override + public void blockStateWrapperCreated(DhApiEventParam event) + { + EventParam eventParam = event.value; + + // can be enabled to flip the opacity of transparent/opaque blocks + if (false) + { + if (eventParam.getBlockStateWrapper().getOpacity() == LodUtil.BLOCK_FULLY_OPAQUE) + { + eventParam.setOpacity(LodUtil.BLOCK_FULLY_TRANSPARENT); + } + else + { + eventParam.setOpacity(LodUtil.BLOCK_FULLY_OPAQUE); + } + } + + // needed for TestCustomColorEvent + eventParam.setAllowApiColorOverride(true); + } + +} diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/testing/TestCustomColorEvent.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/testing/TestCustomColorEvent.java new file mode 100644 index 000000000..7c08334ff --- /dev/null +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/testing/TestCustomColorEvent.java @@ -0,0 +1,86 @@ +package com.seibel.distanthorizons.fabric.testing; + +import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBlockColorOverrideEvent; +import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam; +import com.seibel.distanthorizons.core.logging.DhLogger; +import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; +import com.seibel.distanthorizons.core.util.LodUtil; +import com.seibel.distanthorizons.coreapi.util.ColorUtil; + +import java.awt.*; + +/** + * @see TestBlockWrapperCreatedEvent + */ +public class TestCustomColorEvent extends DhApiBlockColorOverrideEvent +{ + private static final DhLogger LOGGER = new DhLoggerBuilder().build(); + + + + @Override + public void blockStateWrapperCreated(DhApiEventParam event) + { + EventParam eventParam = event.value; + + //randomDatapointColors(eventParam); + //randomPerBlockColors(eventParam); + //blackWhitePositionStripe(eventParam); + positionRainbow(eventParam); + } + + /** each datapoint has a random color */ + private void randomDatapointColors(EventParam eventParam) + { + // random colors for each datapoint + int a = eventParam.getAlpha(); + int r = eventParam.getRed(); + int g = eventParam.getGreen(); + int b = eventParam.getBlue(); + + if (eventParam.getBlockStateWrapper().getOpacity() == LodUtil.BLOCK_FULLY_OPAQUE) + { + eventParam.setColor(255,r,g,b); + } + else + { + eventParam.setColor(60,r,g,b); + } + } + + /** each block has a different color */ + private void randomPerBlockColors(EventParam eventParam) + { + // random colors per block + int r = Math.abs(eventParam.getBlockStateWrapper().hashCode() % 255); + int g = Math.abs((eventParam.getBlockStateWrapper().hashCode() << 4) % 255); + int b = Math.abs((eventParam.getBlockStateWrapper().hashCode() << 8) % 255); + eventParam.setColor(r,g,b); + } + + private void blackWhitePositionStripe(EventParam eventParam) + { + // black-white stripes + int r = Math.abs(eventParam.getBlockPosX() % 255); + int g = r; + int b = r; + eventParam.setColor(r,g,b); + } + + /** rainbow along the X axis repeating every 255 blocks */ + private void positionRainbow(EventParam eventParam) + { + float[] ahsv = ColorUtil.argbToAhsv(ColorUtil.RED); + float a = ahsv[0]; + + int xModPos = Math.abs(eventParam.getBlockPosX() % 510); + float h = xModPos < 255 ? xModPos : 510 - xModPos; + float s = ahsv[2]; + float v = ahsv[3]; + int colorInt = ColorUtil.ahsvToArgb(a,h,s,v); + eventParam.setColor(ColorUtil.getRed(colorInt),ColorUtil.getGreen(colorInt),ColorUtil.getBlue(colorInt)); + } + + + +} From 4bd1136713c586543beb8a9b59e138991bf28b1c Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 3 May 2026 16:36:53 -0500 Subject: [PATCH 36/68] Fix generic buffer cleanup --- .../blaze/BlazeDhGenericObjectRenderer.java | 18 +++++++++++++++ .../generic/GlGenericObjectRenderer.java | 23 +++++++++++++++++++ coreSubProjects | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhGenericObjectRenderer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhGenericObjectRenderer.java index be403eaaa..d0e48930b 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhGenericObjectRenderer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhGenericObjectRenderer.java @@ -615,5 +615,23 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer + //================// + // base overrides // + //================// + //region + + @Override + public void close() + { + if (this.vertUniformBuffer != null) + { + this.vertUniformBuffer.close(); + } + } + + //endregion + + + } #endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/generic/GlGenericObjectRenderer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/generic/GlGenericObjectRenderer.java index a6fbb61b1..5670cf08e 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/generic/GlGenericObjectRenderer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/generic/GlGenericObjectRenderer.java @@ -748,4 +748,27 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer + //================// + // base overrides // + //================// + //region + + @Override + public void close() + { + if (this.boxVertexBuffer != null) + { + this.boxVertexBuffer.close(); + } + + if (this.boxIndexBuffer != null) + { + this.boxIndexBuffer.close(); + } + } + + //endregion + + + } diff --git a/coreSubProjects b/coreSubProjects index 69941fb7f..cb0fee978 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 69941fb7f8e19c3f5f25f6055dbaa822d6a7d942 +Subproject commit cb0fee9780059801c1733666872d34328fd83245 From 37b73e1d5c07e7b310d0a07158fef2208833f820 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 3 May 2026 16:45:40 -0500 Subject: [PATCH 37/68] Improve stack/GC tracking for GL buffers --- .../openGl/glObject/buffer/GLBuffer.java | 38 ++++++++++++------- .../openGl/glObject/buffer/GLIndexBuffer.java | 9 +++-- coreSubProjects | 2 +- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java index 5db900d1a..27aad3dc0 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java @@ -32,6 +32,7 @@ import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.util.ThreadUtil; import com.seibel.distanthorizons.core.util.objects.Pair; import com.seibel.distanthorizons.core.util.objects.pooling.PhantomLoggingHelper; +import com.seibel.distanthorizons.coreapi.ModInfo; import com.seibel.distanthorizons.coreapi.util.StringUtil; import org.lwjgl.opengl.GL32; import org.lwjgl.opengl.GL44; @@ -57,17 +58,11 @@ public class GLBuffer implements AutoCloseable private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE; + // TODO move to a shared location that can be handled by both GL and Blaze3D buffers /** if enabled the number of GC'ed buffers will be logged */ - private static final boolean LOG_PHANTOM_RECOVERY = false; - /** - * If enabled the GC'ed buffers allocation/upload stacks will be logged. - * Note: due to how the buffers are often run on the render thread, - * these stacks will likely only be of limited use. - * For more robust debugging it would likely be best to somehow track - * the stacks of where these calls are happening before they're queued - * for the render thread. - */ - private static final boolean LOG_PHANTOM_ALLOCATION_STACKS = false; + private static final boolean LOG_PHANTOM_RECOVERY = ModInfo.IS_DEV_BUILD; + /** If enabled buffers allocation/upload stacks will be logged when GC'ed. */ + private static final boolean LOG_PHANTOM_ALLOCATION_STACKS = false; // disabled by default due to the increased GC load public static final double BUFFER_EXPANSION_MULTIPLIER = 1.3; public static final double BUFFER_SHRINK_TRIGGER = BUFFER_EXPANSION_MULTIPLIER * BUFFER_EXPANSION_MULTIPLIER; @@ -522,9 +517,26 @@ public class GLBuffer implements AutoCloseable { if (LOG_PHANTOM_ALLOCATION_STACKS) { - StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); - StackTraceElement[] trimmedElements = Arrays.copyOfRange(stackTraceElements, 4, stackTraceElements.length); - String stack = StringUtil.join("\n", trimmedElements).intern(); + String stack; + + RenderThreadTaskHandler.QueuedRunnable parentQueuedRunnable; + // if this is running on the render thread, try getting the render task's stack trace instead + // since it's a lot more helpful than wherever the render thread tasks themselves are being run from + if (RenderThreadTaskHandler.INSTANCE.isCurrentThread() + && (parentQueuedRunnable = RenderThreadTaskHandler.INSTANCE.getCurrentlyRunningTask()) != null + && parentQueuedRunnable.stackTrace != null) + { + // trim off the getStacktrace() and queueRunningOnRenderThread() methods + StackTraceElement[] trimmedElements = Arrays.copyOfRange(parentQueuedRunnable.stackTrace, 2, parentQueuedRunnable.stackTrace.length); + stack = StringUtil.join("\n", trimmedElements).intern(); + } + else + { + // not running on the render thread, use the normal stack trace + StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); + stack = StringUtil.join("\n", stackTraceElements).intern(); + } + BUFFER_ID_TO_ALLOCATION_STRING.put(this.id, stack); } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLIndexBuffer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLIndexBuffer.java index 56793aabb..0a8db0883 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLIndexBuffer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLIndexBuffer.java @@ -37,10 +37,11 @@ public class GLIndexBuffer extends GLBuffer protected int glType = GL32.GL_UNSIGNED_INT; public int getGlType() { return this.glType; } - public GLIndexBuffer(boolean isBufferStorage) - { - super(isBufferStorage); - } + + + public GLIndexBuffer(boolean isBufferStorage) { super(isBufferStorage); } + + @Override public void destroyAsync() diff --git a/coreSubProjects b/coreSubProjects index cb0fee978..40b27335e 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit cb0fee9780059801c1733666872d34328fd83245 +Subproject commit 40b27335ea9b07542f7bb1d2f5576fb03c947c87 From b00079897a71d92aa0e9bf97edf6780044915242 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 3 May 2026 20:46:56 -0500 Subject: [PATCH 38/68] fix blaze generic obj render close on wrong thread --- .../render/blaze/BlazeDhGenericObjectRenderer.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhGenericObjectRenderer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhGenericObjectRenderer.java index d0e48930b..fd92d28fe 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhGenericObjectRenderer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhGenericObjectRenderer.java @@ -57,6 +57,7 @@ import com.seibel.distanthorizons.core.logging.DhLogger; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.logging.f3.F3Screen; import com.seibel.distanthorizons.core.render.RenderParams; +import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler; import com.seibel.distanthorizons.core.render.renderer.GenericRenderObjectFactory; import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IDhGenericObjectVertexBufferContainer; import com.seibel.distanthorizons.core.render.renderer.RenderableBoxGroup; @@ -623,10 +624,14 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer @Override public void close() { - if (this.vertUniformBuffer != null) + // close is called outside the render thread and buffer closing must be done on the render thread + RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("Generic Obj Cleanup", () -> { - this.vertUniformBuffer.close(); - } + if (this.vertUniformBuffer != null) + { + this.vertUniformBuffer.close(); + } + }); } //endregion From 791c2c3426bc6bed5c4a9c355145190771699333 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 3 May 2026 18:20:53 -0500 Subject: [PATCH 39/68] up api version 6.1.0 -> 6.1.1 --- coreSubProjects | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coreSubProjects b/coreSubProjects index 40b27335e..b592012ba 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 40b27335ea9b07542f7bb1d2f5576fb03c947c87 +Subproject commit b592012ba82671e9002a2e25f205060210718406 diff --git a/gradle.properties b/gradle.properties index e0e78d7b0..698c0f8e3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ org.gradle.caching=true mod_name=DistantHorizons api_name=DistantHorizonsApi mod_version=3.0.3-b-dev -api_version=6.1.0 +api_version=6.1.1 maven_group=com.seibel.distanthorizons 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. From fc516a20d5be05fcd9e18613b3a3ced9dab41a08 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 3 May 2026 18:21:26 -0500 Subject: [PATCH 40/68] remove dev from version number --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 698c0f8e3..1e6a8ee00 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.caching=true # Mod Info mod_name=DistantHorizons api_name=DistantHorizonsApi -mod_version=3.0.3-b-dev +mod_version=3.0.3-b api_version=6.1.1 maven_group=com.seibel.distanthorizons mod_readable_name=Distant Horizons From 1f1024251bf1247e89d80d7f3acf34168c887119 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Mon, 4 May 2026 07:41:48 -0500 Subject: [PATCH 41/68] up version number 3.0.3 -> 3.0.4 --- coreSubProjects | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coreSubProjects b/coreSubProjects index b592012ba..b674f4960 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit b592012ba82671e9002a2e25f205060210718406 +Subproject commit b674f49600184a94d4b83888e5a50df4b8f065b7 diff --git a/gradle.properties b/gradle.properties index 1e6a8ee00..770bc07d9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.caching=true # Mod Info mod_name=DistantHorizons api_name=DistantHorizonsApi -mod_version=3.0.3-b +mod_version=3.0.4-b-dev api_version=6.1.1 maven_group=com.seibel.distanthorizons mod_readable_name=Distant Horizons From 7ae4a9f460357cd7239148b529ca7009c201289c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Wed, 6 May 2026 20:51:08 +0200 Subject: [PATCH 42/68] 1.12.2 compiles again --- buildSrc/src/main/groovy/dh-loader.gradle | 88 ++- buildSrc/src/main/groovy/root.gradle | 8 - .../src/main/groovy/unimined-cleanroom.gradle | 15 + cleanroom/build.gradle | 291 +------- cleanroom/gradle/scripts/helpers.gradle | 96 --- .../assets/distanthorizons/lang/en_us.lang | 647 ------------------ .../shaders/apply/blaze/frag.fsh | 27 - .../shaders/apply/blaze/vert.vsh | 15 - .../shaders/copy/blaze/frag.fsh | 13 - .../shaders/copy/blaze/vert.vsh | 12 - .../shaders/debug/blaze/frag.fsh | 14 - .../shaders/debug/blaze/vert.vsh | 14 - .../shaders/debug/gl/frag.frag | 10 - .../shaders/debug/gl/vert.vert | 10 - .../shaders/fade/blaze/dh_fade.fsh | 67 -- .../shaders/fade/blaze/vanilla_fade.fsh | 95 --- .../shaders/fade/blaze/vert.vsh | 15 - .../shaders/fade/gl/apply.frag | 14 - .../shaders/fade/gl/dh_fade.frag | 65 -- .../shaders/fade/gl/vanilla_fade.frag | 91 --- .../shaders/fog/blaze/frag.fsh | 299 -------- .../shaders/fog/blaze/vert.vsh | 15 - .../distanthorizons/shaders/fog/gl/apply.frag | 27 - .../distanthorizons/shaders/fog/gl/fog.frag | 297 -------- .../shaders/generic/blaze/frag.fsh | 10 - .../shaders/generic/blaze/vert.vsh | 101 --- .../shaders/generic/gl/direct/frag.frag | 10 - .../shaders/generic/gl/direct/vert.vert | 41 -- .../shaders/generic/gl/instanced/frag.frag | 10 - .../shaders/generic/gl/instanced/vert.vert | 66 -- .../shaders/lod/blaze/frag.fsh | 125 ---- .../shaders/lod/blaze/vert.vsh | 81 --- .../shaders/shared/gl/apply.frag | 33 - .../shaders/shared/gl/flat_shaded.frag | 123 ---- .../shaders/shared/gl/quad_apply.vert | 15 - .../shaders/shared/gl/standard.vert | 79 --- .../shaders/ssao/blaze/apply.fsh | 86 --- .../shaders/ssao/blaze/frag.fsh | 137 ---- .../shaders/ssao/blaze/vert.vsh | 15 - .../distanthorizons/shaders/ssao/gl/ao.frag | 130 ---- .../shaders/ssao/gl/apply.frag | 78 --- .../shaders/test/blaze/frag.fsh | 10 - .../shaders/test/blaze/vert.vsh | 13 - .../distanthorizons/shaders/test/gl/frag.frag | 9 - .../distanthorizons/shaders/test/gl/vert.vert | 11 - .../textures/clouds-original.png | Bin 6214 -> 0 bytes .../distanthorizons/textures/clouds.png | Bin 553 -> 0 bytes .../distanthorizons/textures/gui/button.png | Bin 3198 -> 0 bytes .../textures/gui/changelog.png | Bin 299 -> 0 bytes .../textures/jar/themeDark.svg | 40 -- .../textures/jar/themeLight.svg | 76 -- .../assets/distanthorizons/textures/null.svg | 10 - .../distanthorizons/textures/test-grid.png | Bin 1103 -> 0 bytes .../0010-sqlite-createInitialDataTables.sql | 37 - ...20-sqlite-createFullDataSourceV2Tables.sql | 33 - .../0030-sqlite-changeTableJournaling.sql | 9 - .../0031-sqlite-useSqliteWalJournaling.sql | 8 - .../0040-sqlite-removeRenderCache.sql | 4 - .../0050-sqlite-addApplyToParentIndex.sql | 3 - .../0060-sqlite-createChunkHashTable.sql | 13 - .../0070-sqlite-createBeaconBeamTable.sql | 16 - .../0080-sqlite-addApplyToChildrenColumn.sql | 9 - ...0090-sqlite-addAdjacentFullDataColumns.sql | 12 - ...100-sqlite-deleteLowDetailDataForRegen.sql | 13 - .../src/main/resources/sqlScripts/readme.md | 51 -- .../main/resources/sqlScripts/scriptList.txt | 12 - .../common/AbstractModInitializer.java | 15 +- .../commonMixins/MixinChunkMapCommon.java | 18 +- .../commonMixins/MixinVanillaFogCommon.java | 56 +- .../common/wrappers/block/BiomeWrapper.java | 36 +- .../wrappers/block/BlockStateWrapper.java | 135 ++-- .../block/ClientBlockStateColorCache.java | 169 ++++- .../block/TintWithoutLevelOverrider.java | 3 +- .../common/wrappers/chunk/ChunkWrapper.java | 1 - .../common/wrappers/gui/DhScreen.java | 6 +- .../common/wrappers/gui/GuiHelper.java | 4 - .../common/wrappers/gui/MinecraftScreen.java | 114 ++- .../wrappers/gui/TexturedButtonWidget.java | 59 +- .../gui/classicConfig/ClassicConfigGUI.java | 230 +++++-- .../gui/classicConfig/DhConfigScreen.java | 318 +++++++-- .../minecraft/MinecraftClientWrapper.java | 112 +-- .../minecraft/MinecraftRenderWrapper.java | 94 ++- .../wrappers/minecraft/ProfilerWrapper.java | 18 +- .../InternalServerGenerator.java | 91 ++- .../resources/1_12_2.distanthorizons_at.cfg | 0 coreSubProjects | 2 +- gradle.properties | 6 +- versionProperties/1.12.2.properties | 10 +- 88 files changed, 1244 insertions(+), 4027 deletions(-) create mode 100644 buildSrc/src/main/groovy/unimined-cleanroom.gradle delete mode 100644 cleanroom/gradle/scripts/helpers.gradle delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/lang/en_us.lang delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/apply/blaze/frag.fsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/apply/blaze/vert.vsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/copy/blaze/frag.fsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/copy/blaze/vert.vsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/blaze/frag.fsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/blaze/vert.vsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/gl/frag.frag delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/gl/vert.vert delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/dh_fade.fsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/vanilla_fade.fsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/vert.vsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/apply.frag delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/dh_fade.frag delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/vanilla_fade.frag delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/blaze/frag.fsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/blaze/vert.vsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/gl/apply.frag delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/gl/fog.frag delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/blaze/frag.fsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/blaze/vert.vsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/direct/frag.frag delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/direct/vert.vert delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/instanced/frag.frag delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/instanced/vert.vert delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/lod/blaze/frag.fsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/lod/blaze/vert.vsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/apply.frag delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/flat_shaded.frag delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/quad_apply.vert delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/standard.vert delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/apply.fsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/frag.fsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/vert.vsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/gl/ao.frag delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/gl/apply.frag delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/test/blaze/frag.fsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/test/blaze/vert.vsh delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/test/gl/frag.frag delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/shaders/test/gl/vert.vert delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/textures/clouds-original.png delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/textures/clouds.png delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/textures/gui/button.png delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/textures/gui/changelog.png delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/textures/jar/themeDark.svg delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/textures/jar/themeLight.svg delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/textures/null.svg delete mode 100644 cleanroom/src/main/resources/assets/distanthorizons/textures/test-grid.png delete mode 100644 cleanroom/src/main/resources/sqlScripts/0010-sqlite-createInitialDataTables.sql delete mode 100644 cleanroom/src/main/resources/sqlScripts/0020-sqlite-createFullDataSourceV2Tables.sql delete mode 100644 cleanroom/src/main/resources/sqlScripts/0030-sqlite-changeTableJournaling.sql delete mode 100644 cleanroom/src/main/resources/sqlScripts/0031-sqlite-useSqliteWalJournaling.sql delete mode 100644 cleanroom/src/main/resources/sqlScripts/0040-sqlite-removeRenderCache.sql delete mode 100644 cleanroom/src/main/resources/sqlScripts/0050-sqlite-addApplyToParentIndex.sql delete mode 100644 cleanroom/src/main/resources/sqlScripts/0060-sqlite-createChunkHashTable.sql delete mode 100644 cleanroom/src/main/resources/sqlScripts/0070-sqlite-createBeaconBeamTable.sql delete mode 100644 cleanroom/src/main/resources/sqlScripts/0080-sqlite-addApplyToChildrenColumn.sql delete mode 100644 cleanroom/src/main/resources/sqlScripts/0090-sqlite-addAdjacentFullDataColumns.sql delete mode 100644 cleanroom/src/main/resources/sqlScripts/0100-sqlite-deleteLowDetailDataForRegen.sql delete mode 100644 cleanroom/src/main/resources/sqlScripts/readme.md delete mode 100644 cleanroom/src/main/resources/sqlScripts/scriptList.txt rename cleanroom/src/main/resources/1_12_2_distanthorizons_at.cfg => common/src/main/resources/1_12_2.distanthorizons_at.cfg (100%) diff --git a/buildSrc/src/main/groovy/dh-loader.gradle b/buildSrc/src/main/groovy/dh-loader.gradle index 09268cf07..109f51ac2 100644 --- a/buildSrc/src/main/groovy/dh-loader.gradle +++ b/buildSrc/src/main/groovy/dh-loader.gradle @@ -23,6 +23,9 @@ plugins { def isNotCommonProject = project.name != "common" +if (isNotCommonProject) { + evaluationDependsOn(":common") +} // ==================== Version Properties ==================== @@ -121,6 +124,15 @@ if (isNotCommonProject) { 'Multi-Release': true, 'Main-Class': 'com.seibel.distanthorizons.core.jar.JarMain', ) + if (project.name == "cleanroom") { + attributes( + 'ModType': 'CRL', + 'MixinConfigs': "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json", + 'FMLCorePlugin': 'com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin', + 'FMLCorePluginContainsFMLMod': true, + 'FMLAT': "src/main/resources/${gradle.ext.accessWidenerVersion}.distanthorizons_at.cfg" + ) + } } } } @@ -133,8 +145,14 @@ unimined.minecraft(sourceSets.main, true) { if (gradle.ext.minecraft_version.startsWith("1.")) { // 26.1+ doesn't use obfuscation mappings { - mojmap() - devNamespace "mojmap" + if(gradle.ext.minecraft_version.startsWith("1.12.2")){ + mcp("stable", "39-1.12") + } + else{ + mojmap() + devNamespace "mojmap" + } + } } } @@ -165,18 +183,22 @@ if (isNotCommonProject) { source(project(":common").sourceSets.main.allSource) } } else { - // Common: fabric for compilation + access widener, no jar remapping or runs unimined.minecraft { - fabric { - loader gradle.ext.fabric_loader_version - accessWidener project.file("src/main/resources/${gradle.ext.accessWidenerVersion}.distanthorizons.accesswidener") + if (gradle.ext.minecraft_version.equals("1.12.2")) { + cleanroom { + loader gradle.ext.cleanroom_loader_version + } + } else { + fabric { + loader gradle.ext.fabric_loader_version + accessWidener project.file("src/main/resources/${gradle.ext.accessWidenerVersion}.distanthorizons.accesswidener") + } } defaultRemapJar = false runs.off = true } } - // ==================== Configurations ==================== evaluationDependsOn(":core") @@ -342,16 +364,23 @@ if (isNotCommonProject) { // Make run tasks use the shadow jar so relocated deps work in dev. // Filter out jars bundled in the shadow jar, but keep jars that the loader also // needs (e.g. NightConfig — DH relocates it, but NeoForge needs the original). - def shadowedPaths = configurations.shadowMe.resolve().collect { it.path }.toSet() - def loaderPaths = configurations.minecraftLibraries.resolve().collect { it.path }.toSet() tasks.withType(JavaExec).configureEach { runTask -> dependsOn(shadowJar) classpath = files(shadowJar.archiveFile) + classpath.filter { file -> - !file.path.contains(project.buildDir.path) && - !file.path.contains("core${File.separator}build") && - !file.path.contains("api${File.separator}build") && - !file.path.contains("common${File.separator}build") && - !(shadowedPaths.contains(file.path) && !loaderPaths.contains(file.path)) + // resolve lazily inside doFirst to avoid triggering + // minecraft config resolution before Cleanroom/FG3 is ready + true + } + doFirst { + def shadowedPaths = configurations.shadowMe.resolve().collect { it.path }.toSet() + def loaderPaths = configurations.minecraftLibraries.resolve().collect { it.path }.toSet() + classpath = files(shadowJar.archiveFile) + classpath.filter { file -> + !file.path.contains(project.buildDir.path) && + !file.path.contains("core${File.separator}build") && + !file.path.contains("api${File.separator}build") && + !file.path.contains("common${File.separator}build") && + !(shadowedPaths.contains(file.path) && !loaderPaths.contains(file.path)) + } } // Shared run directory so all loaders use the same worlds @@ -367,20 +396,22 @@ if (isNotCommonProject) { } runTask.jvmArgs = filteredArgs - // fix (Neo)forge debug running - doFirst { - def modsDir = rootProject.file("run/${isClient ? 'client' : 'server'}/mods") - modsDir.mkdirs() + if(project.name == "forge" || project.name == "neoforge") { + // fix (Neo)forge debug running + doFirst { + def modsDir = rootProject.file("run/${isClient ? 'client' : 'server'}/mods") + modsDir.mkdirs() - // Remove any stale DH jars before copying the fresh one - modsDir.listFiles()?.each { file -> - if (file.name.startsWith(rootProject.mod_name)) file.delete() - } + // Remove any stale DH jars before copying the fresh one + modsDir.listFiles()?.each { file -> + if (file.name.startsWith(rootProject.mod_name)) file.delete() + } - // Copy shadow jar into mods folder so (Neo)Forge discovers it properly - copy { - from shadowJar.archiveFile - into modsDir + // Copy shadow jar into mods folder so (Neo)Forge discovers it properly + copy { + from shadowJar.archiveFile + into modsDir + } } } @@ -418,6 +449,9 @@ if (isNotCommonProject) { } } + tasks.downgradeJar.inputFile.set(tasks.named("remapJar").flatMap { it.archiveFile }) + tasks.jar.finalizedBy(tasks.named("remapJar")) + tasks.named("remapJar").configure { finalizedBy(tasks.shadeDowngradedApi) } } } @@ -486,7 +520,7 @@ if (isNotCommonProject) { // Remove unused access wideners exclude { file -> - if (file.name.contains(".distanthorizons.accesswidener") && file.name != "${rootProject.accessWidenerVersion}.distanthorizons.accesswidener") { + if ((file.name.contains(".distanthorizons.accesswidener") && file.name != "${rootProject.accessWidenerVersion}.distanthorizons.accesswidener")) { return true } return false diff --git a/buildSrc/src/main/groovy/root.gradle b/buildSrc/src/main/groovy/root.gradle index 4f34000fc..ff8640365 100644 --- a/buildSrc/src/main/groovy/root.gradle +++ b/buildSrc/src/main/groovy/root.gradle @@ -46,11 +46,3 @@ def writePreprocessorDefinitions() { writePreprocessorDefinitions() // Wire JVMDowngrader to process remapped jars -gradle.projectsEvaluated { - rootProject.subprojects.each { - if (it.tasks.findByName('remapJar') == null) return - it.tasks.downgradeJar.inputFile = it.tasks.remapJar.archiveFile - it.tasks.jar.finalizedBy(it.tasks.remapJar) - it.tasks.remapJar.finalizedBy(it.tasks.shadeDowngradedApi) - } -} diff --git a/buildSrc/src/main/groovy/unimined-cleanroom.gradle b/buildSrc/src/main/groovy/unimined-cleanroom.gradle new file mode 100644 index 000000000..04112af95 --- /dev/null +++ b/buildSrc/src/main/groovy/unimined-cleanroom.gradle @@ -0,0 +1,15 @@ +plugins { + id 'dh-loader' +} + +unimined.minecraft { + cleanroom { + loader gradle.ext.cleanroom_loader_version + useToolchains = false + accessTransformer project(":common").file("src/main/resources/${gradle.ext.accessWidenerVersion}.distanthorizons_at.cfg") + runs.all { + systemProperty("crl.dev.mixin", "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json") + systemProperty("fml.coreMods.load", "com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin") + } + } +} \ No newline at end of file diff --git a/cleanroom/build.gradle b/cleanroom/build.gradle index 3191c347c..25b33ff99 100644 --- a/cleanroom/build.gradle +++ b/cleanroom/build.gradle @@ -1,284 +1,45 @@ plugins { - id 'java' - id 'java-library' - id 'maven-publish' - id 'com.gradleup.shadow' version '9.2.2' - id 'xyz.wagyourtail.unimined' version '1.4.10-kappa' - id 'net.kyori.blossom' version '2.1.0' + id 'unimined-cleanroom' } -apply from: 'gradle/scripts/helpers.gradle' -// Early Assertions -assertProperty 'mod_version' -assertProperty 'maven_group' -assertProperty 'mod_id' -assertProperty 'mod_name' +// ==================== Mod Dependency Helper ==================== -version = propertyString('mod_version') -group = propertyString('maven_group') - -//base { -// archivesName.set(propertyString('mod_id')) -//} - - -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(21)) - } - //propertyBool('generate_sources_jar') - if (true) { - withSourcesJar() - } - //propertyBool('generate_javadocs_jar') - if (false) { - withJavadocJar() - } +def addMod(path, enabled) { + if (enabled == "2") + dependencies { modImplementation(path) } + else if (enabled == "1") + dependencies { compileOnly(path) } } -configurations { - embed - contain - implementation.extendsFrom(embed) - implementation.extendsFrom(contain) - modCompileOnly - compileOnly.extendsFrom(modCompileOnly) - modRuntimeOnly - runtimeOnly.extendsFrom(modRuntimeOnly) -} -String remapTaskName = "remapShadowJar" - -unimined.minecraft { - version "1.12.2" - - mappings { - mcp("stable", "39-1.12") - } - - cleanroom { - //propertyBool('use_access_transformer') - if (true) { - accessTransformer "${rootProject.projectDir}/cleanroom/src/main/resources/1_12_2_distanthorizons_at.cfg" - } - loader "0.4.4-alpha" - runs.auth.username = "Developer" - runs.all { - systemProperty("crl.dev.mixin", "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json") - jvmArgs += ['-Xmx4G'] - jvmArgs += [ - '-XX:+UseZGC', - '-XX:-UseG1GC' - ] - jvmArgs += ['-XX:+ZGenerational'] - - println "Classpath size BEFORE: ${classpath.files.size()}" - - classpath = classpath.filter { file -> - def remove = - file.path.contains("DistantHorizons-common") || - file.path.contains("DistantHorizons-core") || - file.path.contains("DistantHorizons-api") - - if (remove) { - println "Removing from classpath: $file" - } - - return !remove - } - - println "Classpath size AFTER: ${classpath.files.size()}" - - def extraPath = [ - sourceSets.main.output.classesDirs.asPath, - sourceSets.main.output.resourcesDir.absolutePath, - rootProject.project(':common').sourceSets.main.output.classesDirs.asPath, - rootProject.project(':core').sourceSets.main.output.classesDirs.asPath, - rootProject.project(':api').sourceSets.main.output.classesDirs.asPath, - ].join(File.pathSeparator) - - jvmArgs -= ("-Dcrl.dev.extrapath=") - jvmArgs += ("-Dcrl.dev.extrapath=${extraPath}") - - if (false) { - systemProperty("foundation.dump", "true") - systemProperty("foundation.verbose", "true") - } - //propertyBool('is_coremod') - if (true) { - //coremod_plugin_class_name - //forge for now bcs it will crash but correct is .cleanroom - systemProperty("fml.coreMods.load", "com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin") - } - - - return - } - } - - defaultRemapJar = false - - //propertyBool('enable_shadow') - if (true) { - remap(tasks.shadowJar) { - mixinRemap { - enableBaseMixin() - enableMixinExtra() - disableRefmap() - } - } - } else { - remap(tasks.jar) { - mixinRemap { - enableBaseMixin() - enableMixinExtra() - disableRefmap() - } - } - } - - mods { - remap(configurations.modCompileOnly) - remap(configurations.modRuntimeOnly) - } -} +// ==================== Dependencies ==================== dependencies { - compileOnly "com.cleanroommc:sponge-mixin:0.20.12+mixin.0.8.7" + +} + + +// ==================== Tasks ==================== + +task deleteResources(type: Delete) { + delete file("build/resources/main") } processResources { - - inputs.property 'mod_id', propertyString('mod_id') - inputs.property 'mod_name', propertyString('mod_name') - inputs.property 'mod_version', propertyString('mod_version') - inputs.property 'mod_description', propertyString('mod_description') - inputs.property 'mod_authors', propertyString('mod_authors').replace('[', '').replace(']', '').split(',').collect { it.trim().replace('"', '') }.join('", "') - inputs.property 'mod_credits', propertyString('mod_credits') - inputs.property 'mod_url', propertyString('mod_homepage') - inputs.property 'mod_update_json', propertyString('mod_update_json') - inputs.property 'mod_logo_path', "assets/distanthorizons/icon.png" - - def filterList = ['mcmod.info', 'pack.mcmeta'] - - filesMatching(filterList) { fcd -> - fcd.expand( - 'mod_id': propertyString('mod_id'), - 'mod_name': propertyString('mod_name'), - 'mod_version': propertyString('mod_version'), - 'mod_description': propertyString('mod_description'), - 'mod_authors': propertyString('mod_authors').replace('[', '').replace(']', '').split(',').collect { it.trim().replace('"', '') }.join('", "'), - 'mod_credits': propertyString('mod_credits'), - 'mod_url': propertyString('mod_homepage'), - 'mod_update_json': propertyString('mod_update_json'), - 'mod_logo_path': "assets/distanthorizons/icon.png", - ) - } - rename '(.+_at.cfg)', 'META-INF/$1' + dependsOn(copyCoreResources) + // dependsOn(copyCommonLoaderResources) } -sourceSets { - main { - blossom { - javaSources { - property('mod_id', propertyString('mod_id')) - property('mod_name', propertyString('mod_name')) - property('mod_version', propertyString('mod_version')) - property('package', "${maven_group}.${mod_id}") - } - } - } -} -//propertyBool('enable_shadow') -if (!true) { - shadowJar.enabled = false +tasks.named('runClient') { + dependsOn(copyCoreResources) + // dependsOn(copyCommonLoaderResources) + finalizedBy(deleteResources) } -jar { - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - if (configurations.contain.size() > 0) { - into('/') { - from configurations.contain - } - } - doFirst { - archiveClassifier = 'dev' - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - if (configurations.contain.size() > 0) { - into('/') { - from configurations.contain - } - } - manifest { - def attribute_map = [:] - attribute_map['ModType'] = "CRL" - attribute_map['MixinConfigs'] = "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json" - if (configurations.contain.size() > 0) { - attribute_map['ContainedDeps'] = configurations.contain.collect { it.name }.join(' ') - attribute_map['NonModDeps'] = true - } - //propertyBool('is_coremod') - if (true) { - //coremod_plugin_class_name - attribute_map['FMLCorePlugin'] = "com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin" - //coremod_includes_mod - if (true) { - attribute_map['FMLCorePluginContainsFMLMod'] = true - } - } - //propertyBool('use_access_transformer') - if (true) { - attribute_map['FMLAT'] = "1_12_2_distanthorizons_at.cfg" - } - attributes(attribute_map) - } - } - finalizedBy(tasks.named(remapTaskName).get()) -} - -shadowJar { - configurations = [project.configurations.shadowMe, project.configurations.shadowCommon] - archiveClassifier = "shadow" - - manifest { - def attribute_map = [:] - attribute_map['ModType'] = "CRL" - attribute_map['MixinConfigs'] = "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json" - attribute_map['FMLCorePlugin'] = "com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin" - attribute_map['FMLCorePluginContainsFMLMod'] = true - attribute_map['FMLAT'] = "1_12_2_distanthorizons_at.cfg" - attributes(attribute_map) - } -} - -tasks.named(remapTaskName).configure { - doFirst { - logging.captureStandardOutput LogLevel.INFO - } - doLast { - logging.captureStandardOutput LogLevel.QUIET - } -} - -compileTestJava { - sourceCompatibility = targetCompatibility = JavaVersion.VERSION_21 -} - -test { - useJUnitPlatform() - javaLauncher.set(javaToolchains.launcherFor { - languageVersion = JavaLanguageVersion.of(21) - }) - //propertyBool('show_testing_output') - if (false) { - testLogging { - showStandardStreams = true - } - } -} - -tasks.withType(JavaCompile).configureEach { - options.encoding = 'UTF-8' +sourcesJar { + def commonSources = project(":common").sourcesJar + dependsOn commonSources + from commonSources.archiveFile.map { zipTree(it) } } \ No newline at end of file diff --git a/cleanroom/gradle/scripts/helpers.gradle b/cleanroom/gradle/scripts/helpers.gradle deleted file mode 100644 index 0b3f2ee7f..000000000 --- a/cleanroom/gradle/scripts/helpers.gradle +++ /dev/null @@ -1,96 +0,0 @@ -import groovy.text.SimpleTemplateEngine -import org.codehaus.groovy.runtime.MethodClosure - -ext.propertyString = this.&propertyString as MethodClosure -ext.propertyBool = this.&propertyBool as MethodClosure -ext.propertyStringList = this.&propertyStringList as MethodClosure -ext.interpolate = this.&interpolate as MethodClosure -ext.assertProperty = this.&assertProperty as MethodClosure -ext.assertSubProperties = this.&assertSubProperties as MethodClosure -ext.setDefaultProperty = this.&setDefaultProperty as MethodClosure -ext.assertEnvironmentVariable = this.&assertEnvironmentVariable as MethodClosure - -String propertyString(String key) { - return $property(key).toString() -} - -boolean propertyBool(String key) { - return propertyString(key).toBoolean() -} - -Collection propertyStringList(String key) { - return propertyStringList(key, ' ') -} - -Collection propertyStringList(String key, String delimit) { - return propertyString(key).split(delimit).findAll { !it.isEmpty() } -} - -private Object $property(String key) { - def value = project.findProperty(key) - if (value instanceof String) { - return interpolate(value) - } - return value -} - -String interpolate(String value) { - if (value.startsWith('${{') && value.endsWith('}}')) { - value = value.substring(3, value.length() - 2) - Binding newBinding = new Binding(this.binding.getVariables()) - newBinding.setProperty('it', this) - return new GroovyShell(this.getClass().getClassLoader(), newBinding).evaluate(value) - } - if (value.contains('${')) { - return new SimpleTemplateEngine().createTemplate(value).make(project.properties).toString() - } - return value -} - -void assertProperty(String propertyName) { - def property = property(propertyName) - if (property == null) { - throw new GradleException("Property ${propertyName} is not defined!") - } - if (property.isEmpty()) { - throw new GradleException("Property ${propertyName} is empty!") - } -} - -void assertSubProperties(String propertyName, String... subPropertyNames) { - assertProperty(propertyName) - if (propertyBool(propertyName)) { - for (String subPropertyName : subPropertyNames) { - assertProperty(subPropertyName) - } - } -} - -void setDefaultProperty(String propertyName, boolean warn, defaultValue) { - def property = property(propertyName) - def exists = true - if (property == null) { - exists = false - if (warn) { - project.logger.log(LogLevel.WARN, "Property ${propertyName} is not defined!") - } - } else if (property.isEmpty()) { - exists = false - if (warn) { - project.logger.log(LogLevel.WARN, "Property ${propertyName} is empty!") - } - } - if (!exists) { - project.setProperty(propertyName, defaultValue.toString()) - } -} - -void assertEnvironmentVariable(String propertyName) { - def property = System.getenv(propertyName) - if (property == null) { - throw new GradleException("System Environment Variable $propertyName is not defined!") - } - if (property.isEmpty()) { - throw new GradleException("Property $propertyName is empty!") - } -} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/lang/en_us.lang b/cleanroom/src/main/resources/assets/distanthorizons/lang/en_us.lang deleted file mode 100644 index 1ebba1da3..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/lang/en_us.lang +++ /dev/null @@ -1,647 +0,0 @@ -#PARSE_ESCAPES -distanthorizons.title=Distant Horizons - - - -distanthorizons.general.true=True -distanthorizons.general.false=False -distanthorizons.general.yes=Yes -distanthorizons.general.no=No -distanthorizons.general.back=Back -distanthorizons.general.next=Next -distanthorizons.general.done=Done -distanthorizons.general.cancel=Cancel -distanthorizons.general.reset=Reset -distanthorizons.general.spacer= -distanthorizons.general.apiOverride=API LOCK -distanthorizons.general.disabledByApi.@tooltip=This option is controlled by another mod via DH's API \nso it cannot be changed via the UI or config file. - - - - -distanthorizons.updater.title=Distant Horizons auto updater -distanthorizons.updater.text1=§lNew update available! -distanthorizons.updater.text2=§fDo you want to update from %s§f to %s§f? -distanthorizons.updater.later=Not now -distanthorizons.updater.never=Don't show again -distanthorizons.updater.update=Update -distanthorizons.updater.update.@tooltip=Updates the mod this one time\n(Updates when game is closed) -distanthorizons.updater.silent=Always silent update -distanthorizons.updater.silent.@tooltip=Every time an update is available, it would update\n(§6WARNING§r: This wont prompt you when updating) -distanthorizons.updater.waitingForClose=Distant Horizons will finish updating once the game restarts - - - - -distanthorizons.config.title=Distant Horizons config -distanthorizons.config.client=Client - -distanthorizons.config.client.quickEnableRendering=Enable Rendering -distanthorizons.config.client.quickEnableRendering.@tooltip=Determines if Distant Horizons Renders LODs. - -distanthorizons.config.client.quickShowWorldGenProgress=Show LOD Gen/Import Progress -distanthorizons.config.client.quickShowWorldGenProgress.@tooltip=If true then the world gen/importing progress will be displayed on the screen when running. - -distanthorizons.config.client.qualityPresetSetting=Quality Preset -distanthorizons.config.client.qualityPresetSetting.@tooltip=Modifies a number of graphical settings to quickly change Distant Horizons' rendering quality. \n\nLower this setting if your GPU is at max usage or you are having framerate issues. -distanthorizons.config.client.threadPresetSetting=CPU Load -distanthorizons.config.client.threadPresetSetting.@tooltip=Modifies how many threads Distant Horizons' will use. \n\nIncreasing this setting will improve the Distant Generator speed and LOD loading speed, \nbut will also increase CPU/memory usage and may introduce stuttering. \n\nNote: This is a CPU relative setting. \nIt should put an equal amount of strain on a 2 core CPU as a 64 core CPU. - -distanthorizons.config.client.optionsButton=Show The Options Button -distanthorizons.config.client.optionsButton.@tooltip=Show the config button to the left of the fov button - - - -distanthorizons.config.client.advanced=Advanced options - -distanthorizons.config.client.advanced.graphics=Graphics -distanthorizons.config.client.advanced.worldGenerator=World Generator -distanthorizons.config.client.advanced.server=Server -distanthorizons.config.client.advanced.lodBuilding=LOD Building -distanthorizons.config.client.advanced.multiThreading=Multi-Threading -distanthorizons.config.client.advanced.logging=Logging - - - -distanthorizons.config.client.advanced.graphics.quality=Quality - -distanthorizons.config.client.advanced.graphics.quality.lodChunkRenderDistanceRadius=LOD Chunk Render Distance Radius -distanthorizons.config.client.advanced.graphics.quality.lodChunkRenderDistanceRadius.@tooltip=Distant Horizons' render distance, measured in chunks. \n\nNote: this is a best effort number. \nThe render distance may be above or below this number \ndepending on your other graphic settings. -distanthorizons.config.client.advanced.graphics.quality.horizontalQuality=LOD Dropoff Distance -distanthorizons.config.client.advanced.graphics.quality.horizontalQuality.@tooltip=How far apart drops in quality are.\n\nHigher settings will increase the distance between drops\nbut will increase memory and GPU usage. -distanthorizons.config.client.advanced.graphics.quality.maxHorizontalResolution=Max Horizontal Resolution -distanthorizons.config.client.advanced.graphics.quality.maxHorizontalResolution.@tooltip=The maximum detail LODs are rendered at.\n\n§6Fastest:§r Chunk\n§6Fanciest:§r Block -distanthorizons.config.client.advanced.graphics.quality.verticalQuality=Vertical Quality -distanthorizons.config.client.advanced.graphics.quality.verticalQuality.@tooltip=How well LODs represent overhangs, caves, cliffsides, etc.\n\nHigher options will increase memory and GPU usage. -distanthorizons.config.client.advanced.graphics.quality.horizontalScale=Horizontal Scale -distanthorizons.config.client.advanced.graphics.quality.horizontalScale.@tooltip=How quickly LODs drop off in quality.\n\nLarger numbers will improve how distant terrain looks\nbut will increase memory and GPU usage. -distanthorizons.config.client.advanced.graphics.quality.transparency=Transparency -distanthorizons.config.client.advanced.graphics.quality.blocksToIgnore=Blocks To Ignore -distanthorizons.config.client.advanced.graphics.quality.blocksToIgnore.@tooltip=Defines the types of blocks to ignore when generating LODs. -distanthorizons.config.client.advanced.graphics.quality.tintWithAvoidedBlocks=Tint With Avoided Blocks -distanthorizons.config.client.advanced.graphics.quality.tintWithAvoidedBlocks.@tooltip=§4Note: makes snow, carpet, and trapdoors look really bad§r\nShould the blocks underneath avoided blocks gain the color of the avoided block?\n§6True:§r a red flower on grass will tint the grass below it red\n§6False:§r skipped blocks will not change color of surface below them -distanthorizons.config.client.advanced.graphics.quality.lodShading=LOD Shading -distanthorizons.config.client.advanced.graphics.quality.lodShading.@tooltip=Defines how LODs should be shaded. \nCan be used to improve shader compatibility. -distanthorizons.config.client.advanced.graphics.quality.grassSideRendering=Grass Side Rendering -distanthorizons.config.client.advanced.graphics.quality.grassSideRendering.@tooltip=How should the sides and bottom of grass block LODs render? -distanthorizons.config.client.advanced.graphics.quality.ditherDhFade=Fade Nearby DH LODs -distanthorizons.config.client.advanced.graphics.quality.ditherDhFade.@tooltip=If true LODs will fade away as you get closer to them. \nIf false LODs will cut off abruptly at a set distance from the camera. \nThis setting is affected by the vanilla overdraw prevention config. -distanthorizons.config.client.advanced.graphics.quality.vanillaFadeMode=Vanilla Fade Mode -distanthorizons.config.client.advanced.graphics.quality.vanillaFadeMode.@tooltip=How should vanilla Minecraft fade into Distant Horizons LODs? \n\nNONE: Fastest, there will be a pronounced border between DH and MC rendering. \nSINGLE_PASS: Fades after MC's transparent pass, opaque blocks underwater won't be faded. \nDOUBLE_PASS: Slowest, fades after both MC's opaque and transparent passes, provides the smoothest transition. -distanthorizons.config.client.advanced.graphics.quality.dhFadeFarClipPlane=Fade Before Far Clip Plane -distanthorizons.config.client.advanced.graphics.quality.dhFadeFarClipPlane.@tooltip=Should DH fade out before reaching the far plane? \nThis is helpful to prevent DH clouds from cutting off in the distance. -distanthorizons.config.client.advanced.graphics.quality.brightnessMultiplier=Brightness Multiplier -distanthorizons.config.client.advanced.graphics.quality.brightnessMultiplier.@tooltip=How bright LOD colors are.\n\n0 = black \n1 = normal \n2 = near white -distanthorizons.config.client.advanced.graphics.quality.saturationMultiplier=Saturation Multiplier -distanthorizons.config.client.advanced.graphics.quality.saturationMultiplier.@tooltip=How saturated LOD colors are.\n\n0 = black and white \n1 = normal \n2 = vibrant -distanthorizons.config.client.advanced.graphics.quality.lodBiomeBlending=Biome Blending -distanthorizons.config.client.advanced.graphics.quality.lodBiomeBlending.@tooltip=This is the same as vanilla Biome Blending settings for LOD area. \n\nNote that anything other than '0' will greatly effect Lod building time\nand increase triangle count. The cost on chunk generation speed is also \nquite large if set to too high.\n\n'0' equals to Vanilla Biome Blending of '1x1', \n'1' equals to Vanilla Biome Blending of '3x3', \n'2' equals to Vanilla Biome Blending of '5x5'... \n - - - -distanthorizons.config.client.advanced.graphics.ssao=Ambient Occlusion - -distanthorizons.config.client.advanced.graphics.ssao.enableSsao=Enable Ambient Occlusion -distanthorizons.config.client.advanced.graphics.ssao.enableSsao.@tooltip=Ambient Occlusion adds depth to the lighting of blocks. -distanthorizons.config.client.advanced.graphics.ssao.sampleCount=Sample Count -distanthorizons.config.client.advanced.graphics.ssao.sampleCount.@tooltip=Determines how many points in space are sampled for the occlusion test. \nHigher numbers will improve quality and reduce banding, but will increase GPU load. -distanthorizons.config.client.advanced.graphics.ssao.radius=Radius -distanthorizons.config.client.advanced.graphics.ssao.radius.@tooltip=Determines the radius Screen Space Ambient Occlusion is applied, measured in blocks. -distanthorizons.config.client.advanced.graphics.ssao.strength=Strength -distanthorizons.config.client.advanced.graphics.ssao.strength.@tooltip=Determines how dark the Screen Space Ambient Occlusion effect will be. -distanthorizons.config.client.advanced.graphics.ssao.bias=Bias -distanthorizons.config.client.advanced.graphics.ssao.bias.@tooltip=Increasing the value can reduce banding at the cost of reducing the strength of the effect. -distanthorizons.config.client.advanced.graphics.ssao.minLight=Min Light -distanthorizons.config.client.advanced.graphics.ssao.minLight.@tooltip=Determines how dark the occlusion shadows can be. \n0 = totally black at the corners \n1 = no shadow -distanthorizons.config.client.advanced.graphics.ssao.blurRadius=Blur Radius -distanthorizons.config.client.advanced.graphics.ssao.blurRadius.@tooltip=The radius, measured in pixels, that blurring is calculated for the SSAO. \nHigher numbers will reduce banding at the cost of GPU performance. -distanthorizons.config.client.advanced.graphics.ssao.fadeDistanceInBlocks=Fade Distance -distanthorizons.config.client.advanced.graphics.ssao.fadeDistanceInBlocks.@tooltip=The distance in blocks from the camera where the SSAO will fade out to. \nThis is done to prevent banding and noise at extreme distances. - - - -distanthorizons.config.client.advanced.graphics.genericRendering=Generic Object Rendering -distanthorizons.config.client.advanced.graphics.genericRendering.enableGenericRendering=Enable Rendering -distanthorizons.config.client.advanced.graphics.genericRendering.enableGenericRendering.@tooltip=If true non terrain objects will be rendered in DH's terrain. \nThis includes beacon beams and clouds. -distanthorizons.config.client.advanced.graphics.genericRendering.enableBeaconRendering=Enable Beacon Rendering -distanthorizons.config.client.advanced.graphics.genericRendering.beaconRenderHeight=Beacon render height -distanthorizons.config.client.advanced.graphics.genericRendering.beaconRenderHeight.@tooltip=Sets the maximum height at which beacons will render. \nThis will only affect new beacons coming into LOD render distance. \nBeacons currently visible in LOD chunks will not be affected. -distanthorizons.config.client.advanced.graphics.genericRendering.expandDistantBeacons=Expand Distant Beacons -distanthorizons.config.client.advanced.graphics.genericRendering.expandDistantBeacons.@tooltip=If true LOD beacon beams will be rendered wider at extreme distances, \nmaking them easier to see. \nIf false all LOD beacon beams will only ever be 1 block wide. -distanthorizons.config.client.advanced.graphics.genericRendering.enableBeaconRendering.@tooltip=If true LOD beacon beams will be rendered. -distanthorizons.config.client.advanced.graphics.genericRendering.enableCloudRendering=Enable Cloud Rendering -distanthorizons.config.client.advanced.graphics.genericRendering.enableCloudRendering.@tooltip=If true LOD clouds will be rendered. -distanthorizons.config.client.advanced.graphics.genericRendering.dimensionEnabledCloudRenderingCsv=Enable Cloud Rendering -distanthorizons.config.client.advanced.graphics.genericRendering.dimensionEnabledCloudRenderingCsv.@tooltip=A comma separated separated list of dimension resource locations where DH clouds will render. \n\nExample: \minecraft:overworld,minecraft:the_end\ \n\nChanges will only be seen when the world is re-loaded. -distanthorizons.config.client.advanced.graphics.genericRendering.enableUnexploredFogRendering=Enable Unexplored Fog Rendering -distanthorizons.config.client.advanced.graphics.genericRendering.enableUnexploredFogRendering.@tooltip=If true unexplored/ungenerated LODs will be rendered as large dark gray boxes. -distanthorizons.config.client.advanced.graphics.genericRendering.enableInstancedRendering=Enable Instanced Rendering -distanthorizons.config.client.advanced.graphics.genericRendering.enableInstancedRendering.@tooltip=Can be disabled to use much slower but more compatible direct rendering. \nDisabling this can be used to fix some crashes on Mac. - - - -distanthorizons.config.client.advanced.graphics.fog=Fog - -distanthorizons.config.client.advanced.graphics.fog.enableDhFog=Enable Distant Horizons Fog -distanthorizons.config.client.advanced.graphics.fog.enableDhFog.@tooltip=Determines if fog is drawn on DH LODs. -distanthorizons.config.client.advanced.graphics.fog.colorMode=Fog Color Mode -distanthorizons.config.client.advanced.graphics.fog.colorMode.@tooltip=The color of the fog on LODs. -distanthorizons.config.client.advanced.graphics.fog.enableVanillaFog=Enable Vanilla Fog -distanthorizons.config.client.advanced.graphics.fog.enableVanillaFog.@tooltip=§6True:§r Minecraft renders fog like normal.\n§6False:§r disables Minecraft's fog on vanilla chunks.\n\nMay cause issues with other mods that edit fog. -distanthorizons.config.client.advanced.graphics.fog.advancedFog=Advanced Fog Options - -distanthorizons.config.client.advanced.graphics.fog.farFogStart=Fog Start -distanthorizons.config.client.advanced.graphics.fog.farFogStart.@tooltip=Where should the fog start? \n\n'0.0': Fog start at player's position.\n'1.0': The fog-start's circle fit just in the lod render distance square.\n'1.414': The lod render distance square fit just in the fog-start's circle.\n -distanthorizons.config.client.advanced.graphics.fog.farFogEnd=Fog End -distanthorizons.config.client.advanced.graphics.fog.farFogEnd.@tooltip=Where should the fog end? \n\n'0.0': Fog end at player's position.\n'1.0': The fog-end's circle fit just in the lod render distance square.\n'1.414': The lod render distance square fit just in the fog-end's circle.\n -distanthorizons.config.client.advanced.graphics.fog.farFogMin=Fog Min -distanthorizons.config.client.advanced.graphics.fog.farFogMin.@tooltip=What is the minimum fog thickness? \n\n'0.0': No fog at all.\n'1.0': Fully fog color.\n -distanthorizons.config.client.advanced.graphics.fog.farFogMax=Fog Max -distanthorizons.config.client.advanced.graphics.fog.farFogMax.@tooltip=What is the maximum fog thickness? \n\n'0.0': No fog at all.\n'1.0': Fully fog color.\n -distanthorizons.config.client.advanced.graphics.fog.farFogFalloff=Fog Falloff -distanthorizons.config.client.advanced.graphics.fog.farFogFalloff.@tooltip=How should the fog thickness should be calculated? \n\nLINEAR: Linear based on distance (will ignore 'density')\nEXPONENTIAL: 1/(e^(distance*density)) \nEXPONENTIAL_SQUARED: 1/(e^((distance*density)^2)) \n -distanthorizons.config.client.advanced.graphics.fog.farFogDensity=Fog Density -distanthorizons.config.client.advanced.graphics.fog.farFogDensity.@tooltip=What is the fog's density? - - - -distanthorizons.config.client.advanced.graphics.fog.heightFog=Height Fog Options - -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMixMode=Height Fog Mix Mode -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMixMode.@tooltip=Defines how height effects fog. \nWhen in doubt start with SPHERICAL, ADDITION, or MAX. \n\nSPHERICAL: Fog is calculated based on camera distance. \nCYLINDRICAL: Ignore height, fog is calculated based on horizontal distance. \nMAX: max(heightFog, farFog) \nADDITION: heightFog + farFog \nMULTIPLY: heightFog * farFog \nINVERSE_MULTIPLY: 1 - (1-heightFog) * (1-farFog) \nLIMITED_ADDITION: farFog + max(farFog, heightFog) \nMULTIPLY_ADDITION: farFog + farFog * heightFog \nINVERSE_MULTIPLY_ADDITION: farFog + 1 - (1-heightFog) * (1-farFog) \nAVERAGE: farFog*0.5 + heightFog*0.5 -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogDirection=Height Fog Direction -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogDirection.@tooltip=Where should the height fog be located? \n\nABOVE_CAMERA: Height fog starts from camera to the sky \nBELOW_CAMERA: Height fog starts from camera to the void \nABOVE_AND_BELOW_CAMERA: Height fog starts from camera to both the sky and the void \nABOVE_SET_HEIGHT: Height fog starts from a set height to the sky \nBELOW_SET_HEIGHT: Height fog starts from a set height to the void \nABOVE_AND_BELOW_SET_HEIGHT: Height fog starts from a set height to both the sky and the void \n -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogBaseHeight=Height Fog Base Height -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogBaseHeight.@tooltip=If the height fog is calculated around a set height, what is that height position? -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogStart=Height Fog Start -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogStart.@tooltip=How far the start of height fog should offset? \n\n'0.0': Fog start with no offset.\n'1.0': Fog start with offset of the entire world's height. (Include depth)\n -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogEnd=Height Fog End -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogEnd.@tooltip=How far the end of height fog should offset? \n\n'0.0': Fog end with no offset.\n'1.0': Fog end with offset of the entire world's height. (Include depth)\n -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMin=Height Fog Min -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMin.@tooltip=What is the minimum fog thickness? \n\n'0.0': No fog at all.\n'1.0': Fully fog color.\n -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMax=Height Fog Max -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMax.@tooltip=What is the maximum fog thickness? \n\n'0.0': No fog at all.\n'1.0': Fully fog color.\n -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogFalloff=Height Fog Falloff -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogFalloff.@tooltip=How should the height fog thickness should be calculated? \n\nLINEAR: Linear based on height (will ignore 'density')\nEXPONENTIAL: 1/(e^(height*density)) \nEXPONENTIAL_SQUARED: 1/(e^((height*density)^2)) \n -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogDensity=Height Fog Density -distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogDensity.@tooltip=What is the height fog's density? - - - -distanthorizons.config.client.advanced.graphics.noiseTexture=Noise Texture - -distanthorizons.config.client.advanced.graphics.noiseTexture.enableNoiseTexture=Enable Noise Texture -distanthorizons.config.client.advanced.graphics.noiseTexture.enableNoiseTexture.@tooltip=If enabled a noise texture will be applied to LODs to simulate textures. -distanthorizons.config.client.advanced.graphics.noiseTexture.noiseSteps=Noise Steps -distanthorizons.config.client.advanced.graphics.noiseTexture.noiseSteps.@tooltip=Determines how many steps of noise should be applied to the LODs. -distanthorizons.config.client.advanced.graphics.noiseTexture.noiseIntensity=Noise Intensity -distanthorizons.config.client.advanced.graphics.noiseTexture.noiseIntensity.@tooltip=Determines how intense the noise texture is. -distanthorizons.config.client.advanced.graphics.noiseTexture.noiseDropoff=Noise Dropoff -distanthorizons.config.client.advanced.graphics.noiseTexture.noiseDropoff.@tooltip=Defines how far should the noise texture render before it fades away. (in blocks). \nSet to 0 to disable noise from fading away. - - - -distanthorizons.config.client.advanced.graphics.culling=Culling - -distanthorizons.config.client.advanced.graphics.culling.overdrawPrevention=Overdraw Prevention -distanthorizons.config.client.advanced.graphics.culling.overdrawPrevention.@tooltip=Determines how far from the camera Distant Horizons will start rendering. \nMeasured as a percentage of the vanilla render distance.\n-1 = Auto, overdraw will change based on the vanilla render distance.\n\nHigher values will prevent LODs from rendering behind vanilla blocks at a higher distance,\nbut may cause holes to appear in the LODs. \nHoles are most likely to appear when flying through unloaded terrain. \n\nIncreasing the vanilla render distance increases the effectiveness of this setting. -distanthorizons.config.client.advanced.graphics.culling.reduceOverdrawWithFastMovement=Reduce Overdraw With Fast Movement -distanthorizons.config.client.advanced.graphics.culling.reduceOverdrawWithFastMovement.@tooltip=If set to true the overdraw prevention radius will get closer \nto the camera when flying/moving quickly. \n\nThis helps reduce issues where Minecraft can't load or \ngenerate chunks fast enough to keep up with DH. -distanthorizons.config.client.advanced.graphics.culling.enableCaveCulling=Cave Culling -distanthorizons.config.client.advanced.graphics.culling.enableCaveCulling.@tooltip=If enabled caves will be culled \n\nAdditional Info: Currently this cull all faces \n with skylight value of 0 under the cave culling height in dimensions that \n do not have a ceiling. \n -distanthorizons.config.client.advanced.graphics.culling.caveCullingHeight=Cave Culling Height -distanthorizons.config.client.advanced.graphics.culling.caveCullingHeight.@tooltip=At what Y value should cave culling start? -distanthorizons.config.client.advanced.graphics.culling.disableBeaconDistanceCulling=Enable Beacon Distance Culling -distanthorizons.config.client.advanced.graphics.culling.disableBeaconDistanceCulling.@tooltip=If true beacons near the camera won't be drawn to prevent vanilla overdraw. \nIf false all beacons will be rendered. -distanthorizons.config.client.advanced.graphics.culling.disableFrustumCulling=Disable Frustum Culling -distanthorizons.config.client.advanced.graphics.culling.disableFrustumCulling.@tooltip=If false LODs outside the player's camera \naren't drawn, increasing GPU performance. \n\nIf true all LODs are drawn, even those behind \nthe player's camera, decreasing GPU performance. \n\nDisable this if you see LODs disappearing at the corners of your vision. -distanthorizons.config.client.advanced.graphics.culling.disableShadowPassFrustumCulling=Disable Shadow Pass Frustum Culling -distanthorizons.config.client.advanced.graphics.culling.disableShadowPassFrustumCulling.@tooltip=Identical to the other frustum culling option except that it is \nonly used when a shader mod is present using the DH API \nand the shadow pass is being rendered. \n\nDisable this if shadows render incorrectly. -distanthorizons.config.client.advanced.graphics.culling.ignoredRenderBlockCsv=Ignored Block CSV -distanthorizons.config.client.advanced.graphics.culling.ignoredRenderBlockCsv.@tooltip=A comma separated list of block resource locations that won't be rendered by DH. \nNote: air is always included in this list. -distanthorizons.config.client.advanced.graphics.culling.ignoredRenderCaveBlockCsv=Ignored Cave Block CSV -distanthorizons.config.client.advanced.graphics.culling.ignoredRenderCaveBlockCsv.@tooltip=A comma separated list of block resource locations that shouldn't be rendered \nif they are in a 0 sky light underground area. \nNote: air is always included in this list. - -distanthorizons.config.client.advanced.graphics.overrideVanillaGraphicsSettings=Override Vanilla Settings -distanthorizons.config.client.advanced.graphics.overrideVanillaGraphicsSettings.@tooltip=If true some vanilla graphics settings will be automatically changed \nduring DH setup to provide a better experience. \n\nIE disabling vanilla clouds (which render on top of DH LODs), \nand chunk fading (DH already fades MC chunks). - - - -distanthorizons.config.client.advanced.graphics.experimental=Experimental - -distanthorizons.config.client.advanced.graphics.experimental.earthCurveRatio=Earth Curve Ratio -distanthorizons.config.client.advanced.graphics.experimental.earthCurveRatio.@tooltip=A value of 1 is equivalent to the curvature of Earth in real life. \nThe minimum accepted value is 50 and the maximum value is 5000. \nEverything between 1 and 49 will be rounded up to 50. -distanthorizons.config.client.advanced.graphics.experimental.ignoredDimensionCsv=Ignored Dimension CSV -distanthorizons.config.client.advanced.graphics.experimental.ignoredDimensionCsv.@tooltip=A comma separated list of dimension resource locations where DH won't render. Example: \minecraft:the_nether,minecraft:the_end\ \n\nNote: \nSome DH settings will be disabled and/or changed to improve \nvisuals when DH rendering is disabled. - - - -distanthorizons.config.client.advanced.autoUpdater=Auto Updater - -distanthorizons.config.client.advanced.autoUpdater.enableAutoUpdater=Enable automatic updates -distanthorizons.config.client.advanced.autoUpdater.enableSilentUpdates=Enable Silent Updates -distanthorizons.config.client.advanced.autoUpdater.enableSilentUpdates.@tooltip=Automatically updates the mod when an update is available -distanthorizons.config.client.advanced.autoUpdater.updateBranch=Update Branch -distanthorizons.config.client.advanced.autoUpdater.updateBranch.@tooltip=Where to download the latest update from. \n\nAuto: Downloads either stable or nightly builds based on the current jar. \nStable: Stable builds from Modrinth. \nNightly: Nightly builds from Gitlab. - - - -distanthorizons.config.client.advanced.multiplayer=Multiplayer - -distanthorizons.config.client.advanced.multiplayer.serverFolderNameMode=Server Folder Mode -distanthorizons.config.client.advanced.multiplayer.serverFolderNameMode.@tooltip=Determines the folder format for local multiplayer data.\n\n§6Name Only:§r\nUses the server browser name. Ex: \Minecraft Server\\n§6IP Only:§r\n\192.168.1.40\\n§6Name IP:§r\n\Minecraft Server, IP 192.168.1.40\\n§6Name, IP, Port:§r\n\Minecraft Server, IP 192.168.1.40:25565\\n§6Name, IP, Port, MC Version:§r\n\Minecraft Server, IP 192.168.1.40:25565, GameVersion 1.18.1\\n\n§c§lCaution:§r changing while connected to a multiplayer server may cause glitches. - - - - -distanthorizons.config.client.advanced.debugging=Debug - -distanthorizons.config.client.advanced.debugging.rendererMode=Renderer Mode -distanthorizons.config.client.advanced.debugging.debugRendering=Debug Rendering -distanthorizons.config.client.advanced.debugging.lodOnlyMode=Only Render LODs -distanthorizons.config.client.advanced.debugging.lodOnlyMode.@tooltip=If enabled this will disable (most) vanilla Minecraft rendering. \n\nNOTE: Do not report any issues when this mode is on! \nThis setting is only for fun and debugging. \nMod compatibility is not guaranteed. -distanthorizons.config.client.advanced.debugging.renderWireframe=Render Wireframe -distanthorizons.config.client.advanced.debugging.renderWireframe.@tooltip=If enabled the LODs will render as wireframe. -distanthorizons.config.client.advanced.debugging.enableDebugKeybindings=Enable debug keybindings -distanthorizons.config.client.advanced.debugging.enableDebugKeybindings.@tooltip=If true several keys can be used to toggle debug states. \nF6 - enable/disable LOD rendering \nF7 - enable/disable LOD only rendering \nF8 - cycle through the different debug rendering modes -distanthorizons.config.client.advanced.debugging.enableWhiteWorld=Enable white world -distanthorizons.config.client.advanced.debugging.enableWhiteWorld.@tooltip=If enabled, vertex color will not be passed.\nUseful for debugging shaders. -distanthorizons.config.client.advanced.debugging.showOverlappingQuadErrors=Show overlapping quad errors -distanthorizons.config.client.advanced.debugging.showOverlappingQuadErrors.@tooltip=If true overlapping quads will be rendered as bright red for easy identification. \nIf false the quads will be rendered normally. -distanthorizons.config.client.advanced.debugging.logBufferGarbageCollection=Log Buffer Garbage Collection -distanthorizons.config.client.advanced.debugging.logBufferGarbageCollection.@tooltip=If true OpenGL Buffer garbage collection will be logged \nthis also includes the number of live buffers. -distanthorizons.config.client.advanced.debugging.allowUnsafeValues=Allow Unsafe UI Values -distanthorizons.config.client.advanced.debugging.allowUnsafeValues.@tooltip=If enabled, very limited config input validation will be performed. \n\nWarning: enabling this can cause instability or crashing, use at your own risk. \nNote: this option isn't saved between sessions. - - - - -distanthorizons.config.client.advanced.debugging.debugWireframe=Debug Wireframe - -distanthorizons.config.client.advanced.debugging.debugWireframe.enableRendering=Enable Debug Wireframe Rendering -distanthorizons.config.client.advanced.debugging.debugWireframe.enableRendering.@tooltip=If enabled, various wireframes for debugging internal functions will be drawn. -distanthorizons.config.client.advanced.debugging.debugWireframe.showWorldGenQueue=Show World Gen Queue -distanthorizons.config.client.advanced.debugging.debugWireframe.showNetworkSyncOnLoadQueue=Show Network Sync On Load Queue -distanthorizons.config.client.advanced.debugging.debugWireframe.showRenderSectionStatus=Show Render Section Status -distanthorizons.config.client.advanced.debugging.debugWireframe.showRenderSectionToggling=Show Render Section Toggling -distanthorizons.config.client.advanced.debugging.debugWireframe.showQuadTreeRenderStatus=Show Quad Tree Render Status -distanthorizons.config.client.advanced.debugging.debugWireframe.showFullDataUpdateStatus=Show Full Data Update Status - - - -distanthorizons.config.client.advanced.debugging.openGl=Open GL - -distanthorizons.config.client.advanced.debugging.openGl.overrideVanillaGLLogger=Override Vanilla GL Logger -distanthorizons.config.client.advanced.debugging.openGl.overrideVanillaGLLogger.@tooltip=Defines how OpenGL errors are handled. \nRequires rebooting Minecraft to change. \nWill catch OpenGL errors thrown by other mods. -distanthorizons.config.client.advanced.debugging.openGl.onlyLogGlErrorsOnce=Only Log GL Errors Once -distanthorizons.config.client.advanced.debugging.openGl.onlyLogGlErrorsOnce.@tooltip=If true each Open GL error will only be logged once. \nTEnabling this may cause some error logs to be missed. \nDoes nothing if overrideVanillaGLLogger is set to false. \n\nGenerally this can be kept as 'true' to prevent log spam. \nHowever, Please set this to 'false' if a developer needs your log to debug a GL issue. \n -distanthorizons.config.client.advanced.debugging.openGl.glErrorHandlingMode=OpenGL Error Handling Mode -distanthorizons.config.client.advanced.debugging.openGl.glErrorHandlingMode.@tooltip=Defines how OpenGL errors are handled. \n Requires rebooting Minecraft to apply. \nMay incorrectly catch OpenGL errors thrown by other mods. -distanthorizons.config.client.advanced.debugging.openGl.validateBufferIdsBeforeRendering=Validate Buffer IDs Before Rendering -distanthorizons.config.client.advanced.debugging.openGl.validateBufferIdsBeforeRendering.@tooltip=Massively reduces FPS. \nShould only be used if mysterious EXCEPTION_ACCESS_VIOLATION crashes are happening in DH's rendering code and you're attempting to troubleshoot it. -distanthorizons.config.client.advanced.debugging.openGl.glUploadMode=Uploade Mode -distanthorizons.config.client.advanced.debugging.openGl.glUploadMode.@tooltip=Only for debugging - - - -distanthorizons.config.client.advanced.debugging.columnBuilderDebugging=Render Column Builder - -distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugEnable=Enable Column Builder Limiting -distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugDetailLevel=Column Builder Limit - Detail Level -distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugXPos=Column Builder Limit - X Pos -distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugZPos=Column Builder Limit - Z Pos -distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugXRow=Column Builder Limit - X Row -distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugZRow=Column Builder Limit - Z Row -distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugColumnIndex=Column Builder Limit - Col Index - - - -distanthorizons.config.client.advanced.debugging.f3Screen=F3 Screen - -distanthorizons.config.client.advanced.debugging.f3Screen.showPlayerPos=Show Player Pos -distanthorizons.config.client.advanced.debugging.f3Screen.playerPosSectionDetailLevel=Player Section Pos Detail Level -distanthorizons.config.client.advanced.debugging.f3Screen.showThreadPools=Show Thread Pools -distanthorizons.config.client.advanced.debugging.f3Screen.showCombinedObjectPools=Show Combined Object Pools -distanthorizons.config.client.advanced.debugging.f3Screen.showSeparatedObjectPools=Show Separated Object Pools -distanthorizons.config.client.advanced.debugging.f3Screen.showQueuedChunkUpdateCount=Show Queued Chunk Update Count -distanthorizons.config.client.advanced.debugging.f3Screen.showLevelStatus=Show Level Status -distanthorizons.config.client.advanced.debugging.f3Screen.onlyShowRenderingLevels=Only Show Rendering Levels - - - -distanthorizons.config.client.advanced.debugging.exampleConfigScreen=Debug Config Screen - -distanthorizons.config.client.advanced.debugging.exampleConfigScreen.debugConfigScreenNote=This screen is to debug features of the config screen -distanthorizons.config.client.advanced.debugging.exampleConfigScreen.boolTest=Boolean test -distanthorizons.config.client.advanced.debugging.exampleConfigScreen.byteTest=Byte test -distanthorizons.config.client.advanced.debugging.exampleConfigScreen.intTest=Integer test -distanthorizons.config.client.advanced.debugging.exampleConfigScreen.doubleTest=Double test -distanthorizons.config.client.advanced.debugging.exampleConfigScreen.shortTest=Short test -distanthorizons.config.client.advanced.debugging.exampleConfigScreen.longTest=Long test -distanthorizons.config.client.advanced.debugging.exampleConfigScreen.floatTest=Float test -distanthorizons.config.client.advanced.debugging.exampleConfigScreen.stringTest=String test -distanthorizons.config.client.advanced.debugging.exampleConfigScreen.uiButtonTest=UI Button test -distanthorizons.config.client.advanced.debugging.exampleConfigScreen.listTest=List (ArrayList) test -distanthorizons.config.client.advanced.debugging.exampleConfigScreen.mapTest=Map (HashMap) test -distanthorizons.config.client.advanced.debugging.exampleConfigScreen.categoryTest=Category test -distanthorizons.config.client.advanced.debugging.exampleConfigScreen.linkableTest=Linkable test -distanthorizons.config.client.advanced.debugging.exampleConfigScreen.linkableTest.@tooltip=The value of this should be the same as in Category Test - - - - - -distanthorizons.config.common=Common - - -distanthorizons.config.common.worldGenerator=World Generator - -distanthorizons.config.common.worldGenerator.enableDistantGeneration=Enable Distant Generation -distanthorizons.config.common.worldGenerator.enableDistantGeneration.@tooltip=§6True:§r in single player LODs will be created outside the vanilla render distance.\nDepending on the Generator Mode pre-existing chunks will be important and/o\nmissing chunks will be generated.\nNote: this can use a large amount of CPU.\n\n§6False:§r LODs will only generate within the vanilla render distance. -distanthorizons.config.common.worldGenerator.distantGeneratorMode=Distance Generator Mode -distanthorizons.config.common.worldGenerator.distantGeneratorMode.@tooltip=How complicated the generation should be when generating LODs outside the vanilla render distance. -distanthorizons.config.common.worldGenerator.showGenerationProgress=Show Generation Progress -distanthorizons.config.common.worldGenerator.showGenerationProgress.@tooltip=Determines how should distant generator progress be displayed. -distanthorizons.config.common.worldGenerator.generationProgressDisplayIntervalInSeconds=Progress Display Interval In Seconds -distanthorizons.config.common.worldGenerator.generationProgressDisplayIntervalInSeconds.@tooltip=Determines how long between progress update displays. -distanthorizons.config.common.worldGenerator.generationProgressDisableMessageDisplayTimeInSeconds=Seconds To Show Progress Hiding Instructions -distanthorizons.config.common.worldGenerator.generationProgressDisableMessageDisplayTimeInSeconds.@tooltip=For how many seconds should instructions for disabling the distant generator progress be displayed? \nSetting this to 0 hides the instructional message so the world gen progress is shown immediately when it starts. -distanthorizons.config.common.worldGenerator.generationProgressIncludeChunksPerSecond=Show Generation Speed in Chunks/Second -distanthorizons.config.common.worldGenerator.generationProgressIncludeChunksPerSecond.@tooltip=When logging generation progress also include the rate at which chunks \nare being generated. \nThis can be useful for troubleshooting performance. - - -distanthorizons.config.common.lodBuilding=Lod Building - -distanthorizons.config.common.lodBuilding.disableUnchangedChunkCheck=Disable Unchanged Chunk Check -distanthorizons.config.common.lodBuilding.disableUnchangedChunkCheck.@tooltip=Disabling this check may fix issues where LODs aren't updated after\nblocks have been changed.\n -distanthorizons.config.common.lodBuilding.pullLightingForPregeneratedChunks=Pull Lighting For Pre-generated Chunks -distanthorizons.config.common.lodBuilding.pullLightingForPregeneratedChunks.@tooltip=If true LOD generation for pre-existing chunks will attempt to pull the lighting data \nsaved in Minecraft's Region files. \nIf false DH will pull in chunks without lighting and re-light them. \n\nSetting this to true will result in faster LOD generation \nfor already generated worlds, but is broken by most lighting mods. \n\nSet this to false if LODs are black. -distanthorizons.config.common.lodBuilding.assumePreExistingChunksAreFinished=Assume Pre-Existing Chunks Are Finished -distanthorizons.config.common.lodBuilding.assumePreExistingChunksAreFinished.@tooltip=Setting this to true may solve some issues when using DH with a pre-generated world. -distanthorizons.config.common.lodBuilding.dataCompression=Data Compression -distanthorizons.config.common.lodBuilding.dataCompression.@tooltip=What algorithm should be used to compress new LOD data? \nThis setting will only affect new or updated LOD data, \nany data already generated when this setting is changed will be \nunaffected until it needs to be re-written to the database. \n\nFastest: LZ4 \nHighest Compression: LZMA2 -distanthorizons.config.common.lodBuilding.worldCompression=Lossy World Compression -distanthorizons.config.common.lodBuilding.worldCompression.@tooltip=How should block data be compressed when creating LOD data? \nThis setting will only affect new or updated LOD data, \nany data already generated when this setting is changed will be \nunaffected until it is modified or re-loaded. \n\nMost Accurate: Merge Same Blocks \nHighest Compression: Visually Equal -distanthorizons.config.common.lodBuilding.recalculateChunkHeightmaps=Recalculate Chunk Heightmaps -distanthorizons.config.common.lodBuilding.recalculateChunkHeightmaps.@tooltip=True: Recalculate chunk height maps before chunks can be used by DH. This can fix problems with worlds created by external tools. \nFalse: Assume any height maps handled by Minecraft are correct. \n\nFastest: False\nMost Compatible: True -distanthorizons.config.common.lodBuilding.showMigrationChatWarning=Log Migration In Chat - - -distanthorizons.config.common.lodBuilding.experimental=Experimental - -distanthorizons.config.common.lodBuilding.experimental.upsampleLowerDetailLodsToFillHoles=Upsample Lower Detail LODs To Fill Holes -distanthorizons.config.common.lodBuilding.experimental.upsampleLowerDetailLodsToFillHoles.@tooltip=When active DH will attempt to fill missing LOD data \nwith any data that is present in the tree, preventing holes when moving \nwhen a N-sized generator (or server) is active. \n\n§6EXPERIMENTAL§r Will increase harddrive use and may cause rendering issues. \nSee the config file for more details. - - - - -distanthorizons.config.common.multiThreading=Multi-Threading - -distanthorizons.config.common.multiThreading.numberOfThreads=NO. of threads -distanthorizons.config.common.multiThreading.numberOfThreads.@tooltip=How many threads DH will use. -distanthorizons.config.common.multiThreading.threadRunTimeRatio=Runtime % for threads -distanthorizons.config.common.multiThreading.threadPriority=Thread Priority -distanthorizons.config.common.multiThreading.threadPriority.@tooltip=What Java thread priority should DH's primary thread pools run with?\n\nYou probably don't need to change this unless you are also \nrunning C2ME and are seeing thread starvation in either C2ME or DH. - - - -distanthorizons.config.common.logging=Logging -distanthorizons.config.common.logging.@tooltip=Controls how logging should be handled. - -distanthorizons.config.common.logging.globalFileMaxLevel=Global File Max -distanthorizons.config.common.logging.globalChatMaxLevel=Global Chat Max - -distanthorizons.config.common.logging.logWorldGenEventToFile=World Gen Events - File -distanthorizons.config.common.logging.logWorldGenPerformanceToFile=World Gen Performance - File -distanthorizons.config.common.logging.logWorldGenChunkLoadEventToFile=World Gen Load Events - File -distanthorizons.config.common.logging.logRendererEventToFile=Renderer Events - File -distanthorizons.config.common.logging.logRendererGLEventToFile=OpenGL Events - File -distanthorizons.config.common.logging.logRendererGLEventToChat=OpenGL Events - Chat -distanthorizons.config.common.logging.logNetworkEventToFile=Network Events - File -distanthorizons.config.common.logging.logConnectionConfigChangesToFile=Network Connection Config Changes - File - -distanthorizons.config.common.logging.warning=Warnings -distanthorizons.config.common.logging.warning.showLowMemoryWarningOnStartup=Show Low Memory Warning On Startup -distanthorizons.config.common.logging.warning.showPoolInsufficientMemoryWarning=Show Pool Insufficient Memory Warning -distanthorizons.config.common.logging.warning.showPoolInsufficientMemoryWarning.@tooltip=If DH detects that pooled objects are being garbage collected this will send a chat warning. -distanthorizons.config.common.logging.warning.showHighVanillaRenderDistanceWarning=Show High Vanilla Render Distance Warning -distanthorizons.config.common.logging.warning.showReplayWarningOnStartup=Show Replay Warning -distanthorizons.config.common.logging.warning.showUpdateQueueOverloadedChatWarning=Show Update Queue Overloaded Warning -distanthorizons.config.common.logging.warning.showSlowWorldGenSettingWarnings=Show Slow World Gen Warnings -distanthorizons.config.common.logging.warning.showModCompatibilityWarningsOnStartup=Show Mod Compatibility Warnings -distanthorizons.config.common.logging.warning.showGarbageCollectorWarning=Show Garbage Collector Warning -distanthorizons.config.common.logging.warning.logGarbageCollectorWarning=Log Garbage Collector Warning - - - - - -distanthorizons.config.server=Server - - -distanthorizons.config.server.sendLevelKeys=Send Level Keys -distanthorizons.config.server.sendLevelKeys.@tooltip=Makes the server send level keys for each world.\nDisable this if you use alternative ways to send level keys. - -distanthorizons.config.server.levelKeyPrefix=Level Key Prefix -distanthorizons.config.server.levelKeyPrefix.@tooltip=Prefix of the level keys sent to the clients.\nIf the mod is running behind a proxy, each backend should use a unique value.\nIf this value is empty, level key will be based on the server's seed hash. - -distanthorizons.config.server.enableServerGeneration=Enable Server Generation -distanthorizons.config.server.enableServerGeneration.@tooltip=When enabled, Distant Horizons will attempt to download missing LODs from the server.\n\nNote: the server must have Distant Generation enabled for it to work. - -distanthorizons.config.server.generationRequestRateLimit=Rate Limit for Generation Requests -distanthorizons.config.server.generationRequestRateLimit.@tooltip=How many LOD generation requests per second should a client send?\nAlso limits the number of client requests allowed to stay in the server's queue. - -distanthorizons.config.server.maxGenerationRequestDistance=Max Generation Request Distance -distanthorizons.config.server.maxGenerationRequestDistance.@tooltip=Defines the distance allowed to generate around the player. - -distanthorizons.config.server.enableRealTimeUpdates=Enable Real-time Updates -distanthorizons.config.server.enableRealTimeUpdates.@tooltip=If true, clients will receive real-time LOD updates for chunks outside the client's render distance. - -distanthorizons.config.server.realTimeUpdateDistanceRadiusInChunks=Real-time Update Radius in Chunks -distanthorizons.config.server.realTimeUpdateDistanceRadiusInChunks.@tooltip=Defines the distance the player will receive updates around. - -distanthorizons.config.server.synchronizeOnLoad=Synchronize LODs on Load -distanthorizons.config.server.synchronizeOnLoad.@tooltip=If true, clients will receive updated LODs when joining or loading new LODs. - -distanthorizons.config.server.syncOnLoadRateLimit=Rate Limit for Sync on Load -distanthorizons.config.server.syncOnLoadRateLimit.@tooltip=How many LOD sync requests per second should a client send?\nAlso limits the number of client's requests allowed to stay in the server's queue. - -distanthorizons.config.server.maxSyncOnLoadRequestDistance=Max Sync on Load Request Distance -distanthorizons.config.server.maxSyncOnLoadRequestDistance.@tooltip=Defines the distance allowed to be synchronized around the player.\nShould be the same or larger than maxGenerationRequestDistance in most cases. - -distanthorizons.config.server.playerBandwidthLimit=Per-player Bandwidth Limit, KB/s -distanthorizons.config.server.playerBandwidthLimit.@tooltip=Maximum per-player speed for uploading LODs to the clients, in KB/s.\nValue of 0 disables the limit. -distanthorizons.config.server.globalBandwidthLimit=Global Bandwidth Limit, KB/s -distanthorizons.config.server.globalBandwidthLimit.@tooltip=Maximum global speed for uploading LODs to the clients, in KB/s.\nValue of 0 disables the limit. -distanthorizons.config.server.enableAdaptiveTransferSpeed=Enable Adaptive Transfer Speed -distanthorizons.config.server.enableAdaptiveTransferSpeed.@tooltip=Enables adaptive transfer speed based on client performance.\nIf true, DH will automatically adjust transfer rate to minimize connection lag.\nIf false, transfer speed will remain fixed. - - -distanthorizons.config.server.experimental=Experimental - -distanthorizons.config.server.experimental.enableNSizedGeneration=Enable N-sized generation -distanthorizons.config.server.experimental.enableNSizedGeneration.@tooltip=When enabled on the client, this allows loading lower detail levels as needed to speed up terrain generation.\nThis must also be enabled on the server; otherwise, it will have no effect.\nFor better performance when switching LOD detail levels, enabling [upsampleLowerDetailLodsToFillHoles] is recommended. - - - - - - - - - - - - -distanthorizons.config.enum.EDhApiQualityPreset.CUSTOM=Custom -distanthorizons.config.enum.EDhApiQualityPreset.MINIMUM=1. Minimum -distanthorizons.config.enum.EDhApiQualityPreset.LOW=2. Low -distanthorizons.config.enum.EDhApiQualityPreset.MEDIUM=3. Medium -distanthorizons.config.enum.EDhApiQualityPreset.HIGH=4. High -distanthorizons.config.enum.EDhApiQualityPreset.EXTREME=5. Extreme - -distanthorizons.config.enum.EDhApiThreadPreset.CUSTOM=Custom -distanthorizons.config.enum.EDhApiThreadPreset.MINIMAL_IMPACT=1. Minimal Impact -distanthorizons.config.enum.EDhApiThreadPreset.LOW_IMPACT=2. Low Impact -distanthorizons.config.enum.EDhApiThreadPreset.BALANCED=3. Balanced -distanthorizons.config.enum.EDhApiThreadPreset.AGGRESSIVE=4. Aggressive -distanthorizons.config.enum.EDhApiThreadPreset.I_PAID_FOR_THE_WHOLE_CPU=5. I Paid For The Whole CPU - -distanthorizons.config.enum.EDhApiMaxHorizontalResolution.BLOCK=1. Block -distanthorizons.config.enum.EDhApiMaxHorizontalResolution.TWO_BLOCKS=2. 2 blocks -distanthorizons.config.enum.EDhApiMaxHorizontalResolution.FOUR_BLOCKS=3. 4 blocks -distanthorizons.config.enum.EDhApiMaxHorizontalResolution.HALF_CHUNK=4. Half a chunk -distanthorizons.config.enum.EDhApiMaxHorizontalResolution.CHUNK=5. Chunk - -distanthorizons.config.enum.EDhApiMcRenderingFadeMode.NONE=None -distanthorizons.config.enum.EDhApiMcRenderingFadeMode.SINGLE_PASS=Single Pass -distanthorizons.config.enum.EDhApiMcRenderingFadeMode.DOUBLE_PASS=Double Pass - -distanthorizons.config.enum.EDhApiVerticalQuality.HEIGHT_MAP=1. Height Map -distanthorizons.config.enum.EDhApiVerticalQuality.LOW=2. Low -distanthorizons.config.enum.EDhApiVerticalQuality.MEDIUM=3. Medium -distanthorizons.config.enum.EDhApiVerticalQuality.HIGH=4. High -distanthorizons.config.enum.EDhApiVerticalQuality.VERY_HIGH=5. Very High -distanthorizons.config.enum.EDhApiVerticalQuality.EXTREME=6. Extreme -distanthorizons.config.enum.EDhApiVerticalQuality.PIXEL_ART=7. Pixel Art - -distanthorizons.config.enum.EDhApiHorizontalQuality.LOWEST=Lowest -distanthorizons.config.enum.EDhApiHorizontalQuality.LOW=Low -distanthorizons.config.enum.EDhApiHorizontalQuality.MEDIUM=Medium -distanthorizons.config.enum.EDhApiHorizontalQuality.HIGH=High -distanthorizons.config.enum.EDhApiHorizontalQuality.EXTREME=Extreme - -distanthorizons.config.enum.EDhApiTransparency.DISABLED=Disabled -distanthorizons.config.enum.EDhApiTransparency.FAKE=Fake -distanthorizons.config.enum.EDhApiTransparency.COMPLETE=Complete - -distanthorizons.config.enum.EDhApiFogDrawMode.USE_OPTIFINE_SETTING=Use modded settings -distanthorizons.config.enum.EDhApiFogDrawMode.FOG_ENABLED=Enabled -distanthorizons.config.enum.EDhApiFogDrawMode.FOG_DISABLED=Disabled - -distanthorizons.config.enum.EDhApiFogColorMode.USE_WORLD_FOG_COLOR=Use world fog -distanthorizons.config.enum.EDhApiFogColorMode.USE_SKY_COLOR=Use sky color - -distanthorizons.config.enum.EDhApiFogFalloff.LINEAR=Linear -distanthorizons.config.enum.EDhApiFogFalloff.EXPONENTIAL=Exponential -distanthorizons.config.enum.EDhApiFogFalloff.EXPONENTIAL_SQUARED=Exponential squared - -distanthorizons.config.enum.EDhApiHeightFogMixMode.SPHERICAL=Spherical -distanthorizons.config.enum.EDhApiHeightFogMixMode.CYLINDRICAL=Cylindrical -distanthorizons.config.enum.EDhApiHeightFogMixMode.ADDITION=Addition -distanthorizons.config.enum.EDhApiHeightFogMixMode.MAX=Max -distanthorizons.config.enum.EDhApiHeightFogMixMode.MULTIPLY=Multiply -distanthorizons.config.enum.EDhApiHeightFogMixMode.INVERSE_MULTIPLY=Inverse Multiply -distanthorizons.config.enum.EDhApiHeightFogMixMode.LIMITED_ADDITION=Limited Addition -distanthorizons.config.enum.EDhApiHeightFogMixMode.MULTIPLY_ADDITION=Multiply Addition -distanthorizons.config.enum.EDhApiHeightFogMixMode.INVERSE_MULTIPLY_ADDITION=Inverse Multiply Addition -distanthorizons.config.enum.EDhApiHeightFogMixMode.AVERAGE=Average - -distanthorizons.config.enum.EDhApiHeightFogDirection.ABOVE_CAMERA=Above Camera -distanthorizons.config.enum.EDhApiHeightFogDirection.BELOW_CAMERA=Below Camera -distanthorizons.config.enum.EDhApiHeightFogDirection.ABOVE_AND_BELOW_CAMERA=Above And Below Camera -distanthorizons.config.enum.EDhApiHeightFogDirection.ABOVE_SET_HEIGHT=Above Set Height -distanthorizons.config.enum.EDhApiHeightFogDirection.BELOW_SET_HEIGHT=Below Set Height -distanthorizons.config.enum.EDhApiHeightFogDirection.ABOVE_AND_BELOW_SET_HEIGHT=Above And Below Set Height - -distanthorizons.config.enum.EDhApiVanillaOverdraw.NEVER=Never -distanthorizons.config.enum.EDhApiVanillaOverdraw.DYNAMIC=Dynamic -distanthorizons.config.enum.EDhApiVanillaOverdraw.ALWAYS=Always - -distanthorizons.config.enum.EDhApiDistantGeneratorMode.NONE=1. Existing Only -distanthorizons.config.enum.EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY=2. Pre-Existing Chunks only -distanthorizons.config.enum.EDhApiDistantGeneratorMode.BIOME_ONLY=3. Biome only -distanthorizons.config.enum.EDhApiDistantGeneratorMode.BIOME_ONLY_SIMULATE_HEIGHT=4. Biome only simulate height -distanthorizons.config.enum.EDhApiDistantGeneratorMode.SURFACE=5. Surface -distanthorizons.config.enum.EDhApiDistantGeneratorMode.FEATURES=6. Features -distanthorizons.config.enum.EDhApiDistantGeneratorMode.INTERNAL_SERVER=7. Full - Save Chunks - -distanthorizons.config.enum.EDhApiDistantGeneratorProgressDisplayLocation.OVERLAY=Overlay -distanthorizons.config.enum.EDhApiDistantGeneratorProgressDisplayLocation.CHAT=Chat -distanthorizons.config.enum.EDhApiDistantGeneratorProgressDisplayLocation.LOG=Log -distanthorizons.config.enum.EDhApiDistantGeneratorProgressDisplayLocation.DISABLED=Disabled - -distanthorizons.config.enum.EDhApiDataCompressionMode.UNCOMPRESSED=Uncompressed -distanthorizons.config.enum.EDhApiDataCompressionMode.LZ4=Fastest/Big - LZ4 -distanthorizons.config.enum.EDhApiDataCompressionMode.Z_STD_BLOCK=Fastest/Small - Z_STD - Block -distanthorizons.config.enum.EDhApiDataCompressionMode.Z_STD_STREAM=Fast/Small - Z_STD - Stream -distanthorizons.config.enum.EDhApiDataCompressionMode.LZMA2=Slow/Smallest - LZMA2 - -distanthorizons.config.enum.EDhApiWorldCompressionMode.MERGE_SAME_BLOCKS=1. Merge Same Blocks -distanthorizons.config.enum.EDhApiWorldCompressionMode.VISUALLY_EQUAL=2. Visually Equal - -distanthorizons.config.enum.EDhApiBlocksToAvoid.NONE=None -distanthorizons.config.enum.EDhApiBlocksToAvoid.NON_COLLIDING=Non-Colliding - -distanthorizons.config.enum.EDhApiServerFolderNameMode.NAME_ONLY=Name Only -distanthorizons.config.enum.EDhApiServerFolderNameMode.IP_ONLY=IP Only -distanthorizons.config.enum.EDhApiServerFolderNameMode.NAME_IP=Name and IP -distanthorizons.config.enum.EDhApiServerFolderNameMode.NAME_IP_PORT=Name, IP, Port -distanthorizons.config.enum.EDhApiServerFolderNameMode.NAME_IP_PORT_MC_VERSION=Name, IP, Port, MC version - -distanthorizons.config.enum.EDhApiRendererMode.DEFAULT=Default -distanthorizons.config.enum.EDhApiRendererMode.DEBUG=Debug -distanthorizons.config.enum.EDhApiRendererMode.DISABLED=Disabled - -distanthorizons.config.enum.EDhApiDebugRendering.OFF=Off -distanthorizons.config.enum.EDhApiDebugRendering.SHOW_DETAIL=Show detail -distanthorizons.config.enum.EDhApiDebugRendering.SHOW_GENMODE=Show generation mode -distanthorizons.config.enum.EDhApiDebugRendering.SHOW_BLOCK_MATERIAL=Show Material -distanthorizons.config.enum.EDhApiDebugRendering.SHOW_OVERLAPPING_QUADS=Show overlapping quads -distanthorizons.config.enum.EDhApiDebugRendering.SHOW_RENDER_SOURCE_FLAG=Show render source flag - -distanthorizons.config.enum.EDhApiGLErrorHandlingMode.IGNORE=Ignore -distanthorizons.config.enum.EDhApiGLErrorHandlingMode.LOG=Log -distanthorizons.config.enum.EDhApiGLErrorHandlingMode.LOG_THROW=Log-Throw - -distanthorizons.config.enum.EDhApiGlProfileMode.CORE=Core -distanthorizons.config.enum.EDhApiGlProfileMode.COMPAT=Compat -distanthorizons.config.enum.EDhApiGlProfileMode.ANY=Any - -distanthorizons.config.enum.EDhApiLoggerLevel.ALL=1. All -distanthorizons.config.enum.EDhApiLoggerLevel.DEBUG=2. Debug -distanthorizons.config.enum.EDhApiLoggerLevel.INFO=3. Info -distanthorizons.config.enum.EDhApiLoggerLevel.WARN=4. Warn -distanthorizons.config.enum.EDhApiLoggerLevel.ERROR=5. Error -distanthorizons.config.enum.EDhApiLoggerLevel.DISABLED=6. Disabled - - -distanthorizons.config.enum.EDhApiGpuUploadMethod.AUTO=Auto -distanthorizons.config.enum.EDhApiGpuUploadMethod.NONE=None -distanthorizons.config.enum.EDhApiGpuUploadMethod.BUFFER_STORAGE=Buffer storage -distanthorizons.config.enum.EDhApiGpuUploadMethod.SUB_DATA=Sub data -distanthorizons.config.enum.EDhApiGpuUploadMethod.BUFFER_MAPPING=Buffer mapping -distanthorizons.config.enum.EDhApiGpuUploadMethod.DATA=Data - -distanthorizons.config.enum.EDhApiLodShading.AUTO=Auto -distanthorizons.config.enum.EDhApiLodShading.ENABLED=Enabled -distanthorizons.config.enum.EDhApiLodShading.DISABLED=Disabled - -distanthorizons.config.enum.EDhApiUpdateBranch.STABLE=Stable -distanthorizons.config.enum.EDhApiUpdateBranch.NIGHTLY=Nightly -distanthorizons.config.enum.EDhApiUpdateBranch.AUTO=Auto - -distanthorizons.config.enum.EDhApiGrassSideRendering.AS_GRASS=As Grass -distanthorizons.config.enum.EDhApiGrassSideRendering.FADE_TO_DIRT=Fade To Dirt -distanthorizons.config.enum.EDhApiGrassSideRendering.AS_DIRT=As Dirt - diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/apply/blaze/frag.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/apply/blaze/frag.fsh deleted file mode 100644 index 2b0745aec..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/apply/blaze/frag.fsh +++ /dev/null @@ -1,27 +0,0 @@ -#version 150 core - -in vec2 TexCoord; - -out vec4 fragColor; - -uniform sampler2D uSourceColorTexture; -uniform sampler2D uSourceDepthTexture; - -// DH apply frag -void main() -{ - fragColor = vec4(0.0); - - // a fragment depth of "1" means the fragment wasn't drawn to, - // only update fragments that were drawn to - float fragmentDepth = texture(uSourceDepthTexture, TexCoord).r; - if (fragmentDepth != 1) - { - fragColor = texture(uSourceColorTexture, TexCoord); - } - else - { - // use the original MC texture if no LODs were drawn to this fragment - discard; - } -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/apply/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/apply/blaze/vert.vsh deleted file mode 100644 index f58a25234..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/apply/blaze/vert.vsh +++ /dev/null @@ -1,15 +0,0 @@ -#version 150 core - -in vec2 vPosition; - -out vec2 TexCoord; - -/** - * This is specifically used by application shaders. - * IE post process or pixel transfer shaders, anything that is rendered using a single rectangle. - */ -void main() -{ - gl_Position = vec4(vPosition, 0.0, 1.0); - TexCoord = vPosition.xy * 0.5 + 0.5; -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/copy/blaze/frag.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/copy/blaze/frag.fsh deleted file mode 100644 index 9cbaf97f2..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/copy/blaze/frag.fsh +++ /dev/null @@ -1,13 +0,0 @@ -#version 150 core - -in vec2 TexCoord; - -out vec4 fragColor; - -uniform sampler2D uCopyTexture; - -// DH copy frag -void main() -{ - fragColor = texture(uCopyTexture, TexCoord); -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/copy/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/copy/blaze/vert.vsh deleted file mode 100644 index d9b009b3b..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/copy/blaze/vert.vsh +++ /dev/null @@ -1,12 +0,0 @@ -#version 150 core - -in vec2 vPosition; - -out vec2 TexCoord; - -// DH copy -void main() -{ - gl_Position = vec4(vPosition, 0.0, 1.0); - TexCoord = vPosition.xy * 0.5 + 0.5; -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/blaze/frag.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/blaze/frag.fsh deleted file mode 100644 index 253b92fd5..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/blaze/frag.fsh +++ /dev/null @@ -1,14 +0,0 @@ -#version 150 core - -layout (std140) uniform uniformBlock -{ - mat4 uTransform; - vec4 uColor; -}; - -out vec4 fragColor; - -void main() -{ - fragColor = uColor; -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/blaze/vert.vsh deleted file mode 100644 index 7ff5df869..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/blaze/vert.vsh +++ /dev/null @@ -1,14 +0,0 @@ -#version 150 core - -layout (std140) uniform uniformBlock -{ - mat4 uTransform; - vec4 uColor; -}; - -in vec3 vPosition; - -void main() -{ - gl_Position = uTransform * vec4(vPosition, 1.0); -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/gl/frag.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/gl/frag.frag deleted file mode 100644 index 16f8de33f..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/gl/frag.frag +++ /dev/null @@ -1,10 +0,0 @@ -#version 150 core - -uniform vec4 uColor; - -out vec4 fragColor; - -void main() -{ - fragColor = uColor; -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/gl/vert.vert b/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/gl/vert.vert deleted file mode 100644 index befc43200..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/debug/gl/vert.vert +++ /dev/null @@ -1,10 +0,0 @@ -#version 150 core - -uniform mat4 uTransform; - -in vec3 vPosition; - -void main() -{ - gl_Position = uTransform * vec4(vPosition, 1.0); -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/dh_fade.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/dh_fade.fsh deleted file mode 100644 index a88b324c5..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/dh_fade.fsh +++ /dev/null @@ -1,67 +0,0 @@ -#version 150 core - -in vec2 TexCoord; - -out vec4 fragColor; - -layout (std140) uniform fragUniformBlock -{ - float uStartFadeBlockDistance; - float uEndFadeBlockDistance; - - // inverted model view matrix and projection matrix - mat4 uDhInvMvmProj; -}; - -uniform sampler2D uMcColorTexture; -uniform sampler2D uDhDepthTexture; -uniform sampler2D uDhColorTexture; - - -vec3 calcViewPosition(float fragmentDepth, mat4 invMvmProj) -{ - // normalized device coordinates - vec4 ndc = vec4(TexCoord.xy, fragmentDepth, 1.0); - ndc.xyz = ndc.xyz * 2.0 - 1.0; - - vec4 eyeCoord = invMvmProj * ndc; - return eyeCoord.xyz / eyeCoord.w; -} - -/** - * Used to fade out vanilla chunks so the transition - * between DH and vanilla is smoother. - */ -void main() -{ - // includes both the vanilla chunks as well as DH - vec4 combinedMcDhColor = texture(uMcColorTexture, TexCoord); - // just the DH render pass - vec4 dhColor = texture(uDhColorTexture, TexCoord); - - - - // the DH texture will have white if nothing was written to that pixel. - if (dhColor == vec4(1)) - { - // if not done vanilla clouds will render incorrectly at night - dhColor = combinedMcDhColor; - } - - - float dhFragmentDepth = texture(uDhDepthTexture, TexCoord).r; - vec3 dhVertexWorldPos = calcViewPosition(dhFragmentDepth, uDhInvMvmProj); - float dhFragmentDistance = length(dhVertexWorldPos.xzy); - - - float startFade = uEndFadeBlockDistance; - float endFade = uStartFadeBlockDistance; - - // Smoothly transition between combinedMcDhColor and uDhColorTexture - // as the depth increases from the camera - float fadeStep = smoothstep(startFade, endFade, dhFragmentDistance); - fragColor = mix(combinedMcDhColor, dhColor, fadeStep); - fragColor.a = 1.0; - -} - diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/vanilla_fade.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/vanilla_fade.fsh deleted file mode 100644 index da8d123ae..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/vanilla_fade.fsh +++ /dev/null @@ -1,95 +0,0 @@ -#version 150 core - -in vec2 TexCoord; - -out vec4 fragColor; - -uniform sampler2D uMcDepthTexture; -uniform sampler2D uCombinedMcDhColorTexture; - -uniform sampler2D uDhDepthTexture; -uniform sampler2D uDhColorTexture; - -layout (std140) uniform fragUniformBlock -{ - bool uOnlyRenderLods; - - float uStartFadeBlockDistance; - float uEndFadeBlockDistance; - float uMaxLevelHeight; - - // inverted model view matrix and projection matrix - mat4 uDhInvMvmProj; - mat4 uMcInvMvmProj; -}; - - - -vec3 calcViewPosition(float fragmentDepth, mat4 invMvmProj) -{ - // normalized device coordinates - vec4 ndc = vec4(TexCoord.xy, fragmentDepth, 1.0); - ndc.xyz = ndc.xyz * 2.0 - 1.0; - - vec4 eyeCoord = invMvmProj * ndc; - return eyeCoord.xyz / eyeCoord.w; -} - -/** - * Used to fade out vanilla chunks so the transition - * between DH and vanilla is smoother. - */ -void main() -{ - // includes both the vanilla chunks as well as DH - vec4 combinedMcDhColor = texture(uCombinedMcDhColorTexture, TexCoord); - // just the DH render pass - vec4 dhColor = texture(uDhColorTexture, TexCoord); - - // completely remove the MC render pass to only show LODs - // useful for debugging/troubleshooting, but doesn't improve performance since MC is still rendering - if (uOnlyRenderLods) - { - fragColor = dhColor; - return; - } - - - // ignore anything that DH hasn't drawn to - // We don't use DH's depth here because it would prevent the fade from running before DH has loaded - if (dhColor == vec4(1)) - { - // if not done vanilla clouds will render incorrectly at night - dhColor = combinedMcDhColor; - } - - float mcFragmentDepth = texture(uMcDepthTexture, TexCoord).r; - float dhFragmentDepth = texture(uDhDepthTexture, TexCoord).r; - vec3 dhVertexWorldPos = calcViewPosition(dhFragmentDepth, uDhInvMvmProj); - - // this is a work around to prevent MC clouds rendering behind DH clouds - if (dhVertexWorldPos.y > uMaxLevelHeight) - { - fragColor = vec4(combinedMcDhColor.rgb, 0.0); - } - // a fragment depth of "1" means the fragment wasn't drawn to, - // we only want to fade vanilla rendered objects, not to the sky or LODs - else if (mcFragmentDepth < 1.0) - { - // fade based on distance from the camera - vec3 mcVertexWorldPos = calcViewPosition(mcFragmentDepth, uMcInvMvmProj); - float mcFragmentDistance = length(mcVertexWorldPos.xzy); - - - // Smoothly transition between combinedMcDhColor and uDhColorTexture - // as the depth increases from the camera - float fadeStep = smoothstep(uStartFadeBlockDistance, uEndFadeBlockDistance, mcFragmentDistance); - fragColor = mix(combinedMcDhColor, dhColor, fadeStep); - fragColor.a = 1.0; - } - else - { - fragColor = vec4(combinedMcDhColor.rgb, 0.0); - } -} - diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/vert.vsh deleted file mode 100644 index d7f46cf36..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/blaze/vert.vsh +++ /dev/null @@ -1,15 +0,0 @@ -#version 150 core - -in vec2 vPosition; -in vec4 vColor; - -out vec4 fColor; -out vec2 TexCoord; - -// DH vert fade test -void main() -{ - gl_Position = vec4(vPosition, 0.0, 1.0); - fColor = vec4(vPosition, 0.0, 1.0); - TexCoord = vPosition.xy * 0.5 + 0.5; -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/apply.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/apply.frag deleted file mode 100644 index d1a863b56..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/apply.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 150 core - -in vec2 TexCoord; - -out vec4 fragColor; - -uniform sampler2D uFadeColorTextureUniform; - - - -void main() -{ - fragColor = texture(uFadeColorTextureUniform, TexCoord); -} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/dh_fade.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/dh_fade.frag deleted file mode 100644 index a12562b7b..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/dh_fade.frag +++ /dev/null @@ -1,65 +0,0 @@ -#version 150 core - -in vec2 TexCoord; - -out vec4 fragColor; - -// inverted model view matrix and projection matrix -uniform mat4 uDhInvMvmProj; - -uniform sampler2D uDhDepthTexture; -uniform sampler2D uMcColorTexture; -uniform sampler2D uDhColorTexture; - -uniform float uStartFadeBlockDistance; -uniform float uEndFadeBlockDistance; - - - -vec3 calcViewPosition(float fragmentDepth, mat4 invMvmProj) -{ - // normalized device coordinates - vec4 ndc = vec4(TexCoord.xy, fragmentDepth, 1.0); - ndc.xyz = ndc.xyz * 2.0 - 1.0; - - vec4 eyeCoord = invMvmProj * ndc; - return eyeCoord.xyz / eyeCoord.w; -} - -/** - * Used to fade out vanilla chunks so the transition - * between DH and vanilla is smoother. - */ -void main() -{ - // includes both the vanilla chunks as well as DH - vec4 combinedMcDhColor = texture(uMcColorTexture, TexCoord); - // just the DH render pass - vec4 dhColor = texture(uDhColorTexture, TexCoord); - - - - // the DH texture will have white if nothing was written to that pixel. - if (dhColor == vec4(1)) - { - // if not done vanilla clouds will render incorrectly at night - dhColor = combinedMcDhColor; - } - - - float dhFragmentDepth = texture(uDhDepthTexture, TexCoord).r; - vec3 dhVertexWorldPos = calcViewPosition(dhFragmentDepth, uDhInvMvmProj); - float dhFragmentDistance = length(dhVertexWorldPos.xzy); - - - float startFade = uEndFadeBlockDistance; - float endFade = uStartFadeBlockDistance; - - // Smoothly transition between combinedMcDhColor and uDhColorTexture - // as the depth increases from the camera - float fadeStep = smoothstep(startFade, endFade, dhFragmentDistance); - fragColor = mix(combinedMcDhColor, dhColor, fadeStep); - fragColor.a = 1.0; - -} - diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/vanilla_fade.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/vanilla_fade.frag deleted file mode 100644 index da2064fa0..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fade/gl/vanilla_fade.frag +++ /dev/null @@ -1,91 +0,0 @@ -#version 150 core - -in vec2 TexCoord; - -out vec4 fragColor; - -// inverted model view matrix and projection matrix -uniform mat4 uDhInvMvmProj; -uniform mat4 uMcInvMvmProj; - -uniform sampler2D uMcDepthTexture; -uniform sampler2D uDhDepthTexture; -uniform sampler2D uCombinedMcDhColorTexture; -uniform sampler2D uDhColorTexture; - -uniform float uStartFadeBlockDistance; -uniform float uEndFadeBlockDistance; -uniform float uMaxLevelHeight; - -uniform bool uOnlyRenderLods; - - - -vec3 calcViewPosition(float fragmentDepth, mat4 invMvmProj) -{ - // normalized device coordinates - vec4 ndc = vec4(TexCoord.xy, fragmentDepth, 1.0); - ndc.xyz = ndc.xyz * 2.0 - 1.0; - - vec4 eyeCoord = invMvmProj * ndc; - return eyeCoord.xyz / eyeCoord.w; -} - -/** - * Used to fade out vanilla chunks so the transition - * between DH and vanilla is smoother. - */ -void main() -{ - // includes both the vanilla chunks as well as DH - vec4 combinedMcDhColor = texture(uCombinedMcDhColorTexture, TexCoord); - // just the DH render pass - vec4 dhColor = texture(uDhColorTexture, TexCoord); - - // completely remove the MC render pass to only show LODs - // useful for debugging/troubleshooting, but doesn't improve performance since MC is still rendering - if (uOnlyRenderLods) - { - fragColor = dhColor; - return; - } - - - // ignore anything that DH hasn't drawn to - // We don't use DH's depth here because it would prevent the fade from running before DH has loaded - if (dhColor == vec4(1)) - { - // if not done vanilla clouds will render incorrectly at night - dhColor = combinedMcDhColor; - } - - float mcFragmentDepth = texture(uMcDepthTexture, TexCoord).r; - float dhFragmentDepth = texture(uDhDepthTexture, TexCoord).r; - vec3 dhVertexWorldPos = calcViewPosition(dhFragmentDepth, uDhInvMvmProj); - - // this is a work around to prevent MC clouds rendering behind DH clouds - if (dhVertexWorldPos.y > uMaxLevelHeight) - { - fragColor = vec4(combinedMcDhColor.rgb, 0.0); - } - // a fragment depth of "1" means the fragment wasn't drawn to, - // we only want to fade vanilla rendered objects, not to the sky or LODs - else if (mcFragmentDepth < 1.0) - { - // fade based on distance from the camera - vec3 mcVertexWorldPos = calcViewPosition(mcFragmentDepth, uMcInvMvmProj); - float mcFragmentDistance = length(mcVertexWorldPos.xzy); - - - // Smoothly transition between combinedMcDhColor and uDhColorTexture - // as the depth increases from the camera - float fadeStep = smoothstep(uStartFadeBlockDistance, uEndFadeBlockDistance, mcFragmentDistance); - fragColor = mix(combinedMcDhColor, dhColor, fadeStep); - fragColor.a = 1.0; - } - else - { - fragColor = vec4(combinedMcDhColor.rgb, 0.0); - } -} - diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/blaze/frag.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/blaze/frag.fsh deleted file mode 100644 index 9b0614970..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/blaze/frag.fsh +++ /dev/null @@ -1,299 +0,0 @@ -#version 150 core - -in vec2 TexCoord; - -out vec4 fragColor; - -layout (std140) uniform fragUniformBlock -{ - // fog uniforms - vec4 uFogColor; - float uFogScale; - float uFogVerticalScale; - int uFogDebugMode; - int uFogFalloffType; - - // fog config - float uFarFogStart; - float uFarFogLength; - float uFarFogMin; - float uFarFogRange; - float uFarFogDensity; - - // height fog config - float uHeightFogStart; - float uHeightFogLength; - float uHeightFogMin; - float uHeightFogRange; - float uHeightFogDensity; - - // ??? - bool uHeightFogEnabled; - int uHeightFogFalloffType; - bool uHeightBasedOnCamera; - float uHeightFogBaseHeight; - bool uHeightFogAppliesUp; - bool uHeightFogAppliesDown; - bool uUseSphericalFog; - int uHeightFogMixingMode; - float uCameraBlockYPos; - - // inverted model view matrix and projection matrix - mat4 uInvMvmProj; -}; - -uniform sampler2D uDhDepthTexture; - - - -//====================// -// method definitions // -//====================// - -vec3 calcViewPosition(float fragmentDepth); - -float getFarFogThickness(float dist); -float getHeightFogThickness(float dist); -float calculateHeightFogDepth(float worldYPos); -float mixFogThickness(float far, float height); - -float linearFog(float worldDist, float fogStart, float fogLength, float fogMin, float fogRange); -float exponentialFog(float x, float fogStart, float fogLength, float fogMin, float fogRange, float fogDensity); -float exponentialSquaredFog(float x, float fogStart, float fogLength, float fogMin, float fogRange, float fogDensity); - - - -//======// -// main // -//======// - -/** - * Fragment shader for fog. - * This should be run last so it applies above other affects like Ambient Occlusioning - */ -void main() -{ - float fragmentDepth = texture(uDhDepthTexture, TexCoord).r; - fragColor = vec4(uFogColor.rgb, 0.0); - - // a fragment depth of "1" means the fragment wasn't drawn to, - // we only want to apply Fog to LODs, not to the sky outside the LODs - if (fragmentDepth < 1.0) - { - int fogDebugMode = uFogDebugMode; - if (fogDebugMode == 0) - { - // render fog based on distance from the camera - vec3 vertexWorldPos = calcViewPosition(fragmentDepth); - - float horizontalWorldDistance = length(vertexWorldPos.xz) * uFogScale; - float worldDistance = length(vertexWorldPos.xyz) * uFogScale; - float activeDistance = uUseSphericalFog ? worldDistance : horizontalWorldDistance; - - - // far fog - float farFogThickness = getFarFogThickness(activeDistance); - - // height fog - float heightFogDepth = calculateHeightFogDepth(vertexWorldPos.y); - float heightFogThickness = getHeightFogThickness(heightFogDepth); - - // combined fog - float mixedFogThickness = mixFogThickness(farFogThickness, heightFogThickness); - fragColor.a = clamp(mixedFogThickness, 0.0, 1.0); - } - else if (fogDebugMode == 1) - { - // test code - - // render everything with the fog color - fragColor.a = 1.0; - } - else - { - // test code. - - // this can be fired by manually changing the fullFogMode to a (normally) - // invalid value (like 7). - // By having a separate if statement defined by - // a uniform we don't have to worry about GLSL optimizing away different - // options when testing, causing a bunch of headaches if we just want to render the screen red. - - float depthValue = textureLod(uDhDepthTexture, TexCoord, 0).r; - fragColor.rgb = vec3(depthValue); // Convert depth value to grayscale color - fragColor.a = 1.0; - } - } -} - - - -//================// -// helper methods // -//================// - -vec3 calcViewPosition(float fragmentDepth) -{ - vec4 ndc = vec4(TexCoord.xy, fragmentDepth, 1.0); - ndc.xyz = ndc.xyz * 2.0 - 1.0; - - vec4 eyeCoord = uInvMvmProj * ndc; - return eyeCoord.xyz / eyeCoord.w; -} - - - -//=========// -// far fog // -//=========// - -float getFarFogThickness(float dist) -{ - if (uFogFalloffType == 0) // LINEAR - { - return linearFog(dist, uFarFogStart, uFarFogLength, uFarFogMin, uFarFogRange); - } - else if (uFogFalloffType == 1) // EXPONENTIAL - { - return exponentialFog(dist, uFarFogStart, uFarFogLength, uFarFogMin, uFarFogRange, uFarFogDensity); - } - else // EXPONENTIAL_SQUARED - { - return exponentialSquaredFog(dist, uFarFogStart, uFarFogLength, uFarFogMin, uFarFogRange, uFarFogDensity); - } -} - -float getHeightFogThickness(float dist) -{ - if (!uHeightFogEnabled) - { - return 0.0; - } - - if (uHeightFogFalloffType == 0) // LINEAR - { - return linearFog(dist, uHeightFogStart, uHeightFogLength, uHeightFogMin, uHeightFogRange); - } - else if (uHeightFogFalloffType == 1) // EXPONENTIAL - { - return exponentialFog(dist, uHeightFogStart, uHeightFogLength, uHeightFogMin, uHeightFogRange, uHeightFogDensity); - } - else // EXPONENTIAL_SQUARED - { - return exponentialSquaredFog(dist, uHeightFogStart, uHeightFogLength, uHeightFogMin, uHeightFogRange, uHeightFogDensity); - } -} - -float linearFog(float worldDist, float fogStart, float fogLength, float fogMin, float fogRange) -{ - worldDist = (worldDist - fogStart) / fogLength; - worldDist = clamp(worldDist, 0.0, 1.0); - return fogMin + fogRange * worldDist; -} - -float exponentialFog( - float x, float fogStart, float fogLength, - float fogMin, float fogRange, float fogDensity) -{ - x = max((x-fogStart)/fogLength, 0.0) * fogDensity; - return fogMin + fogRange - fogRange/exp(x); -} - -float exponentialSquaredFog( - float x, float fogStart, float fogLength, - float fogMin, float fogRange, float fogDensity) -{ - x = max((x-fogStart)/fogLength, 0.0) * fogDensity; - return fogMin + fogRange - fogRange/exp(x*x); -} - - - -//============// -// height fog // -//============// - -/** 1 = full fog, 0 = no fog */ -float calculateHeightFogDepth(float worldYPos) -{ - // worldYPos -65 - 384 - - - //worldYPos = worldYPos * -1; // negative, fog below height; positive, fog above height - //return worldYPos * uFogVerticalScale; // "* uFogVerticalScale" is done to convert world position to a percent of the world height; - - if (!uHeightFogEnabled) - { - // ignore the height - return 0.0; - } - - - if (!uHeightBasedOnCamera) - { - worldYPos -= (uHeightFogBaseHeight - uCameraBlockYPos); - } - - - if (uHeightFogAppliesDown && uHeightFogAppliesUp) - { - return abs(worldYPos) * uFogVerticalScale; - } - else if (uHeightFogAppliesDown) - { - // apploy fog below given height - return -worldYPos * uFogVerticalScale; - } - else if (uHeightFogAppliesUp) - { - // apply fog above given height - return worldYPos * uFogVerticalScale; - } - else - { - // shouldn't happen, - return 0.0; - } - -} - -float mixFogThickness(float far, float height) -{ - switch (uHeightFogMixingMode) - { - case 0: // BASIC - case 1: // IGNORE_HEIGHT - return far; - - case 2: // MAX - return max(far, height); - - case 3: // ADDITION - return (far + height); - - case 4: // MULTIPLY - return far * height; - - case 5: // INVERSE_MULTIPLY - return (1.0 - (1.0-far)*(1.0-height)); - - case 6: // LIMITED_ADDITION - return (far + max(far, height)); - - case 7: // MULTIPLY_ADDITION - return (far + far*height); - - case 8: // INVERSE_MULTIPLY_ADDITION - return (far + 1.0 - (1.0-far)*(1.0-height)); - - case 9: // AVERAGE - return (far*0.5 + height*0.5); - } - - // shouldn't happen, but default to BASIC / IGNORE_HEIGHT - // if an invalid option is selected - return far; -} - - - diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/blaze/vert.vsh deleted file mode 100644 index 3f614c123..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/blaze/vert.vsh +++ /dev/null @@ -1,15 +0,0 @@ -#version 150 core - -in vec2 vPosition; - -out vec2 TexCoord; - -/** - * This is specifically used by application shaders. - * IE post process or pixel transfer shaders, anything that is rendered using a single rectangle. - */ -void main() -{ - gl_Position = vec4(vPosition, 1.0, 1.0); - TexCoord = vPosition.xy * 0.5 + 0.5; -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/gl/apply.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/gl/apply.frag deleted file mode 100644 index e74a053e5..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/gl/apply.frag +++ /dev/null @@ -1,27 +0,0 @@ -#version 150 core - -in vec2 TexCoord; - -out vec4 fragColor; - -uniform sampler2D uColorTexture; -uniform sampler2D uDepthTexture; - - -/** - * Fog application shader - * - * This merges the rendered fog onto DH's rendered LODs - */ -void main() -{ - fragColor = vec4(0.0); - - // a fragment depth of "1" means the fragment wasn't drawn to, - // only update fragments that were drawn to - float fragmentDepth = textureLod(uDepthTexture, TexCoord, 0).r; - if (fragmentDepth != 1) - { - fragColor = texture(uColorTexture, TexCoord); - } -} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/gl/fog.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/gl/fog.frag deleted file mode 100644 index d34336cf9..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/fog/gl/fog.frag +++ /dev/null @@ -1,297 +0,0 @@ -#version 150 core - -in vec2 TexCoord; - -out vec4 fragColor; - - - -uniform sampler2D uDepthMap; -// inverted model view matrix and projection matrix -uniform mat4 uInvMvmProj; - -// fog uniforms -uniform vec4 uFogColor; -uniform float uFogScale; -uniform float uFogVerticalScale; -uniform int uFogDebugMode; -uniform int uFogFalloffType; - -// fog config -uniform float uFarFogStart; -uniform float uFarFogLength; -uniform float uFarFogMin; -uniform float uFarFogRange; -uniform float uFarFogDensity; - -// height fog config -uniform float uHeightFogStart; -uniform float uHeightFogLength; -uniform float uHeightFogMin; -uniform float uHeightFogRange; -uniform float uHeightFogDensity; - - -uniform bool uHeightFogEnabled; -uniform int uHeightFogFalloffType; -uniform bool uHeightBasedOnCamera; -uniform float uHeightFogBaseHeight; -uniform bool uHeightFogAppliesUp; -uniform bool uHeightFogAppliesDown; -uniform bool uUseSphericalFog; -uniform int uHeightFogMixingMode; -uniform float uCameraBlockYPos; - - - -//====================// -// method definitions // -//====================// - -vec3 calcViewPosition(float fragmentDepth); - -float getFarFogThickness(float dist); -float getHeightFogThickness(float dist); -float calculateHeightFogDepth(float worldYPos); -float mixFogThickness(float far, float height); - -float linearFog(float worldDist, float fogStart, float fogLength, float fogMin, float fogRange); -float exponentialFog(float x, float fogStart, float fogLength, float fogMin, float fogRange, float fogDensity); -float exponentialSquaredFog(float x, float fogStart, float fogLength, float fogMin, float fogRange, float fogDensity); - - - -//======// -// main // -//======// - -/** - * Fragment shader for fog. - * This should be run last so it applies above other affects like Ambient Occlusioning - */ -void main() -{ - float fragmentDepth = texture(uDepthMap, TexCoord).r; - fragColor = vec4(uFogColor.rgb, 0.0); - - // a fragment depth of "1" means the fragment wasn't drawn to, - // we only want to apply Fog to LODs, not to the sky outside the LODs - if (fragmentDepth < 1.0) - { - int fogDebugMode = uFogDebugMode; - if (fogDebugMode == 0) - { - // render fog based on distance from the camera - vec3 vertexWorldPos = calcViewPosition(fragmentDepth); - - float horizontalWorldDistance = length(vertexWorldPos.xz) * uFogScale; - float worldDistance = length(vertexWorldPos.xyz) * uFogScale; - float activeDistance = uUseSphericalFog ? worldDistance : horizontalWorldDistance; - - - // far fog - float farFogThickness = getFarFogThickness(activeDistance); - - // height fog - float heightFogDepth = calculateHeightFogDepth(vertexWorldPos.y); - float heightFogThickness = getHeightFogThickness(heightFogDepth); - - // combined fog - float mixedFogThickness = mixFogThickness(farFogThickness, heightFogThickness); - fragColor.a = clamp(mixedFogThickness, 0.0, 1.0); - } - else if (fogDebugMode == 1) - { - // test code - - // render everything with the fog color - fragColor.a = 1.0; - } - else - { - // test code. - - // this can be fired by manually changing the fullFogMode to a (normally) - // invalid value (like 7). - // By having a separate if statement defined by - // a uniform we don't have to worry about GLSL optimizing away different - // options when testing, causing a bunch of headaches if we just want to render the screen red. - - float depthValue = textureLod(uDepthMap, TexCoord, 0).r; - fragColor.rgb = vec3(depthValue); // Convert depth value to grayscale color - fragColor.a = 1.0; - } - } -} - - - -//================// -// helper methods // -//================// - -vec3 calcViewPosition(float fragmentDepth) -{ - vec4 ndc = vec4(TexCoord.xy, fragmentDepth, 1.0); - ndc.xyz = ndc.xyz * 2.0 - 1.0; - - vec4 eyeCoord = uInvMvmProj * ndc; - return eyeCoord.xyz / eyeCoord.w; -} - - - -//=========// -// far fog // -//=========// - -float getFarFogThickness(float dist) -{ - if (uFogFalloffType == 0) // LINEAR - { - return linearFog(dist, uFarFogStart, uFarFogLength, uFarFogMin, uFarFogRange); - } - else if (uFogFalloffType == 1) // EXPONENTIAL - { - return exponentialFog(dist, uFarFogStart, uFarFogLength, uFarFogMin, uFarFogRange, uFarFogDensity); - } - else // EXPONENTIAL_SQUARED - { - return exponentialSquaredFog(dist, uFarFogStart, uFarFogLength, uFarFogMin, uFarFogRange, uFarFogDensity); - } -} - -float getHeightFogThickness(float dist) -{ - if (!uHeightFogEnabled) - { - return 0.0; - } - - if (uHeightFogFalloffType == 0) // LINEAR - { - return linearFog(dist, uHeightFogStart, uHeightFogLength, uHeightFogMin, uHeightFogRange); - } - else if (uHeightFogFalloffType == 1) // EXPONENTIAL - { - return exponentialFog(dist, uHeightFogStart, uHeightFogLength, uHeightFogMin, uHeightFogRange, uHeightFogDensity); - } - else // EXPONENTIAL_SQUARED - { - return exponentialSquaredFog(dist, uHeightFogStart, uHeightFogLength, uHeightFogMin, uHeightFogRange, uHeightFogDensity); - } -} - -float linearFog(float worldDist, float fogStart, float fogLength, float fogMin, float fogRange) -{ - worldDist = (worldDist - fogStart) / fogLength; - worldDist = clamp(worldDist, 0.0, 1.0); - return fogMin + fogRange * worldDist; -} - -float exponentialFog( - float x, float fogStart, float fogLength, - float fogMin, float fogRange, float fogDensity) -{ - x = max((x-fogStart)/fogLength, 0.0) * fogDensity; - return fogMin + fogRange - fogRange/exp(x); -} - -float exponentialSquaredFog( - float x, float fogStart, float fogLength, - float fogMin, float fogRange, float fogDensity) -{ - x = max((x-fogStart)/fogLength, 0.0) * fogDensity; - return fogMin + fogRange - fogRange/exp(x*x); -} - - - -//============// -// height fog // -//============// - -/** 1 = full fog, 0 = no fog */ -float calculateHeightFogDepth(float worldYPos) -{ - // worldYPos -65 - 384 - - - //worldYPos = worldYPos * -1; // negative, fog below height; positive, fog above height - //return worldYPos * uFogVerticalScale; // "* uFogVerticalScale" is done to convert world position to a percent of the world height; - - if (!uHeightFogEnabled) - { - // ignore the height - return 0.0; - } - - - if (!uHeightBasedOnCamera) - { - worldYPos -= (uHeightFogBaseHeight - uCameraBlockYPos); - } - - - if (uHeightFogAppliesDown && uHeightFogAppliesUp) - { - return abs(worldYPos) * uFogVerticalScale; - } - else if (uHeightFogAppliesDown) - { - // apploy fog below given height - return -worldYPos * uFogVerticalScale; - } - else if (uHeightFogAppliesUp) - { - // apply fog above given height - return worldYPos * uFogVerticalScale; - } - else - { - // shouldn't happen, - return 0.0; - } - -} - -float mixFogThickness(float far, float height) -{ - switch (uHeightFogMixingMode) - { - case 0: // BASIC - case 1: // IGNORE_HEIGHT - return far; - - case 2: // MAX - return max(far, height); - - case 3: // ADDITION - return (far + height); - - case 4: // MULTIPLY - return far * height; - - case 5: // INVERSE_MULTIPLY - return (1.0 - (1.0-far)*(1.0-height)); - - case 6: // LIMITED_ADDITION - return (far + max(far, height)); - - case 7: // MULTIPLY_ADDITION - return (far + far*height); - - case 8: // INVERSE_MULTIPLY_ADDITION - return (far + 1.0 - (1.0-far)*(1.0-height)); - - case 9: // AVERAGE - return (far*0.5 + height*0.5); - } - - // shouldn't happen, but default to BASIC / IGNORE_HEIGHT - // if an invalid option is selected - return far; -} - - - diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/blaze/frag.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/blaze/frag.fsh deleted file mode 100644 index c3d2ac8c4..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/blaze/frag.fsh +++ /dev/null @@ -1,10 +0,0 @@ -#version 150 core - -in vec4 fColor; - -out vec4 fragColor; - -void main() -{ - fragColor = fColor; -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/blaze/vert.vsh deleted file mode 100644 index 68931fe9a..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/blaze/vert.vsh +++ /dev/null @@ -1,101 +0,0 @@ -#version 330 core - -//layout (location = 1) in vec4 aColor; // RGBA_FLOAT_COLOR -//layout (location = 2) in vec3 aScale; // VEC3_SCALE -//layout (location = 3) in ivec3 aTranslateChunk; // IVEC3_SCALE -//layout (location = 4) in vec3 aTranslateSubChunk; // VEC3_SCALE -//layout (location = 5) in int aMaterial; // IRIS_MATERIAL - -//uniform sampler2D /*vec4*/ uColorMap; -//uniform sampler2D /*vec3*/ uScaleMap; -//uniform sampler2D /*int*/ uTranslateChunkXMap; -//uniform sampler2D /*int*/ uTranslateChunkYMap; -//uniform sampler2D /*int*/ uTranslateChunkZMap; -//uniform sampler2D /*vec3*/ uTranslateSubChunkMap; -//uniform sampler2D /*int*/ uMaterialMap; -// -//in vec3 vPosition; - -in vec3 vPosition; -in vec4 aColor; // RGBA_FLOAT_COLOR -in int aMaterial; // IRIS_MATERIAL - -layout (std140) uniform vertUniformBlock -{ - ivec3 uOffsetChunk; - vec3 uOffsetSubChunk; - ivec3 uCameraPosChunk; - vec3 uCameraPosSubChunk; - - mat4 uProjectionMvm; - int uSkyLight; - int uBlockLight; - - float uNorthShading; - float uSouthShading; - float uEastShading; - float uWestShading; - float uTopShading; - float uBottomShading; -}; - -uniform sampler2D uLightMap; - -out vec4 fColor; - -void main() -{ - vec3 aScale = vec3(1); - - if (aMaterial == 999) - { - aScale = vec3(2); - } - -// vec4 aColor = texelFetch(uColorMap, ivec2(gl_InstanceID,0), 0); -// vec3 aScale = texelFetch(uScaleMap, ivec2(gl_InstanceID,0), 0).xyz; -// -// float chunkX = int(texelFetch(uTranslateChunkXMap, ivec2(gl_InstanceID,0), 0).x); -// float chunkY = int(texelFetch(uTranslateChunkYMap, ivec2(gl_InstanceID,0), 0).x); -// float chunkZ = int(texelFetch(uTranslateChunkZMap, ivec2(gl_InstanceID,0), 0).x); -// ivec3 aTranslateChunk = ivec3(chunkX, chunkY, chunkZ); -// -// vec3 aTranslateSubChunk = texelFetch(uTranslateSubChunkMap, ivec2(gl_InstanceID,0), 0).xyz; -// int aMaterial = int(texelFetch(uMaterialMap, ivec2(gl_InstanceID,0), 0).x); - - // aTranslate - moves the vertex to the boxGroup's relative position - // uOffset - moves the vertex to the boxGroup's world position - // uCameraPos - moves the vertex into camera space - vec3 trans = (uOffsetChunk - uCameraPosChunk) * 16.0f; - // separate float and int values are to fix percission loss at extreme distances from the origin (IE 10,000,000+) - // luckily large translate values minus large cameraPos generally equal values that cleanly fit in a float - trans += (uOffsetSubChunk - uCameraPosSubChunk); - - // combination translation and scaling matrix - mat4 transform = mat4( - aScale.x, 0.0, 0.0, 0.0, - 0.0, aScale.y, 0.0, 0.0, - 0.0, 0.0, aScale.z, 0.0, - trans.x, trans.y, trans.z, 1.0 - ); - - gl_Position = uProjectionMvm * transform * vec4(vPosition, 1.0); - - float blockLight = (float(uBlockLight)+0.5) / 16.0; - float skyLight = (float(uSkyLight)+0.5) / 16.0; - vec4 lightColor = vec4(texture(uLightMap, vec2(blockLight, skyLight)).xyz, 1.0); - - - fColor = lightColor * aColor; - - int vertexIndex = gl_VertexID % 24; - - // apply directional shading - if (vertexIndex >= 0 && vertexIndex < 4) { fColor.rgb *= uNorthShading; } - else if (vertexIndex >= 4 && vertexIndex < 8) { fColor.rgb *= uSouthShading; } - else if (vertexIndex >= 8 && vertexIndex < 12) { fColor.rgb *= uWestShading; } - else if (vertexIndex >= 12 && vertexIndex < 16) { fColor.rgb *= uEastShading; } - else if (vertexIndex >= 16 && vertexIndex < 20) { fColor.rgb *= uBottomShading; } - else if (vertexIndex >= 20 && vertexIndex < 24) { fColor.rgb *= uTopShading; } - -} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/direct/frag.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/direct/frag.frag deleted file mode 100644 index c3d2ac8c4..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/direct/frag.frag +++ /dev/null @@ -1,10 +0,0 @@ -#version 150 core - -in vec4 fColor; - -out vec4 fragColor; - -void main() -{ - fragColor = fColor; -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/direct/vert.vert b/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/direct/vert.vert deleted file mode 100644 index 55cf5cad7..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/direct/vert.vert +++ /dev/null @@ -1,41 +0,0 @@ -#version 150 core - -uniform mat4 uTransform; -uniform vec4 uColor; -uniform int uSkyLight; -uniform int uBlockLight; -uniform sampler2D uLightMap; - -uniform float uNorthShading; -uniform float uSouthShading; -uniform float uEastShading; -uniform float uWestShading; -uniform float uTopShading; -uniform float uBottomShading; - - -in vec3 vPosition; - -out vec4 fColor; - -void main() -{ - gl_Position = uTransform * vec4(vPosition, 1.0); - - - float blockLight = (float(uBlockLight)+0.5) / 16.0; - float skyLight = (float(uSkyLight)+0.5) / 16.0; - vec4 lightColor = vec4(texture(uLightMap, vec2(blockLight, skyLight)).xyz, 1.0); - - - fColor = lightColor * uColor; - - // apply directional shading - if (gl_VertexID >= 0 && gl_VertexID < 4) { fColor.rgb *= uNorthShading; } - else if (gl_VertexID >= 4 && gl_VertexID < 8) { fColor.rgb *= uSouthShading; } - else if (gl_VertexID >= 8 && gl_VertexID < 12) { fColor.rgb *= uWestShading; } - else if (gl_VertexID >= 12 && gl_VertexID < 16) { fColor.rgb *= uEastShading; } - else if (gl_VertexID >= 16 && gl_VertexID < 20) { fColor.rgb *= uBottomShading; } - else if (gl_VertexID >= 20 && gl_VertexID < 24) { fColor.rgb *= uTopShading; } - -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/instanced/frag.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/instanced/frag.frag deleted file mode 100644 index c3d2ac8c4..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/instanced/frag.frag +++ /dev/null @@ -1,10 +0,0 @@ -#version 150 core - -in vec4 fColor; - -out vec4 fragColor; - -void main() -{ - fragColor = fColor; -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/instanced/vert.vert b/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/instanced/vert.vert deleted file mode 100644 index a7d9a6a96..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/generic/gl/instanced/vert.vert +++ /dev/null @@ -1,66 +0,0 @@ -#version 330 core - -layout (location = 1) in vec4 aColor; -layout (location = 2) in vec3 aScale; -layout (location = 3) in ivec3 aTranslateChunk; -layout (location = 4) in vec3 aTranslateSubChunk; -layout (location = 5) in int aMaterial; - -uniform ivec3 uOffsetChunk; -uniform vec3 uOffsetSubChunk; -uniform ivec3 uCameraPosChunk; -uniform vec3 uCameraPosSubChunk; - -uniform mat4 uProjectionMvm; -uniform int uSkyLight; -uniform int uBlockLight; -uniform sampler2D uLightMap; - -uniform float uNorthShading; -uniform float uSouthShading; -uniform float uEastShading; -uniform float uWestShading; -uniform float uTopShading; -uniform float uBottomShading; - - -in vec3 vPosition; - -out vec4 fColor; - -void main() -{ - // aTranslate - moves the vertex to the boxGroup's relative position - // uOffset - moves the vertex to the boxGroup's world position - // uCameraPos - moves the vertex into camera space - vec3 trans = (aTranslateChunk + uOffsetChunk - uCameraPosChunk) * 16.0f; - // separate float and int values are to fix percission loss at extreme distances from the origin (IE 10,000,000+) - // luckily large translate values minus large cameraPos generally equal values that cleanly fit in a float - trans += (aTranslateSubChunk + uOffsetSubChunk - uCameraPosSubChunk); - - // combination translation and scaling matrix - mat4 transform = mat4( - aScale.x, 0.0, 0.0, 0.0, - 0.0, aScale.y, 0.0, 0.0, - 0.0, 0.0, aScale.z, 0.0, - trans.x, trans.y, trans.z, 1.0 - ); - - gl_Position = uProjectionMvm * transform * vec4(vPosition, 1.0); - - float blockLight = (float(uBlockLight)+0.5) / 16.0; - float skyLight = (float(uSkyLight)+0.5) / 16.0; - vec4 lightColor = vec4(texture(uLightMap, vec2(blockLight, skyLight)).xyz, 1.0); - - - fColor = lightColor * aColor; - - // apply directional shading - if (gl_VertexID >= 0 && gl_VertexID < 4) { fColor.rgb *= uNorthShading; } - else if (gl_VertexID >= 4 && gl_VertexID < 8) { fColor.rgb *= uSouthShading; } - else if (gl_VertexID >= 8 && gl_VertexID < 12) { fColor.rgb *= uWestShading; } - else if (gl_VertexID >= 12 && gl_VertexID < 16) { fColor.rgb *= uEastShading; } - else if (gl_VertexID >= 16 && gl_VertexID < 20) { fColor.rgb *= uBottomShading; } - else if (gl_VertexID >= 20 && gl_VertexID < 24) { fColor.rgb *= uTopShading; } - -} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/lod/blaze/frag.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/lod/blaze/frag.fsh deleted file mode 100644 index 86be28a6b..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/lod/blaze/frag.fsh +++ /dev/null @@ -1,125 +0,0 @@ -#version 150 - -in vec4 vertexColor; -in vec3 vertexWorldPos; -in vec3 vPos; -in vec4 gl_FragCoord; - -out vec4 fragColor; - -layout (std140) uniform fragUniformBlock -{ - // Fade/Clip Uniforms - float uClipDistance; - - // Noise Uniforms - float uNoiseIntensity; - int uNoiseSteps; - int uNoiseDropoff; - bool uDitherDhRendering; - bool uNoiseEnabled; -}; - - -// The random functions for diffrent dimentions -float rand(float co) { return fract(sin(co*(91.3458)) * 47453.5453); } -float rand(vec2 co) { return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } -float rand(vec3 co) { return rand(co.xy + rand(co.z)); } - -// Puts steps in a float -// EG. setting stepSize to 4 then this would be the result of this function -// In: 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, ..., 1.1, 1.2, 1.3 -// Out: 0.0, 0.0, 0.0, 0.25, 0.25, 0.5, 0.5, ..., 1.0, 1.0, 1.25 -vec3 quantize(vec3 val, int stepSize) -{ - return floor(val * stepSize) / stepSize; -} - -void applyNoise(inout vec4 fragColor, const in float viewDist) -{ - vec3 vertexNormal = normalize(cross(dFdy(vPos.xyz), dFdx(vPos.xyz))); - // This bit of code is required to fix the vertex position problem cus of floats in the verted world position varuable - vec3 fixedVPos = vPos.xyz + vertexNormal * 0.001; - - float noiseAmplification = uNoiseIntensity; - float lum = (fragColor.r + fragColor.g + fragColor.b) / 3.0; - noiseAmplification = (1.0 - pow(lum * 2.0 - 1.0, 2.0)) * noiseAmplification; // Lessen the effect on depending on how dark the object is, equasion for this is -(2x-1)^{2}+1 - noiseAmplification *= fragColor.a; // The effect would lessen on transparent objects - - // Random value for each position - float randomValue = rand(quantize(fixedVPos, uNoiseSteps)) - * 2.0 * noiseAmplification - noiseAmplification; - - // Modifies the color - // A value of 0 on the randomValue will result in the original color, while a value of 1 will result in a fully bright color - vec3 newCol = fragColor.rgb + (1.0 - fragColor.rgb) * randomValue; - newCol = clamp(newCol, 0.0, 1.0); - - if (uNoiseDropoff != 0) { - float distF = min(viewDist / uNoiseDropoff, 1.0); - newCol = mix(newCol, fragColor.rgb, distF); // The further away it gets, the less noise gets applied - } - - fragColor.rgb = newCol; -} - -/** returns a normalized value between 0.0 and 1.0 */ -float bayerMatrix4x4(vec2 st) -{ - int x = int(mod(st.x, 4.0)); - int y = int(mod(st.y, 4.0)); - - // Flattened 4x4 Bayer matrix - float bayer4x4[16] = float[16]( - 0.0, 8.0, 2.0, 10.0, - 12.0, 4.0, 14.0, 6.0, - 3.0, 11.0, 1.0, 9.0, - 15.0, 7.0, 13.0, 5.0 - ); - - // Calculate the 1D index from the 2D coordinates - int index = y * 4 + x; - - // Return the Bayer value normalized between 0.0 and 1.0 - return bayer4x4[index] / 16.0; -} - - - -void main() -{ - fragColor = vertexColor; - - float viewDist = length(vertexWorldPos); - - if (uDitherDhRendering) - { - // Dither out the fragment based on distance and noise. - // Dithering is used since it works for both opaque and transparent rendering - - // noise increases as the distance increases - // the fragCoord is used since it is stable and small so the dithering is cleaner - float worldNoise = bayerMatrix4x4(gl_FragCoord.xy); - // minor fudge factor to make sure all pixels fade out - // if not included 1 in 16 pixels would never fade away - worldNoise += 0.001; - - float fadeStep = smoothstep(uClipDistance, uClipDistance * 1.5, viewDist); - if (fadeStep <= worldNoise) - { - discard; - } - } - else - { - if (viewDist < uClipDistance && uClipDistance > 0.0) - { - discard; - } - } - - if (uNoiseEnabled) - { - applyNoise(fragColor, viewDist); - } -} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/lod/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/lod/blaze/vert.vsh deleted file mode 100644 index e2eed781e..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/lod/blaze/vert.vsh +++ /dev/null @@ -1,81 +0,0 @@ -#version 150 - -in uvec3 vPosition; -in uint meta; // contains light and micro-offset data -in vec4 vColor; -in int irisMaterial; -in int irisNormal; - -out vec3 vPos; -out vec4 vertexColor; -out vec3 vertexWorldPos; -out float vertexYPos; - -layout (std140) uniform vertUniqueUniformBlock -{ - vec3 uModelOffset; -}; - -layout (std140) uniform vertSharedUniformBlock -{ - bool uIsWhiteWorld; - - float uWorldYOffset; - float uMircoOffset; - float uEarthRadius; - - vec3 uCameraPos; - mat4 uCombinedMatrix; -}; - -uniform sampler2D uLightMap; - -/** - * LOD terrain Vertex Shader - */ -void main() -{ - vPos = vPosition; // This is so it can be passed to the fragment shader - - vertexWorldPos = vPosition.xyz + (uModelOffset - uCameraPos); - - vertexYPos = vPosition.y + uWorldYOffset; - - uint mirco = (meta & 0xFF00u) >> 8u; // mirco offset which is a xyz 2bit value - // 0b00 = no offset - // 0b01 = positive offset - // 0b11 = negative offset - // format is: 0b00zzyyxx - float mx = (mirco & 1u)!=0u ? uMircoOffset : 0.0; - mx = (mirco & 2u)!=0u ? -mx : mx; - //float my = (mirco & 4u)!=0u ? uMircoOffset : 0.0; - //my = (mirco & 8u)!=0u ? -my : my; - float mz = (mirco & 16u)!=0u ? uMircoOffset : 0.0; - mz = (mirco & 32u)!=0u ? -mz : mz; - - vertexWorldPos.x += mx; - //vertexWorldPos.y += my; - vertexWorldPos.z += mz; - - // apply the earth curvature if needed - if (uEarthRadius < -1.0f || uEarthRadius > 1.0f) - { - // vertex transformation logic - stduhpf - float localRadius = uEarthRadius + vertexYPos; - float phi = length(vertexWorldPos.xz) / localRadius; - vertexWorldPos.y += (cos(phi) - 1.0) * localRadius; - vertexWorldPos.xz = vertexWorldPos.xz * sin(phi) / phi; - } - - uint lights = meta & 0xFFu; - float skyLight = (float(lights/16u)+0.5) / 16.0; - float blockLight = (mod(float(lights), 16.0)+0.5) / 16.0; - vertexColor = vec4(texture(uLightMap, vec2(skyLight, blockLight)).xyz, 1.0); - - if (!uIsWhiteWorld) - { - vertexColor *= vColor; - } - - gl_Position = uCombinedMatrix * vec4(vertexWorldPos, 1.0); -} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/apply.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/apply.frag deleted file mode 100644 index ba11b49ef..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/apply.frag +++ /dev/null @@ -1,33 +0,0 @@ -#version 150 core - -in vec2 TexCoord; - -out vec4 fragColor; - -uniform sampler2D gDhColorTexture; -uniform sampler2D gDhDepthTexture; - - -/** - * LOD application shader - * - * This merges the rendered LODs into Minecraft's texture/FBO - */ -void main() -{ - fragColor = vec4(0.0); - - // a fragment depth of "1" means the fragment wasn't drawn to, - // only update fragments that were drawn to - float fragmentDepth = texture(gDhDepthTexture, TexCoord).r; - if (fragmentDepth != 1) - { - fragColor = texture(gDhColorTexture, TexCoord); - } - else - { - // use the original MC texture if no LODs were drawn to this fragment - discard; - } -} - diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/flat_shaded.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/flat_shaded.frag deleted file mode 100644 index d24ba9672..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/flat_shaded.frag +++ /dev/null @@ -1,123 +0,0 @@ -#version 150 - -in vec4 vertexColor; -in vec3 vertexWorldPos; -in vec4 vPos; -in vec4 gl_FragCoord; - -out vec4 fragColor; - - -// Fade/Clip Uniforms -uniform float uClipDistance = 0.0; - -// Noise Uniforms -uniform bool uNoiseEnabled; -uniform int uNoiseSteps; -uniform float uNoiseIntensity; -uniform int uNoiseDropoff; -uniform bool uDitherDhRendering; - - -// The random functions for diffrent dimentions -float rand(float co) { return fract(sin(co*(91.3458)) * 47453.5453); } -float rand(vec2 co) { return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } -float rand(vec3 co) { return rand(co.xy + rand(co.z)); } - -// Puts steps in a float -// EG. setting stepSize to 4 then this would be the result of this function -// In: 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, ..., 1.1, 1.2, 1.3 -// Out: 0.0, 0.0, 0.0, 0.25, 0.25, 0.5, 0.5, ..., 1.0, 1.0, 1.25 -vec3 quantize(vec3 val, int stepSize) -{ - return floor(val * stepSize) / stepSize; -} - -void applyNoise(inout vec4 fragColor, const in float viewDist) -{ - vec3 vertexNormal = normalize(cross(dFdy(vPos.xyz), dFdx(vPos.xyz))); - // This bit of code is required to fix the vertex position problem cus of floats in the verted world position varuable - vec3 fixedVPos = vPos.xyz + vertexNormal * 0.001; - - float noiseAmplification = uNoiseIntensity; - float lum = (fragColor.r + fragColor.g + fragColor.b) / 3.0; - noiseAmplification = (1.0 - pow(lum * 2.0 - 1.0, 2.0)) * noiseAmplification; // Lessen the effect on depending on how dark the object is, equasion for this is -(2x-1)^{2}+1 - noiseAmplification *= fragColor.a; // The effect would lessen on transparent objects - - // Random value for each position - float randomValue = rand(quantize(fixedVPos, uNoiseSteps)) - * 2.0 * noiseAmplification - noiseAmplification; - - // Modifies the color - // A value of 0 on the randomValue will result in the original color, while a value of 1 will result in a fully bright color - vec3 newCol = fragColor.rgb + (1.0 - fragColor.rgb) * randomValue; - newCol = clamp(newCol, 0.0, 1.0); - - if (uNoiseDropoff != 0) { - float distF = min(viewDist / uNoiseDropoff, 1.0); - newCol = mix(newCol, fragColor.rgb, distF); // The further away it gets, the less noise gets applied - } - - fragColor.rgb = newCol; -} - -/** returns a normalized value between 0.0 and 1.0 */ -float bayerMatrix4x4(vec2 st) -{ - int x = int(mod(st.x, 4.0)); - int y = int(mod(st.y, 4.0)); - - // Flattened 4x4 Bayer matrix - float bayer4x4[16] = float[16]( - 0.0, 8.0, 2.0, 10.0, - 12.0, 4.0, 14.0, 6.0, - 3.0, 11.0, 1.0, 9.0, - 15.0, 7.0, 13.0, 5.0 - ); - - // Calculate the 1D index from the 2D coordinates - int index = y * 4 + x; - - // Return the Bayer value normalized between 0.0 and 1.0 - return bayer4x4[index] / 16.0; -} - - - -void main() -{ - fragColor = vertexColor; - - float viewDist = length(vertexWorldPos); - - if (uDitherDhRendering) - { - // Dither out the fragment based on distance and noise. - // Dithering is used since it works for both opaque and transparent rendering - - // noise increases as the distance increases - // the fragCoord is used since it is stable and small so the dithering is cleaner - float worldNoise = bayerMatrix4x4(gl_FragCoord.xy); - // minor fudge factor to make sure all pixels fade out - // if not included 1 in 16 pixels would never fade away - worldNoise += 0.001; - - float fadeStep = smoothstep(uClipDistance, uClipDistance * 1.5, viewDist); - if (fadeStep <= worldNoise) - { - discard; - } - } - else - { - if (viewDist < uClipDistance && uClipDistance > 0.0) - { - discard; - } - } - - if (uNoiseEnabled) - { - applyNoise(fragColor, viewDist); - } -} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/quad_apply.vert b/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/quad_apply.vert deleted file mode 100644 index 3f614c123..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/quad_apply.vert +++ /dev/null @@ -1,15 +0,0 @@ -#version 150 core - -in vec2 vPosition; - -out vec2 TexCoord; - -/** - * This is specifically used by application shaders. - * IE post process or pixel transfer shaders, anything that is rendered using a single rectangle. - */ -void main() -{ - gl_Position = vec4(vPosition, 1.0, 1.0); - TexCoord = vPosition.xy * 0.5 + 0.5; -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/standard.vert b/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/standard.vert deleted file mode 100644 index 1117af78e..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/shared/gl/standard.vert +++ /dev/null @@ -1,79 +0,0 @@ -#version 150 core - -in uvec4 vPosition; -in vec4 color; - -out vec4 vPos; -out vec4 vertexColor; -out vec3 vertexWorldPos; -out float vertexYPos; - -uniform bool uIsWhiteWorld; - -uniform mat4 uCombinedMatrix; -uniform vec3 uModelOffset; -uniform float uWorldYOffset; - -uniform sampler2D uLightMap; -uniform float uMircoOffset; - -uniform float uEarthRadius; - -/** - * Vertex Shader - * - * author: James Seibel - * author: TomTheFurry - * author: stduhpf - * updated: coolGi - * - * version: 2025-12-22 - */ -void main() -{ - vPos = vPosition; // This is so it can be passed to the fragment shader - - vertexWorldPos = vPosition.xyz + uModelOffset; - - vertexYPos = vPosition.y + uWorldYOffset; - - uint meta = vPosition.a; - - uint mirco = (meta & 0xFF00u) >> 8u; // mirco offset which is a xyz 2bit value - // 0b00 = no offset - // 0b01 = positive offset - // 0b11 = negative offset - // format is: 0b00zzyyxx - float mx = (mirco & 1u)!=0u ? uMircoOffset : 0.0; - mx = (mirco & 2u)!=0u ? -mx : mx; - //float my = (mirco & 4u)!=0u ? uMircoOffset : 0.0; - //my = (mirco & 8u)!=0u ? -my : my; - float mz = (mirco & 16u)!=0u ? uMircoOffset : 0.0; - mz = (mirco & 32u)!=0u ? -mz : mz; - - vertexWorldPos.x += mx; - //vertexWorldPos.y += my; - vertexWorldPos.z += mz; - - // apply the earth curvature if needed - if (uEarthRadius < -1.0f || uEarthRadius > 1.0f) - { - // vertex transformation logic - stduhpf - float localRadius = uEarthRadius + vertexYPos; - float phi = length(vertexWorldPos.xz) / localRadius; - vertexWorldPos.y += (cos(phi) - 1.0) * localRadius; - vertexWorldPos.xz = vertexWorldPos.xz * sin(phi) / phi; - } - - uint lights = meta & 0xFFu; - float skyLight = (float(lights/16u)+0.5) / 16.0; - float blockLight = (mod(float(lights), 16.0)+0.5) / 16.0; - vertexColor = vec4(texture(uLightMap, vec2(skyLight, blockLight)).xyz, 1.0); - - if (!uIsWhiteWorld) - { - vertexColor *= color; - } - - gl_Position = uCombinedMatrix * vec4(vertexWorldPos, 1.0); -} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/apply.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/apply.fsh deleted file mode 100644 index ecc9ba828..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/apply.fsh +++ /dev/null @@ -1,86 +0,0 @@ -#version 150 core - -in vec2 TexCoord; - -out vec4 fragColor; - -uniform sampler2D uSourceColorTexture; -uniform sampler2D uSourceDepthTexture; - -layout (std140) uniform applyFragUniformBlock -{ - vec2 uViewSize; - int uBlurRadius; - float uNearClipPlane; // in blocks - float uFarClipPlane; // in blocks -}; - - -float linearizeDepth(const in float depth) { return (uNearClipPlane * uFarClipPlane) / (depth * (uNearClipPlane - uFarClipPlane) + uFarClipPlane); } - -float Gaussian(const in float sigma, const in float x) { return exp(-(x*x) / (2.0 * (sigma*sigma))); } - -float BilateralGaussianBlur(const in vec2 texcoord, const in float linearDepth, const in float g_sigmaV) -{ - float g_sigmaX = 1.6; - float g_sigmaY = 1.6; - - int radius = clamp(uBlurRadius, 1, 3); - - vec2 pixelSize = 1.0 / uViewSize; - - float accum = 0.0; - float total = 0.0; - for (int iy = -radius; iy <= radius; iy++) - { - float fy = Gaussian(g_sigmaY, iy); - - for (int ix = -radius; ix <= radius; ix++) - { - float fx = Gaussian(g_sigmaX, ix); - - vec2 sampleTexCoord = texcoord + ivec2(ix, iy) * pixelSize; - - float sampleValue = textureLod(uSourceColorTexture, sampleTexCoord, 0).r; - - float sampleDepth = textureLod(uSourceDepthTexture, sampleTexCoord, 0).r; - float sampleLinearDepth = linearizeDepth(sampleDepth); - - float depthDiff = abs(sampleLinearDepth - linearDepth); - float fv = Gaussian(g_sigmaV, depthDiff); - - float weight = fx*fy*fv; - accum += weight * sampleValue; - total += weight; - } - } - - if (total <= 1.e-4) - { - return 1.0; - } - return accum / total; -} - - -void main() -{ - fragColor = vec4(1.0); - - float fragmentDepth = textureLod(uSourceDepthTexture, TexCoord, 0).r; - - // a fragment depth of "1" means the fragment wasn't drawn to, - // we only want to apply SSAO to LODs, not to the sky outside the LODs - if (fragmentDepth < 1) - { - if (uBlurRadius > 0) - { - float fragmentDepthLinear = linearizeDepth(fragmentDepth); - fragColor.a = BilateralGaussianBlur(TexCoord, fragmentDepthLinear, 1.6); - } - else - { - fragColor.a = texelFetch(uSourceColorTexture, ivec2(gl_FragCoord.xy), 0).r; - } - } -} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/frag.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/frag.fsh deleted file mode 100644 index 517523342..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/frag.fsh +++ /dev/null @@ -1,137 +0,0 @@ -#version 150 core -#extension GL_ARB_derivative_control : enable - -#define SAMPLE_MAX 64 - -#define saturate(x) (clamp((x), 0.0, 1.0)) - -in vec2 TexCoord; - -out vec4 fragColor; - - -layout (std140) uniform fragUniformBlock -{ - int uSampleCount; - - float uRadius; - float uStrength; - float uMinLight; - float uBias; - float uFadeDistanceInBlocks; - - mat4 uInvProj; - mat4 uProj; -}; - -uniform sampler2D uDhDepthTexture; - -const float EPSILON = 1.e-6; -const float GOLDEN_ANGLE = 2.39996323; -const vec3 MAGIC = vec3(0.06711056, 0.00583715, 52.9829189); -const float PI = 3.1415926538; -const float TAU = PI * 2.0; - - -vec3 unproject(vec4 pos) -{ - return pos.xyz / pos.w; -} - -float InterleavedGradientNoise(const in vec2 pixel) -{ - float x = dot(pixel, MAGIC.xy); - return fract(MAGIC.z * fract(x)); -} - -vec3 calcViewPosition(const in vec3 clipPos) -{ - vec4 viewPos = uInvProj * vec4(clipPos * 2.0 - 1.0, 1.0); - return viewPos.xyz / viewPos.w; -} - -float GetSpiralOcclusion(const in vec2 uv, const in vec3 viewPos, const in vec3 viewNormal) -{ - float dither = InterleavedGradientNoise(gl_FragCoord.xy); - float rotatePhase = dither * TAU; - float rStep = uRadius / uSampleCount; - - vec2 offset; - - float ao = 0.0; - int sampleCount = 0; - float radius = rStep; - for (int i = 0; i < clamp(uSampleCount, 1, SAMPLE_MAX); i++) { - vec2 offset = vec2( - sin(rotatePhase), - cos(rotatePhase) - ) * radius; - - radius += rStep; - rotatePhase += GOLDEN_ANGLE; - - vec3 sampleViewPos = viewPos + vec3(offset, -0.1); - vec3 sampleClipPos = unproject(uProj * vec4(sampleViewPos, 1.0)) * 0.5 + 0.5; - sampleClipPos = saturate(sampleClipPos); - - float sampleClipDepth = textureLod(uDhDepthTexture, sampleClipPos.xy, 0.0).r; - if (sampleClipDepth >= 1.0 - EPSILON) continue; - - sampleClipPos.z = sampleClipDepth; - sampleViewPos = unproject(uInvProj * vec4(sampleClipPos * 2.0 - 1.0, 1.0)); - - vec3 diff = sampleViewPos - viewPos; - float sampleDist = length(diff); - vec3 sampleNormal = diff / sampleDist; - - float sampleNoLm = max(dot(viewNormal, sampleNormal) - uBias, 0.0); - float aoF = 1.0 - saturate(sampleDist / uRadius); - ao += sampleNoLm * aoF; - sampleCount++; - } - - ao /= max(sampleCount, 1); - ao = smoothstep(0.0, uStrength, ao); - - return ao * (1.0 - uMinLight); -} - - -void main() -{ - float fragmentDepth = textureLod(uDhDepthTexture, TexCoord, 0).r; - float occlusion = 0.0; - - // Do not apply to sky - if (fragmentDepth < 1.0) - { - vec3 viewPos = calcViewPosition(vec3(TexCoord, fragmentDepth)); - - // fading is done to prevent banding/noise - // at super far distance - float distanceFromCamera = length(viewPos); - float fadeDistance = uFadeDistanceInBlocks; - if (distanceFromCamera < fadeDistance) - { - #ifdef GL_ARB_derivative_control - // Get higher precision derivatives when available - vec3 viewNormal = cross(dFdxFine(viewPos.xyz), dFdyFine(viewPos.xyz)); - #else - vec3 viewNormal = cross(dFdx(viewPos.xyz), dFdy(viewPos.xyz)); - #endif - - viewNormal = normalize(viewNormal); - occlusion = GetSpiralOcclusion(TexCoord, viewPos, viewNormal); - - // linearly fade with distance - occlusion *= (fadeDistance - distanceFromCamera) / fadeDistance; - } - else - { - // we're out of range, no need to do any SSAO calculations - occlusion = 0.0; - } - } - - fragColor = vec4(vec3(1.0 - occlusion), 1.0); -} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/vert.vsh deleted file mode 100644 index 3f614c123..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/blaze/vert.vsh +++ /dev/null @@ -1,15 +0,0 @@ -#version 150 core - -in vec2 vPosition; - -out vec2 TexCoord; - -/** - * This is specifically used by application shaders. - * IE post process or pixel transfer shaders, anything that is rendered using a single rectangle. - */ -void main() -{ - gl_Position = vec4(vPosition, 1.0, 1.0); - TexCoord = vPosition.xy * 0.5 + 0.5; -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/gl/ao.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/gl/ao.frag deleted file mode 100644 index d4e475348..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/gl/ao.frag +++ /dev/null @@ -1,130 +0,0 @@ -#version 150 core -#extension GL_ARB_derivative_control : enable - -#define SAMPLE_MAX 64 - -#define saturate(x) (clamp((x), 0.0, 1.0)) - -in vec2 TexCoord; - -out vec4 fragColor; - -uniform sampler2D uDepthMap; -uniform int uSampleCount; -uniform float uRadius; -uniform float uStrength; -uniform float uMinLight; -uniform float uBias; -uniform mat4 uInvProj; -uniform mat4 uProj; -uniform float uFadeDistanceInBlocks; - -const float EPSILON = 1.e-6; -const float GOLDEN_ANGLE = 2.39996323; -const vec3 MAGIC = vec3(0.06711056, 0.00583715, 52.9829189); -const float PI = 3.1415926538; -const float TAU = PI * 2.0; - - -vec3 unproject(vec4 pos) -{ - return pos.xyz / pos.w; -} - -float InterleavedGradientNoise(const in vec2 pixel) -{ - float x = dot(pixel, MAGIC.xy); - return fract(MAGIC.z * fract(x)); -} - -vec3 calcViewPosition(const in vec3 clipPos) -{ - vec4 viewPos = uInvProj * vec4(clipPos * 2.0 - 1.0, 1.0); - return viewPos.xyz / viewPos.w; -} - -float GetSpiralOcclusion(const in vec2 uv, const in vec3 viewPos, const in vec3 viewNormal) -{ - float dither = InterleavedGradientNoise(gl_FragCoord.xy); - float rotatePhase = dither * TAU; - float rStep = uRadius / uSampleCount; - - vec2 offset; - - float ao = 0.0; - int sampleCount = 0; - float radius = rStep; - for (int i = 0; i < clamp(uSampleCount, 1, SAMPLE_MAX); i++) { - vec2 offset = vec2( - sin(rotatePhase), - cos(rotatePhase) - ) * radius; - - radius += rStep; - rotatePhase += GOLDEN_ANGLE; - - vec3 sampleViewPos = viewPos + vec3(offset, -0.1); - vec3 sampleClipPos = unproject(uProj * vec4(sampleViewPos, 1.0)) * 0.5 + 0.5; - sampleClipPos = saturate(sampleClipPos); - - float sampleClipDepth = textureLod(uDepthMap, sampleClipPos.xy, 0.0).r; - if (sampleClipDepth >= 1.0 - EPSILON) continue; - - sampleClipPos.z = sampleClipDepth; - sampleViewPos = unproject(uInvProj * vec4(sampleClipPos * 2.0 - 1.0, 1.0)); - - vec3 diff = sampleViewPos - viewPos; - float sampleDist = length(diff); - vec3 sampleNormal = diff / sampleDist; - - float sampleNoLm = max(dot(viewNormal, sampleNormal) - uBias, 0.0); - float aoF = 1.0 - saturate(sampleDist / uRadius); - ao += sampleNoLm * aoF; - sampleCount++; - } - - ao /= max(sampleCount, 1); - ao = smoothstep(0.0, uStrength, ao); - - return ao * (1.0 - uMinLight); -} - - -void main() -{ - float fragmentDepth = textureLod(uDepthMap, TexCoord, 0).r; - float occlusion = 0.0; - - // Do not apply to sky - if (fragmentDepth < 1.0) - { - vec3 viewPos = calcViewPosition(vec3(TexCoord, fragmentDepth)); - - // fading is done to prevent banding/noise - // at super far distance - float distanceFromCamera = length(viewPos); - float fadeDistance = uFadeDistanceInBlocks; - if (distanceFromCamera < fadeDistance) - { - #ifdef GL_ARB_derivative_control - // Get higher precision derivatives when available - vec3 viewNormal = cross(dFdxFine(viewPos.xyz), dFdyFine(viewPos.xyz)); - #else - vec3 viewNormal = cross(dFdx(viewPos.xyz), dFdy(viewPos.xyz)); - #endif - - viewNormal = normalize(viewNormal); - occlusion = GetSpiralOcclusion(TexCoord, viewPos, viewNormal); - - // linearly fade with distance - occlusion *= (fadeDistance - distanceFromCamera) / fadeDistance; - } - else - { - // we're out of range, no need to do any SSAO calculations - occlusion = 0.0; - } - } - - fragColor = vec4(vec3(1.0 - occlusion), 1.0); -} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/gl/apply.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/gl/apply.frag deleted file mode 100644 index 28d8c8869..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/ssao/gl/apply.frag +++ /dev/null @@ -1,78 +0,0 @@ -#version 150 core - -in vec2 TexCoord; - -out vec4 fragColor; - -uniform sampler2D gSSAOMap; -uniform sampler2D gDepthMap; -uniform vec2 gViewSize; -uniform int gBlurRadius; -uniform float gNear; -uniform float gFar; - - -float linearizeDepth(const in float depth) { - return (gNear * gFar) / (depth * (gNear - gFar) + gFar); -} - -float Gaussian(const in float sigma, const in float x) { - return exp(-(x*x) / (2.0 * (sigma*sigma))); -} - -float BilateralGaussianBlur(const in vec2 texcoord, const in float linearDepth, const in float g_sigmaV) { - float g_sigmaX = 1.6; - float g_sigmaY = 1.6; - - int radius = clamp(gBlurRadius, 1, 3); - - vec2 pixelSize = 1.0 / gViewSize; - - float accum = 0.0; - float total = 0.0; - for (int iy = -radius; iy <= radius; iy++) { - float fy = Gaussian(g_sigmaY, iy); - - for (int ix = -radius; ix <= radius; ix++) { - float fx = Gaussian(g_sigmaX, ix); - - vec2 sampleTex = texcoord + ivec2(ix, iy) * pixelSize; - float sampleValue = textureLod(gSSAOMap, sampleTex, 0).r; - float sampleDepth = textureLod(gDepthMap, sampleTex, 0).r; - float sampleLinearDepth = linearizeDepth(sampleDepth); - - float depthDiff = abs(sampleLinearDepth - linearDepth); - float fv = Gaussian(g_sigmaV, depthDiff); - - float weight = fx*fy*fv; - accum += weight * sampleValue; - total += weight; - } - } - - if (total <= 1.e-4) return 1.0; - return accum / total; -} - - -void main() -{ - fragColor = vec4(1.0); - - float fragmentDepth = textureLod(gDepthMap, TexCoord, 0).r; - - // a fragment depth of "1" means the fragment wasn't drawn to, - // we only want to apply SSAO to LODs, not to the sky outside the LODs - if (fragmentDepth < 1) - { - if (gBlurRadius > 0) - { - float fragmentDepthLinear = linearizeDepth(fragmentDepth); - fragColor.a = BilateralGaussianBlur(TexCoord, fragmentDepthLinear, 1.6); - } - else - { - fragColor.a = texelFetch(gSSAOMap, ivec2(gl_FragCoord.xy), 0).r; - } - } -} diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/blaze/frag.fsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/blaze/frag.fsh deleted file mode 100644 index 3fd25f9db..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/blaze/frag.fsh +++ /dev/null @@ -1,10 +0,0 @@ -#version 150 core - -in vec4 fColor; -out vec4 fragColor; - -// DH frag test -void main() -{ - fragColor = fColor; -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/blaze/vert.vsh b/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/blaze/vert.vsh deleted file mode 100644 index 2887fea56..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/blaze/vert.vsh +++ /dev/null @@ -1,13 +0,0 @@ -#version 150 core - -in vec2 vPosition; -in vec4 vColor; - -out vec4 fColor; - -// DH vert test -void main() -{ - gl_Position = vec4(vPosition, 0.0, 1.0); - fColor = vColor; -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/gl/frag.frag b/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/gl/frag.frag deleted file mode 100644 index 2a8a4d685..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/gl/frag.frag +++ /dev/null @@ -1,9 +0,0 @@ -#version 150 core - -in vec4 fColor; -out vec4 fragColor; - -void main() -{ - fragColor = fColor; -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/gl/vert.vert b/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/gl/vert.vert deleted file mode 100644 index 12a66443f..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/shaders/test/gl/vert.vert +++ /dev/null @@ -1,11 +0,0 @@ -#version 150 core - -in vec2 vPosition; -in vec4 color; - -out vec4 fColor; -void main() -{ - gl_Position = vec4(vPosition, 0.0, 1.0); - fColor = color; -} \ No newline at end of file diff --git a/cleanroom/src/main/resources/assets/distanthorizons/textures/clouds-original.png b/cleanroom/src/main/resources/assets/distanthorizons/textures/clouds-original.png deleted file mode 100644 index 825f4814e3fab7899db0e991087484a908873d5f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6214 zcmV-M7`f+(P)Px#1ZP1_K>z@;j|==^1poj522e~?MF0Q*|NsA`*`M72000SaNLh0L01m?j~gZYoErBeyQB=cj_p-0I=rLVQ)}o zX;6sM?D;ZSxmyPL8$XLp<>oVCn8;hlxgU}{YnO7-aJ30Pm&!L>086(&v>*ZaTTf2i z1WW_;x2ojbp#vBqFaZ7H{i6U}4m=>X-|>M`YbH}SX^ zabDL|LB5VokLw92$f8Yu10&lKPTR-LAJj=I00NoF6#!)IU|mX`zAnTf0H&Kojqi^P zo~64l0jJ+={zqwg%;;kjr0 zVm@IVRo_rz8+n0MzzP6+b9E?iL@_)fLSMSVNQv-^{c7~E7)f;mr?C5KvQJiiX5RYE4Y~7NwGfkD z(=8-W%v*mU3Gw_}0B7Qe*RU(*{3vO09*%yfMrp#ojrS1~Y0S8UF4vLSodmr5JhwU3 zF*K1lbNlN@dkQ-`DsVU<(}KX5&sESk{~E573K^_MCAx9^AR~8`e%2WIMwt*Y`35&^ zqy`|(3#UynNOYkJRjxixl7=CqyJ^WMDyj~EluN{A9h^5u_^g=-L0iiY^2COhD7GX; zg^xdfQvy_7d+keHmsnnMa*hk z08L&@b&LxDH(Up>5OD8o+!|R?>TZ7ZII|Zq3iC&rrZ_CNU-$H@UnnI8%W(GL-D(&b z`^7osCJEP$=|r+#YNB7SL+Zn{z$NXjtTk7f>{pI#v8HZGE%L7cafSjfA!Pp0=Oaxm z_0~J-@UYgMv`9WzG7ayF^glC?)&ZyiKrm10bi<*G39oZvFxB_c3H1pLFKz` z+oh9&vW{PxNJm}fdBHbk5I;1>1NDL(fs{Oz#cBG()m|f?OlDFw4r)=x0l33b2Y(>Y zU_%B#$fqbPW#zLH7$(QlB!b21+fRonRsd=j!u`CF*eNH6&c%b~IwZSx+o*OaB1i&P zybiJjM71#=P4u!x6vXr=+PogxCYDHbvd50KU9L1SR+)fSd}?X@0bnJ7XdUvl(bHTe zor>a5_DJT0)m7R5XH1SljMhOg*NgH@QHNNn6lyC=xK#}zYY^*8HSWa(N>)w@X!E-M zA**Aem)lbp8Y@^AvYN3&oa3by<@Y&9iJ*_VJbKoWY)m0Y;vWa;!ZFCt&$1)KZXSRO zca4Z+XthwXkIOHEA8T0^z!aweSY0%8r7wvUu&(AnM0TrK>lQ{MxHNq3~1wP0KZG0G(Ir%h1M>Nyfv_PIJ|b5_eFwQtyTbSk_G!s04nwx z3zHEV(JW=5bUU(#YJ!mx+O+9zQL4K=);kOr+&%#mK0yd7h|)KYjBAHM=F2i2NZoKD zSJ(isZ{zh~z&`O?+QWGidfDVyiV)TXDS*XF)?706D(00O18i)u<4HJMdUf)Y_k9_)9QKcxVHV!ybkmz3gMQfI_ZouVwS6(1TR&KO3*5 zQMvyr0iGMQtks=$eDx;NNW02W+Ljj<is)bzMZqxsuudC`9hv(WF1+8(z0iaH}N9 zHZk_C2CRMetilPHSKwx8YXPv;#?c6K9iVkqbz}w)r0&LO5vuX0`e7}y-0Q|u0?-*m z_))>`SyAms*l!`q3IO>Q@N&4&FRDQRbe=9lb&f@kDpuTBx$S%~AbuHsO zcTF`w0kE54No`Lm8kaPufL<3+NNZV61hcWf+oqhXjT$27d28AsT#9Qg6x6-+?3OQ^ zkB5HpeiTO%7BhpKAU)noxTu-{rrZ?P{hd=M!OKLIyeuj5iJG!^7~e~7FLy#MZa}Lj z$34e^UBc|!{uPq*w%q=4x6)xVgHwB3c2OEaEhDk;WJ-FBn2G(-lAn3vv2GHAOqN{Js{+d8?CCPJa3PK&vm)pN@Q<9 zw{-O+LOb^!CtdoVsjNo;xF7vVxhzNMnCC6VpV(v5Aie<^7d;7#dTQM!S^?A@n)>G>osf?h6%p%3mpmU=)9~h-x6n?Xk5B~Ry|7gee2Fb$qbc%; zlb8>2d8J$3eja}mT+Z$}%WOIW7H|Sf(khkWJZ`senVvLByCntA2QL;E%_e?+tD2O` z$RTL|?uZ}){0qgkVw?ZB*5+8#uUOP3rLK`@$*ATv z(GQti8(JOO^6eNxcg~P)2c(C$AqG7o!JGl$%?Swta!+?Op#ac&yPfK3zGNYH!t`|w zbX8eG#JXb2s8kVMo{_(>kA&vlGWcyiB7sy$Wf2Hm09Xdd5l3!5a|rSRK%rW55#IHN z03h-vaqk}9D7Ca>XLtJOhhy-#KFgjdZ8(kgWSmt(a?3FiDN${KwRXb}GbD9lD#u8u z2i}_z#19#SN|LR4v|&8i@aBFP^0@_N4{BuRcQ5BtJIBCraP9oHDvLjgbvom_1R$Rd zGHIBQMc28fjHJ%fn9mp++yrz63qy?Np>gPkx*$Coht1KQ@FFumdWghJ*i1)`knon! zTEsTslzSBlQss4a5oC!V;>{oEG3Qhn}eSq$Xv7`jEGT8GV zXb|7%g#$hOoKYdv)tfPd#Q*Q7I`Uy1@Hy{AU!*i`2HwXa!re*Q8lpRI&sr^ z<3bEPG$N?c5ghXv4`ryia^OpV(HZQYIRBf!1WVG=93%;g5TfbL<az5f3v!Kgl7-%s9IgXB;hF&<6xS_vHcG7vyvRj_siUH@|rN z6Y@#7v7>qaG$qehNO_uzK=~zs@6yO~JK82iOkNDE)&cuxY@>?!DLq+g!`d@2sM;8j zyf~~i!Mj*S{-h?R$Qq}NKx%#0idMWBGjGpb-%^SV00sae)Wl8!*iM($9;XH9a5Eex zzx@q>7X|F$bPs&;^HGOK99i0Y0pR;wKM|C~4GLB10+da+Q=LW9s5sLf>q`qEa9{ms zY~w+B01e4 z*n4Fvk4ho&ZvFP&2mPWS;iHTlEhwZYz)R9A3uC*}uK?J1+>3o$>4q&+r`mxCsEP8Z zXYz))GY`oWk&s?!fj%V=*;3UxCrH%l?MTUh?$n3mz`_-Q_=22}v|R}C*H%x2a?K=* zD6D4H0-fJ&4Ls18yDw{r6i4A{0`S*9nK{!9K-HllNx2X0Nf~w0$)r>UwO2TyGjAH* z0l->u&ht=@yteR;OCK^R&L@p|J~VV>?+FZ7{7^@@7JG%2F4imOGO>PF$7i-E zYeTQD=p=bL@IqY%-+ZkIR(}1}PEC=Z`d15!u|iq_+GBsu)|~NkOQ};KQCtvf>fgI` z_-!{&;=on01HcPBYh!1yh+wiT*R^s1<(%sEbhzK$s>U~_$in=nA44}uc~R|W4Hi>6>CXa1B`FD@vq{D@gZaV25d0?YTR-T;$t;<+t&vk- zE!i4J^`Csma-Y0}te4?KWfI4)YMF9AGz{EdT@vr4xDaZId0Z3}m$$I=7Er82r_UdA z+6>SMMV5f#%ABwUL*vLMRBNitrhf_tYL}GKHB!pl1kj5;T;||==(C)Dy2C2~WorGE z8jn?&+hW-T>|QLq0)rL%=Q$2*pu_gC?}g{(=>-I8t3J~K+lQ2I>Z#MwY7eqfW<-w$ zg4i4fC;dIFuS&`O@~y);34oOJRN|>aG57&ln`mNT&2THzAyZsCJ+T4c@Mm3(^h@bB zzgvU*`0GcK7t$NJze6W==6skJ1nwj>C&kNq^Hu=*lg~Sqcn2WeYRi{5%y__p&$+Jw zkUehHSBVsGN;Vi&eUhG?YngMu)LdVO7w*vCA(R>%6>);i%k?u0*>#HW2mt$IRnb5L zqVk=S+KfVke#i?fQwRK@0jB+;YwbUJw5m@i7DL{=Xrmz0e#8`Y)un#uYe+i@On#@3u7b(^VJkOQi|r3Euv#R zeIvrnu^O*&h%-@|ML|sG6?LbPVs~T!cGV4@=bdpxL{(wzjd0c?;#nI6+vEv)wQ0Kn zKxpr?%y|Xays$a5`WJeS+P7p_ClR{53P@AHye%Bl@zo?6FS`P`J~0pzHkQHIDnGd! zdm$B4pOn@lwX3Nnxc&<9pq7sheWS7*Im(X-WH*n8HRx>ihYn+nc1tFw9Ctqt0O-fkHuGM_*9p|ON|%hYzAxy;6FatpF2qa$kWX_ z6xof`iasz-2%ei?0q}fr6rl3ncmsN=V)}PWl+!-Bcy@dneS;|{eS{drvv+Nj7pCuL z&?Fe&C4d_MSzWEFXyB}QN9kj8^*IH@*Jl}&_Ch7$Y>&$%iWY-4LbqyX%=-FIByh^8 zY9C5QG)-wOc(*640McLAeJ|Fc#d1Y;Qdt>6OK9$UW9_443HN>doI6SDoc5tqy?gd^ zl7D`$UTXI@0#v%{-D_abIE>uOEV}i_J@JH~o+)?{t#z6}*d7$&L{%jYX8>rZX-h0c zj|)_eGZC=FJAEFDA{vJ3%ByXVOOeJ>Y&oG=$0n)S4FL8pFl+!AO=6s6BDF%R)ybim zl4Yum&kr^L$A({ywOG~C9T7t4BWC+I0I}A*^(Ko$nc(u0)WwIjvV{8Yt7*1n_tHA8 zmrp-7+Vo_`4A6wZ^enfq6PJ)*F7a-7YBYHS%t_OlpRweK@?hBd0&?W964+K;)Vy_> zuO3`yhaM`g$=N}7(#zoDIAXIbo3`||`auHMaJn!CPcf5sxljN}B;^|AD_8mD%{HR^ z#+<|*HS8t7M|>;b>OWJ1P1dybrWHQYf@}I)ByAJO=t;>9a156p83}G?0T*>$@^XpZ)+Z z{cKv+^#=gBapew*36{rR050JIK5Hw7kZd%xV@Y6SV; zVbgLWtO_KWEt8;~RhXq+oM0t%AdD0IsYM(uYqx1z8ZPhN;yjP#at{w0;P5TG$&5(z z#4}R41M5$Ge;_BiBnLpRO~oG`JCv5prF=jL7XIzM*k z?;qiyz7h)nLtp{ETPtbtS9Ed}eC&sHPNM&YGTT7C?+ie1;I{CceK%DuQ&}$DmVTEW z@_bD-cLsZ7wAyWp`4TsZpXYxL0Mgof3Mao_mRR*+HKhwEIpQigT{<6O zwL^6@BdthMA${8FB=l@tach~r7;I4i$p0bE9(W{a-Nx`>yCxDrC?AF!YcE1=ydCwK zPfcLiic>|AE&#C9$Y1Aj7 z&SNT@knU4!X2h=*Pb)LUPx#1ZP1_K>z@;j|==^1poj522e~?MF0Q*|NsA`*`M72000SaNLh0L01m$Z01m$a zI0aKA00053Nkl!Lk-ZJ2bOdQ*{9_o1Aa<*5fm2b<%Kv-b|YP$8s;Q8#k#Jr zoQ@wJgQ@>K1O3&4I4{xr5$TJO(c|p^DDR>LGINT?EQ#Dh zj&S9)m##s6bI`lsX2Ph`dsk9HCYoioJ|D zLRfLUi8MtQGup?-8Xk(9knGx-%!JpKk;#&84w`-%dG04AK}%qNY=Er6F%T0$8;_xi zw&9BF6dH6GRbih@w)2HxzStO&>uS)ve<0AYj>5AR{$W90N^4L=L-RlQUJ&DC0@ZjPh;=*jPLSYvv5M~MFBAl0-BNIsH z15C~g000{K(ZT*WKal6<?_01!^k@7iDG<<3=fuAC~28EsPoqkpK{9G%|Vj005J}`Hw&=0RYXHq~ibpyyzHQsFW8>#s~laM4*8xut5h5 z!4#~(4xGUqyucR%VFpA%3?#rj5JCpzfE)^;7?wd9RKPme1hudO8lVxH;SjXJF*pt9 z;1XPc>u?taU>Kgl7`%oF1VP9M6Ja4bh!J9r*dopd7nzO(B4J20l7OTj>4+3jBE`sZ zqynizYLQ(?Bl0bB6giDtK>Co|$RIL`{EECsF_eL_Q3KQhbwIhO9~z3rpmWi5G!I>X zmZEFX8nhlgfVQHi(M#xcbO3#dj$?q)F%D*o*1Pf{>6$SWH+$s3q(pv=X`qR|$iJF~TPzlc-O$C3+J1 z#CT#lv5;6stS0Uu9wDA3UMCI{Uz12A4#|?_P6{CkNG+sOq(0IRX`DyT~9-sA|ffUF>wk++Z!kWZ5P$;0Hg6gtI-;!FvmBvPc55=u2?Kjj3apE5$3psG>L zsh-pbs)#zDT1jo7c2F-(3)vyY4>O^>2$gY-Gd%Qm(Z8e zYv>2*=jns=cMJ`N4THx>VkjAF8G9M07`GWOnM|ey)0dgZR4~^v8<}UA514ONSSt1^ zd=-((5|uiYR+WC0=c-gyb5%dpd8!Lkt5pxHURHgkMpd&=fR^vEcAI*_=wwAG2sV%zY%w@v@XU~7=xdm1xY6*0;iwVIXu6TaXrs|dqbIl~ z?uTdNHFy_3W~^@g_pF#!K2~{F^;XxcN!DEJEbDF7 zS8PxlSDOr*I-AS3sI8l=#CDr)-xT5$k15hA^;2%zG3@;83hbKf2JJcaVfH2VZT8O{ z%p4LO);n}Nd~$Sk%yw*Wyz8XlG{dRHsl(}4XB%gsbDi@w7p6;)%MzD%mlsoQr;4X; zpL)xc%+^yMd)ZNTI#eJ*$O)i@o$z8)e??LqN_gLa_%;TM>o2SC_ zkmoO6c3xRt`@J4dvz#WL)-Y|z+r(Soy~}%GIzByR`p)SCKE^%*pL(B%zNWq+-#xw~ ze%5}Oeh2)X`#bu}{g3#+;d$~F@lFL`0l@*~0lk45fwKc^10MvL1f>Tx1&sx}1}_Xg z6+#RN4Ot&@lW)Km@*DYMGu&q^n$Z=?2%QyL8~QNJCQKgI5srq>2;UHXZ>IT7>CCnW zh~P(Th`1kV8JQRPeH1AwGO8}>QM6NZadh`A)~w`N`)9q5@sFvDxjWlxwsLl7tZHmh zY-8-3xPZ8-xPf?w_(k!T5_A(J3GIpG#Ms0=iQ{tu=WLoYoaCBRmULsT<=mpV7v|~C z%bs^USv6UZd^m-e5|^?+<%1wXP%juy<)>~<9TW0|n}ttBzM_qyQL(qUN<5P0omQ3h zINdvaL;7fjPeygdGYL;pD|wL_lDQ-EO;$wK-mK5raoH_7l$?~Dqf!lNmb5F^Ft;eT zPi8AClMUo~=55LwlZVRpxOiFd;3B_8yA~shQx|tGF!j;$toK>JuS&gYLDkTP@C~gS@r~shUu{a>bfJ1` z^^VQ7&C1OKHDNXFTgC{M|V%fo{xK_dk6MK@9S!GZ*1JJzrV5xZBjOk z9!NTH<(q(S+MDf~ceQX@Dh|Ry<-sT4rhI$jQ0Sq~!`#Eo-%($2E^vo}is5J@NVEf|KK?WT&2;PCq@=ncR8z zO#GQ^T~S@VXG71PKNocFOt)Y6$@AXlk6rM*aP%VgV%sIRORYVwJx6|U{ozQjTW{-S z_si{9Jg#)~P3t?+@6&(!YQWWV*Z9{iU7vZq@5byKw{9lg9JnRA_4s!7?H6|n?o8ZW zdXIRo{Jz@#>IeD{>VLHUv1Pz*;P_y`V9&!@5AO~Mho1hF|I>%z(nrik)gwkDjgOrl z9~%uCz4Bzvli{bbrxVZ0epdf^>vOB;-~HnIOV3#R*zgPai_gEVd8zYq@2jb=I>#f& zAH2?aJ@Kaet-A=E_D&uc3__ldcM(ExaQ?*T?GxJx0T??0T<)i5 zxTrhpHF1u^(xd>TlykdubC~eu!9dfL?)4du7Y)T;R!WBc%dOUipPJ>!h(By8W#s$5 z_M#9%`#rbIS%J$)0amZ7c<&ze$OgdeyL_B}08qcLE56~;FcGgbB_2@3mkP`Z$b)Ht z>q@Di+jmnhXZdDIJezX4ywY%tKO1A!0c#j@264vr57>VQRHjW)K%t#tnkGRIP^nZ9 zLSULE)9IASWCDQey3}g5M11B>>2|w`a~zhY%$?F`B*%Xq3^Yx#EQ@x#t=P*-$p+$L#NXLpw((AzQr0VO^F8-@udQ@0`g#5;JQ+3=r~U5 kt<807*qoM6N<$g7sq-^lnk5hS=4k__`PV-Ol@H(5E z00ciieB(X5tMqiitAp7JXBgPn*xD*Ls~i6L{rk7Qu(5X7bivdIn_Ax%m|bb@X^H8$ zY*utwa5cB_9E)VBY@Kv9_W$d3`wwSw kvah!}H^+#JO_71&4y)@69i^a$K;JTWy85}Sb4q9e0JKMJwEzGB diff --git a/cleanroom/src/main/resources/assets/distanthorizons/textures/jar/themeDark.svg b/cleanroom/src/main/resources/assets/distanthorizons/textures/jar/themeDark.svg deleted file mode 100644 index a4b041582..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/textures/jar/themeDark.svg +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - diff --git a/cleanroom/src/main/resources/assets/distanthorizons/textures/jar/themeLight.svg b/cleanroom/src/main/resources/assets/distanthorizons/textures/jar/themeLight.svg deleted file mode 100644 index 4864825d9..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/textures/jar/themeLight.svg +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/cleanroom/src/main/resources/assets/distanthorizons/textures/null.svg b/cleanroom/src/main/resources/assets/distanthorizons/textures/null.svg deleted file mode 100644 index 0a575ac81..000000000 --- a/cleanroom/src/main/resources/assets/distanthorizons/textures/null.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/cleanroom/src/main/resources/assets/distanthorizons/textures/test-grid.png b/cleanroom/src/main/resources/assets/distanthorizons/textures/test-grid.png deleted file mode 100644 index f5dde4aa3ae7e237e006d219ec70914b911e2df4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1103 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58CaNs)Vi3hp&(vykh>GZx^prwfgF}}M_)$< zhK>E)e-c@Ne6|3e5ZC|z{{xw!hc4FvDb50q$YKTtzJnmlxMO1WTLuQ^OP(%{Ar-gY z-esJ&Sb>M_!4tNVfAx2-&ERGf(un$9R(JpQ+=U50uQY7gpm%rQ#$B^x=JErLf`AXD z4HwQb{3>nu;Kl0n@%PULfhEhjl;Yx(JUG@6!!NL1G$(KuPeGHxD|Qcm#trNR=N*38?BP-{zu(&! z%ge?%L6!V0VuUcA<4-|@EQL0Zc8S7|O!;*-s73#{YVZs>1IV^?8Z z5SYLv@P0p!g{?fyrC?eirvns*VDR8P%Op9l&;%L*Tzy?+WEg1+B1lVn+V=B}=Kd&=z~js22b@tgs- z!%xQutY>~Sub{}I{MU+zcWh^#fl>k-T;sp9Uy%*YWnlPW%1{}+T{Ccvf`xR#bas*a z30%`%&#~QDdG`@-(9u-EU`A2v@g4As%B;VZU2nx?Df&jd-RkGcZI3Q{WHUNH z-t>O|KE^vM8#c+8{;T6MwQeL`{Fu4ZFpA5*+3KXy7+Awum>v6`(@09RBIr)Vo|VXc^+#~hd5 zVdc=vV8fLm|FE#_Nw9<0%{q^&=j`d zu7XeT>3eT2_JrG%>+b)V#kga0&-1+wjo}P`|3+&oq_w5I|9@|xbj!PcH@P_KMbD-- lq}jP0MGA^PU%xWD{AcjJd? 0; ---batch-- - --- re-downsample all LOD data -update FullData set ApplyToParent = 1; diff --git a/cleanroom/src/main/resources/sqlScripts/readme.md b/cleanroom/src/main/resources/sqlScripts/readme.md deleted file mode 100644 index 683e39c0f..000000000 --- a/cleanroom/src/main/resources/sqlScripts/readme.md +++ /dev/null @@ -1,51 +0,0 @@ - -### All Sql scripts should be run exactly once per database and old scripts shouldn't be changed. Any necessary schema changes should be done by creating new scripts that modify the existing database. - -This system is roughly based on the DbUp library from .NET, for information about DbUp and it's general philosophy please refer to the following doc: -https://dbup.readthedocs.io/en/latest/philosophy-behind-dbup/ - -
- -### Adding New Scripts: -New scripts must be added to the "scriptList.txt" file, otherwise they will not be run.
-(If anyone has a good way to automatically pull all resource files ending in `.sql` instead, please let us know.) - -
- -### File Naming: -- The first 3 numbers are major scripts. -- The 4th number is for minor/related scripts or if a bug fix needs to be applied between scripts. -- flavor of database the script is for (for now this is just sqlite) -- description of the script - -
- -### Mutli-query Scripts: -When creating a script with multiple queries the queries must be separated with the SQL comment `--batch--` otherwise only the first query will be executed. - -Example: -```roomsql -CREATE TABLE TableOne( - DhSectionPos TEXT NOT NULL PRIMARY KEY - ,Data BLOB NULL -); - ---batch-- - -CREATE TABLE TableTwo( - DhSectionPos TEXT NOT NULL PRIMARY KEY - ,Data BLOB NULL -); -``` - -### PRAGMA Auto Commits - -Certain queries will auto commit after running, specifically certain `PRAGMA` commands. In that case we have to disable DH's automatic transactions by putting `--No Transactions--` somewhere in the file. Otherwise, when the system attempts to commit, it will fail due to the PRAGMA having already committed itself. - -Due to how these commands work it's best to only have a single command in the file to prevent confusion and potential database corruption. - -```roomsql ---No Transactions-- - -PRAGMA journal_mode = TRUNCATE; -``` diff --git a/cleanroom/src/main/resources/sqlScripts/scriptList.txt b/cleanroom/src/main/resources/sqlScripts/scriptList.txt deleted file mode 100644 index b64a0d320..000000000 --- a/cleanroom/src/main/resources/sqlScripts/scriptList.txt +++ /dev/null @@ -1,12 +0,0 @@ - -0010-sqlite-createInitialDataTables.sql -0020-sqlite-createFullDataSourceV2Tables.sql -0030-sqlite-changeTableJournaling.sql -0031-sqlite-useSqliteWalJournaling.sql -0040-sqlite-removeRenderCache.sql -0050-sqlite-addApplyToParentIndex.sql -0060-sqlite-createChunkHashTable.sql -0070-sqlite-createBeaconBeamTable.sql -0080-sqlite-addApplyToChildrenColumn.sql -0090-sqlite-addAdjacentFullDataColumns.sql -0100-sqlite-deleteLowDetailDataForRegen.sql diff --git a/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java b/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java index 4ebc2491a..7aef99145 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java @@ -1,6 +1,5 @@ package com.seibel.distanthorizons.common; -import com.mojang.brigadier.CommandDispatcher; import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi; import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent; import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent; @@ -30,7 +29,6 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModAccesso import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker; import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector; import com.seibel.distanthorizons.coreapi.ModInfo; -import net.minecraft.commands.CommandSourceStack; import net.minecraft.server.MinecraftServer; import net.minecraft.server.dedicated.DedicatedServer; import com.seibel.distanthorizons.core.logging.DhLogger; @@ -39,6 +37,11 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import java.util.function.Supplier; +#if MC_VER > MC_1_12_2 +import com.mojang.brigadier.CommandDispatcher; +import net.minecraft.commands.CommandSourceStack; +#endif + /** * Base for all mod loader initializers * and handles most setup. @@ -62,7 +65,9 @@ public abstract class AbstractModInitializer protected abstract IEventProxy createServerProxy(boolean isDedicated); protected abstract void initializeModCompat(); + #if MC_VER > MC_1_12_2 protected abstract void subscribeRegisterCommandsEvent(Consumer> eventHandler); + #endif protected abstract void subscribeClientStartedEvent(Runnable eventHandler); protected abstract void subscribeServerStartingEvent(Consumer eventHandler); @@ -130,8 +135,10 @@ public abstract class AbstractModInitializer this.initializeModCompat(); LOGGER.info(ModInfo.READABLE_NAME + " server Initialized, adding event subscribers..."); + #if MC_VER > MC_1_12_2 this.commandInitializer = new CommandInitializer(); this.subscribeRegisterCommandsEvent(dispatcher -> { this.commandInitializer.initCommands(dispatcher); }); + #endif this.subscribeServerStartingEvent(server -> { @@ -141,11 +148,13 @@ public abstract class AbstractModInitializer Initializer.postConfigInit(); this.postInit(); this.postServerInit(); + #if MC_VER > MC_1_12_2 this.commandInitializer.onServerReady(); + #endif this.checkForUpdates(); - LOGGER.info(ModInfo.READABLE_NAME + " server Initialized at " + server.getServerDirectory()); + LOGGER.info(ModInfo.READABLE_NAME + " server Initialized at " + server.#if MC_VER <= MC_1_12_2 getDataDirectory() #else getServerDirectory() #endif); }); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java index 4f04819d0..3cbed11c8 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java @@ -6,15 +6,20 @@ import com.seibel.distanthorizons.core.api.internal.ServerApi; import com.seibel.distanthorizons.core.api.internal.SharedApi; import com.seibel.distanthorizons.core.pos.DhChunkPos; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper; +#if MC_VER <= MC_1_12_2 +import net.minecraft.world.WorldServer; +import net.minecraft.world.chunk.Chunk; +#else import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ProtoChunk; +#endif import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; public class MixinChunkMapCommon { - public static void onChunkSave(ServerLevel level, ChunkAccess chunk, CallbackInfoReturnable ci) + public static void onChunkSave(#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif level, #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk #if MC_VER > MC_1_12_2, CallbackInfoReturnable ci #endif) { IServerLevelWrapper levelWrapper = ServerLevelWrapper.getWrapper(level); @@ -37,7 +42,7 @@ public class MixinChunkMapCommon // is this chunk being saved to disk? - boolean savingChunkToDisk = ci.getReturnValue(); + boolean savingChunkToDisk = #if MC_VER <= MC_1_12_2 true #else ci.getReturnValue() #endif; // true means a chunk was saved to disk if (!savingChunkToDisk) { @@ -50,7 +55,12 @@ public class MixinChunkMapCommon // MC has a tendency to try saving incomplete or corrupted chunks (which show up as empty or black chunks) // this logic should prevent that from happening - #if MC_VER <= MC_1_17_1 + #if MC_VER <= MC_1_12_2 + if (!chunk.isTerrainPopulated() || !chunk.isLightPopulated()) + { + return; + } + #elif MC_VER <= MC_1_17_1 if (chunk.isUnsaved() || chunk.getUpgradeData() != null || !chunk.isLightCorrect()) { return; @@ -68,7 +78,7 @@ public class MixinChunkMapCommon // some chunks may be missing their biomes, which cause issues when attempting to save them #if MC_VER <= MC_1_17_1 - if (chunk.getBiomes() == null) + if (chunk.#if MC_VER <= MC_1_12_2 getBiomeArray() #else getBiomes() #endif == null) { return; } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java index fc4938e28..cc8538f2f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java @@ -9,24 +9,23 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftCli import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; +#if MC_VER <= MC_1_12_2 +#else +import net.minecraft.client.Camera; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +#endif + +#if MC_VER <= MC_1_12_2 import net.minecraft.client.Minecraft; -import net.minecraft.client.Camera; -import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; - - -import net.minecraft.client.Camera; -import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; - -#if MC_VER < MC_1_17_1 +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.init.MobEffects; +#elif MC_VER < MC_1_17_1 import net.minecraft.world.level.material.FluidState; import net.minecraft.client.renderer.FogRenderer; import net.minecraft.client.renderer.FogRenderer.FogMode; import com.mojang.blaze3d.systems.RenderSystem; - import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; #elif MC_VER < MC_1_21_3 @@ -57,16 +56,18 @@ import net.minecraft.world.level.material.FogType; public class MixinVanillaFogCommon { - - #if MC_VER < MC_1_21_6 + #if MC_VER <= MC_1_12_2 + public static boolean cancelFog(int startCoords, Minecraft mc) + #elif MC_VER < MC_1_21_6 public static boolean cancelFog(Camera camera, FogRenderer.FogMode fogMode) #else public static boolean cancelFog() #endif { - - #if MC_VER < MC_1_21_6 + #if MC_VER <= MC_1_12_2 + EntityPlayerSP entity = mc.player; + #elif MC_VER < MC_1_21_6 Entity entity = camera.getEntity(); #elif MC_VER <= MC_1_21_10 Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera(); @@ -77,12 +78,18 @@ public class MixinVanillaFogCommon #endif - boolean cameraNotInFluid = cameraNotInFluid(camera); + boolean cameraNotInFluid = cameraNotInFluid(mc); + #if MC_VER <= MC_1_12_2 + boolean isSpecialFog = entity.isPotionActive(MobEffects.BLINDNESS); + #else boolean isSpecialFog = (entity instanceof LivingEntity) && ((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS); + #endif boolean cancelFog = !isSpecialFog; cancelFog = cancelFog && cameraNotInFluid; - #if MC_VER < MC_1_21_6 + #if MC_VER <= MC_1_12_2 + cancelFog = cancelFog && startCoords == 0; + #elif MC_VER < MC_1_21_6 cancelFog = cancelFog && (fogMode == FogRenderer.FogMode.FOG_TERRAIN); #endif @@ -92,10 +99,15 @@ public class MixinVanillaFogCommon return cancelFog; } - + #if MC_VER <= MC_1_12_2 + private static boolean cameraNotInFluid(Minecraft mc) + #else private static boolean cameraNotInFluid(Camera camera) + #endif { - #if MC_VER < MC_1_17_1 + #if MC_VER <= MC_1_12_2 + boolean cameraNotInFluid = mc.getRenderViewEntity() != null && !mc.world.getBlockState(mc.getRenderViewEntity().getPosition()).getMaterial().isLiquid(); + #elif MC_VER < MC_1_17_1 FluidState fluidState = camera.getFluidInCamera(); boolean cameraNotInFluid = fluidState.isEmpty(); #else @@ -105,6 +117,4 @@ public class MixinVanillaFogCommon return cameraNotInFluid; } - - } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java index 0d557f2df..5106c5e37 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java @@ -28,12 +28,15 @@ import java.util.concurrent.ConcurrentMap; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; -import net.minecraft.world.level.Level; import com.seibel.distanthorizons.core.logging.DhLogger; - import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper; -#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 +#if MC_VER > MC_1_12_2 +import net.minecraft.world.level.Level; +#endif + +#if MC_VER <= MC_1_12_2 +#elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 import net.minecraft.core.Registry; #elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2 import net.minecraft.core.Holder; @@ -45,14 +48,21 @@ import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; #endif -#if MC_VER <= MC_1_21_10 +#if MC_VER <= MC_1_12_2 +import net.minecraft.util.ResourceLocation; +#elif MC_VER <= MC_1_21_10 import net.minecraft.resources.ResourceLocation; #else import net.minecraft.resources.Identifier; import net.minecraft.core.component.DataComponentMap; #endif +#if MC_VER <= MC_1_12_2 +import net.minecraft.world.biome.Biome; +#else import net.minecraft.world.level.biome.Biome; +#endif + #if MC_VER >= MC_1_18_2 import net.minecraft.world.level.biome.Biomes; @@ -219,8 +229,10 @@ public class BiomeWrapper implements IBiomeWrapper // generate the serial string // + #if MC_VER > MC_1_12_2 Level level = (Level)levelWrapper.getWrappedMcObject(); net.minecraft.core.RegistryAccess registryAccess = level.registryAccess(); + #endif #if MC_VER <= MC_1_21_10 ResourceLocation resourceLocation; @@ -228,7 +240,9 @@ public class BiomeWrapper implements IBiomeWrapper Identifier resourceLocation; #endif - #if MC_VER <= MC_1_17_1 + #if MC_VER <= MC_1_12_2 + resourceLocation = biome.getRegistryName(); + #elif MC_VER <= MC_1_17_1 resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome); #elif MC_VER <= MC_1_19_2 resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome.value()); @@ -293,10 +307,13 @@ public class BiomeWrapper implements IBiomeWrapper { try { + #if MC_VER > MC_1_12_2 Level level = (Level) levelWrapper.getWrappedMcObject(); net.minecraft.core.RegistryAccess registryAccess = level.registryAccess(); + #endif + - BiomeDeserializeResult deserializeResult = deserializeBiome(resourceLocationString, registryAccess); + BiomeDeserializeResult deserializeResult = deserializeBiome(resourceLocationString #if MC_VER > MC_1_12_2, registryAccess #endif); @@ -325,7 +342,7 @@ public class BiomeWrapper implements IBiomeWrapper } } - public static BiomeDeserializeResult deserializeBiome(String resourceLocationString, net.minecraft.core.RegistryAccess registryAccess) throws IOException + public static BiomeDeserializeResult deserializeBiome(String resourceLocationString #if MC_VER > MC_1_12_2, net.minecraft.core.RegistryAccess registryAccess #endif) throws IOException { // parse the resource location int separatorIndex = resourceLocationString.indexOf(":"); @@ -356,7 +373,10 @@ public class BiomeWrapper implements IBiomeWrapper boolean success; - #if MC_VER <= MC_1_17_1 + #if MC_VER == MC_1_12_2 + Biome biome = Biome.REGISTRY.getObject(resourceLocation); + success = (biome != null); + #elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 Biome biome = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).get(resourceLocation); success = (biome != null); #elif MC_VER <= MC_1_19_2 diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index f20398970..931962d56 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -32,12 +32,23 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrappe import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; +#if MC_VER <= MC_1_12_2 +import net.minecraft.block.Block; +import net.minecraft.block.BlockLeaves; +import net.minecraft.block.SoundType; +import net.minecraft.init.Blocks; +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.state.IBlockState; +import net.minecraft.block.properties.IProperty; +import net.minecraftforge.fluids.IFluidBlock; +#else import net.minecraft.tags.BlockTags; import net.minecraft.world.level.block.BeaconBeamBlock; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; +#endif import com.seibel.distanthorizons.core.logging.DhLogger; import java.awt.*; @@ -61,7 +72,7 @@ import net.minecraft.world.level.Level; import net.minecraft.core.BlockPos; import net.minecraft.core.Registry; import net.minecraft.world.level.EmptyBlockGetter; -#else +#elif MC_VER > MC_1_12_2 import net.minecraft.tags.TagKey; import net.minecraft.world.level.Level; import net.minecraft.core.BlockPos; @@ -70,12 +81,15 @@ import net.minecraft.world.level.EmptyBlockGetter; import net.minecraft.core.Holder; #endif -#if MC_VER <= MC_1_21_10 +#if MC_VER <= MC_1_12_2 +import net.minecraft.util.ResourceLocation; +#elif MC_VER <= MC_1_21_10 import net.minecraft.resources.ResourceLocation; #else import net.minecraft.resources.Identifier; #endif + public class BlockStateWrapper implements IBlockStateWrapper { /** example "minecraft:water" */ @@ -87,7 +101,7 @@ public class BlockStateWrapper implements IBlockStateWrapper // must be defined before AIR, otherwise a null pointer will be thrown private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - public static final ConcurrentHashMap WRAPPER_BY_BLOCK_STATE = new ConcurrentHashMap<>(); + public static final ConcurrentHashMap<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, BlockStateWrapper> WRAPPER_BY_BLOCK_STATE = new ConcurrentHashMap<>(); public static final ConcurrentHashMap WRAPPER_BY_RESOURCE_LOCATION = new ConcurrentHashMap<>(); public static final String AIR_STRING = "AIR"; @@ -114,7 +128,7 @@ public class BlockStateWrapper implements IBlockStateWrapper // properties // @Nullable - public final BlockState blockState; + public final #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState; /** technically final, but since it requires a method call to generate it can't be marked as such */ private String serialString; private final int hashCode; @@ -139,15 +153,21 @@ public class BlockStateWrapper implements IBlockStateWrapper // constructors // //==============// //region - + #if MC_VER <= MC_1_12_2 + /** + * Can be faster than {@link BlockStateWrapper#fromBlockState(IBlockState, ILevelWrapper)} + * in cases where the same block state is expected to be referenced multiple times. + */ + #else /** * Can be faster than {@link BlockStateWrapper#fromBlockState(BlockState, ILevelWrapper)} * in cases where the same block state is expected to be referenced multiple times. */ - public static BlockStateWrapper fromBlockState(BlockState blockState, ILevelWrapper levelWrapper, IBlockStateWrapper guess) + #endif + public static BlockStateWrapper fromBlockState(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, ILevelWrapper levelWrapper, IBlockStateWrapper guess) { - BlockState guessBlockState = (guess == null || guess.isAir()) ? null : (BlockState) guess.getWrappedMcObject(); - BlockState inputBlockState = (blockState == null || blockState.isAir()) ? null : blockState; + #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif guessBlockState = (guess == null || guess.isAir()) ? null : (#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif) guess.getWrappedMcObject(); + #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif inputBlockState = (blockState == null || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.AIR #else blockState.isAir() #endif) ? null : blockState; if (guess instanceof BlockStateWrapper && guessBlockState == inputBlockState) @@ -159,7 +179,7 @@ public class BlockStateWrapper implements IBlockStateWrapper return fromBlockState(blockState, levelWrapper); } } - public static BlockStateWrapper fromBlockState(@Nullable BlockState blockState, ILevelWrapper levelWrapper) + public static BlockStateWrapper fromBlockState(@Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, ILevelWrapper levelWrapper) { // air is a special case if (isAir(blockState)) @@ -209,7 +229,7 @@ public class BlockStateWrapper implements IBlockStateWrapper } } private BlockStateWrapper( - @Nullable BlockState blockState, ILevelWrapper levelWrapper, + @Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, ILevelWrapper levelWrapper, @Nullable DhApiBlockStateWrapperCreatedEvent.EventParam overrideEventParam) { this.blockState = blockState; @@ -228,10 +248,12 @@ public class BlockStateWrapper implements IBlockStateWrapper } else { - #if MC_VER < MC_1_20_1 + #if MC_VER <= MC_1_12_2 + this.isLiquid = this.blockState.getMaterial().isLiquid() || this.blockState.getBlock() instanceof IFluidBlock; + #elif MC_VER < MC_1_20_1 this.isLiquid = this.blockState.getMaterial().isLiquid() || !this.blockState.getFluidState().isEmpty(); #else - this.isLiquid = !this.blockState.getFluidState().isEmpty(); + this.isLiquid = !this.blockState.getFluidState().isEmpty(); #endif } } @@ -327,6 +349,8 @@ public class BlockStateWrapper implements IBlockStateWrapper // beacon tint color Color beaconTintColor = null; + // 1.12.2 doesn't have block for beacon beam + #if MC_VER > MC_1_12_2 if (this.blockState != null // beacon blocks also show up here, but since they block the beacon beam we don't want their color && !this.isBeaconBlock) @@ -344,6 +368,7 @@ public class BlockStateWrapper implements IBlockStateWrapper beaconTintColor = ColorUtil.toColorObjRGB(colorInt); } } + #endif this.beaconTintColor = beaconTintColor; @@ -392,8 +417,10 @@ public class BlockStateWrapper implements IBlockStateWrapper if (this.blockState != null) { int mcColor = 0; - - #if MC_VER < MC_1_20_1 + + #if MC_VER <= MC_1_12_2 + mcColor = this.blockState.getMaterial().getMaterialMapColor().colorValue; + #elif MC_VER < MC_1_20_1 mcColor = this.blockState.getMaterial().getColor().col; #else mcColor = this.blockState.getMapColor(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).col; @@ -420,7 +447,7 @@ public class BlockStateWrapper implements IBlockStateWrapper #if MC_VER < MC_1_20_1 this.isSolid = this.blockState.getMaterial().isSolid(); #else - this.isSolid = !this.blockState.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).isEmpty(); + this.isSolid = !this.blockState.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).isEmpty(); #endif } } @@ -432,7 +459,7 @@ public class BlockStateWrapper implements IBlockStateWrapper //region private static EDhApiBlockMaterial calculateEDhApiBlockMaterialId( - @Nullable BlockState blockState, + @Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, String lowercaseSerialString, boolean isLiquid ) @@ -443,7 +470,7 @@ public class BlockStateWrapper implements IBlockStateWrapper } - if (blockState.is(BlockTags.LEAVES) + if (#if MC_VER <= MC_1_12_2 blockState.getBlock() instanceof BlockLeaves #else blockState.is(BlockTags.LEAVES) #endif || lowercaseSerialString.contains("bamboo") || lowercaseSerialString.contains("cactus") || lowercaseSerialString.contains("chorus_flower") @@ -452,16 +479,15 @@ public class BlockStateWrapper implements IBlockStateWrapper { return EDhApiBlockMaterial.LEAVES; } - else if (blockState.is(Blocks.LAVA)) + else if (#if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.LAVA || blockState.getBlock() == Blocks.FLOWING_LAVA #else blockState.is(Blocks.LAVA) #endif) { return EDhApiBlockMaterial.LAVA; } - else if (isLiquid - || blockState.is(Blocks.WATER)) + else if (isLiquid || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.WATER || blockState.getBlock() == Blocks.FLOWING_WATER #else this.blockState.is(Blocks.WATER) #endif) { return EDhApiBlockMaterial.WATER; } - else if (blockState.getSoundType() == SoundType.WOOD + else if (#if MC_VER <= MC_1_12_2 blockState.getBlock().getSoundType() #else blockState.getSoundType() #endif == SoundType.WOOD || lowercaseSerialString.contains("root") #if MC_VER >= MC_1_19_4 || blockState.getSoundType() == SoundType.CHERRY_WOOD @@ -470,7 +496,7 @@ public class BlockStateWrapper implements IBlockStateWrapper { return EDhApiBlockMaterial.WOOD; } - else if (blockState.getSoundType() == SoundType.METAL + else if (#if MC_VER <= MC_1_12_2 blockState.getBlock().getSoundType() #else blockState.getSoundType() #endif == SoundType.METAL #if MC_VER >= MC_1_19_2 || blockState.getSoundType() == SoundType.COPPER #endif @@ -521,7 +547,7 @@ public class BlockStateWrapper implements IBlockStateWrapper { return EDhApiBlockMaterial.TERRACOTTA; } - else if (blockState.is(BlockTags.BASE_STONE_NETHER)) + else if (#if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.NETHERRACK #else blockState.is(BlockTags.BASE_STONE_NETHER) #endif) { return EDhApiBlockMaterial.NETHER_STONE; } @@ -530,7 +556,7 @@ public class BlockStateWrapper implements IBlockStateWrapper { return EDhApiBlockMaterial.STONE; } - else if (blockState.getLightEmission() > 0) + else if (#if MC_VER <= MC_1_12_2 blockState.getLightValue() #else blockState.getLightEmission() #endif > 0) { return EDhApiBlockMaterial.ILLUMINATED; } @@ -541,7 +567,7 @@ public class BlockStateWrapper implements IBlockStateWrapper } private static int calculateOpacity( - @Nullable BlockState blockState, + @Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, boolean isAir, boolean isLiquid ) { @@ -582,24 +608,30 @@ public class BlockStateWrapper implements IBlockStateWrapper return opacity; } - private static boolean getCanOcclude(@Nullable BlockState blockState) + private static boolean getCanOcclude(@Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState) { // defaults to the value used by air boolean canOcclude = false; if (blockState != null) { + #if MC_VER <= MC_1_12_2 + canOcclude = blockState.isOpaqueCube(); + #else canOcclude = blockState.canOcclude(); + #endif } return canOcclude; } - private static boolean getPropagatesSkyLightDown(@Nullable BlockState blockState) + private static boolean getPropagatesSkyLightDown(@Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState) { // defaults to the value used by air boolean propagatesSkyLightDown = true; if (blockState != null) { - #if MC_VER < MC_1_21_3 + #if MC_VER <= MC_1_12_2 + propagatesSkyLightDown = blockState.getBlock().getLightOpacity(blockState) == 0; + #elif MC_VER < MC_1_21_3 propagatesSkyLightDown = blockState.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO); #else propagatesSkyLightDown = blockState.propagatesSkylightDown(); @@ -740,8 +772,12 @@ public class BlockStateWrapper implements IBlockStateWrapper if (defaultBlockStateToIgnore != AIR) { // add all possible blockstates (to account for light blocks with different light values and such) + #if MC_VER <= MC_1_12_2 + List blockStatesToIgnore = defaultBlockStateToIgnore.blockState.getBlock().getBlockState().getValidStates(); + #else List blockStatesToIgnore = defaultBlockStateToIgnore.blockState.getBlock().getStateDefinition().getPossibleStates(); - for (BlockState blockState : blockStatesToIgnore) + #endif + for (#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState : blockStatesToIgnore) { BlockStateWrapper newBlockToIgnore = fromBlockState(blockState, levelWrapper); blockStateWrappers.add(newBlockToIgnore); @@ -788,7 +824,7 @@ public class BlockStateWrapper implements IBlockStateWrapper public int getOpacity() { return this.opacity; } @Override - public int getLightEmission() { return (this.blockState != null) ? this.blockState.getLightEmission() : 0; } + public int getLightEmission() { return (this.blockState != null) ? #if MC_VER <= MC_1_12_2 this.blockState.getLightValue() #else this.blockState.getLightEmission() #endif : 0; } @Override public String getSerialString() { return this.serialString; } @@ -798,7 +834,7 @@ public class BlockStateWrapper implements IBlockStateWrapper @Override public boolean isAir() { return isAir(this.blockState); } - public static boolean isAir(BlockState blockState) { return blockState == null || blockState.isAir(); } + public static boolean isAir(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState) { return blockState == null || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.AIR #else blockState.isAir() #endif; } @Override public boolean isSolid() { return this.isSolid; } @@ -832,7 +868,7 @@ public class BlockStateWrapper implements IBlockStateWrapper //=======================// //region - private static String serialize(BlockState blockState, ILevelWrapper levelWrapper) + private static String serialize(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, ILevelWrapper levelWrapper) { if (blockState == null) { @@ -854,7 +890,9 @@ public class BlockStateWrapper implements IBlockStateWrapper Identifier resourceLocation; #endif - #if MC_VER <= MC_1_17_1 + #if MC_VER <= MC_1_12_2 + resourceLocation = blockState.getBlock().getRegistryName(); + #elif MC_VER <= MC_1_17_1 resourceLocation = Registry.BLOCK.getKey(blockState.getBlock()); #elif MC_VER <= MC_1_19_2 resourceLocation = registryAccess.registryOrThrow(Registry.BLOCK_REGISTRY).getKey(blockState.getBlock()); @@ -953,7 +991,9 @@ public class BlockStateWrapper implements IBlockStateWrapper #endif Block block; - #if MC_VER <= MC_1_17_1 + #if MC_VER <= MC_1_12_2 + block = Block.REGISTRY.getObject(resourceLocation); + #elif MC_VER <= MC_1_17_1 block = Registry.BLOCK.get(resourceLocation); #elif MC_VER <= MC_1_19_2 net.minecraft.core.RegistryAccess registryAccess = level.registryAccess(); @@ -982,11 +1022,15 @@ public class BlockStateWrapper implements IBlockStateWrapper // attempt to find the blockstate from all possibilities - BlockState foundState = null; + #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif foundState = null; if (blockStatePropertiesString != null) { + #if MC_VER <= MC_1_12_2 + List possibleStateList = block.getBlockState().getValidStates(); + #else List possibleStateList = block.getStateDefinition().getPossibleStates(); - for (BlockState possibleState : possibleStateList) + #endif + for (#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif possibleState : possibleStateList) { String possibleStatePropertiesString = serializeBlockStateProperties(possibleState); if (possibleStatePropertiesString.equals(blockStatePropertiesString)) @@ -1010,7 +1054,7 @@ public class BlockStateWrapper implements IBlockStateWrapper } } - foundState = block.defaultBlockState(); + foundState = #if MC_VER <= MC_1_12_2 block.getDefaultState() #else block.defaultBlockState() #endif; } foundWrapper = fromBlockState(foundState, levelWrapper); @@ -1035,26 +1079,35 @@ public class BlockStateWrapper implements IBlockStateWrapper } /** used to compare and save BlockStates based on their properties */ - private static String serializeBlockStateProperties(BlockState blockState) + private static String serializeBlockStateProperties(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState) { // get the property list for this block (doesn't contain this block state's values, just the names and possible values) - java.util.Collection> blockPropertyCollection = blockState.getProperties(); + #if MC_VER <= MC_1_12_2 + java.util.Collection> blockPropertyCollection = blockState.getPropertyKeys(); + #else + java.util.Collection> blockPropertyCollection = blockState.getProperties();; + #endif // alphabetically sort the list so they are always in the same order - List> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection); + List<#if MC_VER <= MC_1_12_2 IProperty #else Property #endif> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection); sortedBlockPropteryList.sort((a, b) -> a.getName().compareTo(b.getName())); StringBuilder stringBuilder = new StringBuilder(); - for (net.minecraft.world.level.block.state.properties.Property property : sortedBlockPropteryList) + for (#if MC_VER <= MC_1_12_2 IProperty #else Property #endif property : sortedBlockPropteryList) { String propertyName = property.getName(); String value = "NULL"; + + #if MC_VER <= MC_1_12_2 + value = blockState.getValue(property).toString(); + #else if (blockState.hasProperty(property)) { value = blockState.getValue(property).toString(); } + #endif stringBuilder.append("{"); stringBuilder.append(propertyName).append(RESOURCE_LOCATION_SEPARATOR).append(value); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java index 20a42bb75..e6dee44e9 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java @@ -32,22 +32,30 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapp import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +#if MC_VER <= MC_1_12_2 +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.util.EnumFacing; +import net.minecraft.block.BlockRotatedPillar; +import net.minecraft.block.*; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.renderer.color.BlockColors; +import net.minecraft.util.math.BlockPos; +#else import net.minecraft.core.Direction; import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.state.BlockState; -import com.seibel.distanthorizons.core.logging.DhLogger; import net.minecraft.world.level.block.state.properties.SlabType; +#endif +import com.seibel.distanthorizons.core.logging.DhLogger; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; +import java.util.*; import java.util.concurrent.locks.ReentrantLock; #if MC_VER >= MC_1_19_2 import net.minecraft.util.RandomSource; #else -import java.util.Random; #endif #if MC_VER < MC_1_21_5 @@ -62,6 +70,15 @@ import net.minecraft.core.BlockPos; import net.minecraft.client.color.block.BlockTintSource; #endif +#if MC_VER <= MC_1_12_2 +/** + * This stores and calculates the colors + * the given {@link IBlockState} should have based + * on the given {@link IClientLevelWrapper}. + * + * @see ColorUtil + */ +#else /** * This stores and calculates the colors * the given {@link BlockState} should have based @@ -69,14 +86,15 @@ import net.minecraft.client.color.block.BlockTintSource; * * @see ColorUtil */ + #endif public class ClientBlockStateColorCache { private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - private static final Minecraft MC = Minecraft.getInstance(); + private static final Minecraft MC = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif; - private static final HashSet BLOCK_STATES_THAT_NEED_LEVEL = new HashSet<>(); - private static final HashSet BROKEN_BLOCK_STATES = new HashSet<>(); + private static final HashSet<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif> BLOCK_STATES_THAT_NEED_LEVEL = new HashSet<>(); + private static final HashSet<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif> BROKEN_BLOCK_STATES = new HashSet<>(); /** * Methods using MC's "RandomSource" object aren't thread safe
@@ -90,15 +108,15 @@ public class ClientBlockStateColorCache /** This is the order each direction on a block is processed when attempting to get the texture/color */ - private static final @Nullable Direction[] COLOR_RESOLUTION_DIRECTION_ORDER = - { - Direction.UP, + private static final @Nullable #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif[] COLOR_RESOLUTION_DIRECTION_ORDER = + { + #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.UP, null, // null represents "unculled" faces, IE the top of farmland - Direction.NORTH, - Direction.EAST, - Direction.WEST, - Direction.SOUTH, - Direction.DOWN + #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.NORTH, + #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.EAST, + #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.WEST, + #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.SOUTH, + #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.DOWN }; private static final int FLOWER_COLOR_SCALE = 5; @@ -113,7 +131,7 @@ public class ClientBlockStateColorCache #endif private final IClientLevelWrapper clientLevelWrapper; - private final BlockState blockState; + private final #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState; private final BlockStateWrapper blockStateWrapper; private boolean isColorResolved = false; @@ -191,8 +209,10 @@ public class ClientBlockStateColorCache }; // these are threadlocals since AbstractDhTintGetter use local variables to handle color queries + #if MC_VER > MC_1_12_2 private static final ThreadLocal TintWithoutLevelOverrideGetter = ThreadLocal.withInitial(TintWithoutLevelOverrider::new); private static final ThreadLocal TintOverrideGetter = ThreadLocal.withInitial(TintGetterOverride::new); + #endif private static final ThreadLocal ColorOverrideEventParamGetter = ThreadLocal.withInitial(DhApiBlockColorOverrideEvent.EventParam::new); //endregion @@ -204,7 +224,7 @@ public class ClientBlockStateColorCache //=============// //region - public ClientBlockStateColorCache(BlockState blockState, IClientLevelWrapper clientLevelWrapper) + public ClientBlockStateColorCache(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, IClientLevelWrapper clientLevelWrapper) { this.blockState = blockState; this.blockStateWrapper = BlockStateWrapper.fromBlockState(blockState, clientLevelWrapper); @@ -232,18 +252,26 @@ public class ClientBlockStateColorCache { // getQuads() isn't thread safe so we need to put this logic in a lock RESOLVE_LOCK.lock(); - + #if MC_VER <= MC_1_12_2 + if (this.blockState.getMaterial().isLiquid()) + #else if (this.blockState.getFluidState().isEmpty()) + #endif { // look for the first non-empty direction List quads = null; - for (Direction direction : COLOR_RESOLUTION_DIRECTION_ORDER) + for (#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif direction : COLOR_RESOLUTION_DIRECTION_ORDER) { quads = this.getQuadsForDirection(direction); if (quads != null && !quads.isEmpty() && !( + #if MC_VER <= MC_1_12_2 + this.blockState.getBlock() instanceof BlockRotatedPillar + && direction == EnumFacing.UP + #else this.blockState.getBlock() instanceof RotatedPillarBlock && direction == Direction.UP + #endif ) ) { @@ -263,8 +291,10 @@ public class ClientBlockStateColorCache try { BakedQuad firstQuad = quads.get(0); - - #if MC_VER <= MC_1_21_11 + + #if MC_VER <= MC_1_12_2 + this.needPostTinting = firstQuad.hasTintIndex(); + #elif MC_VER <= MC_1_21_11 this.needPostTinting = firstQuad.isTinted(); #else this.needPostTinting = firstQuad.materialInfo().isTinted(); @@ -278,7 +308,7 @@ public class ClientBlockStateColorCache this.tintIndex = firstQuad.materialInfo().tintIndex(); #endif - #if MC_VER < MC_1_17_1 + #if MC_VER < MC_1_17_1 && MC_VER > MC_1_12_2 this.baseColor = calculateColorFromTexture( firstQuad.sprite, EColorMode.getColorMode(this.blockState.getBlock())); @@ -338,20 +368,35 @@ public class ClientBlockStateColorCache @Nullable private List getUnculledQuads() { return this.getQuadsForDirection(null); } @Nullable - private List getQuadsForDirection(@Nullable Direction direction) + private List getQuadsForDirection(@Nullable #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif direction) { - BlockState effectiveBlockState = this.blockState; + #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif effectiveBlockState = this.blockState; // if this block is a slab, use it's double variant so we can get the top face, // otherwise the color will use the side, which isn't as accurate + #if MC_VER <= MC_1_12_2 + if (this.blockState.getBlock() instanceof BlockSlab && !((BlockSlab) this.blockState.getBlock()).isDouble()) + { + effectiveBlockState = this.blockState.withProperty(BlockSlab.HALF, BlockSlab.EnumBlockHalf.TOP); + } + #else if (this.blockState.getBlock() instanceof SlabBlock) { effectiveBlockState = this.blockState.setValue( SlabBlock.TYPE, SlabType.DOUBLE ); } + #endif List quads; - #if MC_VER < MC_1_21_5 + #if MC_VER <= MC_1_12_2 + try { + quads = MC.getBlockRendererDispatcher().getModelForState(effectiveBlockState).getQuads(effectiveBlockState, direction, RANDOM.nextLong()); + } + catch (Exception e) + { + quads = Collections.emptyList(); + } + #elif MC_VER < MC_1_21_5 quads = MC.getModelManager().getBlockModelShaper(). getBlockModel(effectiveBlockState).getQuads(effectiveBlockState, direction, RANDOM); #elif MC_VER <= MC_1_21_11 @@ -408,10 +453,18 @@ public class ClientBlockStateColorCache //_ OpenGL RGBA format Java Order: 0xAA BB GG RR tempColor = TextureAtlasSpriteWrapper.getPixelRGBA(texture, 0, u, v); + #if MC_VER <= MC_1_12_2 + int b = (tempColor & 0x000000FF); + int g = (tempColor & 0x0000FF00) >>> 8; + int r = (tempColor & 0x00FF0000) >>> 16; + int a = (tempColor & 0xFF000000) >>> 24; + #else int r = (tempColor & 0x000000FF); int g = (tempColor & 0x0000FF00) >>> 8; int b = (tempColor & 0x00FF0000) >>> 16; int a = (tempColor & 0xFF000000) >>> 24; + #endif + int scale = 1; if (colorMode == EColorMode.Leaves) { @@ -468,7 +521,9 @@ public class ClientBlockStateColorCache } private static int getTextureWidth(TextureAtlasSprite texture) { - #if MC_VER < MC_1_19_4 + #if MC_VER <= MC_1_12_2 + return texture.getIconWidth(); + #elif MC_VER < MC_1_19_4 return texture.getWidth(); #else return texture.contents().width(); @@ -476,7 +531,9 @@ public class ClientBlockStateColorCache } private static int getTextureHeight(TextureAtlasSprite texture) { - #if MC_VER < MC_1_19_4 + #if MC_VER <= MC_1_12_2 + return texture.getIconHeight(); + #elif MC_VER < MC_1_19_4 return texture.getHeight(); #else return texture.contents().height(); @@ -510,7 +567,9 @@ public class ClientBlockStateColorCache private int getParticleIconColor() { return calculateColorFromTexture( - #if MC_VER <= MC_1_21_11 + #if MC_VER <= MC_1_12_2 + Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(this.blockState), + #elif MC_VER <= MC_1_21_11 Minecraft.getInstance().getModelManager().getBlockModelShaper().getParticleIcon(this.blockState), #else Minecraft.getInstance().getModelManager().getBlockStateModelSet().get(this.blockState).particleMaterial().sprite(), @@ -527,7 +586,12 @@ public class ClientBlockStateColorCache public int getColor(BiomeWrapper biomeWrapper, FullDataSourceV2 fullDataSource, DhBlockPos blockPos) { // only get the tint if the block needs to be tinted + #if MC_VER <= MC_1_12_2 + int tintColor = -1; + #else int tintColor = AbstractDhTintGetter.INVALID_COLOR; + #endif + if (this.needPostTinting) { // don't try tinting blocks that don't support our method of tint getting @@ -540,11 +604,44 @@ public class ClientBlockStateColorCache // attempt to get the tint try { + #if MC_VER <= MC_1_12_2 + // 1.12.2 doesn't have BlockAndTintGetter -> get tintColor from biome + WorldClient world = (WorldClient) this.clientLevelWrapper.getWrappedMcObject(); + BlockPos mcPos = new BlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + Block block = this.blockState.getBlock(); + if (block instanceof BlockGrass || block instanceof BlockBush) + { + tintColor = biomeWrapper.biome.getGrassColorAtPos(mcPos); + } + else if (block instanceof BlockLeaves) + { + tintColor = biomeWrapper.biome.getFoliageColorAtPos(mcPos); + } + else if (block instanceof BlockLiquid) // We don't want lava to fall into the else block + { + if(block == Blocks.WATER || block == Blocks.FLOWING_WATER) + { + tintColor = biomeWrapper.biome.getWaterColor(); + } + } + else + { + BlockColors blockColors = Minecraft.getMinecraft().getBlockColors(); + tintColor = blockColors.colorMultiplier(blockState, world, mcPos, this.tintIndex); + + if (tintColor == -1) + { + tintColor = blockColors.getColor(blockState, world, mcPos); + } + } + #else // try to use the fast tint getter logic first if (!BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState)) { try { + + TintWithoutLevelOverrider tintOverride = TintWithoutLevelOverrideGetter.get(); tintOverride.update(biomeWrapper, this.blockStateWrapper, fullDataSource, this.clientLevelWrapper); @@ -607,9 +704,9 @@ public class ClientBlockStateColorCache #endif } } - - // level-specific logic is only needed for MC 1.21.11 and older - #if MC_VER <= MC_1_21_11 + #endif + // level-specific logic is only needed for MC 1.21.11 and older + #if MC_VER <= MC_1_21_11 && MC_VER > MC_1_12_2 // use the level logic only if requested if (BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState)) { @@ -645,7 +742,11 @@ public class ClientBlockStateColorCache int returnColor; + #if MC_VER <= MC_1_12_2 + if (tintColor != -1) + #else if (tintColor != AbstractDhTintGetter.INVALID_COLOR) + #endif { returnColor = ColorUtil.multiplyARGBwithRGB(this.baseColor, tintColor); } @@ -692,11 +793,11 @@ public class ClientBlockStateColorCache static EColorMode getColorMode(Block block) { - if (block instanceof LeavesBlock) + if (block instanceof #if MC_VER <= MC_1_12_2 BlockLeaves #else LeavesBlock #endif) { return Leaves; } - if (block instanceof FlowerBlock) + if (block instanceof #if MC_VER <= MC_1_12_2 BlockFlower #else FlowerBlock #endif) { return Flower; } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintWithoutLevelOverrider.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintWithoutLevelOverrider.java index 406b625c7..af932f3c8 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintWithoutLevelOverrider.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/TintWithoutLevelOverrider.java @@ -18,7 +18,7 @@ */ package com.seibel.distanthorizons.common.wrappers.block; - +#if MC_VER > MC_1_12_2 import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.level.LevelReader; @@ -109,3 +109,4 @@ public class TintWithoutLevelOverrider extends AbstractDhTintGetter } +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java index 01d7745f9..0e2892883 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java @@ -31,7 +31,6 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.ChunkLightStorage import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IMutableBlockPosWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper; - import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; #if MC_VER <= MC_1_12_2 import net.minecraft.block.state.IBlockState; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java index af277f529..e5d6dee88 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java @@ -12,7 +12,8 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; #endif -#if MC_VER < MC_1_20_1 +#if MC_VER <= MC_1_12_2 +#elif MC_VER < MC_1_20_1 import com.mojang.blaze3d.vertex.PoseStack; #elif MC_VER <= MC_1_21_11 import net.minecraft.client.gui.GuiGraphics; @@ -155,7 +156,4 @@ public class DhScreen extends #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #en guiStack.setTooltipForNextFrame(font, text, x, y); } #endif - - - } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GuiHelper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GuiHelper.java index b748a6d77..07acaa434 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GuiHelper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GuiHelper.java @@ -88,11 +88,7 @@ public class GuiHelper #if MC_VER <= MC_1_12_2 public static void SetY(GuiTextField w, int y) { - #if MC_VER < MC_1_19_4 w.y = y; - #else - w.setY(y); - #endif } #endif diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java index 9e1f4ae30..faffcc0dd 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java @@ -1,17 +1,27 @@ package com.seibel.distanthorizons.common.wrappers.gui; +#if MC_VER <= MC_1_12_2 +import org.lwjglx.opengl.Display; +#else import com.mojang.blaze3d.platform.Window; - +#endif import com.seibel.distanthorizons.core.config.gui.AbstractScreen; import net.minecraft.client.Minecraft; + +#if MC_VER > MC_1_12_2 import net.minecraft.client.gui.components.ContainerObjectSelectionList; import net.minecraft.client.gui.screens.Screen; +#endif import org.jetbrains.annotations.NotNull; -#if MC_VER < MC_1_20_1 +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.gui.GuiListExtended; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiSlot; +#elif MC_VER < MC_1_20_1 import com.mojang.blaze3d.vertex.PoseStack; #elif MC_VER <= MC_1_21_11 import net.minecraft.client.gui.GuiGraphics; @@ -24,19 +34,21 @@ import java.util.*; public class MinecraftScreen { - public static Screen getScreen(Screen parent, AbstractScreen screen, String translationName) + public static #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif getScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, AbstractScreen screen, String translationName) { return new ConfigScreenRenderer(parent, screen, translationName); } private static class ConfigScreenRenderer extends DhScreen { - private final Screen parent; + private final #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent; private ConfigListWidget configListWidget; private AbstractScreen screen; - - #if MC_VER < MC_1_19_2 + #if MC_VER <= MC_1_12_2 + public static net.minecraft.util.text.TextComponentTranslation translate(String str, Object... args) + { return new net.minecraft.util.text.TextComponentTranslation(str, args); } + #elif MC_VER < MC_1_19_2 public static net.minecraft.network.chat.TranslatableComponent translate(String str, Object... args) { return new net.minecraft.network.chat.TranslatableComponent(str, args); } #else @@ -44,10 +56,12 @@ public class MinecraftScreen { return net.minecraft.network.chat.Component.translatable(str, args); } #endif - protected ConfigScreenRenderer(Screen parent, AbstractScreen screen, String translationName) + protected ConfigScreenRenderer(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, AbstractScreen screen, String translationName) { super(translate(translationName)); - #if MC_VER < MC_1_21_9 + #if MC_VER <= MC_1_12_2 + screen.minecraftWindow = Display.getWindow(); + #elif MC_VER < MC_1_21_9 screen.minecraftWindow = Minecraft.getInstance().getWindow().getWindow(); #else screen.minecraftWindow = Minecraft.getInstance().getWindow().handle(); @@ -57,18 +71,28 @@ public class MinecraftScreen } @Override + #if MC_VER <= MC_1_12_2 + public void initGui() + #else protected void init() + #endif { - super.init(); // Init Minecraft's screen + super.#if MC_VER <= MC_1_12_2 initGui(); #else init(); #endif // Init Minecraft's screen + #if MC_VER <= MC_1_12_2 + this.screen.width = Display.getWidth(); + this.screen.height = Display.getHeight(); + #else Window mcWindow = this.minecraft.getWindow(); this.screen.width = mcWindow.getWidth(); this.screen.height = mcWindow.getHeight(); + #endif this.screen.scaledWidth = this.width; this.screen.scaledHeight = this.height; this.screen.init(); // Init our own config screen - this.configListWidget = new ConfigListWidget(this.minecraft, this.width, this.height, 0, 0, 25); // Select the area to tint + this.configListWidget = new ConfigListWidget(#if MC_VER <= MC_1_12_2 this.mc #else this.minecraft #endif, this.width, this.height, 0, 0, 25); // Select the area to tint + #if MC_VER > MC_1_12_2 #if MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+ if (this.minecraft != null && this.minecraft.level != null) // Check if in game { @@ -77,10 +101,13 @@ public class MinecraftScreen #endif this.addWidget(this.configListWidget); // Add the tint to the things to be rendered + #endif } @Override - #if MC_VER < MC_1_20_1 + #if MC_VER <= MC_1_12_2 + public void drawScreen(int mouseX, int mouseY, float delta) + #elif MC_VER < MC_1_20_1 public void render(PoseStack matrices, int mouseX, int mouseY, float delta) #elif MC_VER <= MC_1_21_11 public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta) @@ -88,7 +115,9 @@ public class MinecraftScreen public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta) #endif { - #if MC_VER < MC_1_20_2 + #if MC_VER <= MC_1_12_2 + this.drawDefaultBackground(); + #elif MC_VER < MC_1_20_2 this.renderBackground(matrices); // Render background #elif MC_VER < MC_1_21_6 this.renderBackground(matrices, mouseX, mouseY, delta); // Render background @@ -96,7 +125,9 @@ public class MinecraftScreen // background blur is already being rendered, rendering again causes the game to crash #endif - #if MC_VER <= MC_1_21_11 + #if MC_VER <= MC_1_12_2 + this.configListWidget.drawScreen(mouseX, mouseY, delta); + #elif MC_VER <= MC_1_21_11 this.configListWidget.render(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker) #else this.configListWidget.extractRenderState(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker) @@ -106,55 +137,86 @@ public class MinecraftScreen this.screen.mouseY = mouseY; this.screen.render(delta); // Render everything on the main screen - #if MC_VER <= MC_1_21_11 + #if MC_VER <= MC_1_12_2 + super.drawScreen(mouseX, mouseY, delta); // Render the vanilla stuff (currently only used for the background and tint) + #elif MC_VER <= MC_1_21_11 super.render(matrices, mouseX, mouseY, delta); // Render the vanilla stuff (currently only used for the background and tint) #else super.extractRenderState(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker) #endif } - #if MC_VER <= MC_1_21_10 @Override + #if MC_VER <= MC_1_12_2 + public void setWorldAndResolution(Minecraft mc, int width, int height) + #elif MC_VER <= MC_1_21_10 public void resize(Minecraft mc, int width, int height) #else - @Override public void resize(int width, int height) #endif { // Resize Minecraft's screen - #if MC_VER <= MC_1_21_10 + #if MC_VER <= MC_1_12_2 + super.setWorldAndResolution(mc, width, height); + #elif MC_VER <= MC_1_21_10 super.resize(mc, width, height); #else super.resize(width, height); #endif - + #if MC_VER <= MC_1_12_2 + this.screen.width = Display.getWidth(); + this.screen.height = Display.getHeight(); + #else Window mcWindow = this.minecraft.getWindow(); this.screen.width = mcWindow.getWidth(); this.screen.height = mcWindow.getHeight(); + #endif; this.screen.scaledWidth = this.width; this.screen.scaledHeight = this.height; this.screen.onResize(); // Resize our screen } @Override + #if MC_VER <= MC_1_12_2 + public void updateScreen() + #else public void tick() + #endif { + #if MC_VER <= MC_1_12_2 + super.updateScreen(); // Tick Minecraft's screen + #else super.tick(); // Tick Minecraft's screen + #endif + this.screen.tick(); // Tick our screen if (this.screen.close) // If we decide to close the screen, then actually close the screen { + #if MC_VER <= MC_1_12_2 + this.onGuiClosed(); + #else this.onClose(); + #endif } } @Override + #if MC_VER <= MC_1_12_2 + public void onGuiClosed() + #else public void onClose() + #endif { this.screen.onClose(); // Close our screen + #if MC_VER <= MC_1_12_2 + Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); // Goto the parent screen + #else Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Goto the parent screen + #endif } + #if MC_VER > MC_1_12_2 @Override public void onFilesDrop(@NotNull List files) { this.screen.onFilesDrop(files); } @@ -163,10 +225,10 @@ public class MinecraftScreen @Override public boolean shouldCloseOnEsc() { return this.screen.shouldCloseOnEsc; } - + #endif } - public static class ConfigListWidget extends ContainerObjectSelectionList + public static class ConfigListWidget extends #if MC_VER <= MC_1_12_2 GuiListExtended #else ContainerObjectSelectionList #endif { public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing) { @@ -178,6 +240,18 @@ public class MinecraftScreen this.centerListVertically = false; } + #if MC_VER <= MC_1_12_2 + @Override + protected int getSize() + { + return 0; + } + @Override + public IGuiListEntry getListEntry(int index) + { + return null; + } + #endif } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java index f51f5fe3d..62a1e4f5f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java @@ -19,13 +19,21 @@ package com.seibel.distanthorizons.common.wrappers.gui; +#if MC_VER > MC_1_12_2 import net.minecraft.network.chat.Component; +#endif #if MC_VER >= MC_1_17_1 import net.minecraft.client.gui.components.Button; #endif -#if MC_VER < MC_1_17_1 + +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.ResourceLocation; +#elif MC_VER < MC_1_17_1 import net.minecraft.client.gui.components.ImageButton; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; @@ -53,7 +61,9 @@ import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.client.renderer.RenderPipelines; #endif -#if MC_VER <= MC_1_21_10 +#if MC_VER <= MC_1_12_2 +import net.minecraft.util.ResourceLocation; +#elif MC_VER <= MC_1_21_10 import net.minecraft.resources.ResourceLocation; #else import net.minecraft.resources.Identifier; @@ -65,7 +75,10 @@ import net.minecraft.resources.Identifier; * @author coolGi * @version 2023-10-03 */ -#if MC_VER < MC_1_20_2 +#if MC_VER <= MC_1_12_2 +@SuppressWarnings("deprecation") // we use a few deprecated Mojang functions (as expected when running on old MC versions) +public class TexturedButtonWidget extends GuiButton +#elif MC_VER < MC_1_20_2 @SuppressWarnings("deprecation") // we use a few deprecated Mojang functions (as expected when running on old MC versions) public class TexturedButtonWidget extends ImageButton #else @@ -75,7 +88,7 @@ public class TexturedButtonWidget extends Button { public final boolean renderBackground; - #if MC_VER >= MC_1_20_2 + #if MC_VER >= MC_1_20_2 || MC_VER <= MC_1_12_2 private final int u; private final int v; private final int hoveredVOffset; @@ -92,28 +105,32 @@ public class TexturedButtonWidget extends Button public TexturedButtonWidget( - int x, int y, int width, int height, int u, int v, int hoveredVOffset, + #if MC_VER <= MC_1_12_2 int id, #endif int x, int y, int width, int height, int u, int v, int hoveredVOffset, #if MC_VER <= MC_1_21_10 ResourceLocation textureResourceLocation, #else Identifier textureResourceLocation, #endif - int textureWidth, int textureHeight, OnPress pressAction, Component text) + int textureWidth, int textureHeight, #if MC_VER > MC_1_12_2 OnPress pressAction,#endif #if MC_VER <= MC_1_12_2 String #else Component #endif text) { - this(x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, pressAction, text, true); + this(#if MC_VER <= MC_1_12_2 id, #endif x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, #if MC_VER > MC_1_12_2 pressAction, #endif text, true); } public TexturedButtonWidget( - int x, int y, int width, int height, int u, int v, int hoveredVOffset, + #if MC_VER <= MC_1_12_2 int id, #endif int x, int y, int width, int height, int u, int v, int hoveredVOffset, #if MC_VER <= MC_1_21_10 ResourceLocation textureResourceLocation, #else Identifier textureResourceLocation, #endif - int textureWidth, int textureHeight, OnPress pressAction, Component text, + int textureWidth, int textureHeight, #if MC_VER > MC_1_12_2 OnPress pressAction,#endif #if MC_VER <= MC_1_12_2 String #else Component #endif text, boolean renderBackground) { - #if MC_VER < MC_1_20_2 + #if MC_VER <= MC_1_12_2 + super(id, x, y, width, height, text); + #elif MC_VER < MC_1_20_2 super(x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, pressAction, text); #else // We don't pass in the text option since it will render (we normally pass it in for narration) super(x, y, width, height, Component.empty(), pressAction, DEFAULT_NARRATION); + #endif + #if MC_VER >= MC_1_20_2 || MC_VER <= MC_1_12_2 this.u = u; this.v = v; this.hoveredVOffset = hoveredVOffset; @@ -127,7 +144,27 @@ public class TexturedButtonWidget extends Button this.renderBackground = renderBackground; } - #if MC_VER < MC_1_20_2 + #if MC_VER <= MC_1_12_2 + @Override + public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) { + if (this.visible) { + //Render vanilla background + mc.getTextureManager().bindTexture(BUTTON_TEXTURES); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; + int i = this.getHoverState(this.hovered); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); + this.drawTexturedModalRect(this.x, this.y, 0, 46 + i * 20, this.width / 2, this.height); + this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height); + + //Render DH texture + mc.getTextureManager().bindTexture(textureResourceLocation); + drawModalRectWithCustomSizedTexture(this.x, this.y, this.u, (hoveredVOffset * (i - 1)), this.width, this.height, this.textureWidth, this.textureHeight); + } + } + #elif MC_VER < MC_1_20_2 #if MC_VER < MC_1_19_4 @Override public void renderButton(PoseStack matrices, int mouseX, int mouseY, float delta) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/ClassicConfigGUI.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/ClassicConfigGUI.java index fad8baa43..967b804c6 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/ClassicConfigGUI.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/ClassicConfigGUI.java @@ -12,17 +12,24 @@ import com.seibel.distanthorizons.core.config.types.enums.EConfigCommentTextPosi import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.wrapperInterfaces.config.IConfigGui; import net.minecraft.client.Minecraft; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.gui.*; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.text.ITextComponent; +#else import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.ContainerObjectSelectionList; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; +#endif import com.seibel.distanthorizons.core.logging.DhLogger; + import org.jetbrains.annotations.NotNull; - -#if MC_VER < MC_1_20_1 +#if MC_VER <= MC_1_12_2 +#elif MC_VER < MC_1_20_1 import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.GuiComponent; #elif MC_VER <= MC_1_21_11 @@ -94,7 +101,7 @@ public class ClassicConfigGUI //==============// /** if you want to get this config gui's screen call this */ - public static Screen getScreen(Screen parent, String category) + public static #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif getScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, String category) { return new DhConfigScreen(parent, category); } @@ -103,9 +110,13 @@ public class ClassicConfigGUI // helper classes // //================// - public static class ConfigListWidget extends ContainerObjectSelectionList - { - Font textRenderer; + public static class ConfigListWidget extends #if MC_VER <= MC_1_12_2 GuiListExtended #else ContainerObjectSelectionList #endif + { + #if MC_VER <= MC_1_12_2 + public List children = new ArrayList<>(); + #endif + + #if MC_VER <= MC_1_12_2 FontRenderer #else Font #endif textRenderer; public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing) { @@ -116,40 +127,108 @@ public class ClassicConfigGUI #endif this.centerListVertically = false; + #if MC_VER <= MC_1_12_2 + this.textRenderer = minecraftClient.fontRenderer; + #else this.textRenderer = minecraftClient.font; + #endif } - public void addButton(DhConfigScreen gui, AbstractConfigBase dhConfigType, AbstractWidget button, AbstractWidget resetButton, AbstractWidget indexButton, Component text) - { this.addEntry(new DhButtonEntry(gui, dhConfigType, button, text, resetButton, indexButton)); } + #if MC_VER<= MC_1_12_2 + @Override + protected int getSize() + { + return this.children.size(); + } @Override - public int getRowWidth() { return 10_000; } - - public AbstractWidget getHoveredButton(double mouseX, double mouseY) + public IGuiListEntry getListEntry(int index) { - for (DhButtonEntry buttonEntry : this.children()) + return this.children.get(index); + } + + @Override + protected void drawContainerBackground(Tessellator tessellator) + { + if (this.mc.world != null) { - AbstractWidget button = buttonEntry.button; - if (button != null - && button.visible) + return; // in-game don't draw dirt background + } + super.drawContainerBackground(tessellator); + } + #endif + + #if MC_VER <= MC_1_12_2 + public void addButton(DhConfigScreen gui, AbstractConfigBase dhConfigType, Gui button, GuiButton resetButton, GuiButton indexButton, ITextComponent text) + #else + public void addButton(DhConfigScreen gui, AbstractConfigBase dhConfigType, AbstractWidget button, AbstractWidget resetButton, AbstractWidget indexButton, Component text) + #endif + { + #if MC_VER <= MC_1_12_2 + this.children.add(new DhButtonEntry(gui, dhConfigType, button, text, resetButton, indexButton)); + #else + this.addEntry(new DhButtonEntry(gui, dhConfigType, button, text, resetButton, indexButton)); + #endif + } + + @Override + public int #if MC_VER <= MC_1_12_2 getListWidth() #else getRowWidth() #endif { return 10_000; } + + public #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif getHoveredButton(double mouseX, double mouseY) + { + for (DhButtonEntry buttonEntry : #if MC_VER <= MC_1_12_2 this.children #else this.children() #endif) + { + #if MC_VER <= MC_1_12_2 + Gui gui = buttonEntry.button; + if (gui == null) continue; + + double minX, minY, maxX, maxY; + + if (gui instanceof GuiButton button) { - #if MC_VER < MC_1_19_4 - double minX = button.x; - double minY = button.y; - #else - double minX = button.getX(); - double minY = button.getY(); - #endif - - double maxX = minX + button.getWidth(); - double maxY = minY + button.getHeight(); - - if (mouseX >= minX && mouseX < maxX - && mouseY >= minY && mouseY < maxY) - { - return button; - } + if (!button.visible) continue; + minX = button.x; + minY = button.y; + maxX = minX + button.width; + maxY = minY + button.height; } + else if (gui instanceof GuiTextField field) + { + if (!field.getVisible()) continue; + minX = field.x; + minY = field.y; + maxX = minX + field.width; + maxY = minY + field.height; + } + else + { + continue; + } + + if (mouseX >= minX && mouseX < maxX && mouseY >= minY && mouseY < maxY) + { + return gui; + } + #else + AbstractWidget button = (AbstractWidget) buttonEntry.button; + if (button == null || !button.visible) continue; + + #if MC_VER < MC_1_19_4 + double minX = button.x; + double minY = button.y; + #else + double minX = button.getX(); + double minY = button.getY(); + #endif + + double maxX = minX + button.getWidth(); + double maxY = minY + button.getHeight(); + + if (mouseX >= minX && mouseX < maxX && mouseY >= minY && mouseY < maxY) + { + return button; + } + #endif } return null; @@ -158,31 +237,40 @@ public class ClassicConfigGUI } - public static class DhButtonEntry extends ContainerObjectSelectionList.Entry + public static class DhButtonEntry #if MC_VER <= MC_1_12_2 implements GuiListExtended.IGuiListEntry #else extends ContainerObjectSelectionList.Entry #endif { + #if MC_VER <= MC_1_12_2 + private static final FontRenderer textRenderer = Minecraft.getMinecraft().fontRenderer; + #else private static final Font textRenderer = Minecraft.getInstance().font; - - private final AbstractWidget button; - + #endif private final DhConfigScreen gui; - - private final AbstractWidget resetButton; + #if MC_VER <= MC_1_12_2 + public final Gui button; + public final Gui resetButton; + public final Gui indexButton; + #else private final AbstractWidget indexButton; - private final Component text; - private final List children = new ArrayList<>(); + private final AbstractWidget resetButton; + private final AbstractWidget button; + #endif + private final #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif text; + private final List<#if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif> children = new ArrayList<>(); @NotNull private final EConfigCommentTextPosition textPosition; public final AbstractConfigBase dhConfigType; - public static final Map TEXT_BY_WIDGET = new HashMap<>(); - public static final Map BUTTON_BY_WIDGET = new HashMap<>(); + public static final Map< #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif, #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif> TEXT_BY_WIDGET = new HashMap<>(); + public static final Map< #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif, DhButtonEntry> BUTTON_BY_WIDGET = new HashMap<>(); - public DhButtonEntry( - DhConfigScreen gui, AbstractConfigBase dhConfigType, - AbstractWidget button, Component text, AbstractWidget resetButton, AbstractWidget indexButton) + #if MC_VER <= MC_1_12_2 + public DhButtonEntry(DhConfigScreen gui, AbstractConfigBase dhConfigType, Gui button, ITextComponent text, GuiButton resetButton, GuiButton indexButton) + #else + public DhButtonEntry(DhConfigScreen gui, AbstractConfigBase dhConfigType, AbstractWidget button, Component text, AbstractWidget resetButton, AbstractWidget indexButton) + #endif { TEXT_BY_WIDGET.put(button, text); BUTTON_BY_WIDGET.put(button, this); @@ -225,7 +313,9 @@ public class ClassicConfigGUI @Override - #if MC_VER < MC_1_20_1 + #if MC_VER <= MC_1_12_2 + public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float tickDelta) + #elif MC_VER < MC_1_20_1 public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) #elif MC_VER < MC_1_21_9 public void render(GuiGraphics matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) @@ -250,18 +340,33 @@ public class ClassicConfigGUI if (this.button != null) { + #if MC_VER <= MC_1_12_2 + if (this.button instanceof GuiButton guiButton) + { + SetY(guiButton, y); + guiButton.drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta); + } + if (this.button instanceof GuiTextField guiTextField) + { + SetY(guiTextField, y); + guiTextField.drawTextBox(); + } + #else SetY(this.button, y); #if MC_VER <= MC_1_21_11 this.button.render(matrices, mouseX, mouseY, tickDelta); #else this.button.extractRenderState(matrices, mouseX, mouseY, tickDelta); #endif + #endif } if (this.resetButton != null) { - SetY(this.resetButton, y); - #if MC_VER <= MC_1_21_11 + SetY(#if MC_VER <= MC_1_12_2 (GuiButton) #endif this.resetButton, y); + #if MC_VER <= MC_1_12_2 + ((GuiButton) this.resetButton).drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta); + #elif MC_VER <= MC_1_21_11 this.resetButton.render(matrices, mouseX, mouseY, tickDelta); #else this.resetButton.extractRenderState(matrices, mouseX, mouseY, tickDelta); @@ -270,8 +375,10 @@ public class ClassicConfigGUI if (this.indexButton != null) { - SetY(this.indexButton, y); - #if MC_VER <= MC_1_21_11 + SetY(#if MC_VER <= MC_1_12_2 (GuiButton) #endif this.indexButton, y); + #if MC_VER <= MC_1_12_2 + ((GuiButton) this.indexButton).drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta); + #elif MC_VER <= MC_1_21_11 this.indexButton.render(matrices, mouseX, mouseY, tickDelta); #else this.indexButton.extractRenderState(matrices, mouseX, mouseY, tickDelta); @@ -280,7 +387,11 @@ public class ClassicConfigGUI if (this.text != null) { + #if MC_VER <= MC_1_12_2 + int translatedLength = textRenderer.getStringWidth(this.text.getFormattedText()); + #else int translatedLength = textRenderer.width(this.text); + #endif int textXPos; if (this.textPosition == EConfigCommentTextPosition.RIGHT_JUSTIFIED) @@ -313,8 +424,9 @@ public class ClassicConfigGUI throw new UnsupportedOperationException("No text position render defined for [" + this.textPosition + "]"); } - - #if MC_VER < MC_1_20_1 + #if MC_VER <= MC_1_12_2 + textRenderer.drawString(this.text.getFormattedText(), textXPos, y + 5,0xFFFFFF); + #elif MC_VER < MC_1_20_1 GuiComponent.drawString(matrices, textRenderer, this.text, textXPos, y + 5, @@ -344,9 +456,25 @@ public class ClassicConfigGUI } } + #if MC_VER <= MC_1_12_2 + @Override + public void updatePosition(int slotIndex, int x, int y, float partialTicks) { } + + @Override + public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY) + { + return false; // handled in DhConfigScreen.mouseClicked + } + + @Override + public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) { } + #endif + + #if MC_VER > MC_1_12_2 @Override public @NotNull List children() { return this.children; } + #endif #if MC_VER >= MC_1_17_1 @Override diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java index c5c4a110a..808d1733c 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java @@ -13,14 +13,18 @@ import java.util.regex.Pattern; import com.seibel.distanthorizons.api.enums.config.DisallowSelectingViaConfigGui; import com.seibel.distanthorizons.common.wrappers.gui.DhScreen; +import com.seibel.distanthorizons.common.wrappers.gui.GuiHelper; import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget; import com.seibel.distanthorizons.common.wrappers.gui.config.ConfigGuiInfo; import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper; import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.config.ConfigHandler; import com.seibel.distanthorizons.core.config.types.*; +#if MC_VER <= MC_1_12_2 +import com.seibel.distanthorizons.common.wrappers.gui.OnPressed; +#else import com.seibel.distanthorizons.common.wrappers.gui.updater.ChangelogScreen; - +#endif import com.seibel.distanthorizons.core.config.types.enums.EConfigCommentTextPosition; import com.seibel.distanthorizons.core.config.types.enums.EConfigValidity; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; @@ -30,8 +34,15 @@ import com.seibel.distanthorizons.core.util.AnnotationUtil; import com.seibel.distanthorizons.core.wrapperInterfaces.config.IConfigGui; import com.seibel.distanthorizons.core.wrapperInterfaces.config.ILangWrapper; import com.seibel.distanthorizons.coreapi.ModInfo; -import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.gui.*; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.Style; +import net.minecraft.util.text.TextFormatting; +#else +import net.minecraft.ChatFormatting; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Button; @@ -40,12 +51,13 @@ import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; +#endif import com.seibel.distanthorizons.core.logging.DhLogger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; - -#if MC_VER < MC_1_20_1 +#if MC_VER <= MC_1_12_2 +#elif MC_VER < MC_1_20_1 import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.GuiComponent; #elif MC_VER <= MC_1_21_11 @@ -58,14 +70,18 @@ import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.client.gui.narration.NarratableEntry; #endif -#if MC_VER <= MC_1_21_10 +#if MC_VER <= MC_1_12_2 +import net.minecraft.util.ResourceLocation; +#elif MC_VER <= MC_1_21_10 import net.minecraft.resources.ResourceLocation; #else import net.minecraft.resources.Identifier; #endif import org.lwjgl.glfw.GLFW; +#if MC_VER > MC_1_12_2 import com.mojang.blaze3d.platform.InputConstants; +#endif import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.*; import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.Translatable; @@ -80,12 +96,12 @@ class DhConfigScreen extends DhScreen private static final MinecraftClientWrapper MC_CLIENT = MinecraftClientWrapper.INSTANCE; - private final Screen parent; + private final #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent; private final String category; private ClassicConfigGUI.ConfigListWidget configListWidget; private boolean reload = false; - private Button doneButton; + private #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif doneButton; @@ -93,7 +109,7 @@ class DhConfigScreen extends DhScreen // constructor // //=============// - protected DhConfigScreen(Screen parent, String category) + protected DhConfigScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, String category) { super(Translatable( LANG_WRAPPER.langExists(ModInfo.ID + ".config" + (category.isEmpty() ? "." + category : "") + ".title") ? @@ -105,8 +121,14 @@ class DhConfigScreen extends DhScreen } + #if MC_VER <= MC_1_12_2 + @Override + public void updateScreen() { super.updateScreen(); } + #else @Override public void tick() { super.tick(); } + #endif + @@ -114,15 +136,25 @@ class DhConfigScreen extends DhScreen // menu UI creation // //==================// + #if MC_VER <= MC_1_12_2 + @Override + public void initGui() + #else @Override protected void init() + #endif { + #if MC_VER <= MC_1_12_2 + super.initGui(); + #else super.init(); + #endif if (!this.reload) { ConfigHandler.INSTANCE.configFileHandler.loadFromFile(); } + #if MC_VER > MC_1_12_2 // Changelog button if (Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get() // we only have changelogs for stable builds @@ -161,6 +193,7 @@ class DhConfigScreen extends DhScreen Translatable(ModInfo.ID + ".updater.title") )); } + #endif // back button @@ -170,7 +203,11 @@ class DhConfigScreen extends DhScreen (button) -> { ConfigHandler.INSTANCE.configFileHandler.loadFromFile(); + #if MC_VER <= MC_1_12_2 + Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); + #else Objects.requireNonNull(this.minecraft).setScreen(this.parent); + #endif })); // done/close button @@ -181,11 +218,16 @@ class DhConfigScreen extends DhScreen (button) -> { ConfigHandler.INSTANCE.configFileHandler.saveToFile(); + #if MC_VER <= MC_1_12_2 + Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); + #else Objects.requireNonNull(this.minecraft).setScreen(this.parent); + #endif })); - this.configListWidget = new ClassicConfigGUI.ConfigListWidget(this.minecraft, this.width * 2, this.height, 32, 32, 25); + this.configListWidget = new ClassicConfigGUI.ConfigListWidget(#if MC_VER <= MC_1_12_2 this.mc #else this.minecraft #endif, this.width * 2, this.height, 32, 32, 25); + #if MC_VER > MC_1_12_2 #if MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+ if (this.minecraft != null && this.minecraft.level != null) { @@ -194,6 +236,7 @@ class DhConfigScreen extends DhScreen #endif this.addWidget(this.configListWidget); + #endif for (AbstractConfigBase configEntry : ConfigHandler.INSTANCE.configBaseList) { @@ -356,10 +399,25 @@ class DhConfigScreen extends DhScreen private static void setupBooleanMenuOption(ConfigEntry booleanConfigEntry) { // For boolean + #if MC_VER <= MC_1_12_2 + Function func = value -> Translatable("distanthorizons.general."+((Boolean) value ? "true" : "false")).setStyle(new Style().setColor((Boolean) value ? TextFormatting.GREEN : TextFormatting.RED)); + #else Function func = value -> Translatable("distanthorizons.general." + ((Boolean) value ? "true" : "false")).withStyle((Boolean) value ? ChatFormatting.GREEN : ChatFormatting.RED); + #endif final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) booleanConfigEntry.guiValue); + #if MC_VER <= MC_1_12_2 + configGuiInfo.buttonOptionMap = + new AbstractMap.SimpleEntry>( + (button) -> + { + button.enabled = !booleanConfigEntry.apiIsOverriding(); + + booleanConfigEntry.uiSetWithoutSaving(!booleanConfigEntry.get()); + button.displayString = func.apply(booleanConfigEntry.get()).getFormattedText(); + }, func); + #else configGuiInfo.buttonOptionMap = new AbstractMap.SimpleEntry>( (button) -> @@ -369,27 +427,31 @@ class DhConfigScreen extends DhScreen booleanConfigEntry.uiSetWithoutSaving(!booleanConfigEntry.get()); button.setMessage(func.apply(booleanConfigEntry.get())); }, func); + #endif } private static void setupEnumMenuOption(ConfigEntry> enumConfigEntry, Class> enumClass) { List> enumList = Arrays.asList(enumClass.getEnumConstants()); final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) enumConfigEntry.guiValue); - + #if MC_VER <= MC_1_12_2 + Function getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString()); + #else Function getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString()); + #endif configGuiInfo.buttonOptionMap = - new AbstractMap.SimpleEntry>( + new AbstractMap.SimpleEntry<#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif, Function>( (button) -> { // get the currently selected enum and enum index int startingIndex = enumList.indexOf(enumConfigEntry.get()); Enum enumValue = enumList.get(startingIndex); - boolean shiftPressed = - InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_LEFT_SHIFT) - || InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_RIGHT_SHIFT); - - + #if MC_VER <= MC_1_12_2 + boolean shiftPressed = GuiScreen.isShiftKeyDown(); + #else + boolean shiftPressed = InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_LEFT_SHIFT) || InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_RIGHT_SHIFT); + #endif // move forward or backwards depending on if the shift key is pressed int index = shiftPressed ? startingIndex - 1 : startingIndex + 1; @@ -441,9 +503,13 @@ class DhConfigScreen extends DhScreen enumConfigEntry.uiSetWithoutSaving(enumValue); + #if MC_VER <= MC_1_12_2 + button.enabled = !enumConfigEntry.apiIsOverriding(); + button.displayString = getEnumTranslatableFunc.apply(enumConfigEntry.get()).getFormattedText(); + #else button.active = !enumConfigEntry.apiIsOverriding(); - button.setMessage(getEnumTranslatableFunc.apply(enumConfigEntry.get())); + #endif }, getEnumTranslatableFunc); } @@ -460,11 +526,15 @@ class DhConfigScreen extends DhScreen // reset button // //==============// - Button.OnPress btnAction = (button) -> + #if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif btnAction = (button) -> { configEntry.uiSetWithoutSaving(configEntry.getDefaultValue()); this.reload = true; - Objects.requireNonNull(this.minecraft).setScreen(this); + #if MC_VER <= MC_1_12_2 + Objects.requireNonNull(this.mc).displayGuiScreen(ClassicConfigGUI.getScreen(this.parent, this.category)); + #else + Objects.requireNonNull(this.minecraft).setScreen(this.parent); + #endif }; int resetButtonPosX = this.width @@ -472,20 +542,29 @@ class DhConfigScreen extends DhScreen - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN; int resetButtonPosZ = 0; - Button resetButton = MakeBtn( + #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif resetButton = MakeBtn( + #if MC_VER <= MC_1_12_2 + Translatable("distanthorizons.general.reset").setStyle(new Style().setColor(TextFormatting.RED)), + #else Translatable("distanthorizons.general.reset").withStyle(ChatFormatting.RED), + #endif resetButtonPosX, resetButtonPosZ, ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_HEIGHT, btnAction); if (configEntry.apiIsOverriding()) { + #if MC_VER <= MC_1_12_2 + resetButton.enabled = false; + resetButton.displayString = Translatable("distanthorizons.general.apiOverride").setStyle(new Style().setColor(TextFormatting.DARK_GRAY)).getFormattedText(); + #else resetButton.active = false; resetButton.setMessage(Translatable("distanthorizons.general.apiOverride").withStyle(ChatFormatting.DARK_GRAY)); + #endif } else { - resetButton.active = true; + resetButton.#if MC_VER <= MC_1_12_2 enabled #else active #endif = true; } @@ -494,7 +573,7 @@ class DhConfigScreen extends DhScreen // option field // //==============// - Component textComponent = this.GetTranslatableTextComponentForConfig(configEntry); + #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configEntry); int optionFieldPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN @@ -506,21 +585,24 @@ class DhConfigScreen extends DhScreen if (configGuiInfo.buttonOptionMap != null) { // enum/multi option input button - + #if MC_VER <= MC_1_12_2 + Map.Entry> widget = configGuiInfo.buttonOptionMap; + #else Map.Entry> widget = configGuiInfo.buttonOptionMap; + #endif if (configEntry.getType().isEnum()) { widget.setValue((value) -> Translatable(TRANSLATION_PREFIX + "enum." + configEntry.getType().getSimpleName() + "." + configEntry.get().toString())); } - Button button = MakeBtn( + #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif button = MakeBtn( widget.getValue().apply(configEntry.get()), optionFieldPosX, optionFieldPosZ, ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, widget.getKey()); // deactivate the button if the API is overriding it - button.active = !configEntry.apiIsOverriding(); + button.#if MC_VER <= MC_1_12_2 enabled #else active #endif = !configEntry.apiIsOverriding(); this.configListWidget.addButton(this, configEntry, @@ -535,15 +617,19 @@ class DhConfigScreen extends DhScreen { // text box input - EditBox widget = new EditBox(this.font, + #if MC_VER <= MC_1_12_2 GuiTextField #else EditBox #endif widget = new #if MC_VER <= MC_1_12_2 GuiTextField #else EditBox #endif( + #if MC_VER <= MC_1_12_2 0, #endif + #if MC_VER <= MC_1_12_2 this.fontRenderer #else this.font #endif, optionFieldPosX, optionFieldPosZ, - ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, - Translatable("")); - widget.setMaxLength(3_000_000); // hopefully 3 million characters should be enough for any normal use-case, lol - widget.insertText(String.valueOf(configEntry.get())); + ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT + #if MC_VER > MC_1_12_2 ,Translatable("") #endif); + widget.#if MC_VER <= MC_1_12_2 setMaxStringLength(3_000_000); #else setMaxLength(3_000_000); #endif // hopefully 3 million characters should be enough for any normal use-case, lol + widget.#if MC_VER <= MC_1_12_2 setText #else insertText #endif (String.valueOf(configEntry.get())); Predicate processor = configGuiInfo.tooltipFunction.apply(widget, this.doneButton); - #if MC_VER <= MC_1_21_11 + #if MC_VER <= MC_1_12_2 + widget.setValidator(processor::test); + #elif MC_VER <= MC_1_21_11 widget.setFilter(processor); #else widget.setResponder(processor::test); @@ -563,18 +649,22 @@ class DhConfigScreen extends DhScreen { ConfigCategory configCategory = (ConfigCategory) configType; - Component textComponent = this.GetTranslatableTextComponentForConfig(configCategory); + #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configCategory); int categoryPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN; int categoryPosZ = this.height - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT; // Note: the posZ value here seems to be ignored - Button widget = MakeBtn(textComponent, + #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif widget = MakeBtn(textComponent, categoryPosX, categoryPosZ, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, ((button) -> { ConfigHandler.INSTANCE.configFileHandler.saveToFile(); + #if MC_VER <= MC_1_12_2 + Objects.requireNonNull(this.mc).displayGuiScreen(ClassicConfigGUI.getScreen(this, configCategory.getDestination())); + #else Objects.requireNonNull(this.minecraft).setScreen(ClassicConfigGUI.getScreen(this, configCategory.getDestination())); + #endif })); this.configListWidget.addButton(this, configType, widget, null, null, null); @@ -589,11 +679,11 @@ class DhConfigScreen extends DhScreen { ConfigUIButton configUiButton = (ConfigUIButton) configType; - Component textComponent = this.GetTranslatableTextComponentForConfig(configUiButton); + #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configUiButton); int buttonPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN; - Button widget = MakeBtn(textComponent, + #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif widget = MakeBtn(textComponent, buttonPosX, this.height - 28, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, (button) -> ((ConfigUIButton) configType).runAction()); @@ -610,7 +700,7 @@ class DhConfigScreen extends DhScreen { ConfigUIComment configUiComment = (ConfigUIComment) configType; - Component textComponent = this.GetTranslatableTextComponentForConfig(configUiComment); + #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configUiComment); if (configUiComment.parentConfigPath != null) { textComponent = Translatable(TRANSLATION_PREFIX + configUiComment.parentConfigPath); @@ -627,7 +717,7 @@ class DhConfigScreen extends DhScreen { if (configType instanceof ConfigUISpacer) { - Button spacerButton = MakeBtn(Translatable("distanthorizons.general.spacer"), + #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif spacerButton = MakeBtn(Translatable("distanthorizons.general.spacer"), 10, 10, // having too small of a size causes division by 0 errors in older MC versions (IE 1.20.1) 1, 1, (button) -> { }); @@ -652,7 +742,7 @@ class DhConfigScreen extends DhScreen return false; } - private Component GetTranslatableTextComponentForConfig(AbstractConfigBase configType) + private #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif GetTranslatableTextComponentForConfig(AbstractConfigBase configType) { return Translatable(TRANSLATION_PREFIX + configType.getNameAndCategory()); } @@ -662,15 +752,19 @@ class DhConfigScreen extends DhScreen //===========// @Override -#if MC_VER < MC_1_20_1 + #if MC_VER <= MC_1_12_2 + public void drawScreen(int mouseX, int mouseY, float delta) + #elif MC_VER < MC_1_20_1 public void render(PoseStack matrices, int mouseX, int mouseY, float delta) -#elif MC_VER <= MC_1_21_11 + #elif MC_VER <= MC_1_21_11 public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta) -#else + #else public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta) #endif { - #if MC_VER < MC_1_20_2 // 1.20.2 now enables this by default in the `this.list.render` function + #if MC_VER <= MC_1_12_2 + this.drawDefaultBackground(); + #elif MC_VER < MC_1_20_2 // 1.20.2 now enables this by default in the `this.list.render` function this.renderBackground(matrices); #elif MC_VER <= MC_1_21_11 super.render(matrices, mouseX, mouseY, delta); @@ -679,7 +773,9 @@ class DhConfigScreen extends DhScreen #endif // Render buttons - #if MC_VER <= MC_1_21_11 + #if MC_VER <= MC_1_12_2 + this.configListWidget.drawScreen(mouseX, mouseY, delta); + #elif MC_VER <= MC_1_21_11 this.configListWidget.render(matrices, mouseX, mouseY, delta); #else this.configListWidget.extractRenderState(matrices, mouseX, mouseY, delta); @@ -687,43 +783,61 @@ class DhConfigScreen extends DhScreen // Render config title - this.DhDrawCenteredString(matrices, this.font, this.title, + this.DhDrawCenteredString( + #if MC_VER > MC_1_12_2 + matrices, this.font, + #endif + this.title, this.width / 2, 15, - #if MC_VER < MC_1_21_6 + #if MC_VER < MC_1_21_6 0xFFFFFF // RGB white - #else - 0xFFFFFFFF // ARGB white - #endif ); + #else + 0xFFFFFFFF // ARGB white + #endif); // render DH version - this.DhDrawString(matrices, this.font, TextOrLiteral(ModInfo.VERSION), 2, this.height - 10, - #if MC_VER < MC_1_21_6 + this.DhDrawString( + #if MC_VER > MC_1_12_2 + matrices, this.font, + #endif + TextOrLiteral(ModInfo.VERSION), 2, this.height - 10, + #if MC_VER < MC_1_21_6 0xAAAAAA // RGB white - #else - 0xFFAAAAAA // ARGB white - #endif ); + #else + 0xFFAAAAAA // ARGB white + #endif); // If the update is pending, display this message to inform the user that it will apply when the game restarts if (SelfUpdater.deleteOldJarOnJvmShutdown) { - this.DhDrawString(matrices, this.font, Translatable(ModInfo.ID + ".updater.waitingForClose"), 4, this.height - 42, - #if MC_VER < MC_1_21_6 + this.DhDrawString( + #if MC_VER > MC_1_12_2 + matrices, this.font, + #endif + Translatable(ModInfo.ID + ".updater.waitingForClose"), 4, this.height - 42, + #if MC_VER < MC_1_21_6 0xFFFFFF // RGB white - #else - 0xFFFFFFFF // ARGB white - #endif ); + #else + 0xFFFFFFFF // ARGB white + #endif); } + this.renderTooltip( + #if MC_VER > MC_1_12_2 matrices, + #endif + mouseX, mouseY, delta); - this.renderTooltip(matrices, mouseX, mouseY, delta); - - #if MC_VER < MC_1_20_2 + #if MC_VER <= MC_1_12_2 + super.drawScreen(mouseX, mouseY, delta); + #elif MC_VER < MC_1_20_2 super.render(matrices, mouseX, mouseY, delta); #endif } - #if MC_VER < MC_1_20_1 + #if MC_VER <= MC_1_12_2 + private void renderTooltip(int mouseX, int mouseY, float delta) + #elif MC_VER < MC_1_20_1 private void renderTooltip(PoseStack matrices, int mouseX, int mouseY, float delta) #elif MC_VER <= MC_1_21_11 private void renderTooltip(GuiGraphics matrices, int mouseX, int mouseY, float delta) @@ -731,7 +845,7 @@ class DhConfigScreen extends DhScreen private void renderTooltip(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta) #endif { - AbstractWidget hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY); + #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY); if (hoveredWidget == null) { return; @@ -763,22 +877,87 @@ class DhConfigScreen extends DhScreen final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) configBase.guiValue); if (configGuiInfo.errorMessage != null) { - this.DhRenderTooltip(matrices, this.font, configGuiInfo.errorMessage, mouseX, mouseY); + this.DhRenderTooltip( + #if MC_VER > MC_1_12_2 + matrices, this.font, + #endif + configGuiInfo.errorMessage, mouseX, mouseY); } // display the tooltip if present else if (LANG_WRAPPER.langExists(key)) { - List list = new ArrayList<>(); + List<#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif> list = new ArrayList<>(); String lang = LANG_WRAPPER.getLang(key); for (String langLine : lang.split("\n")) { list.add(TextOrTranslatable(langLine)); } - this.DhRenderComponentTooltip(matrices, this.font, list, mouseX, mouseY); + this.DhRenderComponentTooltip( + #if MC_VER > MC_1_12_2 + matrices, this.font, + #endif + list, mouseX, mouseY); } } + #if MC_VER <= MC_1_12_2 + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws java.io.IOException + { + super.mouseClicked(mouseX, mouseY, mouseButton); + + if (mouseY >= this.configListWidget.top && mouseY <= this.configListWidget.bottom) + { + for (ClassicConfigGUI.DhButtonEntry entry : this.configListWidget.children) + { + if (entry.button instanceof GuiButton btn && btn.visible) + { + if (btn.mousePressed(this.mc, mouseX, mouseY)) + { + btn.playPressSound(this.mc.getSoundHandler()); + OnPressed handler = GuiHelper.HANDLER_BY_BUTTON.get(btn); + if (handler != null) handler.pressed(btn); + } + } + else if (entry.button instanceof GuiTextField field && field.getVisible()) + { + field.mouseClicked(mouseX, mouseY, mouseButton); + } + + if (entry.resetButton instanceof GuiButton reset && reset.visible) + { + if (reset.mousePressed(this.mc, mouseX, mouseY)) + { + reset.playPressSound(this.mc.getSoundHandler()); + OnPressed handler = GuiHelper.HANDLER_BY_BUTTON.get(reset); + if (handler != null) handler.pressed(reset); + } + } + } + } + } + + @Override + protected void keyTyped(char typedChar, int keyCode) throws java.io.IOException + { + super.keyTyped(typedChar, keyCode); + for (ClassicConfigGUI.DhButtonEntry entry : this.configListWidget.children) + { + if (entry.button instanceof GuiTextField field) + { + field.textboxKeyTyped(typedChar, keyCode); + } + } + } + + @Override + public void handleMouseInput() throws java.io.IOException + { + super.handleMouseInput(); + this.configListWidget.handleMouseInput(); + } + #endif //==========// @@ -787,11 +966,16 @@ class DhConfigScreen extends DhScreen /** When you close it, it goes to the previous screen and saves */ @Override + #if MC_VER <= MC_1_12_2 + public void onGuiClosed() + #else public void onClose() + #endif { ConfigHandler.INSTANCE.configFileHandler.saveToFile(); + #if MC_VER > MC_1_12_2 Objects.requireNonNull(this.minecraft).setScreen(this.parent); - + #endif ClassicConfigGUI.CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run()); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java index 3b56dc920..2fecfffee 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java @@ -21,7 +21,9 @@ package com.seibel.distanthorizons.common.wrappers.minecraft; import java.io.File; +#if MC_VER > MC_1_12_2 import com.mojang.blaze3d.platform.Window; +#endif import com.seibel.distanthorizons.common.wrappers.gui.NativeDialogUtil; import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper; import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure; @@ -36,19 +38,29 @@ import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos; import com.seibel.distanthorizons.core.pos.DhChunkPos; import com.seibel.distanthorizons.core.logging.DhLogger; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ServerData; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.crash.CrashReport; +import net.minecraft.profiler.Profiler; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.text.TextComponentString; +#else import net.minecraft.CrashReport; import net.minecraft.client.CloudStatus; -import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.player.LocalPlayer; import net.minecraft.core.BlockPos; import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.world.level.ChunkPos; +#endif import org.jetbrains.annotations.Nullable; -#if MC_VER < MC_1_19_2 +#if MC_VER < MC_1_19_2 && MC_VER > MC_1_12_2 import net.minecraft.network.chat.TextComponent; #endif @@ -57,11 +69,12 @@ import net.minecraft.network.chat.TextComponent; import net.minecraft.util.profiling.Profiler; #endif -#if MC_VER <= MC_1_21_10 +#if MC_VER <= MC_1_21_10 && MC_VER > MC_1_12_2 import net.minecraft.client.GraphicsStatus; #else #endif + /** * A singleton that wraps the Minecraft object. * @@ -70,7 +83,7 @@ import net.minecraft.client.GraphicsStatus; public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecraftSharedWrapper { private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - private static final Minecraft MINECRAFT = Minecraft.getInstance(); + private static final Minecraft MINECRAFT = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif; public static final MinecraftClientWrapper INSTANCE = new MinecraftClientWrapper(); @@ -85,19 +98,20 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra //region @Override - public boolean hasSinglePlayerServer() { return MINECRAFT.hasSingleplayerServer(); } + public boolean hasSinglePlayerServer() { return MINECRAFT.#if MC_VER <= MC_1_12_2 isSingleplayer() #else hasSingleplayerServer() #endif; } @Override - public boolean clientConnectedToDedicatedServer() - { - return MINECRAFT.getCurrentServer() != null - && !this.hasSinglePlayerServer(); + public boolean clientConnectedToDedicatedServer() + { + return MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif != null + && !this.hasSinglePlayerServer(); } @Override - public boolean connectedToReplay() - { - return MINECRAFT.getCurrentServer() == null - && !this.hasSinglePlayerServer() ; + public boolean connectedToReplay() + { + return MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif == null + && !this.hasSinglePlayerServer() ; } + @Override public String getCurrentServerName() @@ -108,8 +122,8 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra } else { - ServerData server = MINECRAFT.getCurrentServer(); - return (server != null) ? server.name : "NULL"; + ServerData server = MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif; + return (server != null) ? server.#if MC_VER <= MC_1_12_2 serverName #else name #endif : "NULL"; } } @Override @@ -121,15 +135,15 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra } else { - ServerData server = MINECRAFT.getCurrentServer(); - return (server != null) ? server.ip : "NA"; + ServerData server = MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif; + return (server != null) ? server.#if MC_VER <= MC_1_12_2 serverIP #else ip #endif : "NA"; } } @Override public String getCurrentServerVersion() { - ServerData server = MINECRAFT.getCurrentServer(); - return (server != null) ? server.version.getString() : "UNKOWN"; + ServerData server = MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif; + return (server != null) ? server.#if MC_VER <= MC_1_12_2 gameVersion #else version.getString() #endif : "UNKOWN"; } //endregion @@ -141,7 +155,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra //=================// //region - public LocalPlayer getPlayer() { return MINECRAFT.player; } + public #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif getPlayer() { return MINECRAFT.player; } @Override public boolean playerExists() { return MINECRAFT.player != null; } @@ -149,26 +163,28 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra @Override public DhBlockPos getPlayerBlockPos() { - LocalPlayer player = this.getPlayer(); + #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer(); if (player == null) { return new DhBlockPos(0, 0, 0); } - BlockPos playerPos = player.blockPosition(); + BlockPos playerPos = player.#if MC_VER <= MC_1_12_2 getPosition() #else blockPosition() #endif; return new DhBlockPos(playerPos.getX(), playerPos.getY(), playerPos.getZ()); } @Override public DhChunkPos getPlayerChunkPos() { - LocalPlayer player = this.getPlayer(); + #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer(); if (player == null) { return new DhChunkPos(0, 0); } - #if MC_VER < MC_1_17_1 + #if MC_VER <= MC_1_12_2 + ChunkPos playerPos = new ChunkPos(player.getPosition()); + #elif MC_VER < MC_1_17_1 ChunkPos playerPos = new ChunkPos(player.blockPosition()); #else ChunkPos playerPos = player.chunkPosition(); @@ -198,7 +214,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra @Nullable public IClientLevelWrapper getWrappedClientLevel(boolean bypassLevelKeyManager) { - ClientLevel level = MINECRAFT.level; + #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level = MINECRAFT.#if MC_VER <= MC_1_12_2 world #else level #endif; if (level == null) { return null; @@ -219,13 +235,15 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra @Override public void sendChatMessage(String string) { - LocalPlayer player = this.getPlayer(); + #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer(); if (player == null) { return; } - #if MC_VER < MC_1_19_2 + #if MC_VER <= MC_1_12_2 + player.sendMessage(new TextComponentString(string)); + #elif MC_VER < MC_1_19_2 player.sendMessage(new TextComponent(string), getPlayer().getUUID()); #elif MC_VER < MC_1_21_9 player.displayClientMessage(net.minecraft.network.chat.Component.translatable(string), /*isOverlay*/false); @@ -245,13 +263,15 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra @Override public void sendOverlayMessage(String string) { - LocalPlayer player = this.getPlayer(); + #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer(); if (player == null) { return; } - #if MC_VER < MC_1_19_2 + #if MC_VER <= MC_1_12_2 + MINECRAFT.ingameGUI.setOverlayMessage(string, /*animateColor*/false); + #elif MC_VER < MC_1_19_2 player.displayClientMessage(new TextComponent(string), /*isOverlay*/true); #elif MC_VER <= MC_1_21_11 player.displayClientMessage(net.minecraft.network.chat.Component.translatable(string), /*isOverlay*/true); @@ -273,7 +293,9 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra { LOGGER.info("Disabling vanilla clouds... This is done to prevent vanilla clouds from rendering on top of Distant Horizons LODs."); - #if MC_VER <= MC_1_18_2 + #if MC_VER <= MC_1_12_2 + MINECRAFT.gameSettings.clouds = 0; + #elif MC_VER <= MC_1_18_2 MINECRAFT.options.renderClouds = CloudStatus.OFF; #else MINECRAFT.options.cloudStatus().set(CloudStatus.OFF); @@ -295,7 +317,9 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra { String reasoning = "This is done to fix vanilla chunks (specifically water blocks) not fading into Distant Horizons LODs when DH's 'Vanilla Fade' option is enabled."; - #if MC_VER <= MC_1_18_2 + #if MC_VER <= MC_1_12_2 + // fabulous graphics was added in MC 1.16 + #elif MC_VER <= MC_1_18_2 LOGGER.info("Disabling fabulous graphics... "+reasoning); GraphicsStatus oldGraphicsStatus = MINECRAFT.options.graphicsMode; @@ -331,6 +355,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra * no override and not included in {@link IMinecraftClientWrapper} * since this would only be used in common/client, not core. */ + #if MC_VER > MC_1_12_2 public #if MC_VER < MC_1_21_9 long #else Window @@ -344,12 +369,15 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra return MINECRAFT.getWindow(); #endif } + #endif @Override public IProfilerWrapper getProfiler() { - ProfilerFiller profiler; - #if MC_VER < MC_1_21_3 + #if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif profiler; + #if MC_VER <= MC_1_12_2 + profiler = MINECRAFT.profiler; + #elif MC_VER < MC_1_21_3 profiler = MINECRAFT.getProfiler(); #else profiler = Profiler.get(); @@ -378,7 +406,9 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra executeOnRenderThread(() -> { CrashReport report = new CrashReport(errorMessage, exception); - #if MC_VER < MC_1_20_4 + #if MC_VER <= MC_1_12_2 + MINECRAFT.crashed(report); + #elif MC_VER < MC_1_20_4 Minecraft.crash(report); #else MINECRAFT.delayCrash(report); @@ -387,7 +417,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra } @Override - public void executeOnRenderThread(Runnable runnable) { MINECRAFT.execute(runnable); } + public void executeOnRenderThread(Runnable runnable) { MINECRAFT.#if MC_VER <= MC_1_12_2 addScheduledTask #else execute #endif(runnable); } @Override public void showDialog(String title, String message, String dialogType, String iconType) @@ -403,7 +433,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra //region @Override - public Object getOptionsObject() { return MINECRAFT.options; } + public Object getOptionsObject() { return MINECRAFT.#if MC_VER <= MC_1_12_2 gameSettings #else options #endif; } //endregion @@ -418,19 +448,23 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra public boolean isDedicatedServer() { return false; } @Override - public File getInstallationDirectory() { return MINECRAFT.gameDirectory; } + public File getInstallationDirectory() { return MINECRAFT.#if MC_VER <= MC_1_12_2 gameDir #else gameDirectory #endif; } @Override public int getPlayerCount() { // can be null if the server hasn't finished booting up yet - if (MINECRAFT.getSingleplayerServer() == null) + if (MINECRAFT.#if MC_VER <= MC_1_12_2 getIntegratedServer() #else getSingleplayerServer() #endif == null) { return 1; } else { + #if MC_VER <= MC_1_12_2 + return MINECRAFT.getIntegratedServer().getCurrentPlayerCount(); + #else return MINECRAFT.getSingleplayerServer().getPlayerCount(); + #endif } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java index 440b4935f..31bac5c58 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java @@ -23,8 +23,10 @@ import java.awt.Color; import java.lang.invoke.MethodHandles; import java.util.concurrent.ConcurrentHashMap; +#if MC_VER > MC_1_12_2 import com.mojang.blaze3d.pipeline.RenderTarget; import com.mojang.blaze3d.platform.NativeImage; +#endif import com.seibel.distanthorizons.api.enums.config.EDhApiLodShading; import com.seibel.distanthorizons.common.wrappers.McObjectConverter; import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper; @@ -60,18 +62,28 @@ import com.seibel.distanthorizons.core.util.math.Vec3f; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IOptifineAccessor; +#if MC_VER <= MC_1_12_2 +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fluids.IFluidBlock; +import net.minecraft.init.MobEffects; +import net.minecraft.client.renderer.entity.RenderManager; +#else import net.minecraft.client.Camera; -import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.phys.Vec3; +#endif +import net.minecraft.client.Minecraft; import com.seibel.distanthorizons.core.logging.DhLogger; import org.jetbrains.annotations.NotNull; import org.joml.Vector4f; -#if MC_VER < MC_1_17_1 +#if MC_VER <= MC_1_12_2 +import org.lwjgl.opengl.GL15; +#elif MC_VER < MC_1_17_1 import net.minecraft.tags.FluidTags; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.material.FluidState; @@ -102,7 +114,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper private static final IOptifineAccessor OPTIFINE_ACCESSOR = ModAccessorInjector.INSTANCE.get(IOptifineAccessor.class); private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - private static final Minecraft MC = Minecraft.getInstance(); + private static final Minecraft MC = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif; /** * In the case of immersive portals multiple levels may be active at once, causing conflicting lightmaps.
@@ -133,7 +145,10 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public Vec3f getLookAtVector() { - #if MC_VER <= MC_1_21_10 + #if MC_VER <= MC_1_12_2 + net.minecraft.util.math.Vec3d lookVector = (MC.getRenderViewEntity().getLook(MC.getRenderPartialTicks())); + return new Vec3f((float) lookVector.x, (float) lookVector.y, (float) lookVector.z); + #elif MC_VER <= MC_1_21_10 Camera camera = MC.gameRenderer.getMainCamera(); return new Vec3f(camera.getLookVector().x(), camera.getLookVector().y(), camera.getLookVector().z()); #else @@ -153,37 +168,47 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper { return false; } - else if (MC.player.getActiveEffectsMap() == null) + else if (MC.player.#if MC_VER <= MC_1_12_2 getActivePotionMap() #else getActiveEffectsMap() #endif == null) { return false; } else { + #if MC_VER <= MC_1_12_2 + return MC.player.getActivePotionEffect(MobEffects.BLINDNESS) != null; + #else return MC.player.getActiveEffectsMap().get(MobEffects.BLINDNESS) != null #if MC_VER >= MC_1_19_2 || MC.player.getActiveEffectsMap().get(MobEffects.DARKNESS) != null // Deep dark effect #endif ; + #endif } } @Override public Vec3d getCameraExactPosition() { + #if MC_VER <= MC_1_12_2 + RenderManager rm = MC.getRenderManager(); + return new Vec3d(rm.viewerPosX, rm.viewerPosY, rm.viewerPosZ); + #else Camera camera = MC.gameRenderer.getMainCamera(); #if MC_VER <= MC_1_21_10 Vec3 projectedView = camera.getPosition(); #else Vec3 projectedView = camera.position(); #endif - return new Vec3d(projectedView.x, projectedView.y, projectedView.z); + #endif } @Override public float getPartialTickTime() { - #if MC_VER < MC_1_21_1 + #if MC_VER <= MC_1_12_2 + return MC.getRenderPartialTicks(); + #elif MC_VER < MC_1_21_1 return MC.getFrameTime(); #elif MC_VER < MC_1_21_3 return MC.getTimer().getRealtimeDeltaTicks(); @@ -296,9 +321,17 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public Color getSkyColor() { + #if MC_VER <= MC_1_12_2 + if (MC.world.provider.hasSkyLight()) + #else if (MC.level.dimensionType().hasSkyLight()) + #endif { - #if MC_VER < MC_1_17_1 + #if MC_VER <= MC_1_12_2 + float frameTime = this.getPartialTickTime(); + net.minecraft.util.math.Vec3d colorValues = MC.world.getSkyColor(MC.getRenderViewEntity(), frameTime); + return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z); + #elif MC_VER < MC_1_17_1 float frameTime = this.getPartialTickTime(); Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getBlockPosition(), frameTime); return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z); @@ -325,7 +358,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public int getRenderDistance() { - #if MC_VER <= MC_1_17_1 + #if MC_VER <= MC_1_12_2 + return MC.gameSettings.renderDistanceChunks; + #elif MC_VER <= MC_1_17_1 return MC.options.renderDistance; #else return MC.options.getEffectiveRenderDistance(); @@ -335,14 +370,18 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public int getFrameLimit() { - #if MC_VER <= MC_1_18_2 + #if MC_VER <= MC_1_12_2 + return MC.gameSettings.limitFramerate; + #elif MC_VER <= MC_1_18_2 return MC.options.framerateLimit; #else return MC.options.framerateLimit().get(); #endif } + #if MC_VER > MC_1_12_2 protected RenderTarget getRenderTarget() { return MC.getMainRenderTarget(); } + #endif @Override public boolean mcRendersToFrameBuffer() @@ -373,7 +412,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper return this.finalLevelFrameBufferId; } - #if MC_VER < MC_1_21_5 + #if MC_VER <= MC_1_12_2 + return MC.getFramebuffer().framebufferObject; + #elif MC_VER < MC_1_21_5 return this.getRenderTarget().frameBufferId; #else // MC renders to a texture and then directly to the default FBO now @@ -388,7 +429,10 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public int getDepthTextureId() { - #if MC_VER < MC_1_21_5 + #if MC_VER <= MC_1_12_2 + //1.12.2 is using renderbuffer instead of framebuffer for depth texture + return -1; + #elif MC_VER < MC_1_21_5 return this.getRenderTarget().getDepthTextureId(); #else try @@ -418,7 +462,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public int getColorTextureId() { - #if MC_VER < MC_1_21_5 + #if MC_VER <= MC_1_12_2 + return MC.getFramebuffer().framebufferTexture; + #elif MC_VER < MC_1_21_5 return this.getRenderTarget().getColorTextureId(); #else try @@ -448,7 +494,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public int getTargetFramebufferViewportWidth() { - #if MC_VER < MC_1_21_9 + #if MC_VER <= MC_1_12_2 + return MC.getFramebuffer().framebufferWidth; + #elif MC_VER < MC_1_21_9 return this.getRenderTarget().viewWidth; #else return this.getRenderTarget().width; @@ -458,7 +506,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public int getTargetFramebufferViewportHeight() { - #if MC_VER < MC_1_21_9 + #if MC_VER <= MC_1_12_2 + return MC.getFramebuffer().framebufferHeight; + #elif MC_VER < MC_1_21_9 return this.getRenderTarget().viewHeight; #else return this.getRenderTarget().height; @@ -471,7 +521,11 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public boolean isFogStateSpecial() { - #if MC_VER < MC_1_17_1 + #if MC_VER <= MC_1_12_2 + BlockPos blockPos = new BlockPos(MC.getRenderViewEntity().getPositionEyes(MC.getRenderPartialTicks())); + IBlockState fluidState = MC.getRenderViewEntity().world.getBlockState(blockPos); + return this.playerHasBlindingEffect() || fluidState.getMaterial().isLiquid() || fluidState.getBlock() instanceof IFluidBlock; + #elif MC_VER < MC_1_17_1 Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera(); FluidState fluidState = camera.getFluidInCamera(); Entity entity = camera.getEntity(); @@ -489,6 +543,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper * It's better to use {@link MinecraftRenderWrapper#setLightmapId(int, IClientLevelWrapper)} if possible, * however old MC versions don't support it. */ + #if MC_VER > MC_1_12_2 public void updateLightmap(NativeImage lightPixels, IClientLevelWrapper level) { // Using ClientLevelWrapper as the key would be better, but we don't have a consistent way to create the same @@ -499,6 +554,8 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper LightMapWrapper wrapper = this.lightmapByDimensionType.computeIfAbsent(dimensionType, (dimType) -> new LightMapWrapper()); wrapper.uploadLightmap(lightPixels); } + #endif + public void setLightmapId(int tetxureId, IClientLevelWrapper level) { // Using ClientLevelWrapper as the key would be better, but we don't have a consistent way to create the same @@ -532,6 +589,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper { default: case AUTO: + #if MC_VER <= MC_1_12_2 + // 1.12.2 has no getShade, fall through to ENABLED + #else if (MC.level != null) { Direction mcDir = McObjectConverter.Convert(lodDirection); @@ -545,7 +605,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper { return 0.0f; } - + #endif case ENABLED: switch (lodDirection) { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/ProfilerWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/ProfilerWrapper.java index b9e4392fc..89eab7f41 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/ProfilerWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/ProfilerWrapper.java @@ -21,25 +21,29 @@ package com.seibel.distanthorizons.common.wrappers.minecraft; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IProfilerWrapper; +#if MC_VER <= MC_1_12_2 +import net.minecraft.profiler.Profiler; +#else import net.minecraft.util.profiling.ProfilerFiller; +#endif public class ProfilerWrapper implements IProfilerWrapper { - public ProfilerFiller profiler; + public #if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif profiler; - public ProfilerWrapper(ProfilerFiller newProfiler) { this.profiler = newProfiler; } + public ProfilerWrapper(#if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif newProfiler) { this.profiler = newProfiler; } @Override public IProfileBlock push(String newSection) { - this.profiler.push(newSection); + this.profiler.#if MC_VER <= MC_1_12_2 startSection(newSection) #else push(newSection) #endif; return new ProfileBlock(this.profiler); } @Override public void popPush(String newSection) { - this.profiler.popPush(newSection); + this.profiler.#if MC_VER <= MC_1_12_2 endStartSection(newSection) #else popPush(newSection) #endif; } @@ -51,14 +55,14 @@ public class ProfilerWrapper implements IProfilerWrapper public static class ProfileBlock implements IProfileBlock { - private final ProfilerFiller profiler; - public ProfileBlock(ProfilerFiller newProfiler) { this.profiler = newProfiler; } + public #if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif profiler; + public ProfileBlock(#if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif newProfiler) { this.profiler = newProfiler; } @Override public void close() { - this.profiler.pop(); + this.profiler.#if MC_VER <= MC_1_12_2 endSection() #else pop() #endif; } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java index b2e6b9717..9d89257ef 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java @@ -23,14 +23,23 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IC2meAccess import com.seibel.distanthorizons.coreapi.ModInfo; import org.jetbrains.annotations.Nullable; - +#if MC_VER <= MC_1_12_2 +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.gen.ChunkProviderServer; +import net.minecraftforge.common.ForgeChunkManager; +#else import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.TicketType; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.chunk.ChunkAccess; +#endif -#if MC_VER <= MC_1_20_4 +#if MC_VER <= MC_1_12_2 +#elif MC_VER <= MC_1_20_4 import net.minecraft.world.level.chunk.ChunkStatus; #else import net.minecraft.world.level.chunk.status.ChunkStatus; @@ -64,7 +73,10 @@ public class InternalServerGenerator */ private static final int MS_TO_IGNORE_CHUNK_AFTER_COMPLETION = 5_000; - #if MC_VER < MC_1_21_5 + #if MC_VER <= MC_1_12_2 + public static Map DH_SERVER_GEN_TICKET_MAP = new HashMap<>(); + private final ForgeChunkManager.Ticket DH_SERVER_GEN_TICKET; + #elif MC_VER < MC_1_21_5 private static final TicketType DH_SERVER_GEN_TICKET = TicketType.create("dh_server_gen_ticket", Comparator.comparingLong(ChunkPos::toLong)); #elif MC_VER < MC_1_21_9 private static final TicketType DH_SERVER_GEN_TICKET = new TicketType(/* timeout, 0 = disabled*/0L, /* persist */ false, TicketType.TicketUse.LOADING); @@ -91,6 +103,13 @@ public class InternalServerGenerator { this.params = params; this.dhServerLevel = dhServerLevel; + #if MC_VER <= MC_1_12_2 + this.DH_SERVER_GEN_TICKET = DH_SERVER_GEN_TICKET_MAP.get((WorldServer) this.dhServerLevel.getServerLevelWrapper().getWrappedMcObject()); + if (this.DH_SERVER_GEN_TICKET == null) + { + LOGGER.error("DH_SERVER_GEN_TICKET is null for level: " + dhServerLevel.getServerLevelWrapper().getDimensionName()); + } + #endif this.updateManager = WorldChunkUpdateManager.INSTANCE.getByLevelWrapper(this.dhServerLevel.getServerLevelWrapper()); } @@ -110,14 +129,14 @@ public class InternalServerGenerator // create gen requests // //=====================// - ArrayList> getChunkFutureList = new ArrayList<>(); + ArrayList> getChunkFutureList = new ArrayList<>(); { Iterator chunkPosIterator = ChunkPosGenStream.getIterator(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.widthInChunks, 0); while (chunkPosIterator.hasNext()) { ChunkPos chunkPos = chunkPosIterator.next(); - CompletableFuture requestChunkFuture = + CompletableFuture<#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif> requestChunkFuture = this.requestChunkFromServerAsync(chunkPos) // log errors if necessary .whenCompleteAsync( @@ -160,8 +179,8 @@ public class InternalServerGenerator ArrayList chunkWrappers = new ArrayList<>(); for (int i = 0; i < getChunkFutureList.size(); i++) { - CompletableFuture getChunkFuture = getChunkFutureList.get(i); - ChunkAccess chunk = getChunkFuture.join(); + CompletableFuture<#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif> getChunkFuture = getChunkFutureList.get(i); + #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk = getChunkFuture.join(); if (chunk != null) { ChunkWrapper chunkWrapper = new ChunkWrapper(chunk, this.dhServerLevel.getLevelWrapper()); @@ -245,8 +264,49 @@ public class InternalServerGenerator LOGGER.warn(c2meWarning); } } - private CompletableFuture requestChunkFromServerAsync(ChunkPos chunkPos) + private CompletableFuture<#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif> requestChunkFromServerAsync(ChunkPos chunkPos) { + #if MC_VER <= MC_1_12_2 + WorldServer level = this.params.mcServerLevel; + + if (this.updateManager != null) + { + this.updateManager.addPosToIgnore(McObjectConverter.Convert(chunkPos)); + } + + CompletableFuture future = new CompletableFuture<>(); + level.getMinecraftServer().addScheduledTask(() -> + { + try + { + ChunkProviderServer provider = (ChunkProviderServer) level.getChunkProvider(); + + // load neighbours first so the target chunk can fully populate + for (int i = -1; i <= 1; i++) + { + for (int j = -1; j <= 1; j++) + { + if (i != 0 || j != 0) + { + if (!provider.isChunkGeneratedAt(chunkPos.x + i, chunkPos.z + j)) + { + provider.loadChunk(chunkPos.x + i, chunkPos.z + j); + } + } + } + } + + ForgeChunkManager.forceChunk(DH_SERVER_GEN_TICKET, chunkPos); + Chunk chunk = provider.provideChunk(chunkPos.x, chunkPos.z); + future.complete(chunk); + } + catch (Exception e) + { + future.completeExceptionally(e); + } + }); + return future; + #else return CompletableFuture.supplyAsync(() -> { ServerLevel level = this.params.mcServerLevel; @@ -289,27 +349,35 @@ public class InternalServerGenerator }, this.params.mcServerLevel.getChunkSource().chunkMap.mainThreadExecutor) .thenCompose(Function.identity()); + #endif } /** * mitigates out of memory issues in the vanilla chunk system.
* See: https://github.com/pop4959/Chunky/pull/383 */ - private CompletableFuture releaseChunkFromServerAsync(ServerLevel level, ChunkPos chunkPos) + private CompletableFuture releaseChunkFromServerAsync(#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif level, ChunkPos chunkPos) { CompletableFuture removeTicketFuture = new CompletableFuture<>(); - + #if MC_VER <= MC_1_12_2 + level.getMinecraftServer().addScheduledTask(() -> + #else level.getChunkSource().chunkMap.mainThreadExecutor.execute(() -> + #endif { try { - #if MC_VER < MC_1_21_5 + #if MC_VER <= MC_1_12_2 + ForgeChunkManager.unforceChunk(DH_SERVER_GEN_TICKET, chunkPos); + #elif MC_VER < MC_1_21_5 int chunkLevel = 33; // 33 is equivalent to FULL Chunk level.getChunkSource().distanceManager.removeTicket(DH_SERVER_GEN_TICKET, chunkPos, chunkLevel, chunkPos); #else level.getChunkSource().removeTicketWithRadius(DH_SERVER_GEN_TICKET, chunkPos, 0); #endif + #if MC_VER > MC_1_12_2 level.getChunkSource().chunkMap.tick(() -> false); + #endif #if MC_VER > MC_1_16_5 level.entityManager.tick(); @@ -340,7 +408,6 @@ public class InternalServerGenerator removeTicketFuture.complete(null); } }); - return removeTicketFuture; } diff --git a/cleanroom/src/main/resources/1_12_2_distanthorizons_at.cfg b/common/src/main/resources/1_12_2.distanthorizons_at.cfg similarity index 100% rename from cleanroom/src/main/resources/1_12_2_distanthorizons_at.cfg rename to common/src/main/resources/1_12_2.distanthorizons_at.cfg diff --git a/coreSubProjects b/coreSubProjects index 5933ef824..b674f4960 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 5933ef82458c45e9dd896aa60e7a9064b895ee36 +Subproject commit b674f49600184a94d4b83888e5a50df4b8f065b7 diff --git a/gradle.properties b/gradle.properties index 1287140ff..76049434d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ # Gradle stuff org.gradle.jvmargs=-Xmx4096M -org.gradle.parallel=true -org.gradle.caching=true +org.gradle.parallel=false +org.gradle.caching=false # Mod Info mod_name=DistantHorizons @@ -48,7 +48,7 @@ versionStr= # This defines what MC version Intellij will use for the preprocessor # and what version is used automatically by build and run commands -mcVer=26.1.2 +mcVer=1.12.2 # Defines the maximum amount of memory Minecraft is allowed when run in a development environment minecraftMemoryJavaArg=-Xmx6G diff --git a/versionProperties/1.12.2.properties b/versionProperties/1.12.2.properties index 98a524823..0ab1de705 100644 --- a/versionProperties/1.12.2.properties +++ b/versionProperties/1.12.2.properties @@ -1,9 +1,9 @@ # 1.12.2 version -java_version=21 +java_version=25 minecraft_version=1.12.2 parchment_version= compatible_minecraft_versions=["1.12.2"] -accessWidenerVersion= +accessWidenerVersion=1_12_2 builds_for=cleanroom embed_joml=true @@ -13,6 +13,9 @@ netty_version=4.2.9.Final # LWJGL lwjgl_version=3.3.6 +# Cleanroom loader +cleanroom_loader_version=0.5.6-alpha + # Fabric loader fabric_loader_version= fabric_api_version= @@ -27,8 +30,7 @@ bclib_version= immersive_portals_version= canvas_version= -# iris - needs 1.7.4+ to support the DH API -fabric_incompatibility_list={ "iris": "*" } +fabric_incompatibility_list={} fabric_recommend_list={} # Fabric mod run From 72bfd0a2bb4eec5afac97daa9fd42f165c2bb1d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Thu, 7 May 2026 03:39:49 +0200 Subject: [PATCH 43/68] fix color resolve for liquid blocks --- .../common/wrappers/block/ClientBlockStateColorCache.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java index e6dee44e9..fea9ba3ea 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java @@ -253,7 +253,7 @@ public class ClientBlockStateColorCache // getQuads() isn't thread safe so we need to put this logic in a lock RESOLVE_LOCK.lock(); #if MC_VER <= MC_1_12_2 - if (this.blockState.getMaterial().isLiquid()) + if (!this.blockState.getMaterial().isLiquid()) #else if (this.blockState.getFluidState().isEmpty()) #endif From a4baf9ca0ac07d122cff6f957ab0e439b65c214d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Thu, 7 May 2026 12:23:01 +0200 Subject: [PATCH 44/68] make cleanroom work in dev --- buildSrc/src/main/groovy/dh-loader.gradle | 24 ++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/buildSrc/src/main/groovy/dh-loader.gradle b/buildSrc/src/main/groovy/dh-loader.gradle index 109f51ac2..d22153c59 100644 --- a/buildSrc/src/main/groovy/dh-loader.gradle +++ b/buildSrc/src/main/groovy/dh-loader.gradle @@ -364,17 +364,23 @@ if (isNotCommonProject) { // Make run tasks use the shadow jar so relocated deps work in dev. // Filter out jars bundled in the shadow jar, but keep jars that the loader also // needs (e.g. NightConfig — DH relocates it, but NeoForge needs the original). + def shadowedPaths = configurations.shadowMe.resolve().collect { it.path }.toSet() + def loaderPaths = configurations.minecraftLibraries.resolve().collect { it.path }.toSet() tasks.withType(JavaExec).configureEach { runTask -> dependsOn(shadowJar) - classpath = files(shadowJar.archiveFile) + classpath.filter { file -> - // resolve lazily inside doFirst to avoid triggering - // minecraft config resolution before Cleanroom/FG3 is ready - true - } - doFirst { - def shadowedPaths = configurations.shadowMe.resolve().collect { it.path }.toSet() - def loaderPaths = configurations.minecraftLibraries.resolve().collect { it.path }.toSet() + if (project.name != "cleanroom") { classpath = files(shadowJar.archiveFile) + classpath.filter { file -> + file != shadowJar.archiveFile.get().asFile && + !file.path.contains(project.buildDir.path) && + !file.path.contains("core${File.separator}build") && + !file.path.contains("api${File.separator}build") && + !file.path.contains("common${File.separator}build") && + !(shadowedPaths.contains(file.path) && !loaderPaths.contains(file.path)) + } + } else { + // For cleanroom, don't put shadow jar on app classpath. + // crl.dev.extrapath loads it via LaunchClassLoader instead. + classpath = classpath.filter { file -> !file.path.contains(project.buildDir.path) && !file.path.contains("core${File.separator}build") && !file.path.contains("api${File.separator}build") && @@ -396,7 +402,7 @@ if (isNotCommonProject) { } runTask.jvmArgs = filteredArgs - if(project.name == "forge" || project.name == "neoforge") { + if(project.name == "forge" || project.name == "neoforge" || project.name == "cleanroom") { // fix (Neo)forge debug running doFirst { def modsDir = rootProject.file("run/${isClient ? 'client' : 'server'}/mods") From 32a71933d68eb410060b50252f6dae7395fefb43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Thu, 7 May 2026 15:34:01 +0200 Subject: [PATCH 45/68] Bump forge version on 1.20.1, 1.20.4 for Java 26 support --- versionProperties/1.20.1.properties | 2 +- versionProperties/1.20.4.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/versionProperties/1.20.1.properties b/versionProperties/1.20.1.properties index d5e08040f..8a018834e 100644 --- a/versionProperties/1.20.1.properties +++ b/versionProperties/1.20.1.properties @@ -45,7 +45,7 @@ fabric_api_version=0.92.6+1.20.1 enable_canvas=0 # Forge loader -forge_version=47.2.1 +forge_version=47.4.20 # Neo not used but the variable still needs to be defined to make gradle happy neoforge_version_range=[*,) diff --git a/versionProperties/1.20.4.properties b/versionProperties/1.20.4.properties index 907afb57d..32eb373d3 100644 --- a/versionProperties/1.20.4.properties +++ b/versionProperties/1.20.4.properties @@ -46,7 +46,7 @@ fabric_api_version=0.91.2+1.20.4 enable_canvas=0 # Forge loader -forge_version=49.1.13 +forge_version=49.2.7 neoforge_version= neoforge_version_range=[*,) From eb8fcaee36699a4bb4ffac539b93dd14ba4c4d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Thu, 7 May 2026 15:34:26 +0200 Subject: [PATCH 46/68] Fix compilation of modern --- buildSrc/src/main/groovy/dh-loader.gradle | 2 +- .../common/commonMixins/MixinVanillaFogCommon.java | 6 +++++- .../common/wrappers/block/BlockStateWrapper.java | 10 +++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/buildSrc/src/main/groovy/dh-loader.gradle b/buildSrc/src/main/groovy/dh-loader.gradle index d22153c59..c5d762d28 100644 --- a/buildSrc/src/main/groovy/dh-loader.gradle +++ b/buildSrc/src/main/groovy/dh-loader.gradle @@ -403,7 +403,7 @@ if (isNotCommonProject) { runTask.jvmArgs = filteredArgs if(project.name == "forge" || project.name == "neoforge" || project.name == "cleanroom") { - // fix (Neo)forge debug running + // fix (Neo)forge, Cleanroom debug running doFirst { def modsDir = rootProject.file("run/${isClient ? 'client' : 'server'}/mods") modsDir.mkdirs() diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java index cc8538f2f..1b0e962d2 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java @@ -77,8 +77,12 @@ public class MixinVanillaFogCommon Entity entity = camera.entity(); #endif - + #if MC_VER <= MC_1_12_2 boolean cameraNotInFluid = cameraNotInFluid(mc); + #else + boolean cameraNotInFluid = cameraNotInFluid(camera); + #endif + #if MC_VER <= MC_1_12_2 boolean isSpecialFog = entity.isPotionActive(MobEffects.BLINDNESS); #else diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index 931962d56..4c90bb846 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -483,7 +483,7 @@ public class BlockStateWrapper implements IBlockStateWrapper { return EDhApiBlockMaterial.LAVA; } - else if (isLiquid || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.WATER || blockState.getBlock() == Blocks.FLOWING_WATER #else this.blockState.is(Blocks.WATER) #endif) + else if (isLiquid || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.WATER || blockState.getBlock() == Blocks.FLOWING_WATER #else blockState.is(Blocks.WATER) #endif) { return EDhApiBlockMaterial.WATER; } @@ -615,7 +615,7 @@ public class BlockStateWrapper implements IBlockStateWrapper if (blockState != null) { #if MC_VER <= MC_1_12_2 - canOcclude = blockState.isOpaqueCube(); + canOcclude = blockState.getMaterial().isSolid(); #else canOcclude = blockState.canOcclude(); #endif @@ -1085,16 +1085,16 @@ public class BlockStateWrapper implements IBlockStateWrapper #if MC_VER <= MC_1_12_2 java.util.Collection> blockPropertyCollection = blockState.getPropertyKeys(); #else - java.util.Collection> blockPropertyCollection = blockState.getProperties();; + java.util.Collection> blockPropertyCollection = blockState.getProperties();; #endif // alphabetically sort the list so they are always in the same order - List<#if MC_VER <= MC_1_12_2 IProperty #else Property #endif> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection); + List<#if MC_VER <= MC_1_12_2 IProperty #else net.minecraft.world.level.block.state.properties.Property #endif> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection); sortedBlockPropteryList.sort((a, b) -> a.getName().compareTo(b.getName())); StringBuilder stringBuilder = new StringBuilder(); - for (#if MC_VER <= MC_1_12_2 IProperty #else Property #endif property : sortedBlockPropteryList) + for (#if MC_VER <= MC_1_12_2 IProperty #else net.minecraft.world.level.block.state.properties.Property #endif property : sortedBlockPropteryList) { String propertyName = property.getName(); From 05bdaf0390d78fd68e3ecfd20091e656e22992bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Thu, 7 May 2026 15:39:14 +0200 Subject: [PATCH 47/68] Prevent air transforming into water if waterSubSurfaceBlockReplacementCsv contains invalid resource location --- .../common/wrappers/block/BlockStateWrapper.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index 4c90bb846..9518a969d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -705,6 +705,8 @@ public class BlockStateWrapper implements IBlockStateWrapper ObjectOpenHashSet baseIgnoredBlock = new ObjectOpenHashSet<>(); waterSubsurfaceReplacementBlocks = getAllBlockWrappers(Config.Client.Advanced.Graphics.Culling.waterSubSurfaceBlockReplacementCsv, baseIgnoredBlock, levelWrapper); + waterSubsurfaceReplacementBlocks.remove(AIR); + return waterSubsurfaceReplacementBlocks; } public static IBlockStateWrapper getWaterBlockStateWrapper(ILevelWrapper levelWrapper) From 611c4606d748f7230678941b1d1283987d44dd42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Fri, 8 May 2026 01:15:13 +0200 Subject: [PATCH 48/68] Fix 1.12.2 bugs, fill mcmod.info --- buildSrc/src/main/groovy/dh-loader.gradle | 24 +++++++ cleanroom/build.gradle | 1 + .../cleanroom/CleanroomServerProxy.java | 1 - cleanroom/src/main/resources/mcmod.info | 14 ++-- .../block/ClientBlockStateColorCache.java | 16 +++++ .../BatchGenerationEnvironment.java | 6 +- .../InternalServerGenerator.java | 66 ++++++++++--------- 7 files changed, 85 insertions(+), 43 deletions(-) diff --git a/buildSrc/src/main/groovy/dh-loader.gradle b/buildSrc/src/main/groovy/dh-loader.gradle index c5d762d28..62d197514 100644 --- a/buildSrc/src/main/groovy/dh-loader.gradle +++ b/buildSrc/src/main/groovy/dh-loader.gradle @@ -6,6 +6,7 @@ import org.apache.tools.zip.ZipOutputStream import javax.annotation.Nonnull import java.util.function.Function import java.util.function.Predicate +import groovy.json.JsonSlurper // Convention plugin for all MC-facing subprojects (common + loaders). // Common uses this directly; loaders use it via unimined-fabric/forge/neoforge. @@ -469,6 +470,7 @@ if (isNotCommonProject) { def resourceTargets = [ "build_info.json", "fabric.mod.json", + "mcmod.info", "quilt.mod.json", "META-INF/mods.toml", "META-INF/neoforge.mods.toml", @@ -479,6 +481,7 @@ if (isNotCommonProject) { // Quilt contributors def quilt_contributors = [] def mod_author_list = rootProject.mod_authors.replaceAll("\"", "").replace("[", "").replace("]", "").split(",") + def cleanroom_author_list = rootProject.mod_authors.replace('[', '').replace(']', '').split(',').collect { it.trim().replace('"', '') }.join('", "') for (dev in mod_author_list) { quilt_contributors.push("\"${dev.strip()}\": \"Developer\"") } @@ -496,9 +499,11 @@ if (isNotCommonProject) { def replaceProperties = [ version : rootProject.mod_version, + mod_id : rootProject.mod_id, mod_name : rootProject.mod_readable_name, group : rootProject.maven_group, authors : rootProject.mod_authors, + cleanroom_authors : cleanroom_author_list, description : rootProject.mod_description, homepage : rootProject.mod_homepage, source : rootProject.mod_source, @@ -516,6 +521,7 @@ if (isNotCommonProject) { fabric_incompatibility_list : rootProject.fabric_incompatibility_list, fabric_recommend_list : rootProject.fabric_recommend_list, neoforge_version_range : rootProject.neoforge_version_range, + logo_path : "assets/distanthorizons/icon.png" ] inputs.properties replaceProperties @@ -546,6 +552,24 @@ if (isNotCommonProject) { from fileTree(project(":core").file("src/main/resources")) into project.file("build/resources/main") } + + tasks.register("convertJsonToLang") { + dependsOn(copyCoreResources) + + File input = project.file("build/resources/main/assets/distanthorizons/lang/en_us.json") + File output = project.file("build/resources/main/assets/distanthorizons/lang/en_us.lang") + inputs.file(input) + outputs.file(output) + doLast { + output.withWriter("UTF-8") { writer -> + new JsonSlurper() + .parse(input) + .each { key, value -> + writer.writeLine("${key}=${value.toString().replace("%", "%%").replace("\n", "\\n")}") + } + } + } + } // ==================== JVMDowngrader ==================== diff --git a/cleanroom/build.gradle b/cleanroom/build.gradle index 25b33ff99..3124a395b 100644 --- a/cleanroom/build.gradle +++ b/cleanroom/build.gradle @@ -29,6 +29,7 @@ task deleteResources(type: Delete) { processResources { rename '(.+_at.cfg)', 'META-INF/$1' dependsOn(copyCoreResources) + dependsOn(convertJsonToLang) // dependsOn(copyCommonLoaderResources) } diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java index 011517e97..f519d8d56 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java @@ -79,7 +79,6 @@ public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy { if (GetEventLevel(event) instanceof WorldServer) { - InternalServerGenerator.DH_SERVER_GEN_TICKET_MAP.put(event.getWorld(), ForgeChunkManager.requestTicket(instance, event.getWorld(), ForgeChunkManager.Type.NORMAL)); this.serverApi.serverLevelLoadEvent(getServerLevelWrapper((WorldServer) GetEventLevel(event))); } } diff --git a/cleanroom/src/main/resources/mcmod.info b/cleanroom/src/main/resources/mcmod.info index ab8c3f26b..e8757de68 100644 --- a/cleanroom/src/main/resources/mcmod.info +++ b/cleanroom/src/main/resources/mcmod.info @@ -1,12 +1,12 @@ [{ "modid": "${mod_id}", "name": "${mod_name}", - "version": "${mod_version}", + "version": "${version}", "mcversion": "1.12.2", - "description": "${mod_description}", - "authorList": ["${mod_authors}"], - "credits": "${mod_credits}", - "url": "${mod_url}", - "updateJSON": "${mod_update_json}", - "logoFile": "${mod_logo_path}" + "description": "${description}", + "authorList": ["${cleanroom_authors}"], + "credits": "", + "url": "", + "updateJSON": "", + "logoFile": "${logo_path}" }] \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java index fea9ba3ea..d6114790a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java @@ -35,6 +35,7 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite; #if MC_VER <= MC_1_12_2 import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; +import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.block.BlockRotatedPillar; import net.minecraft.block.*; @@ -252,6 +253,21 @@ public class ClientBlockStateColorCache { // getQuads() isn't thread safe so we need to put this logic in a lock RESOLVE_LOCK.lock(); + + #if MC_VER <= MC_1_12_2 + if (this.blockState.getRenderType() == EnumBlockRenderType.ENTITYBLOCK_ANIMATED) + { + this.needPostTinting = false; + this.tintIndex = 0; + this.baseColor = ColorUtil.argbToInt(255, + this.blockStateWrapper.getMapColor().getRed(), + this.blockStateWrapper.getMapColor().getGreen(), + this.blockStateWrapper.getMapColor().getBlue()); + this.isColorResolved = true; + return; + } + #endif + #if MC_VER <= MC_1_12_2 if (!this.blockState.getMaterial().isLiquid()) #else diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 4c594b46d..ad3958f74 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -792,11 +792,7 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm } - #if MC_VER <= MC_1_12_2 - WorldServer worldServer = (WorldServer) this.dhServerLevel.getServerLevelWrapper().getWrappedMcObject(); - InternalServerGenerator.DH_SERVER_GEN_TICKET_MAP.remove(worldServer); - ForgeChunkManager.releaseTicket(InternalServerGenerator.DH_SERVER_GEN_TICKET_MAP.get(worldServer)); - #else + #if MC_VER > MC_1_12_2 this.chunkFileReader.close(); #endif } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java index 9d89257ef..fc82afcc2 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java @@ -15,6 +15,7 @@ import com.seibel.distanthorizons.core.generation.DhLightingEngine; import com.seibel.distanthorizons.core.level.IDhServerLevel; import com.seibel.distanthorizons.core.logging.DhLogger; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; +import com.seibel.distanthorizons.core.pos.DhChunkPos; import com.seibel.distanthorizons.core.util.ExceptionUtil; import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.util.TimerUtil; @@ -74,8 +75,6 @@ public class InternalServerGenerator private static final int MS_TO_IGNORE_CHUNK_AFTER_COMPLETION = 5_000; #if MC_VER <= MC_1_12_2 - public static Map DH_SERVER_GEN_TICKET_MAP = new HashMap<>(); - private final ForgeChunkManager.Ticket DH_SERVER_GEN_TICKET; #elif MC_VER < MC_1_21_5 private static final TicketType DH_SERVER_GEN_TICKET = TicketType.create("dh_server_gen_ticket", Comparator.comparingLong(ChunkPos::toLong)); #elif MC_VER < MC_1_21_9 @@ -103,13 +102,6 @@ public class InternalServerGenerator { this.params = params; this.dhServerLevel = dhServerLevel; - #if MC_VER <= MC_1_12_2 - this.DH_SERVER_GEN_TICKET = DH_SERVER_GEN_TICKET_MAP.get((WorldServer) this.dhServerLevel.getServerLevelWrapper().getWrappedMcObject()); - if (this.DH_SERVER_GEN_TICKET == null) - { - LOGGER.error("DH_SERVER_GEN_TICKET is null for level: " + dhServerLevel.getServerLevelWrapper().getDimensionName()); - } - #endif this.updateManager = WorldChunkUpdateManager.INSTANCE.getByLevelWrapper(this.dhServerLevel.getServerLevelWrapper()); } @@ -269,41 +261,35 @@ public class InternalServerGenerator #if MC_VER <= MC_1_12_2 WorldServer level = this.params.mcServerLevel; + // ignore chunk update events for this position if (this.updateManager != null) { this.updateManager.addPosToIgnore(McObjectConverter.Convert(chunkPos)); } - + CompletableFuture future = new CompletableFuture<>(); level.getMinecraftServer().addScheduledTask(() -> { - try + ChunkProviderServer provider = level.getChunkProvider(); + + // load neighbours first so the target chunk can fully populate + for (int i = -1; i <= 1; i++) { - ChunkProviderServer provider = (ChunkProviderServer) level.getChunkProvider(); - - // load neighbours first so the target chunk can fully populate - for (int i = -1; i <= 1; i++) + for (int j = -1; j <= 1; j++) { - for (int j = -1; j <= 1; j++) + if (i != 0 || j != 0) { - if (i != 0 || j != 0) + if (this.updateManager != null) { - if (!provider.isChunkGeneratedAt(chunkPos.x + i, chunkPos.z + j)) - { - provider.loadChunk(chunkPos.x + i, chunkPos.z + j); - } + this.updateManager.addPosToIgnore(new DhChunkPos(chunkPos.x + i, chunkPos.z + j)); } + provider.provideChunk(chunkPos.x + i, chunkPos.z + j); } } - - ForgeChunkManager.forceChunk(DH_SERVER_GEN_TICKET, chunkPos); - Chunk chunk = provider.provideChunk(chunkPos.x, chunkPos.z); - future.complete(chunk); - } - catch (Exception e) - { - future.completeExceptionally(e); } + + Chunk chunk = provider.provideChunk(chunkPos.x, chunkPos.z); + future.complete(chunk); }); return future; #else @@ -367,7 +353,27 @@ public class InternalServerGenerator try { #if MC_VER <= MC_1_12_2 - ForgeChunkManager.unforceChunk(DH_SERVER_GEN_TICKET, chunkPos); + for (int i = -1; i <= 1; i++) + { + for (int j = -1; j <= 1; j++) + { + if (i != 0 || j != 0) + { + final int di = i, dj = j; + this.chunkSaveIgnoreTimer.schedule(new TimerTask() + { + @Override + public void run() + { + if (InternalServerGenerator.this.updateManager != null) + { + InternalServerGenerator.this.updateManager.removePosToIgnore(new DhChunkPos(chunkPos.x + di, chunkPos.z + dj)); + } + } + }, MS_TO_IGNORE_CHUNK_AFTER_COMPLETION); + } + } + } #elif MC_VER < MC_1_21_5 int chunkLevel = 33; // 33 is equivalent to FULL Chunk level.getChunkSource().distanceManager.removeTicket(DH_SERVER_GEN_TICKET, chunkPos, chunkLevel, chunkPos); From 8b6bb228e3c6fbcd13bf0dc248fdb302693e6cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Fri, 8 May 2026 01:17:19 +0200 Subject: [PATCH 49/68] Put 26.1.2 back in mcVer --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 76049434d..884dc5c84 100644 --- a/gradle.properties +++ b/gradle.properties @@ -48,7 +48,7 @@ versionStr= # This defines what MC version Intellij will use for the preprocessor # and what version is used automatically by build and run commands -mcVer=1.12.2 +mcVer=26.1.2 # Defines the maximum amount of memory Minecraft is allowed when run in a development environment minecraftMemoryJavaArg=-Xmx6G From 578efbf15fb319893c25aa849f1261bf3f8bb0fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Fri, 8 May 2026 02:19:45 +0200 Subject: [PATCH 50/68] Fix compile of 1.21.6+ --- .../common/commonMixins/MixinVanillaFogCommon.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java index 1b0e962d2..cb6fa00d2 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java @@ -9,6 +9,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftCli import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; +import net.minecraft.client.Minecraft; #if MC_VER <= MC_1_12_2 #else import net.minecraft.client.Camera; @@ -18,7 +19,6 @@ import net.minecraft.world.entity.LivingEntity; #endif #if MC_VER <= MC_1_12_2 -import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.init.MobEffects; #elif MC_VER < MC_1_17_1 From 17bde631ac40bdf7bb827267121e1b70ce701a98 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 12 May 2026 07:02:04 -0500 Subject: [PATCH 51/68] Put back jvmdowngrader --- buildSrc/src/main/groovy/root.gradle | 8 ++++++++ gradle.properties | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/groovy/root.gradle b/buildSrc/src/main/groovy/root.gradle index ff8640365..4f34000fc 100644 --- a/buildSrc/src/main/groovy/root.gradle +++ b/buildSrc/src/main/groovy/root.gradle @@ -46,3 +46,11 @@ def writePreprocessorDefinitions() { writePreprocessorDefinitions() // Wire JVMDowngrader to process remapped jars +gradle.projectsEvaluated { + rootProject.subprojects.each { + if (it.tasks.findByName('remapJar') == null) return + it.tasks.downgradeJar.inputFile = it.tasks.remapJar.archiveFile + it.tasks.jar.finalizedBy(it.tasks.remapJar) + it.tasks.remapJar.finalizedBy(it.tasks.shadeDowngradedApi) + } +} diff --git a/gradle.properties b/gradle.properties index 884dc5c84..1287140ff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ # Gradle stuff org.gradle.jvmargs=-Xmx4096M -org.gradle.parallel=false -org.gradle.caching=false +org.gradle.parallel=true +org.gradle.caching=true # Mod Info mod_name=DistantHorizons From e4312c2f8b5da224379cf20bce6f073bc1e2edfd Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 12 May 2026 07:28:11 -0500 Subject: [PATCH 52/68] reformat 1.12.2 version prop --- versionProperties/1.12.2.properties | 82 ++++++++++++++--------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/versionProperties/1.12.2.properties b/versionProperties/1.12.2.properties index 0ab1de705..46a1d6323 100644 --- a/versionProperties/1.12.2.properties +++ b/versionProperties/1.12.2.properties @@ -19,47 +19,47 @@ cleanroom_loader_version=0.5.6-alpha # Fabric loader fabric_loader_version= fabric_api_version= -# Fabric mod versions -modmenu_version= -starlight_version_fabric= -phosphor_version_fabric= -lithium_version= -sodium_version= -iris_version= -bclib_version= -immersive_portals_version= -canvas_version= - -fabric_incompatibility_list={} -fabric_recommend_list={} - -# Fabric mod run -# 0 = Don't enable and don't run -# 1 = Can be referenced in code but doesn't run -# 2 = Can be referenced in code and runs in client -enable_mod_menu=0 -enable_starlight=0 -enable_phosphor=0 -enable_lithium=0 -enable_sodium=0 -enable_iris=0 -# not available via github, use curse.maven if necessary -enable_bclib=0 -enable_immersive_portals=0 -enable_canvas=0 + # Fabric mod versions + modmenu_version= + starlight_version_fabric= + phosphor_version_fabric= + lithium_version= + sodium_version= + iris_version= + bclib_version= + immersive_portals_version= + canvas_version= + + fabric_incompatibility_list={} + fabric_recommend_list={} + + # Fabric mod run + # 0 = Don't enable and don't run + # 1 = Can be referenced in code but doesn't run + # 2 = Can be referenced in code and runs in client + enable_mod_menu=0 + enable_starlight=0 + enable_phosphor=0 + enable_lithium=0 + enable_sodium=0 + enable_iris=0 + # not available via github, use curse.maven if necessary + enable_bclib=0 + enable_immersive_portals=0 + enable_canvas=0 # Forge loader forge_version= -# Neo not used but the variable still needs to be defined to make gradle happy -neoforge_version_range=[*,) - -# Forge mod versions -terraforged_version= - -# Forge mod run -# 0 = Don't enable and don't run -# 1 = Can be referenced in code but doesn't run -# 2 = Can be referenced in code and runs in client -enable_starlight_forge=0 -enable_terraforged=0 -enable_terrafirmacraft=0 + # Neo not used but the variable still needs to be defined to make gradle happy + neoforge_version_range=[*,) + + # Forge mod versions + terraforged_version= + + # Forge mod run + # 0 = Don't enable and don't run + # 1 = Can be referenced in code but doesn't run + # 2 = Can be referenced in code and runs in client + enable_starlight_forge=0 + enable_terraforged=0 + enable_terrafirmacraft=0 From ac3a22311415c27fc8311c8cee77a0b67da4cf46 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 12 May 2026 07:28:25 -0500 Subject: [PATCH 53/68] add missing licensing headers --- .../CleanroomPluginPacketSender.java | 19 +++++++++++++++++++ .../cleanroom/CleanroomServerProxy.java | 19 +++++++++++++++++++ .../DistantHorizonsConfigPlugin.java | 19 +++++++++++++++++++ .../DistantHorizonsLoadingPlugin.java | 19 +++++++++++++++++++ .../mixins/client/MixinEntityRenderer.java | 19 +++++++++++++++++++ .../client/MixinNetHandlerPlayClient.java | 19 +++++++++++++++++++ .../mixins/client/MixinRenderGlobal.java | 19 +++++++++++++++++++ .../mixins/server/MixinEntityPlayerMP.java | 19 +++++++++++++++++++ 8 files changed, 152 insertions(+) diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomPluginPacketSender.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomPluginPacketSender.java index d710e835b..05ed2c9c6 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomPluginPacketSender.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomPluginPacketSender.java @@ -1,3 +1,22 @@ +/* + * This file is part of the Distant Horizons mod + * licensed under the GNU LGPL v3 License. + * + * Copyright (C) 2020 James Seibel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + package com.seibel.distanthorizons.cleanroom; import com.seibel.distanthorizons.common.AbstractPluginPacketSender; diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java index f519d8d56..12f5f23db 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java @@ -1,3 +1,22 @@ +/* + * This file is part of the Distant Horizons mod + * licensed under the GNU LGPL v3 License. + * + * Copyright (C) 2020 James Seibel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + package com.seibel.distanthorizons.cleanroom; import com.seibel.distanthorizons.common.AbstractModInitializer; diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/DistantHorizonsConfigPlugin.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/DistantHorizonsConfigPlugin.java index 25cc537ff..3a693feaf 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/DistantHorizonsConfigPlugin.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/DistantHorizonsConfigPlugin.java @@ -1,3 +1,22 @@ +/* + * This file is part of the Distant Horizons mod + * licensed under the GNU LGPL v3 License. + * + * Copyright (C) 2020 James Seibel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + package com.seibel.distanthorizons.cleanroom; import net.minecraftforge.fml.common.Loader; diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/DistantHorizonsLoadingPlugin.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/DistantHorizonsLoadingPlugin.java index d5192755f..a604cba7f 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/DistantHorizonsLoadingPlugin.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/DistantHorizonsLoadingPlugin.java @@ -1,3 +1,22 @@ +/* + * This file is part of the Distant Horizons mod + * licensed under the GNU LGPL v3 License. + * + * Copyright (C) 2020 James Seibel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + package com.seibel.distanthorizons.cleanroom; import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinEntityRenderer.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinEntityRenderer.java index e5aeea3f5..fba494e58 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinEntityRenderer.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinEntityRenderer.java @@ -1,3 +1,22 @@ +/* + * This file is part of the Distant Horizons mod + * licensed under the GNU LGPL v3 License. + * + * Copyright (C) 2020 James Seibel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + package com.seibel.distanthorizons.cleanroom.mixins.client; import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper; diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinNetHandlerPlayClient.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinNetHandlerPlayClient.java index 057a638df..3f99f5f7c 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinNetHandlerPlayClient.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinNetHandlerPlayClient.java @@ -1,3 +1,22 @@ +/* + * This file is part of the Distant Horizons mod + * licensed under the GNU LGPL v3 License. + * + * Copyright (C) 2020 James Seibel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + package com.seibel.distanthorizons.cleanroom.mixins.client; import com.seibel.distanthorizons.core.api.internal.ClientApi; diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinRenderGlobal.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinRenderGlobal.java index 434f766fa..44ba6e158 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinRenderGlobal.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinRenderGlobal.java @@ -1,3 +1,22 @@ +/* + * This file is part of the Distant Horizons mod + * licensed under the GNU LGPL v3 License. + * + * Copyright (C) 2020 James Seibel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + package com.seibel.distanthorizons.cleanroom.mixins.client; import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper; diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/server/MixinEntityPlayerMP.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/server/MixinEntityPlayerMP.java index d4d85b389..7f4c9f15c 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/server/MixinEntityPlayerMP.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/server/MixinEntityPlayerMP.java @@ -1,3 +1,22 @@ +/* + * This file is part of the Distant Horizons mod + * licensed under the GNU LGPL v3 License. + * + * Copyright (C) 2020 James Seibel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + package com.seibel.distanthorizons.cleanroom.mixins.server; import com.seibel.distanthorizons.common.wrappers.misc.IMixinServerPlayer; From f17aeca79cde61e8b3884f26e532176c8b3aa14a Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 12 May 2026 07:28:37 -0500 Subject: [PATCH 54/68] add cleanroom run config --- ...ant-horizons [cleanroom_runClient].run.xml | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .run/distant-horizons [cleanroom_runClient].run.xml diff --git a/.run/distant-horizons [cleanroom_runClient].run.xml b/.run/distant-horizons [cleanroom_runClient].run.xml new file mode 100644 index 000000000..5fb0dac77 --- /dev/null +++ b/.run/distant-horizons [cleanroom_runClient].run.xml @@ -0,0 +1,27 @@ + + + + + + + true + true + false + false + false + false + false + + + \ No newline at end of file From d8e7325044c0d7261e15e56ab4927b33cb065fb6 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 12 May 2026 07:28:45 -0500 Subject: [PATCH 55/68] minor gradle cleanup --- buildSrc/src/main/groovy/dh-loader.gradle | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/groovy/dh-loader.gradle b/buildSrc/src/main/groovy/dh-loader.gradle index 62d197514..1e15021c3 100644 --- a/buildSrc/src/main/groovy/dh-loader.gradle +++ b/buildSrc/src/main/groovy/dh-loader.gradle @@ -403,7 +403,10 @@ if (isNotCommonProject) { } runTask.jvmArgs = filteredArgs - if(project.name == "forge" || project.name == "neoforge" || project.name == "cleanroom") { + if(project.name == "forge" + || project.name == "neoforge" + || project.name == "cleanroom") + { // fix (Neo)forge, Cleanroom debug running doFirst { def modsDir = rootProject.file("run/${isClient ? 'client' : 'server'}/mods") @@ -456,6 +459,7 @@ if (isNotCommonProject) { } } + tasks.downgradeJar.inputFile.set(tasks.named("remapJar").flatMap { it.archiveFile }) tasks.jar.finalizedBy(tasks.named("remapJar")) tasks.named("remapJar").configure { finalizedBy(tasks.shadeDowngradedApi) } @@ -481,7 +485,7 @@ if (isNotCommonProject) { // Quilt contributors def quilt_contributors = [] def mod_author_list = rootProject.mod_authors.replaceAll("\"", "").replace("[", "").replace("]", "").split(",") - def cleanroom_author_list = rootProject.mod_authors.replace('[', '').replace(']', '').split(',').collect { it.trim().replace('"', '') }.join('", "') + def cleanroom_author_list = rootProject.mod_authors.replace('[', '').replace(']', '').split(',').collect({ it.trim().replace('"', '') }).join('", "') for (dev in mod_author_list) { quilt_contributors.push("\"${dev.strip()}\": \"Developer\"") } From fbbcd1b95b7f4c2f14a031b2c46069da7f172d13 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 12 May 2026 07:28:59 -0500 Subject: [PATCH 56/68] fix forgix running on only a single modloader --- build.gradle | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 982ccf12c..af874eef2 100644 --- a/build.gradle +++ b/build.gradle @@ -4,10 +4,10 @@ plugins { } forgix { - autoRun = true // add the mod loaders to the end of the jar // put together in the format: "a", "a-b", "a-b-c" + int loaderCount = 0; String modLoaders = ""; ((String) gradle.builds_for) .split(",") @@ -20,7 +20,13 @@ forgix { } modLoaders += loaderName; + + loaderCount++; } + + // run if there are multiple launchers that need merging + autoRun = (loaderCount > 1); + // merged jars are named in the format: // "DistantHorizons-3.0.1-b-dev-26.1-fabric-neoforge.jar" archiveClassifier = modLoaders From e3d6e1bcc6c81b572473aaa9f26f12958e02ef07 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 12 May 2026 07:32:57 -0500 Subject: [PATCH 57/68] use vanilla fog common --- .../cleanroom/mixins/client/MixinEntityRenderer.java | 12 +++--------- .../common/commonMixins/MixinVanillaFogCommon.java | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinEntityRenderer.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinEntityRenderer.java index fba494e58..bb9be72b2 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinEntityRenderer.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinEntityRenderer.java @@ -19,6 +19,7 @@ package com.seibel.distanthorizons.cleanroom.mixins.client; +import com.seibel.distanthorizons.common.commonMixins.MixinVanillaFogCommon; import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper; import com.seibel.distanthorizons.core.api.internal.ClientApi; import com.seibel.distanthorizons.core.config.Config; @@ -68,15 +69,8 @@ public class MixinEntityRenderer @Inject(at = @At("RETURN"), method = "setupFog") private void disableSetupFog(int startCoords, float partialTicks, CallbackInfo ci) { - boolean cameraNotInFluid = mc.getRenderViewEntity() != null && !mc.world.getBlockState(mc.getRenderViewEntity().getPosition()).getMaterial().isLiquid(); - - boolean isSpecialFog = mc.player.isPotionActive(MobEffects.BLINDNESS); - - if (!isSpecialFog - && cameraNotInFluid - && startCoords == 0 // 0 = terrain fog - && !SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class).isFogStateSpecial() - && !Config.Client.Advanced.Graphics.Fog.enableVanillaFog.get()) + boolean cancelFog = MixinVanillaFogCommon.cancelFog(startCoords, mc); + if (cancelFog) { GlStateManager.setFogStart(A_REALLY_REALLY_BIG_VALUE); GlStateManager.setFogEnd(A_EVEN_LARGER_VALUE); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java index cb6fa00d2..291fdcc62 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java @@ -92,7 +92,7 @@ public class MixinVanillaFogCommon boolean cancelFog = !isSpecialFog; cancelFog = cancelFog && cameraNotInFluid; #if MC_VER <= MC_1_12_2 - cancelFog = cancelFog && startCoords == 0; + cancelFog = cancelFog && startCoords == 0; // 0 = terrain fog #elif MC_VER < MC_1_21_6 cancelFog = cancelFog && (fogMode == FogRenderer.FogMode.FOG_TERRAIN); #endif From 7448483f8493f269be360f27d2ae676220008b8f Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 12 May 2026 08:02:26 -0500 Subject: [PATCH 58/68] revert option screen name for consistency --- .../cleanroom/mixins/client/MixinOptionsScreen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinOptionsScreen.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinOptionsScreen.java index 9cf4ca730..82fa8cb47 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinOptionsScreen.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinOptionsScreen.java @@ -66,7 +66,7 @@ public class MixinOptionsScreen extends GuiScreen // Create the button and tell it where to go // For now it goes to the client option by default // Add a title to the button - "DH" /* ModInfo.ID + ".title" */))); + ModInfo.ID + ".title"))); } From fbf812091d3bccc6834aa1a667adcbb3f3239353 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 12 May 2026 21:38:07 -0500 Subject: [PATCH 59/68] MC 1.12.2 refactoring and cleanup --- buildSrc/src/main/groovy/dh-loader.gradle | 1 + cleanroom/build.gradle | 4 +- .../cleanroom/CleanroomClientProxy.java | 28 +- .../cleanroom/CleanroomServerProxy.java | 18 +- .../mixins/server/MixinEntityPlayerMP.java | 16 +- .../common/commands/AbstractCommand.java | 5 +- .../common/commands/CommandInitializer.java | 4 + .../common/commands/ConfigCommand.java | 4 +- .../common/commands/CrashCommand.java | 2 +- .../common/commands/DebugCommand.java | 2 +- .../common/commands/PregenCommand.java | 2 +- .../commonMixins/MixinChunkMapCommon.java | 16 +- .../render/openGl/glObject/GLState.java | 7 + .../common/util/ProxyUtil.java | 12 +- .../wrappers/block/AbstractDhTintGetter.java | 10 +- .../common/wrappers/block/BiomeWrapper.java | 8 +- .../wrappers/block/BlockStateWrapper.java | 381 ++++++++++++++---- .../block/ClientBlockStateColorCache.java | 81 ++-- .../common/wrappers/gui/GetConfigScreen.java | 6 +- .../common/wrappers/gui/MinecraftScreen.java | 18 +- .../common/wrappers/gui/OnPressed.java | 1 + .../wrappers/world/ClientLevelWrapper.java | 3 +- gradle.properties | 2 +- versionProperties/1.12.2.properties | 2 +- 24 files changed, 458 insertions(+), 175 deletions(-) diff --git a/buildSrc/src/main/groovy/dh-loader.gradle b/buildSrc/src/main/groovy/dh-loader.gradle index 1e15021c3..82f62b6a0 100644 --- a/buildSrc/src/main/groovy/dh-loader.gradle +++ b/buildSrc/src/main/groovy/dh-loader.gradle @@ -566,6 +566,7 @@ if (isNotCommonProject) { outputs.file(output) doLast { output.withWriter("UTF-8") { writer -> + writer.writeLine("#PARSE_ESCAPES") new JsonSlurper() .parse(input) .each { key, value -> diff --git a/cleanroom/build.gradle b/cleanroom/build.gradle index 3124a395b..3f021d12b 100644 --- a/cleanroom/build.gradle +++ b/cleanroom/build.gradle @@ -43,4 +43,6 @@ sourcesJar { def commonSources = project(":common").sourcesJar dependsOn commonSources from commonSources.archiveFile.map { zipTree(it) } -} \ No newline at end of file +} + + diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomClientProxy.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomClientProxy.java index a86188d6d..f8fa56352 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomClientProxy.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomClientProxy.java @@ -59,13 +59,6 @@ import org.lwjgl.opengl.GL32; import java.util.concurrent.AbstractExecutorService; -/** - * This handles all events sent to the client, - * and is the starting point for most of the mod. - * - * @author James_Seibel - * @version 2023-7-27 - */ public class CleanroomClientProxy implements AbstractModInitializer.IEventProxy { private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class); @@ -124,6 +117,7 @@ public class CleanroomClientProxy implements AbstractModInitializer.IEventProxy //==============// // chunk events // //==============// + //region @SubscribeEvent public void rightClickBlockEvent(PlayerInteractEvent.RightClickBlock event) @@ -185,11 +179,14 @@ public class CleanroomClientProxy implements AbstractModInitializer.IEventProxy } } + //endregion + //==============// // key bindings // //==============// + //region @SubscribeEvent public void registerKeyBindings(InputEvent.KeyInputEvent event) @@ -206,10 +203,14 @@ public class CleanroomClientProxy implements AbstractModInitializer.IEventProxy ClientApi.INSTANCE.keyPressedEvent(event.getKey());*/ } + //endregion + + //===========// // rendering // //===========// + //region @SubscribeEvent public void afterLevelRenderEvent(TickEvent.RenderTickEvent event) @@ -231,11 +232,20 @@ public class CleanroomClientProxy implements AbstractModInitializer.IEventProxy } @SubscribeEvent - public void onRenderOverlay(RenderGameOverlayEvent.Text event) { + public void onRenderOverlay(RenderGameOverlayEvent.Text event) + { Minecraft mc = Minecraft.getMinecraft(); - if (event.isCanceled() || !mc.gameSettings.showDebugInfo) return; + if (event.isCanceled() + || !mc.gameSettings.showDebugInfo) + { + return; + } F3Screen.addStringToDisplay(event.getRight()); } + //endregion + + + } diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java index 12f5f23db..2d88eaebe 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/CleanroomServerProxy.java @@ -82,15 +82,18 @@ public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy //=============// // constructor // //=============// + //region public CleanroomServerProxy(boolean isDedicated) { this.isDedicated = isDedicated; } + //endregion + //========// // events // //========// - + //region // ServerLevelLoadEvent @SubscribeEvent @@ -132,9 +135,11 @@ public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy @SubscribeEvent public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event) { this.serverApi.serverPlayerJoinEvent(getServerPlayerWrapper(event)); } + @SubscribeEvent public void playerLoggedOutEvent(PlayerEvent.PlayerLoggedOutEvent event) { this.serverApi.serverPlayerDisconnectEvent(getServerPlayerWrapper(event)); } + @SubscribeEvent public void playerChangedDimensionEvent(PlayerEvent.PlayerChangedDimensionEvent event) { @@ -145,15 +150,17 @@ public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy ); } + //endregion + //================// // helper methods // //================// + //region private static ServerLevelWrapper getServerLevelWrapper(WorldServer level) { return ServerLevelWrapper.getWrapper(level); } - private static ServerLevelWrapper getServerLevelWrapper(int dimensionId, PlayerEvent event) { MinecraftServer server = event.player.getServer(); @@ -166,8 +173,9 @@ public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy } private static ServerPlayerWrapper getServerPlayerWrapper(PlayerEvent event) - { - return ServerPlayerWrapper.getWrapper((EntityPlayerMP) event.player); - } + { return ServerPlayerWrapper.getWrapper((EntityPlayerMP) event.player); } + + //endregion + } diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/server/MixinEntityPlayerMP.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/server/MixinEntityPlayerMP.java index 7f4c9f15c..300cb53f5 100644 --- a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/server/MixinEntityPlayerMP.java +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/server/MixinEntityPlayerMP.java @@ -46,23 +46,21 @@ public abstract class MixinEntityPlayerMP implements IMixinServerPlayer @Nullable private volatile WorldServer distantHorizons$dimensionChangeDestination; + + @Override @Nullable public WorldServer distantHorizons$getDimensionChangeDestination() - { - return this.distantHorizons$dimensionChangeDestination; - } + { return this.distantHorizons$dimensionChangeDestination; } @Inject(at = @At("HEAD"), method = "changeDimension(ILnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/entity/Entity;") public void setDimensionChangeDestination(int destinationDimensionID, ITeleporter teleporter, CallbackInfoReturnable cir) - { - this.distantHorizons$dimensionChangeDestination = this.server.getWorld(destinationDimensionID); - } + { this.distantHorizons$dimensionChangeDestination = this.server.getWorld(destinationDimensionID); } @Inject(at = @At("RETURN"), method = "clearInvulnerableDimensionChange") public void clearDimensionChangeDestination(CallbackInfo ci) - { - this.distantHorizons$dimensionChangeDestination = null; - } + { this.distantHorizons$dimensionChangeDestination = null; } + + } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/AbstractCommand.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/AbstractCommand.java index 43da2ede3..4e8d38eb0 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/AbstractCommand.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/AbstractCommand.java @@ -1,6 +1,9 @@ package com.seibel.distanthorizons.common.commands; -#if MC_VER > MC_1_12_2 +#if MC_VER <= MC_1_12_2 +public abstract class AbstractCommand {} + +#else import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.context.CommandContext; import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/CommandInitializer.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/CommandInitializer.java index 42a1739b5..ba0456a32 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/CommandInitializer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/CommandInitializer.java @@ -38,6 +38,8 @@ public class CommandInitializer private static final PermissionCheck COMMAND_PERMISSION_CHECK = new PermissionCheck.Require(Permissions.COMMANDS_OWNER); #endif + + #if MC_VER <= MC_1_12_2 public static ICommand initCommands() { @@ -98,7 +100,9 @@ public class CommandInitializer }; } + #else + /** * A received command dispatcher, which is held until the server is ready to initialize the commands. */ diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/ConfigCommand.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/ConfigCommand.java index a5057c27e..018d52078 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/ConfigCommand.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/ConfigCommand.java @@ -33,7 +33,7 @@ import java.util.function.ToIntBiFunction; /** * Command for managing config. */ -public class ConfigCommand #if MC_VER > MC_1_12_2 extends AbstractCommand #endif +public class ConfigCommand extends AbstractCommand { #if MC_VER <= MC_1_12_2 @SuppressWarnings({"unchecked", "rawtypes"}) @@ -94,7 +94,9 @@ public class ConfigCommand #if MC_VER > MC_1_12_2 extends AbstractCommand #endif } } } + #else + private static final List> commandArguments = Arrays.asList( new CommandArgumentData<>(Integer.class, configEntry -> integer(configEntry.getMin(), configEntry.getMax()), IntegerArgumentType::getInteger), new CommandArgumentData<>(Double.class, configEntry -> doubleArg(configEntry.getMin(), configEntry.getMax()), DoubleArgumentType::getDouble), diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/CrashCommand.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/CrashCommand.java index 4c064aca6..5b9fd17d2 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/CrashCommand.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/CrashCommand.java @@ -17,7 +17,7 @@ import static net.minecraft.commands.Commands.literal; #endif -public class CrashCommand #if MC_VER > MC_1_12_2 extends AbstractCommand #endif +public class CrashCommand extends AbstractCommand { #if MC_VER <= MC_1_12_2 public void execute(ICommandSender sender, String[] args) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/DebugCommand.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/DebugCommand.java index 7752dd066..77a21d783 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/DebugCommand.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/DebugCommand.java @@ -16,7 +16,7 @@ import java.util.ArrayList; import java.util.List; -public class DebugCommand #if MC_VER > MC_1_12_2 extends AbstractCommand #endif +public class DebugCommand extends AbstractCommand { private static String getDebugString() { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commands/PregenCommand.java b/common/src/main/java/com/seibel/distanthorizons/common/commands/PregenCommand.java index 8aa68bdb7..367b9d1be 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commands/PregenCommand.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commands/PregenCommand.java @@ -32,7 +32,7 @@ import java.util.concurrent.CancellationException; import java.util.concurrent.CompletableFuture; -public class PregenCommand #if MC_VER > MC_1_12_2 extends AbstractCommand #endif +public class PregenCommand extends AbstractCommand { private PregenManager getPregenManager() { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java index 3cbed11c8..b72886fb4 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java @@ -18,8 +18,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; public class MixinChunkMapCommon { - - public static void onChunkSave(#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif level, #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk #if MC_VER > MC_1_12_2, CallbackInfoReturnable ci #endif) + #if MC_VER <= MC_1_12_2 + public static void onChunkSave(WorldServer level, Chunk chunk) + #else + public static void onChunkSave(ServerLevel level, ChunkAccess chunk, CallbackInfoReturnable ci) + #endif { IServerLevelWrapper levelWrapper = ServerLevelWrapper.getWrapper(level); @@ -77,8 +80,13 @@ public class MixinChunkMapCommon // biome validation // // some chunks may be missing their biomes, which cause issues when attempting to save them - #if MC_VER <= MC_1_17_1 - if (chunk.#if MC_VER <= MC_1_12_2 getBiomeArray() #else getBiomes() #endif == null) + #if MC_VER <= MC_1_12_2 + if (chunk. getBiomeArray() == null) + { + return; + } + #elif MC_VER <= MC_1_17_1 + if (chunk.getBiomes() == null) { return; } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/GLState.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/GLState.java index b66c410b7..b5f9bb355 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/GLState.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/GLState.java @@ -182,13 +182,20 @@ public class GLState implements AutoCloseable if (frameBufferSet) { if (GL32.glIsTexture(this.frameBufferTexture0)) + { GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_TEXTURE_2D, this.frameBufferTexture0, 0); + } if (this.frameBufferTexture1 != 0 && GL32.glIsTexture(this.frameBufferTexture1)) + { GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT1, GL32.GL_TEXTURE_2D, this.frameBufferTexture1, 0); + } if (GL32.glIsTexture(this.frameBufferDepthTexture)) + { GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_DEPTH_ATTACHMENT, GL32.GL_TEXTURE_2D, this.frameBufferDepthTexture, 0); + } + } GL32.glBindVertexArray(GL32.glIsVertexArray(this.vao) ? this.vao : 0); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/util/ProxyUtil.java b/common/src/main/java/com/seibel/distanthorizons/common/util/ProxyUtil.java index 336ed4e8d..5af15153f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/util/ProxyUtil.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/util/ProxyUtil.java @@ -34,16 +34,22 @@ import net.minecraft.world.level.LevelAccessor; public class ProxyUtil { - public static ILevelWrapper getLevelWrapper(#if MC_VER <= MC_1_12_2 World #else LevelAccessor #endif level) + public static ILevelWrapper getLevelWrapper( + #if MC_VER <= MC_1_12_2 World #else LevelAccessor #endif level + ) { ILevelWrapper levelWrapper; if (level instanceof #if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif) { - levelWrapper = ServerLevelWrapper.getWrapper(#if MC_VER <= MC_1_12_2 (WorldServer) #else (ServerLevel) #endif level); + levelWrapper = ServerLevelWrapper.getWrapper( + #if MC_VER <= MC_1_12_2 (WorldServer) #else (ServerLevel) #endif level + ); } else { - levelWrapper = ClientLevelWrapper.getWrapper(#if MC_VER <= MC_1_12_2 (WorldClient) #else (ClientLevel) #endif level); + levelWrapper = ClientLevelWrapper.getWrapper( + #if MC_VER <= MC_1_12_2 (WorldClient) #else (ClientLevel) #endif level + ); } return levelWrapper; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/AbstractDhTintGetter.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/AbstractDhTintGetter.java index d25b3e4f7..e6361fb32 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/AbstractDhTintGetter.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/AbstractDhTintGetter.java @@ -49,8 +49,6 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter #endif private static final ConcurrentHashMap COLOR_BY_BLOCK_BIOME_PAIR = new ConcurrentHashMap<>(); - /** returned if the color cache is incomplete */ - public static final int INVALID_COLOR = -1; protected BiomeWrapper biomeWrapper; @@ -102,7 +100,7 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter * Can be called by DH directly, skipping some of MC's logic * to speed up tint getting slightly. * - * @return {@link AbstractDhTintGetter#INVALID_COLOR} if any of the biomes needed for this position + * @return {@link ClientBlockStateColorCache#INVALID_COLOR} if any of the biomes needed for this position * were not cached. In that case calling {@link AbstractDhTintGetter#getBlockTint(BlockPos, ColorResolver)} * will need to be called by MC's ColorResolver so we can * populate the color cache. @@ -163,9 +161,9 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter int id = FullDataPointUtil.getId(dataPoint); BiomeWrapper biomeWrapper = (BiomeWrapper) this.fullDataSource.mapping.getBiomeWrapper(id); int color = this.tryGetClientBiomeColor(colorResolver, biomeWrapper); - if (color == INVALID_COLOR) + if (color == ClientBlockStateColorCache.INVALID_COLOR) { - return INVALID_COLOR; + return ClientBlockStateColorCache.INVALID_COLOR; } @@ -214,7 +212,7 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter // no color resolver is present, // the cache needs to be populated before // we can use the fast path - return INVALID_COLOR; + return ClientBlockStateColorCache.INVALID_COLOR; } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java index 5106c5e37..593717c16 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java @@ -342,7 +342,9 @@ public class BiomeWrapper implements IBiomeWrapper } } - public static BiomeDeserializeResult deserializeBiome(String resourceLocationString #if MC_VER > MC_1_12_2, net.minecraft.core.RegistryAccess registryAccess #endif) throws IOException + public static BiomeDeserializeResult deserializeBiome(String resourceLocationString + #if MC_VER > MC_1_12_2, net.minecraft.core.RegistryAccess registryAccess #endif + ) throws IOException { // parse the resource location int separatorIndex = resourceLocationString.indexOf(":"); @@ -373,10 +375,10 @@ public class BiomeWrapper implements IBiomeWrapper boolean success; - #if MC_VER == MC_1_12_2 + #if MC_VER <= MC_1_12_2 Biome biome = Biome.REGISTRY.getObject(resourceLocation); success = (biome != null); - #elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + #elif MC_VER <= MC_1_17_1 Biome biome = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).get(resourceLocation); success = (biome != null); #elif MC_VER <= MC_1_19_2 diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index 9518a969d..59c1428ee 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -153,33 +153,58 @@ public class BlockStateWrapper implements IBlockStateWrapper // constructors // //==============// //region - #if MC_VER <= MC_1_12_2 /** - * Can be faster than {@link BlockStateWrapper#fromBlockState(IBlockState, ILevelWrapper)} + * Can be faster than BlockStateWrapper#fromBlockState(BlockState, ILevelWrapper) * in cases where the same block state is expected to be referenced multiple times. */ - #else - /** - * Can be faster than {@link BlockStateWrapper#fromBlockState(BlockState, ILevelWrapper)} - * in cases where the same block state is expected to be referenced multiple times. - */ - #endif - public static BlockStateWrapper fromBlockState(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, ILevelWrapper levelWrapper, IBlockStateWrapper guess) + public static BlockStateWrapper fromBlockState( + #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, + ILevelWrapper levelWrapper, IBlockStateWrapper guess) { - #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif guessBlockState = (guess == null || guess.isAir()) ? null : (#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif) guess.getWrappedMcObject(); - #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif inputBlockState = (blockState == null || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.AIR #else blockState.isAir() #endif) ? null : blockState; - - if (guess instanceof BlockStateWrapper - && guessBlockState == inputBlockState) - { - return (BlockStateWrapper) guess; - } - else + if (guess == null) { return fromBlockState(blockState, levelWrapper); } + + + // guess block state + BlockStateWrapper wrapperGuess = (BlockStateWrapper) guess; + #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif guessBlockState; + if(isAir(wrapperGuess.blockState)) + { + guessBlockState = null; + } + else + { + #if MC_VER <= MC_1_12_2 + guessBlockState = (IBlockState) guess.getWrappedMcObject(); + #else + guessBlockState = (BlockState) guess.getWrappedMcObject(); + #endif + } + + // input block state + #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif inputBlockState; + if (isAir(blockState)) + { + inputBlockState = null; + } + else + { + inputBlockState = blockState; + } + + + if (guessBlockState == inputBlockState) + { + return (BlockStateWrapper) guess; + } + + return fromBlockState(blockState, levelWrapper); } - public static BlockStateWrapper fromBlockState(@Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, ILevelWrapper levelWrapper) + public static BlockStateWrapper fromBlockState( + @Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, + ILevelWrapper levelWrapper) { // air is a special case if (isAir(blockState)) @@ -248,13 +273,13 @@ public class BlockStateWrapper implements IBlockStateWrapper } else { - #if MC_VER <= MC_1_12_2 - this.isLiquid = this.blockState.getMaterial().isLiquid() || this.blockState.getBlock() instanceof IFluidBlock; - #elif MC_VER < MC_1_20_1 - this.isLiquid = this.blockState.getMaterial().isLiquid() || !this.blockState.getFluidState().isEmpty(); - #else - this.isLiquid = !this.blockState.getFluidState().isEmpty(); - #endif + #if MC_VER <= MC_1_12_2 + this.isLiquid = this.blockState.getMaterial().isLiquid() || this.blockState.getBlock() instanceof IFluidBlock; + #elif MC_VER < MC_1_20_1 + this.isLiquid = this.blockState.getMaterial().isLiquid() || !this.blockState.getFluidState().isEmpty(); + #else + this.isLiquid = !this.blockState.getFluidState().isEmpty(); + #endif } } @@ -349,7 +374,7 @@ public class BlockStateWrapper implements IBlockStateWrapper // beacon tint color Color beaconTintColor = null; - // 1.12.2 doesn't have block for beacon beam + // 1.12.2 doesn't support changing the beacon beam color #if MC_VER > MC_1_12_2 if (this.blockState != null // beacon blocks also show up here, but since they block the beacon beam we don't want their color @@ -462,71 +487,188 @@ public class BlockStateWrapper implements IBlockStateWrapper @Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, String lowercaseSerialString, boolean isLiquid - ) + ) { - if (blockState == null) + if (isAir(blockState)) { return EDhApiBlockMaterial.AIR; } - if (#if MC_VER <= MC_1_12_2 blockState.getBlock() instanceof BlockLeaves #else blockState.is(BlockTags.LEAVES) #endif + + //========// + // leaves // + //========// + //region + + boolean isLeafBlock; + #if MC_VER <= MC_1_12_2 + isLeafBlock = blockState.getBlock() instanceof BlockLeaves; + #else + isLeafBlock = blockState.is(BlockTags.LEAVES); + #endif + if (isLeafBlock || lowercaseSerialString.contains("bamboo") || lowercaseSerialString.contains("cactus") || lowercaseSerialString.contains("chorus_flower") || lowercaseSerialString.contains("mushroom") - ) + ) { return EDhApiBlockMaterial.LEAVES; } - else if (#if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.LAVA || blockState.getBlock() == Blocks.FLOWING_LAVA #else blockState.is(Blocks.LAVA) #endif) + //endregion + + + + //======// + // lava // + //======// + //region + + boolean isLavaBlock; + #if MC_VER <= MC_1_12_2 + isLavaBlock = blockState.getBlock() == Blocks.LAVA || blockState.getBlock() == Blocks.FLOWING_LAVA; + #else + isLavaBlock = blockState.is(Blocks.LAVA); + #endif + if (isLavaBlock) { return EDhApiBlockMaterial.LAVA; } - else if (isLiquid || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.WATER || blockState.getBlock() == Blocks.FLOWING_WATER #else blockState.is(Blocks.WATER) #endif) + + //endregion + + + + //=======// + // water // + //=======// + //region + + boolean isWaterBlock; + #if MC_VER <= MC_1_12_2 + isWaterBlock = blockState.getBlock() == Blocks.WATER || blockState.getBlock() == Blocks.FLOWING_WATER; + #else + isWaterBlock = blockState.is(Blocks.WATER); + #endif + if (isLiquid + || isWaterBlock) { return EDhApiBlockMaterial.WATER; } - else if (#if MC_VER <= MC_1_12_2 blockState.getBlock().getSoundType() #else blockState.getSoundType() #endif == SoundType.WOOD + + //endregion + + + + //======// + // wood // + //======// + //region + + boolean isWoodSoundingBlock; + #if MC_VER <= MC_1_12_2 + isWoodSoundingBlock = blockState.getBlock().getSoundType() == SoundType.WOOD; + #else + isWoodSoundingBlock = blockState.getSoundType() == SoundType.WOOD; + #endif + + boolean isCherryWood; + #if MC_VER <= MC_1_19_2 + isCherryWood = false; + #else + isWoodSoundingBlock = blockState.getSoundType() == SoundType.CHERRY_WOOD; + #endif + + if (isWoodSoundingBlock || lowercaseSerialString.contains("root") - #if MC_VER >= MC_1_19_4 - || blockState.getSoundType() == SoundType.CHERRY_WOOD - #endif - ) + || isCherryWood + ) { return EDhApiBlockMaterial.WOOD; } - else if (#if MC_VER <= MC_1_12_2 blockState.getBlock().getSoundType() #else blockState.getSoundType() #endif == SoundType.METAL - #if MC_VER >= MC_1_19_2 - || blockState.getSoundType() == SoundType.COPPER - #endif - #if MC_VER >= MC_1_20_4 - || blockState.getSoundType() == SoundType.COPPER_BULB - || blockState.getSoundType() == SoundType.COPPER_GRATE - #endif - ) + + //endregion + + + + //=======// + // metal // + //=======// + //region + + boolean isMetalSoundingBlock; + #if MC_VER <= MC_1_12_2 + isMetalSoundingBlock = blockState.getBlock().getSoundType() == SoundType.METAL; + #else + isMetalSoundingBlock = blockState.getSoundType() == SoundType.METAL; + #endif + + boolean isCopperSounding; + #if MC_VER <= MC_1_18_2 + isCopperSounding = false; + #elif MC_VER <= MC_1_20_2 + isCopperSounding = blockState.getSoundType() == SoundType.COPPER + #else + isCopperSounding + = blockState.getSoundType() == SoundType.COPPER + || blockState.getSoundType() == SoundType.COPPER_BULB + || blockState.getSoundType() == SoundType.COPPER_GRATE; + #endif + + if (isMetalSoundingBlock + || isCopperSounding) { return EDhApiBlockMaterial.METAL; } - else if ( - lowercaseSerialString.contains("grass_block") - || lowercaseSerialString.contains("grass_slab") - ) + + //endregion + + + + //=======// + // grass // + //=======// + //region + + if (lowercaseSerialString.contains("grass_block") + || lowercaseSerialString.contains("grass_slab") + ) { return EDhApiBlockMaterial.GRASS; } - else if ( + + //endregion + + + + //======// + // dirt // + //======// + //region + + if ( lowercaseSerialString.contains("dirt") - || lowercaseSerialString.contains("gravel") - || lowercaseSerialString.contains("mud") - || lowercaseSerialString.contains("podzol") - || lowercaseSerialString.contains("mycelium") - ) + || lowercaseSerialString.contains("gravel") + || lowercaseSerialString.contains("mud") + || lowercaseSerialString.contains("podzol") + || lowercaseSerialString.contains("mycelium") + ) { return EDhApiBlockMaterial.DIRT; } + + //endregion + + + + //===========// + // deepslate // + //===========// + //region + #if MC_VER >= MC_1_17_1 - else if (blockState.getSoundType() == SoundType.DEEPSLATE + if (blockState.getSoundType() == SoundType.DEEPSLATE || blockState.getSoundType() == SoundType.DEEPSLATE_BRICKS || blockState.getSoundType() == SoundType.DEEPSLATE_TILES || blockState.getSoundType() == SoundType.POLISHED_DEEPSLATE @@ -535,35 +677,68 @@ public class BlockStateWrapper implements IBlockStateWrapper return EDhApiBlockMaterial.DEEPSLATE; } #endif - else if (lowercaseSerialString.contains("snow")) - { - return EDhApiBlockMaterial.SNOW; - } - else if (lowercaseSerialString.contains("sand")) - { - return EDhApiBlockMaterial.SAND; - } - else if (lowercaseSerialString.contains("terracotta")) - { - return EDhApiBlockMaterial.TERRACOTTA; - } - else if (#if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.NETHERRACK #else blockState.is(BlockTags.BASE_STONE_NETHER) #endif) + + //endregion + + + + //============// + // netherrack // + //============// + //region + + boolean isNetherRack; + #if MC_VER <= MC_1_12_2 + isNetherRack = blockState.getBlock() == Blocks.NETHERRACK; + #else + isNetherRack = blockState.is(BlockTags.BASE_STONE_NETHER); + #endif + + if (isNetherRack) { return EDhApiBlockMaterial.NETHER_STONE; } - else if (lowercaseSerialString.contains("stone") + + //endregion + + + + //=============// + // misc/simple // + //=============// + //region + + if (lowercaseSerialString.contains("snow")) + { + return EDhApiBlockMaterial.SNOW; + } + + if (lowercaseSerialString.contains("sand")) + { + return EDhApiBlockMaterial.SAND; + } + + if (lowercaseSerialString.contains("terracotta")) + { + return EDhApiBlockMaterial.TERRACOTTA; + } + + if (lowercaseSerialString.contains("stone") || lowercaseSerialString.contains("ore")) { return EDhApiBlockMaterial.STONE; } - else if (#if MC_VER <= MC_1_12_2 blockState.getLightValue() #else blockState.getLightEmission() #endif > 0) + + if (getLightEmission(blockState) > 0) { return EDhApiBlockMaterial.ILLUMINATED; } - else - { - return EDhApiBlockMaterial.UNKNOWN; - } + + //endregion + + + + return EDhApiBlockMaterial.UNKNOWN; } private static int calculateOpacity( @@ -691,8 +866,10 @@ public class BlockStateWrapper implements IBlockStateWrapper return waterSurfaceReplacementBlocks; } - ObjectOpenHashSet baseIgnoredBlock = new ObjectOpenHashSet<>(); - waterSurfaceReplacementBlocks = getAllBlockWrappers(Config.Client.Advanced.Graphics.Culling.waterSurfaceBlockReplacementCsv, baseIgnoredBlock, levelWrapper); + ObjectOpenHashSet baseIgnoredBlockResourceSet = new ObjectOpenHashSet<>(); + waterSurfaceReplacementBlocks = getAllBlockWrappers(Config.Client.Advanced.Graphics.Culling.waterSurfaceBlockReplacementCsv, baseIgnoredBlockResourceSet, levelWrapper); + waterSubsurfaceReplacementBlocks.remove(AIR); + return waterSurfaceReplacementBlocks; } public static ObjectOpenHashSet getWaterSubsurfaceReplacementBlocks(ILevelWrapper levelWrapper) @@ -703,8 +880,10 @@ public class BlockStateWrapper implements IBlockStateWrapper return waterSubsurfaceReplacementBlocks; } - ObjectOpenHashSet baseIgnoredBlock = new ObjectOpenHashSet<>(); - waterSubsurfaceReplacementBlocks = getAllBlockWrappers(Config.Client.Advanced.Graphics.Culling.waterSubSurfaceBlockReplacementCsv, baseIgnoredBlock, levelWrapper); + ObjectOpenHashSet baseIgnoredBlockResourceSet = new ObjectOpenHashSet<>(); + waterSubsurfaceReplacementBlocks = getAllBlockWrappers(Config.Client.Advanced.Graphics.Culling.waterSubSurfaceBlockReplacementCsv, baseIgnoredBlockResourceSet, levelWrapper); + // air will be present if any invalid resource locations are present + // but we don't want to replace air with water, that'll cause monoliths waterSubsurfaceReplacementBlocks.remove(AIR); return waterSubsurfaceReplacementBlocks; @@ -826,7 +1005,21 @@ public class BlockStateWrapper implements IBlockStateWrapper public int getOpacity() { return this.opacity; } @Override - public int getLightEmission() { return (this.blockState != null) ? #if MC_VER <= MC_1_12_2 this.blockState.getLightValue() #else this.blockState.getLightEmission() #endif : 0; } + public int getLightEmission() { return getLightEmission(this.blockState); } + public static int getLightEmission(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState) + { + if (blockState == null) + { + return 0; + } + + #if MC_VER <= MC_1_12_2 + return blockState.getLightValue(); + #else + return blockState.getLightEmission(); + #endif + } + @Override public String getSerialString() { return this.serialString; } @@ -836,7 +1029,19 @@ public class BlockStateWrapper implements IBlockStateWrapper @Override public boolean isAir() { return isAir(this.blockState); } - public static boolean isAir(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState) { return blockState == null || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.AIR #else blockState.isAir() #endif; } + public static boolean isAir(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState) + { + if (blockState == null) + { + return true; + } + + #if MC_VER <= MC_1_12_2 + return blockState.getBlock() == Blocks.AIR; + #else + return blockState.isAir(); + #endif + } @Override public boolean isSolid() { return this.isSolid; } @@ -1056,7 +1261,12 @@ public class BlockStateWrapper implements IBlockStateWrapper } } - foundState = #if MC_VER <= MC_1_12_2 block.getDefaultState() #else block.defaultBlockState() #endif; + + #if MC_VER <= MC_1_12_2 + foundState = block.getDefaultState(); + #else + foundState = block.defaultBlockState(); + #endif } foundWrapper = fromBlockState(foundState, levelWrapper); @@ -1086,12 +1296,13 @@ public class BlockStateWrapper implements IBlockStateWrapper // get the property list for this block (doesn't contain this block state's values, just the names and possible values) #if MC_VER <= MC_1_12_2 java.util.Collection> blockPropertyCollection = blockState.getPropertyKeys(); + List> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection); #else java.util.Collection> blockPropertyCollection = blockState.getProperties();; + List> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection); #endif // alphabetically sort the list so they are always in the same order - List<#if MC_VER <= MC_1_12_2 IProperty #else net.minecraft.world.level.block.state.properties.Property #endif> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection); sortedBlockPropteryList.sort((a, b) -> a.getName().compareTo(b.getName())); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java index d6114790a..9514bc0bb 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java @@ -94,7 +94,11 @@ public class ClientBlockStateColorCache private static final Minecraft MC = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif; - private static final HashSet<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif> BLOCK_STATES_THAT_NEED_LEVEL = new HashSet<>(); + #if MC_VER <= MC_1_12_2 + #else + private static final HashSet BLOCK_STATES_THAT_NEED_LEVEL = new HashSet<>(); + #endif + private static final HashSet<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif> BROKEN_BLOCK_STATES = new HashSet<>(); /** @@ -107,6 +111,8 @@ public class ClientBlockStateColorCache */ private static final ReentrantLock RESOLVE_LOCK = new ReentrantLock(); + public static final int INVALID_COLOR = -1; + /** This is the order each direction on a block is processed when attempting to get the texture/color */ private static final @Nullable #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif[] COLOR_RESOLUTION_DIRECTION_ORDER = @@ -225,7 +231,9 @@ public class ClientBlockStateColorCache //=============// //region - public ClientBlockStateColorCache(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, IClientLevelWrapper clientLevelWrapper) + public ClientBlockStateColorCache( + #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, + IClientLevelWrapper clientLevelWrapper) { this.blockState = blockState; this.blockStateWrapper = BlockStateWrapper.fromBlockState(blockState, clientLevelWrapper); @@ -241,6 +249,7 @@ public class ClientBlockStateColorCache //===================// // color calculation // //===================// + //region private void resolveColors() { @@ -268,11 +277,7 @@ public class ClientBlockStateColorCache } #endif - #if MC_VER <= MC_1_12_2 - if (!this.blockState.getMaterial().isLiquid()) - #else - if (this.blockState.getFluidState().isEmpty()) - #endif + if (!this.blockStateWrapper.isLiquid()) { // look for the first non-empty direction List quads = null; @@ -593,6 +598,8 @@ public class ClientBlockStateColorCache EColorMode.getColorMode(this.blockState.getBlock())); } + //endregion + //===============// @@ -602,11 +609,7 @@ public class ClientBlockStateColorCache public int getColor(BiomeWrapper biomeWrapper, FullDataSourceV2 fullDataSource, DhBlockPos blockPos) { // only get the tint if the block needs to be tinted - #if MC_VER <= MC_1_12_2 - int tintColor = -1; - #else - int tintColor = AbstractDhTintGetter.INVALID_COLOR; - #endif + int tintColor = INVALID_COLOR; if (this.needPostTinting) { @@ -624,8 +627,10 @@ public class ClientBlockStateColorCache // 1.12.2 doesn't have BlockAndTintGetter -> get tintColor from biome WorldClient world = (WorldClient) this.clientLevelWrapper.getWrappedMcObject(); BlockPos mcPos = new BlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + Block block = this.blockState.getBlock(); - if (block instanceof BlockGrass || block instanceof BlockBush) + if (block instanceof BlockGrass + || block instanceof BlockBush) { tintColor = biomeWrapper.biome.getGrassColorAtPos(mcPos); } @@ -635,7 +640,8 @@ public class ClientBlockStateColorCache } else if (block instanceof BlockLiquid) // We don't want lava to fall into the else block { - if(block == Blocks.WATER || block == Blocks.FLOWING_WATER) + if(block == Blocks.WATER + || block == Blocks.FLOWING_WATER) { tintColor = biomeWrapper.biome.getWaterColor(); } @@ -721,29 +727,32 @@ public class ClientBlockStateColorCache } } #endif - // level-specific logic is only needed for MC 1.21.11 and older - #if MC_VER <= MC_1_21_11 && MC_VER > MC_1_12_2 - // use the level logic only if requested - if (BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState)) - { - // the level shouldn't be used all the time due to it breaking some blocks tinting - // specifically oceans don't render correctly - TintGetterOverride tintOverride = TintOverrideGetter.get(); - tintOverride.update(biomeWrapper, this.blockStateWrapper, fullDataSource, this.clientLevelWrapper); - tintColor = tintOverride.tryGetBlockTint(new DhBlockPosMutable(blockPos)); - if (tintColor == AbstractDhTintGetter.INVALID_COLOR) + // level-specific logic is only needed for MC 1.21.11 and older + #if MC_VER <= MC_1_21_11 && MC_VER > MC_1_12_2 + // use the level logic only if requested + if (BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState)) { - tintColor = Minecraft.getInstance() - .getBlockColors() - .getColor(this.blockState, - tintOverride, - McObjectConverter.Convert(blockPos), - this.tintIndex); + // the level shouldn't be used all the time due to it breaking some blocks tinting + // specifically oceans don't render correctly + + TintGetterOverride tintOverride = TintOverrideGetter.get(); + tintOverride.update(biomeWrapper, this.blockStateWrapper, fullDataSource, this.clientLevelWrapper); + + tintColor = tintOverride.tryGetBlockTint(new DhBlockPosMutable(blockPos)); + if (tintColor == AbstractDhTintGetter.INVALID_COLOR) + { + tintColor = Minecraft.getInstance() + .getBlockColors() + .getColor(this.blockState, + tintOverride, + McObjectConverter.Convert(blockPos), + this.tintIndex); + } } - } - #endif + #endif + } catch (Exception e) { @@ -758,11 +767,7 @@ public class ClientBlockStateColorCache int returnColor; - #if MC_VER <= MC_1_12_2 - if (tintColor != -1) - #else - if (tintColor != AbstractDhTintGetter.INVALID_COLOR) - #endif + if (tintColor != INVALID_COLOR) { returnColor = ColorUtil.multiplyARGBwithRGB(this.baseColor, tintColor); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GetConfigScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GetConfigScreen.java index 9e57db5a7..6b86db0b1 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GetConfigScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GetConfigScreen.java @@ -15,7 +15,11 @@ public class GetConfigScreen { protected static final DhLogger LOGGER = new DhLoggerBuilder().build(); - public static #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif getScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent) + #if MC_VER <= MC_1_12_2 + public static GuiScreen getScreen(GuiScreen parent) + #else + public static Screen getScreen(Screen parent) + #endif { if (ModInfo.IS_DEV_BUILD) { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java index faffcc0dd..52a334b9d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java @@ -34,7 +34,11 @@ import java.util.*; public class MinecraftScreen { - public static #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif getScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, AbstractScreen screen, String translationName) + #if MC_VER <= MC_1_12_2 + public static GuiScreen getScreen(GuiScreen parent, AbstractScreen screen, String translationName) + #else + public static Screen getScreen(Screen parent, AbstractScreen screen, String translationName) + #endif { return new ConfigScreenRenderer(parent, screen, translationName); } @@ -56,7 +60,9 @@ public class MinecraftScreen { return net.minecraft.network.chat.Component.translatable(str, args); } #endif - protected ConfigScreenRenderer(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, AbstractScreen screen, String translationName) + protected ConfigScreenRenderer( + #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, + AbstractScreen screen, String translationName) { super(translate(translationName)); #if MC_VER <= MC_1_12_2 @@ -77,7 +83,13 @@ public class MinecraftScreen protected void init() #endif { - super.#if MC_VER <= MC_1_12_2 initGui(); #else init(); #endif // Init Minecraft's screen + #if MC_VER <= MC_1_12_2 + super.initGui(); + #else + super.init(); + #endif + + #if MC_VER <= MC_1_12_2 this.screen.width = Display.getWidth(); this.screen.height = Display.getHeight(); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/OnPressed.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/OnPressed.java index 41bc58650..3227ab477 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/OnPressed.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/OnPressed.java @@ -1,4 +1,5 @@ package com.seibel.distanthorizons.common.wrappers.gui; + #if MC_VER <= MC_1_12_2 import net.minecraft.client.gui.GuiButton; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java index 11f1173b5..cdfaa5cc8 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java @@ -85,7 +85,8 @@ public class ClientLevelWrapper implements IClientLevelWrapper private final ConcurrentHashMap<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, ClientBlockStateColorCache> blockColorCacheByBlockState = new ConcurrentHashMap<>(); /** cached method reference to reduce GC overhead */ - private final Function<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, ClientBlockStateColorCache> createCachedBlockColorCacheFunc = (blockState) -> new ClientBlockStateColorCache(blockState, this); + private final Function<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, ClientBlockStateColorCache> createCachedBlockColorCacheFunc + = (blockState) -> new ClientBlockStateColorCache(blockState, this); private boolean cloudColorFailLogged = false; diff --git a/gradle.properties b/gradle.properties index 1287140ff..38f2d23ff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -48,7 +48,7 @@ versionStr= # This defines what MC version Intellij will use for the preprocessor # and what version is used automatically by build and run commands -mcVer=26.1.2 +mcVer=1.12.2 # Defines the maximum amount of memory Minecraft is allowed when run in a development environment minecraftMemoryJavaArg=-Xmx6G diff --git a/versionProperties/1.12.2.properties b/versionProperties/1.12.2.properties index 46a1d6323..48ab26d05 100644 --- a/versionProperties/1.12.2.properties +++ b/versionProperties/1.12.2.properties @@ -8,7 +8,7 @@ builds_for=cleanroom embed_joml=true # Netty -netty_version=4.2.9.Final +netty_version=4.1.9.Final # LWJGL lwjgl_version=3.3.6 From 391e96ad3da5880c8b37612779f77035809e07df Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 12 May 2026 21:54:03 -0500 Subject: [PATCH 60/68] abstract mod init cleanup --- .../distanthorizons/common/AbstractModInitializer.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java b/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java index 7aef99145..17bec1ddc 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java @@ -154,7 +154,14 @@ public abstract class AbstractModInitializer this.checkForUpdates(); - LOGGER.info(ModInfo.READABLE_NAME + " server Initialized at " + server.#if MC_VER <= MC_1_12_2 getDataDirectory() #else getServerDirectory() #endif); + String serverFolderPath; + #if MC_VER <= MC_1_12_2 + serverFolderPath = server.getDataDirectory() + ""; + #else + serverFolderPath = server.getServerDirectory() + ""; + #endif + + LOGGER.info(ModInfo.READABLE_NAME + " server Initialized at " + serverFolderPath); }); } From e087dbc878e1628d89dab4020ff02094729020ff Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 12 May 2026 21:56:30 -0500 Subject: [PATCH 61/68] temp unit test disable --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index b674f4960..e3f586da5 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit b674f49600184a94d4b83888e5a50df4b8f065b7 +Subproject commit e3f586da5698c8529a249b0214d58bb95f27143d From 5ab6bfb6635a770f1a9cdd912e372ac135a5cd9a Mon Sep 17 00:00:00 2001 From: James Seibel Date: Wed, 13 May 2026 07:49:18 -0500 Subject: [PATCH 62/68] preprocessor cleanup --- buildSrc/src/main/groovy/dh-loader.gradle | 9 ++- .../block/ClientBlockStateColorCache.java | 45 +++++++------- .../common/wrappers/chunk/ChunkWrapper.java | 59 ++++++++++++++++--- .../common/wrappers/gui/GuiHelper.java | 21 +++---- .../gui/classicConfig/ClassicConfigGUI.java | 24 ++++++-- .../level/KeyedClientLevelManager.java | 8 ++- .../level/ServerKeyedClientLevelWrapper.java | 6 +- .../minecraft/MinecraftClientWrapper.java | 29 +++++++-- .../minecraft/MinecraftRenderWrapper.java | 7 ++- .../minecraft/MinecraftServerWrapper.java | 6 +- 10 files changed, 159 insertions(+), 55 deletions(-) diff --git a/buildSrc/src/main/groovy/dh-loader.gradle b/buildSrc/src/main/groovy/dh-loader.gradle index 82f62b6a0..852d42f23 100644 --- a/buildSrc/src/main/groovy/dh-loader.gradle +++ b/buildSrc/src/main/groovy/dh-loader.gradle @@ -413,9 +413,12 @@ if (isNotCommonProject) { modsDir.mkdirs() // Remove any stale DH jars before copying the fresh one - modsDir.listFiles()?.each { file -> - if (file.name.startsWith(rootProject.mod_name)) file.delete() - } + modsDir.listFiles()?.each({ file -> + if (file.name.startsWith(rootProject.mod_name)) + { + file.delete() + } + }); // Copy shadow jar into mods folder so (Neo)Forge discovers it properly copy { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java index 9514bc0bb..822929250 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java @@ -71,28 +71,23 @@ import net.minecraft.core.BlockPos; import net.minecraft.client.color.block.BlockTintSource; #endif -#if MC_VER <= MC_1_12_2 /** * This stores and calculates the colors - * the given {@link IBlockState} should have based + * the given BlockState should have based * on the given {@link IClientLevelWrapper}. * * @see ColorUtil */ -#else -/** - * This stores and calculates the colors - * the given {@link BlockState} should have based - * on the given {@link IClientLevelWrapper}. - * - * @see ColorUtil - */ - #endif public class ClientBlockStateColorCache { private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - private static final Minecraft MC = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif; + #if MC_VER <= MC_1_12_2 + private static final Minecraft MC = Minecraft.getMinecraft(); + #else + private static final Minecraft MC = Minecraft.getInstance(); + #endif + #if MC_VER <= MC_1_12_2 #else @@ -115,15 +110,17 @@ public class ClientBlockStateColorCache /** This is the order each direction on a block is processed when attempting to get the texture/color */ - private static final @Nullable #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif[] COLOR_RESOLUTION_DIRECTION_ORDER = + private static final @Nullable + #if MC_VER <= MC_1_12_2 EnumFacing[] #else Direction[] #endif + COLOR_RESOLUTION_DIRECTION_ORDER = { - #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.UP, + #if MC_VER <= MC_1_12_2 EnumFacing.UP #else Direction.UP #endif, null, // null represents "unculled" faces, IE the top of farmland - #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.NORTH, - #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.EAST, - #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.WEST, - #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.SOUTH, - #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.DOWN + #if MC_VER <= MC_1_12_2 EnumFacing.NORTH #else Direction.NORTH #endif, + #if MC_VER <= MC_1_12_2 EnumFacing.EAST #else Direction.EAST #endif, + #if MC_VER <= MC_1_12_2 EnumFacing.WEST #else Direction.WEST #endif, + #if MC_VER <= MC_1_12_2 EnumFacing.SOUTH #else Direction.SOUTH #endif, + #if MC_VER <= MC_1_12_2 EnumFacing.DOWN #else Direction.DOWN #endif }; private static final int FLOWER_COLOR_SCALE = 5; @@ -281,8 +278,16 @@ public class ClientBlockStateColorCache { // look for the first non-empty direction List quads = null; - for (#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif direction : COLOR_RESOLUTION_DIRECTION_ORDER) + + #if MC_VER <= MC_1_12_2 + EnumFacing direction; + #else + Direction direction; + #endif + + for (int i = 0; i < COLOR_RESOLUTION_DIRECTION_ORDER.length; i++) { + direction = COLOR_RESOLUTION_DIRECTION_ORDER[i]; quads = this.getQuadsForDirection(direction); if (quads != null && !quads.isEmpty() && !( diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java index 0e2892883..6290ce269 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java @@ -74,7 +74,8 @@ import net.minecraft.world.level.chunk.LevelChunkSection; import net.minecraft.world.level.chunk.LevelChunkSection; #endif -#if MC_VER <= MC_1_20_4 && MC_VER > MC_1_12_2 +#if MC_VER <= MC_1_12_2 +#elif MC_VER <= MC_1_20_4 import net.minecraft.world.level.chunk.ChunkStatus; #elif MC_VER > MC_1_12_2 import net.minecraft.world.level.chunk.status.ChunkStatus; @@ -93,8 +94,12 @@ public class ChunkWrapper implements IChunkWrapper private static boolean heightmapThreadWarningLogged = false; + #if MC_VER <= MC_1_12_2 + private final Chunk chunk; + #else + private final ChunkAccess chunk; + #endif - private final #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk; private final DhChunkPos chunkPos; private final ILevelWrapper wrappedLevel; @@ -125,7 +130,9 @@ public class ChunkWrapper implements IChunkWrapper * fast since it will be called frequently on the MC * server thread and a slow method will cause server lag. */ - public ChunkWrapper(#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk, ILevelWrapper wrappedLevel) + public ChunkWrapper( + #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk, + ILevelWrapper wrappedLevel) { this.chunk = chunk; this.wrappedLevel = wrappedLevel; @@ -257,7 +264,9 @@ public class ChunkWrapper implements IChunkWrapper return this.maxNonEmptyHeight; } - private static boolean isChunkSectionEmpty(#if MC_VER <= MC_1_12_2 ExtendedBlockStorage #else LevelChunkSection #endif section) + private static boolean isChunkSectionEmpty( + #if MC_VER <= MC_1_12_2 ExtendedBlockStorage #else LevelChunkSection #endif section + ) { #if MC_VER <= MC_1_17_1 return section.isEmpty(); @@ -373,8 +382,12 @@ public class ChunkWrapper implements IChunkWrapper public IBiomeWrapper getBiome(int relX, int relY, int relZ) { #if MC_VER <= MC_1_12_2 + BlockPos.MutableBlockPos blockPos = MUTABLE_BLOCK_POS_REF.get(); + blockPos.setPos(relX, relY, relZ); + World world = (World) this.wrappedLevel.getWrappedMcObject(); - return BiomeWrapper.getBiomeWrapper(this.chunk.getBiome(new BlockPos(relX, relY, relZ), world.getBiomeProvider()), wrappedLevel); + + return BiomeWrapper.getBiomeWrapper(this.chunk.getBiome(blockPos, world.getBiomeProvider()), wrappedLevel); #elif MC_VER < MC_1_17_1 return BiomeWrapper.getBiomeWrapper(this.chunk.getBiomes().getNoiseBiome( relX >> 2, relY >> 2, relZ >> 2), @@ -572,13 +585,41 @@ public class ChunkWrapper implements IChunkWrapper #endif @Override - public int getMaxBlockX() { return this.chunk.getPos().#if MC_VER <= MC_1_12_2 getXEnd() #else getMaxBlockX() #endif; } + public int getMaxBlockX() + { + #if MC_VER <= MC_1_12_2 + return this.chunk.getPos().getXEnd(); + #else + return this.chunk.getPos().getMaxBlockX(); + #endif + } @Override - public int getMaxBlockZ() { return this.chunk.getPos().#if MC_VER <= MC_1_12_2 getZEnd() #else getMaxBlockZ() #endif; } + public int getMaxBlockZ() + { + #if MC_VER <= MC_1_12_2 + return this.chunk.getPos().getZEnd(); + #else + return this.chunk.getPos().getMaxBlockZ(); + #endif + } @Override - public int getMinBlockX() { return this.chunk.getPos().#if MC_VER <= MC_1_12_2 getXStart() #else getMinBlockX() #endif; } + public int getMinBlockX() + { + #if MC_VER <= MC_1_12_2 + return this.chunk.getPos().getXStart(); + #else + return this.chunk.getPos().getMinBlockX(); + #endif + } @Override - public int getMinBlockZ() { return this.chunk.getPos().#if MC_VER <= MC_1_12_2 getZStart() #else getMinBlockZ() #endif; } + public int getMinBlockZ() + { + #if MC_VER <= MC_1_12_2 + return this.chunk.getPos().getZStart(); + #else + return this.chunk.getPos().getMinBlockZ(); + #endif + } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GuiHelper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GuiHelper.java index 07acaa434..378e14911 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GuiHelper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GuiHelper.java @@ -76,28 +76,29 @@ public class GuiHelper #endif } - public static void SetX(#if MC_VER <= MC_1_12_2 GuiButton #else AbstractWidget #endif w, int x) + #if MC_VER <= MC_1_12_2 + public static void SetX(GuiButton widget, int x) + #else + public static void SetX(AbstractWidget widget, int x) + #endif { #if MC_VER < MC_1_19_4 - w.x = x; + widget.x = x; #else - w.setX(x); + widget.setX(x); #endif } #if MC_VER <= MC_1_12_2 - public static void SetY(GuiTextField w, int y) - { - w.y = y; - } + public static void SetY(GuiTextField textField, int y) { textField.y = y; } #endif - public static void SetY(#if MC_VER <= MC_1_12_2 GuiButton #else AbstractWidget #endif w, int y) + public static void SetY(#if MC_VER <= MC_1_12_2 GuiButton #else AbstractWidget #endif widget, int y) { #if MC_VER < MC_1_19_4 - w.y = y; + widget.y = y; #else - w.setY(y); + widget.setY(y); #endif } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/ClassicConfigGUI.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/ClassicConfigGUI.java index 967b804c6..b65c32c0c 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/ClassicConfigGUI.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/ClassicConfigGUI.java @@ -101,7 +101,11 @@ public class ClassicConfigGUI //==============// /** if you want to get this config gui's screen call this */ - public static #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif getScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, String category) + #if MC_VER <= MC_1_12_2 + public static GuiScreen getScreen(GuiScreen parent, String category) + #else + public static Screen getScreen(Screen parent, String category) + #endif { return new DhConfigScreen(parent, category); } @@ -110,8 +114,12 @@ public class ClassicConfigGUI // helper classes // //================// - public static class ConfigListWidget extends #if MC_VER <= MC_1_12_2 GuiListExtended #else ContainerObjectSelectionList #endif - { + #if MC_VER <= MC_1_12_2 + public static class ConfigListWidget extends GuiListExtended + #else + public static class ConfigListWidget extends ContainerObjectSelectionList + #endif + { #if MC_VER <= MC_1_12_2 public List children = new ArrayList<>(); #endif @@ -261,8 +269,13 @@ public class ClassicConfigGUI private final EConfigCommentTextPosition textPosition; public final AbstractConfigBase dhConfigType; - public static final Map< #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif, #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif> TEXT_BY_WIDGET = new HashMap<>(); - public static final Map< #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif, DhButtonEntry> BUTTON_BY_WIDGET = new HashMap<>(); + #if MC_VER <= MC_1_12_2 + public static final Map TEXT_BY_WIDGET = new HashMap<>(); + public static final Map BUTTON_BY_WIDGET = new HashMap<>(); + #else + public static final Map TEXT_BY_WIDGET = new HashMap<>(); + public static final Map BUTTON_BY_WIDGET = new HashMap<>(); + #endif @@ -364,6 +377,7 @@ public class ClassicConfigGUI if (this.resetButton != null) { SetY(#if MC_VER <= MC_1_12_2 (GuiButton) #endif this.resetButton, y); + #if MC_VER <= MC_1_12_2 ((GuiButton) this.resetButton).drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta); #elif MC_VER <= MC_1_21_11 diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/KeyedClientLevelManager.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/KeyedClientLevelManager.java index 0b2e20b6d..5d0db94c6 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/KeyedClientLevelManager.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/KeyedClientLevelManager.java @@ -42,7 +42,13 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager @Override public IServerKeyedClientLevel setServerKeyedLevel(IClientLevelWrapper clientLevel, String serverKey, String levelKey) { - IServerKeyedClientLevel keyedLevel = new ServerKeyedClientLevelWrapper(#if MC_VER <= MC_1_12_2 (WorldClient) #else (ClientLevel) #endif clientLevel.getWrappedMcObject(), serverKey, levelKey); + IServerKeyedClientLevel keyedLevel; + #if MC_VER <= MC_1_12_2 + keyedLevel = new ServerKeyedClientLevelWrapper((WorldClient) clientLevel.getWrappedMcObject(), serverKey, levelKey); + #else + keyedLevel = new ServerKeyedClientLevelWrapper((ClientLevel) clientLevel.getWrappedMcObject(), serverKey, levelKey); + #endif + this.serverKeyedLevel = keyedLevel; this.enabled = true; return keyedLevel; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/ServerKeyedClientLevelWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/ServerKeyedClientLevelWrapper.java index 4d41e1004..c9bf063e0 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/ServerKeyedClientLevelWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/ServerKeyedClientLevelWrapper.java @@ -22,7 +22,11 @@ public class ServerKeyedClientLevelWrapper extends ClientLevelWrapper implements // constructor // //=============// - public ServerKeyedClientLevelWrapper(#if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level, String serverKey, String serverLevelKey) + #if MC_VER <= MC_1_12_2 + public ServerKeyedClientLevelWrapper(WorldClient level, String serverKey, String serverLevelKey) + #else + public ServerKeyedClientLevelWrapper(ClientLevel level, String serverKey, String serverLevelKey) + #endif { super(level); this.serverKey = serverKey; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java index 2fecfffee..f0e66b06f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java @@ -83,7 +83,12 @@ import net.minecraft.client.GraphicsStatus; public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecraftSharedWrapper { private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - private static final Minecraft MINECRAFT = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif; + + #if MC_VER <= MC_1_12_2 + private static final Minecraft MINECRAFT = Minecraft.getMinecraft(); + #else + private static final Minecraft MINECRAFT = Minecraft.getInstance(); + #endif public static final MinecraftClientWrapper INSTANCE = new MinecraftClientWrapper(); @@ -98,19 +103,35 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra //region @Override - public boolean hasSinglePlayerServer() { return MINECRAFT.#if MC_VER <= MC_1_12_2 isSingleplayer() #else hasSingleplayerServer() #endif; } + public boolean hasSinglePlayerServer() + { + #if MC_VER <= MC_1_12_2 + return MINECRAFT.isSingleplayer(); + #else + return MINECRAFT.hasSingleplayerServer(); + #endif + } @Override public boolean clientConnectedToDedicatedServer() { - return MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif != null + return this.hasServerConnection() && !this.hasSinglePlayerServer(); } @Override public boolean connectedToReplay() { - return MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif == null + return !this.hasServerConnection() && !this.hasSinglePlayerServer() ; } + + private boolean hasServerConnection() + { + #if MC_VER <= MC_1_12_2 + return MINECRAFT.getCurrentServerData() != null; + #else + MINECRAFT.getCurrentServer() != null; + #endif + } @Override diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java index 31bac5c58..a62c37223 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java @@ -114,7 +114,12 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper private static final IOptifineAccessor OPTIFINE_ACCESSOR = ModAccessorInjector.INSTANCE.get(IOptifineAccessor.class); private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - private static final Minecraft MC = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif; + + #if MC_VER <= MC_1_12_2 + private static final Minecraft MC = Minecraft.getMinecraft(); + #else + private static final Minecraft MC = Minecraft.getInstance(); + #endif /** * In the case of immersive portals multiple levels may be active at once, causing conflicting lightmaps.
diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftServerWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftServerWrapper.java index 6012898f6..b680875eb 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftServerWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftServerWrapper.java @@ -56,7 +56,11 @@ public class MinecraftServerWrapper implements IMinecraftSharedWrapper throw new IllegalStateException("Trying to get player count before dedicated server completed initialization!"); } - return this.dedicatedServer.#if MC_VER <= MC_1_12_2 getCurrentPlayerCount() #else getPlayerCount() #endif; + #if MC_VER <= MC_1_12_2 + return this.dedicatedServer.getCurrentPlayerCount(); + #else + return this.dedicatedServer.getPlayerCount(); + #endif } From 0d6d4b133e58405a603d576314e73a91738b6899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Wed, 13 May 2026 23:58:25 +0200 Subject: [PATCH 63/68] Fix compile of modern --- .../common/wrappers/block/BlockStateWrapper.java | 4 ++-- .../common/wrappers/block/ClientBlockStateColorCache.java | 4 ++-- .../common/wrappers/minecraft/MinecraftClientWrapper.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index 59c1428ee..11c101bdc 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -576,8 +576,8 @@ public class BlockStateWrapper implements IBlockStateWrapper boolean isCherryWood; #if MC_VER <= MC_1_19_2 isCherryWood = false; - #else - isWoodSoundingBlock = blockState.getSoundType() == SoundType.CHERRY_WOOD; + #else + isCherryWood = blockState.getSoundType() == SoundType.CHERRY_WOOD; #endif if (isWoodSoundingBlock diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java index 822929250..c76354b22 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java @@ -674,7 +674,7 @@ public class ClientBlockStateColorCache // try using DH's cached tint values first if possible tintColor = tintOverride.tryGetBlockTint(new DhBlockPosMutable(blockPos)); - if (tintColor == AbstractDhTintGetter.INVALID_COLOR) + if (tintColor == ClientBlockStateColorCache.INVALID_COLOR) { // one or more tint values weren't calculated, // we need MC's color resolver @@ -705,7 +705,7 @@ public class ClientBlockStateColorCache if (tintColor == -1) { // no color found, use the base color - tintColor = AbstractDhTintGetter.INVALID_COLOR; + tintColor = ClientBlockStateColorCache.INVALID_COLOR; } // save this color to speed up future queries diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java index f0e66b06f..a73b75428 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java @@ -129,7 +129,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra #if MC_VER <= MC_1_12_2 return MINECRAFT.getCurrentServerData() != null; #else - MINECRAFT.getCurrentServer() != null; + return MINECRAFT.getCurrentServer() != null; #endif } From d94faf828d4342870ae08579c0cfcb8c6c780f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Wed, 13 May 2026 23:59:09 +0200 Subject: [PATCH 64/68] Preprocessor cleanup + colored beacons for 1.12.2 --- .../common/wrappers/block/BiomeWrapper.java | 37 +++-- .../wrappers/block/BlockStateWrapper.java | 156 +++++++++++++----- 2 files changed, 143 insertions(+), 50 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java index 593717c16..09f4a0ec5 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java @@ -119,7 +119,11 @@ public class BiomeWrapper implements IBiomeWrapper // constructors // //==============// - public static BiomeWrapper getBiomeWrapper(#if MC_VER < MC_1_18_2 Biome #else Holder #endif biome, ILevelWrapper levelWrapper) + #if MC_VER < MC_1_18_2 + public static BiomeWrapper getBiomeWrapper(Biome biome, ILevelWrapper levelWrapper) + #else + public static BiomeWrapper getBiomeWrapper(Holder biome, ILevelWrapper levelWrapper) + #endif { if (biome == null) { @@ -139,7 +143,12 @@ public class BiomeWrapper implements IBiomeWrapper return newWrapper; } } - private BiomeWrapper(#if MC_VER < MC_1_18_2 Biome #else Holder #endif biome, ILevelWrapper levelWrapper) + + #if MC_VER < MC_1_18_2 + private BiomeWrapper(Biome biome, ILevelWrapper levelWrapper) + #else + private BiomeWrapper(Holder biome, ILevelWrapper levelWrapper) + #endif { this.biome = biome; this.serialString = this.serialize(levelWrapper); @@ -312,9 +321,11 @@ public class BiomeWrapper implements IBiomeWrapper net.minecraft.core.RegistryAccess registryAccess = level.registryAccess(); #endif - - BiomeDeserializeResult deserializeResult = deserializeBiome(resourceLocationString #if MC_VER > MC_1_12_2, registryAccess #endif); - + #if MC_VER <= MC_1_12_2 + BiomeDeserializeResult deserializeResult = deserializeBiome(resourceLocationString); + #else + BiomeDeserializeResult deserializeResult = deserializeBiome(resourceLocationString, registryAccess); + #endif if (!deserializeResult.success) @@ -342,9 +353,11 @@ public class BiomeWrapper implements IBiomeWrapper } } - public static BiomeDeserializeResult deserializeBiome(String resourceLocationString - #if MC_VER > MC_1_12_2, net.minecraft.core.RegistryAccess registryAccess #endif - ) throws IOException + #if MC_VER <= MC_1_12_2 + public static BiomeDeserializeResult deserializeBiome(String resourceLocationString) throws IOException + #else + public static BiomeDeserializeResult deserializeBiome(String resourceLocationString, net.minecraft.core.RegistryAccess registryAccess) throws IOException + #endif { // parse the resource location int separatorIndex = resourceLocationString.indexOf(":"); @@ -435,9 +448,13 @@ public class BiomeWrapper implements IBiomeWrapper public final Biome biome; #else public final Holder biome; - #endif + #endif - public BiomeDeserializeResult(boolean success, #if MC_VER < MC_1_18_2 Biome #else Holder #endif biome) + #if MC_VER < MC_1_18_2 + public BiomeDeserializeResult(boolean success, Biome biome) + #else + public BiomeDeserializeResult(boolean success, Holder biome) + #endif { this.success = success; this.biome = biome; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index 11c101bdc..7c49e7219 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -33,11 +33,8 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; #if MC_VER <= MC_1_12_2 -import net.minecraft.block.Block; -import net.minecraft.block.BlockLeaves; -import net.minecraft.block.SoundType; +import net.minecraft.block.*; import net.minecraft.init.Blocks; -import net.minecraft.block.BlockLiquid; import net.minecraft.block.state.IBlockState; import net.minecraft.block.properties.IProperty; import net.minecraftforge.fluids.IFluidBlock; @@ -101,7 +98,11 @@ public class BlockStateWrapper implements IBlockStateWrapper // must be defined before AIR, otherwise a null pointer will be thrown private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - public static final ConcurrentHashMap<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, BlockStateWrapper> WRAPPER_BY_BLOCK_STATE = new ConcurrentHashMap<>(); + #if MC_VER <= MC_1_12_2 + public static final ConcurrentHashMap WRAPPER_BY_BLOCK_STATE = new ConcurrentHashMap<>(); + #else + public static final ConcurrentHashMap WRAPPER_BY_BLOCK_STATE = new ConcurrentHashMap<>(); + #endif public static final ConcurrentHashMap WRAPPER_BY_RESOURCE_LOCATION = new ConcurrentHashMap<>(); public static final String AIR_STRING = "AIR"; @@ -128,7 +129,11 @@ public class BlockStateWrapper implements IBlockStateWrapper // properties // @Nullable - public final #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState; + #if MC_VER <= MC_1_12_2 + public final IBlockState blockState; + #else + public final BlockState blockState; + #endif /** technically final, but since it requires a method call to generate it can't be marked as such */ private String serialString; private final int hashCode; @@ -157,9 +162,11 @@ public class BlockStateWrapper implements IBlockStateWrapper * Can be faster than BlockStateWrapper#fromBlockState(BlockState, ILevelWrapper) * in cases where the same block state is expected to be referenced multiple times. */ - public static BlockStateWrapper fromBlockState( - #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, - ILevelWrapper levelWrapper, IBlockStateWrapper guess) + #if MC_VER <= MC_1_12_2 + public static BlockStateWrapper fromBlockState(IBlockState blockState, ILevelWrapper levelWrapper, IBlockStateWrapper guess) + #else + public static BlockStateWrapper fromBlockState(BlockState blockState, ILevelWrapper levelWrapper, IBlockStateWrapper guess) + #endif { if (guess == null) { @@ -169,7 +176,11 @@ public class BlockStateWrapper implements IBlockStateWrapper // guess block state BlockStateWrapper wrapperGuess = (BlockStateWrapper) guess; - #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif guessBlockState; + #if MC_VER <= MC_1_12_2 + IBlockState guessBlockState; + #else + BlockState guessBlockState; + #endif if(isAir(wrapperGuess.blockState)) { guessBlockState = null; @@ -184,7 +195,11 @@ public class BlockStateWrapper implements IBlockStateWrapper } // input block state - #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif inputBlockState; + #if MC_VER <= MC_1_12_2 + IBlockState inputBlockState; + #else + BlockState inputBlockState; + #endif if (isAir(blockState)) { inputBlockState = null; @@ -202,9 +217,12 @@ public class BlockStateWrapper implements IBlockStateWrapper return fromBlockState(blockState, levelWrapper); } - public static BlockStateWrapper fromBlockState( - @Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, - ILevelWrapper levelWrapper) + + #if MC_VER <= MC_1_12_2 + public static BlockStateWrapper fromBlockState(@Nullable IBlockState blockState, ILevelWrapper levelWrapper) + #else + public static BlockStateWrapper fromBlockState(@Nullable BlockState blockState, ILevelWrapper levelWrapper) + #endif { // air is a special case if (isAir(blockState)) @@ -253,9 +271,12 @@ public class BlockStateWrapper implements IBlockStateWrapper } } } - private BlockStateWrapper( - @Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, ILevelWrapper levelWrapper, - @Nullable DhApiBlockStateWrapperCreatedEvent.EventParam overrideEventParam) + + #if MC_VER <= MC_1_12_2 + private BlockStateWrapper(@Nullable IBlockState blockState, ILevelWrapper levelWrapper, @Nullable DhApiBlockStateWrapperCreatedEvent.EventParam overrideEventParam) + #else + private BlockStateWrapper(@Nullable BlockState blockState, ILevelWrapper levelWrapper, @Nullable DhApiBlockStateWrapperCreatedEvent.EventParam overrideEventParam) + #endif { this.blockState = blockState; this.serialString = serialize(blockState, levelWrapper); @@ -374,16 +395,26 @@ public class BlockStateWrapper implements IBlockStateWrapper // beacon tint color Color beaconTintColor = null; - // 1.12.2 doesn't support changing the beacon beam color - #if MC_VER > MC_1_12_2 if (this.blockState != null // beacon blocks also show up here, but since they block the beacon beam we don't want their color && !this.isBeaconBlock) { Block block = this.blockState.getBlock(); + int colorInt; + #if MC_VER <= MC_1_12_2 + if (block instanceof BlockStainedGlass) + { + colorInt = blockState.getValue(BlockStainedGlass.COLOR).getColorValue(); + beaconTintColor = ColorUtil.toColorObjRGB(colorInt); + } + else if (block instanceof BlockStainedGlassPane) + { + colorInt = blockState.getValue(BlockStainedGlassPane.COLOR).getColorValue(); + beaconTintColor = ColorUtil.toColorObjRGB(colorInt); + } + #else if (block instanceof BeaconBeamBlock) { - int colorInt; #if MC_VER <= MC_1_19_4 colorInt = ((BeaconBeamBlock) block).getColor().getMaterialColor().col; #else @@ -392,8 +423,8 @@ public class BlockStateWrapper implements IBlockStateWrapper beaconTintColor = ColorUtil.toColorObjRGB(colorInt); } + #endif } - #endif this.beaconTintColor = beaconTintColor; @@ -483,11 +514,11 @@ public class BlockStateWrapper implements IBlockStateWrapper // static constructor helpers // //region - private static EDhApiBlockMaterial calculateEDhApiBlockMaterialId( - @Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, - String lowercaseSerialString, - boolean isLiquid - ) + #if MC_VER <= MC_1_12_2 + private static EDhApiBlockMaterial calculateEDhApiBlockMaterialId(@Nullable IBlockState blockState, String lowercaseSerialString, boolean isLiquid) + #else + private static EDhApiBlockMaterial calculateEDhApiBlockMaterialId(@Nullable BlockState blockState, String lowercaseSerialString, boolean isLiquid) + #endif { if (isAir(blockState)) { @@ -741,10 +772,11 @@ public class BlockStateWrapper implements IBlockStateWrapper return EDhApiBlockMaterial.UNKNOWN; } - private static int calculateOpacity( - @Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, - boolean isAir, boolean isLiquid - ) + #if MC_VER <= MC_1_12_2 + private static int calculateOpacity(@Nullable IBlockState blockState, boolean isAir, boolean isLiquid) + #else + private static int calculateOpacity(@Nullable BlockState blockState, boolean isAir, boolean isLiquid) + #endif { // get block properties (defaults to the values used by air) boolean canOcclude = getCanOcclude(blockState); @@ -783,7 +815,12 @@ public class BlockStateWrapper implements IBlockStateWrapper return opacity; } - private static boolean getCanOcclude(@Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState) + + #if MC_VER <= MC_1_12_2 + private static boolean getCanOcclude(@Nullable IBlockState blockState) + #else + private static boolean getCanOcclude(@Nullable BlockState blockState) + #endif { // defaults to the value used by air boolean canOcclude = false; @@ -798,7 +835,12 @@ public class BlockStateWrapper implements IBlockStateWrapper return canOcclude; } - private static boolean getPropagatesSkyLightDown(@Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState) + + #if MC_VER <= MC_1_12_2 + private static boolean getPropagatesSkyLightDown(@Nullable IBlockState blockState) + #else + private static boolean getPropagatesSkyLightDown(@Nullable BlockState blockState) + #endif { // defaults to the value used by air boolean propagatesSkyLightDown = true; @@ -958,7 +1000,12 @@ public class BlockStateWrapper implements IBlockStateWrapper #else List blockStatesToIgnore = defaultBlockStateToIgnore.blockState.getBlock().getStateDefinition().getPossibleStates(); #endif - for (#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState : blockStatesToIgnore) + + #if MC_VER <= MC_1_12_2 + for (IBlockState blockState : blockStatesToIgnore) + #else + for (BlockState blockState : blockStatesToIgnore) + #endif { BlockStateWrapper newBlockToIgnore = fromBlockState(blockState, levelWrapper); blockStateWrappers.add(newBlockToIgnore); @@ -1006,7 +1053,11 @@ public class BlockStateWrapper implements IBlockStateWrapper @Override public int getLightEmission() { return getLightEmission(this.blockState); } - public static int getLightEmission(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState) + #if MC_VER <= MC_1_12_2 + public static int getLightEmission(IBlockState blockState) + #else + public static int getLightEmission(BlockState blockState) + #endif { if (blockState == null) { @@ -1029,7 +1080,11 @@ public class BlockStateWrapper implements IBlockStateWrapper @Override public boolean isAir() { return isAir(this.blockState); } - public static boolean isAir(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState) + #if MC_VER <= MC_1_12_2 + public static boolean isAir(IBlockState blockState) + #else + public static boolean isAir(BlockState blockState) + #endif { if (blockState == null) { @@ -1075,7 +1130,11 @@ public class BlockStateWrapper implements IBlockStateWrapper //=======================// //region - private static String serialize(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, ILevelWrapper levelWrapper) + #if MC_VER <= MC_1_12_2 + private static String serialize(IBlockState blockState, ILevelWrapper levelWrapper) + #else + private static String serialize(BlockState blockState, ILevelWrapper levelWrapper) + #endif { if (blockState == null) { @@ -1229,7 +1288,11 @@ public class BlockStateWrapper implements IBlockStateWrapper // attempt to find the blockstate from all possibilities - #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif foundState = null; + #if MC_VER <= MC_1_12_2 + IBlockState foundState = null; + #else + BlockState foundState = null; + #endif if (blockStatePropertiesString != null) { #if MC_VER <= MC_1_12_2 @@ -1237,7 +1300,12 @@ public class BlockStateWrapper implements IBlockStateWrapper #else List possibleStateList = block.getStateDefinition().getPossibleStates(); #endif - for (#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif possibleState : possibleStateList) + + #if MC_VER <= MC_1_12_2 + for (IBlockState possibleState : possibleStateList) + #else + for (BlockState possibleState : possibleStateList) + #endif { String possibleStatePropertiesString = serializeBlockStateProperties(possibleState); if (possibleStatePropertiesString.equals(blockStatePropertiesString)) @@ -1291,7 +1359,11 @@ public class BlockStateWrapper implements IBlockStateWrapper } /** used to compare and save BlockStates based on their properties */ - private static String serializeBlockStateProperties(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState) + #if MC_VER <= MC_1_12_2 + private static String serializeBlockStateProperties(IBlockState blockState) + #else + private static String serializeBlockStateProperties(BlockState blockState) + #endif { // get the property list for this block (doesn't contain this block state's values, just the names and possible values) #if MC_VER <= MC_1_12_2 @@ -1307,7 +1379,11 @@ public class BlockStateWrapper implements IBlockStateWrapper StringBuilder stringBuilder = new StringBuilder(); - for (#if MC_VER <= MC_1_12_2 IProperty #else net.minecraft.world.level.block.state.properties.Property #endif property : sortedBlockPropteryList) + #if MC_VER <= MC_1_12_2 + for (IProperty property : sortedBlockPropteryList) + #else + for (net.minecraft.world.level.block.state.properties.Property property : sortedBlockPropteryList) + #endif { String propertyName = property.getName(); From c97fea6d0a2c81317d1eafbb4d7cebe235f8cf4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Thu, 14 May 2026 07:53:00 +0200 Subject: [PATCH 65/68] Fix compile of modern --- .../wrappers/block/ClientBlockStateColorCache.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java index c76354b22..0597dcc2f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java @@ -614,7 +614,7 @@ public class ClientBlockStateColorCache public int getColor(BiomeWrapper biomeWrapper, FullDataSourceV2 fullDataSource, DhBlockPos blockPos) { // only get the tint if the block needs to be tinted - int tintColor = INVALID_COLOR; + int tintColor = ClientBlockStateColorCache.INVALID_COLOR; if (this.needPostTinting) { @@ -656,7 +656,7 @@ public class ClientBlockStateColorCache BlockColors blockColors = Minecraft.getMinecraft().getBlockColors(); tintColor = blockColors.colorMultiplier(blockState, world, mcPos, this.tintIndex); - if (tintColor == -1) + if (tintColor == ClientBlockStateColorCache.INVALID_COLOR) { tintColor = blockColors.getColor(blockState, world, mcPos); } @@ -696,13 +696,13 @@ public class ClientBlockStateColorCache { BlockPos mcPos = McObjectConverter.Convert(blockPos); tintColor = tintSource.colorInWorld(this.blockState, tintOverride, mcPos); - if (tintColor == -1) + if (tintColor == ClientBlockStateColorCache.INVALID_COLOR) { tintColor = tintSource.colorAsTerrainParticle(this.blockState, tintOverride, mcPos); } } - if (tintColor == -1) + if (tintColor == ClientBlockStateColorCache.INVALID_COLOR) { // no color found, use the base color tintColor = ClientBlockStateColorCache.INVALID_COLOR; @@ -746,7 +746,7 @@ public class ClientBlockStateColorCache tintOverride.update(biomeWrapper, this.blockStateWrapper, fullDataSource, this.clientLevelWrapper); tintColor = tintOverride.tryGetBlockTint(new DhBlockPosMutable(blockPos)); - if (tintColor == AbstractDhTintGetter.INVALID_COLOR) + if (tintColor == ClientBlockStateColorCache.INVALID_COLOR) { tintColor = Minecraft.getInstance() .getBlockColors() @@ -772,7 +772,7 @@ public class ClientBlockStateColorCache int returnColor; - if (tintColor != INVALID_COLOR) + if (tintColor != ClientBlockStateColorCache.INVALID_COLOR) { returnColor = ColorUtil.multiplyARGBwithRGB(this.baseColor, tintColor); } From 071a306f14a4c490a0081d44bfcc3a276cde6e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Thu, 14 May 2026 13:03:32 +0200 Subject: [PATCH 66/68] Preprocessor cleanup --- .../common/wrappers/block/BiomeWrapper.java | 14 ++ .../wrappers/block/BlockStateWrapper.java | 3 +- .../block/ClientBlockStateColorCache.java | 113 +++++++-- .../common/wrappers/chunk/ChunkWrapper.java | 56 ++++- .../common/wrappers/gui/DhScreen.java | 16 +- .../common/wrappers/gui/GuiHelper.java | 31 ++- .../common/wrappers/gui/LangWrapper.java | 2 + .../common/wrappers/gui/MinecraftScreen.java | 32 ++- .../wrappers/gui/TexturedButtonWidget.java | 37 +-- .../gui/classicConfig/ClassicConfigGUI.java | 105 ++++++-- .../gui/classicConfig/DhConfigScreen.java | 234 +++++++++++++----- .../wrappers/gui/config/ConfigGuiInfo.java | 19 +- .../level/KeyedClientLevelManager.java | 7 + .../level/ServerKeyedClientLevelWrapper.java | 11 +- .../minecraft/MinecraftClientWrapper.java | 119 +++++++-- .../minecraft/MinecraftRenderWrapper.java | 6 +- .../wrappers/minecraft/ProfilerWrapper.java | 46 +++- .../wrappers/misc/IMixinServerPlayer.java | 6 +- .../wrappers/misc/MutableBlockPosWrapper.java | 8 + .../wrappers/misc/ServerPlayerWrapper.java | 52 +++- 20 files changed, 727 insertions(+), 190 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java index 09f4a0ec5..68b06278d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java @@ -118,6 +118,7 @@ public class BiomeWrapper implements IBiomeWrapper //==============// // constructors // //==============// + //region #if MC_VER < MC_1_18_2 public static BiomeWrapper getBiomeWrapper(Biome biome, ILevelWrapper levelWrapper) @@ -157,11 +158,14 @@ public class BiomeWrapper implements IBiomeWrapper //LOGGER.trace("Created BiomeWrapper ["+this.serialString+"] for ["+biome+"]"); } + //endregion + //=========// // methods // //=========// + //region @Override public String getName() @@ -207,11 +211,14 @@ public class BiomeWrapper implements IBiomeWrapper @Override public String toString() { return this.getSerialString(); } + //endregion + //=======================// // serialization methods // //=======================// + //region public String serialize(ILevelWrapper levelWrapper) { @@ -435,10 +442,14 @@ public class BiomeWrapper implements IBiomeWrapper return new BiomeDeserializeResult(success, biome); } + //endregion + + //================// // helper classes // //================// + //region public static class BiomeDeserializeResult { @@ -461,5 +472,8 @@ public class BiomeWrapper implements IBiomeWrapper } } + //endregion + + } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index 7c49e7219..bcd895020 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -547,6 +547,7 @@ public class BlockStateWrapper implements IBlockStateWrapper { return EDhApiBlockMaterial.LEAVES; } + //endregion @@ -639,7 +640,7 @@ public class BlockStateWrapper implements IBlockStateWrapper #if MC_VER <= MC_1_18_2 isCopperSounding = false; #elif MC_VER <= MC_1_20_2 - isCopperSounding = blockState.getSoundType() == SoundType.COPPER + isCopperSounding = blockState.getSoundType() == SoundType.COPPER; #else isCopperSounding = blockState.getSoundType() == SoundType.COPPER diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java index 0597dcc2f..78b7fa942 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java @@ -94,7 +94,11 @@ public class ClientBlockStateColorCache private static final HashSet BLOCK_STATES_THAT_NEED_LEVEL = new HashSet<>(); #endif - private static final HashSet<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif> BROKEN_BLOCK_STATES = new HashSet<>(); + #if MC_VER <= MC_1_12_2 + private static final HashSet BROKEN_BLOCK_STATES = new HashSet<>(); + #else + private static final HashSet BROKEN_BLOCK_STATES = new HashSet<>(); + #endif /** * Methods using MC's "RandomSource" object aren't thread safe
@@ -110,18 +114,29 @@ public class ClientBlockStateColorCache /** This is the order each direction on a block is processed when attempting to get the texture/color */ - private static final @Nullable - #if MC_VER <= MC_1_12_2 EnumFacing[] #else Direction[] #endif - COLOR_RESOLUTION_DIRECTION_ORDER = + #if MC_VER <= MC_1_12_2 + private static final @Nullable EnumFacing[] COLOR_RESOLUTION_DIRECTION_ORDER = { - #if MC_VER <= MC_1_12_2 EnumFacing.UP #else Direction.UP #endif, + EnumFacing.UP, null, // null represents "unculled" faces, IE the top of farmland - #if MC_VER <= MC_1_12_2 EnumFacing.NORTH #else Direction.NORTH #endif, - #if MC_VER <= MC_1_12_2 EnumFacing.EAST #else Direction.EAST #endif, - #if MC_VER <= MC_1_12_2 EnumFacing.WEST #else Direction.WEST #endif, - #if MC_VER <= MC_1_12_2 EnumFacing.SOUTH #else Direction.SOUTH #endif, - #if MC_VER <= MC_1_12_2 EnumFacing.DOWN #else Direction.DOWN #endif + EnumFacing.NORTH, + EnumFacing.EAST, + EnumFacing.WEST, + EnumFacing.SOUTH, + EnumFacing.DOWN }; + #else + private static final @Nullable Direction[] COLOR_RESOLUTION_DIRECTION_ORDER = + { + Direction.UP, + null, // null represents "unculled" faces, IE the top of farmland + Direction.NORTH, + Direction.EAST, + Direction.WEST, + Direction.SOUTH, + Direction.DOWN + }; + #endif private static final int FLOWER_COLOR_SCALE = 5; @@ -135,7 +150,11 @@ public class ClientBlockStateColorCache #endif private final IClientLevelWrapper clientLevelWrapper; - private final #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState; + #if MC_VER <= MC_1_12_2 + private final IBlockState blockState; + #else + private final BlockState blockState; + #endif private final BlockStateWrapper blockStateWrapper; private boolean isColorResolved = false; @@ -228,9 +247,11 @@ public class ClientBlockStateColorCache //=============// //region - public ClientBlockStateColorCache( - #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, - IClientLevelWrapper clientLevelWrapper) + #if MC_VER <= MC_1_12_2 + public ClientBlockStateColorCache(IBlockState blockState, IClientLevelWrapper clientLevelWrapper) + #else + public ClientBlockStateColorCache(BlockState blockState, IClientLevelWrapper clientLevelWrapper) + #endif { this.blockState = blockState; this.blockStateWrapper = BlockStateWrapper.fromBlockState(blockState, clientLevelWrapper); @@ -394,9 +415,17 @@ public class ClientBlockStateColorCache @Nullable private List getUnculledQuads() { return this.getQuadsForDirection(null); } @Nullable - private List getQuadsForDirection(@Nullable #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif direction) + #if MC_VER <= MC_1_12_2 + private List getQuadsForDirection(@Nullable EnumFacing direction) + #else + private List getQuadsForDirection(@Nullable Direction direction) + #endif { - #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif effectiveBlockState = this.blockState; + #if MC_VER <= MC_1_12_2 + IBlockState effectiveBlockState = this.blockState; + #else + BlockState effectiveBlockState = this.blockState; + #endif // if this block is a slab, use it's double variant so we can get the top face, // otherwise the color will use the side, which isn't as accurate @@ -610,6 +639,7 @@ public class ClientBlockStateColorCache //===============// // public getter // //===============// + //region public int getColor(BiomeWrapper biomeWrapper, FullDataSourceV2 fullDataSource, DhBlockPos blockPos) { @@ -802,6 +832,8 @@ public class ClientBlockStateColorCache return returnColor; } + //endregion + //================// @@ -819,14 +851,54 @@ public class ClientBlockStateColorCache static EColorMode getColorMode(Block block) { - if (block instanceof #if MC_VER <= MC_1_12_2 BlockLeaves #else LeavesBlock #endif) + + + + //========// + // leaves // + //========// + //region + + boolean isLeavesBlock; + #if MC_VER <= MC_1_12_2 + isLeavesBlock = block instanceof BlockLeaves; + #else + isLeavesBlock = block instanceof LeavesBlock; + #endif + if (isLeavesBlock) { return Leaves; } - if (block instanceof #if MC_VER <= MC_1_12_2 BlockFlower #else FlowerBlock #endif) + + //endregion + + + + //========// + // flower // + //========// + //region + + boolean isFlowerBlock; + #if MC_VER <= MC_1_12_2 + isFlowerBlock = block instanceof BlockFlower; + #else + isFlowerBlock = block instanceof FlowerBlock; + #endif + if (isFlowerBlock) { return Flower; } + + //endregion + + + + //=============// + // misc/simple // + //=============// + //region + if (block.toString().contains("glass")) { return Glass; @@ -835,6 +907,11 @@ public class ClientBlockStateColorCache { return Chisel; } + + //endregion + + + return Default; } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java index 6290ce269..d6fc4fe41 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java @@ -124,15 +124,17 @@ public class ChunkWrapper implements IChunkWrapper //=============// // constructor // //=============// - + //region /** * Note: this constructor should be very * fast since it will be called frequently on the MC * server thread and a slow method will cause server lag. */ - public ChunkWrapper( - #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk, - ILevelWrapper wrappedLevel) + #if MC_VER <= MC_1_12_2 + public ChunkWrapper(Chunk chunk, ILevelWrapper wrappedLevel) + #else + public ChunkWrapper(ChunkAccess chunk, ILevelWrapper wrappedLevel) + #endif { this.chunk = chunk; this.wrappedLevel = wrappedLevel; @@ -147,15 +149,22 @@ public class ChunkWrapper implements IChunkWrapper @Override public ChunkWrapper copy() { return new ChunkWrapper(this.chunk, this.wrappedLevel); } + //endregion + //=========// // getters // //=========// + //region @Override public int getHeight() { return getHeight(this.chunk); } - public static int getHeight(#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk) + #if MC_VER <= MC_1_12_2 + public static int getHeight(Chunk chunk) + #else + public static int getHeight(ChunkAccess chunk) + #endif { #if MC_VER < MC_1_17_1 return 255; @@ -166,7 +175,11 @@ public class ChunkWrapper implements IChunkWrapper @Override public int getInclusiveMinBuildHeight() { return getInclusiveMinBuildHeight(this.chunk); } - public static int getInclusiveMinBuildHeight(#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk) + #if MC_VER <= MC_1_12_2 + public static int getInclusiveMinBuildHeight(Chunk chunk) + #else + public static int getInclusiveMinBuildHeight(ChunkAccess chunk) + #endif { #if MC_VER < MC_1_17_1 return 0; @@ -179,7 +192,11 @@ public class ChunkWrapper implements IChunkWrapper @Override public int getExclusiveMaxBuildHeight() { return getExclusiveMaxBuildHeight(this.chunk); } - public static int getExclusiveMaxBuildHeight(#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk) + #if MC_VER <= MC_1_12_2 + public static int getExclusiveMaxBuildHeight(Chunk chunk) + #else + public static int getExclusiveMaxBuildHeight(ChunkAccess chunk) + #endif { #if MC_VER <= MC_1_12_2 return 256; @@ -264,9 +281,11 @@ public class ChunkWrapper implements IChunkWrapper return this.maxNonEmptyHeight; } - private static boolean isChunkSectionEmpty( - #if MC_VER <= MC_1_12_2 ExtendedBlockStorage #else LevelChunkSection #endif section - ) + #if MC_VER <= MC_1_12_2 + private static boolean isChunkSectionEmpty(ExtendedBlockStorage section) + #else + private static boolean isChunkSectionEmpty(LevelChunkSection section) + #endif { #if MC_VER <= MC_1_17_1 return section.isEmpty(); @@ -556,7 +575,12 @@ public class ChunkWrapper implements IChunkWrapper @Override public DhChunkPos getChunkPos() { return this.chunkPos; } - public #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif getChunk() { return this.chunk; } + #if MC_VER <= MC_1_12_2 + public Chunk getChunk() + #else + public ChunkAccess getChunk() + #endif + { return this.chunk; } #if MC_VER > MC_1_12_2 public void trySetStatus(ChunkStatus status) { trySetStatus(this.getChunk(), status); } @@ -621,11 +645,14 @@ public class ChunkWrapper implements IChunkWrapper #endif } + //endregion + //==========// // lighting // //==========// + //region @Override public void setIsDhSkyLightCorrect(boolean isDhLightCorrect) { this.isDhSkyLightCorrect = isDhLightCorrect; } @@ -740,11 +767,14 @@ public class ChunkWrapper implements IChunkWrapper return this.blockLightPosList; } + //endregion + //================// // base overrides // //================// + //region @Override public String toString() { return this.chunk.getClass().getSimpleName() + this.chunk.getPos(); } @@ -760,4 +790,8 @@ public class ChunkWrapper implements IChunkWrapper // return this.blockBiomeHashCode; //} + //endregion + + + } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java index e5d6dee88..87da07d77 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java @@ -23,10 +23,17 @@ import net.minecraft.client.gui.GuiGraphicsExtractor; import java.util.List; -public class DhScreen extends #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif +#if MC_VER <= MC_1_12_2 +public class DhScreen extends GuiScreen +#else +public class DhScreen extends Screen +#endif { #if MC_VER <= MC_1_12_2 protected ITextComponent title; + #endif + + #if MC_VER <= MC_1_12_2 protected DhScreen(ITextComponent title) { this.title = title; @@ -40,7 +47,11 @@ public class DhScreen extends #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #en // addRenderableWidget in 1.17 and over // addButton in 1.16 and below - protected #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif addBtn(#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif button) + #if MC_VER <= MC_1_12_2 + protected GuiButton addBtn(GuiButton button) + #else + protected Button addBtn(Button button) + #endif { #if MC_VER <= MC_1_12_2 this.buttonList.add(button); @@ -53,7 +64,6 @@ public class DhScreen extends #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #en } #if MC_VER <= MC_1_12_2 - @Override protected void actionPerformed(GuiButton button) { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GuiHelper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GuiHelper.java index 378e14911..8df4ce1ac 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GuiHelper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GuiHelper.java @@ -29,8 +29,11 @@ public class GuiHelper public static final Map HANDLER_BY_BUTTON = new HashMap<>(); #endif - public static #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif MakeBtn(#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif base, int posX, int posZ, int width, int height, - #if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif action) + #if MC_VER <= MC_1_12_2 + public static GuiButton MakeBtn(ITextComponent base, int posX, int posZ, int width, int height, OnPressed action) + #else + public static Button MakeBtn(Component base, int posX, int posZ, int width, int height, Button.OnPress action) + #endif { #if MC_VER <= MC_1_12_2 GuiButton button = new GuiButton(HANDLER_BY_BUTTON.size(), posX, posZ, width, height, base.getFormattedText()); @@ -43,7 +46,11 @@ public class GuiHelper #endif } - public static #if MC_VER <= MC_1_12_2 ITextComponent #else MutableComponent #endif TextOrLiteral(String text) + #if MC_VER <= MC_1_12_2 + public static ITextComponent TextOrLiteral(String text) + #else + public static MutableComponent TextOrLiteral(String text) + #endif { #if MC_VER <= MC_1_12_2 return new TextComponentString(text); @@ -54,7 +61,11 @@ public class GuiHelper #endif } - public static #if MC_VER <= MC_1_12_2 ITextComponent #else MutableComponent #endif TextOrTranslatable(String text) + #if MC_VER <= MC_1_12_2 + public static ITextComponent TextOrTranslatable(String text) + #else + public static MutableComponent TextOrTranslatable(String text) + #endif { #if MC_VER <= MC_1_12_2 return new TextComponentString(text); @@ -65,7 +76,11 @@ public class GuiHelper #endif } - public static #if MC_VER <= MC_1_12_2 ITextComponent #else MutableComponent #endif Translatable(String text, Object... args) + #if MC_VER <= MC_1_12_2 + public static ITextComponent Translatable(String text, Object... args) + #else + public static MutableComponent Translatable(String text, Object... args) + #endif { #if MC_VER <= MC_1_12_2 return new TextComponentTranslation(text, args); @@ -93,7 +108,11 @@ public class GuiHelper public static void SetY(GuiTextField textField, int y) { textField.y = y; } #endif - public static void SetY(#if MC_VER <= MC_1_12_2 GuiButton #else AbstractWidget #endif widget, int y) + #if MC_VER <= MC_1_12_2 + public static void SetY(GuiButton widget, int y) + #else + public static void SetY(AbstractWidget widget, int y) + #endif { #if MC_VER < MC_1_19_4 widget.y = y; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/LangWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/LangWrapper.java index eb3f611ed..17136c8f3 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/LangWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/LangWrapper.java @@ -6,9 +6,11 @@ import net.minecraft.client.resources.I18n; #else import net.minecraft.client.resources.language.I18n; #endif + public class LangWrapper implements ILangWrapper { public static final LangWrapper INSTANCE = new LangWrapper(); + @Override public boolean langExists(String str) { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java index 52a334b9d..2da926ba0 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java @@ -45,7 +45,11 @@ public class MinecraftScreen private static class ConfigScreenRenderer extends DhScreen { - private final #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent; + #if MC_VER <= MC_1_12_2 + private final GuiScreen parent; + #else + private final Screen parent; + #endif private ConfigListWidget configListWidget; private AbstractScreen screen; @@ -60,9 +64,11 @@ public class MinecraftScreen { return net.minecraft.network.chat.Component.translatable(str, args); } #endif - protected ConfigScreenRenderer( - #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, - AbstractScreen screen, String translationName) + #if MC_VER <= MC_1_12_2 + protected ConfigScreenRenderer(GuiScreen parent, AbstractScreen screen, String translationName) + #else + protected ConfigScreenRenderer(Screen parent, AbstractScreen screen, String translationName) + #endif { super(translate(translationName)); #if MC_VER <= MC_1_12_2 @@ -89,7 +95,6 @@ public class MinecraftScreen super.init(); #endif - #if MC_VER <= MC_1_12_2 this.screen.width = Display.getWidth(); this.screen.height = Display.getHeight(); @@ -102,16 +107,21 @@ public class MinecraftScreen this.screen.scaledHeight = this.height; this.screen.init(); // Init our own config screen - this.configListWidget = new ConfigListWidget(#if MC_VER <= MC_1_12_2 this.mc #else this.minecraft #endif, this.width, this.height, 0, 0, 25); // Select the area to tint + #if MC_VER <= MC_1_12_2 + this.configListWidget = new ConfigListWidget(this.mc, this.width, this.height, 0, 0, 25); // Select the area to tint + #else + this.configListWidget = new ConfigListWidget(this.minecraft, this.width, this.height, 0, 0, 25); // Select the area to tint + #endif - #if MC_VER > MC_1_12_2 - #if MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+ + #if MC_VER <= MC_1_12_2 + #elif MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+ if (this.minecraft != null && this.minecraft.level != null) // Check if in game { this.configListWidget.setRenderBackground(false); // Disable from rendering } #endif + #if MC_VER > MC_1_12_2 this.addWidget(this.configListWidget); // Add the tint to the things to be rendered #endif } @@ -240,7 +250,11 @@ public class MinecraftScreen #endif } - public static class ConfigListWidget extends #if MC_VER <= MC_1_12_2 GuiListExtended #else ContainerObjectSelectionList #endif + #if MC_VER <= MC_1_12_2 + public static class ConfigListWidget extends GuiListExtended + #else + public static class ConfigListWidget extends ContainerObjectSelectionList + #endif { public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing) { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java index 62a1e4f5f..5609f5749 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java @@ -103,23 +103,30 @@ public class TexturedButtonWidget extends Button private final int textureHeight; #endif - - public TexturedButtonWidget( - #if MC_VER <= MC_1_12_2 int id, #endif int x, int y, int width, int height, int u, int v, int hoveredVOffset, - #if MC_VER <= MC_1_21_10 ResourceLocation textureResourceLocation, - #else Identifier textureResourceLocation, - #endif - int textureWidth, int textureHeight, #if MC_VER > MC_1_12_2 OnPress pressAction,#endif #if MC_VER <= MC_1_12_2 String #else Component #endif text) + #if MC_VER <= MC_1_12_2 + public TexturedButtonWidget(int id, int x, int y, int width, int height, int u, int v, int hoveredVOffset, ResourceLocation textureResourceLocation, int textureWidth, int textureHeight, String text) { - this(#if MC_VER <= MC_1_12_2 id, #endif x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, #if MC_VER > MC_1_12_2 pressAction, #endif text, true); + this(id, x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, text, true); } - public TexturedButtonWidget( - #if MC_VER <= MC_1_12_2 int id, #endif int x, int y, int width, int height, int u, int v, int hoveredVOffset, - #if MC_VER <= MC_1_21_10 ResourceLocation textureResourceLocation, - #else Identifier textureResourceLocation, - #endif - int textureWidth, int textureHeight, #if MC_VER > MC_1_12_2 OnPress pressAction,#endif #if MC_VER <= MC_1_12_2 String #else Component #endif text, - boolean renderBackground) + #elif MC_VER <= MC_1_21_10 + public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, ResourceLocation textureResourceLocation, int textureWidth, int textureHeight, OnPress pressAction, Component text) + { + this(x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, pressAction, text, true); + } + #else + public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, Identifier textureResourceLocation, int textureWidth, int textureHeight, OnPress pressAction, Component text) + { + this(x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, pressAction, text, true); + } + #endif + + #if MC_VER <= MC_1_12_2 + public TexturedButtonWidget(int id, int x, int y, int width, int height, int u, int v, int hoveredVOffset, ResourceLocation textureResourceLocation, int textureWidth, int textureHeight, String text, boolean renderBackground) + #elif MC_VER <= MC_1_21_10 + public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, ResourceLocation textureResourceLocation, int textureWidth, int textureHeight, OnPress pressAction, Component text, boolean renderBackground) + #else + public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, Identifier textureResourceLocation, int textureWidth, int textureHeight, OnPress pressAction, Component text, boolean renderBackground) + #endif { #if MC_VER <= MC_1_12_2 super(id, x, y, width, height, text); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/ClassicConfigGUI.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/ClassicConfigGUI.java index b65c32c0c..7ca4dfaa4 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/ClassicConfigGUI.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/ClassicConfigGUI.java @@ -74,6 +74,7 @@ public class ClassicConfigGUI //==============// // Initializers // //==============// + //region // Some regexes to check if an input is valid public static final Pattern INTEGER_ONLY_REGEX = Pattern.compile("(-?[0-9]*)"); @@ -94,12 +95,14 @@ public class ClassicConfigGUI } + //endregion + //==============// // GUI handling // //==============// - + //region /** if you want to get this config gui's screen call this */ #if MC_VER <= MC_1_12_2 public static GuiScreen getScreen(GuiScreen parent, String category) @@ -108,11 +111,14 @@ public class ClassicConfigGUI #endif { return new DhConfigScreen(parent, category); } + //endregion + //================// // helper classes // //================// + //region #if MC_VER <= MC_1_12_2 public static class ConfigListWidget extends GuiListExtended @@ -124,7 +130,11 @@ public class ClassicConfigGUI public List children = new ArrayList<>(); #endif - #if MC_VER <= MC_1_12_2 FontRenderer #else Font #endif textRenderer; + #if MC_VER <= MC_1_12_2 + FontRenderer textRenderer; + #else + Font textRenderer; + #endif public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing) { @@ -142,7 +152,7 @@ public class ClassicConfigGUI #endif } - #if MC_VER<= MC_1_12_2 + #if MC_VER <= MC_1_12_2 @Override protected int getSize() { @@ -180,11 +190,24 @@ public class ClassicConfigGUI } @Override - public int #if MC_VER <= MC_1_12_2 getListWidth() #else getRowWidth() #endif { return 10_000; } + #if MC_VER <= MC_1_12_2 + public int getListWidth() + #else + public int getRowWidth() + #endif + { return 10_000; } - public #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif getHoveredButton(double mouseX, double mouseY) + #if MC_VER <= MC_1_12_2 + public Gui getHoveredButton(double mouseX, double mouseY) + #else + public AbstractWidget getHoveredButton(double mouseX, double mouseY) + #endif { - for (DhButtonEntry buttonEntry : #if MC_VER <= MC_1_12_2 this.children #else this.children() #endif) + #if MC_VER <= MC_1_12_2 + for (DhButtonEntry buttonEntry : this.children) + #else + for (DhButtonEntry buttonEntry : this.children()) + #endif { #if MC_VER <= MC_1_12_2 Gui gui = buttonEntry.button; @@ -244,14 +267,18 @@ public class ClassicConfigGUI } - - public static class DhButtonEntry #if MC_VER <= MC_1_12_2 implements GuiListExtended.IGuiListEntry #else extends ContainerObjectSelectionList.Entry #endif + #if MC_VER <= MC_1_12_2 + public static class DhButtonEntry implements GuiListExtended.IGuiListEntry + #else + public static class DhButtonEntry extends ContainerObjectSelectionList.Entry + #endif { #if MC_VER <= MC_1_12_2 private static final FontRenderer textRenderer = Minecraft.getMinecraft().fontRenderer; #else private static final Font textRenderer = Minecraft.getInstance().font; #endif + private final DhConfigScreen gui; #if MC_VER <= MC_1_12_2 public final Gui button; @@ -262,8 +289,18 @@ public class ClassicConfigGUI private final AbstractWidget resetButton; private final AbstractWidget button; #endif - private final #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif text; - private final List<#if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif> children = new ArrayList<>(); + + #if MC_VER <= MC_1_12_2 + private final ITextComponent text; + #else + private final Component text; + #endif + + #if MC_VER <= MC_1_12_2 + private final List children = new ArrayList<>(); + #else + private final List children = new ArrayList<>(); + #endif @NotNull private final EConfigCommentTextPosition textPosition; @@ -366,17 +403,23 @@ public class ClassicConfigGUI } #else SetY(this.button, y); - #if MC_VER <= MC_1_21_11 - this.button.render(matrices, mouseX, mouseY, tickDelta); - #else - this.button.extractRenderState(matrices, mouseX, mouseY, tickDelta); - #endif + { + #if MC_VER <= MC_1_21_11 + this.button.render(matrices, mouseX, mouseY, tickDelta); + #else + this.button.extractRenderState(matrices, mouseX, mouseY, tickDelta); + #endif + } #endif } if (this.resetButton != null) { - SetY(#if MC_VER <= MC_1_12_2 (GuiButton) #endif this.resetButton, y); + #if MC_VER <= MC_1_12_2 + SetY((GuiButton) this.resetButton, y); + #else + SetY(this.resetButton, y); + #endif #if MC_VER <= MC_1_12_2 ((GuiButton) this.resetButton).drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta); @@ -389,7 +432,12 @@ public class ClassicConfigGUI if (this.indexButton != null) { - SetY(#if MC_VER <= MC_1_12_2 (GuiButton) #endif this.indexButton, y); + #if MC_VER <= MC_1_12_2 + SetY((GuiButton) this.indexButton, y); + #else + SetY(this.indexButton, y); + #endif + #if MC_VER <= MC_1_12_2 ((GuiButton) this.indexButton).drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta); #elif MC_VER <= MC_1_21_11 @@ -439,17 +487,20 @@ public class ClassicConfigGUI } #if MC_VER <= MC_1_12_2 - textRenderer.drawString(this.text.getFormattedText(), textXPos, y + 5,0xFFFFFF); + textRenderer.drawString( + this.text.getFormattedText(), + textXPos, y + 5, + 0xFFFFFF); #elif MC_VER < MC_1_20_1 GuiComponent.drawString(matrices, textRenderer, - this.text, - textXPos, y + 5, - 0xFFFFFF); + this.text, + textXPos, y + 5, + 0xFFFFFF); #elif MC_VER < MC_1_21_6 - matrices.drawString(textRenderer, - this.text, - textXPos, y + 5, - 0xFFFFFF); + matrices.drawString(textRenderer, + this.text, + textXPos, y + 5, + 0xFFFFFF); #elif MC_VER <= MC_1_21_11 matrices.drawString(textRenderer, this.text, @@ -500,11 +551,14 @@ public class ClassicConfigGUI } + //endregion + //================// // event handling // //================// + //region public static class ConfigCoreInterface implements IConfigGui { @@ -523,4 +577,5 @@ public class ClassicConfigGUI } + //endregion } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java index 808d1733c..7c2bc6867 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java @@ -95,21 +95,34 @@ class DhConfigScreen extends DhScreen private static final MinecraftClientWrapper MC_CLIENT = MinecraftClientWrapper.INSTANCE; + #if MC_VER <= MC_1_12_2 + private final GuiScreen parent; + #else + private final Screen parent; + #endif - private final #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent; private final String category; private ClassicConfigGUI.ConfigListWidget configListWidget; private boolean reload = false; - private #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif doneButton; + #if MC_VER <= MC_1_12_2 + private GuiButton doneButton; + #else + private Button doneButton; + #endif //=============// // constructor // //=============// + //region - protected DhConfigScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, String category) + #if MC_VER <= MC_1_12_2 + protected DhConfigScreen(GuiScreen parent, String category) + #else + protected DhConfigScreen(Screen parent, String category) + #endif { super(Translatable( LANG_WRAPPER.langExists(ModInfo.ID + ".config" + (category.isEmpty() ? "." + category : "") + ".title") ? @@ -120,27 +133,35 @@ class DhConfigScreen extends DhScreen this.category = category; } + //endregion - #if MC_VER <= MC_1_12_2 + + + //===================// + // menu UI lifecycle // + //===================// + //region + @Override + #if MC_VER <= MC_1_12_2 public void updateScreen() { super.updateScreen(); } #else - @Override public void tick() { super.tick(); } #endif + + //endregion + + - - - //==================// // menu UI creation // //==================// + //region - #if MC_VER <= MC_1_12_2 @Override + #if MC_VER <= MC_1_12_2 public void initGui() #else - @Override protected void init() #endif { @@ -225,16 +246,21 @@ class DhConfigScreen extends DhScreen #endif })); - this.configListWidget = new ClassicConfigGUI.ConfigListWidget(#if MC_VER <= MC_1_12_2 this.mc #else this.minecraft #endif, this.width * 2, this.height, 32, 32, 25); + #if MC_VER <= MC_1_12_2 + this.configListWidget = new ClassicConfigGUI.ConfigListWidget(this.mc, this.width * 2, this.height, 32, 32, 25); + #else + this.configListWidget = new ClassicConfigGUI.ConfigListWidget(this.minecraft, this.width * 2, this.height, 32, 32, 25); + #endif - #if MC_VER > MC_1_12_2 - #if MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+ + #if MC_VER <= MC_1_12_2 + #elif MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+ if (this.minecraft != null && this.minecraft.level != null) { this.configListWidget.setRenderBackground(false); } #endif + #if MC_VER > MC_1_12_2 this.addWidget(this.configListWidget); #endif @@ -407,40 +433,47 @@ class DhConfigScreen extends DhScreen final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) booleanConfigEntry.guiValue); - #if MC_VER <= MC_1_12_2 configGuiInfo.buttonOptionMap = + #if MC_VER <= MC_1_12_2 new AbstractMap.SimpleEntry>( - (button) -> - { - button.enabled = !booleanConfigEntry.apiIsOverriding(); - - booleanConfigEntry.uiSetWithoutSaving(!booleanConfigEntry.get()); - button.displayString = func.apply(booleanConfigEntry.get()).getFormattedText(); - }, func); - #else - configGuiInfo.buttonOptionMap = + #else new AbstractMap.SimpleEntry>( + #endif (button) -> { + #if MC_VER <= MC_1_12_2 + button.enabled = !booleanConfigEntry.apiIsOverriding(); + #else button.active = !booleanConfigEntry.apiIsOverriding(); - + #endif + booleanConfigEntry.uiSetWithoutSaving(!booleanConfigEntry.get()); + + #if MC_VER <= MC_1_12_2 + button.displayString = func.apply(booleanConfigEntry.get()).getFormattedText(); + #else button.setMessage(func.apply(booleanConfigEntry.get())); + #endif }, func); - #endif } private static void setupEnumMenuOption(ConfigEntry> enumConfigEntry, Class> enumClass) { List> enumList = Arrays.asList(enumClass.getEnumConstants()); final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) enumConfigEntry.guiValue); + #if MC_VER <= MC_1_12_2 Function getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString()); #else Function getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString()); #endif + configGuiInfo.buttonOptionMap = - new AbstractMap.SimpleEntry<#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif, Function>( + #if MC_VER <= MC_1_12_2 + new AbstractMap.SimpleEntry>( + #else + new AbstractMap.SimpleEntry>( + #endif (button) -> { // get the currently selected enum and enum index @@ -525,6 +558,7 @@ class DhConfigScreen extends DhScreen //==============// // reset button // //==============// + //region #if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif btnAction = (button) -> { @@ -567,13 +601,20 @@ class DhConfigScreen extends DhScreen resetButton.#if MC_VER <= MC_1_12_2 enabled #else active #endif = true; } - + //endregion + + //==============// // option field // //==============// + //region - #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configEntry); + #if MC_VER <= MC_1_12_2 + ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configEntry); + #else + Component textComponent = this.GetTranslatableTextComponentForConfig(configEntry); + #endif int optionFieldPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN @@ -590,20 +631,28 @@ class DhConfigScreen extends DhScreen #else Map.Entry> widget = configGuiInfo.buttonOptionMap; #endif + if (configEntry.getType().isEnum()) { widget.setValue((value) -> Translatable(TRANSLATION_PREFIX + "enum." + configEntry.getType().getSimpleName() + "." + configEntry.get().toString())); } - #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif button = MakeBtn( + #if MC_VER <= MC_1_12_2 + GuiButton button = MakeBtn( + #else + Button button = MakeBtn( + #endif widget.getValue().apply(configEntry.get()), optionFieldPosX, optionFieldPosZ, ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, widget.getKey()); // deactivate the button if the API is overriding it - button.#if MC_VER <= MC_1_12_2 enabled #else active #endif = !configEntry.apiIsOverriding(); - + #if MC_VER <= MC_1_12_2 + button.enabled = !configEntry.apiIsOverriding(); + #else + button.active = !configEntry.apiIsOverriding(); + #endif this.configListWidget.addButton(this, configEntry, button, @@ -616,15 +665,20 @@ class DhConfigScreen extends DhScreen else { // text box input - - #if MC_VER <= MC_1_12_2 GuiTextField #else EditBox #endif widget = new #if MC_VER <= MC_1_12_2 GuiTextField #else EditBox #endif( - #if MC_VER <= MC_1_12_2 0, #endif - #if MC_VER <= MC_1_12_2 this.fontRenderer #else this.font #endif, + #if MC_VER <= MC_1_12_2 + GuiTextField widget = new GuiTextField(0, this.fontRenderer, optionFieldPosX, optionFieldPosZ, - ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT - #if MC_VER > MC_1_12_2 ,Translatable("") #endif); - widget.#if MC_VER <= MC_1_12_2 setMaxStringLength(3_000_000); #else setMaxLength(3_000_000); #endif // hopefully 3 million characters should be enough for any normal use-case, lol - widget.#if MC_VER <= MC_1_12_2 setText #else insertText #endif (String.valueOf(configEntry.get())); + ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT); + widget.setMaxStringLength(3_000_000); // hopefully 3 million characters should be enough for any normal use-case, lol + widget.setText(String.valueOf(configEntry.get())); + #else + EditBox widget = new EditBox(this.font, + optionFieldPosX, optionFieldPosZ, + ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, + Translatable("")); + widget.setMaxLength(3_000_000); // hopefully 3 million characters should be enough for any normal use-case, lol + widget.insertText(String.valueOf(configEntry.get())); + #endif Predicate processor = configGuiInfo.tooltipFunction.apply(widget, this.doneButton); #if MC_VER <= MC_1_12_2 @@ -639,6 +693,8 @@ class DhConfigScreen extends DhScreen return true; } + + //endregion } return false; @@ -649,12 +705,21 @@ class DhConfigScreen extends DhScreen { ConfigCategory configCategory = (ConfigCategory) configType; - #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configCategory); + #if MC_VER <= MC_1_12_2 + ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configCategory); + #else + Component textComponent = this.GetTranslatableTextComponentForConfig(configCategory); + #endif int categoryPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN; int categoryPosZ = this.height - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT; // Note: the posZ value here seems to be ignored - #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif widget = MakeBtn(textComponent, + #if MC_VER <= MC_1_12_2 + GuiButton widget = MakeBtn( + #else + Button widget = MakeBtn( + #endif + textComponent, categoryPosX, categoryPosZ, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, ((button) -> @@ -679,11 +744,20 @@ class DhConfigScreen extends DhScreen { ConfigUIButton configUiButton = (ConfigUIButton) configType; - #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configUiButton); + #if MC_VER <= MC_1_12_2 + ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configUiButton); + #else + Component textComponent = this.GetTranslatableTextComponentForConfig(configUiButton); + #endif int buttonPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN; - #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif widget = MakeBtn(textComponent, + #if MC_VER <= MC_1_12_2 + GuiButton widget = MakeBtn( + #else + Button widget = MakeBtn( + #endif + textComponent, buttonPosX, this.height - 28, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, (button) -> ((ConfigUIButton) configType).runAction()); @@ -700,7 +774,11 @@ class DhConfigScreen extends DhScreen { ConfigUIComment configUiComment = (ConfigUIComment) configType; - #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configUiComment); + #if MC_VER <= MC_1_12_2 + ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configUiComment); + #else + Component textComponent = this.GetTranslatableTextComponentForConfig(configUiComment); + #endif if (configUiComment.parentConfigPath != null) { textComponent = Translatable(TRANSLATION_PREFIX + configUiComment.parentConfigPath); @@ -716,8 +794,13 @@ class DhConfigScreen extends DhScreen private boolean tryCreateSpacer(AbstractConfigBase configType) { if (configType instanceof ConfigUISpacer) - { - #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif spacerButton = MakeBtn(Translatable("distanthorizons.general.spacer"), + { + #if MC_VER <= MC_1_12_2 + GuiButton spacerButton = MakeBtn( + #else + Button spacerButton = MakeBtn( + #endif + Translatable("distanthorizons.general.spacer"), 10, 10, // having too small of a size causes division by 0 errors in older MC versions (IE 1.20.1) 1, 1, (button) -> { }); @@ -742,14 +825,21 @@ class DhConfigScreen extends DhScreen return false; } - private #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif GetTranslatableTextComponentForConfig(AbstractConfigBase configType) + #if MC_VER <= MC_1_12_2 + private ITextComponent GetTranslatableTextComponentForConfig(AbstractConfigBase configType) + #else + private Component GetTranslatableTextComponentForConfig(AbstractConfigBase configType) + #endif { return Translatable(TRANSLATION_PREFIX + configType.getNameAndCategory()); } + //endregion + //===========// // rendering // //===========// + //region @Override #if MC_VER <= MC_1_12_2 @@ -823,10 +913,11 @@ class DhConfigScreen extends DhScreen #endif); } - this.renderTooltip( - #if MC_VER > MC_1_12_2 matrices, - #endif - mouseX, mouseY, delta); + #if MC_VER <= MC_1_12_2 + this.renderTooltip(mouseX, mouseY, delta); + #else + this.renderTooltip(matrices, mouseX, mouseY, delta); + #endif #if MC_VER <= MC_1_12_2 super.drawScreen(mouseX, mouseY, delta); @@ -841,11 +932,15 @@ class DhConfigScreen extends DhScreen private void renderTooltip(PoseStack matrices, int mouseX, int mouseY, float delta) #elif MC_VER <= MC_1_21_11 private void renderTooltip(GuiGraphics matrices, int mouseX, int mouseY, float delta) -#else + #else private void renderTooltip(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta) #endif { - #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY); + #if MC_VER <= MC_1_12_2 + Gui hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY); + #else + AbstractWidget hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY); + #endif if (hoveredWidget == null) { return; @@ -877,27 +972,32 @@ class DhConfigScreen extends DhScreen final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) configBase.guiValue); if (configGuiInfo.errorMessage != null) { - this.DhRenderTooltip( - #if MC_VER > MC_1_12_2 - matrices, this.font, - #endif - configGuiInfo.errorMessage, mouseX, mouseY); + #if MC_VER <= MC_1_12_2 + this.DhRenderTooltip(configGuiInfo.errorMessage, mouseX, mouseY); + #else + this.DhRenderTooltip(matrices, this.font, configGuiInfo.errorMessage, mouseX, mouseY); + #endif } // display the tooltip if present else if (LANG_WRAPPER.langExists(key)) { - List<#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif> list = new ArrayList<>(); + #if MC_VER <= MC_1_12_2 + List list = new ArrayList<>(); + #else + List list = new ArrayList<>(); + #endif + String lang = LANG_WRAPPER.getLang(key); for (String langLine : lang.split("\n")) { list.add(TextOrTranslatable(langLine)); } - this.DhRenderComponentTooltip( - #if MC_VER > MC_1_12_2 - matrices, this.font, - #endif - list, mouseX, mouseY); + #if MC_VER <= MC_1_12_2 + this.DhRenderComponentTooltip(list, mouseX, mouseY); + #else + this.DhRenderComponentTooltip(matrices, this.font, list, mouseX, mouseY); + #endif } } @@ -959,11 +1059,14 @@ class DhConfigScreen extends DhScreen } #endif + //endregion + + //==========// // shutdown // //==========// - + //region /** When you close it, it goes to the previous screen and saves */ @Override #if MC_VER <= MC_1_12_2 @@ -979,5 +1082,6 @@ class DhConfigScreen extends DhScreen ClassicConfigGUI.CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run()); } + //endregion } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/config/ConfigGuiInfo.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/config/ConfigGuiInfo.java index 3638da5ed..131f2f548 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/config/ConfigGuiInfo.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/config/ConfigGuiInfo.java @@ -32,10 +32,23 @@ public class ConfigGuiInfo implements IConfigGuiInfo */ @Nullable - public #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif errorMessage; + #if MC_VER <= MC_1_12_2 + public ITextComponent errorMessage; + #else + public Component errorMessage; + #endif + + #if MC_VER <= MC_1_12_2 + public BiFunction> tooltipFunction; + #else + public BiFunction> tooltipFunction; + #endif - public BiFunction<#if MC_VER <= MC_1_12_2 GuiTextField #else EditBox #endif,#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif, Predicate> tooltipFunction; /** determines which options the button will show */ - public AbstractMap.SimpleEntry<#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif, Function> buttonOptionMap; + #if MC_VER <= MC_1_12_2 + public AbstractMap.SimpleEntry> buttonOptionMap; + #else + public AbstractMap.SimpleEntry> buttonOptionMap; + #endif } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/KeyedClientLevelManager.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/KeyedClientLevelManager.java index 5d0db94c6..25b076a8a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/KeyedClientLevelManager.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/KeyedClientLevelManager.java @@ -26,14 +26,18 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager //=============// // constructor // //=============// + //region private KeyedClientLevelManager() { } + //endregion + //======================// // level override logic // //======================// + //region @Override @Nullable @@ -61,5 +65,8 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager @Override public void disable() { this.enabled = false; } + //endregion + + } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/ServerKeyedClientLevelWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/ServerKeyedClientLevelWrapper.java index c9bf063e0..147191346 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/ServerKeyedClientLevelWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/level/ServerKeyedClientLevelWrapper.java @@ -21,6 +21,7 @@ public class ServerKeyedClientLevelWrapper extends ClientLevelWrapper implements //=============// // constructor // //=============// + //region #if MC_VER <= MC_1_12_2 public ServerKeyedClientLevelWrapper(WorldClient level, String serverKey, String serverLevelKey) @@ -33,13 +34,17 @@ public class ServerKeyedClientLevelWrapper extends ClientLevelWrapper implements this.serverLevelKey = serverLevelKey; } + //endregion + - @Override - public String getServerKey() { return this.serverKey; } //======================// // level identification // //======================// + //region + + @Override + public String getServerKey() { return this.serverKey; } @Override public String getServerLevelKey() { return this.serverLevelKey; } @@ -47,6 +52,8 @@ public class ServerKeyedClientLevelWrapper extends ClientLevelWrapper implements @Override public String getDhIdentifier() { return this.getServerLevelKey(); } + //endregion + } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java index a73b75428..ddffdd7a6 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java @@ -156,17 +156,46 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra } else { - ServerData server = MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif; - return (server != null) ? server.#if MC_VER <= MC_1_12_2 serverIP #else ip #endif : "NA"; + ServerData server = getCurrentServerData(); + return getServerIp(server); } } @Override public String getCurrentServerVersion() { - ServerData server = MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif; - return (server != null) ? server.#if MC_VER <= MC_1_12_2 gameVersion #else version.getString() #endif : "UNKOWN"; + ServerData server = getCurrentServerData(); + return getServerVersion(server); } + private ServerData getCurrentServerData() + { + #if MC_VER <= MC_1_12_2 + return MINECRAFT.getCurrentServerData(); + #else + return MINECRAFT.getCurrentServer(); + #endif + } + private String getServerIp(ServerData server) + { + if (server == null) { return "NA"; } + + #if MC_VER <= MC_1_12_2 + return server.serverIP; + #else + return server.ip; + #endif + } + private String getServerVersion(ServerData server) + { + if (server == null) { return "UNKOWN"; } + + #if MC_VER <= MC_1_12_2 + return server.gameVersion; + #else + return server.version.getString(); + #endif + } + //endregion @@ -176,7 +205,11 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra //=================// //region - public #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif getPlayer() { return MINECRAFT.player; } + #if MC_VER <= MC_1_12_2 + public EntityPlayerSP getPlayer() { return MINECRAFT.player; } + #else + public LocalPlayer getPlayer() { return MINECRAFT.player; } + #endif @Override public boolean playerExists() { return MINECRAFT.player != null; } @@ -184,20 +217,32 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra @Override public DhBlockPos getPlayerBlockPos() { - #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer(); + #if MC_VER <= MC_1_12_2 + EntityPlayerSP player = this.getPlayer(); + #else + LocalPlayer player = this.getPlayer(); + #endif if (player == null) { return new DhBlockPos(0, 0, 0); } - BlockPos playerPos = player.#if MC_VER <= MC_1_12_2 getPosition() #else blockPosition() #endif; + #if MC_VER <= MC_1_12_2 + BlockPos playerPos = player.getPosition(); + #else + BlockPos playerPos = player.blockPosition(); + #endif return new DhBlockPos(playerPos.getX(), playerPos.getY(), playerPos.getZ()); } @Override public DhChunkPos getPlayerChunkPos() { - #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer(); + #if MC_VER <= MC_1_12_2 + EntityPlayerSP player = this.getPlayer(); + #else + LocalPlayer player = this.getPlayer(); + #endif if (player == null) { return new DhChunkPos(0, 0); @@ -235,7 +280,11 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra @Nullable public IClientLevelWrapper getWrappedClientLevel(boolean bypassLevelKeyManager) { - #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level = MINECRAFT.#if MC_VER <= MC_1_12_2 world #else level #endif; + #if MC_VER <= MC_1_12_2 + WorldClient level = MINECRAFT.world; + #else + ClientLevel level = MINECRAFT.level; + #endif if (level == null) { return null; @@ -256,7 +305,11 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra @Override public void sendChatMessage(String string) { - #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer(); + #if MC_VER <= MC_1_12_2 + EntityPlayerSP player = this.getPlayer(); + #else + LocalPlayer player = this.getPlayer(); + #endif if (player == null) { return; @@ -284,7 +337,11 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra @Override public void sendOverlayMessage(String string) { - #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer(); + #if MC_VER <= MC_1_12_2 + EntityPlayerSP player = this.getPlayer(); + #else + LocalPlayer player = this.getPlayer(); + #endif if (player == null) { return; @@ -395,7 +452,12 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra @Override public IProfilerWrapper getProfiler() { - #if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif profiler; + #if MC_VER <= MC_1_12_2 + Profiler profiler; + #else + ProfilerFiller profiler; + #endif + #if MC_VER <= MC_1_12_2 profiler = MINECRAFT.profiler; #elif MC_VER < MC_1_21_3 @@ -438,7 +500,14 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra } @Override - public void executeOnRenderThread(Runnable runnable) { MINECRAFT.#if MC_VER <= MC_1_12_2 addScheduledTask #else execute #endif(runnable); } + public void executeOnRenderThread(Runnable runnable) + { + #if MC_VER <= MC_1_12_2 + MINECRAFT.addScheduledTask(runnable); + #else + MINECRAFT.execute(runnable); + #endif + } @Override public void showDialog(String title, String message, String dialogType, String iconType) @@ -454,7 +523,14 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra //region @Override - public Object getOptionsObject() { return MINECRAFT.#if MC_VER <= MC_1_12_2 gameSettings #else options #endif; } + public Object getOptionsObject() + { + #if MC_VER <= MC_1_12_2 + return MINECRAFT.gameSettings; + #else + return MINECRAFT.options; + #endif + } //endregion @@ -469,13 +545,24 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra public boolean isDedicatedServer() { return false; } @Override - public File getInstallationDirectory() { return MINECRAFT.#if MC_VER <= MC_1_12_2 gameDir #else gameDirectory #endif; } + public File getInstallationDirectory() + { + #if MC_VER <= MC_1_12_2 + return MINECRAFT.gameDir; + #else + return MINECRAFT.gameDirectory; + #endif + } @Override public int getPlayerCount() { // can be null if the server hasn't finished booting up yet - if (MINECRAFT.#if MC_VER <= MC_1_12_2 getIntegratedServer() #else getSingleplayerServer() #endif == null) + #if MC_VER <= MC_1_12_2 + if (MINECRAFT.getIntegratedServer() == null) + #else + if (MINECRAFT.getSingleplayerServer() == null) + #endif { return 1; } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java index a62c37223..fb3c295b9 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java @@ -173,7 +173,11 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper { return false; } - else if (MC.player.#if MC_VER <= MC_1_12_2 getActivePotionMap() #else getActiveEffectsMap() #endif == null) + #if MC_VER <= MC_1_12_2 + else if (MC.player.getActivePotionMap() == null) + #else + else if (MC.player.getActiveEffectsMap() == null) + #endif { return false; } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/ProfilerWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/ProfilerWrapper.java index 89eab7f41..4d29a7f76 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/ProfilerWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/ProfilerWrapper.java @@ -29,21 +29,38 @@ import net.minecraft.util.profiling.ProfilerFiller; public class ProfilerWrapper implements IProfilerWrapper { - public #if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif profiler; + #if MC_VER <= MC_1_12_2 + public Profiler profiler; + #else + public ProfilerFiller profiler; + #endif - public ProfilerWrapper(#if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif newProfiler) { this.profiler = newProfiler; } + #if MC_VER <= MC_1_12_2 + public ProfilerWrapper(Profiler newProfiler) + #else + public ProfilerWrapper(ProfilerFiller newProfiler) + #endif + { this.profiler = newProfiler; } @Override public IProfileBlock push(String newSection) { - this.profiler.#if MC_VER <= MC_1_12_2 startSection(newSection) #else push(newSection) #endif; + #if MC_VER <= MC_1_12_2 + this.profiler.startSection(newSection); + #else + this.profiler.push(newSection); + #endif return new ProfileBlock(this.profiler); } @Override public void popPush(String newSection) { - this.profiler.#if MC_VER <= MC_1_12_2 endStartSection(newSection) #else popPush(newSection) #endif; + #if MC_VER <= MC_1_12_2 + this.profiler.endStartSection(newSection); + #else + this.profiler.popPush(newSection) ; + #endif } @@ -55,14 +72,27 @@ public class ProfilerWrapper implements IProfilerWrapper public static class ProfileBlock implements IProfileBlock { - public #if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif profiler; - public ProfileBlock(#if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif newProfiler) { this.profiler = newProfiler; } - + #if MC_VER <= MC_1_12_2 + public Profiler profiler; + #else + public ProfilerFiller profiler; + #endif + + #if MC_VER <= MC_1_12_2 + public ProfileBlock(Profiler newProfiler) + #else + public ProfileBlock(ProfilerFiller newProfiler) + #endif + { this.profiler = newProfiler; } @Override public void close() { - this.profiler.#if MC_VER <= MC_1_12_2 endSection() #else pop() #endif; + #if MC_VER <= MC_1_12_2 + this.profiler.endSection(); + #else + this.profiler.pop(); + #endif } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/IMixinServerPlayer.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/IMixinServerPlayer.java index 88b574c7c..fc80b31e8 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/IMixinServerPlayer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/IMixinServerPlayer.java @@ -11,7 +11,11 @@ import org.jetbrains.annotations.Nullable; public interface IMixinServerPlayer { @Nullable - #if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif distantHorizons$getDimensionChangeDestination(); + #if MC_VER <= MC_1_12_2 + WorldServer distantHorizons$getDimensionChangeDestination(); + #else + ServerLevel distantHorizons$getDimensionChangeDestination(); + #endif #if MC_VER == MC_1_16_5 void distantHorizons$setDimensionChangeDestination(ServerLevel dimensionChangeDestination); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/MutableBlockPosWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/MutableBlockPosWrapper.java index acd0276cd..a1b3f93b9 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/MutableBlockPosWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/MutableBlockPosWrapper.java @@ -16,19 +16,27 @@ public class MutableBlockPosWrapper implements IMutableBlockPosWrapper //=============// // constructor // //=============// + //region public MutableBlockPosWrapper() { this.pos = new BlockPos.MutableBlockPos(); } + //endregion + //===========// // overrides // //===========// + //region @Override public Object getWrappedMcObject() { return this.pos; } + //endregion + + + } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/ServerPlayerWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/ServerPlayerWrapper.java index 7fc168557..dd9665aaf 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/ServerPlayerWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/ServerPlayerWrapper.java @@ -36,31 +36,64 @@ import java.util.concurrent.ConcurrentMap; #endif public class ServerPlayerWrapper implements IServerPlayerWrapper { - private static final ConcurrentMap<#if MC_VER <= MC_1_12_2 NetHandlerPlayServer #else ServerGamePacketListenerImpl #endif , ServerPlayerWrapper> serverPlayerWrapperMap = new MapMaker().weakKeys().weakValues().makeMap(); + #if MC_VER <= MC_1_12_2 + private static final ConcurrentMap serverPlayerWrapperMap = new MapMaker().weakKeys().weakValues().makeMap(); + #else + private static final ConcurrentMap serverPlayerWrapperMap = new MapMaker().weakKeys().weakValues().makeMap(); + #endif - private final #if MC_VER <= MC_1_12_2 NetHandlerPlayServer #else ServerGamePacketListenerImpl #endif connection; + #if MC_VER <= MC_1_12_2 + private final NetHandlerPlayServer connection; + #else + private final ServerGamePacketListenerImpl connection; + #endif //=============// // constructor // //=============// + //region - public static ServerPlayerWrapper getWrapper(#if MC_VER <= MC_1_12_2 EntityPlayerMP #else ServerPlayer #endif serverPlayer) + #if MC_VER <= MC_1_12_2 + public static ServerPlayerWrapper getWrapper(EntityPlayerMP serverPlayer) + #else + public static ServerPlayerWrapper getWrapper(ServerPlayer serverPlayer) + #endif { return serverPlayerWrapperMap.computeIfAbsent(serverPlayer.connection, ignored -> new ServerPlayerWrapper(serverPlayer.connection)); } - private ServerPlayerWrapper(#if MC_VER <= MC_1_12_2 NetHandlerPlayServer #else ServerGamePacketListenerImpl #endif connection) { this.connection = connection; } + #if MC_VER <= MC_1_12_2 + private ServerPlayerWrapper(NetHandlerPlayServer connection) + #else + private ServerPlayerWrapper(ServerGamePacketListenerImpl connection) + #endif + { this.connection = connection; } + + //endregion //=========// // getters // //=========// + //region - private #if MC_VER <= MC_1_12_2 EntityPlayerMP #else ServerPlayer #endif getServerPlayer() { return this.connection.player; } + #if MC_VER <= MC_1_12_2 + private EntityPlayerMP getServerPlayer() + #else + private ServerPlayer getServerPlayer() + #endif + { return this.connection.player; } @Override - public String getName() { return this.getServerPlayer().getName()#if MC_VER > MC_1_12_2 .getString() #endif ; } + public String getName() + { + #if MC_VER <= MC_1_12_2 + return this.getServerPlayer().getName(); + #else + return this.getServerPlayer().getName().getString(); + #endif + } @Override public IServerLevelWrapper getLevel() @@ -103,11 +136,14 @@ public class ServerPlayerWrapper implements IServerPlayerWrapper #endif } + //endregion + //================// // base overrides // //================// + //region @Override public Object getWrappedMcObject() { return this.getServerPlayer(); } @@ -133,4 +169,8 @@ public class ServerPlayerWrapper implements IServerPlayerWrapper @Override public int hashCode() { return Objects.hashCode(this.connection); } + //endregion + + + } From 817c26849155d3e539184c5967c46d4e85dd9366 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 14 May 2026 07:11:44 -0500 Subject: [PATCH 67/68] Tint color cleanup --- .../block/ClientBlockStateColorCache.java | 28 +++++++------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java index 78b7fa942..f83856c39 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/ClientBlockStateColorCache.java @@ -696,9 +696,7 @@ public class ClientBlockStateColorCache if (!BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState)) { try - { - - + { TintWithoutLevelOverrider tintOverride = TintWithoutLevelOverrideGetter.get(); tintOverride.update(biomeWrapper, this.blockStateWrapper, fullDataSource, this.clientLevelWrapper); @@ -708,14 +706,14 @@ public class ClientBlockStateColorCache { // one or more tint values weren't calculated, // we need MC's color resolver - #if MC_VER <= MC_1_21_11 - tintColor = Minecraft.getInstance() + #if MC_VER <= MC_1_21_11 + tintColor = Minecraft.getInstance() .getBlockColors() .getColor(this.blockState, tintOverride, // tintOverride will save the result of this query to speed up future queries McObjectConverter.Convert(blockPos), this.tintIndex); - #else + #else BlockTintSource tintSource = Minecraft.getInstance() .getBlockColors() .getTintSource(this.blockState, this.tintIndex); @@ -732,12 +730,6 @@ public class ClientBlockStateColorCache } } - if (tintColor == ClientBlockStateColorCache.INVALID_COLOR) - { - // no color found, use the base color - tintColor = ClientBlockStateColorCache.INVALID_COLOR; - } - // save this color to speed up future queries TintWithoutLevelOverrider.setStaticColor(this.blockStateWrapper, biomeWrapper, tintColor); // try to get the blended color with this new information @@ -747,18 +739,18 @@ public class ClientBlockStateColorCache } catch (Exception e) { - #if MC_VER <= MC_1_21_11 - // this exception generally occurs if the tint requires other blocks besides itself - LOGGER.debug("Unable to use ["+ TintWithoutLevelOverrider.class.getSimpleName()+"] to get the block tint for block: [" + this.blockState + "] and biome: [" + biomeWrapper + "] at pos: " + blockPos + ". Error: [" + e.getMessage() + "]. Attempting to use backup method...", e); - BLOCK_STATES_THAT_NEED_LEVEL.add(this.blockState); - #else + #if MC_VER <= MC_1_21_11 + // this exception generally occurs if the tint requires other blocks besides itself + LOGGER.debug("Unable to use ["+ TintWithoutLevelOverrider.class.getSimpleName()+"] to get the block tint for block: [" + this.blockState + "] and biome: [" + biomeWrapper + "] at pos: " + blockPos + ". Error: [" + e.getMessage() + "]. Attempting to use backup method...", e); + BLOCK_STATES_THAT_NEED_LEVEL.add(this.blockState); + #else // only display the error once per block/biome type to reduce log spam if (!BROKEN_BLOCK_STATES.contains(this.blockState)) { LOGGER.warn("Failed to get block color for block: [" + this.blockState + "] and biome: [" + biomeWrapper + "] at pos: " + blockPos + ". Error: [" + e.getMessage() + "]. Note: future errors for this block/biome will be ignored.", e); BROKEN_BLOCK_STATES.add(this.blockState); } - #endif + #endif } } #endif From 2884094dee331d4f553c570d04961acf0e8f38d7 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 14 May 2026 07:49:32 -0500 Subject: [PATCH 68/68] refactoring and cleanup --- .../common/wrappers/McObjectConverter.java | 4 +- .../gui/classicConfig/DhConfigScreen.java | 1 + .../minecraft/MinecraftClientWrapper.java | 13 ++++- .../minecraft/MinecraftRenderWrapper.java | 29 +++++----- .../wrappers/minecraft/ProfilerWrapper.java | 4 ++ .../wrappers/misc/ServerPlayerWrapper.java | 1 + .../wrappers/world/ClientLevelWrapper.java | 56 +++++++++++++++---- .../BatchGenerationEnvironment.java | 4 ++ 8 files changed, 82 insertions(+), 30 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java index b6e050174..aa08f77db 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java @@ -63,7 +63,7 @@ public class McObjectConverter FloatBuffer buffer = FloatBuffer.allocate(16); storeMatrix(mcMatrix, buffer); Mat4f matrix = new Mat4f(buffer); - #if MC_VER < MC_1_19_4 && MC_VER > MC_1_12_2 + #if MC_VER > MC_1_12_2 && MC_VER < MC_1_19_4 matrix.transpose(); // In 1.19.3 and later, we no longer need to transpose it #endif return matrix; @@ -109,7 +109,9 @@ public class McObjectConverter static { EDhDirection[] lodDirs = EDhDirection.values(); + directions = new #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif[lodDirs.length]; + lodDirections = new EDhDirection[lodDirs.length]; for (EDhDirection lodDir : lodDirs) { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java index 7c2bc6867..073b6b242 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java @@ -170,6 +170,7 @@ class DhConfigScreen extends DhScreen #else super.init(); #endif + if (!this.reload) { ConfigHandler.INSTANCE.configFileHandler.loadFromFile(); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java index ddffdd7a6..f1ada541e 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java @@ -143,8 +143,13 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra } else { - ServerData server = MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif; - return (server != null) ? server.#if MC_VER <= MC_1_12_2 serverName #else name #endif : "NULL"; + #if MC_VER <= MC_1_12_2 + ServerData server = MINECRAFT.getCurrentServerData(); + return (server != null) ? server.serverName : "NULL"; + #else + ServerData server = MINECRAFT.getCurrentServer(); + return (server != null) ? server.name : "NULL"; + #endif } } @Override @@ -382,11 +387,13 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra public void disableVanillaChunkFadeIn() { - LOGGER.info("Disabling vanilla chunk fade in... This is done to prevent vanilla chunks from flashing on the Distant Horizons boarder when moving (which is distracting)."); + String message = "Disabling vanilla chunk fade in... This is done to prevent vanilla chunks from flashing on the Distant Horizons boarder when moving (which is distracting)."; #if MC_VER <= MC_1_21_10 // chunk fade in was added MC 1.21.11 #else + LOGGER.info(message); + MINECRAFT.options.chunkSectionFadeInTime().set(0.0); #endif } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java index fb3c295b9..b3e34ef94 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java @@ -173,26 +173,27 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper { return false; } + #if MC_VER <= MC_1_12_2 - else if (MC.player.getActivePotionMap() == null) - #else - else if (MC.player.getActiveEffectsMap() == null) - #endif + if (MC.player.getActivePotionMap() == null) { return false; } - else + + return MC.player.getActivePotionEffect(MobEffects.BLINDNESS) != null; + #else + if (MC.player.getActiveEffectsMap() == null) { - #if MC_VER <= MC_1_12_2 - return MC.player.getActivePotionEffect(MobEffects.BLINDNESS) != null; - #else - return MC.player.getActiveEffectsMap().get(MobEffects.BLINDNESS) != null - #if MC_VER >= MC_1_19_2 - || MC.player.getActiveEffectsMap().get(MobEffects.DARKNESS) != null // Deep dark effect - #endif - ; - #endif + return false; } + + return MC.player.getActiveEffectsMap().get(MobEffects.BLINDNESS) != null + #if MC_VER >= MC_1_19_2 + || MC.player.getActiveEffectsMap().get(MobEffects.DARKNESS) != null // Deep dark effect + #endif + ; + #endif + } @Override diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/ProfilerWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/ProfilerWrapper.java index 4d29a7f76..89c4e4b4b 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/ProfilerWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/ProfilerWrapper.java @@ -35,6 +35,8 @@ public class ProfilerWrapper implements IProfilerWrapper public ProfilerFiller profiler; #endif + + #if MC_VER <= MC_1_12_2 public ProfilerWrapper(Profiler newProfiler) #else @@ -42,6 +44,8 @@ public class ProfilerWrapper implements IProfilerWrapper #endif { this.profiler = newProfiler; } + + @Override public IProfileBlock push(String newSection) { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/ServerPlayerWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/ServerPlayerWrapper.java index dd9665aaf..91b052577 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/ServerPlayerWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/misc/ServerPlayerWrapper.java @@ -107,6 +107,7 @@ public class ServerPlayerWrapper implements IServerPlayerWrapper #else ServerLevel level = ((IMixinServerPlayer) this.getServerPlayer()).distantHorizons$getDimensionChangeDestination(); #endif + if (level == null) { #if MC_VER <= MC_1_12_2 diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java index cdfaa5cc8..7da7629a5 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java @@ -6,6 +6,7 @@ import com.seibel.distanthorizons.common.wrappers.block.BiomeWrapper; import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper; import com.seibel.distanthorizons.common.wrappers.block.ClientBlockStateColorCache; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; +import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper; import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.level.*; @@ -76,17 +77,31 @@ public class ClientLevelWrapper implements IClientLevelWrapper * where, upon world closure, some levels aren't shutdown/removed properly * and/or for servers were the level object isn't consistent */ - private static final Map<#if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif, WeakReference> LEVEL_WRAPPER_REF_BY_CLIENT_LEVEL = Collections.synchronizedMap(new WeakHashMap<>()); + private static final Map< + #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif, + WeakReference> LEVEL_WRAPPER_REF_BY_CLIENT_LEVEL = Collections.synchronizedMap(new WeakHashMap<>()); private static final IKeyedClientLevelManager KEYED_CLIENT_LEVEL_MANAGER = SingletonInjector.INSTANCE.get(IKeyedClientLevelManager.class); - private static final Minecraft MINECRAFT = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif; + #if MC_VER <= MC_1_12_2 + private static final Minecraft MINECRAFT = Minecraft.getMinecraft(); + #else + private static final Minecraft MINECRAFT = Minecraft.getInstance(); + #endif + + #if MC_VER <= MC_1_12_2 + private final WorldClient level; + private final ConcurrentHashMap blockColorCacheByBlockState = new ConcurrentHashMap<>(); + #else + private final ClientLevel level; + private final ConcurrentHashMap blockColorCacheByBlockState = new ConcurrentHashMap<>(); + #endif - private final #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level; - private final ConcurrentHashMap<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, ClientBlockStateColorCache> blockColorCacheByBlockState = new ConcurrentHashMap<>(); /** cached method reference to reduce GC overhead */ - private final Function<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, ClientBlockStateColorCache> createCachedBlockColorCacheFunc - = (blockState) -> new ClientBlockStateColorCache(blockState, this); + private final Function< + #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, + ClientBlockStateColorCache> createCachedBlockColorCacheFunc + = (blockState) -> new ClientBlockStateColorCache(blockState, this); private boolean cloudColorFailLogged = false; @@ -117,7 +132,9 @@ public class ClientLevelWrapper implements IClientLevelWrapper * IE rendering. */ @Nullable - public static IClientLevelWrapper getWrapperIfDifferent(@Nullable IClientLevelWrapper levelWrapper, @NotNull #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level) + public static IClientLevelWrapper getWrapperIfDifferent( + @Nullable IClientLevelWrapper levelWrapper, + @NotNull #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level) { if (KEYED_CLIENT_LEVEL_MANAGER.isEnabled() && KEYED_CLIENT_LEVEL_MANAGER.getServerKeyedLevel() != levelWrapper) { @@ -135,10 +152,13 @@ public class ClientLevelWrapper implements IClientLevelWrapper } @Nullable - public static IClientLevelWrapper getWrapper(@NotNull #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level) { return getWrapper(level, false); } + public static IClientLevelWrapper getWrapper( + @NotNull #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level) + { return getWrapper(level, false); } @Nullable - public static IClientLevelWrapper getWrapper(@Nullable #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level, boolean bypassLevelKeyManager) + public static IClientLevelWrapper getWrapper( + @Nullable #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level, boolean bypassLevelKeyManager) { if (!bypassLevelKeyManager) { @@ -197,7 +217,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper #if MC_VER <= MC_1_12_2 WorldServer[] serverLevels = MINECRAFT.getIntegratedServer().worlds; #else - Iterable<#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif> serverLevels = MINECRAFT.getSingleplayerServer().getAllLevels(); + Iterable serverLevels = MINECRAFT.getSingleplayerServer().getAllLevels(); #endif // attempt to find the server level with the same dimension type @@ -457,10 +477,20 @@ public class ClientLevelWrapper implements IClientLevelWrapper public Color getCloudColor(float tickDelta) { #if MC_VER < MC_1_21_3 - #if MC_VER <= MC_1_12_2 Vec3d #else Vec3 #endif colorVec3 = null; + + #if MC_VER <= MC_1_12_2 + Vec3d colorVec3 = null; + #else + Vec3 colorVec3 = null; + #endif try { - colorVec3 = this.level.#if MC_VER <= MC_1_12_2 getCloudColour #else getCloudColor #endif (tickDelta); + #if MC_VER <= MC_1_12_2 + colorVec3 = this.level.getCloudColour(tickDelta); + #else + colorVec3 = this.level.getCloudColor(tickDelta); + #endif + return new Color((float)colorVec3.x, (float)colorVec3.y, (float)colorVec3.z); } catch (Exception e) @@ -544,4 +574,6 @@ public class ClientLevelWrapper implements IClientLevelWrapper //endregion + + } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index ad3958f74..01b7d919e 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -198,6 +198,7 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm this.updateManager = WorldChunkUpdateManager.INSTANCE.getByLevelWrapper(this.dhServerLevel.getServerLevelWrapper()); this.globalParams = new GlobalWorldGenParams(dhServerLevel); this.internalServerGenerator = new InternalServerGenerator(this.globalParams, this.dhServerLevel); + #if MC_VER > MC_1_12_2 this.chunkFileReader = new ChunkFileReader(this.globalParams); @@ -327,8 +328,11 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm //================// // variable setup // //================// + #if MC_VER <= MC_1_12_2 + // MC 1.12 can only run world gen on the main thread this.internalServerGenerator.generateChunksViaInternalServer(genEvent); + #else int borderSize = MAX_WORLD_GEN_CHUNK_BORDER_NEEDED; // genEvent.size - 1 converts the even width size to an odd number for MC compatability