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] 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()